When specifying orders for a bulk action, use `id[]` rather than `order[]` in the URL query.

This prevents a potential conflict with the `order` key, used to specify order direction.
This commit is contained in:
barryhughes 2023-08-01 13:56:41 -07:00
parent 62645e0ba8
commit c33934a851
3 changed files with 7 additions and 7 deletions

View File

@ -58,10 +58,10 @@ class COTRedirectionController {
$params['_wpnonce'] = wp_create_nonce( 'bulk-posts' );
}
// If an `order` array parameter is present, rename as `post`.
if ( isset( $params['order'] ) && is_array( $params['order'] ) ) {
$params['post'] = $params['order'];
unset( $params['order'] );
// If an `id` array parameter is present, rename as `post`
if ( isset( $params['id'] ) && is_array( $params['id'] ) ) {
$params['post'] = $params['id'];
unset( $params['id'] );
}
$params['post_type'] = 'shop_order';

View File

@ -867,7 +867,7 @@ class ListTable extends WP_List_Table {
public function column_cb( $item ) {
ob_start();
?>
<input id="cb-select-<?php echo esc_attr( $item->get_id() ); ?>" type="checkbox" name="<?php echo esc_attr( $this->_args['singular'] ); ?>[]" value="<?php echo esc_attr( $item->get_id() ); ?>" />
<input id="cb-select-<?php echo esc_attr( $item->get_id() ); ?>" type="checkbox" name="id[]" value="<?php echo esc_attr( $item->get_id() ); ?>" />
<div class="locked-indicator">
<span class="locked-indicator-icon" aria-hidden="true"></span>
@ -1197,7 +1197,7 @@ class ListTable extends WP_List_Table {
$action = 'delete';
} else {
$ids = isset( $_REQUEST['order'] ) ? array_reverse( array_map( 'absint', (array) $_REQUEST['order'] ) ) : array();
$ids = isset( $_REQUEST['id'] ) ? array_reverse( array_map( 'absint', (array) $_REQUEST['id'] ) ) : array();
}
/**

View File

@ -139,7 +139,7 @@ class COTRedirectionControllerTest extends WC_Unit_Test_Case {
$this->sut->handle_hpos_admin_requests(
array(
'arbitrary' => '3pd-integration',
'order' => array(
'id' => array(
123,
456,
),