Site icon: Polish up Site Icon on the general settings screen.

This fixes a number of issues, chief among them:
- Updates to the site title are reflected in the preview.
- Improve alt text for preview
- Make string describing site icon more succinct.
- Add inline documentation to JavaScript

Props kebbet, jorbin, swissspidy, afercia, mukesh27, alexstine, jameskoster, andraganescu.
Fixes #54370.


Built from https://develop.svn.wordpress.org/trunk@57713


git-svn-id: http://core.svn.wordpress.org/trunk@57214 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Aaron Jorbin 2024-02-26 20:18:09 +00:00
parent 0eb0449db0
commit 7173bb9a94
14 changed files with 256 additions and 124 deletions

View File

@ -790,7 +790,7 @@ ul#add-to-blog-users {
outline: 2px solid transparent; outline: 2px solid transparent;
} }
.button-add-site-icon{ .button-add-site-icon {
width: 100%; width: 100%;
cursor: pointer; cursor: pointer;
text-align: center; text-align: center;
@ -802,23 +802,23 @@ ul#add-to-blog-users {
} }
.button-add-site-icon:focus, .button-add-site-icon:focus,
.button-add-site-icon:hover{ .button-add-site-icon:hover {
background: white; background: #fff;
} }
.site-icon-section .favicon-preview{ .site-icon-section .favicon-preview {
float: right; float: right;
} }
.site-icon-section .app-icon-preview{ .site-icon-section .app-icon-preview {
float: right; float: right;
margin: 0 20px; margin: 0 20px;
} }
.site-icon-section .site-icon-preview img{ .site-icon-section .site-icon-preview img {
max-width: 100%; max-width: 100%;
} }
.button-ad-site-icon:focus{ .button-add-site-icon:focus {
background-color: #fff; background-color: #fff;
border-color: #3582c4; border-color: #3582c4;
border-style: solid; border-style: solid;

File diff suppressed because one or more lines are too long

View File

@ -789,7 +789,7 @@ ul#add-to-blog-users {
outline: 2px solid transparent; outline: 2px solid transparent;
} }
.button-add-site-icon{ .button-add-site-icon {
width: 100%; width: 100%;
cursor: pointer; cursor: pointer;
text-align: center; text-align: center;
@ -801,23 +801,23 @@ ul#add-to-blog-users {
} }
.button-add-site-icon:focus, .button-add-site-icon:focus,
.button-add-site-icon:hover{ .button-add-site-icon:hover {
background: white; background: #fff;
} }
.site-icon-section .favicon-preview{ .site-icon-section .favicon-preview {
float: left; float: left;
} }
.site-icon-section .app-icon-preview{ .site-icon-section .app-icon-preview {
float: left; float: left;
margin: 0 20px; margin: 0 20px;
} }
.site-icon-section .site-icon-preview img{ .site-icon-section .site-icon-preview img {
max-width: 100%; max-width: 100%;
} }
.button-ad-site-icon:focus{ .button-add-site-icon:focus {
background-color: #fff; background-color: #fff;
border-color: #3582c4; border-color: #3582c4;
border-style: solid; border-style: solid;

File diff suppressed because one or more lines are too long

View File

@ -8,7 +8,6 @@
overflow: hidden; overflow: hidden;
position: relative; position: relative;
max-width: 180px; max-width: 180px;
float: right;
} }
.site-icon-preview .favicon, .site-icon-preview .favicon,

View File

