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

Commit

Permalink
Unset blocks on the PHP side if on the widgets page (#3737)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikejolley committed Jan 27, 2021
1 parent 187d2fc commit fabf8ac
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/Library.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public static function define_tables() {
* Register blocks, hooking up assets and render functions as needed.
*/
public static function register_blocks() {
global $wp_version;
global $wp_version, $pagenow;

$blocks = [
'AllReviews',
'FeaturedCategory',
Expand Down Expand Up @@ -69,6 +70,18 @@ public static function register_blocks() {
if ( Package::feature()->is_experimental_build() ) {
$blocks[] = 'SingleProduct';
}
/**
* This disables specific blocks in Widget Areas by not registering them.
*/
if ( 'themes.php' === $pagenow ) {
$blocks_to_unset = [
'AllProducts',
'PriceFilter',
'AttributeFilter',
'ActiveFilters',
];
$blocks = array_diff( $blocks, $blocks_to_unset );
}
foreach ( $blocks as $class ) {
$class = __NAMESPACE__ . '\\BlockTypes\\' . $class;
$instance = new $class();
Expand Down

0 comments on commit fabf8ac

Please sign in to comment.