Merge pull request #18726 from woocommerce/fix/theme-compat

Theme compat updates
This commit is contained in:
Mike Jolley 2018-01-31 22:29:08 +00:00 committed by GitHub
commit 2d8d5f3fdb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 7 deletions

View File

@ -264,6 +264,11 @@ class WC_Post_types {
$has_archive = false;
}
// If theme support changes, we may need to flush permalinks since some are changed based on this flag.
if ( update_option( 'current_theme_supports_woocommerce', current_theme_supports( 'woocommerce' ) ? 1 : 0 ) ) {
add_option( 'woocommerce_queue_flush_rewrite_rules', 'true' );
}
register_post_type( 'product',
apply_filters( 'woocommerce_register_post_type_product',
array(

View File

@ -566,7 +566,11 @@ class WC_Shortcode_Products {
$original_post = $GLOBALS['post'];
do_action( "woocommerce_shortcode_before_{$this->type}_loop", $this->attributes );
do_action( 'woocommerce_before_shop_loop' );
// Fire standard shop loop hooks when paginating results so we can show result counts and so on.
if ( wc_string_to_bool( $this->attributes['paginate'] ) ) {
do_action( 'woocommerce_before_shop_loop' );
}
woocommerce_product_loop_start();
@ -589,7 +593,11 @@ class WC_Shortcode_Products {
$GLOBALS['post'] = $original_post; // WPCS: override ok.
woocommerce_product_loop_end();
do_action( 'woocommerce_after_shop_loop' );
// Fire standard shop loop hooks when paginating results so we can show result counts and so on.
if ( wc_string_to_bool( $this->attributes['paginate'] ) ) {
do_action( 'woocommerce_after_shop_loop' );
}
do_action( "woocommerce_shortcode_after_{$this->type}_loop", $this->attributes );
wp_reset_postdata();

View File

@ -165,11 +165,6 @@ function wc_setup_loop( $args = array() ) {
'current_page' => 1,
);
// Merge any existing values.
if ( isset( $GLOBALS['woocommerce_loop'] ) ) {
$default_args = array_merge( $default_args, $GLOBALS['woocommerce_loop'] );
}
// If this is a main WC query, use global args as defaults.
if ( $GLOBALS['wp_query']->get( 'wc_query' ) ) {
$default_args = array_merge( $default_args, array(
@ -182,6 +177,11 @@ function wc_setup_loop( $args = array() ) {
) );
}
// Merge any existing values.
if ( isset( $GLOBALS['woocommerce_loop'] ) ) {
$default_args = array_merge( $default_args, $GLOBALS['woocommerce_loop'] );
}
$GLOBALS['woocommerce_loop'] = wp_parse_args( $args, $default_args );
}
add_action( 'woocommerce_before_shop_loop', 'wc_setup_loop' );