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
This commit is contained in:
gziolo 2019-09-19 15:47:58 +00:00
parent 03390f00c5
commit 1fb85addf9
5 changed files with 63 additions and 19 deletions

View File

@ -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(
'<div class="%1$s">%2$s</div>',
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',

View File

@ -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'], ' [&hellip;]' ) );
// Change existing [...] to [&hellip;].
if ( '[...]' == substr( $excerpt, -5 ) ) {
if ( '[...]' === substr( $excerpt, -5 ) ) {
$excerpt = substr( $excerpt, 0, -5 ) . '[&hellip;]';
}
@ -79,8 +79,24 @@ function render_block_core_rss( $attributes ) {
$list_items .= "<li class='wp-block-rss__item'>{$title}{$date}{$author}{$excerpt}</li>";
}
$classes = 'grid' === $attributes['blockLayout'] ? ' is-grid columns-' . $attributes['columns'] : '';
$list_items_markup = "<ul class='wp-block-rss{$classes}'>{$list_items}</ul>";
$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 = "<ul class='{$class}'>{$list_items}</ul>";
// 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' );

View File

@ -16,6 +16,8 @@ function render_block_core_search( $attributes ) {
static $instance_id = 0;
$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(
'<form class="%s" role="search" method="get" action="%s">%s</form>',
$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' );

View File

@ -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&#8217;t have any %s, so there&#8217;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(
'align' => array(
'type' => 'string',
'default' => 'post_tag',
'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' );

View File

@ -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.