3

I would like to use $allowedposttags to allow extra HTML tags during entry submission. Can I allow all attributes for a specific tag using $allowedposttags?

For example, the code below will allow iframe tags and the src, height, and width attributes in the iframe tags:

$allowedposttags['iframe'] = array(
    'src' => array(),
    'height' => array(),
    'width' => array()
);

How can I allow all attributes in this example, not just src, height, and width?

2
  • I'm starting to think that this isn't possible with just $allowedposttags. On line 718 of wp-includes/kses.php, attributes that aren't present in $allowedposttags are skipped. Nov 12, 2012 at 19:20
  • 1
    kses is designed to be a whitelist. There's no option to allow unlimited attributes without rewriting a lot of it. This is for safety.
    – Otto
    Nov 13, 2012 at 1:33

1 Answer 1

4

I'm pretty sure you have to explicitly name all allowed attributes - just use:

$allowedposttags['iframe'] = array (
    'align'       => true,
    'frameborder' => true,
    'height'      => true,
    'width'       => true,
    'sandbox'     => true,
    'seamless'    => true,
    'scrolling'   => true,
    'srcdoc'      => true,
    'src'         => true,
    'class'       => true,
    'id'          => true,
    'style'       => true,
    'border'      => true,
);

If you can think of others let me know!

1
  • 1
    Skies the limit, I think. If we don't count custom attributes, the spec has the definitive list, I believe. Nov 12, 2012 at 19:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.