Make WordPress Core


Ignore:
Timestamp:
12/05/2005 03:04:25 AM (21 years ago)
Author:
ryan
Message:

tinyMCE updates from skeltoac. fixes #1991

File:
1 edited

Legend:

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

    r3162 r3265  
    3838        }
    3939
     40        function wp_compact_tinymce_js($text) {
     41                // This function was custom-made for TinyMCE 2.0, not expected to work with any other JS.
     42
     43                echo "\n//" . strlen(gzdeflate($text)) . " bytes gzdeflated\n";
     44                echo "//" . microtime() . " " . strlen($text) . " Micro Time Length\n";
     45
     46                // Strip comments
     47                $text = preg_replace("!(^|\s+)//.*$!m", '', $text);
     48                echo "//" . microtime() . " " . strlen($text) . " Stripped // comments\n";
     49                $text = preg_replace("!/\*.*?\*/!s", '', $text);
     50                echo "//" . microtime() . " " . strlen($text) . " Stripped /* */ comments\n";
     51
     52                // Strip leading tabs, carriage returns and unnecessary line breaks.
     53                $text = preg_replace("!^\t+!m", '', $text);
     54                echo "//" . microtime() . " " . strlen($text) . " Stripped leading tabs\n";
     55                $text = str_replace("\r", '', $text);
     56                echo "//" . microtime() . " " . strlen($text) . " Stripped returns\n";
     57                $text = preg_replace("!(^|{|}|;|:|\))\n!m", '\\1', $text);
     58                echo "//" . microtime() . " " . strlen($text) . " Stripped safe linebreaks\n";
     59
     60                // Strip spaces. This one is not generally economical.
     61                //$text = preg_replace("!\s*(\=|\=\=|\!\=|\<\=|\>\=|\+=|\+|\s|:|,)\s*!", '\\1', $text);
     62                //echo "//" . microtime() . " " . strlen($text) . " Stripped safe spaces\n";
     63
     64                echo "//" . strlen(gzdeflate($text)) . " bytes gzdeflated\n";
     65                return $text;
     66        }
     67
    4068        // General options
    4169        $suffix = "";                                                   // Set to "_src" to use source version
     
    5280        $encodings = explode(',', strtolower($_SERVER['HTTP_ACCEPT_ENCODING']));
    5381        if (in_array('gzip', $encodings) && function_exists('ob_gzhandler'))
    54                 ob_start("ob_gzhandler");
     82                @ ob_start("ob_gzhandler"); // Don't let warnings foul up the JS
    5583
    5684        // Output rest of headers
     
    6391                // Write main script and patch some things
    6492                if ($index == 0) {
    65                         echo file_get_contents(realpath("tiny_mce" . $suffix . ".js"));
     93// WP                   echo file_get_contents(realpath("tiny_mce" . $suffix . ".js"));
     94                        $tinymce = file_get_contents(realpath("tiny_mce.js"));
     95                        echo wp_compact_tinymce_js($tinymce);
    6696                        echo "\n\n";
    6797                        echo "TinyMCE.prototype.loadScript = function() {};\n";
Note: See TracChangeset for help on using the changeset viewer.