mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-03-23 14:54:33 +00:00
Improvements to the script loader: allows plugins to queue scripts for the front end head and footer, adds hooks for server side caching of compressed scripts, adds support for ENFORCE_GZIP constant (deflate is used by default since it's faster), see #8628, fixes #8884
git-svn-id: https://develop.svn.wordpress.org/trunk@10442 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -92,14 +92,19 @@ if ( isset($_GET['test']) && 1 == $_GET['test'] ) {
|
||||
if ( ini_get('zlib.output_compression') )
|
||||
exit('');
|
||||
|
||||
if ( false !== strpos( strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'gzip') && function_exists('gzencode') ) {
|
||||
$out = 'var wpCompressionTest = 1;';
|
||||
$force_gzip = ( isset($_GET['c']) && 'gzip' == $_GET['c'] );
|
||||
|
||||
if ( false !== strpos( strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'deflate') && function_exists('gzdeflate') && ! $force_gzip ) {
|
||||
header('Content-Encoding: deflate');
|
||||
$out = gzdeflate( $out, 3 );
|
||||
} elseif ( false !== strpos( strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'gzip') && function_exists('gzencode') ) {
|
||||
header('Content-Encoding: gzip');
|
||||
$out = gzencode( 'var wpCompressionTest = 1;', 3 );
|
||||
}
|
||||
|
||||
if ( ! isset($out) )
|
||||
$out = gzencode( $out, 3 );
|
||||
} else {
|
||||
exit('');
|
||||
|
||||
}
|
||||
|
||||
header( 'Expires: Wed, 11 Jan 1984 05:00:00 GMT' );
|
||||
header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' );
|
||||
header( 'Cache-Control: no-cache, must-revalidate, max-age=0' );
|
||||
@@ -118,7 +123,8 @@ if ( empty($load) )
|
||||
require(ABSPATH . '/wp-includes/script-loader.php');
|
||||
require(ABSPATH . '/wp-includes/version.php');
|
||||
|
||||
$compress = ( isset($_GET['c']) && 1 == $_GET['c'] );
|
||||
$compress = ( isset($_GET['c']) && $_GET['c'] );
|
||||
$force_gzip = ( $compress && 'gzip' == $_GET['c'] );
|
||||
$expires_offset = 31536000;
|
||||
$out = '';
|
||||
|
||||
@@ -137,9 +143,12 @@ header('Content-Type: application/x-javascript; charset=UTF-8');
|
||||
header('Expires: ' . gmdate( "D, d M Y H:i:s", time() + $expires_offset ) . ' GMT');
|
||||
header("Cache-Control: public, max-age=$expires_offset");
|
||||
|
||||
if ( $compress && ! ini_get('zlib.output_compression') && function_exists('gzencode') ) {
|
||||
if ( $compress && ! ini_get('zlib.output_compression') ) {
|
||||
header('Vary: Accept-Encoding'); // Handle proxies
|
||||
if ( false !== strpos( strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'gzip') ) {
|
||||
if ( false !== strpos( strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'deflate') && function_exists('gzdeflate') && ! $force_gzip ) {
|
||||
header('Content-Encoding: deflate');
|
||||
$out = gzdeflate( $out, 3 );
|
||||
} elseif ( false !== strpos( strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'gzip') && function_exists('gzencode') ) {
|
||||
header('Content-Encoding: gzip');
|
||||
$out = gzencode( $out, 3 );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user