From cbbf361c03584db293274428ae59a991d7307ac4 Mon Sep 17 00:00:00 2001 From: Konstantin Obenland Date: Thu, 24 Mar 2016 02:02:27 +0000 Subject: [PATCH] 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 --- wp-content/themes/twentyfifteen/functions.php | 7 +++++-- wp-includes/class-wp-customize-manager.php | 14 +++++++++----- wp-includes/theme.php | 17 +++++++++++++++++ wp-includes/version.php | 2 +- 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/wp-content/themes/twentyfifteen/functions.php b/wp-content/themes/twentyfifteen/functions.php index 618906f39b..50cce93413 100644 --- a/wp-content/themes/twentyfifteen/functions.php +++ b/wp-content/themes/twentyfifteen/functions.php @@ -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], '#' ); diff --git a/wp-includes/class-wp-customize-manager.php b/wp-includes/class-wp-customize-manager.php index 370ebdddcd..8057e57ae0 100644 --- a/wp-includes/class-wp-customize-manager.php +++ b/wp-includes/class-wp-customize-manager.php @@ -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' ), diff --git a/wp-includes/theme.php b/wp-includes/theme.php index 1ad720c4f6..49ecdbbb3f 100644 --- a/wp-includes/theme.php +++ b/wp-includes/theme.php @@ -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 ) ); diff --git a/wp-includes/version.php b/wp-includes/version.php index afd784c97a..5112df1c3c 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.