From ecc42d0db648fdfabbc045fe1a4ba6ff10c6aa43 Mon Sep 17 00:00:00 2001 From: Himanshu Pathak Date: Wed, 29 Jul 2026 17:25:18 +0530 Subject: [PATCH 1/3] prevent submission of admin filter forms when no filter criteria are selected --- src/wp-includes/script-loader.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index a364439f0abbb..861014c6b3504 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -767,8 +767,10 @@ function wp_default_scripts( $scripts ) { $scripts->set_translations( 'common' ); $bulk_action_observer_ids = array( - 'bulk_action' => 'action', - 'changeit' => 'new_role', + 'bulk_action' => 'action', + 'changeit' => 'new_role', + 'filter_action' => 'filter_action', + 'post-query-submit' => 'post-query-submit', ); did_action( 'init' ) && $scripts->localize( 'common', From 65e629644f1eee83a144992f1e602d2d60c2998d Mon Sep 17 00:00:00 2001 From: Himanshu Pathak Date: Wed, 29 Jul 2026 17:25:38 +0530 Subject: [PATCH 2/3] prevent form submission and display error notice when applying empty list table filters --- src/js/_enqueues/admin/common.js | 48 +++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/src/js/_enqueues/admin/common.js b/src/js/_enqueues/admin/common.js index c3d49310e8897..c6da83fa5c018 100644 --- a/src/js/_enqueues/admin/common.js +++ b/src/js/_enqueues/admin/common.js @@ -1330,7 +1330,53 @@ $( function() { 'bulk_action' : window.bulkActionObserverIds.bulk_action, 'changeit' : window.bulkActionObserverIds.changeit }; - if ( ! Object.keys( bulkFieldRelations ).includes( submitterName ) ) { + + var filterButtonNames = [ + window.bulkActionObserverIds.filter_action, + window.bulkActionObserverIds['post-query-submit'] + ]; + + if ( ! Object.keys( bulkFieldRelations ).includes( submitterName ) && ! filterButtonNames.includes( submitterName ) ) { + return; + } + + if ( filterButtonNames.includes( submitterName ) ) { + var filterDropdowns = form.querySelectorAll( '.actions select' ); + var isFilterActionValid = false; + var urlParams = new URLSearchParams( window.location.search ); + + for ( var i = 0; i < filterDropdowns.length; i++ ) { + var select = filterDropdowns[ i ]; + if ( select.name === 'action' || select.name === 'action2' ) { + continue; + } + if ( select.value !== '0' && select.value !== '' && select.value !== '-1' ) { + isFilterActionValid = true; + break; + } + if ( urlParams.has( select.name ) ) { + isFilterActionValid = true; + break; + } + } + + if ( isFilterActionValid ) { + return; + } + + event.preventDefault(); + event.stopPropagation(); + $( 'html, body' ).animate( { scrollTop: 0 } ); + + var filterErrorMessage = __( 'Please select a filter to apply.' ); + addAdminNotice( { + id: 'no-filter-selected', + type: 'error', + message: filterErrorMessage, + dismissible: true, + } ); + + wp.a11y.speak( filterErrorMessage ); return; } From 662e20f289fe23b01b016f1975d2bfa674a829dc Mon Sep 17 00:00:00 2001 From: Himanshu Pathak Date: Fri, 14 Aug 2026 11:23:35 +0530 Subject: [PATCH 3/3] add filter_action and post-query-submit keys to bulk_action_observer_ids filter documentation --- src/wp-includes/script-loader.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index 861014c6b3504..03a38e5ff98b1 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -779,12 +779,15 @@ function wp_default_scripts( $scripts ) { * Filters the array of field name attributes for bulk actions. * * @since 6.8.1 + * @since 7.2.0 Added 'filter_action' and 'post-query-submit' keys. * * @param array $bulk_action_observer_ids { * An array of field name attributes for bulk actions. * - * @type string $bulk_action The bulk action field name. Default 'action'. - * @type string $changeit The new role field name. Default 'new_role'. + * @type string $bulk_action The bulk action field name. Default 'action'. + * @type string $changeit The new role field name. Default 'new_role'. + * @type string $filter_action The list table Filter button field name. Default 'filter_action'. + * @type string $post-query-submit The media library Filter button field name. Default 'post-query-submit'. * } */ apply_filters( 'bulk_action_observer_ids', $bulk_action_observer_ids )