/**
  * Upload an image via plupload.
  *
  * @return
  */
 function charitable_plupload_image_upload()
 {
     $post_id = (int) filter_input(INPUT_POST, 'post_id', FILTER_SANITIZE_NUMBER_INT);
     $field_id = (string) filter_input(INPUT_POST, 'field_id');
     check_ajax_referer('charitable-upload-images-' . $field_id);
     $file = $_FILES['async-upload'];
     $file_attr = wp_handle_upload($file, array('test_form' => false));
     if (isset($file_attr['error'])) {
         wp_send_json_error($file_attr);
     }
     $attachment = array('guid' => $file_attr['url'], 'post_mime_type' => $file_attr['type'], 'post_title' => preg_replace('/\\.[^.]+$/', '', basename($file['name'])), 'post_content' => '', 'post_status' => 'inherit');
     /**
      * Insert the file as an attachment.
      */
     $attachment_id = wp_insert_attachment($attachment, $file_attr['file'], $post_id);
     if (is_wp_error($attachment_id)) {
         wp_send_json_error();
     }
     wp_update_attachment_metadata($attachment_id, wp_generate_attachment_metadata($attachment_id, $file_attr['file']));
     $size = (string) filter_input(INPUT_POST, 'size');
     $max_uploads = (int) filter_input(INPUT_POST, 'max_uploads', FILTER_SANITIZE_NUMBER_INT);
     if (!$size) {
         $size = 'thumbnail';
     }
     ob_start();
     charitable_template('form-fields/picture-preview.php', array('image' => $attachment_id, 'field' => array('key' => $field_id, 'size' => $size, 'max_uploads' => $max_uploads)));
     wp_send_json_success(ob_get_clean());
 }
 /**
  * Displays the widget on the frontend.
  *
  * @param   array       $args
  * @param   array       $instance
  * @return  void
  * @access  public
  * @since   1.0.0
  */
 public function widget($args, $instance)
 {
     if (!array_key_exists('campaign_id', $instance) || '' == $instance['campaign_id']) {
         return;
     }
     charitable_template('widgets/donate.php', array_merge($args, $instance));
 }
 /**
  * The callback method for the campaigns shortcode.
  *
  * This receives the user-defined attributes and passes the logic off to the class.
  *
  * @param   array $atts User-defined shortcode attributes.
  * @return  string
  * @access  public
  * @static
  * @since   1.0.0
  */
 public static function display($atts = array())
 {
     $defaults = array('logged_in_message' => __('You are already logged in!', 'charitable'), 'redirect' => esc_url(charitable_get_login_redirect_url()), 'registration_link_text' => __('Register', 'charitable'));
     $args = shortcode_atts($defaults, $atts, 'charitable_login');
     $args['login_form_args'] = self::get_login_form_args($args);
     if (is_user_logged_in()) {
         ob_start();
         charitable_template('shortcodes/logged-in.php', $args);
         return ob_get_clean();
     }
     if (false == $args['registration_link_text'] || 'false' == $args['registration_link_text']) {
         $args['registration_link'] = false;
     } else {
         $registration_link = charitable_get_permalink('registration_page');
         if (charitable_get_permalink('login_page') === $registration_link) {
             $args['registration_link'] = false;
         } else {
             if (isset($_GET['redirect_to'])) {
                 $registration_link = add_query_arg('redirect_to', $_GET['redirect_to'], $registration_link);
             }
             $args['registration_link'] = $registration_link;
         }
     }
     ob_start();
     charitable_template('shortcodes/login.php', $args);
     return apply_filters('charitable_login_shortcode', ob_get_clean());
 }
 /**
  * Display the widget contents on the front-end.
  *
  * @param   array $args
  * @param   array $instance
  * @return  void
  * @access  public
  * @since   1.0.0
  */
 public function widget($args, $instance)
 {
     $instance = $this->get_parsed_args($instance);
     $view_args = array_merge($args, $instance);
     $view_args['donors'] = $this->get_widget_donors($instance);
     charitable_template('widgets/donors.php', $view_args);
 }
 /**
  * Displays the widget on the frontend. 
  *
  * @param   array       $args
  * @param   array       $instance
  * @return  void
  * @access  public
  * @since   1.0.0    
  */
 public function widget($args, $instance)
 {
     if (!isset($instance['campaign_id']) || $instance['campaign_id'] == '') {
         return;
     }
     charitable_template('widgets/donate.php', array_merge($args, $instance));
 }
 /**
  * The callback method for the campaigns shortcode.
  *
  * This receives the user-defined attributes and passes the logic off to the class. 
  *
  * @param   array   $atts   User-defined shortcode attributes.
  * @return  string
  * @access  public
  * @static
  * @since   1.0.0
  */
 public static function display($atts)
 {
     $args = shortcode_atts($default, $atts, 'donations');
     $view_args = array('donations' => self::get_donations($args));
     ob_start();
     charitable_template('shortcodes/my-donations.php', $view_args);
     return apply_filters('charitable_my_donations_shortcode', ob_get_clean(), $args);
 }
 /**
  * Display the widget contents on the front-end. 
  *
  * @param   array $args
  * @param   array $instance
  * @access  public 
  * @since   1.0.0
  */
 public function widget($args, $instance)
 {
     $view_args = array_merge($args, $instance);
     if (!isset($view_args['title'])) {
         $view_args['title'] = __('Donation Statistics', 'charitable');
     }
     charitable_template('widgets/donation-stats.php', $view_args);
 }
 /**
  * The callback method for the campaigns shortcode.
  *
  * This receives the user-defined attributes and passes the logic off to the class. 
  *
  * @param   array   $atts   User-defined shortcode attributes.
  * @return  string
  * @access  public
  * @static
  * @since   1.0.0
  */
 public static function display($atts)
 {
     if (!is_user_logged_in()) {
         return Charitable_Login_Shortcode::display($atts);
     }
     $args = shortcode_atts(array(), $atts, 'charitable_profile');
     ob_start();
     charitable_template('shortcodes/profile.php', array('form' => new Charitable_Profile_Form($args)));
     return apply_filters('charitable_profile_shortcode', ob_get_clean());
 }
