Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/woocomme.../includes
File: class-wc-template-loader.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Template Loader
[2] Fix | Delete
*
[3] Fix | Delete
* @package WooCommerce\Classes
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
defined( 'ABSPATH' ) || exit;
[7] Fix | Delete
[8] Fix | Delete
/**
[9] Fix | Delete
* Template loader class.
[10] Fix | Delete
*/
[11] Fix | Delete
class WC_Template_Loader {
[12] Fix | Delete
[13] Fix | Delete
/**
[14] Fix | Delete
* Store the shop page ID.
[15] Fix | Delete
*
[16] Fix | Delete
* @var integer
[17] Fix | Delete
*/
[18] Fix | Delete
private static $shop_page_id = 0;
[19] Fix | Delete
[20] Fix | Delete
/**
[21] Fix | Delete
* Store whether we're processing a product inside the_content filter.
[22] Fix | Delete
*
[23] Fix | Delete
* @var boolean
[24] Fix | Delete
*/
[25] Fix | Delete
private static $in_content_filter = false;
[26] Fix | Delete
[27] Fix | Delete
/**
[28] Fix | Delete
* Is WooCommerce support defined?
[29] Fix | Delete
*
[30] Fix | Delete
* @var boolean
[31] Fix | Delete
*/
[32] Fix | Delete
private static $theme_support = false;
[33] Fix | Delete
[34] Fix | Delete
/**
[35] Fix | Delete
* Hook in methods.
[36] Fix | Delete
*/
[37] Fix | Delete
public static function init() {
[38] Fix | Delete
self::$theme_support = wc_current_theme_supports_woocommerce_or_fse();
[39] Fix | Delete
self::$shop_page_id = wc_get_page_id( 'shop' );
[40] Fix | Delete
[41] Fix | Delete
// Supported themes.
[42] Fix | Delete
if ( self::$theme_support ) {
[43] Fix | Delete
add_filter( 'template_include', array( __CLASS__, 'template_loader' ) );
[44] Fix | Delete
add_filter( 'comments_template', array( __CLASS__, 'comments_template_loader' ) );
[45] Fix | Delete
[46] Fix | Delete
// Loads gallery scripts on Product page for FSE themes.
[47] Fix | Delete
if ( wp_is_block_theme() ) {
[48] Fix | Delete
self::add_support_for_product_page_gallery();
[49] Fix | Delete
}
[50] Fix | Delete
} else {
[51] Fix | Delete
// Unsupported themes.
[52] Fix | Delete
add_action( 'template_redirect', array( __CLASS__, 'unsupported_theme_init' ) );
[53] Fix | Delete
}
[54] Fix | Delete
}
[55] Fix | Delete
[56] Fix | Delete
/**
[57] Fix | Delete
* Load a template.
[58] Fix | Delete
*
[59] Fix | Delete
* Handles template usage so that we can use our own templates instead of the theme's.
[60] Fix | Delete
*
[61] Fix | Delete
* Templates are in the 'templates' folder. WooCommerce looks for theme
[62] Fix | Delete
* overrides in /theme/woocommerce/ by default.
[63] Fix | Delete
*
[64] Fix | Delete
* For beginners, it also looks for a woocommerce.php template first. If the user adds
[65] Fix | Delete
* this to the theme (containing a woocommerce() inside) this will be used for all
[66] Fix | Delete
* WooCommerce templates.
[67] Fix | Delete
*
[68] Fix | Delete
* @param string $template Template to load.
[69] Fix | Delete
* @return string
[70] Fix | Delete
*/
[71] Fix | Delete
public static function template_loader( $template ) {
[72] Fix | Delete
if ( is_embed() ) {
[73] Fix | Delete
return $template;
[74] Fix | Delete
}
[75] Fix | Delete
[76] Fix | Delete
$default_file = self::get_template_loader_default_file();
[77] Fix | Delete
[78] Fix | Delete
if ( $default_file ) {
[79] Fix | Delete
/**
[80] Fix | Delete
* Filter hook to choose which files to find before WooCommerce does it's own logic.
[81] Fix | Delete
*
[82] Fix | Delete
* @since 3.0.0
[83] Fix | Delete
* @var array
[84] Fix | Delete
*/
[85] Fix | Delete
$search_files = self::get_template_loader_files( $default_file );
[86] Fix | Delete
$template = locate_template( $search_files );
[87] Fix | Delete
[88] Fix | Delete
if ( ! $template || WC_TEMPLATE_DEBUG_MODE ) {
[89] Fix | Delete
if ( false !== strpos( $default_file, 'product_cat' ) || false !== strpos( $default_file, 'product_tag' ) ) {
[90] Fix | Delete
$cs_template = str_replace( '_', '-', $default_file );
[91] Fix | Delete
$template = WC()->plugin_path() . '/templates/' . $cs_template;
[92] Fix | Delete
} else {
[93] Fix | Delete
$template = WC()->plugin_path() . '/templates/' . $default_file;
[94] Fix | Delete
}
[95] Fix | Delete
}
[96] Fix | Delete
}
[97] Fix | Delete
[98] Fix | Delete
return $template;
[99] Fix | Delete
}
[100] Fix | Delete
[101] Fix | Delete
/**
[102] Fix | Delete
* Checks whether a block template for a given taxonomy exists.
[103] Fix | Delete
*
[104] Fix | Delete
* **Note:** This checks both the `templates` and `block-templates` directories
[105] Fix | Delete
* as both conventions should be supported.
[106] Fix | Delete
*
[107] Fix | Delete
* @param object $taxonomy Object taxonomy to check.
[108] Fix | Delete
* @return boolean
[109] Fix | Delete
*/
[110] Fix | Delete
private static function taxonomy_has_block_template( $taxonomy ): bool {
[111] Fix | Delete
if ( taxonomy_is_product_attribute( $taxonomy->taxonomy ) ) {
[112] Fix | Delete
$template_name = 'taxonomy-product_attribute';
[113] Fix | Delete
} else {
[114] Fix | Delete
$template_name = 'taxonomy-' . $taxonomy->taxonomy;
[115] Fix | Delete
}
[116] Fix | Delete
[117] Fix | Delete
return self::has_block_template( $template_name );
[118] Fix | Delete
}
[119] Fix | Delete
[120] Fix | Delete
/**
[121] Fix | Delete
* Checks whether a block template with that name exists.
[122] Fix | Delete
*
[123] Fix | Delete
* **Note: ** This checks both the `templates` and `block-templates` directories
[124] Fix | Delete
* as both conventions should be supported.
[125] Fix | Delete
*
[126] Fix | Delete
* @since 5.5.0
[127] Fix | Delete
* @param string $template_name Template to check.
[128] Fix | Delete
* @return boolean
[129] Fix | Delete
*/
[130] Fix | Delete
private static function has_block_template( $template_name ) {
[131] Fix | Delete
if ( ! $template_name ) {
[132] Fix | Delete
return false;
[133] Fix | Delete
}
[134] Fix | Delete
[135] Fix | Delete
$has_template = false;
[136] Fix | Delete
$template_filename = $template_name . '.html';
[137] Fix | Delete
// Since Gutenberg 12.1.0, the conventions for block templates directories have changed,
[138] Fix | Delete
// we should check both these possible directories for backwards-compatibility.
[139] Fix | Delete
$possible_templates_dirs = array( 'templates', 'block-templates' );
[140] Fix | Delete
[141] Fix | Delete
// Combine the possible root directory names with either the template directory
[142] Fix | Delete
// or the stylesheet directory for child themes, getting all possible block templates
[143] Fix | Delete
// locations combinations.
[144] Fix | Delete
$filepath = DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . $template_filename;
[145] Fix | Delete
$legacy_filepath = DIRECTORY_SEPARATOR . 'block-templates' . DIRECTORY_SEPARATOR . $template_filename;
[146] Fix | Delete
$possible_paths = array(
[147] Fix | Delete
get_stylesheet_directory() . $filepath,
[148] Fix | Delete
get_stylesheet_directory() . $legacy_filepath,
[149] Fix | Delete
get_template_directory() . $filepath,
[150] Fix | Delete
get_template_directory() . $legacy_filepath,
[151] Fix | Delete
);
[152] Fix | Delete
[153] Fix | Delete
// Check the first matching one.
[154] Fix | Delete
foreach ( $possible_paths as $path ) {
[155] Fix | Delete
if ( is_readable( $path ) ) {
[156] Fix | Delete
$has_template = true;
[157] Fix | Delete
break;
[158] Fix | Delete
}
[159] Fix | Delete
}
[160] Fix | Delete
[161] Fix | Delete
/**
[162] Fix | Delete
* Filters the value of the result of the block template check.
[163] Fix | Delete
*
[164] Fix | Delete
* @since x.x.x
[165] Fix | Delete
*
[166] Fix | Delete
* @param boolean $has_template value to be filtered.
[167] Fix | Delete
* @param string $template_name The name of the template.
[168] Fix | Delete
*/
[169] Fix | Delete
return (bool) apply_filters( 'woocommerce_has_block_template', $has_template, $template_name );
[170] Fix | Delete
}
[171] Fix | Delete
[172] Fix | Delete
/**
[173] Fix | Delete
* Get the default filename for a template except if a block template with
[174] Fix | Delete
* the same name exists.
[175] Fix | Delete
*
[176] Fix | Delete
* @since 3.0.0
[177] Fix | Delete
* @since 5.5.0 If a block template with the same name exists, return an
[178] Fix | Delete
* empty string.
[179] Fix | Delete
* @since 6.3.0 It checks custom product taxonomies
[180] Fix | Delete
* @return string
[181] Fix | Delete
*/
[182] Fix | Delete
private static function get_template_loader_default_file() {
[183] Fix | Delete
if (
[184] Fix | Delete
is_singular( 'product' ) &&
[185] Fix | Delete
! self::has_block_template( 'single-product' )
[186] Fix | Delete
) {
[187] Fix | Delete
$default_file = 'single-product.php';
[188] Fix | Delete
} elseif ( is_product_taxonomy() ) {
[189] Fix | Delete
$object = get_queried_object();
[190] Fix | Delete
[191] Fix | Delete
if ( self::taxonomy_has_block_template( $object ) ) {
[192] Fix | Delete
$default_file = '';
[193] Fix | Delete
} elseif ( taxonomy_is_product_attribute( $object->taxonomy ) ) {
[194] Fix | Delete
$default_file = 'taxonomy-product-attribute.php';
[195] Fix | Delete
} elseif ( is_tax( 'product_cat' ) || is_tax( 'product_tag' ) ) {
[196] Fix | Delete
$default_file = 'taxonomy-' . $object->taxonomy . '.php';
[197] Fix | Delete
} elseif ( ! self::has_block_template( 'archive-product' ) ) {
[198] Fix | Delete
$default_file = 'archive-product.php';
[199] Fix | Delete
} else {
[200] Fix | Delete
$default_file = '';
[201] Fix | Delete
}
[202] Fix | Delete
} elseif (
[203] Fix | Delete
( is_post_type_archive( 'product' ) || is_page( wc_get_page_id( 'shop' ) ) ) &&
[204] Fix | Delete
! self::has_block_template( 'archive-product' )
[205] Fix | Delete
) {
[206] Fix | Delete
$default_file = self::$theme_support ? 'archive-product.php' : '';
[207] Fix | Delete
} else {
[208] Fix | Delete
$default_file = '';
[209] Fix | Delete
}
[210] Fix | Delete
return $default_file;
[211] Fix | Delete
}
[212] Fix | Delete
[213] Fix | Delete
/**
[214] Fix | Delete
* Get an array of filenames to search for a given template.
[215] Fix | Delete
*
[216] Fix | Delete
* @since 3.0.0
[217] Fix | Delete
* @param string $default_file The default file name.
[218] Fix | Delete
* @return string[]
[219] Fix | Delete
*/
[220] Fix | Delete
private static function get_template_loader_files( $default_file ) {
[221] Fix | Delete
$templates = apply_filters( 'woocommerce_template_loader_files', array(), $default_file );
[222] Fix | Delete
$templates[] = 'woocommerce.php';
[223] Fix | Delete
[224] Fix | Delete
if ( is_page_template() ) {
[225] Fix | Delete
$page_template = get_page_template_slug();
[226] Fix | Delete
[227] Fix | Delete
if ( $page_template ) {
[228] Fix | Delete
$validated_file = validate_file( $page_template );
[229] Fix | Delete
if ( 0 === $validated_file ) {
[230] Fix | Delete
$templates[] = $page_template;
[231] Fix | Delete
} else {
[232] Fix | Delete
error_log( "WooCommerce: Unable to validate template path: \"$page_template\". Error Code: $validated_file." ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
[233] Fix | Delete
}
[234] Fix | Delete
}
[235] Fix | Delete
}
[236] Fix | Delete
[237] Fix | Delete
if ( is_singular( 'product' ) ) {
[238] Fix | Delete
$object = get_queried_object();
[239] Fix | Delete
$name_decoded = urldecode( $object->post_name );
[240] Fix | Delete
if ( $name_decoded !== $object->post_name ) {
[241] Fix | Delete
$templates[] = "single-product-{$name_decoded}.php";
[242] Fix | Delete
}
[243] Fix | Delete
$templates[] = "single-product-{$object->post_name}.php";
[244] Fix | Delete
}
[245] Fix | Delete
[246] Fix | Delete
if ( is_product_taxonomy() ) {
[247] Fix | Delete
$object = get_queried_object();
[248] Fix | Delete
[249] Fix | Delete
$templates[] = 'taxonomy-' . $object->taxonomy . '-' . $object->slug . '.php';
[250] Fix | Delete
$templates[] = WC()->template_path() . 'taxonomy-' . $object->taxonomy . '-' . $object->slug . '.php';
[251] Fix | Delete
$templates[] = 'taxonomy-' . $object->taxonomy . '.php';
[252] Fix | Delete
$templates[] = WC()->template_path() . 'taxonomy-' . $object->taxonomy . '.php';
[253] Fix | Delete
[254] Fix | Delete
if ( taxonomy_is_product_attribute( $object->taxonomy ) ) {
[255] Fix | Delete
$templates[] = 'taxonomy-product_attribute.php';
[256] Fix | Delete
$templates[] = WC()->template_path() . 'taxonomy-product_attribute.php';
[257] Fix | Delete
$templates[] = $default_file;
[258] Fix | Delete
}
[259] Fix | Delete
[260] Fix | Delete
if ( is_tax( 'product_cat' ) || is_tax( 'product_tag' ) ) {
[261] Fix | Delete
$cs_taxonomy = str_replace( '_', '-', $object->taxonomy );
[262] Fix | Delete
$cs_default = str_replace( '_', '-', $default_file );
[263] Fix | Delete
$templates[] = 'taxonomy-' . $object->taxonomy . '-' . $object->slug . '.php';
[264] Fix | Delete
$templates[] = WC()->template_path() . 'taxonomy-' . $cs_taxonomy . '-' . $object->slug . '.php';
[265] Fix | Delete
$templates[] = 'taxonomy-' . $object->taxonomy . '.php';
[266] Fix | Delete
$templates[] = WC()->template_path() . 'taxonomy-' . $cs_taxonomy . '.php';
[267] Fix | Delete
$templates[] = $cs_default;
[268] Fix | Delete
}
[269] Fix | Delete
}
[270] Fix | Delete
[271] Fix | Delete
$templates[] = $default_file;
[272] Fix | Delete
if ( isset( $cs_default ) ) {
[273] Fix | Delete
$templates[] = WC()->template_path() . $cs_default;
[274] Fix | Delete
}
[275] Fix | Delete
$templates[] = WC()->template_path() . $default_file;
[276] Fix | Delete
[277] Fix | Delete
return array_unique( $templates );
[278] Fix | Delete
}
[279] Fix | Delete
[280] Fix | Delete
/**
[281] Fix | Delete
* Load comments template.
[282] Fix | Delete
*
[283] Fix | Delete
* @param string $template template to load.
[284] Fix | Delete
* @return string
[285] Fix | Delete
*/
[286] Fix | Delete
public static function comments_template_loader( $template ) {
[287] Fix | Delete
if ( get_post_type() !== 'product' ) {
[288] Fix | Delete
return $template;
[289] Fix | Delete
}
[290] Fix | Delete
[291] Fix | Delete
$check_dirs = array(
[292] Fix | Delete
trailingslashit( get_stylesheet_directory() ) . WC()->template_path(),
[293] Fix | Delete
trailingslashit( get_template_directory() ) . WC()->template_path(),
[294] Fix | Delete
trailingslashit( get_stylesheet_directory() ),
[295] Fix | Delete
trailingslashit( get_template_directory() ),
[296] Fix | Delete
trailingslashit( WC()->plugin_path() ) . 'templates/',
[297] Fix | Delete
);
[298] Fix | Delete
[299] Fix | Delete
if ( WC_TEMPLATE_DEBUG_MODE ) {
[300] Fix | Delete
$check_dirs = array( array_pop( $check_dirs ) );
[301] Fix | Delete
}
[302] Fix | Delete
[303] Fix | Delete
foreach ( $check_dirs as $dir ) {
[304] Fix | Delete
if ( file_exists( trailingslashit( $dir ) . 'single-product-reviews.php' ) ) {
[305] Fix | Delete
return trailingslashit( $dir ) . 'single-product-reviews.php';
[306] Fix | Delete
}
[307] Fix | Delete
}
[308] Fix | Delete
}
[309] Fix | Delete
[310] Fix | Delete
/**
[311] Fix | Delete
* Unsupported theme compatibility methods.
[312] Fix | Delete
*/
[313] Fix | Delete
[314] Fix | Delete
/**
[315] Fix | Delete
* Hook in methods to enhance the unsupported theme experience on pages.
[316] Fix | Delete
*
[317] Fix | Delete
* @since 3.3.0
[318] Fix | Delete
*/
[319] Fix | Delete
public static function unsupported_theme_init() {
[320] Fix | Delete
if ( 0 < self::$shop_page_id ) {
[321] Fix | Delete
if ( is_product_taxonomy() ) {
[322] Fix | Delete
self::unsupported_theme_tax_archive_init();
[323] Fix | Delete
} elseif ( is_product() ) {
[324] Fix | Delete
self::unsupported_theme_product_page_init();
[325] Fix | Delete
} else {
[326] Fix | Delete
self::unsupported_theme_shop_page_init();
[327] Fix | Delete
}
[328] Fix | Delete
}
[329] Fix | Delete
}
[330] Fix | Delete
[331] Fix | Delete
/**
[332] Fix | Delete
* Hook in methods to enhance the unsupported theme experience on the Shop page.
[333] Fix | Delete
*
[334] Fix | Delete
* @since 3.3.0
[335] Fix | Delete
*/
[336] Fix | Delete
private static function unsupported_theme_shop_page_init() {
[337] Fix | Delete
add_filter( 'the_content', array( __CLASS__, 'unsupported_theme_shop_content_filter' ), 10 );
[338] Fix | Delete
add_filter( 'the_title', array( __CLASS__, 'unsupported_theme_title_filter' ), 10, 2 );
[339] Fix | Delete
add_filter( 'comments_number', array( __CLASS__, 'unsupported_theme_comments_number_filter' ) );
[340] Fix | Delete
}
[341] Fix | Delete
[342] Fix | Delete
/**
[343] Fix | Delete
* Hook in methods to enhance the unsupported theme experience on Product pages.
[344] Fix | Delete
*
[345] Fix | Delete
* @since 3.3.0
[346] Fix | Delete
*/
[347] Fix | Delete
private static function unsupported_theme_product_page_init() {
[348] Fix | Delete
add_filter( 'the_content', array( __CLASS__, 'unsupported_theme_product_content_filter' ), 10 );
[349] Fix | Delete
add_filter( 'post_thumbnail_html', array( __CLASS__, 'unsupported_theme_single_featured_image_filter' ) );
[350] Fix | Delete
add_filter( 'woocommerce_product_tabs', array( __CLASS__, 'unsupported_theme_remove_review_tab' ) );
[351] Fix | Delete
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
[352] Fix | Delete
remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 );
[353] Fix | Delete
self::add_support_for_product_page_gallery();
[354] Fix | Delete
}
[355] Fix | Delete
[356] Fix | Delete
/**
[357] Fix | Delete
* Add theme support for Product page gallery.
[358] Fix | Delete
*
[359] Fix | Delete
* @since x.x.x
[360] Fix | Delete
*/
[361] Fix | Delete
private static function add_support_for_product_page_gallery() {
[362] Fix | Delete
add_theme_support( 'wc-product-gallery-zoom' );
[363] Fix | Delete
add_theme_support( 'wc-product-gallery-lightbox' );
[364] Fix | Delete
add_theme_support( 'wc-product-gallery-slider' );
[365] Fix | Delete
}
[366] Fix | Delete
[367] Fix | Delete
/**
[368] Fix | Delete
* Enhance the unsupported theme experience on Product Category and Attribute pages by rendering
[369] Fix | Delete
* those pages using the single template and shortcode-based content. To do this we make a dummy
[370] Fix | Delete
* post and set a shortcode as the post content. This approach is adapted from bbPress.
[371] Fix | Delete
*
[372] Fix | Delete
* @since 3.3.0
[373] Fix | Delete
*/
[374] Fix | Delete
private static function unsupported_theme_tax_archive_init() {
[375] Fix | Delete
global $wp_query, $post;
[376] Fix | Delete
[377] Fix | Delete
$queried_object = get_queried_object();
[378] Fix | Delete
$args = self::get_current_shop_view_args();
[379] Fix | Delete
$shortcode_args = array(
[380] Fix | Delete
'page' => $args->page,
[381] Fix | Delete
'columns' => $args->columns,
[382] Fix | Delete
'rows' => $args->rows,
[383] Fix | Delete
'orderby' => '',
[384] Fix | Delete
'order' => '',
[385] Fix | Delete
'paginate' => true,
[386] Fix | Delete
'cache' => false,
[387] Fix | Delete
);
[388] Fix | Delete
[389] Fix | Delete
if ( is_product_category() ) {
[390] Fix | Delete
$shortcode_args['category'] = sanitize_title( $queried_object->slug );
[391] Fix | Delete
} elseif ( taxonomy_is_product_attribute( $queried_object->taxonomy ) ) {
[392] Fix | Delete
$shortcode_args['attribute'] = sanitize_title( $queried_object->taxonomy );
[393] Fix | Delete
$shortcode_args['terms'] = sanitize_title( $queried_object->slug );
[394] Fix | Delete
} elseif ( is_product_tag() ) {
[395] Fix | Delete
$shortcode_args['tag'] = sanitize_title( $queried_object->slug );
[396] Fix | Delete
} else {
[397] Fix | Delete
// Default theme archive for all other taxonomies.
[398] Fix | Delete
return;
[399] Fix | Delete
}
[400] Fix | Delete
[401] Fix | Delete
// Description handling.
[402] Fix | Delete
if ( ! empty( $queried_object->description ) && ( empty( $_GET['product-page'] ) || 1 === absint( $_GET['product-page'] ) ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
[403] Fix | Delete
$prefix = '<div class="term-description">' . wc_format_content( wp_kses_post( $queried_object->description ) ) . '</div>';
[404] Fix | Delete
} else {
[405] Fix | Delete
$prefix = '';
[406] Fix | Delete
}
[407] Fix | Delete
[408] Fix | Delete
add_filter( 'woocommerce_shortcode_products_query', array( __CLASS__, 'unsupported_archive_layered_nav_compatibility' ) );
[409] Fix | Delete
$shortcode = new WC_Shortcode_Products( $shortcode_args );
[410] Fix | Delete
remove_filter( 'woocommerce_shortcode_products_query', array( __CLASS__, 'unsupported_archive_layered_nav_compatibility' ) );
[411] Fix | Delete
$shop_page = get_post( self::$shop_page_id );
[412] Fix | Delete
[413] Fix | Delete
$dummy_post_properties = array(
[414] Fix | Delete
'ID' => 0,
[415] Fix | Delete
'post_status' => 'publish',
[416] Fix | Delete
'post_author' => $shop_page->post_author,
[417] Fix | Delete
'post_parent' => 0,
[418] Fix | Delete
'post_type' => 'page',
[419] Fix | Delete
'post_date' => $shop_page->post_date,
[420] Fix | Delete
'post_date_gmt' => $shop_page->post_date_gmt,
[421] Fix | Delete
'post_modified' => $shop_page->post_modified,
[422] Fix | Delete
'post_modified_gmt' => $shop_page->post_modified_gmt,
[423] Fix | Delete
'post_content' => $prefix . $shortcode->get_content(),
[424] Fix | Delete
'post_title' => wc_clean( $queried_object->name ),
[425] Fix | Delete
'post_excerpt' => '',
[426] Fix | Delete
'post_content_filtered' => '',
[427] Fix | Delete
'post_mime_type' => '',
[428] Fix | Delete
'post_password' => '',
[429] Fix | Delete
'post_name' => $queried_object->slug,
[430] Fix | Delete
'guid' => '',
[431] Fix | Delete
'menu_order' => 0,
[432] Fix | Delete
'pinged' => '',
[433] Fix | Delete
'to_ping' => '',
[434] Fix | Delete
'ping_status' => '',
[435] Fix | Delete
'comment_status' => 'closed',
[436] Fix | Delete
'comment_count' => 0,
[437] Fix | Delete
'filter' => 'raw',
[438] Fix | Delete
);
[439] Fix | Delete
[440] Fix | Delete
// Set the $post global.
[441] Fix | Delete
$post = new WP_Post( (object) $dummy_post_properties ); // @codingStandardsIgnoreLine.
[442] Fix | Delete
[443] Fix | Delete
// Copy the new post global into the main $wp_query.
[444] Fix | Delete
$wp_query->post = $post;
[445] Fix | Delete
$wp_query->posts = array( $post );
[446] Fix | Delete
[447] Fix | Delete
// Prevent comments form from appearing.
[448] Fix | Delete
$wp_query->post_count = 1;
[449] Fix | Delete
$wp_query->is_404 = false;
[450] Fix | Delete
$wp_query->is_page = true;
[451] Fix | Delete
$wp_query->is_single = true;
[452] Fix | Delete
$wp_query->is_archive = false;
[453] Fix | Delete
$wp_query->is_tax = true;
[454] Fix | Delete
$wp_query->max_num_pages = 0;
[455] Fix | Delete
[456] Fix | Delete
// Prepare everything for rendering.
[457] Fix | Delete
setup_postdata( $post );
[458] Fix | Delete
remove_all_filters( 'the_content' );
[459] Fix | Delete
remove_all_filters( 'the_excerpt' );
[460] Fix | Delete
add_filter( 'template_include', array( __CLASS__, 'force_single_template_filter' ) );
[461] Fix | Delete
}
[462] Fix | Delete
[463] Fix | Delete
/**
[464] Fix | Delete
* Add layered nav args to WP_Query args generated by the 'products' shortcode.
[465] Fix | Delete
*
[466] Fix | Delete
* @since 3.3.4
[467] Fix | Delete
* @param array $query WP_Query args.
[468] Fix | Delete
* @return array
[469] Fix | Delete
*/
[470] Fix | Delete
public static function unsupported_archive_layered_nav_compatibility( $query ) {
[471] Fix | Delete
foreach ( WC()->query->get_layered_nav_chosen_attributes() as $taxonomy => $data ) {
[472] Fix | Delete
$query['tax_query'][] = array(
[473] Fix | Delete
'taxonomy' => $taxonomy,
[474] Fix | Delete
'field' => 'slug',
[475] Fix | Delete
'terms' => $data['terms'],
[476] Fix | Delete
'operator' => 'and' === $data['query_type'] ? 'AND' : 'IN',
[477] Fix | Delete
'include_children' => false,
[478] Fix | Delete
);
[479] Fix | Delete
}
[480] Fix | Delete
return $query;
[481] Fix | Delete
}
[482] Fix | Delete
[483] Fix | Delete
/**
[484] Fix | Delete
* Force the loading of one of the single templates instead of whatever template was about to be loaded.
[485] Fix | Delete
*
[486] Fix | Delete
* @since 3.3.0
[487] Fix | Delete
* @param string $template Path to template.
[488] Fix | Delete
* @return string
[489] Fix | Delete
*/
[490] Fix | Delete
public static function force_single_template_filter( $template ) {
[491] Fix | Delete
$possible_templates = array(
[492] Fix | Delete
'page',
[493] Fix | Delete
'single',
[494] Fix | Delete
'singular',
[495] Fix | Delete
'index',
[496] Fix | Delete
);
[497] Fix | Delete
[498] Fix | Delete
foreach ( $possible_templates as $possible_template ) {
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function