From 47838b38ae55887fa6ea4289e8ea1ec5267c899e Mon Sep 17 00:00:00 2001 From: Sergey Mitroshin Date: Wed, 21 Aug 2024 09:56:04 -0400 Subject: [PATCH] Google Analytics: delete feature removal notices (#38882) Remove Google Analytics deprecation/removal notices introduced in #38078 and #38701. --- .../components/jetpack-notices/index.jsx | 50 ------------------- .../class-jetpack-redux-state-helper.php | 1 - .../changelog/delete-ga-deprecation-notices | 4 ++ .../plugins/jetpack/src/class-deprecate.php | 49 ++++-------------- 4 files changed, 13 insertions(+), 91 deletions(-) create mode 100644 projects/plugins/jetpack/changelog/delete-ga-deprecation-notices 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 8cfbb00b895ee..55afb625d29f3 100644 --- a/projects/plugins/jetpack/_inc/client/components/jetpack-notices/index.jsx +++ b/projects/plugins/jetpack/_inc/client/components/jetpack-notices/index.jsx @@ -36,7 +36,6 @@ import { import { getLicensingError, clearLicensingError } from 'state/licensing'; import { getModule } from 'state/modules'; import { getSiteDataErrors } from 'state/site'; -import { isPluginActive } from 'state/site/plugins'; import { StartFreshDeprecationWarning } from '../../writing/custom-css'; import DismissableNotices from './dismissable'; import JetpackConnectionErrors from './jetpack-connection-errors'; @@ -187,12 +186,6 @@ class JetpackNotices extends React.Component { const cookieParsed = cookie.parse( document.cookie ); this.state = { - isGoogleAnalyticsNoticeDismissed: - cookieParsed && - cookieParsed.hasOwnProperty( - 'jetpack_deprecate_dismissed[jetpack-ga-admin-removal-notice]' - ) && - '1' === cookieParsed[ 'jetpack_deprecate_dismissed[jetpack-ga-admin-removal-notice]' ], isMasterbarNoticeDismissed: cookieParsed && cookieParsed.hasOwnProperty( @@ -203,20 +196,6 @@ class JetpackNotices extends React.Component { }; } - dismissGoogleAnalyticsNotice = () => { - this.setState( { isGoogleAnalyticsNoticeDismissed: true } ); - - document.cookie = cookie.serialize( - 'jetpack_deprecate_dismissed[jetpack-ga-admin-removal-notice]', - '1', - { - path: '/', - maxAge: 365 * 24 * 60 * 60, - SameSite: 'None', - } - ); - }; - dismissMasterbarNotice = () => { this.setState( { isMasterbarNoticeDismissed: true } ); @@ -237,8 +216,6 @@ class JetpackNotices extends React.Component { ); const isUserConnectScreen = this.props.location.pathname.startsWith( '/connect-user' ); - const showGoogleAnalyticsNotice = - this.props.showGoogleAnalyticsNotice && ! this.state.isGoogleAnalyticsNoticeDismissed; const showMasterbarNotice = this.props.showMasterbarNotice && ! this.state.isMasterbarNoticeDismissed; @@ -300,21 +277,6 @@ class JetpackNotices extends React.Component { ) } - { showGoogleAnalyticsNotice && ( - -
{ __( "Jetpack's Google Analytics has been removed.", 'jetpack' ) }
- - { __( - 'To keep tracking visits and more information on this change, please refer to this document', - 'jetpack' - ) } - -
- ) } { showMasterbarNotice && ( apply_filters( 'jetpack_subscription_site_enabled', false ), '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/changelog/delete-ga-deprecation-notices b/projects/plugins/jetpack/changelog/delete-ga-deprecation-notices new file mode 100644 index 0000000000000..ac42e37368344 --- /dev/null +++ b/projects/plugins/jetpack/changelog/delete-ga-deprecation-notices @@ -0,0 +1,4 @@ +Significance: patch +Type: other + +Delete the Google Analytics removal notices. diff --git a/projects/plugins/jetpack/src/class-deprecate.php b/projects/plugins/jetpack/src/class-deprecate.php index 8837c02e30a4c..e60d91392bf50 100644 --- a/projects/plugins/jetpack/src/class-deprecate.php +++ b/projects/plugins/jetpack/src/class-deprecate.php @@ -28,10 +28,12 @@ class Deprecate { * Initialize the class. */ 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' ) ); + if ( $this->has_notices() ) { + 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' ) ); + } } /** @@ -76,15 +78,6 @@ public function enqueue_admin_scripts() { * @return void */ public function render_admin_notices() { - if ( $this->show_ga_notice() ) { - $support_url = Redirect::get_url( 'jetpack-support-google-analytics' ); - - $this->render_notice( - 'jetpack-ga-admin-removal-notice', - esc_html__( "Jetpack's Google Analytics has been removed.", 'jetpack' ) - . ' ' . 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' ); @@ -101,21 +94,9 @@ public function render_admin_notices() { * * @param array $slugs Already added bubbles. * - * @return mixed + * @return array */ public function add_my_jetpack_red_bubbles( $slugs ) { - if ( $this->show_ga_notice() ) { - $slugs['jetpack-google-analytics-deprecate-feature'] = array( - 'data' => array( - 'text' => __( "Jetpack's Google Analytics has been removed.", 'jetpack' ), - 'link' => array( - 'label' => esc_html__( 'See documentation', 'jetpack' ), - 'url' => Redirect::get_url( 'jetpack-support-google-analytics' ), - ), - 'id' => 'jetpack-ga-admin-removal-notice', - ), - ); - } if ( $this->show_masterbar_notice() ) { $slugs['jetpack-masterbar-deprecate-feature'] = array( 'data' => array( @@ -168,24 +149,12 @@ private function render_notice( $id, $text, $params = array() ) { } /** - * Check if there are any notices to be displayed, so we wouldn't load unnecessary JS. + * Check if there are any notices to be displayed, so we wouldn't load unnecessary JS and run excessive hooks. * * @return bool */ private function has_notices() { - return ( $this->show_ga_notice() || $this->show_masterbar_notice() ); - } - - /** - * Check if Google Analytics notice should show up. - * - * @return bool - */ - private function show_ga_notice() { - return ( new Modules() )->is_active( 'google-analytics', false ) - && ! is_plugin_active( 'jetpack-legacy-google-analytics/jetpack-legacy-google-analytics.php' ) - && ! ( new Host() )->is_woa_site() - && empty( $_COOKIE['jetpack_deprecate_dismissed']['jetpack-ga-admin-removal-notice'] ); + return $this->show_masterbar_notice(); } /**