/**
 * Hide the campaign summary stats from a specific campaign, using the campaign ID.
 *
 * @param   Charitable_Campaign $campaign
 */
function charitable_template_campaign_summary($campaign)
{
    $campaign_id = 325;
    // Replace with the ID of your campaign.
    if ($campaign_id == $campaign->ID) {
        // If you still want to show a Donate button, uncomment the line below.
        // charitable_template_donate_button( $campaign );
        return;
    }
    charitable_template('campaign/summary.php', array('campaign' => $campaign));
}
 /**
  * The callback method for the campaigns shortcode.
  *
  * This receives the user-defined attributes and passes the logic off to the class.
  *
  * @param   array   $atts   User-defined shortcode attributes.
  * @return  string
  * @access  public
  * @static
  * @since   1.0.0
  */
 public static function display($atts = array())
 {
     $defaults = array('logged_in_message' => __('You are already logged in!', 'charitable'), 'redirect' => false, 'login_link_text' => __('Signed up already? Login instead.', 'charitable'));
     $args = shortcode_atts($defaults, $atts, 'charitable_registration');
     ob_start();
     if (is_user_logged_in()) {
         charitable_template('shortcodes/logged-in.php', $args);
         return ob_get_clean();
     }
     charitable_template('shortcodes/registration.php', array('form' => new Charitable_Registration_Form($args)));
     return apply_filters('charitable_registration_shortcode', ob_get_clean());
 }
 /**
  * The callback method for the campaigns shortcode.
  *
  * This receives the user-defined attributes and passes the logic off to the class. 
  *
  * @param   array   $atts   User-defined shortcode attributes.
  * @return  string
  * @access  public
  * @static
  * @since   1.0.0
  */
 public static function display($atts)
 {
     global $wp;
     $defaults = array('logged_in_message' => __('You are already logged in!', 'charitable'));
     $args = shortcode_atts($defaults, $atts, 'charitable_login');
     ob_start();
     if (is_user_logged_in()) {
         charitable_template('shortcodes/logged-in.php', $args);
         return ob_get_clean();
     }
     $args['login_form_args'] = self::get_login_form_args($args);
     charitable_template('shortcodes/login.php', $args);
     return apply_filters('charitable_login_shortcode', ob_get_clean());
 }
 /**
  * The callback method for the campaigns shortcode.
  *
  * This receives the user-defined attributes and passes the logic off to the class.
  *
  * @param   array $atts User-defined shortcode attributes.
  * @return  string
  * @access  public
  * @static
  * @since   1.4.0
  */
 public static function display($atts)
 {
     $defaults = array();
     $args = shortcode_atts($defaults, $atts, 'charitable_my_donations');
     ob_start();
     /* If the user is logged out, redirect to login/registration page. */
     if (!is_user_logged_in()) {
         echo Charitable_Login_Shortcode::display(array('redirect' => charitable_get_current_url()));
         return;
     }
     $user = charitable_get_user(get_current_user_id());
     $view_args = array('donations' => new Charitable_Donations_Query(array('output' => 'posts', 'donor_id' => $user->get_donor_id(), 'orderby' => 'date', 'order' => 'DESC', 'number' => -1)));
     charitable_template('shortcodes/my-donations.php', $view_args);
     return apply_filters('charitable_my_donations_shortcode', ob_get_clean(), $args);
 }
 /**
  * Render any notices.
  *
  * @param   array $notices
  * @return  void
  * @since   1.4.0
  */
 function charitable_template_notices($notices = array())
 {
     if (empty($notices)) {
         $notices = charitable_get_notices()->get_notices();
     }
     charitable_template('form-fields/notices.php', array('notices' => $notices));
 }
 /**
  * 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));
 }
 /**
  * Display the widget contents on the front-end. 
  *
  * @param   array $args
  * @param   array $instance
  * @access  public 
  * @since   1.0.0
  */
 public function widget($args, $instance)
 {
     $view_args = array_merge($args, $instance);
     charitable_template('widgets/campaign-terms.php', $view_args);
 }
