Deactivate Plugin on Theme Switch

I haven’t tested this, so it might not work correctly, but the essence of what you’re trying to do is hook into the after_switch_theme hook and see if the $old_name is DahTheme. If it is, that means that the current theme isn’t DahTheme, so you want to deactivate the plugin. function wpse_after_switch_theme( $old_name, $old_theme ) … Read more

How to automate wordpress plugin activate and deactivate by php logic?

Method 1 You can use activate_plugin() and deactivate_plugins() to activate/deactivate plugins programmatically. If you want to control the time at which those actions happen, then you can use wp_schedule_event() too. Method 2 I know you asked about PHP, but if you have WP-CLI installed on your server, you can also write a script that uses … Read more

Can a plugin deactivate itself?

As far as I know, a plugin can be deactivated in these conditions: manual deactivation failed plugin upgrade remove or rename the containing folder changing the active plugin list in the database Hopefully someone else will come through and add to this if I missed any.

Show a confirmation message on plugin deactivation

I have implemented a workaround with JavaScript. I’m loading my own JavaScript file: wp_enqueue_script(‘wp-deactivation-message’, plugins_url(‘js/message.js’, dirname(__FILE__)), array()); which contains a script that adds following Event Listener – when user clicks on our plugin deactivate button it prevent it from performing this action and display a JavaScript popup asking what you need, if user accepts it … Read more

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

Here’s my bare-bones template that I use when creating a plugin with OOP. Feel free to modify to your liking. Template if ( !defined( ‘ABSPATH’ ) ) exit; // Exit if accessed directly if ( !class_exists( ‘MyPluginName’ ) ) { class MyPluginName { public function __construct() { // Call your actions/filters here add_action( ‘tag’, array( … Read more

Displaying a message when plug-in is deactivated

Actually, there’s a better way. All of my plugins require PHP5. Until recently, that wasn’t a requirement in WordPress, so a lot of people tried to install my plugins on systems missing vital PHP functions. I added some checks to my plugin to make sure it would work and, if not, display a message. But … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)