Created
January 27, 2024 21:43
-
-
Save taricco/21ec8ff62cdcb63804c3444c4fae485c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*** ACF filter to allow unsafe html in certain fields (updated for ACF 6.2.5 Security Release) | |
@link https://wpfieldwork.com/diving-into-acfs-latest-security-release/ | |
–––––––––––––––––––––––––––––––––––––––––––––––––– ***/ | |
add_filter('acf/the_field/allow_unsafe_html', function ($allowed, $atts) { | |
// Ensure $atts is an array and has the 'field' key | |
if (!is_array($atts) || !isset($atts['field'])) { | |
return $allowed; | |
} | |
// List of ACF field names | |
$allowed_fields = [ | |
'wsv_global_after_body_code', | |
'wsv_per_page_footer_code', | |
'wsv_global_footer_code', | |
'wsv_homepage_footer_code', | |
'wsv_per_page_header_code', | |
'wsv_global_header_code', | |
'wsv_homepage_header_code' | |
]; | |
// Check if the current field is in the allowed fields list | |
if (in_array($atts['field'], $allowed_fields)) { | |
return true; | |
} | |
return $allowed; | |
}, 10, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment