PluginProbe
Gutenberg / 8.5.1
Gutenberg v8.5.1
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/categories.php +15 -16 12.6.0 → 8.5.1 View file →
@@ -22,40 +22,39 @@
22 22 'orderby' => 'name',
23 23 'show_count' => ! empty( $attributes['showPostCounts'] ),
24 24 'title_li' => '',
25 25 );
26 - if ( ! empty( $attributes['showOnlyTopLevel'] ) && $attributes['showOnlyTopLevel'] ) {
27 - $args['parent'] = 0;
28 - }
29 26
30 27 if ( ! empty( $attributes['displayAsDropdown'] ) ) {
31 28 $id = 'wp-block-categories-' . $block_id;
32 29 $args['id'] = $id;
33 30 $args['show_option_none'] = __( 'Select Category' );
34 - $wrapper_markup = '<div %1$s><label class="screen-reader-text" for="' . esc_attr( $id ) . '">' . __( 'Categories' ) . '</label>%2$s</div>';
31 + $wrapper_markup = '<div class="%1$s">%2$s</div>';
35 32 $items_markup = wp_dropdown_categories( $args );
36 33 $type = 'dropdown';
37 34
38 35 if ( ! is_admin() ) {
39 - // Inject the dropdown script immediately after the select dropdown.
40 - $items_markup = preg_replace(
41 - '#(?<=</select>)#',
42 - gutenberg_build_dropdown_script_block_core_categories( $id ),
43 - $items_markup,
44 - 1
45 - );
36 + $wrapper_markup .= gutenberg_build_dropdown_script_block_core_categories( $id );
46 37 }
47 38 } else {
48 - $wrapper_markup = '<ul %1$s>%2$s</ul>';
39 + $wrapper_markup = '<ul class="%1$s">%2$s</ul>';
49 40 $items_markup = wp_list_categories( $args );
50 41 $type = 'list';
51 42 }
52 43
53 - $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => "wp-block-categories-{$type}" ) );
44 + $class = "wp-block-categories wp-block-categories-{$type}";
54 45
46 + if ( isset( $attributes['align'] ) ) {
47 + $class .= " align{$attributes['align']}";
48 + }
49 +
50 + if ( isset( $attributes['className'] ) ) {
51 + $class .= " {$attributes['className']}";
52 + }
53 +
55 54 return sprintf(
56 55 $wrapper_markup,
57 - $wrapper_attributes,
56 + esc_attr( $class ),
58 57 $items_markup
59 58 );
60 59 }
61 60
@@ -72,14 +71,14 @@
72 71 <script type='text/javascript'>
73 72 /* <![CDATA[ */
74 73 ( function() {
75 74 var dropdown = document.getElementById( '<?php echo esc_js( $dropdown_id ); ?>' );
76 - function gutenberg_onCatChange() {
75 + function onCatChange() {
77 76 if ( dropdown.options[ dropdown.selectedIndex ].value > 0 ) {
78 77 location.href = "<?php echo home_url(); ?>/?cat=" + dropdown.options[ dropdown.selectedIndex ].value;
79 78 }
80 79 }
81 - dropdown.onchange = gutenberg_onCatChange;
80 + dropdown.onchange = onCatChange;
82 81 })();
83 82 /* ]]> */
84 83 </script>
85 84 <?php