register_items_route( \WP_REST_Server::READABLE, $this->get_controller()->get_collection_params() ); } /** * Index route. * * GET `/notes/summary` * * @param \WP_REST_Request $request * * @return array */ protected function get_items( $request ) { $user_id = get_current_user_id(); $query = Note_Summary::query() ->only_visible( $user_id ) ->only_visible_posts( $user_id ); foreach ( $this->get_controller()->get_filters() as $param => $callback ) { if ( $request->has_param( $param ) ) { call_user_func( $callback, $query, $request->get_param( $param ) ); } } return [ 'data' => $query->get(), 'meta' => [], ]; } /** * @inheritDoc */ public function get_permission_callback( $request ) { return current_user_can( Capabilities::READ_NOTES ); } }