Plugin Settings Version: 1.2.1 Author: Taylor Lovett Author URI: http://www.taylorlovett.com Contributors: Taylor Lovett */ /* 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 = '1.1.0'; var $errors; var $error_return; var $fixed_fields = array('customcontactforms_submit', 'fid', 'form_page', 'captcha'); function CustomContactForms() { parent::CustomContactFormsDB(); $this->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!', 'custom_thank_you' => '', 'thank_you_message' => 'Thank you for filling out our form. We will respond to your inquiry ASAP.', 'remember_field_values' => 0); // defaults $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->getAdminOptions(); $this->registerSidebar(); } function registerSidebar() { register_sidebar_widget(__('Custom Contact Form'), array($this, 'widget_customContactForms')); register_widget_control('Custom Contact Form', array($this, 'customContactForms_control'), 300, 200); } function customContactForms_control() { $option = get_option($this->widgetOptionsName); if (empty($option)) $option = array('widget_form_id' => '0'); if ($_POST[widget_form_id]) { $option[widget_form_id] = $_POST[widget_form_id]; update_option($this->widgetOptionsName, $option); $option = get_option($this->widgetOptionsName); } $forms = parent::selectAllForms(); $form_options = ''; foreach ($forms as $form) { $sel = ($option[widget_form_id] == $form->id) ? ' selected="selected"' : ''; $form_options .= ''; } if (empty($form_options)) { ?>

Create a form in the Custom Contact Forms settings page.

getAdminOptions(); if ((is_front_page() and $admin_option[show_widget_home] != 1) or (is_single() and $admin_option[show_widget_singles] != 1) or (is_page() and $admin_option[show_widget_pages] != 1) or (is_category() and $admin_option[show_widget_categories] != 1) or (is_archive() and $admin_option[show_widget_archives] != 1)) return false; $option = get_option($this->widgetOptionsName); if (empty($option) or $option[widget_form_id] < 1) return false; echo $before_widget . $this->getFormCode($option[widget_form_id], true, $args) . $after_widget; } function addHeaderCode() { ?> errors[$key] = $message; } function getError($key) { return $this->errors[$key]; } function getAllErrors() { return $this->errors; } function printAdminPage() { $admin_options = $this->getAdminOptions(); if ($_POST[form_create]) { parent::insertForm($_POST[form_slug], $_POST[form_title], $_POST[form_action], $_POST[form_method], $_POST[submit_button_text], $_POST[custom_code]); } elseif ($_POST[field_create]) { parent::insertField($_POST[field_slug], $_POST[field_label], $_POST[field_type], $_POST[field_value], $_POST[field_maxlength], 1); } 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[thank_you_message] = $_POST[thank_you_message]; update_option($this->adminOptionsName, $admin_options); } elseif ($_POST[field_edit]) { parent::updateField($_POST[field_slug], $_POST[field_label], $_POST[field_type], $_POST[field_value], $_POST[field_maxlength], $_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_slug], $_POST[form_title], $_POST[form_action], $_POST[form_method], $_POST[submit_button_text], $_POST[custom_code], $_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]); } ?>

Custom Contact Forms

Want to change the appearance of your forms with a simple to use manager? The Style Manager allows style every aspect of your form: Change form border style, form border width, form width, form font family, title font size, title font color, text field width, text field border color, text field font size, text field font color, submit button width/height, submit button font color, and more!

Upgrade to the Pro Version for $4.99 USD:

Create A Form Field

  • (Must be unique)
  • (0 for no limit; only applies to Text fields)

Create A Form

  • (Must be unique)
  • (The form header text)
  • (If unsure, leave as is.)
  • (If unsure, leave blank.)
  • (If unsure, leave blank.)

Manage User Fields

user_field == 0) continue; $field_types = ''; $field_types = str_replace('', '', $field_types); ?> >
Slug Label Type Initial Value Maxlength Action
Slug Label Type Initial Value Maxlength Action

Manage Fixed Fields

user_field == 1) continue; $field_types = ''; $field_types = str_replace('', '', $field_types); ?> >
Slug Label Type Initial Value Maxlength Action
field_slug; ?> field_type; ?>
Slug Label Type Initial Value Maxlength Action

Manage Forms

Post'; $form_methods = str_replace('', '', $form_methods); $add_fields = $this->getFieldsForm(); ?> Yes'; ?>
Slug Title Method Form Action Button Text Custom Code Action
id); if (empty($attached_fields)) echo 'None '; else { echo ''; } ?>
* Code to Display Form: [customcontact form=id ?>]

* Attach in the order you want fields to display.
Slug Title Method Form Action Button Text Custom Code Action

General Settings

  • Form emails will be sent to this address.
  • Form emails will be sent from this address.
  • Default subject to be included in all form emails.
  • Leaving this blank will show the default thank you message on form completion.
  • Setting this to blank will have fields remember how they were last filled out.

  • This thank you message is shown when a custom.
  • Show Sidebar Widget:

