'GET', 'callback' => array( $this, 'boot' ), 'permission_callback' => static fn(): bool => current_user_can( 'manage_options' ), ) ); register_rest_route( self::NAMESPACE, '/system/status', array( 'methods' => 'GET', 'callback' => array( $this, 'status' ), 'permission_callback' => static fn(): bool => current_user_can( 'manage_options' ), ) ); } /** * Everything the dashboard needs to draw, in one round trip. * * Opening the plugin fired four REST calls before first paint — score, * KPIs, content coverage, setup state. Each one is its own HTTP round * trip; on a 200 ms-latency host that is 200 ms saved three times over. * The four routes stay untouched (deep links, recalc and other screens * use them singly); this endpoint dispatches them internally, so there * is exactly one implementation of each payload and nothing can drift. */ public function boot(): WP_REST_Response { $piece = static function ( string $route ) { $response = rest_do_request( new \WP_REST_Request( 'GET', '/airanksuite/v1' . $route ) ); return $response->is_error() ? null : $response->get_data(); }; return new WP_REST_Response( array( 'score' => $piece( '/score' ), 'kpis' => $piece( '/dashboard/kpis' ), 'content' => $piece( '/score/content' ), 'setup' => $piece( '/setup/status' ), ) ); } public function status(): WP_REST_Response { global $wp_version; return new WP_REST_Response( array( 'plugin_version' => AIRANKSUITE_VERSION, 'wp_version' => $wp_version, 'php_version' => PHP_VERSION, 'modules' => Kernel::instance()->moduleIds(), 'quarantined' => array_keys( (array) get_option( 'airanksuite_quarantine', array() ) ), // Front-end callbacks that threw and were caught. Empty is the // only acceptable value on a healthy install. 'hook_failures' => \AiRankSuite\Support\Guard::failures(), 'permalinks' => (bool) get_option( 'permalink_structure' ), 'multisite' => is_multisite(), ) ); } }