Allow custom tags with dashes in kses filter in Wordpress

admin

Administrator
Staff member
I wrote a small Wordpress plugin which allows adding user defined HTML Custom Element Tags (like
Code:
<my-element>
) to the HTML of a Post. So with that a User that doesn't have the capability
Code:
unfiltered_html
is at least capable of using such predefined Custom Tags.

The Problem is if I add a filter like so:

Code:
add_filter('wp_kses_allowed_html', 'returnAllowedCustomTags', 10, 2);
function returnAllowedCustomTags($allowedTags, $context) {
    $myAllowedTags = array('my-element' = > array(), 'myelement' = > array());
    $allowedTags = array_merge($allowedTags, $myAllowedTags);
    return $allowedTags;
}

Saving html
Code:
<myelement>blah</myelement>
is possible. But saving html
Code:
<my-element>blah</my-element>
is not possible. I think this is because before filtering the HTML Tags with dashes are removed from HTML string.

Is there a good solution (without adjust wordpress core files) to prevent wordpress kses from filtering html tags with dashes?

And I don't want to give the users the
Code:
unfiltered_html
capability.