function validate_page_slug_seamless_donations_admin_forms_callback($_submitted_array, $_existing_array, $_setup_object) { $_submitted_array = apply_filters('validate_page_slug_seamless_donations_admin_forms_callback', $_submitted_array, $_existing_array, $_setup_object); $section = seamless_donations_get_submitted_admin_section($_submitted_array); switch ($section) { case 'seamless_donations_admin_forms_section_levels': // SAVE LEVELS // $none_enabled = true; $giving_levels = dgx_donate_get_giving_levels(); foreach ($giving_levels as $giving_level) { if ($_submitted_array[$section]['giving_levels'][$giving_level]) { dgx_donate_enable_giving_level($giving_level); $none_enabled = false; } else { dgx_donate_disable_giving_level($giving_level); } } if ($none_enabled) { $_aErrors[$section]['giving_levels'] = __('At least one giving level is required.', 'seamless-donations'); $_setup_object->setFieldErrors($_aErrors); $_setup_object->setSettingNotice(__('There were errors in your submission.', 'seamless-donations')); return $_existing_array; } $_setup_object->setSettingNotice('Form updated successfully.', 'updated'); break; case 'seamless_donations_admin_forms_section_defaults': // SAVE DEFAULTS // update_option('dgx_donate_currency', $_submitted_array[$section]['dgx_donate_currency']); update_option('dgx_donate_default_country', $_submitted_array[$section]['dgx_donate_default_country']); $_setup_object->setSettingNotice('Form updated successfully.', 'updated'); break; case 'seamless_donations_admin_forms_section_fields': // SAVE FIELDS // update_option('dgx_donate_show_designated_funds_section', $_submitted_array[$section]['dgx_donate_show_designated_funds_section']); update_option('dgx_donate_show_repeating_option', $_submitted_array[$section]['dgx_donate_show_repeating_option']); update_option('dgx_donate_show_tribute_section', $_submitted_array[$section]['dgx_donate_show_tribute_section']); update_option('dgx_donate_show_employer_section', $_submitted_array[$section]['dgx_donate_show_employer_section']); update_option('dgx_donate_show_donor_telephone_field', $_submitted_array[$section]['dgx_donate_show_donor_telephone_field']); update_option('dgx_donate_show_donor_employer_field', $_submitted_array[$section]['dgx_donate_show_donor_employer_field']); update_option('dgx_donate_show_donor_occupation_field', $_submitted_array[$section]['dgx_donate_show_donor_occupation_field']); update_option('dgx_donate_show_mailing_list_option', $_submitted_array[$section]['dgx_donate_show_mailing_list_option']); update_option('dgx_donate_show_anonymous_option', $_submitted_array[$section]['dgx_donate_show_anonymous_option']); update_option('dgx_donate_show_donor_address_fields', $_submitted_array[$section]['dgx_donate_show_donor_address_fields']); $_setup_object->setSettingNotice('Form updated successfully.', 'updated'); break; case 'seamless_donations_admin_forms_section_tweaks': // SAVE TWEAKS // update_option('dgx_donate_labels_for_input', $_submitted_array[$section]['dgx_donate_labels_for_input']); $_setup_object->setSettingNotice('Form updated successfully.', 'updated'); break; case 'seamless_donations_admin_forms_section_extension': // LET EXTENSIONS DO THE PROCESSING break; default: $_setup_object->setSettingNotice(__('There was an unexpected error in your entry.', 'seamless-donations')); } }
function seamless_donations_init_defaults() { // functionally identical to dgx_donate_init_defaults, but likely to change over time // Thank you email option defaults // validate name - replace with sanitized blog name if needed $from_name = get_option('dgx_donate_email_name'); if (empty($from_name)) { $from_name = get_bloginfo('name'); $from_name = preg_replace("/[^a-zA-Z ]+/", "", $from_name); // letters and spaces only please update_option('dgx_donate_email_name', $from_name); } // validate email - replace with admin email if needed $from_email = get_option('dgx_donate_email_reply'); if (empty($from_email) || !is_email($from_email)) { $from_email = get_option('admin_email'); update_option('dgx_donate_email_reply', $from_email); } $thankSubj = get_option('dgx_donate_email_subj'); if (empty($thankSubj)) { $thankSubj = "Thank you for your donation"; update_option('dgx_donate_email_subj', $thankSubj); } $bodyText = get_option('dgx_donate_email_body'); if (empty($bodyText)) { $bodyText = "Dear [firstname] [lastname],\n\n"; $bodyText .= "Thank you for your generous donation of [amount]. Please note that no goods "; $bodyText .= "or services were received in exchange for this donation."; update_option('dgx_donate_email_body', $bodyText); } $recurring_text = get_option('dgx_donate_email_recur'); if (empty($recurring_text)) { $recurring_text = __("Thank you for electing to have your donation automatically repeated each month.", 'seamless-donations'); update_option('dgx_donate_email_recur', $recurring_text); } $designatedText = get_option('dgx_donate_email_desig'); if (empty($designatedText)) { $designatedText = "Your donation has been designated to the [fund] fund."; update_option('dgx_donate_email_desig', $designatedText); } $anonymousText = get_option('dgx_donate_email_anon'); if (empty($anonymousText)) { $anonymousText = "You have requested that your donation be kept anonymous. Your name will not be revealed to the public."; update_option('dgx_donate_email_anon', $anonymousText); } $mailingListJoinText = get_option('dgx_donate_email_list'); if (empty($mailingListJoinText)) { $mailingListJoinText = "Thank you for joining our mailing list. We will send you updates from time-to-time. If "; $mailingListJoinText .= "at any time you would like to stop receiving emails, please send us an email to be "; $mailingListJoinText .= "removed from the mailing list."; update_option('dgx_donate_email_list', $mailingListJoinText); } $tributeText = get_option('dgx_donate_email_trib'); if (empty($tributeText)) { $tributeText = "You have asked to make this donation in honor of or memory of someone else. Thank you! We will notify the "; $tributeText .= "honoree within the next 5-10 business days."; update_option('dgx_donate_email_trib', $tributeText); } $employer_text = get_option('dgx_donate_email_empl'); if (empty($employer_text)) { $employer_text = "You have specified that your employer matches some or all of your donation. "; update_option('dgx_donate_email_empl', $employer_text); } $closingText = get_option('dgx_donate_email_close'); if (empty($closingText)) { $closingText = "Thanks again for your support!"; update_option('dgx_donate_email_close', $closingText); } $signature = get_option('dgx_donate_email_sig'); if (empty($signature)) { $signature = "Director of Donor Relations"; update_option('dgx_donate_email_sig', $signature); } //// PayPal defaults $notifyEmails = get_option('dgx_donate_notify_emails'); if (empty($notifyEmails)) { $notifyEmails = get_option('admin_email'); update_option('dgx_donate_notify_emails', $notifyEmails); } $paymentGateway = get_option('dgx_donate_payment_gateway'); if (empty($paymentGateway)) { update_option('dgx_donate_payment_gateway', DGXDONATEPAYPALSTD); } $payPalServer = get_option('dgx_donate_paypal_server'); if (empty($payPalServer)) { update_option('dgx_donate_paypal_server', 'LIVE'); } $paypal_email = get_option('dgx_donate_paypal_email'); if (!is_email($paypal_email)) { update_option('dgx_donate_paypal_email', ''); } // Thank you page default $thankYouText = get_option('dgx_donate_thanks_text'); if (empty($thankYouText)) { $message = "Thank you for donating! A thank you email with the details of your donation "; $message .= "will be sent to the email address you provided."; update_option('dgx_donate_thanks_text', $message); } // Giving levels default $givingLevels = dgx_donate_get_giving_levels(); $noneChecked = true; foreach ($givingLevels as $givingLevel) { $levelEnabled = dgx_donate_is_giving_level_enabled($givingLevel); if ($levelEnabled) { $noneChecked = false; } } if ($noneChecked) { // Select 1000, 500, 100, 50 by default dgx_donate_enable_giving_level(1000); dgx_donate_enable_giving_level(500); dgx_donate_enable_giving_level(100); dgx_donate_enable_giving_level(50); } // Currency $currency = get_option('dgx_donate_currency'); if (empty($currency)) { update_option('dgx_donate_currency', 'USD'); } // Country default $default_country = get_option('dgx_donate_default_country'); if (empty($default_country)) { update_option('dgx_donate_default_country', 'US'); } // State default $default_state = get_option('dgx_donate_default_state'); if (empty($default_state)) { update_option('dgx_donate_default_state', 'WA'); } // Province default $default_province = get_option('dgx_donate_default_province'); if (empty($default_province)) { update_option('dgx_donate_default_province', 'AB'); } // Show Employer match section default $show_employer_section = get_option('dgx_donate_show_employer_section'); if (empty($show_employer_section)) { update_option('dgx_donate_show_employer_section', 'false'); } // Show occupation field default $show_occupation_section = get_option('dgx_donate_show_donor_occupation_field'); if (empty($show_occupation_section)) { update_option('dgx_donate_show_donor_occupation_field', 'false'); } // Show donor employer default $show_occupation_section = get_option('dgx_donate_show_donor_employer_field'); if (empty($show_occupation_section)) { update_option('dgx_donate_show_donor_employer_field', 'false'); } // Show Tribute Gift section default $show_tribute_section = get_option('dgx_donate_show_tribute_section'); if (empty($show_tribute_section)) { update_option('dgx_donate_show_tribute_section', 'true'); } // Scripts location default $scripts_in_footer = get_option('dgx_donate_scripts_in_footer'); if (empty($scripts_in_footer)) { update_option('dgx_donate_scripts_in_footer', 'false'); } }
function dgx_donate_save_giving_levels_settings() { $noneEnabled = true; $givingLevels = dgx_donate_get_giving_levels(); foreach ($givingLevels as $givingLevel) { $key = dgx_donate_get_giving_level_key($givingLevel); if (isset($_POST[$key])) { dgx_donate_enable_giving_level($givingLevel); $noneEnabled = false; } else { dgx_donate_disable_giving_level($givingLevel); } } // If they are all disabled, at least enable the first one if ($noneEnabled) { dgx_donate_enable_giving_level($givingLevels[0]); } }