Automattic\WooCommerce\Blocks

BlockTypesController::get_block_types()protectedWC 1.0

Get list of block types.

{} Это метод класса: BlockTypesController{}

Хуков нет.

Возвращает

Массив.

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->get_block_types();

Код BlockTypesController::get_block_types() WC 7.1.0

protected function get_block_types() {
	global $pagenow;

	$block_types = [
		'AllReviews',
		'FeaturedCategory',
		'FeaturedProduct',
		'HandpickedProducts',
		'ProductBestSellers',
		'ProductCategories',
		'ProductCategory',
		'ProductNew',
		'ProductOnSale',
		'ProductsByAttribute',
		'ProductTopRated',
		'ReviewsByProduct',
		'ReviewsByCategory',
		'ProductSearch',
		'ProductTag',
		'AllProducts',
		'PriceFilter',
		'AttributeFilter',
		'StockFilter',
		'RatingFilter',
		'ActiveFilters',
		'ClassicTemplate',
		'ProductAddToCart',
		'ProductButton',
		'ProductCategoryList',
		'ProductImage',
		'ProductPrice',
		'ProductRating',
		'ProductSaleBadge',
		'ProductSKU',
		'ProductStockIndicator',
		'ProductSummary',
		'ProductTagList',
		'ProductTitle',
		'MiniCart',
		'MiniCartContents',
		'ProductQuery',
		'FilterWrapper',
	];

	$block_types = array_merge( $block_types, Cart::get_cart_block_types(), Checkout::get_checkout_block_types() );

	if ( Package::feature()->is_experimental_build() ) {
		$block_types[] = 'SingleProduct';
	}

	/**
	 * 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 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,
			[
				'ClassicTemplate',
			]
		);
	}

	return $block_types;
}