• No plugins want to activate from the plugins page. The message “Plugin activated” is displayed, but nothing really happens. When WPPP is not active they activate just fine. The culprit seems with the firing of the plugin_load_first() function. Tried various things and what finally worked for me was changing the hook from wp_loaded to the latest possible one: wp_dashboard_setup , according this reference. Most tests were performed with Autoptimize (de)activation.

    wp-performance-pack.php ~line 271 modified like this:

    add_action( 'wp_dashboard_setup', array( $this, 'plugin_load_first' ) ); 

    The issue was happening on a Linux VPS. Interestingly, I don’t have the issue with a local copy of that same website on WAMP.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter alx359

    (@alx359)

    Unfortunately, the proposed fix didn’t work as intended. Installed Debug Bar and noticed WPPP isn’t the first to load, as the Author intended.

    Did a bit more of research and a more effective hook came up (thanks chatGPT4):

    // Changed hook as other plugins won't activate
    // This filter shall fire before option('active_plugins') gets updated, ensuring WPPP always stays on top
      add_filter( 'pre_update_option_active_plugins', array( $this, 'plugin_load_first' ) );  
    //add_action( 'wp_loaded', array( $this, 'plugin_load_first' ) ); 

    Now, replace plugin_load_first() with a slightly modified version that takes into account the filter expectations:

    public function plugin_load_first( $plugins ) {
        $path = plugin_basename( __FILE__ );
        $key  = array_search( $path, $plugins );
    
         // Check WPPP is still at the top of the list
        if( false !== $key && $key > 0 ) {
            // Move WPPP at the top
            array_splice ( $plugins, $key, 1 );
            array_unshift( $plugins, $path );
        }
        // Return the (updated) active plugins list
        return $plugins;
    }

    HTH.

    Thread Starter alx359

    (@alx359)

    Forgot to update into activate() the new param $plugin of plugin_load_first().

    wp-performance-pack.php ~385 this should do:

    //$this->plugin_load_first();
    $this->plugin_load_first(get_option('active_plugins'));

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Plugins won’t activate’ is closed to new replies.