| @@ -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 | */ |
| @@ -426,8 +448,20 @@ | ||
| 426 | 448 | return \sanitize_text_field( \wp_unslash( $_GET['page'] ) ); |
| 427 | 449 | } |
| 428 | 450 | |
| 429 | 451 | return ''; |
| 452 | + } | |
| 453 | + | |
| 454 | + /** | |
| 455 | + * Returns whether the current admin overview (list table) shows the trash. | |
| 456 | + * | |
| 457 | + * Mirrors the check WP_Posts_List_Table itself uses to decide it is on the trash view. | |
| 458 | + * | |
| 459 | + * @return bool Whether the current admin overview shows the trash. | |
| 460 | + */ | |
| 461 | + public function is_trash_overview(): bool { | |
| 462 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information. | |
| 463 | + return isset( $_REQUEST['post_status'] ) && $_REQUEST['post_status'] === 'trash'; | |
| 430 | 464 | } |
| 431 | 465 | |
| 432 | 466 | /** |
| 433 | 467 | * Checks if the current global post is the privacy policy page. |