/** * This example shows how to change the output of the line items * displayed by the donation summary in email receipts. In this example, * we simply display the total amount donated on each line. * * @param string $line_item The default output provided by Charitable. * @param Object $campaign_donation A single record from the wp_charitable_campaign_donations table. * @return string */ function en_filter_email_donation_summary_line_item($line_item, $campaign_donation) { $line_item = charitable_format_money($campaign_donation->amount); $line_item .= PHP_EOL; // Be sure to add this to force each line item onto a new line. return $line_item; }
/** * Returns the fundraising goal formatted as a monetary amount. * * @return string * @access public * @since 1.0.0 */ public function get_monetary_goal() { if (!$this->has_goal()) { return ''; } return charitable_format_money($this->get('goal')); }
data-progress-stroke="<?php echo esc_attr(get_theme_mod('accent_colour', '#7bb4e0')); ?> "> </li> <li class="campaign-raised"> <span><?php echo number_format($progress, 2); ?> <sup>%</sup></span> <?php _e('Funded', 'reach'); ?> </li> <li class="campaign-pledged"> <span><?php echo charitable_format_money($campaign->get_donated_amount()); ?> </span> <?php _e('Pledged', 'reach'); ?> </li> <li class="campaign-time-left"> <?php echo $campaign->get_time_left(); ?> </li> </ul>
/** * Validate the form submission. * * @return boolean * @access public * @since 1.0.0 */ public function validate_submission() { if (!$this->validate_nonce()) { return false; } $has_required_fields = $this->check_required_fields($this->get_merged_fields()); if (!$has_required_fields) { return false; } if (self::get_donation_amount() <= 0 && !apply_filters('charitable_permit_0_donation', false)) { charitable_get_notices()->add_error(sprintf(__('You must donate more than %s.', 'charitable'), charitable_format_money('0'))); return false; } return apply_filters('charitable_validate_donation_form_submission', true, $this); }
/** * Render the Amount column. * * @param WP_Post $donation * @return string * @access public * @since 1.0.0 */ public function column_amount($donation) { $donation = charitable_get_donation($donation->ID); $gateway = $donation->get_gateway_object() ? $donation->get_gateway_object()->get_name() : $donation->get_gateway(); $method = sprintf(_x('via %s', 'via payment method', 'charitable'), $gateway); $value = sprintf('%s<span class="meta">%s</span>', charitable_format_money($donation->get_total_donation_amount()), $method); return apply_filters('charitable_donations_table_column', $value, $donation->ID, 'amount'); }
?> "> <td class="reorder-col"><span class="icon-donations-grab handle"></span></td> <?php foreach ($fields as $key => $field) { if (is_array($donation) && isset($donation[$key])) { $value = $donation[$key]; } elseif ('amount' == $key) { $value = $donation; } else { $value = ''; } if ('amount' == $key && strlen($value)) { $value = charitable_format_money($value); } ?> <td class="<?php echo $key; ?> -col"><input type="text" class="campaign_suggested_donations" name="_campaign_suggested_donations[<?php echo $i; ?> ][<?php echo $key; ?> ]"
/** * Display the total amount donated to the campaign. * * @return string * @access public * @since 1.1.0 */ public function get_campaign_donated_amount() { if (!$this->has_valid_campaign()) { return ''; } return charitable_format_money($this->campaign->get_donated_amount()); }
</thead> <tbody> <?php foreach ($donations as $donation) { ?> <tr> <td><?php echo mysql2date('F j, Y', get_post_field('post_date', $donation->ID)); ?> </td> <td><?php echo $donation->campaigns; ?> </td> <td><?php echo charitable_format_money($donation->amount); ?> </td> <td><a href="<?php echo esc_attr(charitable_get_permalink('donation_receipt_page', array('donation_id' => $donation->ID))); ?> "><?php _e('View Receipt', 'charitable'); ?> </a></td> </tr> <?php } ?> </tbody> </table>
/** * Checks whether the set amount is valid. * * @return boolean * @access public * @since 1.4.6 */ public function validate_amount() { $ret = true; /* Ensure that a valid amount has been submitted. */ if (self::get_donation_amount() <= 0 && !apply_filters('charitable_permit_0_donation', false)) { charitable_get_notices()->add_error(sprintf(__('You must donate more than %s.', 'charitable'), charitable_format_money('0'))); $ret = false; } return apply_filters('charitable_validate_donation_form_submission_amount_check', $ret, $this); }
$campaign = charitable_get_current_campaign(); ?> <ul class="campaign-stats"> <li class="campaign-raised"> <span><?php echo charitable_format_money($campaign->get_donated_amount()); ?> </span> <?php _e('Pledged', 'reach'); ?> </li> <li class="campaign-goal"> <span><?php echo charitable_format_money($campaign->get_goal()); ?> </span> <?php _e('Goal', 'reach'); ?> </li> <li class="campaign-backers"> <span><?php echo $campaign->get_donor_count(); ?> </span> <?php _e('Donors', 'reach'); ?>
/** * Loads public facing scripts and stylesheets. * * @return void * @access public * @since 1.0.0 */ public function setup_scripts() { if (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) { $suffix = ''; $version = ''; } else { $suffix = '.min'; $version = charitable()->get_version(); } $assets_dir = charitable()->get_path('assets', false); /* Main Charitable script. */ $vars = apply_filters('charitable_javascript_vars', array('ajaxurl' => admin_url('admin-ajax.php'), 'loading_gif' => $assets_dir . '/images/charitable-loading.gif', 'currency_format_num_decimals' => esc_attr(charitable_get_option('decimal_count', 2)), 'currency_format_decimal_sep' => esc_attr(charitable_get_option('decimal_separator', '.')), 'currency_format_thousand_sep' => esc_attr(charitable_get_option('thousands_separator', ',')), 'currency_format' => esc_attr(charitable_get_currency_helper()->get_accounting_js_format()), 'error_invalid_amount' => sprintf(__('You must donate more than %s.', 'charitable'), charitable_format_money('0')), 'error_required_fields' => __('Please fill out all required fields.', 'charitable'), 'error_unknown' => __('Your donation could not be processed. Please reload the page and try again.', 'charitable'), 'error_invalid_cc_number' => __('The credit card passed is not valid.', 'charitable'), 'error_invalid_cc_expiry' => __('The credit card expiry date is not valid.', 'charitable'))); /* Accounting.js */ wp_register_script('accounting', $assets_dir . 'js/libraries/accounting' . $suffix . '.js', array('jquery-core'), $version, true); wp_register_script('charitable-script', $assets_dir . 'js/charitable' . $suffix . '.js', array('accounting', 'jquery-core'), $version, true); wp_localize_script('charitable-script', 'CHARITABLE_VARS', $vars); /* Credit card validation */ wp_register_script('charitable-credit-card', $assets_dir . 'js/charitable-credit-card' . $suffix . '.js', array('charitable-script'), $version, true); /* Enqueue credit card & /* Main styles */ wp_register_style('charitable-styles', $assets_dir . 'css/charitable' . $suffix . '.css', array(), $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', $assets_dir . 'js/libraries/leanModal' . $suffix . '.js', array('jquery-core'), $version); wp_register_style('lean-modal-css', $assets_dir . 'css/modal' . $suffix . '.css', array(), $version); } /* pupload Fields is also registered but NOT enqueued. */ $upload_vars = array('remove_image' => _x('Remove', 'remove image button text', 'charitable'), 'max_file_uploads_single' => __('You can only upload %d file', 'charitable'), 'max_file_uploads_plural' => __('You can only upload a maximum of %d files', 'charitable'), 'max_file_size' => __('%1$s exceeds the max upload size of %2$s', 'charitable'), 'upload_problem' => __('%s failed to upload. Please try again.', 'charitable')); wp_register_script('charitable-plup-fields', $assets_dir . 'js/charitable-plupload-fields' . $suffix . '.js', array('jquery-ui-sortable', 'wp-ajax-response', 'plupload-all'), $version, true); wp_localize_script('charitable-plup-fields', 'CHARITABLE_UPLOAD_VARS', $upload_vars); wp_register_style('charitable-plup-styles', $assets_dir . 'css/charitable-plupload-fields' . $suffix . '.css', array(), $version); }
"> <input id="<?php echo $field_id; ?> " type="radio" name="donation_amount" value="<?php echo $suggestion['amount']; ?> " <?php echo $checked; ?> /><?php printf('<span class="amount">%s</span> <span class="description">%s</span>', charitable_format_money($suggestion['amount']), isset($suggestion['description']) ? $suggestion['description'] : ''); ?> </label> </li> <?php } ?> <?php if ($campaign->get('allow_custom_donations')) { $has_custom_donation_amount = !$amount_is_suggestion && $amount; ?> <li class="donation-amount custom-donation-amount"> <label for="form-<?php
<?php /** * Renders the campaign goal block in the settings metabox for the Campaign post type. * * @author Studio 164a * @since 1.0.0 */ global $post; $title = isset($view_args['title']) ? $view_args['title'] : ''; $tooltip = isset($view_args['tooltip']) ? '<span class="tooltip"> ' . $view_args['tooltip'] . '</span>' : ''; $description = isset($view_args['description']) ? '<span class="charitable-helper">' . $view_args['description'] . '</span>' : ''; $goal = get_post_meta($post->ID, '_campaign_goal', true); $goal = !$goal ? '' : charitable_format_money($goal); ?> <div id="charitable-campaign-goal-metabox-wrap" class="charitable-metabox-wrap"> <label class="screen-reader-text" for="campaign_goal"><?php echo $title; ?> </label> <input type="text" id="campaign_goal" name="_campaign_goal" placeholder="∞" value="<?php echo $goal; ?> " /> <?php echo $description; ?> </div>
?> </span> </li> <li class="donation-date"> <?php _e('Date:', 'charitable'); ?> <span class="donation-summary-value"><?php echo $donation->get_date(); ?> </span> </li> <li class="donation-total"> <?php _e('Total:', 'charitable'); ?> <span class="donation-summary-value"><?php echo charitable_format_money($donation->get_total_donation_amount()); ?> </span> </li> <li class="donation-method"> <?php _e('Payment Method:', 'charitable'); ?> <span class="donation-summary-value"><?php echo $donation->get_gateway_label(); ?> </span> </li> </ul>
} if ($view_args['show_location'] && strlen($donor->get_location())) { ?> <div class="donor-location"><?php echo $donor->get_location(); ?> </div> <?php } if ($view_args['show_amount']) { ?> <div class="donor-donation-amount"><?php echo charitable_format_money($donor->get_amount($campaign_id)); ?> </div> <?php } ?> </li> <?php } ?> </ol>
/** * Add information to the dashboard donations table listing. * * @see WP_Posts_List_Table::single_row() * * @param string $column_name The name of the column to display. * @param int $post_id The current post ID. * @return void * @access public * @since 1.0.0 */ public function dashboard_column_item($column_name, $post_id) { $donation = $this->get_donation($post_id); switch ($column_name) { case 'id': $display = $donation->get_number(); break; case 'donor': $display = $donation->get_donor()->get_name(); break; case 'details': $display = sprintf('<a href="%s">%s</a>', esc_url(add_query_arg(array('post' => $donation->ID, 'action' => 'edit'), admin_url('post.php'))), __('View Donation Details', 'charitable')); break; case 'amount': $display = charitable_format_money($donation->get_total_donation_amount()); break; case 'campaigns': $display = implode(', ', $donation->get_campaigns()); break; case 'donation_date': $display = $donation->get_date(); break; case 'status': $display = $donation->get_status(true); break; default: $display = ''; break; } echo apply_filters('charitable_donation_column_display', $display, $column_name, $post_id, $donation); }
/** * Add information to the dashboard donations table listing. * * @see WP_Posts_List_Table::single_row() * * @param string $column_name The name of the column to display. * @param int $post_id The current post ID. * @return void * @access public * @since 1.0.0 */ public function dashboard_column_item($column_name, $post_id) { $donation = charitable_get_donation($post_id); switch ($column_name) { case 'id': $title = esc_attr__('View Donation Details', 'charitable'); $name = $donation->get_donor()->get_name(); if ($name) { $text = sprintf(_x('#%d by %s', 'number symbol', 'charitable'), $post_id, $name); } else { $text = sprintf(_x('#%d', 'number symbol', 'charitable'), $post_id); } $url = esc_url(add_query_arg(array('post' => $post_id, 'action' => 'edit'), admin_url('post.php'))); $display = sprintf('<a href="%s" title="%s">%s</a>', $url, $title, $text); break; case 'post_status': $display = sprintf('<mark class="status %s">%s</mark>', esc_attr($donation->get_status()), strtolower($donation->get_status(true))); break; case 'amount': $display = charitable_format_money($donation->get_total_donation_amount()); $display .= '<span class="meta">' . sprintf(_x('via %s', 'charitable'), $donation->get_gateway_label()) . '</span>'; break; case 'campaigns': $campaigns = array(); foreach ($donation->get_campaign_donations() as $cd) { $campaigns[] = sprintf('<a href="edit.php?post_type=%s&campaign_id=%s">%s</a>', Charitable::DONATION_POST_TYPE, $cd->campaign_id, $cd->campaign_name); } $display = implode(', ', $campaigns); break; case 'donation_date': $display = $donation->get_date(); break; default: $display = ''; break; } echo apply_filters('charitable_donation_column_display', $display, $column_name, $post_id, $donation); }
* @since 1.0.0 */ $widget_title = apply_filters('widget_title', $view_args['title']); $campaigns_count = Charitable_Campaigns::query(array('posts_per_page' => -1, 'fields' => 'ids'))->found_posts; $campaigns_text = $campaigns_count == 1 ? __('Campaign', 'charitable') : __('Campaigns', 'charitable'); echo $view_args['before_widget']; if (!empty($widget_title)) { echo $view_args['before_title'] . $widget_title . $view_args['after_title']; } ?> <ul class="donation-stats"> <li> <?php printf('<span class="figure">%d</span> %s', $campaigns_count, $campaigns_text); ?> </li> <li> <?php printf('<span class="figure">%s</span> %s', charitable_format_money(charitable_get_table('campaign_donations')->get_total(), 0), __('Donated', 'charitable')); ?> </li> <li> <?php printf('<span class="figure">%d</span> %s', charitable_get_table('donors')->count_donors_with_donations(), __('Donors', 'charitable')); ?> </li> </ul> <?php echo $view_args['after_widget'];
/** * Return the contribution as a nicely formatted amount. * * @return string * @access public * @since 1.0.0 */ public function get_contribution_amount() { if ($this->benefactor->contribution_amount_is_percentage) { $amount = apply_filters('charitable_benefactor_contribution_amount_percentage', $this->benefactor->contribution_amount . '%', $this->benefactor->contribution_amount, $this); } else { $amount = apply_filters('charitable_benefactor_contribution_amount_fixed', charitable_format_money($this->benefactor->contribution_amount), $this->benefactor->contribution_amount, $this); } return $amount; }