Definition:
function get_comment_link( $comment = null, $args = array() {}
Retrieve the link to a given comment.
Parameters
- object|string|int $comment: Comment to retrieve.
- array $args: Optional args.
Return values
returns:The permalink to the given comment.
Defined filters
- get_comment_link
apply_filters( 'get_comment_link', $link . '#comment-' . $comment->comment_ID, $comment, $args )
Source code
function get_comment_link( $comment = null, $args = array() ) { global $wp_rewrite, $in_comment_loop; $comment = get_comment($comment); // Backwards compat if ( !is_array($args) ) { $page = $args; $args = array(); $args['page'] = $page; } $defaults = array( 'type' => 'all', 'page' => '', 'per_page' => '', 'max_depth' => '' ); $args = wp_parse_args( $args, $defaults ); if ( '' === $args['per_page'] && get_option('page_comments') ) $args['per_page'] = get_option('comments_per_page'); if ( empty($args['per_page']) ) { $args['per_page'] = 0; $args['page'] = 0; } if ( $args['per_page'] ) { if ( '' == $args['page'] ) $args['page'] = ( !empty($in_comment_loop) ) ? get_query_var('cpage') : get_page_of_comment( $comment->comment_ID, $args ); if ( $wp_rewrite->using_permalinks() ) $link = user_trailingslashit( trailingslashit( get_permalink( $comment->comment_post_ID ) ) . 'comment-page-' . $args['page'], 'comment' ); else $link = add_query_arg( 'cpage', $args['page'], get_permalink( $comment->comment_post_ID ) ); } else { $link = get_permalink( $comment->comment_post_ID ); } return apply_filters( 'get_comment_link', $link . '#comment-' . $comment->comment_ID, $comment, $args ); }
1320
No comments yet... Be the first to leave a reply!