Articles of deactivation

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

Is it possible to build logic to control the activation and deactivation of specific wordpress plugins , for example Activation/Deactivation triggered by time period? thanks for knowledge sharing.

Reset Roles (or undo role changes on theme change)

I am creating a theme that deletes some user roles that are not necessary and creates others. (It deletes author and contributor and renames subscriber). Everything works, but on theme deactivation, I want to readd all the roles I deleted. Do I have to manually go in and create the roles (author and contributor), manually […]

how to deactivate a plugin without using a WP function?

I wish to deactivate my plugin, but WITHOUT using update_option() or any other core WP function. What’s the best way to go about this? Direct DB connection and modification?

Show a confirmation message on plugin deactivation

When my plugin is deactivated, I want to get a confirmation from the user whether all plugin options/tables need to be deleted or left as it is. Based on the option selected, I want to proceed further. Is it possible ? If yes, how ?

Remove Action from Plugin within extended class and no assigned variable

I have tried so many solutions for this but I can’t figure it out. Here is a simplified version of the plugin code: class YITH_Vendors_Frontend_Premium extends YITH_Vendors_Frontend { public function __construct() { add_action( ‘woocommerce_register_form’, array( $this, ‘register_form’ ) ); } So I want to remove this action from my child themes function.php. The problem is […]

disable active plugins for specific theme

I want to disable some plugins from a specific theme.I am using deactivate_plugins hook to deactivate. following is my code. add_action(‘wp_head’,’disable_plugins’); function disable_plugins(){ include_once(ABSPATH.’wp-admin/includes/plugin.php’); $current_theme = wp_get_theme(); $current_theme_name = $current_theme->Name; if($current_theme_name == ‘Twenty Sixteen’){ if ( is_plugin_active(‘press-release/init.php’) ) { deactivate_plugins(‘press-release/init.php’); } } } This code deactivate plugins at wp_head hook but issue is I want […]

Why my Plugin keeps deactivating automatically?

I have a plugin called ‘virtual theme’ which I downloaded from the plugin directory, and it works great but i noticed sometimes when there’s a change it with other plugins it seems to stop working and shows a page not found. Going to the plugin page it still shows like its active. So what i […]

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 […]