7.4.33 | Linux x86_64
Server128.199.10.0
Userwww-data (uid:33)
PHP7.4.33 (apache2handler)
Terminal
Upload
Files: /var/www/html/wp-includes/blocks
View: post-date.php
<?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 * @since 6.9.0 Added `datetime` attribute and Block Bindings support. * * @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 ) { $classes = array(); if ( ! isset( $attributes['datetime'] ) && ! ( isset( $attributes['metadata']['bindings']['datetime']['source'] ) && isset( $attributes['metadata']['bindings']['datetime']['args'] ) ) ) { /* * This is the legacy version of the block that didn't have the `datetime` attribute. * This branch needs to be kept for backward compatibility. */ $source = get_block_bindings_source( 'core/post-data' ); if ( isset( $attributes['displayType'] ) && 'modified' === $attributes['displayType'] ) { $source_args = array( 'field' => 'modified', ); } else { $source_args = array( 'field' => 'date', ); } $attributes['datetime'] = $source->get_value( $source_args, $block, 'datetime' ); } if ( isset( $source_args['field'] ) && 'modified' === $source_args['field'] ) { $classes[] = 'wp-block-post-date__modified-date'; } if ( empty( $attributes['datetime'] ) ) { // If the `datetime` attribute is set but empty, it could be because Block Bindings // set it that way. This can happen e.g. if the block is bound to the // post's last modified date, and the latter lies before the publish date. // (See https://github.com/WordPress/gutenberg/pull/46839 where this logic was originally // implemented.) // In this case, we have to respect and return the empty value. return ''; } $unformatted_date = $attributes['datetime']; $post_timestamp = strtotime( $unformatted_date ); if ( isset( $attributes['format'] ) && 'human-diff' === $attributes['format'] ) { 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 { $format = empty( $attributes['format'] ) ? get_option( 'date_format' ) : $attributes['format']; $formatted_date = wp_date( $format, $post_timestamp ); } if ( isset( $attributes['textAlign'] ) ) { $classes[] = 'has-text-align-' . $attributes['textAlign']; } if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) { $classes[] = 'has-link-color'; } $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classes ) ) ); $time_tag = sprintf( '<time datetime="%1$s">%2$s</time>', $unformatted_date, $formatted_date ); if ( isset( $attributes['isLink'] ) && $attributes['isLink'] && isset( $block->context['postId'] ) ) { $time_tag = sprintf( '<a href="%1s">%2s</a>', get_the_permalink( $block->context['postId'] ), $time_tag ); } return sprintf( '<div %1$s>%2$s</div>', $wrapper_attributes, $time_tag ); } /** * 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' );
NameSizeActions
accordion/--
accordion-heading/--
accordion-item/--
accordion-item.php3KView Edit Del
accordion-panel/--
accordion.php1.1KView Edit Del
archives/--
archives.php4.3KView Edit Del
audio/--
avatar/--
avatar.php5.5KView Edit Del
block/--
block.php4.1KView Edit Del
blocks-json.php194.5KView Edit Del
breadcrumbs/--
breadcrumbs.php18.6KView Edit Del
button/--
button.php1.7KView Edit Del
buttons/--
calendar/--
calendar.php5.9KView Edit Del
categories/--
categories.php4.8KView Edit Del
code/--
column/--
columns/--
comment-author-name/--
comment-author-name.php2.1KView Edit Del
comment-content/--
comment-content.php2.4KView Edit Del
comment-date/--
comment-date.php1.8KView Edit Del
comment-edit-link/--
comment-edit-link.php1.7KView Edit Del
comment-reply-link/--
comment-reply-link.php2KView Edit Del
comment-template/--
comment-template.php4.4KView Edit Del
comments/--
comments-pagination/--
comments-pagination-next/--
comments-pagination-next.php1.9KView Edit Del
comments-pagination-numbers/--
comments-pagination-numbers.php1.6KView Edit Del
comments-pagination-previous/--
comments-pagination-previous.php1.7KView Edit Del
comments-pagination.php1.2KView Edit Del
comments-title/--
comments-title.php2.7KView Edit Del
comments.php6.6KView Edit Del
cover/--
cover.php7.2KView Edit Del
details/--
details.php1.5KView Edit Del
embed/--
file/--
file.php1.8KView Edit Del
footnotes/--
footnotes.php3.7KView Edit Del
freeform/--
gallery/--
gallery.php8.9KView Edit Del
group/--
heading/--
heading.php1.3KView Edit Del
home-link/--
home-link.php5.3KView Edit Del
html/--
icon/--
icon.php4KView Edit Del
image/--
image.php17.2KView Edit Del
index.php5KView Edit Del
latest-comments/--
latest-comments.php5.4KView Edit Del
latest-posts/--
latest-posts.php8.6KView Edit Del
legacy-widget/--
legacy-widget.php3.9KView Edit Del
list/--
list-item/--
list.php1.2KView Edit Del
loginout/--
loginout.php1.6KView Edit Del
math/--
media-text/--
media-text.php4.2KView Edit Del
missing/--
more/--
navigation/--
navigation-link/--
navigation-link.php15.8KView Edit Del
navigation-overlay-close/--
navigation-overlay-close.php1.7KView Edit Del
navigation-submenu/--
navigation-submenu.php11.5KView Edit Del
navigation.php63.3KView Edit Del
nextpage/--
page-list/--
page-list-item/--
page-list-item.php361BView Edit Del
page-list.php14.7KView Edit Del
paragraph/--
paragraph.php1.1KView Edit Del
pattern/--
pattern.php1.7KView Edit Del
post-author/--
post-author-biography/--
post-author-biography.php1.5KView Edit Del
post-author-name/--
post-author-name.php1.9KView Edit Del
post-author.php2.7KView Edit Del
post-comments-count/--
post-comments-count.php1.2KView Edit Del
post-comments-form/--
post-comments-form.php2.7KView Edit Del
post-comments-link/--
post-comments-link.php2.2KView Edit Del
post-content/--
post-content.php2.3KView Edit Del
post-date/--
post-date.php3.6KView Edit Del
post-excerpt/--
post-excerpt.php4.2KView Edit Del
post-featured-image/--
post-featured-image.php9KView Edit Del
post-navigation-link/--
post-navigation-link.php4.7KView Edit Del
post-template/--
post-template.php5.6KView Edit Del
post-terms/--
post-terms.php3.6KView Edit Del
post-time-to-read/--
post-time-to-read.php6.3KView Edit Del
post-title/--
post-title.php2.1KView Edit Del
preformatted/--
pullquote/--
query/--
query-no-results/--
query-no-results.php1.8KView Edit Del
query-pagination/--
query-pagination-next/--
query-pagination-next.php3.6KView Edit Del
query-pagination-numbers/--
query-pagination-numbers.php4.6KView Edit Del
query-pagination-previous/--
query-pagination-previous.php3.4KView Edit Del
query-pagination.php1.1KView Edit Del
query-title/--
query-title.php2.7KView Edit Del
query-total/--
query-total.php2.4KView Edit Del
query.php5.6KView Edit Del
quote/--
read-more/--
read-more.php1.8KView Edit Del
require-dynamic-blocks.php4.9KView Edit Del
require-static-blocks.php520BView Edit Del
rss/--
rss.php4.5KView Edit Del
search/--
search.php23.3KView Edit Del
separator/--
shortcode/--
shortcode.php735BView Edit Del
site-logo/--
site-logo.php6.2KView Edit Del
site-tagline/--
site-tagline.php1.2KView Edit Del
site-title/--
site-title.php1.8KView Edit Del
social-link/--
social-link.php66KView Edit Del
social-links/--
spacer/--
table/--
tag-cloud/--
tag-cloud.php1.6KView Edit Del
template-part/--
template-part.php10.2KView Edit Del
term-count/--
term-count.php1.8KView Edit Del
term-description/--
term-description.php1.7KView Edit Del
term-name/--
term-name.php2KView Edit Del
term-template/--
term-template.php4.4KView Edit Del
terms-query/--
text-columns/--
verse/--
video/--
video.php2.7KView Edit Del
widget-group/--
widget-group.php2.4KView Edit Del