WordPress.org

Make WordPress Core

Ticket #6295: 6295.002.diff

File 6295.002.diff, 4.9 KB (added by azaozz, 10 years ago)

Includes the above patch plus some more small fixes

  • tiny_mce_config.php

     
    3636        if ( function_exists('file_put_contents') )
    3737                return @file_put_contents( $path, $content );
    3838
     39        $newfile = false;
    3940        $fp = @fopen( $path, 'wb' );
    4041        if ($fp) {
    41                 fwrite( $fp, $content );
     42                $newfile = fwrite( $fp, $content );
    4243                fclose($fp);
    4344        }
     45        return $newfile;
    4446}
    4547
    4648// Set up init variables
     
    5860/*
    5961Setting mce_valid_elements to *[*] skips all of the internal cleanup and can cause problems.
    6062The minimal setting would be -strong/-b[*],-em/-i[*],*[*].
    61 Best is to use the default cleanup by not specifying mce_valid_elements,
    62 and then use extended_valid_elements to add to it.
     63Best is to use the default cleanup by not specifying mce_valid_elements. It contains full set of XHTML 1.0.
     64If others are needed, mce_extended_valid_elements can be used to add to it, or mce_invalid_elements to remove.
    6365*/
    6466$valid_elements = apply_filters('mce_valid_elements', '');
    6567$invalid_elements = apply_filters('mce_invalid_elements', '');
     68$extended_valid_elements = apply_filters('mce_extended_valid_elements', '');
    6669
    67 $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';
    68 
    69 $extended_valid_elements = apply_filters('mce_extended_valid_elements', $extended_valid_elements);
    70 
    7170/*
    7271The following filter allows localization scripts to change the languages displayed in the spellchecker's drop-down menu.
    7372By default it uses Google's spellchecker API, but can be configured to use PSpell/ASpell if installed on the server.
     
    105104       
    106105        if ( ! empty($mce_external_languages) ) {
    107106                foreach ( $mce_external_languages as $name => $path ) {
    108                         $loaded_langs[] = $name;
    109                
    110                         if ( is_file($path) ) include_once($path);
    111                         $ext_plugins .= $strings;
     107                        if ( is_readable($path) ) {
     108                                include_once($path);
     109                                $ext_plugins .= $strings;
     110                                $loaded_langs[] = $name;
     111                        }
    112112                }
    113113        }
    114114
     
    174174);
    175175
    176176if ( $valid_elements ) $initArray['valid_elements'] = $valid_elements;
    177 //if ( $extended_valid_elements ) $initArray['extended_valid_elements'] = $extended_valid_elements;
     177if ( $extended_valid_elements ) $initArray['extended_valid_elements'] = $extended_valid_elements;
    178178if ( $invalid_elements ) $initArray['invalid_elements'] = $invalid_elements;
    179179
    180180// For people who really REALLY know what they're doing with TinyMCE
     
    242242header( 'Expires: ' . gmdate( "D, d M Y H:i:s", time() + $expiresOffset ) . ' GMT' );
    243243
    244244// Use cached file if exists
    245 if ( $disk_cache && is_file($cache_file) ) {
     245if ( $disk_cache && is_file($cache_file) && is_readable($cache_file) ) {
    246246
    247247        $mtime = gmdate("D, d M Y H:i:s", filemtime($cache_file)) . " GMT";
    248248       
     
    302302}
    303303
    304304// Write file
    305 if ( '' != $cacheKey ) {
    306         if ( is_dir($cache_path) ) {           
     305if ( '' != $cacheKey && is_dir($cache_path) && is_readable($cache_path) ) {     
    307306
    308                 $old_cache = array();
    309                 $handle = opendir($cache_path);
    310                 while ( false !== ( $file = readdir($handle) ) ) {
    311                         if ( $file == '.' || $file == '..' ) continue;
    312             $saved = filectime("$cache_path/$file");
    313                         if ( strpos($file, 'tinymce_') !== false && substr($file, -3) == $cache_ext ) $old_cache["$saved"] = $file;
    314                 }
    315                 closedir($handle);
    316                        
    317                 krsort($old_cache);
    318                 if ( 1 >= $old_cache_max ) $del_cache = $old_cache;
    319                 else $del_cache = array_slice( $old_cache, ($old_cache_max - 1) );
    320                        
    321                 foreach ( $del_cache as $key )
    322                         @unlink("$cache_path/$key");
     307        $old_cache = array();
     308        $handle = opendir($cache_path);
     309        while ( false !== ( $file = readdir($handle) ) ) {
     310                if ( $file == '.' || $file == '..' ) continue;
     311        $saved = filectime("$cache_path/$file");
     312                if ( strpos($file, 'tinymce_') !== false && substr($file, -3) == $cache_ext ) $old_cache["$saved"] = $file;
    323313        }
     314        closedir($handle);
     315                       
     316        krsort($old_cache);
     317        if ( 1 >= $old_cache_max ) $del_cache = $old_cache;
     318        else $del_cache = array_slice( $old_cache, ($old_cache_max - 1) );
    324319
    325         putFileContents( $cache_file, $content );
     320        foreach ( $del_cache as $key )
     321                @unlink("$cache_path/$key");
    326322
    327         $mtime = gmdate( "D, d M Y H:i:s", filemtime($cache_file) ) . " GMT";
    328         header( 'Last-Modified: ' . $mtime );
     323        if ( putFileContents( $cache_file, $content ) && is_readable($cache_file) ) {
     324                $mtime = gmdate( "D, d M Y H:i:s", filemtime($cache_file) ) . " GMT";
     325                header( 'Last-Modified: ' . $mtime );
     326                header( 'Cache-Control: must-revalidate', false );
     327        }
    329328}
    330329
    331330// Stream to client
    332 header( 'Cache-Control: must-revalidate', false );
    333331header( 'Content-Length: ' . strlen($content) );
    334332echo $content;
    335333?>
    336  No newline at end of file