Strategies to implement selective loading of plugins

Filter option_active_plugins. You can change the result of get_option() here without actually changing the database.

if ( defined( 'DOING_AJAX' ) && DOING_AJAX )
    add_filter( 'option_active_plugins', 'disable_plugins_temporary' );

function disable_plugins_temporary( $plugins )
{
    // unset plugins you don't need, then

    return $plugins;
}

Background

wp_get_active_and_valid_plugins() calls get_option( 'active_plugins', array() ) to get the active plugins. In get_option( $option, $default = false ) we find this filter:

return apply_filters( 'option_' . $option, maybe_unserialize( $value ) );

So the resulting name for our filter is option_active_plugins.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)