This Notice can be triggered by several variations/wrappers of the function add_submenu_page
.
as of WP v5.8
- add_plugins_page
- add_users_page
- add_dashboard_page
- add_posts_page
- add_media_page
- add_links_page
- add_pages_page
- add_comments_page
- add_management_page
- add_options_page
- add_theme_page
To narrow the scope looking for the right function, we can modify the core file ./wp-admin/includes/plugin.php
( around line 1420 ) to be more verbose about it.
_doing_it_wrong(
__FUNCTION__,
sprintf(
/* translators: %s: add_submenu_page() */
__( 'The seventh parameter passed to %s should be an integer representing menu position. %s' ),
'<code>add_submenu_page()</code>',
print_r( $new_sub_menu, true )
),
'5.3.0'
);
In my case the offending function was add_dashboard_page
add_dashboard_page(
'Link Builder',
'Link Builder',
'manage_options',
'mytheme-woocommerce-helper',
array( $this, 'mytheme_woocommerce_helper_create_admin_page' ),
'dashicons-admin-generic',
2
);
Notice before edit core file:
PHP Notice: add_submenu_page was called <strong>incorrectly</strong>.
The seventh parameter passed to <code>add_submenu_page()</code>
should be an integer representing menu position.
Please see <a href="https://wordpress.org/support/article/debugging-in-wordpress/">Debugging in WordPress</a> for more information.
(This message was added in version 5.3.0.) in wp-includes/functions.php on line 5535
Notice after edit core file:
PHP Notice: add_submenu_page was called <strong>incorrectly</strong>.
The seventh parameter passed to <code>add_submenu_page()</code>
should be an integer representing menu position.
Array
(
[0] => Link Builder
[1] => manage_options
[2] => mytheme-woocommerce-helper
[3] => Link Builder
)
warning/disclaimer/notes
Do this edit only in a development instance. WP core updates or upgrades will revert the changes. Plugins like wordfence will emit a warning and maybe revert the changes.