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

Auto-insert the Mini Cart block after the Navigation block #10649

Closed
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
Next Next commit
Enable Auto-insert for the Mini Cart block after the navigation block…
… in the feature plugin.
  • Loading branch information
nefeline committed Aug 17, 2023
commit e485e95f4503a10f854115e5bbfeb787c271ee83
14 changes: 14 additions & 0 deletions src/BlockTypes/MiniCart.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,23 @@ 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_loaded', array( $this, 'register_auto_insert' ) );
add_action( 'wp_print_footer_scripts', array( $this, 'print_lazy_load_scripts' ), 2 );
}

/**
* Auto-insert the Mini cart block after the navigation block.
*
* Since this is still an experimental feature within Gutenberg, this feature is enabled exclusively in the feature plugin.
*/
public function register_auto_insert() {
if ( ! function_exists( 'gutenberg_register_auto_inserted_block' ) || ! WC_BLOCKS_IS_FEATURE_PLUGIN ) {
return;
}

gutenberg_register_auto_inserted_block( 'woocommerce/mini-cart', 'after', 'core/navigation' );
}

/**
* Get the editor script handle for this block type.
*
Expand Down