Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions packages/block-library/src/post-date/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,7 @@ export default function PostDateEdit( {
} )
}
checked={ displayType === 'modified' }
help={ __(
'Only shows if the post has been modified'
) }
help={ __( "Show the post's last modified date" ) }
/>
</PanelBody>
</InspectorControls>
Expand Down
13 changes: 4 additions & 9 deletions packages/block-library/src/post-date/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,12 @@ function render_block_core_post_date( $attributes, $content, $block ) {
}

/*
* If the "Display last modified date" setting is enabled,
* only display the modified date if it is later than the publishing date.
* If the "Display last modified date" setting is enabled.
*/
if ( isset( $attributes['displayType'] ) && 'modified' === $attributes['displayType'] ) {
if ( get_the_modified_date( 'Ymdhi', $post_ID ) > get_the_date( 'Ymdhi', $post_ID ) ) {
$formatted_date = get_the_modified_date( empty( $attributes['format'] ) ? '' : $attributes['format'], $post_ID );
$unformatted_date = esc_attr( get_the_modified_date( 'c', $post_ID ) );
$classes[] = 'wp-block-post-date__modified-date';
} else {
return '';
}
$formatted_date = get_the_modified_date( empty( $attributes['format'] ) ? '' : $attributes['format'], $post_ID );
$unformatted_date = esc_attr( get_the_modified_date( 'c', $post_ID ) );
$classes[] = 'wp-block-post-date__modified-date';
}

$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classes ) ) );
Expand Down
Loading