get_comment_author_url_link

Retrieves the HTML link of the url of the author of the current comment.

Description

(string) get_comment_author_url_link( (string) $linktext = '', (string) $before = '', (string) $after = '', (int) $comment = 0 ); 

$linktext parameter is only used if the URL does not exist for the comment author. If the URL does exist then the URL will be used and the $linktext will be ignored.

Encapsulate the HTML link between the $before and $after. So it will appear in the order of $before, link, and finally $after.

Returns (string)

The HTML link between the $before and $after parameters.

Parameters (4)

0. $linktext — Optional. (string) => ''
The text to display instead of the comment author's email address. Default empty.
1. $before — Optional. (string) => ''
The text or HTML to display before the email link. Default empty.
2. $after — Optional. (string) => ''
The text or HTML to display after the email link. Default empty.
3. $comment — Optional. (int)
Comment ID or WP_Comment object. Default is the current comment.

Usage

  1. if ( !function_exists( 'get_comment_author_url_link' ) ) { 
  2. require_once ABSPATH . WPINC . '/comment-template.php'; 
  3.  
  4. // Optional. The text to display instead of the comment 
  5. // author's email address. Default empty. 
  6. $linktext = ''; 
  7.  
  8. // Optional. The text or HTML to display before the email link. 
  9. // Default empty. 
  10. $before = ''; 
  11.  
  12. // Optional. The text or HTML to display after the email link. 
  13. // Default empty. 
  14. $after = ''; 
  15.  
  16. // Optional. Comment ID or WP_Comment object. 
  17. // Default is the current comment. 
  18. $comment = -1; 
  19.  
  20. // NOTICE! Understand what this does before running. 
  21. $result = get_comment_author_url_link($linktext, $before, $after, $comment); 
  22.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/comment-template.php  
  1. function get_comment_author_url_link( $linktext = '', $before = '', $after = '', $comment = 0 ) { 
  2. $url = get_comment_author_url( $comment ); 
  3. $display = ($linktext != '') ? $linktext : $url; 
  4. $display = str_replace( 'http://www.', '', $display ); 
  5. $display = str_replace( 'http://', '', $display ); 
  6.  
  7. if ( '/' == substr($display, -1) ) { 
  8. $display = substr($display, 0, -1); 
  9.  
  10. $return = "$before<a href='$url' rel='external'>$display</a>$after"; 
  11.  
  12. /** 
  13. * Filters the comment author's returned URL link. 
  14. * @since 1.5.0 
  15. * @param string $return The HTML-formatted comment author URL link. 
  16. */