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 { ...@@ -22,7 +22,10 @@ class WooCommerce_Quick_Donation_Admin_Function {
add_action( 'parse_query', array( $this, 'hide_donation_order_woocommerce_order' ) ); 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_filter( 'wc_order_types',array($this,'add_wc_order_types'),1,2);
add_action( 'delete_post', array($this,'delete_donation')); add_action( 'delete_post', array($this,'delete_donation'));
add_action( 'wp_ajax_CreateDonationProduct', array($this,'create_donation_product') ); 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 { ...@@ -123,7 +126,7 @@ class WooCommerce_Quick_Donation_Admin_Function {
public function create_donation_product(){ public function create_donation_product(){
if(! isset($_REQUEST['_wpnonce'])) { 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; exit;
} }
...@@ -134,14 +137,14 @@ class WooCommerce_Quick_Donation_Admin_Function { ...@@ -134,14 +137,14 @@ class WooCommerce_Quick_Donation_Admin_Function {
$donation_exist = $install::check_donation_exists(); $donation_exist = $install::check_donation_exists();
if(isset($_REQUEST['force'])){ if(isset($_REQUEST['force'])){
$post_id = $install::$callBack_function(); $post_id = $install->$callBack_function();
update_option(WC_QD_DB.'product_id',$post_id); update_option(WC_QD_DB.'product_id',$post_id);
echo '<span class="wcqdsuccess">'.__('Donation Product Created',WC_QD_TXT).'</span>'; echo '<span class="wcqdsuccess">'.__('Donation Product Created',WC_QD_TXT).'</span>';
exit; exit;
} }
if(! $donation_exist){ if(! $donation_exist){
$post_id = $install::$callBack_function(); $post_id = $install->$callBack_function();
update_option(WC_QD_DB.'product_id',$post_id); update_option(WC_QD_DB.'product_id',$post_id);
echo '<span class="wcqdsuccess">'.__('Donation Product Created',WC_QD_TXT).'</span>'; echo '<span class="wcqdsuccess">'.__('Donation Product Created',WC_QD_TXT).'</span>';
} else { } else {
...@@ -154,4 +157,18 @@ class WooCommerce_Quick_Donation_Admin_Function { ...@@ -154,4 +157,18 @@ class WooCommerce_Quick_Donation_Admin_Function {
exit; 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 { ...@@ -177,7 +177,7 @@ class WooCommerce_Quick_Donation_Admin {
define('WC_QD_QRY_OVERRIDE',true); define('WC_QD_QRY_OVERRIDE',true);
$order_ids = WC_QD()->db()->get_donation_order_ids(); $order_ids = WC_QD()->db()->get_donation_order_ids();
$order_ids = WC_QD()->db()->extract_donation_id($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', $args = array('posts_per_page' => '0',
'post_type' => 'shop_order', 'post_type' => 'shop_order',
'post_status' => array_keys(wc_get_order_statuses()), 'post_status' => array_keys(wc_get_order_statuses()),
...@@ -198,8 +198,8 @@ class WooCommerce_Quick_Donation_Admin { ...@@ -198,8 +198,8 @@ class WooCommerce_Quick_Donation_Admin {
$args['meta_query'][]['compare'] = '='; $args['meta_query'][]['compare'] = '=';
} }
if(isset($_GET['post_status'])){ $args['post_status'] = $_GET['post_status'];} if(isset($_GET['post_status'])){ $args['post_status'] = $_GET['post_status'];}
$wp_query = new WP_Query($args);
$wp_query = new WP_Query($args);
tt_render_list_page($wp_query); tt_render_list_page($wp_query);
} }
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
$links = ''; $links = '';
foreach($pages as $pageid => $page){ foreach($pages as $pageid => $page){
$class = 'nav-tab '; $class = 'nav-tab ';
$url = menu_page_url($pageid, false ); $url = menu_page_url($pageid, false );
if($active == $pageid){$class .= ' nav-tab-active'; } if($active == $pageid){$class .= ' nav-tab-active'; }
......
...@@ -19,12 +19,25 @@ if(! WC_QD()->donation_product_exist_public()){ ...@@ -19,12 +19,25 @@ if(! WC_QD()->donation_product_exist_public()){
<td><?php _e('Reinstall Donation Product',WC_QD_TXT); ?> </td> <td><?php _e('Reinstall Donation Product',WC_QD_TXT); ?> </td>
<td> <td>
<p> <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> <span class="description"><?php echo $product_exist; ?></span>
</p> </p>
</td> </td>
</tr> </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> </tbody>
</table> </table>
......
...@@ -116,14 +116,15 @@ class WC_Quick_Donation_Listing_Table extends WP_List_Table { ...@@ -116,14 +116,15 @@ class WC_Quick_Donation_Listing_Table extends WP_List_Table {
} }
public function process_bulk_action() { public function process_bulk_action() {
global $pagenow; global $pagenow, $wpdb;
if(!isset($_REQUEST['_wpnonce'])){return;} if(!isset($_REQUEST['_wpnonce'])){return;}
$nonce = esc_attr( $_REQUEST['_wpnonce'] ); $nonce = esc_attr( $_REQUEST['_wpnonce'] );
if ( ! wp_verify_nonce( $nonce, 'bulk-donations') ) { if ( ! wp_verify_nonce( $nonce, 'bulk-donations') ) {
wp_die( __('Invalid Nonce for deleting WC Donation Orders', WC_QD_TXT)); wp_die( __('Invalid Nonce for deleting WC Donation Orders', WC_QD_TXT));
} }
//check_admin_referer('bulk-posts'); $doaction = $this->current_action();
if($doaction){
$pagenum = $this->get_pagenum(); $pagenum = $this->get_pagenum();
$sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'locked', 'ids'), wp_get_referer() ); $sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'locked', 'ids'), wp_get_referer() );
if ( ! $sendback ) if ( ! $sendback )
...@@ -132,10 +133,25 @@ class WC_Quick_Donation_Listing_Table extends WP_List_Table { ...@@ -132,10 +133,25 @@ class WC_Quick_Donation_Listing_Table extends WP_List_Table {
if ( strpos($sendback, 'post.php') !== false ) if ( strpos($sendback, 'post.php') !== false )
$sendback = admin_url($post_new_file); $sendback = admin_url($post_new_file);
if(isset($_REQUEST['post'])){
$post_ids = array_map('intval', $_REQUEST['post']); $post_ids = array_map('intval', $_REQUEST['post']);
}
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); $total_post = count($post_ids);
$ids = implode(', ',$post_ids); $ids = implode(', ',$post_ids);
$doaction = $this->current_action();
$Notice_Txt = ''; $Notice_Txt = '';
switch ( $doaction ) { switch ( $doaction ) {
case 'trash': case 'trash':
...@@ -232,6 +248,9 @@ class WC_Quick_Donation_Listing_Table extends WP_List_Table { ...@@ -232,6 +248,9 @@ class WC_Quick_Donation_Listing_Table extends WP_List_Table {
break; break;
} }
}
$sendback = remove_query_arg( array('action', 'action2', 'tags_input', 'post_author', 'comment_status', 'ping_status', '_status', 'post', 'bulk_edit', 'post_view'), $sendback ); $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); wp_redirect($sendback);
exit(); exit();
...@@ -335,7 +354,6 @@ class WC_Quick_Donation_Listing_Table extends WP_List_Table { ...@@ -335,7 +354,6 @@ class WC_Quick_Donation_Listing_Table extends WP_List_Table {
$counts = (object) $counts; $counts = (object) $counts;
wp_cache_set( $cache_key.'_donation', $counts, 'counts' ); wp_cache_set( $cache_key.'_donation', $counts, 'counts' );
return $counts; return $counts;
} }
/** /**
......
...@@ -107,6 +107,12 @@ class WooCommerce_Quick_Donation_DB { ...@@ -107,6 +107,12 @@ class WooCommerce_Quick_Donation_DB {
} }
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){ public function extract_donation_id($ids){
$return_ids = array(); $return_ids = array();
foreach($ids as $i){ foreach($ids as $i){
......
...@@ -6,6 +6,13 @@ jQuery(document).ready(function(){ ...@@ -6,6 +6,13 @@ jQuery(document).ready(function(){
if(jQuery(this).hasClass('wcqdAutoRemove')){ if(jQuery(this).hasClass('wcqdAutoRemove')){
autoRemove = true; 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 Spinner = jQuery('<span class="spinner WCQDSpinner"></span>');
var Clicked = jQuery(this); var Clicked = jQuery(this);
var POST_URL = jQuery(this).attr('href'); var POST_URL = jQuery(this).attr('href');
......
...@@ -5,8 +5,8 @@ Tags: WooCommerce,Quick Dontion,quick donation,online donation,wordpress donatio ...@@ -5,8 +5,8 @@ Tags: WooCommerce,Quick Dontion,quick donation,online donation,wordpress donatio
Requires at least: 3.0 or higher Requires at least: 3.0 or higher
Tested up to: 4.4 Tested up to: 4.4
WC requires at least: 1.0 WC requires at least: 1.0
WC tested up to: 2.4.8 WC tested up to: 2.4.10
Stable tag: 1.3.7 Beta Stable tag: 1.3.7.1 Beta
License: GPLv2 or later License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html 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- ...@@ -120,6 +120,12 @@ Yes you can! Join in on our <a href="https://github.com/technofreaky/woocomerce-
== Changelog == == 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 = = 1.3.7 =
* **Added** - French translation * **Added** - French translation
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* *
* @author Varun Sridharan * @author Varun Sridharan
* @package WooCommerce Quick Donation/Templates/fields * @package WooCommerce Quick Donation/Templates/fields
* @version 0.2 * @version 0.3
*/ */
?> ?>
...@@ -22,7 +22,7 @@ foreach($project_list as $id => $val){ ...@@ -22,7 +22,7 @@ foreach($project_list as $id => $val){
} }
$field_output .= ' </optgroup>'; $field_output .= ' </optgroup>';
} else { } else {
if($pre_selected == $k){$attr = 'selected';} if($pre_selected == $id){$attr = 'selected';}
$field_output .= '<option value="'.$id.'" '.$attr.'>'.$val.'</option>'; $field_output .= '<option value="'.$id.'" '.$attr.'>'.$val.'</option>';
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* Plugin Name: WooCommerce Quick Donation * Plugin Name: WooCommerce Quick Donation
* Plugin URI: http://wordpress.org/plugins/woocommerce-quick-donation/ * Plugin URI: http://wordpress.org/plugins/woocommerce-quick-donation/
* Description: Turns WooCommerce Into Online Donation * Description: Turns WooCommerce Into Online Donation
* Version: 1.3.7 BETA * Version: 1.3.7.1 BETA
* Author: Varun Sridharan * Author: Varun Sridharan
* Author URI: http://varunsridharan.in * Author URI: http://varunsridharan.in
* Text Domain: woocommerce-quick-donation * 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