PluginProbe
Gutenberg / 14.5.2
Gutenberg v14.5.2
24.0.0 23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 All 403 releases
← All changes | build/block-library/blocks/archives.php +12 -13 12.6.0 → 14.5.2 View file →
@@ -15,16 +15,17 @@
15 15 * @return string Returns the post content with archives added.
16 16 */
17 17 function gutenberg_render_block_core_archives( $attributes ) {
18 18 $show_post_count = ! empty( $attributes['showPostCounts'] );
19 + $type = isset( $attributes['type'] ) ? $attributes['type'] : 'monthly';
19 20
20 - $class = '';
21 + $class = 'wp-block-archives-list';
21 22
22 23 if ( ! empty( $attributes['displayAsDropdown'] ) ) {
23 24
24 - $class .= ' wp-block-archives-dropdown';
25 + $class = 'wp-block-archives-dropdown';
25 26
26 - $dropdown_id = uniqid( 'wp-block-archives-' );
27 + $dropdown_id = wp_unique_id( 'wp-block-archives-' );
27 28 $title = __( 'Archives' );
28 29
29 30 /** This filter is documented in wp-includes/widgets/class-wp-widget-archives.php */
30 31 $dropdown_args = apply_filters(
@@ -29,9 +30,9 @@
29 30 /** This filter is documented in wp-includes/widgets/class-wp-widget-archives.php */
30 31 $dropdown_args = apply_filters(
31 32 'widget_archives_dropdown_args',
32 33 array(
33 - 'type' => 'monthly',
34 + 'type' => $type,
34 35 'format' => 'option',
35 36 'show_post_count' => $show_post_count,
36 37 )
37 38 );
@@ -39,12 +40,10 @@
39 40 $dropdown_args['echo'] = 0;
40 41
41 42 $archives = wp_get_archives( $dropdown_args );
42 43
43 - $classnames = esc_attr( $class );
44 + $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $class ) );
44 45
45 - $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classnames ) );
46 -
47 46 switch ( $dropdown_args['type'] ) {
48 47 case 'yearly':
49 48 $label = __( 'Select Year' );
50 49 break;
@@ -61,12 +60,14 @@
61 60 $label = __( 'Select Post' );
62 61 break;
63 62 }
64 63
65 - $block_content = '<label for="' . esc_attr( $dropdown_id ) . '">' . esc_html( $title ) . '</label>
66 - <select id="' . esc_attr( $dropdown_id ) . '" name="archive-dropdown" onchange="document.location.href=this.options[this.selectedIndex].value;">
67 - <option value="">' . esc_html( $label ) . '</option>' . $archives . '</select>';
64 + $show_label = empty( $attributes['showLabel'] ) ? ' screen-reader-text' : '';
68 65
66 + $block_content = '<label for="' . $dropdown_id . '" class="wp-block-archives__label' . $show_label . '">' . esc_html( $title ) . '</label>
67 + <select id="' . $dropdown_id . '" name="archive-dropdown" onchange="document.location.href=this.options[this.selectedIndex].value;">
68 + <option value="">' . esc_html( $label ) . '</option>' . $archives . '</select>';
69 +
69 70 return sprintf(
70 71 '<div %1$s>%2$s</div>',
71 72 $wrapper_attributes,
72 73 $block_content
@@ -72,15 +73,13 @@
72 73 $block_content
73 74 );
74 75 }
75 76
76 - $class .= ' wp-block-archives-list';
77 -
78 77 /** This filter is documented in wp-includes/widgets/class-wp-widget-archives.php */
79 78 $archives_args = apply_filters(
80 79 'widget_archives_args',
81 80 array(
82 - 'type' => 'monthly',
81 + 'type' => $type,
83 82 'show_post_count' => $show_post_count,
84 83 )
85 84 );
86 85