Skip to content

Commit 1cbd92c

Browse files
authored
Merge branch 'WordPress:trunk' into trunk
2 parents fc72c25 + e4dc6ee commit 1cbd92c

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

src/js/_enqueues/admin/site-icon.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
$appIconPreview = $( '#app-icon-preview' ),
1515
$hiddenDataField = $( '#site_icon_hidden_field' ),
1616
$removeButton = $( '#js-remove-site-icon' ),
17+
$adminBarSiteName = $( '#wp-admin-bar-site-name' ),
18+
$adminBarSiteNameLink = $adminBarSiteName.children( 'a' ).first(),
1719
frame;
1820

1921
/**
@@ -194,6 +196,19 @@
194196
'url(' + attributes.url + ')'
195197
);
196198

199+
// Replace the site icon in the admin bar.
200+
$adminBarSiteNameLink.children( 'img.site-icon' ).remove();
201+
$( '<img />' )
202+
.attr( {
203+
class: 'site-icon',
204+
src: attributes.url,
205+
alt: '',
206+
width: 20,
207+
height: 20,
208+
} )
209+
.prependTo( $adminBarSiteNameLink );
210+
$adminBarSiteName.addClass( 'has-site-icon' );
211+
197212
// If the choose button is not in the update state, swap the classes.
198213
if ( $chooseButton.attr( 'data-state' ) !== '1' ) {
199214
$chooseButton.attr( {
@@ -225,6 +240,10 @@
225240
alt: '',
226241
} );
227242

243+
// Remove the site icon from the admin bar.
244+
$adminBarSiteNameLink.children( 'img.site-icon' ).remove();
245+
$adminBarSiteName.removeClass( 'has-site-icon' );
246+
228247
/**
229248
* Resets state to the button, for correct visual style and state.
230249
* Updates the text of the button.

src/wp-admin/includes/options.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,15 @@ function options_general_add_js() {
4040
homeURL = ( <?php echo wp_json_encode( get_home_url(), JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ); ?> || '' ).replace( /^(https?:\/\/)?(www\.)?/, '' );
4141

4242
$( '#blogname' ).on( 'input', function() {
43-
var title = $.trim( $( this ).val() ) || homeURL;
43+
var title = $.trim( $( this ).val() ) || homeURL,
44+
$siteIcon = $siteName.children();
4445

4546
// Truncate to 40 characters.
4647
if ( 40 < title.length ) {
4748
title = title.substring( 0, 40 ) + '\u2026';
4849
}
4950

50-
$siteName.text( title );
51+
$siteName.text( title ).prepend( $siteIcon );
5152
$siteIconPreview.text( title );
5253
});
5354

0 commit comments

Comments
 (0)