Ejemplo n.º 1
0
function dgx_donate_get_state_selector($select_name, $select_initial_value)
{
    $output = "<select class='dgx_donate_state_select' id='" . esc_attr($select_name) . "' name='" . esc_attr($select_name) . "'>";
    $states = dgx_donate_get_states();
    foreach ($states as $state_abbr => $state_name) {
        $selected = "";
        if (strcasecmp($select_initial_value, $state_abbr) == 0) {
            $selected = " selected ";
        }
        $output .= "<option value='" . esc_attr($state_abbr) . "'" . esc_attr($selected) . ">" . esc_html($state_name) . "</option>";
    }
    $output .= "</select>";
    return $output;
}
Ejemplo n.º 2
0
function seamless_donations_get_billing_section()
{
    $show_address = get_option('dgx_donate_show_donor_address_fields');
    if ($show_address != 'true') {
        return array();
    }
    $default_country = get_option('dgx_donate_default_country');
    $countries_array = dgx_donate_get_countries();
    $states_array = dgx_donate_get_states();
    $provinces_array = dgx_donate_get_provinces();
    $postal_code_array = dgx_donate_get_countries_requiring_postal_code();
    $postal_code_reveal_array = array();
    for ($postal_code_index = 0; $postal_code_index < count($postal_code_array); ++$postal_code_index) {
        $postal_code_country = $postal_code_array[$postal_code_index];
        switch ($postal_code_country) {
            case 'US':
                $postal_code_reveal_array['US'] = 'conceal-donor-state conceal-donor-postcode';
                break;
            case 'CA':
                $postal_code_reveal_array['CA'] = 'conceal-donor-province conceal-donor-postcode';
                break;
            case 'GB':
                $postal_code_reveal_array['GB'] = 'gift-aid conceal-donor-postcode';
                break;
            default:
                $postal_code_reveal_array[$postal_code_country] = 'conceal-donor-postcode';
        }
    }
    $billing_section = array('id' => 'dgx-donate-form-billing-section', 'class' => 'dgx-donate-form-section', 'elements' => array('donation_header' => array('type' => 'static', 'before' => '<h2>', 'after' => '</h2>', 'value' => esc_html__('Donor Address', 'seamless-donations')), '_dgx_donate_donor_address' => array('type' => 'text', 'size' => 20, 'validation' => 'required', 'before' => esc_html__('Address: ', 'seamless-donations')), '_dgx_donate_donor_address2' => array('type' => 'text', 'size' => 20, 'before' => esc_html__('Address 2: ', 'seamless-donations'), 'after' => "<span class='dgx-donate-comment'>" . esc_html__('(optional)', 'seamless-donations') . "</span>"), '_dgx_donate_donor_city' => array('type' => 'text', 'size' => 20, 'validation' => 'required', 'before' => esc_html__('City: ', 'seamless-donations')), '_dgx_donate_donor_state' => array('type' => 'select', 'size' => 1, 'options' => $states_array, 'before' => esc_html__('State : ', 'seamless-donations')), '_dgx_donate_donor_province' => array('type' => 'select', 'size' => 1, 'options' => $provinces_array, 'before' => esc_html__('Province: ', 'seamless-donations')), '_dgx_donate_donor_country' => array('type' => 'select', 'conceal' => 'conceal-donor-state conceal-donor-postcode conceal-donor-province gift-aid', 'reveal' => $postal_code_reveal_array, 'options' => $countries_array, 'value' => $default_country, 'size' => 1, 'before' => esc_html__('Country: ', 'seamless-donations')), '_dgx_donate_donor_zip' => array('type' => 'text', 'size' => 10, 'before' => esc_html__('Postal Code: ', 'seamless-donations')), 'dgx_donate_uk_gift_aid' => array('type' => 'checkbox', 'prompt' => esc_html__("I am a UK taxpayer and my gift qualifies for Gift Aid.", 'seamless-donations'))));
    // since these fields are visible on page load, we need to make certain fields visible based on country
    // therefore, we don't want them cloaked, but we want them still interactive, so we'll put them in
    // class instead.
    switch ($default_country) {
        case 'US':
            $billing_section['elements']['_dgx_donate_donor_state']['class'] = 'conceal-donor-state';
            $billing_section['elements']['_dgx_donate_donor_province']['cloak'] = 'conceal-donor-province';
            $billing_section['elements']['_dgx_donate_donor_zip']['class'] = 'conceal-donor-postcode';
            $billing_section['elements']['dgx_donate_uk_gift_aid']['cloak'] = 'gift-aid';
            break;
        case 'CA':
            $billing_section['elements']['_dgx_donate_donor_state']['cloak'] = 'conceal-donor-state';
            $billing_section['elements']['_dgx_donate_donor_province']['class'] = 'conceal-donor-province';
            $billing_section['elements']['_dgx_donate_donor_zip']['class'] = 'conceal-donor-postcode';
            $billing_section['elements']['dgx_donate_uk_gift_aid']['cloak'] = 'gift-aid';
            break;
        case 'GB':
            $billing_section['elements']['_dgx_donate_donor_state']['cloak'] = 'conceal-donor-state';
            $billing_section['elements']['_dgx_donate_donor_province']['cloak'] = 'conceal-donor-province';
            $billing_section['elements']['_dgx_donate_donor_zip']['class'] = 'conceal-donor-postcode';
            $billing_section['elements']['dgx_donate_uk_gift_aid']['class'] = 'gift-aid';
            break;
        default:
            $billing_section['elements']['_dgx_donate_donor_state']['cloak'] = 'conceal-donor-state';
            $billing_section['elements']['_dgx_donate_donor_province']['cloak'] = 'conceal-donor-province';
            $billing_section['elements']['_dgx_donate_donor_zip']['cloak'] = 'conceal-donor-postcode';
            $billing_section['elements']['dgx_donate_uk_gift_aid']['cloak'] = 'gift-aid';
    }
    $billing_section = apply_filters('seamless_donations_form_billing_section', $billing_section);
    return $billing_section;
}