PATH:
var
/
www
/
clients
/
client1
/
web1
/
web
/
wp-includes
/
blocks
<?php /** * Server-side rendering of the `core/post-excerpt` block. * * @package WordPress */ /** * Renders the `core/post-excerpt` 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 excerpt for the current post wrapped inside "p" tags. */ function render_block_core_post_excerpt( $attributes, $content, $block ) { if ( ! isset( $block->context['postId'] ) ) { return ''; } $more_text = ! empty( $attributes['moreText'] ) ? '<a class="wp-block-post-excerpt__more-link" href="' . esc_url( get_the_permalink( $block->context['postId'] ) ) . '">' . wp_kses_post( $attributes['moreText'] ) . '</a>' : ''; $filter_excerpt_more = static function ( $more ) use ( $more_text ) { return empty( $more_text ) ? $more : ''; }; /** * Some themes might use `excerpt_more` filter to handle the * `more` link displayed after a trimmed excerpt. Since the * block has a `more text` attribute we have to check and * override if needed the return value from this filter. * So if the block's attribute is not empty override the * `excerpt_more` filter and return nothing. This will * result in showing only one `read more` link at a time. * * This hook needs to be applied before the excerpt is retrieved with get_the_excerpt. * Otherwise, the read more link filter from the theme is not removed. */ add_filter( 'excerpt_more', $filter_excerpt_more ); /* * The purpose of the excerpt length setting is to limit the length of both * automatically generated and user-created excerpts. * Because the excerpt_length filter only applies to auto generated excerpts, * wp_trim_words is used instead. */ $excerpt_length = $attributes['excerptLength']; $excerpt = get_the_excerpt( $block->context['postId'] ); if ( isset( $excerpt_length ) ) { $excerpt = wp_trim_words( $excerpt, $excerpt_length ); } $classes = array(); 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 ) ) ); $content = '<p class="wp-block-post-excerpt__excerpt">' . $excerpt; $show_more_on_new_line = ! isset( $attributes['showMoreOnNewLine'] ) || $attributes['showMoreOnNewLine']; if ( $show_more_on_new_line && ! empty( $more_text ) ) { $content .= '</p><p class="wp-block-post-excerpt__more-text">' . $more_text . '</p>'; } else { $content .= " $more_text</p>"; } remove_filter( 'excerpt_more', $filter_excerpt_more ); return sprintf( '<div %1$s>%2$s</div>', $wrapper_attributes, $content ); } /** * Registers the `core/post-excerpt` block on the server. * * @since 5.8.0 */ function register_block_core_post_excerpt() { register_block_type_from_metadata( __DIR__ . '/post-excerpt', array( 'render_callback' => 'render_block_core_post_excerpt', ) ); } add_action( 'init', 'register_block_core_post_excerpt' ); /** * If themes or plugins filter the excerpt_length, we need to * override the filter in the editor, otherwise * the excerpt length block setting has no effect. * Returns 100 because 100 is the max length in the setting. */ if ( is_admin() || defined( 'REST_REQUEST' ) && REST_REQUEST ) { add_filter( 'excerpt_length', static function () { return 100; }, PHP_INT_MAX ); }
[+]
..
[-] query-pagination-numbers.php
[edit]
[-] archives.php
[edit]
[+]
term-count
[-] blocks-json.php
[edit]
[-] require-static-blocks.php
[edit]
[+]
comments-pagination-previous
[+]
post-featured-image
[+]
post-title
[+]
preformatted
[+]
post-comments-count
[-] shortcode.php
[edit]
[+]
list
[-] post-title.php
[edit]
[+]
table
[-] loginout.php
[edit]
[-] file.php
[edit]
[+]
legacy-widget
[-] query-pagination.php
[edit]
[+]
comments-pagination-next
[+]
accordion
[-] post-time-to-read.php
[edit]
[+]
post-author-biography
[+]
comment-edit-link
[+]
block
[+]
comment-reply-link
[+]
search
[+]
page-list
[+]
pullquote
[-] query-pagination-next.php
[edit]
[+]
navigation
[+]
social-link
[+]
accordion-item
[-] categories.php
[edit]
[+]
avatar
[-] post-terms.php
[edit]
[+]
image
[+]
post-content
[+]
comment-author-name
[+]
comment-date
[+]
button
[-] query-total.php
[edit]
[-] comments-pagination.php
[edit]
[-] tag-cloud.php
[edit]
[-] index.php
[edit]
[-] pattern.php
[edit]
[+]
comments
[-] term-description.php
[edit]
[+]
post-excerpt
[-] latest-posts.php
[edit]
[-] post-comments-form.php
[edit]
[-] comment-author-name.php
[edit]
[-] comment-template.php
[edit]
[+]
html
[+]
post-author-name
[-] comments-pagination-next.php
[edit]
[-] post-date.php
[edit]
[-] gallery.php
[edit]
[-] require-dynamic-blocks.php
[edit]
[+]
site-logo
[+]
widget-group
[-] site-logo.php
[edit]
[-] navigation.php
[edit]
[+]
spacer
[-] rss.php
[edit]
[-] accordion-item.php
[edit]
[-] cover.php
[edit]
[+]
file
[-] post-author-name.php
[edit]
[+]
post-comments-link
[-] comments-pagination-previous.php
[edit]
[+]
comment-content
[+]
columns
[-] query.php
[edit]
[+]
post-time-to-read
[+]
query-pagination-next
[+]
pattern
[+]
home-link
[+]
math
[-] avatar.php
[edit]
[+]
navigation-link
[-] post-featured-image.php
[edit]
[-] term-template.php
[edit]
[-] site-title.php
[edit]
[+]
comments-pagination-numbers
[+]
query-no-results
[+]
group
[+]
loginout
[+]
archives
[+]
social-links
[+]
cover
[-] block.php
[edit]
[-] post-content.php
[edit]
[+]
freeform
[+]
shortcode
[-] media-text.php
[edit]
[-] navigation-link.php
[edit]
[+]
post-comments-form
[-] navigation-submenu.php
[edit]
[+]
post-navigation-link
[-] comments.php
[edit]
[+]
comment-template
[-] term-name.php
[edit]
[-] latest-comments.php
[edit]
[+]
query-pagination-previous
[+]
term-description
[-] widget-group.php
[edit]
[-] social-link.php
[edit]
[+]
separator
[+]
post-date
[-] query-pagination-previous.php
[edit]
[+]
nextpage
[+]
tag-cloud
[+]
categories
[-] post-navigation-link.php
[edit]
[+]
template-part
[+]
accordion-panel
[-] list.php
[edit]
[+]
video
[-] accordion.php
[edit]
[+]
term-name
[+]
media-text
[-] post-author-biography.php
[edit]
[+]
read-more
[+]
query-total
[-] video.php
[edit]
[+]
embed
[+]
audio
[-] calendar.php
[edit]
[+]
code
[-] legacy-widget.php
[edit]
[+]
latest-posts
[-] comment-reply-link.php
[edit]
[-] home-link.php
[edit]
[-] image.php
[edit]
[-] page-list-item.php
[edit]
[+]
heading
[+]
navigation-submenu
[+]
verse
[+]
paragraph
[+]
site-tagline
[+]
gallery
[-] post-comments-count.php
[edit]
[-] comments-pagination-numbers.php
[edit]
[+]
quote
[-] post-excerpt.php
[edit]
[+]
query-pagination
[-] post-comments-link.php
[edit]
[+]
more
[+]
latest-comments
[+]
rss
[-] read-more.php
[edit]
[+]
post-template
[+]
footnotes
[-] comment-content.php
[edit]
[-] term-count.php
[edit]
[+]
site-title
[-] page-list.php
[edit]
[+]
comments-title
[-] button.php
[edit]
[-] comment-edit-link.php
[edit]
[+]
missing
[-] site-tagline.php
[edit]
[-] heading.php
[edit]
[+]
page-list-item
[+]
buttons
[-] post-template.php
[edit]
[+]
column
[-] post-author.php
[edit]
[+]
query
[+]
list-item
[+]
query-pagination-numbers
[-] template-part.php
[edit]
[+]
accordion-heading
[+]
post-author
[-] footnotes.php
[edit]
[-] comment-date.php
[edit]
[+]
query-title
[+]
comments-pagination
[-] query-title.php
[edit]
[+]
term-template
[-] query-no-results.php
[edit]
[+]
text-columns
[+]
post-terms
[-] comments-title.php
[edit]
[+]
calendar
[+]
terms-query
[-] search.php
[edit]
[+]
details