\d+)/subscription', [ 'args' => [ 'id' => [ 'description' => __( 'Request ID.', 'feature-request-system' ), 'type' => 'integer', 'minimum' => 1, 'required' => true, ], ], [ 'methods' => WP_REST_Server::CREATABLE, 'callback' => [ self::class, 'follow' ], // The rules are checked in the callback, which answers anyone with what applies to them. 'permission_callback' => '__return_true', ], [ 'methods' => WP_REST_Server::DELETABLE, 'callback' => [ self::class, 'unfollow' ], 'permission_callback' => '__return_true', ], ] ); } /** * Makes the current user follow a request. * * @param WP_REST_Request $request REST request. * @phpstan-param WP_REST_Request> $request */ public static function follow( WP_REST_Request $request ): WP_REST_Response { return Response::from( Subscriptions::follow( (int) $request['id'] ) ); } /** * Makes the current user stop following a request. * * @param WP_REST_Request $request REST request. * @phpstan-param WP_REST_Request> $request */ public static function unfollow( WP_REST_Request $request ): WP_REST_Response { return Response::from( Subscriptions::unfollow( (int) $request['id'] ) ); } }