Finds one or more posts that have the given flag enabled

@param string $flag
@param string $post_type

@return \WP_Post[]
761454
public static function findPostsByFlag ($flag, $post_type = PostTypes::ANY)
    {
        return Post::findByExactMeta($flag, Checkbox::ON, $post_type);
    }
123903
public static function getFields($post_type)
    {
        $postType = PostType::all()->where('slug', $post_type)->first();

        if($postType) {
            return $postType->fields;
        }
        
        return [];
    }
9547
public function list_flags($folder, $uids, $mod_seq = null)
    {
        if (!strlen($folder)) {
            $folder = $this->folder;
        }

        if (!$this->check_connection()) {
            return array();
        }

        // @TODO: when cache was synchronized in this request
        // we might already have asked for flag updates, use it.

        $flags  = $this->conn->fetch($folder, $uids, true, array('FLAGS'), $mod_seq);
        $result = array();

        if (!empty($flags)) {
            foreach ($flags as $message) {
                $result[$message->uid] = $message->flags;
            }
        }

        return $result;
    }
954057
public function flagPost($postId, $flag)
	{
		$token = $this->oauth->getToken();

		// Set parameters.
		$parameters = array(
			'oauth_token' => $token['key'],
		);

		// Set the success response code.
		$this->oauth->setOption('success_code', 204);

		// Set the API base
		$base = '/v1/posts/' . $postId . '/category/code';

		// Build xml.
		$xml = '<code>' . $flag . '</code>';

		// Build the request path.
		$path = $this->getOption('api.url') . $base;

		$header['Content-Type'] = 'text/xml';

		// Send the request.
		$response = $this->oauth->oauthRequest($path, 'PUT', $parameters, $xml, $header);

		return $response;
	}
966511
private function getBitflags(array $flags)
    {
        $val = null;
        foreach ($flags as $flag) {
            $val = $val | $flag;
        }

        return $val;
    }
441801
public function getAllByPostType($lang = "", $postTypeID)
    {
        $orderBy = (isset($_GET['order'])) ? $orderBy = $_GET['order'] : 'tagID';
        $orderType = (isset($_GET['type'])) ? $orderType = $_GET['type'] : 'DESC';
        // get data
        return Tag::where('postTypeID', $postTypeID)->orderBy($orderBy, $orderType)->paginate(Tag::$rowsPerPage);
    }
333674
public function postsIndex($lang, $postTypeSlug, $view)
    {
        $postType = PostType::findBySlug($postTypeSlug);
        if(!$postType) {
            return response()->view('errors.404', ['message' => "This post type does not exist!"], 404);
        }

        // check if user has permissions to access this link
        $key = ($view == 'list') ? 'read' : $view;
        if(!User::hasAccess($postTypeSlug, $key)) {
            return view('errors.permissions');
        }

        return view('content');
    }
1122022
public function cpac_post_types( $post_types ) {

		foreach ( $post_types as $post_type => $post_type_name ) {
			if ( 0 === strpos( $post_type, '_pods_' ) || 0 === strpos( $post_type_name, '_pods_' ) ) {
				unset( $post_types[ $post_type ] );
			}
		}

		return $post_types;
	}
1030666
public function get_post_type($post_type){
    global $wpdb;

    $query = $wpdb->prepare( "SELECT * FROM ".MF_TABLE_POSTTYPES." WHERE type = %s", array( $post_type ) );

    $post_type = $wpdb->get_row( $query, ARRAY_A );
    if($post_type){
      $post_type_id = $post_type['id'];
      $post_type = unserialize($post_type['arguments']);
      $post_type['core']['id'] = $post_type_id;
      return $post_type;
    }
    return false;
  }
299238
public function getAllPostsOfCategory($lang, $postType, $categoryID)
    {
        // check if user has permissions to access this link
        if(!User::hasAccess($postType, 'read')) {
            return $this->noPermission();
        }
        // order info
        $orderBy = (isset($_GET['order'])) ? $_GET['order'] : 'postID';
        $orderType = (isset($_GET['type'])) ? $_GET['type'] : 'DESC';

        // get postIDs from relations
        $relations = DB::table(categoriesRelationTable($postType))->where('categoryID', $categoryID)->select('postID')->get();
        $postIDs = [];
        foreach ($relations as $postID){
            $postIDs[] = $postID->postID;
        }
        // get post list
        $list = DB::table($postType)->whereIn('postID', $postIDs)->orderBy($orderBy, $orderType)->paginate(Post::$rowsPerPage);
        return Language::filterRows($list);
    }
