PluginProbe
ActivityPub / 5.7.0
ActivityPub v5.7.0
9.3.1 9.3.0 9.2.2 9.2.1 9.2.0 9.1.0 9.0.2 9.0.1 9.0.0 8.3.0 8.2.1 8.2.0 8.1.1 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.2.0 1.3.0 2.0.0 2.0.1 2.1.0 2.1.1 All 160 releases
← All changes | includes/rest/class-moderators-controller.php +2 -37 8.2.15.7.0 View file →
@@ -8,8 +8,9 @@
8 8 namespace Activitypub\Rest;
9 9
10 10 use Activitypub\Collection\Actors;
11 11
12 +use function Activitypub\get_context;
12 13 use function Activitypub\get_rest_url_by_path;
13 14
14 15 /**
15 16 * ActivityPub Moderators_Controller class.
@@ -14,9 +15,8 @@
14 15 /**
15 16 * ActivityPub Moderators_Controller class.
16 17 */
17 18 class Moderators_Controller extends \WP_REST_Controller {
18 - use Collection;
19 19
20 20 /**
21 21 * The namespace of this controller's route.
22 22 *
@@ -42,28 +42,8 @@
42 42 array(
43 43 'methods' => \WP_REST_Server::READABLE,
44 44 'callback' => array( $this, 'get_items' ),
45 45 'permission_callback' => '__return_true',
46 - 'args' => array(
47 - 'page' => array(
48 - 'description' => 'Current page of the collection.',
49 - 'type' => 'integer',
50 - 'minimum' => 1,
51 - // No default so we can differentiate between Collection and CollectionPage requests.
52 - ),
53 - 'per_page' => array(
54 - 'description' => 'Maximum number of items to be returned in result set.',
55 - 'type' => 'integer',
56 - 'default' => 100,
57 - 'minimum' => 1,
58 - ),
59 - 'order' => array(
60 - 'description' => 'Order sort attribute ascending or descending.',
61 - 'type' => 'string',
62 - 'default' => 'desc',
63 - 'enum' => array( 'asc', 'desc' ),
64 - ),
65 - ),
66 46 ),
67 47 'schema' => array( $this, 'get_item_schema' ),
68 48 )
69 49 );
@@ -89,24 +69,14 @@
89 69 */
90 70 $actors = apply_filters( 'activitypub_rest_moderators', $actors );
91 71
92 72 $response = array(
73 + '@context' => get_context(),
93 74 'id' => get_rest_url_by_path( 'collections/moderators' ),
94 75 'type' => 'OrderedCollection',
95 - 'totalItems' => \count( $actors ),
96 76 'orderedItems' => $actors,
97 77 );
98 78
99 - // Set the JSON-LD context if not already set.
100 - if ( empty( $response['@context'] ) ) {
101 - // Ensure the context is the first element in the response.
102 - $response = array( '@context' => $this->json_ld_context ) + $response;
103 - }
104 -
105 - if ( \is_wp_error( $response ) ) {
106 - return $response;
107 - }
108 -
109 79 $response = \rest_ensure_response( $response );
110 80 $response->header( 'Content-Type', 'application/activity+json; charset=' . \get_option( 'blog_charset' ) );
111 81
112 82 return $response;
@@ -149,13 +119,8 @@
149 119 'items' => array(
150 120 'type' => 'string',
151 121 'format' => 'uri',
152 122 ),
153 - 'required' => true,
154 - ),
155 - 'totalItems' => array(
156 - 'type' => 'integer',
157 - 'minimum' => 0,
158 123 'required' => true,
159 124 ),
160 125 ),
161 126 );