钩子文档

customize_render_partials_before

💡 云策文档标注

概述

customize_render_partials_before 是一个 WordPress 动作钩子,在部分渲染之前立即触发,允许插件执行如脚本和样式队列操作。

关键要点

  • 这是一个动作钩子,用于在部分渲染前执行自定义代码。
  • 插件可以利用此钩子调用 wp_enqueue_scripts() 并收集响应中可能入队的脚本和样式列表。
  • 钩子参数包括 $this(WP_Customize_Selective_Refresh 组件)和 $partials(部分ID为键的数组,包含放置上下文数据)。
  • 首次引入于 WordPress 4.5.0 版本。

注意事项

确保在部分渲染前正确使用此钩子,以避免影响选择性刷新功能。


📄 原文内容

Fires immediately before partials are rendered.

Description

Plugins may do things like call wp_enqueue_scripts() and gather a list of the scripts and styles which may get enqueued in the response.

Parameters

$refreshWP_Customize_Selective_Refresh
Selective refresh component.
$partialsarray
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.

Source

do_action( 'customize_render_partials_before', $this, $partials );

Changelog

Version Description
4.5.0 Introduced.