Recall & Review
beginner
What is the purpose of the uninstall hook in WordPress plugins?
The uninstall hook is used to clean up all plugin data like options, custom tables, and settings when the plugin is deleted, ensuring no leftover data remains.
Click to reveal answer
beginner
Which file should contain the uninstall hook code in a WordPress plugin?
The uninstall hook code should be placed in an uninstall.php file or handled via register_uninstall_hook() in the main plugin file.
Click to reveal answer
intermediate
How do you register an uninstall hook in a WordPress plugin?
Use register_uninstall_hook(__FILE__, 'function_name') in the main plugin file to specify the cleanup function to run on uninstall.
Click to reveal answer
intermediate
Why should you avoid using deactivation hooks for cleanup tasks?
Deactivation hooks run when a plugin is turned off but not deleted, so cleanup here could remove data users want to keep. Cleanup belongs in uninstall hooks.
Click to reveal answer
beginner
What kind of data should you remove in the uninstall hook?
Remove all plugin-created options, custom database tables, user meta, and files that are no longer needed to keep the site clean.
Click to reveal answer
Where should you place the uninstall cleanup code in a WordPress plugin?
✗ Incorrect
Uninstall cleanup code belongs in uninstall.php or registered with register_uninstall_hook() to run only when the plugin is deleted.
What happens if you only use the deactivation hook for cleanup?
✗ Incorrect
Deactivation hook runs when plugin is turned off, so removing data here can cause loss if user just wants to pause the plugin.
Which function registers an uninstall hook in WordPress?
✗ Incorrect
register_uninstall_hook() is the correct function to register a cleanup function for plugin uninstall.
What kind of plugin data should NOT be left behind after uninstall?
✗ Incorrect
Plugin-specific data like options and custom tables should be removed to avoid cluttering the database.
If a plugin does not have an uninstall hook, what happens when it is deleted?
✗ Incorrect
Without an uninstall hook, only plugin files are deleted; data like options remain in the database.
Explain how to properly clean up plugin data when uninstalling a WordPress plugin.
Think about what happens when a plugin is deleted and how to remove all traces.
You got /4 concepts.
Describe the difference between deactivation and uninstall hooks in WordPress plugins.
Consider when each hook runs and what should happen to plugin data.
You got /4 concepts.