Make WordPress Core

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#38680 closed enhancement (wontfix)

get_comment_author_link must be target blank

Reported by: vaibhav8275's profile vaibhav8275 Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Comments Keywords: target-blank has-patch
Focuses: accessibility, template Cc:

Description

In comment-template.php

get_comment_author_link function must return target='_blank' for comment author link, no one likes users leave there website just by clicking comment author link.

<?php
function get_comment_author_link( $comment_ID = 0 ) {
        $comment = get_comment( $comment_ID );
        $url     = get_comment_author_url( $comment );
        $author  = get_comment_author( $comment );

        if ( empty( $url ) || 'http://' == $url )
                $return = $author;
        else
                $return = "<a target='_blank' href='$url' rel='external nofollow' class='url'>$author</a>";

        /**
         * Filters the comment author's link for display.
         *
         * @since 1.5.0
         * @since 4.1.0 The `$author` and `$comment_ID` parameters were added.
         *
         * @param string $return     The HTML-formatted comment author link.
         *                           Empty for an invalid URL.
         * @param string $author     The comment author's username.
         * @param int    $comment_ID The comment ID.
         */
        return apply_filters( 'get_comment_author_link', $return, $author, $comment->comment_ID );
}

Attachments (1)

38680.patch (546 bytes) - added by mayurk 8 years ago.

Download all attachments as: .zip

Change History (9)

#1 @afercia
8 years ago

  • Keywords target-blank added
  • Milestone changed from Awaiting Review to Future Release
  • Version 4.6.1 deleted

Thanks @vaibhav8275 and welcome to Trac! There's an ongoing discussion about target="_blank" in the admin, see #23432 and many of these attributes were recently removed for better accessibility.

About the front-end, personally I think WordPress shouldn't encourage the usage of target="_blank" so it shouldn't be included in the default output. Worth noting there's the get_comment_author_link filter that can be used to completely customize the link. So if themes really want to add target="_blank", they already can.

However, the ongoing discussion has focused mainly on the admin screens so far, so there's the need to start taking into consideration what is the better option for the front-end too. Discussion can happen on this ticket or also on Slack, any feedback welcome.

#2 @afercia
8 years ago

  • Focuses accessibility added

@mayurk
8 years ago

#3 @mayurk
8 years ago

  • Keywords has-patch added

I have attached patch for above change.

#4 @afercia
8 years ago

no one likes users leave there website

I'd argue that if users open a link to an external website in a new tab, either intentionally or following a link with target="blank", they actually leave your website because they're focusing their attention on the new tab.
The fact that your website is still open in a background tab may make your statistics tool happy, but the truth is your users are not really "visiting" your website any longer.

For accessibility reasons, WordPress should not encourage the usage of target="blank" and should let users have full control of their browsers instead. If users really want to open links in new tabs, they can do that: major browsers introduced tabs about 10 years ago and I guess users are pretty familiar with the idea of tabbed navigation.

Using target="blank" may still make sense in very limited cases, for example in the admin when navigating away from a page would cause a data loss. In that case users should be clearly informed activating the link is going to open a new tab. I'd strongly recommend to avoid any other usage.

#5 @joedolson
8 years ago

no one likes users leave there website

On this point, I would also comment that it is not the site owner's place to control whether or not a user has left their website; that is something that the user themselves is in charge of. Opening the link in a new tab just means it's slightly more work for the user to close your site.

#6 @peterwilsoncc
8 years ago

  • Keywords close added

I agree with @afercia's comment above:

WordPress should not encourage the usage of target="blank" and should let users have full control of their browsers instead.

There are numerous accessibility problems with this approach and site owners can use the filter.

#7 @SergeyBiryukov
8 years ago

  • Keywords close removed
  • Milestone Future Release deleted
  • Resolution set to wontfix
  • Status changed from new to closed

This ticket was mentioned in Slack in #accessibility by afercia. View the logs.


8 years ago

Note: See TracTickets for help on using tickets.