WC_Brands::template_loader
- Handles template usage so that we can use our own templates instead of the themes.
- Templates are in the 'templates' folder. woocommerce looks for theme overides in /theme/woocommerce/ by default
- For beginners, it also looks for a woocommerce.php template first. If the user adds this to the theme (containing a woocommerce() inside) this will be used for all woocommerce templates.
- @param string $template Template.
Метод класса: WC_Brands{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$WC_Brands = new WC_Brands(); $WC_Brands->template_loader( $template );
- $template(обязательный)
- .
Код WC_Brands::template_loader() WC Brands::template loader WC 10.4.3
public function template_loader( $template ) {
$find = array( 'woocommerce.php' );
$file = '';
if ( is_tax( 'product_brand' ) ) {
$term = get_queried_object();
$file = 'taxonomy-' . $term->taxonomy . '.php';
$find[] = 'taxonomy-' . $term->taxonomy . '-' . $term->slug . '.php';
$find[] = $this->template_url . 'taxonomy-' . $term->taxonomy . '-' . $term->slug . '.php';
$find[] = $file;
$find[] = $this->template_url . $file;
}
if ( $file ) {
$template = locate_template( $find );
if ( ! $template ) {
$template = WC()->plugin_path() . '/templates/brands/' . $file;
}
}
return $template;
}