From 0538f64d01deff9d685cf7bf5960c8010a623a44 Mon Sep 17 00:00:00 2001
From: Evan Mullins
Date: Tue, 17 Sep 2024 14:39:39 -0700
Subject: [PATCH 1/6] apply 62019 patch from dhruvang21
---
src/js/_enqueues/admin/user-profile.js | 25 ++++++++++++++++++++++++-
src/wp-admin/css/common.css | 5 +++++
src/wp-admin/user-edit.php | 2 ++
src/wp-includes/script-loader.php | 2 +-
4 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/src/js/_enqueues/admin/user-profile.js b/src/js/_enqueues/admin/user-profile.js
index 54215c7b420b8..99e5a0c0e4fa9 100644
--- a/src/js/_enqueues/admin/user-profile.js
+++ b/src/js/_enqueues/admin/user-profile.js
@@ -7,6 +7,7 @@
var updateLock = false,
isSubmitting = false,
__ = wp.i18n.__,
+ clipboard = new ClipboardJS( '.application-password-display .copy-button' ),
$pass1Row,
$pass1,
$pass2,
@@ -18,7 +19,8 @@
currentPass,
$form,
originalFormContent,
- $passwordWrapper;
+ $passwordWrapper,
+ successTimeout;
function generatePassword() {
if ( typeof zxcvbn !== 'function' ) {
@@ -346,6 +348,27 @@
}
}
+ // Debug information copy section.
+ clipboard.on( 'success', function( e ) {
+ var triggerElement = $( e.trigger ),
+ successElement = $( '.success', triggerElement.closest( '.application-password-display' ) );
+
+ // Clear the selection and move focus back to the trigger.
+ e.clearSelection();
+
+ // Show success visual feedback.
+ clearTimeout( successTimeout );
+ successElement.removeClass( 'hidden' );
+
+ // Hide success visual feedback after 3 seconds since last success.
+ successTimeout = setTimeout( function() {
+ successElement.addClass( 'hidden' );
+ }, 3000 );
+
+ // Handle success audible feedback.
+ wp.a11y.speak( __( 'Site information has been copied to your clipboard.' ) );
+ } );
+
$( function() {
var $colorpicker, $stylesheet, user_id, current_user_id,
select = $( '#display_name' ),
diff --git a/src/wp-admin/css/common.css b/src/wp-admin/css/common.css
index 287f2ee7b4958..8d5486e797606 100644
--- a/src/wp-admin/css/common.css
+++ b/src/wp-admin/css/common.css
@@ -916,6 +916,11 @@ a#remove-post-thumbnail:hover,
border: none;
}
+.application-password-display .success {
+ color: #007017;
+ margin-left: 0.5rem;
+}
+
/*------------------------------------------------------------------------------
3.0 - Actions
------------------------------------------------------------------------------*/
diff --git a/src/wp-admin/user-edit.php b/src/wp-admin/user-edit.php
index 860a0a6e07340..92f32ad19803f 100644
--- a/src/wp-admin/user-edit.php
+++ b/src/wp-admin/user-edit.php
@@ -984,6 +984,8 @@
?>
+
+