uninstall.php does not appear to trigger when uninstalling my plugin

i am new to plugin development in wordpress and i have have this simple test plugin that i am working on. The problem i am having is that the uninstall.php file does not appear to get trigger and as such the database entried i wish to remove remain after the plugin in uninstalled from the WordPress admin. Plugin code: defined( 'ABSPATH' ) or die( 'Looks like you made a wrong turn there buddy' ); class TestPlugin { function __construct() { …
Category: Web

How to remove plugin-specific custom taxonomy terms when plugin is uninstalled?

I'm trying to write a class that would allow for easy removal of all plugin-related data when the plugin is uninstalled. Specifically, I want it to remove plugin options, custom post type entries, and custom taxonomies and their terms. What I have written mostly works, but the get_terms function returns an 'invalid_taxonomy' error. Looking into it further, I found that the global $wp_taxonomies does not recognize the custom taxonomies created by the plugin during the uninstall.php process. So my question …
Category: Web

How can I completely disable a WordPress installation?

I would like to completely disable a Wordpress website. I'd like it to be completely inaccessible to visitors, and have no activity taking place on the server (no updates, cron jobs, etc.) I'd like to do this in a non-destructive manner, so that I can access the files if I need to (via FTP), or even re-enable the site at a future date. In other words, "put it in mothballs." I've tried searching but only come up with "maintenance mode" …
Category: Web

delete widget upon uninstall

I developped a plugin that makes use of the widgets. It is compatible with both pre-5.8 WordPress widgets (legacy widgets) and the new block editor widgets. The widgets of my plugin do nothing but adding shortcodes. I was wondering if there is a way to delete widgets upon uninstall? I use an uninstall.php file to clean the user's WP, and would like to also remove the widgets upon uninstall. There is no valid reason for the user to keep them …
Category: Web

Bulk uninstall applications

I like to try out lots of apps. Often a site like Lifehacker or Droidlife will feature several that are similar in functionality and I will install them all in order to compare features. That leaves me with lots and lots of applications that I end up not wanting to keep. Unfortunately, I can only uninstall one at a time. Is there an app or method that would allow me to uninstall a bunch at a time?
Category: Android

How Do I Uninstall a Current WordPress Theme and Install a Fresh Theme

I own a site called explainz.com. The current theme is all messed up. I am considering installing a new theme. How do I actually go about it? Would it be sufficient if I just uninstalled the existing theme and installed the new theme from my dashboard? Is there anything else I need to do so that there are no previous theme remnants. By the way, I would be individually uninstalling certain plugins as well. Thanks!!
Category: Web

How can I delete options with register_uninstall_hook?

Right now, I have this code: function mr_np_activate(){ // hook uninstall if ( function_exists('register_uninstall_hook') ) register_uninstall_hook(__FILE__,'mr_np_uninstall'); } register_activation_hook(__FILE__,'mr_np_activate'); /** * Delete options * **/ function mr_np_uninstall() { delete_option('my_plugins_options'); } But when I remove my plugin, all my options are there. (I made another plugin just to show my options). How can I delete options when plugin is removed?
Category: Web

How to delete custom taxonomy terms in plugin's uninstall.php?

I am writing my plugin's uninstall.php file and would like it to delete any terms that were created in the plugin's custom taxonomy. In the plugin's uninstall.php file I am using this: // Delete all custom terms for this taxonomy $terms = get_terms('custom_taxonomy'); foreach ($terms as $term) { wp_delete_term( $term->ID, 'custom_taxonomy' ); } The problem seems to be that the custom taxonomy isn't registered at this point, so get_terms returns an error for "invalid taxonomy", thus I can't delete the …
Category: Web

Scripts don't enqueue after removing plugin

Using the Ultimate Member plugin. My custom scripts are loading in my child-theme as follows: function some_theme_enqueue_styles() { wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' ); wp_enqueue_script('my-scripts', get_stylesheet_directory_uri() . '/js/my-s.js', array(), '', true); } add_action( 'wp_enqueue_scripts', 'some_theme_enqueue_styles' ); I'm trying to remove this plugin, but after deactivating it, my custom scripts stop loading (not CSS, just JS files). Been Googling for a while and can't seem to find an answer. Any idea?
Category: Web

UnInstallation of a Plugin from a developers perspective - The correct and clean method

I think a good developer should provide the uninstallation in the safest and cleanest possible way. I downloaded various plugins today to understand the process, but everything was very confusing. I found that many plugins are using both uninstall.php files and register_uninstall_hook(__FILE__, 'pluginprefix_function_to_run'); Is it correct? because the link that I have provided above says that these two are two different methods. so what is correct using either registration hook or uninstall.php or both?
Category: Web

How to remove traces from widget during uninstallation

I have a small plugin, which registers a custom widget and now I am wondering how to remove all traces of this widget when the plugin is removed through the administration. If I look in the database after removal of the plugin, I can still see traces of the widget in the wp_options table: +-----------+----------------------------+--------------------------------+----------+ | option_id | option_name | option_value | autoload | +-----------+----------------------------+--------------------------------+----------+ | 158 | widget_my_plugin_widget | a:1:{s:12:"_multiwidget";i:1;} | yes | +-----------+----------------------------+--------------------------------+----------+ +-----------+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------+ | option_id | option_name …
Category: Web

check_admin_referer fails on new AJAX plugin uninstall with "Are you sure you want to do this?"

Before WordPress core had AJAX plugin actions, uninstallation in register_uninstall_hook() worked fine: if ( ! current_user_can( 'activate_plugins' ) ) return; check_admin_referer( 'bulk-plugins' ); It needs a real HTTP/POST, so if you you disable JavaScript in your browser on WP 4.9 it works. But it fails with AJAX plugin uninstallation with Are you sure you want to do this? I'd like to keep up strong security. What is the solution? What is the AJAX counterpart of check_admin_referer( 'bulk-plugins' ) in plugin …
Category: Web

plugin uninstall function drop the tables, but shows errors on admin

I'm new in Wordpress and I have a function that drop the tables of my plugin on DB. <?php if (! defined('WP_UNINSTALL_PLUGIN')) { exit; } // Uninstallation actions here global $wpdb; $table_names = [ $wpdb->prefix . "questions", $wpdb->prefix . "difficulties", $wpdb->prefix . "modalities", $wpdb->prefix . "fields", $wpdb->prefix . "themes", $wpdb->prefix . "subjects", $wpdb->prefix . "disciplines", $wpdb->prefix . "training_areas", $wpdb->prefix . "levels", $wpdb->prefix . "roles", $wpdb->prefix . "banks", ]; foreach ($table_names as $table_name) { $wpdb->query("DROP TABLE IF EXISTS $table_name"); } But …
Category: Web

Plugin could not be deleted due to an error: Could not fully remove the plugin(s) my-plugin/my-plugin.php

Why uninstalling the following (empty) plugin results in error? Here is my-plugin/my-plugin.php: <?php /* Plugin Name: My Plugin */ and my-plugin/uninstall.php: <?php When I click 'Delete' and then confirm, I get the following error: Plugin could not be deleted due to an error: Could not fully remove the plugin(s) my-plugin/my-plugin.php. What's wrong here? ~/Sites/wordpress/wp-content/plugins/my-plugin $ ls -ll total 16 -rwxrwxrwx@ 1 me staff 34 13 Aug 21:43 my-plugin.php -rwxrwxrwx@ 1 me staff 6 13 Aug 21:44 uninstall.php
Category: Web

Where could I see uninstallation directives for a plugin?

Where could I see uninstallation directives for a plugin? I have a plugin named "Wordfence" I want to remove. I need to remove it manually due to what might be a bug in the plugin. How Could I see what files and tables (or data inside tables) the uninstallation process deletes? I mean, generally in Wordpress, under what php file, plugins usually have their installation directives? Thanks,
Category: Web

One of my plugins broke when I tried to update it, how do I safely uninstall it?

I recently tried to update Yoast SEO to its most recent release (4.3). My site is running the most recent version of WordPress (4.7.2). When I tried to install it, it gave me some error having to do with files, and I can't find the error message anymore. Yoast ceased to be displayed as a plugin installed on the server (not listed under active or inactive either). I tried to re-install it, but it threw an error along the lines …
Category: Web

uninstall a theme programmaticlly

I'm working on a plugin that create, install, switch between child themes. But I have a problem that my plugin creates just 2 or 3 child themes ( Is there any limit in creating child themes?). So I'm looking for a way to delete a child theme programmatically by codes before throwing my function that create the other theme. Thank you.
Category: Web

Plugin retrieving results even after uninstallation

I'm using the WP REST API plugin to get info from my website. I built a little plugin that uses this one. In my plugin I'm just removing some fields from the responses that I don't need. Everything was working well until some hours ago the filter by category I was applying when requesting the categories stopped working. It started retrieving all posts. I tried on an HTTP Request tool (POSTMAN) invoking the WP REST API and it doesn't filter …
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.