Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
33 lines
850 B
PHP
33 lines
850 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
// WP_HTTP_Response first: real WordPress' WP_REST_Response extends it (ConnectionUsage::successful()
|
|
// tells a WP_REST_Response apart from a WP_Error/array via instanceof WP_HTTP_Response).
|
|
if (! class_exists('WP_HTTP_Response')) {
|
|
class WP_HTTP_Response
|
|
{
|
|
/** @param array<string, string> $headers */
|
|
public function __construct(public mixed $data = null, public int $status = 200, public array $headers = [])
|
|
{
|
|
}
|
|
|
|
public function get_status(): int
|
|
{
|
|
return $this->status;
|
|
}
|
|
|
|
/** @return array<string, string> */
|
|
public function get_headers(): array
|
|
{
|
|
return $this->headers;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (! class_exists('WP_REST_Response')) {
|
|
class WP_REST_Response extends WP_HTTP_Response
|
|
{
|
|
}
|
|
}
|