Reputation: 10240
I'm trying to filter the $allowedtags
global in WordPress so that users can submit certain HTML elements only in comments.
This is how I'm currently doing it:
function my_allowed_tags() {
global $allowedtags;
$allowedtags['pre'] = array( 'style' => array() );
}
add_action( 'init', 'my_allowed_tags' );
This now allows the use of <pre>
tags in comments along with a default list of tags that are already allowed by $allowedtags
such as <p>
, <a>
, <img>
etc.
How can I initialise the $allowedtags
global so that no tags are allowed by default?
Ref: http://codex.wordpress.org/Global_Variables#Admin_Globals
Upvotes: 1
Views: 365
Reputation: 4611
Add a filter which resets the global to an empty array before your current action fires.
function reset_allowed_tags() {
global $allowedtags;
$allowedtags = array();
}
add_action('init', 'reset_allowed_tags', 0);
Upvotes: 1