diff --git src/wp-includes/widgets/class-wp-widget-categories.php src/wp-includes/widgets/class-wp-widget-categories.php
index 13be3425e1..dd12d7c4da 100644
|
|
class WP_Widget_Categories extends WP_Widget { |
86 | 86 | * @param array $cat_args An array of Categories widget drop-down arguments. |
87 | 87 | * @param array $instance Array of settings for the current widget. |
88 | 88 | */ |
89 | | wp_dropdown_categories( apply_filters( 'widget_categories_dropdown_args', $cat_args, $instance ) ); |
| 89 | $cat_args = apply_filters( 'widget_categories_dropdown_args', $cat_args, $instance ); |
| 90 | $cat_args['echo'] = false; |
| 91 | |
| 92 | $dropdown = wp_dropdown_categories( $cat_args ); |
| 93 | $onchange = 'if ( this.value > 0 ) { var form = this.form; if ( ! form ) { form = this.parentNode; while ( form && form.nodeName !== \'form\' ) { form = form.parentNode; } } if ( form ) { form.submit(); } }'; |
| 94 | $dropdown = preg_replace( |
| 95 | '/(?<=<select\b)/', |
| 96 | sprintf( ' onchange="%s" ', esc_attr( $onchange ) ), |
| 97 | $dropdown, |
| 98 | 1 |
| 99 | ); |
| 100 | echo $dropdown; |
90 | 101 | |
91 | 102 | echo '</form>'; |
92 | | ?> |
93 | | |
94 | | <script type='text/javascript'> |
95 | | /* <![CDATA[ */ |
96 | | (function() { |
97 | | var dropdown = document.getElementById( "<?php echo esc_js( $dropdown_id ); ?>" ); |
98 | | function onCatChange() { |
99 | | if ( dropdown.options[ dropdown.selectedIndex ].value > 0 ) { |
100 | | dropdown.parentNode.submit(); |
101 | | } |
102 | | } |
103 | | dropdown.onchange = onCatChange; |
104 | | })(); |
105 | | /* ]]> */ |
106 | | </script> |
107 | | |
108 | | <?php |
109 | 103 | } else { |
110 | 104 | ?> |
111 | 105 | <ul> |