edit_comment_link

函式
edit_comment_link ( $text = null, $before = '', $after = '' )
引數
  • (string) $text Optional. Anchor text. If null, default is 'Edit This'. Default null.
    Required:
    Default: null
  • (string) $before Optional. Display before edit link. Default empty.
    Required:
    Default: (empty)
  • (string) $after Optional. Display after edit link. Default empty.
    Required:
    Default: (empty)
定義位置
相關方法
get_comment_linkget_edit_comment_linkget_comments_linknext_comments_linkedit_comment
引入
1.0.0
棄用
-

edit_comment_link: 這個函式生成一個連結,用於在WordPress管理面板中編輯一個指定的評論。

顯示帶有格式的編輯註釋連結。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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;
}
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; }
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;
}

常見問題

FAQs
檢視更多 >