/**
  * 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), 'login_page' => array('title' => __('Login Page', 'charitable'), 'type' => 'select', 'priority' => 32, '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' => 34, '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')), 'profile_page' => array('title' => __('Profile Page', 'charitable'), 'type' => 'select', 'priority' => 36, 'options' => charitable_get_admin_settings()->get_pages(), 'help' => __('The static page should contain the <code>[charitable_profile]</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;
 }
 function test_charitable_get_location_helper()
 {
     $this->assertInstanceOf('Charitable_Locations', charitable_get_location_helper());
 }
 /**
  * Returns printable address of donor.
  *
  * @param   $donation_id Optional. If set, will return the address provided for the specific donation. Otherwise, returns the current address for the user.
  * @return  string
  * @access  public
  * @since   1.0.0
  */
 public function get_address($donation_id = '')
 {
     $address_fields = false;
     if ($donation_id) {
         $address_fields = get_post_meta($donation_id, 'donor', true);
     }
     /* If the address fields were not set by the check above, get them from the user meta. */
     if (!is_array($address_fields)) {
         $address_fields = array('first_name' => $this->get('first_name'), 'last_name' => $this->get('last_name'), 'company' => $this->get('donor_company'), 'address' => $this->get('donor_address'), 'address_2' => $this->get('donor_address_2'), 'city' => $this->get('donor_city'), 'state' => $this->get('donor_state'), 'postcode' => $this->get('donor_postcode'), 'country' => $this->get('donor_country'));
     }
     $address_fields = apply_filters('charitable_user_address_fields', $address_fields, $this, $donation_id);
     return charitable_get_location_helper()->get_formatted_address($address_fields);
 }
