diff --git a/projects/packages/connection/changelog/update-sso-optimize-admin-notices-callback b/projects/packages/connection/changelog/update-sso-optimize-admin-notices-callback new file mode 100644 index 0000000000000..ae5bb946df85e --- /dev/null +++ b/projects/packages/connection/changelog/update-sso-optimize-admin-notices-callback @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +SSO: optimize 'admin_notices' action callback. diff --git a/projects/packages/connection/src/sso/class-user-admin.php b/projects/packages/connection/src/sso/class-user-admin.php index 42c7e045be64b..d194fac2be9e9 100644 --- a/projects/packages/connection/src/sso/class-user-admin.php +++ b/projects/packages/connection/src/sso/class-user-admin.php @@ -59,7 +59,11 @@ public function __construct() { add_filter( 'manage_users_columns', array( $this, 'jetpack_user_connected_th' ) ); add_filter( 'manage_users_custom_column', array( $this, 'jetpack_show_connection_status' ), 10, 3 ); add_action( 'user_row_actions', array( $this, 'jetpack_user_table_row_actions' ), 10, 2 ); - add_action( 'admin_notices', array( $this, 'handle_invitation_results' ) ); + + if ( isset( $_GET['jetpack-sso-invite-user'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended + add_action( 'admin_notices', array( $this, 'handle_invitation_results' ) ); + } + add_action( 'admin_post_jetpack_invite_user_to_wpcom', array( $this, 'invite_user_to_wpcom' ) ); add_action( 'admin_post_jetpack_revoke_invite_user_to_wpcom', array( $this, 'handle_request_revoke_invite' ) ); add_action( 'admin_post_jetpack_resend_invite_user_to_wpcom', array( $this, 'handle_request_resend_invite' ) );