WithdrawalsList::process_bulk_action()
Source
File: classes/WithdrawalsList.php
function process_bulk_action() { global $wpdb; $withdraw_page_url = admin_url( 'admin.php?page=dozent_withdrawals' ); $date = dozent_mysql_time(); $redirect = false; //Detect when a bulk action is being triggered... if ( 'delete' === $this->current_action() ) { $should_withdraw_delete = apply_filters( 'dozent_should_withdraw_delete', true ); if ( $should_withdraw_delete ) { $withdraw_id = (int) sanitize_text_field( $_GET['withdraw_id'] ); do_action( 'dozent_before_delete_withdraw', $withdraw_id ); $wpdb->delete( $wpdb->dozent_withdrawal, array( 'withdraw_id' => $withdraw_id ) ); do_action( 'dozent_after_delete_withdraw', $withdraw_id ); $redirect = true; } else { wp_die( 'Items deleted (or they would be if we had items to delete)!' ); } } /** * Reject Withdraw */ if ( 'completed' === $this->current_action() ) { $withdraw_id = (int) sanitize_text_field( $_GET['withdraw_id'] ); $withdraw = $wpdb->get_row( "SELECT * FROM {$wpdb->dozent_withdrawal} WHERE withdraw_id = {$withdraw_id} " ); if ( ! $withdraw || $withdraw->status === 'completed' ) { return; } do_action( 'dozent_before_completed_withdraw', $withdraw_id ); $wpdb->update( $wpdb->dozent_withdrawal, array( 'status' => 'completed', 'updated_at' => $date ), array( 'withdraw_id' => $withdraw_id ) ); do_action( 'dozent_after_completed_withdraw', $withdraw_id ); $redirect = true; } /** * Rejected */ if ( 'rejected' === $this->current_action() ) { $withdraw_id = (int) sanitize_text_field( $_GET['withdraw_id'] ); $withdraw = $wpdb->get_row( "SELECT * FROM {$wpdb->dozent_withdrawal} WHERE withdraw_id = {$withdraw_id} " ); if ( ! $withdraw || $withdraw->status === 'rejected' ) { return; } do_action( 'dozent_before_rejected_withdraw', $withdraw_id ); $wpdb->update( $wpdb->dozent_withdrawal, array( 'status' => 'rejected', 'updated_at' => $date ), array( 'withdraw_id' => $withdraw_id ) ); do_action( 'dozent_after_rejected_withdraw', $withdraw_id ); $redirect = true; } if ( $redirect ) { die( "<script>location.href='{$withdraw_page_url}';</script>" ); } }