Recent

Custom_PermalinksclassPro only

Custom Permalinks Class.

Namespace: WebberZone\Knowledge_Base\Pro
Since: 3.0.0
Source: includes/pro/class-custom-permalinks.php line 22

Methods

__construct()

Constructor.

Since: 3.0.0
Line: 87

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: 134

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.

route_term_ids()

Translate product and section IDs into their taxonomy query vars.

WordPress taxonomy query vars expect term slugs. Resolve ID placeholders before WP_Query parses the request so the normal taxonomy and permalink-clash handling can process the request.

Since: 3.1.4
Line: 182

public function route_term_ids( array $query_vars ): array;
Type Name Description
array $query_vars Parsed query vars.

Returns: array — Filtered query vars.

filter_post_type_link()

Filter Knowledge Base permalinks to support placeholders.

Since: 3.0.0
Line: 224

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 links for KB taxonomies to support nested structures.

Since: 3.0.0
Line: 280

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: 438

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: 450

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: 501

public function add_custom_rewrite_rules(  );

add_query_vars()

Add custom query variables for KB permalinks.

Since: 3.0.0
Line: 835

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 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: 887

public function resolve_permalink_clash( $query );
Type Name Description
\WP_Query $query The WP_Query instance (passed by reference).

Get the custom permalink structure from options.

Since: 3.0.0
Line: 978

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: 1046

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.

product_id_placeholder()

Get product ID placeholder replacement.

Since: 3.1.4
Line: 1061

public function product_id_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 ID or empty string.

section_name_placeholder()

Get section placeholder replacement.

Since: 3.0.0
Line: 1113

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: 1146

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: 1174

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: 1202

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: 1214

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: 1226

public function author_placeholder( $post ): string;
Type Name Description
\WP_Post $post Post object.

Returns: string — Author nicename.