Ejemplo n.º 1
0
 function setUp()
 {
     parent::setUp();
     $this->charitable = charitable();
     $this->directory_path = $this->charitable->get_path('directory');
     $this->directory_url = $this->charitable->get_path('directory', false);
 }
Ejemplo n.º 2
0
 function setUp()
 {
     parent::setUp();
     $this->charitable = charitable();
     $this->roles = new Charitable_Roles($this->charitable);
     $this->roles->add_roles();
     $this->roles->add_caps();
 }
 /**
  * Enqueue script.
  *
  * @return  void
  * @access  public
  * @since   1.2.0
  */
 public function register_script()
 {
     $screen = get_current_screen();
     if ('campaign' == $screen->id) {
         $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
         wp_register_script('charitable-benefactors-js', charitable()->get_path('assets', false) . 'js/charitable-admin-benefactors.' . $suffix . 'js', array('charitable-admin'), charitable()->get_version(), false);
         wp_enqueue_script('charitable-benefactors-js');
     }
 }
 /**
  * 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');
     }
 }
 /**
  * Add the general tab settings fields. 
  *
  * @param   array[] $fields
  * @return  array[]
  * @access  public
  * @since   1.0.0
  */
 public function add_general_fields($fields = array())
 {
     if (!charitable_is_settings_view('general')) {
         return array();
     }
     $general_fields = array('section' => array('title' => '', 'type' => 'hidden', 'priority' => 10000, 'value' => 'general'), 'section_locale' => array('title' => __('Currency & Location', 'charitable'), 'type' => 'heading', 'priority' => 2), 'country' => array('title' => __('Base Country', 'charitable'), 'type' => 'select', 'priority' => 4, 'default' => 'AU', 'options' => charitable()->get_location_helper()->get_countries()), 'currency' => array('title' => __('Currency', 'charitable'), 'type' => 'select', 'priority' => 10, 'default' => 'AUD', 'options' => charitable()->get_currency_helper()->get_all_currencies()), 'currency_format' => array('title' => __('Currency Format', 'charitable'), 'type' => 'select', 'priority' => 12, 'default' => 'left', 'options' => array('left' => '$23.00', 'right' => '23.00$', 'left-with-space' => '$ 23.00', 'right-with-space' => '23.00 $')), 'decimal_separator' => array('title' => __('Decimal Separator', 'charitable'), 'type' => 'select', 'priority' => 14, 'default' => '.', 'options' => array('.' => 'Period (12.50)', ',' => 'Comma (12,50)')), 'thousands_separator' => array('title' => __('Thousands Separator', 'charitable'), 'type' => 'select', 'priority' => 16, 'default' => ',', 'options' => array(',' => __('Comma (10,000)', 'charitable'), '.' => __('Period (10.000)', 'charitable'), '' => __('None', 'charitable'))), 'decimal_count' => array('title' => __('Number of Decimals', 'charitable'), 'type' => 'number', 'priority' => 18, 'default' => 2, 'class' => 'short'), 'section_donation_form' => array('title' => __('Donation Form', 'charitable'), 'type' => 'heading', 'priority' => 20), 'donation_form_display' => array('title' => __('Display Options', 'charitable'), 'type' => 'select', 'priority' => 22, 'default' => 'separate_page', 'options' => array('separate_page' => __('Show on a Separate Page', 'charitable'), 'same_page' => __('Show on the Same Page', 'charitable'), 'modal' => __('Reveal in a Modal', 'charitable')), 'help' => __('Choose how you want a campaign\'s donation form to show.', 'charitable')), 'section_pages' => array('title' => __('Pages', 'charitable'), 'type' => 'heading', 'priority' => 30), 'profile_page' => array('title' => __('Profile Page', 'charitable'), 'type' => 'select', 'priority' => 34, 'options' => charitable_get_admin_settings()->get_pages(), 'help' => __('The static page should contain the <code>[charitable_profile]</code> shortcode.', 'charitable')), 'login_page' => array('title' => __('Login Page', 'charitable'), 'type' => 'select', 'priority' => 34, 'default' => 'wp', 'options' => array('wp' => __('Use WordPress Login', 'charitable'), 'pages' => array('options' => charitable_get_admin_settings()->get_pages(), 'label' => __('Choose a Static Page', 'charitable'))), 'help' => __('Allow users to login via the normal WordPress login page or via a static page. The static page should contain the <code>[charitable_login]</code> shortcode.', 'charitable')), 'registration_page' => array('title' => __('Registration Page', 'charitable'), 'type' => 'select', 'priority' => 36, 'default' => 'wp', 'options' => array('wp' => __('Use WordPress Registration Page', 'charitable'), 'pages' => array('options' => charitable_get_admin_settings()->get_pages(), 'label' => __('Choose a Static Page', 'charitable'))), 'help' => __('Allow users to register via the default WordPress login or via a static page. The static page should contain the <code>[charitable_registration]</code> shortcode.', 'charitable')), 'donation_receipt_page' => array('title' => __('Donation Receipt Page', 'charitable'), 'type' => 'select', 'priority' => 38, 'default' => 'auto', 'options' => array('auto' => __('Automatic', 'charitable'), 'pages' => array('options' => charitable_get_admin_settings()->get_pages(), 'label' => __('Choose a Static Page', 'charitable'))), 'help' => __('Choose the page that users will be redirected to after donating. Leave it set to automatic to use the built-in Charitable receipt. If you choose a static page, it should contain the <code>[donation_receipt]</code> shortcode.', 'charitable')));
     $fields = array_merge($fields, $general_fields);
     return $fields;
 }
