The customize_render_partials_after WordPress PHP action fires immediately after partials are rendered. It allows plugins to perform tasks such as calling wp_footer()
to scrape scripts output and return them via the customize_render_partials_response
filter.
Usage
add_action('customize_render_partials_after', 'your_custom_function', 10, 2); function your_custom_function($refresh, $partials) { // your custom code here return $refresh; }
Parameters
- $refresh (WP_Customize_Selective_Refresh): Selective refresh component.
- $partials (array): 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.
More information
See WordPress Developer Resources: customize_render_partials_after
Examples
Add a custom script after partials are rendered
Add a custom script to the footer after the partials have been rendered:
add_action('customize_render_partials_after', 'add_custom_script', 10, 2); function add_custom_script($refresh, $partials) { wp_enqueue_script('custom-script', 'path/to/your/custom-script.js', array(), '1.0.0', true); return $refresh; }
Modify partials data
Modify the $partials
data after they are rendered:
add_action('customize_render_partials_after', 'modify_partials_data', 10, 2); function modify_partials_data($refresh, $partials) { // Modify partials data foreach ($partials as $key => $value) { // your custom code here } return $refresh; }
Log rendered partials
Log the rendered partials for debugging purposes:
add_action('customize_render_partials_after', 'log_rendered_partials', 10, 2); function log_rendered_partials($refresh, $partials) { error_log(print_r($partials, true)); return $refresh; }
Apply custom CSS to rendered partials
Add custom CSS to specific partials after they are rendered:
add_action('customize_render_partials_after', 'apply_custom_css', 10, 2); function apply_custom_css($refresh, $partials) { if (isset($partials['your_partial_id'])) { wp_add_inline_style('your-style-handle', 'your-custom-css'); } return $refresh; }
Trigger custom action after partials rendering
Trigger a custom action after the partials are rendered:
add_action('customize_render_partials_after', 'trigger_custom_action', 10, 2); function trigger_custom_action($refresh, $partials) { do_action('your_custom_action'); return $refresh; }
END