wp_kses() strips data attributes even if it’s in the allowed list

I added a function that will return the allowed html tags array if ( ! function_exists( ‘allowed_html_tags’ ) ) { /** * Allowed html tags for wp_kses() function * * @return array Array of allowed html tags. */ function allowed_html_tags() { return array( ‘a’ => array( ‘href’ => array(), ‘title’ => array(), ‘class’ => array(), … Read more

WP Editor strips input placeholder attribute

Why WP Editor also strips the “placeholder” attribute of the input text element ? Ofcourse, i am using the HTML mode. Here is the input: <input type=”text” value=”” name=”s” style=”width: 550px;” placeholder=”Search this website..”> After updating the post (after strip): <input type=”text” value=”” name=”s” style=”width: 550px;”> I do not want WP Editor to strip such … Read more

How to allow data:image attribute in src tag during post insert?

I’m inserting a post using wp_post_insert(). And my post’s content looks like this: <img src=”data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAN4AAAB6CA { … } but on the insert process, WordPress removes the data attribute. So above code becomes this: <img src=”image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAN4AAAB6CA { … } I’ve tried something like this but no luck: function my_filter_allowed_html($allowed, $context){ if (is_array($context)) { return … Read more

What is the difference between strip_tags and wp_filter_nohtml_kses?

What is the difference between strip_tags and wp_filter_nohtml_kses. I tried to figure wp_filter_nohtml_kses from the source but it looks like it does something a bit more complex than strip all html even though thats what the codex says. I think the kses functions are expensive so I wonder why not use strip_tags if all it … Read more