Changeset 42343 for trunk/src/wp-admin/load-scripts.php
- Timestamp:
- 11/30/2017 11:09:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/load-scripts.php
r38470 r42343 6 6 * Set this to error_reporting( -1 ) for debugging. 7 7 */ 8 error_reporting( 0);8 error_reporting( 0 ); 9 9 10 10 /** Set ABSPATH for execution */ … … 16 16 17 17 $load = $_GET['load']; 18 if ( is_array( $load ) ) 18 if ( is_array( $load ) ) { 19 19 $load = implode( '', $load ); 20 } 20 21 21 22 $load = preg_replace( '/[^a-z0-9,_-]+/i', '', $load ); 22 23 $load = array_unique( explode( ',', $load ) ); 23 24 24 if ( empty( $load) )25 if ( empty( $load ) ) { 25 26 exit; 27 } 26 28 27 29 require( ABSPATH . 'wp-admin/includes/noop.php' ); … … 29 31 require( ABSPATH . WPINC . '/version.php' ); 30 32 31 $compress = ( isset($_GET['c']) && $_GET['c'] );32 $force_gzip = ( $compress && 'gzip' == $_GET['c'] );33 $compress = ( isset( $_GET['c'] ) && $_GET['c'] ); 34 $force_gzip = ( $compress && 'gzip' == $_GET['c'] ); 33 35 $expires_offset = 31536000; // 1 year 34 $out = '';36 $out = ''; 35 37 36 38 $wp_scripts = new WP_Scripts(); 37 wp_default_scripts( $wp_scripts);39 wp_default_scripts( $wp_scripts ); 38 40 39 41 if ( isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) && stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ) === $wp_version ) { … … 47 49 48 50 foreach ( $load as $handle ) { 49 if ( ! array_key_exists($handle, $wp_scripts->registered) )51 if ( ! array_key_exists( $handle, $wp_scripts->registered ) ) { 50 52 continue; 53 } 51 54 52 $path = ABSPATH . $wp_scripts->registered[ $handle]->src;53 $out .= get_file( $path) . "\n";55 $path = ABSPATH . $wp_scripts->registered[ $handle ]->src; 56 $out .= get_file( $path ) . "\n"; 54 57 } 55 58 56 header( "Etag: $wp_version");57 header( 'Content-Type: application/javascript; charset=UTF-8');58 header( 'Expires: ' . gmdate( "D, d M Y H:i:s", time() + $expires_offset ) . ' GMT');59 header( "Cache-Control: public, max-age=$expires_offset");59 header( "Etag: $wp_version" ); 60 header( 'Content-Type: application/javascript; charset=UTF-8' ); 61 header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + $expires_offset ) . ' GMT' ); 62 header( "Cache-Control: public, max-age=$expires_offset" ); 60 63 61 if ( $compress && ! ini_get( 'zlib.output_compression') && 'ob_gzhandler' != ini_get('output_handler') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) ) {62 header( 'Vary: Accept-Encoding'); // Handle proxies63 if ( false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') && function_exists('gzdeflate') && ! $force_gzip ) {64 header( 'Content-Encoding: deflate');64 if ( $compress && ! ini_get( 'zlib.output_compression' ) && 'ob_gzhandler' != ini_get( 'output_handler' ) && isset( $_SERVER['HTTP_ACCEPT_ENCODING'] ) ) { 65 header( 'Vary: Accept-Encoding' ); // Handle proxies 66 if ( false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate' ) && function_exists( 'gzdeflate' ) && ! $force_gzip ) { 67 header( 'Content-Encoding: deflate' ); 65 68 $out = gzdeflate( $out, 3 ); 66 } elseif ( false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') && function_exists('gzencode') ) {67 header( 'Content-Encoding: gzip');69 } elseif ( false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip' ) && function_exists( 'gzencode' ) ) { 70 header( 'Content-Encoding: gzip' ); 68 71 $out = gzencode( $out, 3 ); 69 72 }
Note: See TracChangeset
for help on using the changeset viewer.