Exemplo n.º 1
0
 static function email_sent_redirect()
 {
     // displays thank you after email is sent
     // Redirct after email sent?
     self::$redirect_enable = 'false';
     if (self::$form_options['redirect_enable'] == 'true') {
         self::$redirect_enable = 'true';
         $ctf_redirect_url = self::$form_options['redirect_url'];
     }
     // allow shortcode redirect to override options redirect settings
     if (self::$global_options['enable_php_sessions'] == 'true' && $_SESSION['fsc_shortcode_redirect_' . self::$form_id_num] != '') {
         self::$redirect_enable = 'true';
         $ctf_redirect_url = strip_tags($_SESSION['fsc_shortcode_redirect_' . self::$form_id_num]);
     }
     if (self::$redirect_enable == 'true') {
         if ($ctf_redirect_url == '#') {
             // if you put # for the redirect URL it will redirect to the same page the form is on regardless of the page.
             $ctf_redirect_url = self::$form_action_url;
         }
         // filter hook for changing the redirect URL. You could make a function that changes it based on fields
         $ctf_redirect_url = apply_filters('si_contact_redirect_url', $ctf_redirect_url, self::$email_fields, self::$form_data['mailto_id'], self::$form_id_num);
         // redirect query string code
         if (self::$form_options['redirect_query'] == 'true') {
             // build query string
             $query_string = self::export_convert(self::$email_fields, self::$form_options['redirect_rename'], self::$form_options['redirect_ignore'], self::$form_options['redirect_add'], 'query');
             if (!preg_match("/\\?/", $ctf_redirect_url)) {
                 $ctf_redirect_url .= '?' . $query_string;
             } else {
                 $ctf_redirect_url .= '&' . $query_string;
             }
         }
         $ctf_redirect_timeout = absint(self::$form_options['redirect_seconds']);
         // time in seconds to wait before loading another Web page
         if ($ctf_redirect_timeout == 0) {
             // use wp_redirect when timeout seconds is 0.
             // So now if you set the timeout to 0 seconds, then post the form, it gets instantly redirected to the redirect URL
             // and you are responsible to display the "your message has been sent, thank you" message there.
             wp_redirect(esc_url_raw($ctf_redirect_url));
             exit;
         }
         // meta refresh page timer feature
         // allows some seconds to to display the "your message has been sent, thank you" message.
         self::$meta_string = "<meta http-equiv=\"refresh\" content=\"{$ctf_redirect_timeout};URL=" . esc_url($ctf_redirect_url) . "\">\n";
         if (is_admin()) {
             add_action('admin_head', 'FSCF_Process::meta_refresh', 1);
         } else {
             add_action('wp_head', 'FSCF_Process::meta_refresh', 1);
         }
     }
     // end if (self::$redirect_enable == 'true')
 }