From 1fb85addf9dc3ba34415353a850b0c0393fe3f5e Mon Sep 17 00:00:00 2001 From: gziolo Date: Thu, 19 Sep 2019 15:47:58 +0000 Subject: [PATCH] Block Editor: Fixes failing unit tests related to Social Link blocks Follow-up for #47843 - update the WordPress Packages to the ones used in the Gutenberg 6.5 release. Props desrosj. Fixes #47843. Built from https://develop.svn.wordpress.org/trunk@46190 git-svn-id: http://core.svn.wordpress.org/trunk@46002 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/blocks/calendar.php | 5 ++++- wp-includes/blocks/rss.php | 35 ++++++++++++++++++++++++++------ wp-includes/blocks/search.php | 17 +++++++++++++--- wp-includes/blocks/tag-cloud.php | 23 +++++++++++++-------- wp-includes/version.php | 2 +- 5 files changed, 63 insertions(+), 19 deletions(-) diff --git a/wp-includes/blocks/calendar.php b/wp-includes/blocks/calendar.php index 8e26626f5f..3d2e8061ba 100644 --- a/wp-includes/blocks/calendar.php +++ b/wp-includes/blocks/calendar.php @@ -34,7 +34,7 @@ function render_block_core_calendar( $attributes ) { $custom_class_name = empty( $attributes['className'] ) ? '' : ' ' . $attributes['className']; $align_class_name = empty( $attributes['align'] ) ? '' : ' ' . "align{$attributes['align']}"; - return sprintf( + $output = sprintf( '
%2$s
', esc_attr( 'wp-block-calendar' . $custom_class_name . $align_class_name ), get_calendar( true, false ) @@ -44,6 +44,8 @@ function render_block_core_calendar( $attributes ) { $monthnum = $previous_monthnum; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited $year = $previous_year; + + return $output; } /** @@ -56,6 +58,7 @@ function register_block_core_calendar() { 'attributes' => array( 'align' => array( 'type' => 'string', + 'enum' => array( 'left', 'center', 'right', 'wide', 'full' ), ), 'className' => array( 'type' => 'string', diff --git a/wp-includes/blocks/rss.php b/wp-includes/blocks/rss.php index b5fe3abaf5..0300585de2 100644 --- a/wp-includes/blocks/rss.php +++ b/wp-includes/blocks/rss.php @@ -32,7 +32,7 @@ function render_block_core_rss( $attributes ) { 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 ); @@ -69,7 +69,7 @@ function render_block_core_rss( $attributes ) { $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,8 +79,24 @@ function render_block_core_rss( $attributes ) { $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'; + } + + if ( isset( $attributes['columns'] ) && 'grid' === $attributes['blockLayout'] ) { + $class .= ' columns-' . $attributes['columns']; + } + + if ( isset( $attributes['className'] ) ) { + $class .= ' ' . $attributes['className']; + } + + $list_items_markup = ""; // PHP 5.2 compatibility. See: http://simplepie.org/wiki/faq/i_m_getting_memory_leaks. $rss->__destruct(); @@ -93,9 +109,17 @@ function render_block_core_rss( $attributes ) { * Registers the `core/rss` block on server. */ function register_block_core_rss() { - register_block_type( 'core/rss', + register_block_type( + 'core/rss', array( 'attributes' => array( + 'align' => array( + 'type' => 'string', + 'enum' => array( 'left', 'center', 'right', 'wide', 'full' ), + ), + 'className' => array( + 'type' => 'string', + ), 'columns' => array( 'type' => 'number', 'default' => 2, @@ -133,5 +157,4 @@ function register_block_core_rss() { ) ); } - add_action( 'init', 'register_block_core_rss' ); diff --git a/wp-includes/blocks/search.php b/wp-includes/blocks/search.php index ac7da463e9..6cd909fc6f 100644 --- a/wp-includes/blocks/search.php +++ b/wp-includes/blocks/search.php @@ -15,7 +15,9 @@ function render_block_core_search( $attributes ) { static $instance_id = 0; - $input_id = 'wp-block-search__input-' . ++$instance_id; + $input_id = 'wp-block-search__input-' . ++$instance_id; + $label_markup = ''; + $button_markup = ''; if ( ! empty( $attributes['label'] ) ) { $label_markup = sprintf( @@ -44,6 +46,10 @@ function render_block_core_search( $attributes ) { $class .= ' ' . $attributes['className']; } + if ( isset( $attributes['align'] ) ) { + $class .= ' align' . $attributes['align']; + } + return sprintf( '', $class, @@ -60,6 +66,13 @@ function register_block_core_search() { 'core/search', array( 'attributes' => array( + 'align' => array( + 'type' => 'string', + 'enum' => array( 'left', 'center', 'right', 'wide', 'full' ), + ), + 'className' => array( + 'type' => 'string', + ), 'label' => array( 'type' => 'string', 'default' => __( 'Search' ), @@ -73,10 +86,8 @@ function register_block_core_search() { 'default' => __( 'Search' ), ), ), - 'render_callback' => 'render_block_core_search', ) ); } - add_action( 'init', 'register_block_core_search' ); diff --git a/wp-includes/blocks/tag-cloud.php b/wp-includes/blocks/tag-cloud.php index c60f8a1dd6..cf9c4d2453 100644 --- a/wp-includes/blocks/tag-cloud.php +++ b/wp-includes/blocks/tag-cloud.php @@ -30,7 +30,14 @@ function render_block_core_tag_cloud( $attributes ) { $tag_cloud = wp_tag_cloud( $args ); if ( ! $tag_cloud ) { - $tag_cloud = esc_html( __( 'No terms to show.' ) ); + $labels = get_taxonomy_labels( get_taxonomy( $attributes['taxonomy'] ) ); + $tag_cloud = esc_html( + sprintf( + /* translators: %s: taxonomy name */ + __( 'Your site doesn’t have any %s, so there’s nothing to display here at the moment.' ), + strtolower( $labels->name ) + ) + ); } return sprintf( @@ -48,24 +55,24 @@ function register_block_core_tag_cloud() { 'core/tag-cloud', array( 'attributes' => array( - 'taxonomy' => array( - 'type' => 'string', - 'default' => 'post_tag', + 'align' => array( + 'type' => 'string', + 'enum' => array( 'left', 'center', 'right', 'wide', 'full' ), ), 'className' => array( 'type' => 'string', ), + 'taxonomy' => array( + 'type' => 'string', + 'default' => 'post_tag', + ), 'showTagCounts' => array( 'type' => 'boolean', 'default' => false, ), - 'align' => array( - 'type' => 'string', - ), ), 'render_callback' => 'render_block_core_tag_cloud', ) ); } - add_action( 'init', 'register_block_core_tag_cloud' ); diff --git a/wp-includes/version.php b/wp-includes/version.php index b96ed34073..0c562ca3b1 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.3-alpha-46189'; +$wp_version = '5.3-alpha-46190'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.