Changeset 59072 for trunk/src/wp-includes/blocks/post-date.php
- Timestamp:
- 09/20/2024 01:53:52 AM (6 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/blocks/post-date.php
r58187 r59072 21 21 } 22 22 23 $post_ID = $block->context['postId']; 24 $formatted_date = get_the_date( empty( $attributes['format'] ) ? '' : $attributes['format'], $post_ID ); 23 $post_ID = $block->context['postId']; 24 25 if ( isset( $attributes['format'] ) && 'human-diff' === $attributes['format'] ) { 26 $post_timestamp = get_post_timestamp( $post_ID ); 27 if ( $post_timestamp > time() ) { 28 // translators: %s: human-readable time difference. 29 $formatted_date = sprintf( __( '%s from now' ), human_time_diff( $post_timestamp ) ); 30 } else { 31 // translators: %s: human-readable time difference. 32 $formatted_date = sprintf( __( '%s ago' ), human_time_diff( $post_timestamp ) ); 33 } 34 } else { 35 $formatted_date = get_the_date( empty( $attributes['format'] ) ? '' : $attributes['format'], $post_ID ); 36 } 25 37 $unformatted_date = esc_attr( get_the_date( 'c', $post_ID ) ); 26 38 $classes = array(); … … 39 51 if ( isset( $attributes['displayType'] ) && 'modified' === $attributes['displayType'] ) { 40 52 if ( get_the_modified_date( 'Ymdhi', $post_ID ) > get_the_date( 'Ymdhi', $post_ID ) ) { 41 $formatted_date = get_the_modified_date( empty( $attributes['format'] ) ? '' : $attributes['format'], $post_ID ); 53 if ( isset( $attributes['format'] ) && 'human-diff' === $attributes['format'] ) { 54 // translators: %s: human-readable time difference. 55 $formatted_date = sprintf( __( '%s ago' ), human_time_diff( get_post_timestamp( $post_ID, 'modified' ) ) ); 56 } else { 57 $formatted_date = get_the_modified_date( empty( $attributes['format'] ) ? '' : $attributes['format'], $post_ID ); 58 } 42 59 $unformatted_date = esc_attr( get_the_modified_date( 'c', $post_ID ) ); 43 60 $classes[] = 'wp-block-post-date__modified-date';
Note: See TracChangeset
for help on using the changeset viewer.