Disable pluggins only in mobile version
I have set up the child theme, could you give me an example of the function code for one plugin? If I want to deactivate 2 I just put the function two times?
There is 2 that I am considering deactivating: SEO Facebook Comment and ViperBar.Admin
It’s rather difficult (if not impossible) to selectively disable plugins from within a theme. This is because a theme is loaded after all the plugins have been loaded. Therefore, at best you will see the plugin still active on first view of the mobile theme, and then deactivated on subsequent views.
And of course, you will have to activate the plugins again whenever the desktop theme is viewed. Once this happens, the above will repeat again. And it’s very likely that both mobile and desktop view of your site can be viewed at the same time (or at least within very little time difference) by two or more visitors.
A workaround to this limitation is to restart all of WordPress’ loading and processing immediately after the plugins deactivation, but this will reduce performance somewhat as the first round of processing is effectively thrown away to restart again. There is also no telling what effect that will have on caching plugins if you use any.
It’s perhaps better to just hide the output of the plugins by using the mobile theme’s Custom CSS feature.
Prasanna, if you have suggestions on how to make it work, I’m all ears.Admin
Actually, on further testing, it appears that restarting all of WordPress’ loading and processing immediately after plugins deactivation have no performance cost whatsoever (at least on my limited testing condition). It could be that the performance cost induced for restarting the processes is compensated by the performance advantage of not loading and processing the deactivated plugins later on.
I’m not really sure about
deactivate_plugins()function. But one of my friends wanted to remove facebook comments from his mobile site. I just removed the filter and it worked without any compromise in the performance.
remove_filter('comments_array', 'facebook_comments');AdminQuote:I’m not really sure about deactivate_plugins() function. But one of my friends wanted to remove facebook comments from his mobile site. I just removed the filter and it worked without any compromise in the performance.
Yeah, that’s analogous to using Custom CSS to hide the output, but in a cleaner way with performance advantage. But you’ll still have to figure out which filters/actions to remove, and which scripts and stylesheets to dequeue. That can be easy for some plugins, but can also be tedious and difficult for more complex plugins.
deactivate_plugins(), we can effectively list all plugins and let the user tick which one to enable and disable for the mobile theme.
You must be logged in to reply to this topic.