REST API: Introduce the rest_preload_api_request() function.

This function helps perform multiple REST API requests, for the purpose of preloading data into a page.

Props pento.

Merges [43763] to trunk.

See #45110.

git-svn-id: https://develop.svn.wordpress.org/trunk@44123 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jonathan Desrosiers
2018-12-13 20:46:19 +00:00
parent ab070e219b
commit 08cc6047d1
2 changed files with 62 additions and 0 deletions

View File

@@ -712,4 +712,13 @@ class Tests_REST_API extends WP_UnitTestCase {
$routes = $GLOBALS['wp_rest_server']->get_routes();
$this->assertEquals( $routes['/test-ns/test'][0]['methods'], array( 'GET' => true ) );
}
/**
* Ensure rest_preload_api_request() works without notices in PHP 5.2.
*
* The array_reduce() function only accepts mixed variables starting with PHP 5.3.
*/
function test_rest_preload_api_request_no_notices_php_52() {
$this->assertTrue( is_array( rest_preload_api_request( 0, '/' ) ) );
}
}