Merge pull request #20445 from roshansameer/webhook-bulk-delete-bottom
Fix - on webhook bulk action footer delete selection
This commit is contained in:
commit
4b1e08b9b9
|
@ -207,6 +207,22 @@ class WC_Admin_Webhooks_Table_List extends WP_List_Table {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process bulk actions.
|
||||
*/
|
||||
public function process_bulk_action() {
|
||||
$action = $this->current_action();
|
||||
$webhooks = isset( $_REQUEST['webhook'] ) ? array_map( 'absint', (array) $_REQUEST['webhook'] ) : array(); // WPCS: input var okay, CSRF ok.
|
||||
|
||||
if ( ! current_user_can( 'manage_woocommerce' ) ) {
|
||||
wp_die( esc_html__( 'You do not have permission to edit Webhooks', 'woocommerce' ) );
|
||||
}
|
||||
|
||||
if ( 'delete' === $action ) {
|
||||
WC_Admin_Webhooks::bulk_delete( $webhooks );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the table navigation above or below the table.
|
||||
* Included to remove extra nonce input.
|
||||
|
|
|
@ -150,7 +150,7 @@ class WC_Admin_Webhooks {
|
|||
*
|
||||
* @param array $webhooks List of webhooks IDs.
|
||||
*/
|
||||
private function bulk_delete( $webhooks ) {
|
||||
public static function bulk_delete( $webhooks ) {
|
||||
foreach ( $webhooks as $webhook_id ) {
|
||||
$webhook = new WC_Webhook( (int) $webhook_id );
|
||||
$webhook->delete( true );
|
||||
|
@ -179,27 +179,6 @@ class WC_Admin_Webhooks {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Bulk actions.
|
||||
*/
|
||||
private function bulk_actions() {
|
||||
check_admin_referer( 'woocommerce-settings' );
|
||||
|
||||
if ( ! current_user_can( 'manage_woocommerce' ) ) {
|
||||
wp_die( esc_html__( 'You do not have permission to edit Webhooks', 'woocommerce' ) );
|
||||
}
|
||||
|
||||
if ( isset( $_REQUEST['action'] ) ) { // WPCS: input var okay, CSRF ok.
|
||||
$webhooks = isset( $_REQUEST['webhook'] ) ? array_map( 'absint', (array) $_REQUEST['webhook'] ) : array(); // WPCS: input var okay, CSRF ok.
|
||||
|
||||
$action = sanitize_text_field( wp_unslash( $_REQUEST['action'] ) ); // WPCS: input var okay, CSRF ok.
|
||||
|
||||
if ( 'delete' === $action ) {
|
||||
$this->bulk_delete( $webhooks );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Webhooks admin actions.
|
||||
*/
|
||||
|
@ -210,11 +189,6 @@ class WC_Admin_Webhooks {
|
|||
$this->save();
|
||||
}
|
||||
|
||||
// Bulk actions.
|
||||
if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['webhook'] ) ) { // WPCS: input var okay, CSRF ok.
|
||||
$this->bulk_actions();
|
||||
}
|
||||
|
||||
// Delete webhook.
|
||||
if ( isset( $_GET['delete'] ) ) { // WPCS: input var okay, CSRF ok.
|
||||
$this->delete();
|
||||
|
@ -299,6 +273,7 @@ class WC_Admin_Webhooks {
|
|||
$count = count( $data_store->get_webhooks_ids() );
|
||||
|
||||
if ( 0 < $count ) {
|
||||
$webhooks_table_list->process_bulk_action();
|
||||
$webhooks_table_list->prepare_items();
|
||||
|
||||
echo '<input type="hidden" name="page" value="wc-settings" />';
|
||||
|
|
Loading…
Reference in New Issue