cache = $cache; $this->server = $server; $this->htaccess = $htaccess; } /** * Returns the check identifier. * * @return string Identifier. */ public function get_id(): string { return 'page_cache'; } /** * Whether a loopback request is required. * * @return bool False. */ public function needs_loopback(): bool { return false; } /** * Runs the check. * * @return Result The finding. */ public function run(): Result { $label = __( 'Page caching', 'ai-blackout' ); $plugins = $this->cache->get_active_plugins(); $covered = $this->htaccess->is_applied(); $detail = array( 'operating' => $this->cache->is_operating(), 'drop_in' => $this->cache->has_drop_in(), 'plugins' => array_values( $plugins ), 'evidence' => $this->cache->get_evidence(), 'server_covered' => $covered, ); if ( $this->cache->is_operating() ) { return new Result( $this->get_id(), $label, $covered ? Result::INFO : Result::INERT, ! empty( $plugins ) ? sprintf( /* translators: %s: Comma-separated plugin names. */ __( 'A page cache is running (%s).', 'ai-blackout' ), implode( ', ', $plugins ) ) : __( 'A page cache is running.', 'ai-blackout' ), $covered ? __( 'Visitors are often served without WordPress running. Your server-level rules block AI crawlers before that happens, so caching does not weaken your protection.', 'ai-blackout' ) : __( 'Visitors are often served without WordPress running, which means WordPress-level blocking is skipped for those requests. AI crawlers hitting a cached page are not being refused.', 'ai-blackout' ), $covered ? '' : ( $this->server->supports_htaccess() ? __( 'Server rules run before the cache and would close this gap. See the .htaccess layer for why they are not in place.', 'ai-blackout' ) : __( 'Add the nginx rule to your server configuration, or ask your host to add it.', 'ai-blackout' ) ), $detail ); } if ( $this->cache->is_installed_but_dormant() ) { return new Result( $this->get_id(), $label, Result::INFO, $this->cache->describe_dormancy(), __( 'Because pages are not being cached, requests are reaching WordPress and WordPress-level blocking is working. If you switch to a host or setup where this cache starts working, check this screen again.', 'ai-blackout' ), '', $detail ); } return new Result( $this->get_id(), $label, Result::INFO, __( 'No page cache was found inside WordPress.', 'ai-blackout' ), __( 'Requests appear to be reaching WordPress, so WordPress-level blocking should be working. Caching run by your host or a CDN is invisible from inside WordPress, so this is not a guarantee. The self-test can confirm what visitors actually receive.', 'ai-blackout' ), '', $detail ); } }