wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



get_edit_comment_link › WordPress Function

Seit2.3.0
Veraltetn/v
get_edit_comment_link ( $comment_id = 0, $context = 'display' )
Parameter: (2)
  • (int|WP_Comment) $comment_id Optional. Comment ID or WP_Comment object.
    Erforderlich: Nein
    Standard:
  • (string) $context Optional. Context in which the URL should be used. Either 'display', to include HTML entities, or 'url'. Default 'display'.
    Erforderlich: Nein
    Standard: 'display'
Gibt zurück:
  • (string|void) The edit comment link URL for the given comment, or void if the comment id does not exist or the current user is not allowed to edit it.
Definiert in:
Codex:
Changelog:
  • 6.7.0

Retrieves the edit comment link.



Quellcode

function get_edit_comment_link( $comment_id = 0, $context = 'display' ) {
	$comment = get_comment( $comment_id );

	if ( ! is_object( $comment ) || ! current_user_can( 'edit_comment', $comment->comment_ID ) ) {
		return;
	}

	if ( 'display' === $context ) {
		$action = 'comment.php?action=editcomment&c=';
	} else {
		$action = 'comment.php?action=editcomment&c=';
	}

	$location = admin_url( $action ) . $comment->comment_ID;

	// Ensure the $comment_id variable passed to the filter is always an ID.
	$comment_id = (int) $comment->comment_ID;

	/**
	 * Filters the comment edit link.
	 *
	 * @since 2.3.0
	 * @since 6.7.0 The $comment_id and $context parameters are now being passed to the filter.
	 *
	 * @param string $location   The edit link.
	 * @param int    $comment_id Unique ID of the comment to generate an edit link.
	 * @param string $context    Context to include HTML entities in link. Default 'display'.
	 */
	return apply_filters( 'get_edit_comment_link', $location, $comment_id, $context );
}