Make WordPress Core

Changeset 36851


Ignore:
Timestamp:
03/04/2016 11:46:07 PM (8 years ago)
Author:
westonruter
Message:

Customize: Eliminate unnecessary WP_Customize_Site_Logo_Control in favor of re-using WP_Customize_Image_Control.

  • Removes double margin-bottom from all the media controls.
  • All media controls now send {settingId}-attachment-data messages to the preview when a media setting is updated so that the preview has access to the attachment data.
  • Fixes receiving of attachment-data message for custom_logo which resulted in instant JS-applied preview not working. See #36096.

See #33755.
Fixes #35941.

Location:
trunk/src
Files:
1 deleted
4 edited

Legend:

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

    r36837 r36851  
    722722.customize-control-cropped_image .current,
    723723.customize-control-site_icon .current,
    724 .customize-control-custom_logo .current,
    725724.customize-control-header .current {
    726725    margin-bottom: 8px;
     
    764763.customize-control-site_icon .default-button,
    765764.customize-control-site_icon .upload-button,
    766 .customize-control-custom_logo .remove-button,
    767 .customize-control-custom_logo .default-button,
    768 .customize-control-custom_logo .upload-button,
    769765.customize-control-header button.new,
    770766.customize-control-header button.remove {
     
    780776.customize-control-cropped_image .current .container,
    781777.customize-control-site_icon .current .container,
    782 .customize-control-custom_logo .current .container,
    783778.customize-control-header .current .container {
    784779    overflow: hidden;
     
    794789.customize-control-cropped_image .current .container,
    795790.customize-control-site_icon .current .container,
    796 .customize-control-custom_logo .current .container,
    797791.customize-control-image .current .container {
    798792    min-height: 40px;
     
    823817.customize-control-cropped_image .inner,
    824818.customize-control-site_icon .inner,
    825 .customize-control-custom_logo .inner,
    826819.customize-control-header .inner {
    827820    display: none;
     
    839832.customize-control-cropped_image .inner,
    840833.customize-control-site_icon .inner,
    841 .customize-control-custom_logo .inner,
    842834.customize-control-image .inner {
    843835    display: block;
     
    851843.customize-control-cropped_image .inner,
    852844.customize-control-site_icon .inner,
    853 .customize-control-custom_logo.inner,
    854845.customize-control-header .inner,
    855846.customize-control-header .inner .dashicons {
     
    951942}
    952943
    953 .customize-control-media .actions,
    954 .customize-control-upload .actions,
    955 .customize-control-image .actions,
    956 .customize-control-background .actions,
    957 .customize-control-cropped_image .actions,
    958 .customize-control-site_icon .actions,
    959 .customize-control-header .actions {
    960     margin-bottom: 32px;
    961 }
    962 
    963944.customize-control-header .choice {
    964945    position: relative;
     
    995976.customize-control-site_icon .remove-button,
    996977.customize-control-site_icon .default-button,
    997 .customize-control-custom_logo .remove-button,
    998 .customize-control-custom_logo .default-button,
    999978.customize-control-header .remove {
    1000979    float: left;
     
    1008987.customize-control-cropped_image .upload-button,
    1009988.customize-control-site_icon .upload-button,
    1010 .customize-control-custom_logo .upload-button,
    1011989.customize-control-header .new {
    1012990    float: right;
  • trunk/src/wp-admin/js/customize-controls.js

    r36837 r36851  
    17911791                });
    17921792
    1793             // Re-render whenever the control's setting changes.
    1794             control.setting.bind( function () { control.renderContent(); } );
     1793            control.setting.bind( function( value ) {
     1794
     1795                // Send attachment information to the preview for possible use in `postMessage` transport.
     1796                wp.media.attachment( value ).fetch().done( function() {
     1797                    wp.customize.previewer.send( control.setting.id + '-attachment-data', this.attributes );
     1798                } );
     1799
     1800                // Re-render whenever the control's setting changes.
     1801                control.renderContent();
     1802            } );
    17951803        },
    17961804
     
    23042312
    23052313    /**
    2306      * A control for selecting custom logos.
    2307      *
    2308      * @class
    2309      * @augments wp.customize.MediaControl
    2310      * @augments wp.customize.Control
    2311      * @augments wp.customize.Class
    2312      */
    2313     api.CustomLogoControl = api.MediaControl.extend({
    2314 
    2315         /**
    2316          * When the control's DOM structure is ready,
    2317          * set up internal event bindings.
    2318          */
    2319         ready: function() {
    2320             var control = this;
    2321 
    2322             // Shortcut so that we don't have to use _.bind every time we add a callback.
    2323             _.bindAll( control, 'restoreDefault', 'removeFile', 'openFrame', 'select' );
    2324 
    2325             // Bind events, with delegation to facilitate re-rendering.
    2326             control.container.on( 'click keydown', '.upload-button', control.openFrame );
    2327             control.container.on( 'click keydown', '.thumbnail-image img', control.openFrame );
    2328             control.container.on( 'click keydown', '.default-button', control.restoreDefault );
    2329             control.container.on( 'click keydown', '.remove-button', control.removeFile );
    2330 
    2331             control.setting.bind( function( attachmentId ) {
    2332                 wp.media.attachment( attachmentId ).fetch().done( function() {
    2333                     wp.customize.previewer.send( 'custom-logo-attachment-data', this.attributes );
    2334                 } );
    2335 
    2336                 // Re-render whenever the control's setting changes.
    2337                 control.renderContent();
    2338             } );
    2339         }
    2340     });
    2341 
    2342     /**
    23432314     * @class
    23442315     * @augments wp.customize.Control
     
    32463217        cropped_image: api.CroppedImageControl,
    32473218        site_icon:     api.SiteIconControl,
    3248         custom_logo:   api.CustomLogoControl,
    32493219        header:        api.HeaderControl,
    32503220        background:    api.BackgroundControl,
  • trunk/src/wp-includes/class-wp-customize-manager.php

    r36838 r36851  
    218218        require_once( ABSPATH . WPINC . '/customize/class-wp-customize-cropped-image-control.php' );
    219219        require_once( ABSPATH . WPINC . '/customize/class-wp-customize-site-icon-control.php' );
    220         require_once( ABSPATH . WPINC . '/customize/class-wp-customize-custom-logo-control.php' );
    221220        require_once( ABSPATH . WPINC . '/customize/class-wp-customize-header-image-control.php' );
    222221        require_once( ABSPATH . WPINC . '/customize/class-wp-customize-theme-control.php' );
     
    18491848        $this->register_control_type( 'WP_Customize_Cropped_Image_Control' );
    18501849        $this->register_control_type( 'WP_Customize_Site_Icon_Control' );
    1851         $this->register_control_type( 'WP_Customize_Custom_Logo_Control' );
    18521850        $this->register_control_type( 'WP_Customize_Theme_Control' );
    18531851
     
    19661964        ) );
    19671965
    1968         $this->add_control( new WP_Customize_Custom_Logo_Control( $this, 'custom_logo', array(
     1966        $this->add_control( new WP_Customize_Media_Control( $this, 'custom_logo', array(
    19691967            'label'    => __( 'Logo' ),
    19701968            'section'  => 'title_tagline',
    19711969            'priority' => 0,
     1970            'mime_type' => 'image',
     1971            'button_labels' => array(
     1972                'select'       => __( 'Select logo' ),
     1973                'change'       => __( 'Change logo' ),
     1974                'remove'       => __( 'Remove' ),
     1975                'default'      => __( 'Default' ),
     1976                'placeholder'  => __( 'No logo selected' ),
     1977                'frame_title'  => __( 'Select logo' ),
     1978                'frame_button' => __( 'Choose logo' ),
     1979            ),
    19721980        ) ) );
    19731981
  • trunk/src/wp-includes/js/customize-preview.js

    r36837 r36851  
    235235         * @since 4.5.0
    236236         */
    237         api.preview.bind( 'custom-logo-attachment-data', function( attachment ) {
     237        api.preview.bind( 'custom_logo-attachment-data', function( attachment ) {
    238238            var $logo  = $( '.custom-logo' ),
    239239                size   = $logo.data( 'size' ),
Note: See TracChangeset for help on using the changeset viewer.