/**
  * Uninstall the plugin.
  *
  * @access 	public
  * @since 	1.0.0
  */
 public function __construct()
 {
     if (charitable()->is_deactivation() && charitable_get_option('delete_data_on_uninstall')) {
         $this->remove_caps();
         $this->remove_post_data();
         $this->remove_tables();
         do_action('charitable_uninstall');
     }
 }
 /**
  * Load the donation receipt template if we're looking at a donation receipt. 
  *
  * @param 	string 		$template
  * @return 	string
  * @access  public
  * @since 	1.0.0
  */
 public function donation_receipt_template($template)
 {
     if (charitable_is_page('donation_receipt_page')) {
         if ('auto' != charitable_get_option('donation_receipt_page', 'auto')) {
             return $template;
         }
         new Charitable_Ghost_Page('donation-receipt-page', array('title' => __('Your Receipt', 'charitable'), 'content' => sprintf('<p>%s</p>', __('Thank you for your donation!', 'charitable'))));
         $new_template = apply_filters('charitable_donation_receipt_page_template', array('donation-receipt-page.php', 'page.php', 'index.php'));
         $template = charitable_get_template_path($new_template, $template);
     }
     return $template;
 }
 /**
  * Loads public facing scripts and stylesheets. 
  *
  * @return 	void
  * @access 	public
  * @since 	1.0.0
  */
 public function wp_enqueue_scripts()
 {
     $vars = apply_filters('charitable_javascript_vars', array('ajaxurl' => admin_url('admin-ajax.php')));
     wp_register_script('charitable-script', charitable()->get_path('assets', false) . 'js/charitable.js', array('jquery'), charitable()->get_version());
     wp_localize_script('charitable-script', 'CHARITABLE_VARS', $vars);
     wp_enqueue_script('charitable-script');
     wp_register_style('charitable-styles', charitable()->get_path('assets', false) . 'css/charitable.css', array(), charitable()->get_version());
     wp_enqueue_style('charitable-styles');
     /* Lean Modal is registered but NOT enqueued yet. */
     if ('modal' == charitable_get_option('donation_form_display', 'separate_page')) {
         wp_register_script('lean-modal', charitable()->get_path('assets', false) . 'js/libraries/jquery.leanModal.js', array('jquery'), charitable()->get_version());
         wp_register_style('lean-modal-css', charitable()->get_path('assets', false) . 'css/modal.css', array(), charitable()->get_version());
     }
 }
/**
 * This returns the value for a particular Charitable setting.
 *
 * @param 	mixed		$key 			Accepts an array of strings or a single string.
 * @param 	mixed 		$default 		The value to return if key is not set.
 * @param 	array 		$settings 		Optional. Used when $key is an array.
 * @return 	mixed
 * @since 	1.0.0
 */
function charitable_get_option($key, $default = false, $settings = array())
{
    if (empty($settings)) {
        $settings = get_option('charitable_settings');
    }
    if (is_array($key)) {
        $current_key = current($key);
        /* Key does not exist */
        if (!isset($settings[$current_key])) {
            return $default;
        } else {
            array_shift($key);
            if (empty($key)) {
                return $settings[$current_key];
            } else {
                return charitable_get_option($key, $default, $settings[$current_key]);
            }
        }
    } else {
        return isset($settings[$key]) ? $settings[$key] : $default;
    }
}
Beispiel #5
0
<?php

/**
 * Display a series of checkboxes.
 *
 * @author  Studio 164a
 * @package Charitable/Admin View/Settings
 * @since   1.0.0
 */
$value = charitable_get_option($view_args['key'], array());
if (empty($value)) {
    $value = isset($view_args['default']) ? (array) $view_args['default'] : array();
}
if (!is_array($value)) {
    $value = (array) $value;
}
?>
<ul class="charitable-checkbox-list <?php 
echo esc_attr($view_args['classes']);
?>
">

    <?php 
