Customize: Site logos are custom logos.

Brings the nomenclature closer to custom headers and backgrounds.

See https://wordpress.slack.com/archives/core/p1456955151003150
See #35945. 


git-svn-id: https://develop.svn.wordpress.org/trunk@36837 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Konstantin Obenland 2016-03-03 19:55:15 +00:00
parent 2d64d06594
commit 43ff969765
9 changed files with 80 additions and 86 deletions

View File

@ -721,7 +721,7 @@ p.customize-section-description {
.customize-control-background .current,
.customize-control-cropped_image .current,
.customize-control-site_icon .current,
.customize-control-site_logo .current,
.customize-control-custom_logo .current,
.customize-control-header .current {
margin-bottom: 8px;
}
@ -763,9 +763,9 @@ p.customize-section-description {
.customize-control-site_icon .remove-button,
.customize-control-site_icon .default-button,
.customize-control-site_icon .upload-button,
.customize-control-site_logo .remove-button,
.customize-control-site_logo .default-button,
.customize-control-site_logo .upload-button,
.customize-control-custom_logo .remove-button,
.customize-control-custom_logo .default-button,
.customize-control-custom_logo .upload-button,
.customize-control-header button.new,
.customize-control-header button.remove {
white-space: normal;
@ -779,7 +779,7 @@ p.customize-section-description {
.customize-control-background .current .container,
.customize-control-cropped_image .current .container,
.customize-control-site_icon .current .container,
.customize-control-site_logo .current .container,
.customize-control-custom_logo .current .container,
.customize-control-header .current .container {
overflow: hidden;
-webkit-border-radius: 2px;
@ -793,7 +793,7 @@ p.customize-section-description {
.customize-control-background .current .container,
.customize-control-cropped_image .current .container,
.customize-control-site_icon .current .container,
.customize-control-site_logo .current .container,
.customize-control-custom_logo .current .container,
.customize-control-image .current .container {
min-height: 40px;
}
@ -822,7 +822,7 @@ p.customize-section-description {
.customize-control-background .inner,
.customize-control-cropped_image .inner,
.customize-control-site_icon .inner,
.customize-control-site_logo .inner,
.customize-control-custom_logo .inner,
.customize-control-header .inner {
display: none;
position: absolute;
@ -838,7 +838,7 @@ p.customize-section-description {
.customize-control-background .inner,
.customize-control-cropped_image .inner,
.customize-control-site_icon .inner,
.customize-control-site_logo .inner,
.customize-control-custom_logo .inner,
.customize-control-image .inner {
display: block;
min-height: 40px;
@ -850,7 +850,7 @@ p.customize-section-description {
.customize-control-background .inner,
.customize-control-cropped_image .inner,
.customize-control-site_icon .inner,
.customize-control-site_logo.inner,
.customize-control-custom_logo.inner,
.customize-control-header .inner,
.customize-control-header .inner .dashicons {
line-height: 20px;
@ -994,8 +994,8 @@ p.customize-section-description {
.customize-control-cropped_image .default-button,
.customize-control-site_icon .remove-button,
.customize-control-site_icon .default-button,
.customize-control-site_logo .remove-button,
.customize-control-site_logo .default-button,
.customize-control-custom_logo .remove-button,
.customize-control-custom_logo .default-button,
.customize-control-header .remove {
float: left;
margin-right: 3px;
@ -1007,7 +1007,7 @@ p.customize-section-description {
.customize-control-background .upload-button,
.customize-control-cropped_image .upload-button,
.customize-control-site_icon .upload-button,
.customize-control-site_logo .upload-button,
.customize-control-custom_logo .upload-button,
.customize-control-header .new {
float: right;
}

View File

@ -72,7 +72,7 @@ require_once(ABSPATH . 'wp-admin/includes/user.php');
/** WordPress Site Icon API */
require_once(ABSPATH . 'wp-admin/includes/class-wp-site-icon.php');
/** WordPress Site Logo API */
/** WordPress Custom Logo API */
require_once(ABSPATH . 'wp-admin/includes/class-wp-site-logo.php');
/** WordPress Update Administration API */

View File

@ -1,6 +1,6 @@
<?php
/**
* Administration API: WP_Site_Logo class
* Administration API: WP_Custom_Logo class
*
* @package WordPress
* @subpackage Administration
@ -8,11 +8,11 @@
*/
/**
* Core class used to implement site logo functionality.
* Core class used to implement custom logo functionality.
*
* @since 4.5.0
*/
class WP_Site_Logo {
class WP_Custom_Logo {
/**
* Get current logo settings stored in theme mod.
@ -34,13 +34,13 @@ class WP_Site_Logo {
*/
public function head_text_styles() {
// Bail if our theme supports custom headers.
if ( current_theme_supports( 'custom-header' ) || get_theme_mod( 'site_logo_header_text', true ) ) {
if ( current_theme_supports( 'custom-header' ) || get_theme_mod( 'custom_logo_header_text', true ) ) {
return;
}
// Is Display Header Text unchecked? If so, hide the header text.
?>
<!-- Site Logo: hide header text -->
<!-- Custom Logo: hide header text -->
<style type="text/css">
<?php echo sanitize_html_class( $this->header_text_classes() ); ?> {
position: absolute;
@ -51,7 +51,7 @@ class WP_Site_Logo {
}
/**
* Resets the site logo if the current logo is deleted in the media manager.
* Reset the custom logo if the current logo is deleted in the media manager.
*
* @since 4.5.0
* @access public
@ -59,10 +59,10 @@ class WP_Site_Logo {
* @param int $post_id Post ID.
*/
public function delete_attachment_data( $post_id ) {
$site_logo_id = get_theme_mod( 'site_logo' );
$custom_logo_id = get_theme_mod( 'custom_logo' );
if ( $site_logo_id && $site_logo_id == $post_id ) {
remove_theme_mod( 'site_logo' );
if ( $custom_logo_id && $custom_logo_id == $post_id ) {
remove_theme_mod( 'custom_logo' );
}
}
@ -105,7 +105,7 @@ class WP_Site_Logo {
* @return string String of classes to hide.
*/
protected function header_text_classes() {
$args = get_theme_support( 'site-logo' );
$args = get_theme_support( 'custom-logo' );
if ( isset( $args[0]['header-text'] ) ) {
// Use any classes defined in add_theme_support().
@ -131,8 +131,8 @@ class WP_Site_Logo {
}
/**
* WP_Site_Logo instance.
* WP_Custom_Logo instance.
*
* @global WP_Site_Logo $wp_site_logo
* @global WP_Custom_Logo $wp_custom_logo
*/
$GLOBALS['wp_site_logo'] = new WP_Site_Logo;
$GLOBALS['wp_custom_logo'] = new WP_Custom_Logo;

View File

@ -2303,14 +2303,14 @@
});
/**
* A control for selecting Site Logos.
* A control for selecting custom logos.
*
* @class
* @augments wp.customize.MediaControl
* @augments wp.customize.Control
* @augments wp.customize.Class
*/
api.SiteLogoControl = api.MediaControl.extend({
api.CustomLogoControl = api.MediaControl.extend({
/**
* When the control's DOM structure is ready,
@ -2330,7 +2330,7 @@
control.setting.bind( function( attachmentId ) {
wp.media.attachment( attachmentId ).fetch().done( function() {
wp.customize.previewer.send( 'site-logo-attachment-data', this.attributes );
wp.customize.previewer.send( 'custom-logo-attachment-data', this.attributes );
} );
// Re-render whenever the control's setting changes.
@ -3245,7 +3245,7 @@
image: api.ImageControl,
cropped_image: api.CroppedImageControl,
site_icon: api.SiteIconControl,
site_logo: api.SiteLogoControl,
custom_logo: api.CustomLogoControl,
header: api.HeaderControl,
background: api.BackgroundControl,
theme: api.ThemeControl

View File

@ -1848,7 +1848,7 @@ final class WP_Customize_Manager {
$this->register_control_type( 'WP_Customize_Background_Image_Control' );
$this->register_control_type( 'WP_Customize_Cropped_Image_Control' );
$this->register_control_type( 'WP_Customize_Site_Icon_Control' );
$this->register_control_type( 'WP_Customize_Site_Logo_Control' );
$this->register_control_type( 'WP_Customize_Custom_Logo_Control' );
$this->register_control_type( 'WP_Customize_Theme_Control' );
/* Themes */
@ -1960,22 +1960,22 @@ final class WP_Customize_Manager {
'width' => 512,
) ) );
$this->add_setting( 'site_logo', array(
'theme_supports' => array( 'site-logo' ),
$this->add_setting( 'custom_logo', array(
'theme_supports' => array( 'custom-logo' ),
'transport' => 'postMessage',
) );
$this->add_control( new WP_Customize_Site_Logo_Control( $this, 'site_logo', array(
$this->add_control( new WP_Customize_Custom_Logo_Control( $this, 'custom_logo', array(
'label' => __( 'Logo' ),
'section' => 'title_tagline',
'priority' => 0,
) ) );
if ( isset( $this->selective_refresh ) ) {
$this->selective_refresh->add_partial( 'site_logo', array(
'settings' => array( 'site_logo' ),
'selector' => '.site-logo-link',
'render_callback' => array( $this, '_render_site_logo_partial' ),
$this->selective_refresh->add_partial( 'custom_logo', array(
'settings' => array( 'custom_logo' ),
'selector' => '.custom-logo-link',
'render_callback' => array( $this, '_render_custom_logo_partial' ),
'container_inclusive' => true,
) );
}
@ -2211,10 +2211,10 @@ final class WP_Customize_Manager {
}
/**
* Callback for rendering the site logo, used in the site_logo partial.
* Callback for rendering the custom logo, used in the custom_logo partial.
*
* This method exists because the partial object and context data are passed
* into a partial's render_callback so we cannot use get_the_site_logo() as
* into a partial's render_callback so we cannot use get_custom_logo() as
* the render_callback directly since it expects a blog ID as the first
* argument. When WP no longer supports PHP 5.3, this method can be removed
* in favor of an anonymous function.
@ -2224,10 +2224,10 @@ final class WP_Customize_Manager {
* @since 4.5.0
* @access private
*
* @return string Site logo.
* @return string Custom logo.
*/
public function _render_site_logo_partial() {
return get_the_site_logo();
public function _render_custom_logo_partial() {
return get_custom_logo();
}
}

View File

@ -1,6 +1,6 @@
<?php
/**
* Customize API: WP_Customize_Site_Logo_Control class
* Customize API: WP_Customize_Custom_Logo_Control class
*
* @package WordPress
* @subpackage Customize
@ -8,7 +8,7 @@
*/
/**
* Customize Site Logo control class.
* Customize custom logo control class.
*
* Used only for custom functionality in JavaScript.
*
@ -16,7 +16,7 @@
*
* @see WP_Customize_Image_Control
*/
class WP_Customize_Site_Logo_Control extends WP_Customize_Image_Control {
class WP_Customize_Custom_Logo_Control extends WP_Customize_Image_Control {
/**
* Control type.
@ -25,7 +25,7 @@ class WP_Customize_Site_Logo_Control extends WP_Customize_Image_Control {
* @access public
* @var string
*/
public $type = 'site_logo';
public $type = 'custom_logo';
/**
* Constructor.

View File

@ -839,56 +839,56 @@ function has_site_icon( $blog_id = 0 ) {
}
/**
* Whether the site has a Site Logo.
* Whether the site has a custom logo.
*
* @since 4.5.0
*
* @param int $blog_id Optional. ID of the blog in question. Default current blog.
* @return bool Whether the site has a site logo or not.
* @return bool Whether the site has a custom logo or not.
*/
function has_site_logo( $blog_id = 0 ) {
function has_custom_logo( $blog_id = 0 ) {
if ( is_multisite() && (int) $blog_id !== get_current_blog_id() ) {
switch_to_blog( $blog_id );
}
$site_logo_id = get_theme_mod( 'site_logo' );
$custom_logo_id = get_theme_mod( 'custom_logo' );
if ( is_multisite() && ms_is_switched() ) {
restore_current_blog();
}
return (bool) $site_logo_id;
return (bool) $custom_logo_id;
}
/**
* Returns a Site Logo, linked to home.
* Returns a custom logo, linked to home.
*
* @since 4.5.0
*
* @param int $blog_id Optional. ID of the blog in question. Default current blog.
* @return string Site logo markup.
* @return string Custom logo markup.
*/
function get_the_site_logo( $blog_id = 0 ) {
function get_custom_logo( $blog_id = 0 ) {
$html = '';
if ( is_multisite() && (int) $blog_id !== get_current_blog_id() ) {
switch_to_blog( $blog_id );
}
$site_logo_id = get_theme_mod( 'site_logo' );
$custom_logo_id = get_theme_mod( 'custom_logo' );
if ( is_multisite() && ms_is_switched() ) {
restore_current_blog();
}
$size = get_theme_support( 'site-logo' );
$size = get_theme_support( 'custom-logo' );
$size = $size[0]['size'];
// We have a logo. Logo is go.
if ( $site_logo_id ) {
$html = sprintf( '<a href="%1$s" class="site-logo-link" rel="home" itemprop="url">%2$s</a>',
if ( $custom_logo_id ) {
$html = sprintf( '<a href="%1$s" class="custom-logo-link" rel="home" itemprop="url">%2$s</a>',
esc_url( home_url( '/' ) ),
wp_get_attachment_image( $site_logo_id, $size, false, array(
'class' => "site-logo attachment-$size",
wp_get_attachment_image( $custom_logo_id, $size, false, array(
'class' => "custom-logo attachment-$size",
'data-size' => $size,
'itemprop' => 'logo',
) )
@ -897,32 +897,32 @@ function get_the_site_logo( $blog_id = 0 ) {
// If no logo is set but we're in the Customizer, leave a placeholder (needed for the live preview).
elseif ( is_customize_preview() ) {
$html = sprintf( '<a href="%1$s" class="site-logo-link" style="display:none;"><img class="site-logo" data-size="%2$s" /></a>',
$html = sprintf( '<a href="%1$s" class="custom-logo-link" style="display:none;"><img class="custom-logo" data-size="%2$s" /></a>',
esc_url( home_url( '/' ) ),
esc_attr( $size )
);
}
/**
* Filter the Site Logo output.
* Filter the custom logo output.
*
* @since 4.5.0
*
* @param string $html Site Logo HTML output.
* @param string $html Custom logo HTML output.
* @param string $size Size specified in add_theme_support declaration, or 'thumbnail' default.
*/
return apply_filters( 'get_the_site_logo', $html, $size );
return apply_filters( 'get_custom_logo', $html, $size );
}
/**
* Displays a Site Logo, linked to home.
* Displays a custom logo, linked to home.
*
* @since 4.5.0
*
* @param int $blog_id Optional. ID of the blog in question. Default current blog.
*/
function the_site_logo( $blog_id = 0 ) {
echo get_the_site_logo( $blog_id );
function the_custom_logo( $blog_id = 0 ) {
echo get_custom_logo( $blog_id );
}
/**

View File

@ -224,9 +224,9 @@
});
/**
* Site Logo
* Custom Logo
*
* The site logo setting only contains the attachment ID. To avoid having to send an AJAX request to get more
* The custom logo setting only contains the attachment ID. To avoid having to send an AJAX request to get more
* data, we send a separate message with the attachment data we get from the Customizer's media modal.
* Therefore first callback handles only the event of a new logo being selected.
*
@ -234,8 +234,8 @@
*
* @since 4.5.0
*/
api.preview.bind( 'site-logo-attachment-data', function( attachment ) {
var $logo = $( '.site-logo' ),
api.preview.bind( 'custom-logo-attachment-data', function( attachment ) {
var $logo = $( '.custom-logo' ),
size = $logo.data( 'size' ),
srcset = [];
@ -255,27 +255,25 @@
srcset: srcset
} );
$( '.site-logo-link' ).show();
$( 'body' ).addClass( 'wp-site-logo' );
$( '.custom-logo-link' ).show();
} );
api( 'site_logo', function( setting ) {
api( 'custom_logo', function( setting ) {
setting.bind( function( newValue ) {
if ( ! newValue ) {
$( '.site-logo-link' ).hide();
$( 'body' ).removeClass( 'wp-site-logo' );
$( '.custom-logo-link' ).hide();
}
} );
// Focus on the control when the logo is clicked, if there is no site_logo partial.
if ( ! api.selectiveRefresh || ! api.selectiveRefresh.partial.has( 'site_logo' ) ) {
$( document.body ).on( 'click', '.site-logo-link', function( e ) {
// Focus on the control when the logo is clicked, if there is no custom_logo partial.
if ( ! api.selectiveRefresh || ! api.selectiveRefresh.partial.has( 'custom_logo' ) ) {
$( document.body ).on( 'click', '.custom-logo-link', function( e ) {
if ( ! e.shiftKey ) {
return;
}
api.preview.send( 'focus-control-for-setting', 'site_logo' );
api.preview.send( 'focus-control-for-setting', 'custom_logo' );
} );
$( '.site-logo-link' ).attr( 'title', api.settings.l10n.shiftClickToEdit );
$( '.custom-logo-link' ).attr( 'title', api.settings.l10n.shiftClickToEdit );
}
} );

View File

@ -706,10 +706,6 @@ function get_body_class( $class = '' ) {
if ( get_background_color() !== get_theme_support( 'custom-background', 'default-color' ) || get_background_image() )
$classes[] = 'custom-background';
if ( has_site_logo() ) {
$classes[] = 'wp-site-logo';
}
$page = $wp_query->get( 'page' );
if ( ! $page || $page < 2 )