Make WordPress Core

Ticket #63531: 63531.diff

File 63531.diff, 2.3 KB (added by whyisjake, 8 months ago)
  • src/wp-includes/blocks/categories.php

     
    5050                $show_label     = empty( $attributes['showLabel'] ) ? ' screen-reader-text' : '';
    5151                $default_label  = $taxonomy->label;
    5252                $label_text     = ! empty( $attributes['label'] ) ? wp_kses_post( $attributes['label'] ) : $default_label;
    53                 $wrapper_markup = '<div %1$s><label class="wp-block-categories__label' . $show_label . '" for="' . esc_attr( $id ) . '">' . $label_text . '</label>%2$s</div>';
     53                $wrapper_markup = '<div %1$s><form action="' . esc_url( home_url() ) . '" method="get"><label class="wp-block-categories__label' . $show_label . '" for="' . esc_attr( $id ) . '">' . $label_text . '</label>%2$s<button type="submit">' . esc_html__( 'View' ) . '</button></form></div>';
    5454                $items_markup   = wp_dropdown_categories( $args );
    5555                $type           = 'dropdown';
    56 
    57                 if ( ! is_admin() ) {
    58                         // Inject the dropdown script immediately after the select dropdown.
    59                         $items_markup = preg_replace(
    60                                 '#(?<=</select>)#',
    61                                 build_dropdown_script_block_core_categories( $id ),
    62                                 $items_markup,
    63                                 1
    64                         );
    65                 }
    6656        } else {
    6757                $args['show_option_none'] = $taxonomy->labels->no_terms;
    6858
  • src/wp-includes/widgets/class-wp-widget-categories.php

     
    9090                         */
    9191                        wp_dropdown_categories( apply_filters( 'widget_categories_dropdown_args', $cat_args, $instance ) );
    9292
     93                        echo '<button type="submit">' . esc_html__( 'View' ) . '</button>';
    9394                        echo '</form>';
    9495
    95                         ob_start();
    96                         ?>
    97 
    98 <script>
    99 (function() {
    100         var dropdown = document.getElementById( "<?php echo esc_js( $dropdown_id ); ?>" );
    101         function onCatChange() {
    102                 if ( dropdown.options[ dropdown.selectedIndex ].value > 0 ) {
    103                         dropdown.parentNode.submit();
    104                 }
    105         }
    106         dropdown.onchange = onCatChange;
    107 })();
    108 </script>
    109 
    110                         <?php
    111                         wp_print_inline_script_tag( wp_remove_surrounding_empty_script_tags( ob_get_clean() ) );
    11296                } else {
    11397                        $format = current_theme_supports( 'html5', 'navigation-widgets' ) ? 'html5' : 'xhtml';
    11498