API / Minn\Runtime / PostReads

PostReads final class

Minn\Runtime\PostReads · public/minn/src/Minn/Runtime/PostReads.php · 310 lines

What WordPress's post functions tell about posts: a page's path and a page by its path, a post's type, status and fields, whether it can be viewed, when posts last changed, posts by query arguments and a post's children and categories, the SQL that limits a query to what an author may read, and the caches primed for a list of posts.

Public

staticpageUri(mixed $page = 0): mixed#

A page's path from its ancestors' slugs (get_page_uri), or false.

staticpageByPath(mixed $path, mixed $output = 'OBJECT', mixed $type = 'page'): mixed#

A page by its path (get_page_by_path): one type looks among attachments too; a list looks among exactly its types.

statictype(mixed $post = NULL): mixed#

A post's type (get_post_type), or false.

staticstatus(mixed $post = NULL): mixed#

A post's status (get_post_status): an attachment's is its parent's (a trashed parent's from before the trash); false for none.

staticfield(mixed $field, mixed $post = NULL, mixed $context = 'display'): mixed#

One of a post's fields in a context (get_post_field), empty when there is none.

staticpubliclyViewable(mixed $post = NULL): bool#

Whether a post can be viewed by anyone (is_post_publicly_viewable): its type and its status both viewable.

staticlastTime(mixed $timezone, mixed $field, mixed $type = 'any'): mixed#

When a public post was last published or changed (_get_last_post_time), in GMT, the site's time or the server's (with microseconds); false for none or a question it cannot answer.

staticlastDate(mixed $timezone = 'server', mixed $type = 'any'): mixed#

When a public post was last published (get_lastpostdate), as get_lastpostdate leaves it.

staticlastModified(mixed $timezone = 'server', mixed $type = 'any'): mixed#

When a public post last changed or was published, the later (get_lastpostmodified), pre_get_lastpostmodified answering first.

staticquery(mixed $args = NULL): mixed#

Posts by query arguments (get_posts): five published posts by date unless asked otherwise, numberposts read as posts_per_page, category, include and exclude read as the query's own, stickies ignored, no rows counted.

@return array<int, mixed>
staticchildren(mixed $args = '', mixed $output = 'OBJECT'): array#

A post's children (get_children), the post being read's when none is named, keyed by id, as objects or arrays.

@return array<int, mixed>
staticcategories(mixed $postId = 0, mixed $args = array ( )): mixed#

A post's categories (wp_get_post_categories), their ids unless asked otherwise; empty on an error.

staticmimeTypeWhere(mixed $types, mixed $tableAlias = ''): string#

The WHERE clause for MIME types (wp_post_mime_type_where), a wildcard or a list.

staticbyAuthorSql(mixed $type, mixed $full = true, mixed $author = NULL, mixed $publicOnly = false): string#

The SQL limiting posts to what may be read (get_posts_by_author_sql): an author's own, the published, and the private ones the reader may read.

staticprime(mixed $ids, mixed $updateTermCache = true, mixed $updateMetaCache = true): void#

Posts read into the caches together (_prime_post_caches): rows, and their meta and terms unless asked not to.

staticupdateCaches(mixed $posts, mixed $type = 'post', mixed $updateTermCache = true, mixed $updateMetaCache = true): void#

A list of posts kept in the caches (update_post_caches): whole posts kept as they are, then primed.

staticidFromUrl(mixed $url): int#

The post an address names (url_to_postid): a ?p= or ?page_id= id, else with pretty permalinks a page by its path, a post whose own address it is, or an attachment by its own; 0 for none.

Internals 4

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

privatefilledArguments(array $parsed): array#

The query arguments get_posts fills from its own: a status when none is given (inherit for attachments, publish for the rest), the page size from numberposts when no posts_per_page is, the category as cat.

$parsedarray<array-key, mixed>
@return array<string, mixed>
privatechosenPosts(array $parsed): array#

The posts get_posts names by id: the included ones, the page as large as their number; else the ones left out; else none.

$parsedarray<array-key, mixed>
@return array<string, mixed>
privateidList(mixed $list): array#
@return array<int, int> ids from a list or a string, each once, as positive integers
privatestore(): Minn\Content\Posts#