Skip to content

Commit

Permalink
General: remove backwards-compatible code for versions < 6.4 (#37049)
Browse files Browse the repository at this point in the history
Epic: #33615
  • Loading branch information
jeherve authored Apr 24, 2024
1 parent 13bf003 commit d7b76e9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 28 deletions.
4 changes: 4 additions & 0 deletions projects/packages/connection/changelog/update-rm-63-code
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

General: remove code that was added to remain compatible with versions of WordPress lower than 6.4.
15 changes: 1 addition & 14 deletions projects/packages/connection/src/sso/class-user-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,16 +151,13 @@ public function revoke_user_invite( $user_id ) {

/**
* Renders invitations errors/success messages in users.php.
*
* @phan-suppress PhanUndeclaredFunction,UnusedSuppression -- Existence of wp_admin_notice (added in WP 6.4) is checked inline.
* @todo Remove suppression and function_exists check when we drop support for WP 6.3.
*/
public function handle_invitation_results() {
$valid_nonce = isset( $_GET['_wpnonce'] )
? wp_verify_nonce( sanitize_key( $_GET['_wpnonce'] ), 'jetpack-sso-invite-user' )
: false;

if ( ! $valid_nonce || ! isset( $_GET['jetpack-sso-invite-user'] ) || ! function_exists( 'wp_admin_notice' ) ) {
if ( ! $valid_nonce || ! isset( $_GET['jetpack-sso-invite-user'] ) ) {
return;
}
if ( $_GET['jetpack-sso-invite-user'] === 'success' ) {
Expand Down Expand Up @@ -610,10 +607,6 @@ public function jetpack_user_table_row_actions( $actions, $user_object ) {
* Render the invitation email message.
*/
public function render_invitation_email_message() {
// @todo Remove function_exists check (and phan suppression below) when we drop support for WP 6.3.
if ( ! function_exists( 'wp_admin_notice' ) ) {
return;
}
$message = wp_kses(
__(
'We highly recommend inviting users to join WordPress.com and log in securely using <a class="jetpack-sso-admin-create-user-invite-message-link-sso" rel="noopener noreferrer" target="_blank" href="https://jetpack.com/support/sso/">Secure Sign On</a> to ensure maximum security and efficiency.',
Expand All @@ -628,7 +621,6 @@ public function render_invitation_email_message() {
),
)
);
// @phan-suppress-next-line PhanUndeclaredFunction -- Existence of wp_admin_notice (added in WP 6.4) is checked above. @phan-suppress-current-line UnusedPluginSuppression
wp_admin_notice(
$message,
array(
Expand All @@ -644,10 +636,6 @@ public function render_invitation_email_message() {
* Render a note that wp.com invites will be automatically revoked.
*/
public function render_invitations_notices_for_deleted_users() {
// @todo Remove function_exists check (and phan suppression below) when we drop support for WP 6.3.
if ( ! function_exists( 'wp_admin_notice' ) ) {
return;
}
check_admin_referer( 'bulk-users' );

// When one user is deleted, the param is `user`, when multiple users are deleted, the param is `users`.
Expand Down Expand Up @@ -686,7 +674,6 @@ function ( $user_id ) {
),
array( 'strong' => true )
);
// @phan-suppress-next-line PhanUndeclaredFunction -- Existence of wp_admin_notice (added in WP 6.4) is checked above. @phan-suppress-current-line UnusedPluginSuppression
wp_admin_notice(
$message,
array(
Expand Down
4 changes: 4 additions & 0 deletions projects/plugins/jetpack/changelog/update-rm-63-code
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: compat

General: remove code that was added to remain compatible with versions of WordPress lower than 6.4.
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,13 @@ public function revoke_user_invite( $user_id ) {

/**
* Renders invitations errors/success messages in users.php.
*
* @phan-suppress PhanUndeclaredFunction,UnusedSuppression -- Existence of wp_admin_notice (added in WP 6.4) is checked inline.
* @todo Remove suppression and function_exists check when we drop support for WP 6.3.
*/
public function handle_invitation_results() {
$valid_nonce = isset( $_GET['_wpnonce'] )
? wp_verify_nonce( sanitize_key( $_GET['_wpnonce'] ), 'jetpack-sso-invite-user' )
: false;

if ( ! $valid_nonce || ! isset( $_GET['jetpack-sso-invite-user'] ) || ! function_exists( 'wp_admin_notice' ) ) {
if ( ! $valid_nonce || ! isset( $_GET['jetpack-sso-invite-user'] ) ) {
return;
}
if ( $_GET['jetpack-sso-invite-user'] === 'success' ) {
Expand Down Expand Up @@ -597,10 +594,6 @@ public function jetpack_user_table_row_actions( $actions, $user_object ) {
* Render the invitation email message.
*/
public function render_invitation_email_message() {
// @todo Remove function_exists check (and phan suppression below) when we drop support for WP 6.3.
if ( ! function_exists( 'wp_admin_notice' ) ) {
return;
}
$message = wp_kses(
__(
'We highly recommend inviting users to join WordPress.com and log in securely using <a class="jetpack-sso-admin-create-user-invite-message-link-sso" rel="noopener noreferrer" target="_blank" href="https://jetpack.com/support/sso/">Secure Sign On</a> to ensure maximum security and efficiency.',
Expand All @@ -615,7 +608,6 @@ public function render_invitation_email_message() {
),
)
);
// @phan-suppress-next-line PhanUndeclaredFunction -- Existence of wp_admin_notice (added in WP 6.4) is checked above. @phan-suppress-current-line UnusedPluginSuppression
wp_admin_notice(
$message,
array(
Expand All @@ -631,10 +623,6 @@ public function render_invitation_email_message() {
* Render a note that wp.com invites will be automatically revoked.
*/
public function render_invitations_notices_for_deleted_users() {
// @todo Remove function_exists check (and phan suppression below) when we drop support for WP 6.3.
if ( ! function_exists( 'wp_admin_notice' ) ) {
return;
}
check_admin_referer( 'bulk-users' );

// When one user is deleted, the param is `user`, when multiple users are deleted, the param is `users`.
Expand Down Expand Up @@ -673,7 +661,6 @@ function ( $user_id ) {
),
array( 'strong' => true )
);
// @phan-suppress-next-line PhanUndeclaredFunction -- Existence of wp_admin_notice (added in WP 6.4) is checked above. @phan-suppress-current-line UnusedPluginSuppression
wp_admin_notice(
$message,
array(
Expand Down

0 comments on commit d7b76e9

Please sign in to comment.