Skip to content

Instantly share code, notes, and snippets.

@taricco
Created January 27, 2024 21:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taricco/21ec8ff62cdcb63804c3444c4fae485c to your computer and use it in GitHub Desktop.
Save taricco/21ec8ff62cdcb63804c3444c4fae485c to your computer and use it in GitHub Desktop.
/*** 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