This commit is contained in:
Hanson.xyz Dev
2026-01-04 17:50:08 -06:00
parent 7e45ce0756
commit acc8ac87a0
4131 changed files with 232562 additions and 250244 deletions
@@ -96,19 +96,36 @@ class WP_Widget_Categories extends WP_Widget {
?>
<script>
(function() {
var dropdown = document.getElementById( "<?php echo esc_js( $dropdown_id ); ?>" );
function onCatChange() {
if ( dropdown.options[ dropdown.selectedIndex ].value > 0 ) {
dropdown.parentNode.submit();
( ( dropdownId ) => {
const dropdown = document.getElementById( dropdownId );
function onSelectChange() {
setTimeout( () => {
if ( 'escape' === dropdown.dataset.lastkey ) {
return;
}
if ( dropdown.value && parseInt( dropdown.value ) > 0 && dropdown instanceof HTMLSelectElement ) {
dropdown.parentElement.submit();
}
}, 250 );
}
function onKeyUp( event ) {
if ( 'Escape' === event.key ) {
dropdown.dataset.lastkey = 'escape';
} else {
delete dropdown.dataset.lastkey;
}
}
dropdown.onchange = onCatChange;
})();
function onClick() {
delete dropdown.dataset.lastkey;
}
dropdown.addEventListener( 'keyup', onKeyUp );
dropdown.addEventListener( 'click', onClick );
dropdown.addEventListener( 'change', onSelectChange );
})( <?php echo wp_json_encode( $dropdown_id, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ); ?> );
</script>
<?php
wp_print_inline_script_tag( wp_remove_surrounding_empty_script_tags( ob_get_clean() ) );
wp_print_inline_script_tag( wp_remove_surrounding_empty_script_tags( ob_get_clean() ) . "\n//# sourceURL=" . rawurlencode( __METHOD__ ) );
} else {
$format = current_theme_supports( 'html5', 'navigation-widgets' ) ? 'html5' : 'xhtml';