There are various opinions on this, but generally, if you’re “deleting” (as opposed to simply “deactivating”), you don’t necessarily need to confirm it. However, you certainly could.
The general approach to that is to include a setting to remove all settings upon delete or not. Let’s say it’s a checkbox in the plugin’s settings to “delete all” and if it’s not checked, you wont’ clear the options. (Also, in the example, assuming that all settings are a single array, with the settings as keys – but this is just an example)
// if uninstall.php is not called by WordPress, die
if (!defined('WP_UNINSTALL_PLUGIN')) {
die;
}
$option_name="wporg_option";
// $option_name['delete_all'] contains my option setting to delete all settings.
if ( 1 == $option_name['delete_all'] ) {
delete_option($option_name);
// for site options in Multisite
delete_site_option($option_name);
}
Related Posts:
- How to override existing plugin action with new action
- Add custom TinyMCE 4 Button, Usable since WordPress 3.9-beta1
- How to store username and password to API in wordpress option DB?
- Which hook should be used to add an action containing a redirect?
- Is it worth checking if class_exists when developing a plugin and how to do it?
- the_content after all shortcodes are parsed
- Where to enqueue stylesheets for plugin?
- How do I resolve Notice: Undefined offset: 0 in /wp-includes/capabilities.php on line 1145
- Category listing with thumbnail and description on home page
- How can the tinyMCE dom be manipulated (offical API does not seem to work)?
- stray elements
- Deletion of shared options using uninstall.php
- Pass javascript result to shortcode executer function
- URLs of plugin resources?
- anything like add_meta_box for categories?
- Plugin Settings not Saving on Ajax re-ordered table
- Can we create a category list page in WordPress?
- How to include class from addon after to be sure one class exists in the main plugin?
- Developing a plug-in to charge for
- WordPress: After Gutenberg plugin migration to block.json the localization/ translations with PolyGlot in JavaScript does not work anymore
- What is the Difference between directly call a function and call a function using add_action?
- What is better way to use Bootstrap inside admin panel?
- Undefined function wp_set_password
- Updating my plugin without releasing a new version
- How to modify the new WordPress 4.5 link inline toolbar
- Is it possible to check is loaded language files correctly with WordPress plugin?
- Prevent plugin from deleting important directories
- Default category got deleted. How to get it back as ID=1?
- What allows a template file from plugin to be copied in child theme and overridden?
- How to set “Site Address (URL)” programmatically on WP multisite?
- creating custom archive template within plugin for custom post type using archive_template filter
- Advice on plugin structure
- Problem with parameters in url and pagination
- Trying to understand order and frequency of action hooks firing
- Where can i find wordpress auto update code flows?
- Create & Save multiple Meta-boxes
- Are there any scripts, classes, and/or functions built-in to WP for a plugin to export/import its saved data from wp_options?
- How to fetch all images from a WordPress draft using PHP?
- Can’t get woocommerce_get_price_html to work [closed]
- jQuery selectors for editor elements safe to use?
- wp_set_object_terms not updating database without a die()
- WordPress form action – doesn’t work
- How to fetch only current hour posts?
- Fatal error: Uncaught Error: Call to undefined function get_option()
- Strange Situation When Try To Retrieve Github Gist Using wp_remote_get
- template_redirect or admin-ajax.php?
- jQuery does not enqueue for my purpose… (before an inline script in the footer)
- how to get all the child category name in a specified category name?
- Widget HTML Display Problem
- Can I add custom css to an mu-plugin?
- Change WooCommerce Email Header using custom plugin
- How to get the current page Title and Page URL in footer.php
- insert query on a custom table using ajax with jQuery plugin Jeditable
- my own SVN for a plugin/theme
- How to add search form in main page body?
- Activate theme via plugin script?
- How can I add function calls to my plugin’s options.php default submit routine?
- WordPress Rest API with rest_do_request, possible race condition?
- Need help about understand api, wp, $ syntax in WordPress plugin script
- Is it possible to use WP-CLI in a plugin (or theme)?
- Secruity Questions on a timer
- How to rename the plugin PHP file without affecting existent users?
- Add location tag to wordpress posts
- Open tab on current day problem jQuery and WordPress
- Plugin working on my local installation but Cannot be activated online
- Load php file with jquery in single.php
- WordPress Page Reload Takes forever during theme development
- Anyone using unzip_file successfully? It uploads the zip but doesn’t extract it!
- WP 3-way voting system: On to something! Please help!
- Why is the expected file not being deleted?
- How to determine which capability to use?
- How to add some basic inline CSS using existing plugin or theme?
- How does one update complex options?
- How to highlight a page in the page list (Admin Menu)?
- Forbidden Error in ajax call with wordpress
- How to use setAttributes outside of the edit function return
- WP plugin svn checkout 429 error “Too many requests”
- How to prevent wp_insert_post from creating a new post every second?
- Hook for validating and rejecting frontend image upload
- Multisite and the JSON REST API: How to?
- Can’t create a blank template
- Download stopped working in 4.7.4
- $wpdb Mysql trigger problem
- Looping single post in a theme
- WP Ajax on page load not working on bluehost but was working on Godaddy
- Is there a way to tell if a shorcode’s handler is being run before or after the content formatting filter?
- How to create an embedded code for wordpress shortcode?
- WordPress postboxes On Tabbed Views and Hiding Registered Pages
- How can I send an id over the url?
- grouping my widgets wordpress
- Creating custom Insert Media page
- Get fields of a widget
- Yet another wp_insert_post infinite loop. What is wrong?
- Initialize class inside plugin
- “Print to printer” functionality in a plugin
- How do you filter get_media_items by mime type in a custom media upload tab?
- Which subset of html does WordPress support?
- How to set init for maximum script execution, memory limit and max files upload in wordpress
- Trying to build a plugin – Cannot modify header information
- Display months on a drop down calendar as TEXT instead of Numbers