/**
 * Load a view from the admin/views folder.
 *
 * If the view is not found, an Exception will be thrown.
 *
 * Example usage: charitable_admin_view('metaboxes/cause-metabox');
 *
 * @param 	string      $view           The view to display.
 * @param 	array 		$view_args 		Optional. Arguments to pass through to the view itself
 * @return 	void
 * @since 	1.0.0
 */
function charitable_admin_view($view, $view_args = array())
{
    $filename = apply_filters('charitable_admin_view_path', charitable()->get_path('admin') . 'views/' . $view . '.php', $view, $view_args);
    if (!is_readable($filename)) {
        _doing_it_wrong(__FUNCTION__, __('Passed view (' . $filename . ') not found or is not readable.', 'charitable'), '1.0.0');
    }
    ob_start();
    include $filename;
    ob_end_flush();
}
Ejemplo n.º 7
0
 function setUp()
 {
     parent::setUp();
     $this->charitable = charitable();
     $this->currency_helper = $this->charitable->get_currency_helper();
     $this->set_currency_format('left');
     $this->set_currency('AUD');
     $this->set_decimal_count(2);
     $this->set_decimal_separator('.');
     $this->set_thousands_separator(',');
 }
/**
 * Returns the given donation.
 *
 * This will first attempt to retrieve it from the object cache to prevent duplicate objects.
 *
 * @param   int     $donation_id
 * @param   boolean $force
 * @return  Charitable_Donation
 * @since   1.0.0
 */
