What @Sumit says in the comments (and you found out for yourself) is correct. If you deactivate a plugin in a theme it is deactivated permanently, until it is activated again.
Also, if you attach your deactivation action to wp_head
it is executed at every pageload, which is not necessary. What you need to do is deactivate the plugin when the theme is activated, and reactivate the plugin when another theme is activated. There are action hooks for this: after_switch_theme
on activation and switch_theme
on deactivation. So you would have:
add_action('after_switch_theme','disable_plugins');
add_action('switch_theme','enable_plugins');
You already have the disable_plugins
function, the other one you’ll need to write yourself.
Related Posts:
- Deactivate Plugin on Theme Switch
- OOP: Display warning and deactivate the plugin if PHP version is less than 5.4
- add_action in functions.php, do_action in plugin?
- Plugin Deactivate Self on Activation Errors
- Prevent a plugin from being automatically activated
- Hooking in to replace the Sidebar/Widget areas
- How to get menu location in wp_update_nav_menu hook
- How to deactivate my plugin upon deactivation of NextGen
- Hooking into the HTML header container
- Is it possible to disable a theme programmatically?
- wp_login_form() ignoring login_form action hook
- When/where would want to attach other classes to the base class in a WordPress plugin?
- Genesis Child Theme – Customize body
- Link custom post type to page
- How can I disable W3 Total Cache Image Lazy Load for Specific Post Type?
- How to disable a widget area of a specific page?
- Securing langugae folder
- when i activate my WordPress plugin cannot see customizer options or preview
- Writing SEO for Homepage when homepage is set to display latest posts
- Plugin function in child theme
- How to prevent redoing get_posts queries and make results available to other scripts?
- Fatal error: Class ‘RDTheme’ not found
- Edit plugin’s HTML output with Hooks
- Use action, filter, or hook to append HTML to WordPress plugin function
- Showing different js file for different theme in wordpress customizer api
- Display Woocommerce attribute name above product title
- Passing function into add_action always returns the first argument
- Unable to activate themes on localhost
- Unset plugins on front-end belonging to specific category
- Hook to display element as product on category page
- How to roll back WordPress version or prevent migration from forcing update?
- Multisite converted to Single Site can’t add new plugins or new themes
- Getting unknown text in footer of email
- How to fix blog article view and share #’s?
- Google trying to index child theme files
- Seeking specific WordPress Layout
- WordPress panel is not loading after plugin activated with error: HTTP ERROR 500
- Description: Too much time has passed without sending any data for document
- When the user entered an unauthorized url redirect to login page
- {status}_{post_type} does not run correctly?
- Customize plugin templates
- how to add navigation icons in specific template?
- wordpress plugin translation not working
- How can I make the search bar in my wordpress site search all of the pages rather than just the blog posts?
- WordPress Boilerplate Plugin doesn’t see callback functions for add_settings_field and add_settings_section
- I want add repository theme folder
- Cron job emails blank
- How to make a website with two types of logins , Sellers and buyers?
- What is the correct entry point for capturing coverage data
- In the WordPress API is there a way to set the width of the post/page container
- Identify if the_post hook is being called from the admin post list
- why my wordpress dont have toolbar like, plugin, themes and other?
- Hook on widget context plugin to add custom context for widget
- Shows warning when enable “wp_gallery_custom_links” plugin with Themify Builder
- how to add custom css at top above all css file for specific url
- How can I add a custom checkbox / radio button on the admin theme options to display a CSS or other?
- Why all my wordpress sites keeps telling me that everything is up to date at /wp-admin/update-core.php?
- How can I save cookies to members
- plugin not hooking to my custom hook
- How to Call Function From Separate WordPress Install on Same Server?
- How to add separator between default and custom panels in WordPress customizer?
- Why can’t I shove an instance of a class into a variable from a do_action hook?
- Add a filter to a method in the parent theme
- Publish check if the edited content has HTML “div”
- How to link file or image from wordpress plugin dir to theme by using themes function.php, is it possible?
- Creating Custom Hook for my plugin
- Speed issues because of CSS & JavaScript
- WordPress Theme/Plugin Install (about FTP Connection)
- Admin page and admin menu. Permissions plugin
- Using activated_plugin to run code
- WordPress core update fails – no issues with plugin updates
- Why the output of an image gallery plugin is not displayed into a page of my custom theme?
- Passing a parameter to filter and action functions
- Run only on plug-in activation instead of wp_head
- WordPress hook source
- How to add the functionality of WordPress needed to be installed to be mandatory while installing themes
- What Are the Advantages of Using an mu-plugin
- How to fix On “An unexpected error occurred” message when I click on Add new theme or plugin?
- How to display post by date written (1974) and not date published (today)?
- Things that saved lose when logout
- Modify a plugin’s content
- Ajax specific template not loading in replacement of index.php
- Images is not showing after migration
- How should I use a plugin function as a hook?
- Woocommerce: deleted single-product.php, everything still works. How is it possible?
- Manually return false for function_exists
- How to `remove_action` from plugin
- Theme styling for plugins
- Incentive theme – Getting ’You do not have sufficient permissions’ while trying to install plugins
- Child Theme Changes Are Not Reflecting In Parent Theme
- Automatic updates of plugins and themes outside of wordpress.org
- pluggable function in theme, to be overridden by plugin
- Plugin hook breaks new WP 4.0 media library grid view?
- Input gets deleted/overwritten after changing to different Admin Menu
- Creating themes using the one Plugin (Toolkit)
- Plugin Hook: Get posts
- What is the process for reimplementing a back up WordPress?
- Notice: Use of undefined constant Redux_TEXT_DOMAIN – assumed ‘Redux_TEXT_DOMAIN’
- Theme specific plugin, how?
- How to install wordpress theme’s plug-ins?