Automattic\WooCommerce\Admin\Features\ProductBlockEditor

Init::enqueue_scripts()publicWC 1.0

Enqueue scripts needed for the product form block editor.

Метод класса: Init{}

Хуков нет.

Возвращает

null. Ничего (null).

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

$Init = new Init();
$Init->enqueue_scripts();

Код Init::enqueue_scripts() WC 9.3.1

public function enqueue_scripts() {
	if ( ! PageController::is_admin_or_embed_page() ) {
		return;
	}

	$editor_settings = $this->get_product_editor_settings();

	$script_handle = 'wc-admin-edit-product';
	wp_register_script( $script_handle, '', array( 'wp-blocks' ), '0.1.0', true );
	wp_enqueue_script( $script_handle );
	wp_add_inline_script(
		$script_handle,
		'var productBlockEditorSettings = productBlockEditorSettings || ' . wp_json_encode( $editor_settings ) . ';',
		'before'
	);
	wp_add_inline_script(
		$script_handle,
		sprintf( 'wp.blocks.setCategories( %s );', wp_json_encode( $editor_settings['blockCategories'] ) ),
		'before'
	);
	wp_tinymce_inline_scripts();
	wp_enqueue_media();
	wp_register_style( 'wc-global-presets', false ); // phpcs:ignore
	wp_add_inline_style( 'wc-global-presets', wp_get_global_stylesheet( array( 'presets' ) ) );
	wp_enqueue_style( 'wc-global-presets' );
}