Support

Account

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?