/** * Static method that is fired within 24 hours after a campaign is finished. * * @param int $campaign_id * @return boolean * @access public * @static * @since 1.1.0 */ public static function send_with_campaign_id($campaign_id) { if (!charitable_get_helper('emails')->is_enabled_email(self::get_email_id())) { return false; } $email = new Charitable_Email_Campaign_End(array('campaign' => new Charitable_Campaign($campaign_id))); /** * Don't resend the email. */ if ($email->is_sent_already($campaign_id)) { return false; } /** * Check whether the campaign expired in the last 24 hours. */ if (!$email->is_time_to_send()) { return false; } $sent = $email->send(); /** * Log that the email was sent. */ if (apply_filters('charitable_log_email_send', true, self::get_email_id(), $email)) { $email->log($campaign_id, $sent); } return true; }
/** * Static method that is fired right after a donation is completed, sending the donation receipt. * * @param int $donation_id * @return boolean * @access public * @static * @since 1.0.0 */ public static function send_with_donation_id($donation_id) { if (!charitable_get_helper('emails')->is_enabled_email(self::get_email_id())) { return false; } if (!charitable_is_approved_status(get_post_status($donation_id))) { return false; } $donation = charitable_get_donation($donation_id); if (!is_object($donation) || 0 == count($donation->get_campaign_donations())) { return false; } if (!apply_filters('charitable_send_' . self::get_email_id(), true, $donation)) { return false; } $email = new Charitable_Email_New_Donation(array('donation' => $donation)); /** * Don't resend the email. */ if ($email->is_sent_already($donation_id)) { return false; } $sent = $email->send(); /** * Log that the email was sent. */ if (apply_filters('charitable_log_email_send', true, self::get_email_id(), $email)) { $email->log($donation_id, $sent); } return true; }
/** * Right after a donation is made, this sends the donation receipt to * the donor if the donation is pending AND it was made in offline mode. * * @param int $donation_id * @return boolean */ function en_send_donation_receipt_for_pending_offline($donation_id) { /* Verify that the email is enabled. */ if (!charitable_get_helper('emails')->is_enabled_email(Charitable_Email_Donation_Receipt::get_email_id())) { return false; } /* If the donation is not pending, stop here. */ if ('charitable-pending' != get_post_status($donation_id)) { return false; } /* If the donation was not made with the offline payment option, stop here. */ if ('offline' != get_post_meta($donation_id, 'donation_gateway', true)) { return false; } /* All three of those checks passed, so proceed with sending the email. */ $email = new Charitable_Email_Donation_Receipt(array('donation' => new Charitable_Donation($donation_id))); /* Don't resend the email. */ if ($email->is_sent_already($donation_id)) { return false; } $sent = $email->send(); /* Log that the email was sent. */ if (apply_filters('charitable_log_email_send', true, Charitable_Email_Donation_Receipt::get_email_id(), $email)) { $email->log($donation_id, $sent); } return true; }
/** * Static method that is fired right after a donation is completed, sending the donation receipt. * * @param int $donation_id * @return boolean * @access public * @static * @since 1.0.0 */ public static function send_with_donation_id($donation_id) { if (!charitable_get_helper('emails')->is_enabled_email(self::get_email_id())) { return false; } if (!Charitable_Donation::is_approved_status(get_post_status($donation_id))) { return false; } $email = new Charitable_Email_Donation_Receipt(array('donation' => new Charitable_Donation($donation_id))); $email->send(); return true; }
/** * Static method that is fired within 24 hours after a campaign is finished. * * @param int $campaign_id * @return boolean * @access public * @static * @since 1.1.0 */ public static function send_with_campaign_id($campaign_id) { if (!charitable_get_helper('emails')->is_enabled_email(self::get_email_id())) { return false; } $campaign = new Charitable_Campaign($campaign_id); $time_since_ended = $campaign->get_time_since_ended(); /* If the since since ended is 0 (campaign is still going) or more than 24 hours, return false */ if ($time_since_ended == 0 || $time_since_ended > 86400) { return false; } $email = new Charitable_Email_Campaign_End(array('campaign' => $campaign)); $email->send(); return true; }
/** * Right after a donation is made, this sends a notification to admin if * the donation is pending AND it was made in offline mode. * * @param int $donation_id * @return boolean */ function en_send_donation_notification_for_pending_offline($donation_id) { /* Verify that the email is enabled. */ if (!charitable_get_helper('emails')->is_enabled_email(Charitable_Email_New_Donation::get_email_id())) { return false; } /* If the donation is not pending, stop here. */ if ('charitable-pending' != get_post_status($donation_id)) { return false; } /* If the donation was not made with the offline payment option, stop here. */ if ('offline' != get_post_meta($donation_id, 'donation_gateway', true)) { return false; } /* All three of those checks passed, so proceed with sending the email. */ $email = new Charitable_Email_New_Donation(array('donation' => new Charitable_Donation($donation_id))); $email->send(); return true; }
/** * Static method that is fired right after a donation is completed, sending the donation receipt. * * @param int $donation_id * @return boolean * @access public * @static * @since 1.0.0 */ public static function send_with_donation_id($donation_id) { if (!charitable_get_helper('emails')->is_enabled_email(self::get_email_id())) { return false; } if (!charitable_is_approved_status(get_post_status($donation_id))) { return false; } $email = new Charitable_Email_Donation_Receipt(array('donation' => charitable_get_donation($donation_id))); /** * Don't resend the email. */ if ($email->is_sent_already($donation_id)) { return false; } $sent = $email->send(); /** * Log that the email was sent. */ if (apply_filters('charitable_log_email_send', true, self::get_email_id(), $email)) { $email->log($donation_id, $sent); } return true; }
<?php /** * Display the Welcome page. * * @author Studio 164a * @package Charitable/Admin View/Welcome Page * @since 1.0.0 */ wp_enqueue_style('charitable-admin-pages'); $gateways = Charitable_Gateways::get_instance()->get_active_gateways_names(); $campaigns = wp_count_posts('campaign'); $campaigns_count = $campaigns->publish + $campaigns->draft + $campaigns->future + $campaigns->pending + $campaigns->private; $emails = charitable_get_helper('emails')->get_enabled_emails_names(); $install = isset($_GET['install']) && $_GET['install']; ?> <div class="wrap about-wrap charitable-wrap"> <h1> <strong>Charitable</strong> <sup class="version"><?php echo charitable()->get_version(); ?> </sup> </h1> <div class="badge"> <a href="https://www.wpcharitable.com/?utm_source=welcome-page&utm_medium=wordpress-dashboard&utm_campaign=home&utm_content=icon" target="_blank"><i class="icon-charitable"></i></a> </div> <div class="intro"> <?php if ($install) { _e('Thank you for installing Charitable!', 'charitable');
<?php /** * Email Preview * * @author Studio 164a * @package Charitable/Templates/Emails * @version 1.0.0 */ if (!defined('ABSPATH')) { exit; } // Exit if accessed directly if (!isset($_GET['email_id'])) { return; } $email = charitable_get_helper('emails')->get_email($_GET['email_id']); $email_object = new $email(); echo $email_object->preview();
/** * Set up payment fields based on the gateways that are installed and which one is default. * * @return void * @access protected * @since 1.0.0 */ protected function setup_payment_fields() { $active_gateways = charitable_get_helper('gateways')->get_active_gateways(); $has_gateways = apply_filters('charitable_has_active_gateways', !empty($active_gateways)); /* If no gateways have been selected, display a notice and return the fields */ if (!$has_gateways) { charitable_get_notices()->add_error($this->get_no_active_gateways_notice()); return; } if (count($active_gateways) == 1) { add_filter('charitable_donation_form_hidden_fields', array($this, 'add_hidden_gateway_field')); } add_action('charitable_donation_form_fields', array($this, 'add_payment_fields')); }
/** * Returns the helper class of the email we're editing. * * @return Charitable_Email|false * @access private * @since 1.0.0 */ private function get_current_email_class() { $email = charitable_get_helper('emails')->get_email($_GET['edit_email']); return $email ? new $email() : false; }
/** * Returns the gateway's object helper. * * @return false|Charitable_Gateway * @access public * @since 1.0.0 */ public function get_gateway_object() { $class = charitable_get_helper('gateways')->get_gateway($this->get_gateway()); if (!$class) { return false; } return new $class(); }
/** * Checks for updated license and invalidates status field if not set. * * @param mixed[] $values The parsed values combining old values & new values. * @param mixed[] $new_values The newly submitted values. * @return mixed[] * @access public * @since 1.0.0 */ public function save_license($values, $new_values) { /* If we didn't just submit licenses, stop here. */ if (!isset($new_values['licenses'])) { return $values; } $licenses = $new_values['licenses']; foreach ($licenses as $product_key => $license) { $license_data = charitable_get_helper('licenses')->verify_license($product_key, $license); if (empty($license_data)) { continue; } $values['licenses'][$product_key] = $license_data; } return $values; }
<?php /** * Display the table of emails. * * @author Studio 164a * @package Charitable/Admin View/Settings * @since 1.0.0 */ $helper = charitable_get_helper('emails'); $emails = $helper->get_available_emails(); if (count($emails)) { foreach ($emails as $email) { $email = new $email(); $is_enabled = $helper->is_enabled_email($email->get_email_id()); $action_url = esc_url(add_query_arg(array('charitable_action' => $is_enabled ? 'disable_email' : 'enable_email', 'email_id' => $email->get_email_id(), '_nonce' => wp_create_nonce('email')), admin_url('admin.php?page=charitable-settings&tab=emails'))); ?> <div class="charitable-settings-object charitable-email cf"> <h4><?php echo $email->get_name(); ?> </h4> <span class="actions"> <?php if ($is_enabled) { $settings_url = esc_url(add_query_arg(array('group' => 'emails_' . $email->get_email_id()), admin_url('admin.php?page=charitable-settings&tab=emails'))); ?> <a href="<?php echo $settings_url; ?> " class="button button-primary"><?php
<?php /** * Display the table of payment gateways. * * @author Studio 164a * @package Charitable/Admin View/Settings * @since 1.0.0 */ $helper = charitable_get_helper('gateways'); $gateways = $helper->get_available_gateways(); $default = $helper->get_default_gateway(); if (count($gateways)) { foreach ($gateways as $gateway) { $gateway = new $gateway(); $is_active = $helper->is_active_gateway($gateway->get_gateway_id()); $action_url = esc_url(add_query_arg(array('charitable_action' => $is_active ? 'disable_gateway' : 'enable_gateway', 'gateway_id' => $gateway->get_gateway_id(), '_nonce' => wp_create_nonce('gateway')), admin_url('admin.php?page=charitable-settings&tab=gateways'))); $make_default_url = esc_url(add_query_arg(array('charitable_action' => 'make_default_gateway', 'gateway_id' => $gateway->get_gateway_id(), '_nonce' => wp_create_nonce('gateway')), admin_url('admin.php?page=charitable-settings&tab=gateways'))); ?> <div class="charitable-settings-object charitable-gateway cf"> <h4><?php echo $gateway->get_name(); ?> </h4> <?php if ($gateway->get_gateway_id() == $default) { ?> <span class="default-gateway"><?php _e('Default gateway', 'charitable'); ?>
<?php /** * Display the table of products requiring licenses. * * @author Studio 164a * @package Charitable/Admin View/Settings * @since 1.0.0 */ $helper = charitable_get_helper('licenses'); $products = $helper->get_products(); if (empty($products)) { return; } foreach ($products as $key => $product) { $license = $helper->get_license_details($key); $is_active = $license && $license['valid']; ?> <div class="charitable-settings-object charitable-licensed-product cf"> <h4><?php echo $product['name']; ?> </h4> <input type="text" name="charitable_settings[licenses][<?php echo $key; ?> ]" id="charitable_settings_licenses_<?php echo $key; ?> " class="charitable-settings-field" placeholder="<?php _e('Add your license key', 'charitable');
/** * Add gateway keys to the settings groups. * * @param string[] $groups * @return string[] * @access public * @since 1.0.0 */ public function add_gateway_settings_dynamic_groups($groups) { foreach (charitable_get_helper('gateways')->get_active_gateways() as $gateway_key => $gateway) { if (!class_exists($gateway)) { continue; } $groups['gateways_' . $gateway_key] = apply_filters('charitable_gateway_settings_fields_gateways_gateway', array(), new $gateway()); } return $groups; }
/** * Returns the donation for the current request. * * @return Charitable_Donation * @since 1.0.0 */ function charitable_get_current_donation() { return charitable_get_helper('request')->get_current_donation(); }
function test_charitable_get_helper() { $this->assertInstanceOf('Charitable_Gateways', charitable_get_helper('gateways')); }
/** * Set up licensing for the extension. * * @return void * @access private * @since 1.0.0 */ private function setup_licensing() { charitable_get_helper('licenses')->register_licensed_product(Charitable_Extension_Boilerplate::NAME, Charitable_Extension_Boilerplate::AUTHOR, Charitable_Extension_Boilerplate::VERSION, $this->plugin_file); }