Exemplo n.º 1
0
/**
 * Delete a purchase log
 *
 * @deprecated  Use WPSC_Purchase_Log->delete() instead.
 *
 * @param   int|string  $purchlog_id  Required. Purchase log ID (empty string is deprecated).
 * @return  boolean                   Deleted successfully.
 */
function wpsc_delete_purchlog($purchlog_id = '')
{
    global $wpdb;
    // Deprecate empty purchase log ID parameter.
    if ($purchlog_id == '') {
        _wpsc_doing_it_wrong('wpsc_delete_purchlog', __('$purchlog_id parameter requires a numeric purchase log ID.', 'wp-e-commerce'), '3.9.0');
        return false;
    }
    $log = new WPSC_Purchase_Log($purchlog_id);
    return $log->delete();
}
 public function process_bulk_action()
 {
     global $wpdb;
     $current_action = $this->list_table->current_action();
     do_action('wpsc_sales_log_process_bulk_action', $current_action);
     if (!$current_action || 'download_csv' != $current_action && empty($_REQUEST['post'])) {
         if (!empty($_REQUEST['_wp_http_referer'])) {
             wp_redirect(esc_url_raw(remove_query_arg(array('_wp_http_referer', '_wpnonce', 'action', 'action2'), stripslashes($_SERVER['REQUEST_URI']))));
             exit;
         }
         unset($_REQUEST['post']);
         return;
     }
     if ('download_csv' == $current_action) {
         $this->download_csv();
         exit;
     }
     $sendback = remove_query_arg(array('_wpnonce', '_wp_http_referer', 'action', 'action2', 'confirm', 'post', 'last_paged'));
     if ('delete' == $current_action) {
         // delete action
         if (empty($_REQUEST['confirm'])) {
             $this->list_table->disable_search_box();
             $this->list_table->disable_bulk_actions();
             $this->list_table->disable_sortable();
             $this->list_table->disable_month_filter();
             $this->list_table->disable_views();
             $this->list_table->set_per_page(0);
             add_action('wpsc_purchase_logs_list_table_before', array($this, 'action_list_table_before'));
             return;
         } else {
             if (empty($_REQUEST['post'])) {
                 return;
             }
             $ids = array_map('intval', $_REQUEST['post']);
             foreach ($ids as $id) {
                 $log = new WPSC_Purchase_Log($id);
                 $log->delete();
             }
             $sendback = add_query_arg(array('paged' => $_REQUEST['last_paged'], 'deleted' => count($_REQUEST['post'])), $sendback);
         }
     }
     // change status actions
     if (is_numeric($current_action) && !empty($_REQUEST['post'])) {
         foreach ($_REQUEST['post'] as $id) {
             wpsc_purchlog_edit_status($id, $current_action);
         }
         $sendback = add_query_arg(array('updated' => count($_REQUEST['post'])), $sendback);
     }
     wp_redirect(esc_url_raw($sendback));
     exit;
 }