Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jetpack: Add shim for 13.9+ to prevent Jetpack_SSO fatal and admin notices for 13.5+ #5937

Merged
merged 5 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions admin-notice/admin-notice.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,20 @@ function () use ( $admin_notice_controller ) {
do_action( 'vip_admin_notice_init', $admin_notice_controller );
}
);

add_action(
'vip_admin_notice_init',
function ( $admin_notice_controller ) {
$message = 'Heads up! Your site is using a deprecated plugin <a href="https://github.com/Automattic/jetpack-force-2fa/">jetpack-force-2fa</a>. This functionality is already included in Jetpack as of version 13.5. Please remove the plugin to avoid potential conflicts with future Jetpack updates.';
$admin_notice_controller->add(
new Admin_Notice(
$message,
[
new Expression_Condition( class_exists( 'Jetpack_Force_2FA' ) && class_exists( 'Jetpack' ) && defined( 'JETPACK__VERSION' ) && version_compare( JETPACK__VERSION, '13.5', '>=' ) ),
],
'deprecated-standalone-jetpack-2fa-plugin',
'error'
)
);
}
);
7 changes: 7 additions & 0 deletions vip-jetpack/jetpack-sso-dummy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

if ( ! class_exists( '\Automattic\Jetpack\Connection\SSO' ) ) {
return;
}

class Jetpack_SSO extends \Automattic\Jetpack\Connection\SSO {}
12 changes: 12 additions & 0 deletions vip-jetpack/vip-jetpack.php
Original file line number Diff line number Diff line change
Expand Up @@ -434,3 +434,15 @@ function vip_prevent_jetpack_post_by_email_database_noise() {
unset( $_POST['invite_user_wpcom'] );
}
});

/**
* Jetpack 13.9 removes the legacy Jetpack_SSO class. Unfortunately, this class is still used by
* the deprecated standalone jetpack-force-2fa plugin (which is still in use by some). This is a dummy
* class to prevent fatal errors when the standalone plugin is enabled.
*/
add_action( 'plugins_loaded', function () {
if ( class_exists( 'Jetpack_Force_2FA' ) && ! class_exists( 'Jetpack_SSO' ) && class_exists( 'Jetpack' ) &&
defined( 'JETPACK__VERSION' ) && version_compare( JETPACK__VERSION, '13.9', '>=' ) ) {
require_once __DIR__ . '/jetpack-sso-dummy.php';
}
} );
Loading