Fix for “Fatal error: require():”
-
If you are seeing errors such as:
Try the following:
Open up
w3-total-cache-api.php
, look forfunction w3tc_class_autoload( $class )
.
Erase the entire function (from line 120 to line 163) and replace it with the following:function w3tc_class_autoload( $class ) { $base = null; // some php pass classes with slash if ( substr( $class, 0, 1 ) == "\\" ) $class = substr( $class, 1 ); if ( substr( $class, 0, 5 ) == 'HTTP_' || substr( $class, 0, 7 ) == 'Minify_' ) { $base = W3TC_LIB_DIR . DIRECTORY_SEPARATOR . 'Minify' . DIRECTORY_SEPARATOR; } elseif ( substr( $class, 0, 8 ) == 'Minify0_' ) { $base = W3TC_LIB_DIR . DIRECTORY_SEPARATOR . 'Minify' . DIRECTORY_SEPARATOR; $class = substr( $class, 8 ); } elseif ( substr( $class, 0, 7 ) == 'Google_' && ( !defined( 'W3TC_GOOGLE_LIBRARY' ) || W3TC_GOOGLE_LIBRARY ) ) { // Google library $classPath = explode( '_', $class ); if ( count( $classPath ) > 3 ) { // Maximum class file path depth in this project is 3. $classPath = array_slice( $classPath, 0, 3 ); } $filePath = W3TC_LIB_DIR . DIRECTORY_SEPARATOR . implode( '/', $classPath ) . '.php'; if ( is_readable( $filePath ) ) { require $filePath; } return; } if ( !is_null( $base ) ) { $file = $base . strtr( $class, "\\_", DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR ) . '.php'; if ( is_readable( $file ) ) { require_once $file; } } else if ( substr( $class, 0, 5 ) == 'W3TC\\' ) { $filename = W3TC_DIR . DIRECTORY_SEPARATOR . substr( $class, 5 ) . '.php'; if ( is_readable( $filename ) ) { require $filename; } else { if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { debug_print_backtrace(); } } return; } }
- The topic ‘Fix for “Fatal error: require():”’ is closed to new replies.