WPML
apply_filters( $custom_field_val, $custom_field_name )
类型
filter
WPML 版本
4.1.0

说明

自定义字段可能会以 WPML 无法理解的格式进行编码。在 WPML 能够翻译这些字段之前,必须先对其进行解码和编码。为了实现这一点,必须使用 wpml_decode_custom_fieldwpml_encode_custom_field 过滤器。如果除了 WPML 已经处理的编码之外还有其他自定义编码,则可以使用这些过滤器。

参数

$custom_field_val
需要编码的字段中包含的值
$custom_field_name
需要编码的字段名称

使用示例

示例
add_filter( 'wpml_encode_custom_field', 'my_encode_function', 10, 2 );

function my_encode_function( $custom_field_val, $custom_field_name ) {
   if ( $custom_field_name === 'my-special-field' ) {
      $custom_field_val = my_special_encoding_function( $custom_field_val );
   }

  return $custom_field_val;
}

wpml_decode_custom_field, wpml_footer_language_selector, wpml_add_language_form_field, wpml_ls_exclude_in_menu, wpml_is_rtl, wpml_alternate_hreflang, wpml_head_langs, wpml_must_translate_canonical_url, wpml_browser_redirect_language_params, wpml_active_languages

所有 29 个 全站语言信息 钩子 →