From a415c29efee45520ae252d2aa28f1083a521cd7b Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 09:56:49 +0200 Subject: Adding upstream version 6.4.3+dfsg1. Signed-off-by: Daniel Baumann --- wp-includes/blocks/post-content.php | 75 +++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 wp-includes/blocks/post-content.php (limited to 'wp-includes/blocks/post-content.php') diff --git a/wp-includes/blocks/post-content.php b/wp-includes/blocks/post-content.php new file mode 100644 index 0000000..dd84574 --- /dev/null +++ b/wp-includes/blocks/post-content.php @@ -0,0 +1,75 @@ +context['postId'] ) ) { + return ''; + } + + $post_id = $block->context['postId']; + + if ( isset( $seen_ids[ $post_id ] ) ) { + // WP_DEBUG_DISPLAY must only be honored when WP_DEBUG. This precedent + // is set in `wp_debug_mode()`. + $is_debug = WP_DEBUG && WP_DEBUG_DISPLAY; + + return $is_debug ? + // translators: Visible only in the front end, this warning takes the place of a faulty block. + __( '[block rendering halted]' ) : + ''; + } + + $seen_ids[ $post_id ] = true; + + // When inside the main loop, we want to use queried object + // so that `the_preview` for the current post can apply. + // We force this behavior by omitting the third argument (post ID) from the `get_the_content`. + $content = get_the_content(); + // Check for nextpage to display page links for paginated posts. + if ( has_block( 'core/nextpage' ) ) { + $content .= wp_link_pages( array( 'echo' => 0 ) ); + } + + /** This filter is documented in wp-includes/post-template.php */ + $content = apply_filters( 'the_content', str_replace( ']]>', ']]>', $content ) ); + unset( $seen_ids[ $post_id ] ); + + if ( empty( $content ) ) { + return ''; + } + + $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => 'entry-content' ) ); + + return ( + '
' . + $content . + '
' + ); +} + +/** + * Registers the `core/post-content` block on the server. + */ +function register_block_core_post_content() { + register_block_type_from_metadata( + __DIR__ . '/post-content', + array( + 'render_callback' => 'render_block_core_post_content', + ) + ); +} +add_action( 'init', 'register_block_core_post_content' ); -- cgit v1.2.3