Jordy
Jordy

Reputation: 4809

wp_kses_allowed_html not triggered on WP frontend

I'm a bit confused. Why is the wp_kses_allowed_html hook not triggered on the frontend of my WordPress website, but it is on the wp-admin backend?

I have added the code below to the very top of my plugin file. I want it to allow a custom data attribute on an <a> element.

add_filter('wp_kses_allowed_html', function($allowed_tags, $context) {

    error_log("wp_kses_allowed_html triggered");

    if (!isset($allowed_tags['a'])) {
        $allowed_tags['a'] = array();
    }
    
    $allowed_tags['a']['data-custom-attribute'] = true;
    
    return $allowed_tags;
}, 10, 2);

Upvotes: 0

Views: 35

Answers (0)

Related Questions