/** * */ public static function contactform($atts = null, $content = null) { if ($atts == 'generator') { return; } extract(shortcode_atts(array('email' => '', 'subject' => '', 'success' => '', 'captcha' => '', 'akismet' => '', 'attachment' => '', 'sidebar' => false), $atts)); $out = ''; $out_textarea = ''; $out_attachment = ''; $out_captcha = ''; $out_submit = ''; $form_id = self::_form_id(); $miss_form_id = 'miss_form' . $form_id; $url = add_query_arg(array()) . '#' . $miss_form_id; $required_error = ''; $form_inputs = array(); $submit_button = false; $form_inputs['miss_email'] = is_email(trim($email)) ? trim($email) : get_option('admin_email'); $form_inputs['miss_subject'] = !empty($subject) ? $subject : false; $form_inputs['success'] = !empty($success) ? $success : 'mail_sent'; $form_inputs['akismet'] = $akismet == 'true' ? true : false; $form_inputs['sidebar'] = !empty($sidebar) ? true : false; if (isset($_POST['_miss_form_nonajax_response']['errored_fields'])) { foreach ($_POST['_miss_form_nonajax_response']['errored_fields'] as $key => $value) { $errored_fields[$value] = $value; } } if (empty($content)) { $content = '[name label="' . __('Name', MISS_TEXTDOMAIN) . '" required="true"][email label="' . __('Email', MISS_TEXTDOMAIN) . '" required="true"][textfield label="' . __('Website', MISS_TEXTDOMAIN) . '"][textarea required="true"][captcha]'; } if (preg_match_all("/\\[([^\\s^\\]]+)\\s?([^\\]]*)/", $content, $matches)) { miss_stripslashes(); $out .= '<div id="' . $miss_form_id . '" class="miss_form">'; $out .= '<form action="' . esc_url_raw($url) . '" method="post">'; $out .= isset($_POST['_miss_form_nonajax_response']) && $_POST['_miss_form_nonajax_response']['id'] == $form_id && (!$_POST['_miss_form_nonajax_response']['sidebar'] || empty($_POST['_miss_form_nonajax_response']['errored_fields'])) ? $_POST['_miss_form_nonajax_response']['messages'] : ''; $out .= '<div class="row-fluid">'; for ($i = 0; $i < count($matches[0]); $i++) { if (!$form_inputs['sidebar']) { if ($matches[1][$i] != 'textarea' && $matches[1][$i] != 'autoresponder' && $matches[1][$i] != 'submit' && $matches[1][$i] != 'captcha' && $matches[1][$i] != 'attachment') { $span = 'span4 '; $out .= '<div class="' . $span . $matches[1][$i] . '_field' . '">'; } elseif ($matches[1][$i] == 'submit' || $matches[1][$i] == 'captcha') { $span = 'span6 '; $out_submit .= '<div class="' . $span . $matches[1][$i] . '_field' . '">'; } elseif ($matches[1][$i] == 'textarea') { $span = 'span12 '; $out_textarea .= '<div class="' . $span . $matches[1][$i] . '_field' . '">'; } elseif ($matches[1][$i] == 'attachment') { $span = 'span12 '; } else { $span = ''; $out .= '<div class=" ' . $span . $matches[1][$i] . '_field' . '">'; } } else { if ($matches[1][$i] != 'textarea' && $matches[1][$i] != 'autoresponder' && $matches[1][$i] != 'submit' && $matches[1][$i] != 'captcha' && $matches[1][$i] != 'attachment') { $span = 'span6 '; $out .= '<div class="' . $span . $matches[1][$i] . '_field' . '">'; } elseif ($matches[1][$i] == 'captcha') { $span = 'span8 '; $out_submit .= '<div class="' . $span . $matches[1][$i] . '_field' . '">'; } elseif ($matches[1][$i] == 'submit') { $span = 'span4 '; $out_submit .= '<div class="' . $span . $matches[1][$i] . '_field' . '">'; } elseif ($matches[1][$i] == 'textarea') { $span = 'span12 '; $out_textarea .= '<div class="' . $span . $matches[1][$i] . '_field' . '">'; } elseif ($matches[1][$i] == 'attachment') { $span = 'span12 '; } else { $span = ''; $out .= '<div class=" ' . $span . $matches[1][$i] . '_field' . '">'; } } $field_id = 'miss_field' . $i . $form_id; $matches[2][$i] = shortcode_parse_atts($matches[2][$i]); if (isset($errored_fields)) { $required_error = !in_array($field_id, $errored_fields) ? '' : ' required_error'; } $required = $matches[1][$i] == 'captcha' ? 'captcha' : (empty($matches[2][$i]['required']) ? false : ($matches[1][$i] == 'email' ? 'email' : 'true')); $label = !empty($matches[2][$i]['label']) ? $matches[2][$i]['label'] : ''; if ($required == 'captcha') { $num1 = rand(1, 10); $num2 = rand(1, 10); $label = $num1 . ' + ' . $num2 . ' '; } if ($required && $required != 'captcha' && $label != '') { //$out .= '<span class="star">*</span>'; $label .= ' *'; } if ($required == 'captcha') { $out_submit .= '<label class="span4" for="' . $field_id . '">' . $label . '</label>'; $out_submit .= '<input type="text" name="' . $field_id . '" id="' . $field_id . '" size="auto" class="im-capthca_input span8 ' . $required_error . ($matches[1][$i] != 'textfield' ? ' ' . $matches[1][$i] : '') . '' . ($required ? ' required' : '') . '" value="' . (isset($_POST[$field_id]) ? esc_attr($_POST[$field_id]) : '') . '" placeholder="' . __('Enter sum', MISS_ADMIN_TEXTDOMAIN) . '" />'; $form_inputs['fields'][$field_id] = array('type' => $matches[1][$i], 'label' => $label, 'required' => $required); if ($required == 'captcha') { $form_inputs['fields'][$field_id]['captcha'] = $num1 + $num2; } } if ($matches[1][$i] == 'textfield' || $matches[1][$i] == 'name' || $matches[1][$i] == 'email') { $out .= '<input type="text" name="' . $field_id . '" id="' . $field_id . '" size="auto" class="span12 ' . $required_error . ($matches[1][$i] != 'textfield' ? ' ' . $matches[1][$i] : '') . '' . ($required ? ' required' : '') . '" value="' . (isset($_POST[$field_id]) ? esc_attr($_POST[$field_id]) : '') . '" placeholder="' . $label . '"/>'; $form_inputs['fields'][$field_id] = array('type' => $matches[1][$i], 'label' => $label, 'required' => $required); if ($required == 'captcha') { $form_inputs['fields'][$field_id]['captcha'] = $num1 + $num2; } } elseif ($matches[1][$i] == 'textarea') { /* $out_textarea .= '<label for="' . $field_id . '">' . $label; $out_textarea .= '</label>'; */ $out_textarea .= ''; } elseif ($matches[1][$i] == 'submit' || $matches[1][$i] == 'autoresponder' || $matches[1][$i] == 'captcha' || $matches[1][$i] == 'attachment') { $out .= ''; $out .= ''; } else { $out .= '<label for="' . $field_id . '">' . $label; $out .= '</label>'; } if ($matches[1][$i] == 'attachment') { $out_attachment .= '<label for="' . $field_id . '"><h3>' . $label; $out_attachment .= '</h3></label>'; $out_attachment .= '<input type="file" style="line-height: 0" name="' . $field_id . '" id="' . $field_id . '" size="auto" class="span12 ' . $required_error . ($matches[1][$i] != 'attachment' ? ' ' . $matches[1][$i] : '') . '' . ($required ? ' required' : '') . '" placeholder="' . $label . '"/>'; $form_inputs['fields'][$field_id] = array('type' => $matches[1][$i], 'label' => $label, 'required' => $required); } if ($matches[1][$i] == 'textarea') { $out_textarea .= '<textarea name="' . $field_id . '" id="' . $field_id . '" class="span12 ' . $required_error . ($required ? ' required' : '') . '" rows="5" cols="40" placeholder="' . $label . '">' . (isset($_POST[$field_id]) ? esc_attr($_POST[$field_id]) : '') . '</textarea>'; $form_inputs['fields'][$field_id] = array('type' => $matches[1][$i], 'label' => $label, 'required' => $required); } if ($matches[1][$i] == 'checkbox') { /* $out .= '<input type="checkbox" name="' . $field_id . '" id="' . $field_id . '" class="styled' . $required_error . ( $required ? ' required' : '' ) . '"' . ( isset( $_POST[$field_id] ) ? ' checked="checked"' : '' ) . ' value="1" />'; $form_inputs['fields'][$field_id] = array( 'type' => $matches[1][$i], 'label' => $label, 'required' => $required ); */ if (!empty($matches[2][$i]['value'])) { $options = explode(',', $matches[2][$i]['value']); foreach ($options as $key => $value) { $value = trim($value); $radio_id = $field_id . '_' . $key; $out .= '<input type="checkbox" name="' . $radio_id . '[' . $key . ']" id="' . $radio_id . '" class="styled ' . $required_error . ($required ? ' required' : '') . '"' . (!isset($_POST[$radio_id]) ? '' : ($_POST[$radio_id][$key] == $value ? ' checked="checked"' : '')) . ' value="' . $value . '" /> <label for="' . $radio_id . '" class="radio_label">' . $value . '</label>'; } $form_inputs['fields'][$field_id] = array('type' => $matches[1][$i], 'label' => $label, 'value' => $options, 'required' => $required); } } if ($matches[1][$i] == 'radio') { if (!empty($matches[2][$i]['value'])) { $options = explode(',', $matches[2][$i]['value']); foreach ($options as $key => $value) { $radio_id = $field_id . '_' . $key; $out .= '<input type="radio" name="' . $field_id . '" id="' . $radio_id . '" class="styled' . $required_error . ($required ? ' required' : '') . '"' . (!isset($_POST[$field_id]) ? $key == 0 ? ' checked="checked"' : '' : ($_POST[$field_id] == $key ? ' checked="checked"' : '')) . ' value="' . $key . '" />'; $out .= '<label for="' . $radio_id . '" class="radio_label">' . $value . '</label>'; } $form_inputs['fields'][$field_id] = array('type' => $matches[1][$i], 'label' => $label, 'value' => $options, 'required' => $required); } } if ($matches[1][$i] == 'select') { if (!empty($matches[2][$i]['value'])) { $options = explode(',', $matches[2][$i]['value']); $out .= '<select name="' . $field_id . '" id="' . $field_id . '" class="span12' . $required_error . ($required ? ' required' : '') . '">'; foreach ($options as $key => $value) { $out .= '<option value="' . $value . '"' . (!isset($_POST[$field_id]) ? '' : ($_POST[$field_id] == $value ? ' selected="selected"' : '')) . '>' . $value . '</option>'; } $out .= '</select>'; $form_inputs['fields'][$field_id] = array('type' => $matches[1][$i], 'label' => $label, 'required' => $required); } } if ($matches[1][$i] == 'submit') { $submit_button = true; $submit_value = !empty($matches[2][$i]['value']) ? $matches[2][$i]['value'] : 'Submit'; $out_submit .= '<input type="submit" value="' . $submit_value . '" class="contact_form_submit styled_button" />'; $out_submit .= '<div class="miss_contact_feedback">'; $out_submit .= '<img src="' . esc_url(THEME_IMAGES_ASSETS . '/dummy/transparent.gif') . '" style="background-image: url(' . THEME_IMAGES_ASSETS . '/preloaders/preloader.gif);" alt="Loading...">'; $out_submit .= '</div>'; } if ($matches[1][$i] == 'autoresponder') { $name = !empty($matches[2][$i]['fromname']) ? $matches[2][$i]['fromname'] : get_bloginfo('name'); $email = !empty($matches[2][$i]['fromemail']) ? trim($matches[2][$i]['fromemail']) : $form_inputs['miss_email']; $subject = !empty($matches[2][$i]['subject']) ? $matches[2][$i]['subject'] : false; $message = !empty($matches[2][$i]['message']) ? $matches[2][$i]['message'] : false; $form_inputs['autoresponder'][] = array('name' => $name, 'email' => $email, 'subject' => $subject, 'message' => $message); } if ($matches[1][$i] != 'textarea' && $matches[1][$i] != 'autoresponder' && $matches[1][$i] != 'submit' && $matches[1][$i] != 'captcha' && $matches[1][$i] != 'attachment') { $out .= '</div>'; } elseif ($matches[1][$i] == 'submit' || $matches[1][$i] == 'captcha') { $out_submit .= '</div>'; } elseif ($matches[1][$i] == 'textarea') { $out_textarea .= '</div>'; } elseif ($matches[1][$i] == 'attachment') { $out_textarea .= '</div>'; } else { $out .= '</div>'; } } if ($captcha == 'true') { $field_id = "miss_field{$i}{$form_id}"; if (isset($errored_fields)) { $required_error = !in_array($field_id, $errored_fields) ? '' : ' required_error'; } $captch_span = $form_inputs['sidebar'] ? 'span8' : 'span6'; $out_captcha .= '<div class="' . $captch_span . ' captcha_field">'; $num1 = rand(1, 10); $num2 = rand(1, 10); $label = $num1 . ' + ' . $num2 . ' '; $out_captcha .= '<input type="text" name="' . $field_id . '" id="' . $field_id . '" class="span8 required' . $required_error . '" value="' . (isset($_POST[$field_id]) ? esc_attr($_POST[$field_id]) : '') . '" placeholder="' . __('Sum', MISS_ADMIN_TEXTDOMAIN) . '" />'; $form_inputs['fields'][$field_id] = array('type' => 'captcha', 'label' => $label, 'required' => 'captcha'); $out_captcha .= '<label class="span4" for="' . $field_id . '">' . $label . '</label>'; $form_inputs['fields'][$field_id]['captcha'] = $num1 + $num2; $out_captcha .= '</div>'; } if (!$submit_button) { $submit_span = $form_inputs['sidebar'] ? 'span4' : 'span6'; $out_submit .= '<div class="' . $submit_span . ' submit_field">'; $out_submit .= '<input type="submit" value="' . __('Submit', MISS_TEXTDOMAIN) . '" class="contact_form_submit styled_button" />'; $out_submit .= '<div class="miss_contact_feedback">'; $out_submit .= '<img src="' . esc_url(THEME_IMAGES_ASSETS . '/dummy/transparent.gif') . '" style="background-image: url(' . THEME_IMAGES_ASSETS . '/preloaders/preloader.gif);" alt="Loading...">'; $out_submit .= '</div>'; $out_submit .= '</div>'; } $honeypot_captcha_input = array('miss_required', 'miss_name_required', 'miss_email_required', 'miss_date_required', 'miss_zip_required'); $honeypot_captcha_rand = array_rand($honeypot_captcha_input, 2); foreach ($honeypot_captcha_rand as $key) { $out .= '<div class=" ' . $honeypot_captcha_input[$key] . '">'; $out .= '<input type="text" name="' . $honeypot_captcha_input[$key] . '" id="' . $honeypot_captcha_input[$key] . '" />'; $out .= '</div>'; $form_inputs['fields'][$honeypot_captcha_input[$key]] = array('required' => 'honeypot'); } $encode_form_inputs = miss_encode($form_inputs, $serialize = true); if (!empty($out_textarea)) { $out .= '<div class="row-fluid">'; $out .= $out_textarea; $out .= '</div>'; } if (!empty($out_attachment)) { $out .= '<div class="row-fluid">'; $out .= $out_attachment; $out .= '</div>'; } $out .= '<div class="row-fluid">'; $out .= $out_captcha; $out .= $out_submit; $out .= '</div>'; $out .= '<div class="" style="display:none;">'; $out .= '<input type="hidden" name="_miss_form" value="' . $form_id . '">'; $out .= '<input type="hidden" name="_miss_form_encode" value="' . $encode_form_inputs . '">'; $out .= '</div>'; $out .= '</div>'; $out .= '</form>'; $out .= '</div>'; } if ($sidebar == false) { return $out; } else { return $out; } }
/** * */ public static function im_contactform($atts = null, $content = null) { $multiplier_cycle_number = 15; $multiple_params = array(array('heading' => __('{{1}} Field Type', MISS_ADMIN_TEXTDOMAIN), 'description' => __('Select here type for this field', MISS_ADMIN_TEXTDOMAIN), 'param_name' => 'type_{{1}}', 'value' => array(__('Textfield', MISS_ADMIN_TEXTDOMAIN) => 'textfield', __('E-mail', MISS_ADMIN_TEXTDOMAIN) => 'email', __('Textarea', MISS_ADMIN_TEXTDOMAIN) => 'textarea', __('Checkbox', MISS_ADMIN_TEXTDOMAIN) => 'checkbox', __('Radio', MISS_ADMIN_TEXTDOMAIN) => 'radio', __('Select', MISS_ADMIN_TEXTDOMAIN) => 'select'), 'type' => 'dropdown'), array('heading' => __('{{1}} Field Label', MISS_ADMIN_TEXTDOMAIN), 'description' => __('Type here name (Label) for this field', MISS_ADMIN_TEXTDOMAIN), 'param_name' => 'label_{{1}}', 'type' => 'textfield'), array('heading' => __('{{1}} Field Values', MISS_ADMIN_TEXTDOMAIN), 'description' => __('Only for Field Type: checkbox, radio, select. You can add several values. Separate values bu comma. Example: I agree, I do not agree, ...', MISS_ADMIN_TEXTDOMAIN), 'param_name' => 'values_{{1}}', 'type' => 'textfield'), array('heading' => __('{{1}} Required Field', MISS_ADMIN_TEXTDOMAIN), 'description' => __('Check here if field is required', MISS_ADMIN_TEXTDOMAIN), 'param_name' => 'required_{{1}}', 'type' => 'checkbox', 'value' => array(__('Required', MISS_ADMIN_TEXTDOMAIN) => 'required'))); if ($atts == 'generator') { $params = array(array('heading' => __('Your E-mail', MISS_ADMIN_TEXTDOMAIN), 'description' => __('E-mail address that will receive the message from this form.', MISS_ADMIN_TEXTDOMAIN), 'param_name' => 'email', 'value' => '', 'type' => 'textfield'), array('heading' => __('Subject', MISS_ADMIN_TEXTDOMAIN), 'description' => __('You can place a custom subject line here. This is the subject that you will see in your emails.', MISS_ADMIN_TEXTDOMAIN), 'param_name' => 'subject', 'value' => '', 'type' => 'textfield'), array('heading' => __('Success Message', MISS_ADMIN_TEXTDOMAIN), 'description' => __('When the form is submitted successfully this message will be displayed to the user. Common examples would be, "Thanks you" or something similar.', MISS_ADMIN_TEXTDOMAIN), 'param_name' => 'success', 'value' => '', 'type' => 'textfield'), array('heading' => __('Spam Protection', MISS_ADMIN_TEXTDOMAIN), 'description' => __('You can choose whether to use a captcha for spam protection or the akismet plugin. If using akismet then make sure you sign up with their service and have the akismet plugin enabled.', MISS_ADMIN_TEXTDOMAIN), 'param_name' => 'spam', 'value' => array(__('Captcha', MISS_ADMIN_TEXTDOMAIN) => 'captcha', __('Akismet', MISS_ADMIN_TEXTDOMAIN) => 'akismet'), 'type' => 'checkbox'), array('heading' => __('Autoresponder', MISS_ADMIN_TEXTDOMAIN), 'description' => __('Check here for automatically respond for user which uses this form', MISS_ADMIN_TEXTDOMAIN), 'param_name' => 'autoresponder', 'value' => array(__('Enable', MISS_ADMIN_TEXTDOMAIN) => 'true'), 'type' => 'checkbox'), array('heading' => __('From Name (Autoresponder)', MISS_ADMIN_TEXTDOMAIN), 'description' => __('Name that will be displayed in a auto response letter.', MISS_ADMIN_TEXTDOMAIN), 'param_name' => 'autoresponder_name', 'type' => 'textfield', 'dependency' => array('element' => 'autoresponder', 'value' => array('true'))), array('heading' => __('From E-mail (Autoresponder)', MISS_ADMIN_TEXTDOMAIN), 'description' => __('E-mail that will be displayed in a auto response letter.', MISS_ADMIN_TEXTDOMAIN), 'param_name' => 'autoresponder_email', 'type' => 'textfield', 'dependency' => array('element' => 'autoresponder', 'value' => array('true'))), array('heading' => __('Subject (Autoresponder)', MISS_ADMIN_TEXTDOMAIN), 'description' => __('Subject that will be displayed in a auto response letter.', MISS_ADMIN_TEXTDOMAIN), 'param_name' => 'autoresponder_subject', 'type' => 'textfield', 'dependency' => array('element' => 'autoresponder', 'value' => array('true'))), array('heading' => __('Message (Autoresponder)', MISS_ADMIN_TEXTDOMAIN), 'description' => __('Message that will be displayed in a auto response letter.', MISS_ADMIN_TEXTDOMAIN), 'param_name' => 'autoresponder_message', 'type' => 'textarea', 'dependency' => array('element' => 'autoresponder', 'value' => array('true'))), array('heading' => __('Number Of Fields', MISS_ADMIN_TEXTDOMAIN), 'description' => __('Select how many fields you want.', MISS_ADMIN_TEXTDOMAIN), 'param_name' => 'multiplier', 'value' => range(1, $multiplier_cycle_number), 'type' => 'dropdown')); $params = array_merge($params, miss_vc_multiple_params($multiplier_cycle_number, $multiple_params)); return array('name' => __('Custom Contact Form', MISS_ADMIN_TEXTDOMAIN), 'base' => 'im_contactform', 'icon' => 'im-icon-envelop', 'category' => __('Theme Short-Codes', MISS_ADMIN_TEXTDOMAIN), 'params' => $params); } /* START check all variables and set default values */ miss_stripslashes(); $out = ''; extract(shortcode_atts(array('email' => '', 'subject' => '', 'success' => '', 'spam' => '', 'autoresponder' => '', 'autoresponder_name' => '', 'autoresponder_email' => '', 'autoresponder_subject' => '', 'autoresponder_message' => '', 'sidebar' => false, 'multiplier' => 1), $atts)); $i = 1; for ($i = 1; $i <= $multiplier; $i++) { foreach ($multiple_params as $key => $value) { $value['param_name'] = str_replace('{{1}}', $i, $value['param_name']); $atts[$value['param_name']] = (isset($atts[$value['param_name']]) and $atts[$value['param_name']] != '') ? $atts[$value['param_name']] : ''; } } $spam = explode(',', $spam); $akismet = in_array('akismet', $spam) ? 'true' : ''; $captcha = in_array('captcha', $spam) ? 'true' : ''; $form_id = self::_shortcode_id(); $miss_form_id = 'miss_form' . $form_id; $url = add_query_arg(array()) . '#' . $miss_form_id; $form_inputs = array(); $form_inputs['miss_email'] = is_email(trim($email)) ? trim($email) : get_option('admin_email'); $form_inputs['miss_subject'] = !empty($subject) ? $subject : ''; $form_inputs['success'] = !empty($success) ? $success : 'mail_sent'; $form_inputs['akismet'] = $akismet == 'true' ? true : false; $form_inputs['sidebar'] = !empty($sidebar) ? true : false; if ($autoresponder == 'true') { $name = !empty($autoresponder_name) ? $autoresponder_name : get_bloginfo('name'); $email = !empty($autoresponder_email) ? trim($autoresponder_email) : $form_inputs['miss_email']; $subject = !empty($autoresponder_subject) ? $autoresponder_subject : false; $message = !empty($autoresponder_message) ? $autoresponder_message : false; $form_inputs['autoresponder'][] = array('name' => $name, 'email' => $email, 'subject' => $subject, 'message' => $message); } if (isset($_POST['_miss_form_nonajax_response']['errored_fields'])) { foreach ($_POST['_miss_form_nonajax_response']['errored_fields'] as $key => $value) { $errored_fields[$value] = $value; } } /* END check all variables and set default values */ /* START assembling output variable */ $out .= '<div id="' . $miss_form_id . '" class="miss_form">'; $out .= '<form action="' . esc_url_raw($url) . '" method="post">'; $out .= isset($_POST['_miss_form_nonajax_response']) && $_POST['_miss_form_nonajax_response']['id'] == $form_id && (!$_POST['_miss_form_nonajax_response']['sidebar'] || empty($_POST['_miss_form_nonajax_response']['errored_fields'])) ? $_POST['_miss_form_nonajax_response']['messages'] : ''; $out .= '<div class="row-fluid">'; for ($i = 1; $i <= $multiplier; $i++) { $field = ''; $if_textarea_container = ''; $field_id = 'miss_field' . $i . $form_id; $atts['required_' . $i] = empty($atts['required_' . $i]) ? false : ($atts['type_' . $i] == 'email' ? 'email' : 'true'); $atts['label_' . $i] = $atts['required_' . $i] != '' ? $atts['label_' . $i] . ' *' : $atts['label_' . $i]; if (isset($errored_fields)) { $required_error = !in_array($field_id, $errored_fields) ? '' : 'required_error'; } else { $required_error = ''; } if ($atts['type_' . $i] == 'textarea') { $span = 'span12 '; $if_textarea_container = '</div><!-- class="row-fluid" --><div class="row-fluid">'; } elseif (!$form_inputs['sidebar']) { $span = 'span4 '; } else { $span = 'span6 '; } /* START check field type $atts['type_' . $i] (textarea, checkbox, select ...) and set $field variable */ if ($atts['type_' . $i] == 'textarea') { $field = '<textarea name="' . $field_id . '" id="' . $field_id . '" class="span12 ' . $required_error . ' ' . ($atts['required_' . $i] ? ' required' : '') . '" rows="5" cols="40" placeholder="' . $atts['label_' . $i] . '">' . (isset($_POST[$field_id]) ? esc_attr($_POST[$field_id]) : '') . '</textarea>'; } elseif ($atts['type_' . $i] == 'textfield' || $atts['type_' . $i] == 'email') { $field = '<input type="text" name="' . $field_id . '" id="' . $field_id . '" size="auto" class="span12 ' . $required_error . ' ' . ($atts['required_' . $i] ? ' required' : '') . '" value="' . (isset($_POST[$field_id]) ? esc_attr($_POST[$field_id]) : '') . '" placeholder="' . $atts['label_' . $i] . '"/>'; } elseif ($atts['type_' . $i] == 'radio') { if (explode(',', $atts['values_' . $i])) { $options = explode(',', $atts['values_' . $i]); $field .= '<label for="' . $field_id . '">' . $atts['label_' . $i] . '</label>'; foreach ($options as $key => $value) { $radio_id = $field_id . '_' . $key; $field .= '<div class="connector"><input type="radio" name="' . $field_id . '" id="' . $radio_id . '" class="styled ' . $required_error . ' ' . ($atts['required_' . $i] ? ' required' : '') . '"' . (!isset($_POST[$field_id]) ? $key == 0 ? ' checked="checked"' : '' : ($_POST[$field_id] == $key ? ' checked="checked"' : '')) . ' value="' . $key . '" /> <label for="' . $radio_id . '" class="radio_label">' . trim($value) . '</label></div>'; } } } elseif ($atts['type_' . $i] == 'checkbox') { if (explode(',', $atts['values_' . $i])) { $options = explode(',', $atts['values_' . $i]); $field .= '<label for="' . $field_id . '">' . $atts['label_' . $i] . '</label>'; foreach ($options as $key => $value) { $value = trim($value); $radio_id = $field_id . '_' . $key; $field .= '<div class="connector"><input type="checkbox" name="' . $radio_id . '[' . $key . ']" id="' . $radio_id . '" class="styled ' . $required_error . ' ' . ($atts['required_' . $i] ? ' required' : '') . '"' . (!isset($_POST[$radio_id]) ? '' : ($_POST[$radio_id][$key] == $value ? ' checked="checked"' : '')) . ' value="' . $value . '" /> <label for="' . $radio_id . '" class="radio_label">' . trim($value) . '</label></div>'; } } } elseif ($atts['type_' . $i] == 'select') { if (explode(',', $atts['values_' . $i])) { $options = explode(',', $atts['values_' . $i]); $field .= '<label for="' . $field_id . '">' . $atts['label_' . $i] . '</label>'; $field .= '<select name="' . $field_id . '" id="' . $field_id . '" class="span12' . $required_error . ($atts['required_' . $i] ? ' required' : '') . '">'; foreach ($options as $key => $value) { $field .= '<option value="' . trim($value) . '"' . (!isset($_POST[$field_id]) ? '' : ($_POST[$field_id] == $value ? ' selected="selected"' : '')) . '>' . trim($value) . '</option>'; } $field .= '<select>'; } } else { $field = ''; } /* END check field type (textarea, ..., select) and set $field variable */ $options = isset($options) && is_array($options) && count($options) > 0 ? $options : false; $form_inputs['fields'][$field_id] = array('type' => $atts['type_' . $i], 'label' => $atts['label_' . $i], 'required' => $atts['required_' . $i], 'value' => $options); $out .= $if_textarea_container . '<div class="' . $span . $atts['type_' . $i] . '_field' . '">' . $field . '</div><!-- class="' . $span . $atts['type_' . $i] . '_field' . '" -->' . $if_textarea_container; } // for ($i = 1; $i <= $multiplier; $i++ ) /* close previous row and open new row for captcha_and_submit */ $out .= '</div><!-- class="row-fluid" --><div class="row-fluid captcha_and_submit">'; if ($captcha == 'true') { $field_id = 'miss_field' . $i . $form_id; if (isset($errored_fields)) { $required_error = !in_array($field_id, $errored_fields) ? '' : ' required_error'; } $out .= '<div class="span8 captcha_field">'; $num1 = rand(1, 10); $num2 = rand(1, 10); $label = $num1 . ' + ' . $num2; $out .= '<input type="text" name="' . $field_id . '" id="' . $field_id . '" class="span6 required' . $required_error . '" value="' . (isset($_POST[$field_id]) ? esc_attr($_POST[$field_id]) : '') . '" placeholder="' . __('Sum *', MISS_ADMIN_TEXTDOMAIN) . '" />'; $out .= '<label class="span6" for="' . $field_id . '"> ' . $label . ' </label>'; $out .= '</div><!-- class="captcha_field" -->'; $form_inputs['fields'][$field_id] = array('type' => 'captcha', 'label' => $label, 'required' => 'captcha'); $form_inputs['fields'][$field_id]['captcha'] = $num1 + $num2; } $out .= '<div class="span4 submit_field">'; $out .= '<input type="submit" value="' . __('Submit', MISS_TEXTDOMAIN) . '" class="contact_form_submit styled_button" />'; $out .= '<div class="miss_contact_feedback">'; $out .= '<img src="' . esc_url(THEME_IMAGES_ASSETS . '/dummy/transparent.gif') . '" style="background-image: url(' . THEME_IMAGES_ASSETS . '/preloaders/preloader.gif);" alt="Loading">'; $out .= '</div>'; $out .= '</div><!-- class="submit_field" -->'; $encode_form_inputs = miss_encode($form_inputs, $serialize = true); $out .= '<div class="" style="display:none;">'; $out .= '<input type="hidden" name="_miss_form" value="' . $form_id . '">'; $out .= '<input type="hidden" name="_miss_form_encode" value="' . $encode_form_inputs . '">'; $out .= '</div>'; $out .= '</div>'; /* close row captcha_and_submit */ $out .= '</form>'; $out .= '</div><!-- id="' . $miss_form_id . '" class="miss_form" -->'; /* END assembling output variable */ return $out; }
/** * */ function export_options($value) { $toggle_class = !empty($value['toggle_class']) ? $value['toggle_class'] . ' ' : ''; $out = '<div class="' . $toggle_class . 'miss_option_set textarea_option_set">'; $out .= $this->option_start($value); $options = $this->saved_options; $export_options = array(); if (!empty($options)) { foreach ($options as $key => $option) { if (is_string($option)) { $export_options[$key] = preg_replace("/(\r\n|\r|\n)\\s*/i", '<br /><br />', stripslashes($option)); } else { $export_options[$key] = $option; } } } if (!empty($export_options)) { $export_options = array_merge($export_options, array('missmyway_options_export' => true)); $export_options = miss_encode($export_options, $serialize = true); } $out .= '<textarea rows="8" cols="8" name="' . MISS_SETTINGS . '[' . $value['id'] . ']" id="' . $value['id'] . '" class="miss_textarea">' . $export_options . '</textarea><br />'; $out .= $this->option_end($value); $out .= '</div><!-- .textarea_option_set -->'; return $out; }