diff -r be944660c56a -r 3d72ae0968f4 wp/wp-includes/blocks/archives.php --- 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 = ' - '; + $block_content = ' + '; return sprintf( - '
%2$s
', - esc_attr( $class ), + '
%2$s
', + $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(