Searching inside all uninstall.php
files that I have in my hard-drive, I’ve found two that had the function is_multisite()
: User Role Editor and Add Code to Head.
Both use a $wpdb
loop. Simplified:
<?php
/**
* Plugin Uninstall Procedure
*/
// Make sure that we are uninstalling
if ( !defined( 'WP_UNINSTALL_PLUGIN' ) )
exit();
// Leave no trail
$option_name="plugin_option_name";
if ( !is_multisite() )
{
delete_option( $option_name );
}
else
{
global $wpdb;
$blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
$original_blog_id = get_current_blog_id();
foreach ( $blog_ids as $blog_id )
{
switch_to_blog( $blog_id );
delete_option( $option_name );
// OR
// delete_site_option( $option_name );
}
switch_to_blog( $original_blog_id );
}
Related Q&A: Uninstall, Activate, Deactivate a plugin: typical features & how-to
Related Posts:
- How do I create a custom role capability?
- Prevent network activation of plugin
- Changing Plugin Load Order
- What is wrong with using add_option with Multisite instead of add_blog_option in a plugin
- How to Get a List of Sub Blogs without Using get_blog_list()?
- Cron firing my function everytime wp-admin is visited
- Error getting correct blog_id on MU from functions.php
- How do I make specific plugin functionality apply to different sites in a network?
- WordPress multisite apply different options over each site from same plugin
- Filters ‘request’ and ‘parse_query’ not firing in sites.php nor link-manager.php
- Multisite, sharing content by URL
- Only allow plugin to be activated on root site of multisite
- How to use wp_set_password in a plugin?
- WordPress Media mime type filter problem 4.0
- What is the best way to overwrite /wp-admin/ms-delete-site.php
- Where should I store global data for my multi-site WordPress plugin?
- unable to stop loop when using wp_insert_post with publish_post hook
- Customize multisite site creation with user data
- Multisite plugin development and wp_enqueue_script
- Plugin Uninstall and Deactivate via Options Menu
- how to activate plugin network-wide, and save setting across sites
- Sharing a common set of image files for media library, across all sites within multisite
- What is difference between blog id and site id?
- How to create a Tools menu on the Network Admin dashboard from a plugin
- Override the default Add/Edit site forms of the Network Panel in custom plugin
- How to set “Site Address (URL)” programmatically on WP multisite?
- How to associate an existing user to a site in a multisite setup programmatically
- WordPress Multisite with Azure B2C redirect_urls after Login
- How To Change Post Author Default?
- Adding (blog-specific) links to “My Sites” admin page
- Plugin menu addition in multisite
- What should happen when a WordPress Plugin is activated across the network (Network Wide Activation)
- Multiple Plugin best practice in Multisite
- Selectively update themes in WordPress multisite
- Problem with context in multisite – getting main site data in every blog (get_pages())
- how to invoke wordpress API from other existing PHP system
- WP Multisite login not working on one subsite. Possibly cookies/ history issue?
- register_activation_hook on multisite
- WordPress multisite,use same cookies across all website?
- WP: Search and replace in DB programmatically
- How to get current logged-in user details in multisite?
- add_action wp_ajax_ not loading in plugin file WP Network
- Clean way to initialize plugin in newly-added site when plugin has been network activated?
- How to share user data across multiple WordPress websites?
- Is there anything special required to make a plugin work in a multisite environment?
- How to edit wp-signup.php content using plugin
- How do I ensure I can loop through every enqueued script and CSS?
- Custom Plugin activation error in Multisite
- Replace “content-area” of themes 404 page with plugin?
- Multisite and the JSON REST API: How to?
- Testing Plugins for Multisite
- Same header/footer in Admin, across all network sites in multisite
- Change Admin menu placement using hooks
- Force remove parent theme CSS/JS and call them from Child theme
- Plugin – create a page without it appearing in the side menu
- API to trigger prompt on leaving page
- Are shortcodes case-sensitive?
- Copy Tags from one post type to another post type
- How to Add Page Template from Plugin without Losing $this
- Backslashes being stripped from CSS
- Extending WP_List_Table seems getting wrong with $this->get_columns() – what’s wrong?
- Why doesn’t flush_rewrite_rules run on plugin activation?
- Finding posts containing matching array elements in a meta field usign WP_Query
- Namespaced action and filter tags
- Adding Dropbox dropin js using wp_enqueue_script
- How to add custom fields to the all users page
- Can Page Templates be Applied to Archive and Post Templates?
- WooCommerce Admin Reports : Get custom product report based on date range
- Auto gallery from folder contents
- Is there a plugin that will allow a tag cloud to be created from any mysql field?
- Allow users to add / remove settings in plugin
- Update problem with update_option() in combination with register_setting()
- Why does my widget break other widgets?
- Plugin – Make sure jquery is loaded in my settings page plus my JS file
- Is it possible to enable and disable wp debug from functions.php?
- Default settings aren’t used
- Best way to include and use Zoho SDK in a wordpress plugin
- How to change WooCommerce loop product title HTML output in single product page and archive page
- How remove trashed WooCommerce orders from wc_get_orders() result?
- How to use nonce
- Does WordPress default CSS have Grids?
- How to avoid conflicts with db.php / $wpdb and other plugins that decide to use them?
- Plugin can’t be activated [closed]
- Is there an action_filter hook to add content before the post title?
- CSS not being applied using wp_enqueue_style
- Count products with custom metadata field in an order
- Adding and handling custom settings tab to fusion element
- WordPress Reset password Strength set to medium
- Problem with baseurl and interaction with plugin
- Why setcookie function redirecting to home page in wordpress?
- Should all roles be allowed CRUD operation on the database?
- Associating special meaning with user id 0
- Filter get_user_by instead of replace function
- Downloading Generated XML File
- How to create a custom search form and handler?
- How to use permalink query to go to specific tabs in posts
- Method to retrieve category names and IDs only as an array?
- Send Webhook when post-status is publish or trash
- Using “add_image_size” to register custom image sizes inside plugins not working
- How do I access the contents of WordPress Classic editor in admin area with JavaScript?