function charitable_get_donation($donation_id, $force = false)
{
    if (!did_action('charitable_start') && false === (defined('DOING_AJAX') && DOING_AJAX)) {
        charitable_get_deprecated()->doing_it_wrong(__FUNCTION__, __('charitable_get_donation should not be called before the charitable_start action.', 'charitable'), '1.0.0');
        return false;
    }
    $donation = wp_cache_get($donation_id, 'charitable_donation', $force);
    if (!$donation) {
        $donation = charitable()->donation_factory->get_donation($donation_id);
        wp_cache_set($donation_id, $donation, 'charitable_donation');
    }
    return $donation;
}
Ejemplo n.º 9
0
 /**
  * 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());
     }
 }
 /**
  * Returns the donation form content for a particular campaign, through AJAX.
  *
  * @return  void
  * @since   1.2.3
  */
 function charitable_ajax_get_donation_form()
 {
     if (!isset($_POST['campaign_id'])) {
         wp_send_json_error();
     }
     /* Load the template files. */
     require_once charitable()->get_path('includes') . 'public/charitable-template-functions.php';
     require_once charitable()->get_path('includes') . 'public/charitable-template-hooks.php';
     $campaign = new Charitable_Campaign($_POST['campaign_id']);
     ob_start();
     $campaign->get_donation_form()->render();
     $output = ob_get_clean();
     wp_send_json_success($output);
     die;
 }
        /**
         * Print the widget contents. 
         *
         * @return  void
         * @access  public
         * @static
         * @since   1.2.0
         */
        public static function display()
        {
            ?>
        
        <p class="hide-if-no-js">
            <img src="<?php 
            echo charitable()->get_path('assets', false);
            ?>
/images/charitable-loading.gif" width="60" height="60" alt="<?php 
            esc_attr_e('Loading&hellip;', 'charitable');
            ?>
" />
        </p>
<?php 
        }
 /**
  * Instantiate session object. Private constructor.
  *
  * @access 	private
  * @since 	1.0.0
  */
 private function __construct()
 {
     if (!defined('WP_SESSION_COOKIE')) {
         define('WP_SESSION_COOKIE', 'charitable_session');
     }
     if (!class_exists('Recursive_ArrayAccess')) {
         require_once charitable()->get_path('includes') . 'libraries/wp-session/class-recursive-arrayaccess.php';
     }
     if (!class_exists('WP_Session')) {
         require_once charitable()->get_path('includes') . 'libraries/wp-session/class-wp-session.php';
         require_once charitable()->get_path('includes') . 'libraries/wp-session/wp-session.php';
     }
     /* Set the expiration length & variant of the session */
     add_filter('wp_session_expiration', array($this, 'set_session_length'), 99999);
     add_filter('wp_session_expiration_variant', array($this, 'set_session_expiration_variant_length'), 99999);
     $this->session = WP_Session::get_instance();
 }
 /**
  * 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()->get_currency_helper()->get_monetary_amount($this->benefactor->contribution_amount), $this->benefactor->contribution_amount, $this);
     }
     return $amount;
 }
Ejemplo n.º 14
0
        <div class="upgrade">
            <h2><?php 
_e('Upgrade for a price you can afford', 'charitable');
?>
</h2>
            <p><?php 
_e('With Charitable, <strong>you choose how much you pay</strong> to upgrade. Why? Because we think that every great organization deserves awesome fundraising software, regardless of the size of its budget.', 'charitable');
?>
</p>
            <p><a href="https://www.wpcharitable.com/packages/?utm_source=welcome-page&amp;utm_medium=wordpress-dashboard&amp;utm_campaign=pwyw-packages" class="button-primary">Unlock more features</a></p>
        </div>
    </div>
    <div class="column-right">
        <div class="column-inside">            
            <img src="<?php 
echo charitable()->get_path('assets', false);
?>
images/reach-mockup.png" alt="<?php 
_e('Screenshot of Reach, a WordPress fundraising theme designed to complement Charitable', 'charitable');
?>
" title="<?php 
_e('Reach is a WordPress fundraising theme designed to complement Charitable', 'charitable');
?>
" style="margin-bottom: 21px;" width="336" height="166" />
            <h2><?php 
_e('Try Reach, a free theme designed for fundraising', 'charitable');
?>
</h2>
            <p><?php 
_e('We built Reach to help non-profits &amp; social entrepreneurs run beautiful online fundraising campaigns. Whether you’re creating a website for your organization’s peer-to-peer fundraising event or building an online crowdfunding platform, Reach is the perfect starting point.', 'charitable');
?>
 /**
  * Return the base template path.
  *
  * @return  string
  * @access  public
  * @since   1.0.0
  */
 public function get_base_template_path()
 {
     return charitable()->get_path('templates');
 }
Ejemplo n.º 16
0
 * @version 1.0.0
 */
if (!defined('ABSPATH')) {
    exit;
}
// Exit if accessed directly
if (!isset($view_args['form'])) {
    return;
}
/**
 * @var Charitable_Donation_Form
 */
$form = $view_args['form'];
$campaign = $form->get_campaign();
$suggested_donations = $campaign->get_suggested_donations();
$currency_helper = charitable()->get_currency_helper();
$donation_amount = $campaign->get_donation_amount_in_session();
if (empty($suggested_donations) && !$campaign->get('allow_custom_donations')) {
    return;
}
/**
 * @hook    charitable_donation_form_before_donation_amount
 */
