Skip to content

Commit

Permalink
Jetpack: Check $submenu is not NULL before adding Scan option (#39424)
Browse files Browse the repository at this point in the history
* Check $submenu is not NULL before accessing it

* Add changelog

---------

Co-authored-by: mmtr <1233880+mmtr@users.noreply.github.com>

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/11127201442

Upstream-Ref: Automattic/jetpack@75f87b5
  • Loading branch information
mmtr authored and matticbot committed Oct 1, 2024
1 parent 3d7d02c commit 5ac422f
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 93 deletions.
60 changes: 30 additions & 30 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions vendor/automattic/jetpack-masterbar/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.9.5-alpha] - unreleased

This is an alpha version! The changes listed here are not final.

## [0.9.4] - 2024-09-30
### Changed
- Remove user connection nudges where they aren't needed. Add user connection nudges where needed [#39533]
Expand Down Expand Up @@ -140,6 +144,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Updated package dependencies. [#37669]
- Updated package dependencies. [#37706]

[0.9.5-alpha]: https://github.com/Automattic/jetpack-masterbar/compare/v0.9.4...v0.9.5-alpha
[0.9.4]: https://github.com/Automattic/jetpack-masterbar/compare/v0.9.3...v0.9.4
[0.9.3]: https://github.com/Automattic/jetpack-masterbar/compare/v0.9.2...v0.9.3
[0.9.2]: https://github.com/Automattic/jetpack-masterbar/compare/v0.9.1...v0.9.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,11 +328,15 @@ public function add_jetpack_menu() {
parent::add_jetpack_menu();
}

$scan_position = $this->get_submenu_item_count( 'jetpack' ) - 1;

global $submenu;
$backup_submenu_label = __( 'Backup', 'jetpack-masterbar' );
$submenu_labels = array_column( $submenu['jetpack'], 3 );
$backup_position = array_search( $backup_submenu_label, $submenu_labels, true );
$scan_position = $backup_position !== false ? $backup_position + 1 : $this->get_submenu_item_count( 'jetpack' ) - 1;
if ( isset( $submenu['jetpack'] ) ) {
$backup_submenu_label = __( 'Backup', 'jetpack-masterbar' );
$submenu_labels = array_column( $submenu['jetpack'], 3 );
$backup_position = array_search( $backup_submenu_label, $submenu_labels, true );
$scan_position = $backup_position !== false ? $backup_position + 1 : $this->get_submenu_item_count( 'jetpack' ) - 1;
}

// @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal -- Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539.
add_submenu_page( 'jetpack', esc_attr__( 'Scan', 'jetpack-masterbar' ), __( 'Scan', 'jetpack-masterbar' ), 'manage_options', 'https://wordpress.com/scan/history/' . $this->domain, null, $scan_position );
Expand Down
2 changes: 1 addition & 1 deletion vendor/automattic/jetpack-masterbar/src/class-main.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
class Main {

const PACKAGE_VERSION = '0.9.4';
const PACKAGE_VERSION = '0.9.5-alpha';

/**
* Initializer.
Expand Down
2 changes: 1 addition & 1 deletion vendor/automattic/jetpack-mu-wpcom/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"automattic/jetpack-calypsoify": "^0.1.6",
"automattic/jetpack-classic-theme-helper": "^0.6.2",
"automattic/jetpack-connection": "^5.1.1",
"automattic/jetpack-masterbar": "^0.9.4",
"automattic/jetpack-masterbar": "^0.9.5-alpha",
"automattic/jetpack-redirect": "^2.0.4",
"automattic/jetpack-stats-admin": "^0.22.1",
"automattic/jetpack-status": "^4.0.2",
Expand Down
Loading

0 comments on commit 5ac422f

Please sign in to comment.