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.


Built from https://develop.svn.wordpress.org/trunk@37077


git-svn-id: http://core.svn.wordpress.org/trunk@37044 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Konstantin Obenland 2016-03-24 02:02:27 +00:00
parent f8a66d7bf2
commit cbbf361c03
4 changed files with 32 additions and 8 deletions

View File

@ -108,8 +108,11 @@ function twentyfifteen_setup() {
*
* @since Twenty Fifteen 1.5
*/
add_image_size( 'twentyfifteen-logo', 248, 248 );
add_theme_support( 'custom-logo', array( 'size' => 'twentyfifteen-logo' ) );
add_theme_support( 'custom-logo', array(
'height' => 248,
'width' => 248,
'flex-height' => true,
) );
$color_scheme = twentyfifteen_get_color_scheme();
$default_color = trim( $color_scheme[0], '#' );

View File

@ -1959,11 +1959,15 @@ final class WP_Customize_Manager {
'transport' => 'postMessage',
) );
$this->add_control( new WP_Customize_Media_Control( $this, 'custom_logo', array(
'label' => __( 'Logo' ),
'section' => 'title_tagline',
'priority' => 8,
'mime_type' => 'image',
$custom_logo_args = get_theme_support( 'custom-logo' );
$this->add_control( new WP_Customize_Cropped_Image_Control( $this, 'custom_logo', array(
'label' => __( 'Logo' ),
'section' => 'title_tagline',
'priority' => 8,
'height' => $custom_logo_args[0]['height'],
'width' => $custom_logo_args[0]['width'],
'flex_height' => $custom_logo_args[0]['flex-height'],
'flex_width' => $custom_logo_args[0]['flex-width'],
'button_labels' => array(
'select' => __( 'Select logo' ),
'change' => __( 'Change logo' ),

View File

@ -1559,6 +1559,23 @@ function add_theme_support( $feature ) {
$args[0] = array_merge( $_wp_theme_features['html5'][0], $args[0] );
break;
case 'custom-logo':
$defaults = array(
'width' => null,
'height' => null,
'flex-width' => false,
'flex-height' => false,
'header-text' => '',
);
$args[0] = wp_parse_args( array_intersect_key( $args[0], $defaults ), $defaults );
// Allow full flexibility if no size is specified.
if ( is_null( $args[0]['width'] ) && is_null( $args[0]['height'] ) ) {
$args[0]['flex-width'] = true;
$args[0]['flex-height'] = true;
}
break;
case 'custom-header-uploads' :
return add_theme_support( 'custom-header', array( 'uploads' => true ) );

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.5-beta4-37076';
$wp_version = '4.5-beta4-37077';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.