How can I overwrite the WordPress validate_plugin function. I need to disable that function alone for my plugin, and it should not affect any other plugin.

I don't want the validate_plugin function for my plugin right now, I couldn't find a declared hook, do_action or apply_filter, within the function in the wp-admin/includes/plugin.php file.

function run_activate_plugin( $plugin ) {
    $current = get_option( 'active_plugins' );
    $plugin = plugin_basename( trim( $plugin ) );

    if ( !in_array( $plugin, $current ) ) {
        $current[] = $plugin;
        sort( $current );
        do_action( 'activate_plugin', trim( $plugin ) );
        update_option( 'active_plugins', $current );
        do_action( 'activate_' . trim( $plugin ) );
        do_action( 'activated_plugin', trim( $plugin) );

    return null;
run_activate_plugin( 'plugin/subfolder/plugin.php');


If i activate the plugin from subfolder it got deactivate because of that above function. So that the reason i want to disable the validate_plugin function for my plugin alone.

run_activate_plugin( 'plugin/subfolder/plugin.php');

Generally run_activate_plugin argument is to be look like

run_activate_plugin( 'akismet/akismet.php');

But now i am doing activate the plugin from subfolder like this way

run_activate_plugin( 'akismet/newfolder/akismet.php');

Any suggestions?

  • Why validate_plugin? All that does is check whether "the file exists and {@link validate_file() is valid file}.". I can't imagine why you would not want that.
    – s_ha_dum
    Commented Jan 28, 2014 at 14:24
  • Thanks for your reply. Actually i am trying to activate more than one plugin which means activate another plugin inside the subfolder. wordpress.stackexchange.com/questions/131475/… But for some reason i can't able to activate the plugin which is in subfolder when i comment those function in core it working perfect Commented Jan 28, 2014 at 14:29
  • I am fairly certain that I have been able to do this before (but not 100% sure :) ). Post some (minimal) code please-- enough that someone could duplicate the issue.
    – s_ha_dum
    Commented Jan 28, 2014 at 14:46
  • Much Appreciate your help. I edited the code :) Commented Jan 28, 2014 at 16:30

1 Answer 1


My solution: generate a backtrace in the function and bail early if called from validate_active_plugins().

function action_option_active_plugins( $value, $option ) {

    // Look at the call backtrace and bail early if called from validation function.
    $backtrace = debug_backtrace( 2 ); // Exclude ['object'] and ['args']
    foreach( $backtrace as $frame ) {
        if( $frame['function'] === 'validate_active_plugins' ) {
            return $value;

    //Do other stuff with $value...

    return $value;
 add_filter( 'option_active_plugins', 'wpcom_vip_option_active_plugins', 10, 2 );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.