예제 #1
0
function cscf_ContactForm()
{
    $contact = new cscf_Contact();
    if ($contact->IsValid()) {
        if ($contact->SendMail()) {
            $view = new CSCF_View('message-sent');
            $view->Set('heading', cscf_PluginSettings::SentMessageHeading());
            $view->Set('message', cscf_PluginSettings::SentMessageBody());
        } else {
            $view = new CSCF_View('message-not-sent');
        }
        return $view->Render();
    }
    //here we need some jquery scripts and styles, so load them here
    if (cscf_PluginSettings::UseClientValidation() == true) {
        wp_enqueue_script('jquery-validate');
        wp_enqueue_script('cscf-validate');
    }
    //only load the stylesheet if required
    if (cscf_PluginSettings::LoadStyleSheet() == true) {
        wp_enqueue_style('cscf-bootstrap');
    }
    $messageSentView = new CSCF_View('message-sent');
    $messageSentView->Set('heading', cscf_PluginSettings::SentMessageHeading());
    $messageSentView->Set('message', cscf_PluginSettings::SentMessageBody());
    $view = new CSCF_View('contact-form');
    $view->Set('contact', $contact);
    $view->Set('message', cscf_PluginSettings::Message());
    $view->Set('version', CSCF_VERSION_NUM);
    $view->Set('confirmEmail', cscf_PluginSettings::ConfirmEmail());
    $view->Set('postID', get_the_ID());
    $view->Set('messageSentView', $messageSentView);
    $view->Set('messageNotSentView', new CSCF_View('message-not-sent'));
    return $view->Render();
}
 public function SendMail()
 {
     apply_filters('cscf_spamfilter', $this);
     if ($this->IsSpam === true) {
         return true;
     }
     $filters = new cscf_Filters();
     if (cscf_PluginSettings::OverrideFrom() & cscf_PluginSettings::FromEmail() != "") {
         $filters->fromEmail = cscf_PluginSettings::FromEmail();
     } else {
         $filters->fromEmail = $this->Email;
     }
     $filters->fromName = $this->Name;
     //add filters
     $filters->add('wp_mail_from');
     $filters->add('wp_mail_from_name');
     //headers
     $header = "Reply-To: " . $this->Email . "\r\n";
     //message
     $message = "From: " . $this->Name . "\n\n";
     $message .= "Email: " . $this->Email . "\n\n";
     $message .= "Message:\n\n" . $this->Message;
     $result = wp_mail(cscf_PluginSettings::RecipientEmails(), cscf_PluginSettings::Subject(), stripslashes($message), $header);
     //remove filters (play nice)
     $filters->remove('wp_mail_from');
     $filters->remove('wp_mail_from_name');
     return $result;
 }
                    <?php 
if (isset($contact->Errors['message'])) {
    echo $contact->Errors['message'];
}
?>
                </span>
            </div>

            <!-- recaptcha -->
            <?php 
