get_edit_comment_link()
Retrieves the edit comment link.
Uses: admin_url()
Used By: edit_comment_link()
1 time — 0.0028741 sec (very slow) | 50000 times — 6.57 sec (fast) | PHP 7.3.12, WP 5.3.2
Hooks from the function
Return
String|null
. The edit comment link URL for the given comment.
Usage
get_edit_comment_link( $comment_id );
- $comment_id(int|WP_Comment)
- Comment ID or WP_Comment object.
Examples
#1 Get the link (URL) to edit the comment
echo get_edit_comment_link( 2020 ); // http://example.com/wp-admin/comment.php?action=editcomment&c=2020
#2 Get a full-fledged link
This example is analogous to what the edit_comment_link() function returns:
echo '<a class="comment-edit-link" href="' . get_edit_comment_link( 2020 ) . '">✎</a>';
Changelog
Since 2.3.0 | Introduced. |
get_edit_comment_link() get edit comment link code WP 6.1.1
function get_edit_comment_link( $comment_id = 0 ) { $comment = get_comment( $comment_id ); if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) ) { return; } $location = admin_url( 'comment.php?action=editcomment&c=' ) . $comment->comment_ID; /** * Filters the comment edit link. * * @since 2.3.0 * * @param string $location The edit link. */ return apply_filters( 'get_edit_comment_link', $location ); }