Example #16
0
 * Display a list of campaigns.
 *
 * @author  Studio 164a
 * @since   1.0.0
 */
if (!defined('ABSPATH')) {
    exit;
}
// Exit if accessed directly
$campaigns = $view_args['campaigns'];
if (!$campaigns->have_posts()) {
    return;
}
if ($view_args['columns'] > 1) {
    $loop_class = sprintf('campaign-loop campaign-grid campaign-grid-%d', $view_args['columns']);
} else {
    $loop_class = 'campaign-loop';
}
?>
<ol class="<?php 
echo $loop_class;
?>
">

<?php 
while ($campaigns->have_posts()) {
    $campaigns->the_post();
    charitable_template('campaign-loop/campaign.php');
}
?>
</ol>
 /**
  * Render the donation form.
  *
  * @return  void
  * @access  public
  * @since   1.0.0
  */
 public function render()
 {
     /* Load the script if it hasn't been loaded yet. */
     if (!wp_script_is('charitable-script', 'enqueued')) {
         Charitable_Public::get_instance()->enqueue_donation_form_scripts();
     }
     charitable_template('donation-form/form-donation.php', array('campaign' => $this->get_campaign(), 'form' => $this, 'form_id' => 'charitable-donation-amount-form'));
 }
 /**
  * Add a password field to the end of the form.  
  *
  * @param   Charitable_Donation_Form $form
  * @return  void
  * @access  public
  * @since   1.0.0
  */
 public function add_password_field($form)
 {
     if (!$form->is_current_form($this->id)) {
         return;
     }
     /**
      * Make sure we are not logged in.
      */
     if (0 !== wp_get_current_user()->ID) {
         return;
     }
     charitable_template('donation-form/user-login-fields.php');
 }
<?php

/**
 * This template was deprecated in 1.2.3. Use campaign-loop/donate-link.php instead.
 * 
 * @deprecated
 */
charitable_template('campaign-loop/donate-link.php', $view_args);
 /**
  * Display the widget contents on the front-end. 
  *
  * @param 	array $args
  * @param 	array $instance
  * @access 	public 
  * @since 	1.0.0
  */
 public function widget($args, $instance)
 {
     $view_args = array_merge($args, $instance);
     $view_args['campaigns'] = $this->get_widget_campaigns($instance);
     charitable_template('widgets/campaigns.php', $view_args);
 }
