Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Fix: WooCommerce Blocks causing malfunction of the navigation block on WordPress 6.3 #10283

Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions bin/webpack-entries.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,8 @@ const getEntryConfig = ( type = 'main', exclude = [] ) => {

module.exports = {
getEntryConfig,

externals: {
'@wordpress/edit-site': 'wp.editSite',
},
nefeline marked this conversation as resolved.
Show resolved Hide resolved
};
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"./assets/js/blocks/filter-wrapper/register-components.ts",
"./assets/js/blocks/product-query/variations/**.tsx",
"./assets/js/blocks/product-query/index.tsx",
"./assets/js/blocks/product-query/inspector-controls.tsx"
"./assets/js/blocks/product-query/inspector-controls.tsx",
"./assets/js/templates/revert-button/index.tsx"
],
"repository": {
"type": "git",
Expand Down
18 changes: 14 additions & 4 deletions src/AssetsController.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<?php
namespace Automattic\WooCommerce\Blocks;

use Automattic\WooCommerce\Blocks\Package;
use Automattic\WooCommerce\Blocks\Assets\Api as AssetApi;
use Automattic\WooCommerce\Blocks\Assets\AssetDataRegistry as AssetDataRegistry;

/**
* AssetsController class.
Expand Down Expand Up @@ -41,6 +39,7 @@ protected function init() {
add_action( 'admin_enqueue_scripts', array( $this, 'update_block_style_dependencies' ), 20 );
add_action( 'wp_enqueue_scripts', array( $this, 'update_block_settings_dependencies' ), 100 );
add_action( 'admin_enqueue_scripts', array( $this, 'update_block_settings_dependencies' ), 100 );
add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_site_editor_dependencies' ) );
}

/**
Expand All @@ -56,7 +55,7 @@ public function register_assets() {
$this->api->register_script( 'wc-blocks-vendors', $this->api->get_block_asset_build_path( 'wc-blocks-vendors' ), [], false );
$this->api->register_script( 'wc-blocks-registry', 'build/wc-blocks-registry.js', [], false );
$this->api->register_script( 'wc-blocks', $this->api->get_block_asset_build_path( 'wc-blocks' ), [ 'wc-blocks-vendors' ], false );
$this->api->register_script( 'wc-blocks-shared-context', 'build/wc-blocks-shared-context.js', [] );
$this->api->register_script( 'wc-blocks-shared-context', 'build/wc-blocks-shared-context.js' );
$this->api->register_script( 'wc-blocks-shared-hocs', 'build/wc-blocks-shared-hocs.js', [], false );

// The price package is shared externally so has no blocks prefix.
Expand All @@ -76,6 +75,17 @@ public function register_assets() {
);
}

/**
* Enqueues the block editor assets.
*/
public function enqueue_site_editor_dependencies() {
$current_screen = get_current_screen();

if ( $current_screen instanceof \WP_Screen && 'site-editor' === $current_screen->base ) {
wp_enqueue_script( 'wp-edit-site' );
}
}

/**
* Defines resource hints to help speed up the loading of some critical blocks.
*
Expand All @@ -93,7 +103,7 @@ public function add_resource_hints( $urls, $relation_type ) {
// We only need to prefetch when the cart has contents.
$cart = wc()->cart;

if ( ! $cart || ! $cart instanceof \WC_Cart || 0 === $cart->get_cart_contents_count() ) {
if ( ! $cart instanceof \WC_Cart || 0 === $cart->get_cart_contents_count() ) {
return $urls;
}

Expand Down