I need to filter the $atts
array for every shortcode (either every shortcode registered or just every shortcode in page) but can’t find a way which also caters for situations in which the attribute names may not be known beforehand.
Example: [shortcode known_attribute="value" 8c69f120="unknown attribute"]
I tried by looping through $GLOBALS['shortcode_tags']
and using the shortcode_atts_{$shortcode}
filter but because shortcode_atts
is a combination of array_merge
and unset atts not in $pairs
array, this won’t work.
Does anyone know how to apply a filter to $atts
for every shortcode in a way which caters for shortcodes for which attribute names cannot necessarily be known beforehand?
I’m not sure what you’re trying to do exactly, but you can catch any attribute and modify (or unset) the corresponding output with something like the following:
One important caveat: shortcodes are not required to define the third
$shortcode
parameter, which is essential for the$shortcode_atts_{$shortcode}
filter to do its thing.