kraftbj / genesis-enews-extended

WordPress widget to provide additional functionality to the Genesis eNews widget.
https://kraft.blog/genesis-enews-extended/
Other
12 stars 15 forks source link

wp_kses_post removes html attributes? #59

Closed kraftbj closed 11 years ago

kraftbj commented 11 years ago

div style="display:none" is stripped to div when div is allowed. Look for workaround (using WP function?)

kraftbj commented 11 years ago

Correction: wp_kses_post is stripping the attribute.

kraftbj commented 11 years ago

Tried both:

global $allowedposttags;

$tags = array( 'div' );
$new_attributes = array( 'style' => array() );

foreach ( $tags as $tag ) {
    if ( isset( $allowedposttags[ $tag ] ) && is_array( $allowedposttags[ $tag ] ) )
        $allowedposttags[ $tag ] = array_merge( $allowedposttags[ $tag ], $new_attributes );
}

and

global $allowedposttags;
$allowedposttags['div'] = array( 'style' => array () );

added, both failed.

kraftbj commented 11 years ago

<div style="test">test</div> works fine; not stripped. <div style="display:none;">test</div> fails.

kraftbj commented 11 years ago

This is intended WP behavior to disallow the display CSS rule inline. Suggested workflow is to add class="example" and add .example { display:none;} via style.css, etc.