[wp-trac] [WordPress Trac] #43215: Allow wp_kses to pass allowed CSS properties

WordPress Trac noreply at wordpress.org
Thu Jan 16 07:15:25 UTC 2025


#43215: Allow wp_kses to pass allowed CSS properties
-----------------------------+------------------------------
 Reporter:  mclaurent        |       Owner:  (none)
     Type:  feature request  |      Status:  new
 Priority:  normal           |   Milestone:  Awaiting Review
Component:  Security         |     Version:  4.9.2
 Severity:  normal           |  Resolution:
 Keywords:                   |     Focuses:
-----------------------------+------------------------------

Comment (by davidtheplumber):

 Submit a feature request to WordPress Core to allow per-element and per-
 attribute configuration within the $allowed_html array. Until then, fork
 wp_kses for your project:

 {{{
 $allowed_output_html = array(
     'script' => array(),
     'noscript' => array(),
     'iframe' => array(
         'src' => array(),
         'width' => array(),
         'height' => array(),
         'style' => array('display', 'visibility'),
     ),
 );

 $google_tag_manager_noscript = <<<ENDSTRING
 <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=123"
     height="0" width="0"
 style="display:none;visibility:hidden"></iframe></noscript>
 ENDSTRING;

 echo my_custom_wp_kses($google_tag_manager_noscript, $allowed_output_html,
 $allowed_output_protocol);
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/43215#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list