Plugins Flashcards
Q: What is a WordPress plugin?
A: A PHP-based tool that extends the functionality of a WordPress site.
Q: Where are plugins stored in a WordPress installation?
A: In the wp-content/plugins directory.
Q: What is the minimum requirement for a WordPress plugin?
A: A PHP file with a plugin header comment.
Q: How are plugins activated?
A: Via the Plugins menu in the WordPress Admin dashboard.
Q: What happens when a plugin is deactivated?
A: The plugin’s functionality stops, but its data is typically retained.
Q: What is the purpose of the plugin header comment?
A: To define metadata like the plugin name, description, author, and version.
Q: How do you create a plugin header?
/*
Plugin Name: My Plugin
Description: A brief description of the plugin.
Version: 1.0
Author: Your Name
*/
Q: What is the add_action() function used for in a plugin?
A: To attach a function to a specific action hook.
Q: What is the add_filter() function used for in a plugin?
A: To modify the output or behaviour of specific WordPress functionality.
Q: Where should plugin-specific styles and scripts be enqueued?
A: In the wp_enqueue_scripts or admin_enqueue_scripts hooks.
Q: What is the recommended folder structure for a plugin?
my-plugin/
├── my-plugin.php
├── includes/
├── assets/
│ ├── css/
│ └── js/
└── languages/
Q: What is the main plugin file?
A: The PHP file that contains the plugin header and is used to initialise the plugin.
Q: How can you organise reusable functions in a plugin?
A: Place them in a separate file within an includes/ directory.
Q: What is the purpose of the languages/ folder in a plugin?
A: To store translation files for internationalisation.
Q: How do you load translation files in a plugin?
A: Use the load_plugin_textdomain() function.
Q: Why should you use namespacing in plugins?
A: To avoid naming conflicts with other plugins or themes.