Why do_shortcode is not executing the shortcode in data-* html attributes?

do_shortcodes_in_html_tags() runs attributes through wp_kses_one_attr() which checks them against wp_kses_allowed_html( 'post' ) which by default only accepts standard non-data attributes, so you’d have to add your attribute:

add_filter( 'wp_kses_allowed_html', function ( $allowedposttags, $context ) {
    if ( $context == 'post' ) {
        $allowedposttags['a']['data-abc'] = 1;
    }
    return $allowedposttags;
}, 10, 2 );

Leave a Comment