WC_Brands::should_load_brands_styles
Determines if brands styles should be loaded on the current page.
Method of the class: WC_Brands{}
Hooks from the method
Returns
true|false.
Usage
// private - for code of main (parent) class only $result = $this->should_load_brands_styles();
Changelog
| Since 10.4.0 | Introduced. |
WC_Brands::should_load_brands_styles() WC Brands::should load brands styles code WC 10.4.3
private function should_load_brands_styles() {
global $post;
// Should load on brand taxonomy archive pages.
if ( is_tax( 'product_brand' ) ) {
return true;
}
// Should load on single product pages that have brands assigned.
if ( is_singular( 'product' ) && has_term( '', 'product_brand' ) ) {
return true;
}
// Check if any brand shortcodes are present in the content.
if ( $post && ! empty( $post->post_content ) ) {
$brand_shortcodes = array(
'brand_products',
'product_brand',
'product_brand_list',
'product_brand_thumbnails',
'product_brand_thumbnails_description',
);
foreach ( $brand_shortcodes as $shortcode ) {
if ( has_shortcode( $post->post_content, $shortcode ) ) {
return true;
}
}
}
// Check if any brand widgets are active.
if ( is_active_widget( false, false, 'wc_brands_brand_description' ) ||
is_active_widget( false, false, 'woocommerce_brand_nav' ) ||
is_active_widget( false, false, 'wc_brands_brand_thumbnails' ) ) {
return true;
}
/**
* Filter whether brands styles should be loaded.
*
* @since 10.4.0
*
* @param bool $should_load Whether to load brands styles.
*/
return apply_filters( 'woocommerce_should_load_brands_styles', false );
}