Settings
Version: 3.1.0
Author: Taylor Lovett
Author URI: http://www.taylorlovett.com
*/
/*
Copyright (C) 2010-2011 Taylor Lovett, taylorlovett.com (admin@taylorlovett.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
require_once('custom-contact-forms-db.php');
require_once('custom-contact-forms-mailer.php');
require_once('custom-contact-forms-images.php');
if (!class_exists('CustomContactForms')) {
class CustomContactForms extends CustomContactFormsDB {
var $adminOptionsName = 'customContactFormsAdminOptions';
var $widgetOptionsName = 'widget_customContactForms';
var $version = '2.1.0';
var $form_errors;
var $error_return;
var $gets;
var $current_thank_you_message;
var $current_thank_you_message_title;
var $fixed_fields = array('customcontactforms_submit' => '',
'fid' => '',
'fixedEmail' => 'Use this field if you want the plugin to throw an error on fake emails.',
'form_page' => '',
'captcha' => 'This field requires users to type numbers in an image preventing spam.',
'ishuman' => 'This field requires users to check a box to prove they aren\'t a spam bot.'
);
function CustomContactForms() {
parent::CustomContactFormsDB();
$this->form_errors = array();
}
function getAdminOptions() {
$admin_email = get_option('admin_email');
$customcontactAdminOptions = array('show_widget_home' => 1, 'show_widget_pages' => 1, 'show_widget_singles' => 1, 'show_widget_categories' => 1, 'show_widget_archives' => 1, 'default_to_email' => $admin_email, 'default_from_email' => $admin_email, 'default_form_subject' => 'Someone Filled Out Your Contact Form!',
'remember_field_values' => 0, 'author_link' => 1, 'enable_widget_tooltips' => 1, 'wp_mail_function' => 1, 'form_success_message_title' => 'Form Success!', 'form_success_message' => 'Thank you for filling out our web form. We will get back to you ASAP.', 'enable_jquery' => 1, 'code_type' => 'XHTML'); // default general settings
$customcontactOptions = get_option($this->adminOptionsName);
if (!empty($customcontactOptions)) {
foreach ($customcontactOptions as $key => $option)
$customcontactAdminOptions[$key] = $option;
}
update_option($this->adminOptionsName, $customcontactAdminOptions);
return $customcontactAdminOptions;
}
function init() {
$this->storeGets();
$this->getAdminOptions();
if (!is_admin()) {
$this->startSession();
$this->processForms();
}
}
function insertStyleSheets() {
wp_register_style('customContactFormsStyleSheet', get_option('siteurl') . '/wp-content/plugins/custom-contact-forms/custom-contact-forms.css');
wp_enqueue_style('customContactFormsStyleSheet');
}
function insertAdminScripts() {
wp_enqueue_script('jquery');
wp_enqueue_script('ccf-main', get_option('siteurl') . '/wp-content/plugins/custom-contact-forms/js/custom-contact-forms-admin.js', array('jquery', 'jquery-ui-core', 'jquery-ui-tabs'/*, 'jquery-ui-draggable', 'jquery-ui-resizable', 'jquery-ui-dialog'*/), '1.0');
}
function insertFrontEndScripts() {
if (!is_admin()) {
$admin_options = $this->getAdminOptions();
if ($admin_options[enable_jquery] == 1) {
wp_enqueue_script('jquery');
wp_enqueue_script('jquery-tools', get_option('siteurl') . '/wp-content/plugins/custom-contact-forms/js/jquery.tools.min.js');
//wp_enqueue_script('jquery-ui-position', get_option('siteurl') . '/wp-content/plugins/custom-contact-forms/js/jquery.ui.position.js');
//wp_enqueue_script('jquery-ui-widget', get_option('siteurl') . '/wp-content/plugins/custom-contact-forms/js/jquery.ui.widget.js');
//wp_enqueue_script('jquery-bgiframe', get_option('siteurl') . '/wp-content/plugins/custom-contact-forms/js/jquery.bgiframe-2.1.1.js');
wp_enqueue_script('ccf-main', get_option('siteurl') . '/wp-content/plugins/custom-contact-forms/js/custom-contact-forms.js', array('jquery', 'jquery-ui-core', 'jquery-ui-tabs', 'jquery-ui-resizable'/*, 'jquery-ui-draggable', 'jquery-ui-dialog'*/), '1.0');
//jquery-ui-position
}
}
}
function setFormError($key, $message) {
$this->form_errors[$key] = $message;
}
function storeGets() {
foreach ($_GET as $k => $v) {
$this->gets[$k] = $v;
}
}
function getFormError($key) {
return $this->form_errors[$key];
}
function getAllFormErrors() {
return $this->form_errors;
}
function printAdminPage() {
$admin_options = $this->getAdminOptions();
if ($_POST[form_create]) {
parent::insertForm($_POST[form]);
} elseif ($_POST[field_create]) {
parent::insertField($_POST[field]);
} elseif ($_POST[general_settings]) {
$admin_options[default_to_email] = $_POST[default_to_email];
$admin_options[default_from_email] = $_POST[default_from_email];
$admin_options[default_form_subject] = $_POST[default_form_subject];
$admin_options[show_widget_categories] = $_POST[show_widget_categories];
$admin_options[show_widget_singles] = $_POST[show_widget_singles];
$admin_options[show_widget_pages] = $_POST[show_widget_pages];
$admin_options[show_widget_archives] = $_POST[show_widget_archives];
$admin_options[show_widget_home] = $_POST[show_widget_home];
$admin_options[custom_thank_you] = $_POST[custom_thank_you];
$admin_options[author_link] = $_POST[author_link];
$admin_options[enable_jquery] = $_POST[enable_jquery];
$admin_options[code_type] = $_POST[code_type];
$admin_options[form_success_message] = $_POST[form_success_message];
$admin_options[form_success_message_title] = $_POST[form_success_message_title];
$admin_options[wp_mail_function] = $_POST[wp_mail_function];
$admin_options[enable_widget_tooltips] = $_POST[enable_widget_tooltips];
$admin_options[remember_field_values] = $_POST[remember_field_values];
update_option($this->adminOptionsName, $admin_options);
} elseif ($_POST[field_edit]) {
parent::updateField($_POST[field], $_POST[fid]);
} elseif ($_POST[field_delete]) {
parent::deleteField($_POST[fid]);
} elseif ($_POST[form_delete]) {
parent::deleteForm($_POST[fid]);
} elseif ($_POST[form_edit]) {
parent::updateForm($_POST[form], $_POST[fid]);
} elseif ($_POST[form_add_field]) {
parent::addFieldToForm($_POST[field_id], $_POST[fid]);
} elseif ($_POST[disattach_field]) {
parent::disattachField($_POST[disattach_field_id], $_POST[fid]);
} elseif ($_POST[style_create]) {
parent::insertStyle($_POST[style]);
} elseif ($_POST[style_edit]) {
parent::updateStyle($_POST[style], $_POST[sid]);
} elseif ($_POST[style_delete]) {
parent::deleteStyle($_POST[sid]);
} elseif ($_POST[contact_author]) {
$this_url = (!empty($_SERVER['HTTP_REFERER'])) ? $_SERVER['HTTP_REFERER'] : $_SERVER['SERVER_NAME'];
$this->contactAuthor($_POST[name], $_POST[email], $this_url, $_POST[message], $_POST[type]);
}
$styles = parent::selectAllStyles();
$style_options = '';
foreach ($styles as $style)
$style_options .= '';
?>
2. Create fields and attach those fields to the forms of your choice. * Attach the fields in the order that you want them to show up in the form. If you mess up you can detach and reattach them.
3. Display those forms in posts and pages by inserting the code: [customcontact form=FORMID]. Replace FORMID with the id listed to the left of the form slug next to the form of your choice above. You can also display forms in theme files; the code for this is provided within each forms admin section.
4. Prevent spam by attaching the fixed field, captcha or ishuman. Captcha requires users to type in a number shown on an image. Ishuman requires users to check a box to prove they aren't a spam bot.
5. Add a form to your sidebar, by dragging the Custom Contact Form widget in to your sidebar.
6. Configure the General Settings appropriately; this is important if you want to receive your web form messages!
7. Create form styles to change your forms appearances. The image below explains how each style field can change the look of your forms.
8. (advanced) If you are confident in your HTML and CSS skills, you can use the Custom HTML Forms feature as a framework and write your forms from scratch. This allows you to use this plugin simply to process your form requests. The Custom HTML Forms feature will process and email any form variables sent to it regardless of whether they are created in the fields manager.
Create A Style for Your Forms
Manage Form Styles
Custom Contact Forms Plugin News
displayPluginNewsFeed(); ?>
Report a Bug/Suggest a Feature
Custom HTML Forms (Advanced)
If you know HTML and simply want to use this plugin to process form requests, this feature is for you.
The following HTML is a the framework to which you must adhere. In order for your form to work you MUST do the following:
a) Keep the form action/method the same (yes the action is supposed to be empty), b) Include all the hidden fields shown below, c) provide a
hidden field with a success message or thank you page (both hidden fields are included below, you must choose one or the other and fill in the value part of the input field appropriately.
getAllFormErrors();
if (!empty($errors)) {
$out = '