Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Honor the Disable Visual Editor setting #12000

Merged
merged 5 commits into from
Nov 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ function the_gutenberg_project() {
* @since 0.1.0
*/
function gutenberg_menu() {
if ( ! gutenberg_can_edit_post( $post ) ) {
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check is creating a warning and for me it doesn't make sense to check this here at all. It's being addressed in #12053

global $submenu;

add_menu_page(
Expand Down Expand Up @@ -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.
*
Expand Down
6 changes: 0 additions & 6 deletions lib/client-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand Down