plugin_path() . '/templates/' . $default_file; } } return $template; } /** * Get the default filename for a template. * * @since 3.0.0 * @return string */ private static function get_template_loader_default_file() { if ( is_singular( 'product' ) ) { $default_file = 'single-product.php'; } elseif ( is_product_taxonomy() ) { $term = get_queried_object(); if ( is_tax( 'product_cat' ) || is_tax( 'product_tag' ) ) { $default_file = 'taxonomy-' . $term->taxonomy . '.php'; } else { $default_file = 'archive-product.php'; } } elseif ( is_post_type_archive( 'product' ) || is_page( wc_get_page_id( 'shop' ) ) ) { $default_file = 'archive-product.php'; } else { $default_file = ''; } return $default_file; } /** * Get an array of filenames to search for a given template. * * @since 3.0.0 * @param string $default_file The default file name. * @return string[] */ private static function get_template_loader_files( $default_file ) { $search_files = apply_filters( 'woocommerce_template_loader_files', array(), $default_file ); $search_files[] = 'woocommerce.php'; if ( is_page_template() ) { $search_files[] = get_page_template_slug(); } if ( is_product_taxonomy() ) { $term = get_queried_object(); $search_files[] = 'taxonomy-' . $term->taxonomy . '-' . $term->slug . '.php'; $search_files[] = WC()->template_path() . 'taxonomy-' . $term->taxonomy . '-' . $term->slug . '.php'; $search_files[] = 'taxonomy-' . $term->taxonomy . '.php'; $search_files[] = WC()->template_path() . 'taxonomy-' . $term->taxonomy . '.php'; } $search_files[] = $default_file; $search_files[] = WC()->template_path() . $default_file; return array_unique( $search_files ); } /** * Load comments template. * * @param mixed $template * @return string */ public static function comments_template_loader( $template ) { if ( get_post_type() !== 'product' ) { return $template; } $check_dirs = array( trailingslashit( get_stylesheet_directory() ) . WC()->template_path(), trailingslashit( get_template_directory() ) . WC()->template_path(), trailingslashit( get_stylesheet_directory() ), trailingslashit( get_template_directory() ), trailingslashit( WC()->plugin_path() ) . 'templates/', ); if ( WC_TEMPLATE_DEBUG_MODE ) { $check_dirs = array( array_pop( $check_dirs ) ); } foreach ( $check_dirs as $dir ) { if ( file_exists( trailingslashit( $dir ) . 'single-product-reviews.php' ) ) { return trailingslashit( $dir ) . 'single-product-reviews.php'; } } } } WC_Template_Loader::init();