PATH:
home
/
ptadmin
/
public_html
/
wp-includes
/
blocks
<?php /** * Server-side rendering of the `core/post-date` block. * * @package WordPress */ /** * Renders the `core/post-date` block on the server. * * @since 5.8.0 * * @param array $attributes Block attributes. * @param string $content Block default content. * @param WP_Block $block Block instance. * @return string Returns the filtered post date for the current post wrapped inside "time" tags. */ function render_block_core_post_date( $attributes, $content, $block ) { if ( ! isset( $block->context['postId'] ) ) { return ''; } $post_ID = $block->context['postId']; if ( isset( $attributes['format'] ) && 'human-diff' === $attributes['format'] ) { $post_timestamp = get_post_timestamp( $post_ID ); if ( $post_timestamp > time() ) { // translators: %s: human-readable time difference. $formatted_date = sprintf( __( '%s from now' ), human_time_diff( $post_timestamp ) ); } else { // translators: %s: human-readable time difference. $formatted_date = sprintf( __( '%s ago' ), human_time_diff( $post_timestamp ) ); } } else { $formatted_date = get_the_date( empty( $attributes['format'] ) ? '' : $attributes['format'], $post_ID ); } $unformatted_date = esc_attr( get_the_date( 'c', $post_ID ) ); $classes = array(); if ( isset( $attributes['textAlign'] ) ) { $classes[] = 'has-text-align-' . $attributes['textAlign']; } if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) { $classes[] = 'has-link-color'; } /* * If the "Display last modified date" setting is enabled, * only display the modified date if it is later than the publishing date. */ if ( isset( $attributes['displayType'] ) && 'modified' === $attributes['displayType'] ) { if ( get_the_modified_date( 'Ymdhi', $post_ID ) > get_the_date( 'Ymdhi', $post_ID ) ) { if ( isset( $attributes['format'] ) && 'human-diff' === $attributes['format'] ) { // translators: %s: human-readable time difference. $formatted_date = sprintf( __( '%s ago' ), human_time_diff( get_post_timestamp( $post_ID, 'modified' ) ) ); } else { $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 ''; } } $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classes ) ) ); if ( isset( $attributes['isLink'] ) && $attributes['isLink'] ) { $formatted_date = sprintf( '<a href="%1s">%2s</a>', get_the_permalink( $post_ID ), $formatted_date ); } return sprintf( '<div %1$s><time datetime="%2$s">%3$s</time></div>', $wrapper_attributes, $unformatted_date, $formatted_date ); } /** * Registers the `core/post-date` block on the server. * * @since 5.8.0 */ function register_block_core_post_date() { register_block_type_from_metadata( __DIR__ . '/post-date', array( 'render_callback' => 'render_block_core_post_date', ) ); } add_action( 'init', 'register_block_core_post_date' );
[+]
media-text
[+]
comments-pagination-next
[+]
table
[+]
widget-group
[-] query-no-results.php
[edit]
[+]
post-featured-image
[+]
post-template
[-] site-title.php
[edit]
[-] comment-content.php
[edit]
[-] page-list.php
[edit]
[-] search.php
[edit]
[-] shortcode.php
[edit]
[+]
comments-pagination-previous
[+]
group
[-] post-author-biography.php
[edit]
[+]
latest-comments
[+]
query-no-results
[+]
freeform
[-] require-static-blocks.php
[edit]
[+]
query-pagination
[+]
post-content
[-] post-title.php
[edit]
[+]
pattern
[-] button.php
[edit]
[-] query-pagination-numbers.php
[edit]
[+]
post-author-biography
[+]
comment-author-name
[+]
site-title
[-] error_log
[edit]
[-] site-logo.php
[edit]
[+]
navigation-link
[-] comments-pagination.php
[edit]
[-] comments.php
[edit]
[+]
columns
[+]
post-navigation-link
[-] navigation-link.php
[edit]
[+]
paragraph
[-] index.php
[edit]
[+]
comment-reply-link
[-] tag-cloud.php
[edit]
[-] site-tagline.php
[edit]
[+]
query-title
[-] post-featured-image.php
[edit]
[-] calendar.php
[edit]
[-] template-part.php
[edit]
[-] comments-title.php
[edit]
[+]
comments-pagination
[+]
text-columns
[+]
image
[+]
details
[-] comment-edit-link.php
[edit]
[+]
tag-cloud
[-] comments-pagination-previous.php
[edit]
[+]
latest-posts
[+]
button
[-] image.php
[edit]
[-] media-text.php
[edit]
[+]
missing
[+]
gallery
[+]
buttons
[+]
page-list
[+]
avatar
[-] post-date.php
[edit]
[+]
query-pagination-previous
[-] gallery.php
[edit]
[+]
spacer
[+]
term-description
[-] comment-date.php
[edit]
[-] query.php
[edit]
[+]
video
[+]
post-author-name
[+]
site-tagline
[+]
..
[-] heading.php
[edit]
[+]
social-links
[+]
comment-content
[-] legacy-widget.php
[edit]
[+]
template-part
[+]
post-date
[-] comments-pagination-next.php
[edit]
[+]
nextpage
[+]
audio
[+]
post-title
[+]
list-item
[-] comments-pagination-numbers.php
[edit]
[-] query-pagination-next.php
[edit]
[+]
comments-title
[-] social-link.php
[edit]
[+]
query-pagination-next
[+]
post-excerpt
[+]
block
[+]
home-link
[+]
comment-edit-link
[-] comment-reply-link.php
[edit]
[-] footnotes.php
[edit]
[-] query-pagination-previous.php
[edit]
[+]
column
[+]
embed
[-] post-content.php
[edit]
[+]
navigation-submenu
[+]
social-link
[+]
post-terms
[+]
legacy-widget
[+]
cover
[+]
code
[+]
archives
[-] post-author-name.php
[edit]
[+]
html
[+]
rss
[-] query-title.php
[edit]
[+]
verse
[+]
comments-pagination-numbers
[-] widget-group.php
[edit]
[-] navigation.php
[edit]
[-] block.php
[edit]
[-] page-list-item.php
[edit]
[-] loginout.php
[edit]
[-] query-pagination.php
[edit]
[-] avatar.php
[edit]
[+]
post-author
[-] post-author.php
[edit]
[-] latest-posts.php
[edit]
[-] require-dynamic-blocks.php
[edit]
[-] categories.php
[edit]
[+]
query
[+]
list
[+]
footnotes
[-] comment-template.php
[edit]
[+]
query-pagination-numbers
[+]
post-comments-form
[+]
heading
[+]
navigation
[+]
more
[-] pattern.php
[edit]
[-] file.php
[edit]
[-] term-description.php
[edit]
[-] rss.php
[edit]
[+]
read-more
[-] post-comments-form.php
[edit]
[-] post-terms.php
[edit]
[-] archives.php
[edit]
[-] latest-comments.php
[edit]
[-] blocks-json.php
[edit]
[+]
calendar
[+]
categories
[-] list.php
[edit]
[+]
comments
[+]
comment-template
[-] post-template.php
[edit]
[-] read-more.php
[edit]
[+]
search
[+]
preformatted
[+]
loginout
[+]
pullquote
[-] post-navigation-link.php
[edit]
[-] comment-author-name.php
[edit]
[+]
separator
[-] navigation-submenu.php
[edit]
[+]
quote
[+]
site-logo
[+]
file
[+]
page-list-item
[-] cover.php
[edit]
[+]
shortcode
[-] post-excerpt.php
[edit]
[+]
comment-date
[-] home-link.php
[edit]