Example #4
0
 function test_get_formatted_address()
 {
     add_option('charitable_default_country', 'AU');
     $address_fields = array('first_name' => 'James', 'last_name' => 'Gordon', 'company' => 'Gotham City Police Department', 'address' => 'Unit 3', 'address_2' => '22 Batman Avenue', 'city' => 'Gotham', 'postcode' => '29292', 'state' => 'Gotham State', 'country' => 'US');
     // "{name}\n{company}\n{address_1}\n{address_2}\n{city}, {state_code} {postcode}\n{country}"
     $expected = "James Gordon<br/>Gotham City Police Department<br/>Unit 3<br/>22 Batman Avenue<br/>Gotham, GOTHAM STATE 29292<br/>United States (US)";
     $this->assertEquals($expected, charitable_get_location_helper()->get_formatted_address($address_fields));
     // Second address. Within country, with state code.
     $address_fields = array('first_name' => 'Jack', 'last_name' => 'Daniels', 'company' => 'Jack Daniel\'s Tennessee Whiskey', 'address' => '299 Smith Street', 'address_2' => '', 'city' => 'Darwin', 'postcode' => '0800', 'state' => 'NT', 'country' => 'AU');
     // "{name}\n{company}\n{address_1}\n{address_2}\n{city} {state} {postcode}",
     $expected = "Jack Daniels<br/>Jack Daniel&#039;s Tennessee Whiskey<br/>299 Smith Street<br/>Darwin Northern Territory 0800";
     $this->assertEquals($expected, charitable_get_location_helper()->get_formatted_address($address_fields));
 }
 /**
  * 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;
 }
 /**
  * Returns the fields related to the person making the donation. 
  *
  * @return  array
  * @access  public
  * @since   1.0.0
  */
 public function get_user_fields()
 {
     $user_fields = apply_filters('charitable_donation_form_user_fields', array('first_name' => array('label' => __('First name', 'charitable'), 'type' => 'text', 'priority' => 4, 'value' => $this->get_user_value('first_name'), 'required' => true, 'requires_registration' => false, 'data_type' => 'user'), 'last_name' => array('label' => __('Last name', 'charitable'), 'type' => 'text', 'priority' => 6, 'value' => $this->get_user_value('last_name'), 'required' => true, 'requires_registration' => false, 'data_type' => 'user'), 'email' => array('label' => __('Email', 'charitable'), 'type' => 'email', 'required' => true, 'priority' => 8, 'value' => $this->get_user_value('user_email'), 'requires_registration' => false, 'data_type' => 'user'), 'address' => array('label' => __('Address', 'charitable'), 'type' => 'text', 'priority' => 10, 'value' => $this->get_user_value('donor_address'), 'required' => false, 'requires_registration' => true, 'data_type' => 'user'), 'address_2' => array('label' => __('Address 2', 'charitable'), 'type' => 'text', 'priority' => 12, 'value' => $this->get_user_value('donor_address_2'), 'required' => false, 'requires_registration' => true, 'data_type' => 'user'), 'city' => array('label' => __('City', 'charitable'), 'type' => 'text', 'priority' => 14, 'value' => $this->get_user_value('donor_city'), 'required' => false, 'requires_registration' => true, 'data_type' => 'user'), 'state' => array('label' => __('State', 'charitable'), 'type' => 'text', 'priority' => 16, 'value' => $this->get_user_value('donor_state'), 'required' => false, 'requires_registration' => true, 'data_type' => 'user'), 'postcode' => array('label' => __('Postcode / ZIP code', 'charitable'), 'type' => 'text', 'priority' => 18, 'value' => $this->get_user_value('donor_postcode'), 'required' => false, 'requires_registration' => true, 'data_type' => 'user'), 'country' => array('label' => __('Country', 'charitable'), 'type' => 'select', 'options' => charitable_get_location_helper()->get_countries(), 'priority' => 20, 'value' => $this->get_user_value('donor_country', charitable_get_option('country')), 'required' => false, 'requires_registration' => true, 'data_type' => 'user'), 'phone' => array('label' => __('Phone', 'charitable'), 'type' => 'text', 'priority' => 22, 'value' => $this->get_user_value('donor_phone'), 'required' => false, 'requires_registration' => true, 'data_type' => 'user')), $this);
     uasort($user_fields, 'charitable_priority_sort');
     return $user_fields;
 }
 /**
  * Returns printable address of donor. 
  *
  * @param   $donation_id Optional. If set, will return the address provided for the specific donation. Otherwise, returns the current address for the user. 
  * @return  string
  * @access  public
  * @since   1.0.0
  */
 public function get_address($donation_id = "")
 {
     if ($donation_id) {
         $address_fields = get_post_meta($donation_id, 'donor', true);
     } else {
         $address_fields = array('first_name' => $this->get('first_name'), 'last_name' => $this->get('last_name'), 'company' => $this->get('donor_company'), 'address' => $this->get('donor_address'), 'address_2' => $this->get('donor_address_2'), 'city' => $this->get('donor_city'), 'state' => $this->get('donor_state'), 'postcode' => $this->get('donor_postcode'), 'country' => $this->get('donor_country'));
     }
     $address_fields = apply_filters('charitable_user_address_fields', $address_fields, $this, $donation_id);
     return charitable_get_location_helper()->get_formatted_address($address_fields);
 }
 /**
  * Add donation content fields' fake data for previews.
  *
  * @param   array $fields
  * @param   Charitable_Email $email
  * @return  array
  * @access  public
  * @since   1.0.0
  */
 public function add_preview_donation_content_fields($fields, Charitable_Email $email)
 {
     if (!$this->is_current_email($email)) {
         return $fields;
     }
     if (!in_array('donation', $this->object_types)) {
         return $fields;
     }
     $fields['donor'] = 'John Deere';
     $fields['donor_first_name'] = 'John';
     $fields['donor_email'] = '*****@*****.**';
     $fields['donor_address'] = charitable_get_location_helper()->get_formatted_address(array('first_name' => 'John', 'last_name' => 'Deere', 'company' => 'Deere & Company', 'address' => 'One John Deere Place', 'city' => 'Moline', 'state' => 'Illinois', 'postcode' => '61265', 'country' => 'US'));
     // Yes, this is in fact the address of John Deere headquarters :)
     $fields['donor_phone'] = '1300 000 000';
     $fields['donation_id'] = 164;
     $fields['donation_summary'] = __('Fake Campaign: $50.00', 'charitable') . PHP_EOL;
     $fields['donation_date'] = date_i18n(get_option('date_format'));
     $fields['donation_status'] = __('Paid', 'charitable');
     return $fields;
 }
Example #9
0
 /**
  * @deprecated
  */
 public function get_location_helper()
 {
     charitable_get_deprecated()->deprecated_function(__METHOD__, '1.2.0', 'charitable_get_location_helper');
     return charitable_get_location_helper();
 }
Example #10
0
 /**
  * @deprecated
  */
 public function get_location_helper()
 {
     return charitable_get_location_helper();
 }