From 52367b606562f5667836cc93289f41c54a41ea19 Mon Sep 17 00:00:00 2001
From: bindlegirl <1242807+bindlegirl@users.noreply.github.com>
Date: Thu, 13 Feb 2025 15:58:14 +0100
Subject: [PATCH 1/6] Separated SSO and Connection status
---
.../packages/connection/src/class-plugin.php | 5 +
.../src/class-users-connection-admin.php | 162 ++++++++++++++++++
.../src/js/jetpack-users-connection.js | 10 ++
.../connection/src/sso/class-user-admin.php | 151 ++++++++--------
.../connection/src/sso/jetpack-sso-users.js | 2 +-
5 files changed, 251 insertions(+), 79 deletions(-)
create mode 100644 projects/packages/connection/src/class-users-connection-admin.php
create mode 100644 projects/packages/connection/src/js/jetpack-users-connection.js
diff --git a/projects/packages/connection/src/class-plugin.php b/projects/packages/connection/src/class-plugin.php
index 37ac8bc129787..19d66829ccde4 100644
--- a/projects/packages/connection/src/class-plugin.php
+++ b/projects/packages/connection/src/class-plugin.php
@@ -38,6 +38,11 @@ class Plugin {
*/
public function __construct( $slug ) {
$this->slug = $slug;
+
+ // Always initialize Users_Connection_Admin - it will handle its own conditional loading
+ if ( is_admin() ) {
+ new Users_Connection_Admin();
+ }
}
/**
diff --git a/projects/packages/connection/src/class-users-connection-admin.php b/projects/packages/connection/src/class-users-connection-admin.php
new file mode 100644
index 0000000000000..d1448c33e60ad
--- /dev/null
+++ b/projects/packages/connection/src/class-users-connection-admin.php
@@ -0,0 +1,162 @@
+
+ %1$s
+
+ ',
+ esc_html__( 'WordPress.com account', 'jetpack-connection' ),
+ esc_attr__( 'Tooltip', 'jetpack-connection' )
+ );
+ return $columns;
+ }
+
+ /**
+ * Render the connection column content.
+ *
+ * @param string $output Custom column output.
+ * @param string $column_name Column name.
+ * @param int $user_id ID of the currently-listed user.
+ * @return string
+ */
+ public function render_connection_column( $output, $column_name, $user_id ) {
+ if ( self::COLUMN_ID !== $column_name ) {
+ return $output;
+ }
+
+ if ( ( new Manager() )->is_user_connected( $user_id ) ) {
+ return sprintf(
+ '%2$s',
+ esc_attr__( 'This user is connected and can log-in to this site.', 'jetpack-connection' ),
+ esc_html__( 'Connected', 'jetpack-connection' )
+ );
+ }
+
+ return $output;
+ }
+
+ /**
+ * Enqueue scripts and styles.
+ *
+ * @param string $hook The current admin page.
+ */
+ public function enqueue_scripts( $hook ) {
+ if ( 'users.php' !== $hook ) {
+ return;
+ }
+
+ Assets::register_script(
+ 'jetpack-users-connection',
+ 'js/jetpack-users-connection.js',
+ __FILE__,
+ array(
+ 'strategy' => 'defer',
+ 'in_footer' => true,
+ 'enqueue' => true,
+ 'version' => Package_Version::PACKAGE_VERSION,
+ )
+ );
+
+ wp_localize_script(
+ 'jetpack-users-connection',
+ 'jetpackConnectionTooltips',
+ array(
+ 'columnTooltip' => esc_html__( 'Jetpack enables users to connect their WordPress.com accounts to log in securely and enable additional features.', 'jetpack-connection' ),
+ )
+ );
+ }
+
+ /**
+ * Add styles for the connection column.
+ */
+ public function add_connection_column_styles() {
+ ?>
+
+ 'defer',
- 'in_footer' => true,
- 'enqueue' => true,
- 'version' => Package_Version::PACKAGE_VERSION,
- )
- );
-
- $tooltip_string = esc_attr__( 'Jetpack SSO allows a seamless and secure experience on WordPress.com. Join millions of WordPress users who trust us to keep their accounts safe.', 'jetpack-connection' );
-
- wp_add_inline_script(
- 'jetpack-sso-users',
- "var Jetpack_SSOTooltip = { 'tooltipString': '{$tooltip_string}' }",
- 'before'
- );
-
- $columns['user_jetpack'] = sprintf(
- '%2$s',
- $tooltip_string,
- esc_html__( 'SSO Status', 'jetpack-connection' ),
- esc_attr__( 'Tooltip', 'jetpack-connection' )
- );
+ _deprecated_function( __METHOD__, 'package-$$next-version$$' );
return $columns;
}
@@ -1179,59 +1156,58 @@ private static function delete_external_contributor( $user_id ) {
* @param string $val HTML for the column.
* @param string $col User list table column.
* @param int $user_id User ID.
- *
- * @return string
+ * @return string Modified column content.
*/
public function jetpack_show_connection_status( $val, $col, $user_id ) {
- if ( 'user_jetpack' === $col ) {
- if ( ( new Manager() )->is_user_connected( $user_id ) ) {
- $connection_html = sprintf(
- '%2$s',
- esc_attr__( 'This user is connected and can log-in to this site.', 'jetpack-connection' ),
- esc_html__( 'Connected', 'jetpack-connection' )
- );
- return $connection_html;
- } else {
- $has_pending_invite = self::has_pending_wpcom_invite( $user_id );
- if ( $has_pending_invite ) {
- $connection_html = sprintf(
- '%2$s',
- esc_attr__( 'This user didn’t accept the invitation to join this site yet.', 'jetpack-connection' ),
- esc_html__( 'Pending invite', 'jetpack-connection' )
- );
- return $connection_html;
- }
- $nonce = wp_create_nonce( 'jetpack-sso-invite-user' );
- $connection_html = sprintf(
- // Using formmethod and formaction because we can't nest forms and have to submit using the main form.
- '
- %2$s
-
- %3$s
-
- ',
- add_query_arg(
- array(
- 'user_id' => $user_id,
- 'invite_nonce' => $nonce,
- 'action' => 'jetpack_invite_user_to_wpcom',
- ),
- admin_url( 'admin-post.php' )
- ),
- esc_html__( 'Send invite', 'jetpack-connection' ),
- esc_attr__( 'This user doesn’t have an SSO connection to WordPress.com. Invite them to the site to increase security and improve their experience.', 'jetpack-connection' ),
- esc_attr__( 'Tooltip', 'jetpack-connection' )
+ if ( 'user_jetpack' !== $col ) {
+ return $val;
+ }
+
+ // Get base connection status from parent
+ $connection_status = parent::render_connection_column( '', $col, $user_id );
+
+ // If user is not connected, check for pending invite
+ if ( ! $connection_status ) {
+ $has_pending_invite = self::has_pending_wpcom_invite( $user_id );
+ if ( $has_pending_invite ) {
+ return sprintf(
+ '%2$s',
+ esc_attr__( 'This user didn’t accept the invitation to join this site yet.', 'jetpack-connection' ),
+ esc_html__( 'Pending invite', 'jetpack-connection' )
);
- return $connection_html;
}
+
+ // Show invite button for non-connected users
+ $nonce = wp_create_nonce( 'jetpack-sso-invite-user' );
+ return sprintf(
+ '
+ %2$s
+
+ %3$s
+
+ ',
+ add_query_arg(
+ array(
+ 'user_id' => $user_id,
+ 'invite_nonce' => $nonce,
+ 'action' => 'jetpack_invite_user_to_wpcom',
+ ),
+ admin_url( 'admin-post.php' )
+ ),
+ esc_html__( 'Send invite', 'jetpack-connection' ),
+ esc_attr__( 'This user doesn’t have a Jetpack SSO connection to WordPress.com. Invite them to the site to increase security and improve their experience.', 'jetpack-connection' ),
+ esc_attr__( 'Tooltip', 'jetpack-connection' )
+ );
}
- return $val;
+
+ return $connection_status;
}
/**
* Creates error notices and redirects the user to the previous page.
*
* @param array $query_params - query parameters added to redirection URL.
+ * @return string|void The redirect URL or void on failure.
*/
public function create_error_notice_and_redirect( $query_params ) {
$ref = wp_get_referer();
@@ -1258,9 +1234,6 @@ public function jetpack_user_table_styles() {
#the-list tr:has(.sso-pending-invite) {
background: #E9F0F5;
}
- .fixed .column-user_jetpack {
- width: 100px;
- }
.jetpack-sso-invitation {
background: none;
border: none;
@@ -1297,9 +1270,6 @@ public function jetpack_user_table_styles() {
position: relative;
cursor: pointer;
}
- .jetpack-sso-th-tooltip {
- left: -170px;
- }
.jetpack-sso-td-tooltip {
left: -256px;
}
@@ -1323,4 +1293,29 @@ public function jetpack_user_table_styles() {
'defer',
+ 'in_footer' => true,
+ 'enqueue' => true,
+ 'version' => Package_Version::PACKAGE_VERSION,
+ )
+ );
+ }
}
diff --git a/projects/packages/connection/src/sso/jetpack-sso-users.js b/projects/packages/connection/src/sso/jetpack-sso-users.js
index ea36dae308f39..778eab060b2bc 100644
--- a/projects/packages/connection/src/sso/jetpack-sso-users.js
+++ b/projects/packages/connection/src/sso/jetpack-sso-users.js
@@ -5,7 +5,7 @@ document.addEventListener( 'DOMContentLoaded', function () {
tooltip.innerHTML += ' [?]';
const tooltipTextbox = document.createElement( 'span' );
- tooltipTextbox.classList.add( 'jetpack-sso-invitation-tooltip', 'jetpack-sso-th-tooltip' );
+ tooltipTextbox.classList.add( 'jetpack-sso-invitation-tooltip' );
const tooltipString = window.Jetpack_SSOTooltip.tooltipString;
tooltipTextbox.innerHTML += tooltipString;
From aef9e3784952d240e7ff07071640f772e25fede0 Mon Sep 17 00:00:00 2001
From: bindlegirl <1242807+bindlegirl@users.noreply.github.com>
Date: Thu, 13 Feb 2025 17:52:06 +0100
Subject: [PATCH 2/6] Add changelogs
---
.../changelog/add-display-connection-status-users-page | 4 ++++
.../connection/src/class-users-connection-admin.php | 7 ++++++-
projects/packages/connection/webpack.config.js | 1 +
.../changelog/add-display-connection-status-users-page | 4 ++++
.../changelog/add-display-connection-status-users-page | 4 ++++
.../changelog/add-display-connection-status-users-page | 4 ++++
.../changelog/add-display-connection-status-users-page | 4 ++++
.../changelog/add-display-connection-status-users-page | 4 ++++
.../changelog/add-display-connection-status-users-page | 4 ++++
.../changelog/add-display-connection-status-users-page | 4 ++++
.../changelog/add-display-connection-status-users-page | 4 ++++
.../changelog/add-display-connection-status-users-page | 4 ++++
.../changelog/add-display-connection-status-users-page | 4 ++++
.../changelog/add-display-connection-status-users-page | 4 ++++
.../changelog/add-display-connection-status-users-page | 4 ++++
15 files changed, 59 insertions(+), 1 deletion(-)
create mode 100644 projects/packages/connection/changelog/add-display-connection-status-users-page
create mode 100644 projects/plugins/automattic-for-agencies-client/changelog/add-display-connection-status-users-page
create mode 100644 projects/plugins/backup/changelog/add-display-connection-status-users-page
create mode 100644 projects/plugins/boost/changelog/add-display-connection-status-users-page
create mode 100644 projects/plugins/inspect/changelog/add-display-connection-status-users-page
create mode 100644 projects/plugins/jetpack/changelog/add-display-connection-status-users-page
create mode 100644 projects/plugins/mu-wpcom-plugin/changelog/add-display-connection-status-users-page
create mode 100644 projects/plugins/protect/changelog/add-display-connection-status-users-page
create mode 100644 projects/plugins/search/changelog/add-display-connection-status-users-page
create mode 100644 projects/plugins/social/changelog/add-display-connection-status-users-page
create mode 100644 projects/plugins/starter-plugin/changelog/add-display-connection-status-users-page
create mode 100644 projects/plugins/videopress/changelog/add-display-connection-status-users-page
create mode 100644 projects/plugins/wpcomsh/changelog/add-display-connection-status-users-page
diff --git a/projects/packages/connection/changelog/add-display-connection-status-users-page b/projects/packages/connection/changelog/add-display-connection-status-users-page
new file mode 100644
index 0000000000000..90cab5cd014d8
--- /dev/null
+++ b/projects/packages/connection/changelog/add-display-connection-status-users-page
@@ -0,0 +1,4 @@
+Significance: minor
+Type: changed
+
+Connection: Display connection status on Users page independent of the SSO module.
diff --git a/projects/packages/connection/src/class-users-connection-admin.php b/projects/packages/connection/src/class-users-connection-admin.php
index d1448c33e60ad..79953b61ef65b 100644
--- a/projects/packages/connection/src/class-users-connection-admin.php
+++ b/projects/packages/connection/src/class-users-connection-admin.php
@@ -89,13 +89,15 @@ public function enqueue_scripts( $hook ) {
Assets::register_script(
'jetpack-users-connection',
- 'js/jetpack-users-connection.js',
+ '../dist/jetpack-users-connection.js',
__FILE__,
array(
'strategy' => 'defer',
'in_footer' => true,
'enqueue' => true,
'version' => Package_Version::PACKAGE_VERSION,
+ 'deps' => array( 'wp-i18n' ),
+
)
);
@@ -142,6 +144,9 @@ public function add_connection_column_styles() {
box-shadow: 5px 10px 10px rgba(0, 0, 0, 0.1);
left: -170px;
}
+ .column-user_jetpack {
+ width: 140px;
+ }
/* Show tooltip on hover and focus */
.jetpack-connection-tooltip-icon:hover .jetpack-connection-tooltip,
.jetpack-connection-tooltip-icon:focus-within .jetpack-connection-tooltip {
diff --git a/projects/packages/connection/webpack.config.js b/projects/packages/connection/webpack.config.js
index 27f00aad5d8f1..3ab8f6576e45a 100644
--- a/projects/packages/connection/webpack.config.js
+++ b/projects/packages/connection/webpack.config.js
@@ -77,6 +77,7 @@ module.exports = [
},
},
'identity-crisis': './src/identity-crisis/_inc/admin.jsx',
+ 'jetpack-users-connection': './src/js/jetpack-users-connection.js',
...ssoEntries,
},
plugins: [
diff --git a/projects/plugins/automattic-for-agencies-client/changelog/add-display-connection-status-users-page b/projects/plugins/automattic-for-agencies-client/changelog/add-display-connection-status-users-page
new file mode 100644
index 0000000000000..4c2ef3d14ff18
--- /dev/null
+++ b/projects/plugins/automattic-for-agencies-client/changelog/add-display-connection-status-users-page
@@ -0,0 +1,4 @@
+Significance: minor
+Type: changed
+
+Connection: Display connection status on Users page independent of the SSO module.
diff --git a/projects/plugins/backup/changelog/add-display-connection-status-users-page b/projects/plugins/backup/changelog/add-display-connection-status-users-page
new file mode 100644
index 0000000000000..4c2ef3d14ff18
--- /dev/null
+++ b/projects/plugins/backup/changelog/add-display-connection-status-users-page
@@ -0,0 +1,4 @@
+Significance: minor
+Type: changed
+
+Connection: Display connection status on Users page independent of the SSO module.
diff --git a/projects/plugins/boost/changelog/add-display-connection-status-users-page b/projects/plugins/boost/changelog/add-display-connection-status-users-page
new file mode 100644
index 0000000000000..4c2ef3d14ff18
--- /dev/null
+++ b/projects/plugins/boost/changelog/add-display-connection-status-users-page
@@ -0,0 +1,4 @@
+Significance: minor
+Type: changed
+
+Connection: Display connection status on Users page independent of the SSO module.
diff --git a/projects/plugins/inspect/changelog/add-display-connection-status-users-page b/projects/plugins/inspect/changelog/add-display-connection-status-users-page
new file mode 100644
index 0000000000000..4c2ef3d14ff18
--- /dev/null
+++ b/projects/plugins/inspect/changelog/add-display-connection-status-users-page
@@ -0,0 +1,4 @@
+Significance: minor
+Type: changed
+
+Connection: Display connection status on Users page independent of the SSO module.
diff --git a/projects/plugins/jetpack/changelog/add-display-connection-status-users-page b/projects/plugins/jetpack/changelog/add-display-connection-status-users-page
new file mode 100644
index 0000000000000..dd6b5fb994e6a
--- /dev/null
+++ b/projects/plugins/jetpack/changelog/add-display-connection-status-users-page
@@ -0,0 +1,4 @@
+Significance: minor
+Type: enhancement
+
+Connection: Display connection status on Users page independent of the SSO module.
diff --git a/projects/plugins/mu-wpcom-plugin/changelog/add-display-connection-status-users-page b/projects/plugins/mu-wpcom-plugin/changelog/add-display-connection-status-users-page
new file mode 100644
index 0000000000000..4c2ef3d14ff18
--- /dev/null
+++ b/projects/plugins/mu-wpcom-plugin/changelog/add-display-connection-status-users-page
@@ -0,0 +1,4 @@
+Significance: minor
+Type: changed
+
+Connection: Display connection status on Users page independent of the SSO module.
diff --git a/projects/plugins/protect/changelog/add-display-connection-status-users-page b/projects/plugins/protect/changelog/add-display-connection-status-users-page
new file mode 100644
index 0000000000000..4c2ef3d14ff18
--- /dev/null
+++ b/projects/plugins/protect/changelog/add-display-connection-status-users-page
@@ -0,0 +1,4 @@
+Significance: minor
+Type: changed
+
+Connection: Display connection status on Users page independent of the SSO module.
diff --git a/projects/plugins/search/changelog/add-display-connection-status-users-page b/projects/plugins/search/changelog/add-display-connection-status-users-page
new file mode 100644
index 0000000000000..4c2ef3d14ff18
--- /dev/null
+++ b/projects/plugins/search/changelog/add-display-connection-status-users-page
@@ -0,0 +1,4 @@
+Significance: minor
+Type: changed
+
+Connection: Display connection status on Users page independent of the SSO module.
diff --git a/projects/plugins/social/changelog/add-display-connection-status-users-page b/projects/plugins/social/changelog/add-display-connection-status-users-page
new file mode 100644
index 0000000000000..4c2ef3d14ff18
--- /dev/null
+++ b/projects/plugins/social/changelog/add-display-connection-status-users-page
@@ -0,0 +1,4 @@
+Significance: minor
+Type: changed
+
+Connection: Display connection status on Users page independent of the SSO module.
diff --git a/projects/plugins/starter-plugin/changelog/add-display-connection-status-users-page b/projects/plugins/starter-plugin/changelog/add-display-connection-status-users-page
new file mode 100644
index 0000000000000..4c2ef3d14ff18
--- /dev/null
+++ b/projects/plugins/starter-plugin/changelog/add-display-connection-status-users-page
@@ -0,0 +1,4 @@
+Significance: minor
+Type: changed
+
+Connection: Display connection status on Users page independent of the SSO module.
diff --git a/projects/plugins/videopress/changelog/add-display-connection-status-users-page b/projects/plugins/videopress/changelog/add-display-connection-status-users-page
new file mode 100644
index 0000000000000..4c2ef3d14ff18
--- /dev/null
+++ b/projects/plugins/videopress/changelog/add-display-connection-status-users-page
@@ -0,0 +1,4 @@
+Significance: minor
+Type: changed
+
+Connection: Display connection status on Users page independent of the SSO module.
diff --git a/projects/plugins/wpcomsh/changelog/add-display-connection-status-users-page b/projects/plugins/wpcomsh/changelog/add-display-connection-status-users-page
new file mode 100644
index 0000000000000..4c2ef3d14ff18
--- /dev/null
+++ b/projects/plugins/wpcomsh/changelog/add-display-connection-status-users-page
@@ -0,0 +1,4 @@
+Significance: minor
+Type: changed
+
+Connection: Display connection status on Users page independent of the SSO module.
From f156eb8862f67902fa8eecc2612fad5bd0175f42 Mon Sep 17 00:00:00 2001
From: bindlegirl <1242807+bindlegirl@users.noreply.github.com>
Date: Thu, 13 Feb 2025 18:18:45 +0100
Subject: [PATCH 3/6] Fix phan warnings
---
projects/packages/connection/src/class-plugin.php | 9 ++++++++-
.../packages/connection/src/sso/class-user-admin.php | 5 +++--
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/projects/packages/connection/src/class-plugin.php b/projects/packages/connection/src/class-plugin.php
index 19d66829ccde4..0054cfe9d37c5 100644
--- a/projects/packages/connection/src/class-plugin.php
+++ b/projects/packages/connection/src/class-plugin.php
@@ -31,6 +31,13 @@ class Plugin {
*/
private $slug;
+ /**
+ * Users Connection Admin instance.
+ *
+ * @var Users_Connection_Admin
+ */
+ private $users_connection_admin;
+
/**
* Initialize the plugin manager.
*
@@ -41,7 +48,7 @@ public function __construct( $slug ) {
// Always initialize Users_Connection_Admin - it will handle its own conditional loading
if ( is_admin() ) {
- new Users_Connection_Admin();
+ $this->users_connection_admin = new Users_Connection_Admin();
}
}
diff --git a/projects/packages/connection/src/sso/class-user-admin.php b/projects/packages/connection/src/sso/class-user-admin.php
index b929cf77316aa..bc5d7e6655ab9 100644
--- a/projects/packages/connection/src/sso/class-user-admin.php
+++ b/projects/packages/connection/src/sso/class-user-admin.php
@@ -1207,7 +1207,7 @@ public function jetpack_show_connection_status( $val, $col, $user_id ) {
* Creates error notices and redirects the user to the previous page.
*
* @param array $query_params - query parameters added to redirection URL.
- * @return string|void The redirect URL or void on failure.
+ * @return void
*/
public function create_error_notice_and_redirect( $query_params ) {
$ref = wp_get_referer();
@@ -1219,7 +1219,8 @@ public function create_error_notice_and_redirect( $query_params ) {
$query_params,
$ref
);
- return wp_safe_redirect( $url );
+ wp_safe_redirect( $url );
+ exit;
}
/**
From 23b4ec0b17019043bdccde5cb10e9c49ca72b9f5 Mon Sep 17 00:00:00 2001
From: bindlegirl <1242807+bindlegirl@users.noreply.github.com>
Date: Thu, 13 Feb 2025 18:32:04 +0100
Subject: [PATCH 4/6] More phan happiness
---
projects/packages/connection/src/sso/class-user-admin.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/projects/packages/connection/src/sso/class-user-admin.php b/projects/packages/connection/src/sso/class-user-admin.php
index bc5d7e6655ab9..1ffa968de8d35 100644
--- a/projects/packages/connection/src/sso/class-user-admin.php
+++ b/projects/packages/connection/src/sso/class-user-admin.php
@@ -1207,7 +1207,7 @@ public function jetpack_show_connection_status( $val, $col, $user_id ) {
* Creates error notices and redirects the user to the previous page.
*
* @param array $query_params - query parameters added to redirection URL.
- * @return void
+ * @return never
*/
public function create_error_notice_and_redirect( $query_params ) {
$ref = wp_get_referer();
From 8a91471328bcc58a6ea825e45f6dd5c65b74d018 Mon Sep 17 00:00:00 2001
From: bindlegirl <1242807+bindlegirl@users.noreply.github.com>
Date: Fri, 14 Feb 2025 10:10:18 +0100
Subject: [PATCH 5/6] Fixing stuff for tests
---
projects/packages/connection/src/class-plugin.php | 6 ++----
.../connection/src/class-users-connection-admin.php | 11 +++++++++--
.../packages/connection/src/sso/class-user-admin.php | 2 +-
3 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/projects/packages/connection/src/class-plugin.php b/projects/packages/connection/src/class-plugin.php
index 0054cfe9d37c5..80cd3df7f9e85 100644
--- a/projects/packages/connection/src/class-plugin.php
+++ b/projects/packages/connection/src/class-plugin.php
@@ -46,10 +46,8 @@ class Plugin {
public function __construct( $slug ) {
$this->slug = $slug;
- // Always initialize Users_Connection_Admin - it will handle its own conditional loading
- if ( is_admin() ) {
- $this->users_connection_admin = new Users_Connection_Admin();
- }
+ // Initialize Users_Connection_Admin
+ $this->users_connection_admin = new Users_Connection_Admin();
}
/**
diff --git a/projects/packages/connection/src/class-users-connection-admin.php b/projects/packages/connection/src/class-users-connection-admin.php
index 79953b61ef65b..b57619bdf8b66 100644
--- a/projects/packages/connection/src/class-users-connection-admin.php
+++ b/projects/packages/connection/src/class-users-connection-admin.php
@@ -21,10 +21,17 @@ class Users_Connection_Admin {
const COLUMN_ID = 'user_jetpack';
/**
- * Initialize the Users Connection Admin functionality.
+ * Constructor.
*/
public function __construct() {
- // Only initialize if we're in admin and current user can manage options
+ // Only set up hooks if we're in the admin area and user has proper permissions
+ add_action( 'init', array( $this, 'init' ) );
+ }
+
+ /**
+ * Initialize the admin functionality if conditions are met.
+ */
+ public function init() {
if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
return;
}
diff --git a/projects/packages/connection/src/sso/class-user-admin.php b/projects/packages/connection/src/sso/class-user-admin.php
index 1ffa968de8d35..bf3a623e5cb83 100644
--- a/projects/packages/connection/src/sso/class-user-admin.php
+++ b/projects/packages/connection/src/sso/class-user-admin.php
@@ -1207,7 +1207,7 @@ public function jetpack_show_connection_status( $val, $col, $user_id ) {
* Creates error notices and redirects the user to the previous page.
*
* @param array $query_params - query parameters added to redirection URL.
- * @return never
+ * @phan-suppress PhanPluginNeverReturnMethod
*/
public function create_error_notice_and_redirect( $query_params ) {
$ref = wp_get_referer();
From 865869fb3188a24d5971d97e098c1bb8794cfd83 Mon Sep 17 00:00:00 2001
From: Jeremy Herve
Date: Mon, 17 Feb 2025 09:21:35 +0100
Subject: [PATCH 6/6] Wording changes based on review
Co-authored-by: bindlegirl <1242807+bindlegirl@users.noreply.github.com>
---
.../packages/connection/src/class-users-connection-admin.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/projects/packages/connection/src/class-users-connection-admin.php b/projects/packages/connection/src/class-users-connection-admin.php
index b57619bdf8b66..2c0551c5bc0fd 100644
--- a/projects/packages/connection/src/class-users-connection-admin.php
+++ b/projects/packages/connection/src/class-users-connection-admin.php
@@ -76,7 +76,7 @@ public function render_connection_column( $output, $column_name, $user_id ) {
if ( ( new Manager() )->is_user_connected( $user_id ) ) {
return sprintf(
'%2$s',
- esc_attr__( 'This user is connected and can log-in to this site.', 'jetpack-connection' ),
+ esc_attr__( 'This user has connected their WordPress.com account.', 'jetpack-connection' ),
esc_html__( 'Connected', 'jetpack-connection' )
);
}
@@ -112,7 +112,7 @@ public function enqueue_scripts( $hook ) {
'jetpack-users-connection',
'jetpackConnectionTooltips',
array(
- 'columnTooltip' => esc_html__( 'Jetpack enables users to connect their WordPress.com accounts to log in securely and enable additional features.', 'jetpack-connection' ),
+ 'columnTooltip' => esc_html__( 'Connecting a WordPress.com account unlocks Jetpackās full suite of features including secure logins.', 'jetpack-connection' ),
)
);
}