'', 'redirect' => '', 'hidden' => '', 'email_to' => '', ), $atts ) ); // Verify form number self::$global_options = FSCF_Util::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.', 'si-contact-form' ); return; } $frm_id = self::$form_id_num; // Get the form options self::$form_options = FSCF_Util::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', 'si-contact-form' ), self::$form_id_num ); return; } // Update some language // The update_lang function receives the array by reference, so it can be changed FSCF_Util::update_lang(self::$form_options); // Store shortcode atts // http://www.fastsecurecontactform.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.', 'si-contact-form' ); 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', 'si-contact-form') == $_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 ( FSCF_Process::$form_processed && FSCF_Process::$form_id_num == self::$form_id_num && empty(FSCF_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 (!isset(self::$add_recaptcha_js)) { self::$add_recaptcha_js_array = array(); self::$add_recaptcha_js = ''; } if ( ! empty(FSCF_Process::$form_errors) && FSCF_Process::$form_id_num == self::$form_id_num ) { // The form was processed, but had errors if ( ! empty(FSCF_Process::$form_data) ) { // If this is not true, there is an internal error... self::$form_content = array_merge( self::$form_content, FSCF_Process::$form_data ); self::$form_errors = array_merge( self::$form_errors, FSCF_Process::$form_errors ); // XXX later, improve variable usage for error tracking? self::$contact_error = true; } } // ***** Display the Form ***** self::$placeholder = 0; self::$add_recaptcha_script = 0; $string = "\n\n
\n" . self::$form_options['welcome']; $string = self::display_form($string); } return($string); } // end function process_short_code() 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 external_style_head() { // puts style on form preview when external css is enabled wp_enqueue_script('jquery'); ?> 'fscf-div-form', // Form DIV, how wide is the form DIV 'left_box_style' => 'fscf-div-left-box', // left box DIV, container for vcita 'right_box_style' => 'fscf-div-right-box', // right box DIV, container for vcita 'clear_style' => 'fscf-div-clear', // clear both 'field_left_style' => 'fscf-div-field-left', // field left 'field_prefollow_style' => 'fscf-div-field-prefollow', // field prefollow 'field_follow_style' => 'fscf-div-field-follow', // field follow 'title_style' => 'fscf-div-label', // Input labels alignment DIV 'field_div_style' => 'fscf-div-field', // Input fields alignment DIV 'captcha_div_style_sm' => 'fscf-div-captcha-sm', // Small CAPTCHA DIV 'captcha_div_style_m' => 'fscf-div-captcha-m', // Large CAPTCHA DIV 'captcha_image_style' => 'fscf-image-captcha', // CAPTCHA image alignment 'captcha_reload_image_style' => 'fscf-image-captcha-refresh', // CAPTCHA refresh image alignment 'submit_div_style' => 'fscf-div-submit', // Submit DIV 'border_style' => 'fscf-fieldset', // style of the fieldset box (if enabled) // Styles of labels, fields and text 'required_style' => 'fscf-required-indicator', // required field indicator 'required_text_style' => 'fscf-required-text', // required field text 'hint_style' => 'fscf-hint-text', // small text hints like file types 'error_style' => 'fscf-div-error', // Input validation messages 'redirect_style' => 'fscf-div-redirecting', // Redirecting message 'fieldset_style' => 'fscf-fieldset-field', // style of the fieldset box (for a field) 'label_style' => 'fscf-label', // Field labels 'option_label_style' => 'fscf-option-label', // Options labels 'field_style' => 'fscf-input-text', // Input text fields 'captcha_input_style' => 'fscf-input-captcha', // CAPTCHA input field 'textarea_style' => 'fscf-input-textarea', // Input Textarea 'select_style' => 'fscf-input-select', // Input Select 'checkbox_style' => 'fscf-input-checkbox', // Input checkbox 'radio_style' => 'fscf-input-radio', // Input radio 'button_style' => 'fscf-button-submit', // Submit button 'reset_style' => 'fscf-button-reset', // Reset button 'vcita_button_style' => 'fscf-button-vcita', // vCita button 'vcita_div_button_style' => 'fscf-button-div-vcita', // vCita button div box 'powered_by_style' => 'fscf-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'); // check for custom post types, // none of the field slugs can be the same as a post type rewrite_slug // or you will get "page not found" when posting the form with that field filled in $pt_args = array('public' => true,'_builtin' => false); $post_types = get_post_types( $pt_args, 'objects' ); $pt_slugs = array(); if ( $post_types ) { foreach ( $post_types as $post_type ) { $pt_slugs[] = ( isset( $post_type->rewrite_slug ) ) ? $post_type->rewrite_slug : $post_type->name; } } if ($fields && is_array($fields)) { foreach ($decoy_fields as $index => $decoy) { if (isset($fields[$decoy])) // decoy field matches a form field, remove the decoy from list unset($decoy_fields[$index]); if (!empty($pt_slugs) && in_array( $decoy, $pt_slugs ) ) unset($decoy_fields[$index]); // decoy field matches a custom post type, remove the decoy from list } } 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 $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 = FSCF_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 .= '