Get posts with conditions
@param array $args
@param bool $load_terms
@return array
963901
public static function getWhere($args = array(), $load_terms = true)
    {
        $instance = Post\Factory::create(get_called_class());

        // Allow sorting both by core fields and custom fields
        // See: http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters
        $default_orderby = $instance->getDefaultOrderBy();
        $default_order = $instance->getDefaultOrder();
        $default_args = array(
            'post_type'  => $instance->getPostType(),
            'numberposts'=> -1,
            'orderby'    => $default_orderby,
            'order'      => $default_order,
        );

        // Sometimes you will specify a default orderby using getDefaultOrderBy
        if ($default_orderby !== 'menu_order') {
            $fields = $instance->getFields();
            if (array_key_exists($default_orderby, $fields)) {
                $default_args['meta_key'] = $default_orderby;
                
                // Number fields should be sorted numerically, not alphabetically
                // Of course, this currently requires you to use type=number to achieve numeric sorting
                $default_args['orderby'] = ($fields[$default_orderby]['type'] === 'number')
                    ? 'meta_value_num'
                    : 'meta_value';
            }
        }

        // But other times, you'll just pass in orderby via $args,
        // e.g. if you call getBy or getWhere with the $args param
        if (array_key_exists('orderby', $args)) {
            $fields = $instance->getFields();
            if (array_key_exists($args['orderby'], $fields)) {
                $args['meta_key'] = $args['orderby'];
                
                // Number fields should be sorted numerically, not alphabetically
                // Of course, this currently requires you to use type=number to achieve numeric sorting
                $args['orderby'] = ($fields[$args['orderby']]['type'] === 'number')
                    ? 'meta_value_num'
                    : 'meta_value';
            }
        }
        
        $criteria = array_merge($default_args, $args);
        return Post\Factory::createMultiple(get_posts($criteria), $load_terms);
    }
105984
protected function getSearchQuery(array $args)
    {
        return implode(' ', array_map(function ($term) {
            return strpos($term, ' ') ? '"' . $term . '"' : $term;
        }, $args));
    }
863540
protected function search($args) {
		$q      = trim($args['q']);
		$mimes  = !empty($args['mimes']) && is_array($args['mimes']) ? $args['mimes'] : array();
		$result = array();

		foreach ($this->volumes as $volume) {
			$result = array_merge($result, $volume->search($q, $mimes));
		}
		
		return array('files' => $result);
	}
480699
protected function validateConditionTrigger($condition_id, array $args)
    {
        try {
            $handlers = $this->condition->getHandlers();
            return static::call($handlers, $condition_id, 'validate', $args);
        } catch (Exception $ex) {
            return $ex->getMessage();
        }
    }
298132
public function filter_function($args)
    {
        return function ($item) use ($args) {
            $columns = $args['columns'];
            $search = $args['search']['value'];
            if (!empty($search)) {
                if ($item instanceof Model) {
                    foreach ($columns as $key => $value) {
                        if ($value['searchable']) {
                            $columnValue = $this->getFiledValue($item, $key);
                            if (strpos($columnValue, $search) !== false) {
                                return true;
                            }
                        }
                    }
                }
                return false;
            }
            return true;
        };
    }
956429
public static function search( $args )
    {
        $http = eZHTTPTool::instance();

        if ( $http->hasPostVariable( 'SearchStr' ) )
            $searchStr = trim( $http->postVariable( 'SearchStr' ) );

        $searchOffset = 0;
        if ( $http->hasPostVariable( 'SearchOffset' ))
            $searchOffset = (int) $http->postVariable( 'SearchOffset' );

        $searchLimit = 10;
        if ( $http->hasPostVariable( 'SearchLimit' ))
            $searchLimit = (int) $http->postVariable( 'SearchLimit' );

        if ( $searchLimit > 30 ) $searchLimit = 30;

        if ( $http->hasPostVariable( 'SearchSubTreeArray' ) && $http->postVariable( 'SearchSubTreeArray' ) )
        {
            $search_sub_tree_array = explode( ',', $http->postVariable( 'SearchSubTreeArray' ) );
        }

        //Prepare the search params
        $param = array( 'SearchOffset' => $searchOffset,
                        'SearchLimit' => $searchLimit+1,
                        'SortArray' => array( 'score', 0 ),
                        'SearchSubTreeArray' => $search_sub_tree_array
                      );

        if ( $http->hasPostVariable( 'enable-spellcheck' ) and $http->postVariable( 'enable-spellcheck' ) == 1 )
        {
            $param['SpellCheck'] = array( true );
        }

        if ( $http->hasPostVariable( 'show-facets' ) and $http->postVariable( 'show-facets' ) == 1 )
        {
            $defaultFacetFields = eZFunctionHandler::execute( 'ezfind', 'getDefaultSearchFacets', array() );
            $param['facet'] = $defaultFacetFields;
        }

        $solr = new eZSolr();
        $searchList = $solr->search( $searchStr, $param );

        $result = array();
        $result['SearchResult'] = eZFlowAjaxContent::nodeEncode( $searchList['SearchResult'], array(), false );
        $result['SearchCount'] = $searchList['SearchCount'];
        $result['SearchOffset'] = $searchOffset;
        $result['SearchLimit'] = $searchLimit;
        $result['SearchExtras'] = array();

        if ( isset( $param['SpellCheck'] ) )
            $result['SearchExtras']['spellcheck'] = $searchList['SearchExtras']->attribute( 'spellcheck' );

        if ( isset( $param['facet'] ) )
        {
            $facetInfo = array();
            $retrievedFacets = $searchList['SearchExtras']->attribute( 'facet_fields' );
            $baseSearchUrl = "/content/search/";
            eZURI::transformURI( $baseSearchUrl, false, 'full' );

            foreach ( $defaultFacetFields as $key => $defaultFacet )
            {
                $facetData = $retrievedFacets[$key];
                $facetInfo[$key] = array();
                $facetInfo[$key][] = $defaultFacet['name'];

                if ( $facetData != null )
                {
                    foreach ( $facetData['nameList'] as $key2 => $facetName )
                    {
                        $tmp = array();
                        if ( $key2 != '' )
                        {
                            $tmp[] = $baseSearchUrl . '?SearchText=' . $searchStr . '&filter[]=' . $facetData['queryLimit'][$key2] . '&activeFacets[' . $defaultFacet['field'] . ':' . $defaultFacet['name'] . ']=' . $facetName;
                            $tmp[] = $facetName;
                            $tmp[] = "(" . $facetData['countList'][$key2] . ")";
                            $facetInfo[$key][] = $tmp;
                        }
                    }
                }
            }
            $result['SearchExtras']['facets'] = $facetInfo;
        }

        return $result;
    }
