* @since 3.5.0 */ class CoreUtils { /** * Check to see if the Gutenberg Editor is being used. * * @link https://wordpress.stackexchange.com/a/324866 * * @since 3.0.0 * @since 3.5.0 Moved from Core\Utils to Core\CoreUtils */ public static function isGutenbergPage() { if (function_exists('is_gutenberg_page') && is_gutenberg_page()) { // The Gutenberg plugin is on. return true; } $currentScreen = null; if (function_exists('get_current_screen')) { $currentScreen = get_current_screen(); } if ($currentScreen === null) { return false; } if (method_exists($currentScreen, 'is_block_editor') && $currentScreen->is_block_editor()) { // Gutenberg page on 5+. return true; } return false; } /** * Check to see if current screen is an edit screen * (this includes the screen that lists the posts). * * @since 4.0.0 * @since 4.0.5 Ensure is_admin() and $screen */ public static function isEditScreen() { if (! is_admin()) { return false; } if (! function_exists('get_current_screen')) { return false; } $screen = get_current_screen(); if (! $screen || ! ($screen instanceof \WP_Screen)) { return false; } // TODO improve this check? if ($screen->parent_base === 'edit' || $screen->base === 'post') { return true; } return false; } }