--- a/wp/wp-includes/blocks/archives.php Wed Sep 21 18:19:35 2022 +0200
+++ b/wp/wp-includes/blocks/archives.php Tue Sep 27 16:37:53 2022 +0200
@@ -16,21 +16,21 @@
*/
function render_block_core_archives( $attributes ) {
$show_post_count = ! empty( $attributes['showPostCounts'] );
-
- $class = '';
+ $type = isset( $attributes['type'] ) ? $attributes['type'] : 'monthly';
+ $class = '';
if ( ! empty( $attributes['displayAsDropdown'] ) ) {
$class .= ' wp-block-archives-dropdown';
- $dropdown_id = esc_attr( uniqid( 'wp-block-archives-' ) );
+ $dropdown_id = wp_unique_id( 'wp-block-archives-' );
$title = __( 'Archives' );
/** This filter is documented in wp-includes/widgets/class-wp-widget-archives.php */
$dropdown_args = apply_filters(
'widget_archives_dropdown_args',
array(
- 'type' => 'monthly',
+ 'type' => $type,
'format' => 'option',
'show_post_count' => $show_post_count,
)
@@ -40,6 +40,10 @@
$archives = wp_get_archives( $dropdown_args );
+ $classnames = esc_attr( $class );
+
+ $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classnames ) );
+
switch ( $dropdown_args['type'] ) {
case 'yearly':
$label = __( 'Select Year' );
@@ -58,15 +62,13 @@
break;
}
- $label = esc_html( $label );
-
- $block_content = '<label class="screen-reader-text" for="' . $dropdown_id . '">' . $title . '</label>
- <select id="' . $dropdown_id . '" name="archive-dropdown" onchange="document.location.href=this.options[this.selectedIndex].value;">
- <option value="">' . $label . '</option>' . $archives . '</select>';
+ $block_content = '<label for="' . esc_attr( $dropdown_id ) . '">' . esc_html( $title ) . '</label>
+ <select id="' . esc_attr( $dropdown_id ) . '" name="archive-dropdown" onchange="document.location.href=this.options[this.selectedIndex].value;">
+ <option value="">' . esc_html( $label ) . '</option>' . $archives . '</select>';
return sprintf(
- '<div class="%1$s">%2$s</div>',
- esc_attr( $class ),
+ '<div %1$s>%2$s</div>',
+ $wrapper_attributes,
$block_content
);
}
@@ -77,7 +79,7 @@
$archives_args = apply_filters(
'widget_archives_args',
array(
- 'type' => 'monthly',
+ 'type' => $type,
'show_post_count' => $show_post_count,
)
);
@@ -86,9 +88,7 @@
$archives = wp_get_archives( $archives_args );
- $classnames = esc_attr( $class );
-
- $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classnames ) );
+ $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $class ) );
if ( empty( $archives ) ) {
return sprintf(