if (!defined('ABSPATH')) {
    exit;
}
// Exit if accessed directly
$content = $view_args['content'];
if (is_user_logged_in()) {
    ?>

<div class="charitable-notice">
    <?php 
    _e('You do not have access to this donation receipt.', 'charitable');
    ?>
    
</div>

<?php 
} else {
    ?>

<div class="charitable-notice">
    <?php 
    _e('You must be logged in to access your donation receipt.', 'charitable');
    ?>
</div>

<?php 
    charitable_template('shortcodes/login.php', array('redirect' => charitable_get_current_url()));
    ?>

<?php 
}
 /**
  * Receives the IPN from PayPal after the sandbox test and attempts to verify the result.
  *
  * @return  void
  * @access  public
  * @static
  * @since   1.4.3
  */
 public static function process_sandbox_test_ipn()
 {
     $gateway = new Charitable_Gateway_Paypal();
     $data = $gateway->get_encoded_ipn_data();
     /* If any of these checks fail, we conclude that this is not a proper IPN from PayPal. */
     if (empty($data) || !is_array($data)) {
         die("empty data");
     }
     /* Compare the token with the one we generated. */
     $token = get_option('charitable_paypal_sandbox_test_token');
     if (!array_key_exists('custom', $data) || $token !== $data['custom']) {
         die("missing or mismatched custom data");
     }
     $remote_post_vars = array('method' => 'POST', 'timeout' => 45, 'redirection' => 5, 'httpversion' => '1.1', 'blocking' => true, 'headers' => array('host' => 'www.paypal.com', 'connection' => 'close', 'content-type' => 'application/x-www-form-urlencoded', 'post' => '/cgi-bin/webscr HTTP/1.1'), 'sslverify' => false, 'body' => $data);
     /* Call the PayPal API to verify the IPN. */
     $protocol = is_ssl() ? 'https://' : 'http://';
     $remote_url = $protocol . 'www.sandbox.paypal.com/cgi-bin/webscr';
     $api_response = wp_remote_post($remote_url, $remote_post_vars);
     $succeeded = !is_wp_error($api_response);
     $message = '';
     if ($succeeded) {
         $result = 'succeeded';
         $subject = __('Your PayPal integration is working', 'charitable');
         $message = __('<p>Good news! We successfuly received the Instant Payment Notification from PayPal and were able to verify it with them.</p>', 'charitable');
         $message .= __('<p>This means that your website is all set to continue receiving donations through PayPal. You should not experience any issues when PayPal upgrades its SSL certificates.</p>', 'charitable');
         $message .= __('<p>Cheers<br />Eric & Wes', 'charitable');
     } else {
         $result = 'failed';
         $subject = __('Your PayPal test failed', 'charitable');
         $message .= __('<p>We received the Instant Payment Notification from PayPal but were not able to verify its authenticity.', 'charitable');
         $message .= __('<p>Our communicaton with PayPal failed with the following errors:</p>', 'charitable');
         $message .= '<ul>';
         foreach ($api_response->get_error_messages() as $error) {
             $message .= sprintf('<li>%s</li>', $error);
         }
         $message .= '</ul>';
         $message .= __('<p>Unfortunately, this means that you are likely to face problems with your PayPal donations from October 2016 onwards. Your donors will still be able to proceed to PayPal and make their donation, but their donations will not be automatically marked as Paid in your WordPress dashboard.</p>', 'charitable');
         $message .= __('<h3>Short-term fix</h3>', 'charitable');
         $message .= __('<p><strong>Disable IPN verification</strong>. This makes your donation verification process less secure, but it will allow your donations to continue getting marked as Paid. To set this up, log into your WordPress dashboard and go to <em>Charitable</em> > <em>Settings</em> > <em>Payment Gateways</em>, select your PayPal settings and enable the "Disable IPN Verification" setting.', 'charitable');
         $message .= __('<h3>Long-term solution</h3>', 'charitable');
         $message .= __('<p><strong>Get in touch with your web host</strong>. Please refer them to <a href="https://www.paypal-knowledge.com/infocenter/index?page=content&widgetview=true&id=FAQ1766&viewlocale=en_US">the upgrade information provided by PayPal</a>. You should also provide them with the error message you received from PayPal above.</p>', 'charitable');
         $message .= __('<p>If your web host is unable to upgrade the software on your server, we strongly recommend switching to a hosting platform that provides a more modern, and secure service.</p>', 'charitable');
         $message .= __('<p>Cheers<br />Eric & Wes', 'charitable');
     }
     /* Store the result. */
     update_option('charitable_paypal_sandbox_test', $result);
     /* Clear the token. */
     delete_option('charitable_paypal_sandbox_test_token');
     /* Set a transient to display the success/failure of the test. */
     set_transient('charitable_paypal-sandbox-test_notice', 1);
     /* Remove the transient about the PayPal upgrade. */
     delete_transient('charitable_release-143-paypal_notice');
     /* Send an email to the site admin. */
     ob_start();
     charitable_template('emails/header.php', array('email' => null, 'headline' => $subject));
     echo $message;
     charitable_template('emails/footer.php');
     $message = ob_get_clean();
     $headers = "From: Charitable <*****@*****.**>\r\n";
     $headers .= "Reply-To: support@wpcharitable.com\r\n";
     $headers .= "Content-Type: text/html; charset=utf-8\r\n";
     /* Send an email to the site administrator letting them know. */
     $sent = wp_mail(get_option('admin_email'), $subject, $message, $headers);
 }
