1

I have come up with two ways I thought this should work and I'm having no joy with either.

First I tried hooking into the preprocess_comment filter.

// Set allowed html in comments.
add_filter( 'preprocess_comment', 'csm_filter_allowed_comment_html' );

function csm_filter_allowed_comment_html( $comment ) {

    global $allowedtags;

    $allowedtags['a'] = array(
        'href' => array(),
        'title' => array(),
        'rel' => array(),
        'data-flw' => array(),
    );
    return $comment;
}

But this did not allow me to use data-flw="true" in my comment anchors.

Then I thought, maybe I needed to do it earlier and bigger, so I tried just adding the filter to the { init }, figuring that the array would be altered already when a comment came along.

// Set allowed html in comments.
add_filter( 'init', 'csm_filter_allowed_comment_html' );

function csm_filter_allowed_comment_html() {

    global $allowedtags;

    $allowedtags['a'] = array(
        'href' => array(),
        'title' => array(),
        'rel' => array(),
        'data-flw' => array(),
    );
}

Still nothing. I've read through the kses.php and I've searched for examples, most of the few I've found suggest my first attempt should work. I'm at a loss for where I've gone wrong here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.