[wp-trac] [WordPress Trac] #48635: Comment link output redux

WordPress Trac noreply at wordpress.org
Tue Jan 28 05:50:08 UTC 2020


#48635: Comment link output redux
--------------------------+----------------------
 Reporter:  johnh10       |       Owner:  (none)
     Type:  defect (bug)  |      Status:  closed
 Priority:  normal        |   Milestone:
Component:  Privacy       |     Version:
 Severity:  normal        |  Resolution:  invalid
 Keywords:                |     Focuses:
--------------------------+----------------------
Changes (by garrett-eclipse):

 * status:  new => closed
 * resolution:   => invalid
 * milestone:  Awaiting Review =>


Comment:

 Hi @johnh10

 Reviewing the Comment List Table and it's column_author implementation it
 looks like you're looking at either the `get_comment_author_IP` or
 `get_comment_author_url` filters. Bother of these filters are used for
 generating the link and text for their respective links and as such I
 wouldn't suggest latching into them to change their expected return to
 display custom HTML. It's expected these results would be run through
 esc_url for the link, and you wouldn't want to put display in something
 that's used within the href.

 Instead to introduce custom dom in the column you have a couple options;
 1. Replace the column using the available filters for introducing your own
 custom column.
 2. Use JS to introduce your change.

 I'll quickly cover #1 as they're WP filters.

 {{{#!php
 <?php
 function my_comment_columns( $columns )
 {
         unset( $columns['author'] );
         $mycolumns['my_author_column'] = __( 'My Author Column' );
         return $mycolumns + $columns;
 }
 add_filter( 'manage_edit-comments_columns', 'my_comment_columns' );
 }}}

 {{{#!php
 <?php
 function my_comment_author_column( $column, $comment_ID )
 {
         if ( 'my_author_column' == $column ) {
                 // Add Custom Logic Here
                 echo 'Custom Author Data for ID: ' . $comment_ID;
         }
 }
 add_filter( 'manage_comments_custom_column', 'my_comment_author_column',
 10, 2 );
 }}}

 References;
 https://codex.wordpress.org/Plugin_API/Filter_Reference/manage_edit-
 post_type_columns
 https://developer.wordpress.org/reference/hooks/manage_comments_custom_column/

 As there's filters to allow you to replace the column as you see fit and
 the filters you're looking at are expected to be escaped I'm going to
 close this as invalid. Feel free to reopen for further discussion is I've
 misunderstood the issue here.

 All the best

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


More information about the wp-trac mailing list