Example #23
0
            <p class="charitable-drag-drop-buttons">
                <button id="<?php 
echo $field['key'];
?>
-browse-button" class="button"><?php 
_ex('Select Files', 'image upload', 'charitable');
?>
</button>
            </p>
        </div>
        <div class="charitable-drag-drop-image-loader" style="display: none;">
            <p class="loader-title"><?php 
_e('Uploading...', 'charitable');
?>
</p>
            <ul class="images"></ul>
        </div>
        <ul id="<?php 
echo $field['key'];
?>
-dragdrop-images" class="charitable-drag-drop-images charitable-drag-drop-images-<?php 
echo $max_uploads;
?>
"><?php 
foreach ($value as $image) {
    charitable_template('form-fields/picture-preview.php', array('image' => $image, 'field' => $field));
}
?>
</ul>
    </div>
</div>
Example #24
0
 /**
  * Display the campaign sharing icons.
  *
  * @uses 	charitable_template
  *
  * @param   Charitable_Campaign $campaign
  * @return  void
  * @since   1.0.0
  */
 function reach_template_campaign_share(Charitable_Campaign $campaign)
 {
     charitable_template('campaign/share.php', array('campaign' => $campaign));
 }
 /**
  * Display error notices at the start of the form, if there are any.	
  *
  * @param 	Charitable_Form 	$form
  * @return 	void
  * @access  public
  * @since 	1.0.0
  */
 public function render_error_notices($form)
 {
     if (!$form->is_current_form($this->id)) {
         return false;
     }
     $errors = charitable_get_notices()->get_errors();
     if (!empty($errors)) {
         charitable_template('form-fields/errors.php', array('form' => $form, 'errors' => $errors));
     }
 }
 /**
  * Display the widget contents on the front-end. 
  *
  * @param   array $args
  * @param   array $instance
  * @access  public 
  * @since   1.0.0
  */
 public function widget($args, $instance)
 {
     charitable_template('widgets/donation-stats.php', array_merge($args, $instance));
 }
 /**
  * Build the email.  
  *
  * @return  string
  * @access  protected
  * @since   1.0.0
  */
 protected function build_email()
 {
     ob_start();
     charitable_template('emails/header.php', array('email' => $this));
     charitable_template('emails/body.php', array('email' => $this));
     charitable_template('emails/footer.php', array('email' => $this));
     $message = ob_get_clean();
     return apply_filters('charitable_email_message', $message, $this);
 }
 /**
  * Closes the hidden donor fields wrapper div if the user is logged in.
  *
  * @param   Charitable_Form $form
  * @return  void
  * @since   1.0.0
  */
 function charitable_template_donation_form_donor_fields_hidden_wrapper_end(Charitable_Form $form)
 {
     /* Verify that the user is logged in and has all required fields filled out */
     if (!$form->get_user() || !$form->user_has_required_fields()) {
         return;
     }
     charitable_template('donation-form/donor-fields/hidden-fields-wrapper-end.php');
 }