Skip to content

Commit

Permalink
Jetpack plugin: Remove 'WordPress.com Toolbar' module (#39406)
Browse files Browse the repository at this point in the history
* Jetpack: Remove masterbar module
  • Loading branch information
fgiannar authored Sep 25, 2024
1 parent c017b20 commit bce25e6
Show file tree
Hide file tree
Showing 139 changed files with 31 additions and 9,312 deletions.
1 change: 0 additions & 1 deletion projects/packages/jetpack-mu-wpcom/.phan/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
__DIR__ . '/../../../plugins/jetpack/3rd-party/class.jetpack-amp-support.php', // class Jetpack_AMP_Support
__DIR__ . '/../../../plugins/jetpack/modules/custom-css/custom-css.php', // class Jetpack_Custom_CSS_Enhancements
__DIR__ . '/../../../plugins/jetpack/class-jetpack-stats-dashboard-widget.php', // class Jetpack_Stats_Dashboard_Widget
__DIR__ . '/../../../plugins/jetpack/modules/masterbar/nudges/bootstrap.php', // function Automattic\Jetpack\Dashboard_Customizations\register_css_nudge_control phpcs:ignore Squiz.PHP.CommentedOutCode.Found
__DIR__ . '/../../../plugins/wpcomsh/wpcomsh.php', // function wpcomsh_record_tracks_event
),
'exclude_analysis_directory_list' => array(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fixed
Comment: Jetpack-mu-wpcom: Fix invalid namespace in wpcom-admin-menu feature


Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ function wpcom_hide_customizer_submenu_on_block_theme() {

remove_action( 'customize_register', array( 'Jetpack_Fonts_Typekit', 'maybe_override_for_advanced_mode' ), 20 );

remove_action( 'customize_register', 'Automattic\Jetpack\Dashboard_Customizations\register_css_nudge_control' );
remove_action( 'customize_register', 'Automattic\Jetpack\Masterbar\register_css_nudge_control' );

remove_action( 'customize_register', array( 'Jetpack_Custom_CSS_Enhancements', 'customize_register' ) );
}
Expand Down
1 change: 0 additions & 1 deletion projects/plugins/jetpack/.gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
/jetpack_vendor/automattic/**/src/css/*.scss production-exclude
/jetpack_vendor/automattic/**/composer.json production-exclude
/modules/**/test/** production-exclude
/modules/masterbar/admin-color-schemes/colors/**/*.scss production-exclude
/modules/widgets/follow-button.php production-exclude
/modules/widget-visibility/editor/** production-exclude
/node_modules/** production-exclude
Expand Down
12 changes: 3 additions & 9 deletions projects/plugins/jetpack/.phan/baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
return [
// # Issue statistics:
// PhanTypeMismatchArgument : 460+ occurrences
// PhanTypeMismatchArgument : 450+ occurrences
// PhanPluginDuplicateConditionalNullCoalescing : 260+ occurrences
// PhanNoopNew : 200+ occurrences
// PhanTypeMismatchArgumentProbablyReal : 200+ occurrences
Expand Down Expand Up @@ -40,7 +40,6 @@
// PhanSuspiciousMagicConstant : 15+ occurrences
// PhanTypeExpectedObjectPropAccessButGotNull : 15+ occurrences
// PhanTypeMismatchPropertyDefault : 15+ occurrences
// PhanUndeclaredMethod : 15+ occurrences
// PhanPluginDuplicateExpressionAssignmentOperation : 10+ occurrences
// PhanRedefineClass : 10+ occurrences
// PhanRedundantConditionInLoop : 10+ occurrences
Expand All @@ -49,6 +48,7 @@
// PhanTypeMismatchProperty : 10+ occurrences
// PhanTypeMismatchReturnNullable : 10+ occurrences
// PhanUndeclaredFunction : 10+ occurrences
// PhanUndeclaredMethod : 10+ occurrences
// PhanTypeComparisonToArray : 9 occurrences
// PhanPluginRedundantAssignment : 8 occurrences
// PhanRedefinedClassReference : 8 occurrences
Expand All @@ -57,7 +57,6 @@
// PhanCommentAbstractOnInheritedMethod : 6 occurrences
// PhanDeprecatedClass : 5 occurrences
// PhanNonClassMethodCall : 5 occurrences
// PhanTypeArraySuspiciousNull : 5 occurrences
// PhanTypeMismatchDimAssignment : 5 occurrences
// PhanTypeSuspiciousStringExpression : 5 occurrences
// PhanAccessMethodInternal : 4 occurrences
Expand All @@ -78,6 +77,7 @@
// PhanParamTooManyCallable : 2 occurrences
// PhanPluginDuplicateSwitchCaseLooseEquality : 2 occurrences
// PhanStaticCallToNonStatic : 2 occurrences
// PhanTypeArraySuspiciousNull : 2 occurrences
// PhanTypeMismatchArgumentInternalProbablyReal : 2 occurrences
// PhanUndeclaredClassInCallable : 2 occurrences
// PhanUndeclaredClassMethod : 2 occurrences
Expand Down Expand Up @@ -338,7 +338,6 @@
'modules/likes/jetpack-likes-master-iframe.php' => ['PhanPluginDuplicateConditionalNullCoalescing'],
'modules/likes/jetpack-likes-settings.php' => ['PhanDeprecatedFunction', 'PhanRedundantCondition'],
'modules/markdown/easy-markdown.php' => ['PhanParamTooMany', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeArraySuspiciousNullable', 'PhanTypeMismatchArgument', 'PhanUndeclaredProperty'],
'modules/masterbar/profile-edit/bootstrap.php' => ['PhanNoopNew'],
'modules/memberships/class-jetpack-memberships.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredMethod'],
'modules/module-headings.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchReturnProbablyReal'],
'modules/monitor.php' => ['PhanNoopNew', 'PhanTypeMismatchReturnProbablyReal'],
Expand Down Expand Up @@ -519,11 +518,6 @@
'tests/php/media/test-class.jetpack-media-extractor.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal'],
'tests/php/media/test-class.jetpack-post-images.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'tests/php/modules/geo-location/test_class.jetpack-geo-location.php' => ['PhanDeprecatedFunction', 'PhanTypeMismatchArgumentProbablyReal'],
'tests/php/modules/masterbar/test-class-admin-color-schemes.php' => ['PhanNoopNew'],
'tests/php/modules/masterbar/test-class-admin-menu.php' => ['PhanTypeArraySuspiciousNull', 'PhanTypeInvalidDimOffset'],
'tests/php/modules/masterbar/test-class-atomic-admin-menu.php' => ['PhanRedefineFunction'],
'tests/php/modules/masterbar/test-class-masterbar.php' => ['PhanUndeclaredMethod'],
'tests/php/modules/masterbar/test-class-posts-list-page-notification.php' => ['PhanTypeMismatchArgument'],
'tests/php/modules/photon/test_class.jetpack-photon-static-asset-cdn.php' => ['PhanTypeMismatchProperty'],
'tests/php/modules/post-by-email/test-class.post-by-email-api.php' => ['PhanParamTooMany'],
'tests/php/modules/publicize/test_class.publicize.php' => ['PhanDeprecatedFunction', 'PhanPluginDuplicateConditionalNullCoalescing'],
Expand Down
4 changes: 3 additions & 1 deletion projects/plugins/jetpack/3rd-party/beaverbuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@

namespace Automattic\Jetpack\Third_Party;

use Automattic\Jetpack\Status\Host;

add_action( 'init', __NAMESPACE__ . '\beaverbuilder_refresh' );

/**
* If masterbar module is active force BeaverBuilder to refresh when publishing a layout.
*/
function beaverbuilder_refresh() {
if ( \Jetpack::is_module_active( 'masterbar' ) ) {
if ( ( new Host() )->is_woa_site() ) {
add_filter( 'fl_builder_should_refresh_on_publish', '__return_true' );
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { JETPACK_CONTACT_BETA_SUPPORT } from 'constants/urls';
import { getRedirectUrl } from '@automattic/jetpack-components';
import { ExternalLink } from '@wordpress/components';
import { createInterpolateElement } from '@wordpress/element';
import { __, sprintf } from '@wordpress/i18n';
import ConnectionBanner from 'components/connection-banner';
import NoticesList from 'components/global-notices';
import SimpleNotice from 'components/notice';
import NoticeAction from 'components/notice/notice-action.jsx';
import cookie from 'cookie';
import PropTypes from 'prop-types';
import React from 'react';
import { connect } from 'react-redux';
Expand All @@ -30,7 +28,6 @@ import {
userCanConnectSite,
userIsSubscriber,
getConnectionErrors,
isWoASite,
} from 'state/initial-state';
import { getLicensingError, clearLicensingError } from 'state/licensing';
import { getSiteDataErrors } from 'state/site';
Expand Down Expand Up @@ -178,46 +175,13 @@ UserUnlinked.propTypes = {
class JetpackNotices extends React.Component {
static displayName = 'JetpackNotices';

constructor( props ) {
super( props );

const cookieParsed = cookie.parse( document.cookie );
this.state = {
isMasterbarNoticeDismissed:
cookieParsed &&
Object.hasOwn(
cookieParsed,
'jetpack_deprecate_dismissed[jetpack-masterbar-admin-removal-notice]'
) &&
'1' ===
cookieParsed[ 'jetpack_deprecate_dismissed[jetpack-masterbar-admin-removal-notice]' ],
};
}

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 =>
Object.hasOwn( error, 'action' )
);

const isUserConnectScreen = this.props.location.pathname.startsWith( '/connect-user' );

const showMasterbarNotice =
this.props.showMasterbarNotice && ! this.state.isMasterbarNoticeDismissed;

return (
<div aria-live="polite">
<NoticesList />
Expand Down Expand Up @@ -270,24 +234,6 @@ class JetpackNotices extends React.Component {
onDismissClick={ this.props.clearLicensingError }
/>
) }

{ showMasterbarNotice && (
<SimpleNotice
status="is-warning"
dismissText={ __( 'Dismiss', 'jetpack' ) }
onDismissClick={ this.dismissMasterbarNotice }
>
<div>
{ __( "Jetpack's WordPress.com Toolbar feature has been removed.", 'jetpack' ) }
</div>
<ExternalLink href={ getRedirectUrl( 'jetpack-support-masterbar' ) }>
{ __(
'To find out more about what this means for you, please refer to this document',
'jetpack'
) }
</ExternalLink>
</SimpleNotice>
) }
</div>
);
}
Expand All @@ -312,7 +258,6 @@ export default connect(
isReconnectingSite: isReconnectingSite( state ),
licensingError: getLicensingError( state ),
hasConnectedOwner: hasConnectedOwner( state ),
showMasterbarNotice: window.Initial_State?.isMasterbarActive && ! isWoASite( state ),
};
},
dispatch => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ export class NavigationSettings extends React.Component {
</NavItem>
) }
{ this.props.hasAnyOfTheseModules( [
'masterbar',
'markdown',
'custom-content-types',
'post-by-email',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ describe( 'NavigationSettings', () => {
monitor: true,
vaultpress: true,
stats: true,
masterbar: true,
'google-analytics': true,
'seo-tools': true,
wordads: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ export function maybeHideNavMenuItem( module, values ) {
}

export function maybeReloadAfterAction( newOptionValue ) {
const reloadForOptionValues = [ 'masterbar', 'jetpack_testimonial', 'jetpack_portfolio' ];
const reloadForOptionValues = [ 'jetpack_testimonial', 'jetpack_portfolio' ];

if ( some( reloadForOptionValues, optionValue => optionValue in newOptionValue ) ) {
window.location.reload();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,10 @@ export const updateSettings = ( newOptionValues, noticeMessages = {} ) => {
...noticeMessages,
};

// Changes to these options affect WordPress.com Toolbar appearance,
// and we need to reload the page for them to take effect.
const reloadForOptionValues = [ 'masterbar', 'jetpack_testimonial', 'jetpack_portfolio' ];
// For changes to these options we need to reload the page in order for them to take effect.
const reloadForOptionValues = [ 'jetpack_testimonial', 'jetpack_portfolio' ];

// Adapt message for masterbar toggle, since it needs to reload.
// Adapt message for above options, since it needs to reload.
if (
'object' === typeof newOptionValues &&
some( reloadForOptionValues, optionValue => optionValue in newOptionValues )
Expand Down
4 changes: 1 addition & 3 deletions projects/plugins/jetpack/_inc/client/writing/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
isCurrentUserLinked,
getConnectUrl,
} from 'state/connection';
import { userCanManageModules, userCanEditPosts, isAtomicSite } from 'state/initial-state';
import { userCanManageModules, userCanEditPosts } from 'state/initial-state';
import { isModuleActivated, getModuleOverride, getModule } from 'state/modules';
import { isModuleFound } from 'state/search';
import { getSettings } from 'state/settings';
Expand Down Expand Up @@ -41,7 +41,6 @@ export class Writing extends React.Component {
'carousel',
'copy-post',
'latex',
'masterbar',
'markdown',
'shortcodes',
'custom-content-types',
Expand Down Expand Up @@ -107,7 +106,6 @@ export default connect( state => {
return {
module: module_name => getModule( state, module_name ),
settings: getSettings( state ),
masterbarIsAlwaysActive: isAtomicSite( state ),
isOfflineMode: isOfflineMode( state ),
isUnavailableInOfflineMode: module_name => isUnavailableInOfflineMode( state, module_name ),
userCanEditPosts: userCanEditPosts( state ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
use Automattic\Jetpack\IP\Utils as IP_Utils;
use Automattic\Jetpack\Licensing;
use Automattic\Jetpack\Licensing\Endpoints as Licensing_Endpoints;
use Automattic\Jetpack\Modules;
use Automattic\Jetpack\My_Jetpack\Initializer as My_Jetpack_Initializer;
use Automattic\Jetpack\My_Jetpack\Jetpack_Manage;
use Automattic\Jetpack\Partner;
Expand Down Expand Up @@ -248,7 +247,6 @@ public static function get_initial_state() {
'isSubscriptionSiteEnabled' => apply_filters( 'jetpack_subscription_site_enabled', false ),
'newsletterDateExample' => gmdate( get_option( 'date_format' ), time() ),
'subscriptionSiteEditSupported' => $current_theme->is_block_theme(),
'isMasterbarActive' => ( new Modules() )->is_active( 'masterbar', false ),
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: major
Type: major

Jetpack plugin: Remove 'WordPress.com Toolbar' module
23 changes: 5 additions & 18 deletions projects/plugins/jetpack/modules/masterbar.php
Original file line number Diff line number Diff line change
@@ -1,24 +1,11 @@
<?php
/**
* Module Name: WordPress.com Toolbar and Dashboard customizations
* Module Description: Replaces the admin bar with a useful toolbar to quickly manage your site via WordPress.com. Also adds additional customizations to the WPAdmin dashboard experience for better compatibility with WP.com.
* Sort Order: 38
* Recommendation Order: 16
* First Introduced: 4.8
* Requires Connection: Yes
* Requires User Connection: Yes
* Auto Activate: No
* Module Tags: General
* Additional Search Queries: adminbar, masterbar, colorschemes, profile-edit
* The WordPress.com Toolbar and Dashboard customizations Module has been deprecated and this file
* will be removed in an upcoming Jetpack release.
*
* @deprecated $$$next-version$
*
* @package automattic/jetpack
*/

/**
* 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
*/
_deprecated_file( __FILE__, 'jetpack-$$next-version$$' );
Loading

0 comments on commit bce25e6

Please sign in to comment.