钩子文档

customize_preview_{$this->id}

💡 云策文档标注

概述

customize_preview_{$this->id} 是一个 WordPress 动态 Hook,在 WP_Customize_Setting::preview() 方法被调用时触发,专门用于处理非 theme_mods 或 options 类型的设置。

关键要点

  • 这是一个动态 Hook,其名称中的 $this->id 部分指代设置 ID,允许针对特定设置进行定制。
  • Hook 在 WP_Customize_Setting::preview() 方法执行时触发,主要用于自定义设置值的预览逻辑。
  • 参数为 $setting,即 WP_Customize_Setting 实例,提供对当前设置的访问。
  • 自 WordPress 3.4.0 版本引入,用于扩展自定义器功能。

代码示例

do_action( "customize_preview_{$this->id}", $this );

📄 原文内容

Fires when the WP_Customize_Setting::preview() method is called for settings not handled as theme_mods or options.

Description

The dynamic portion of the hook name, $this->id, refers to the setting ID.

Parameters

$settingWP_Customize_Setting

Source

do_action( "customize_preview_{$this->id}", $this );

Changelog

Version Description
3.4.0 Introduced.