Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (8 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-content/themes/twentyfifteen/inc/custom-header.php

    r33092 r42343  
    1414 */
    1515function twentyfifteen_custom_header_setup() {
    16     $color_scheme        = twentyfifteen_get_color_scheme();
    17     $default_text_color  = trim( $color_scheme[4], '#' );
     16    $color_scheme       = twentyfifteen_get_color_scheme();
     17    $default_text_color = trim( $color_scheme[4], '#' );
    1818
    1919    /**
     
    3232     * }
    3333     */
    34     add_theme_support( 'custom-header', apply_filters( 'twentyfifteen_custom_header_args', array(
    35         'default-text-color'     => $default_text_color,
    36         'width'                  => 954,
    37         'height'                 => 1300,
    38         'wp-head-callback'       => 'twentyfifteen_header_style',
    39     ) ) );
     34    add_theme_support(
     35        'custom-header', apply_filters(
     36            'twentyfifteen_custom_header_args', array(
     37                'default-text-color' => $default_text_color,
     38                'width'              => 954,
     39                'height'             => 1300,
     40                'wp-head-callback'   => 'twentyfifteen_header_style',
     41            )
     42        )
     43    );
    4044}
    4145add_action( 'after_setup_theme', 'twentyfifteen_custom_header_setup' );
     
    5458
    5559    if ( strlen( $color ) == 3 ) {
    56         $r = hexdec( substr( $color, 0, 1 ).substr( $color, 0, 1 ) );
    57         $g = hexdec( substr( $color, 1, 1 ).substr( $color, 1, 1 ) );
    58         $b = hexdec( substr( $color, 2, 1 ).substr( $color, 2, 1 ) );
    59     } else if ( strlen( $color ) == 6 ) {
     60        $r = hexdec( substr( $color, 0, 1 ) . substr( $color, 0, 1 ) );
     61        $g = hexdec( substr( $color, 1, 1 ) . substr( $color, 1, 1 ) );
     62        $b = hexdec( substr( $color, 2, 1 ) . substr( $color, 2, 1 ) );
     63    } elseif ( strlen( $color ) == 6 ) {
    6064        $r = hexdec( substr( $color, 0, 2 ) );
    6165        $g = hexdec( substr( $color, 2, 2 ) );
     
    6569    }
    6670
    67     return array( 'red' => $r, 'green' => $g, 'blue' => $b );
     71    return array(
     72        'red'   => $r,
     73        'green' => $g,
     74        'blue'  => $b,
     75    );
    6876}
    6977
    7078if ( ! function_exists( 'twentyfifteen_header_style' ) ) :
    71 /**
    72  * Styles the header image and text displayed on the blog.
    73  *
    74  * @since Twenty Fifteen 1.0
    75  *
    76  * @see twentyfifteen_custom_header_setup()
    77  */
    78 function twentyfifteen_header_style() {
    79     $header_image = get_header_image();
    80 
    81     // If no custom options for text are set, let's bail.
    82     if ( empty( $header_image ) && display_header_text() ) {
    83         return;
    84     }
    85 
    86     // If we get this far, we have custom styles. Let's do this.
    87     ?>
    88     <style type="text/css" id="twentyfifteen-header-css">
    89     <?php
     79    /**
     80    * Styles the header image and text displayed on the blog.
     81    *
     82    * @since Twenty Fifteen 1.0
     83    *
     84    * @see twentyfifteen_custom_header_setup()
     85    */
     86    function twentyfifteen_header_style() {
     87        $header_image = get_header_image();
     88
     89        // If no custom options for text are set, let's bail.
     90        if ( empty( $header_image ) && display_header_text() ) {
     91            return;
     92        }
     93
     94        // If we get this far, we have custom styles. Let's do this.
     95        ?>
     96        <style type="text/css" id="twentyfifteen-header-css">
     97        <?php
    9098        // Short header for when there is no Custom Header and Header Text is hidden.
    9199        if ( empty( $header_image ) && ! display_header_text() ) :
     
    183191    </style>
    184192    <?php
    185 }
     193    }
    186194endif; // twentyfifteen_header_style
    187195
Note: See TracChangeset for help on using the changeset viewer.