WordPress.org

Make WordPress Core

Changeset 37077


Ignore:
Timestamp:
03/24/2016 02:01:50 AM (2 years ago)
Author:
obenland
Message:

Customize: Bring custom-logo args closer to custom-header.

Allows themes to specify the desired width and height of logos, and whether
that is flexible or not. Has the benefit of not having to generate a logo-sized
file for every image uploaded.

Props westonruter, celloexpressions.
Fixes #36255.

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-content/themes/twentyfifteen/functions.php

    r37040 r37077  
    109109     * @since Twenty Fifteen 1.5
    110110     */
    111     add_image_size( 'twentyfifteen-logo', 248, 248 );
    112     add_theme_support( 'custom-logo', array( 'size' => 'twentyfifteen-logo' ) );
     111    add_theme_support( 'custom-logo', array(
     112        'height'      => 248,
     113        'width'       => 248,
     114        'flex-height' => true,
     115    ) );
    113116
    114117    $color_scheme  = twentyfifteen_get_color_scheme();
  • trunk/src/wp-includes/class-wp-customize-manager.php

    r37066 r37077  
    19601960        ) );
    19611961
    1962         $this->add_control( new WP_Customize_Media_Control( $this, 'custom_logo', array(
    1963             'label'    => __( 'Logo' ),
    1964             'section'  => 'title_tagline',
    1965             'priority' => 8,
    1966             'mime_type' => 'image',
     1962        $custom_logo_args = get_theme_support( 'custom-logo' );
     1963        $this->add_control( new WP_Customize_Cropped_Image_Control( $this, 'custom_logo', array(
     1964            'label'         => __( 'Logo' ),
     1965            'section'       => 'title_tagline',
     1966            'priority'      => 8,
     1967            'height'        => $custom_logo_args[0]['height'],
     1968            'width'         => $custom_logo_args[0]['width'],
     1969            'flex_height'   => $custom_logo_args[0]['flex-height'],
     1970            'flex_width'    => $custom_logo_args[0]['flex-width'],
    19671971            'button_labels' => array(
    19681972                'select'       => __( 'Select logo' ),
  • trunk/src/wp-includes/theme.php

    r37040 r37077  
    15601560            break;
    15611561
     1562        case 'custom-logo':
     1563            $defaults = array(
     1564                'width'       => null,
     1565                'height'      => null,
     1566                'flex-width'  => false,
     1567                'flex-height' => false,
     1568                'header-text' => '',
     1569            );
     1570            $args[0] = wp_parse_args( array_intersect_key( $args[0], $defaults ), $defaults );
     1571
     1572            // Allow full flexibility if no size is specified.
     1573            if ( is_null( $args[0]['width'] ) && is_null( $args[0]['height'] ) ) {
     1574                $args[0]['flex-width']  = true;
     1575                $args[0]['flex-height'] = true;
     1576            }
     1577            break;
     1578
    15621579        case 'custom-header-uploads' :
    15631580            return add_theme_support( 'custom-header', array( 'uploads' => true ) );
Note: See TracChangeset for help on using the changeset viewer.