mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
Administration: Allow WP_List_Table::get_bulk_items() to receive a nested array in order to output optgroups.
The allowed format for bulk actions is now an associative array where each element represents either a top level option value and label, or an array representing an optgroup and its options. For a standard option, the array element key is the field value and the array element value is the field label. For an optgroup, the array element key is the label and the array element value is an associative array of options as above. Props goldenapples, mattkeys, valentinbora, davidbaumwald Fixes #19278 git-svn-id: https://develop.svn.wordpress.org/trunk@49190 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -352,6 +352,42 @@ class Tests_Admin_includesListTable extends WP_UnitTestCase {
|
||||
$this->assertNotContains( 'id="delete_all"', $output );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 19278
|
||||
*/
|
||||
public function test_bulk_action_menu_supports_options_and_optgroups() {
|
||||
$table = _get_list_table( 'WP_Comments_List_Table', array( 'screen' => 'edit-comments' ) );
|
||||
|
||||
add_filter(
|
||||
'bulk_actions-edit-comments',
|
||||
function() {
|
||||
return array(
|
||||
'delete' => 'Delete',
|
||||
'Change State' => array(
|
||||
'feature' => 'Featured',
|
||||
'sale' => 'On Sale',
|
||||
),
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
ob_start();
|
||||
$table->bulk_actions();
|
||||
$output = ob_get_clean();
|
||||
|
||||
$this->assertContains(
|
||||
<<<'OPTIONS'
|
||||
<option value="delete">Delete</option>
|
||||
<optgroup label="Change State">
|
||||
<option value="feature">Featured</option>
|
||||
<option value="sale">On Sale</option>
|
||||
</optgroup>
|
||||
OPTIONS
|
||||
,
|
||||
$output
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 45089
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user