@param string $post_type
@param array  $args
@param null   $callback
@param array  $params

@return \WP_Query
356109
public static function displayItems ($post_type = 'any', array $args = array(), $callback = null, array $params = array())
    {
        $query = new \WP_Query(array_merge(array(
            'post_type' => $post_type
        ), $args));
        if ($query->have_posts()) {
            global $post;
            while ($query->have_posts()) {
                $query->the_post();
                if ($callback !== null)
                    call_user_func_array($callback, array_merge(array($post), $params));
            }
            wp_reset_postdata();
        }
        return $query;
    }
94506
public function registerScopeMetaBox($postType, $choises)
    {
        if (!is_string($postType)) {
            return WP_Error("Post type variable must be of the type string.");
        }

        if (!is_array($choises)) {
            return WP_Error("Choises variable must be of the type assoc array.");
        }

        if (!function_exists('acf_add_local_field_group')) {
            return WP_Error("Could not find required ACF function acf_add_local_field_group.");
        }

        acf_add_local_field_group(array(
            'key' => 'group_' . substr(md5($postType . '_scope'), 0, 13),
            'title' => __('Scope styling', 'modularity'),
            'fields' => array(
                array(
                    'key' => 'field_' . substr(md5($postType . '_scope'), 0, 13),
                    'label' => __('Select an apperance for this instance of module', 'modularity'),
                    'name' => 'module_css_scope',
                    'type' => 'select',
                    'instructions' => __('By selecting a scope for this class, they will appear in a different way than the standard layout.', 'modularity'),
                    'required' => 0,
                    'conditional_logic' => 0,
                    'wrapper' => array(
                        'width' => '',
                        'class' => '',
                        'id' => '',
                    ),
                    'choices' => $choises,
                    'default_value' => array(
                    ),
                    'allow_null' => 1,
                    'multiple' => 0,
                    'ui' => 0,
                    'ajax' => 0,
                    'return_format' => 'value',
                    'placeholder' => '',
                ),
            ),
            'location' => array(
                array(
                    array(
                        'param' => 'post_type',
                        'operator' => '==',
                        'value' => $postType,
                    ),
                ),
            ),
            'menu_order' => 0,
            'position' => 'side',
            'style' => 'default',
            'label_placement' => 'top',
            'instruction_placement' => 'label',
            'hide_on_screen' => '',
            'active' => 1,
            'description' => '',
        ));

        return true;
    }
1102246
function parseArgs() {
    var args = Array.prototype.slice.call(arguments);

    var ret = {
        query: args[0],
        params: [],
        options: {},
        callback: undefined,
        endCallback: undefined
    };

    args.shift();

    // If specified, params must be an array
    if (args[0] instanceof Array) {
        ret.params = args[0];
        args.shift();
    }

    // If specified, options must be a non-Function object
    if (! (args[0] instanceof Function)) {
        ret.options = args[0];
        args.shift();
    }

    ret.callback = args[0];
    ret.endCallback = args[1];

    if (ret.query === undefined || ret.callback === undefined) {
        throw new Error('query and callback are required');
    }

    return ret;
}
840350
public function mf_get_post_types( $args = array(), $output = 'object', $operator = 'and' ){
    global $wpdb;

    $post_types = get_post_types( $args, $output, $operator );

    foreach ( $post_types as $key => $type ) {
      if( $output == 'names' ) {
        if( $type == 'attachment' || $type == 'revision' || $type == 'nav_menu_item'   ) {
          unset($post_types[$key]);
        }
      } else if ($output == 'object' ) {
        unset($post_types['attachment']);
        unset($post_types['revision']);
        unset($post_types['nav_menu_item']);
      }
    }

    return $post_types;
  }
199884
public function maybe_callback( $query, $post_args ) {
		$cmb   = isset( $post_args['cmb_id'] ) ? $post_args['cmb_id'] : '';
		$group = isset( $post_args['group_id'] ) ? $post_args['group_id'] : '';
		$field = isset( $post_args['field_id'] ) ? $post_args['field_id'] : '';

		$cmb = cmb2_get_metabox( $cmb );
		if ( $cmb && $group ) {
			$group = $cmb->get_field( $group );
		}

		if ( $cmb && $field ) {
			$group = $group ? $group : null;
			$field = $cmb->get_field( $field, $group );
		}

		if ( $field && ( $cb = $field->maybe_callback( 'attached_posts_search_query_cb' ) ) ) {
			call_user_func( $cb, $query, $field, $this );
		}
	}
882669
public static function url( array $args = [], string $url = null ) {
		if ( is_null( $url ) ) {
			$url = $_SERVER['REQUEST_URI'];
		}

		return add_query_arg( $args, $url );
	}