509599
private function getParams(array $args)
    {
        if (count($args) == 0) {
            return [];
        }

        $params = array_slice($args, -1)[0];

        return is_array($params) ? $params : [];
    }
1086661
public function get( $args, $assoc_args ) {
		list( $object_id, $meta_key ) = $args;

		$object_id = $this->check_object_id( $object_id );

		$value = $this->get_metadata( $object_id, $meta_key, true );

		if ( '' === $value ) {
			die( 1 );
		}

		WP_CLI::print_value( $value, $assoc_args );
	}
357564
public function terms($taxonomy = null, array $arguments = [])
    {
        if (isset($taxonomy)) {
            return $this->model->getTerms($this, $taxonomy, $arguments);
        }

        return $this->model->getAllTerms($this);
    }
458391
public static function get_terms( $args = null, $maybe_args = array(), $TermClass = 'Timber\Term' ) {
		return TermGetter::get_terms($args, $maybe_args, $TermClass);
	}
720843
public function getFields(array $args = [])
    {
        if (empty($args)) {
            return $this->fields;
        }

        return \array_filter($this->fields, function (AbstractType $field) use ($args) {
            return $field->filter($args);
        });
    }
820459
public static function getValidItems( $args )
    {
        $http = eZHTTPTool::instance();
        $tpl = eZTemplate::factory();

        $result = array();

        $blockID = $http->postVariable('block_id');
        $offset = $http->postVariable('offset');
        $limit = $http->postVariable('limit');

        $validNodes = eZFlowPool::validNodes( $blockID );
        $counter = 0;
        foreach( $validNodes as $validNode )
        {
            if ( !$validNode->attribute( 'can_read' ) )
                continue;
            $counter++;

            if ( $counter <= $offset )
                continue;

            $tpl->setVariable('node', $validNode);
            $tpl->setVariable('view', 'block_item');
            $tpl->setVariable('image_class', 'blockgallery1');
            $content = $tpl->fetch('design:node/view/view.tpl');

            $result[] = $content;

            if ( $counter === $limit )
                break;
        }

        return $result;
    }
304586
public static function find($post_id, $load_terms = true)
    {
        $instance = Post\Factory::create(get_called_class());
        $instance->load($post_id, $load_terms);
        return $instance;
    }
856712
protected function get_place_holders( $args ) {
		$wheres = [];
		foreach ( $args as $key => $val ) {
			if ( ! isset( $this->default_placeholder[ $key ] ) ) {
				throw new \Exception( sprintf( __( 'Model %1$s has no column "%2$s".', 'karma' ), get_called_class(), $key ), 500 );
			}
			$wheres[] = $this->default_placeholder[ $key ];
		}
		return $wheres;
	}
241101
public static function createMultiple($posts, $load_terms = true)
    {
        if (!Arr::iterable($posts)) {
            return $posts;
        }
        
        $out = array();
        foreach ($posts as $k => $post) {
            if (!get_post_status($post)) {
                continue;
            }
            $record = self::create($post, $load_terms);
            $out[$k] = $record;
        }
        return $out;
    }
748328
public static function queryPosts($args)
    {
        $query = new WP_Query($args);
        // Set default return to false
        $posts = false;
        // Iterate and build the array of instances instances
        if ($query->have_posts()) {
            global $post;
            // Create the array
            $posts = array();
            while ($query->have_posts()) {
                $query->the_post();
                $thePost = static::create($post);
                array_push($posts, $thePost);
            }
        }
        return $posts;
    }
619390
public function createTerm(string $term, string $taxonomy, array $args = []): array
    {
        $args['taxonomy'] = $taxonomy;
        $args['term'] = $term;

        $term = $this->getDriver()->term->create($args);

        return array(
            'id'   => $term->term_id,
            'slug' => $term->slug
        );
    }