示例#1
0
/**
 * Process the delete referral request
 *
 * @since 1.7
 * @return void
 */
function affwp_process_delete_referral($data)
{
    if (!is_admin()) {
        return false;
    }
    if (!current_user_can('manage_referrals')) {
        wp_die(__('You do not have permission to manage referrals', 'affiliate-wp'), array('response' => 403));
    }
    if (!wp_verify_nonce($data['_wpnonce'], 'affwp_delete_referral_nonce')) {
        wp_die(__('Security check failed', 'affiliate-wp'), array('response' => 403));
    }
    if (affwp_delete_referral($data['referral_id'])) {
        wp_safe_redirect(admin_url('admin.php?page=affiliate-wp-referrals&affwp_notice=referral_deleted'));
        exit;
    } else {
        wp_safe_redirect(admin_url('admin.php?page=affiliate-wp-referrals&affwp_notice=referral_delete_failed'));
        exit;
    }
}
示例#2
0
 /**
  * Process the bulk actions
  *
  * @access public
  * @since 1.0
  * @return void
  */
 public function process_bulk_action()
 {
     if (empty($_REQUEST['_wpnonce'])) {
         return;
     }
     if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'bulk-referrals') && !wp_verify_nonce($_REQUEST['_wpnonce'], 'referral-nonce')) {
         return;
     }
     $ids = isset($_GET['referral_id']) ? $_GET['referral_id'] : array();
     if (!is_array($ids)) {
         $ids = array($ids);
     }
     $ids = array_map('absint', $ids);
     $action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : false;
     if (empty($ids) || empty($action)) {
         return;
     }
     foreach ($ids as $id) {
         if ('delete' === $this->current_action()) {
             affwp_delete_referral($id);
         }
         if ('reject' === $this->current_action()) {
             affwp_set_referral_status($id, 'rejected');
         }
         if ('accept' === $this->current_action()) {
             affwp_set_referral_status($id, 'unpaid');
         }
         if ('mark_as_paid' === $this->current_action()) {
             affwp_set_referral_status($id, 'paid');
         }
         if ('mark_as_unpaid' === $this->current_action()) {
             affwp_set_referral_status($id, 'unpaid');
         }
         do_action('affwp_referrals_do_bulk_action_' . $this->current_action(), $id);
     }
 }