WordPress.org

Make WordPress Core

Opened 11 months ago

Closed 9 months ago

Last modified 9 months ago

#48635 closed defect (bug) (invalid)

Comment link output redux

Reported by: johnh10 Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Privacy Keywords:
Focuses: Cc:

Description

This is a follow-up to #44054.

With these changes, a user is unable to filter the link outside of strict conditions.

For instance, I want to highlight or mark certain comment author IPs using filters. Before, I could use inline css to change the color to be very visible. That no longer works.

I also tried surrounding the IP with exclamation points but it's not as good.

In either case, the same value is used for the href as well as the anchor text, which means clicking the modified author IP no longer works as expected. Shouldn't the href be the original, unfiltered IP value?

Attachments (2)

Capture1.JPG (13.7 KB) - added by johnh10 11 months ago.
Example of modified comment_author_link with inline css
Capture2.JPG (11.3 KB) - added by johnh10 11 months ago.
Example of modified comment_author_link with extra chars

Download all attachments as: .zip

Change History (5)

@johnh10
11 months ago

Example of modified comment_author_link with inline css

@johnh10
11 months ago

Example of modified comment_author_link with extra chars

#1 follow-up: @Otto42
11 months ago

The change in that ticket only escapes output for the wp_comments_personal_data_exporter() function, it doesn't have anything to do with filtering output for the comment IP address where your images show.

The escaping of the data you appear to be pointing at is in the comments list table, and that change was made 4 years ago: https://core.trac.wordpress.org/changeset/35748

#2 in reply to: ↑ 1 @johnh10
11 months ago

Replying to Otto42:

The change in that ticket only escapes output for the wp_comments_personal_data_exporter() function, it doesn't have anything to do with filtering output for the comment IP address where your images show.

The escaping of the data you appear to be pointing at is in the comments list table, and that change was made 4 years ago: https://core.trac.wordpress.org/changeset/35748

Sorry if I was in the wrong code section.

I guess the question is, should the user be able to filter the comment author IP anchor text with styling? Without changing the href of the comment author IP?

Should the changes in the attached screenshots be allowed or denied?

#3 @garrett-eclipse
9 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

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
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
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

Last edited 9 months ago by garrett-eclipse (previous) (diff)
Note: See TracTickets for help on using tickets.