What are allowedposttags and allowedtags?

The question:

I have been going crazy trying to google up what these globals are. What are allowedposttags and allowedtags? What is the difference between the two? Is there a list of all WP Globals and an explanation of what they are?

For MCE Editor – to allow users not logged in to use lists and underline + strikethrough add following:

add_action('init', 'my_html_tags_code', 10);
function my_html_tags_code() {
  global $allowedposttags, $allowedtags;
    //$allowedposttags["ol"] = array();
    //$allowedposttags["ul"] = array();
    $allowedtags["ol"] = array();
    $allowedtags["ul"] = array();
    $allowedtags["li"] = array();
    $allowedtags["span"] = array( "style" => array() );

The Solutions:

Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.

Method 1

These are arrays that are used by the wp_kses library. Basically they are white lists of html tags and attributes that WordPress allows in posts and comments. If memory serves correctly, “allowedposttags” is used for sanitizing post_content while “allowedtags” is used for comments.

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Comment