if ($contact->RecaptchaPublicKey != '' && $contact->RecaptchaPrivateKey != '') {
    ?>
                <script type="text/javascript">
                 var RecaptchaOptions = {
                    theme : '<?php 
    echo cscf_PluginSettings::Theme();
    ?>
'
                 };
                 </script>            
                <div class="control-group form-group<?php 
    if (isset($contact->Errors['recaptcha'])) {
        echo ' error';
    }
    ?>
">
                        <div id="recaptcha_div">
                            <?php 
    echo cscf_recaptcha_get_html($contact->RecaptchaPublicKey, null, isset($_SERVER['HTTPS']));
    ?>
                        <div for="cscf_recaptcha" class="help-block has-error error"><?php 
예제 #4
0
    public function create_fields($args)
    {
        $fieldname = $args[0];
        switch ($fieldname) {
            case 'use_recaptcha':
                $checked = cscf_PluginSettings::UseRecaptcha() == true ? "checked" : "";
                ?>
<input type="checkbox" <?php 
                echo $checked;
                ?>
  id="use_recaptcha"
                         name="<?php 
                echo CSCF_OPTIONS_KEY;
                ?>
[use_recaptcha]"><?php 
                break;
            case 'load_stylesheet':
                $checked = cscf_PluginSettings::LoadStyleSheet() == true ? "checked" : "";
                ?>
<input type="checkbox" <?php 
                echo $checked;
                ?>
  id="load_stylesheet"
                         name="<?php 
                echo CSCF_OPTIONS_KEY;
                ?>
[load_stylesheet]"><?php 
                break;
            case 'recaptcha_public_key':
                $disabled = cscf_PluginSettings::UseRecaptcha() == false ? "readonly" : "";
                ?>
<input <?php 
                echo $disabled;
                ?>
 type="text" size="60" id="recaptcha_public_key"
                                                  name="<?php 
                echo CSCF_OPTIONS_KEY;
                ?>
[recaptcha_public_key]"
                                                  value="<?php 
                echo cscf_PluginSettings::PublicKey();
                ?>
" /><?php 
                break;
            case 'recaptcha_private_key':
                $disabled = cscf_PluginSettings::UseRecaptcha() == false ? "readonly" : "";
                ?>
<input <?php 
                echo $disabled;
                ?>
 type="text" size="60" id="recaptcha_private_key"
                                                  name="<?php 
                echo CSCF_OPTIONS_KEY;
                ?>
[recaptcha_private_key]"
                                                  value="<?php 
                echo cscf_PluginSettings::PrivateKey();
                ?>
" /><?php 
                break;
            case 'recipient_emails':
                ?>
                <ul id="recipients"><?php 
                foreach (cscf_PluginSettings::RecipientEmails() as $key => $recipientEmail) {
                    ?>
                    <li class="recipient_email" data-element="<?php 
                    echo $key;
                    ?>
">
                        <input class="enter_recipient" type="email" size="50"
                               name="<?php 
                    echo CSCF_OPTIONS_KEY;
                    ?>
[recipient_emails][<?php 
                    echo $key;
                    ?>
]"
                               value="<?php 
                    echo $recipientEmail;
                    ?>
"/>
                        <input class="add_recipient" title="Add New Recipient" type="submit" name="add_recipient"
                               value="+">
                        <input class="remove_recipient" title="Remove This Recipient" type="submit"
                               name="remove_recipient[<?php 
                    echo $key;
                    ?>
]" value="-">
                    </li>

                <?php 
                }
                ?>
</ul><?php 
                break;
            case 'confirm-email':
                $checked = cscf_PluginSettings::ConfirmEmail() == true ? "checked" : "";
                ?>
<input type="checkbox" <?php 
                echo $checked;
                ?>
  id="confirm-email"
                         name="<?php 
                echo CSCF_OPTIONS_KEY;
                ?>
[confirm-email]"><?php 
                break;
            case 'override-from':
                $checked = cscf_PluginSettings::OverrideFrom() == true ? "checked" : "";
                ?>
<input type="checkbox" <?php 
                echo $checked;
                ?>
  id="override-from"
                         name="<?php 
                echo CSCF_OPTIONS_KEY;
                ?>
[override-from]"><?php 
                break;
            case 'email-sender':
                $checked = cscf_PluginSettings::EmailToSender() == true ? "checked" : "";
                ?>
<input type="checkbox" <?php 
                echo $checked;
                ?>
  id="email-sender"
                         name="<?php 
                echo CSCF_OPTIONS_KEY;
                ?>
[email-sender]"><?php 
                break;
            case 'from-email':
                $disabled = cscf_PluginSettings::OverrideFrom() == false ? "readonly" : "";
                ?>
<input <?php 
                echo $disabled;
                ?>
 type="text" size="60" id="from-email"
                                                  name="<?php 
                echo CSCF_OPTIONS_KEY;
                ?>
[from-email]"
                                                  value="<?php 
                echo cscf_PluginSettings::FromEmail();
                ?>
" /><?php 
                break;
            case 'subject':
                ?>
<input type="text" size="60" id="subject" name="<?php 
                echo CSCF_OPTIONS_KEY;
                ?>
[subject]"
                         value="<?php 
                echo cscf_PluginSettings::Subject();
                ?>
" /><?php 
                break;
            case 'sent_message_heading':
                ?>
<input type="text" size="60" id="sent_message_heading"
                         name="<?php 
                echo CSCF_OPTIONS_KEY;
                ?>
[sent_message_heading]"
                         value="<?php 
                echo cscf_PluginSettings::SentMessageHeading();
                ?>
" /><?php 
                break;
            case 'sent_message_body':
                ?>
<textarea cols="63" rows="8"
                            name="<?php 
                echo CSCF_OPTIONS_KEY;
                ?>
[sent_message_body]"><?php 
                echo cscf_PluginSettings::SentMessageBody();
                ?>
</textarea><?php 
                break;
            case 'message':
                ?>
<textarea cols="63" rows="8"
                            name="<?php 
                echo CSCF_OPTIONS_KEY;
                ?>
[message]"><?php 
                echo cscf_PluginSettings::Message();
                ?>
</textarea><?php 
                break;
            case 'theme':
                $theme = cscf_PluginSettings::Theme();
                $disabled = cscf_PluginSettings::UseRecaptcha() == false ? "disabled" : "";
                ?>
                <select <?php 
                echo $disabled;
                ?>
 id="theme" name="<?php 
                echo CSCF_OPTIONS_KEY;
                ?>
[theme]">
                    <option <?php 
                echo $theme == "light" ? "selected" : "";
                ?>
                        value="light"><?php 
                _e('Light', 'cleanandsimple');
                ?>
</option>
                    <option <?php 
                echo $theme == "dark" ? "selected" : "";
                ?>
                        value="dark"><?php 
                _e('Dark', 'cleanandsimple');
                ?>
</option>
                </select>
                <?php 
                break;
            case 'use_client_validation':
                $checked = cscf_PluginSettings::UseClientValidation() == true ? "checked" : "";
                ?>
<input type="checkbox" <?php 
                echo $checked;
                ?>
  id="use_client_validation"
                         name="<?php 
                echo CSCF_OPTIONS_KEY;
                ?>
[use_client_validation]"><?php 
                break;
            default:
                break;
        }
    }
