Init
in package
Loads assets related to the product block editor.
Table of Contents
- EDITOR_CONTEXT_NAME = 'woocommerce/edit-product'
- The context name used to identify the editor.
- $product_templates : array<string|int, mixed>
- Registered product templates.
- $redirection_controller : RedirectionController
- Redirection controller.
- $supported_product_types : array<string|int, mixed>
- Supported product types.
- __construct() : mixed
- Constructor
- add_user_data_fields() : array<string|int, mixed>
- Adds fields so that we can store user preferences for the variations block.
- dequeue_conflicting_styles() : mixed
- Dequeue conflicting styles.
- enable_rest_api_for_product_variation() : array<string|int, mixed>
- Enables variation post type in REST API.
- enqueue_scripts() : mixed
- Enqueue scripts needed for the product form block editor.
- enqueue_styles() : mixed
- Enqueue styles needed for the rich text editor.
- get_block_types() : array<string|int, mixed>
- Filters woocommerce block types.
- possibly_add_template_id() : mixed
- Adds the product template ID to the product if it doesn't exist.
- register_layout_templates() : mixed
- Register layout templates.
- register_metadata_attribute() : array<string|int, mixed>
- Registers the metadata block attribute for all block types.
- register_product_templates() : mixed
- Register product templates.
- register_user_metas() : mixed
- Register user metas.
- set_current_screen_to_block_editor_if_wc_admin() : mixed
- Sets the current screen to the block editor if a wc-admin page.
- update_edit_product_link() : string
- Update the edit product links when the new experience is enabled.
- create_default_product_template_by_custom_product_type() : array<string|int, mixed>
- Create default product template by custom product type if it does not have a template associated yet.
- get_default_product_templates() : array<string|int, mixed>
- Get default product templates.
- get_product_editor_settings() : mixed
- Get the product editor settings.
Constants
EDITOR_CONTEXT_NAME
The context name used to identify the editor.
public
mixed
EDITOR_CONTEXT_NAME
= 'woocommerce/edit-product'
Properties
$product_templates
Registered product templates.
private
array<string|int, mixed>
$product_templates
= array()
$redirection_controller
Redirection controller.
private
RedirectionController
$redirection_controller
$supported_product_types
Supported product types.
private
array<string|int, mixed>
$supported_product_types
= array('simple')
Methods
__construct()
Constructor
public
__construct() : mixed
Return values
mixed —add_user_data_fields()
Adds fields so that we can store user preferences for the variations block.
public
add_user_data_fields(array<string|int, mixed> $user_data_fields) : array<string|int, mixed>
Parameters
- $user_data_fields : array<string|int, mixed>
-
User data fields.
Return values
array<string|int, mixed> —dequeue_conflicting_styles()
Dequeue conflicting styles.
public
dequeue_conflicting_styles() : mixed
Return values
mixed —enable_rest_api_for_product_variation()
Enables variation post type in REST API.
public
enable_rest_api_for_product_variation(array<string|int, mixed> $args) : array<string|int, mixed>
Parameters
- $args : array<string|int, mixed>
-
Array of post type arguments.
Return values
array<string|int, mixed> — Array of post type arguments.enqueue_scripts()
Enqueue scripts needed for the product form block editor.
public
enqueue_scripts() : mixed
Return values
mixed —enqueue_styles()
Enqueue styles needed for the rich text editor.
public
enqueue_styles() : mixed
Return values
mixed —get_block_types()
Filters woocommerce block types.
public
get_block_types(array<string|int, string> $block_types) : array<string|int, mixed>
Parameters
- $block_types : array<string|int, string>
-
Array of woocommerce block types.
Return values
array<string|int, mixed> —possibly_add_template_id()
Adds the product template ID to the product if it doesn't exist.
public
possibly_add_template_id(WP_REST_Response $response, WC_Product $product) : mixed
Parameters
- $response : WP_REST_Response
-
The response object.
- $product : WC_Product
-
The product.
Return values
mixed —register_layout_templates()
Register layout templates.
public
register_layout_templates() : mixed
Return values
mixed —register_metadata_attribute()
Registers the metadata block attribute for all block types.
public
register_metadata_attribute(array<string|int, mixed> $args) : array<string|int, mixed>
This is a fallback/temporary solution until the Gutenberg core version registers the metadata attribute.
Parameters
- $args : array<string|int, mixed>
-
Array of arguments for registering a block type.
Tags
Return values
array<string|int, mixed> — $argsregister_product_templates()
Register product templates.
public
register_product_templates() : mixed
Return values
mixed —register_user_metas()
Register user metas.
public
register_user_metas() : mixed
Return values
mixed —set_current_screen_to_block_editor_if_wc_admin()
Sets the current screen to the block editor if a wc-admin page.
public
set_current_screen_to_block_editor_if_wc_admin() : mixed
Return values
mixed —update_edit_product_link()
Update the edit product links when the new experience is enabled.
public
update_edit_product_link(string $link, int $post_id) : string
Parameters
- $link : string
-
The edit link.
- $post_id : int
-
Post ID.
Return values
string —create_default_product_template_by_custom_product_type()
Create default product template by custom product type if it does not have a template associated yet.
private
create_default_product_template_by_custom_product_type(array<string|int, mixed> $templates) : array<string|int, mixed>
Parameters
- $templates : array<string|int, mixed>
-
The registered product templates.
Return values
array<string|int, mixed> — The new templates.get_default_product_templates()
Get default product templates.
private
get_default_product_templates() : array<string|int, mixed>
Return values
array<string|int, mixed> — The default templates.get_product_editor_settings()
Get the product editor settings.
private
get_product_editor_settings() : mixed