attributes appended on render.
*
* @since 5.9.0
*
* @param array $allowed_namespaces List of namespaces.
*/
$allowed_blocks = (array) apply_filters( '__experimental_woocommerce_blocks_add_data_attributes_to_block', [] );
if ( ! in_array( $block_namespace, $allowed_namespaces, true ) && ! in_array( $block_name, $allowed_blocks, true ) ) {
return $content;
}
$attributes = (array) $block['attrs'];
$exclude_attributes = [ 'className', 'align' ];
$escaped_data_attributes = [
'data-block-name="' . esc_attr( $block['blockName'] ) . '"',
];
foreach ( $attributes as $key => $value ) {
if ( in_array( $key, $exclude_attributes, true ) ) {
continue;
}
if ( is_bool( $value ) ) {
$value = $value ? 'true' : 'false';
}
if ( ! is_scalar( $value ) ) {
$value = wp_json_encode( $value );
}
$escaped_data_attributes[] = 'data-' . esc_attr( strtolower( preg_replace( '/(?'; // phpcs:ignore WordPress.Security.NonceVerification
}
/**
* Hide legacy widgets with a feature complete block equivalent in the inserter
* and prevent them from showing as an option in the Legacy Widget block.
*
* @param array $widget_types An array of widgets hidden in core.
* @return array $widget_types An array inluding the WooCommerce widgets to hide.
*/
public function hide_legacy_widgets_with_block_equivalent( $widget_types ) {
array_push(
$widget_types,
'woocommerce_product_search',
'woocommerce_product_categories',
'woocommerce_recent_reviews',
'woocommerce_product_tag_cloud',
'woocommerce_price_filter',
'woocommerce_layered_nav',
'woocommerce_layered_nav_filters',
'woocommerce_rating_filter'
);
return $widget_types;
}
/**
* Delete product transients when a product is deleted.
*/
public function delete_product_transients() {
delete_transient( 'wc_blocks_has_downloadable_product' );
}
/**
* Get list of block types.
*
* @return array
*/
protected function get_block_types() {
global $pagenow;
$block_types = [
'ActiveFilters',
'AddToCartForm',
'AllProducts',
'AllReviews',
'AttributeFilter',
'Breadcrumbs',
'CatalogSorting',
'ClassicTemplate',
'ClassicShortcode',
'CustomerAccount',
'FeaturedCategory',
'FeaturedProduct',
'FilterWrapper',
'HandpickedProducts',
'MiniCart',
'StoreNotices',
'PriceFilter',
'ProductAddToCart',
'ProductBestSellers',
'ProductButton',
'ProductCategories',
'ProductCategory',
'ProductCollection',
'ProductCollectionNoResults',
'ProductImage',
'ProductImageGallery',
'ProductNew',
'ProductOnSale',
'ProductPrice',
'ProductTemplate',
'ProductQuery',
'ProductAverageRating',
'ProductRating',
'ProductRatingCounter',
'ProductRatingStars',
'ProductResultsCount',
'ProductReviews',
'ProductSaleBadge',
'ProductSearch',
'ProductSKU',
'ProductStockIndicator',
'ProductSummary',
'ProductTag',
'ProductTitle',
'ProductTopRated',
'ProductsByAttribute',
'RatingFilter',
'ReviewsByCategory',
'ReviewsByProduct',
'RelatedProducts',
'ProductDetails',
'SingleProduct',
'StockFilter',
'PageContentWrapper',
'OrderConfirmation\Status',
'OrderConfirmation\Summary',
'OrderConfirmation\Totals',
'OrderConfirmation\TotalsWrapper',
'OrderConfirmation\Downloads',
'OrderConfirmation\DownloadsWrapper',
'OrderConfirmation\BillingAddress',
'OrderConfirmation\ShippingAddress',
'OrderConfirmation\BillingWrapper',
'OrderConfirmation\ShippingWrapper',
'OrderConfirmation\AdditionalInformation',
];
$block_types = array_merge(
$block_types,
Cart::get_cart_block_types(),
Checkout::get_checkout_block_types(),
MiniCartContents::get_mini_cart_block_types()
);
if ( Package::feature()->is_experimental_build() ) {
$block_types[] = 'ProductGallery';
$block_types[] = 'ProductGalleryLargeImage';
$block_types[] = 'ProductGalleryLargeImageNextPrevious';
$block_types[] = 'ProductGalleryPager';
$block_types[] = 'ProductGalleryThumbnails';
$block_types[] = 'CollectionFilters';
$block_types[] = 'CollectionStockFilter';
$block_types[] = 'CollectionPriceFilter';
}
/**
* This disables specific blocks in Widget Areas by not registering them.
*/
if ( in_array( $pagenow, [ 'widgets.php', 'themes.php', 'customize.php' ], true ) && ( empty( $_GET['page'] ) || 'gutenberg-edit-site' !== $_GET['page'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
$block_types = array_diff(
$block_types,
[
'AllProducts',
'Cart',
'Checkout',
]
);
}
/**
* This disables specific blocks in Post and Page editor by not registering them.
*/
if ( in_array( $pagenow, [ 'post.php', 'post-new.php' ], true ) ) {
$block_types = array_diff(
$block_types,
[
'AddToCartForm',
'Breadcrumbs',
'CatalogSorting',
'ClassicTemplate',
'ProductResultsCount',
'ProductDetails',
'OrderConfirmation\Status',
'OrderConfirmation\Summary',
'OrderConfirmation\Totals',
'OrderConfirmation\TotalsWrapper',
'OrderConfirmation\Downloads',
'OrderConfirmation\DownloadsWrapper',
'OrderConfirmation\BillingAddress',
'OrderConfirmation\ShippingAddress',
'OrderConfirmation\BillingWrapper',
'OrderConfirmation\ShippingWrapper',
'OrderConfirmation\AdditionalInformation',
]
);
}
return $block_types;
}
}
Fatal error: Uncaught Error: Class 'Automattic\WooCommerce\Blocks\BlockTypesController' not found in /home/arasetne/public_html/wp-content/plugins/woocommerce/packages/woocommerce-blocks/src/Domain/Bootstrap.php:283
Stack trace:
#0 /home/arasetne/public_html/wp-content/plugins/woocommerce/packages/woocommerce-blocks/src/Registry/AbstractDependencyType.php(42): Automattic\WooCommerce\Blocks\Domain\Bootstrap->Automattic\WooCommerce\Blocks\Domain\{closure}(Object(Automattic\WooCommerce\Blocks\Registry\Container))
#1 /home/arasetne/public_html/wp-content/plugins/woocommerce/packages/woocommerce-blocks/src/Registry/SharedType.php(28): Automattic\WooCommerce\Blocks\Registry\AbstractDependencyType->resolve_value(Object(Automattic\WooCommerce\Blocks\Registry\Container))
#2 /home/arasetne/public_html/wp-content/plugins/woocommerce/packages/woocommerce-blocks/src/Registry/Container.php(96): Automattic\WooCommerce\Blocks\Registry\SharedType->get(Object(Automattic\WooCommerce\Blocks\Registry\Container))
#3 /home/arasetne/public_html/ in /home/arasetne/public_html/wp-content/plugins/woocommerce/packages/woocommerce-blocks/src/Domain/Bootstrap.php on line 283