Skip to content

Commit

Permalink
Jetpack: clean and deprecate unused functionality on Jetpack admin pa…
Browse files Browse the repository at this point in the history
…ges (#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.
  • Loading branch information
sergeymitr authored Sep 26, 2024
1 parent eaa996e commit 8d8e0e6
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 53 deletions.
2 changes: 1 addition & 1 deletion projects/plugins/jetpack/.phan/baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ abstract class Jetpack_Admin_Page {
* Jetpack Object.
*
* @var Jetpack
* @deprecated $$next-version$$ Use `Jetpack::init()` instead.
*/
public $jetpack;

Expand Down Expand Up @@ -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 ) {
Expand Down Expand Up @@ -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' ) );
Expand Down Expand Up @@ -135,27 +143,25 @@ 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();
}

/**
* Add page specific scripts and jetpack stats for all menu pages.
*/
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' ) );
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: other

Clean and deprecate unused functionality on Jetpack admin pages.
48 changes: 4 additions & 44 deletions projects/plugins/jetpack/class.jetpack.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' =>
'<p><strong>' . __( 'Jetpack', 'jetpack' ) . '</strong></p>' .
'<p>' . __( 'Jetpack supercharges your self-hosted WordPress site with the awesome cloud power of WordPress.com.', 'jetpack' ) . '</p>' .
'<p>' . __( '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' ) . '</p>',
)
);

// Screen Content.
if ( current_user_can( 'manage_options' ) ) {
$current_screen->add_help_tab(
array(
'id' => 'settings',
'title' => __( 'Settings', 'jetpack' ),
'content' =>
'<p><strong>' . __( 'Jetpack', 'jetpack' ) . '</strong></p>' .
'<p>' . __( 'You can activate or deactivate individual Jetpack modules to suit your needs.', 'jetpack' ) . '</p>' .
'<ol>' .
'<li>' . __( 'Each module has an Activate or Deactivate link so you can toggle one individually.', 'jetpack' ) . '</li>' .
'<li>' . __( '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' ) . '</li>' .
'</ol>' .
'<p>' . __( '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' ) . '</p>',
)
);
}

// Help Sidebar.
$support_url = Redirect::get_url( 'jetpack-support' );
$faq_url = Redirect::get_url( 'jetpack-faq' );
$current_screen->set_help_sidebar(
'<p><strong>' . __( 'For more information:', 'jetpack' ) . '</strong></p>' .
'<p><a href="' . esc_url( $faq_url ) . '" rel="noopener noreferrer" target="_blank">' . __( 'Jetpack FAQ', 'jetpack' ) . '</a></p>' .
'<p><a href="' . esc_url( $support_url ) . '" rel="noopener noreferrer" target="_blank">' . __( 'Jetpack Support', 'jetpack' ) . '</a></p>' .
'<p><a href="' . esc_url( self::admin_url( array( 'page' => 'jetpack-debugger' ) ) ) . '">' . __( 'Jetpack Debugging Center', 'jetpack' ) . '</a></p>'
);
}
public function admin_help() {}

/**
* Add action links for the Jetpack plugin.
Expand Down

0 comments on commit 8d8e0e6

Please sign in to comment.