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

WP 5.3 compatibility: Fix the parameters passed to add_submenu_page() #14315

Open
2 tasks
afercia opened this issue Jan 30, 2020 · 0 comments
Open
2 tasks

WP 5.3 compatibility: Fix the parameters passed to add_submenu_page() #14315

afercia opened this issue Jan 30, 2020 · 0 comments
Labels
severity: minor Yoast: Management Issues about options and management of the plugin

Comments

@afercia
Copy link
Contributor

afercia commented Jan 30, 2020

  • I've read and understood the contribution guidelines.
  • I've searched for any related issues and avoided creating a duplicate issue.

Please give us a description of what happened.

Noticed while investigating on #14196

WordPress 5.3 added a $position argument to all these functions:

add_submenu_page()
add_management_page()
add_options_page()
add_theme_page()
add_plugins_page()
add_users_page()
add_dashboard_page()
add_posts_page()
add_media_page()
add_links_page()
add_pages_page()
add_comments_page()

See related WordPress Trac changeset and ticket:
https://core.trac.wordpress.org/changeset/46197
https://core.trac.wordpress.org/ticket/39776

Yoast SEO uses its own methods for the admin menu but in the end it uses add_submenu_page().

$position is now the add_submenu_page() 7th argument. and this is incompatible with the way
the function is used in Yoast SEO, where a 7th parameter isn't actually passed but it's used for a "hook callback". See for example WPSEO_Base_Menu->register_submenu_page() and WPSEO_Base_Menu->get_submenu_page().

protected function register_submenu_page( $submenu_page ) {
$page_title = $submenu_page[2];
// We cannot use $submenu_page[1] because add-ons define that, so hard-code this value.
if ( $submenu_page[4] === 'wpseo_licenses' ) {
$page_title = $this->get_license_page_title();
}
$page_title .= ' - Yoast SEO';
// Force the general manage capability to be used.
$submenu_page[3] = $this->get_manage_capability();
// Register submenu page.
$hook_suffix = add_submenu_page(
$submenu_page[0],
$page_title,
$submenu_page[2],
$submenu_page[3],
$submenu_page[4],
$submenu_page[5]
);
// If necessary, add hooks for the submenu page.
if ( isset( $submenu_page[6] ) && ( is_array( $submenu_page[6] ) ) ) {
$this->add_page_hooks( $hook_suffix, $submenu_page[6] );
}
}

See also this comment on the WordPress Trac follow-up ticket
https://core.trac.wordpress.org/ticket/48599#comment:8

@Djennez Djennez added severity: minor Yoast: Management Issues about options and management of the plugin labels Jan 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity: minor Yoast: Management Issues about options and management of the plugin
Projects
None yet
Development

No branches or pull requests

2 participants