wp/wp-includes/blocks/comment-date.php
changeset 21 48c4eec2b7e6
parent 19 3d72ae0968f4
child 22 8c2e4d02f4ef
equal deleted inserted replaced
20:7b1b88e27a20 21:48c4eec2b7e6
     5  * @package WordPress
     5  * @package WordPress
     6  */
     6  */
     7 
     7 
     8 /**
     8 /**
     9  * Renders the `core/comment-date` block on the server.
     9  * Renders the `core/comment-date` block on the server.
       
    10  *
       
    11  * @since 6.0.0
    10  *
    12  *
    11  * @param array    $attributes Block attributes.
    13  * @param array    $attributes Block attributes.
    12  * @param string   $content    Block default content.
    14  * @param string   $content    Block default content.
    13  * @param WP_Block $block      Block instance.
    15  * @param WP_Block $block      Block instance.
    14  * @return string Return the post comment's date.
    16  * @return string Return the post comment's date.
    21 	$comment = get_comment( $block->context['commentId'] );
    23 	$comment = get_comment( $block->context['commentId'] );
    22 	if ( empty( $comment ) ) {
    24 	if ( empty( $comment ) ) {
    23 		return '';
    25 		return '';
    24 	}
    26 	}
    25 
    27 
    26 	$classes = '';
    28 	$classes = ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) ? 'has-link-color' : '';
    27 
    29 
    28 	$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) );
    30 	$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) );
    29 	$formatted_date     = get_comment_date(
    31 	$formatted_date     = get_comment_date(
    30 		isset( $attributes['format'] ) ? $attributes['format'] : '',
    32 		isset( $attributes['format'] ) ? $attributes['format'] : '',
    31 		$comment
    33 		$comment
    44 	);
    46 	);
    45 }
    47 }
    46 
    48 
    47 /**
    49 /**
    48  * Registers the `core/comment-date` block on the server.
    50  * Registers the `core/comment-date` block on the server.
       
    51  *
       
    52  * @since 6.0.0
    49  */
    53  */
    50 function register_block_core_comment_date() {
    54 function register_block_core_comment_date() {
    51 	register_block_type_from_metadata(
    55 	register_block_type_from_metadata(
    52 		__DIR__ . '/comment-date',
    56 		__DIR__ . '/comment-date',
    53 		array(
    57 		array(