Make WordPress Core

Changeset 40991 for trunk


Ignore:
Timestamp:
07/01/2017 09:30:10 PM (9 years ago)
Author:
azaozz
Message:

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

Fixes #40960 for trunk.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/js/widgets/text-widgets.js

    r40990 r40991  
    113113                                // Abort building if the textarea is gone, likely due to the widget having been deleted entirely.
    114114                                if ( ! document.getElementById( id ) ) {
     115                                        return;
     116                                }
     117
     118                                // The user has disabled TinyMCE.
     119                                if ( typeof window.tinymce === 'undefined' ) {
     120                                        wp.editor.initialize( id, {
     121                                                quicktags: true
     122                                        });
     123
    115124                                        return;
    116125                                }
  • trunk/src/wp-includes/class-wp-editor.php

    r40927 r40991  
    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.