Themes: Add filter on bulk action fields.

Because validation was added in [59134] to prevent submitting bulk actions with no selected action, sites that remove or change the default bulk actions can fail due to the missing required inputs. Add a filter (`bulk_action_observer_ids`) that allows modifying the actions accepted to fulfill validation rules.

Props ethitter, kabir93, jorbin, davidbaumwald, joedolson.
Fixes #63005.
Built from https://develop.svn.wordpress.org/trunk@60186


git-svn-id: http://core.svn.wordpress.org/trunk@59522 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
joedolson
2025-04-25 18:20:32 +00:00
parent ef85ed97e2
commit 228f05af93
4 changed files with 26 additions and 4 deletions

View File

@@ -1327,8 +1327,8 @@ $( function() {
// Observe submissions from posts lists for 'bulk_action' or users lists for 'new_role'.
var bulkFieldRelations = {
'bulk_action' : 'action',
'changeit' : 'new_role'
'bulk_action' : window.bulkActionObserverIds.bulk_action,
'changeit' : window.bulkActionObserverIds.changeit
};
if ( ! Object.keys( bulkFieldRelations ).includes( submitterName ) ) {
return;

File diff suppressed because one or more lines are too long

View File

@@ -757,6 +757,28 @@ function wp_default_scripts( $scripts ) {
$scripts->add( 'common', "/wp-admin/js/common$suffix.js", array( 'jquery', 'hoverIntent', 'utils', 'wp-a11y' ), false, 1 );
$scripts->set_translations( 'common' );
$bulk_action_observer_ids = array(
'bulk_action' => 'action',
'changeit' => 'new_role',
);
did_action( 'init' ) && $scripts->localize(
'common',
'bulkActionObserverIds',
/**
* Filters the array of field name attributes for bulk actions.
*
* @since 6.8.1
*
* @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'.
* }
*/
apply_filters( 'bulk_action_observer_ids', $bulk_action_observer_ids )
);
$scripts->add( 'wp-sanitize', "/wp-includes/js/wp-sanitize$suffix.js", array(), false, 1 );
$scripts->add( 'sack', "/wp-includes/js/tw-sack$suffix.js", array(), '1.6.1', 1 );

View File

@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.9-alpha-60185';
$wp_version = '6.9-alpha-60186';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.