Skip to content

Commit a6595ef

Browse files
committed
poc scoping
1 parent 4cd2bfe commit a6595ef

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

settings/route-additions.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
return [
4+
'post' => [
5+
'POST' => [
6+
'defaults' => [
7+
'status' => 'private',
8+
],
9+
],
10+
],
11+
];

src/RouteInformation.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,25 @@ public function is_list(): bool
7878
return ! $this->is_singular();
7979
}
8080

81+
public function get_scope(): string
82+
{
83+
if ( ! $this->is_wp_rest_controller()) {
84+
return 'default';
85+
}
86+
87+
$context = [
88+
WP_REST_Posts_Controller::class => 'post',
89+
WP_REST_Users_Controller::class => 'user',
90+
WP_REST_Taxonomies_Controller::class => 'taxonomy',
91+
];
92+
93+
return $context[get_class($this->get_wp_rest_controller())];
94+
}
95+
8196
public function is_wp_rest_controller(): bool
8297
{
8398
// The callback form for a WP_REST_Controller is [ WP_REST_Controller, method ]
84-
if ( ! is_array( $this->callback ) ) {
99+
if ( ! is_array($this->callback)) {
85100
return false;
86101
}
87102

0 commit comments

Comments
 (0)