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.

Reviewed by Jorbin.
Merges [60186] to the 6.8 branch.

Props ethitter, kabir93, jorbin, davidbaumwald, joedolson.
Fixes #63005.

Built from https://develop.svn.wordpress.org/branches/6.8@60188


git-svn-id: http://core.svn.wordpress.org/branches/6.8@59524 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Aaron Jorbin
2025-04-25 18:38:29 +00:00
parent 690978a7d3
commit 40745ab9c3
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'. // Observe submissions from posts lists for 'bulk_action' or users lists for 'new_role'.
var bulkFieldRelations = { var bulkFieldRelations = {
'bulk_action' : 'action', 'bulk_action' : window.bulkActionObserverIds.bulk_action,
'changeit' : 'new_role' 'changeit' : window.bulkActionObserverIds.changeit
}; };
if ( ! Object.keys( bulkFieldRelations ).includes( submitterName ) ) { if ( ! Object.keys( bulkFieldRelations ).includes( submitterName ) ) {
return; 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->add( 'common', "/wp-admin/js/common$suffix.js", array( 'jquery', 'hoverIntent', 'utils', 'wp-a11y' ), false, 1 );
$scripts->set_translations( 'common' ); $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( '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 ); $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 * @global string $wp_version
*/ */
$wp_version = '6.8.1-alpha-60187'; $wp_version = '6.8.1-alpha-60188';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.