From 8d8e0e6ef75b32c52029a57740cb6e13c6312296 Mon Sep 17 00:00:00 2001 From: Sergey Mitroshin Date: Thu, 26 Sep 2024 10:49:55 -0400 Subject: [PATCH] Jetpack: clean and deprecate unused functionality on Jetpack admin pages (#39547) * Deprecate the "help tab" functionality, clean up what we can. * Deprecate the callback hooked into `jetpack_loaded` so we could remove it in the next version. --- projects/plugins/jetpack/.phan/baseline.php | 2 +- .../admin-pages/class.jetpack-admin-page.php | 22 +++++---- .../remove-jetpack-page-excessive-hook | 4 ++ projects/plugins/jetpack/class.jetpack.php | 48 ++----------------- 4 files changed, 23 insertions(+), 53 deletions(-) create mode 100644 projects/plugins/jetpack/changelog/remove-jetpack-page-excessive-hook diff --git a/projects/plugins/jetpack/.phan/baseline.php b/projects/plugins/jetpack/.phan/baseline.php index b03ed0bddc38a..61acd515a45fc 100644 --- a/projects/plugins/jetpack/.phan/baseline.php +++ b/projects/plugins/jetpack/.phan/baseline.php @@ -108,7 +108,7 @@ '_inc/genericons.php' => ['PhanTypeMismatchArgumentProbablyReal'], '_inc/lib/admin-pages/class-jetpack-about-page.php' => ['PhanTypeMismatchArgument'], '_inc/lib/admin-pages/class-jetpack-redux-state-helper.php' => ['PhanParamTooMany', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanRedundantCondition', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDimAssignment'], - '_inc/lib/admin-pages/class.jetpack-admin-page.php' => ['PhanTypeMismatchReturnProbablyReal', 'PhanUndeclaredProperty'], + '_inc/lib/admin-pages/class.jetpack-admin-page.php' => ['PhanDeprecatedProperty', 'PhanTypeMismatchReturnProbablyReal', 'PhanUndeclaredProperty'], '_inc/lib/class-jetpack-ai-helper.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchPropertyDefault'], '_inc/lib/class-jetpack-instagram-gallery-helper.php' => ['PhanTypeMismatchArgument'], '_inc/lib/class-jetpack-mapbox-helper.php' => ['PhanTypeMismatchArgumentNullable'], diff --git a/projects/plugins/jetpack/_inc/lib/admin-pages/class.jetpack-admin-page.php b/projects/plugins/jetpack/_inc/lib/admin-pages/class.jetpack-admin-page.php index a349a6df16724..763df7535f8a7 100644 --- a/projects/plugins/jetpack/_inc/lib/admin-pages/class.jetpack-admin-page.php +++ b/projects/plugins/jetpack/_inc/lib/admin-pages/class.jetpack-admin-page.php @@ -18,6 +18,7 @@ abstract class Jetpack_Admin_Page { * Jetpack Object. * * @var Jetpack + * @deprecated $$next-version$$ Use `Jetpack::init()` instead. */ public $jetpack; @@ -56,12 +57,20 @@ public function additional_styles() {} * The constructor. */ public function __construct() { + /** + * Keeping it for backward compatibility in case the `$jetpack` property is still in use. + * To be removed. + * + * @deprecated $$next-version$$ + */ add_action( 'jetpack_loaded', array( $this, 'on_jetpack_loaded' ) ); } /** * Runs on Jetpack being ready to load its packages. * + * @deprecated $$next-version$$ + * * @param Jetpack $jetpack object. */ public function on_jetpack_loaded( $jetpack ) { @@ -93,7 +102,6 @@ public function add_actions() { $hook = $this->get_page_hook(); // Attach hooks common to all Jetpack admin pages based on the created hook. - add_action( "load-$hook", array( $this, 'admin_help' ) ); add_action( "load-$hook", array( $this, 'admin_page_load' ) ); add_action( "admin_print_styles-$hook", array( $this, 'admin_styles' ) ); add_action( "admin_print_scripts-$hook", array( $this, 'admin_scripts' ) ); @@ -135,19 +143,17 @@ public function render() { } /** - * Load Help tab. + * Doesn't do anything anymore. * - * @todo This may no longer be used. + * @deprecated $$next-version$$ No longer used. */ - public function admin_help() { - $this->jetpack->admin_help(); - } + public function admin_help() {} /** * Call the existing admin page events. */ public function admin_page_load() { - $this->jetpack->admin_page_load(); + Jetpack::init()->admin_page_load(); } /** @@ -155,7 +161,7 @@ public function admin_page_load() { */ public function admin_scripts() { $this->page_admin_scripts(); // Delegate to inheriting class. - add_action( 'admin_footer', array( $this->jetpack, 'do_stats' ) ); + add_action( 'admin_footer', array( Jetpack::init(), 'do_stats' ) ); } /** diff --git a/projects/plugins/jetpack/changelog/remove-jetpack-page-excessive-hook b/projects/plugins/jetpack/changelog/remove-jetpack-page-excessive-hook new file mode 100644 index 0000000000000..e7eafbfcdfa12 --- /dev/null +++ b/projects/plugins/jetpack/changelog/remove-jetpack-page-excessive-hook @@ -0,0 +1,4 @@ +Significance: minor +Type: other + +Clean and deprecate unused functionality on Jetpack admin pages. diff --git a/projects/plugins/jetpack/class.jetpack.php b/projects/plugins/jetpack/class.jetpack.php index 1dfacebb27068..8753a4ec42be6 100644 --- a/projects/plugins/jetpack/class.jetpack.php +++ b/projects/plugins/jetpack/class.jetpack.php @@ -3558,54 +3558,14 @@ public function upload_handler( $update_media_item = false ) { } /** - * Add help to the Jetpack page + * Doesn't do anything anymore. + * + * @deprecated $$next-version$$ We no longer show the "Help" button. * * @since Jetpack (1.2.3) * @return void */ - public function admin_help() { - $current_screen = get_current_screen(); - - // Overview. - $current_screen->add_help_tab( - array( - 'id' => 'home', - 'title' => __( 'Home', 'jetpack' ), - 'content' => - '

' . __( 'Jetpack', 'jetpack' ) . '

' . - '

' . __( 'Jetpack supercharges your self-hosted WordPress site with the awesome cloud power of WordPress.com.', 'jetpack' ) . '

' . - '

' . __( 'On this page, you are able to view the modules available within Jetpack, learn more about them, and activate or deactivate them as needed.', 'jetpack' ) . '

', - ) - ); - - // Screen Content. - if ( current_user_can( 'manage_options' ) ) { - $current_screen->add_help_tab( - array( - 'id' => 'settings', - 'title' => __( 'Settings', 'jetpack' ), - 'content' => - '

' . __( 'Jetpack', 'jetpack' ) . '

' . - '

' . __( 'You can activate or deactivate individual Jetpack modules to suit your needs.', 'jetpack' ) . '

' . - '
    ' . - '
  1. ' . __( 'Each module has an Activate or Deactivate link so you can toggle one individually.', 'jetpack' ) . '
  2. ' . - '
  3. ' . __( 'Using the checkboxes next to each module, you can select multiple modules to toggle via the Bulk Actions menu at the top of the list.', 'jetpack' ) . '
  4. ' . - '
' . - '

' . __( 'Using the tools on the right, you can search for specific modules, filter by module categories or which are active, or change the sorting order.', 'jetpack' ) . '

', - ) - ); - } - - // Help Sidebar. - $support_url = Redirect::get_url( 'jetpack-support' ); - $faq_url = Redirect::get_url( 'jetpack-faq' ); - $current_screen->set_help_sidebar( - '

' . __( 'For more information:', 'jetpack' ) . '

' . - '

' . __( 'Jetpack FAQ', 'jetpack' ) . '

' . - '

' . __( 'Jetpack Support', 'jetpack' ) . '

' . - '

' . __( 'Jetpack Debugging Center', 'jetpack' ) . '

' - ); - } + public function admin_help() {} /** * Add action links for the Jetpack plugin.