is_oauth = true; $this->connector_slug = is_string( $connector_slug ) ? $connector_slug : ''; $this->client_name = is_string( $client_name ) ? $client_name : ''; } /** * Did an OAuth bearer token authenticate this request? */ public function is_oauth(): bool { return $this->is_oauth; } /** * Connector slug, or '' when this is not a connector-backed client. */ public function get_connector_slug(): string { return $this->connector_slug; } /** * Client name from the OAuth client row, or ''. */ public function get_client_name(): string { return $this->client_name; } /** * Callback for `rest_pre_dispatch` @ priority 5 — A17 stage 1. * * Resets before dispatch. Priority 5 so it runs ahead of any handler that * short-circuits at the default 10. Returns `$result` unchanged. * * @param mixed $result Pre-dispatch short-circuit value. * @param mixed $rest_server REST server (unused). * @param mixed $request The incoming request (unused). * @return mixed */ public function reset_for_request( $result = null, $rest_server = null, $request = null ) { unset( $rest_server, $request ); $this->wipe(); return $result; } /** * Callback for `rest_post_dispatch` @ 999 and `shutdown` @ 999 — A17 stages * 2 and 3. * * Takes and returns a passthrough so one method can serve both a filter and * an action. * * @param mixed $passthrough Value to return unchanged. * @return mixed */ public function clear( $passthrough = null ) { $this->wipe(); return $passthrough; } /** * Drop every captured value. */ private function wipe(): void { $this->is_oauth = false; $this->connector_slug = ''; $this->client_name = ''; } }