@ -1,2 +1,2 @@
/*! This file is auto-generated */ /*! This file is auto-generated */
.site-icon-preview .favicon-preview{margin:5px 0 20px;overflow:hidden;position:relative;max-width:180px;float:right}.site-icon-preview .browser-title,.site-icon-preview .favicon{height:16px;right:88px;overflow:hidden;position:absolute;top:16px}.site-icon-preview .favicon{width:16px}.site-icon-preview .browser-title{right:109px;width:72px;white-space:nowrap}.site-icon-preview .app-icon-preview{background-color:#000;border-radius:16px;height:64px;overflow:hidden;width:64px;margin-top:5px}.site-icon-preview .app-icon-preview,.site-icon-preview .favicon{direction:ltr}.customize-control-site_icon .favicon-preview{float:right;margin-left:12px;margin-bottom:0}.customize-control-site_icon .app-icon-preview{margin-top:9px}.site-icon-section button.reset{color:#b32d2e;text-decoration:none;border-color:transparent;box-shadow:none;background:0 0}.site-icon-section button.reset:focus,.site-icon-section button.reset:hover{background:#b32d2e;color:#fff;border-color:#b32d2e;box-shadow:0 0 0 1px #b32d2e}.site-icon-section .action-buttons{display:flex;flex-wrap:wrap;gap:10px} .site-icon-preview .favicon-preview{margin:5px 0 20px;overflow:hidden;position:relative;max-width:180px}.site-icon-preview .browser-title,.site-icon-preview .favicon{height:16px;right:88px;overflow:hidden;position:absolute;top:16px}.site-icon-preview .favicon{width:16px}.site-icon-preview .browser-title{right:109px;width:72px;white-space:nowrap}.site-icon-preview .app-icon-preview{background-color:#000;border-radius:16px;height:64px;overflow:hidden;width:64px;margin-top:5px}.site-icon-preview .app-icon-preview,.site-icon-preview .favicon{direction:ltr}.customize-control-site_icon .favicon-preview{float:right;margin-left:12px;margin-bottom:0}.customize-control-site_icon .app-icon-preview{margin-top:9px}.site-icon-section button.reset{color:#b32d2e;text-decoration:none;border-color:transparent;box-shadow:none;background:0 0}.site-icon-section button.reset:focus,.site-icon-section button.reset:hover{background:#b32d2e;color:#fff;border-color:#b32d2e;box-shadow:0 0 0 1px #b32d2e}.site-icon-section .action-buttons{display:flex;flex-wrap:wrap;gap:10px}

View File

@ -7,7 +7,6 @@
overflow: hidden; overflow: hidden;
position: relative; position: relative;
max-width: 180px; max-width: 180px;
float: left;
} }
.site-icon-preview .favicon, .site-icon-preview .favicon,

View File

