Skip to content

Commit 30965dd

Browse files
authored
[menu] Added a new filter for enabling the advanced CPT-related menu logic. (#779)
1 parent 8be2505 commit 30965dd

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

includes/managers/class-fs-admin-menu-manager.php

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -700,21 +700,27 @@ function main_menu_url() {
700700
}
701701

702702
$menu_slug = $menu['menu'][2];
703-
$parent_slug = 'admin.php';
704-
705-
/**
706-
* This line and the `if` block below it is based on the `menu_page_url()` function of WordPress.
707-
*
708-
* @author Leo Fajardo (@leorw)
709-
* @since 2.7.4
710-
*/
711-
global $_parent_pages;
712-
713-
if ( ! empty( $_parent_pages[ $menu_slug ] ) ) {
714-
$_parent_slug = $_parent_pages[ $menu_slug ];
715-
$parent_slug = isset( $_parent_pages[ $_parent_slug ] ) ?
716-
$parent_slug :
717-
$menu['parent_slug'];
703+
$parent_slug = isset( $menu['parent_slug'] ) ?
704+
$menu['parent_slug'] :
705+
'admin.php';
706+
707+
if ( fs_apply_filter( $this->_module_unique_affix, 'enable_cpt_advanced_menu_logic', false ) ) {
708+
$parent_slug = 'admin.php';
709+
710+
/**
711+
* This line and the `if` block below it are based on the `menu_page_url()` function of WordPress.
712+
*
713+
* @author Leo Fajardo (@leorw)
714+
* @since 2.10.2
715+
*/
716+
global $_parent_pages;
717+
718+
if ( ! empty( $_parent_pages[ $menu_slug ] ) ) {
719+
$_parent_slug = $_parent_pages[ $menu_slug ];
720+
$parent_slug = isset( $_parent_pages[ $_parent_slug ] ) ?
721+
$parent_slug :
722+
$menu['parent_slug'];
723+
}
718724
}
719725

720726
return admin_url(

0 commit comments

Comments
 (0)