Filter hook 'rest_post_dispatch'

in WP Core File wp-includes/rest-api.php at line 2929

Description

Append result of internal request to REST API for purpose of preloading data to be attached to a page. Expected to be called in the context of `array_reduce`. / function rest_preload_api_request( $memo, $path ) { /* array_reduce() doesn't support passing an array in PHP 5.2, so we need to make sure we start with one.

Occurrences

Filename Line Number
wp-includes/rest-api.php 2929
wp-includes/rest-api/class-wp-rest-server.php 462
wp-includes/rest-api/class-wp-rest-server.php 761
wp-includes/rest-api/class-wp-rest-server.php 1795

Parameters

Type Name Description
array $memo Reduce accumulator.
string $path REST API path to preload.

Usage Examples

Example 1

add_filter( 'rest_post_dispatch', 'rest_send_allow_header'

Example 2

add_filter( 'rest_post_dispatch', 'rest_filter_response_fields'

PHP Doc

/**
 * Append result of internal request to REST API for purpose of preloading data to be attached to a page.
 * Expected to be called in the context of `array_reduce`.
 *
 * @since 5.0.0
 *
 * @param array  $memo Reduce accumulator.
 * @param string $path REST API path to preload.
 * @return array Modified reduce accumulator.
 */
function rest_preload_api_request( $memo, $path ) {
	/*
	 * array_reduce() doesn't support passing an array in PHP 5.2,
	 * so we need to make sure we start with one.
	 */