woocommerce-multilingual
/
addons
/
wpml-dependencies
/
lib
/
classes
/
block-editor
/
class-wpml-block-editor-helper.php
woocommerce-multilingual
/
addons
/
wpml-dependencies
/
lib
/
classes
/
block-editor
Last commit date
class-wpml-block-editor-helper.php
3 weeks ago
class-wpml-block-editor-helper.php
49 lines
| 1 | <?php |
| 2 | |
| 3 | class WPML_Block_Editor_Helper { |
| 4 | |
| 5 | public static function is_active() { |
| 6 | $gutenberg = ! ( false === has_filter( 'replace_editor', 'gutenberg_init' ) ); |
| 7 | |
| 8 | $block_editor = version_compare( $GLOBALS['wp_version'], '5.0-beta', '>' ); |
| 9 | |
| 10 | if ( ! $gutenberg && ! $block_editor ) { |
| 11 | return false; |
| 12 | } |
| 13 | |
| 14 | if ( self::is_classic_editor_plugin_active() ) { |
| 15 | $editor_option = get_option( 'classic-editor-replace' ); |
| 16 | $block_editor_active = array( 'no-replace', 'block' ); |
| 17 | |
| 18 | return in_array( $editor_option, $block_editor_active, true ); |
| 19 | } |
| 20 | |
| 21 | return true; |
| 22 | } |
| 23 | |
| 24 | public static function is_edit_post() { |
| 25 | $current_screen = get_current_screen(); |
| 26 | return $current_screen && 'post' === $current_screen->base && self::is_active() && self::is_block_editor( $current_screen ); |
| 27 | } |
| 28 | |
| 29 | public static function is_classic_editor_plugin_active() { |
| 30 | if ( ! function_exists( 'is_plugin_active' ) ) { |
| 31 | include_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 32 | } |
| 33 | |
| 34 | if ( is_plugin_active( 'classic-editor/classic-editor.php' ) ) { |
| 35 | return true; |
| 36 | } |
| 37 | |
| 38 | return false; |
| 39 | } |
| 40 | |
| 41 | public static function is_block_editor( $current_screen ) { |
| 42 | if ( version_compare( $GLOBALS['wp_version'], '5.0-beta', '>' ) ) { |
| 43 | return $current_screen->is_block_editor(); |
| 44 | } else { |
| 45 | return false; |
| 46 | } |
| 47 | } |
| 48 | } |
| 49 |