TinyMCE: respect the Disable the visual editor when writing user setting and don't output the TinyMCE components when using wp_enqueue_editor().

Merges [40991] onto 4.8 branch.
Props azaozz.
Fixes #40960 for 4.8.1.

Built from https://develop.svn.wordpress.org/branches/4.8@41067


git-svn-id: http://core.svn.wordpress.org/branches/4.8@40919 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Weston Ruter 2017-07-18 01:55:32 +00:00
parent db65c15aba
commit d68bbe13cb
3 changed files with 66 additions and 44 deletions

View File

@ -181,6 +181,15 @@ wp.textWidgets = ( function( $ ) {
return; 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. // Destroy any existing editor so that it can be re-initialized after a widget-updated event.
if ( tinymce.get( id ) ) { if ( tinymce.get( id ) ) {
restoreTextMode = tinymce.get( id ).isHidden(); restoreTextMode = tinymce.get( id ).isHidden();

File diff suppressed because one or more lines are too long

View File

@ -819,6 +819,9 @@ final class _WP_Editors {
* *
*/ */
public static function print_default_editor_scripts() { public static function print_default_editor_scripts() {
$user_can_richedit = user_can_richedit();
if ( $user_can_richedit ) {
$settings = self::default_settings(); $settings = self::default_settings();
$settings['toolbar1'] = 'bold,italic,bullist,numlist,link'; $settings['toolbar1'] = 'bold,italic,bullist,numlist,link';
@ -830,14 +833,14 @@ final class _WP_Editors {
$settings['directionality'] = 'rtl'; $settings['directionality'] = 'rtl';
} }
// In production all plugins are loaded (they are in wp-editor.js.gz) // In production all plugins are loaded (they are in wp-editor.js.gz).
// but only these will be initialized by default. // 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( $settings['plugins'] = implode( ',', array(
'charmap', 'charmap',
'colorpicker', 'colorpicker',
'hr', 'hr',
'lists', 'lists',
// 'media',
'paste', 'paste',
'tabfocus', 'tabfocus',
'textcolor', 'textcolor',
@ -848,15 +851,13 @@ final class _WP_Editors {
'wpemoji', 'wpemoji',
'wpgallery', 'wpgallery',
'wplink', 'wplink',
// 'wpdialogs',
'wptextpattern', 'wptextpattern',
// 'wpview',
) ); ) );
$settings = self::_parse_init( $settings ); $settings = self::_parse_init( $settings );
} else {
$suffix = SCRIPT_DEBUG ? '' : '.min'; $settings = '{}';
$baseurl = self::get_baseurl(); }
?> ?>
<script type="text/javascript"> <script type="text/javascript">
@ -871,6 +872,13 @@ final class _WP_Editors {
}; };
}; };
<?php
if ( $user_can_richedit ) {
$suffix = SCRIPT_DEBUG ? '' : '.min';
$baseurl = self::get_baseurl();
?>
var tinyMCEPreInit = { var tinyMCEPreInit = {
baseURL: "<?php echo $baseurl; ?>", baseURL: "<?php echo $baseurl; ?>",
suffix: "<?php echo $suffix; ?>", suffix: "<?php echo $suffix; ?>",
@ -878,10 +886,15 @@ final class _WP_Editors {
qtInit: {}, qtInit: {},
load_ext: function(url,lang){var sl=tinymce.ScriptLoader;sl.markDone(url+'/langs/'+lang+'.js');sl.markDone(url+'/langs/'+lang+'_dlg.js');} load_ext: function(url,lang){var sl=tinymce.ScriptLoader;sl.markDone(url+'/langs/'+lang+'.js');sl.markDone(url+'/langs/'+lang+'_dlg.js');}
}; };
<?php
}
?>
</script> </script>
<?php <?php
if ( $user_can_richedit ) {
self::print_tinymce_scripts(); self::print_tinymce_scripts();
}
/** /**
* Fires when the editor scripts are loaded for later initialization, * Fires when the editor scripts are loaded for later initialization,