I'm a bit unfamiliar with WP development... but what I'm trying to achieve is basically:
Query all current posts
Run wp_kses on all the post's content?
What I'm trying so far in functions.php
I am using WordPresses wp_kses() function to sanitize html before saving post content. I have specified that it should preserve all div attributes that begin with tb-*. However, the function is still removing these html attributes.
Do you know why
When writing code that accepts input from users I always sanitize data one variable at a time.
Example:
$title = wp_strip_all_tags($_POST['title']);
$content = wp_strip_all_tags($_POST['content']);
I had the idea of simplifying things by sanitizing everyt
In my Custom Post Type (CPT), I altered the display of the post title using the method mentioned here. But for my custom use case, I need to pass some HTML like <sup></sup>. But by default WP List Table clas
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 below
I am using below code for wp_kses(). But it's ignoring rel & target in the result. I want to show rel="nofolow" target="_blank" in my result (link).
$allowed_tags= array(
'br' => array(),
'p' => array(),
I am using below code for wp_kses(). But it's ignoring rel & target in the result. I want to show rel="nofolow" target="_blank" in my result (link).
$allowed_tags= array(
'br' => array(),
'p' => array(),
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(