Skip to content

Commit

Permalink
My Jetpack: Only add the My Jetpack menu item and page if we are in t…
Browse files Browse the repository at this point in the history
…he WordPress admin side (#39334)

* Only add the My Jetpack menu item and page if we are in the WordPress admin side

This avoids reading a language option in the frontend

* changelog
  • Loading branch information
oskosk authored Sep 10, 2024
1 parent 2110d68 commit b52119c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: This is a performance internal change


27 changes: 18 additions & 9 deletions projects/packages/my-jetpack/src/class-initializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,8 @@ public static function init() {
// Add custom WP REST API endoints.
add_action( 'rest_api_init', array( __CLASS__, 'register_rest_endpoints' ) );

$page_suffix = Admin_Menu::add_menu(
__( 'My Jetpack', 'jetpack-my-jetpack' ),
__( 'My Jetpack', 'jetpack-my-jetpack' ),
'edit_posts',
'my-jetpack',
array( __CLASS__, 'admin_page' ),
-1
);
add_action( 'admin_menu', array( __CLASS__, 'add_my_jetpack_menu_item' ) );

add_action( 'load-' . $page_suffix, array( __CLASS__, 'admin_init' ) );
add_action( 'admin_init', array( __CLASS__, 'setup_historically_active_jetpack_modules_sync' ) );
// This is later than the admin-ui package, which runs on 1000
add_action( 'admin_init', array( __CLASS__, 'maybe_show_red_bubble' ), 1001 );
Expand Down Expand Up @@ -166,6 +158,23 @@ public static function is_licensing_ui_enabled() {
);
}

/**
* Add My Jetpack menu item to the admin menu.
*
* @return void
*/
public static function add_my_jetpack_menu_item() {
$page_suffix = Admin_Menu::add_menu(
__( 'My Jetpack', 'jetpack-my-jetpack' ),
__( 'My Jetpack', 'jetpack-my-jetpack' ),
'edit_posts',
'my-jetpack',
array( __CLASS__, 'admin_page' ),
-1
);
add_action( 'load-' . $page_suffix, array( __CLASS__, 'admin_init' ) );
}

/**
* Callback for the load my jetpack page hook.
*
Expand Down

0 comments on commit b52119c

Please sign in to comment.