[wp-trac] [WordPress Trac] #51082: Default value for comment_type changed can lead to comments not shown

WordPress Trac noreply at wordpress.org
Wed Sep 2 00:00:02 UTC 2020


#51082: Default value for comment_type changed can lead to comments not shown
--------------------------+------------------------------
 Reporter:  Ov3rfly       |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Comments      |     Version:  5.5
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------

Comment (by SergeyBiryukov):

 Replying to [ticket:51082 Ov3rfly]:
 > The theme in question uses a callback function for `wp_list_comments()`
 with this code:
 >
 > {{{
 > switch ( $comment->comment_type ) :
 >       case '' :
 >               // print normal comment here...
 >               break;
 >       case 'pingback'  :
 >       case 'trackback' :
 >               break;
 > endswitch;
 > }}}

 Here's a workaround for any themes using that pattern:
 {{{
 function wp51082_restore_empty_comment_type_on_frontend( $comment ) {
         if ( ! is_admin() && 'comment' === $comment->comment_type ) {
                 $comment->comment_type = '';
         }

         return $comment;
 }
 add_filter( 'get_comment',
 'wp51082_restore_empty_comment_type_on_frontend' );
 }}}

 In my testing, this makes comments display again an older version of
 Twenty Ten, before it was updated in [47597].

 I don't have any Artisteer themes to test, but it should probably work for
 them too.

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


More information about the wp-trac mailing list