wp/wp-includes/blocks/post-date.php
changeset 19 3d72ae0968f4
parent 18 be944660c56a
child 21 48c4eec2b7e6
equal deleted inserted replaced
18:be944660c56a 19:3d72ae0968f4
    19 	}
    19 	}
    20 
    20 
    21 	$post_ID            = $block->context['postId'];
    21 	$post_ID            = $block->context['postId'];
    22 	$align_class_name   = empty( $attributes['textAlign'] ) ? '' : "has-text-align-{$attributes['textAlign']}";
    22 	$align_class_name   = empty( $attributes['textAlign'] ) ? '' : "has-text-align-{$attributes['textAlign']}";
    23 	$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $align_class_name ) );
    23 	$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $align_class_name ) );
    24 	$formatted_date     = get_the_date( isset( $attributes['format'] ) ? $attributes['format'] : '', $post_ID );
    24 	$formatted_date     = get_the_date( empty( $attributes['format'] ) ? '' : $attributes['format'], $post_ID );
    25 	if ( isset( $attributes['isLink'] ) && $attributes['isLink'] ) {
    25 	if ( isset( $attributes['isLink'] ) && $attributes['isLink'] ) {
    26 		$formatted_date = sprintf( '<a href="%1s">%2s</a>', get_the_permalink( $post_ID ), $formatted_date );
    26 		$formatted_date = sprintf( '<a href="%1s">%2s</a>', get_the_permalink( $post_ID ), $formatted_date );
    27 	}
    27 	}
    28 
    28 
    29 	return sprintf(
    29 	return sprintf(
    30 		'<div %1$s><time datetime="%2$s">%3$s</time></div>',
    30 		'<div %1$s><time datetime="%2$s">%3$s</time></div>',
    31 		$wrapper_attributes,
    31 		$wrapper_attributes,
    32 		get_the_date( 'c', $post_ID ),
    32 		esc_attr( get_the_date( 'c', $post_ID ) ),
    33 		$formatted_date
    33 		$formatted_date
    34 	);
    34 	);
    35 }
    35 }
    36 
    36 
    37 /**
    37 /**