Fixed missing bulk action notices for REST API keys

This commit is contained in:
Claudio Sanches 2018-07-04 16:24:27 -03:00
parent 5d3653b8ca
commit b044e4c46d
1 changed files with 16 additions and 4 deletions

View File

@ -172,8 +172,11 @@ class WC_Admin_API_Keys {
* Notices.
*/
public static function notices() {
if ( isset( $_GET['revoked'] ) && 1 === $_GET['revoked'] ) { // WPCS: input var okay, CSRF ok.
WC_Admin_Settings::add_message( __( 'API key revoked successfully.', 'woocommerce' ) );
if ( isset( $_GET['revoked'] ) ) { // WPCS: input var okay, CSRF ok.
$revoked = absint( $_GET['revoked'] ); // WPCS: input var okay, CSRF ok.
/* translators: %d: count */
WC_Admin_Settings::add_message( sprintf( _n( '%d API key permanently revoked.', '%d API keys permanently revoked.', $revoked, 'woocommerce' ), $revoked ) );
}
}
@ -191,7 +194,7 @@ class WC_Admin_API_Keys {
}
}
wp_redirect( esc_url_raw( add_query_arg( array( 'revoked' => 1 ), admin_url( 'admin.php?page=wc-settings&tab=advanced&section=keys' ) ) ) );
wp_safe_redirect( esc_url_raw( add_query_arg( array( 'revoked' => 1 ), admin_url( 'admin.php?page=wc-settings&tab=advanced&section=keys' ) ) ) );
exit();
}
@ -221,9 +224,18 @@ class WC_Admin_API_Keys {
* @param array $keys API Keys.
*/
private function bulk_revoke_key( $keys ) {
$qty = 0;
foreach ( $keys as $key_id ) {
$this->remove_key( $key_id );
$result = $this->remove_key( $key_id );
if ( $result ) {
$qty++;
}
}
// Redirect to webhooks page.
wp_safe_redirect( esc_url_raw( add_query_arg( array( 'revoked' => $qty ), admin_url( 'admin.php?page=wc-settings&tab=advanced&section=keys' ) ) ) );
exit();
}
/**