Make WordPress Core


Ignore:
Timestamp:
02/18/2008 05:11:12 PM (18 years ago)
Author:
ryan
Message:

TinyMCE config enhancements from azaozz. fixes #5896 #5888

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/js/tinymce/tiny_mce_config.php

    r6789 r6894  
    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 = '*[*]';
     
    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";
     
    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
     
    9191$mce_buttons_4 = apply_filters('mce_buttons_4', array());
    9292$mce_buttons_4 = implode($mce_buttons_4, ',');
    93 
    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, ',');
    9793
    9894$mce_locale = ( '' == get_locale() ) ? 'en' : strtolower( substr(get_locale(), 0, 2) ); // only ISO 639-1
     
    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',
     
    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
     
    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');
     
    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;
    165 
    166 $initArray['disk_cache'] = $initArray['compress'] = $initArray['del_old_cache'] = null;
    167 unset( $initArray['disk_cache'], $initArray['compress'], $initArray['del_old_cache'] );
     158$old_cache_max = ( isset($initArray['old_cache_max']) ) ? (int) $initArray['old_cache_max'] : 0;
     159
     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'] );
     
    189183
    190184    $ver = isset($_GET['ver']) ? (int) $_GET['ver'] : '';
    191     $cacheKey = $initArray['plugins'] . $language . $theme . $suffix . $ver;
    192 
     185    $cacheKey = $suffix . $ver;
     186
     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
     
    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
     
    225221
    226222// Patch loading functions
    227 $content .= 'tinyMCE_GZ.start();';
     223$content .= 'tinyMCEPreInit.start();';
    228224
    229225// Add all languages (WP)
     
    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');
    261            
    262         if ( '' != $old_key ) { //  && $old_key != $cacheKey
    263             $old_cache = $cache_path . '/tiny_mce_' . $old_key . $cache_ext;
    264             @unlink($old_cache);
     253if ( '' != $cacheKey && $cache_path ) {
     254    if ( $old_cache_max ) {
     255        $old_keys = getFileContents('tinymce_compressed_key' . $cache_ext);
     256           
     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?>
Note: See TracChangeset for help on using the changeset viewer.