Recent

Custom_Permalinks class Pro only

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;
TypeNameDescription
array$query_varsQuery 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;
TypeNameDescription
string$permalinkThe post’s permalink.
\WP_Post$postThe post in question.

Returns: string — Filtered permalink.

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;
TypeNameDescription
string$termlinkTerm link URL.
object$termTerm object.
string$taxonomyTaxonomy 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;
TypeNameDescription
int$object_idThe 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;
TypeNameDescription
object$termTerm 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;
TypeNameDescription
array$query_varsThe 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: 840

public function resolve_permalink_clash( $query );
TypeNameDescription
\WP_Query$queryThe WP_Query instance (passed by reference).

Get the custom permalink structure from options.

Since: 3.0.0
Line: 931

public function get_permalink_structure( $type = ... ): string;
TypeNameDescription
string$typeOptional. 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;
TypeNameDescription
\WP_Post|\WP_Term$itemPost object or term object.
array$termsOptional. 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;
TypeNameDescription
\WP_Post|\WP_Term$itemPost object or term object.
array$termsOptional. 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;
TypeNameDescription
\WP_Post|\WP_Term$itemPost object or term object.
array$termsOptional. 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;
TypeNameDescription
\WP_Post|\WP_Term$itemPost object or term object.
array$termsOptional. 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;
TypeNameDescription
\WP_Post$postPost 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;
TypeNameDescription
\WP_Post$postPost object.

Returns: string — Post ID.

author_placeholder()

Get author placeholder replacement.

Since: 3.0.0
Line: 1149

public function author_placeholder( $post ): string;
TypeNameDescription
\WP_Post$postPost object.

Returns: string — Author nicename.