예제 #5
0
 public function SendMail()
 {
     apply_filters('cscf_spamfilter', $this);
     if ($this->IsSpam === true) {
         return true;
     }
     $filters = new cscf_Filters();
     if (cscf_PluginSettings::OverrideFrom() & cscf_PluginSettings::FromEmail() != "") {
         $filters->fromEmail = cscf_PluginSettings::FromEmail();
     } else {
         $filters->fromEmail = $this->Email;
     }
     $filters->fromName = $this->Name;
     //add filters
     $filters->add('wp_mail_from');
     $filters->add('wp_mail_from_name');
     //headers
     $header = "Reply-To: " . $this->Email . "\r\n";
     //message
     $message = "From: " . $this->Name . "\n\n";
     $message .= "Email: " . $this->Email . "\n\n";
     $message .= "Page URL: " . get_permalink($this->PostID) . "\n\n";
     $message .= "Message:\n\n" . $this->Message;
     $result = wp_mail(cscf_PluginSettings::RecipientEmails(), cscf_PluginSettings::Subject(), stripslashes($message), $header);
     //remove filters (play nice)
     $filters->remove('wp_mail_from');
     $filters->remove('wp_mail_from_name');
     //send an email to the form-filler
     if ($this->EmailToSender) {
         $recipients = cscf_PluginSettings::RecipientEmails();
         if (cscf_PluginSettings::OverrideFrom() & cscf_PluginSettings::FromEmail() != "") {
             $filters->fromEmail = cscf_PluginSettings::FromEmail();
         } else {
             $filters->fromEmail = $recipients[0];
         }
         $filters->fromName = get_bloginfo('name');
         //add filters
         $filters->add('wp_mail_from');
         $filters->add('wp_mail_from_name');
         $header = "";
         $message = cscf_PluginSettings::SentMessageBody() . "\n\n";
         $message .= __("Here is a copy of your message :", "cleanandsimple") . "\n\n";
         $message .= $this->Message;
         $result = wp_mail($this->Email, cscf_PluginSettings::Subject(), stripslashes($message), $header);
         //remove filters (play nice)
         $filters->remove('wp_mail_from');
         $filters->remove('wp_mail_from_name');
     }
     return $result;
 }