From d381d597d5de5c9af42a20b7d8073822890a2120 Mon Sep 17 00:00:00 2001 From: Leo Fajardo Date: Mon, 24 May 2021 21:27:11 +0800 Subject: [PATCH] [menu] [menu-url] Fixed an issue with the menu URL generation logic. --- .../managers/class-fs-admin-menu-manager.php | 34 +++++++++++++------ start.php | 2 +- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/includes/managers/class-fs-admin-menu-manager.php b/includes/managers/class-fs-admin-menu-manager.php index f4d3f0b8c..ebd5c2953 100644 --- a/includes/managers/class-fs-admin-menu-manager.php +++ b/includes/managers/class-fs-admin-menu-manager.php @@ -699,16 +699,30 @@ function main_menu_url() { $menu = $this->find_main_submenu(); } - $parent_slug = isset( $menu['parent_slug'] ) ? - $menu['parent_slug'] : - 'admin.php'; - - return admin_url( - $parent_slug . - ( false === strpos( $parent_slug, '?' ) ? '?' : '&' ) . - 'page=' . - $menu['menu'][2] - ); + $menu_slug = $menu['menu'][2]; + $parent_slug = 'admin.php'; + + /** + * This line and the `if` block below it is based on the `menu_page_url()` function of WordPress. + * + * @author Leo Fajardo (@leorw) + * @since 2.7.4 + */ + global $_parent_pages; + + if ( ! empty( $_parent_pages[ $menu_slug ] ) ) { + $_parent_slug = $_parent_pages[ $menu_slug ]; + $parent_slug = isset( $_parent_pages[ $_parent_slug ] ) ? + $parent_slug : + $menu['parent_slug']; + } + + return admin_url( + $parent_slug . + ( false === strpos( $parent_slug, '?' ) ? '?' : '&' ) . + 'page=' . + $menu_slug + ); } /** diff --git a/start.php b/start.php index eab56e26a..419131ba2 100644 --- a/start.php +++ b/start.php @@ -15,7 +15,7 @@ * * @var string */ - $this_sdk_version = '2.7.4.2'; + $this_sdk_version = '2.7.4.3'; #region SDK Selection Logic --------------------------------------------------------------------