apply_filters( $custom_field_val, $custom_field_name )
- Loại
- filter
- Danh mục
- Thông tin ngôn ngữ toàn trang web
- Phiên bản WPML
- 4.1.0
Miêu tả
Các trường tùy chỉnh có thể được mã hóa theo một định dạng mà WPML không hiểu. Các trường đó phải được giải mã và mã hóa trước khi WPML có thể dịch chúng. Để thực hiện điều này, phải sử dụng các bộ lọc wpml_decode_custom_field và wpml_encode_custom_field. Các bộ lọc này có thể được sử dụng nếu có mã hóa tùy chỉnh bổ sung ngoài những mã hóa đã được WPML xử lý.
Đối số
- $custom_field_val
- Giá trị chứa trong trường cần được giải mã
- $custom_field_name
- Tên của trường cần được giải mã
Ví dụ sử dụng
Ví dụ
add_filter( 'wpml_decode_custom_field', 'my_decode_function', 10, 2 );
function my_decode_function( $custom_field_val, $custom_field_name ) {
if ( $custom_field_name === 'my-special-field' ) {
$custom_field_val = my_special_decoding_function( $custom_field_val );
}
return $custom_field_val;
}
Các hook liên quan
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, wpml_encode_custom_field