函数文档

wp_get_duotone_filter_property()

💡 云策文档标注

概述

wp_get_duotone_filter_property() 函数用于返回 CSS filter 属性的 URL 值,以引用渲染的 SVG 双色调滤镜。该函数已在 WordPress 6.3.0 版本中被弃用。

关键要点

  • 函数返回 CSS filter 属性的 URL 值,用于引用双色调滤镜的 SVG 渲染。
  • 接受一个必需参数 $preset,表示 theme.json 中定义的双色调预设值。
  • 自 WordPress 6.3.0 起被弃用,建议使用 WP_Duotone::get_filter_css_property_value_from_preset() 替代。
  • 函数内部调用 _deprecated_function() 标记弃用,并转发到 WP_Duotone 类的方法。

代码示例

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

注意事项

  • 该函数已弃用,开发者应避免在新代码中使用,并迁移到 WP_Duotone::get_filter_css_property_value_from_preset()。
  • 参数 $preset 必须为有效的双色调预设数组,通常来自 theme.json 配置。
  • 弃用信息会在函数被调用时触发,帮助开发者识别和更新代码。

📄 原文内容

Returns the CSS filter property url to reference the rendered SVG.

Parameters

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

Return

string Duotone CSS filter property url value.

Source

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

Changelog

Version Description
6.3.0 Deprecated.
6.1.0 Allow unset for preset colors.
5.9.0 Introduced.