Automattic\WooCommerce\Admin\Features\ProductBlockEditor

Init::set_current_screen_to_block_editor_if_wc_admin()publicWC 1.0

Sets the current screen to the block editor if a wc-admin page.

Method of the class: Init{}

No Hooks.

Return

null. Nothing (null).

Usage

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

Init::set_current_screen_to_block_editor_if_wc_admin() code WC 9.0.1

public function set_current_screen_to_block_editor_if_wc_admin() {
	$screen = get_current_screen();

	// phpcs:ignore Squiz.PHP.CommentedOutCode.Found
	// (no idea why I need that phpcs:ignore above, but I'm tired trying to re-write this comment to get it to pass)
	// we can't check the 'path' query param because client-side routing is used within wc-admin,
	// so this action handler is only called on the initial page load from the server, which might
	// not be the product edit page (it mostly likely isn't).
	if ( PageController::is_admin_page() ) {
		$screen->is_block_editor( true );

		wp_add_inline_script(
			'wp-blocks',
			'wp.blocks && wp.blocks.unstable__bootstrapServerSideBlockDefinitions && wp.blocks.unstable__bootstrapServerSideBlockDefinitions(' . wp_json_encode( get_block_editor_server_block_settings() ) . ');'
		);
	}
}