Customize: Prevent absent site icon link from outputting an empty string as href in customizer; use /favicon.ico as fallback.
An empty string causes some browsers to use the current URL as the `href`. When using `history.replaceState()` Chrome will re-fetch the favicon with each call, meaning that `customize.php` gets hit with wasted requests which tax the server. Fixes #38377. Built from https://develop.svn.wordpress.org/trunk@38901 git-svn-id: http://core.svn.wordpress.org/trunk@38844 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -3333,7 +3333,7 @@
|
||||
* @param {object} attachment
|
||||
*/
|
||||
setImageFromAttachment: function( attachment ) {
|
||||
var sizes = [ 'site_icon-32', 'thumbnail', 'full' ],
|
||||
var sizes = [ 'site_icon-32', 'thumbnail', 'full' ], link,
|
||||
icon;
|
||||
|
||||
_.each( sizes, function( size ) {
|
||||
@@ -3347,8 +3347,13 @@
|
||||
// Set the Customizer setting; the callback takes care of rendering.
|
||||
this.setting( attachment.id );
|
||||
|
||||
if ( ! icon ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Update the icon in-browser.
|
||||
$( 'link[sizes="32x32"]' ).attr( 'href', icon.url );
|
||||
link = $( 'link[rel="icon"][sizes="32x32"]' );
|
||||
link.attr( 'href', icon.url );
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -3365,7 +3370,7 @@
|
||||
this.params.attachment = {};
|
||||
this.setting( '' );
|
||||
this.renderContent(); // Not bound to setting change when emptying.
|
||||
$( 'link[rel="icon"]' ).attr( 'href', '' );
|
||||
$( 'link[rel="icon"][sizes="32x32"]' ).attr( 'href', '/favicon.ico' ); // Set to default.
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
4
wp-admin/js/customize-controls.min.js
vendored
4
wp-admin/js/customize-controls.min.js
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user