示例#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();
}
示例#2
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;
        }
    }