Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Administration: Allow filtering of bulk action fields #8536

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/js/_enqueues/admin/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1321,8 +1321,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.bulkFieldRelations.bulk_action,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use optional chaining here for cleaner and safer code?

'changeit' : window.bulkFieldRelations.changeit

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use optional chaining here for cleaner and safer code?

};
if ( ! Object.keys( bulkFieldRelations ).includes( submitterName ) ) {
return;
Expand Down
22 changes: 22 additions & 0 deletions src/wp-includes/script-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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_field_relations = array(
'bulk_action' => 'action',
'changeit' => 'new_role',
);
did_action( 'init' ) && $scripts->localize(
'common',
'bulkFieldRelations',
/**
* Filters the array of field relations for the bulk actions.
*
* @since 6.7.3
*
* @param array $bulk_field_relations {
* An array of field relations for the 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_field_relations', $bulk_field_relations )
);

$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 );
Expand Down
Loading