Skip to content

Commit

Permalink
Editor: Respect show_avatars option in block editor and Customizer.
Browse files Browse the repository at this point in the history
This adds checks for the `show_avatars` option before setting the avatar for post lock modals in the block editor and the Customizer.

Follow-up to [41839], [53070].

Props ffffelix.
Fixes #62081.

git-svn-id: https://develop.svn.wordpress.org/trunk@59078 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
SergeyBiryukov committed Sep 22, 2024
1 parent f49909e commit e2d9ffc
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
6 changes: 5 additions & 1 deletion src/wp-admin/css/customize-controls.css
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ body {
max-width: 366px;
min-height: 64px;
width: auto;
padding: 25px 25px 25px 109px;
padding: 25px;
position: relative;
background: #fff;
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
Expand All @@ -41,6 +41,10 @@ body {
top: calc( 50% - 100px );
}

#customize-controls #customize-notifications-area .notice.notification-overlay.notification-changeset-locked .customize-changeset-locked-message.has-avatar {
padding-left: 109px;
}

#customize-controls #customize-notifications-area .notice.notification-overlay.notification-changeset-locked .currently-editing {
margin-top: 0;
}
Expand Down
7 changes: 5 additions & 2 deletions src/wp-admin/edit-form-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,12 @@ static function ( $classes ) {
if ( $locked ) {
$user = get_userdata( $user_id );
$user_details = array(
'avatar' => get_avatar_url( $user_id, array( 'size' => 128 ) ),
'name' => $user->display_name,
'name' => $user->display_name,
);

if ( get_option( 'show_avatars' ) ) {
$user_details['avatar'] = get_avatar_url( $user_id, array( 'size' => 128 ) );
}
}

$lock_details = array(
Expand Down
19 changes: 13 additions & 6 deletions src/wp-includes/class-wp-customize-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -3334,11 +3334,16 @@ protected function get_lock_user_data( $user_id ) {
return null;
}

return array(
'id' => $lock_user->ID,
'name' => $lock_user->display_name,
'avatar' => get_avatar_url( $lock_user->ID, array( 'size' => 128 ) ),
$user_details = array(
'id' => $lock_user->ID,
'name' => $lock_user->display_name,
);

if ( get_option( 'show_avatars' ) ) {
$user_details['avatar'] = get_avatar_url( $lock_user->ID, array( 'size' => 128 ) );
}

return $user_details;
}

/**
Expand Down Expand Up @@ -4307,8 +4312,10 @@ public function render_control_templates() {

<script type="text/html" id="tmpl-customize-changeset-locked-notification">
<li class="notice notice-{{ data.type || 'info' }} {{ data.containerClasses || '' }}" data-code="{{ data.code }}" data-type="{{ data.type }}">
<div class="notification-message customize-changeset-locked-message">
<img class="customize-changeset-locked-avatar" src="{{ data.lockUser.avatar }}" alt="{{ data.lockUser.name }}" />
<div class="notification-message customize-changeset-locked-message {{ data.lockUser.avatar ? 'has-avatar' : '' }}">
<# if ( data.lockUser.avatar ) { #>
<img class="customize-changeset-locked-avatar" src="{{ data.lockUser.avatar }}" alt="{{ data.lockUser.name }}" />
<# } #>
<p class="currently-editing">
<# if ( data.message ) { #>
{{{ data.message }}}
Expand Down

0 comments on commit e2d9ffc

Please sign in to comment.