| @@ -398,8 +398,30 @@ | ||
| 398 | 398 | return $pagenow; |
| 399 | 399 | } |
| 400 | 400 | |
| 401 | 401 | /** |
| 402 | + * Determines whether the current admin screen is the block editor. | |
| 403 | + * | |
| 404 | + * Deliberately uses get_current_screen() and not WP_Screen::get(): the latter re-applies | |
| 405 | + * the replace_editor filter on every call, which is a render hook with side effects | |
| 406 | + * (e.g. it breaks the WooCommerce block email editor). | |
| 407 | + * | |
| 408 | + * Only reliable after set_current_screen() has run (during admin page load, after | |
| 409 | + * admin_init); earlier calls return false. | |
| 410 | + * | |
| 411 | + * @return bool Whether the current screen is the block editor. | |
| 412 | + */ | |
| 413 | + public function is_block_editor() { | |
| 414 | + if ( ! \function_exists( 'get_current_screen' ) ) { | |
| 415 | + return false; | |
| 416 | + } | |
| 417 | + | |
| 418 | + $screen = \get_current_screen(); | |
| 419 | + | |
| 420 | + return $screen !== null && $screen->is_block_editor(); | |
| 421 | + } | |
| 422 | + | |
| 423 | + /** | |
| 402 | 424 | * Check if the current opened page is a Yoast SEO page. |
| 403 | 425 | * |
| 404 | 426 | * @return bool True when current page is a yoast seo plugin page. |
| 405 | 427 | */ |