0
0
Wordpressframework~5 mins

Uninstall and cleanup hooks in Wordpress - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
AIn uninstall.php or via register_uninstall_hook()
BIn the main plugin activation function
CInside the plugin's stylesheet
DIn the theme's functions.php file
What happens if you only use the deactivation hook for cleanup?
ANothing happens on deactivation
BData is removed only when plugin is deleted
CData is removed when plugin is turned off, which may be unwanted
DPlugin automatically reactivates
Which function registers an uninstall hook in WordPress?
Aadd_filter('cleanup')
Bregister_uninstall_hook()
Cregister_deactivation_hook()
Dadd_action('uninstall')
What kind of plugin data should NOT be left behind after uninstall?
ATheme files
BPlugin images used by other plugins
CWordPress core files
DOptions, custom tables, user meta
If a plugin does not have an uninstall hook, what happens when it is deleted?
APlugin files are deleted but data remains in the database
BPlugin files and data are fully removed
CPlugin cannot be deleted
DWordPress crashes
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.