@ -1,2 +1,2 @@
/*! This file is auto-generated */ /*! This file is auto-generated */
.site-icon-preview .favicon-preview{margin:5px 0 20px;overflow:hidden;position:relative;max-width:180px;float:left}.site-icon-preview .browser-title,.site-icon-preview .favicon{height:16px;left:88px;overflow:hidden;position:absolute;top:16px}.site-icon-preview .favicon{width:16px}.site-icon-preview .browser-title{left:109px;width:72px;white-space:nowrap}.site-icon-preview .app-icon-preview{background-color:#000;border-radius:16px;height:64px;overflow:hidden;width:64px;margin-top:5px}.site-icon-preview .app-icon-preview,.site-icon-preview .favicon{direction:ltr}.customize-control-site_icon .favicon-preview{float:left;margin-right:12px;margin-bottom:0}.customize-control-site_icon .app-icon-preview{margin-top:9px}.site-icon-section button.reset{color:#b32d2e;text-decoration:none;border-color:transparent;box-shadow:none;background:0 0}.site-icon-section button.reset:focus,.site-icon-section button.reset:hover{background:#b32d2e;color:#fff;border-color:#b32d2e;box-shadow:0 0 0 1px #b32d2e}.site-icon-section .action-buttons{display:flex;flex-wrap:wrap;gap:10px} .site-icon-preview .favicon-preview{margin:5px 0 20px;overflow:hidden;position:relative;max-width:180px}.site-icon-preview .browser-title,.site-icon-preview .favicon{height:16px;left:88px;overflow:hidden;position:absolute;top:16px}.site-icon-preview .favicon{width:16px}.site-icon-preview .browser-title{left:109px;width:72px;white-space:nowrap}.site-icon-preview .app-icon-preview{background-color:#000;border-radius:16px;height:64px;overflow:hidden;width:64px;margin-top:5px}.site-icon-preview .app-icon-preview,.site-icon-preview .favicon{direction:ltr}.customize-control-site_icon .favicon-preview{float:left;margin-right:12px;margin-bottom:0}.customize-control-site_icon .app-icon-preview{margin-top:9px}.site-icon-section button.reset{color:#b32d2e;text-decoration:none;border-color:transparent;box-shadow:none;background:0 0}.site-icon-section button.reset:focus,.site-icon-section button.reset:hover{background:#b32d2e;color:#fff;border-color:#b32d2e;box-shadow:0 0 0 1px #b32d2e}.site-icon-section .action-buttons{display:flex;flex-wrap:wrap;gap:10px}

View File

@ -36,6 +36,7 @@ function options_general_add_js() {
<script type="text/javascript"> <script type="text/javascript">
jQuery( function($) { jQuery( function($) {
var $siteName = $( '#wp-admin-bar-site-name' ).children( 'a' ).first(), var $siteName = $( '#wp-admin-bar-site-name' ).children( 'a' ).first(),
$siteIconPreview = $('#site-icon-preview-site-title'),
homeURL = ( <?php echo wp_json_encode( get_home_url() ); ?> || '' ).replace( /^(https?:\/\/)?(www\.)?/, '' ); homeURL = ( <?php echo wp_json_encode( get_home_url() ); ?> || '' ).replace( /^(https?:\/\/)?(www\.)?/, '' );
$( '#blogname' ).on( 'input', function() { $( '#blogname' ).on( 'input', function() {
@ -47,6 +48,7 @@ function options_general_add_js() {
} }
$siteName.text( title ); $siteName.text( title );
$siteIconPreview.text( title );
}); });
$( 'input[name="date_format"]' ).on( 'click', function() { $( 'input[name="date_format"]' ).on( 'click', function() {

View File

@ -1,15 +1,40 @@
(function($) { /**
var frame; * Handle the site icon setting in options-general.php.
*
* @since 6.5.0
* @output wp-admin/js/site-icon.js
*/
function calculateImageSelectOptions ( attachment ) { /* global jQuery, wp */
var realWidth = attachment.get( 'width' ),
( function ( $ ) {
var $chooseButton = $( '#choose-from-library-button' ),
$iconPreview = $( '#site-icon-preview' ),
$browserIconPreview = $( '#browser-icon-preview' ),
$appIconPreview = $( '#app-icon-preview' ),
$hiddenDataField = $( '#site_icon_hidden_field' ),
$removeButton = $( '#js-remove-site-icon' ),
frame;
/**
* Calculate image selection options based on the attachment dimensions.
*
* @since 6.5.0
*
* @param {Object} attachment The attachment object representing the image.
* @return {Object} The image selection options.
*/
function calculateImageSelectOptions( attachment ) {
var realWidth = attachment.get( 'width' ),
realHeight = attachment.get( 'height' ), realHeight = attachment.get( 'height' ),
xInit = 512, xInit = 512,
yInit = 512, yInit = 512,
ratio = xInit / yInit, ratio = xInit / yInit,
xImg = xInit, xImg = xInit,
yImg = yInit, yImg = yInit,
x1, y1, imgSelectOptions; x1,
y1,
imgSelectOptions;
if ( realWidth / realHeight > ratio ) { if ( realWidth / realHeight > ratio ) {
yInit = realHeight; yInit = realHeight;
@ -35,104 +60,177 @@
x1: x1, x1: x1,
y1: y1, y1: y1,
x2: xInit + x1, x2: xInit + x1,
y2: yInit + y1 y2: yInit + y1,
}; };
return imgSelectOptions; return imgSelectOptions;
} }
$( function() { /**
// Build the choose from library frame. * Initializes the media frame for selecting or cropping an image.
$( '#choose-from-library-link' ).on( 'click', function() { *
var $el = $(this); * @since 6.5.0
*/
$chooseButton.on( 'click', function () {
var $el = $( this );
// Create the media frame. // Create the media frame.
frame = wp.media({ frame = wp.media( {
button: { button: {
// Set the text of the button. // Set the text of the button.
text: $el.data('update'), text: $el.data( 'update' ),
// Don't close, we might need to crop.
close: false // Don't close, we might need to crop.
}, close: false,
states: [ },
new wp.media.controller.Library({ states: [
title: $el.data( 'choose' ), new wp.media.controller.Library( {
library: wp.media.query({ type: 'image' }), title: $el.data( 'choose-text' ),
date: false, library: wp.media.query( { type: 'image' } ),
suggestedWidth: $el.data( 'size' ), date: false,
suggestedHeight: $el.data( 'size' ) suggestedWidth: $el.data( 'size' ),
}), suggestedHeight: $el.data( 'size' ),
new wp.media.controller.SiteIconCropper({ } ),
control: { new wp.media.controller.SiteIconCropper( {
params: { control: {
width: $el.data( 'size' ), params: {
height: $el.data( 'size' ) width: $el.data( 'size' ),
} height: $el.data( 'size' ),
}, },
imgSelectOptions: calculateImageSelectOptions },
}) imgSelectOptions: calculateImageSelectOptions,
] } ),
}); ],
} );
frame.on( 'cropped', function( attachment) { frame.on( 'cropped', function ( attachment ) {
$( '#site_icon_hidden_field' ).val(attachment.id); $hiddenDataField.val( attachment.id );
switchToUpdate(attachment.url); switchToUpdate( attachment );
frame.close();
// Start over with a frame that is so fresh and so clean clean.
frame = null;
} );
// When an image is selected, run a callback.
frame.on( 'select', function () {
// Grab the selected attachment.
var attachment = frame.state().get( 'selection' ).first();
if (
attachment.attributes.height === $el.data( 'size' ) &&
$el.data( 'size' ) === attachment.attributes.width
) {
switchToUpdate( attachment.attributes );
frame.close(); frame.close();
// Start over with a frame that is so fresh and so clean clean.
frame = null;
});
// When an image is selected, run a callback. // Set the value of the hidden input to the attachment id.
frame.on( 'select', function() { $hiddenDataField.val( attachment.id );
// Grab the selected attachment. } else {
var attachment = frame.state().get('selection').first(); frame.setState( 'cropper' );
}
} );
if ( attachment.attributes.height === $el.data('size') && $el.data('size') === attachment.attributes.width ) { frame.open();
// Set the value of the hidden input to the attachment id. } );
$( '#site_icon_hidden_field').val(attachment.id);
switchToUpdate(attachment.attributes.url);
frame.close();
} else {
frame.setState( 'cropper' );
}
});
frame.open(); /**
}); * Update the UI when a site icon is selected.
}); *
* @since 6.5.0
*
* @param {array} attributes The attributes for the attachment.
*/
function switchToUpdate( attributes ) {
var i18nAppAlternativeString, i18nBrowserAlternativeString;
function switchToUpdate( url ){ if ( attributes.alt ) {
// Set site-icon-img src to the url and remove the hidden class. i18nAppAlternativeString = wp.i18n.sprintf(
$( '#site-icon-preview').find('img').not('.browser-preview').each( function(i, img ){ /* translators: %s: The selected image alt text. */
$(img).attr('src', url ); wp.i18n.__( 'App icon preview: Current image: %s' ),
}); attributes.alt
$( '#site-icon-preview' ).removeClass( 'hidden' ); );
// Remove hidden class from remove. i18nBrowserAlternativeString = wp.i18n.sprintf(
$( '#js-remove-site-icon' ).removeClass( 'hidden' ); /* translators: %s: The selected image alt text. */
// If the button is not in the update state, swap the classes. wp.i18n.__( 'Browser icon preview: Current image: %s' ),
if( $( '#choose-from-library-link' ).attr( 'data-state' ) !== '1' ){ attributes.alt
var classes = $( '#choose-from-library-link' ).attr( 'class' ); );
$( '#choose-from-library-link' ).attr( 'class', $( '#choose-from-library-link' ).attr('data-alt-classes') ); } else {
$( '#choose-from-library-link' ).attr( 'data-alt-classes', classes ); i18nAppAlternativeString = wp.i18n.sprintf(
$( '#choose-from-library-link' ).attr( 'data-state', '1' ); /* translators: %s: The selected image filename. */
wp.i18n.__(
'App icon preview: The current image has no alternative text. The file name is: %s'
),
attributes.filename
);
i18nBrowserAlternativeString = wp.i18n.sprintf(
/* translators: %s: The selected image filename. */
wp.i18n.__(
'Browser icon preview: The current image has no alternative text. The file name is: %s'
),
attributes.filename
);
} }
// swap the text of the button // Set site-icon-img src and alternative text to app icon preview.
$( '#choose-from-library-link' ).text( $( '#choose-from-library-link' ).attr( 'data-update-text' ) ); $appIconPreview.attr( {
src: attributes.url,
alt: i18nAppAlternativeString,
} );
// Set site-icon-img src and alternative text to browser preview.
$browserIconPreview.attr( {
src: attributes.url,
alt: i18nBrowserAlternativeString,
} );
// Remove hidden class from icon preview div and remove button.
$iconPreview.removeClass( 'hidden' );
$removeButton.removeClass( 'hidden' );
// If the choose button is not in the update state, swap the classes.
if ( $chooseButton.attr( 'data-state' ) !== '1' ) {
$chooseButton.attr( {
class: $chooseButton.attr( 'data-alt-classes' ),
'data-alt-classes': $chooseButton.attr( 'class' ),
'data-state': '1',
} );
}
// Swap the text of the choose button.
$chooseButton.text( $chooseButton.attr( 'data-update-text' ) );
} }
$( '#js-remove-site-icon' ).on( 'click', function() { /**
$( '#site_icon_hidden_field' ).val( 'false' ); * Handles the click event of the remove button.
$( '#site-icon-preview' ).toggleClass( 'hidden' ); *
* @since 6.5.0
*/
$removeButton.on( 'click', function () {
$hiddenDataField.val( 'false' );
$( this ).toggleClass( 'hidden' ); $( this ).toggleClass( 'hidden' );
$iconPreview.toggleClass( 'hidden' );
$browserIconPreview.attr( {
src: '',
alt: '',
} );
$appIconPreview.attr( {
src: '',
alt: '',
} );
var classes = $( '#choose-from-library-link' ).attr( 'class' ); /**
$( '#choose-from-library-link' ).attr( 'class', $( '#choose-from-library-link' ).attr( 'data-alt-classes' ) ); * Resets state to the button, for correct visual style and state.
$( '#choose-from-library-link' ).attr( 'data-alt-classes', classes ); * Updates the text of the button.
* Sets focus state to the button.
// Swap the text of the button. */
$( '#choose-from-library-link' ).text( $( '#choose-from-library-link' ).attr( 'data-choose-text' ) ); $chooseButton
// Set the state of the button so it can be changed on new icon. .attr( {
$( '#choose-from-library-link' ).attr( 'data-state', ''); class: $chooseButton.attr( 'data-alt-classes' ),
}); 'data-alt-classes': $chooseButton.attr( 'class' ),
}(jQuery)); 'data-state': '',
} )
.text( $chooseButton.attr( 'data-choose-text' ) )
.trigger( 'focus' );
} );
} )( jQuery );

View File

@ -1,2 +1,2 @@
/*! This file is auto-generated */ /*! This file is auto-generated */
!function(a){var i;function t(t){var e=t.get("width"),t=t.get("height"),i=512,a=512,r=i/a,o=i,s=a;return r<e/t?i=(a=t)*r:a=(i=e)/r,{aspectRatio:i+":"+a,handles:!0,keys:!0,instance:!0,persistent:!0,imageWidth:e,imageHeight:t,minWidth:i<o?i:o,minHeight:a<s?a:s,x1:r=(e-i)/2,y1:o=(t-a)/2,x2:i+r,y2:a+o}}function r(i){var t;a("#site-icon-preview").find("img").not(".browser-preview").each(function(t,e){a(e).attr("src",i)}),a("#site-icon-preview").removeClass("hidden"),a("#js-remove-site-icon").removeClass("hidden"),"1"!==a("#choose-from-library-link").attr("data-state")&&(t=a("#choose-from-library-link").attr("class"),a("#choose-from-library-link").attr("class",a("#choose-from-library-link").attr("data-alt-classes")),a("#choose-from-library-link").attr("data-alt-classes",t),a("#choose-from-library-link").attr("data-state","1")),a("#choose-from-library-link").text(a("#choose-from-library-link").attr("data-update-text"))}a(function(){a("#choose-from-library-link").on("click",function(){var e=a(this);(i=wp.media({button:{text:e.data("update"),close:!1},states:[new wp.media.controller.Library({title:e.data("choose"),library:wp.media.query({type:"image"}),date:!1,suggestedWidth:e.data("size"),suggestedHeight:e.data("size")}),new wp.media.controller.SiteIconCropper({control:{params:{width:e.data("size"),height:e.data("size")}},imgSelectOptions:t})]})).on("cropped",function(t){a("#site_icon_hidden_field").val(t.id),r(t.url),i.close(),i=null}),i.on("select",function(){var t=i.state().get("selection").first();t.attributes.height===e.data("size")&&e.data("size")===t.attributes.width?(a("#site_icon_hidden_field").val(t.id),r(t.attributes.url),i.close()):i.setState("cropper")}),i.open()})}),a("#js-remove-site-icon").on("click",function(){a("#site_icon_hidden_field").val("false"),a("#site-icon-preview").toggleClass("hidden"),a(this).toggleClass("hidden");var t=a("#choose-from-library-link").attr("class");a("#choose-from-library-link").attr("class",a("#choose-from-library-link").attr("data-alt-classes")),a("#choose-from-library-link").attr("data-alt-classes",t),a("#choose-from-library-link").text(a("#choose-from-library-link").attr("data-choose-text")),a("#choose-from-library-link").attr("data-state","")})}(jQuery); !function(t){var a,i=t("#choose-from-library-button"),s=t("#site-icon-preview"),r=t("#browser-icon-preview"),n=t("#app-icon-preview"),l=t("#site_icon_hidden_field"),o=t("#js-remove-site-icon");function c(t){var e=t.get("width"),t=t.get("height"),a=512,i=512,s=a/i,r=a,n=i;return s<e/t?a=(i=t)*s:i=(a=e)/s,{aspectRatio:a+":"+i,handles:!0,keys:!0,instance:!0,persistent:!0,imageWidth:e,imageHeight:t,minWidth:a<r?a:r,minHeight:i<n?i:n,x1:s=(e-a)/2,y1:r=(t-i)/2,x2:a+s,y2:i+r}}function d(t){var e,a=t.alt?(e=wp.i18n.sprintf(wp.i18n.__("App icon preview: Current image: %s"),t.alt),wp.i18n.sprintf(wp.i18n.__("Browser icon preview: Current image: %s"),t.alt)):(e=wp.i18n.sprintf(wp.i18n.__("App icon preview: The current image has no alternative text. The file name is: %s"),t.filename),wp.i18n.sprintf(wp.i18n.__("Browser icon preview: The current image has no alternative text. The file name is: %s"),t.filename));n.attr({src:t.url,alt:e}),r.attr({src:t.url,alt:a}),s.removeClass("hidden"),o.removeClass("hidden"),"1"!==i.attr("data-state")&&i.attr({class:i.attr("data-alt-classes"),"data-alt-classes":i.attr("class"),"data-state":"1"}),i.text(i.attr("data-update-text"))}i.on("click",function(){var e=t(this);(a=wp.media({button:{text:e.data("update"),close:!1},states:[new wp.media.controller.Library({title:e.data("choose-text"),library:wp.media.query({type:"image"}),date:!1,suggestedWidth:e.data("size"),suggestedHeight:e.data("size")}),new wp.media.controller.SiteIconCropper({control:{params:{width:e.data("size"),height:e.data("size")}},imgSelectOptions:c})]})).on("cropped",function(t){l.val(t.id),d(t),a.close(),a=null}),a.on("select",function(){var t=a.state().get("selection").first();t.attributes.height===e.data("size")&&e.data("size")===t.attributes.width?(d(t.attributes),a.close(),l.val(t.id)):a.setState("cropper")}),a.open()}),o.on("click",function(){l.val("false"),t(this).toggleClass("hidden"),s.toggleClass("hidden"),r.attr({src:"",alt:""}),n.attr({src:"",alt:""}),i.attr({class:i.attr("data-alt-classes"),"data-alt-classes":i.attr("class"),"data-state":""}).text(i.attr("data-choose-text")).trigger("focus")})}(jQuery);

View File

@ -107,34 +107,70 @@ $tagline_description = sprintf(
$classes_for_upload_button = 'upload-button button-add-media button-add-site-icon'; $classes_for_upload_button = 'upload-button button-add-media button-add-site-icon';
$classes_for_update_button = 'button'; $classes_for_update_button = 'button';
$classes_for_wrapper = '';
$classes_for_avatar = 'avatar avatar-150';
if ( has_site_icon() ) { if ( has_site_icon() ) {
$classes_for_avatar .= ' has-site-icon'; $classes_for_wrapper .= ' has-site-icon';
$classes_for_button = $classes_for_update_button; $classes_for_button = $classes_for_update_button;
$classes_for_button_on_change = $classes_for_upload_button; $classes_for_button_on_change = $classes_for_upload_button;
} else { } else {
$classes_for_avatar .= ' hidden'; $classes_for_wrapper .= ' hidden';
$classes_for_button = $classes_for_upload_button; $classes_for_button = $classes_for_upload_button;
$classes_for_button_on_change = $classes_for_update_button; $classes_for_button_on_change = $classes_for_update_button;
} }
// Handle alt text for site icon on page load.
$site_icon_id = (int) get_option( 'site_icon' );
$app_icon_alt_value = '';
$browser_icon_alt_value = '';
if ( $site_icon_id ) {
$img_alt = get_post_meta( $site_icon_id, '_wp_attachment_image_alt', true );
$filename = wp_basename( get_site_icon_url() );
$app_icon_alt_value = sprintf(
/* translators: %s: The selected image filename. */
__( 'App icon preview: The current image has no alternative text. The file name is: %s' ),
$filename
);
$browser_icon_alt_value = sprintf(
/* translators: %s: The selected image filename. */
__( 'Browser icon preview: The current image has no alternative text. The file name is: %s' ),
$filename
);
if ( $img_alt ) {
$app_icon_alt_value = sprintf(
/* translators: %s: The selected image alt text. */
__( 'App icon preview: Current image: %s' ),
$img_alt
);
$browser_icon_alt_value = sprintf(
/* translators: %s: The selected image alt text. */
__( 'Browser icon preview: Current image: %s' ),
$img_alt
);
}
}
?> ?>
<div id="site-icon-preview" class="site-icon-preview wp-clearfix <?php echo esc_attr( $classes_for_avatar ); ?>">
<div id="site-icon-preview" class="site-icon-preview wp-clearfix settings-page-preview <?php echo esc_attr( $classes_for_wrapper ); ?>">
<div class="favicon-preview"> <div class="favicon-preview">
<img src="<?php echo esc_url( admin_url( 'images/' . ( is_rtl() ? 'browser-rtl.png' : 'browser.png' ) ) ); ?>" class="browser-preview" width="182" alt=""> <img src="<?php echo esc_url( admin_url( 'images/' . ( is_rtl() ? 'browser-rtl.png' : 'browser.png' ) ) ); ?>" class="browser-preview" width="182" alt="">
<div class="favicon"> <div class="favicon">
<img src="<?php site_icon_url(); ?>" alt="<?php esc_attr_e( 'Preview as a browser icon' ); ?>"> <img id="browser-icon-preview" src="<?php site_icon_url(); ?>" alt="<?php echo esc_attr( $browser_icon_alt_value ); ?>">
</div> </div>
<span class="browser-title" aria-hidden="true"><?php echo get_bloginfo( 'name' ); ?></span> <span id="site-icon-preview-site-title" class="browser-title" aria-hidden="true"><?php bloginfo( 'name' ); ?></span>
</div> </div>
<img class="app-icon-preview" src="<?php site_icon_url(); ?>" alt="<?php esc_attr_e( 'Preview as an app icon' ); ?>"> <img id="app-icon-preview" class="app-icon-preview" src="<?php site_icon_url(); ?>" alt="<?php echo esc_attr( $app_icon_alt_value ); ?>">
</div> </div>
<input type="hidden" name="site_icon" id="site_icon_hidden_field" value="<?php form_option( 'site_icon' ); ?>" /> <input type="hidden" name="site_icon" id="site_icon_hidden_field" value="<?php form_option( 'site_icon' ); ?>" />
<div class="action-buttons"> <div class="action-buttons">
<button type="button" <button type="button"
id="choose-from-library-link" id="choose-from-library-button"
type="button" type="button"
class="<?php echo esc_attr( $classes_for_button ); ?>" class="<?php echo esc_attr( $classes_for_button ); ?>"
data-alt-classes="<?php echo esc_attr( $classes_for_button_on_change ); ?>" data-alt-classes="<?php echo esc_attr( $classes_for_button_on_change ); ?>"
@ -160,13 +196,10 @@ $tagline_description = sprintf(
</button> </button>
</div> </div>
<p class="description">
<?php _e( 'Site Icons are what you see in browser tabs, bookmark bars, and within the WordPress mobile apps. Upload one here!' ); ?>
</p>
<p class="description"> <p class="description">
<?php <?php
/* translators: %s: Site Icon size in pixels. */ /* translators: %s: Site Icon size in pixels. */
printf( __( 'Site Icons should be square and at least %s pixels.' ), '<strong>512 &times; 512</strong>' ); printf( __( 'Site Icons are what you see in browser tabs, bookmark bars, and within the WordPress mobile apps. They should be square and at least %s pixels.' ), '<code>512 &times; 512</code>' );
?> ?>
</p> </p>

View File

@ -849,7 +849,8 @@ function wp_default_scripts( $scripts ) {
$scripts->add( 'wp-lists', "/wp-includes/js/wp-lists$suffix.js", array( 'wp-ajax-response', 'jquery-color' ), false, 1 ); $scripts->add( 'wp-lists', "/wp-includes/js/wp-lists$suffix.js", array( 'wp-ajax-response', 'jquery-color' ), false, 1 );
$scripts->add( 'site-icon', '/wp-admin/js/site-icon.js', array( 'jquery', 'jcrop' ), false, 1 ); $scripts->add( 'site-icon', '/wp-admin/js/site-icon.js', array( 'jquery' ), false, 1 );
$scripts->set_translations( 'site-icon' );
// WordPress no longer uses or bundles Prototype or script.aculo.us. These are now pulled from an external source. // WordPress no longer uses or bundles Prototype or script.aculo.us. These are now pulled from an external source.
$scripts->add( 'prototype', 'https://ajax.googleapis.com/ajax/libs/prototype/1.7.1.0/prototype.js', array(), '1.7.1' ); $scripts->add( 'prototype', 'https://ajax.googleapis.com/ajax/libs/prototype/1.7.1.0/prototype.js', array(), '1.7.1' );

View File

@ -16,7 +16,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '6.5-beta2-57712'; $wp_version = '6.5-beta2-57713';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.