diff --git a/projects/plugins/jetpack/_inc/client/components/jetpack-notices/index.jsx b/projects/plugins/jetpack/_inc/client/components/jetpack-notices/index.jsx
index 85686df8191d0..8cfbb00b895ee 100644
--- a/projects/plugins/jetpack/_inc/client/components/jetpack-notices/index.jsx
+++ b/projects/plugins/jetpack/_inc/client/components/jetpack-notices/index.jsx
@@ -193,12 +193,19 @@ class JetpackNotices extends React.Component {
'jetpack_deprecate_dismissed[jetpack-ga-admin-removal-notice]'
) &&
'1' === cookieParsed[ 'jetpack_deprecate_dismissed[jetpack-ga-admin-removal-notice]' ],
+ isMasterbarNoticeDismissed:
+ cookieParsed &&
+ cookieParsed.hasOwnProperty(
+ 'jetpack_deprecate_dismissed[jetpack-masterbar-admin-removal-notice]'
+ ) &&
+ '1' ===
+ cookieParsed[ 'jetpack_deprecate_dismissed[jetpack-masterbar-admin-removal-notice]' ],
};
-
- this.dismissGoogleAnalyticsNotice = this.dismissGoogleAnalyticsNotice.bind( this );
}
- dismissGoogleAnalyticsNotice() {
+ dismissGoogleAnalyticsNotice = () => {
+ this.setState( { isGoogleAnalyticsNoticeDismissed: true } );
+
document.cookie = cookie.serialize(
'jetpack_deprecate_dismissed[jetpack-ga-admin-removal-notice]',
'1',
@@ -208,8 +215,21 @@ class JetpackNotices extends React.Component {
SameSite: 'None',
}
);
- this.setState( { isGoogleAnalyticsNoticeDismissed: true } );
- }
+ };
+
+ dismissMasterbarNotice = () => {
+ this.setState( { isMasterbarNoticeDismissed: true } );
+
+ document.cookie = cookie.serialize(
+ 'jetpack_deprecate_dismissed[jetpack-masterbar-admin-removal-notice]',
+ '1',
+ {
+ path: '/',
+ maxAge: 365 * 24 * 60 * 60,
+ SameSite: 'None',
+ }
+ );
+ };
render() {
const siteDataErrors = this.props.siteDataErrors.filter( error =>
@@ -220,6 +240,9 @@ class JetpackNotices extends React.Component {
const showGoogleAnalyticsNotice =
this.props.showGoogleAnalyticsNotice && ! this.state.isGoogleAnalyticsNoticeDismissed;
+ const showMasterbarNotice =
+ this.props.showMasterbarNotice && ! this.state.isMasterbarNoticeDismissed;
+
return (
@@ -292,6 +315,23 @@ class JetpackNotices extends React.Component {
) }
+ { showMasterbarNotice && (
+
+
+ { __( "Jetpack's WordPress.com Toolbar feature has been removed.", 'jetpack' ) }
+
+
+ { __(
+ 'To find out more about what this means for you, please refer to this document',
+ 'jetpack'
+ ) }
+
+
+ ) }
);
}
@@ -330,6 +370,7 @@ export default connect(
state,
'jetpack-legacy-google-analytics/jetpack-legacy-google-analytics.php'
),
+ showMasterbarNotice: window.Initial_State?.isMasterbarActive && ! isWoASite( state ),
};
},
dispatch => {
diff --git a/projects/plugins/jetpack/_inc/client/writing/index.jsx b/projects/plugins/jetpack/_inc/client/writing/index.jsx
index 0ba27d6ca320d..9906411e838d2 100644
--- a/projects/plugins/jetpack/_inc/client/writing/index.jsx
+++ b/projects/plugins/jetpack/_inc/client/writing/index.jsx
@@ -15,7 +15,6 @@ import { isModuleFound } from 'state/search';
import { getSettings } from 'state/settings';
import Composing from './composing';
import CustomContentTypes from './custom-content-types';
-import { Masterbar } from './masterbar';
import PostByEmail from './post-by-email';
import ThemeEnhancements from './theme-enhancements';
import Widgets from './widgets';
@@ -92,9 +91,6 @@ export class Writing extends React.Component {
userCanManageModules={ this.props.userCanManageModules }
/>
) }
- { this.props.isModuleFound( 'masterbar' ) && ! this.props.masterbarIsAlwaysActive && (
-
- ) }
{ ! showComposing && ! showPostByEmail && (
{ __(
diff --git a/projects/plugins/jetpack/_inc/client/writing/masterbar.jsx b/projects/plugins/jetpack/_inc/client/writing/masterbar.jsx
deleted file mode 100644
index 5fd9cd9c154d1..0000000000000
--- a/projects/plugins/jetpack/_inc/client/writing/masterbar.jsx
+++ /dev/null
@@ -1,65 +0,0 @@
-import { getRedirectUrl } from '@automattic/jetpack-components';
-import { __, _x } from '@wordpress/i18n';
-import ConnectUserBar from 'components/connect-user-bar';
-import { withModuleSettingsFormHelpers } from 'components/module-settings/with-module-settings-form-helpers';
-import { ModuleToggle } from 'components/module-toggle';
-import SettingsCard from 'components/settings-card';
-import SettingsGroup from 'components/settings-group';
-import React, { Component } from 'react';
-
-export const Masterbar = withModuleSettingsFormHelpers(
- class extends Component {
- render() {
- const isActive = this.props.getOptionValue( 'masterbar' ),
- unavailableInOfflineMode = this.props.isUnavailableInOfflineMode( 'masterbar' );
-
- return (
-
-
-
- { __(
- 'The WordPress.com toolbar replaces the default WordPress admin toolbar. It offers one-click access to notifications, your WordPress.com profile and your other Jetpack and WordPress.com websites. You can also catch up on the sites you follow in the Reader.',
- 'jetpack'
- ) }
-
-
-
- { __( 'Enable the WordPress.com toolbar', 'jetpack' ) }
-
-
-
-
- { ! this.props.isUnavailableInOfflineMode( 'masterbar' ) && ! this.props.isLinked && (
-
- ) }
-
- );
- }
- }
-);
diff --git a/projects/plugins/jetpack/_inc/lib/admin-pages/class-jetpack-redux-state-helper.php b/projects/plugins/jetpack/_inc/lib/admin-pages/class-jetpack-redux-state-helper.php
index f7a4dba2ca5fb..31b87c1dfddfe 100644
--- a/projects/plugins/jetpack/_inc/lib/admin-pages/class-jetpack-redux-state-helper.php
+++ b/projects/plugins/jetpack/_inc/lib/admin-pages/class-jetpack-redux-state-helper.php
@@ -249,6 +249,7 @@ public static function get_initial_state() {
'newsletterDateExample' => gmdate( get_option( 'date_format' ), time() ),
'subscriptionSiteEditSupported' => $current_theme->is_block_theme(),
'isGoogleAnalyticsActive' => ( new Modules() )->is_active( 'google-analytics', false ),
+ 'isMasterbarActive' => ( new Modules() )->is_active( 'masterbar', false ),
);
}
diff --git a/projects/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-admin-menu.php b/projects/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-admin-menu.php
index 75885fee98be1..d157eb2f3e222 100644
--- a/projects/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-admin-menu.php
+++ b/projects/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-admin-menu.php
@@ -6,8 +6,6 @@
* @since 9.1.0
*/
-use Automattic\Jetpack\Status\Host;
-
/**
* Class WPCOM_REST_API_V2_Endpoint_Admin_Menu
*/
@@ -85,9 +83,6 @@ public function get_item_permissions_check( $request ) { // phpcs:ignore Generic
* @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.
*/
public function get_item( $request ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter, VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
- if ( ! ( new Host() )->is_wpcom_platform() && get_option( 'wpcom_admin_interface' ) !== 'wp-admin' ) {
- require_once JETPACK__PLUGIN_DIR . 'jetpack_vendor/automattic/jetpack-masterbar/src/admin-menu/load.php';
- }
// All globals need to be declared for menu items to properly register.
global $admin_page_hooks, $menu, $menu_order, $submenu, $_wp_menu_nopriv, $_wp_submenu_nopriv; // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
@@ -119,7 +114,9 @@ private function hide_customizer_menu_on_block_theme() {
remove_action( 'customize_register', array( 'Jetpack_Fonts_Typekit', 'maybe_override_for_advanced_mode' ), 20 );
- remove_action( 'customize_register', 'Automattic\Jetpack\Masterbar\register_css_nudge_control' );
+ if ( class_exists( 'Automattic\Jetpack\Masterbar' ) ) {
+ remove_action( 'customize_register', 'Automattic\Jetpack\Masterbar\register_css_nudge_control' );
+ }
remove_action( 'customize_register', array( 'Jetpack_Custom_CSS_Enhancements', 'customize_register' ) );
}
diff --git a/projects/plugins/jetpack/changelog/remove-masterbar-feature-jetpack b/projects/plugins/jetpack/changelog/remove-masterbar-feature-jetpack
new file mode 100644
index 0000000000000..62e4cd1a3448a
--- /dev/null
+++ b/projects/plugins/jetpack/changelog/remove-masterbar-feature-jetpack
@@ -0,0 +1,4 @@
+Significance: minor
+Type: compat
+
+WordPress.com Toolbar: Removed feature from Jetpack self-hosted sites.
diff --git a/projects/plugins/jetpack/modules/masterbar.php b/projects/plugins/jetpack/modules/masterbar.php
index d5493b8714c7f..62e0a5e3c1578 100644
--- a/projects/plugins/jetpack/modules/masterbar.php
+++ b/projects/plugins/jetpack/modules/masterbar.php
@@ -14,6 +14,11 @@
* @package automattic/jetpack
*/
-use Automattic\Jetpack\Masterbar\Main as Jetpack_Masterbar;
-
-Jetpack_Masterbar::init();
+/**
+ * Remove Masterbar from the old Module list.
+ * Available at wp-admin/admin.php?page=jetpack_modules
+ * We only need this function and module file until the Masterbar is fully removed from Jetpack including notices).
+ *
+ * @param array $items Array of Jetpack modules.
+ * @return array
+ */
diff --git a/projects/plugins/jetpack/src/class-deprecate.php b/projects/plugins/jetpack/src/class-deprecate.php
index 4a106f6bcb206..8837c02e30a4c 100644
--- a/projects/plugins/jetpack/src/class-deprecate.php
+++ b/projects/plugins/jetpack/src/class-deprecate.php
@@ -31,6 +31,7 @@ private function __construct() {
add_action( 'admin_notices', array( $this, 'render_admin_notices' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) );
add_filter( 'my_jetpack_red_bubble_notification_slugs', array( $this, 'add_my_jetpack_red_bubbles' ) );
+ add_filter( 'jetpack_modules_list_table_items', array( $this, 'remove_masterbar_module_list' ) );
}
/**
@@ -70,7 +71,7 @@ public function enqueue_admin_scripts() {
}
/**
- * Render Google Analytics deprecation notice.
+ * Render deprecation notices for relevant features.
*
* @return void
*/
@@ -84,6 +85,15 @@ public function render_admin_notices() {
. ' ' . esc_html__( 'To keep tracking visits and more information on this change, please refer to this document', 'jetpack' ) . '.'
);
}
+ if ( $this->show_masterbar_notice() ) {
+ $support_url = Redirect::get_url( 'jetpack-support-masterbar' );
+
+ $this->render_notice(
+ 'jetpack-masterbar-admin-removal-notice',
+ esc_html__( "Jetpack's WordPress.com Toolbar feature has been removed.", 'jetpack' )
+ . ' ' . esc_html__( 'To find out more about what this means for you, please refer to this document', 'jetpack' ) . '.'
+ );
+ }
}
/**
@@ -106,6 +116,18 @@ public function add_my_jetpack_red_bubbles( $slugs ) {
),
);
}
+ if ( $this->show_masterbar_notice() ) {
+ $slugs['jetpack-masterbar-deprecate-feature'] = array(
+ 'data' => array(
+ 'text' => __( "Jetpack's WordPress.com Toolbar feature has been removed.", 'jetpack' ),
+ 'link' => array(
+ 'label' => esc_html__( 'See documentation', 'jetpack' ),
+ 'url' => Redirect::get_url( 'jetpack-support-masterbar' ),
+ ),
+ 'id' => 'jetpack-masterbar-admin-removal-notice',
+ ),
+ );
+ }
return $slugs;
}
@@ -151,7 +173,7 @@ private function render_notice( $id, $text, $params = array() ) {
* @return bool
*/
private function has_notices() {
- return $this->show_ga_notice();
+ return ( $this->show_ga_notice() || $this->show_masterbar_notice() );
}
/**
@@ -165,4 +187,30 @@ private function show_ga_notice() {
&& ! ( new Host() )->is_woa_site()
&& empty( $_COOKIE['jetpack_deprecate_dismissed']['jetpack-ga-admin-removal-notice'] );
}
+
+ /**
+ * Check if Masterbar notice should show up.
+ *
+ * @return bool
+ */
+ private function show_masterbar_notice() {
+ return ( new Modules() )->is_active( 'masterbar', false )
+ && ! ( new Host() )->is_woa_site()
+ && empty( $_COOKIE['jetpack_deprecate_dismissed']['jetpack-masterbar-admin-removal-notice'] );
+ }
+
+ /**
+ * Remove Masterbar from the old Module list.
+ * Available at wp-admin/admin.php?page=jetpack_modules
+ * We only need this function until the Masterbar is fully removed from Jetpack (including notices).
+ *
+ * @param array $items Array of Jetpack modules.
+ * @return array
+ */
+ public function remove_masterbar_module_list( $items ) {
+ if ( isset( $items['masterbar'] ) && get_option( 'wpcom_admin_interface' ) !== 'wp-admin' ) {
+ unset( $items['masterbar'] );
+ }
+ return $items;
+ }
}