request = $request; return is_user_logged_in() && current_user_can( 'edit_posts' ); } public function register_routes() { $this->post( $this->endpoint, [ $this, 'sync' ] ); } /** * A no-op when the cache is fresh, which is the common case — the editor * calls this on every load and must not re-fetch the catalog each time. * Concurrent editors collapse onto one fetch via the sync lock. */ public function sync() { $result = PatternSync::get_instance()->sync_if_stale(); return $this->success( [ 'status' => $result['status'], 'count' => $result['count'], 'plan_key' => $result['plan_key'], // The client only needs to refresh its pattern store when the set it // already loaded is out of date. 'changed' => 'synced' === $result['status'], ] ); } }