On this page
get_comment_to_edit( int $id ): WP_Comment|false
Returns a WP_Comment object based on comment ID.
Parameters
$idint Required-
ID of comment to retrieve.
Return
WP_Comment|false Comment if found. False on failure.
Source
File: wp-admin/includes/comment.php. View all references
function get_comment_to_edit( $id ) {
$comment = get_comment( $id );
if ( ! $comment ) {
return false;
}
$comment->comment_ID = (int) $comment->comment_ID;
$comment->comment_post_ID = (int) $comment->comment_post_ID;
$comment->comment_content = format_to_edit( $comment->comment_content );
/**
* Filters the comment content before editing.
*
* @since 2.0.0
*
* @param string $comment_content Comment content.
*/
$comment->comment_content = apply_filters( 'comment_edit_pre', $comment->comment_content );
$comment->comment_author = format_to_edit( $comment->comment_author );
$comment->comment_author_email = format_to_edit( $comment->comment_author_email );
$comment->comment_author_url = format_to_edit( $comment->comment_author_url );
$comment->comment_author_url = esc_url( $comment->comment_author_url );
return $comment;
}
Hooks
- apply_filters( 'comment_edit_pre',
string $comment_content ) -
Filters the comment content before editing.
Related
Uses
| Uses | Description |
|---|---|
| format_to_edit() wp-includes/formatting.php | Acts on text which is about to be edited. |
| 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. |
Changelog
| Version | Description |
|---|---|
| 2.0.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/get_comment_to_edit