0
0
Wordpressframework~10 mins

Admin menu pages in Wordpress - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to add a new admin menu page in WordPress.

Wordpress
<?php
add_action('admin_menu', function() {
    add_menu_page('My Plugin', 'My Plugin', 'manage_options', 'my-plugin', '[1]');
});
Drag options to blanks, or click blank then click option'
Amy_plugin_page
Badmin_page
Cplugin_menu
Dmenu_callback
Attempts:
3 left
💡 Hint
Common Mistakes
Using a string that is not a function name.
Omitting the callback function parameter.
Passing a non-callable value.
2fill in blank
medium

Complete the code to add a submenu page under the existing admin menu.

Wordpress
<?php
add_action('admin_menu', function() {
    add_submenu_page('my-plugin', 'Settings', 'Settings', 'manage_options', '[1]', 'my_plugin_settings_page');
});
Drag options to blanks, or click blank then click option'
Amy-plugin-settings
Bsettings-page
Cplugin-settings
Dmy-plugin-submenu
Attempts:
3 left
💡 Hint
Common Mistakes
Using the parent slug instead of a unique submenu slug.
Using spaces in the slug.
Omitting the submenu slug.
3fill in blank
hard

Fix the error in the code to properly register an admin menu page with a capability check.

Wordpress
<?php
add_action('admin_menu', function() {
    add_menu_page('Dashboard', 'Dashboard', '[1]', 'dashboard', 'dashboard_page');
});
Drag options to blanks, or click blank then click option'
Aedit_posts
Badministrator
Cadmin
Dmanage_options
Attempts:
3 left
💡 Hint
Common Mistakes
Using role names instead of capabilities.
Using invalid capability strings.
Omitting the capability parameter.
4fill in blank
hard

Fill both blanks to add a submenu page with a custom icon and position.

Wordpress
<?php
add_action('admin_menu', function() {
    add_menu_page('Custom Menu', 'Custom Menu', 'manage_options', 'custom-menu', 'custom_menu_page', [1], [2]);
});
Drag options to blanks, or click blank then click option'
Aplugins_url('icon.png', __FILE__)
Bdashicons-admin-generic
C5
D10
Attempts:
3 left
💡 Hint
Common Mistakes
Using icon class name instead of URL for the icon parameter.
Using string instead of number for position.
Swapping icon and position parameters.
5fill in blank
hard

Fill all three blanks to create a submenu page with a dashicon and a callback function.

Wordpress
<?php
add_action('admin_menu', function() {
    add_submenu_page('tools.php', 'Tool Settings', 'Tool Settings', [1], [2], [3]);
});
Drag options to blanks, or click blank then click option'
Amanage_options
Btool-settings
Ctool_settings_page
Dedit_posts
Attempts:
3 left
💡 Hint
Common Mistakes
Using role names instead of capabilities.
Using invalid or duplicate slugs.
Omitting the callback function.