0
0
Wordpressframework~10 mins

Why plugins extend functionality in Wordpress - Test Your Understanding

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

Complete the code to activate a plugin in WordPress.

Wordpress
activate_plugin('[1]');
Drag options to blanks, or click blank then click option'
Aplugin-slug/plugin-file.php
Bwp-content/plugins
Cthemes/plugin.php
Dindex.php
Attempts:
3 left
💡 Hint
Common Mistakes
Using the themes folder path instead of plugins.
Using just the folder name without the main plugin file.
2fill in blank
medium

Complete the code to add a plugin's functionality using a WordPress hook.

Wordpress
add_action('init', [1]);
Drag options to blanks, or click blank then click option'
A'admin_menu'
B'my_plugin_function'
C'the_content'
D'wp_head'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a hook name instead of a function name.
Not using quotes around the function name.
3fill in blank
hard

Fix the error in the plugin activation code below by filling the blank.

Wordpress
if ( !function_exists( '[1]' ) ) {
    function my_plugin_function() {
        // plugin code
    }
}
Drag options to blanks, or click blank then click option'
Aadd_action
Bactivate_plugin
Cmy_plugin_function
Dplugin_dir_path
Attempts:
3 left
💡 Hint
Common Mistakes
Using a WordPress function name instead of the plugin function.
Leaving the blank empty.
4fill in blank
hard

Fill both blanks to correctly register a shortcode in a plugin.

Wordpress
add_shortcode('[1]', [2]);
Drag options to blanks, or click blank then click option'
Amy_shortcode
B'my_shortcode_function'
Cinit
Dthe_content
Attempts:
3 left
💡 Hint
Common Mistakes
Using hook names instead of shortcode tag.
Mixing function names with hook names.
5fill in blank
hard

Fill all three blanks to create a plugin that adds a custom menu item in the admin dashboard.

Wordpress
add_action('[1]', '[2]');

function [3]() {
    add_menu_page('Custom Page', 'Custom Menu', 'manage_options', 'custom_slug', 'custom_page_callback');
}
Drag options to blanks, or click blank then click option'
Aadmin_menu
Bregister_custom_menu
Cinit
Dcustom_menu_function
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong hook names like 'init'.
Mismatching function names between hook and definition.