|null, fresh: bool} Current state. */ public static function report() { if ( ! Helpers::is_module_enabled( self::SLUG ) ) { return array( 'enabled' => false, 'report' => null, 'fresh' => false, ); } $cached = ConflictCache::cached(); if ( null === $cached ) { return array( 'enabled' => true, 'report' => ConflictReport::not_run(), 'fresh' => false, ); } return array( 'enabled' => true, 'report' => $cached['report'], 'fresh' => $cached['fresh'], ); } /** * Recomputes the report and stores it, superseding any cached entry. * * Only an authorised admin request may call this; see * `ConflictDetectorPage`, which checks `manage_options` and a dedicated * nonce before it does. Not attached to any hook, so no cron, REST, AJAX * or front-end path can reach it. * * @since 1.6.0 * * @return array Freshly computed report. */ public static function retest() { return ConflictCache::store( ConflictReport::build() ); } /** * Returns the statistics a later Dashboard will consume. * * Reads whatever `report()` currently has - never recomputes - so this is * safe to call from anywhere, including a frontend request. A disabled * module, or one that has never completed a report, contributes zero to * every count rather than a fabricated figure. * * @since 1.6.0 * * @return array{active_conflict_count: int, unknown_feature_count: int, unavailable_feature_count: int, active_supported_plugins: int} Statistics. */ public static function stats() { $state = self::report(); if ( ! $state['enabled'] || null === $state['report'] ) { return array( 'active_conflict_count' => 0, 'unknown_feature_count' => 0, 'unavailable_feature_count' => 0, 'active_supported_plugins' => 0, ); } return $state['report']['stats']; } }