Clean the cache-manifests, make $manifest_version and $tinymce_version global vars accessible from the manifest

git-svn-id: http://svn.automattic.com/wordpress/trunk@11388 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2009-05-18 20:29:26 +00:00
parent 7f6ecdd706
commit 80969e073e
6 changed files with 57 additions and 162 deletions

View File

@ -15,15 +15,10 @@ error_reporting(0);
/** Set ABSPATH for execution */
define( 'ABSPATH', dirname(dirname(__FILE__)) . '/' );
define( 'WPINC', 'wp-includes' );
require(ABSPATH . '/wp-admin/includes/manifest.php');
$man_version = '';
$files = get_manifest($man_version);
$man_version = md5($man_version);
$files = get_manifest();
header( 'Expires: Wed, 11 Jan 1984 05:00:00 GMT' );
header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' );
@ -31,10 +26,10 @@ header( 'Cache-Control: no-cache, must-revalidate, max-age=0' );
header( 'Pragma: no-cache' );
header( 'Content-Type: text/cache-manifest; charset=UTF-8' );
?>
CACHE MANIFEST
#
# Version: <?php echo $man_version; ?>_20080710
#
CACHE MANIFEST
#
# Version: <?php echo $man_version; ?>
#
<?php
foreach ( $files as $file ) {
// If version is not set, just output the file
@ -42,6 +37,6 @@ foreach ( $files as $file ) {
echo $file[0] . "\n";
// If ver is set but ignoreQuery is not, output file with ver tacked on
else
echo $file[0] . '?ver=' . $file[1] . "\n";
echo $file[0] . '?' . $file[1] . "\n";
}

View File

@ -15,15 +15,10 @@ error_reporting(0);
/** Set ABSPATH for execution */
define( 'ABSPATH', dirname(dirname(__FILE__)) . '/' );
define( 'WPINC', 'wp-includes' );
require(ABSPATH . '/wp-admin/includes/manifest.php');
$man_version = '';
$files = get_manifest($man_version);
$man_version = md5($man_version);
$files = get_manifest();
header( 'Expires: Wed, 11 Jan 1984 05:00:00 GMT' );
header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' );
@ -33,7 +28,7 @@ header( 'Content-Type: application/x-javascript; charset=UTF-8' );
?>
{
"betaManifestVersion" : 1,
"version" : "<?php echo $man_version; ?>_20081201",
"version" : "<?php echo $man_version; ?>",
"entries" : [
<?php
$entries = '';
@ -44,10 +39,10 @@ foreach ( $files as $file ) {
$entries .= '{ "url" : "' . $file[0] . '" },' . "\n";
// If ver is set but ignoreQuery is not, output file with ver tacked on
elseif ( !isset($file[2]) )
$entries .= '{ "url" : "' . $file[0] . '?ver=' . $file[1] . '" },' . "\n";
$entries .= '{ "url" : "' . $file[0] . '?' . $file[1] . '" },' . "\n";
// Output url, src, and ignoreQuery
else
$entries .= '{ "url" : "' . $file[0] . '", "src" : "' . $file[0] . '?ver=' . $file[1] . '", "ignoreQuery" : true },' . "\n";
$entries .= '{ "url" : "' . $file[0] . '", "src" : "' . $file[0] . '?' . $file[1] . '", "ignoreQuery" : true },' . "\n";
}
echo trim( trim($entries), ',' );

View File

@ -2,136 +2,21 @@
if ( !defined('ABSPATH') )
exit;
/**
* @ignore
*/
function __() {}
/**
* @ignore
*/
function _c() {}
require(ABSPATH . 'wp-includes/version.php');
/**
* @ignore
*/
function _x() {}
/**
* @ignore
*/
function add_filter() {}
/**
* @ignore
*/
function esc_attr() {}
/**
* @ignore
*/
function attribute_escape() {}
/**
* @ignore
*/
function apply_filters() {}
/**
* @ignore
*/
function get_option() {}
/**
* @ignore
*/
function is_lighttpd_before_150() {}
/**
* @ignore
*/
function add_action() {}
/**
* @ignore
*/
function do_action_ref_array() {}
/**
* @ignore
*/
function get_bloginfo() {}
/**
* @ignore
*/
function is_admin() {return true;}
/**
* @ignore
*/
function site_url() {}
/**
* @ignore
*/
function admin_url() {}
/**
* @ignore
*/
function wp_guess_url() {}
require(ABSPATH . '/wp-includes/script-loader.php');
require(ABSPATH . '/wp-includes/version.php');
$man_version = md5( $tinymce_version . $manifest_version );
$mce_ver = "ver=$tinymce_version";
/**
* Retrieve list of all cacheable WP files
*
* Array format: file, version (optional), bool (whether to use src and set ignoreQuery)
*/
function &get_manifest() {
global $mce_ver;
$wp_scripts = new WP_Scripts();
wp_default_scripts($wp_scripts);
$wp_styles = new WP_Styles();
wp_default_styles($wp_styles);
function &get_manifest(&$man_ver) {
global $wp_scripts, $wp_styles, $wp_version;
$files = array();
foreach ( $wp_scripts->registered as $script ) {
if ( empty($script->src) ) continue;
$ver = empty($script->ver) ? $wp_version : $script->ver;
if ( 'editor' == $script->handle ) $mce_ver = $script->ver;
$src = str_replace( array( '/wp-admin/', '/wp-includes/' ), array( '', '../wp-includes/' ), $script->src );
$files[] = array($src, $ver);
$man_ver .= $ver;
}
foreach ( $wp_styles->registered as $style ) {
if ( empty($style->src) ) continue;
$ver = empty($style->ver) ? $wp_version : $style->ver;
$src = str_replace( array( '/wp-admin/', '/wp-includes/' ), array( '', '../wp-includes/' ), $style->src );
if ( 'colors' == $style->handle ) $src = 'css/colors-classic.css';
$files[] = array($src, $ver);
$man_ver .= $ver;
if ( isset($style->extra['rtl']) && $style->extra['rtl'] ) {
if ( is_bool( $style->extra['rtl'] ) )
$rtl_href = str_replace( '.css', '-rtl.css', $src );
else
$rtl_href = str_replace( array( '/wp-admin/', '/wp-includes/' ), array( '', '../wp-includes/' ), $style->extra['rtl'] );
$files[] = array($rtl_href, $ver);
$man_ver .= $ver;
}
}
$images = array(
$files = array(
array('images/align-center.png'),
array('images/align-left.png'),
array('images/align-none.png'),
@ -203,11 +88,11 @@ function &get_manifest(&$man_ver) {
array('../wp-includes/js/thickbox/tb-close.png'),
);
$files = array_merge($files, $images);
if ( @is_file('../wp-includes/js/tinymce/tiny_mce.js') ) :
$mce = array(
array('../wp-includes/js/tinymce/wp-tinymce.php', $mce_ver, true),
array('../wp-includes/js/tinymce/wp-tinymce.php', 'c=1&' . $mce_ver, true),
array('../wp-includes/js/tinymce/wp-tinymce.php', 'c=0&' . $mce_ver, true),
array('../wp-includes/js/tinymce/tiny_mce.js', $mce_ver, true),
array('../wp-includes/js/tinymce/langs/wp-langs-en.js', $mce_ver, true),
array('../wp-includes/js/tinymce/utils/mctabs.js', $mce_ver, true),

View File

@ -1151,13 +1151,18 @@ function post_preview() {
/**
* Adds the TinyMCE editor used on the Write and Edit screens.
*
* Has option to output a trimmed down version used in Press This.
*
* @package WordPress
* @since 2.7
*
* TinyMCE is loaded separately from other Javascript by using wp-tinymce.php. It outputs concatenated
* and optionaly pre-compressed version of the core and all default plugins. Additional plugins are loaded
* directly by TinyMCE using non-blocking method. Custom plugins can be refreshed by adding a query string
* to the URL when queueing them with the mce_external_plugins filter.
*
* @param bool $teeny optional Output a trimmed down version used in Press This.
*/
function wp_tiny_mce( $teeny = false ) {
global $concatenate_scripts, $compress_scripts;
global $concatenate_scripts, $compress_scripts, $tinymce_version;
if ( ! user_can_richedit() )
return;
@ -1334,7 +1339,16 @@ function wp_tiny_mce( $teeny = false ) {
$language = $initArray['language'];
$zip = $compress_scripts ? 1 : 0;
$ver = apply_filters('tiny_mce_version', '323');
/**
* Deprecated
*
* The tiny_mce_version filter is not needed since external plugins are loaded directly by TinyMCE.
* These plugins can be refreshed by appending query string to the URL passed to mce_external_plugins filter.
* If the plugin has a popup dialog, a query string can be added to the button action that opens it (in the plugin's code).
*/
$version = apply_filters('tiny_mce_version', '');
$version = 'ver=' . $tinymce_version . $version;
if ( 'en' != $language )
include_once(ABSPATH . WPINC . '/js/tinymce/langs/wp-langs.php');
@ -1350,7 +1364,7 @@ function wp_tiny_mce( $teeny = false ) {
tinyMCEPreInit = {
base : "<?php echo $baseurl; ?>",
suffix : "",
query : "ver=<?php echo $ver; ?>",
query : "<?php echo $version; ?>",
mceInit : {<?php echo $mce_options; ?>},
load_ext : function(url,lang){var sl=tinymce.ScriptLoader;sl.markDone(url+'/langs/'+lang+'.js');sl.markDone(url+'/langs/'+lang+'_dlg.js');}
};
@ -1359,14 +1373,14 @@ tinyMCEPreInit = {
<?php
if ( $concatenate_scripts )
echo "<script type='text/javascript' src='$baseurl/wp-tinymce.php?c=$zip&amp;ver=$ver'></script>\n";
echo "<script type='text/javascript' src='$baseurl/wp-tinymce.php?c=$zip&amp;$version'></script>\n";
else
echo "<script type='text/javascript' src='$baseurl/tiny_mce.js?ver=$ver'></script>\n";
echo "<script type='text/javascript' src='$baseurl/tiny_mce.js?$version'></script>\n";
if ( 'en' != $language && isset($lang) )
echo "<script type='text/javascript'>\n$lang\n</script>\n";
else
echo "<script type='text/javascript' src='$baseurl/langs/wp-langs-en.js?ver=$ver'></script>\n";
echo "<script type='text/javascript' src='$baseurl/langs/wp-langs-en.js?$version'></script>\n";
?>
<script type="text/javascript">

View File

@ -8,8 +8,8 @@
* file.
*
* Several constants are used to manage the loading, concatenating and compression of scripts and CSS:
* define('SCRIPT_DEBUG', true); loads the develppment (non-minified) versions of all scripts
* define('CONCATENATE_SCRIPTS', false); disables both compression and cancatenating,
* define('SCRIPT_DEBUG', true); loads the development (non-minified) versions of all scripts and disables compression and concatenation
* define('CONCATENATE_SCRIPTS', false); disables compression and concatenation,
* define('COMPRESS_SCRIPTS', false); disables compression of scripts,
* define('COMPRESS_CSS', false); disables compression of CSS,
* define('ENFORCE_GZIP', true); forces gzip for compression (default is deflate).
@ -86,13 +86,7 @@ function wp_default_scripts( &$scripts ) {
$scripts->add( 'colorpicker', "/wp-includes/js/colorpicker$suffix.js", array('prototype'), '3517m' );
// Modify this version when tinyMCE plugins are changed.
function mce_version() {
return '20090503';
}
add_filter( 'tiny_mce_version', 'mce_version' );
$scripts->add( 'editor', "/wp-admin/js/editor$suffix.js", false, mce_version() );
$scripts->add( 'editor', "/wp-admin/js/editor$suffix.js", false, '20090503' );
$scripts->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.6');

View File

@ -17,4 +17,16 @@ $wp_version = '2.8-beta1-11380';
*/
$wp_db_version = 10851;
?>
/**
* Holds the TinyMCE version
*
* @global string $tinymce_version
*/
$tinymce_version = '323';
/**
* Holds the cache manifest version
*
* @global string $manifest_version
*/
$manifest_version = '20090517';