Deactivate all plugins and theme by IP address

If you have an issue with the backend, and you have no clue, it would be very useful disabling all the plugins and the theme.

If you are able to access the FDP Backend settings page, and the issue occurs only during the page loading, you can easily find the cause of the problem by disabling one plugin after the other and the theme using FDP.

If you are not able to access the backend at all, but you already have Freesoul Deactivate Plugins, you can read this blog post. In this case, FDP will guide you to the solution.

If the problem occurs during an action continue reading.

For example, it’s impossible to upload an image to the media library, or the page doesn’t save the changes, If you don’t have the PRO version of Freesoul Deactivate Plugins, do the following:

  • Create a PHP file in wp-content/mu-plugins and call it e.g. my-mu-plugin.php
  • Write the following code:
<?php
defined( 'ABSPATH' ) || exit;
if( $_SERVER['REMOTE_ADDR'] === 'xx.xxx.xxx.xx' ){
 $disable_plugins = true;
 $disable_theme = true;
 if(
   is_admin()
   && (
    !wp_doing_ajax()
    || (
    isset( $_SERVER['HTTP_REFERER'] )
    && false !== strpos( $_SERVER['HTTP_REFERER'],'wp-admin' )
  )
 )
){
  //Disable theme and all plugins if the current request is for an administrative purpose
  if( $disable_plugins ){
   add_filter( 'option_active_plugins','__return_empty_array' );
  }
  if( $disable_theme ){
   add_filter( 'stylesheet_directory','__return_false',20,3 );
   add_filter( 'theme_root','__return_false',20 );
   add_filter( 'stylesheet','__return_false',20 );
   add_filter( 'template','__return_false',20 );
  }
 }
}

Replace xx.xxx.xxx.xx with your IP address.

Set $disable_plugins to true to disable all the plugins, and $disable_theme to true to disable the theme. This will work only for your IP address. All other users will see the website as usual.

Then repeat the same action that was giving issues. If the issue doesn’t occur anymore, one of the plugins or the theme was the cause. If so, enable the theme, or the plugins, to find out if one of the plugins or the theme was the cause.

This procedure will answer the question “Is the issue caused by a plugin or the theme”?
If also disabling all the plugins and the theme you still have the same issue, don’t lose time anymore with them, and focus on other possible causes.

If after disabling all the plugins and the theme you still have issues, you should focus on:

  • The WordPress core
  • The files wp-config.php, the drop-in plugins, and all the files included in wp-content/mu-plugins
  • The server
  • The database

To check the core, update WordPress. If you can’t do it from the backend, do it via FTP.

In wp-config.php you may have some settings that cause the problem. For instance, a custom path for the upload folder or whatever changes the default settings.

If you don’t know about drop-in plugins, here you have a complete list of them.

About the server, It depends on the nature of the problem, but usually, you should check the file .htaccess, the folder permissions, and the PHP version.

If nothing helps, be sure you have nothing strange saved in the database. It may happen for example that you migrated the website and somewhere you still have paths of the old website.