Home › Forums › General Issues › Escaping Fields exception › Reply To: Escaping Fields exception
@hube2 now I’ve an other issue with all the fields. This is my code for the specific field exception:
if ( ! function_exists( 'acf_kses_post' ) ) :
function acf_kses_post( $value, $post_id, $field ) {
// exception for specific fields
$header_code = get_field_object('header_code', 'option');
$header_field_key = $header_code['key'];
$footer_code = get_field_object('footer_code', 'option');
$footer_field_key = $footer_code['key'];
if( $field['key'] == $header_field_key || $footer_field_key ) {
return $value;
}
// escaping all fields
if( is_array($value) ) {
return array_map('acf_kses_post', $value);
}
return wp_kses_post( $value );
}
endif;
add_filter('acf/update_value', 'acf_kses_post', 10, 4);
The issue is now I can add <script> tags to all other fields too. Is there anything missing in the code?
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.