/**
  * Checks If Donation Product Exist In WooCommerce Products
  */
 private function check_donation_product_exist($notice = true)
 {
     $install = new WC_QD_INSTALL();
     if (!$install->check_donation_exists()) {
         self::$is_donation_product_exist = false;
         if ($notice) {
             wc_qd_notice(__('WooCommerce Donation Product Not Exist', WC_QD_TXT), 'error', true);
         }
     }
 }
 public function process_bulk_action()
 {
     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));
     }
     $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']);
         }
         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);
     exit;
 }
 public function get_admin_pay_gate()
 {
     $gateway = $this->get_payment_gateways();
     if (!empty($gateway)) {
         return $gateway;
     } else {
         wc_qd_notice(__('No Payment Gateway Configured In WooCommerce. Kindly Configure One', WC_QD_TXT), 'error');
     }
     return array();
 }
 public function add_notice()
 {
     wc_qd_notice(sprintf('<p>%s</p> <p class="submit"><a id="WCQDShowTXT" class="button-primary debug-report" href="javascript:;">%s</a></p>', __('Please copy and paste this information in your ticket when contacting support:', WC_QD_TXT), __('Get System Report', WC_QD_TXT)), 'update', array('wraper' => false));
 }
 /**
  * Checks For Template Version 
  */
 public static function check_template_files()
 {
     $template_files = self::get_template_list();
     $outdated = false;
     if (is_array($template_files)) {
         foreach ($template_files as $file) {
             $theme_file = false;
             if (file_exists(get_stylesheet_directory() . '/' . $file)) {
                 $theme_file = get_stylesheet_directory() . '/' . $file;
             } elseif (file_exists(get_stylesheet_directory() . WC_QD_THEME_TEMPLATE . $file)) {
                 $theme_file = get_stylesheet_directory() . WC_QD_THEME_TEMPLATE . $file;
             } elseif (file_exists(get_template_directory() . '/' . $file)) {
                 $theme_file = get_template_directory() . '/' . $file;
             } elseif (file_exists(get_template_directory() . WC_QD_THEME_TEMPLATE . $file)) {
                 $theme_file = get_template_directory() . WC_QD_THEME_TEMPLATE . $file;
             }
             if ($theme_file !== false) {
                 $core_version = WC_Admin_Status::get_file_version(WC_QD_TEMPLATE . $file);
                 $theme_version = WC_Admin_Status::get_file_version($theme_file);
                 if ($core_version && $theme_version && version_compare($theme_version, $core_version, '<')) {
                     $outdated = true;
                     break;
                 }
             }
         }
         if ($outdated) {
             $theme = wp_get_theme();
             $message = sprintf(__('<p> <strong>Your theme (%s) contains outdated copies of some WooCommerce Quick Donation template files.</strong> These files may need updating to ensure they are compatible with the current version of WooCommerce Quick Donation. You can see which files are affected from the %ssystem status page%s. If in doubt, check with the author of the theme. </p> <p class="submit">%sLear More About Templates%s %s</p>', WC_QD_TXT), esc_html($theme['Name']), '<a href="' . admin_url('admin.php?page=wc-status') . '">', '</a>', '<a  target="_blank" href="" class="button-primary" href="">', '</a>', wc_qd_remove_link('class="button" '));
             wc_qd_notice($message, 'error', array('times' => 0, 'wraper' => false));
         }
     }
 }