public function __construct() { $order_ids = WC_QD()->db()->get_user_donations_ids(); $this->order_ids = WC_QD()->db()->extract_donation_id($order_ids); add_filter('woocommerce_my_account_my_orders_query', array($this, 'change_myaccount_query')); add_action('woocommerce_before_my_account', array($this, 'show_recent_donations')); }
public function check_order($order_id) { if (!WC_QD()->db()->_is_donation($order_id)) { return; } $this->remove_emails = true; }
public function get_message($id, $search_replace = array()) { if ($id == null) { return false; } $text = WC_QD()->settings()->get_option($id); $replaced_text = str_replace(array_keys($search_replace), array_values($search_replace), $text); return $replaced_text; }
/** * Trigger. */ function trigger($order_id) { if ($order_id) { $this->object = wc_get_order($order_id); $this->find['order-date'] = '{order_date}'; $this->find['order-number'] = '{order_number}'; $this->find['donation-project-name'] = '{project_name}'; $order_id = $this->object->get_order_number(); $project_id = WC_QD()->db()->get_project_id($order_id); $project_name = get_the_title($project_id); $this->replace['order-date'] = date_i18n(wc_date_format(), strtotime($this->object->order_date)); $this->replace['order-number'] = $this->object->get_order_number(); $this->replace['donation-project-name'] = $project_name; } if (!$this->is_enabled() || !$this->get_recipient()) { return; } $this->send($this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments()); }
public function wc_quick_donation_single_handler($settings) { $settings = shortcode_atts(array('title' => 'true', 'content' => 'true', 'defined_amount' => false, 'id' => false), $settings); $title = ''; $content = ''; $project = get_post($settings['id']); setup_postdata($project); $donation_price = WC_QD()->f()->generate_price_box($settings['defined_amount']); $donation_price .= WC_QD()->f()->generate_donation_selbox(false, 'hidden', $settings['id']); if ($settings['title'] == 'true') { $title = get_the_title($settings['id']); } if ($settings['content'] == 'true') { $content = get_the_excerpt(); } $currency = get_woocommerce_currency_symbol(); $return_value = ''; $messages = ''; $return_value .= WC_QD()->f()->load_template('single-donation-form.php', WC_QD_TEMPLATE, array('project_id' => $settings['id'], 'project' => $project, 'donation_price' => $donation_price, 'currency' => $currency, 'title' => $title, 'content' => $content)); return $return_value; }
/** * Register the JavaScript for the admin area. */ public function enqueue_scripts() { if (in_array($this->current_screen(), $this->get_screen_ids())) { wp_enqueue_script(WC_QD_SLUG . '_core_script', WC_QD_JS . 'admin-script.js', array('jquery'), WC_QD()->version, false); } if ($this->tools == $this->current_screen()) { wp_enqueue_script(WC_QD_SLUG . '_tools_Page_script', WC_QD_JS . 'tools-page.js', array('jquery'), WC_QD()->version, false); } if ($this->sys_info == $this->current_screen()) { wp_register_script(WC_QD_SLUG . '_sysinfo_script', WC_QD_JS . 'sysinfo.js', array('jquery'), WC_QD()->version, false); wp_localize_script(WC_QD_SLUG . '_sysinfo_script', 'systemInfoAjax', array('ajaxurl' => admin_url('admin-ajax.php'))); wp_enqueue_script(WC_QD_SLUG . '_sysinfo_script'); } }
* string $type ajax, frontend or admin * @return bool */ public function is_request($type) { switch ($type) { case 'admin': return is_admin(); case 'ajax': return defined('DOING_AJAX'); case 'cron': return defined('DOING_CRON'); case 'frontend': return (!is_admin() || defined('DOING_AJAX')) && !defined('DOING_CRON'); } } } require_once plugin_dir_path(__FILE__) . 'includes/class-wc-dependencies.php'; require_once plugin_dir_path(__FILE__) . 'includes/class-admin-notice.php'; if (WC_QD_Dependencies()) { function WC_QD() { return WooCommerce_Quick_Donation::get_instance(); } $GLOBALS['woocommerce_quick_donation'] = WC_QD(); include WC_QD_INC . 'class-activate-welcome.php'; $default_args = array('dbslug' => WC_QD_DB, 'welcome_slug' => WC_QD_TXT . '-welcome-page', 'wp_plugin_slug' => WC_QD_TXT, 'wp_plugin_url' => 'http://wordpress.org/plugins/woocommerce-quick-donation/', 'tweet_text' => 'Turns WooCommerce Into Online Donation', 'twitter_user' => 'varunsridharan2', 'twitter_hash' => 'WCQD', 'gitub_user' => 'technofreaky', 'github_repo' => 'woocomerce-quick-donation', 'plugin_name' => WC_QD, 'version' => WC_QD_V, 'template' => WC_QD_INC . 'views/welcome-page.php', 'menu_name' => WC_QD . ' Welcome Page', 'plugin_file' => __FILE__); new wp_wc_wcqd_welcome_page($default_args); } else { wc_qd_notice(__('WooCommerce Is Required. To Use This Plugin :)', 'woocommerce-quick-donation'), 'error', array('times' => 1)); }
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; }
* @author Varun Sridharan * @package WooCommerce Quick Donation/Templates/order * @version 0.1 */ if (!defined('ABSPATH')) { exit; } ?> <tr class="<?php echo esc_attr(apply_filters('woocommerce_order_item_class', 'order_item', $item, $order)); ?> "> <td class="product-name"> <?php $is_visible = $product && $product->is_visible(); $project_id = WC_QD()->db()->get_project_id($order->id); echo sprintf('<a href="%s">%s</a>', get_permalink($project_id), get_the_title($project_id)); ?> </td> <td class="product-total"> <?php echo $order->get_formatted_line_subtotal($item); ?> </td> </tr> <?php if ($order->has_status(array('completed', 'processing')) && ($purchase_note = get_post_meta($product->id, '_purchase_note', true))) { ?> <tr class="product-purchase-note"> <td colspan="3"><?php echo wpautop(do_shortcode(wp_kses_post($purchase_note)));
<table class="wc-order-totals"> <tr> <td class="label"><strong> <?php _e('Project Name', WC_QD_TXT); ?> : </strong></td> <td class="total"> <div class="view"><?php $project_ID = WC_QD()->db()->get_project_id($post->ID); $title = get_the_title($project_ID); $link = get_permalink($project_ID); printf('<a href="%s"> %s </a> ', $link, $title); ?> </div> </td> </tr> <?php if (wc_tax_enabled()) { ?> <?php foreach ($order->get_tax_totals() as $code => $tax) { ?> <tr> <td class="label"><?php echo $tax->label; ?> :</td> <td class="total"><?php
function wcqd_get_donate_link($donation_id = '364', $amount = 10, $echo = false) { $link = WC_QD()->f()->get_donate_link($donation_id, $amount, false); if ($echo) { echo $link; return; } return $link; }
<?php global $options; $options[] = array('name' => __('General', WC_QD_TXT), 'type' => 'heading'); $options[] = array('name' => __('Redirect User To', WC_QD_TXT), 'desc' => __('After Donation Added To Cart', WC_QD_TXT), 'id' => WC_QD_DB . 'redirect_user', 'tip' => 'Select Payment gateway for users to pay for donation', 'css' => 'width:75%;', 'type' => 'select', 'select2' => true, 'options' => array('cart' => 'Cart Page', 'checkout' => 'Checkout Page')); $options[] = array('name' => __('Donation Payment Gateway', WC_QD_TXT), 'desc' => __('Custom Message To Show When Empty Donation Entered', WC_QD_TXT), 'id' => WC_QD_DB . 'payment_gateway', 'tip' => 'Select Payment gateway for users to pay for donation', 'css' => 'width:75%;', 'type' => 'select', 'multiple' => true, 'select2' => true, 'options' => WC_QD()->f()->get_admin_pay_gate());
<?php global $options; $options = array(); WC_QD()->load_files(WC_QD_ADMIN . 'settings/settings-*.php');
public function get_template($located, $template_name, $args, $template_path, $default_path) { $file = ''; $order_id = 0; $found = false; if (isset($args['order_id'])) { $order_id = $args['order_id']; } if (isset($args['order']->id)) { $order_id = $args['order']->id; } if (isset(self::$search_template['general'][$template_name])) { $file = WC_QD()->f()->locate_template(self::$search_template['general'][$template_name]); $found = true; } if (WC_QD()->check_donation_exists_cart()) { if (isset(self::$search_template['is_donation'][$template_name])) { $file = WC_QD()->f()->locate_template(self::$search_template['is_donation'][$template_name]); $found = true; } } if (WC_QD()->db()->_is_donation($order_id)) { if (isset(self::$search_template['after_order'][$template_name])) { $file = WC_QD()->f()->locate_template(self::$search_template['after_order'][$template_name]); $found = true; } } if ($found) { return $file; } /*else { $file = wc_locate_template($template_name); return $file; }*/ return $located; }
<?php $product_exist = __(' This will help you to create a new donation product. if not exist', WC_QD_TXT); if (!WC_QD()->donation_product_exist_public()) { $product_exist = sprintf(' <span class="wc_qd_error" >%s</span>', __('Donation Product Dose Not Exist In WooCommerce. Please Create It ', WC_QD_TXT)); } ?> <form action="" method="post"> <input type="hidden" value="wc_qd_wp_tools" name="action"> <?php wp_nonce_field('wc_qd_wp_tools'); ?> <table cellspacing="0" class="wc_status_table widefat wc_qd_system_toold"> <thead class="tools"> <tr> <th colspan="2"><?php _e('System Tools', WC_QD_TXT); ?> </th> </tr> </thead> <tbody class="tools"> <tr class="clear_transients"> <td><?php _e('Reinstall Donation Product', WC_QD_TXT); ?> </td> <td> <p> <button type="button" class="wcqdAjaxCall button clear_transients"
<?php global $fields; /** General Settings **/ $fields['settings_general']['general'][] = array('id' => WC_QD_DB . 'redirect_user', 'type' => 'select', 'label' => __('Redirect User To', WC_QD_TXT), 'desc' => __('After Donation Added To Cart', WC_QD_TXT), 'size ' => 'small', 'options' => array('cart' => __('Cart Page', WC_QD_TXT), 'checkout' => __('Checkout Page', WC_QD_TXT)), 'attr' => array('class' => 'wc-enhanced-select', 'style' => 'width:auto;max-width:35%;')); /** General Settings **/ $fields['settings_general']['general'][] = array('id' => WC_QD_DB . 'already_exist_redirect_user', 'type' => 'select', 'label' => __('Donation Exist Redirect', WC_QD_TXT), 'desc' => __('Redirect User When Donation Already Exist In Cart', WC_QD_TXT), 'size ' => 'small', 'options' => array('cart' => __('Cart Page', WC_QD_TXT), 'checkout' => __('Checkout Page', WC_QD_TXT)), 'attr' => array('class' => 'wc-enhanced-select', 'style' => 'width:auto;max-width:35%;')); $fields['settings_general']['general'][] = array('label' => __('Donation Payment Gateway', WC_QD_TXT), 'desc' => __('Select Payment gateway for users to pay for donation', WC_QD_TXT), 'id' => WC_QD_DB . 'payment_gateway', 'type' => 'select', 'attr' => array('class' => 'wc-enhanced-select', 'style' => 'width:auto;max-width:35%;', 'multiple' => 'multiple'), 'multiple' => true, 'options' => WC_QD()->f()->get_admin_pay_gate()); /** Message Settings **/ $fields['settings_message']['message'][] = array('desc' => sprintf(__('<span> Add <code>%s</code> To Get Ented Amount By User.</span> <br/> <span> Add <code>%s</code> To Get Minimum Required Amount From Selected Project </span> <br/> <span> Add <code>%s</code> To Get Minimum Required Amount From Selected Project </span>', WC_QD_TXT), '{donation_amount}', '{min_amount}', '{max_amount}'), 'id' => WC_QD_DB . 'empty_donation_msg_1', 'attr' => array('style' => 'min-width:50%; width:auto;max-width:75%;'), 'type' => 'content'); $fields['settings_message']['message'][] = array('label' => __('Donation Conflict', WC_QD_TXT), 'desc' => __('Custom Message To Show When User Trying To Add Donation With Other Products', WC_QD_TXT), 'id' => WC_QD_DB . 'donation_with_other_products', 'attr' => array('style' => 'min-width:50%; width:auto;max-width:75%;'), 'type' => 'textarea'); $fields['settings_message']['message'][] = array('label' => __('Empty Donation Amount', WC_QD_TXT), 'desc' => __('Custom Message To Show When Empty Donation Entered', WC_QD_TXT), 'id' => WC_QD_DB . 'empty_donation_msg', 'attr' => array('style' => 'min-width:50%; width:auto;max-width:75%;'), 'type' => 'textarea'); $fields['settings_message']['message'][] = array('label' => __('Donation Already Exist', WC_QD_TXT), 'desc' => __('Custom Message To Show When User Trying To Add Another Donation To Cart', WC_QD_TXT), 'id' => WC_QD_DB . 'donation_already_exist', 'attr' => array('style' => 'min-width:50%; width:auto;max-width:75%;'), 'type' => 'textarea'); $fields['settings_message']['message'][] = array('label' => __('Invalid Donation Amount', WC_QD_TXT), 'desc' => __('Custom Message To Show When Invalid Donation Entered', WC_QD_TXT), 'id' => WC_QD_DB . 'invalid_donation_msg', 'attr' => array('style' => 'min-width:50%; width:auto;max-width:75%;'), 'type' => 'textarea'); $fields['settings_message']['message'][] = array('label' => __('Minimum Required Donation Amount', WC_QD_TXT), 'desc' => __('Custom Message To Show When Minimum Required Donation Not Entered', WC_QD_TXT), 'id' => WC_QD_DB . 'min_rda_msg', 'attr' => array('style' => 'min-width:50%; width:auto;max-width:75%;'), 'type' => 'textarea'); $fields['settings_message']['message'][] = array('label' => __('Maximum Required Donation Amount', WC_QD_TXT), 'desc' => __('Custom Message To Show When Maximum Required Donation Not Entered ', WC_QD_TXT), 'id' => WC_QD_DB . 'max_rda_msg', 'attr' => array('style' => 'min-width:50%; width:auto;max-width:75%;'), 'type' => 'textarea'); /** Shortcode Settings **/ $fields['settings_shortcode']['shortcode'][] = array('id' => WC_QD_DB . 'default_render_type', 'type' => 'select', 'label' => __('Pre Selected Project Name', WC_QD_TXT), 'desc' => __('default project render type', WC_QD_TXT), 'size ' => 'small', 'options' => array('select' => __('Select Box', WC_QD_TXT), 'radio' => __('Radio Button', WC_QD_TXT)), 'attr' => array('class' => 'wc-enhanced-select', 'style' => 'width:auto;max-width:35%;')); $fields['settings_shortcode']['shortcode'][] = array('id' => WC_QD_DB . 'shortcode_show_errors', 'type' => 'select', 'label' => __('Show Errors', WC_QD_TXT), 'desc' => __('Set to hide errors when <code> wc_print_notice</code> called before loading dontion form', WC_QD_TXT), 'size ' => 'small', 'options' => array('true' => __('Show Errors', WC_QD_TXT), 'false' => __('Hide Errors', WC_QD_TXT)), 'attr' => array('class' => 'wc-enhanced-select', 'style' => 'width:auto;max-width:35%;')); $fields['settings_shortcode']['shortcode'][] = array('id' => WC_QD_DB . 'pre_selected_project', 'type' => 'select', 'label' => __('Pre Selected Project Name', WC_QD_TXT), 'desc' => __('this value will be selected in donation project box', WC_QD_TXT), 'size ' => 'small', 'options' => WC_QD()->f()->get_porject_list(), 'attr' => array('class' => 'wc-enhanced-select', 'style' => 'width:auto;max-width:35%;')); $fields['settings_shortcode']['shortcode'][] = array('id' => WC_QD_DB . 'pre_defined_amount', 'type' => 'textarea', 'label' => __('Pre Defined Project Amount', WC_QD_TXT), 'desc' => __('Enter Donation Amount Like <code> 10|20|30|40 </code>', WC_QD_TXT), 'size ' => 'small', 'attr' => array('style' => 'min-width:35%; width:auto;max-width:75%;'));
/** * Generate HTML for a single row on the users.php admin panel. * * @since 3.1.0 * @since 4.2.0 The `$style` argument was deprecated. * @access public * * @param object $user_object The current user object. * @param string $style Deprecated. Not used. * @param string $role Optional. Key for the $wp_roles array. Default empty. * @param int $numposts Optional. Post count to display for this user. Defaults * to zero, as in, a new user has made zero posts. * @return string Output for a single row. */ public function single_row($user_object, $style = '', $role = '', $numposts = 0) { $wp_roles = wp_roles(); if (!$user_object instanceof WP_User) { $user_object = get_userdata((int) $user_object); } $user_object->filter = 'display'; $email = $user_object->user_email; if ($this->is_site_users) { $url = "site-users.php?id={$this->site_id}&"; } else { $url = 'users.php?'; } $checkbox = ''; // Check if the user for this row is editable if (current_user_can('list_users')) { // Set up the user editing link $edit_link = esc_url(add_query_arg('wp_http_referer', urlencode(wp_unslash($_SERVER['REQUEST_URI'])), get_edit_user_link($user_object->ID))); // Set up the hover actions for this user $actions = array(); if (current_user_can('edit_user', $user_object->ID)) { $edit = "<strong><a href=\"{$edit_link}\">{$user_object->user_login}</a></strong>"; $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>'; } else { $edit = "<strong>{$user_object->user_login}</strong>"; } if (!is_multisite() && get_current_user_id() != $user_object->ID && current_user_can('delete_user', $user_object->ID)) { $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("users.php?action=delete&user={$user_object->ID}", 'bulk-users') . "'>" . __('Delete') . "</a>"; } if (is_multisite() && get_current_user_id() != $user_object->ID && current_user_can('remove_user', $user_object->ID)) { $actions['remove'] = "<a class='submitdelete' href='" . wp_nonce_url($url . "action=remove&user={$user_object->ID}", 'bulk-users') . "'>" . __('Remove') . "</a>"; } /** * Filter the action links displayed under each user in the Users list table. * * @since 2.8.0 * * @param array $actions An array of action links to be displayed. * Default 'Edit', 'Delete' for single site, and * 'Edit', 'Remove' for Multisite. * @param WP_User $user_object WP_User object for the currently-listed user. */ $actions = apply_filters('user_row_actions', $actions, $user_object); // Set up the checkbox ( because the user is editable, otherwise it's empty ) $checkbox = '<label class="screen-reader-text" for="user_' . $user_object->ID . '">' . sprintf(__('Select %s'), $user_object->user_login) . '</label>' . "<input type='checkbox' name='users[]' id='user_{$user_object->ID}' class='{$role}' value='{$user_object->ID}' />"; } else { $edit = '<strong>' . $user_object->user_login . '</strong>'; } $role_name = isset($wp_roles->role_names[$role]) ? translate_user_role($wp_roles->role_names[$role]) : __('None'); $avatar = get_avatar($user_object->ID, 32); $r = "<tr id='user-{$user_object->ID}'>"; list($columns, $hidden, $sortable, $primary) = $this->get_column_info(); foreach ($columns as $column_name => $column_display_name) { $classes = "{$column_name} column-{$column_name}"; if ($primary === $column_name) { $classes .= ' has-row-actions column-primary'; } if ('posts' === $column_name) { $classes .= ' num'; // Special case for that column } if (in_array($column_name, $hidden)) { $classes .= ' hidden'; } $data = 'data-colname="' . wp_strip_all_tags($column_display_name) . '"'; $attributes = "class='{$classes}' {$data}"; if ('cb' === $column_name) { $r .= "<th scope='row' class='check-column'>{$checkbox}</th>"; } else { $r .= "<td {$attributes}>"; switch ($column_name) { case 'username': $r .= "{$avatar} {$edit}"; break; case 'name': $r .= "{$user_object->first_name} {$user_object->last_name}"; break; case 'email': $r .= "<a href='" . esc_url("mailto:{$email}") . "'>{$email}</a>"; break; case 'projects': $projects = WC_QD()->db()->get_donation_grouped_count($user_object->ID); foreach ($projects as $project) { $r .= '<span> <strong> <a href="' . get_permalink($project['projectid']) . '" > ' . get_the_title($project['projectid']) . ' </a>'; $r .= ' </strong> x ' . $project['num_posts'] . '</span> <br/>'; } break; case 'donations': $donation_ids = WC_QD()->db()->get_user_donations_ids($user_object->ID); $donation_ids = WC_QD()->db()->extract_donation_id($donation_ids); $price = array(); foreach ($donation_ids as $donation) { $order = wc_get_order($donation); if ($order === false) { wcqd_delete_donation_entry($donation); continue; } $prices = $order->get_total(); $currname = $order->get_order_currency(); if (!isset($price[$currname])) { $price[$currname] = 0; } $price[$currname] = $price[$currname] + $prices; } foreach ($price as $pk => $pv) { $r .= " <strong> {$pk} : {$pv} <strong> <br/>"; } break; default: /** * Filter the display output of custom columns in the Users list table. * * @since 2.8.0 * * @param string $output Custom column output. Default empty. * @param string $column_name Column name. * @param int $user_id ID of the currently-listed user. */ $r .= apply_filters('manage_users_custom_column', '', $column_name, $user_object->ID); } if ($primary === $column_name) { $r .= $this->row_actions($actions); } $r .= "</td>"; } } $r .= '</tr>'; return $r; }
public function remove_metabox($post) { $is_donation = WC_QD()->db()->_is_donation($post->ID); if ($is_donation) { remove_meta_box('woocommerce-order-items', 'shop_order', 'normal'); remove_meta_box('woocommerce-order-downloads', 'shop_order', 'normal'); remove_meta_box('woocommerce-order-data', 'shop_order', 'normal'); add_meta_box('woocommerce-quick-donation-order-data', sprintf(__('%s Data', WC_QD_TXT), 'Donation'), 'WC_Quick_Donation_Meta_Box_Order_Data::output', 'shop_order', 'normal', 'high'); remove_action('woocommerce_process_shop_order_meta', 'WC_Meta_Box_Order_Data::save', 40); } }
public function save_order_id_db($order_id) { global $woocommerce; if ($this->check_donation_exists_cart()) { $project_id = intval($woocommerce->session->projects); $user_id = get_current_user_id(); update_post_meta($order_id, "_is_donation", true); update_post_meta($order_id, "_project_details", $woocommerce->session->projects); WC_QD()->db()->add_db_option($order_id, $project_id, $user_id); } }
foreach (WC_QD()->settings()->settings_field as $setting) { foreach ($setting as $setK => $set) { echo "\n " . '-- ' . $setK . ' Settings' . " \n"; foreach ($set as $s) { $value = WC_QD()->settings()->get_option($s['id']); if (is_array($value)) { $value = json_encode($value); } if (empty($value)) { $value = 'null'; } echo $s['id'] . ' : ' . $value . " \n"; } } } ?> ## Template Override Information <?php $override = WC_QD()->admin()->functions->get_OverRided(); foreach ($override as $temp) { $is_old = ''; if ($temp['is_old']) { $is_old = '[You are using an outdated version. kindly update it]'; } echo "" . $temp['file'] . " || Core Version " . $temp['corev'] . " || Theme Version" . $temp['themev'] . " {$is_old}" . " \n"; } ?> ### End WooCommerce Quick Donation Status ###