函数文档

wp_get_duotone_filter_id()

💡 云策文档标注

概述

wp_get_duotone_filter_id() 函数用于生成双色调滤镜的 CSS id,但已在 WordPress 6.3.0 版本中弃用,建议使用替代方法。

关键要点

  • 函数返回双色调滤镜的带前缀 id,适用于 CSS 选择器。
  • 参数 $preset 是必需的,表示 theme.json 中定义的双色调预设值。
  • 返回值类型为字符串,即双色调滤镜的 CSS id。
  • 此函数在 WordPress 6.3.0 版本中被弃用,内部调用 WP_Duotone::get_filter_id_from_preset() 方法。
  • 函数最初在 WordPress 5.9.1 版本中引入。

注意事项

由于函数已弃用,开发者应避免在新代码中使用,转而使用 WP_Duotone::get_filter_id_from_preset() 方法。


📄 原文内容

Returns the prefixed id for the duotone filter for use as a CSS id.

Parameters

$presetarrayrequired
Duotone preset value as seen in theme.json.

Return

string Duotone filter CSS id.

Source

function wp_get_duotone_filter_id( $preset ) {
	_deprecated_function( __FUNCTION__, '6.3.0' );
	return WP_Duotone::get_filter_id_from_preset( $preset );
}

Changelog

Version Description
6.3.0 Deprecated.
5.9.1 Introduced.