WC_Widget_Brand_Thumbnails::widget
Echoes the widget content.
Method of the class: WC_Widget_Brand_Thumbnails{}
Hooks from the method
Returns
null. Nothing (null).
Usage
$WC_Widget_Brand_Thumbnails = new WC_Widget_Brand_Thumbnails(); $WC_Widget_Brand_Thumbnails->widget( $args, $instance );
- $args(array) (required)
- Display arguments including 'before_title', 'after_title', 'before_widget', and 'after_widget'.
- $instance(array) (required)
- The settings for the particular instance of the widget.
Notes
- See: WP_Widget
WC_Widget_Brand_Thumbnails::widget() WC Widget Brand Thumbnails::widget code WC 10.4.3
public function widget( $args, $instance ) {
$instance = wp_parse_args(
$instance,
array(
'title' => '',
'columns' => 1,
'exclude' => '',
'orderby' => 'name',
'hide_empty' => 0,
'number' => '',
)
);
$exclude = array_map( 'intval', explode( ',', $instance['exclude'] ) );
$order = 'name' === $instance['orderby'] ? 'asc' : 'desc';
$brands = get_terms(
array(
'taxonomy' => 'product_brand',
'hide_empty' => $instance['hide_empty'],
'orderby' => $instance['orderby'],
'exclude' => $exclude,
'number' => $instance['number'],
'order' => $order,
)
);
if ( ! $brands ) {
return;
}
/**
* Filter the widget's title.
*
* @since 9.4.0
*
* @param string $title Widget title
* @param array $instance The settings for the particular instance of the widget.
* @param string $woo_widget_idbase The widget's id base.
*/
$title = apply_filters( 'widget_title', $instance['title'], $instance, $this->woo_widget_idbase );
echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput
if ( '' !== $title ) {
echo $args['before_title'] . $title . $args['after_title']; // phpcs:ignore WordPress.Security.EscapeOutput
}
wc_get_template(
'widgets/brand-thumbnails.php',
array(
'brands' => $brands,
'columns' => (int) $instance['columns'],
'fluid_columns' => ! empty( $instance['fluid_columns'] ) ? true : false,
),
'woocommerce',
WC()->plugin_path() . '/templates/brands/'
);
echo $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput
}