Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (6 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-styles.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 */
     
    2626$load = array_unique( explode( ',', $load ) );
    2727
    28 if ( empty($load) )
     28if ( empty( $load ) ) {
    2929    exit;
     30}
    3031
    31 $compress = ( isset($_GET['c']) && $_GET['c'] );
    32 $force_gzip = ( $compress && 'gzip' == $_GET['c'] );
    33 $rtl = ( isset($_GET['dir']) && 'rtl' == $_GET['dir'] );
     32$compress       = ( isset( $_GET['c'] ) && $_GET['c'] );
     33$force_gzip     = ( $compress && 'gzip' == $_GET['c'] );
     34$rtl            = ( isset( $_GET['dir'] ) && 'rtl' == $_GET['dir'] );
    3435$expires_offset = 31536000; // 1 year
    35 $out = '';
     36$out            = '';
    3637
    3738$wp_styles = new WP_Styles();
    38 wp_default_styles($wp_styles);
     39wp_default_styles( $wp_styles );
    3940
    4041if ( isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) && stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ) === $wp_version ) {
     
    4849
    4950foreach ( $load as $handle ) {
    50     if ( !array_key_exists($handle, $wp_styles->registered) )
     51    if ( ! array_key_exists( $handle, $wp_styles->registered ) ) {
    5152        continue;
     53    }
    5254
    53     $style = $wp_styles->registered[$handle];
     55    $style = $wp_styles->registered[ $handle ];
    5456
    5557    if ( empty( $style->src ) ) {
     
    7072        $content = str_replace( '../js/tinymce/', '../' . WPINC . '/js/tinymce/', $content );
    7173        $content = str_replace( '../fonts/', '../' . WPINC . '/fonts/', $content );
    72         $out .= $content;
     74        $out    .= $content;
    7375    } else {
    7476        $out .= str_replace( '../images/', 'images/', $content );
     
    7678}
    7779
    78 header("Etag: $wp_version");
    79 header('Content-Type: text/css; charset=UTF-8');
    80 header('Expires: ' . gmdate( "D, d M Y H:i:s", time() + $expires_offset ) . ' GMT');
    81 header("Cache-Control: public, max-age=$expires_offset");
     80header( "Etag: $wp_version" );
     81header( 'Content-Type: text/css; charset=UTF-8' );
     82header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + $expires_offset ) . ' GMT' );
     83header( "Cache-Control: public, max-age=$expires_offset" );
    8284
    83 if ( $compress && ! ini_get('zlib.output_compression') && 'ob_gzhandler' != ini_get('output_handler') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) ) {
    84     header('Vary: Accept-Encoding'); // Handle proxies
    85     if ( false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') && function_exists('gzdeflate') && ! $force_gzip ) {
    86         header('Content-Encoding: deflate');
     85if ( $compress && ! ini_get( 'zlib.output_compression' ) && 'ob_gzhandler' != ini_get( 'output_handler' ) && isset( $_SERVER['HTTP_ACCEPT_ENCODING'] ) ) {
     86    header( 'Vary: Accept-Encoding' ); // Handle proxies
     87    if ( false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate' ) && function_exists( 'gzdeflate' ) && ! $force_gzip ) {
     88        header( 'Content-Encoding: deflate' );
    8789        $out = gzdeflate( $out, 3 );
    88     } elseif ( false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') && function_exists('gzencode') ) {
    89         header('Content-Encoding: gzip');
     90    } elseif ( false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip' ) && function_exists( 'gzencode' ) ) {
     91        header( 'Content-Encoding: gzip' );
    9092        $out = gzencode( $out, 3 );
    9193    }
Note: See TracChangeset for help on using the changeset viewer.