WP_REST_Server::READABLE, 'callback' => array( $this, 'show' ), 'permission_callback' => static fn(): bool => current_user_can( 'manage_options' ), ) ); } /** * Reports the progress. Without WP-Cron each call also runs one small step of the scan. * * @return WP_REST_Response Whether it runs, and the counts so far. */ public function show(): WP_REST_Response { // Without WP-Cron, the open page drives the scan: each poll runs one small batch. if ( $this->environment->cron_disabled() && $this->scan->status()['running'] ) { $this->scan->run(); } $status = $this->scan->status(); return new WP_REST_Response( array( 'running' => $status['running'], 'checked' => $status['checked'], 'in_sync' => $status['in_sync'], 'differs' => count( $status['differs'] ), ) ); } }