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 này 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, cần 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ó thêm mã hóa tùy chỉnh 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 mã hóa
- $custom_field_name
- Tên của trường cần được mã hóa
Ví dụ sử dụng
Ví dụ
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;
}
Các hook liên quan
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