customize_render_partials_response
Filter HookDescription
Filters the response from rendering the partials. Plugins may use this filter to inject `$scripts` and `$styles`, which are dependencies for the partials being rendered. The response data will be available to the client via the `render-partials-response` JS event, so the client can then inject the scripts and styles into the DOM if they have not already been enqueued there. If plugins do this, they'll need to take care for any scripts that do `document.write()` and make sure that these are not injected, or else to override the function to no-op, or else the page will be destroyed. Plugins should be aware that `$scripts` and `$styles` may eventually be included by default in the response. for the containers requested. is enabled. }Hook Information
File Location |
wp-includes/customize/class-wp-customize-selective-refresh.php
View on GitHub
|
Hook Type | Filter |
Line Number | 437 |
Hook Parameters
Type | Name | Description |
---|---|---|
array
|
$response
|
{ Response. |
WP_Customize_Selective_Refresh
|
$refresh
|
Selective refresh component. |
array
|
$partials
|
Placements' context data for the partials rendered in the request. The array is keyed by partial ID, with each item being an array of the placements' context data. |
Usage Examples
Basic Usage
<?php
// Hook into customize_render_partials_response
add_filter('customize_render_partials_response', 'my_custom_filter', 10, 3);
function my_custom_filter($response, $refresh, $partials) {
// Your custom filtering logic here
return $response;
}
Source Code Context
wp-includes/customize/class-wp-customize-selective-refresh.php:437
- How this hook is used in WordPress core
<?php
432 * @param WP_Customize_Selective_Refresh $refresh Selective refresh component.
433 * @param array $partials Placements' context data for the partials rendered in the request.
434 * The array is keyed by partial ID, with each item being an array of
435 * the placements' context data.
436 */
437 $response = apply_filters( 'customize_render_partials_response', $response, $this, $partials );
438
439 wp_send_json_success( $response );
440 }
441 }
PHP Documentation
<?php
/**
* Filters the response from rendering the partials.
*
* Plugins may use this filter to inject `$scripts` and `$styles`, which are dependencies
* for the partials being rendered. The response data will be available to the client via
* the `render-partials-response` JS event, so the client can then inject the scripts and
* styles into the DOM if they have not already been enqueued there.
*
* If plugins do this, they'll need to take care for any scripts that do `document.write()`
* and make sure that these are not injected, or else to override the function to no-op,
* or else the page will be destroyed.
*
* Plugins should be aware that `$scripts` and `$styles` may eventually be included by
* default in the response.
*
* @since 4.5.0
*
* @param array $response {
* Response.
*
* @type array $contents Associative array mapping a partial ID its corresponding array of contents
* for the containers requested.
* @type array $errors List of errors triggered during rendering of partials, if `WP_DEBUG_DISPLAY`
* is enabled.
* }
* @param WP_Customize_Selective_Refresh $refresh Selective refresh component.
* @param array $partials Placements' context data for the partials rendered in the request.
* The array is keyed by partial ID, with each item being an array of
* the placements' context data.
*/
Quick Info
- Hook Type: Filter
- Parameters: 3
- File: wp-includes/customize/class-wp-customize-selective-refresh.php
Related Hooks
Related hooks will be displayed here in future updates.