Articles of deactivation

Plugin Deactivate Self on Activation Errors

Hi I’m wondering if someone can point me in the right direction here. I’m having trouble figuring out how deactivate_plugins() works. I’ve been using variations of the below for awhile now and it’s always seemed to work until recently. register_activation_hook(__FILE__, ‘my_plugin_activate_deactivate’); add_action(‘after_switch_theme’, ‘my_plugin_activate_deactivate’); function my_plugin_activate_deactivate() { if ( !function_exists (‘mythemename’) { deactivate_plugins( plugin_basename(__FILE__) ); } […]

Displaying a message when plug-in is deactivated

I’m using the following code to deactivate my WordPress Plugin if the requirements are not met public function activate() { if (!$this->check_requirements()) { deactivate_plugins(plugin_basename(__FILE__)); wp_redirect(admin_url(‘plugins.php’)); exit; } } The function activate() is called when the plug-in is activated. I want to add a message to the user explaining what happened. Is there a way to […]

Disable WooCommerce action

I’m customizing a WooCommerce theme and am going to be moving the title. There is an action in content-single-product.php called: do_action( ‘woocommerce_single_product_summary’ ); in the woocommerce_hooks.php file the title action is: add_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_title’, 5 ); I can easily comment this out and place the title function where I need to. I’d prefer to disable […]

Can a plugin deactivate itself?

We have a situation where a couple of our longstanding plugins (Google Analytics is one) are currently offering the option to “Activate” them. This figures, because Google Analytics traffic stopped dead a while back. So it seems as if it did turn itself off. Is this possible? Can the plugin’s original author issue an update […]

Do you clean up your self-written plugins' at deactivation?

After developing some plugins for myself, some of them is ready to be published. For all, I’ve written deactivation functions, which deletes the set options, the database, etc. after themselves. But I’m having doubts about the reason for these, for example, what if it’s only a temporary inactivation? What do you think, does a process […]

Deactivate plugin upon deactivation of another plugin

Wondering if its possible to deactivate a plugin in the deactivation code of another plugin? IE. i have a widget that i’m adding via its own plugin that won’t function if the ‘master’ plugin isn’t activated…

Must activation/deactivation functions in a class be static?

The description for register_uninstall_hook‘s $callback parameter states: Must be a static method or function.1 There is no such comment for register_activation_hook or register_deactivation_hook. However, in the Codex entry for register_activation_hook there is an example that reads: Or, because the activation hook requires a static function, if you’re inside of a __construct():2 In a GitHub issue, […]

OOP: Display warning and deactivate the plugin if PHP version is less than 5.4

I want to show a notice to the user and deactivate my plugin, using OOP code style, if the user has a PHP version less than 5.4. The code works fine when I create my plugin using non-OOP. It shows an warning to the user and deactivate the plugin and prevents user from activating the […]

How to Modify/Change a Buddypress/WordPress Account Activation Process

I’m developing a custom BuddyPress/WordPress Plugin. Here’s how a user would normally register. A user registers as usual on registration page His/Her account is deactivated till he/she clicks on activation link in his/her email He/She is sent an activation link through the email he/she registered with He/She activates his account by clicking on the link […]

Uninstall, Activate, Deactivate a plugin: typical features & how-to

I’m making a wordpress plugin. What are typical things I should include in the uninstall feature? For example, should I delete any tables I created in the install function? Do I clean up my option entries? Anything else?