'', 'redirect' => '', 'hidden' => '', 'email_to' => '', ), $atts)); // Verify form number self::$global_options = SWEETCF_Utils::get_global_options(); self::$form_id_num = '1'; if (isset($form) && is_numeric($form)) { self::$form_id_num = (int) $form; } else { echo __('Contact Form Shortcode Error: Invalid form number in shortcode.', 'sweetcontact'); return; } $frm_id = self::$form_id_num; // Get the form options self::$form_options = SWEETCF_Utils::get_form_options(self::$form_id_num, false); // Don't use defaults if it doesn't exist if (!self::$form_options) { // Form does not exist in options table // Display error message and return echo sprintf(__('Contact Form Shortcode Error: Form %s does not exist', 'sweetcontact'), self::$form_id_num); return; } // Update some language // The update_lang function receives the array by reference, so it can be changed SWEETCF_Utils::update_lang(self::$form_options); // Store shortcode atts // http://sweetcaptcha.com/shortcode-options if (self::$global_options['enable_php_sessions'] == 'true') { // this feature only works when PHP sessions are enabled $_SESSION["fsc_shortcode_redirect_$frm_id"] = $redirect; $_SESSION["fsc_shortcode_hidden_$frm_id"] = $hidden; $_SESSION["fsc_shortcode_email_to_$frm_id"] = $email_to; } else { if (!empty($redirect) || !empty($hidden) || !empty($email_to)) { // trying to use shorcode attributes with the required PHP sessions setting turn off // Display error message and return echo __('Contact Form Shortcode Error: Using shorcode attributes requires the PHP sessions setting to be enabled on the Advanced tab in form settings.', 'sweetcontact'); return; } } self::$form_action_url = self::get_form_action_url(); // initialize vars self::$contact_error = 0; // Save parameters from query string, if any self::get_query_parms(); // initialize external css if (self::$form_options['external_style'] == 'true') { self::get_ext_css(); } // Has a preview been selected? $preview = ( isset($_POST['ctf_action']) && __('Preview Form', 'sweetcontact') == $_POST['ctf_action'] ) ? true : false; //if (is_admin() && $preview && self::$form_options['external_style'] == 'true') { self::external_style_head(); } self::$req_field_ind = ( self::$form_options['req_field_indicator_enable'] == 'true' ) ? '' . self::$form_options['req_field_indicator'] . '' : ''; // See if a form has been processed, and if so, if there were errors if (SWEETCF_Process::$form_processed && SWEETCF_Process::$form_id_num == self::$form_id_num && empty(SWEETCF_Process::$form_errors)) { // Form was processed and has no errors--display thank you message $string = self::display_thank_you(); } else { if (!isset(self::$add_date_js)) { self::$add_date_js_array = array(); self::$add_date_js = ''; } if (!empty(SWEETCF_Process::$form_errors) && SWEETCF_Process::$form_id_num == self::$form_id_num) { // The form was processed, but had errors if (!empty(SWEETCF_Process::$form_data)) { // If this is not true, there is an internal error... self::$form_content = array_merge(self::$form_content, SWEETCF_Process::$form_data); self::$form_errors = array_merge(self::$form_errors, SWEETCF_Process::$form_errors); // XXX later, improve variable usage for error tracking? self::$contact_error = true; } } // ***** Display the Form ***** self::$placeholder = 0; $string = "\n\n
\n" . self::$form_options['welcome']; $string = self::display_form($string); } return($string); } static function get_this_css($tag) { // returns the correct css, inline or external css return $this_style = ( self::$form_options['external_style'] == 'true' ) ? 'class="' . self::$ext_css[$tag] . '"' : self::convert_css(self::$form_options[$tag]); } static function get_ext_css() { // external css class names self::$ext_css = array( // Alignment DIVs 'form_style' => 'swcf-div-form', // Form DIV, how wide is the form DIV 'left_box_style' => 'swcf-div-left-box', // left box DIV, container for vcita 'right_box_style' => 'swcf-div-right-box', // right box DIV, container for vcita 'clear_style' => 'swcf-div-clear', // clear both 'field_left_style' => 'swcf-div-field-left', // field left 'field_prefollow_style' => 'swcf-div-field-prefollow', // field prefollow 'field_follow_style' => 'swcf-div-field-follow', // field follow 'title_style' => 'swcf-div-label', // Input labels alignment DIV 'field_div_style' => 'swcf-div-field', // Input fields alignment DIV 'captcha_div_style_sm' => 'swcf-div-captcha-sm', // Small CAPTCHA DIV 'captcha_div_style_m' => 'swcf-div-captcha-m', // Large CAPTCHA DIV 'captcha_image_style' => 'swcf-image-captcha', // CAPTCHA alignment 'captcha_reload_image_style' => 'swcf-image-captcha-refresh', // CAPTCHA refresh image alignment 'submit_div_style' => 'swcf-div-submit', // Submit DIV 'border_style' => 'swcf-fieldset', // style of the fieldset box (if enabled) // Styles of labels, fields and text 'required_style' => 'swcf-required-indicator', // required field indicator 'required_text_style' => 'swcf-required-text', // required field text 'hint_style' => 'swcf-hint-text', // small text hints like file types 'error_style' => 'swcf-div-error', // Input validation messages 'redirect_style' => 'swcf-div-redirecting', // Redirecting message 'fieldset_style' => 'swcf-fieldset-field', // style of the fieldset box (for a field) 'label_style' => 'swcf-label', // Field labels 'option_label_style' => 'swcf-option-label', // Options labels 'field_style' => 'swcf-input-text', // Input text fields 'captcha_input_style' => 'swcf-input-captcha', // CAPTCHA input field 'textarea_style' => 'swcf-input-textarea', // Input Textarea 'select_style' => 'swcf-input-select', // Input Select 'checkbox_style' => 'swcf-input-checkbox', // Input checkbox 'radio_style' => 'swcf-input-radio', // Input radio 'button_style' => 'swcf-button-submit', // Submit button 'reset_style' => 'swcf-button-reset', // Reset button 'powered_by_style' => 'swcf-powered-by', // the "powered by" link ); } static function get_honeypot_slugs($fields) { // filter a list of field names that are not currently used on the form $decoy_fields = array('address', 'suite', 'company', 'phone', 'title', 'city', 'state', 'fax', 'newsletter', 'webites', 'zipcode', 'address2', 'firstname', 'lastname', 'birthday'); if ($fields && is_array($fields)) { foreach ($decoy_fields as $index => $decoy) { if (isset($fields[$decoy])) { unset($decoy_fields[$index]); } } } sort($decoy_fields); return $decoy_fields; } static function get_todays_honeypot_slug($fields) { // find a decoy field name that is not currently used on the form, change it each day of the week // TODO $decoy_fields = self::get_honeypot_slugs($fields); $max = count($decoy_fields); if ($max > 5) { $index = date('w'); } else if ($max > 0) { $index = 0; } else { return 'email456'; } return $decoy_fields[$index]; } static function display_form($string) { // Build the code to display the form in $string and return it. The form code will be appended to $string and returned global $captcha_path_cf; // used by secureimage.php $captcha_path_cf = SWCF_CAPTCHA_PATH; // Set up the styles for the form self::$style['hint'] = self::convert_css(self::$form_options['hint_style']); self::$style['textarea'] = self::convert_css(self::$form_options['textarea_style']); self::$style['checkbox'] = self::convert_css(self::$form_options['checkbox_style']); self::$style['option_label'] = self::convert_css(self::$form_options['option_label_style']); // option label self::$style['label'] = self::convert_css(self::$form_options['label_style']); // label self::$style['form'] = self::convert_css(self::$form_options['form_style']); self::$style['border'] = self::convert_css(self::$form_options['border_style']); self::$style['fieldset'] = self::convert_css(self::$form_options['fieldset_style']); self::$style['select'] = self::convert_css(self::$form_options['select_style']); self::$style['title'] = self::convert_css(self::$form_options['title_style']); self::$style['field'] = self::convert_css(self::$form_options['field_style']); // text fields self::$style['field_div'] = self::convert_css(self::$form_options['field_div_style']); self::$style['error'] = self::convert_css(self::$form_options['error_style']); self::$style['required'] = self::convert_css(self::$form_options['required_style']); self::$style['required_text'] = self::convert_css(self::$form_options['required_text_style']); self::$style['submit_div'] = self::convert_css(self::$form_options['submit_div_style']); self::$style['submit'] = self::convert_css(self::$form_options['button_style']); self::$style['reset'] = self::convert_css(self::$form_options['reset_style']); self::$aria_required = ' aria-required="true" '; $hidden = "\n"; if (self::$contact_error) { // this is for some people who hide the form in a div, if there are validation errors, unhide it self::$form_options['form_style'] = str_replace('display: none;', '', self::$form_options['form_style']); } $string .= '
'; $form_attributes = ''; if (!empty(self::$form_options['form_attributes'])) { $form_attributes = self::$form_options['form_attributes'] . ' '; } $anchor = ''; if (self::$form_options['anchor_enable'] == 'true') { $anchor = '#SWCFContact' . self::$form_id_num; } $string .= '
'; if (self::$form_options['border_enable'] == 'true') { $string .= '
\n"; if (self::$form_options['title_border'] != '') { $string .= ''; $string .= self::$form_options['title_border']; $string .= "\n"; } } // check attachment directory $frm_id = self::$form_id_num; // needed for use w/in "" below.. can't use self:: $swcf_attach_dir = SWCF_ATTACH_DIR; if (self::$have_attach) { self::init_temp_dir(SWCF_ATTACH_DIR); if (self::$form_options['php_mailer_enable'] == 'php') { self::set_form_error("$swcf_attach_dir$frm_id", __('Attachments are only supported when the Send Email function is set to WordPress. You can find this setting on the contact form settings page.', 'sweetcontact')); } if (!is_dir(SWCF_ATTACH_DIR)) { self::set_form_error("$swcf_attach_dir$frm_id", __('The temporary folder for the attachment field does not exist.', 'sweetcontact')); } else if (!is_writable(SWCF_ATTACH_DIR)) { self::set_form_error("$swcf_attach_dir$frm_id", __('The temporary folder for the attachment field is not writable.', 'sweetcontact')); } else { // delete files over 3 minutes old in the attachment directory // full directory sweep cleanup //self::clean_temp_dir( SWCF_ATTACH_DIR, 3 ); } } // print input error message if (self::$contact_error) { // There are errors, so print the generic error message $string .= '
\n"; $string .= (self::$form_options['error_correct'] != '') ? self::$form_options['error_correct'] : __('Please make corrections below and try again.', 'sweetcontact'); $string .= "\n
\n"; // Print errors that appear at the top of the form $string .= self::echo_if_error("swcf_attach_dir$frm_id"); } // Get the email-to list self::$contacts = (self::$contacts) ? self::$contacts : SWEETCF_Options::get_contact_list(); if (empty(self::$contacts)) { $string .= '
' . __('ERROR: Misconfigured email address in options.', 'sweetcontact') . "\n
\n"; } if (self::$global_options['enable_php_sessions'] == 'true') { // this feature only works when PHP sessions are enabled if (!empty($_SESSION["fsc_shortcode_hidden_$frm_id"])) { $hidden_fields = self::get_hidden_fields(); if (!empty($hidden_fields)) { foreach ($hidden_fields as $key => $value) { $hidden .= "\n" . '' . "\n"; } } } else { unset($_SESSION["fsc_shortcode_hidden_$frm_id"]); } } // Add a hidden field if this is the admin preview, so that we return to the preview after submit if (is_admin()) { $hidden .= '' . "\n"; } $hidden .= '' . "\n"; $hidden .= '' . "\n"; $hidden .= '' . "\n"; $hidden .= '' . "\n"; if (self::$form_options['req_field_label_enable'] == 'true' && self::$form_options['req_field_indicator_enable'] == 'true') { $string .= "\n" . '
' . "\n"; $string .= ' ' . self::$form_options['req_field_indicator'] . ' '; $string .= (self::$form_options['tooltip_required'] != '') ? self::$form_options['tooltip_required'] : __('indicates required field', 'sweetcontact'); $string .= "\n
\n\n"; } // If there are multiple mail-to contacts, display a select form if (count(self::$contacts) > 1) { $string .= '
' . "\n" .'
' .'
' .'
' . self::echo_if_error('contact') . '
'; } else { $hidden .= '' . "\n"; } $open_fieldset = false; // is a fieldset field open? // A div class="swcf-clear" is used to group a field with any that follow it // $open_div tracks whether this div is currently open $open_div = false; $date_fields = array(); // List of date fields self::$printed_tooltip_filetypes = 0; // ********** Go through all the fields and print them ********** // fill in any missing defaults $field_opt_defaults = array( 'hide_label' => 'false', 'placeholder' => 'false', ); // Create a list of follow values for fields $field_follow = array(); foreach (self::$form_options['fields'] as $key => $field) { if ('true' != $field['disable']) { $field_follow[] = $field['follow']; } } $fld_cnt = 0; $fields_in_use = array(); $string .= "\n" . '
' . "\n"; foreach (self::$form_options['fields'] as $key => $field) { //var_export($field); // fill in any missing field options defaults foreach ($field_opt_defaults as $dfkey => $dfval) { if (!isset($field[$dfkey]) || empty($field[$dfkey])) { $field[$dfkey] = $dfval; } } //echo '
';var_export($field); if ('true' == $field['disable']) { continue; } $fields_in_use[$field['slug']] = 1; if ('true' == $field['follow'] && $open_div) { $string .= '
'; } else { if ($open_div) { // close the preceeding div used for grouping $string .= "
\n"; $open_div = false; } if ('fieldset' == $field['type'] || 'fieldset-close' == $field['type']) { $string .= "\n" . '
\n"; } else { $open_div = true; $textarea_class = ( SWCF_MESSAGE_FIELD == $field['standard'] ) ? ' message-textarea-wrapper' : ''; $string .= "\n" . '
' . "\n" . ' '; $string .= '
'; // narrow } else { $string .= self::get_this_css('field_left_style') . '>'; // wide } } } $fld_cnt++; // Display code common to all/most field types if (!in_array($field['type'], array('fieldset', 'fieldset-close', 'hidden'))) { if ($field['notes'] != '') { $string .= "\n" . self::swcf_notes($field['notes']); } if (('checkbox' != $field['type'] && $field['standard'] < 1) && ( 'false' == $field['hide_label'] )) { // hiding the label // Standard field labels can be changed in options, so don't print them here // single checkbox labels are printed next to the checkbox $string .= "\n
\n
"; } else if (('checkbox' == $field['type'] && $field['standard'] < 1) || ( 'true' == $field['hide_label'] )) { // single checkbox keep the div to maintain style left alignment (no label here), or hide label was checked $string .= "\n
\n"; } $open_fieldset = true; break; case 'fieldset-close' : if ($open_fieldset) { $string .= "
\n"; } $open_fieldset = false; break; case 'hidden' : $string .= ' ' . "\n"; break; case 'password' : $string .= '
' . self::echo_if_error($field['slug']) . "\n" . ' $field['type'] && 'fieldset-close' <> $field['type'] && 'hidden' <> $field['type']) { if ($field['notes_after'] != '') { $string .= self::swcf_notes($field['notes_after']) . "\n"; } } if ($open_div) { $string .= "
\n"; // close field div } } $string .= "\n" . '
' . "\n"; // end of sweetontact-form-fields-wrapper // action hook for form display after fields $string = apply_filters('sw_contact_display_after_fields', $string, self::$style, self::$form_errors, self::$form_id_num); if (count($date_fields) > 0) { self::setup_calendar($date_fields); } // Are there any date fields? if ($open_div) { $string .= '
' . "\n"; } wp_enqueue_style('sweetcf-styles-frontend', plugins_url('sweetcontact/includes/sweetcf-styles.css'), false, SWCF_BUILD); if (self::$form_options['design_type'] == '2') { // Vertical Design wp_enqueue_style('sweetcf-styles-vertical', plugins_url('sweetcontact/includes/sweetcf-styles-vertical.css'), false, SWCF_BUILD); } else { wp_enqueue_style('sweetcf-styles-horizontal', plugins_url('sweetcontact/includes/sweetcf-styles-horizontal.css'), false, SWCF_BUILD); } if (self::is_captcha_enabled(self::$form_id_num)) { $string .= self::display_captcha() . "\n"; } // hidden empty honeypot field, if enabled if (self::$form_options['honeypot_enable'] == 'true') { $honeypot_slug = self::get_todays_honeypot_slug($fields_in_use); $string .= ' ' . self::echo_if_error($honeypot_slug) . '
'; } // Display the submit button $string .= "\n
'; } $string .= "\n
\n"; if (self::$form_options['border_enable'] == 'true') { $string .= "\n"; } $string .= $hidden; // Close the form $string .= "\n\n"; $string .= ''; $string .= "
\n"; if (self::$placeholder && self::$form_options['external_style'] == 'false') { self::$add_placeholder_script = 1; // for adding the javascript $placeholder_style = self::$form_options['placeholder_style']; if (preg_match("/^style=\"(.*)\"$/i", $placeholder_style, $matches)) $placeholder_style = $matches[1]; if (preg_match("/^class=\"(.*)\"$/i", $placeholder_style, $matches)) $placeholder_style = $matches[1]; $string .= ' '; } $string .= "\n" . '' . "\n"; return($string); } static function display_name($key, $field) { // Returns the code to display the name field on the form global $current_user, $user_ID; // Get defaults // Find logged in user's WP name (auto form fill feature): if (isset(self::$form_content[$field['slug']]) && '' == self::$form_content[$field['slug']] && $user_ID != '' && $current_user->user_login != 'admin' && !current_user_can('manage_options') && self::$form_options['auto_fill_enable'] == 'true') { // user logged in (and not admin rights) (and auto_fill_enable set in options) self::$form_content[$field['slug']] = $current_user->user_login; } $f_default = $m_default = $mi_default = $l_default = ''; if ($field['default'] != '') { if (self::$form_options['name_format'] == 'first_last') { if (!preg_match('/^(.*)(==)(.*)$/', $field['default'], $matches)) { $field['default'] = 'First Name==Last Name'; } // default to proper format if (preg_match('/^(.*)(==)(.*)$/', $field['default'], $matches)) { $f_default = $matches[1]; $l_default = $matches[3]; } } else if (self::$form_options['name_format'] == 'first_middle_last') { if (!preg_match('/^(.*)(==)(.*)(==)(.*)$/', $field['default'], $matches)) { $field['default'] = 'First Name==Middle Name==Last Name'; } // default to proper format if (preg_match('/^(.*)(==)(.*)(==)(.*)$/', $field['default'], $matches)) { $f_default = $matches[1]; $m_default = $matches[3]; $l_default = $matches[5]; } } else if (self::$form_options['name_format'] == 'first_middle_i_last') { if (!preg_match('/^(.*)(==)(.*)(==)(.*)$/', $field['default'], $matches)) { $field['default'] = 'First Name==Middle Initial==Last Name'; } // default to proper format if (preg_match('/^(.*)(==)(.*)(==)(.*)$/', $field['default'], $matches)) { $f_default = $matches[1]; $mi_default = $matches[3]; $l_default = $matches[5]; } } } $string = ''; $f_name_string = '
\n"; if ('false' == $field['hide_label']) { $f_name_string .= ' \n"; } $f_name_string .= '
' . self::echo_if_error('f_name') . ' \n"; if ('false' == $field['hide_label']) { $l_name_string .= ' \n"; } $l_name_string .= '
' . self::echo_if_error('l_name') . ' \n"; if ('false' == $field['hide_label']) { $string .= ' \n"; } $string .= '
' . self::echo_if_error('full_name') . ' '; } $string .= $l_name_string; break; case 'first_middle_i_last': $string .= $f_name_string; // See if name parts are to be displayed inline if ('true' == $field['inline']) { $string .= '
'; } $string .= '
\n"; if ('false' == $field['hide_label']) { $string .= ' \n"; } $string .= '
' . self::echo_if_error('mi_name') . ' '; } $string .= $l_name_string; break; case 'first_middle_last': $string .= $f_name_string; // See if name parts are to be displayed inline if ('true' == $field['inline']) { $string .= '
'; } $string .= '
\n"; if ('false' == $field['hide_label']) { $string .= ' \n"; } $string .= '
' . self::echo_if_error('m_name') . ' '; } $string .= $l_name_string; break; } return($string); } static function display_email($key, $field) { global $current_user, $user_ID; $string = ''; //filter hook for email input type, someone might want to change it from type='text' to type='email' $email_input_type = apply_filters('sw_contact_email_input_type', 'text', self::$form_id_num); // Find logged in user's WP email address (auto form fill feature): if ('' == self::$form_content[$field['slug']] && $user_ID != '' && $current_user->user_login != 'admin' && !current_user_can('manage_options') && self::$form_options['auto_fill_enable'] == 'true') { // user logged in (and not admin rights) (and auto_fill_enable set in options) self::$form_content[$field['slug']] = $current_user->user_email; if ('true' == self::$form_options['double_email']) { self::$form_content['email2'] = $current_user->user_email; } } $email_default = ''; $email2_default = ''; if ('true' == self::$form_options['double_email']) { $field['req'] = 'true'; $default = self::$form_options['fields']['1']['default']; // email field // find the true default for email, email2 // is there xx==xx if (!preg_match('/^(.*)(==)(.*)$/', $default, $matches)) { $default = 'Email==Re-enter Email'; } if (preg_match('/^(.*)(==)(.*)$/', $default, $matches)) { $email_default = $matches[1]; $email2_default = $matches[3]; } } else { $email_default = $field['default']; } $string .= "\n
\n"; if ('false' == $field['hide_label']) { $string .= ' \n"; } $string .= "
\n"; $string .= '
' . self::echo_if_error('email') . "\n \n"; if ('true' == self::$form_options['double_email']) { $string .= "
\n
\n\n" . '
' . "\n" . '
'; $string .= "\n
\n"; if ('false' == $field['hide_label']) { $string .= ' \n"; } $string .= "
\n
' . self::echo_if_error('email2') . "\n \n"; } return($string); } static function display_field_text($key, $field) { // display function for a text, email, or url field type $string = ''; if (SWCF_NAME_FIELD == $field['standard']) { return(self::display_name($key, $field)); } if (SWCF_EMAIL_FIELD == $field['standard']) { return(self::display_email($key, $field)); } if (SWCF_SUBJECT_FIELD == $field['standard']) { // Display field title for special fields $string = ''; $string .= "\n
\n"; if ('false' == $field['hide_label']) { $string .= ' \n"; } $string .= "
"; } $type = $field['type']; if ('email' == $field['type'] || 'url' == $field['type']) { $type = 'text'; } // TODO $string .= "\n
' . self::echo_if_error($field['slug']) . "\n" . ' \n"; if ('false' == $field['hide_label']) { $string .= ' \n"; } $string .= "
\n
' . self::echo_if_error('message') . "\n \n
\n"; } return($string); } static function display_field_select($key, $field) { $string = ''; // Get the options list $opts_array = explode("\n", $field['options']); $frm_id = self::$form_id_num; if ('' == $opts_array[0]) { // Error: no options were entered self::set_form_error("swcf_select$frm_id", __('Error: No options were entered for a select field in settings.', 'sweetcontact')); $string .= self::echo_if_error("swcf_select$frm_id"); } // Display the field if (SWCF_SUBJECT_FIELD == $field['standard']) { // Display field title for special fields $string = ''; $string .= "\n
\n"; if ('false' == $field['hide_label']) { $string .= ' \n"; } $string .= "
"; // Check for subject_id parm for backward compatibility if (0 == count(self::$form_content[$field['slug']]) && '' != self::$form_content['subject_id']) self::$form_content[$field['slug']][] = self::$form_content['subject_id']; } $mult = ( 'select-multiple' == $field['type'] ) ? ' multiple="multiple"' : ''; $string .= "\n
' . self::echo_if_error($field['slug']) . "\n \n
\n"; return($string); } static function display_field_checkbox($key, $field) { // Displays checkbox, checkbox-multiple, and radio field types $string = ''; // Get the options list $opts_array = explode("\n", $field['options']); if ('' == $opts_array[0]) { if ('checkbox' == $field['type']) { // use the field name as the option name $opts_array[0] = $field['label']; } else { // Error: no options were entered self::$contact_error = 1; self::$form_errors['swcf_checkbox'] = __('Error: No options were entered for a checkbox-multiple field in settings.', 'sweetcontact'); $string .= self::echo_if_error('swcf_checkbox'); } } if ('checkbox' == $field['type']) { // Single checkbox $string .= "\n
' . self::echo_if_error($field['slug']) . "\n" . ' ' . $field['label']; $string .= ( 'true' == $field['req'] ) ? self::$req_field_ind : ''; $string .= "\n
\n"; } else { // checkbox-multiple or radio if ('checkbox-multiple' == $field['type']) { $ftype = 'checkbox'; } else { $ftype = 'radio'; } $string .= "\n
' . self::echo_if_error($field['slug']) . "\n"; $opt_cnt = 1; foreach ($opts_array as $opt) { $opt = trim($opt); if ('false' == $field['inline'] && $opt_cnt > 1) { $string .= "
\n"; } else if ($opt_cnt > 1) { $string .= "\n"; } $string .= ' 0 && in_array($opt_cnt, self::$form_content[$field['slug']])) { $string .= ' checked="checked"'; } } else if ($opt_cnt == self::$form_content[$field['slug']]) { $string .= ' checked="checked"'; } // is this key==value set? Just display the value $matches = array(); if (preg_match('/^(.*)(==)(.*)$/', $opt, $matches)) { $opt = $matches[3]; } if ($field['attributes'] != '') { $string .= ' ' . $field['attributes']; } $string .= ' /> "; $opt_cnt++; } // end foreach $string .= "\n
\n"; } return($string); } static function display_field_date($key, $field) { $string = ''; $cal_date_array = array( 'mm/dd/yyyy' => esc_html(__('mm/dd/yyyy', 'sweetcontact')), 'dd/mm/yyyy' => esc_html(__('dd/mm/yyyy', 'sweetcontact')), 'mm-dd-yyyy' => esc_html(__('mm-dd-yyyy', 'sweetcontact')), 'dd-mm-yyyy' => esc_html(__('dd-mm-yyyy', 'sweetcontact')), 'mm.dd.yyyy' => esc_html(__('mm.dd.yyyy', 'sweetcontact')), 'dd.mm.yyyy' => esc_html(__('dd.mm.yyyy', 'sweetcontact')), 'yyyy/mm/dd' => esc_html(__('yyyy/mm/dd', 'sweetcontact')), 'yyyy-mm-dd' => esc_html(__('yyyy-mm-dd', 'sweetcontact')), 'yyyy.mm.dd' => esc_html(__('yyyy.mm.dd', 'sweetcontact')), ); $string .= "\n
' . self::echo_if_error($field['slug']) . "\n ' . self::echo_if_error($field['slug']) . "\n '; $file_type_message .= sprintf((self::$form_options['tooltip_filetypes'] != '') ? self::$form_options['tooltip_filetypes'] : __('Acceptable file types: %s.', 'sweetcontact'), self::$form_options['attach_types']); $file_type_message .= '
'; $file_type_message .= sprintf((self::$form_options['tooltip_filesize'] != '') ? self::$form_options['tooltip_filesize'] : __('Maximum file size: %s.', 'sweetcontact'), self::$form_options['attach_size']) . "\n"; //filter hook for file attachment acceptable types message $file_type_message = apply_filters('sw_contact_file_type_message', $file_type_message, self::$form_options, self::$form_id_num); $string .= $file_type_message; } self::$printed_tooltip_filetypes++; $string .= "
\n"; } return($string); } static function setup_calendar($date_fields) { // Set up the popup calendar display for date fields foreach ($date_fields as $v) { self::$add_date_js_array[] = self::$form_id_num . '_' . $v; } if (self::$add_date_js == '') { // only add for 1st form with date fields self::$add_date_js = '
'; } } $ctf_thank_you .= '
'; if (self::$form_options['border_enable'] == 'true') { $ctf_thank_you .= ' '; } $ctf_thank_you .= '
'; //filter hook for thank_you_message return apply_filters('sw_contact_thank_you_message', $ctf_thank_you, self::$form_id_num); } static function set_form_error($fld, $msg) { // Sets a form error for field $fld with message $msg // This is called from SWEETCF_Process class functions // The key is 'field' plus the field index number, or a special name such as capctha, f_name, swcf_select, etc. self::$form_errors[$fld] = $msg; self::$contact_error = 1; // Set the error flag } static function check_form_errors() { // Returns 1 if there are form errors, and 0 if not return(self::$contact_error); } static function swcf_notes($notes) { $html = "\n
\n$notes\n"; // filter hook for html_before_after return apply_filters('sw_contact_html_before_after', $html, self::$form_id_num); } static function get_form_action_url() { // returns the URL for the WP page the form was on if (function_exists('qtrans_convertURL')) { // compatible with qtranslate plugin. In case of multi-lingual pages, the /de/ /en/ language url is used. $form_action_url = qtrans_convertURL(strip_tags($_SERVER['REQUEST_URI'])); } else { $form_action_url = 'http://' . strip_tags($_SERVER['HTTP_HOST']) . strip_tags($_SERVER['REQUEST_URI']); } // set the type of request (SSL or not) if (is_ssl()) { $form_action_url = preg_replace('|http://|', 'https://', $form_action_url); } //filter hook for form action URL return apply_filters('sweetcontact_form_action_url', $form_action_url, self::$form_id_num); } } ?>