You just need to obtain the basename of any plugin to deactivate it.
if( $uninstall == true ) {
delete_option( 'CHANGETHIS' );
deactivate_plugins( plugin_basename( __FILE__ ) );
}
Generally they look like mypluginfolder/mypluginmasterfile.php
Give that a shot.
There are a variety of ways to getting it to work.
If you want a button on the options page to call that, you could just POST to the options page and check to see if the uninstall button was clicked.
Something like:
$uninstall = isset( $_POST[ 'uninstall' ] ) ? true : false;
Related Posts:
- WordPress multisite,use same cookies across all website?
- How do I create a custom role capability?
- function deactivate_plugins does not exist
- register_uninstall_hook() vs uninstall.php – which one is better way to handle plugin uninstallation script?
- Changing Plugin Load Order
- What is an alternative method to the WordPress private _doing_it_wrong() function
- 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
- function triggered by “manage_users_custom_column” filter not working
- How do I make specific plugin functionality apply to different sites in a network?
- WordPress plugin how to run function when button is clicked
- WordPress multisite apply different options over each site from same plugin
- Shortcodes, output buffering, and WordPress functions
- How does uninstalling WordPress plugins work?
- When to check if a function exists
- Filters ‘request’ and ‘parse_query’ not firing in sites.php nor link-manager.php
- Only allow plugin to be activated on root site of multisite
- Dynamically Override Fancy Title
- Problem with `wp_mail()`
- WordPress Media mime type filter problem 4.0
- Calling a function from functions.php in custom page/ blog post
- What is the function to get plugin base url in multisite?
- Call to undefined function get_blog_option()
- What is the difference between current_page_parent and current_page_ancestor?
- Plugin development: is adding empty index.php files necessary?
- 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
- Sharing a common set of image files for media library, across all sites within multisite
- How can I add a CSS rule to edit.php?
- Widget update function not saving values
- How to set “Site Address (URL)” programmatically on WP multisite?
- $content variable – Is this a reserved variable for a WordPress function? – php / wordpress
- How to use WP_Term with (menu) argument in the wp_nav_menu?
- WordPress after content Hook & external template part
- How to add class in plugin only for network site?
- override pluggable.php functions
- How to associate an existing user to a site in a multisite setup programmatically
- creating custom function to log actions in plugin
- add_rewrite_rule works in themes function php but when moved into plugin it stops working
- Maximum lifetime for nonce
- Where can i find wordpress auto update code flows?
- Adding option to Gallery shortcode
- Plugin menu addition in multisite
- mysql_real_escape_string() vs. esc_sql() in WordPress
- WordPress function get_the_terms() returns ‘Invalid taxonomy’ error
- Problem with context in multisite – getting main site data in every blog (get_pages())
- Checking for existence of a page by title?
- how to get context information inside my funcion
- WordPress class, using add_action to call member function does not work
- how to invoke wordpress API from other existing PHP system
- Redirect to another page using contact form 7? [closed]
- WP Multisite login not working on one subsite. Possibly cookies/ history issue?
- Function/Class to list categories with checkboxes
- Warning: call_user_func_array() expects parameter 1 to be a valid callback
- Print Dashboard submenu name and filename
- Autogenerate a Table of Contents
- Alternative functions for mysql_free_result and mysql_ping in wordpress functions
- Call to undefined function is_home() or any conditional tags
- unregister_setting() vs delete_option() for plugin update
- How to change WooCommerce loop product title HTML output in single product page and archive page
- wp_schedule_event is registered but function isn’t running
- 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?
- How to edit wp-signup.php content using plugin
- Remove Permalink Meta Box not working?
- Setting post_id for single.php based on URL without a redirect
- using admin functions on frontend
- Javascript Function Called Too Early in PHP Script
- WP 3-way voting system: On to something! Please help!
- Custom Settings Plugin Save foreach checkboxes
- Change the behaviour of a button
- function add custom fields to media gallery
- Make visible page only in the trash
- Redirection from a specific page for users logged in but not with membership
- WordPress: I wanted to use Add rewrite rule multiple times for multiple CPT in my plugin
- WordPress Ajax not returning Response
- How do I ensure I can loop through every enqueued script and CSS?
- Remove tag from all posts when publishing new post
- Custom Plugin activation error in Multisite
- Replace “content-area” of themes 404 page with plugin?
- wp_ajax add_action fuction won’t fire on custom jQuery action
- foreach argument to get specific file types getting too many returns
- Remove from a div by class name from post page if post author role is not administrator
- Building WordPress Themes With Bootstrap with Adi Purdila → TutsPlus
- Same header/footer in Admin, across all network sites in multisite
- Ajax not working to insert, query and result data
- Template file structure , wordpress hook for altering the template
- WordPress permalink setting
- How can I see a varibles value when my plugin runs?
- How can I add recent posts to menu like mashable
- Why is ‘register_activation_hook’ undefined?
- Dynamic banner for use on external sites
- Custom options page for themes
- Call do_action() within WordPress cronjob
- How to plugin function code move to theme function.php ? I’ve tried below code but not working [closed]
- WordPress simple ‘Hello World’ plugin – problems