WordPress WordPress Plugin Architecture & Configuration 1 — Questions and Answers
Question 1: What is the minimum required header comment in a WordPress plugin file?
- Plugin Name: (Correct answer)
- Author:
- Version:
- Description:
Correct answer: Plugin Name:
Only 'Plugin Name:' is required in the plugin header comment for WordPress to recognize and list a plugin.
Question 2: Which WordPress function is used to register an activation hook for a plugin?
- register_activation_hook() (Correct answer)
- add_action('activate')
- plugin_activate()
- wp_register_activation()
Correct answer: register_activation_hook()
register_activation_hook() runs a specified callback function when the plugin is activated from the WordPress admin.
Question 3: What WordPress function checks whether a plugin is currently active?
- is_plugin_active() (Correct answer)
- plugin_is_active()
- check_plugin()
- wp_plugin_active()
Correct answer: is_plugin_active()
is_plugin_active() checks if a specific plugin is active by verifying its presence in the active plugins option.
Question 4: Where should plugin option data typically be stored in WordPress?
- The wp_options table using the Options API (Correct answer)
- A custom flat file
- The wp_posts table
- Session variables
Correct answer: The wp_options table using the Options API
WordPress plugins should use the Options API (get_option/update_option) which stores data in the wp_options table.
Question 5: What is a WordPress nonce used for in plugin development?
- Verifying form submissions and protecting against CSRF attacks (Correct answer)
- Encrypting user passwords
- Caching database queries
- Registering post types
Correct answer: Verifying form submissions and protecting against CSRF attacks
Nonces are one-time security tokens used to verify that form submissions and URL requests come from legitimate, authenticated sources.
Question 6: Which WordPress function allows a plugin to add a top-level admin menu page?
- add_menu_page() (Correct answer)
- add_options_page()
- add_dashboard_page()
- register_menu()
Correct answer: add_menu_page()
add_menu_page() creates a new top-level item in the WordPress admin sidebar navigation.
What is the minimum required header comment in a WordPress plugin file?