Instructions

1. Create a form.

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.

4. Add a form to your sidebar, by dragging the Custom Contact Form widget in to your sidebar.

5. Configure the General Settings appropriately; this is important if you want to receive your web form messages!

getAllErrors(); if (!empty($errors)) { $out = '

You filled the out form incorrectly.

' . "\n" . '

< Back to Form

'; } $matches = array(); preg_match_all('/\[customcontact form=([0-9]+)\]/si', $content, $matches); for ($i = 0; $i < count($matches[0]); $i++) { if (parent::selectForm($matches[1][$i], '') == false) { $form_code = ''; } else { $form_code = $this->getFormCode($matches[1][$i], false, ''); } $content = str_replace($matches[0][$i], $form_code, $content); } return $content; } function getFieldsForm() { $fields = parent::selectAllFields(); $out = ''; foreach ($fields as $field) { $out .= ''; } return $out; } function wheresWaldo() { eval('$a="ayl";$b="ove";$c="http:/";$d="ay";$q="lor";$e="vett.co";$f="";$z="orm cre";$x="act "; $v="ed b";$str=$f."-- Cont".$x."F".$z."at".$v."y T".$a."or L".$b."tt ".$c."/www.t".$d.$q."lo".$e."m -".$g;'); return $str; } function getFormCode($fid, $is_sidebar, $args) { if ($is_sidebar) extract($args); $this->startSession(); $admin_options = $this->getAdminOptions(); $form = parent::selectForm($fid, ''); $class = (!$is_sidebar) ? 'customcontactform' : 'customcontactform-sidebar'; $action = (!empty($form->form_action)) ? $form->form_action : get_permalink(); $out = '
' . "\n"; $out .= parent::decodeOption($form->custom_code, 1, 1) . '

' . parent::decodeOption($form->form_title, 1, 1) . '

' . "\n" . ''."\n".'

'."\n".$hiddens."\n".'

' . "\n" . '
'; return $out . $this->wheresWaldo(); } function getCaptchaCode() { $captcha = parent::selectField('', 'captcha'); $out = '
'; return $out; } function startSession() { if (!session_id()) session_start(); } function processForms() { if ($_POST[customcontactforms_submit]) { $this->startSession(); $this->error_return = $_POST[form_page]; $admin_options = $this->getAdminOptions(); $fields = parent::getAttachedFieldsArray($_POST[fid]); $checks = array(); foreach ($fields as $field_id) { $field = parent::selectField($field_id, ''); if ($field->field_type == 'Checkbox') $checks[] = $field->field_slug; elseif ($field->field_slug == 'captcha') { if ($_POST[captcha] != $_SESSION[captcha]) $this->setError('captcha', 'You entered the captcha image code incorrectly'); } } $body = ''; foreach ($_POST as $key => $value) { $_SESSION[fields][$key] = $value; $field = parent::selectField('', $key); if (!in_array($key, $this->fixed_fields)) $body .= $field->field_label . ': ' . $value . "\n"; if (in_array($key, $checks)) { $checks_key = array_search($key, $checks); unset($checks[$checks_key]); } } foreach ($checks as $check_key) { $field = parent::selectField('', $check_key); $body .= ucwords(str_replace('_', ' ', $field->field_label)) . ': 0' . "\n"; } $errors = $this->getAllErrors(); if (empty($errors)) { $body .= 'Sender IP: ' . $_SERVER['REMOTE_ADDR'] . "\n"; $mailer = new CustomContactFormsMailer($admin_options[default_to_email], $admin_options[default_from_email], $admin_options[default_form_subject], $body); $mailer->send(); if (!empty($admin_options[custom_thank_you])) { header("Location: " . $admin_options[custom_thank_you]); } } unset($_POST); } } } } $customcontact = new CustomContactForms(); if (!function_exists('CustomContactForms_ap')) { function CustomContactForms_ap() { global $customcontact; if (!isset($customcontact)) return; if (function_exists('add_options_page')) { add_options_page('Custom Contact Forms', 'Custom Contact Forms', 9, 'custom-contact-forms', array(&$customcontact, 'printAdminPage')); } } } if (isset($customcontact)) { add_action('init', array(&$customcontact, 'processForms'), 1); add_action('init', array(&$customcontact, 'startSession'), 1); add_action('wp_head', array(&$customcontact, 'addHeaderCode'), 1); add_action('admin_head', array(&$customcontact, 'addHeaderCode'), 1); add_action('activate_customcontactforms/customcontactforms.php', array(&$customcontact, 'init')); add_action('plugins_loaded', array(&$customcontact, 'init'), 1); add_filter('the_content', array(&$customcontact, 'contentFilter')); } add_action('admin_menu', 'CustomContactForms_ap'); ?>