diff --git a/src/Assets/AssetDataRegistry.php b/src/Assets/AssetDataRegistry.php index 6baf566c426..a4f4f296a17 100644 --- a/src/Assets/AssetDataRegistry.php +++ b/src/Assets/AssetDataRegistry.php @@ -67,7 +67,7 @@ public function __construct( Api $asset_api ) { */ protected function init() { add_action( 'init', array( $this, 'register_data_script' ) ); - add_action( is_admin() ? 'admin_print_footer_scripts' : 'wp_print_footer_scripts', array( $this, 'enqueue_asset_data' ), 2 ); + add_action( is_admin() ? 'admin_print_footer_scripts' : 'wp_print_footer_scripts', array( $this, 'enqueue_asset_data' ), 1 ); } /** diff --git a/src/BlockTypes/MiniCart.php b/src/BlockTypes/MiniCart.php index e232403a32e..84fb4096d7f 100644 --- a/src/BlockTypes/MiniCart.php +++ b/src/BlockTypes/MiniCart.php @@ -70,10 +70,7 @@ public function __construct( AssetApi $asset_api, AssetDataRegistry $asset_data_ protected function initialize() { parent::initialize(); add_action( 'wp_loaded', array( $this, 'register_empty_cart_message_block_pattern' ) ); - add_action( 'wp_print_footer_scripts', array( $this, 'enqueue_wc_settings' ), 1 ); - // We need this action to run after enqueue_wc_settings() and dequeue_wc_settings(), - // otherwise it might incorrectly consider wc_settings script to be enqueued. - add_action( 'wp_print_footer_scripts', array( $this, 'print_lazy_load_scripts' ), 4 ); + add_action( 'wp_print_footer_scripts', array( $this, 'print_lazy_load_scripts' ), 2 ); } /** @@ -193,30 +190,6 @@ protected function enqueue_data( array $attributes = [] ) { do_action( 'woocommerce_blocks_cart_enqueue_data' ); } - /** - * Function to enqueue `wc-settings` script and dequeue it later on so when - * AssetDataRegistry runs, it appears enqueued- This allows the necessary - * data to be printed to the page. - */ - public function enqueue_wc_settings() { - // Return early if another block has already enqueued `wc-settings`. - if ( wp_script_is( 'wc-settings', 'enqueued' ) ) { - return; - } - // We are lazy-loading `wc-settings`, but we need to enqueue it here so - // AssetDataRegistry knows it's going to load. - wp_enqueue_script( 'wc-settings' ); - // After AssetDataRegistry function runs, we dequeue `wc-settings`. - add_action( 'wp_print_footer_scripts', array( $this, 'dequeue_wc_settings' ), 3 ); - } - - /** - * Function to dequeue `wc-settings` script. - */ - public function dequeue_wc_settings() { - wp_dequeue_script( 'wc-settings' ); - } - /** * Prints the variable containing information about the scripts to lazy load. */