API / Minn\Front / Permalinks

Permalinks final readonly class

Minn\Front\Permalinks · public/minn/src/Minn/Front/Permalinks.php · 265 lines

Builds public URLs from the site's permalink structure. With an empty structure every link is a query-string form (?p=, ?cat=); with a structure, published and private posts get their pretty form and every other status keeps the query form, which is what the reference emits.

Constants and properties

privateQUERY_ONLY = array ( 0 => 'wp_pattern_category', 1 => 'wp_theme', 2 => 'wp_template_part_area', )

Core taxonomies with no front-end archive: their terms link by query only.

privatereadonly Minn\Content\Posts $posts

Promoted from the constructor.

privatereadonly Minn\Content\Terms $terms

Promoted from the constructor.

propreadonly string $home

Promoted from the constructor.

propreadonly string $structure

Promoted from the constructor.

propreadonly int $frontPageId

Promoted from the constructor.

propreadonly int $postsPageId

Promoted from the constructor.

privatereadonly ?Closure $registry

Promoted from the constructor.

Public

new__construct(Minn\Content\Posts $posts, Minn\Content\Terms $terms, string $home, string $structure, int $frontPageId = 0, int $postsPageId = 0, ?Closure $registry = NULL)#
methodtypeSlug(string $type): string#

The rewrite slug a plugin gave its post type, else the type's name.

methodtaxonomySlug(string $taxonomy): ?string#

The rewrite slug a plugin gave its taxonomy; null for one the engine does not know.

methodforPostTypeArchive(array $type): string#

A post type archive's address: its has_archive slug, or the type's slug when has_archive is true.

staticfromDb(Minn\Db $db): self#

Link building from the site's own settings.

methodisPretty(): bool#

Whether the site uses a permalink structure.

methodurl(string $path = ''): string#

A URL under the home.

staticfeedPath(string $base, string $type): string#

A feed's address under a base path ("/", "/category/news/", "/hello-world/"): feed/ for the default feed (rss2, and rss with it), feed/<type>/ for another; a comments-<type> feed is its <type>.

methodlink(Minn\Content\PostRecord $post): string#

A post's link as plugins and clients are given it: once the runtime runs, the reference's, through its link filters (post_link, page_link, post_type_link, as get_permalink() answers); before, the engine's own.

methodforComment(int $commentId, ?Minn\Content\PostRecord $post, int $postId): string#

A comment's link as plugins and clients are given it: once the runtime runs, get_comment_link()'s (its paging and its filter, over the post's filtered link); before, the post's own with the anchor.

methodforPost(Minn\Content\PostRecord $post): string#

A post's permalink, by the engine's own rules (no plugin filters: address matching uses it).

methodforPage(Minn\Content\PostRecord $page): string#

A page's permalink, the home for the front page.

methodpagePath(Minn\Content\PostRecord $page): string#

A page's own pretty path, even for the static front page (its comments feed lives there).

methodforAttachment(Minn\Content\PostRecord $attachment): string#

An attachment's public link: its slug under the parent's permalink when attached, at the root when not, or the query form under plain permalinks.

methodforTerm(Minn\Content\TermRecord $term): string#

A term's archive URL.

methodforAuthor(Minn\Content\UserRecord $user): string#

An author's archive URL.

methodforDate(int $year, ?int $month = NULL, ?int $day = NULL): string#

A date archive's URL.

methodforSearch(string $term): string#

A search's URL.

methodforPaged(string $baseUrl, int $page): string#

A listing URL for a page number.

Internals 3

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

privatefiltered(): bool#

Whether links go through the reference's filters: once plugins can hook them.

privatehasPrettyLink(Minn\Content\PostRecord $post): bool#
privatefill(Minn\Content\PostRecord $post): string#