Current Path: > home > codekrsu > > cuddlebuds.lk > wp-content > > plugins > woocommerce > includes
Operation : Linux premium131.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64 Software : Apache Server IP : 162.0.232.56 | Your IP: 216.73.216.111 Domains : 1034 Domain(s) Permission : [ 0755 ]
Name | Type | Size | Last Modified | Actions |
---|---|---|---|---|
abstracts | Directory | - | - | |
admin | Directory | - | - | |
blocks | Directory | - | - | |
cli | Directory | - | - | |
customizer | Directory | - | - | |
data-stores | Directory | - | - | |
emails | Directory | - | - | |
export | Directory | - | - | |
gateways | Directory | - | - | |
import | Directory | - | - | |
integrations | Directory | - | - | |
interfaces | Directory | - | - | |
legacy | Directory | - | - | |
libraries | Directory | - | - | |
log-handlers | Directory | - | - | |
payment-tokens | Directory | - | - | |
product-usage | Directory | - | - | |
queue | Directory | - | - | |
react-admin | Directory | - | - | |
rest-api | Directory | - | - | |
shipping | Directory | - | - | |
shortcodes | Directory | - | - | |
theme-support | Directory | - | - | |
tracks | Directory | - | - | |
traits | Directory | - | - | |
walkers | Directory | - | - | |
wccom-site | Directory | - | - | |
widgets | Directory | - | - | |
class-wc-ajax.php | File | 122567 bytes | June 23 2025 19:46:28. | |
class-wc-auth.php | File | 12995 bytes | July 30 2024 19:31:16. | |
class-wc-autoloader.php | File | 3401 bytes | September 23 2024 20:44:04. | |
class-wc-background-emailer.php | File | 4685 bytes | August 20 2020 23:18:50. | |
class-wc-background-updater.php | File | 3535 bytes | August 20 2020 23:18:50. | |
class-wc-brands-brand-settings-manager.php | File | 1826 bytes | September 23 2024 20:44:04. | |
class-wc-brands-coupons.php | File | 7059 bytes | January 21 2025 18:53:44. | |
class-wc-brands.php | File | 34095 bytes | July 07 2025 13:23:42. | |
class-wc-breadcrumb.php | File | 9722 bytes | October 21 2020 03:38:50. | |
class-wc-cache-helper.php | File | 11438 bytes | August 27 2024 23:04:44. | |
class-wc-cart-fees.php | File | 3448 bytes | September 26 2023 21:42:36. | |
class-wc-cart-session.php | File | 20140 bytes | June 23 2025 19:46:28. | |
class-wc-cart-totals.php | File | 29166 bytes | July 07 2025 13:23:42. | |
class-wc-cart.php | File | 72605 bytes | June 30 2025 17:49:22. | |
class-wc-checkout.php | File | 51349 bytes | May 12 2025 21:07:28. | |
class-wc-cli.php | File | 2935 bytes | May 12 2025 21:07:28. | |
class-wc-comments.php | File | 23066 bytes | June 23 2025 19:46:28. | |
class-wc-countries.php | File | 50342 bytes | May 12 2025 21:07:28. | |
class-wc-coupon.php | File | 40825 bytes | June 23 2025 19:46:28. | |
class-wc-customer-download-log.php | File | 3452 bytes | August 20 2020 23:18:50. | |
class-wc-customer-download.php | File | 10587 bytes | July 30 2024 19:31:16. | |
class-wc-customer.php | File | 33300 bytes | June 23 2025 19:46:28. | |
class-wc-data-exception.php | File | 1321 bytes | May 23 2018 19:30:10. | |
class-wc-data-store.php | File | 6752 bytes | October 19 2022 00:34:38. | |
class-wc-datetime.php | File | 2310 bytes | April 20 2022 06:50:54. | |
class-wc-deprecated-action-hooks.php | File | 6746 bytes | February 27 2024 18:59:46. | |
class-wc-deprecated-filter-hooks.php | File | 7518 bytes | February 22 2023 07:17:34. | |
class-wc-discounts.php | File | 37476 bytes | June 23 2025 19:46:28. | |
class-wc-download-handler.php | File | 29053 bytes | December 18 2024 22:19:16. | |
class-wc-emails.php | File | 34457 bytes | June 23 2025 19:46:28. | |
class-wc-embed.php | File | 4342 bytes | January 21 2025 18:53:44. | |
class-wc-form-handler.php | File | 46932 bytes | June 23 2025 19:46:28. | |
class-wc-frontend-scripts.php | File | 28511 bytes | May 12 2025 21:07:28. | |
class-wc-geo-ip.php | File | 31139 bytes | June 23 2025 19:46:28. | |
class-wc-geolite-integration.php | File | 2036 bytes | January 16 2020 06:10:02. | |
class-wc-geolocation.php | File | 11594 bytes | May 12 2025 21:07:28. | |
class-wc-https.php | File | 4439 bytes | June 20 2023 23:45:50. | |
class-wc-install.php | File | 109669 bytes | June 23 2025 19:46:28. | |
class-wc-integrations.php | File | 1308 bytes | August 20 2020 23:18:50. | |
class-wc-log-levels.php | File | 3992 bytes | January 30 2024 23:24:56. | |
class-wc-logger.php | File | 9601 bytes | May 12 2025 21:07:28. | |
class-wc-meta-data.php | File | 2260 bytes | April 20 2022 06:50:54. | |
class-wc-order-factory.php | File | 8728 bytes | April 30 2024 19:35:34. | |
class-wc-order-item-coupon.php | File | 4175 bytes | December 22 2021 00:24:58. | |
class-wc-order-item-fee.php | File | 9431 bytes | March 03 2025 22:28:12. | |
class-wc-order-item-meta.php | File | 5942 bytes | December 22 2021 00:24:58. | |
class-wc-order-item-product.php | File | 16221 bytes | May 12 2025 21:07:28. | |
class-wc-order-item-shipping.php | File | 9013 bytes | May 12 2025 21:07:28. | |
class-wc-order-item-tax.php | File | 6644 bytes | December 22 2021 00:24:58. | |
class-wc-order-item.php | File | 18990 bytes | May 12 2025 21:07:28. | |
class-wc-order-query.php | File | 2615 bytes | July 28 2021 04:11:34. | |
class-wc-order-refund.php | File | 6135 bytes | May 12 2025 21:07:28. | |
class-wc-order.php | File | 76529 bytes | June 23 2025 19:46:28. | |
class-wc-payment-gateways.php | File | 16110 bytes | June 30 2025 17:49:22. | |
class-wc-payment-tokens.php | File | 6390 bytes | November 23 2022 05:58:58. | |
class-wc-post-data.php | File | 22246 bytes | March 03 2025 22:28:12. | |
class-wc-post-types.php | File | 32771 bytes | May 12 2025 21:07:28. | |
class-wc-privacy-background-process.php | File | 1833 bytes | March 03 2025 22:28:12. | |
class-wc-privacy-erasers.php | File | 13935 bytes | September 23 2024 20:44:04. | |
class-wc-privacy-exporters.php | File | 15044 bytes | July 28 2021 04:11:34. | |
class-wc-privacy.php | File | 17629 bytes | June 23 2025 19:46:28. | |
class-wc-product-attribute.php | File | 7137 bytes | January 19 2022 02:24:34. | |
class-wc-product-download.php | File | 12547 bytes | April 10 2024 16:54:10. | |
class-wc-product-external.php | File | 5104 bytes | March 03 2025 22:28:12. | |
class-wc-product-factory.php | File | 3974 bytes | January 21 2025 18:53:44. | |
class-wc-product-grouped.php | File | 5737 bytes | May 12 2025 21:07:28. | |
class-wc-product-query.php | File | 2332 bytes | January 21 2025 18:53:44. | |
class-wc-product-simple.php | File | 2762 bytes | January 21 2025 18:53:44. | |
class-wc-product-variable.php | File | 25166 bytes | June 02 2025 15:59:32. | |
class-wc-product-variation.php | File | 20661 bytes | May 12 2025 21:07:28. | |
class-wc-query.php | File | 34161 bytes | May 12 2025 21:07:28. | |
class-wc-rate-limiter.php | File | 4100 bytes | December 01 2021 04:23:30. | |
class-wc-regenerate-images-request.php | File | 7923 bytes | January 25 2023 03:19:12. | |
class-wc-regenerate-images.php | File | 15806 bytes | June 25 2024 21:17:40. | |
class-wc-register-wp-admin-settings.php | File | 5171 bytes | June 22 2021 15:24:06. | |
class-wc-rest-authentication.php | File | 22068 bytes | June 25 2024 21:17:40. | |
class-wc-rest-exception.php | File | 276 bytes | September 23 2020 01:16:50. | |
class-wc-session-handler.php | File | 21358 bytes | July 14 2025 13:28:08. | |
class-wc-shipping-rate.php | File | 9566 bytes | June 23 2025 19:46:28. | |
class-wc-shipping-zone.php | File | 13392 bytes | September 23 2020 01:16:50. | |
class-wc-shipping-zones.php | File | 4106 bytes | August 20 2020 23:18:50. | |
class-wc-shipping.php | File | 13160 bytes | May 12 2025 21:07:28. | |
class-wc-shortcodes.php | File | 19274 bytes | January 21 2025 18:53:44. | |
class-wc-structured-data.php | File | 24367 bytes | March 03 2025 22:28:12. | |
class-wc-tax.php | File | 37969 bytes | June 20 2023 23:45:50. | |
class-wc-template-loader.php | File | 21893 bytes | June 09 2025 15:55:46. | |
class-wc-tracker.php | File | 50557 bytes | June 23 2025 19:46:28. | |
class-wc-validation.php | File | 5929 bytes | May 28 2024 14:28:20. | |
class-wc-webhook.php | File | 30111 bytes | December 18 2024 22:19:16. | |
class-woocommerce.php | File | 51138 bytes | July 23 2025 12:38:10. | |
wc-account-functions.php | File | 14449 bytes | June 23 2025 19:46:28. | |
wc-attribute-functions.php | File | 21687 bytes | January 21 2025 18:53:44. | |
wc-brands-functions.php | File | 4270 bytes | September 23 2024 20:44:04. | |
wc-cart-functions.php | File | 21080 bytes | June 30 2025 17:49:22. | |
wc-conditional-functions.php | File | 14916 bytes | June 23 2025 19:46:28. | |
wc-core-functions.php | File | 88756 bytes | June 30 2025 17:49:22. | |
wc-coupon-functions.php | File | 3169 bytes | May 12 2025 21:07:28. | |
wc-deprecated-functions.php | File | 39030 bytes | May 12 2025 21:07:28. | |
wc-formatting-functions.php | File | 50031 bytes | June 30 2025 17:49:22. | |
wc-notice-functions.php | File | 8277 bytes | June 23 2025 19:46:28. | |
wc-order-functions.php | File | 41609 bytes | June 23 2025 19:46:28. | |
wc-order-item-functions.php | File | 5153 bytes | January 25 2023 03:19:12. | |
wc-order-step-logger-functions.php | File | 5135 bytes | May 12 2025 21:07:28. | |
wc-page-functions.php | File | 9657 bytes | September 23 2024 20:44:04. | |
wc-product-functions.php | File | 59920 bytes | June 23 2025 19:46:28. | |
wc-rest-functions.php | File | 14176 bytes | June 23 2025 19:46:28. | |
wc-stock-functions.php | File | 17544 bytes | January 21 2025 18:53:44. | |
wc-template-functions.php | File | 135937 bytes | June 23 2025 19:46:28. | |
wc-template-hooks.php | File | 12957 bytes | May 12 2025 21:07:28. | |
wc-term-functions.php | File | 24381 bytes | June 16 2025 19:21:28. | |
wc-update-functions.php | File | 95221 bytes | June 23 2025 19:46:28. | |
wc-user-functions.php | File | 35023 bytes | June 23 2025 19:46:28. | |
wc-webhook-functions.php | File | 5905 bytes | June 25 2024 21:17:40. | |
wc-widget-functions.php | File | 2063 bytes | August 20 2020 23:18:50. |
<?php /** * Template Loader * * @package WooCommerce\Classes */ defined( 'ABSPATH' ) || exit; /** * Template loader class. */ class WC_Template_Loader { /** * Store the shop page ID. * * @var integer */ private static $shop_page_id = 0; /** * Store whether we're processing a product inside the_content filter. * * @var boolean */ private static $in_content_filter = false; /** * Is WooCommerce support defined? * * @var boolean */ private static $theme_support = false; /** * Hook in methods. */ public static function init() { self::$theme_support = wc_current_theme_supports_woocommerce_or_fse(); self::$shop_page_id = wc_get_page_id( 'shop' ); // Supported themes. if ( self::$theme_support ) { add_filter( 'template_include', array( __CLASS__, 'template_loader' ) ); add_filter( 'comments_template', array( __CLASS__, 'comments_template_loader' ) ); // Loads gallery scripts on Product page for FSE themes. if ( wp_is_block_theme() ) { self::add_support_for_product_page_gallery(); } } else { // Unsupported themes. add_action( 'template_redirect', array( __CLASS__, 'unsupported_theme_init' ) ); } } /** * Load a template. * * Handles template usage so that we can use our own templates instead of the theme's. * * Templates are in the 'templates' folder. WooCommerce looks for theme * overrides 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 to load. * @return string */ public static function template_loader( $template ) { if ( is_embed() ) { return $template; } $default_file = self::get_template_loader_default_file(); if ( $default_file ) { /** * Filter hook to choose which files to find before WooCommerce does it's own logic. * * @since 3.0.0 * @var array */ $search_files = self::get_template_loader_files( $default_file ); $template = locate_template( $search_files ); if ( ! $template || WC_TEMPLATE_DEBUG_MODE ) { if ( false !== strpos( $default_file, 'product_cat' ) || false !== strpos( $default_file, 'product_tag' ) ) { $cs_template = str_replace( '_', '-', $default_file ); $template = WC()->plugin_path() . '/templates/' . $cs_template; } else { $template = WC()->plugin_path() . '/templates/' . $default_file; } } } return $template; } /** * Checks whether a block template for a given taxonomy exists. * * **Note:** This checks both the `templates` and `block-templates` directories * as both conventions should be supported. * * @param object $taxonomy Object taxonomy to check. * @return boolean */ private static function taxonomy_has_block_template( $taxonomy ): bool { if ( taxonomy_is_product_attribute( $taxonomy->taxonomy ) ) { $template_name = 'taxonomy-product_attribute'; } else { $template_name = 'taxonomy-' . $taxonomy->taxonomy; } return self::has_block_template( $template_name ); } /** * Checks whether a block template with that name exists. * * **Note: ** This checks both the `templates` and `block-templates` directories * as both conventions should be supported. * * @since 5.5.0 * @param string $template_name Template to check. * @return boolean */ private static function has_block_template( $template_name ) { if ( ! $template_name ) { return false; } $has_template = false; $template_filename = $template_name . '.html'; // Since Gutenberg 12.1.0, the conventions for block templates directories have changed, // we should check both these possible directories for backwards-compatibility. $possible_templates_dirs = array( 'templates', 'block-templates' ); // Combine the possible root directory names with either the template directory // or the stylesheet directory for child themes, getting all possible block templates // locations combinations. $filepath = DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . $template_filename; $legacy_filepath = DIRECTORY_SEPARATOR . 'block-templates' . DIRECTORY_SEPARATOR . $template_filename; $possible_paths = array( get_stylesheet_directory() . $filepath, get_stylesheet_directory() . $legacy_filepath, get_template_directory() . $filepath, get_template_directory() . $legacy_filepath, ); // Check the first matching one. foreach ( $possible_paths as $path ) { if ( is_readable( $path ) ) { $has_template = true; break; } } /** * Filters the value of the result of the block template check. * * @since x.x.x * * @param boolean $has_template value to be filtered. * @param string $template_name The name of the template. */ return (bool) apply_filters( 'woocommerce_has_block_template', $has_template, $template_name ); } /** * Get the default filename for a template except if a block template with * the same name exists. * * @since 3.0.0 * @since 5.5.0 If a block template with the same name exists, return an * empty string. * @since 6.3.0 It checks custom product taxonomies * @return string */ 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; } /** * 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 ) { $templates = apply_filters( 'woocommerce_template_loader_files', array(), $default_file ); $templates[] = 'woocommerce.php'; if ( is_page_template() ) { $page_template = get_page_template_slug(); if ( $page_template ) { $validated_file = validate_file( $page_template ); if ( 0 === $validated_file ) { $templates[] = $page_template; } else { error_log( "WooCommerce: Unable to validate template path: \"$page_template\". Error Code: $validated_file." ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log } } } if ( is_singular( 'product' ) ) { $object = get_queried_object(); $name_decoded = urldecode( $object->post_name ); if ( $name_decoded !== $object->post_name ) { $templates[] = "single-product-{$name_decoded}.php"; } $templates[] = "single-product-{$object->post_name}.php"; } if ( is_product_taxonomy() ) { $object = get_queried_object(); $templates[] = 'taxonomy-' . $object->taxonomy . '-' . $object->slug . '.php'; $templates[] = WC()->template_path() . 'taxonomy-' . $object->taxonomy . '-' . $object->slug . '.php'; $templates[] = 'taxonomy-' . $object->taxonomy . '.php'; $templates[] = WC()->template_path() . 'taxonomy-' . $object->taxonomy . '.php'; if ( taxonomy_is_product_attribute( $object->taxonomy ) ) { $templates[] = 'taxonomy-product_attribute.php'; $templates[] = WC()->template_path() . 'taxonomy-product_attribute.php'; $templates[] = $default_file; } if ( is_tax( 'product_cat' ) || is_tax( 'product_tag' ) ) { $cs_taxonomy = str_replace( '_', '-', $object->taxonomy ); $cs_default = str_replace( '_', '-', $default_file ); $templates[] = 'taxonomy-' . $object->taxonomy . '-' . $object->slug . '.php'; $templates[] = WC()->template_path() . 'taxonomy-' . $cs_taxonomy . '-' . $object->slug . '.php'; $templates[] = 'taxonomy-' . $object->taxonomy . '.php'; $templates[] = WC()->template_path() . 'taxonomy-' . $cs_taxonomy . '.php'; $templates[] = $cs_default; } } $templates[] = $default_file; if ( isset( $cs_default ) ) { $templates[] = WC()->template_path() . $cs_default; } $templates[] = WC()->template_path() . $default_file; return array_unique( $templates ); } /** * Load comments template. * * @param string $template template to load. * @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'; } } } /** * Unsupported theme compatibility methods. */ /** * Hook in methods to enhance the unsupported theme experience on pages. * * @since 3.3.0 */ public static function unsupported_theme_init() { if ( 0 < self::$shop_page_id ) { if ( is_product_taxonomy() ) { self::unsupported_theme_tax_archive_init(); } elseif ( is_product() ) { self::unsupported_theme_product_page_init(); } else { self::unsupported_theme_shop_page_init(); } } } /** * Hook in methods to enhance the unsupported theme experience on the Shop page. * * @since 3.3.0 */ private static function unsupported_theme_shop_page_init() { add_filter( 'the_content', array( __CLASS__, 'unsupported_theme_shop_content_filter' ), 10 ); add_filter( 'the_title', array( __CLASS__, 'unsupported_theme_title_filter' ), 10, 2 ); add_filter( 'comments_number', array( __CLASS__, 'unsupported_theme_comments_number_filter' ) ); } /** * Hook in methods to enhance the unsupported theme experience on Product pages. * * @since 3.3.0 */ private static function unsupported_theme_product_page_init() { add_filter( 'the_content', array( __CLASS__, 'unsupported_theme_product_content_filter' ), 10 ); add_filter( 'post_thumbnail_html', array( __CLASS__, 'unsupported_theme_single_featured_image_filter' ) ); add_filter( 'woocommerce_product_tabs', array( __CLASS__, 'unsupported_theme_remove_review_tab' ) ); remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 ); remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 ); self::add_support_for_product_page_gallery(); } /** * Add theme support for Product page gallery. * * @since x.x.x */ private static function add_support_for_product_page_gallery() { add_theme_support( 'wc-product-gallery-zoom' ); add_theme_support( 'wc-product-gallery-lightbox' ); add_theme_support( 'wc-product-gallery-slider' ); } /** * Enhance the unsupported theme experience on Product Category and Attribute pages by rendering * those pages using the single template and shortcode-based content. To do this we make a dummy * post and set a shortcode as the post content. This approach is adapted from bbPress. * * @since 3.3.0 */ private static function unsupported_theme_tax_archive_init() { global $wp_query, $post; $queried_object = get_queried_object(); $args = self::get_current_shop_view_args(); $shortcode_args = array( 'page' => $args->page, 'columns' => $args->columns, 'rows' => $args->rows, 'orderby' => '', 'order' => '', 'paginate' => true, 'cache' => false, ); if ( is_product_category() ) { $shortcode_args['category'] = sanitize_title( $queried_object->slug ); } elseif ( taxonomy_is_product_attribute( $queried_object->taxonomy ) ) { $shortcode_args['attribute'] = sanitize_title( $queried_object->taxonomy ); $shortcode_args['terms'] = sanitize_title( $queried_object->slug ); } elseif ( is_product_tag() ) { $shortcode_args['tag'] = sanitize_title( $queried_object->slug ); } else { // Default theme archive for all other taxonomies. return; } // Description handling. if ( ! empty( $queried_object->description ) && ( empty( $_GET['product-page'] ) || 1 === absint( $_GET['product-page'] ) ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended $prefix = '<div class="term-description">' . wc_format_content( wp_kses_post( $queried_object->description ) ) . '</div>'; } else { $prefix = ''; } add_filter( 'woocommerce_shortcode_products_query', array( __CLASS__, 'unsupported_archive_layered_nav_compatibility' ) ); $shortcode = new WC_Shortcode_Products( $shortcode_args ); remove_filter( 'woocommerce_shortcode_products_query', array( __CLASS__, 'unsupported_archive_layered_nav_compatibility' ) ); $shop_page = get_post( self::$shop_page_id ); $dummy_post_properties = array( 'ID' => 0, 'post_status' => 'publish', 'post_author' => $shop_page->post_author, 'post_parent' => 0, 'post_type' => 'page', 'post_date' => $shop_page->post_date, 'post_date_gmt' => $shop_page->post_date_gmt, 'post_modified' => $shop_page->post_modified, 'post_modified_gmt' => $shop_page->post_modified_gmt, 'post_content' => $prefix . $shortcode->get_content(), 'post_title' => wc_clean( $queried_object->name ), 'post_excerpt' => '', 'post_content_filtered' => '', 'post_mime_type' => '', 'post_password' => '', 'post_name' => $queried_object->slug, 'guid' => '', 'menu_order' => 0, 'pinged' => '', 'to_ping' => '', 'ping_status' => '', 'comment_status' => 'closed', 'comment_count' => 0, 'filter' => 'raw', ); // Set the $post global. $post = new WP_Post( (object) $dummy_post_properties ); // @codingStandardsIgnoreLine. // Copy the new post global into the main $wp_query. $wp_query->post = $post; $wp_query->posts = array( $post ); // Prevent comments form from appearing. $wp_query->post_count = 1; $wp_query->is_404 = false; $wp_query->is_page = true; $wp_query->is_single = true; $wp_query->is_archive = false; $wp_query->is_tax = true; $wp_query->max_num_pages = 0; // Prepare everything for rendering. setup_postdata( $post ); remove_all_filters( 'the_content' ); remove_all_filters( 'the_excerpt' ); add_filter( 'template_include', array( __CLASS__, 'force_single_template_filter' ) ); } /** * Add layered nav args to WP_Query args generated by the 'products' shortcode. * * @since 3.3.4 * @param array $query WP_Query args. * @return array */ public static function unsupported_archive_layered_nav_compatibility( $query ) { foreach ( WC()->query->get_layered_nav_chosen_attributes() as $taxonomy => $data ) { $query['tax_query'][] = array( 'taxonomy' => $taxonomy, 'field' => 'slug', 'terms' => $data['terms'], 'operator' => 'and' === $data['query_type'] ? 'AND' : 'IN', 'include_children' => false, ); } return $query; } /** * Force the loading of one of the single templates instead of whatever template was about to be loaded. * * @since 3.3.0 * @param string $template Path to template. * @return string */ public static function force_single_template_filter( $template ) { $possible_templates = array( 'page', 'single', 'singular', 'index', ); foreach ( $possible_templates as $possible_template ) { $path = get_query_template( $possible_template ); if ( $path ) { return $path; } } return $template; } /** * Get information about the current shop page view. * * @since 3.3.0 * @return array */ private static function get_current_shop_view_args() { return (object) array( 'page' => absint( max( 1, absint( get_query_var( 'paged' ) ) ) ), 'columns' => wc_get_default_products_per_row(), 'rows' => wc_get_default_product_rows_per_page(), ); } /** * Filter the title and insert WooCommerce content on the shop page. * * For non-WC themes, this will setup the main shop page to be shortcode based to improve default appearance. * * @since 3.3.0 * @param string $title Existing title. * @param int|null $id ID of the post being filtered. * @return string */ public static function unsupported_theme_title_filter( $title, $id = null ) { if ( is_null( $id ) || self::$theme_support || ! $id !== self::$shop_page_id ) { return $title; } if ( is_page( self::$shop_page_id ) || ( is_home() && 'page' === get_option( 'show_on_front' ) && absint( get_option( 'page_on_front' ) ) === self::$shop_page_id ) ) { $args = self::get_current_shop_view_args(); $title_suffix = array(); if ( $args->page > 1 ) { /* translators: %d: Page number. */ $title_suffix[] = sprintf( esc_html__( 'Page %d', 'woocommerce' ), $args->page ); } if ( $title_suffix ) { $title = $title . ' – ' . implode( ', ', $title_suffix ); } } return $title; } /** * Filter the content and insert WooCommerce content on the shop page. * * For non-WC themes, this will setup the main shop page to be shortcode based to improve default appearance. * * @since 3.3.0 * @param string $content Existing post content. * @return string */ public static function unsupported_theme_shop_content_filter( $content ) { global $wp_query; if ( self::$theme_support || ! is_main_query() || ! in_the_loop() ) { return $content; } self::$in_content_filter = true; // Remove the filter we're in to avoid nested calls. remove_filter( 'the_content', array( __CLASS__, 'unsupported_theme_shop_content_filter' ) ); // Unsupported theme shop page. if ( is_page( self::$shop_page_id ) ) { $args = self::get_current_shop_view_args(); $shortcode = new WC_Shortcode_Products( array_merge( WC()->query->get_catalog_ordering_args(), array( 'page' => $args->page, 'columns' => $args->columns, 'rows' => $args->rows, 'orderby' => '', 'order' => '', 'paginate' => true, 'cache' => false, ) ), 'products' ); // Allow queries to run e.g. layered nav. add_action( 'pre_get_posts', array( WC()->query, 'product_query' ) ); $content = $content . $shortcode->get_content(); // Remove actions and self to avoid nested calls. remove_action( 'pre_get_posts', array( WC()->query, 'product_query' ) ); WC()->query->remove_ordering_args(); } self::$in_content_filter = false; return $content; } /** * Filter the content and insert WooCommerce content on the shop page. * * For non-WC themes, this will setup the main shop page to be shortcode based to improve default appearance. * * @since 3.3.0 * @param string $content Existing post content. * @return string */ public static function unsupported_theme_product_content_filter( $content ) { global $wp_query; if ( self::$theme_support || ! is_main_query() || ! in_the_loop() ) { return $content; } self::$in_content_filter = true; // Remove the filter we're in to avoid nested calls. remove_filter( 'the_content', array( __CLASS__, 'unsupported_theme_product_content_filter' ) ); if ( is_product() ) { $content = do_shortcode( '[product_page id="' . get_the_ID() . '" show_title=0 status="any"]' ); } self::$in_content_filter = false; return $content; } /** * Suppress the comments number on the Shop page for unsupported themes since there is no commenting on the Shop page. * * @since 3.4.5 * @param string $comments_number The comments number text. * @return string */ public static function unsupported_theme_comments_number_filter( $comments_number ) { if ( is_page( self::$shop_page_id ) ) { return ''; } return $comments_number; } /** * Are we filtering content for unsupported themes? * * @since 3.3.2 * @return bool */ public static function in_content_filter() { return (bool) self::$in_content_filter; } /** * Prevent the main featured image on product pages because there will be another featured image * in the gallery. * * @since 3.3.0 * @param string $html Img element HTML. * @return string */ public static function unsupported_theme_single_featured_image_filter( $html ) { if ( self::in_content_filter() || ! is_product() || ! is_main_query() ) { return $html; } return ''; } /** * Remove the Review tab and just use the regular comment form. * * @param array $tabs Tab info. * @return array */ public static function unsupported_theme_remove_review_tab( $tabs ) { unset( $tabs['reviews'] ); return $tabs; } } add_action( 'init', array( 'WC_Template_Loader', 'init' ) );
SILENT KILLER Tool