diff --git src/wp-includes/js/customize-preview.js src/wp-includes/js/customize-preview.js
index 39ac5f4..ac77551 100644
|
|
|
226 | 226 | /** |
227 | 227 | * Custom Logo |
228 | 228 | * |
229 | | * The custom logo setting only contains the attachment ID. To avoid having to send an AJAX request to get more |
230 | | * data, we send a separate message with the attachment data we get from the Customizer's media modal. |
231 | | * Therefore first callback handles only the event of a new logo being selected. |
232 | | * |
233 | | * We don't need any information about a removed logo, so the second callback only handles that. |
| 229 | * Toggle the wp-custom-logo body class when a logo is added or removed. |
234 | 230 | * |
235 | 231 | * @since 4.5.0 |
236 | 232 | */ |
237 | | api.preview.bind( 'custom_logo-attachment-data', function( attachment ) { |
238 | | var $logo = $( '.custom-logo' ), |
239 | | size = $logo.data( 'size' ), |
240 | | srcset = []; |
241 | | |
242 | | // If the source was smaller than the size required by the theme, give the biggest we've got. |
243 | | if ( ! attachment.sizes[ size ] ) { |
244 | | size = 'full'; |
245 | | } |
246 | | |
247 | | _.each( attachment.sizes, function( size ) { |
248 | | srcset.push( size.url + ' ' + size.width + 'w' ); |
249 | | } ); |
250 | | |
251 | | $logo.attr( { |
252 | | height: attachment.sizes[ size ].height, |
253 | | width: attachment.sizes[ size ].width, |
254 | | src: attachment.sizes[ size ].url, |
255 | | srcset: srcset |
256 | | } ); |
257 | | |
258 | | $( '.custom-logo-link' ).show(); |
259 | | $( 'body' ).addClass( 'wp-custom-logo' ); |
260 | | } ); |
261 | | |
262 | 233 | api( 'custom_logo', function( setting ) { |
263 | | setting.bind( function( newValue ) { |
264 | | if ( ! newValue ) { |
265 | | $( '.custom-logo-link' ).hide(); |
266 | | $( 'body' ).removeClass( 'wp-custom-logo' ); |
267 | | } |
| 234 | $( 'body' ).toggleClass( 'wp-custom-logo', !! setting.get() ); |
| 235 | setting.bind( function( attachmentId ) { |
| 236 | $( 'body' ).toggleClass( 'wp-custom-logo', !! attachmentId ); |
268 | 237 | } ); |
269 | | |
270 | | // Focus on the control when the logo is clicked, if there is no custom_logo partial. |
271 | | if ( ! api.selectiveRefresh || ! api.selectiveRefresh.partial.has( 'custom_logo' ) ) { |
272 | | $( document.body ).on( 'click', '.custom-logo-link', function( e ) { |
273 | | if ( ! e.shiftKey ) { |
274 | | return; |
275 | | } |
276 | | api.preview.send( 'focus-control-for-setting', 'custom_logo' ); |
277 | | } ); |
278 | | $( '.custom-logo-link' ).attr( 'title', api.settings.l10n.shiftClickToEdit ); |
279 | | } |
280 | 238 | } ); |
281 | 239 | |
282 | 240 | api.trigger( 'preview-ready' ); |