Commit 18dc04d8 authored by Varun Sridharan's avatar Varun Sridharan

#58 Fixed and minor changes done

* Fixed Empty Trash Issue
* Fixed  #58
* Added  Option To Clear Donation Log In system tools menu
parent f3266f8b
......@@ -22,7 +22,10 @@ class WooCommerce_Quick_Donation_Admin_Function {
add_action( 'parse_query', array( $this, 'hide_donation_order_woocommerce_order' ) );
add_filter( 'wc_order_types',array($this,'add_wc_order_types'),1,2);
add_action( 'delete_post', array($this,'delete_donation'));
add_action( 'wp_ajax_CreateDonationProduct', array($this,'create_donation_product') );
add_action( 'wp_ajax_ClearDonationLog', array($this,'clear_wc_qd_logs') );
}
......@@ -123,7 +126,7 @@ class WooCommerce_Quick_Donation_Admin_Function {
public function create_donation_product(){
if(! isset($_REQUEST['_wpnonce'])) {
echo '<span class="wc_qd_error">Invalid Nonce. kindly try again</span>';
echo '<span class="wc_qd_error">'.__('Invalid Nonce. kindly try again',WC_QD_TXT).'</span>';
exit;
}
......@@ -134,14 +137,14 @@ class WooCommerce_Quick_Donation_Admin_Function {
$donation_exist = $install::check_donation_exists();
if(isset($_REQUEST['force'])){
$post_id = $install::$callBack_function();
$post_id = $install->$callBack_function();
update_option(WC_QD_DB.'product_id',$post_id);
echo '<span class="wcqdsuccess">'.__('Donation Product Created',WC_QD_TXT).'</span>';
exit;
}
if(! $donation_exist){
$post_id = $install::$callBack_function();
$post_id = $install->$callBack_function();
update_option(WC_QD_DB.'product_id',$post_id);
echo '<span class="wcqdsuccess">'.__('Donation Product Created',WC_QD_TXT).'</span>';
} else {
......@@ -154,4 +157,18 @@ class WooCommerce_Quick_Donation_Admin_Function {
exit;
}
public function clear_wc_qd_logs(){
if(! isset($_REQUEST['_wpnonce'])) {
echo '<span class="wc_qd_error">'.__('Invalid Nonce. kindly try again',WC_QD_TXT).'</span>';
exit;
}
if(wp_verify_nonce($_REQUEST['_wpnonce'], 'ClearDonationLog')){
$delete = WC_QD()->db()->delete_donation_logs();
echo '<span class="wcqdsuccess">'.sprintf(__('%s Records Deleted',WC_QD_TXT),$delete).'</span>';
}
exit;
}
}
\ No newline at end of file
......@@ -177,7 +177,7 @@ class WooCommerce_Quick_Donation_Admin {
define('WC_QD_QRY_OVERRIDE',true);
$order_ids = WC_QD()->db()->get_donation_order_ids();
$order_ids = WC_QD()->db()->extract_donation_id($order_ids);
if(empty($order_ids)) { $order_ids[] = 0;}
$args = array('posts_per_page' => '0',
'post_type' => 'shop_order',
'post_status' => array_keys(wc_get_order_statuses()),
......@@ -197,9 +197,9 @@ class WooCommerce_Quick_Donation_Admin {
$args['meta_query'][]['value'] = $_GET['dproj'];
$args['meta_query'][]['compare'] = '=';
}
if(isset($_GET['post_status'])){ $args['post_status'] = $_GET['post_status'];}
$wp_query = new WP_Query($args);
if(isset($_GET['post_status'])){ $args['post_status'] = $_GET['post_status'];}
$wp_query = new WP_Query($args);
tt_render_list_page($wp_query);
}
......
......@@ -12,6 +12,7 @@
$links = '';
foreach($pages as $pageid => $page){
$class = 'nav-tab ';
$url = menu_page_url($pageid, false );
if($active == $pageid){$class .= ' nav-tab-active'; }
......
......@@ -19,11 +19,24 @@ if(! WC_QD()->donation_product_exist_public()){
<td><?php _e('Reinstall Donation Product',WC_QD_TXT); ?> </td>
<td>
<p>
<button type="button" class="wcqdAjaxCall button clear_transients" href="<?php echo wp_nonce_url(admin_url('admin-ajax.php?action=CreateDonationProduct'),'CreateDonationProduct'); ?>"><?php _e('Create Donation Product',WC_QD_TXT); ?></button>
<button type="button" class="wcqdAjaxCall button clear_transients"
href="<?php echo wp_nonce_url(admin_url('admin-ajax.php?action=CreateDonationProduct'),'CreateDonationProduct'); ?>"><?php _e('Create Donation Product',WC_QD_TXT); ?></button>
<span class="description"><?php echo $product_exist; ?></span>
</p>
</td>
</tr>
<tr class="clear_transients">
<td><?php _e('Clear Donation Log',WC_QD_TXT); ?> </td>
<td>
<p>
<button type="button" class="ConfirmAction wcqdAjaxCall button"
data-alert-text="Are You Sure Want To Clear All Logs"
href="<?php echo wp_nonce_url(admin_url('admin-ajax.php?action=ClearDonationLog'),'ClearDonationLog'); ?>"><?php _e('Clear Log',WC_QD_TXT); ?></button>
<span class="description"><?php _e('Clear Logs From WC Donation Table. which resets user donation count & other logs'); ?></span>
</p>
</td>
</tr>
</tbody>
......
......@@ -116,121 +116,140 @@ class WC_Quick_Donation_Listing_Table extends WP_List_Table {
}
public function process_bulk_action() {
global $pagenow;
global $pagenow, $wpdb;
if(!isset($_REQUEST['_wpnonce'])){return;}
$nonce = esc_attr( $_REQUEST['_wpnonce'] );
if ( ! wp_verify_nonce( $nonce, 'bulk-donations') ) {
wp_die( __('Invalid Nonce for deleting WC Donation Orders', WC_QD_TXT));
}
//check_admin_referer('bulk-posts');
$pagenum = $this->get_pagenum();
$sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'locked', 'ids'), wp_get_referer() );
if ( ! $sendback )
$sendback = admin_url( $parent_file );
$sendback = add_query_arg( 'paged', $pagenum, $sendback );
if ( strpos($sendback, 'post.php') !== false )
$sendback = admin_url($post_new_file);
$post_ids = array_map('intval', $_REQUEST['post']);
$total_post = count($post_ids);
$ids = implode(', ',$post_ids);
$doaction = $this->current_action();
$Notice_Txt = '';
switch ( $doaction ) {
case 'trash':
$trashed = $locked = 0;
foreach( (array) $post_ids as $post_id ) {
if ( !current_user_can( 'delete_post', $post_id) )
wp_die( __('You are not allowed to move this item to the Trash.'));
if ( wp_check_post_lock( $post_id ) ) {
$locked++;
continue;
}
if ( !wp_trash_post($post_id) )
wp_die( __('Error in moving to Trash.') );
$trashed++;
$Notice_Txt = ' Trashed ';
}
$sendback = add_query_arg( array('trashed' => $trashed, 'ids' => join(',', $post_ids), 'locked' => $locked ), $sendback );
wc_qd_notice(
sprintf(
_n( '%s Donation Order Trashed ( %s )',
'%s Donation Orders Trashed ( %s )' , $total_post, $ids, WC_QD_TXT ),
$total_post,$ids
)
);
$doaction = $this->current_action();
if($doaction){
$pagenum = $this->get_pagenum();
$sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'locked', 'ids'), wp_get_referer() );
if ( ! $sendback )
$sendback = admin_url( $parent_file );
$sendback = add_query_arg( 'paged', $pagenum, $sendback );
if ( strpos($sendback, 'post.php') !== false )
$sendback = admin_url($post_new_file);
if(isset($_REQUEST['post'])){
$post_ids = array_map('intval', $_REQUEST['post']);
break;
case 'untrash':
$untrashed = 0;
foreach( (array) $post_ids as $post_id ) {
if ( !current_user_can( 'delete_post', $post_id) )
wp_die( __('You are not allowed to restore this item from the Trash.') );
if ( !wp_untrash_post($post_id) )
wp_die( __('Error in restoring from Trash.') );
$untrashed++;
}
$sendback = add_query_arg('untrashed', $untrashed, $sendback);
wc_qd_notice(
sprintf(
_n( '%s Donation Order restored from trash ( %s )',
'%s Donation Orders restored from trash ( %s )' , $total_post, $ids, WC_QD_TXT ),
$total_post,
$ids
)
);
break;
case 'delete':
$deleted = 0;
foreach( (array) $post_ids as $post_id ) {
$post_del = get_post($post_id);
if ( !current_user_can( 'delete_post', $post_id ) )
wp_die( __('You are not allowed to delete this item.') );
if ( $post_del->post_type == 'attachment' ) {
if ( ! wp_delete_attachment($post_id) )
wp_die( __('Error in deleting.') );
} else {
if ( !wp_delete_post($post_id) )
wp_die( __('Error in deleting.') );
}
$deleted++;
}
$sendback = add_query_arg('deleted', $deleted, $sendback);
wc_qd_notice(
sprintf(
_n( '%s Donation Order permanently deleted ( %s )',
'%s Donation Orders permanently deleted ( %s )' , $total_post, $ids, WC_QD_TXT ),
$total_post,
$ids
)
);
break;
case 'edit':
if ( isset($_REQUEST['bulk_edit']) ) {
$done = bulk_edit_posts($_REQUEST);
if ( is_array($done) ) {
$done['updated'] = count( $done['updated'] );
$done['skipped'] = count( $done['skipped'] );
$done['locked'] = count( $done['locked'] );
$sendback = add_query_arg( $done, $sendback );
}
}
break;
}
}
var_dump($this->screen);
if ( 'delete_all' == $doaction ) {
// Prepare for deletion of all posts with a specified post status (i.e. Empty trash).
$post_status = preg_replace('/[^a-z0-9_-]+/i', '', 'trash');
// Validate the post status exists.
if ( get_post_status_object( $post_status ) ) {
$post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type=%s AND post_status = %s", 'shop_order', $post_status ) );
}
$doaction = 'delete';
}
$total_post = count($post_ids);
$ids = implode(', ',$post_ids);
$Notice_Txt = '';
switch ( $doaction ) {
case 'trash':
$trashed = $locked = 0;
foreach( (array) $post_ids as $post_id ) {
if ( !current_user_can( 'delete_post', $post_id) )
wp_die( __('You are not allowed to move this item to the Trash.'));
if ( wp_check_post_lock( $post_id ) ) {
$locked++;
continue;
}
if ( !wp_trash_post($post_id) )
wp_die( __('Error in moving to Trash.') );
$trashed++;
$Notice_Txt = ' Trashed ';
}
$sendback = add_query_arg( array('trashed' => $trashed, 'ids' => join(',', $post_ids), 'locked' => $locked ), $sendback );
wc_qd_notice(
sprintf(
_n( '%s Donation Order Trashed ( %s )',
'%s Donation Orders Trashed ( %s )' , $total_post, $ids, WC_QD_TXT ),
$total_post,$ids
)
);
break;
case 'untrash':
$untrashed = 0;
foreach( (array) $post_ids as $post_id ) {
if ( !current_user_can( 'delete_post', $post_id) )
wp_die( __('You are not allowed to restore this item from the Trash.') );
if ( !wp_untrash_post($post_id) )
wp_die( __('Error in restoring from Trash.') );
$untrashed++;
}
$sendback = add_query_arg('untrashed', $untrashed, $sendback);
wc_qd_notice(
sprintf(
_n( '%s Donation Order restored from trash ( %s )',
'%s Donation Orders restored from trash ( %s )' , $total_post, $ids, WC_QD_TXT ),
$total_post,
$ids
)
);
break;
case 'delete':
$deleted = 0;
foreach( (array) $post_ids as $post_id ) {
$post_del = get_post($post_id);
if ( !current_user_can( 'delete_post', $post_id ) )
wp_die( __('You are not allowed to delete this item.') );
if ( $post_del->post_type == 'attachment' ) {
if ( ! wp_delete_attachment($post_id) )
wp_die( __('Error in deleting.') );
} else {
if ( !wp_delete_post($post_id) )
wp_die( __('Error in deleting.') );
}
$deleted++;
}
$sendback = add_query_arg('deleted', $deleted, $sendback);
wc_qd_notice(
sprintf(
_n( '%s Donation Order permanently deleted ( %s )',
'%s Donation Orders permanently deleted ( %s )' , $total_post, $ids, WC_QD_TXT ),
$total_post,
$ids
)
);
break;
case 'edit':
if ( isset($_REQUEST['bulk_edit']) ) {
$done = bulk_edit_posts($_REQUEST);
if ( is_array($done) ) {
$done['updated'] = count( $done['updated'] );
$done['skipped'] = count( $done['skipped'] );
$done['locked'] = count( $done['locked'] );
$sendback = add_query_arg( $done, $sendback );
}
}
break;
}
}
$sendback = remove_query_arg( array('action', 'action2', 'tags_input', 'post_author', 'comment_status', 'ping_status', '_status', 'post', 'bulk_edit', 'post_view'), $sendback );
wp_redirect($sendback);
......@@ -334,8 +353,7 @@ class WC_Quick_Donation_Listing_Table extends WP_List_Table {
foreach ( $results as $row ) {$counts[ $row['post_status'] ] = $row['num_posts'];}
$counts = (object) $counts;
wp_cache_set( $cache_key.'_donation', $counts, 'counts' );
wp_cache_set( $cache_key.'_donation', $counts, 'counts' );
return $counts;
}
/**
......
......@@ -105,7 +105,13 @@ class WooCommerce_Quick_Donation_DB {
$db_request = $wpdb->delete( WC_QD_TB, array('donationid' => $id));
return $db_request;
}
public function delete_donation_logs(){
global $wpdb;
$db_request = $wpdb->query("DELETE FROM ".WC_QD_TB);
return $db_request;
}
public function extract_donation_id($ids){
$return_ids = array();
......
......@@ -6,6 +6,13 @@ jQuery(document).ready(function(){
if(jQuery(this).hasClass('wcqdAutoRemove')){
autoRemove = true;
}
if(jQuery(this).hasClass('ConfirmAction')){
var r = confirm(jQuery(this).attr('data-alert-text'));
if (r != true) { return ; }
}
var Spinner = jQuery('<span class="spinner WCQDSpinner"></span>');
var Clicked = jQuery(this);
var POST_URL = jQuery(this).attr('href');
......
......@@ -5,8 +5,8 @@ Tags: WooCommerce,Quick Dontion,quick donation,online donation,wordpress donatio
Requires at least: 3.0 or higher
Tested up to: 4.4
WC requires at least: 1.0
WC tested up to: 2.4.8
Stable tag: 1.3.7 Beta
WC tested up to: 2.4.10
Stable tag: 1.3.7.1 Beta
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
......@@ -120,6 +120,12 @@ Yes you can! Join in on our <a href="https://github.com/technofreaky/woocomerce-
== Changelog ==
= 1.3.7.1 =
* **Fixed** - Fixed Empty Trash Issue
* **Fixed** - [`T_PAAMAYIM_NEKUDOTAYIM` Critical: Update to latest kills admin area] (https://github.com/technofreaky/woocomerce-quick-donation/issues/58) After Last UPDATE [1.3.7]
* **Added** - Option To Clear Donation Log In system tools menu
= 1.3.7 =
* **Added** - French translation
......
......@@ -4,7 +4,7 @@
*
* @author Varun Sridharan
* @package WooCommerce Quick Donation/Templates/fields
* @version 0.2
* @version 0.3
*/
?>
......@@ -22,7 +22,7 @@ foreach($project_list as $id => $val){
}
$field_output .= ' </optgroup>';
} else {
if($pre_selected == $k){$attr = 'selected';}
if($pre_selected == $id){$attr = 'selected';}
$field_output .= '<option value="'.$id.'" '.$attr.'>'.$val.'</option>';
}
......
......@@ -3,7 +3,7 @@
* Plugin Name: WooCommerce Quick Donation
* Plugin URI: http://wordpress.org/plugins/woocommerce-quick-donation/
* Description: Turns WooCommerce Into Online Donation
* Version: 1.3.7 BETA
* Version: 1.3.7.1 BETA
* Author: Varun Sridharan
* Author URI: http://varunsridharan.in
* Text Domain: woocommerce-quick-donation
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment