WordPress.org

Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (4 years ago)
Author:
pento
Message:

Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/load-scripts.php

    r38470 r42343  
    66 * Set this to error_reporting( -1 ) for debugging.
    77 */
    8 error_reporting(0);
     8error_reporting( 0 );
    99
    1010/** Set ABSPATH for execution */
     
    1616
    1717$load = $_GET['load'];
    18 if ( is_array( $load ) )
     18if ( is_array( $load ) ) {
    1919    $load = implode( '', $load );
     20}
    2021
    2122$load = preg_replace( '/[^a-z0-9,_-]+/i', '', $load );
    2223$load = array_unique( explode( ',', $load ) );
    2324
    24 if ( empty($load) )
     25if ( empty( $load ) ) {
    2526    exit;
     27}
    2628
    2729require( ABSPATH . 'wp-admin/includes/noop.php' );
     
    2931require( ABSPATH . WPINC . '/version.php' );
    3032
    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'] );
    3335$expires_offset = 31536000; // 1 year
    34 $out = '';
     36$out            = '';
    3537
    3638$wp_scripts = new WP_Scripts();
    37 wp_default_scripts($wp_scripts);
     39wp_default_scripts( $wp_scripts );
    3840
    3941if ( isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) && stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ) === $wp_version ) {
     
    4749
    4850foreach ( $load as $handle ) {
    49     if ( !array_key_exists($handle, $wp_scripts->registered) )
     51    if ( ! array_key_exists( $handle, $wp_scripts->registered ) ) {
    5052        continue;
     53    }
    5154
    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";
    5457}
    5558
    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");
     59header( "Etag: $wp_version" );
     60header( 'Content-Type: application/javascript; charset=UTF-8' );
     61header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + $expires_offset ) . ' GMT' );
     62header( "Cache-Control: public, max-age=$expires_offset" );
    6063
    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 proxies
    63     if ( false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') && function_exists('gzdeflate') && ! $force_gzip ) {
    64         header('Content-Encoding: deflate');
     64if ( $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' );
    6568        $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' );
    6871        $out = gzencode( $out, 3 );
    6972    }
Note: See TracChangeset for help on using the changeset viewer.