Complete the code to define a basic WordPress plugin header.
<?php
/*
Plugin Name: [1]
*/
?>The plugin header must include a unique name. "My Custom Plugin" clearly identifies the plugin.
Complete the code to add a custom shortcode that outputs 'Hello, World!'.
function custom_shortcode() {
return '[1]';
}
add_shortcode('greet', 'custom_shortcode');The shortcode function should return the exact string 'Hello, World!' as required.
Fix the error in the code to properly enqueue a custom stylesheet in the plugin.
function enqueue_custom_styles() {
wp_enqueue_style('[1]', plugin_dir_url(__FILE__) . 'style.css');
}
add_action('wp_enqueue_scripts', 'enqueue_custom_styles');The handle name for the stylesheet should be a unique identifier like 'custom-style'. Using the filename directly is incorrect.
Fill both blanks to register a custom post type named 'book' with support for title and editor.
function register_book_post_type() {
register_post_type('book', [
'labels' => ['name' => 'Books'],
'public' => true,
'supports' => [[1], [2]]
]);
}
add_action('init', 'register_book_post_type');The 'supports' array should include 'title' and 'editor' to enable those features for the custom post type.
Fill all three blanks to create a function that adds a custom admin menu page with the title 'Custom Plugin'.
function add_custom_admin_menu() {
add_menu_page([1], [2], [3], 'custom-plugin', 'custom_plugin_page');
}
add_action('admin_menu', 'add_custom_admin_menu');The first argument is the page title, the second is the menu title, and the third is the capability required to access the menu, which is 'manage_options'.