WC_Widget_Layered_Nav
extends WC_Widget
in package
Widget layered nav class.
Table of Contents
- $settings : array<string|int, mixed>
- Settings.
- $widget_cssclass : string
- CSS class.
- $widget_description : string
- Widget description.
- $widget_id : string
- Widget ID.
- $widget_name : string
- Widget name.
- __construct() : mixed
- Constructor.
- cache_widget() : string
- Cache the widget.
- flush_widget_cache() : mixed
- Flush the cache.
- form() : mixed
- Outputs the settings update form.
- get_cached_widget() : bool
- Get cached widget.
- init_settings() : mixed
- Init settings after post types are registered.
- update() : array<string|int, mixed>
- Updates a particular instance of a widget.
- widget() : mixed
- Output widget.
- widget_end() : mixed
- Output the html at the end of a widget.
- widget_start() : mixed
- Output the html at the start of a widget.
- get_current_page_url() : string
- Get current page URL with various filtering props supported by WC.
- get_current_taxonomy() : string
- Return the currently viewed taxonomy name.
- get_current_term_id() : int
- Return the currently viewed term ID.
- get_current_term_slug() : int
- Return the currently viewed term slug.
- get_filtered_term_product_counts() : array<string|int, mixed>
- Count products within certain terms, taking the main WP query into consideration.
- get_instance_display_type() : string
- Get this widgets display type.
- get_instance_query_type() : string
- Get this widgets query type.
- get_instance_taxonomy() : string
- Get this widgets taxonomy.
- get_instance_title() : string
- Get this widgets title.
- get_main_meta_query() : array<string|int, mixed>
- Wrapper for WC_Query::get_main_search_queryget_main_meta_query to ease unit testing.
- get_main_search_query_sql() : string
- Wrapper for WC_Query::get_main_search_query_sql() to ease unit testing.
- get_main_tax_query() : array<string|int, mixed>
- Wrapper for WC_Query::get_main_tax_query() to ease unit testing.
- get_widget_id_for_cache() : string
- Get widget id plus scheme/protocol to prevent serving mixed content from (persistently) cached widgets.
- layered_nav_dropdown() : bool
- Show dropdown layered nav.
- layered_nav_list() : bool
- Show list based layered nav.
Properties
$settings
Settings.
public
array<string|int, mixed>
$settings
$widget_cssclass
CSS class.
public
string
$widget_cssclass
$widget_description
Widget description.
public
string
$widget_description
$widget_id
Widget ID.
public
string
$widget_id
$widget_name
Widget name.
public
string
$widget_name
Methods
__construct()
Constructor.
public
__construct() : mixed
Return values
mixed —cache_widget()
Cache the widget.
public
cache_widget(array<string|int, mixed> $args, string $content) : string
Parameters
- $args : array<string|int, mixed>
-
Arguments.
- $content : string
-
Content.
Return values
string — the content that was cachedflush_widget_cache()
Flush the cache.
public
flush_widget_cache() : mixed
Return values
mixed —form()
Outputs the settings update form.
public
form(array<string|int, mixed> $instance) : mixed
Parameters
- $instance : array<string|int, mixed>
-
Instance.
Tags
Return values
mixed —get_cached_widget()
Get cached widget.
public
get_cached_widget(array<string|int, mixed> $args) : bool
Parameters
- $args : array<string|int, mixed>
-
Arguments.
Return values
bool — true if the widget is cached otherwise falseinit_settings()
Init settings after post types are registered.
public
init_settings() : mixed
Return values
mixed —update()
Updates a particular instance of a widget.
public
update(array<string|int, mixed> $new_instance, array<string|int, mixed> $old_instance) : array<string|int, mixed>
Parameters
- $new_instance : array<string|int, mixed>
-
New Instance.
- $old_instance : array<string|int, mixed>
-
Old Instance.
Tags
Return values
array<string|int, mixed> —widget()
Output widget.
public
widget(array<string|int, mixed> $args, array<string|int, mixed> $instance) : mixed
Parameters
- $args : array<string|int, mixed>
-
Arguments.
- $instance : array<string|int, mixed>
-
Instance.
Tags
Return values
mixed —widget_end()
Output the html at the end of a widget.
public
widget_end(array<string|int, mixed> $args) : mixed
Parameters
- $args : array<string|int, mixed>
-
Arguments.
Return values
mixed —widget_start()
Output the html at the start of a widget.
public
widget_start(array<string|int, mixed> $args, array<string|int, mixed> $instance) : mixed
Parameters
- $args : array<string|int, mixed>
-
Arguments.
- $instance : array<string|int, mixed>
-
Instance.
Return values
mixed —get_current_page_url()
Get current page URL with various filtering props supported by WC.
protected
get_current_page_url() : string
Tags
Return values
string —get_current_taxonomy()
Return the currently viewed taxonomy name.
protected
get_current_taxonomy() : string
Return values
string —get_current_term_id()
Return the currently viewed term ID.
protected
get_current_term_id() : int
Return values
int —get_current_term_slug()
Return the currently viewed term slug.
protected
get_current_term_slug() : int
Return values
int —get_filtered_term_product_counts()
Count products within certain terms, taking the main WP query into consideration.
protected
get_filtered_term_product_counts(array<string|int, mixed> $term_ids, string $taxonomy, string $query_type) : array<string|int, mixed>
This query allows counts to be generated based on the viewed products, not all products.
Parameters
- $term_ids : array<string|int, mixed>
-
Term IDs.
- $taxonomy : string
-
Taxonomy.
- $query_type : string
-
Query Type.
Return values
array<string|int, mixed> —get_instance_display_type()
Get this widgets display type.
protected
get_instance_display_type(array<string|int, mixed> $instance) : string
Parameters
- $instance : array<string|int, mixed>
-
Array of instance options.
Return values
string —get_instance_query_type()
Get this widgets query type.
protected
get_instance_query_type(array<string|int, mixed> $instance) : string
Parameters
- $instance : array<string|int, mixed>
-
Array of instance options.
Return values
string —get_instance_taxonomy()
Get this widgets taxonomy.
protected
get_instance_taxonomy(array<string|int, mixed> $instance) : string
Parameters
- $instance : array<string|int, mixed>
-
Array of instance options.
Return values
string —get_instance_title()
Get this widgets title.
protected
get_instance_title(array<string|int, mixed> $instance) : string
Parameters
- $instance : array<string|int, mixed>
-
Array of instance options.
Return values
string —get_main_meta_query()
Wrapper for WC_Query::get_main_search_queryget_main_meta_query to ease unit testing.
protected
get_main_meta_query() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —get_main_search_query_sql()
Wrapper for WC_Query::get_main_search_query_sql() to ease unit testing.
protected
get_main_search_query_sql() : string
Tags
Return values
string —get_main_tax_query()
Wrapper for WC_Query::get_main_tax_query() to ease unit testing.
protected
get_main_tax_query() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —get_widget_id_for_cache()
Get widget id plus scheme/protocol to prevent serving mixed content from (persistently) cached widgets.
protected
get_widget_id_for_cache(string $widget_id[, string $scheme = '' ]) : string
Parameters
- $widget_id : string
-
Id of the cached widget.
- $scheme : string = ''
-
Scheme for the widget id.
Tags
Return values
string — Widget id including scheme/protocol.layered_nav_dropdown()
Show dropdown layered nav.
protected
layered_nav_dropdown(array<string|int, mixed> $terms, string $taxonomy, string $query_type) : bool
Parameters
- $terms : array<string|int, mixed>
-
Terms.
- $taxonomy : string
-
Taxonomy.
- $query_type : string
-
Query Type.
Return values
bool — Will nav display?layered_nav_list()
Show list based layered nav.
protected
layered_nav_list(array<string|int, mixed> $terms, string $taxonomy, string $query_type) : bool
Parameters
- $terms : array<string|int, mixed>
-
Terms.
- $taxonomy : string
-
Taxonomy.
- $query_type : string
-
Query Type.