Ecommerce Shopify WordPress Discussion

Disable WordPress plugin per request

Is it possible to get Wordpress to disable a plugin for a single page visit using URL args? For e.g. So far I've tried the following: deactivate_plugins( $disable_pluggins_arr, true, // silent mode (no deactivation hooks fired) false // network wide ); This works hover it's also disabled globally. Same goes for using options_active_plugins hook add_filter( 'option_active_plugins', function( $plugins ){ $plugins = array_diff( $plugins, $disable_pluggins_arr ); return $plugins; }); It disables the plugins but it's stored in the database and visiting any other page will not have them active. How can I temporarily bypass a plugin from loading when using ?disable_plugin=akismet/akismet.php for that request;
Yes it's possible but the corresponding code cannot be written in the functions.php or in an ordinary plugin. You MUST create your own mu-plugin for this. Read more about Must-Use-Plugins here. Your filter hook is ok but you need to define where to fire and where not to fire. Also the wp-admin path should be excluded (the backend). So create a new subfolder mu-plugins under wp-content. Next, take the snippet below and create a file with it (e.g. bypass-plugins.php). Copy the file to /wp-content/mu-plugins/. Finally, adjust the variables $bypass_path and $bypass_plugins to your needs. <?php /** * Plugin Name: Bypass Plugins * Description: Bypass WordPress plugins on a specific page. * Version: 1.0.0 */ # no direct access if ( ! defined( 'ABSPATH' ) ) { header( 'HTTP/1.1 403 Forbidden' ); exit; } # the bypass path $bypass_path = '/some-path/'; # plugins to be bypassed $bypass_plugins = [ 'akismet/akismet.php', 'hello.php' ]; # get url path from request $url_path = parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH ); # check if in the backend $is_backend = strpos( $url_path, '/wp-admin/' ); # check for bypass path $is_bypass_path = strpos( $url_path, $bypass_path ); # not in the backend but bypass path detected - do the magic if ( $is_backend === false && $is_bypass_path !== false ) { /* To make things work we need the option_{$option} hook and use it on a filter. * * * The 'option_active_plugins' filter hook returns an array of active plugins. * With the help of PHP array_diff we remove the plugins to be bypassed from * the array of active plugins and return it. */ add_filter( 'option_active_plugins', function ( $plugins ) use ( $bypass_plugins ) { return array_diff( $plugins, $bypass_plugins ); } ); }

February 4, 2024

TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.