Skip to content

Commit

Permalink
Cherry pick 46429 into release/8.8 (#46473)
Browse files Browse the repository at this point in the history
* Fix wrong Shop title shown in classic themes after deleting the page (#46429)

* Fix wrong Shop title shown in classic themes after deleting the page

* Add changelog file

* Add explanatory comment

* Prep for cherry pick 46429

---------

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
Co-authored-by: WooCommerce Bot <no-reply@woo.com>
  • Loading branch information
3 people committed Apr 11, 2024
1 parent 22845c3 commit e20ee59
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 21 deletions.
1 change: 1 addition & 0 deletions plugins/woocommerce/readme.txt
Expand Up @@ -169,6 +169,7 @@ WooCommerce comes with some sample data you can use to see how products look; im

**WooCommerce**

* Fix - Fix wrong Shop title shown in classic themes after deleting the page [#46429](https://github.com/woocommerce/woocommerce/pull/46429)
* Fix - Fixed an issue where orders could be placed when no shipping options were available [#46026](https://github.com/woocommerce/woocommerce/pull/46026)
* Fix - Fix a bug where saved payment methods were not rendered correctly in the heckout block [#46019](https://github.com/woocommerce/woocommerce/pull/46019)
* Fix - Removed count from is_array check to fix Analytics comparison filter. [#45939](https://github.com/woocommerce/woocommerce/pull/45939)
Expand Down
25 changes: 25 additions & 0 deletions plugins/woocommerce/src/Blocks/BlockTemplatesController.php
Expand Up @@ -29,6 +29,7 @@ public function init() {
add_filter( 'current_theme_supports-block-templates', array( $this, 'remove_block_template_support_for_shop_page' ) );
add_filter( 'taxonomy_template_hierarchy', array( $this, 'add_archive_product_to_eligible_for_fallback_templates' ), 10, 1 );
add_action( 'after_switch_theme', array( $this, 'check_should_use_blockified_product_grid_templates' ), 10, 2 );
add_filter( 'post_type_archive_title', array( $this, 'update_product_archive_title' ), 10, 2 );

if ( wc_current_theme_is_fse_theme() ) {
// By default, the Template Part Block only supports template parts that are in the current theme directory.
Expand Down Expand Up @@ -558,6 +559,30 @@ public function block_template_is_available( $template_name, $template_type = 'w
) || $this->get_block_templates( array( $template_name ), $template_type );
}

/**
* Update the product archive title to "Shop".
*
* Attention: this method is run in classic themes as well, so it
* can't be moved to the ProductCatalogTemplate class. See:
* https://github.com/woocommerce/woocommerce/pull/46429
*
* @param string $post_type_name Post type 'name' label.
* @param string $post_type Post type.
*
* @return string
*/
public function update_product_archive_title( $post_type_name, $post_type ) {
if (
function_exists( 'is_shop' ) &&
is_shop() &&
'product' === $post_type
) {
return __( 'Shop', 'woocommerce' );
}

return $post_type_name;
}

/**
* Remove the template panel from the Sidebar of the Shop page because
* the Site Editor handles it.
Expand Down
Expand Up @@ -23,7 +23,6 @@ class ProductCatalogTemplate extends AbstractTemplate {
*/
public function init() {
add_action( 'template_redirect', array( $this, 'render_block_template' ) );
add_filter( 'post_type_archive_title', array( $this, 'update_product_archive_title' ), 10, 2 );
}

/**
Expand Down Expand Up @@ -58,24 +57,4 @@ public function render_block_template() {
add_filter( 'woocommerce_has_block_template', '__return_true', 10, 0 );
}
}

/**
* Update the product archive title to "Shop".
*
* @param string $post_type_name Post type 'name' label.
* @param string $post_type Post type.
*
* @return string
*/
public function update_product_archive_title( $post_type_name, $post_type ) {
if (
function_exists( 'is_shop' ) &&
is_shop() &&
'product' === $post_type
) {
return __( 'Shop', 'woocommerce' );
}

return $post_type_name;
}
}

0 comments on commit e20ee59

Please sign in to comment.