poc scoping

This commit is contained in:
David Mosterd 2025-03-16 16:06:01 +01:00
parent 4cd2bfe607
commit a6595eff35
2 changed files with 27 additions and 1 deletions

View file

@ -0,0 +1,11 @@
<?php

return [
'post' => [
'POST' => [
'defaults' => [
'status' => 'private',
],
],
],
];

View file

@ -78,10 +78,25 @@ class RouteInformation
return ! $this->is_singular();
}

public function get_scope(): string
{
if ( ! $this->is_wp_rest_controller()) {
return 'default';
}

$context = [
WP_REST_Posts_Controller::class => 'post',
WP_REST_Users_Controller::class => 'user',
WP_REST_Taxonomies_Controller::class => 'taxonomy',
];

return $context[get_class($this->get_wp_rest_controller())];
}

public function is_wp_rest_controller(): bool
{
// The callback form for a WP_REST_Controller is [ WP_REST_Controller, method ]
if ( ! is_array( $this->callback ) ) {
if ( ! is_array($this->callback)) {
return false;
}