ContextSeeing a 'Cannot redeclare' error usually means your site has just crashed into the 'White Screen of Death' (WSOD). This happens because PHP hit a wall. It tried to load a class or function that already exists in the system's memory, and PHP doesn't allow duplicates.
The exact error message usually looks like this:
Fatal error: Cannot redeclare class WC_Cart (previously declared in /wp-content/plugins/woocommerce/includes/class-wc-cart.php) in /wp-content/plugins/woocommerce/includes/class-wc-cart.php on line 1
When the error points to the same file twice, like the WC_Cart example above, it is a bit of a riddle. It usually means the file was loaded through two different paths—often due to a symbolic link. It could also mean a rogue plugin is trying to 'mock' or override a core WooCommerce class improperly.
Debug ProcessSince you are likely locked out of your WordPress dashboard, grab your FTP credentials or open your hosting File Manager. You will need to dig into the files directly to see what is happening.
1. Enable WordPress DebuggingOpen your wp-config.php file in the root directory. Look for the line define( 'WP_DEBUG', false ); and replace it with these three lines:
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', true );
This reveals the full file paths causing the clash. Often, you will find two different plugins trying to use the same common library, such as an outdated version of class-tgm-plugin-activation.php.
2. Spot the CulpritCheck the error message paths. If the paths are different, the second one mentioned is usually the plugin you just installed or updated. That is your 'culprit.' If the paths are identical, the code is likely using require instead of require_once.
Step-by-Step Solutions### Method 1: The 'Rename' ShortcutIf the crash happened right after a plugin update, use FTP to navigate to /wp-content/plugins/. Rename the suspect plugin's folder—for example, change jetpack to jetpack-off. This instantly deactivates the plugin. If your site suddenly breathes again, you have found the source.
Method 2: Switch to require_onceCustom code often triggers this error if you load the same file multiple times. Using require or include is risky in loops or complex themes. It is better to use the 'once' variants to tell PHP to skip the file if it is already loaded.
Avoid this:
require( plugin_dir_path( __FILE__ ) . 'includes/helpers.php' );
Use this instead:
require_once( plugin_dir_path( __FILE__ ) . 'includes/helpers.php' );
Method 3: Use Defensive Wrapper ChecksProfessional developers always check if a name is taken before using it. This simple 'if' statement prevents 99% of redeclaration errors in the WordPress ecosystem.
For Functions:
if ( ! function_exists( 'my_unique_prefix_utility' ) ) {
function my_unique_prefix_utility() {
// Code goes here
}
}
For Classes:
if ( ! class_exists( 'My_Plugin_Handler' ) ) {
class My_Plugin_Handler {
// Code goes here
}
}

