Make WordPress Core


Ignore:
Timestamp:
09/20/2024 01:53:52 AM (6 months ago)
Author:
noisysocks
Message:

Editor: Update packages for 6.7 Beta 1.

Syncs @wordpress/* packages to the wp-6.7 npm tag.

Fixes #61906.
Props peterwilsoncc, gziolo, kevin940726.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/blocks/post-date.php

    r58187 r59072  
    2121    }
    2222
    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    }
    2537    $unformatted_date = esc_attr( get_the_date( 'c', $post_ID ) );
    2638    $classes          = array();
     
    3951    if ( isset( $attributes['displayType'] ) && 'modified' === $attributes['displayType'] ) {
    4052        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            }
    4259            $unformatted_date = esc_attr( get_the_modified_date( 'c', $post_ID ) );
    4360            $classes[]        = 'wp-block-post-date__modified-date';
Note: See TracChangeset for help on using the changeset viewer.