BlockRegistry
in package
Product block registration and style registration functionality.
Table of Contents
- BLOCKS_DIR = 'product-editor/blocks'
- The directory where blocks are stored after build.
- PRODUCT_BLOCKS = ['woocommerce/conditional', 'woocommerce/product-category-field', 'woocommerce/product-checkbox-field', 'woocommerce/product-collapsible', 'woocommerce/product-description-field', 'woocommerce/product-images-field', 'woocommerce/product-inventory-email-field', 'woocommerce/product-sku-field', 'woocommerce/product-name-field', 'woocommerce/product-pricing-field', 'woocommerce/product-radio-field', 'woocommerce/product-regular-price-field', 'woocommerce/product-sale-price-field', 'woocommerce/product-schedule-sale-fields', 'woocommerce/product-section', 'woocommerce/product-shipping-class-field', 'woocommerce/product-shipping-dimensions-fields', 'woocommerce/product-summary-field', 'woocommerce/product-tab', 'woocommerce/product-inventory-quantity-field', 'woocommerce/product-toggle-field', 'woocommerce/product-variations-fields']
- Array of all available product blocks.
- init() : mixed
- Initialize all blocks.
- register_categories() : mixed
- Register product related block categories.
- get_file_path() : mixed
- Get a file path for a given block file.
- register_block() : WP_Block_Type|false
- Register a single block.
- register_product_blocks() : mixed
- Register all the product blocks.
- remove_block_prefix() : string
- Get the block name without the "woocommerce/" prefix.
Constants
BLOCKS_DIR
The directory where blocks are stored after build.
public
mixed
BLOCKS_DIR
= 'product-editor/blocks'
PRODUCT_BLOCKS
Array of all available product blocks.
public
mixed
PRODUCT_BLOCKS
= ['woocommerce/conditional', 'woocommerce/product-category-field', 'woocommerce/product-checkbox-field', 'woocommerce/product-collapsible', 'woocommerce/product-description-field', 'woocommerce/product-images-field', 'woocommerce/product-inventory-email-field', 'woocommerce/product-sku-field', 'woocommerce/product-name-field', 'woocommerce/product-pricing-field', 'woocommerce/product-radio-field', 'woocommerce/product-regular-price-field', 'woocommerce/product-sale-price-field', 'woocommerce/product-schedule-sale-fields', 'woocommerce/product-section', 'woocommerce/product-shipping-class-field', 'woocommerce/product-shipping-dimensions-fields', 'woocommerce/product-summary-field', 'woocommerce/product-tab', 'woocommerce/product-inventory-quantity-field', 'woocommerce/product-toggle-field', 'woocommerce/product-variations-fields']
Methods
init()
Initialize all blocks.
public
init() : mixed
Return values
mixed —register_categories()
Register product related block categories.
public
register_categories(array<string|int, array<string|int, mixed>> $block_categories, WP_Block_Editor_Context $editor_context) : mixed
Parameters
- $block_categories : array<string|int, array<string|int, mixed>>
-
Array of categories for block types.
- $editor_context : WP_Block_Editor_Context
-
The current block editor context.
Return values
mixed —get_file_path()
Get a file path for a given block file.
private
get_file_path(string $path) : mixed
Parameters
- $path : string
-
File path.
Return values
mixed —register_block()
Register a single block.
private
register_block(string $block_name) : WP_Block_Type|false
Parameters
- $block_name : string
-
Block name.
Return values
WP_Block_Type|false — The registered block type on success, or false on failure.register_product_blocks()
Register all the product blocks.
private
register_product_blocks() : mixed
Return values
mixed —remove_block_prefix()
Get the block name without the "woocommerce/" prefix.
private
remove_block_prefix(string $block_name) : string
Parameters
- $block_name : string
-
Block name.