| 1 |
<?php |
| 2 |
|
| 3 |
namespace Leadin\wp; |
| 4 |
|
| 5 |
/** |
| 6 |
* Static function that wraps WordPress utility functions for WordPress pages. |
| 7 |
*/ |
| 8 |
class Page { |
| 9 |
/** |
| 10 |
* Return true if the current page has Gutenberg active. |
| 11 |
*/ |
| 12 |
public static function is_gutenberg_page() { |
| 13 |
if ( function_exists( 'is_gutenberg_page' ) && is_gutenberg_page() ) { |
| 14 |
// The Gutenberg plugin is on. |
| 15 |
return true; |
| 16 |
} |
| 17 |
|
| 18 |
$current_screen = get_current_screen(); |
| 19 |
if ( method_exists( $current_screen, 'is_block_editor' ) && $current_screen->is_block_editor() ) { |
| 20 |
// Gutenberg page on 5+. |
| 21 |
return true; |
| 22 |
} |
| 23 |
return false; |
| 24 |
} |
| 25 |
|
| 26 |
/** |
| 27 |
* Return true if the current page is the WP Admin dashboard. |
| 28 |
*/ |
| 29 |
public static function is_dashboard() { |
| 30 |
$screen = get_current_screen(); |
| 31 |
return 'dashboard' === $screen->id; |
| 32 |
} |
| 33 |
} |
| 34 |
|