1024306
protected function postsArgs() {
		global $wp_query, $wp_rewrite;

		// Setting up default values based on the current URL.
		$pagenum_link    = html_entity_decode( get_pagenum_link() );
		$this->url_parts = explode( '?', $pagenum_link );

		// Get total number of pages.
		$total = isset( $wp_query->max_num_pages ) ? $wp_query->max_num_pages : 1;

		// Get the current page.
		$current = get_query_var( 'paged' ) ? intval( get_query_var( 'paged' ) ) : 1;

		// Append the format placeholder to the base URL.
		$base = trailingslashit( $this->url_parts[0] ) . '%_%';

		// URL base depends on permalink settings.
		$format  = $wp_rewrite->using_index_permalinks() && ! strpos( $pagenum_link, 'index.php' ) ? 'index.php/' : '';
		$format .= $wp_rewrite->using_permalinks() ? user_trailingslashit( $wp_rewrite->pagination_base . '/%#%', 'paged' ) : '?paged=%#%';

		return [
			'base'    => $base,
			'format'  => $format,
			'total'   => $total,
			'current' => $current
		];
	}
680863
public function register_post_type() {

		if ( ! isset( $this->args['query_var'] ) || ( true === $this->args['query_var'] ) ) {
			$query_var = $this->post_type;
		} else {
			$query_var = $this->args['query_var'];
		}

		$existing = get_post_type_object( $this->post_type );
		$taxonomies = get_taxonomies( [
			'query_var' => $query_var,
		], 'objects' );

		if ( $query_var && count( $taxonomies ) ) {
			// https://core.trac.wordpress.org/ticket/35089
			foreach ( $taxonomies as $tax ) {
				if ( $tax->query_var === $query_var ) {
					trigger_error( esc_html( sprintf(
						/* translators: %s: Post type query variable name */
						__( 'Post type query var "%s" clashes with a taxonomy query var of the same name', 'extended-cpts' ),
						$query_var
					) ), E_USER_ERROR );
				}
			}
		}

		if ( empty( $existing ) ) {

			$cpt = register_post_type( $this->post_type, $this->args );

			if ( is_wp_error( $cpt ) ) {
				trigger_error( esc_html( $cpt->get_error_message() ), E_USER_ERROR );
			}
		} else {

			# This allows us to call `register_extended_post_type()` on an existing post type to add custom functionality
			# to the post type.
			$this->extend( $existing );

		}

	}
723216
function get_posts( $post_ids )
	{
		// validate
		if( empty($post_ids) )
		{
			return $post_ids;
		}
		
		
		// vars
		$r = array();
		
		
		// find posts (DISTINCT POSTS)
		$posts = get_posts(array(
			'numberposts'	=>	-1,
			'post__in'		=>	$post_ids,
			'post_type'		=>	apply_filters('acf/get_post_types', array()),
			'post_status'	=>	'any',
		));

		
		$ordered_posts = array();
		foreach( $posts as $p )
		{
			// create array to hold value data
			$ordered_posts[ $p->ID ] = $p;
		}
		
		
		// override value array with attachments
		foreach( $post_ids as $k => $v)
		{
			// check that post exists (my have been trashed)
			if( isset($ordered_posts[ $v ]) )
			{
				$r[] = $ordered_posts[ $v ];
			}
		}
		
		
		// return
		return $r;
	}
1274196
public static function preGetPosts( $callback, $priority = null, $accepted_args = null ) {
		self::action( 'pre_get_posts', $callback, $priority, $accepted_args );
	}
1055666
private function _get_args_from_params(array $params)
	{
		$byType	=	$this->container->requestRouteParams;
		$args	=	[];
		foreach ($params as $param)
		{
			if ($param->hasType() && isset($byType[$type = strtolower($param->getType())]))
				$args[] = $byType[$type];
			else if (isset($this->params[$param->name]))
				$args[] = $this->params[$param->name];
			else if (isset($_GET[$param->name]))
				$args[] = $_GET[$param->name];
			else if (isset($_POST[$param->name]))
				$args[] = $_POST[$param->name];
			else
			{
				if ( ! $param->isOptional())
					throw new \Exception('Unable to find NON-optional parameter `' . $param->name . ($param->hasType() ? '` of type `' . $param->getType() : null) . '` for route controller/handler: ' . var_export($this->route, true));
				$args[] = $param->getDefaultValue();
			}
		}
		return $args;
	}
870187
public function pre_get_posts( \WP_Query &$wp_query ){
        if( !is_admin() && $wp_query->is_main_query() && ($api_class = $wp_query->get($this->api_class)) ){
            // Detect class is valid
            try{
                // Fix escaped namespace delimiter
                $api_class = str_replace('\\\\', '\\', $api_class);
                // Check class existence
                if( !$this->is_valid_class($api_class) ){
                    throw new \Exception($this->__('Specified URL is invalid.'), 404);
                }
                /** @var RestBase $instance */
                $instance = $api_class::get_instance();
                $instance->parse_request($wp_query->get($this->api_vars), $wp_query);
            }catch ( \Exception $e ){
                switch( $e->getCode() ){
                    case 404:
                        $wp_query->set_404();
                        break;
                    case 200:
                    case 201:
                        // If status is O.K.
                        // Do nothing.
                        break;
                    default:
                        wp_die($e->getMessage(), get_status_header_desc($e->getCode()), [
                            'response' => $e->getCode(),
                            'back_link' => true,
                        ]);
                        break;
                }
            }
        }
    }
