[wp-trac] [WordPress Trac] #62644: Editing comments as an admin, in the Admin UI, filters the HTML elements of the comment as though the edit was done by the original author.

WordPress Trac noreply at wordpress.org
Thu Dec 5 14:26:36 UTC 2024


#62644: Editing comments as an admin, in the Admin UI, filters the HTML elements of
the comment as though the edit was done by the original author.
--------------------------+------------------------------
 Reporter:  turbodb       |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Comments      |     Version:  6.7.1
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------

Comment (by siliconforks):

 Did you try using the `wp_kses_allowed_html` filter, as suggested in the
 forum topic?

 Example:

 {{{#!php
 <?php

 function my_wp_kses_allowed_html_for_comments( $html, $context ) {
         if ( 'pre_comment_content' === $context ) {
                 $html['img'] = [
                         'src'=> true,
                         'class'=> true,
                         'style'=> true,
                         'alt'=> true
                 ];
         }
         return $html;
 }

 add_filter( 'wp_kses_allowed_html',
 'my_wp_kses_allowed_html_for_comments', 10, 2 );
 }}}

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


More information about the wp-trac mailing list