[wp-trac] [WordPress Trac] #32992: Allow make_clickable() to add target="_blank"

WordPress Trac noreply at wordpress.org
Mon Jul 20 16:12:32 UTC 2015


#32992: Allow make_clickable() to add target="_blank"
---------------------------+--------------------------------
 Reporter:  nicolamustone  |       Owner:
     Type:  enhancement    |      Status:  new
 Priority:  normal         |   Milestone:  Awaiting Review
Component:  Formatting     |     Version:  trunk
 Severity:  normal         |  Resolution:
 Keywords:                 |     Focuses:  ui, accessibility
---------------------------+--------------------------------

Comment (by joedolson):

 It's not difficult to test whether or not a string is a URL; assuming
 you're working with a PHP version above 5.2.0, you can use this:

 {{{

 if (filter_var($field, FILTER_VALIDATE_URL) === FALSE) {
    $return = "<a href='" . esc_url( $field ) . "'>" . esc_url( $field ) .
 "</a>";
 } else {
    $return = esc_html( $field );
 }
 }}}


 http://php.net/manual/en/function.filter-var.php

 I think that your use case is an outlier use case, and probably not ideal
 for core.

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


More information about the wp-trac mailing list