Complete the code to add a new admin menu page in WordPress.
<?php add_action('admin_menu', function() { add_menu_page('My Plugin', 'My Plugin', 'manage_options', 'my-plugin', '[1]'); });
The last parameter is the callback function that outputs the page content. Here, my_plugin_page is the function name.
Complete the code to add a submenu page under the existing admin menu.
<?php add_action('admin_menu', function() { add_submenu_page('my-plugin', 'Settings', 'Settings', 'manage_options', '[1]', 'my_plugin_settings_page'); });
The fifth parameter is the slug for the submenu page. It should be unique and related to the parent menu slug.
Fix the error in the code to properly register an admin menu page with a capability check.
<?php add_action('admin_menu', function() { add_menu_page('Dashboard', 'Dashboard', '[1]', 'dashboard', 'dashboard_page'); });
The capability parameter must be a valid WordPress capability string like manage_options to control access properly.
Fill both blanks to add a submenu page with a custom icon and position.
<?php add_action('admin_menu', function() { add_menu_page('Custom Menu', 'Custom Menu', 'manage_options', 'custom-menu', 'custom_menu_page', [1], [2]); });
The sixth parameter is the URL to the icon image, and the seventh is the menu position number.
Fill all three blanks to create a submenu page with a dashicon and a callback function.
<?php add_action('admin_menu', function() { add_submenu_page('tools.php', 'Tool Settings', 'Tool Settings', [1], [2], [3]); });
The capability is manage_options, the slug is tool-settings, and the callback function is tool_settings_page.