Automattic\WooCommerce\Admin\Features\ProductBlockEditor
Init::set_current_screen_to_block_editor_if_wc_admin
Sets the current screen to the block editor if a wc-admin page.
Метод класса: Init{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$Init = new Init(); $Init->set_current_screen_to_block_editor_if_wc_admin();
Код Init::set_current_screen_to_block_editor_if_wc_admin() Init::set current screen to block editor if wc admin WC 10.5.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(), JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) . ');'
);
}
}