diff --git a/src/wp-admin/js/widgets/text-widgets.js b/src/wp-admin/js/widgets/text-widgets.js index 5a68516e5d..dfd2a88fc1 100644 --- a/src/wp-admin/js/widgets/text-widgets.js +++ b/src/wp-admin/js/widgets/text-widgets.js @@ -115,6 +115,15 @@ wp.textWidgets = ( function( $ ) { return; } + // The user has disabled TinyMCE. + if ( typeof window.tinymce === 'undefined' ) { + wp.editor.initialize( id, { + quicktags: true + }); + + return; + } + // Destroy any existing editor so that it can be re-initialized after a widget-updated event. if ( tinymce.get( id ) ) { restoreTextMode = tinymce.get( id ).isHidden(); diff --git a/src/wp-includes/class-wp-editor.php b/src/wp-includes/class-wp-editor.php index da39c96de1..86966d6f6b 100644 --- a/src/wp-includes/class-wp-editor.php +++ b/src/wp-includes/class-wp-editor.php @@ -819,45 +819,46 @@ final class _WP_Editors { * */ public static function print_default_editor_scripts() { - $settings = self::default_settings(); + $user_can_richedit = user_can_richedit(); - $settings['toolbar1'] = 'bold,italic,bullist,numlist,link'; - $settings['wpautop'] = false; - $settings['indent'] = true; - $settings['elementpath'] = false; + if ( $user_can_richedit ) { + $settings = self::default_settings(); - if ( is_rtl() ) { - $settings['directionality'] = 'rtl'; + $settings['toolbar1'] = 'bold,italic,bullist,numlist,link'; + $settings['wpautop'] = false; + $settings['indent'] = true; + $settings['elementpath'] = false; + + if ( is_rtl() ) { + $settings['directionality'] = 'rtl'; + } + + // In production all plugins are loaded (they are in wp-editor.js.gz). + // The 'wpview', 'wpdialogs', and 'media' TinyMCE plugins are not initialized by default. + // Can be added from js by using the 'wp-before-tinymce-init' event. + $settings['plugins'] = implode( ',', array( + 'charmap', + 'colorpicker', + 'hr', + 'lists', + 'paste', + 'tabfocus', + 'textcolor', + 'fullscreen', + 'wordpress', + 'wpautoresize', + 'wpeditimage', + 'wpemoji', + 'wpgallery', + 'wplink', + 'wptextpattern', + ) ); + + $settings = self::_parse_init( $settings ); + } else { + $settings = '{}'; } - // In production all plugins are loaded (they are in wp-editor.js.gz) - // but only these will be initialized by default. - $settings['plugins'] = implode( ',', array( - 'charmap', - 'colorpicker', - 'hr', - 'lists', - // 'media', - 'paste', - 'tabfocus', - 'textcolor', - 'fullscreen', - 'wordpress', - 'wpautoresize', - 'wpeditimage', - 'wpemoji', - 'wpgallery', - 'wplink', - // 'wpdialogs', - 'wptextpattern', - // 'wpview', - ) ); - - $settings = self::_parse_init( $settings ); - - $suffix = SCRIPT_DEBUG ? '' : '.min'; - $baseurl = self::get_baseurl(); - ?>