rest_authorization_required_code() ) ); } /** * Standard ID argument. * * @return array */ protected function id_arg() { return array( 'id' => array( 'type' => 'integer', 'required' => true, 'sanitize_callback' => 'absint', ), ); } /** * Paged list response with total headers. * * @param array $items Items. * @param int $total Total. * @param int $per_page Per page. * @return \WP_REST_Response */ protected function paged( array $items, $total, $per_page ) { $response = rest_ensure_response( $items ); $response->header( 'X-WP-Total', (string) (int) $total ); $response->header( 'X-WP-TotalPages', (string) (int) max( 1, ceil( $total / max( 1, $per_page ) ) ) ); return $response; } }