This will give you the option to register your unistall hook during plugin activation.
function myplugin_activation_callback(){
register_uninstall_hook( __FILE__, 'myplugin_uninstall_callback' );
}
register_activation_hook( __FILE__, 'myplugin_activation_callback' );
function myplugin_uninstall_callback(){
//Perform your uninstall operations here
delete_option('test_option');
}
However, the simplest way is to use an uninstall.php file with the following codes:
if (!defined('WP_UNINSTALL_PLUGIN')) {
die;
}
//Perform your uninstall operations here
delete_option('test_option');
It’s not recommended to use both at the same time.
Related Posts:
- My WordPress website was hacked [closed]
- add_action in a custom plugin
- Add custom text color WordPress 3.9 TinyMCE 4 Visual editor
- ACF: post query, hide duplicate values [closed]
- AJAX fileupload – TypeError: not a function ajaxSubmit()
- WordPress Jquery UI Spinner
- How to customize a plugin?
- Create a single website with 3 theme options in wordpress
- Updating options into the wp database performance
- Creating author Specific page URL
- I want to know about the plugins that help in while I write code on my Page? [closed]
- Check if user is on backend page
- How to get specific string/value from an array? php [closed]
- React error #231with Custom Blocks after upgrade to WP 5.5
- WordPress super admin login issue. (Automatically logout)
- Background Music WP [closed]
- WordPress failing to update plugins
- Image tooltip enable/disable
- Error trying to update plugins
- Why is it important to check for isset and is_array before checking in_array in this example?
- Upload files to the plugin menu
- I can’t get blog posts into ‘featured areas’ on homepage
- Plugins & backup not working correctly on new Digital Ocean server
- do_action in conditional
- Show WordPress Plugin Menu(Admin) To Editor
- Don’t load the theme for a page FROM a plugin EDITED
- Call another page in forms
- How many MySQL queries per visit I should normally have?
- WordPress Feed Creator Name Tag Full Name Instead Of First Name
- How to force load a page in plugin?
- Attachments broken after giving WordPress its own directory
- Want to modify a Plugin – Tweetily – Can I make it tweet a Custom Field instead of Post Title?
- Multisite Plugin – Access options (wp_options) on child sites
- Chat support plugin? [closed]
- Problem enabling the user to edit Markdown and displaying the HTML output (WMD Editor plugin for WordPress)
- Displaying the facebook profile picture in the WP-FB AutoConnect widget?
- Trigger jQuery to add events after AJAX-loading table in admin plugin
- how does ‘init’ /’parse_request’ hook work for wordpress?
- Service status plugin
- How can I disable an attribute from a Gutenberg block included in a template via InnerBlocks?
- Why the internal link get converted into a comment?
- Remove Zero Money From Previews Order woocommerce
- How to add gallery to post and make seperate album page with gallery link to post?
- Having a problem with rewrite_rules and rewrite_tags – url not rewriting properly and query var missing
- Share login credential with QR code
- Shortcode do not return the right data in post
- Display pagination in reservation Plugin and and Print table as pdf
- Undeletable column in Posts
- Search in WordPress
- Get full URL of WP plugin admin page
- WooCommerce Stripe payment plugin working perfectly in storefront parent theme but not in the child theme
- Performance considerations – postmeta table versus new table for custom posts with foreign keys?
- Content disappears when searching with Search & Filter plugin
- Avoid WordPress header bar when form submission using admin_post in the frontend
- How to fix shifting header after installing speed / cache plugins?
- WordPress website dont load CSS, JS and images
- PHP message: WordPress database error Deadlock found when trying to get lock
- Field salespeople task management
- WordPress Boilerplate Plugin doesn’t see callback functions for add_settings_field and add_settings_section
- Hide ‘add to cart’ button for some products [duplicate]
- Bootstrap carousel – Using shortcode inside enclosing shortcode
- Can’t manage plugins anymore
- ClassLoader.php issues after moving to a new host
- plugins break after moving wp-content folder
- How to populate a Mailchimp newsletter with latest events from WordPress plugin EventOn?
- Options page textarea to populate custom post select field
- Add Flatr button to Sharing option
- Change localization only for plugin
- How to get author developer link on plugin page
- wp_schedule_event need to deactivate plugin changing recurrance
- Cannot access variables within a widget
- Show all posts of all categories but excluding a category on custom blog page with pagination of my theme
- ajax request not returning the result
- adding image in the header of my dev widget
- passing ‘&’ in return function of add_filter
- Is there going to an issue running different features of WP site in different subdomains?
- Session alternative for plugins (due to caching)
- WordPress 3.5 install error
- Is there a plugin that will override the “Error establishing a database connection” message? [closed]
- Add meta tags with a plugin?
- Plugin with custom domain
- How to use ‘Event Manager Shortcodes’ plugin via the php code? [closed]
- Customize Multi-Column Tag Map to fetch specific post-type
- Upload Image to desired directory through plugin
- Fast Tranfering my WordPress site to another server
- woocommerce retriving category name as div class?
- Duplicating wordpress install issue
- Woocommerce add product variations block to my custom template
- Display out of stock products in WooCommerce [closed]
- How to give access to the particular page in wordpress for specific username/email NOT roles [closed]
- How to display content depending on the Woocommerce Product Category
- Ajax button “Load more” is not loading correct language version posts for logged out users
- WordPress REST API Visual Composer Shortcodes
- Plugin that supports the purchase and installation of other plugins?
- No Google Analytics code rendered in the header?
- Redirect OLD/Path to NEWURL/Path
- How can I use the zip of my plugin in another website?
- Executing ACF field as a shortcode
- Cron Job not working
- Create custom Header and Footer for a page that uses diffrent theme then the rest of the website