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 to include PHP files in plugins the correct way
- How can you check if you are in a particular page in the WP Admin section? For example how can I check if I am in the Users > Your Profile page?
- How do I create a custom role capability?
- Why does WordPress add 0 (zero) to an Ajax response?
- Passing arguments to a admin menu page callback?
- function deactivate_plugins does not exist
- Prevent network activation of plugin
- Uninstall script for a plugin in Multisite
- 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
- Understanding WordPress functions’ naming conventions
- Using OOP plugin’s methods throughout the website
- 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
- Error getting correct blog_id on MU from functions.php
- How do I make specific plugin functionality apply to different sites in a network?
- How can I change the frequency of a scheduled event?
- WordPress plugin how to run function when button is clicked
- When is it appropriate to put functions on page template vs. functions.php?
- WordPress multisite apply different options over each site from same plugin
- Shortcodes, output buffering, and WordPress functions
- How can i list current author’s categories?
- Determine which theme location a wp_get_nav_menu_items is for
- 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
- Deletion of shared options using uninstall.php
- Checking for existence of a page by title?
- Multisite, sharing content by URL
- Only allow plugin to be activated on root site of multisite
- Dynamically Override Fancy Title
- Problems with removing admin bar
- How to use wp_set_password in a plugin?
- Problem with `wp_mail()`
- What should happen when a WordPress Plugin is activated across the network (Network Wide Activation)
- Remove unwanted elements for a wp_nav_menu
- Multiple Plugin best practice in Multisite
- How to call plugin function per site in a multisite?
- How do I update a field of a meta box?
- How to add user details to different tables immediately after user registration
- Plugin development: delete options when updating to a new version
- mysql_real_escape_string() vs. esc_sql() in WordPress
- Selectively update themes in WordPress multisite
- WordPress function get_the_terms() returns ‘Invalid taxonomy’ error
- How to remove plugin-specific custom taxonomy terms when plugin is uninstalled?
- 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]
- How to modify files inside wp-includes directory in wordpress
- WP Multisite login not working on one subsite. Possibly cookies/ history issue?
- Fatal error: Call to a member function get_page_permastruct() on a non-object
- wp_get_post_terms Order by not working
- Function/Class to list categories with checkboxes
- register_activation_hook on multisite
- wp_get_theme Warning: Illegal offset type
- Why wp_die() doesn’t work with wp_redirect but exit() works
- 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
- Apply styles to blockquote element with the WYSIWYG editor
- Call to undefined function is_home() or any conditional tags
- WP: Search and replace in DB programmatically
- unregister_setting() vs delete_option() for plugin update
- How to change WooCommerce loop product title HTML output in single product page and archive page
- How to output functions from plugin inside theme
- wp_schedule_event is registered but function isn’t running
- How to get current logged-in user details in multisite?
- add_action wp_ajax_ not loading in plugin file WP Network
- Overwriting a plugin function
- Writing editor content to a file
- 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
- Remove Permalink Meta Box not working?
- Adding tables to dashboard pages programmatically?
- 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
- Modify code for functions.php with specific twitter user url and hashtags
- can’t access some WordPress function from my plugin
- WP 3-way voting system: On to something! Please help!
- Custom Settings Plugin Save foreach checkboxes
- Customise Grouped Product display in Woocommerce with custom column
- Change the behaviour of a button
- Can someone explain what’s the use of parse request function in WordPress?
- Add default value from selection
- function add custom fields to media gallery
- Override category archive page title (not the head title)
- 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