Custom_Permalinks
Custom Permalinks Class.
Namespace: WebberZone\Knowledge_Base\Pro
Since: 3.0.0
Source: includes/class-custom-permalinks.php line 22
Methods
__construct()
Constructor.
Since: 3.0.0
Line: 86
public function __construct( );
route_root_level_article()
Route root-level article requests (%postname% structure) before WP builds the main query.
Runs on the ‘request’ filter to minimally adjust query vars. We avoid setting flags and let WordPress decide templates. This prevents WP from setting p=0 and avoids front_page confusion.
Since: 3.0.x
Line: 132
public function route_root_level_article( array $query_vars ): array;
| Type | Name | Description |
|---|---|---|
array | $query_vars | Query vars parsed from the request. |
Returns: array — Filtered query vars.
filter_post_type_link()
Filter Knowledge Base permalinks to support placeholders.
Since: 3.0.0
Line: 177
public function filter_post_type_link( $permalink, $post ): string;
| Type | Name | Description |
|---|---|---|
string | $permalink | The post’s permalink. |
\WP_Post | $post | The post in question. |
Returns: string — Filtered permalink.
filter_term_link()
Filter term links for KB taxonomies to support nested structures.
Since: 3.0.0
Line: 233
public function filter_term_link( $termlink, $term, $taxonomy ): string;
| Type | Name | Description |
|---|---|---|
string | $termlink | Term link URL. |
object | $term | Term object. |
string | $taxonomy | Taxonomy slug. |
Returns: string — Modified term link.
invalidate_post_terms_cache()
Invalidate the cached term list for a post when its terms change.
Hooked to set_object_terms so that a cache entry populated before
taxonomies were assigned (e.g. during wp_insert_post() hooks) does not
persist and cause empty placeholder replacements on the next get_permalink() call.
Since: 3.1.0
Line: 391
public function invalidate_post_terms_cache( int $object_id ): void;
| Type | Name | Description |
|---|---|---|
int | $object_id | The object whose terms were changed. |
Returns: void
get_term_hierarchy_path()
Get the hierarchical path for a term including all parent terms.
Since: 3.0.0
Line: 403
public function get_term_hierarchy_path( $term ): string;
| Type | Name | Description |
|---|---|---|
object | $term | Term object. |
Returns: string — Term path including parents, separated by slashes.
add_custom_rewrite_rules()
Add custom rewrite rules for KB permalinks.
Since: 3.0.0
Line: 454
public function add_custom_rewrite_rules( );
add_query_vars()
Add custom query variables for KB permalinks.
Since: 3.0.0
Line: 788
public function add_query_vars( array $query_vars ): array;
| Type | Name | Description |
|---|---|---|
array | $query_vars | The array of registered query variables. |
Returns: array — Modified query vars array.
resolve_permalink_clash()
Resolve permalink clashes between products and sections.
If a URL results in both wzkb_product and wzkb_category query vars being set, this function checks if the wzkb_category is a valid section. If so, it prioritizes the section query.
Since: 3.0.x
Line: 840
public function resolve_permalink_clash( $query );
| Type | Name | Description |
|---|---|---|
\WP_Query | $query | The WP_Query instance (passed by reference). |
get_permalink_structure()
Get the custom permalink structure from options.
Since: 3.0.0
Line: 931
public function get_permalink_structure( $type = ... ): string;
| Type | Name | Description |
|---|---|---|
string | $type | Optional. Type of permalink structure to get (product, section, article). |
Returns: string — Permalink structure.
product_name_placeholder()
Get product placeholder replacement.
Since: 3.0.0
Line: 999
public function product_name_placeholder( $item, $terms = ... ): string;
| Type | Name | Description |
|---|---|---|
\WP_Post|\WP_Term | $item | Post object or term object. |
array | $terms | Optional. Pre-fetched terms for the post. |
Returns: string — Product slug or empty string.
section_name_placeholder()
Get section placeholder replacement.
Since: 3.0.0
Line: 1036
public function section_name_placeholder( $item, $terms = ... ): string;
| Type | Name | Description |
|---|---|---|
\WP_Post|\WP_Term | $item | Post object or term object. |
array | $terms | Optional. Pre-fetched terms for the post. |
Returns: string — Section slug or empty string.
section_id_placeholder()
Get section ID placeholder replacement.
Since: 3.0.0
Line: 1069
public function section_id_placeholder( $item, $terms = ... ): string|int;
| Type | Name | Description |
|---|---|---|
\WP_Post|\WP_Term | $item | Post object or term object. |
array | $terms | Optional. Pre-fetched terms for the post. |
Returns: string|int — Section ID or empty string.
tag_name_placeholder()
Get tag placeholder replacement.
Since: 3.0.0
Line: 1097
public function tag_name_placeholder( $item, $terms = ... ): string;
| Type | Name | Description |
|---|---|---|
\WP_Post|\WP_Term | $item | Post object or term object. |
array | $terms | Optional. Pre-fetched terms for the post. |
Returns: string — Tag slug or empty string.
postname_placeholder()
Get postname (slug) placeholder replacement.
Since: 3.0.0
Line: 1125
public function postname_placeholder( $post ): string;
| Type | Name | Description |
|---|---|---|
\WP_Post | $post | Post object. |
Returns: string — Post slug.
post_id_placeholder()
Get post ID placeholder replacement.
Since: 3.0.0
Line: 1137
public function post_id_placeholder( $post ): string;
| Type | Name | Description |
|---|---|---|
\WP_Post | $post | Post object. |
Returns: string — Post ID.
author_placeholder()
Get author placeholder replacement.
Since: 3.0.0
Line: 1149
public function author_placeholder( $post ): string;
| Type | Name | Description |
|---|---|---|
\WP_Post | $post | Post object. |
Returns: string — Author nicename.