PostLinks final class
Minn\Runtime\PostLinks · public/minn/src/Minn/Runtime/PostLinks.php · 151 lines
Post addresses as the reference's link functions build them (probe permalinks): a post through pre_post_link (the structure) and post_link; a page from get_page_uri through _get_page_link and page_link; an attachment under its parent's address, or its own; a plugin's type by its address pattern (the permastruct its rewrite registered) through post_type_link, by its query var without one. Plain (?p=, ?page_id=, ?post_type=) unless its status is public, or private and readable by whoever asks, or it is a sample: a draft, a scheduled or trashed post, a revision, a private one a visitor asks for. "Leaving the name" keeps the slug as its placeholder (%postname%, %pagename%, %{type}%) for an editor to fill in, and get_sample_permalink shows a draft as it would be published.
Constants and properties
| const | LEAVE_NAME = 1 | The slug kept as its placeholder. |
| const | SAMPLE = 2 | The address an editor previews: a draft as if published. |
| private | UNPUBLISHED = array ( 0 => 'draft', 1 => 'pending', 2 => 'auto-draft', 3 => 'future', ) |
Public
| static | post(WP_Post $post, int $flags): string# | A post's address (not a page, attachment or plugin type). |
| static | page(WP_Post $post, int $flags): string# | A page's own address, before page_link: ?page_id= while unpublished, its tag when the name is left, else its path. |
| static | attachment(WP_Post $post, int $flags): string# | An attachment's address: under a parent it belongs to, else its own slug, else ?attachment_id=. |
| static | custom(WP_Post $post, int $flags): string# | A plugin type's address by its pattern, by its query var, or by the type and id plainly. |
| static | sample(WP_Post $post, ?string $title, ?string $name): array# | The address an editor shows with the slug to edit: the post as if published, its name made unique, the address with the name left, a page's parents written in. @return array{0: string, 1: string} |
Internals 3
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | tokens(WP_Post $post, int $flags): array# | What each structure tag of a post stands for; the name stays a tag when it is left. |
| private | category(WP_Post $post): string# | The %category% part: the post's first category by id (post_link_category may choose another), under its parents. |
| private | plain(WP_Post $post, int $flags): bool# | Whether a post's address is the plain one: its status neither public nor private and readable, unless it is a sample of a status that is not internal (a trashed post and a revision stay plain as samples). |
Nothing matches.