WordPress.org

Ready to get started?Download WordPress

Forums

W3 Total Cache
W3- Total Cache Error when Activating (3 posts)

  1. inov8hosting
    Member
    Posted 9 months ago #

    I am getting the following error when I try to active this plugin

    Plugin could not be activated because it triggered a fatal error
    Please network activate W3 Total Cache when using WordPress Multisite.

    We're not running a multi-site installation anymore. This was a converted site from a MU to a standalone and I'm assuming the activation still sees that. Is there a way around this?

    http://wordpress.org/plugins/w3-total-cache/

  2. krupnik
    Member
    Posted 9 months ago #

    Having exactly the same error on wordpress v 3.6.1 with W3 version 0.9.3. Please post if you find a fix.

    Cheers

  3. jay_allen
    Member
    Posted 5 months ago #

    I'm going to guess that you, like me, have the Proper Network Activation plugin installed.

    The issue is a conflict between the Proper Network Activation (PNA) plugin and the W3 Total Cache (W3TC) plugin. The PNA plugin doesn't call the W3TC plugin's activate() function as it would expect and hence the W3TC plugin doesn't think it's activated network-wide.

    Here is the relevant code in wp-content/plugins/w3-total-cache/lib/W3/RootAdminActivation.php which expects and gets a parameter of $network_wide equal to 1 when the PNA plugin is not installed. However, the PNA plugin calls the function without an argument (meaning $network_wide = 0) which causes the process to skip the appropriate first block and instead fall to the final else which throws the message and dies.

    class W3_RootAdminActivation {
            function activate($network_wide) {
                w3_require_once(W3TC_INC_DIR . '/functions/activation.php');
                // decline non-network activation at WPMU
                if (w3_is_network()) {
                    if ($network_wide) {
                        // we are in network activation
                    } else if ($_GET['action'] == 'error_scrape' &&
                            strpos($_SERVER['REQUEST_URI'], '/network/') !== false) {
                        // workaround for error_scrape page called after error
                        // really we are in network activation and going to throw some error
                    } else {
                            echo 'Please <a href="' . network_admin_url('plugins.php') . '">network activate</a> W3 Total Cache when using WordPress Multisite. ';
                            die;
                    }

    I fixed the above by adding a PROPER network activation check within that final 'else' block:

    class W3_RootAdminActivation {
            function activate($network_wide) {
                w3_require_once(W3TC_INC_DIR . '/functions/activation.php');
                // decline non-network activation at WPMU
                if (w3_is_network()) {
                    if ($network_wide) {
                        // we are in network activation
                    } else if ($_GET['action'] == 'error_scrape' &&
                            strpos($_SERVER['REQUEST_URI'], '/network/') !== false) {
                        // workaround for error_scrape page called after error
                        // really we are in network activation and going to throw some error
                    } else {
                        if ( ! function_exists( 'is_plugin_active_for_network' ) )
                            require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
    
                        if ( ! is_plugin_active_for_network( 'w3-total-cache/w3-total-cache.php' ) ) {
                            echo 'Please <a href="' . network_admin_url('plugins.php') . '">network activate</a> W3 Total Cache when using WordPress Multisite. ';
                            die;
                        }
                    }

    This code properly functions by throwing the error ONLY if the w3tc plugin is not network activated.

Reply

You must log in to post.

About this Plugin

About this Topic