admin管理员组

文章数量:1279055

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);

本文标签: phpwpksesallowedhtml not triggered on WP frontendStack Overflow