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

Fix: Mini Cart block is not available from the Edit template screen #6351

Merged
merged 6 commits into from
May 5, 2022
Merged
Changes from 4 commits
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
16 changes: 3 additions & 13 deletions src/BlockTypesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public function hide_legacy_widgets_with_block_equivalent( $widget_types ) {
* @return array
*/
protected function get_block_types() {
global $wp_version, $pagenow;
global $pagenow;

$block_types = [
'AllReviews',
Expand Down Expand Up @@ -193,20 +193,10 @@ protected function get_block_types() {
'ProductSummary',
'ProductTagList',
'ProductTitle',
'MiniCart',
'MiniCartContents',
];

/**
* Mini Cart blocks should be available in Site Editor, Widgets and frontend (is_admin function checks this) only.
*/
if (
! is_admin() ||
in_array( $pagenow, [ 'widgets.php', 'customize.php', 'site-editor.php' ], true ) ||
! empty( $_GET['page'] ) && 'gutenberg-edit-site' === $_GET['page'] // phpcs:ignore WordPress.Security.NonceVerification
) {
$block_types[] = 'MiniCart';
$block_types[] = 'MiniCartContents';
}

if ( Package::feature()->is_feature_plugin_build() ) {
$block_types[] = 'Checkout';
$block_types[] = 'Cart';
Expand Down