69154
public static function get_unique_custom_fields_by_post_type($post_type = "post") {
    global $wpdb;

    $query = "SELECT DISTINCT(type) FROM ".MF_TABLE_CUSTOM_FIELDS. " WHERE post_type = '".$post_type."'";

    $fields = $wpdb->get_col($query);
    return $fields;
  }
1239393
public function getPostedPostings()
    {
        $criteria = Criteria::create()
            ->where(Criteria::expr()->neq('postedAt', null))
            ->orderBy(array('postedAt' => Criteria::ASC))
        ;

        return $this->getPostings()->matching($criteria);
    }
789103
public function findByPostId($postId)
    {
        $args = array(
            'post_id' => $postId,
            'parent' => 0
        );
        $comments = get_comments($args);
        // Convert and return the comments
        return $this->convertAndReturn($comments);
    }
921934
private function getPostSelectedTags($id, $postTypeSlug)
    {
        // get selected tags from the DB table tags_relations
        $selectedTags = [];
        $tagsRelationTable = tagsRelationTable($postTypeSlug);
        $tagsRelations = DB::table($tagsRelationTable)
            ->leftJoin('tags', $tagsRelationTable.'.tagID', 'tags.tagID')
            ->where($tagsRelationTable.'.postID', $id)
            ->select("tags.tagID", $tagsRelationTable.".language", "tags.title", "tags.slug")
            ->get();

        foreach($tagsRelations as $tagsRelation){
            if(!isset($selectedTags[$tagsRelation->language])) {
                $selectedTags[$tagsRelation->language] = [];
            }
            $selectedTags[$tagsRelation->language][] = $tagsRelation;
        }

        return $selectedTags;
    }
42093
public boolean hasPosTag(String posTag) {
    boolean found = false;
    for (AnalyzedToken reading : anTokReadings) {
      if (reading.getPOSTag() != null) {
        found = posTag.equals(reading.getPOSTag());
        if (found) {
          break;
        }
      }
    }
    return found;
  }
743860
public static function findByExactMeta ($meta_key, $meta_value, $post_type = PostTypes::ANY)
    {
        return get_posts(array(
            'post_type'  => $post_type,
            'meta_key'   => $meta_key,
            'meta_value' => $meta_value
        ));
    }
507440
@Override
    public List<Post> findRelatedPosts(Post post, int size) {
        if (size <= 0 || (post.getCategories().isEmpty() && post.getTags().isEmpty())) {
            return null;
        }

        // n = n(a, b);
        // x = n / (sqrt(a.count) * sqrt(b.count))
        Map<Post, Integer> categoriesCountMap = calculatePostsCount(post, post.getCategories());
        Map<Post, Integer> tagsCountMap = calculatePostsCount(post, post.getTags());

        Map<Post, Double> scoreMap = new HashMap<Post, Double>();
        //categories
        for (Map.Entry<Post, Integer> en : categoriesCountMap.entrySet()) {
            double score = calculate(en.getValue(), post.getCategories().size(), en.getKey().getCategories().size());
            score = score * categoriesFactor;
            scoreMap.put(en.getKey(), score);
        }

        //tags
        for (Map.Entry<Post, Integer> en : tagsCountMap.entrySet()) {
            double score = calculate(en.getValue(), post.getTags().size(), en.getKey().getTags().size());
            Double val = scoreMap.get(en.getKey());
            if (val == null) {
                val = 0.0;
            }
            score = score * tagsFactor + val.doubleValue();
            scoreMap.put(en.getKey(), score);
        }

        final long time = post.getDate().getTime();
        List<Entry<Post, Double>> list = new ArrayList<Entry<Post, Double>>(scoreMap.entrySet());
        Collections.sort(list, new Comparator<Entry<Post, Double>>() {
            @Override
            public int compare(Entry<Post, Double> o1, Entry<Post, Double> o2) {
                double x = o1.getValue().doubleValue() - o2.getValue().doubleValue();
                int compare = (int) (x * 100000000.0);
                if (x == 0) {
                    //most near
                    long a = Math.abs(o1.getKey().getDate().getTime() - time);
                    long b = Math.abs(o2.getKey().getDate().getTime() - time);
                    return (a < b ? 1 : (a == b ? 0 : -1));
                    //most recent
                    //return o1.getKey().compareTo(o2.getKey());
                }
                return compare;
            }
        });

        Collections.reverse(list);

        if (size > list.size()) {
            size = list.size();
        }

        List<Entry<Post, Double>> subList = list.subList(0, size);

        ArrayList<Post> result = new ArrayList<Post>();
        for (Entry<Post, Double> en : subList) {
            result.add(en.getKey());
        }

        return result;
    }