From 56afcf2d681255e613f19b2fe5d66903ddd8db50 Mon Sep 17 00:00:00 2001 From: Dominik Schilling Date: Sun, 5 Jul 2020 13:00:07 +0000 Subject: [PATCH] Posts: Provide a HiDPI version for the avatar used in post locked dialogs. Props wpdesk, audrasjb, ocean90. Fixes #39633. Built from https://develop.svn.wordpress.org/trunk@48318 git-svn-id: http://core.svn.wordpress.org/trunk@48087 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/misc.php | 14 ++++++-------- wp-admin/js/inline-edit-post.js | 9 ++++++++- wp-admin/js/inline-edit-post.min.js | 2 +- wp-admin/js/post.js | 9 ++++++++- wp-admin/js/post.min.js | 2 +- wp-includes/version.php | 2 +- 6 files changed, 25 insertions(+), 13 deletions(-) diff --git a/wp-admin/includes/misc.php b/wp-admin/includes/misc.php index bee524cb50..77d6649138 100644 --- a/wp-admin/includes/misc.php +++ b/wp-admin/includes/misc.php @@ -1053,9 +1053,9 @@ function wp_check_locked_posts( $response, $data, $screen_id ) { 'text' => sprintf( __( '%s is currently editing' ), $user->display_name ), ); - $avatar = get_avatar( $user->ID, 18 ); - if ( $avatar && preg_match( "|src='([^']+)'|", $avatar, $matches ) ) { - $send['avatar_src'] = $matches[1]; + if ( get_option( 'show_avatars' ) ) { + $send['avatar_src'] = get_avatar_url( $user->ID, array( 'size' => 18 ) ); + $send['avatar_src_2x'] = get_avatar_url( $user->ID, array( 'size' => 36 ) ); } $checked[ $key ] = $send; @@ -1103,11 +1103,9 @@ function wp_refresh_post_lock( $response, $data, $screen_id ) { 'text' => sprintf( __( '%s has taken over and is currently editing.' ), $user->display_name ), ); - $avatar = get_avatar( $user->ID, 64 ); - if ( $avatar ) { - if ( preg_match( "|src='([^']+)'|", $avatar, $matches ) ) { - $error['avatar_src'] = $matches[1]; - } + if ( get_option( 'show_avatars' ) ) { + $error['avatar_src'] = get_avatar_url( $user->ID, array( 'size' => 64 ) ); + $error['avatar_src_2x'] = get_avatar_url( $user->ID, array( 'size' => 128 ) ); } $send['lock_error'] = $error; diff --git a/wp-admin/js/inline-edit-post.js b/wp-admin/js/inline-edit-post.js index 642bc4487b..f997e17f14 100644 --- a/wp-admin/js/inline-edit-post.js +++ b/wp-admin/js/inline-edit-post.js @@ -529,7 +529,14 @@ $( document ).on( 'heartbeat-tick.wp-check-locked-posts', function( e, data ) { row.find('.check-column checkbox').prop('checked', false); if ( lock_data.avatar_src ) { - avatar = $( '' ).attr( 'src', lock_data.avatar_src.replace( /&/g, '&' ) ); + avatar = $( '', { + 'class': 'avatar avatar-18 photo', + width: 18, + height: 18, + alt: '', + src: lock_data.avatar_src, + srcset: lock_data.avatar_src_2x ? lock_data.avatar_src_2x + ' 2x' : undefined + } ); row.find('.column-title .locked-avatar').empty().append( avatar ); } row.addClass('wp-locked'); diff --git a/wp-admin/js/inline-edit-post.min.js b/wp-admin/js/inline-edit-post.min.js index e0efd06b3e..ed3db02007 100644 --- a/wp-admin/js/inline-edit-post.min.js +++ b/wp-admin/js/inline-edit-post.min.js @@ -1,2 +1,2 @@ /*! This file is auto-generated */ -window.wp=window.wp||{},function(h,a){window.inlineEditPost={init:function(){var i=this,t=h("#inline-edit"),e=h("#bulk-edit");i.type=h("table.widefat").hasClass("pages")?"page":"post",i.what="#post-",t.keyup(function(t){if(27===t.which)return inlineEditPost.revert()}),e.keyup(function(t){if(27===t.which)return inlineEditPost.revert()}),h(".cancel",t).click(function(){return inlineEditPost.revert()}),h(".save",t).click(function(){return inlineEditPost.save(this)}),h("td",t).keydown(function(t){if(13===t.which&&!h(t.target).hasClass("cancel"))return inlineEditPost.save(this)}),h(".cancel",e).click(function(){return inlineEditPost.revert()}),h('#inline-edit .inline-edit-private input[value="private"]').click(function(){var t=h("input.inline-edit-password-input");h(this).prop("checked")?t.val("").prop("disabled",!0):t.prop("disabled",!1)}),h("#the-list").on("click",".editinline",function(){h(this).attr("aria-expanded","true"),inlineEditPost.edit(this)}),h("#bulk-edit").find("fieldset:first").after(h("#inline-edit fieldset.inline-edit-categories").clone()).siblings("fieldset:last").prepend(h("#inline-edit label.inline-edit-tags").clone()),h('select[name="_status"] option[value="future"]',e).remove(),h("#doaction, #doaction2").click(function(t){var e;i.whichBulkButtonId=h(this).attr("id"),e=i.whichBulkButtonId.substr(2),"edit"===h('select[name="'+e+'"]').val()?(t.preventDefault(),i.setBulk()):0