Ticket #28722: 28722.2.diff
File 28722.2.diff, 4.1 KB (added by , 10 years ago) |
---|
-
src/wp-admin/load-scripts.php
123 123 124 124 if ( empty($load) ) 125 125 exit; 126 126 127 127 require(ABSPATH . WPINC . '/script-loader.php'); 128 128 require(ABSPATH . WPINC . '/version.php'); 129 129 130 130 $compress = ( isset($_GET['c']) && $_GET['c'] ); 131 131 $force_gzip = ( $compress && 'gzip' == $_GET['c'] ); 132 132 $expires_offset = 31536000; // 1 year 133 133 $out = ''; 134 134 135 135 $wp_scripts = new WP_Scripts(); 136 136 wp_default_scripts($wp_scripts); 137 137 138 if ( isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) && stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ) === $wp_version ) { 139 header('HTTP/1.1 304 Not Modified'); 140 exit(); 141 } 142 138 143 foreach( $load as $handle ) { 139 144 if ( !array_key_exists($handle, $wp_scripts->registered) ) 140 145 continue; 141 146 142 147 $path = ABSPATH . $wp_scripts->registered[$handle]->src; 143 148 $out .= get_file($path) . "\n"; 144 149 } 145 150 151 header("Etag: $wp_version"); 146 152 header('Content-Type: application/x-javascript; charset=UTF-8'); 147 153 header('Expires: ' . gmdate( "D, d M Y H:i:s", time() + $expires_offset ) . ' GMT'); 148 154 header("Cache-Control: public, max-age=$expires_offset"); 149 155 150 156 if ( $compress && ! ini_get('zlib.output_compression') && 'ob_gzhandler' != ini_get('output_handler') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) ) { 151 157 header('Vary: Accept-Encoding'); // Handle proxies 152 158 if ( false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') && function_exists('gzdeflate') && ! $force_gzip ) { 153 159 header('Content-Encoding: deflate'); 154 160 $out = gzdeflate( $out, 3 ); 155 161 } elseif ( false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') && function_exists('gzencode') ) { 156 162 header('Content-Encoding: gzip'); 157 163 $out = gzencode( $out, 3 ); 158 164 } 159 165 } 160 166 -
src/wp-admin/load-styles.php
98 98 $load = preg_replace( '/[^a-z0-9,_-]+/i', '', $_GET['load'] ); 99 99 $load = array_unique( explode( ',', $load ) ); 100 100 101 101 if ( empty($load) ) 102 102 exit; 103 103 104 104 $compress = ( isset($_GET['c']) && $_GET['c'] ); 105 105 $force_gzip = ( $compress && 'gzip' == $_GET['c'] ); 106 106 $rtl = ( isset($_GET['dir']) && 'rtl' == $_GET['dir'] ); 107 107 $expires_offset = 31536000; // 1 year 108 108 $out = ''; 109 109 110 110 $wp_styles = new WP_Styles(); 111 111 wp_default_styles($wp_styles); 112 112 113 if ( isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) && stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ) === $wp_version ) { 114 header('HTTP/1.1 304 Not Modified'); 115 exit(); 116 } 117 113 118 foreach( $load as $handle ) { 114 119 if ( !array_key_exists($handle, $wp_styles->registered) ) 115 120 continue; 116 121 117 122 $style = $wp_styles->registered[$handle]; 118 123 $path = ABSPATH . $style->src; 119 124 120 125 if ( $rtl && ! empty( $style->extra['rtl'] ) ) { 121 126 // All default styles have fully independent RTL files. 122 127 $path = str_replace( '.min.css', '-rtl.min.css', $path ); 123 128 } 124 129 125 130 $content = get_file( $path ) . "\n"; 126 131 127 132 if ( strpos( $style->src, '/' . WPINC . '/css/' ) === 0 ) { 128 133 $content = str_replace( '../images/', '../' . WPINC . '/images/', $content ); 129 134 $content = str_replace( '../js/tinymce/', '../' . WPINC . '/js/tinymce/', $content ); 130 135 $content = str_replace( '../fonts/', '../' . WPINC . '/fonts/', $content ); 131 136 $out .= $content; 132 137 } else { 133 138 $out .= str_replace( '../images/', 'images/', $content ); 134 139 } 135 140 } 136 141 142 header("Etag: $wp_version"); 137 143 header('Content-Type: text/css; charset=UTF-8'); 138 144 header('Expires: ' . gmdate( "D, d M Y H:i:s", time() + $expires_offset ) . ' GMT'); 139 145 header("Cache-Control: public, max-age=$expires_offset"); 140 146 141 147 if ( $compress && ! ini_get('zlib.output_compression') && 'ob_gzhandler' != ini_get('output_handler') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) ) { 142 148 header('Vary: Accept-Encoding'); // Handle proxies 143 149 if ( false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') && function_exists('gzdeflate') && ! $force_gzip ) { 144 150 header('Content-Encoding: deflate'); 145 151 $out = gzdeflate( $out, 3 ); 146 152 } elseif ( false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') && function_exists('gzencode') ) { 147 153 header('Content-Encoding: gzip'); 148 154 $out = gzencode( $out, 3 ); 149 155 } 150 156 } 151 157