WC_Template_Loader::get_template_loader_default_file
Get the default filename for a template except if a block template with the same name exists.
Метод класса: WC_Template_Loader{}
Хуков нет.
Возвращает
Строку.
Использование
$result = WC_Template_Loader::get_template_loader_default_file();
Список изменений
| С версии 3.0.0 | Введена. |
| С версии 5.5.0 | If a block template with the same name exists, return an empty string. |
| С версии 6.3.0 | It checks custom product taxonomies |
Код WC_Template_Loader::get_template_loader_default_file() WC Template Loader::get template loader default file WC 10.8.1
private static function get_template_loader_default_file() {
if (
is_singular( 'product' ) &&
! self::has_block_template( 'single-product' )
) {
$default_file = 'single-product.php';
} elseif ( is_product_taxonomy() ) {
$object = get_queried_object();
if ( self::taxonomy_has_block_template( $object ) ) {
$default_file = '';
} elseif ( taxonomy_is_product_attribute( $object->taxonomy ) ) {
$default_file = 'taxonomy-product-attribute.php';
} elseif ( is_tax( 'product_cat' ) || is_tax( 'product_tag' ) ) {
$default_file = 'taxonomy-' . $object->taxonomy . '.php';
} elseif ( ! self::has_block_template( 'archive-product' ) ) {
$default_file = 'archive-product.php';
} else {
$default_file = '';
}
} elseif (
( is_post_type_archive( 'product' ) || is_page( wc_get_page_id( 'shop' ) ) ) &&
! self::has_block_template( 'archive-product' )
) {
$default_file = self::$theme_support ? 'archive-product.php' : '';
} else {
$default_file = '';
}
return $default_file;
}