818794
protected function loadPostTypes()
    {
        if ($config = $this->loadConfigFile('post_types.php')) {
            $callbacks = array();

            // Create one callback for each post type, and register in
            // init action

            foreach ($config as $postTypeName => $args) {
                $callbacks[] = $cb = function () use ($postTypeName, $args) {
                    register_post_type($postTypeName, $args);
                };

                add_action('init', $cb, 0);
            }

            // Flush URL caches for (you need to register custom post types
            // first)

            register_activation_hook($this->getPluginFile(), function () use ($callbacks) {
                foreach ($callbacks as $cb) {
                    $cb();
                }

                flush_rewrite_rules();
            });
        }

        return $this;
    }
1350768
public function wp_bootstrap_pagination($args = array())
    {

        $defaults = array(
            'range' => 4,
            'custom_query' => FALSE,
            'previous_string' => __('Previous', 'theme'),
            'next_string' => __('Next', 'theme'),
            'before_output' => '<div class="post-nav"><ul class="pager">',
            'after_output' => '</ul></div>'
        );

        $args = wp_parse_args($args, apply_filters('wp_bootstrap_pagination_defaults', $defaults));

        $args['range'] = (int)$args['range'] - 1;
        if (!$args['custom_query'])
            $args['custom_query'] = @$GLOBALS['wp_query'];
        $count = (int)$args['custom_query']->max_num_pages;
        $page = intval(get_query_var('paged'));
        $ceil = ceil($args['range'] / 2);

        if ($count <= 1)
            return FALSE;

        if (!$page)
            $page = 1;

        if ($count > $args['range']) {
            if ($page <= $args['range']) {
                $min = 1;
                $max = $args['range'] + 1;
            } elseif ($page >= ($count - $ceil)) {
                $min = $count - $args['range'];
                $max = $count;
            } elseif ($page >= $args['range'] && $page < ($count - $ceil)) {
                $min = $page - $ceil;
                $max = $page + $ceil;
            }
        } else {
            $min = 1;
            $max = $count;
        }

        $echo = '';
        $previous = intval($page) - 1;
        $previous = esc_attr(get_pagenum_link($previous));

        $firstpage = esc_attr(get_pagenum_link(1));
        if ($firstpage && (1 != $page))
            $echo .= '<li class="previous"><a href="' . $firstpage . '">' . __('First', 'theme') . '</a></li>';
        if ($previous && (1 != $page))
            $echo .= '<li><a href="' . $previous . '" title="' . __('previous', 'theme') . '">' . $args['previous_string'] . '</a></li>';

        if (!empty($min) && !empty($max)) {
            for ($i = $min; $i <= $max; $i++) {
                if ($page == $i) {
                    $echo .= '<li class="active"><span class="active">' . str_pad((int)$i, 2, '0', STR_PAD_LEFT) . '</span></li>';
                } else {
                    $echo .= sprintf('<li><a href="%s">%002d</a></li>', esc_attr(get_pagenum_link($i)), $i);
                }
            }
        }

        $next = intval($page) + 1;
        $next = esc_attr(get_pagenum_link($next));
        if ($next && ($count != $page))
            $echo .= '<li><a href="' . $next . '" title="' . __('next', 'theme') . '">' . $args['next_string'] . '</a></li>';

        $lastpage = esc_attr(get_pagenum_link($count));
        if ($lastpage) {
            $echo .= '<li class="next"><a href="' . $lastpage . '">' . __('Last', 'theme') . '</a></li>';
        }
        if (isset($echo))
            echo $args['before_output'] . $echo . $args['after_output'];
    }
432323
function runQuery(client, queryString, args, callback) {
  if (activeBackend === 'mysql') {
    queryString = queryString.replace(/\$\d+/, '?');
  }

  client.query(queryString, args, function (err, result) {
    if (err) {
      callback(err, null);
      return;
    }
    if (activeBackend === 'mysql') {
      callback(err, result);
    }
    else if (activeBackend === 'pgsql') {
      var rows = [];
      if (result.rows) {
        rows = result.rows;
      }
      callback(err, rows);
    }
  });
}
708004
private function get_update_type_str( $assoc_args ) {
		$update_type = ' ';
		foreach ( array( 'major', 'minor', 'patch' ) as $type ) {
			if ( true === \WP_CLI\Utils\get_flag_value( $assoc_args, $type ) ) {
				$update_type = ' ' . $type . ' ';
				break;
			}
		}
		return $update_type;
	}
23144
protected function query_start($sql, array $params = null, $type, $extrainfo = null) {
        parent::query_start($sql, $params, $type, $extrainfo);
    }