<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[55132] trunk: Editor: Adds pagination and ordering support to `WP_REST_Pattern_Directory_Controller`.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/55132">55132</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/55132","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>hellofromTonya</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2023-01-24 16:52:42 +0000 (Tue, 24 Jan 2023)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Editor: Adds pagination and ordering support to `WP_REST_Pattern_Directory_Controller`.

Adds pagination and ordering support to `WP_REST_Pattern_Directory_Controller` by allow listing `'per_page'`, `'page'`, `'offset'`, `'order'`, and `'orderby'` query parameters. This change enables pagination and ordering features in the pattern directory explorer by using the same sort as wordpress.org/patterns.

Reference:
* [https://github.com/WordPress/gutenberg/pull/45293 Gutenberg PR 45293]

Follow-up to <a href="https://core.trac.wordpress.org/changeset/55098">[55098]</a>, <a href="https://core.trac.wordpress.org/changeset/51206">[51206]</a>, <a href="https://core.trac.wordpress.org/changeset/51021">[51021]</a>.

Props ntsekouras, ryelle, arrasel403, hellofromTonya, ironprogrammer, mukesh27, robinwpdeveloper.
Fixes <a href="https://core.trac.wordpress.org/ticket/57501">#57501</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesrestapiendpointsclasswprestpatterndirectorycontrollerphp">trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php</a></li>
<li><a href="#trunktestsphpunittestsrestapirestpatterndirectorycontrollerphp">trunk/tests/phpunit/tests/rest-api/rest-pattern-directory-controller.php</a></li>
<li><a href="#trunktestsqunitfixtureswpapigeneratedjs">trunk/tests/qunit/fixtures/wp-api-generated.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesrestapiendpointsclasswprestpatterndirectorycontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php   2023-01-24 16:03:26 UTC (rev 55131)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php     2023-01-24 16:52:42 UTC (rev 55132)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -81,6 +81,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * @since 5.8.0
</span><span class="cx" style="display: block; padding: 0 10px">         * @since 6.0.0 Added 'slug' to request.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * @since 6.2.0 Added 'per_page', 'page', 'offset', 'order', and 'orderby' to request.
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><span class="cx" style="display: block; padding: 0 10px">         * @param WP_REST_Request $request Full details about the request.
</span><span class="cx" style="display: block; padding: 0 10px">         * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -93,32 +94,24 @@
</span><span class="cx" style="display: block; padding: 0 10px">                 */
</span><span class="cx" style="display: block; padding: 0 10px">                require ABSPATH . WPINC . '/version.php';
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $query_args = array(
-                       'locale'     => get_user_locale(),
-                       'wp-version' => $wp_version,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $valid_query_args = array(
+                       'offset'   => true,
+                       'order'    => true,
+                       'orderby'  => true,
+                       'page'     => true,
+                       'per_page' => true,
+                       'search'   => true,
+                       'slug'     => true,
</ins><span class="cx" style="display: block; padding: 0 10px">                 );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                $query_args = array_intersect_key( $request->get_params(), $valid_query_args );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $category_id = $request['category'];
-               $keyword_id  = $request['keyword'];
-               $search_term = $request['search'];
-               $slug        = $request['slug'];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $query_args['locale']             = get_user_locale();
+               $query_args['wp-version']         = $wp_version; // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable -- it's defined in `version.php` above.
+               $query_args['pattern-categories'] = isset( $request['category'] ) ? $request['category'] : false;
+               $query_args['pattern-keywords']   = isset( $request['keyword'] ) ? $request['keyword'] : false;
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                if ( $category_id ) {
-                       $query_args['pattern-categories'] = $category_id;
-               }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $query_args = array_filter( $query_args );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                if ( $keyword_id ) {
-                       $query_args['pattern-keywords'] = $keyword_id;
-               }
-
-               if ( $search_term ) {
-                       $query_args['search'] = $search_term;
-               }
-
-               if ( $slug ) {
-                       $query_args['slug'] = $slug;
-               }
-
</del><span class="cx" style="display: block; padding: 0 10px">                 $transient_key = $this->get_transient_key( $query_args );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                /*
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -303,6 +296,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * Retrieves the search parameters for the block pattern's collection.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * @since 5.8.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * @since 6.2.0 Added 'per_page', 'page', 'offset', 'order', and 'orderby' to request.
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><span class="cx" style="display: block; padding: 0 10px">         * @return array Collection parameters.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -309,10 +303,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        public function get_collection_params() {
</span><span class="cx" style="display: block; padding: 0 10px">                $query_params = parent::get_collection_params();
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // Pagination is not supported.
-               unset( $query_params['page'] );
-               unset( $query_params['per_page'] );
-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $query_params['per_page']['default'] = 100;
</ins><span class="cx" style="display: block; padding: 0 10px">                 $query_params['search']['minLength'] = 1;
</span><span class="cx" style="display: block; padding: 0 10px">                $query_params['context']['default']  = 'view';
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -333,6 +324,37 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        'type'        => 'array',
</span><span class="cx" style="display: block; padding: 0 10px">                );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                $query_params['offset'] = array(
+                       'description' => __( 'Offset the result set by a specific number of items.' ),
+                       'type'        => 'integer',
+               );
+
+               $query_params['order'] = array(
+                       'description' => __( 'Order sort attribute ascending or descending.' ),
+                       'type'        => 'string',
+                       'default'     => 'desc',
+                       'enum'        => array( 'asc', 'desc' ),
+               );
+
+               $query_params['orderby'] = array(
+                       'description' => __( 'Sort collection by post attribute.' ),
+                       'type'        => 'string',
+                       'default'     => 'date',
+                       'enum'        => array(
+                               'author',
+                               'date',
+                               'id',
+                               'include',
+                               'modified',
+                               'parent',
+                               'relevance',
+                               'slug',
+                               'include_slugs',
+                               'title',
+                               'favorite_count',
+                       ),
+               );
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 /**
</span><span class="cx" style="display: block; padding: 0 10px">                 * Filter collection parameters for the block pattern directory controller.
</span><span class="cx" style="display: block; padding: 0 10px">                 *
</span></span></pre></div>
<a id="trunktestsphpunittestsrestapirestpatterndirectorycontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/rest-api/rest-pattern-directory-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/rest-api/rest-pattern-directory-controller.php  2023-01-24 16:03:26 UTC (rev 55131)
+++ trunk/tests/phpunit/tests/rest-api/rest-pattern-directory-controller.php    2023-01-24 16:52:42 UTC (rev 55132)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -31,6 +31,15 @@
</span><span class="cx" style="display: block; padding: 0 10px">        private static $controller;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * List of URLs captured.
+        *
+        * @since 6.2.0
+        *
+        * @var string[]
+        */
+       protected static $http_request_urls;
+
+       /**
</ins><span class="cx" style="display: block; padding: 0 10px">          * Set up class test fixtures.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * @since 5.8.0
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -44,10 +53,31 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        )
</span><span class="cx" style="display: block; padding: 0 10px">                );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                self::$http_request_urls = array();
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 static::$controller = new WP_REST_Pattern_Directory_Controller();
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * Tear down after class.
+        *
+        * @since 6.2.0
+        */
+       public static function wpTearDownAfterClass() {
+               self::delete_user( self::$contributor_id );
+       }
+
+       /**
+        * Clear the captured request URLs after each test.
+        *
+        * @since 6.2.0
+        */
+       public function tear_down() {
+               self::$http_request_urls = array();
+               parent::tear_down();
+       }
+
+       /**
</ins><span class="cx" style="display: block; padding: 0 10px">          * Asserts that the pattern matches the expected response schema.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * @param WP_REST_Response[] $pattern An individual pattern from the REST API response.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -311,6 +341,176 @@
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * Tests if the provided query args are passed through to the wp.org API.
+        *
+        * @since 6.2.0
+        *
+        * @ticket 57501
+        *
+        * @covers WP_REST_Pattern_Directory_Controller::get_items
+        *
+        * @dataProvider data_get_items_query_args
+        *
+        * @param string $param    Query parameter name (ex, page).
+        * @param mixed  $value    Query value to test.
+        * @param bool   $is_error Whether this value should error or not.
+        * @param mixed  $expected Expected value (or expected error code).
+        */
+       public function test_get_items_query_args( $param, $value, $is_error, $expected ) {
+               wp_set_current_user( self::$contributor_id );
+               add_filter( 'pre_http_request', array( $this, 'mock_request_to_apiwporg_url' ), 10, 3 );
+
+               $request = new WP_REST_Request( 'GET', '/wp/v2/pattern-directory/patterns' );
+               if ( $value ) {
+                       $request->set_query_params( array( $param => $value ) );
+               }
+
+               $response = rest_do_request( $request );
+               $data     = $response->get_data();
+               if ( $is_error ) {
+                       $this->assertSame( $expected, $data['code'], 'Response error code does not match' );
+                       $this->assertStringContainsString( $param, $data['message'], 'Response error message does not match' );
+               } else {
+                       $this->assertCount( 1, self::$http_request_urls, 'The number of HTTP Request URLs is not 1' );
+                       $this->assertStringContainsString( $param . '=' . $expected, self::$http_request_urls[0], 'The param and/or value do not match' );
+               }
+       }
+
+       /**
+        * Data provider.
+        *
+        * return array[]
+        */
+       public function data_get_items_query_args() {
+               return array(
+                       'per_page default'   => array(
+                               'param'    => 'per_page',
+                               'value'    => false,
+                               'is_error' => false,
+                               'expected' => 100,
+                       ),
+                       'per_page custom-1'  => array(
+                               'param'    => 'per_page',
+                               'value'    => 5,
+                               'is_error' => false,
+                               'expected' => 5,
+                       ),
+                       'per_page custom-2'  => array(
+                               'param'    => 'per_page',
+                               'value'    => 50,
+                               'is_error' => false,
+                               'expected' => 50,
+                       ),
+                       'per_page invalid-1' => array(
+                               'param'    => 'per_page',
+                               'value'    => 200,
+                               'is_error' => true,
+                               'expected' => 'rest_invalid_param',
+                       ),
+                       'per_page invalid-2' => array(
+                               'param'    => 'per_page',
+                               'value'    => 'abc',
+                               'is_error' => true,
+                               'expected' => 'rest_invalid_param',
+                       ),
+
+                       'page default'       => array(
+                               'param'    => 'page',
+                               'value'    => false,
+                               'is_error' => false,
+                               'expected' => 1,
+                       ),
+                       'page custom'        => array(
+                               'param'    => 'page',
+                               'value'    => 5,
+                               'is_error' => false,
+                               'expected' => 5,
+                       ),
+                       'page invalid'       => array(
+                               'param'    => 'page',
+                               'value'    => 'abc',
+                               'is_error' => true,
+                               'expected' => 'rest_invalid_param',
+                       ),
+
+                       'offset custom'      => array(
+                               'param'    => 'offset',
+                               'value'    => 5,
+                               'is_error' => false,
+                               'expected' => 5,
+                       ),
+                       'offset invalid-1'   => array(
+                               'param'    => 'offset',
+                               'value'    => 'abc',
+                               'is_error' => true,
+                               'expected' => 'rest_invalid_param',
+                       ),
+
+                       'order default'      => array(
+                               'param'    => 'order',
+                               'value'    => false,
+                               'is_error' => false,
+                               'expected' => 'desc',
+                       ),
+                       'order custom'       => array(
+                               'param'    => 'order',
+                               'value'    => 'asc',
+                               'is_error' => false,
+                               'expected' => 'asc',
+                       ),
+                       'order invalid-1'    => array(
+                               'param'    => 'order',
+                               'value'    => 10,
+                               'is_error' => true,
+                               'expected' => 'rest_invalid_param',
+                       ),
+                       'order invalid-2'    => array(
+                               'param'    => 'order',
+                               'value'    => 'fake',
+                               'is_error' => true,
+                               'expected' => 'rest_invalid_param',
+                       ),
+
+                       'orderby default'    => array(
+                               'param'    => 'orderby',
+                               'value'    => false,
+                               'is_error' => false,
+                               'expected' => 'date',
+                       ),
+                       'orderby custom-1'   => array(
+                               'param'    => 'orderby',
+                               'value'    => 'title',
+                               'is_error' => false,
+                               'expected' => 'title',
+                       ),
+                       'orderby custom-2'   => array(
+                               'param'    => 'orderby',
+                               'value'    => 'date',
+                               'is_error' => false,
+                               'expected' => 'date',
+                       ),
+                       'orderby custom-3'   => array(
+                               'param'    => 'orderby',
+                               'value'    => 'favorite_count',
+                               'is_error' => false,
+                               'expected' => 'favorite_count',
+                       ),
+                       'orderby invalid-1'  => array(
+                               'param'    => 'orderby',
+                               'value'    => 10,
+                               'is_error' => true,
+                               'expected' => 'rest_invalid_param',
+                       ),
+                       'orderby invalid-2'  => array(
+                               'param'    => 'orderby',
+                               'value'    => 'fake',
+                               'is_error' => true,
+                               'expected' => 'rest_invalid_param',
+                       ),
+               );
+       }
+
+       /**
</ins><span class="cx" style="display: block; padding: 0 10px">          * @doesNotPerformAssertions
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_get_item() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -573,4 +773,33 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        3
</span><span class="cx" style="display: block; padding: 0 10px">                );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+       /**
+        * Mock the request to wp.org URL to capture the URLs.
+        *
+        * @since 6.2.0
+        *
+        * @return array faux/mocked response.
+        */
+       public function mock_request_to_apiwporg_url( $response, $args, $url ) {
+               if ( 'api.wordpress.org' !== wp_parse_url( $url, PHP_URL_HOST ) ) {
+                       return $response;
+               }
+
+               self::$http_request_urls[] = $url;
+
+               // Return a response to prevent external API request.
+               $response = array(
+                       'headers'  => array(),
+                       'response' => array(
+                               'code'    => 200,
+                               'message' => 'OK',
+                       ),
+                       'body'     => '[]',
+                       'cookies'  => array(),
+                       'filename' => null,
+               );
+
+               return $response;
+       }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunktestsqunitfixtureswpapigeneratedjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/qunit/fixtures/wp-api-generated.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/qunit/fixtures/wp-api-generated.js    2023-01-24 16:03:26 UTC (rev 55131)
+++ trunk/tests/qunit/fixtures/wp-api-generated.js      2023-01-24 16:52:42 UTC (rev 55132)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -10475,6 +10475,21 @@
</span><span class="cx" style="display: block; padding: 0 10px">                             "default": "view",
</span><span class="cx" style="display: block; padding: 0 10px">                             "required": false
</span><span class="cx" style="display: block; padding: 0 10px">                         },
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        "page": {
+                            "description": "Current page of the collection.",
+                            "type": "integer",
+                            "default": 1,
+                            "minimum": 1,
+                            "required": false
+                        },
+                        "per_page": {
+                            "description": "Maximum number of items to be returned in result set.",
+                            "type": "integer",
+                            "default": 100,
+                            "minimum": 1,
+                            "maximum": 100,
+                            "required": false
+                        },
</ins><span class="cx" style="display: block; padding: 0 10px">                         "search": {
</span><span class="cx" style="display: block; padding: 0 10px">                             "description": "Limit results to those matching a string.",
</span><span class="cx" style="display: block; padding: 0 10px">                             "type": "string",
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -10497,6 +10512,40 @@
</span><span class="cx" style="display: block; padding: 0 10px">                             "description": "Limit results to those matching a pattern (slug).",
</span><span class="cx" style="display: block; padding: 0 10px">                             "type": "array",
</span><span class="cx" style="display: block; padding: 0 10px">                             "required": false
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        },
+                        "offset": {
+                            "description": "Offset the result set by a specific number of items.",
+                            "type": "integer",
+                            "required": false
+                        },
+                        "order": {
+                            "description": "Order sort attribute ascending or descending.",
+                            "type": "string",
+                            "default": "desc",
+                            "enum": [
+                                "asc",
+                                "desc"
+                            ],
+                            "required": false
+                        },
+                        "orderby": {
+                            "description": "Sort collection by post attribute.",
+                            "type": "string",
+                            "default": "date",
+                            "enum": [
+                                "author",
+                                "date",
+                                "id",
+                                "include",
+                                "modified",
+                                "parent",
+                                "relevance",
+                                "slug",
+                                "include_slugs",
+                                "title",
+                                "favorite_count"
+                            ],
+                            "required": false
</ins><span class="cx" style="display: block; padding: 0 10px">                         }
</span><span class="cx" style="display: block; padding: 0 10px">                     }
</span><span class="cx" style="display: block; padding: 0 10px">                 }
</span></span></pre>
</div>
</div>

</body>
</html>