<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[57713] trunk/src: Site icon: Polish up Site Icon on the general settings screen.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/57713">57713</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/57713","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>jorbin</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2024-02-26 20:16:09 +0000 (Mon, 26 Feb 2024)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>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 <a href="https://core.trac.wordpress.org/ticket/54370">#54370</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcjs_enqueuesadminsiteiconjs">trunk/src/js/_enqueues/admin/site-icon.js</a></li>
<li><a href="#trunksrcwpadmincssformscss">trunk/src/wp-admin/css/forms.css</a></li>
<li><a href="#trunksrcwpadmincsssiteiconcss">trunk/src/wp-admin/css/site-icon.css</a></li>
<li><a href="#trunksrcwpadminincludesoptionsphp">trunk/src/wp-admin/includes/options.php</a></li>
<li><a href="#trunksrcwpadminoptionsgeneralphp">trunk/src/wp-admin/options-general.php</a></li>
<li><a href="#trunksrcwpincludesscriptloaderphp">trunk/src/wp-includes/script-loader.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcjs_enqueuesadminsiteiconjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/js/_enqueues/admin/site-icon.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/js/_enqueues/admin/site-icon.js 2024-02-26 16:25:28 UTC (rev 57712)
+++ trunk/src/js/_enqueues/admin/site-icon.js 2024-02-26 20:16:09 UTC (rev 57713)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,15 +1,40 @@
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-(function($) {
- var frame;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * Handle the site icon setting in options-general.php.
+ *
+ * @since 6.5.0
+ * @output wp-admin/js/site-icon.js
+ */
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function calculateImageSelectOptions ( attachment ) {
- var realWidth = attachment.get( 'width' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/* global jQuery, wp */
+
+( 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' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> realHeight = attachment.get( 'height' ),
</span><span class="cx" style="display: block; padding: 0 10px"> xInit = 512,
</span><span class="cx" style="display: block; padding: 0 10px"> yInit = 512,
</span><span class="cx" style="display: block; padding: 0 10px"> ratio = xInit / yInit,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- xImg = xInit,
- yImg = yInit,
- x1, y1, imgSelectOptions;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ xImg = xInit,
+ yImg = yInit,
+ x1,
+ y1,
+ imgSelectOptions;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( realWidth / realHeight > ratio ) {
</span><span class="cx" style="display: block; padding: 0 10px"> yInit = realHeight;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -35,104 +60,177 @@
</span><span class="cx" style="display: block; padding: 0 10px"> x1: x1,
</span><span class="cx" style="display: block; padding: 0 10px"> y1: y1,
</span><span class="cx" style="display: block; padding: 0 10px"> x2: xInit + x1,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- y2: yInit + y1
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ y2: yInit + y1,
</ins><span class="cx" style="display: block; padding: 0 10px"> };
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> return imgSelectOptions;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $( function() {
- // Build the choose from library frame.
- $( '#choose-from-library-link' ).on( 'click', function() {
- var $el = $(this);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Initializes the media frame for selecting or cropping an image.
+ *
+ * @since 6.5.0
+ */
+ $chooseButton.on( 'click', function () {
+ var $el = $( this );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Create the media frame.
- frame = wp.media({
- button: {
- // Set the text of the button.
- text: $el.data('update'),
- // Don't close, we might need to crop.
- close: false
- },
- states: [
- new wp.media.controller.Library({
- title: $el.data( 'choose' ),
- library: wp.media.query({ type: 'image' }),
- date: false,
- suggestedWidth: $el.data( 'size' ),
- suggestedHeight: $el.data( 'size' )
- }),
- new wp.media.controller.SiteIconCropper({
- control: {
- params: {
- width: $el.data( 'size' ),
- height: $el.data( 'size' )
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Create the media frame.
+ frame = wp.media( {
+ button: {
+ // Set the text of the button.
+ text: $el.data( 'update' ),
+
+ // Don't close, we might need to crop.
+ close: false,
+ },
+ states: [
+ new wp.media.controller.Library( {
+ title: $el.data( 'choose-text' ),
+ library: wp.media.query( { type: 'image' } ),
+ date: false,
+ suggestedWidth: $el.data( 'size' ),
+ suggestedHeight: $el.data( 'size' ),
+ } ),
+ new wp.media.controller.SiteIconCropper( {
+ control: {
+ params: {
+ width: $el.data( 'size' ),
+ height: $el.data( 'size' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> },
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- imgSelectOptions: calculateImageSelectOptions
- })
- ]
- });
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ },
+ imgSelectOptions: calculateImageSelectOptions,
+ } ),
+ ],
+ } );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- frame.on( 'cropped', function( attachment) {
- $( '#site_icon_hidden_field' ).val(attachment.id);
- switchToUpdate(attachment.url);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ frame.on( 'cropped', function ( attachment ) {
+ $hiddenDataField.val( attachment.id );
+ 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 );
</ins><span class="cx" style="display: block; padding: 0 10px"> frame.close();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Start over with a frame that is so fresh and so clean clean.
- frame = null;
- });
</del><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // When an image is selected, run a callback.
- frame.on( 'select', function() {
- // Grab the selected attachment.
- var attachment = frame.state().get('selection').first();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Set the value of the hidden input to the attachment id.
+ $hiddenDataField.val( attachment.id );
+ } else {
+ frame.setState( 'cropper' );
+ }
+ } );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( attachment.attributes.height === $el.data('size') && $el.data('size') === attachment.attributes.width ) {
- // 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' );
- }
- });
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ frame.open();
+ } );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- frame.open();
- });
- });
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * 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;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function switchToUpdate( url ){
- // Set site-icon-img src to the url and remove the hidden class.
- $( '#site-icon-preview').find('img').not('.browser-preview').each( function(i, img ){
- $(img).attr('src', url );
- });
- $( '#site-icon-preview' ).removeClass( 'hidden' );
- // Remove hidden class from remove.
- $( '#js-remove-site-icon' ).removeClass( 'hidden' );
- // If the button is not in the update state, swap the classes.
- if( $( '#choose-from-library-link' ).attr( 'data-state' ) !== '1' ){
- var classes = $( '#choose-from-library-link' ).attr( 'class' );
- $( '#choose-from-library-link' ).attr( 'class', $( '#choose-from-library-link' ).attr('data-alt-classes') );
- $( '#choose-from-library-link' ).attr( 'data-alt-classes', classes );
- $( '#choose-from-library-link' ).attr( 'data-state', '1' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( attributes.alt ) {
+ i18nAppAlternativeString = wp.i18n.sprintf(
+ /* translators: %s: The selected image alt text. */
+ wp.i18n.__( 'App icon preview: Current image: %s' ),
+ attributes.alt
+ );
+ i18nBrowserAlternativeString = wp.i18n.sprintf(
+ /* translators: %s: The selected image alt text. */
+ wp.i18n.__( 'Browser icon preview: Current image: %s' ),
+ attributes.alt
+ );
+ } else {
+ i18nAppAlternativeString = wp.i18n.sprintf(
+ /* 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
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // swap the text of the button
- $( '#choose-from-library-link' ).text( $( '#choose-from-library-link' ).attr( 'data-update-text' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Set site-icon-img src and alternative text to app icon preview.
+ $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' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $( '#js-remove-site-icon' ).on( 'click', function() {
- $( '#site_icon_hidden_field' ).val( 'false' );
- $( '#site-icon-preview' ).toggleClass( 'hidden' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Handles the click event of the remove button.
+ *
+ * @since 6.5.0
+ */
+ $removeButton.on( 'click', function () {
+ $hiddenDataField.val( 'false' );
</ins><span class="cx" style="display: block; padding: 0 10px"> $( this ).toggleClass( 'hidden' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $iconPreview.toggleClass( 'hidden' );
+ $browserIconPreview.attr( {
+ src: '',
+ alt: '',
+ } );
+ $appIconPreview.attr( {
+ src: '',
+ alt: '',
+ } );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- var classes = $( '#choose-from-library-link' ).attr( 'class' );
- $( '#choose-from-library-link' ).attr( 'class', $( '#choose-from-library-link' ).attr( 'data-alt-classes' ) );
- $( '#choose-from-library-link' ).attr( 'data-alt-classes', classes );
-
- // Swap the text of the button.
- $( '#choose-from-library-link' ).text( $( '#choose-from-library-link' ).attr( 'data-choose-text' ) );
- // Set the state of the button so it can be changed on new icon.
- $( '#choose-from-library-link' ).attr( 'data-state', '');
- });
-}(jQuery));
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Resets state to the button, for correct visual style and state.
+ * Updates the text of the button.
+ * Sets focus state to the button.
+ */
+ $chooseButton
+ .attr( {
+ class: $chooseButton.attr( 'data-alt-classes' ),
+ 'data-alt-classes': $chooseButton.attr( 'class' ),
+ 'data-state': '',
+ } )
+ .text( $chooseButton.attr( 'data-choose-text' ) )
+ .trigger( 'focus' );
+ } );
+} )( jQuery );
</ins></span></pre></div>
<a id="trunksrcwpadmincssformscss"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/css/forms.css</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/css/forms.css 2024-02-26 16:25:28 UTC (rev 57712)
+++ trunk/src/wp-admin/css/forms.css 2024-02-26 20:16:09 UTC (rev 57713)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -789,7 +789,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> outline: 2px solid transparent;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-.button-add-site-icon{
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+.button-add-site-icon {
</ins><span class="cx" style="display: block; padding: 0 10px"> width: 100%;
</span><span class="cx" style="display: block; padding: 0 10px"> cursor: pointer;
</span><span class="cx" style="display: block; padding: 0 10px"> text-align: center;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -801,23 +801,23 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> .button-add-site-icon:focus,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-.button-add-site-icon:hover{
- background: white;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+.button-add-site-icon:hover {
+ background: #fff;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-.site-icon-section .favicon-preview{
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+.site-icon-section .favicon-preview {
</ins><span class="cx" style="display: block; padding: 0 10px"> float: left;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-.site-icon-section .app-icon-preview{
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+.site-icon-section .app-icon-preview {
</ins><span class="cx" style="display: block; padding: 0 10px"> float: left;
</span><span class="cx" style="display: block; padding: 0 10px"> margin: 0 20px;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-.site-icon-section .site-icon-preview img{
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+.site-icon-section .site-icon-preview img {
</ins><span class="cx" style="display: block; padding: 0 10px"> max-width: 100%;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-.button-ad-site-icon:focus{
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+.button-add-site-icon:focus {
</ins><span class="cx" style="display: block; padding: 0 10px"> background-color: #fff;
</span><span class="cx" style="display: block; padding: 0 10px"> border-color: #3582c4;
</span><span class="cx" style="display: block; padding: 0 10px"> border-style: solid;
</span></span></pre></div>
<a id="trunksrcwpadmincsssiteiconcss"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/css/site-icon.css</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/css/site-icon.css 2024-02-26 16:25:28 UTC (rev 57712)
+++ trunk/src/wp-admin/css/site-icon.css 2024-02-26 20:16:09 UTC (rev 57713)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -7,7 +7,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> overflow: hidden;
</span><span class="cx" style="display: block; padding: 0 10px"> position: relative;
</span><span class="cx" style="display: block; padding: 0 10px"> max-width: 180px;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- float: left;
</del><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> .site-icon-preview .favicon,
</span></span></pre></div>
<a id="trunksrcwpadminincludesoptionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/options.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/options.php 2024-02-26 16:25:28 UTC (rev 57712)
+++ trunk/src/wp-admin/includes/options.php 2024-02-26 20:16:09 UTC (rev 57713)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -36,6 +36,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <script type="text/javascript">
</span><span class="cx" style="display: block; padding: 0 10px"> jQuery( function($) {
</span><span class="cx" style="display: block; padding: 0 10px"> var $siteName = $( '#wp-admin-bar-site-name' ).children( 'a' ).first(),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $siteIconPreview = $('#site-icon-preview-site-title'),
</ins><span class="cx" style="display: block; padding: 0 10px"> homeURL = ( <?php echo wp_json_encode( get_home_url() ); ?> || '' ).replace( /^(https?:\/\/)?(www\.)?/, '' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $( '#blogname' ).on( 'input', function() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -47,6 +48,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $siteName.text( title );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $siteIconPreview.text( title );
</ins><span class="cx" style="display: block; padding: 0 10px"> });
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $( 'input[name="date_format"]' ).on( 'click', function() {
</span></span></pre></div>
<a id="trunksrcwpadminoptionsgeneralphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/options-general.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/options-general.php 2024-02-26 16:25:28 UTC (rev 57712)
+++ trunk/src/wp-admin/options-general.php 2024-02-26 20:16:09 UTC (rev 57713)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -107,34 +107,70 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $classes_for_upload_button = 'upload-button button-add-media button-add-site-icon';
</span><span class="cx" style="display: block; padding: 0 10px"> $classes_for_update_button = 'button';
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $classes_for_wrapper = '';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $classes_for_avatar = 'avatar avatar-150';
</del><span class="cx" style="display: block; padding: 0 10px"> if ( has_site_icon() ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $classes_for_avatar .= ' has-site-icon';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $classes_for_wrapper .= ' has-site-icon';
</ins><span class="cx" style="display: block; padding: 0 10px"> $classes_for_button = $classes_for_update_button;
</span><span class="cx" style="display: block; padding: 0 10px"> $classes_for_button_on_change = $classes_for_upload_button;
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $classes_for_avatar .= ' hidden';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $classes_for_wrapper .= ' hidden';
</ins><span class="cx" style="display: block; padding: 0 10px"> $classes_for_button = $classes_for_upload_button;
</span><span class="cx" style="display: block; padding: 0 10px"> $classes_for_button_on_change = $classes_for_update_button;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // 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 = '';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 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
+ );
+ }
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <div id="site-icon-preview" class="site-icon-preview wp-clearfix <?php echo esc_attr( $classes_for_avatar ); ?>">
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+
+ <div id="site-icon-preview" class="site-icon-preview wp-clearfix settings-page-preview <?php echo esc_attr( $classes_for_wrapper ); ?>">
</ins><span class="cx" style="display: block; padding: 0 10px"> <div class="favicon-preview">
</span><span class="cx" style="display: block; padding: 0 10px"> <img src="<?php echo esc_url( admin_url( 'images/' . ( is_rtl() ? 'browser-rtl.png' : 'browser.png' ) ) ); ?>" class="browser-preview" width="182" alt="">
</span><span class="cx" style="display: block; padding: 0 10px"> <div class="favicon">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <img src="<?php site_icon_url(); ?>" alt="<?php esc_attr_e( 'Preview as a browser icon' ); ?>">
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <img id="browser-icon-preview" src="<?php site_icon_url(); ?>" alt="<?php echo esc_attr( $browser_icon_alt_value ); ?>">
</ins><span class="cx" style="display: block; padding: 0 10px"> </div>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <span class="browser-title" aria-hidden="true"><?php echo get_bloginfo( 'name' ); ?></span>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <span id="site-icon-preview-site-title" class="browser-title" aria-hidden="true"><?php bloginfo( 'name' ); ?></span>
</ins><span class="cx" style="display: block; padding: 0 10px"> </div>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <img class="app-icon-preview" src="<?php site_icon_url(); ?>" alt="<?php esc_attr_e( 'Preview as an app icon' ); ?>">
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <img id="app-icon-preview" class="app-icon-preview" src="<?php site_icon_url(); ?>" alt="<?php echo esc_attr( $app_icon_alt_value ); ?>">
</ins><span class="cx" style="display: block; padding: 0 10px"> </div>
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> <input type="hidden" name="site_icon" id="site_icon_hidden_field" value="<?php form_option( 'site_icon' ); ?>" />
</span><span class="cx" style="display: block; padding: 0 10px"> <div class="action-buttons">
</span><span class="cx" style="display: block; padding: 0 10px"> <button type="button"
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- id="choose-from-library-link"
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ id="choose-from-library-button"
</ins><span class="cx" style="display: block; padding: 0 10px"> type="button"
</span><span class="cx" style="display: block; padding: 0 10px"> class="<?php echo esc_attr( $classes_for_button ); ?>"
</span><span class="cx" style="display: block; padding: 0 10px"> data-alt-classes="<?php echo esc_attr( $classes_for_button_on_change ); ?>"
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -161,12 +197,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> </div>
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> <p class="description">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <?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">
</del><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px"> /* translators: %s: Site Icon size in pixels. */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- printf( __( 'Site Icons should be square and at least %s pixels.' ), '<strong>512 × 512</strong>' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 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 × 512</code>' );
</ins><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><span class="cx" style="display: block; padding: 0 10px"> </p>
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="trunksrcwpincludesscriptloaderphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/script-loader.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/script-loader.php 2024-02-26 16:25:28 UTC (rev 57712)
+++ trunk/src/wp-includes/script-loader.php 2024-02-26 20:16:09 UTC (rev 57713)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -849,7 +849,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $scripts->add( 'wp-lists', "/wp-includes/js/wp-lists$suffix.js", array( 'wp-ajax-response', 'jquery-color' ), false, 1 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $scripts->add( 'site-icon', '/wp-admin/js/site-icon.js', array( 'jquery', 'jcrop' ), false, 1 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $scripts->add( 'site-icon', '/wp-admin/js/site-icon.js', array( 'jquery' ), false, 1 );
+ $scripts->set_translations( 'site-icon' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // WordPress no longer uses or bundles Prototype or script.aculo.us. These are now pulled from an external source.
</span><span class="cx" style="display: block; padding: 0 10px"> $scripts->add( 'prototype', 'https://ajax.googleapis.com/ajax/libs/prototype/1.7.1.0/prototype.js', array(), '1.7.1' );
</span></span></pre>
</div>
</div>
</body>
</html>