ensure(); } } /** * Ensure WP_CACHE, the drop-in and cache directories are ready. * * @return array */ public function ensure() { $status = array( 'wp_cache_defined' => defined( 'WP_CACHE' ) && WP_CACHE, 'dropin_installed' => false, 'directories_ready' => false, 'checked_at' => time(), 'ready' => false, 'blockers' => array(), ); if ( ! get_option( 'nbh_performance_cache_enabled', false ) ) { update_option( 'nbh_performance_cache_bootstrap_status', $status, false ); return $status; } // Avoid writing executable drop-ins until caching can actually be used. if ( ! $status['wp_cache_defined'] ) { $status['blockers'][] = 'wp_cache_disabled'; update_option( 'nbh_performance_cache_bootstrap_status', $status, false ); return $status; } $status['directories_ready'] = wp_mkdir_p( WP_CONTENT_DIR . '/cache/nbh-performance/pages' ); $status['dropin_installed'] = ( new DropInInstaller() )->install(); // WP_CACHE must be configured by the administrator or host. Never edit wp-config.php. if ( ! $status['directories_ready'] ) { $status['blockers'][] = 'cache_directory_unwritable'; } if ( ! $status['dropin_installed'] ) { $status['blockers'][] = 'cache_dropin_unavailable'; } $status['ready'] = empty( $status['blockers'] ) && ! get_option( 'nbh_performance_safe_mode', true ); update_option( 'nbh_performance_cache_bootstrap_status', $status, false ); return $status; } }