Make WordPress Core


Ignore:
Timestamp:
08/19/2011 01:14:56 AM (15 years ago)
Author:
azaozz
Message:

Fix Press This editors, see #17144

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/class-wp-editor.php

    r18519 r18570  
    4949            'editor_class' => '', // add extra class(es) to the editor textarea
    5050            'teeny' => false, // output the minimal editor config used in Press This
     51            'dfw' => false, // replace the default fullscreen with DFW (needs specific css)
    5152            'tinymce' => true, // load TinyMCE, can be used to pass settings directly to TinyMCE using an array()
    5253            'quicktags' => true // load Quicktags, can be used to pass settings directly to Quicktags using an array()
     
    228229
    229230                    $plugins = array_unique( apply_filters('tiny_mce_plugins', $plugins) );
    230 
    231                     if ( 'content' == $editor_id ) // enable DFW only on Add/Edit Post screens for now
    232                         $plugins[] = 'wpfullscreen';
    233 
    234                     $this->plugins = $plugins;
    235 
    236                     /*
    237                     The following filter allows localization scripts to change the languages displayed in the spellchecker's drop-down menu.
    238                     By default it uses Google's spellchecker API, but can be configured to use PSpell/ASpell if installed on the server.
    239                     The + sign marks the default language. More information:
    240                     http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/spellchecker
    241                     */
    242                     $mce_spellchecker_languages = apply_filters('mce_spellchecker_languages', '+English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr,German=de,Italian=it,Polish=pl,Portuguese=pt,Spanish=es,Swedish=sv');
    243 
    244                     $this->first_init = array(
    245                         'mode' => 'exact',
    246                         'width' => '100%',
    247                         'theme' => 'advanced',
    248                         'skin' => 'wp_theme',
    249                         'language' => $this->mce_locale,
    250                         'spellchecker_languages' => $mce_spellchecker_languages,
    251                         'theme_advanced_toolbar_location' => 'top',
    252                         'theme_advanced_toolbar_align' => 'left',
    253                         'theme_advanced_statusbar_location' => 'bottom',
    254                         'theme_advanced_resizing' => true,
    255                         'theme_advanced_resize_horizontal' => false,
    256                         'dialog_type' => 'modal',
    257                         'formats' => "{
    258                             alignleft : [
    259                                 {selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li', styles : {textAlign : 'left'}},
    260                                 {selector : 'img,table', classes : 'alignleft'}
    261                             ],
    262                             aligncenter : [
    263                                 {selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li', styles : {textAlign : 'center'}},
    264                                 {selector : 'img,table', classes : 'aligncenter'}
    265                             ],
    266                             alignright : [
    267                                 {selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li', styles : {textAlign : 'right'}},
    268                                 {selector : 'img,table', classes : 'alignright'}
    269                             ],
    270                             strikethrough : {inline : 'del'}
    271                         }",
    272                         'relative_urls' => false,
    273                         'remove_script_host' => false,
    274                         'convert_urls' => false,
    275                         'remove_linebreaks' => true,
    276                         'gecko_spellcheck' => true,
    277                         'keep_styles' => false,
    278                         'entities' => '38,amp,60,lt,62,gt',
    279                         'accessibility_focus' => true,
    280                         'tabfocus_elements' => 'major-publishing-actions',
    281                         'media_strict' => false,
    282                         'paste_remove_styles' => true,
    283                         'paste_remove_spans' => true,
    284                         'paste_strip_class_attributes' => 'all',
    285                         'paste_text_use_dialog' => true,
    286                         'extended_valid_elements' => 'article[*],aside[*],audio[*],canvas[*],command[*],datalist[*],details[*],embed[*],figcaption[*],figure[*],footer[*],header[*],hgroup[*],keygen[*],mark[*],meter[*],nav[*],output[*],progress[*],section[*],source[*],summary,time[*],video[*],wbr',
    287                         'wpeditimage_disable_captions' => $no_captions,
    288                         'wp_fullscreen_content_css' => "$this->baseurl/plugins/wpfullscreen/css/wp-fullscreen.css",
    289                         'plugins' => implode( ',', $plugins )
    290                     );
    291 
    292                     // load editor_style.css if the current theme supports it
    293                     if ( ! empty( $editor_styles ) && is_array( $editor_styles ) ) {
    294                         $mce_css = array();
    295                         $style_uri = get_stylesheet_directory_uri();
    296                         if ( ! is_child_theme() ) {
    297                             foreach ( $editor_styles as $file )
     231                }
     232
     233                if ( $settings['dfw'] )
     234                    $plugins[] = 'wpfullscreen';
     235
     236                $this->plugins = $plugins;
     237
     238                /*
     239                The following filter allows localization scripts to change the languages displayed in the spellchecker's drop-down menu.
     240                By default it uses Google's spellchecker API, but can be configured to use PSpell/ASpell if installed on the server.
     241                The + sign marks the default language. More information:
     242                http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/spellchecker
     243                */
     244                $mce_spellchecker_languages = apply_filters('mce_spellchecker_languages', '+English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr,German=de,Italian=it,Polish=pl,Portuguese=pt,Spanish=es,Swedish=sv');
     245
     246                $this->first_init = array(
     247                    'mode' => 'exact',
     248                    'width' => '100%',
     249                    'theme' => 'advanced',
     250                    'skin' => 'wp_theme',
     251                    'language' => $this->mce_locale,
     252                    'spellchecker_languages' => $mce_spellchecker_languages,
     253                    'theme_advanced_toolbar_location' => 'top',
     254                    'theme_advanced_toolbar_align' => 'left',
     255                    'theme_advanced_statusbar_location' => 'bottom',
     256                    'theme_advanced_resizing' => true,
     257                    'theme_advanced_resize_horizontal' => false,
     258                    'dialog_type' => 'modal',
     259                    'formats' => "{
     260                        alignleft : [
     261                            {selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li', styles : {textAlign : 'left'}},
     262                            {selector : 'img,table', classes : 'alignleft'}
     263                        ],
     264                        aligncenter : [
     265                            {selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li', styles : {textAlign : 'center'}},
     266                            {selector : 'img,table', classes : 'aligncenter'}
     267                        ],
     268                        alignright : [
     269                            {selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li', styles : {textAlign : 'right'}},
     270                            {selector : 'img,table', classes : 'alignright'}
     271                        ],
     272                        strikethrough : {inline : 'del'}
     273                    }",
     274                    'relative_urls' => false,
     275                    'remove_script_host' => false,
     276                    'convert_urls' => false,
     277                    'remove_linebreaks' => true,
     278                    'gecko_spellcheck' => true,
     279                    'keep_styles' => false,
     280                    'entities' => '38,amp,60,lt,62,gt',
     281                    'accessibility_focus' => true,
     282                    'tabfocus_elements' => 'major-publishing-actions',
     283                    'media_strict' => false,
     284                    'paste_remove_styles' => true,
     285                    'paste_remove_spans' => true,
     286                    'paste_strip_class_attributes' => 'all',
     287                    'paste_text_use_dialog' => true,
     288                    'extended_valid_elements' => 'article[*],aside[*],audio[*],canvas[*],command[*],datalist[*],details[*],embed[*],figcaption[*],figure[*],footer[*],header[*],hgroup[*],keygen[*],mark[*],meter[*],nav[*],output[*],progress[*],section[*],source[*],summary,time[*],video[*],wbr',
     289                    'wpeditimage_disable_captions' => $no_captions,
     290                    'wp_fullscreen_content_css' => "$this->baseurl/plugins/wpfullscreen/css/wp-fullscreen.css",
     291                    'plugins' => implode( ',', $plugins )
     292                );
     293
     294                // load editor_style.css if the current theme supports it
     295                if ( ! empty( $editor_styles ) && is_array( $editor_styles ) ) {
     296                    $mce_css = array();
     297                    $style_uri = get_stylesheet_directory_uri();
     298                    if ( ! is_child_theme() ) {
     299                        foreach ( $editor_styles as $file )
     300                            $mce_css[] = "$style_uri/$file";
     301                    } else {
     302                        $style_dir    = get_stylesheet_directory();
     303                        $template_uri = get_template_directory_uri();
     304                        $template_dir = get_template_directory();
     305                        foreach ( $editor_styles as $file ) {
     306                            if ( file_exists( "$template_dir/$file" ) )
     307                                $mce_css[] = "$template_uri/$file";
     308                            if ( file_exists( "$style_dir/$file" ) )
    298309                                $mce_css[] = "$style_uri/$file";
    299                         } else {
    300                             $style_dir    = get_stylesheet_directory();
    301                             $template_uri = get_template_directory_uri();
    302                             $template_dir = get_template_directory();
    303                             foreach ( $editor_styles as $file ) {
    304                                 if ( file_exists( "$template_dir/$file" ) )
    305                                     $mce_css[] = "$template_uri/$file";
    306                                 if ( file_exists( "$style_dir/$file" ) )
    307                                     $mce_css[] = "$style_uri/$file";
    308                             }
    309310                        }
    310                         $mce_css = implode( ',', $mce_css );
    311                     } else {
    312                         $mce_css = '';
    313311                    }
    314 
    315                     $mce_css = trim( apply_filters( 'mce_css', $mce_css ), ' ,' );
    316 
    317                     if ( ! empty($mce_css) )
    318                         $this->first_init['content_css'] = $mce_css;
     312                    $mce_css = implode( ',', $mce_css );
     313                } else {
     314                    $mce_css = '';
    319315                }
     316
     317                $mce_css = trim( apply_filters( 'mce_css', $mce_css ), ' ,' );
     318
     319                if ( ! empty($mce_css) )
     320                    $this->first_init['content_css'] = $mce_css;
    320321            }
    321322
    322323            if ( $settings['teeny'] ) {
    323                 $mce_buttons = apply_filters( 'teeny_mce_buttons', array('bold, italic, underline, blockquote, separator, strikethrough, bullist, numlist,justifyleft, justifycenter, justifyright, undo, redo, link, unlink, fullscreen'), $editor_id );
     324                $mce_buttons = apply_filters( 'teeny_mce_buttons', array('bold', 'italic', 'underline', 'blockquote', 'separator', 'strikethrough', 'bullist', 'numlist', 'justifyleft', 'justifycenter', 'justifyright', 'undo', 'redo', 'link', 'unlink', 'fullscreen'), $editor_id );
    324325                $mce_buttons_2 = $mce_buttons_3 = $mce_buttons_4 = array();
    325326            } else {
    326                 $mce_buttons = apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', '|', 'bullist', 'numlist', 'blockquote', '|', 'justifyleft', 'justifycenter', 'justifyright', '|', 'link', 'unlink', 'wp_more', '|', 'spellchecker', 'fullscreen', 'wp_fullscreen', 'wp_adv' ), $editor_id);
     327                $mce_buttons = apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', '|', 'bullist', 'numlist', 'blockquote', '|', 'justifyleft', 'justifycenter', 'justifyright', '|', 'link', 'unlink', 'wp_more', '|', 'spellchecker', 'fullscreen', 'wp_adv' ), $editor_id);
    327328                $mce_buttons_2 = apply_filters('mce_buttons_2', array( 'formatselect', 'underline', 'justifyfull', 'forecolor', '|', 'pastetext', 'pasteword', 'removeformat', '|', 'charmap', '|', 'outdent', 'indent', '|', 'undo', 'redo', 'wp_help' ), $editor_id);
    328329                $mce_buttons_3 = apply_filters('mce_buttons_3', array(), $editor_id);
     
    330331            }
    331332
    332             if ( 'content' == $editor_id )
    333                 $arg = array('fullscreen');
    334             else
    335                 $arg = array('wp_fullscreen');
    336 
    337             $_buttons = compact('mce_buttons', 'mce_buttons_2', 'mce_buttons_3', 'mce_buttons_4');
    338             foreach ( $_buttons as $key => $val ) {
    339                 $_buttons[$key] = array_diff( $val, $arg );
    340             }
    341 
    342             extract($_buttons, EXTR_OVERWRITE);
     333            if ( $settings['dfw'] ) {
     334                function replace_fullscreen(&$val) {
     335                    if ( $val == 'fullscreen' )
     336                        $val = 'wp_fullscreen';
     337                }
     338
     339                array_walk($mce_buttons, 'replace_fullscreen');
     340                array_walk($mce_buttons_2, 'replace_fullscreen');
     341                array_walk($mce_buttons_3, 'replace_fullscreen');
     342                array_walk($mce_buttons_4, 'replace_fullscreen');
     343            }
    343344
    344345            $mceInit = array (
Note: See TracChangeset for help on using the changeset viewer.