do_action('charitable_donation_form_before_donation_amount', $view_args['form']);
if ($donation_amount) {
    ?>
    
    <p class="set-donation-amount"><?php 
    printf('%s: <strong>%s</strong>', __('Your Donation Amount', 'charitable'), $currency_helper->get_monetary_amount($donation_amount));
    ?>
        <a href="#" class="change-donation" data-charitable-toggle="charitable-donation-options-<?php 
Ejemplo n.º 17
0
 /**
  * Add Extensions link to the plugin row meta. 
  *
  * @param   string[] $links
  * @param   string $file        The plugin file 
  * @return  string[] $links
  * @access  public
  * @since   1.2.0
  */
 public function add_plugin_row_meta($links, $file)
 {
     if (plugin_basename(charitable()->get_path()) != $file) {
         return $links;
     }
     $extensions_link = esc_url(add_query_arg(array('utm_source' => 'plugins-page', 'utm_medium' => 'plugin-row', 'utm_campaign' => 'admin'), 'https://wpcharitable.com/extensions/'));
     $links[] = '<a href="' . $extensions_link . '">' . __('Extensions', 'charitable') . '</a>';
     return $links;
 }
 /**
  * Load the theme-customizer.js file.
  *
  * @return  void
  * @access  public
  * @since   1.2.0
  */
 public function load_customizer_script()
 {
     $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
     wp_register_script('charitable-customizer', charitable()->get_path('assets', false) . 'js/charitable-customizer' . $suffix . '.js', array('jquery-core', 'customize-preview'), '1.2.0-beta5', true);
     wp_enqueue_script('charitable-customizer');
 }
Ejemplo n.º 19
0
$_tests_dir = getenv('WP_TESTS_DIR');
// Look for a wordpress-tests-lib directory on the same level as the WordPress installation.
if (!$_tests_dir) {
    $_tests_dir = '/tmp/wordpress-tests-lib';
}
if (!defined('COOKIE_DOMAIN')) {
    define('COOKIE_DOMAIN', false);
}
if (!defined('COOKIEPATH')) {
    define('COOKIEPATH', 'charitable.test');
}
require_once $_tests_dir . '/includes/functions.php';
function _manually_load_plugin()
{
    require dirname(__FILE__) . '/../charitable.php';
}
tests_add_filter('muplugins_loaded', '_manually_load_plugin');
require $_tests_dir . '/includes/bootstrap.php';
activate_plugin('charitable/charitable.php');
echo "Installing Charitable...\n";
// Install Charitable
charitable()->activate();
charitable()->charitable_install();
global $current_user;
$current_user = new WP_User(1);
$current_user->set_role('administrator');
require 'includes/charitable-testcase.php';
require 'helpers/charitable-campaign-helper.php';
require 'helpers/charitable-donation-helper.php';
require 'helpers/charitable-donor-helper.php';
Ejemplo n.º 20
0
<?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()->get_currency_helper()->get_monetary_amount($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="&#8734;" value="<?php 
echo $goal;
?>
" />
	<?php 
echo $description;
?>
</div>
 *
 * @see     Charitable_Admin::add_admin_body_class()
 */
add_filter('admin_body_class', array(Charitable_Admin::get_instance(), 'add_admin_body_class'));
/**
 * Remove jQuery UI styles added by Ninja Forms.
 *
 * @see     Charitable_Admin::remove_jquery_ui_styles_nf()
 */
add_filter('media_buttons_context', array(Charitable_Admin::get_instance(), 'remove_jquery_ui_styles_nf'), 20);
/**
 * Add action links to the Charitable plugin block.
 *
 * @see     Charitable_Admin::add_plugin_action_links()
 */
add_filter('plugin_action_links_' . plugin_basename(charitable()->get_path()), array(Charitable_Admin::get_instance(), 'add_plugin_action_links'));
/**
 * Add a link to the settings page from the Charitable plugin block.
 *
 * @see     Charitable_Admin::add_plugin_row_meta()
 */
add_filter('plugin_row_meta', array(Charitable_Admin::get_instance(), 'add_plugin_row_meta'), 10, 2);
/**
 * Export donations.
 *
 * @see     Charitable_Admin::export_donations()
 */
add_action('charitable_export_donations', array(Charitable_Admin::get_instance(), 'export_donations'));
/**
 * Add Charitable menu.
 *
Ejemplo n.º 22
0
<?php

/**
 * Display the donations page. 
 *
 * @author  Studio 164a
 * @package Charitable/Admin View/Settings
 * @since   1.0.0
 */
require_once charitable()->get_path('admin') . 'donations/class-charitable-donations-table.php';
$donation_post_type = get_post_type_object('donation');
$donations_table = new Charitable_Donations_Table();
$donations_table->prepare_items();
$start_date = isset($_GET['start-date']) ? sanitize_text_field($_GET['start-date']) : null;
$end_date = isset($_GET['end-date']) ? sanitize_text_field($_GET['end-date']) : null;
$status = isset($_GET['posts_status']) ? $_GET['posts_status'] : '';
ob_start();
?>
<div class="wrap">
    <h2><?php 
echo $donation_post_type->labels->menu_name;
?>
</h2>
    <?php 
do_action('charitable_donations_page_top');
?>
    <form id="charitable-donations" method="get" action="<?php 
echo admin_url('admin.php?page=charitable-donations-table');
?>
">
        <input type="hidden" name="page" value="charitable-donations-table" />
Ejemplo n.º 23
0
 function test_load_dependencies()
 {
     $this->assertFileExists(charitable()->get_path('public') . 'class-charitable-template.php');
     $this->assertFileExists(charitable()->get_path('public') . 'class-charitable-template-part.php');
     $this->assertFileExists(charitable()->get_path('public') . 'class-charitable-templates.php');
 }
Ejemplo n.º 24
0
foreach ($form->get_fields() as $key => $field) {
    do_action('charitable_form_field', $field, $key, $form, $i);
    $i += apply_filters('charitable_form_field_increment', 1, $field, $key, $form, $i);
}
?>
	
	</div>

	<?php 
/**
 * @hook    charitable_form_after_fields
 */
do_action('charitable_form_after_fields', $form);
?>
	<div class="charitable-form-field charitable-submit-field">
		<button class="button button-primary" type="submit" name="donate"><?php 
_e('Donate', 'charitable');
?>
</button>
		<div class="charitable-form-processing" style="display: none;">
			<img src="<?php 
echo esc_url(charitable()->get_path('assets', false));
?>
/images/charitable-loading.gif" width="60" height="60" alt="<?php 
esc_attr_e('Loading&hellip;', 'charitable');
?>
" />
		</div>
	</div>
</form>
Ejemplo n.º 25
0
<?php

$_tests_dir = getenv('WP_TESTS_DIR');
// Look for a wordpress-tests-lib directory on the same level as the WordPress installation.
if (!$_tests_dir) {
    $_tests_dir = '/tmp/wordpress-tests-lib';
}
if (!defined('COOKIE_DOMAIN')) {
    define('COOKIE_DOMAIN', false);
}
if (!defined('COOKIEPATH')) {
    define('COOKIEPATH', 'charitable.test');
}
require_once $_tests_dir . '/includes/functions.php';
function _manually_load_plugin()
{
    require dirname(__FILE__) . '/../charitable.php';
}
tests_add_filter('muplugins_loaded', '_manually_load_plugin');
require $_tests_dir . '/includes/bootstrap.php';
activate_plugin('charitable/charitable.php');
echo "Installing Charitable...\n";
// Install Charitable
charitable()->activate();
global $current_user;
$current_user = new WP_User(1);
$current_user->set_role('administrator');
require 'helpers/charitable-campaign-helper.php';
require 'helpers/charitable-donation-helper.php';
require 'helpers/charitable-donor-helper.php';
 /**
  * @covers charitable_get_template_path
  */
 public function test_get_template_path()
 {
     $expected = charitable()->get_path('templates', true) . 'campaign-loop.php';
     $this->assertEquals($expected, charitable_get_template_path('campaign-loop.php'));
 }
 /**
  * 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()->get_currency_helper()->get_monetary_amount($this->campaign->get_donated_amount());
 }
 /**
  * Export donations. 
  *
  * @return  void
  * @access  public
  * @since   1.3.0
  */
 public function export_donations()
 {
     if (!wp_verify_nonce($_GET['_charitable_export_nonce'], 'charitable_export_donations')) {
         return false;
     }
     require_once charitable()->get_path('admin') . 'reports/class-charitable-export-donations.php';
     $report_type = $_GET['report_type'];
     $export_args = apply_filters('charitable_donations_export_args', array('start_date' => $_GET['start_date'], 'end_date' => $_GET['end_date'], 'status' => $_GET['post_status'], 'campaign_id' => $_GET['campaign_id'], 'report_type' => $report_type));
     $export_class = apply_filters('charitable_donations_export_class', 'Charitable_Export_Donations', $report_type, $export_args);
     new $export_class($export_args);
     exit;
 }
 function test_charitable()
 {
     $this->assertInstanceOf('Charitable', charitable());
 }
/**
 * Returns the Charitable_Deprecated class, loading the file if required.
 *
 * @return 	Charitable_Deprecated
 * @since 	1.4.0
 */
function charitable_get_deprecated()
{
    if (!class_exists('Charitable_Deprecated')) {
        require_once charitable()->get_path('includes') . 'deprecated/class-charitable-deprecated.php';
    }
    return Charitable_Deprecated::get_instance();
}