Jetpack::state( 'message', 'module_deactivated' );
Jetpack::state( 'module', $modules );
wp_safe_redirect( wp_get_referer() );
* Apparently we redirect to the referrer instead of whatever WordPress
* wants to redirect to when activating and deactivating modules.
* @param string $module Module slug.
* @param bool $redirect Should we exit after the module has been activated. Default to true.
public function fix_redirect( $module, $redirect = true ) {
if ( wp_get_referer() ) {
add_filter( 'wp_redirect', 'wp_get_referer' );
* Add debugger admin menu.
public function admin_menu_debugger() {
require_once JETPACK__PLUGIN_DIR . '_inc/lib/debugger.php';
Jetpack_Debugger::disconnect_and_redirect();
$debugger_hook = add_submenu_page(
__( 'Debugging Center', 'jetpack' ),
array( $this, 'wrap_debugger_page' )
add_action( "admin_head-$debugger_hook", array( 'Jetpack_Debugger', 'jetpack_debug_admin_head' ) );
public function wrap_debugger_page() {
if ( ! current_user_can( 'manage_options' ) ) {
Jetpack_Admin_Page::wrap_ui( array( $this, 'debugger_page' ), array( 'is-wide' => true ) );
public function debugger_page() {
require_once JETPACK__PLUGIN_DIR . '_inc/lib/debugger.php';
Jetpack_Debugger::jetpack_debug_display_handler();
* Determines if JITMs should display on a particular screen.
* @param bool $value The default value of the filter.
* @param string $screen_id The ID of the screen being tested for JITM display.
* @return bool True if JITMs should display, false otherwise.
public function should_display_jitms_on_screen( $value, $screen_id ) {
// Disable all JITMs on these pages.
'jetpack_page_akismet-key-config',
'admin_page_jetpack_modules',
* Check if we're on a Jetpack admin page.
* Similar to how WooCommerce checks for its admin pages by comparing
* against known screen ID patterns.
* @return bool True if on a Jetpack admin page, false otherwise.
private function is_jetpack_admin_page() {
$screen = get_current_screen();
// Check for Jetpack admin pages:
// - toplevel_page_jetpack (main Jetpack menu page)
// - toplevel_page_jetpack-network (Jetpack Network Admin menu page)
// - jetpack_page_* (Jetpack submenu pages)
// - admin_page_jetpack* (legacy/special Jetpack pages)
// Or check if parent_base is 'jetpack' or 'jetpack-network' (submenu pages)
$screen->id === 'toplevel_page_jetpack' ||
$screen->id === 'toplevel_page_jetpack-network' ||
str_starts_with( $screen->id, 'jetpack_page_' ) ||
str_starts_with( $screen->id, 'admin_page_jetpack' ) ||
$screen->parent_base === 'jetpack' ||
$screen->parent_base === 'jetpack-network'
* Add a body class to Jetpack admin pages.
* @param string $classes Space-separated list of CSS classes.
* @return string Modified class list.
public function add_jetpack_admin_body_class( $classes ) {
if ( $this->is_jetpack_admin_page() ) {
return trim( $classes ) . ' jetpack-admin-page ';
* Add inline styles to remove footer padding on Jetpack pages.
* This needs to be inline because jetpack-admin.css is not loaded on
* React-powered admin pages (they use load_wrapper_styles instead).
public function add_footer_removal_styles() {
if ( ! $this->is_jetpack_admin_page() ) {
echo '<style>.jetpack-admin-page #wpbody-content { padding-bottom: 0; } .jetpack-admin-page #wpfooter { display: none; }</style>';
* Remove the admin footer text on Jetpack pages.
* @param string $content The default footer text.
* @return string Empty string on Jetpack pages, original content otherwise.
public function maybe_remove_admin_footer_text( $content ) {
return $this->is_jetpack_admin_page() ? '' : $content;
* Remove the admin footer version on Jetpack pages.
* @param string $content The default footer version text.
* @return string Empty string on Jetpack pages, original content otherwise.
public function maybe_remove_admin_footer_version( $content ) {
return $this->is_jetpack_admin_page() ? '' : $content;