0
0
Wordpressframework~10 mins

Why custom plugins solve unique needs 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 define a basic WordPress plugin header.

Wordpress
<?php
/*
Plugin Name: [1]
*/
?>
Drag options to blanks, or click blank then click option'
ATest Plugin
BHello World
CSample Plugin
DMy Custom Plugin
Attempts:
3 left
💡 Hint
Common Mistakes
Leaving the plugin name blank
Using a generic name that conflicts with other plugins
2fill in blank
medium

Complete the code to add a custom shortcode that outputs 'Hello, World!'.

Wordpress
function custom_shortcode() {
    return '[1]';
}
add_shortcode('greet', 'custom_shortcode');
Drag options to blanks, or click blank then click option'
AHello, World!
BWelcome!
CHi there!
DGoodbye!
Attempts:
3 left
💡 Hint
Common Mistakes
Returning a different greeting
Forgetting to return a string
3fill in blank
hard

Fix the error in the code to properly enqueue a custom stylesheet in the plugin.

Wordpress
function enqueue_custom_styles() {
    wp_enqueue_style('[1]', plugin_dir_url(__FILE__) . 'style.css');
}
add_action('wp_enqueue_scripts', 'enqueue_custom_styles');
Drag options to blanks, or click blank then click option'
Astyle.css
Bcustom-style
Cstylesheet
Dmy-style
Attempts:
3 left
💡 Hint
Common Mistakes
Using the filename as the handle
Not using a unique handle
4fill in blank
hard

Fill both blanks to register a custom post type named 'book' with support for title and editor.

Wordpress
function register_book_post_type() {
    register_post_type('book', [
        'labels' => ['name' => 'Books'],
        'public' => true,
        'supports' => [[1], [2]]
    ]);
}
add_action('init', 'register_book_post_type');
Drag options to blanks, or click blank then click option'
A'title'
B'editor'
C'thumbnail'
D'comments'
Attempts:
3 left
💡 Hint
Common Mistakes
Including unsupported features like 'comments' or 'thumbnail' unnecessarily
Forgetting to include 'title' or 'editor'
5fill in blank
hard

Fill all three blanks to create a function that adds a custom admin menu page with the title 'Custom Plugin'.

Wordpress
function add_custom_admin_menu() {
    add_menu_page([1], [2], [3], 'custom-plugin', 'custom_plugin_page');
}
add_action('admin_menu', 'add_custom_admin_menu');
Drag options to blanks, or click blank then click option'
A'Custom Plugin'
B'manage_options'
C'Custom Plugin Title'
D'administrator'
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect capability strings
Mixing up page title and menu title