function dgx_donate_queue_scripts() { $load_in_footer = 'true' == get_option('dgx_donate_scripts_in_footer'); $script_url = plugin_dir_url(dirname(__FILE__)) . 'js/script.js'; wp_enqueue_script('dgx_donate_script', $script_url, array('jquery'), false, $load_in_footer); $script_url = plugins_url('/js/geo-selects.js', __FILE__); wp_enqueue_script('dgx_donate_geo_selects_script', $script_url, array('jquery'), false, $load_in_footer); // declare the URL to the file that handles the AJAX request (wp-admin/admin-ajax.php) wp_localize_script('dgx_donate_script', 'dgxDonateAjax', array('ajaxurl' => admin_url('admin-ajax.php'), 'nonce' => wp_create_nonce('dgx-donate-nonce'), 'postalCodeRequired' => dgx_donate_get_countries_requiring_postal_code())); }
function seamless_donations_enqueue_scripts() { wp_enqueue_script('jquery'); $script_url = plugins_url('/js/seamless-donations.js', __FILE__); // wp_register_script ( 'seamless_javascript_code', $script_url, array( 'jquery' ), false ); wp_enqueue_script('seamless_javascript_code', $script_url, array('jquery')); // declare the URL to the file that handles the AJAX request (wp-admin/admin-ajax.php) wp_localize_script('seamless_javascript_code', 'dgxDonateAjax', array('ajaxurl' => admin_url('admin-ajax.php'), 'nonce' => wp_create_nonce('dgx-donate-nonce'), 'postalCodeRequired' => dgx_donate_get_countries_requiring_postal_code())); }
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; }
function dgx_donate_country_requires_postal_code($country_code) { return in_array($country_code, dgx_donate_get_countries_requiring_postal_code()); }