On this page
edit_comment_link( string $text = null, string $before = '', string $after = '' )
Displays the edit comment link with formatting.
Parameters
$textstring Optional-
Anchor text. If null, default is 'Edit This'.
Default:
null $beforestring Optional-
Display before edit link.
Default:
'' $afterstring Optional-
Display after edit link.
Default:
''
Source
File: wp-includes/link-template.php. View all references
function edit_comment_link( $text = null, $before = '', $after = '' ) {
$comment = get_comment();
if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) ) {
return;
}
if ( null === $text ) {
$text = __( 'Edit This' );
}
$link = '<a class="comment-edit-link" href="' . esc_url( get_edit_comment_link( $comment ) ) . '">' . $text . '</a>';
/**
* Filters the comment edit link anchor tag.
*
* @since 2.3.0
*
* @param string $link Anchor tag for the edit link.
* @param string $comment_id Comment ID as a numeric string.
* @param string $text Anchor text.
*/
echo $before . apply_filters( 'edit_comment_link', $link, $comment->comment_ID, $text ) . $after;
}
Hooks
- apply_filters( 'edit_comment_link',
string $link ,string $comment_id ,string $text ) -
Filters the comment edit link anchor tag.
Related
Uses
| Uses | Description |
|---|---|
| get_edit_comment_link() wp-includes/link-template.php | Retrieves the edit comment link. |
| current_user_can() wp-includes/capabilities.php | Returns whether the current user has the specified capability. |
| __() wp-includes/l10n.php | Retrieves the translation of $text. |
| esc_url() wp-includes/formatting.php | Checks and cleans a URL. |
| apply_filters() wp-includes/plugin.php | Calls the callback functions that have been added to a filter hook. |
| get_comment() wp-includes/comment.php | Retrieves comment data given a comment ID or comment object. |
Used By
| Used By | Description |
|---|---|
| Walker_Comment::comment() wp-includes/class-walker-comment.php | Outputs a single comment. |
| Walker_Comment::html5_comment() wp-includes/class-walker-comment.php | Outputs a comment in the HTML5 format. |
| Walker_Comment::ping() wp-includes/class-walker-comment.php | Outputs a pingback comment. |
Changelog
| Version | Description |
|---|---|
| 1.0.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/edit_comment_link