diff -r 3d4e9c994f10 -r a86126ab1dd4 wp/wp-includes/blocks/rss.php --- a/wp/wp-includes/blocks/rss.php Tue Oct 22 16:11:46 2019 +0200 +++ b/wp/wp-includes/blocks/rss.php Tue Dec 15 13:49:49 2020 +0100 @@ -20,10 +20,6 @@ } if ( ! $rss->get_item_quantity() ) { - // PHP 5.2 compatibility. See: http://simplepie.org/wiki/faq/i_m_getting_memory_leaks. - $rss->__destruct(); - unset( $rss ); - return '
' . __( 'An error has occurred, which probably means the feed is down. Try again later.' ) . '
'; } @@ -32,7 +28,7 @@ foreach ( $rss_items as $item ) { $title = esc_html( trim( strip_tags( $item->get_title() ) ) ); if ( empty( $title ) ) { - $title = __( '(Untitled)' ); + $title = __( '(no title)' ); } $link = $item->get_link(); $link = esc_url( $link ); @@ -59,7 +55,11 @@ $author = $item->get_author(); if ( is_object( $author ) ) { $author = $author->get_name(); - $author = '' . __( 'by' ) . ' ' . esc_html( strip_tags( $author ) ) . ''; + $author = '' . sprintf( + /* translators: %s: the author. */ + __( 'by %s' ), + esc_html( strip_tags( $author ) ) + ) . ''; } } @@ -69,7 +69,7 @@ $excerpt = esc_attr( wp_trim_words( $excerpt, $attributes['excerptLength'], ' […]' ) ); // Change existing [...] to […]. - if ( '[...]' == substr( $excerpt, -5 ) ) { + if ( '[...]' === substr( $excerpt, -5 ) ) { $excerpt = substr( $excerpt, 0, -5 ) . '[…]'; } @@ -79,59 +79,35 @@ $list_items .= "
  • {$title}{$date}{$author}{$excerpt}
  • "; } - $classes = 'grid' === $attributes['blockLayout'] ? ' is-grid columns-' . $attributes['columns'] : ''; - $list_items_markup = ""; + $class = 'wp-block-rss'; + if ( isset( $attributes['align'] ) ) { + $class .= ' align' . $attributes['align']; + } + + if ( isset( $attributes['blockLayout'] ) && 'grid' === $attributes['blockLayout'] ) { + $class .= ' is-grid'; + } - // PHP 5.2 compatibility. See: http://simplepie.org/wiki/faq/i_m_getting_memory_leaks. - $rss->__destruct(); - unset( $rss ); + if ( isset( $attributes['columns'] ) && 'grid' === $attributes['blockLayout'] ) { + $class .= ' columns-' . $attributes['columns']; + } - return $list_items_markup; + if ( isset( $attributes['className'] ) ) { + $class .= ' ' . $attributes['className']; + } + + return sprintf( '', esc_attr( $class ), $list_items ); } /** * Registers the `core/rss` block on server. */ function register_block_core_rss() { - register_block_type( 'core/rss', + register_block_type_from_metadata( + __DIR__ . '/rss', array( - 'attributes' => array( - 'columns' => array( - 'type' => 'number', - 'default' => 2, - ), - 'blockLayout' => array( - 'type' => 'string', - 'default' => 'list', - ), - 'feedURL' => array( - 'type' => 'string', - 'default' => '', - ), - 'itemsToShow' => array( - 'type' => 'number', - 'default' => 5, - ), - 'displayExcerpt' => array( - 'type' => 'boolean', - 'default' => false, - ), - 'displayAuthor' => array( - 'type' => 'boolean', - 'default' => false, - ), - 'displayDate' => array( - 'type' => 'boolean', - 'default' => false, - ), - 'excerptLength' => array( - 'type' => 'number', - 'default' => 55, - ), - ), 'render_callback' => 'render_block_core_rss', ) ); } - add_action( 'init', 'register_block_core_rss' );