Edit File by line
/home/zeestwma/richards.../wp-inclu.../blocks
File: post-date.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Server-side rendering of the `core/post-date` block.
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* Renders the `core/post-date` block on the server.
[8] Fix | Delete
*
[9] Fix | Delete
* @since 5.8.0
[10] Fix | Delete
*
[11] Fix | Delete
* @param array $attributes Block attributes.
[12] Fix | Delete
* @param string $content Block default content.
[13] Fix | Delete
* @param WP_Block $block Block instance.
[14] Fix | Delete
* @return string Returns the filtered post date for the current post wrapped inside "time" tags.
[15] Fix | Delete
*/
[16] Fix | Delete
function render_block_core_post_date( $attributes, $content, $block ) {
[17] Fix | Delete
if ( ! isset( $block->context['postId'] ) ) {
[18] Fix | Delete
return '';
[19] Fix | Delete
}
[20] Fix | Delete
[21] Fix | Delete
$post_ID = $block->context['postId'];
[22] Fix | Delete
$formatted_date = get_the_date( empty( $attributes['format'] ) ? '' : $attributes['format'], $post_ID );
[23] Fix | Delete
$unformatted_date = esc_attr( get_the_date( 'c', $post_ID ) );
[24] Fix | Delete
$classes = array();
[25] Fix | Delete
[26] Fix | Delete
if ( isset( $attributes['textAlign'] ) ) {
[27] Fix | Delete
$classes[] = 'has-text-align-' . $attributes['textAlign'];
[28] Fix | Delete
}
[29] Fix | Delete
if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) {
[30] Fix | Delete
$classes[] = 'has-link-color';
[31] Fix | Delete
}
[32] Fix | Delete
[33] Fix | Delete
/*
[34] Fix | Delete
* If the "Display last modified date" setting is enabled,
[35] Fix | Delete
* only display the modified date if it is later than the publishing date.
[36] Fix | Delete
*/
[37] Fix | Delete
if ( isset( $attributes['displayType'] ) && 'modified' === $attributes['displayType'] ) {
[38] Fix | Delete
if ( get_the_modified_date( 'Ymdhi', $post_ID ) > get_the_date( 'Ymdhi', $post_ID ) ) {
[39] Fix | Delete
$formatted_date = get_the_modified_date( empty( $attributes['format'] ) ? '' : $attributes['format'], $post_ID );
[40] Fix | Delete
$unformatted_date = esc_attr( get_the_modified_date( 'c', $post_ID ) );
[41] Fix | Delete
$classes[] = 'wp-block-post-date__modified-date';
[42] Fix | Delete
} else {
[43] Fix | Delete
return '';
[44] Fix | Delete
}
[45] Fix | Delete
}
[46] Fix | Delete
[47] Fix | Delete
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classes ) ) );
[48] Fix | Delete
[49] Fix | Delete
if ( isset( $attributes['isLink'] ) && $attributes['isLink'] ) {
[50] Fix | Delete
$formatted_date = sprintf( '<a href="%1s">%2s</a>', get_the_permalink( $post_ID ), $formatted_date );
[51] Fix | Delete
}
[52] Fix | Delete
[53] Fix | Delete
return sprintf(
[54] Fix | Delete
'<div %1$s><time datetime="%2$s">%3$s</time></div>',
[55] Fix | Delete
$wrapper_attributes,
[56] Fix | Delete
$unformatted_date,
[57] Fix | Delete
$formatted_date
[58] Fix | Delete
);
[59] Fix | Delete
}
[60] Fix | Delete
[61] Fix | Delete
/**
[62] Fix | Delete
* Registers the `core/post-date` block on the server.
[63] Fix | Delete
*
[64] Fix | Delete
* @since 5.8.0
[65] Fix | Delete
*/
[66] Fix | Delete
function register_block_core_post_date() {
[67] Fix | Delete
register_block_type_from_metadata(
[68] Fix | Delete
__DIR__ . '/post-date',
[69] Fix | Delete
array(
[70] Fix | Delete
'render_callback' => 'render_block_core_post_date',
[71] Fix | Delete
)
[72] Fix | Delete
);
[73] Fix | Delete
}
[74] Fix | Delete
add_action( 'init', 'register_block_core_post_date' );
[75] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function