WC_Brands::woocommerce_brands_update_layered_nav_link
Injects Brands filters into layered nav links.
Method of the class: WC_Brands{}
Hooks from the method
Returns
String. Term html.
Usage
$WC_Brands = new WC_Brands(); $WC_Brands->woocommerce_brands_update_layered_nav_link( $term_html, $term, $link, $count );
- $term_html(string) (required)
- Original link html.
- $term(mixed) (required)
- Term that is currently added.
- $link(string) (required)
- Original layered nav item link.
- $count(number) (required)
- Number of items in that filter.
WC_Brands::woocommerce_brands_update_layered_nav_link() WC Brands::woocommerce brands update layered nav link code WC 10.3.5
public function woocommerce_brands_update_layered_nav_link( $term_html, $term, $link, $count ) {
if ( empty( $_GET['filter_product_brand'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
return $term_html;
}
$filter_product_brand = wc_clean( wp_unslash( $_GET['filter_product_brand'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
$current_attributes = array_map( 'intval', explode( ',', $filter_product_brand ) );
$current_values = ! empty( $current_attributes ) ? $current_attributes : array();
$link = add_query_arg(
array(
'filtering' => '1',
'filter_product_brand' => implode( ',', $current_values ),
),
wp_specialchars_decode( $link )
);
$term_html = '<a rel="nofollow" href="' . esc_url( $link ) . '">' . esc_html( $term->name ) . '</a>';
$term_html .= ' ' . apply_filters( 'woocommerce_layered_nav_count', '<span class="count">(' . absint( $count ) . ')</span>', $count, $term );
return $term_html;
}