Disabling chosen plugins while editing products in WooCommerce

  • Unknown's avatar

    Hi,

    I have the following problem: I try to make a simple script, which will be able to turn off chosen plugins, while editing products in WooCommerce. For my website I used Divi Builder, and the problem is, whenever you want to edit a product and save the changes… it takes around 20 seconds. In Google Dev Tools (Network tab) I can clearly see that it downloads nearlt 50mb of resources (sic!). When you switch off all plugins except Divi and Woo, it takes “only” 24mb of resources and saves the page in about 6 seconds. So to be able to automatically disable plugins while editing, I’ve created mu-plugins folder and used the following code (I’ve chosen Query Monitor for testing puropouses):

    <?php
    add_filter( ‘option_active_plugins’, ‘disable_plugins_per_page’ );
    function disable_plugins_per_page( $plugin_list ) {

    // Quit immediately if not post edit area.
    global $pagenow;
    if (( $pagenow == ‘post.php’ || $pagenow == ‘edit.php’ )) {
    $disable_plugins = array (
    // Plugin Name
    ‘query-monitor/query-monitor.php’
    );
    $plugins_to_disable = array();
    foreach ( $plugin_list as $plugin ) {
    if ( true == in_array( $plugin, $disable_plugins ) ) {
    //error_log( “Found $plugin in list of active plugins.” );
    $plugins_to_disable[] = $plugin;
    }
    }
    // If there are plugins to disable then remove them from the list,
    // otherwise return the original list.
    if ( count( $plugins_to_disable ) ) {
    $new_list = array_diff( $plugin_list, $plugins_to_disable );
    return $new_list;
    }
    }
    return $plugin_list;
    }

    unfortunatelly it still loads all the CSS and JS of the plugin…
    I would be super gratefull for any help here:(

    The blog I need help with is: (visible only to logged in users)

  • Hi there,

    These community forums only provide support for WordPress.com hosted sites. The WooCommerce team should be able to assist you with this. You’ll need to reach out to them here.

    Thanks!

  • The topic ‘Disabling chosen plugins while editing products in WooCommerce’ is closed to new replies.