Make WordPress Core

Changeset 41067


Ignore:
Timestamp:
07/18/2017 01:54:14 AM (9 years ago)
Author:
westonruter
Message:

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.

Location:
branches/4.8
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/4.8

  • branches/4.8/src/wp-admin/js/widgets/text-widgets.js

    r41053 r41067  
    179179                                // Abort building if the textarea is gone, likely due to the widget having been deleted entirely.
    180180                                if ( ! document.getElementById( id ) ) {
     181                                        return;
     182                                }
     183
     184                                // The user has disabled TinyMCE.
     185                                if ( typeof window.tinymce === 'undefined' ) {
     186                                        wp.editor.initialize( id, {
     187                                                quicktags: true
     188                                        });
     189
    181190                                        return;
    182191                                }
  • branches/4.8/src/wp-includes/class-wp-editor.php

    r41066 r41067  
    820820         */
    821821        public static function print_default_editor_scripts() {
    822                 $settings = self::default_settings();
    823 
    824                 $settings['toolbar1'] = 'bold,italic,bullist,numlist,link';
    825                 $settings['wpautop'] = false;
    826                 $settings['indent'] = true;
    827                 $settings['elementpath'] = false;
    828 
    829                 if ( is_rtl() ) {
    830                         $settings['directionality'] = 'rtl';
    831                 }
    832 
    833                 // In production all plugins are loaded (they are in wp-editor.js.gz)
    834                 // but only these will be initialized by default.
    835                 $settings['plugins'] = implode( ',', array(
    836                         'charmap',
    837                         'colorpicker',
    838                         'hr',
    839                         'lists',
    840         //              'media',
    841                         'paste',
    842                         'tabfocus',
    843                         'textcolor',
    844                         'fullscreen',
    845                         'wordpress',
    846                         'wpautoresize',
    847                         'wpeditimage',
    848                         'wpemoji',
    849                         'wpgallery',
    850                         'wplink',
    851         //              'wpdialogs',
    852                         'wptextpattern',
    853         //              'wpview',
    854                 ) );
    855 
    856                 $settings = self::_parse_init( $settings );
    857 
    858                 $suffix = SCRIPT_DEBUG ? '' : '.min';
    859                 $baseurl = self::get_baseurl();
     822                $user_can_richedit = user_can_richedit();
     823
     824                if ( $user_can_richedit ) {
     825                        $settings = self::default_settings();
     826
     827                        $settings['toolbar1'] = 'bold,italic,bullist,numlist,link';
     828                        $settings['wpautop'] = false;
     829                        $settings['indent'] = true;
     830                        $settings['elementpath'] = false;
     831
     832                        if ( is_rtl() ) {
     833                                $settings['directionality'] = 'rtl';
     834                        }
     835
     836                        // In production all plugins are loaded (they are in wp-editor.js.gz).
     837                        // The 'wpview', 'wpdialogs', and 'media' TinyMCE plugins are not initialized by default.
     838                        // Can be added from js by using the 'wp-before-tinymce-init' event.
     839                        $settings['plugins'] = implode( ',', array(
     840                                'charmap',
     841                                'colorpicker',
     842                                'hr',
     843                                'lists',
     844                                'paste',
     845                                'tabfocus',
     846                                'textcolor',
     847                                'fullscreen',
     848                                'wordpress',
     849                                'wpautoresize',
     850                                'wpeditimage',
     851                                'wpemoji',
     852                                'wpgallery',
     853                                'wplink',
     854                                'wptextpattern',
     855                        ) );
     856
     857                        $settings = self::_parse_init( $settings );
     858                } else {
     859                        $settings = '{}';
     860                }
    860861
    861862                ?>
     
    872873                };
    873874
    874                 var tinyMCEPreInit = {
    875                         baseURL: "<?php echo $baseurl; ?>",
    876                         suffix: "<?php echo $suffix; ?>",
    877                         mceInit: {},
    878                         qtInit: {},
    879                         load_ext: function(url,lang){var sl=tinymce.ScriptLoader;sl.markDone(url+'/langs/'+lang+'.js');sl.markDone(url+'/langs/'+lang+'_dlg.js');}
    880                 };
     875                <?php
     876
     877                if ( $user_can_richedit ) {
     878                        $suffix = SCRIPT_DEBUG ? '' : '.min';
     879                        $baseurl = self::get_baseurl();
     880
     881                        ?>
     882                        var tinyMCEPreInit = {
     883                                baseURL: "<?php echo $baseurl; ?>",
     884                                suffix: "<?php echo $suffix; ?>",
     885                                mceInit: {},
     886                                qtInit: {},
     887                                load_ext: function(url,lang){var sl=tinymce.ScriptLoader;sl.markDone(url+'/langs/'+lang+'.js');sl.markDone(url+'/langs/'+lang+'_dlg.js');}
     888                        };
     889                        <?php
     890                }
     891                ?>
    881892                </script>
    882893                <?php
    883894
    884                 self::print_tinymce_scripts();
     895                if ( $user_can_richedit ) {
     896                        self::print_tinymce_scripts();
     897                }
    885898
    886899                /**
Note: See TracChangeset for help on using the changeset viewer.