foreach ($view_args['options'] as $option => $label) {
    ?>

        <li><input type="checkbox" 
                id="<?php 
    printf('charitable_settings_%s_%s', implode('_', $view_args['key']), $option);
    ?>
" 
 /**
  * Conditionally load the donation form scripts if we're viewing the donation form.
  *
  * @return  boolean True if scripts were loaded. False otherwise.
  * @access  public
  * @since   1.4.0
  */
 public function maybe_enqueue_donation_form_scripts()
 {
     $load = charitable_is_page('campaign_donation_page');
     if (!$load) {
         $load = 'charitable_campaign_loop_before' == current_action() && 'modal' == charitable_get_option('donation_form_display', 'separate_page');
     }
     if ($load) {
         $this->enqueue_donation_form_scripts();
     }
     return $load;
 }
 /**
  * Redirect the user to the Charitable login page.
  *
  * @return  void
  * @access  public
  * @since   1.4.0
  */
 public function maybe_redirect_to_charitable_login()
 {
     if (!apply_filters('charitable_disable_wp_login', false)) {
         return;
     }
     if ('wp' == charitable_get_option('login_page', 'wp')) {
         return;
     }
     /* Don't prevent logging out. */
     if ($_SERVER['REQUEST_METHOD'] != 'GET') {
         return;
     }
     wp_safe_redirect(esc_url_raw(charitable_get_permalink('login_page')));
     exit;
 }
 /**
  * Returns the currently enabled emails. 
  *
  * @return  string[]
  * @access  public
  * @since   1.0.0
  */
 public function get_enabled_emails()
 {
     return charitable_get_option('enabled_emails', array());
 }
 function test_charitable_get_option()
 {
     $this->assertFalse(charitable_get_option('nonexistentkey'));
 }
 /**
  * Return the base of the PayPal
  *
  * @param   bool $ssl_check
  * @return  string
  * @access  public
  * @since   1.0.0
  */
 public function get_redirect_url($ssl_check = false)
 {
     $protocol = is_ssl() || !$ssl_check ? 'https://' : 'http://';
     if (charitable_get_option('test_mode')) {
         $paypal_uri = $protocol . 'www.sandbox.paypal.com/cgi-bin/webscr';
     } else {
         $paypal_uri = $protocol . 'www.paypal.com/cgi-bin/webscr';
     }
     return apply_filters('charitable_paypal_uri', $paypal_uri);
 }
 /**
  * Return the value for a particular gateway setting.
  *
  * @param   string $setting
  * @return  mixed
  * @access  public
  * @since   1.0.0
  */
 public function get_value($setting)
 {
     $default = isset($this->defaults[$setting]) ? $this->defaults[$setting] : '';
     return charitable_get_option($setting, $default, $this->get_settings());
 }
 /**
  * Return the list of licenses.
  *
  * Note: The licenses are not necessarily valid. If a user enters an invalid
  * license, the license will be stored but it will be flagged as invalid.
  *
  * @return  array[]
  * @access  public
  * @since   1.0.0
  */
 public function get_licenses()
 {
     if (!isset($this->licenses)) {
         $this->licenses = charitable_get_option('licenses', array());
     }
     return $this->licenses;
 }
 /**
  * Load the reset password template.
  *
  * @param   string $template
  * @return  string
  * @access  protected
  * @since   1.4.0
  */
 protected function get_reset_password_template($template)
 {
     if ('wp' == charitable_get_option('login_page', 'wp')) {
         return $template;
     }
     new Charitable_Ghost_Page('reset-password-page', array('title' => __('Reset Password', 'charitable'), 'content' => '<!-- Silence is golden -->'));
     $new_template = apply_filters('charitable_reset_password_page_template', array('reset-password-page.php', 'page.php', 'index.php'));
     return charitable_get_template_path($new_template, $template);
 }
/**
 * Renders the custom styles added by Charitable.
 *
 * Override this template by copying it to yourtheme/charitable/custom-styles.css.php
 *
 * @author  Studio 164a
 * @package Charitable/Templates/Donation Receipt
 * @since   1.0.0
 * @version 1.0.0
 */
if (!defined('ABSPATH')) {
    exit;
}
// Exit if accessed directly
$highlight_colour = charitable_get_option('highlight_colour', apply_filters('charitable_default_highlight_colour', '#f89d35'));
?>
<style id="charitable-highlight-colour-styles">
.campaign-raised .amount, 
.campaign-figures .amount,
.donors-count, 
.time-left,
.charitable-form-field a:not(.button),
.charitable-form-fields .charitable-fieldset a:not(.button),
.charitable-notice,
.charitable-notice .errors a {
    color: <?php 
echo $highlight_colour;
?>
;
}
 /**
  * Save the meta for the donation.  
  *
  * @param   int $donation_id
  * @return  void
  * @access  public
  * @since   1.0.0
  */
 public function save_donation_meta($donation_id)
 {
     $meta = array('donation_gateway' => $this->get_donation_data_value('gateway'), 'donor' => $this->get_donation_data_value('user'), 'test_mode' => charitable_get_option('test_mode', 0), 'donation_key' => $this->get_donation_data_value('donation_key'));
     if ($this->get_donation_data_value('meta')) {
         $meta = array_merge($meta, $this->get_donation_data_value('meta'));
     }
     $meta = apply_filters('charitable_donation_meta', $meta, $donation_id, $this);
     foreach ($meta as $meta_key => $value) {
         $value = apply_filters('charitable_sanitize_donation_meta', $value, $meta_key);
         update_post_meta($donation_id, $meta_key, $value);
     }
 }
 /**
  * Determine the status of Test Mode and display an alert if it is active
  *
  * @return  void
  * @access  protected
  * @since   1.4.7
  */
 protected function check_test_mode()
 {
     $in_test_mode = charitable_get_option('test_mode', 0);
     /* If test mode is enabled, and current user is an admin, display an alert on the form. */
     if ($in_test_mode && current_user_can('manage_charitable_settings')) {
         charitable_get_notices()->add_error($this->get_test_mode_active_notice());
     }
 }
 /**
  * Returns the currently enabled emails.
  *
  * @return  string[]
  * @access  public
  * @since   1.0.0
  */
 public function get_enabled_emails()
 {
     $enabled = charitable_get_option('enabled_emails', array());
     /* The Password Reset email is always enabled. */
     $enabled['password_reset'] = 'Charitable_Email_Password_Reset';
     return $enabled;
 }
" />
		<input type="hidden" name="notify_url" value="<?php 
echo esc_url($notify_url);
?>
" />
		<input type="hidden" name="cbt" value="<?php 
echo esc_attr(get_bloginfo('name'));
?>
" />
		<input type="hidden" name="bn" value="Charitable_SP" />
		<input type="hidden" name="cmd" value="<?php 
echo $mode;
?>
" />
		<input type="hidden" name="country" value="<?php 
echo esc_attr(charitable_get_option('country', 'AU'));
?>
" />        
		<table class="form-table">
			<tbody>
				<tr>
					<th scope="row"><h3><?php 
_e('Run a Test Donation', 'charitable');
?>
</h3></th>
					<td><hr /></td>
				</tr>
				<tr>
					<td colspan="2" style="padding: 0 0 15px 0;">
						<p><?php 
printf(__("In October 2016, PayPal is upgrading the SSL certificates used to secure its web sites and API endpoints. <a href='%s' title='How PayPal\\'s SSL Certificate Upgrade Will Affect You — And How You Can Prepare for It'>Read about how these changes will impact you.</a>", 'charitable'), 'https://www.wpcharitable.com/how-paypals-ssl-certificate-upgrade-will-affect-you-and-how-you-can-prepare-for-it/?utm_source=notice&utm_medium=wordpress-dashboard&utm_campaign=paypal-ssl-upgrade&utm_content=blog-post');
 /**
  * Renders the donate button template.
  *
  * @return  void
  * @access  public
  * @since   1.2.3
  */
 public function donate_button_loop_template()
 {
     if ($this->has_ended()) {
         return;
     }
     $display_option = charitable_get_option('donation_form_display', 'separate_page');
     switch ($display_option) {
         case 'modal':
             $template_name = 'campaign-loop/donate-modal.php';
             break;
         default:
             $template_name = apply_filters('charitable_donate_button_loop_template', 'campaign-loop/donate-link.php', $this);
     }
     charitable_template($template_name, array('campaign' => $this));
 }
Beispiel #20
0
 *
 * @author  Studio 164a
 * @package Charitable/Admin View/Welcome Page
 * @since   1.0.0
 */
wp_enqueue_style('charitable-admin-pages');
require_once ABSPATH . 'wp-admin/includes/translation-install.php';
$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'];
$languages = wp_get_available_translations();
$locale = get_locale();
$language = isset($languages[$locale]['native_name']) ? $languages[$locale]['native_name'] : $locale;
$currency = charitable_get_option('currency', 'AUD');
$extensions = array();
if ('en_ZA' == $locale || 'ZAR' == $currency) {
    $extensions['ambassadors'] = __('Peer to peer fundraising or crowdfunding', 'charitable');
    $extensions['payfast'] = __('Accept donations in South African Rand', 'charitable');
    $extensions['anonymous-donations'] = __('Let donors give anonymously', 'charitable');
    $extensions['user-avatar'] = __('Let your donors upload their own profile photo', 'charitable');
} elseif ('hi_IN' == $locale || 'INR' == $currency) {
    $extensions['ambassadors'] = __('Peer to peer fundraising or crowdfunding', 'charitable');
    $extensions['payu-money'] = __('Accept donations in Indian Rupees', 'charitable');
    $extensions['anonymous-donations'] = __('Let donors give anonymously', 'charitable');
    $extensions['user-avatar'] = __('Let your donors upload their own profile photo', 'charitable');
} elseif (class_exists('EDD')) {
    $extensions['ambassadors'] = __('Peer to peer fundraising or crowdfunding', 'charitable');
    $extensions['easy-digital-downloads-connect'] = __('Collect donations with Easy Digital Downloads', 'charitable');
    $extensions['anonymous-donations'] = __('Let donors give anonymously', 'charitable');
/**
 * Return the site currency.
 *
 * @return  string
 * @since   1.0.0
 */
function charitable_get_currency()
{
    return charitable_get_option('currency', 'AUD');
}
 /**
  * Returns true if test mode is enabled.	
  *
  * @return  boolean
  * @access  public
  * @since   1.0.0
  */
 public function in_test_mode()
 {
     $enabled = charitable_get_option('test_mode', false);
     return apply_filters('charitable_in_test_mode', $enabled);
 }
 /**
  * Display the donation form. This is used with the_content filter.
  *
  * @param   string  $content
  * @return  string
  * @since   1.0.0
  */
 function charitable_template_donation_form_content($content)
 {
     if (charitable_is_page('campaign_donation_page')) {
         if ('same_page' == charitable_get_option('donation_form_display', 'separate_page')) {
             return $content;
         }
         ob_start();
         charitable_template('content-donation-form.php');
         $content = ob_get_clean();
     }
     return $content;
 }
 /**
  * Only show the required user fields if that option was enabled by the site admin. 
  *
  * @return  array[]
  * @access  public
  * @since   1.2.0
  */
 public function hide_non_required_user_fields($fields)
 {
     if (!charitable_get_option('donation_form_minimal_fields', false)) {
         return $fields;
     }
     foreach ($fields as $key => $field) {
         if (isset($field['required']) && $field['required']) {
             continue;
         }
         unset($fields[$key]);
     }
     return $fields;
 }
 /**
  * Return the keys to use.
  *
  * This will return the test keys if test mode is enabled. Otherwise, returns
  * the production keys.
  *
  * @return  string[]
  * @access  public
  * @since   1.0.0
  */
 public function get_keys()
 {
     $keys = array();
     if (charitable_get_option('test_mode')) {
         $keys['secret_key'] = trim($this->get_value('test_secret_key'));
         $keys['public_key'] = trim($this->get_value('test_public_key'));
     } else {
         $keys['secret_key'] = trim($this->get_value('live_secret_key'));
         $keys['public_key'] = trim($this->get_value('live_public_key'));
     }
     return $keys;
 }
 /**
  * Return the currency symbol for a given currency. 
  *
  * This function was changed to a public method in 1.3.7.
  *
  * Credit: This is based on the WooCommerce implemenation.
  *
  * @uses 	charitable_currency_symbol
  * @param 	string $currency Optional. If not set, currency is based on currently selected currency.
  * @return 	string
  * @access 	public
  * @since 	1.0.0
  */
 public function get_currency_symbol($currency = "")
 {
     if (!strlen($currency)) {
         $currency = charitable_get_option('currency', 'AUD');
     }
     switch ($currency) {
         case 'AED':
             $currency_symbol = 'د.إ';
             break;
         case 'BDT':
             $currency_symbol = '&#2547;';
             break;
         case 'BRL':
             $currency_symbol = '&#82;&#36;';
             break;
         case 'BGN':
             $currency_symbol = '&#1083;&#1074;.';
             break;
         case 'AUD':
         case 'ARS':
         case 'CAD':
         case 'CLP':
         case 'MXN':
         case 'NZD':
         case 'HKD':
         case 'SGD':
         case 'USD':
             $currency_symbol = '&#36;';
             break;
         case 'EUR':
             $currency_symbol = '&euro;';
             break;
         case 'CNY':
         case 'RMB':
         case 'JPY':
             $currency_symbol = '&yen;';
             break;
         case 'RUB':
             $currency_symbol = '&#1088;&#1091;&#1073;.';
             break;
         case 'KRW':
             $currency_symbol = '&#8361;';
             break;
         case 'TRY':
             $currency_symbol = '&#8378;';
             break;
         case 'NOK':
             $currency_symbol = '&#107;&#114;';
             break;
         case 'ZAR':
             $currency_symbol = '&#82;';
             break;
         case 'CZK':
             $currency_symbol = '&#75;&#269;';
             break;
         case 'MYR':
             $currency_symbol = '&#82;&#77;';
             break;
         case 'DKK':
             $currency_symbol = 'kr.';
             break;
         case 'HUF':
             $currency_symbol = '&#70;&#116;';
             break;
         case 'IDR':
             $currency_symbol = 'Rp';
             break;
         case 'INR':
             $currency_symbol = 'Rs.';
             break;
         case 'ISK':
             $currency_symbol = 'Kr.';
             break;
         case 'ILS':
             $currency_symbol = '&#8362;';
             break;
         case 'PHP':
             $currency_symbol = '&#8369;';
             break;
         case 'PLN':
             $currency_symbol = '&#122;&#322;';
             break;
         case 'SEK':
             $currency_symbol = '&#107;&#114;';
             break;
         case 'CHF':
             $currency_symbol = '&#67;&#72;&#70;';
             break;
         case 'TWD':
             $currency_symbol = '&#78;&#84;&#36;';
             break;
         case 'THB':
             $currency_symbol = '&#3647;';
             break;
         case 'GBP':
             $currency_symbol = '&pound;';
             break;
         case 'RON':
             $currency_symbol = 'lei';
             break;
         case 'VND':
             $currency_symbol = '&#8363;';
             break;
         case 'NGN':
             $currency_symbol = '&#8358;';
             break;
         case 'HRK':
             $currency_symbol = 'Kn';
             break;
         default:
             $currency_symbol = '';
             break;
     }
     return apply_filters('charitable_currency_symbol', $currency_symbol, $currency);
 }
 /**
  * Return the value of an option specific to this email. 
  *
  * @param   string  $key
  * @return  mixed
  * @access  protected
  * @since   1.0.0
  */
 protected function get_option($key, $default)
 {
     return charitable_get_option(array('emails_' . $this->get_email_id(), $key), $default);
 }
 /**
  * Return the user's address fields. 
  *
  * @return  array
  * @access  public
  * @since   1.0.0
  */
 public function get_address_fields()
 {
     $address_fields = apply_filters('charitable_user_address_fields', array('address' => array('label' => __('Address', 'charitable'), 'type' => 'text', 'priority' => 22, 'required' => false, 'value' => $this->get_user_value('donor_address')), 'address_2' => array('label' => __('Address 2', 'charitable'), 'type' => 'text', 'priority' => 24, 'required' => false, 'value' => $this->get_user_value('donor_address_2')), 'city' => array('label' => __('City', 'charitable'), 'type' => 'text', 'priority' => 26, 'required' => false, 'value' => $this->get_user_value('donor_city')), 'state' => array('label' => __('State', 'charitable'), 'type' => 'text', 'priority' => 28, 'required' => false, 'value' => $this->get_user_value('donor_state')), 'postcode' => array('label' => __('Postcode / ZIP code', 'charitable'), 'type' => 'text', 'priority' => 30, 'required' => false, 'value' => $this->get_user_value('donor_postcode')), 'country' => array('label' => __('Country', 'charitable'), 'type' => 'select', 'options' => charitable_get_location_helper()->get_countries(), 'priority' => 32, 'required' => false, 'value' => $this->get_user_value('donor_country', charitable_get_option('country'))), 'phone' => array('label' => __('Phone', 'charitable'), 'type' => 'text', 'priority' => 34, 'required' => false, 'value' => $this->get_user_value('donor_phone'))), $this);
     uasort($address_fields, 'charitable_priority_sort');
     return $address_fields;
 }
Beispiel #29
0
<?php

/**
 * Display email field. 
 *
 * @author  Studio 164a
 * @package Charitable/Admin Views/Settings
 * @since   1.0.0
 */
$value = charitable_get_option($view_args['key']);
if (empty($value)) {
    $value = isset($view_args['default']) ? $view_args['default'] : '';
}
?>
<input type="email"  
    id="<?php 
printf('charitable_settings_%s', implode('_', $view_args['key']));
?>
" 
    name="<?php 
printf('charitable_settings[%s]', $view_args['name']);
?>
"
    value="<?php 
echo esc_attr($value);
?>
" 
    class="<?php 
echo esc_attr($view_args['classes']);
?>
" 
/**
 * Checks whether the current request is for the campaign editing page. 
 *
 * This is used when you call charitable_is_page( 'profile_page' ). 
 * In general, you should use charitable_is_page() instead since it will
 * take into account any filtering by plugins/themes.
 *
 * @see     charitable_is_page
 * @return  boolean
 * @since   1.0.0
 */
function charitable_is_profile_page($ret = false)
{
    global $post;
    $page = charitable_get_option('profile_page', false);
    return false == $page || is_null($post) ? false : $page == $post->ID;
}