Template_Handler
Handles the search results template, seamless mode and block template registration.
Namespace: WebberZone\Better_Search\Frontend
Since: 4.0.0
Source: includes/frontend/class-template-handler.php line 22
Methods
__construct()
Constructor class.
Since: 4.0.0
Line: 38
public function __construct( );
load_seamless_mode()
Load seamless mode and hook into WP_Query to check if better_search_query is set and true. If so, load the Better Search query. For non-seamless mode, add a filter to bypass the main query for search requests.
Since: 4.0.0
Line: 61
public function load_seamless_mode( WP_Query $query );
| Type | Name | Description |
|---|---|---|
\WP_Query |
$query |
Query object. |
template_include()
Displays the search results First checks if the theme contains a search template and uses that If search template is missing, generates the results below
Since: 4.0.0
Line: 119
public function template_include( $template );
| Type | Name | Description |
|---|---|---|
string |
$template |
Search template to use. |
register_patterns()
Register block patters
Since: 4.0.0
Line: 178
public function register_patterns( );
manage_block_templates()
Manage block templates for the wz_knowledgebase custom post type.
Since: 4.0.0
Line: 211
public function manage_block_templates( $query_result, $query, $template_type ): array;
| Type | Name | Description |
|---|---|---|
array |
$query_result |
Array of found block templates. |
array |
$query |
Arguments to retrieve templates. |
string |
$template_type |
$template_type wp_template or wp_template_part. |
Returns: array — Updated array of found block templates.
get_prefetched_results() static
Return pre-fetched search results cached during load_seamless_mode().
Since: 4.3.0
Line: 258
static public function get_prefetched_results( ): \Better_Search_Query|null;
Returns: \Better_Search_Query|null
get_template_content() static
Get the content of a template file.
Line: 334
static public function get_template_content( $template ): string;
| Type | Name | Description |
|---|---|---|
string |
$template |
The template file to include. |
Returns: string — The content of the template file.
wp_head() static
Insert styles into WordPress Head. Filters wp_head.
Since: 4.0.0
Line: 345
static public function wp_head( );
add_custom_archive_template()
Add custom archive template for the wz_knowledgebase custom post type.
Since: 4.0.0
Line: 380
public function add_custom_archive_template( $templates ): array;
| Type | Name | Description |
|---|---|---|
array |
$templates |
Array of found templates. |
Returns: array — Updated array of found templates.
add_custom_index_template()
Add custom archive template for the wz_knowledgebase custom post type.
Since: 4.0.0
Line: 395
public function add_custom_index_template( $templates ): array;
| Type | Name | Description |
|---|---|---|
array |
$templates |
Array of found templates. |
Returns: array — Updated array of found templates.
add_custom_search_template()
Add custom search template for the wz_knowledgebase custom post type.
Since: 4.0.0
Line: 407
public function add_custom_search_template( $templates ): array;
| Type | Name | Description |
|---|---|---|
array |
$templates |
Array of found templates. |
Returns: array — Updated array of found templates.