Make WordPress Core

Ticket #5896: loading-compressor-upd.patch

File loading-compressor-upd.patch, 18.0 KB (added by azaozz, 19 years ago)
  • wp-admin/page-new.php

     
    55$editing = true;
    66wp_enqueue_script('autosave');
    77wp_enqueue_script('page');
    8 wp_enqueue_script('editor');
     8if ( user_can_richedit() )
     9        wp_enqueue_script('editor');
    910wp_enqueue_script('thickbox');
    1011wp_enqueue_script('media-upload');
    1112
  • wp-admin/page.php

     
    5353        }
    5454
    5555        wp_enqueue_script('page');
    56         wp_enqueue_script('editor');
     56        if ( user_can_richedit() )
     57                wp_enqueue_script('editor');
    5758        wp_enqueue_script('thickbox');
    5859        wp_enqueue_script('media-upload');
    5960
  • wp-admin/post-new.php

     
    55$editing = true;
    66wp_enqueue_script('autosave');
    77wp_enqueue_script('post');
    8 wp_enqueue_script('editor');
     8if ( user_can_richedit() )
     9        wp_enqueue_script('editor');
    910wp_enqueue_script('thickbox');
    1011wp_enqueue_script('media-upload');
    1112
  • wp-admin/post.php

     
    6262        }
    6363
    6464        wp_enqueue_script('post');
    65         wp_enqueue_script('editor');
     65        if ( user_can_richedit() )
     66                wp_enqueue_script('editor');
    6667        wp_enqueue_script('thickbox');
    6768        wp_enqueue_script('media-upload');
    6869
  • wp-admin/wp-admin.css

     
    260260        color: #fff;
    261261}
    262262
    263 #postdivrich #quicktags {
     263#postdivrich #quicktags, #postdiv #quicktags {
    264264        background: #cee1ef;
    265265        padding: 0;
    266266        border: 0 none;
    267267}
    268268
    269 #postdiv #quicktags {
    270         padding-right: 6px;
    271 }
    272 
    273269#quicktags #ed_toolbar {
    274270        padding: 0 2px;
    275271}
  • wp-includes/general-template.php

     
    923923        if (($rows < 3) || ($rows > 100))
    924924                $rows = 12;
    925925
    926         $rows = "rows='$rows'";
    927 
    928         if ( user_can_richedit() ) :
    929                 $wp_default_editor = wp_default_editor();
    930                 $active = " class='active'";
    931                 $inactive = " onclick='switchEditors.go(\"$id\");'";
    932 
    933                 if ( 'tinymce' == $wp_default_editor )
    934                         add_filter('the_editor_content', 'wp_richedit_pre');
    935                 else if ( 'html' == $wp_default_editor )
    936                         add_filter('the_editor_content', 'wp_htmledit_pre');
    937 
    938                 //      The following line moves the border so that the active button "attaches" to the toolbar. Only IE needs it.
    939         ?>
    940     <style type="text/css">
    941                 #postdivrich table, #postdivrich #quicktags {border-top: none;}
    942                 #quicktags {border-bottom: none; padding-bottom: 2px; margin-bottom: -1px;}
    943         </style>
    944 
    945         <div id='editor-toolbar' style='display:none;'>
    946                 <div class='zerosize'><input accesskey='e' type='button' onclick='switchEditors.go("<?php echo $id; ?>")' /></div>
    947                 <a id='edButtonHTML'<?php echo 'html' == $wp_default_editor ? $active : $inactive; ?>><?php _e('HTML'); ?></a>
    948                 <a id='edButtonPreview'<?php echo 'tinymce' == $wp_default_editor ? $active : $inactive; ?>><?php _e('Visual'); ?></a>
    949 
    950                 <div id="media-buttons">
    951                 <?php _e('Add media:'); ?>
    952                 <?php do_action( 'media_buttons'); ?>
    953                 </div>
     926        $rows = "rows='$rows'"; ?>
     927        <div id="editor-toolbar">
     928        <?php if ( user_can_richedit() ) {
     929                $wp_default_editor = wp_default_editor(); ?>
     930                <div class="zerosize"><input accesskey="e" type="button" onclick="switchEditors.go('<?php echo $id; ?>')" /></div>
     931                <?php if ( 'tinymce' == $wp_default_editor ) {
     932                        add_filter('the_editor_content', 'wp_richedit_pre'); ?>
     933                        <a id="edButtonHTML" onclick="switchEditors.go('<?php echo $id; ?>');"><?php _e('HTML'); ?></a>
     934                        <a id="edButtonPreview" class="active"><?php _e('Visual'); ?></a>
     935                <?php } elseif ( 'html' == $wp_default_editor ) {
     936                        add_filter('the_editor_content', 'wp_htmledit_pre'); ?>
     937                        <a id="edButtonHTML" class="active"><?php _e('HTML'); ?></a>
     938                        <a id="edButtonPreview" onclick="switchEditors.go('<?php echo $id; ?>');"><?php _e('Visual'); ?></a>
     939                <?php }
     940        } ?>
     941                <div id="media-buttons">
     942                <?php _e('Add media:'); ?>
     943                <?php do_action( 'media_buttons'); ?>
     944                </div>
    954945        </div>
    955946
    956         <script type="text/javascript">
    957         // <![CDATA[
    958                 if ( typeof tinyMCE != "undefined" )
    959                         document.getElementById('editor-toolbar').style.display = 'block';
    960         // ]]>
    961         </script>
    962        
    963         <?php else: // Rich editor is disabled in profile but we still need the media buttons   ?>
    964                
    965         <div id='editor-toolbar' style='display:block;'>
    966                 <div id="media-buttons">
    967                 <?php _e('Add media:'); ?>
    968                 <?php do_action( 'media_buttons'); ?>
    969                 </div>
    970         </div>
    971 
    972         <?php endif; // user_can_richedit() ?>
    973 
    974947        <div id="quicktags">
    975948        <?php wp_print_scripts( 'quicktags' ); ?>
    976949        <script type="text/javascript">edToolbar()</script>
    977950        </div>
    978951
    979         <?php if ( 'html' != $wp_default_editor ) : ?>
    980         <script type="text/javascript">
    981         // <![CDATA[
    982                 if ( typeof tinyMCE != "undefined" )
    983                         document.getElementById("quicktags").style.display="none";
    984         // ]]>
    985         </script>
    986         <?php endif; // 'html' != $wp_default_editor
     952    <?php if ( 'html' != $wp_default_editor ) : ?>
     953    <script type="text/javascript">
     954    // <![CDATA[
     955        if ( typeof tinyMCE != "undefined" )
     956            document.getElementById("quicktags").style.display="none";
     957    // ]]>
     958    </script>
     959    <?php endif; // 'html' != $wp_default_editor
    987960
    988961        $the_editor = apply_filters('the_editor', "<div id='editorcontainer'><textarea class='' $rows cols='40' name='$id' tabindex='2' id='$id'>%s</textarea></div>\n");
    989962        $the_editor_content = apply_filters('the_editor_content', $content);
     
    991964        printf($the_editor, $the_editor_content);
    992965
    993966        ?>
    994         <script type="text/javascript">
    995         //<!--
    996         edCanvas = document.getElementById('<?php echo $id; ?>');
    997         <?php if ( $prev_id && user_can_richedit() ) : ?>
    998         // If tinyMCE is defined.
    999         if ( typeof tinyMCE != 'undefined' ) {
    1000         // This code is meant to allow tabbing from Title to Post (TinyMCE).
     967    <script type="text/javascript">
     968    // <![CDATA[
     969    edCanvas = document.getElementById('<?php echo $id; ?>');
     970    <?php if ( $prev_id && user_can_richedit() ) : ?>
     971    // If tinyMCE is defined.
     972    if ( typeof tinyMCE != 'undefined' ) {
     973    // This code is meant to allow tabbing from Title to Post (TinyMCE).
    1001974        document.getElementById('<?php echo $prev_id; ?>').onkeydown = function (e) {
    1002975            e = e || window.event;
    1003976            if (e.keyCode == 9 && !e.shiftKey && !e.controlKey && !e.altKey) {
     
    1010983                return true;
    1011984            }
    1012985        }
    1013         }
    1014         <?php endif; ?>
    1015         //-->
    1016         </script>
    1017         <?php
     986    }
     987    <?php endif; ?>
     988    // ]]>
     989    </script>
     990    <?php
    1018991}
    1019992
    1020993function get_search_query() {
  • wp-includes/js/tinymce/tiny_mce_config.php

     
    4747$https = ( isset($_SERVER['HTTPS']) && 'on' == $_SERVER['HTTPS'] ) ? true : false;
    4848       
    4949$baseurl = get_option('siteurl') . '/wp-includes/js/tinymce';
    50 $baseurl = $https ? str_replace('http://', 'https://', $baseurl) : $baseurl;
     50if ( $https ) str_replace('http://', 'https://', $baseurl);
    5151
    5252$mce_css = $baseurl . '/wordpress.css';
    5353$mce_css = apply_filters('mce_css', $mce_css);
    54 $mce_css = $https ? str_replace('http://', 'https://', $mce_css) : $mce_css;
     54if ( $https ) str_replace('http://', 'https://', $mce_css);
    5555
    5656$valid_elements = '*[*]';
    5757$valid_elements = apply_filters('mce_valid_elements', $valid_elements);
     
    7272$ext_plugins = "\n";
    7373foreach ( $mce_external_plugins as $name => $url ) {
    7474        $plugins[] = '-' . $name;
    75         $url = $https ? str_replace('http://', 'https://', $url) : $url;
     75        if ( $https ) str_replace('http://', 'https://', $url);
    7676       
    7777        $ext_plugins .= 'tinymce.PluginManager.load("' . $name . '", "' . $url . '");' . "\n";
    7878}
    7979
    8080$plugins = implode($plugins, ',');
    8181
    82 $mce_buttons = apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', '|', 'bullist', 'numlist', 'outdent', 'indent', '|', 'justifyleft', 'justifycenter', 'justifyright', '|', 'link', 'unlink', 'image', 'wp_more', '|', 'spellchecker', '|', 'wp_help', 'wp_adv' ));
     82$mce_buttons = apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', '|', 'bullist', 'numlist', 'outdent', 'indent', '|', 'justifyleft', 'justifycenter', 'justifyright', '|', 'link', 'unlink', 'image', 'wp_more', '|', 'spellchecker', 'fullscreen', 'wp_adv' ));
    8383$mce_buttons = implode($mce_buttons, ',');
    8484
    85 $mce_buttons_2 = apply_filters('mce_buttons_2', array('formatselect', 'underline', 'justifyfull', 'forecolor', '|', 'pastetext', 'pasteword', '|', 'removeformat', 'cleanup', '|', 'media', 'charmap', 'blockquote', '|', 'undo', 'redo', 'fullscreen' ));
     85$mce_buttons_2 = apply_filters('mce_buttons_2', array('formatselect', 'underline', 'justifyfull', 'forecolor', '|', 'pastetext', 'pasteword', '|', 'removeformat', 'cleanup', '|', 'media', 'charmap', 'blockquote', '|', 'undo', 'redo', 'wp_help' ));
    8686$mce_buttons_2 = implode($mce_buttons_2, ',');
    8787
    8888$mce_buttons_3 = apply_filters('mce_buttons_3', array());
     
    9191$mce_buttons_4 = apply_filters('mce_buttons_4', array());
    9292$mce_buttons_4 = implode($mce_buttons_4, ',');
    9393
    94 // all these browsers are now 100% supported, no need for this
    95 //$mce_browsers = apply_filters('mce_browsers', array('msie', 'gecko', 'opera', 'safari'));
    96 //$mce_browsers = implode($mce_browsers, ',');
    97 
    9894$mce_locale = ( '' == get_locale() ) ? 'en' : strtolower( substr(get_locale(), 0, 2) ); // only ISO 639-1
    9995
    10096// TinyMCE init settings
     
    114110        'theme_advanced_statusbar_location' => 'bottom',
    115111        'theme_advanced_resizing' => true,
    116112        'theme_advanced_resize_horizontal' => false,
    117 //      'browsers' => "$mce_browsers",
    118113        'dialog_type' => 'modal',
    119         'convert_urls' => false,
    120114        'relative_urls' => false,
    121115        'remove_script_host' => false,
    122116        'fix_list_elements' => true,
    123         'fix_table_elements' => true,
     117//      'fix_table_elements' => true,
    124118        'gecko_spellcheck' => true,
    125119        'entities' => '38,amp,60,lt,62,gt',
    126120        'accessibility_focus' => false,
     
    131125        // pass-through the settings for compression and caching, so they can be changed with "tiny_mce_before_init"
    132126        'disk_cache' => true,
    133127        'compress' => true,
    134         'del_old_cache' => true
     128        'old_cache_max' => '3' // number of cache files to keep
    135129);
    136130
    137131if ( $valid_elements ) $initArray['valid_elements'] = $valid_elements;
     
    148142ob_end_clean();
    149143
    150144/*
    151 // Do we need to support this? Most likely will breal TinyMCE 3...
     145// Do we need to support this? Most likely will break TinyMCE 3...
    152146ob_start();
    153147do_action('tinymce_before_init');
    154148$mce_deprecated2 = ob_get_contents() || '';
     
    161155
    162156$disk_cache = ( ! isset($initArray['disk_cache']) || false == $initArray['disk_cache'] ) ? false : true;
    163157$compress = ( ! isset($initArray['compress']) || false == $initArray['compress'] ) ? false : true;
    164 $del_old_cache = ( ! isset($initArray['del_old_cache']) || false == $initArray['del_old_cache'] ) ? false : true;
     158$old_cache_max = ( isset($initArray['old_cache_max']) ) ? (int) $initArray['old_cache_max'] : 0;
    165159
    166 $initArray['disk_cache'] = $initArray['compress'] = $initArray['del_old_cache'] = null;
    167 unset( $initArray['disk_cache'], $initArray['compress'], $initArray['del_old_cache'] );
     160$initArray['disk_cache'] = $initArray['compress'] = $initArray['old_cache_max'] = null;
     161unset( $initArray['disk_cache'], $initArray['compress'], $initArray['old_cache_max'] );
    168162
    169163$plugins = explode( ',', $initArray['plugins'] );
    170164$theme = ( 'simple' == $initArray['theme'] ) ? 'simple' : 'advanced';
     
    188182if ( $disk_cache && $cache_path ) {
    189183
    190184        $ver = isset($_GET['ver']) ? (int) $_GET['ver'] : '';
    191         $cacheKey = $initArray['plugins'] . $language . $theme . $suffix . $ver;
     185        $cacheKey = $suffix . $ver;
    192186
     187        foreach ( $initArray as $v )
     188                $cacheKey .= $v;
     189       
    193190        foreach ( $custom_js as $file )
    194191                $cacheKey .= $file;
    195192
    196193        $cacheKey = md5( $cacheKey );
    197         $cache_file = $cache_path . '/tiny_mce_' . $cacheKey . $cache_ext;
     194        $cache_file = $cache_path . '/tinymce_' . $cacheKey . $cache_ext;
    198195}
    199196
    200197cache_javascript_headers();
     
    209206}
    210207
    211208foreach ( $initArray as $k => $v )
    212     $mce_options .= $k . ':"' . $v . '", ';
     209    $mce_options .= $k . ':"' . $v . '",';
    213210
    214211$mce_options .= $mce_deprecated1;
    215212$mce_options = rtrim( trim($mce_options), '\n\r,' );
    216213
    217 $content = 'var tinyMCEPreInit = { suffix : "' . $suffix . '", base : "' . $baseurl . '" };';
    218 $content .= 'var tinyMCE_GZ = { settings : { themes : "' . $theme . '", plugins : "' . $initArray['plugins'] . '", languages : "' . $language . '", debug : false, suffix : "' . $suffix . '" }, baseURL : "' . $baseurl . '" };';
     214$content .= 'var tinyMCEPreInit = { settings : { themes : "' . $theme . '", plugins : "' . $initArray['plugins'] . '", languages : "' . $language . '", debug : false }, base : "' . $baseurl . '", suffix : "' . $suffix . '" };';
    219215
    220216// Load patch
    221217$content .= getFileContents( 'tiny_mce_ext.js' );
     
    224220$content .= getFileContents( 'tiny_mce' . $suffix . '.js' );
    225221
    226222// Patch loading functions
    227 $content .= 'tinyMCE_GZ.start();';
     223$content .= 'tinyMCEPreInit.start();';
    228224
    229225// Add all languages (WP)
    230226include_once( dirname(__FILE__).'/langs/wp-langs.php' );
     
    247243// Generate GZIP'd content
    248244if ( '.gz' == $cache_ext ) {
    249245        header('Content-Encoding: ' . $enc);
    250         $cache_data = gzencode( $content, 9, FORCE_GZIP );
    251 } else
    252         $cache_data = $content;
     246        $content = gzencode( $content, 9, FORCE_GZIP );
     247}
    253248
    254249// Stream to client
    255 echo $cache_data;
     250echo $content;
    256251
    257252// Write file
    258 if ( '' != $cacheKey ) {
    259         if ( $del_old_cache ) {
    260                 $old_key = getFileContents('tiny_mce_compressed_key');
     253if ( '' != $cacheKey && $cache_path ) {
     254        if ( $old_cache_max ) {
     255                $old_keys = getFileContents('tinymce_compressed_key' . $cache_ext);
    261256                       
    262                 if ( '' != $old_key ) { //  && $old_key != $cacheKey
    263                         $old_cache = $cache_path . '/tiny_mce_' . $old_key . $cache_ext;
    264                         @unlink($old_cache);
     257                if ( '' != $old_keys ) {
     258                        $keys_ar = explode( "\n", $old_keys );
     259                        if ( ($old_cache_max - 1) > count($old_keys_ar) )
     260                                $old_keys_rem = array_slice( $keys_ar, ($old_cache_max - 1) );
     261                       
     262                        foreach ( $old_keys_rem as $key ) {
     263                                $key = trim($key);
     264                                if ( 32 != strlen($key) ) continue;
     265                                $old_cache = $cache_path . '/tinymce_' . $key . $cache_ext;
     266                                @unlink($old_cache);
     267                        }
     268                       
     269                        array_unshift( $keys_ar, $cacheKey );
     270                        $keys_ar = array_slice( $keys_ar, 0, $old_cache_max );
     271                        $cacheKey = trim( implode( "\n", $keys_ar ) );
     272                       
    265273                }
    266                        
    267                 putFileContents( 'tiny_mce_compressed_key', $cacheKey );
     274               
     275                putFileContents( 'tinymce_compressed_key' . $cache_ext, $cacheKey );
    268276        }
    269                
    270         putFileContents( $cache_file, $cache_data );
     277       
     278        putFileContents( $cache_file, $content );
    271279}
    272280?>
     281 No newline at end of file
  • wp-includes/js/tinymce/tiny_mce_ext.js

     
    1 
    2 tinyMCE_GZ.start = function() {
     1tinyMCEPreInit.start = function() {
    32        var t = this, each = tinymce.each, s = t.settings, sl = tinymce.ScriptLoader, ln = s.languages.split(',');
    43
    54        function load(u, sp) {
    65                var o;
    76
    87                if (!sp)
    9                         u = t.baseURL + u;
     8                        u = t.base + u;
    109
    1110                o = {url : u, state : 2};
    1211                sl.queue.push(o);
     
    2221        // Add themes with languages
    2322        each(s.themes.split(','), function(n) {
    2423                if (n) {
    25                         load('/themes/' + n + '/editor_template' + s.suffix + '.js');
     24                        load('/themes/' + n + '/editor_template' + t.suffix + '.js');
    2625
    2726                        each (ln, function(c) {
    2827                                if (c)
     
    3433        // Add plugins with languages
    3534        each(s.plugins.split(','), function(n) {
    3635                if (n && n.charAt(0) != '-') {
    37                         load('/plugins/' + n + '/editor_plugin' + s.suffix + '.js');
     36                        load('/plugins/' + n + '/editor_plugin' + t.suffix + '.js');
    3837
    3938                        each (ln, function(c) {
    4039                                if (c)
  • wp-includes/script-loader.php

     
    2929
    3030                $this->add( 'colorpicker', '/wp-includes/js/colorpicker.js', false, '3517' );
    3131
    32                 // Modify this version when tinyMCE plugins are changed
    33                 $mce_config = apply_filters('tiny_mce_config_url', '/wp-includes/js/tinymce/tiny_mce_config.php');
    34                 $this->add( 'tiny_mce', $mce_config, false, '20080209' );
     32                // Let a plugin replace the visual editor
     33                $visual_editor = apply_filters('visual_editor', array('tiny_mce'));
     34                $this->add( 'editor', false, $visual_editor, '20080218' );
    3535               
     36                $this->add( 'editor_functions', '/wp-admin/js/editor.js', false, '20080208' );
     37               
     38                // Modify this version when tinyMCE plugins are changed.
     39                $mce_version = apply_filters('tiny_mce_version', '20080209');
     40                $this->add( 'tiny_mce', '/wp-includes/js/tinymce/tiny_mce_config.php', array('editor_functions'), $mce_version );
     41                $this->localize( 'tiny_mce', 'wpTinyMCEConfig', array( 'defaultEditor' => wp_default_editor() ) );
     42               
    3643                $this->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.6');
    3744
    3845                $this->add( 'autosave', '/wp-includes/js/autosave.js', array('jquery', 'schedule'), '20080206');
     
    474481        return $js_array;
    475482}
    476483
    477 // These localizations require information that may not be loaded even by init
    478 function wp_just_in_time_script_localization() {
    479         wp_localize_script( 'tiny_mce', 'wpTinyMCEConfig', array( 'defaultEditor' => wp_default_editor() ) );
    480 }
    481 
    482 add_filter( 'wp_print_scripts', 'wp_just_in_time_script_localization' );
    483484add_filter( 'print_scripts_array', 'wp_prototype_before_jquery' );
    484485
    485 ?>
     486?>
     487 No newline at end of file