diff --git a/gutenberg.php b/gutenberg.php index 762707d175574..7ce8db46c2078 100644 --- a/gutenberg.php +++ b/gutenberg.php @@ -67,6 +67,9 @@ function the_gutenberg_project() { * @since 0.1.0 */ function gutenberg_menu() { + if ( ! gutenberg_can_edit_post( $post ) ) { + return; + } global $submenu; add_menu_page( @@ -200,6 +203,13 @@ function gutenberg_pre_init() { add_filter( 'replace_editor', 'gutenberg_init', 10, 2 ); } +/** + * Enable Gutenberg based on user_can_richedit setting. + * Set gutenberg_can_edit_post based on user setting for disable visual editor. + */ +add_filter( 'gutenberg_can_edit_post_type', 'user_can_richedit', 5 ); +add_filter( 'gutenberg_can_edit_post', 'user_can_richedit', 5 ); + /** * Initialize Gutenberg. * diff --git a/lib/client-assets.php b/lib/client-assets.php index 7f4acff26619e..e69773ec13b12 100644 --- a/lib/client-assets.php +++ b/lib/client-assets.php @@ -1419,12 +1419,6 @@ function gutenberg_editor_scripts_and_styles( $hook ) { 'after' ); - // Ignore Classic Editor's `rich_editing` user option, aka "Disable visual - // editor". Forcing this to be true guarantees that TinyMCE and its plugins - // are available in Gutenberg. Fixes - // https://github.com/WordPress/gutenberg/issues/5667. - add_filter( 'user_can_richedit', '__return_true' ); - wp_enqueue_script( 'wp-edit-post' ); wp_enqueue_script( 'wp-format-library' ); wp_enqueue_style( 'wp-format-library' );