Skip to content

Commit

Permalink
Admin menu: update order of submenu items within the Jetpack menu.
Browse files Browse the repository at this point in the history
This changes the order of the different submenu items, like so:

1. **My Jetpack**
2. Activity Log (External)
3. **Jetpack Manage** (External)
4. **Stats**
5. **Boost**
6. **VideoPress**
7. **Social**
8. **Protect**
9. **Akismet Anti-spam**
10. **VaultPress Backup** / Scan / VaultPress (External) / VaultPress
11. Search
12. **Dashboard**
13. **Settings**
14. **Subscribers** (External)
15. WordAds
16. Beta Tester
  • Loading branch information
jeherve committed Aug 7, 2024
1 parent e0ff257 commit 469c79e
Show file tree
Hide file tree
Showing 41 changed files with 168 additions and 44 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

Admin menu: update the order of the different submenu items within the Jetpack menu.
2 changes: 1 addition & 1 deletion projects/packages/admin-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@automattic/jetpack-admin-ui",
"version": "0.4.2",
"version": "0.4.3-alpha",
"description": "Generic Jetpack wp-admin UI elements",
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/packages/admin-ui/#readme",
"bugs": {
Expand Down
11 changes: 9 additions & 2 deletions projects/packages/admin-ui/src/class-admin-menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
class Admin_Menu {

const PACKAGE_VERSION = '0.4.2';
const PACKAGE_VERSION = '0.4.3-alpha';

/**
* Whether this class has been initialized
Expand Down Expand Up @@ -58,7 +58,14 @@ function () {
remove_action( 'admin_menu', array( 'Akismet_Admin', 'admin_menu' ), 5 );

// Add an Anti-spam menu item for Jetpack.
self::add_menu( __( 'Akismet Anti-spam', 'jetpack-admin-ui' ), __( 'Akismet Anti-spam', 'jetpack-admin-ui' ), 'manage_options', 'akismet-key-config', array( 'Akismet_Admin', 'display_page' ) );
self::add_menu(
__( 'Akismet Anti-spam', 'jetpack-admin-ui' ),
__( 'Akismet Anti-spam', 'jetpack-admin-ui' ),
'manage_options',
'akismet-key-config',
array( 'Akismet_Admin', 'display_page' ),
9
);
},
4
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

Admin menu: update the order of the different submenu items within the Jetpack menu.
3 changes: 2 additions & 1 deletion projects/packages/backup/src/class-jetpack-backup.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ public static function initialize() {
_x( 'VaultPress Backup', 'The Jetpack VaultPress Backup product name, without the Jetpack prefix', 'jetpack-backup-pkg' ),
'manage_options',
'jetpack-backup',
array( __CLASS__, 'plugin_settings_page' )
array( __CLASS__, 'plugin_settings_page' ),
10
);
add_action( 'load-' . $page_suffix, array( __CLASS__, 'admin_init' ) );

Expand Down
2 changes: 1 addition & 1 deletion projects/packages/backup/src/class-package-version.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
class Package_Version {

const PACKAGE_VERSION = '3.4.2';
const PACKAGE_VERSION = '3.4.3-alpha';

const PACKAGE_SLUG = 'backup';

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

Admin menu: update the order of the different submenu items within the Jetpack menu.
2 changes: 1 addition & 1 deletion projects/packages/my-jetpack/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@automattic/jetpack-my-jetpack",
"version": "4.32.0",
"version": "4.32.1-alpha",
"description": "WP Admin page with information and configuration shared among all Jetpack stand-alone plugins",
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/packages/my-jetpack/#readme",
"bugs": {
Expand Down
2 changes: 1 addition & 1 deletion projects/packages/my-jetpack/src/class-activitylog.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static function add_submenu_jetpack() {
'manage_options',
esc_url( Redirect::get_url( 'cloud-activity-log-wp-menu', $args ) ),
null,
1
2
);
}
}
2 changes: 1 addition & 1 deletion projects/packages/my-jetpack/src/class-initializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Initializer {
*
* @var string
*/
const PACKAGE_VERSION = '4.32.0';
const PACKAGE_VERSION = '4.32.1-alpha';

/**
* HTML container ID for the IDC screen on My Jetpack page.
Expand Down
2 changes: 1 addition & 1 deletion projects/packages/my-jetpack/src/class-jetpack-manage.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static function add_submenu_jetpack() {
'manage_options',
esc_url( Redirect::get_url( 'cloud-manage-dashboard-wp-menu', $args ) ),
null,
100
3
);
}

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

Admin menu: update the order of the different submenu items within the Jetpack menu.
2 changes: 1 addition & 1 deletion projects/packages/search/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jetpack-search",
"version": "0.44.14",
"version": "0.44.15-alpha",
"description": "Package for Jetpack Search products",
"main": "main.js",
"directories": {
Expand Down
2 changes: 1 addition & 1 deletion projects/packages/search/src/class-package.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* Search package general information
*/
class Package {
const VERSION = '0.44.14';
const VERSION = '0.44.15-alpha';
const SLUG = 'search';

/**
Expand Down
3 changes: 2 additions & 1 deletion projects/packages/search/src/dashboard/class-dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ public function add_wp_admin_submenu() {
_x( 'Search', 'product name shown in menu', 'jetpack-search-pkg' ),
'manage_options',
'jetpack-search',
array( $this, 'render' )
array( $this, 'render' ),
11
);
} else {
// always add the page, but hide it from the menu.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

Admin menu: update the order of the different submenu items within the Jetpack menu.
2 changes: 1 addition & 1 deletion projects/packages/stats-admin/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@automattic/jetpack-stats-admin",
"version": "0.21.0",
"version": "0.21.1-alpha",
"description": "Stats Dashboard",
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/packages/stats-admin/#readme",
"bugs": {
Expand Down
3 changes: 2 additions & 1 deletion projects/packages/stats-admin/src/class-dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ public function add_wp_admin_submenu() {
_x( 'Stats', 'product name shown in menu', 'jetpack-stats-admin' ),
'manage_options',
'stats',
array( $this, 'render' )
array( $this, 'render' ),
4
);

if ( $page_suffix ) {
Expand Down
2 changes: 1 addition & 1 deletion projects/packages/stats-admin/src/class-main.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Main {
/**
* Stats version.
*/
const VERSION = '0.21.0';
const VERSION = '0.21.1-alpha';

/**
* Singleton Main instance.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

Admin menu: update the order of the different submenu items within the Jetpack menu.
2 changes: 1 addition & 1 deletion projects/packages/videopress/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@automattic/jetpack-videopress",
"version": "0.23.30",
"version": "0.23.31-alpha",
"description": "VideoPress package",
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/packages/videopress/#readme",
"bugs": {
Expand Down
3 changes: 2 additions & 1 deletion projects/packages/videopress/src/class-admin-ui.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public static function init() {
_x( 'VideoPress', 'The Jetpack VideoPress product name, without the Jetpack prefix', 'jetpack-videopress-pkg' ),
'manage_options',
self::ADMIN_PAGE_SLUG,
array( __CLASS__, 'plugin_settings_page' )
array( __CLASS__, 'plugin_settings_page' ),
6
);
add_action( 'load-' . $page_suffix, array( __CLASS__, 'admin_init' ) );

Expand Down
2 changes: 1 addition & 1 deletion projects/packages/videopress/src/class-package-version.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* The Package_Version class.
*/
class Package_Version {
const PACKAGE_VERSION = '0.23.30';
const PACKAGE_VERSION = '0.23.31-alpha';

const PACKAGE_SLUG = 'videopress';

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

Admin menu: update the order of the different submenu items within the Jetpack menu.
2 changes: 1 addition & 1 deletion projects/packages/wordads/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@automattic/jetpack-wordads",
"version": "0.3.25",
"version": "0.3.26-alpha",
"description": "Earn income by allowing Jetpack to display high quality ads.",
"main": "main.js",
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/packages/wordads/#readme",
Expand Down
2 changes: 1 addition & 1 deletion projects/packages/wordads/src/class-package.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* WordAds package general information
*/
class Package {
const VERSION = '0.3.25';
const VERSION = '0.3.26-alpha';
const SLUG = 'wordads';

/**
Expand Down
3 changes: 2 additions & 1 deletion projects/packages/wordads/src/dashboard/class-dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ public function add_wp_admin_submenu() {
_x( 'WordAds', 'product name shown in menu', 'jetpack-wordads' ),
'manage_options',
'jetpack-wordads',
array( $this, 'render' )
array( $this, 'render' ),
15
);

add_action( 'load-' . $page_suffix, array( $this, 'admin_init' ) );
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

Admin menu: update the order of the different submenu items within the Jetpack menu.
3 changes: 2 additions & 1 deletion projects/plugins/beta/src/class-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ public static function add_actions() {
'Beta Tester',
'update_plugins',
'jetpack-beta',
array( self::class, 'render' )
array( self::class, 'render' ),
16
);

if ( false !== self::$hookname ) {
Expand Down
3 changes: 2 additions & 1 deletion projects/plugins/boost/app/admin/class-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ public function handle_admin_menu() {
$menu_label,
'manage_options',
JETPACK_BOOST_SLUG,
array( $this, 'render_settings' )
array( $this, 'render_settings' ),
5
);
add_action( 'load-' . $page_suffix, array( $this, 'admin_init' ) );
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

Admin menu: update the order of the different submenu items within the Jetpack menu.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName

use Automattic\Jetpack\Admin_UI\Admin_Menu;
use Automattic\Jetpack\Assets\Logo;
use Automattic\Jetpack\Connection\Initial_State as Connection_Initial_State;
use Automattic\Jetpack\Connection\Manager as Connection_Manager;
Expand Down Expand Up @@ -77,6 +78,21 @@ public function add_page_actions( $hook ) {
}
}

/**
* Remove the main Jetpack submenu if a site is in offline mode or connected.
* At that point, admins can access the Jetpack Dashboard instead.
*
* @since $$next-version$$
*/
public function remove_jetpack_menu() {
if (
( new Status() )->is_offline_mode()
|| Jetpack::is_connection_ready()
) {
remove_submenu_page( 'jetpack', 'jetpack' );
}
}

/**
* Add Jetpack Dashboard sub-link and point it to AAG if the user can view stats, manage modules or if Protect is active.
*
Expand All @@ -85,9 +101,18 @@ public function add_page_actions( $hook ) {
* @since 4.3.0
*/
public function jetpack_add_dashboard_sub_nav_item() {
if ( ( new Status() )->is_offline_mode() || Jetpack::is_connection_ready() ) {
add_submenu_page( 'jetpack', __( 'Dashboard', 'jetpack' ), __( 'Dashboard', 'jetpack' ), 'jetpack_admin_page', 'jetpack#/dashboard', '__return_null', 1 );
remove_submenu_page( 'jetpack', 'jetpack' );
if (
( new Status() )->is_offline_mode()
|| Jetpack::is_connection_ready()
) {
Admin_Menu::add_menu(
__( 'Dashboard', 'jetpack' ),
__( 'Dashboard', 'jetpack' ),
'jetpack_admin_page',
Jetpack::admin_url( array( 'page' => 'jetpack#/dashboard' ) ),
null,

Check failure on line 113 in projects/plugins/jetpack/_inc/lib/admin-pages/class.jetpack-react-page.php

View workflow job for this annotation

GitHub Actions / Static analysis

TypeError PhanTypeMismatchArgumentProbablyReal Argument 5 ($function) is null of type null but \Automattic\Jetpack\Admin_UI\Admin_Menu::add_menu() takes callable (no real type) defined at jetpack_vendor/automattic/jetpack-admin-ui/src/class-admin-menu.php:171 (the inferred real argument type has nothing in common with the parameter's phpdoc type)
12
);
}
}

Expand Down Expand Up @@ -165,7 +190,14 @@ private function can_access_settings() {
*/
public function jetpack_add_settings_sub_nav_item() {
if ( $this->can_access_settings() ) {
add_submenu_page( 'jetpack', __( 'Settings', 'jetpack' ), __( 'Settings', 'jetpack' ), 'jetpack_admin_page', 'jetpack#/settings', '__return_null' );
Admin_Menu::add_menu(
__( 'Settings', 'jetpack' ),
__( 'Settings', 'jetpack' ),
'jetpack_admin_page',
Jetpack::admin_url( array( 'page' => 'jetpack#/settings' ) ),
null,

Check failure on line 198 in projects/plugins/jetpack/_inc/lib/admin-pages/class.jetpack-react-page.php

View workflow job for this annotation

GitHub Actions / Static analysis

TypeError PhanTypeMismatchArgumentProbablyReal Argument 5 ($function) is null of type null but \Automattic\Jetpack\Admin_UI\Admin_Menu::add_menu() takes callable (no real type) defined at jetpack_vendor/automattic/jetpack-admin-ui/src/class-admin-menu.php:171 (the inferred real argument type has nothing in common with the parameter's phpdoc type)
13
);
}
}

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

Admin menu: update the order of the different submenu items within the Jetpack menu.
1 change: 1 addition & 0 deletions projects/plugins/jetpack/class.jetpack-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ private function __construct() {

add_action( 'admin_init', array( $jetpack_react, 'react_redirects' ), 0 );
add_action( 'admin_menu', array( $jetpack_react, 'add_actions' ), 998 );
add_action( 'admin_menu', array( $jetpack_react, 'remove_jetpack_menu' ), 1000 );
add_action( 'jetpack_admin_menu', array( $jetpack_react, 'jetpack_add_dashboard_sub_nav_item' ) );
add_action( 'jetpack_admin_menu', array( $jetpack_react, 'jetpack_add_settings_sub_nav_item' ) );
add_action( 'jetpack_admin_menu', array( $this, 'admin_menu_debugger' ) );
Expand Down
Loading

0 comments on commit 469c79e

Please sign in to comment.