/home/u523506497/domains/mymelon.in/public_html/wp-includes/blocks UP
<?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.
*
* To ensure the block's excerptLength setting works correctly for auto-generated
* excerpts, we temporarily override excerpt_length to 101 (the max block setting)
* so that wp_trim_excerpt doesn't pre-trim the content before wp_trim_words can
* apply the user's desired length.
*/
$excerpt_length = $attributes['excerptLength'];
add_filter( 'excerpt_length', 'block_core_post_excerpt_excerpt_length', PHP_INT_MAX );
$excerpt = get_the_excerpt( $block->context['postId'] );
remove_filter( 'excerpt_length', 'block_core_post_excerpt_excerpt_length', PHP_INT_MAX );
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' );
/**
* Callback for the excerpt_length filter to override the excerpt length.
*
* 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 101 (one more than the max block setting of 100) to ensure
* wp_trim_words can detect when trimming is needed and add the ellipsis.
*
* @since 7.0.0
*
* @return int The excerpt length.
*/
function block_core_post_excerpt_excerpt_length() {
return 101;
}
if ( is_admin() ) {
add_filter( 'excerpt_length', 'block_core_post_excerpt_excerpt_length', PHP_INT_MAX );
}
| accordion | - | |
| accordion-heading | - | |
| accordion-item | - | |
| accordion-item.php | 3052 | V |
| accordion-panel | - | |
| accordion.php | 1147 | V |
| archives | - | |
| archives.php | 4385 | V |
| audio | - | |
| avatar | - | |
| avatar.php | 5638 | V |
| block | - | |
| block.php | 3122 | V |
| blocks-json.php | 210661 | V |
| breadcrumbs | - | |
| breadcrumbs.php | 19057 | V |
| button | - | |
| button.php | 4211 | V |
| buttons | - | |
| calendar | - | |
| calendar.php | 6075 | V |
| categories | - | |
| categories.php | 4938 | V |
| code | - | |
| column | - | |
| columns | - | |
| comment-author-name | - | |
| comment-author-name.php | 2136 | V |
| comment-content | - | |
| comment-content.php | 2459 | V |
| comment-date | - | |
| comment-date.php | 1865 | V |
| comment-edit-link | - | |
| comment-edit-link.php | 1713 | V |
| comment-reply-link | - | |
| comment-reply-link.php | 2075 | V |
| comment-template | - | |
| comment-template.php | 4494 | V |
| comments | - | |
| comments-pagination | - | |
| comments-pagination-next | - | |
| comments-pagination-next.php | 1924 | V |
| comments-pagination-numbers | - | |
| comments-pagination-numbers.php | 1632 | V |
| comments-pagination-previous | - | |
| comments-pagination-previous.php | 1790 | V |
| comments-pagination.php | 1261 | V |
| comments-title | - | |
| comments-title.php | 2787 | V |
| comments.php | 6784 | V |
| cover | - | |
| cover.php | 7404 | V |
| details | - | |
| details.php | 1498 | V |
| embed | - | |
| file | - | |
| file.php | 1879 | V |
| footnotes | - | |
| footnotes.php | 3818 | V |
| freeform | - | |
| gallery | - | |
| gallery.php | 22345 | V |
| group | - | |
| heading | - | |
| heading.php | 1301 | V |
| home-link | - | |
| home-link.php | 4703 | V |
| html | - | |
| icon | - | |
| icon.php | 4374 | V |
| image | - | |
| image.php | 17642 | V |
| index.php | 5104 | V |
| latest-comments | - | |
| latest-comments.php | 5622 | V |
| latest-posts | - | |
| latest-posts.php | 10459 | V |
| legacy-widget | - | |
| legacy-widget.php | 4011 | V |
| list | - | |
| list-item | - | |
| list.php | 1273 | V |
| loginout | - | |
| loginout.php | 2123 | V |
| math | - | |
| media-text | - | |
| media-text.php | 4298 | V |
| missing | - | |
| more | - | |
| navigation | - | |
| navigation-link | - | |
| navigation-link.php | 16654 | V |
| navigation-overlay-close | - | |
| navigation-overlay-close.php | 1765 | V |
| navigation-submenu | - | |
| navigation-submenu.php | 11050 | V |
| navigation.php | 70892 | V |
| nextpage | - | |
| page-list | - | |
| page-list-item | - | |
| page-list-item.php | 361 | V |
| page-list.php | 13863 | V |
| paragraph | - | |
| paragraph.php | 1139 | V |
| pattern | - | |
| pattern.php | 1788 | V |
| playlist | - | |
| playlist-track | - | |
| playlist-track.php | 2487 | V |
| playlist.php | 6616 | V |
| post-author | - | |
| post-author-biography | - | |
| post-author-biography.php | 1524 | V |
| post-author-name | - | |
| post-author-name.php | 1962 | V |
| post-author.php | 2734 | V |
| post-comments-count | - | |
| post-comments-count.php | 1275 | V |
| post-comments-form | - | |
| post-comments-form.php | 2805 | V |
| post-comments-link | - | |
| post-comments-link.php | 2237 | V |
| post-content | - | |
| post-content.php | 2668 | V |
| post-date | - | |
| post-date.php | 3692 | V |
| post-excerpt | - | |
| post-excerpt.php | 4315 | V |
| post-featured-image | - | |
| post-featured-image.php | 9452 | V |
| post-navigation-link | - | |
| post-navigation-link.php | 4807 | V |
| post-template | - | |
| post-template.php | 5940 | V |
| post-terms | - | |
| post-terms.php | 3640 | V |
| post-time-to-read | - | |
| post-time-to-read.php | 6411 | V |
| post-title | - | |
| post-title.php | 2138 | V |
| preformatted | - | |
| pullquote | - | |
| query | - | |
| query-no-results | - | |
| query-no-results.php | 1847 | V |
| query-pagination | - | |
| query-pagination-next | - | |
| query-pagination-next.php | 3676 | V |
| query-pagination-numbers | - | |
| query-pagination-numbers.php | 4700 | V |
| query-pagination-previous | - | |
| query-pagination-previous.php | 3473 | V |
| query-pagination.php | 1176 | V |
| query-title | - | |
| query-title.php | 2771 | V |
| query-total | - | |
| query-total.php | 2471 | V |
| query.php | 5690 | V |
| quote | - | |
| read-more | - | |
| read-more.php | 1846 | V |
| require-dynamic-blocks.php | 5256 | V |
| require-static-blocks.php | 535 | V |
| rss | - | |
| rss.php | 4609 | V |
| search | - | |
| search.php | 25600 | V |
| separator | - | |
| shortcode | - | |
| shortcode.php | 735 | V |
| site-logo | - | |
| site-logo.php | 6334 | V |
| site-tagline | - | |
| site-tagline.php | 1203 | V |
| site-title | - | |
| site-title.php | 1864 | V |
| social-link | - | |
| social-link.php | 67602 | V |
| social-links | - | |
| spacer | - | |
| tab-list | - | |
| tab-list.php | 2322 | V |
| tab-panel | - | |
| tab-panel.php | 1669 | V |
| tab-panels | - | |
| table | - | |
| tabs | - | |
| tabs.php | 3949 | V |
| tag-cloud | - | |
| tag-cloud.php | 1586 | V |
| template-part | - | |
| template-part.php | 9964 | V |
| term-count | - | |
| term-count.php | 1843 | V |
| term-description | - | |
| term-description.php | 1770 | V |
| term-name | - | |
| term-name.php | 2038 | V |
| term-template | - | |
| term-template.php | 4518 | V |
| terms-query | - | |
| text-columns | - | |
| verse | - | |
| video | - | |
| video-plain.php | 0 | V |
| video.php | 2733 | V |
| widget-group | - | |
| widget-group.php | 2438 | V |