1) ? $page - 1 : 0; } public static function nextPage($page, $per_page = 10) { return ($page < App::totalPages($per_page)) ? $page + 1 : 0; } public static function totalPages($per_page = 10) { $request = new \WP_REST_Request('GET', '/pressbooks/v2/books'); $request->set_query_params([ 'per_page' => $per_page, ]); $response = rest_do_request($request); return $response->headers['X-WP-TotalPages']; } public static function books($page = 1, $per_page = 10) { $request = new \WP_REST_Request('GET', '/pressbooks/v2/books'); $request->set_query_params([ 'page' => $page, 'per_page' => $per_page, ]); $response = rest_do_request($request); return rest_get_server()->response_to_data($response, true); } }