API / Minn\Runtime / PostQuery

PostQuery final class

Minn\Runtime\PostQuery · public/minn/src/Minn/Runtime/PostQuery.php · 394 lines

WP_Query::get_posts as the reference runs it (probe wp-query-sql): the variables parsed and handed to pre_get_posts, the clauses written piece by piece, every filter a plugin may change them through in the reference's order (suppress_filters keeps the ones it keeps), the request split into an id query when that is cheaper, the count, a single post's status check and preview, sticky posts on the home listing, and the results filters.

Used by 1

Constants and properties

privateWP_Query $query
privateobject $wpdb
privateMinn\Runtime\PostQueryParts $parts
privatereadonly Minn\Db $db

Promoted from the constructor.

Public

new__construct(Minn\Db $db)#
methodrun(WP_Query $query, object $wpdb, mixed $urlSearch): mixed#

Runs a query object's variables and fills it in: the posts (or ids, or id => parent), the request, the counts. Returns what get_posts returns.

$wpdbobjectthe database object plugins see, so the request runs where their filters expect it
$urlSearchmixedthe search string the URL carries, if any (a search from elsewhere is url-decoded)
methodsearch(WP_Query $query, array $q, mixed $urlSearch): string#

A search's WHERE fragment, settling the search variables (the terms, how many the string split into, the title matches its order ranks by).

$qarray<string, mixed>
methodstopwords(): array#

The search stopwords, translated and filtered. @return list<string>

@return list<string>

Internals 13

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privateprepare(): void#

Parses the variables, hands them to pre_get_posts, and reads the meta query from them.

privatedefaults(array $q): void#

The defaults get_posts settles before it writes a clause. @param array<string, mixed> $q

$qarray<string, mixed>
privatepageSize(array $q): void#

posts_per_page from the option, showposts, an archive's own size or the feed's, and nopaging. @param array<string, mixed> $q

$qarray<string, mixed>
privateclauses(array $q, mixed $urlSearch): void#

Writes the clauses, in the reference's order. @param array<string, mixed> $q

$qarray<string, mixed>
privatetaxonomies(array $q): void#

The tax query's clauses (not for a single post), a taxonomy archive's types, and the compatibility variables. @param array<string, mixed> $q

$qarray<string, mixed>
privatesearchOrder(array $q): void#

A search's relevance order, ahead of the order asked for, when no other order is asked for. @param array<string, mixed> $q

$qarray<string, mixed>
privatefiltered(array $q): void#

The clause filters, paging between the first two and the rest, and posts_selection. @param array<string, mixed> $q

$qarray<string, mixed>
privatethrough(array $hooks, string $clausesHook): void#

Each piece through its filter, then all seven through the clauses filter. @param array<string, string> $hooks

$hooksarray<string, string>
privatepaging(array $q): void#

LIMIT for a listing that pages: the offset when one is given, the page's start otherwise. @param array<string, mixed> $q

$qarray<string, mixed>
privateexecute(array $q): mixed#

Writes the request, runs it (or takes posts_pre_query's answer), and finishes the results. @param array<string, mixed> $q

$qarray<string, mixed>
privateidsOnly(array $q): array#

The ids (or id => parent) a query for them returns. @param array<string, mixed> $q

$qarray<string, mixed>
privateselect(array $q, string $old, string $foundRows): void#

Runs the request: ids first, then their posts, when the query can be split that way. @param array<string, mixed> $q

$qarray<string, mixed>
privatefoundPosts(array $q): void#

found_posts (from FOUND_ROWS() when the query paged, else the posts' count) and max_num_pages. @param array<string, mixed> $q

$qarray<string, mixed>