Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[menu] Added a new filter for enabling the advanced CPT-related menu … #779

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 21 additions & 15 deletions includes/managers/class-fs-admin-menu-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -700,21 +700,27 @@ function main_menu_url() {
}

$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'];
$parent_slug = isset( $menu['parent_slug'] ) ?
$menu['parent_slug'] :
'admin.php';

if ( fs_apply_filter( $this->_module_unique_affix, 'enable_cpt_advanced_menu_logic', false ) ) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have documentation about enable_cpt_advanced_menu_logic hook somewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DanieleAlessandra This will be documented. Thanks!

$parent_slug = 'admin.php';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to re-define $parent_slug here? it has just been defined on line 703.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DanieleAlessandra The line above preserves the original behavior when the new filter is not used. When the filter is applied, the behavior changes slightly, and not using admin.php may lead to unexpected issues.


/**
* This line and the `if` block below it are based on the `menu_page_url()` function of WordPress.
*
* @author Leo Fajardo (@leorw)
* @since 2.10.2
*/
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(
Expand Down
2 changes: 1 addition & 1 deletion start.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
* @var string
*/
$this_sdk_version = '2.10.1.1';
$this_sdk_version = '2.10.1.2';

#region SDK Selection Logic --------------------------------------------------------------------

Expand Down
Loading