wp_cache_check_global_config()
No Hooks.
Return
null
. Nothing (null).
Usage
wp_cache_check_global_config();
wp_cache_check_global_config() wp cache check global config code WPSCache 1.12.4
<?php function wp_cache_check_global_config() { global $wp_cache_check_wp_config; if ( !isset( $wp_cache_check_wp_config ) ) return true; if ( file_exists( ABSPATH . 'wp-config.php') ) { $global_config_file = ABSPATH . 'wp-config.php'; } else { $global_config_file = dirname( ABSPATH ) . '/wp-config.php'; } if ( preg_match( '#^\s*(define\s*\(\s*[\'"]WP_CACHE[\'"]|const\s+WP_CACHE\s*=)#m', file_get_contents( $global_config_file ) ) === 1 ) { // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents if ( defined( 'WP_CACHE' ) && ! constant( 'WP_CACHE' ) ) { ?> <div class="notice notice-error"><h4><?php esc_html_e( 'WP_CACHE constant set to false', 'wp-super-cache' ); ?></h4> <p><?php esc_html_e( 'The WP_CACHE constant is used by WordPress to load the code that serves cached pages. Unfortunately, it is set to false. Please edit your wp-config.php and add or edit the following line above the final require_once command:', 'wp-super-cache' ); ?></p> <p><code>define('WP_CACHE', true);</code></p></div> <?php return false; } else { return true; } } $line = 'define(\'WP_CACHE\', true);'; if ( ! is_writeable_ACLSafe( $global_config_file ) || ! wp_cache_replace_line( 'define *\( *\'WP_CACHE\'', $line, $global_config_file ) ) { if ( defined( 'WP_CACHE' ) && constant( 'WP_CACHE' ) == false ) { echo '<div class="notice notice-error">' . __( "<h4>WP_CACHE constant set to false</h4><p>The WP_CACHE constant is used by WordPress to load the code that serves cached pages. Unfortunately, it is set to false. Please edit your wp-config.php and add or edit the following line above the final require_once command:<br /><br /><code>define('WP_CACHE', true);</code></p>", 'wp-super-cache' ) . "</div>"; } else { echo '<div class="notice notice-error"><p>' . __( "<strong>Error: WP_CACHE is not enabled</strong> in your <code>wp-config.php</code> file and I couldn’t modify it.", 'wp-super-cache' ) . "</p>"; echo "<p>" . sprintf( __( "Edit <code>%s</code> and add the following line:<br /> <code>define('WP_CACHE', true);</code><br />Otherwise, <strong>WP-Cache will not be executed</strong> by WordPress core. ", 'wp-super-cache' ), $global_config_file ) . "</p></div>"; } return false; } else { echo "<div class='notice notice-warning'>" . __( '<h4>WP_CACHE constant added to wp-config.php</h4><p>If you continue to see this warning message please see point 5 of the <a href="https://wordpress.org/plugins/wp-super-cache/faq/">Troubleshooting Guide</a>. The WP_CACHE line must be moved up.', 'wp-super-cache' ) . "</p></div>"; } return true; }