Make WordPress Core


Ignore:
Timestamp:
03/06/2008 07:56:02 PM (17 years ago)
Author:
ryan
Message:

Added filter for changing the languages selection for the spellchecker, fixed problems with valid_elements and added filter for extended_valid_elements, update to the latest version. Props azaozz. fixes #6111

File:
1 edited

Legend:

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

    r7159 r7173  
    4545
    4646// Set up init variables
    47 $https = ( isset($_SERVER['HTTPS']) && 'on' == $_SERVER['HTTPS'] ) ? true : false;
     47$https = ( isset($_SERVER['HTTPS']) && 'on' == strtolower($_SERVER['HTTPS']) ) ? true : false;
    4848   
    4949$baseurl = get_option('siteurl') . '/wp-includes/js/tinymce';
     
    5454if ( $https ) str_replace('http://', 'https://', $mce_css);
    5555
    56 $valid_elements = '*[*]';
    57 $valid_elements = apply_filters('mce_valid_elements', $valid_elements);
    58    
     56/*
     57Setting mce_valid_elements to *[*] skips all of the internal cleanup and can cause problems.
     58The minimal setting would be -strong/-b[*],-em/-i[*],*[*].
     59Best is to use the default cleanup by not specifying mce_valid_elements,
     60and then use extended_valid_elements to add to it.
     61*/
     62$valid_elements = apply_filters('mce_valid_elements', '');
    5963$invalid_elements = apply_filters('mce_invalid_elements', '');
     64
     65$extended_valid_elements = '@[id|class|style|title|dir<ltr?rtl|lang|xml::lang|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup],bdo,code,col[*],colgroup[*],dfn,fieldset,form[*],input[*],kbd,label[*],legend[*],noscript,optgroup[*],option[*],q[cite|class],samp,textarea[*],title,var';
     66
     67$extended_valid_elements = apply_filters('mce_extended_valid_elements', $extended_valid_elements);
     68
     69/*
     70The following filter allows localization scripts to change the languages displayed in the spellchecker's drop-down menu.
     71By default it uses Google's spellchecker API, but can be configured to use PSpell/ASpell if installed on the server.
     72The + sign marks the default language.
     73More information:
     74http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/spellchecker
     75*/
     76$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');
    6077
    6178$plugins = array( 'safari', 'inlinepopups', 'autosave', 'spellchecker', 'paste', 'wordpress', 'media', 'fullscreen' );
     
    7188
    7289$ext_plugins = "\n";
    73 foreach ( $mce_external_plugins as $name => $url ) {
    74     $plugins[] = '-' . $name;
    75     if ( $https ) str_replace('http://', 'https://', $url);
    76    
    77     $ext_plugins .= 'tinymce.PluginManager.load("' . $name . '", "' . $url . '");' . "\n";
    78 }
    79 
     90if ( ! empty($mce_external_plugins) ) {
     91    foreach ( $mce_external_plugins as $name => $url ) {
     92        if ( $https ) str_replace('http://', 'https://', $url);
     93        $plugins[] = '-' . $name;
     94        $ext_plugins .= 'tinymce.PluginManager.load("' . $name . '", "' . $url . '");' . "\n";
     95    }
     96}
    8097$plugins = implode($plugins, ',');
    8198
     
    106123    'theme_advanced_buttons4' => "$mce_buttons_4",
    107124    'language' => "$mce_locale",
     125    'spellchecker_languages' => "$mce_spellchecker_languages",
    108126    'theme_advanced_toolbar_location' => 'top',
    109127    'theme_advanced_toolbar_align' => 'left',
     
    114132    'relative_urls' => false,
    115133    'remove_script_host' => false,
    116     'fix_list_elements' => true,
    117     'fix_table_elements' => true,
    118134    'gecko_spellcheck' => true,
    119135    'entities' => '38,amp,60,lt,62,gt',
     
    130146
    131147if ( $valid_elements ) $initArray['valid_elements'] = $valid_elements;
     148if ( $extended_valid_elements ) $initArray['extended_valid_elements'] = $extended_valid_elements;
    132149if ( $invalid_elements ) $initArray['invalid_elements'] = $invalid_elements;
    133150
     
    241258// Write file
    242259if ( '' != $cacheKey ) {
    243     if ( $old_cache_max ) {
    244         $keys_file = $cache_path . '/tinymce_compressed' . $cache_ext . '_key';
    245         $old_keys = getFileContents($keys_file);
     260    if ( (int) $old_cache_max && is_dir($cache_path) ) {       
     261
     262        $old_cache = array();
     263        $handle = opendir($cache_path);
     264        while ( false !== ( $file = readdir($handle) ) ) {
     265            if ( $file == '.' || $file == '..' ) continue;
     266            $saved = filectime("$cache_path/$file");
     267            if ( strpos($file, 'tinymce_') !== false && substr($file, -3) == $cache_ext ) $old_cache["$saved"] = $file;
     268        }
     269        closedir($handle);
    246270           
    247         if ( '' != $old_keys ) {
    248             $keys_ar = explode( "\n", $old_keys );
    249             if ( 1 >= $old_cache_max ) $old_keys_rem = $keys_ar;
    250             else $old_keys_rem = array_slice( $keys_ar, ($old_cache_max - 1) );
     271        krsort($old_cache);
     272        if ( 1 >= $old_cache_max ) $del_cache = $old_cache;
     273        else $del_cache = array_slice( $old_cache, ($old_cache_max - 1) );
    251274           
    252             foreach ( $old_keys_rem as $key ) {
    253                 $key = trim($key);
    254                 if ( 32 != strlen($key) ) continue;
    255                 $old_cache = $cache_path . '/tinymce_' . $key . $cache_ext;
    256                 @unlink($old_cache);
    257             }
    258            
    259             array_unshift( $keys_ar, $cacheKey );
    260             $keys_ar = array_slice( $keys_ar, 0, $old_cache_max );
    261             $cacheKey = trim( implode( "\n", $keys_ar ) );
    262         }
    263 
    264         putFileContents( $keys_file, $cacheKey );
     275        foreach ( $del_cache as $key )
     276            @unlink("$cache_path/$key");
    265277    }
    266278
Note: See TracChangeset for help on using the changeset viewer.