Make WordPress Core

Changeset 36837


Ignore:
Timestamp:
03/03/2016 07:55:15 PM (9 years ago)
Author:
obenland
Message:

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.

Location:
trunk/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/css/customize-controls.css

    r36804 r36837  
    722722.customize-control-cropped_image .current,
    723723.customize-control-site_icon .current,
    724 .customize-control-site_logo .current,
     724.customize-control-custom_logo .current,
    725725.customize-control-header .current {
    726726    margin-bottom: 8px;
     
    764764.customize-control-site_icon .default-button,
    765765.customize-control-site_icon .upload-button,
    766 .customize-control-site_logo .remove-button,
    767 .customize-control-site_logo .default-button,
    768 .customize-control-site_logo .upload-button,
     766.customize-control-custom_logo .remove-button,
     767.customize-control-custom_logo .default-button,
     768.customize-control-custom_logo .upload-button,
    769769.customize-control-header button.new,
    770770.customize-control-header button.remove {
     
    780780.customize-control-cropped_image .current .container,
    781781.customize-control-site_icon .current .container,
    782 .customize-control-site_logo .current .container,
     782.customize-control-custom_logo .current .container,
    783783.customize-control-header .current .container {
    784784    overflow: hidden;
     
    794794.customize-control-cropped_image .current .container,
    795795.customize-control-site_icon .current .container,
    796 .customize-control-site_logo .current .container,
     796.customize-control-custom_logo .current .container,
    797797.customize-control-image .current .container {
    798798    min-height: 40px;
     
    823823.customize-control-cropped_image .inner,
    824824.customize-control-site_icon .inner,
    825 .customize-control-site_logo .inner,
     825.customize-control-custom_logo .inner,
    826826.customize-control-header .inner {
    827827    display: none;
     
    839839.customize-control-cropped_image .inner,
    840840.customize-control-site_icon .inner,
    841 .customize-control-site_logo .inner,
     841.customize-control-custom_logo .inner,
    842842.customize-control-image .inner {
    843843    display: block;
     
    851851.customize-control-cropped_image .inner,
    852852.customize-control-site_icon .inner,
    853 .customize-control-site_logo.inner,
     853.customize-control-custom_logo.inner,
    854854.customize-control-header .inner,
    855855.customize-control-header .inner .dashicons {
     
    995995.customize-control-site_icon .remove-button,
    996996.customize-control-site_icon .default-button,
    997 .customize-control-site_logo .remove-button,
    998 .customize-control-site_logo .default-button,
     997.customize-control-custom_logo .remove-button,
     998.customize-control-custom_logo .default-button,
    999999.customize-control-header .remove {
    10001000    float: left;
     
    10081008.customize-control-cropped_image .upload-button,
    10091009.customize-control-site_icon .upload-button,
    1010 .customize-control-site_logo .upload-button,
     1010.customize-control-custom_logo .upload-button,
    10111011.customize-control-header .new {
    10121012    float: right;
  • trunk/src/wp-admin/includes/admin.php

    r36698 r36837  
    7373require_once(ABSPATH . 'wp-admin/includes/class-wp-site-icon.php');
    7474
    75 /** WordPress Site Logo API */
     75/** WordPress Custom Logo API */
    7676require_once(ABSPATH . 'wp-admin/includes/class-wp-site-logo.php');
    7777
  • trunk/src/wp-admin/includes/class-wp-site-logo.php

    r36820 r36837  
    11<?php
    22/**
    3  * Administration API: WP_Site_Logo class
     3 * Administration API: WP_Custom_Logo class
    44 *
    55 * @package WordPress
     
    99
    1010/**
    11  * Core class used to implement site logo functionality.
     11 * Core class used to implement custom logo functionality.
    1212 *
    1313 * @since 4.5.0
    1414 */
    15 class WP_Site_Logo {
     15class WP_Custom_Logo {
    1616
    1717    /**
     
    3535    public function head_text_styles() {
    3636        // Bail if our theme supports custom headers.
    37         if ( current_theme_supports( 'custom-header' ) || get_theme_mod( 'site_logo_header_text', true ) ) {
     37        if ( current_theme_supports( 'custom-header' ) || get_theme_mod( 'custom_logo_header_text', true ) ) {
    3838            return;
    3939        }
     
    4141        // Is Display Header Text unchecked? If so, hide the header text.
    4242        ?>
    43         <!-- Site Logo: hide header text -->
     43        <!-- Custom Logo: hide header text -->
    4444        <style type="text/css">
    4545            <?php echo sanitize_html_class( $this->header_text_classes() ); ?>  {
     
    5252
    5353    /**
    54      * Resets the site logo if the current logo is deleted in the media manager.
     54     * Reset the custom logo if the current logo is deleted in the media manager.
    5555     *
    5656     * @since 4.5.0
     
    6060     */
    6161    public function delete_attachment_data( $post_id ) {
    62         $site_logo_id = get_theme_mod( 'site_logo' );
     62        $custom_logo_id = get_theme_mod( 'custom_logo' );
    6363
    64         if ( $site_logo_id && $site_logo_id == $post_id ) {
    65             remove_theme_mod( 'site_logo' );
     64        if ( $custom_logo_id && $custom_logo_id == $post_id ) {
     65            remove_theme_mod( 'custom_logo' );
    6666        }
    6767    }
     
    106106     */
    107107    protected function header_text_classes() {
    108         $args = get_theme_support( 'site-logo' );
     108        $args = get_theme_support( 'custom-logo' );
    109109
    110110        if ( isset( $args[0]['header-text'] ) ) {
     
    132132
    133133/**
    134  * WP_Site_Logo instance.
     134 * WP_Custom_Logo instance.
    135135 *
    136  * @global WP_Site_Logo $wp_site_logo
     136 * @global WP_Custom_Logo $wp_custom_logo
    137137 */
    138 $GLOBALS['wp_site_logo'] = new WP_Site_Logo;
     138$GLOBALS['wp_custom_logo'] = new WP_Custom_Logo;
  • trunk/src/wp-admin/js/customize-controls.js

    r36805 r36837  
    23042304
    23052305    /**
    2306      * A control for selecting Site Logos.
     2306     * A control for selecting custom logos.
    23072307     *
    23082308     * @class
     
    23112311     * @augments wp.customize.Class
    23122312     */
    2313     api.SiteLogoControl = api.MediaControl.extend({
     2313    api.CustomLogoControl = api.MediaControl.extend({
    23142314
    23152315        /**
     
    23312331            control.setting.bind( function( attachmentId ) {
    23322332                wp.media.attachment( attachmentId ).fetch().done( function() {
    2333                     wp.customize.previewer.send( 'site-logo-attachment-data', this.attributes );
     2333                    wp.customize.previewer.send( 'custom-logo-attachment-data', this.attributes );
    23342334                } );
    23352335
     
    32463246        cropped_image: api.CroppedImageControl,
    32473247        site_icon:     api.SiteIconControl,
    3248         site_logo:     api.SiteLogoControl,
     3248        custom_logo:   api.CustomLogoControl,
    32493249        header:        api.HeaderControl,
    32503250        background:    api.BackgroundControl,
  • trunk/src/wp-includes/class-wp-customize-manager.php

    r36796 r36837  
    18491849        $this->register_control_type( 'WP_Customize_Cropped_Image_Control' );
    18501850        $this->register_control_type( 'WP_Customize_Site_Icon_Control' );
    1851         $this->register_control_type( 'WP_Customize_Site_Logo_Control' );
     1851        $this->register_control_type( 'WP_Customize_Custom_Logo_Control' );
    18521852        $this->register_control_type( 'WP_Customize_Theme_Control' );
    18531853
     
    19611961        ) ) );
    19621962
    1963         $this->add_setting( 'site_logo', array(
    1964             'theme_supports' => array( 'site-logo' ),
     1963        $this->add_setting( 'custom_logo', array(
     1964            'theme_supports' => array( 'custom-logo' ),
    19651965            'transport'      => 'postMessage',
    19661966        ) );
    19671967
    1968         $this->add_control( new WP_Customize_Site_Logo_Control( $this, 'site_logo', array(
     1968        $this->add_control( new WP_Customize_Custom_Logo_Control( $this, 'custom_logo', array(
    19691969            'label'    => __( 'Logo' ),
    19701970            'section'  => 'title_tagline',
     
    19731973
    19741974        if ( isset( $this->selective_refresh ) ) {
    1975             $this->selective_refresh->add_partial( 'site_logo', array(
    1976                 'settings'            => array( 'site_logo' ),
    1977                 'selector'            => '.site-logo-link',
    1978                 'render_callback'     => array( $this, '_render_site_logo_partial' ),
     1975            $this->selective_refresh->add_partial( 'custom_logo', array(
     1976                'settings'            => array( 'custom_logo' ),
     1977                'selector'            => '.custom-logo-link',
     1978                'render_callback'     => array( $this, '_render_custom_logo_partial' ),
    19791979                'container_inclusive' => true,
    19801980            ) );
     
    22122212
    22132213    /**
    2214      * Callback for rendering the site logo, used in the site_logo partial.
     2214     * Callback for rendering the custom logo, used in the custom_logo partial.
    22152215     *
    22162216     * This method exists because the partial object and context data are passed
    2217      * into a partial's render_callback so we cannot use get_the_site_logo() as
     2217     * into a partial's render_callback so we cannot use get_custom_logo() as
    22182218     * the render_callback directly since it expects a blog ID as the first
    22192219     * argument. When WP no longer supports PHP 5.3, this method can be removed
     
    22252225     * @access private
    22262226     *
    2227      * @return string Site logo.
    2228      */
    2229     public function _render_site_logo_partial() {
    2230         return get_the_site_logo();
     2227     * @return string Custom logo.
     2228     */
     2229    public function _render_custom_logo_partial() {
     2230        return get_custom_logo();
    22312231    }
    22322232}
  • trunk/src/wp-includes/customize/class-wp-customize-site-logo-control.php

    r36698 r36837  
    11<?php
    22/**
    3  * Customize API: WP_Customize_Site_Logo_Control class
     3 * Customize API: WP_Customize_Custom_Logo_Control class
    44 *
    55 * @package WordPress
     
    99
    1010/**
    11  * Customize Site Logo control class.
     11 * Customize custom logo control class.
    1212 *
    1313 * Used only for custom functionality in JavaScript.
     
    1717 * @see WP_Customize_Image_Control
    1818 */
    19 class WP_Customize_Site_Logo_Control extends WP_Customize_Image_Control {
     19class WP_Customize_Custom_Logo_Control extends WP_Customize_Image_Control {
    2020
    2121    /**
     
    2626     * @var string
    2727     */
    28     public $type = 'site_logo';
     28    public $type = 'custom_logo';
    2929
    3030    /**
  • trunk/src/wp-includes/general-template.php

    r36802 r36837  
    840840
    841841/**
    842  * Whether the site has a Site Logo.
     842 * Whether the site has a custom logo.
    843843 *
    844844 * @since 4.5.0
    845845 *
    846846 * @param int $blog_id Optional. ID of the blog in question. Default current blog.
    847  * @return bool Whether the site has a site logo or not.
    848  */
    849 function has_site_logo( $blog_id = 0 ) {
     847 * @return bool Whether the site has a custom logo or not.
     848 */
     849function has_custom_logo( $blog_id = 0 ) {
    850850    if ( is_multisite() && (int) $blog_id !== get_current_blog_id() ) {
    851851        switch_to_blog( $blog_id );
    852852    }
    853853
    854     $site_logo_id = get_theme_mod( 'site_logo' );
     854    $custom_logo_id = get_theme_mod( 'custom_logo' );
    855855
    856856    if ( is_multisite() && ms_is_switched() ) {
     
    858858    }
    859859
    860     return (bool) $site_logo_id;
    861 }
    862 
    863 /**
    864  * Returns a Site Logo, linked to home.
     860    return (bool) $custom_logo_id;
     861}
     862
     863/**
     864 * Returns a custom logo, linked to home.
    865865 *
    866866 * @since 4.5.0
    867867 *
    868868 * @param int $blog_id Optional. ID of the blog in question. Default current blog.
    869  * @return string Site logo markup.
    870  */
    871 function get_the_site_logo( $blog_id = 0 ) {
     869 * @return string Custom logo markup.
     870 */
     871function get_custom_logo( $blog_id = 0 ) {
    872872    $html = '';
    873873
     
    876876    }
    877877
    878     $site_logo_id = get_theme_mod( 'site_logo' );
     878    $custom_logo_id = get_theme_mod( 'custom_logo' );
    879879
    880880    if ( is_multisite() && ms_is_switched() ) {
    881881        restore_current_blog();
    882882    }
    883     $size = get_theme_support( 'site-logo' );
     883    $size = get_theme_support( 'custom-logo' );
    884884    $size = $size[0]['size'];
    885885
    886886    // We have a logo. Logo is go.
    887     if ( $site_logo_id ) {
    888         $html = sprintf( '<a href="%1$s" class="site-logo-link" rel="home" itemprop="url">%2$s</a>',
     887    if ( $custom_logo_id ) {
     888        $html = sprintf( '<a href="%1$s" class="custom-logo-link" rel="home" itemprop="url">%2$s</a>',
    889889            esc_url( home_url( '/' ) ),
    890             wp_get_attachment_image( $site_logo_id, $size, false, array(
    891                 'class'     => "site-logo attachment-$size",
     890            wp_get_attachment_image( $custom_logo_id, $size, false, array(
     891                'class'     => "custom-logo attachment-$size",
    892892                'data-size' => $size,
    893893                'itemprop'  => 'logo',
     
    898898    // If no logo is set but we're in the Customizer, leave a placeholder (needed for the live preview).
    899899    elseif ( is_customize_preview() ) {
    900         $html = sprintf( '<a href="%1$s" class="site-logo-link" style="display:none;"><img class="site-logo" data-size="%2$s" /></a>',
     900        $html = sprintf( '<a href="%1$s" class="custom-logo-link" style="display:none;"><img class="custom-logo" data-size="%2$s" /></a>',
    901901            esc_url( home_url( '/' ) ),
    902902            esc_attr( $size )
     
    905905
    906906    /**
    907      * Filter the Site Logo output.
     907     * Filter the custom logo output.
    908908     *
    909909     * @since 4.5.0
    910910     *
    911      * @param string $html Site Logo HTML output.
     911     * @param string $html Custom logo HTML output.
    912912     * @param string $size Size specified in add_theme_support declaration, or 'thumbnail' default.
    913913     */
    914     return apply_filters( 'get_the_site_logo', $html, $size );
    915 }
    916 
    917 /**
    918  * Displays a Site Logo, linked to home.
     914    return apply_filters( 'get_custom_logo', $html, $size );
     915}
     916
     917/**
     918 * Displays a custom logo, linked to home.
    919919 *
    920920 * @since 4.5.0
     
    922922 * @param int $blog_id Optional. ID of the blog in question. Default current blog.
    923923 */
    924 function the_site_logo( $blog_id = 0 ) {
    925     echo get_the_site_logo( $blog_id );
     924function the_custom_logo( $blog_id = 0 ) {
     925    echo get_custom_logo( $blog_id );
    926926}
    927927
  • trunk/src/wp-includes/js/customize-preview.js

    r36698 r36837  
    225225
    226226        /**
    227          * Site Logo
    228          *
    229          * The site logo setting only contains the attachment ID. To avoid having to send an AJAX request to get more
     227         * Custom Logo
     228         *
     229         * The custom logo setting only contains the attachment ID. To avoid having to send an AJAX request to get more
    230230         * data, we send a separate message with the attachment data we get from the Customizer's media modal.
    231231         * Therefore first callback handles only the event of a new logo being selected.
     
    235235         * @since 4.5.0
    236236         */
    237         api.preview.bind( 'site-logo-attachment-data', function( attachment ) {
    238             var $logo  = $( '.site-logo' ),
     237        api.preview.bind( 'custom-logo-attachment-data', function( attachment ) {
     238            var $logo  = $( '.custom-logo' ),
    239239                size   = $logo.data( 'size' ),
    240240                srcset = [];
     
    256256            } );
    257257
    258             $( '.site-logo-link' ).show();
    259             $( 'body' ).addClass( 'wp-site-logo' );
    260         } );
    261 
    262         api( 'site_logo', function( setting ) {
     258            $( '.custom-logo-link' ).show();
     259        } );
     260
     261        api( 'custom_logo', function( setting ) {
    263262            setting.bind( function( newValue ) {
    264263                if ( ! newValue ) {
    265                     $( '.site-logo-link' ).hide();
    266                     $( 'body' ).removeClass( 'wp-site-logo' );
    267                 }
    268             } );
    269 
    270             // Focus on the control when the logo is clicked, if there is no site_logo partial.
    271             if ( ! api.selectiveRefresh || ! api.selectiveRefresh.partial.has( 'site_logo' ) ) {
    272                 $( document.body ).on( 'click', '.site-logo-link', function( e ) {
     264                    $( '.custom-logo-link' ).hide();
     265                }
     266            } );
     267
     268            // Focus on the control when the logo is clicked, if there is no custom_logo partial.
     269            if ( ! api.selectiveRefresh || ! api.selectiveRefresh.partial.has( 'custom_logo' ) ) {
     270                $( document.body ).on( 'click', '.custom-logo-link', function( e ) {
    273271                    if ( ! e.shiftKey ) {
    274272                        return;
    275273                    }
    276                     api.preview.send( 'focus-control-for-setting', 'site_logo' );
     274                    api.preview.send( 'focus-control-for-setting', 'custom_logo' );
    277275                } );
    278                 $( '.site-logo-link' ).attr( 'title', api.settings.l10n.shiftClickToEdit );
     276                $( '.custom-logo-link' ).attr( 'title', api.settings.l10n.shiftClickToEdit );
    279277            }
    280278        } );
  • trunk/src/wp-includes/post-template.php

    r36698 r36837  
    706706    if ( get_background_color() !== get_theme_support( 'custom-background', 'default-color' ) || get_background_image() )
    707707        $classes[] = 'custom-background';
    708 
    709     if ( has_site_logo() ) {
    710         $classes[] = 'wp-site-logo';
    711     }
    712708
    713709    $page = $wp_query->get( 'page' );
Note: See TracChangeset for help on using the changeset viewer.