render_block_core_comment_edit_link

函数


render_block_core_comment_edit_link ( $attributes, $content, $block )
参数
  • (array)
    $attributes
    Block attributes.
    Required:
  • (string)
    $content
    Block default content.
    Required:
  • (WP_Block)
    $block
    Block instance.
    Required:
返回值
  • (string) Return the post comment’s date.
定义位置
  • wp-includes/blocks/comment-edit-link.php
    , line 17
引入
弃用

渲染服务器上的`core/comment-edit-link`区块。

function render_block_core_comment_edit_link( $attributes, $content, $block ) {
	if ( ! isset( $block->context['commentId'] ) || ! current_user_can( 'edit_comment', $block->context['commentId'] ) ) {
		return '';
	}

	$edit_comment_link = get_edit_comment_link( $block->context['commentId'] );

	$link_atts = '';

	if ( ! empty( $attributes['linkTarget'] ) ) {
		$link_atts .= sprintf( 'target="%s"', esc_attr( $attributes['linkTarget'] ) );
	}

	$classes = '';
	if ( isset( $attributes['textAlign'] ) ) {
		$classes .= 'has-text-align-' . $attributes['textAlign'];
	}

	$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) );

	return sprintf(
		'
%4$s
', $wrapper_attributes, esc_url( $edit_comment_link ), $link_atts, esc_html__( 'Edit' ) ); }