| 1 |
<?php |
| 2 |
/* |
| 3 |
Plugin Name: Custom Contact Forms |
| 4 |
Plugin URI: http://taylorlovett.com/wordpress-plugins |
| 5 |
Description: VERSION 2.2.4 RELEASED! YOU CAN NOW CUSTOMIZE EVERY ASPECT OF YOUR FORMS APPEARANCE WITH ANY EASY TO USE FORM - BORDERS, FONT SIZES, COLORS, PADDING, MARGINS, BACKGROUNDS, AND MORE. Custom Contact Forms is a plugin for handling and displaying custom web forms [customcontact form=1] in any page, post, category, or archive in which you want the form to show. This plugin allows you to create fields with a variety of options and to attach them to specific forms you create; definitely allows for more customization than any other Wordpress Contact Form plugin; comes with a customizable captcha spam blocker! Also comes with a web form widget to drag-and-drop in to your sidebar. <a href="options-general.php?page=custom-contact-forms" title="Maryland Wordpress Developer">Plugin Settings</a> |
| 6 |
Version: 2.2.4 |
| 7 |
Author: <a href="http://www.taylorlovett.com" title="Maryland Wordpress Developer">Taylor Lovett</a> |
| 8 |
Author URI: http://www.taylorlovett.com |
| 9 |
Contributors: Taylor Lovett |
| 10 |
*/ |
| 11 |
/* |
| 12 |
Copyright (C) 2010-2011 Taylor Lovett, taylorlovett.com (admin@taylorlovett.com) |
| 13 |
This program is free software; you can redistribute it and/or modify |
| 14 |
it under the terms of the GNU General Public License as published by |
| 15 |
the Free Software Foundation; either version 3 of the License, or |
| 16 |
(at your option) any later version. |
| 17 |
This program is distributed in the hope that it will be useful, |
| 18 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 |
GNU General Public License for more details. |
| 21 |
You should have received a copy of the GNU General Public License |
| 22 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 23 |
*/ |
| 24 |
require_once('custom-contact-forms-db.php'); |
| 25 |
require_once('custom-contact-forms-mailer.php'); |
| 26 |
require_once('custom-contact-forms-images.php'); |
| 27 |
if (!class_exists('CustomContactForms')) { |
| 28 |
class CustomContactForms extends CustomContactFormsDB { |
| 29 |
var $adminOptionsName = 'customContactFormsAdminOptions'; |
| 30 |
var $widgetOptionsName = 'widget_customContactForms'; |
| 31 |
var $version = '2.1.0'; |
| 32 |
var $form_errors; |
| 33 |
var $error_return; |
| 34 |
var $fixed_fields = array('customcontactforms_submit', 'fid', 'form_page', 'captcha', 'ishuman'); |
| 35 |
|
| 36 |
function CustomContactForms() { |
| 37 |
parent::CustomContactFormsDB(); |
| 38 |
$this->form_errors = array(); |
| 39 |
} |
| 40 |
|
| 41 |
function getAdminOptions() { |
| 42 |
$admin_email = get_option('admin_email'); |
| 43 |
$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' => '', 'remember_field_values' => 0, 'author_link' => 1, 'enable_widget_tooltips' => 1); // defaults |
| 44 |
$customcontactOptions = get_option($this->adminOptionsName); |
| 45 |
if (!empty($customcontactOptions)) { |
| 46 |
foreach ($customcontactOptions as $key => $option) |
| 47 |
$customcontactAdminOptions[$key] = $option; |
| 48 |
} |
| 49 |
update_option($this->adminOptionsName, $customcontactAdminOptions); |
| 50 |
return $customcontactAdminOptions; |
| 51 |
} |
| 52 |
function init() { |
| 53 |
$this->getAdminOptions(); |
| 54 |
if (!is_admin()) { |
| 55 |
wp_enqueue_script('jquery'); |
| 56 |
$this->startSession(); |
| 57 |
$this->processForms(); |
| 58 |
} |
| 59 |
$this->registerSidebar(); |
| 60 |
} |
| 61 |
|
| 62 |
function registerSidebar() { |
| 63 |
register_sidebar_widget(__('Custom Contact Form'), array($this, 'widget_customContactForms')); |
| 64 |
register_widget_control('Custom Contact Form', array($this, 'customContactForms_control'), 300, 200); |
| 65 |
} |
| 66 |
|
| 67 |
function customContactForms_control() { |
| 68 |
$option = get_option($this->widgetOptionsName); |
| 69 |
if (empty($option)) $option = array('widget_form_id' => '0'); |
| 70 |
if ($_POST[widget_form_id]) { |
| 71 |
$option[widget_form_id] = $_POST[widget_form_id]; |
| 72 |
update_option($this->widgetOptionsName, $option); |
| 73 |
$option = get_option($this->widgetOptionsName); |
| 74 |
} |
| 75 |
$forms = parent::selectAllForms(); |
| 76 |
|
| 77 |
$form_options = ''; |
| 78 |
foreach ($forms as $form) { |
| 79 |
$sel = ($option[widget_form_id] == $form->id) ? ' selected="selected"' : ''; |
| 80 |
$form_options .= '<option value="'.$form->id.'"'.$sel.'>'.$form->form_slug.'</option>'; |
| 81 |
} |
| 82 |
if (empty($form_options)) { ?> |
| 83 |
<p>Create a form in the Custom Contact Forms settings page.</p> |
| 84 |
<?php |
| 85 |
} else { |
| 86 |
?> |
| 87 |
<p> |
| 88 |
<label for="widget_form_id">Show Form:</label> |
| 89 |
<select name="widget_form_id"> |
| 90 |
<?php echo $form_options; ?> |
| 91 |
</select> |
| 92 |
</p> |
| 93 |
<?php |
| 94 |
} |
| 95 |
} |
| 96 |
function widget_customContactForms($args) { |
| 97 |
extract($args); |
| 98 |
$admin_option = $this->getAdminOptions(); |
| 99 |
if ((is_front_page() and $admin_option[show_widget_home] != 1) or (is_single() and $admin_option[show_widget_singles] != 1) or |
| 100 |
(is_page() and $admin_option[show_widget_pages] != 1) or (is_category() and $admin_option[show_widget_categories] != 1) or |
| 101 |
(is_archive() and $admin_option[show_widget_archives] != 1)) |
| 102 |
return false; |
| 103 |
$option = get_option($this->widgetOptionsName); |
| 104 |
if (empty($option) or $option[widget_form_id] < 1) return false; |
| 105 |
echo $before_widget . $this->getFormCode($option[widget_form_id], true) . $after_widget; |
| 106 |
} |
| 107 |
function addHeaderCode() { |
| 108 |
|
| 109 |
?> |
| 110 |
<!-- Custom Contact Forms by Taylor Lovett - http://www.taylorlovett.com --> |
| 111 |
<link rel="stylesheet" href="<?php echo get_option('siteurl'); ?>/wp-content/plugins/custom-contact-forms/custom-contact-forms.css" type="text/css" media="screen" /> |
| 112 |
<!--<script type="text/javascript" language="javascript" src="<?php echo get_option('siteurl'); ?>/wp-content/plugins/custom-contact-forms/js/custom-contact-forms.js"></script>--> |
| 113 |
<?php //wp_enqueue_script('jquery-dialog', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.3/jquery-ui.min.js'); |
| 114 |
wp_enqueue_script('jquery-tools', get_option('siteurl') . '/wp-content/plugins/custom-contact-forms/js/jquery.tools.min.js'); |
| 115 |
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'), '1.0'); |
| 116 |
} |
| 117 |
|
| 118 |
function setFormError($key, $message) { |
| 119 |
$this->form_errors[$key] = $message; |
| 120 |
} |
| 121 |
|
| 122 |
function getFormError($key) { |
| 123 |
return $this->form_errors[$key]; |
| 124 |
} |
| 125 |
|
| 126 |
function getAllFormErrors() { |
| 127 |
return $this->form_errors; |
| 128 |
} |
| 129 |
|
| 130 |
function printAdminPage() { |
| 131 |
$admin_options = $this->getAdminOptions(); |
| 132 |
if ($_POST[form_create]) { |
| 133 |
parent::insertForm($_POST[form_slug], $_POST[form_title], $_POST[form_action], $_POST[form_method], $_POST[submit_button_text], $_POST[custom_code], $_POST[form_style]); |
| 134 |
} elseif ($_POST[field_create]) { |
| 135 |
parent::insertField($_POST[field]); |
| 136 |
} elseif ($_POST[general_settings]) { |
| 137 |
$admin_options[default_to_email] = $_POST[default_to_email]; |
| 138 |
$admin_options[default_from_email] = $_POST[default_from_email]; |
| 139 |
$admin_options[default_form_subject] = $_POST[default_form_subject]; |
| 140 |
$admin_options[show_widget_categories] = $_POST[show_widget_categories]; |
| 141 |
$admin_options[show_widget_singles] = $_POST[show_widget_singles]; |
| 142 |
$admin_options[show_widget_pages] = $_POST[show_widget_pages]; |
| 143 |
$admin_options[show_widget_archives] = $_POST[show_widget_archives]; |
| 144 |
$admin_options[show_widget_home] = $_POST[show_widget_home]; |
| 145 |
$admin_options[custom_thank_you] = $_POST[custom_thank_you]; |
| 146 |
$admin_options[author_link] = $_POST[author_link]; |
| 147 |
$admin_options[enable_widget_tooltips] = $_POST[enable_widget_tooltips]; |
| 148 |
$admin_options[remember_field_values] = $_POST[remember_field_values]; |
| 149 |
update_option($this->adminOptionsName, $admin_options); |
| 150 |
} elseif ($_POST[field_edit]) { |
| 151 |
parent::updateField($_POST[field_slug], $_POST[field_label], $_POST[field_type], $_POST[field_value], $_POST[field_maxlength], $_POST[field_instructions], $_POST[fid]); |
| 152 |
} elseif ($_POST[field_delete]) { |
| 153 |
parent::deleteField($_POST[fid]); |
| 154 |
} elseif ($_POST[form_delete]) { |
| 155 |
parent::deleteForm($_POST[fid]); |
| 156 |
} elseif ($_POST[form_edit]) { |
| 157 |
parent::updateForm($_POST[form_slug], $_POST[form_title], $_POST[form_action], $_POST[form_method], $_POST[submit_button_text], $_POST[custom_code], $_POST[form_style], $_POST[fid]); |
| 158 |
} elseif ($_POST[form_add_field]) { |
| 159 |
parent::addFieldToForm($_POST[field_id], $_POST[fid]); |
| 160 |
} elseif ($_POST[disattach_field]) { |
| 161 |
parent::disattachField($_POST[disattach_field_id], $_POST[fid]); |
| 162 |
} elseif ($_POST[style_create]) { |
| 163 |
parent::insertStyle($_POST[style]); |
| 164 |
} elseif ($_POST[style_edit]) { |
| 165 |
parent::updateStyle($_POST[style]); |
| 166 |
} elseif ($_POST[style_delete]) { |
| 167 |
parent::deleteStyle($_POST[style][id]); |
| 168 |
} elseif ($_POST[contact_author]) { |
| 169 |
$this_url = (!empty($_SERVER['HTTP_REFERER'])) ? $_SERVER['HTTP_REFERER'] : $_SERVER['SERVER_NAME']; |
| 170 |
$this->contactAuthor($_POST[name], $_POST[email], $this_url, $_POST[message], $_POST[type]); |
| 171 |
} |
| 172 |
$styles = parent::selectAllStyles(); |
| 173 |
$style_options = '<option value="0">None</option>'; |
| 174 |
foreach ($styles as $style) |
| 175 |
$style_options .= '<option value="'.$style->id.'">'.$style->style_slug.'</option>'; |
| 176 |
?> |
| 177 |
<div id="customcontactforms-admin"> |
| 178 |
<div id="icon-themes" class="icon32"></div> |
| 179 |
<h2>Custom Contact Forms</h2> |
| 180 |
<ul id="plugin-nav"> |
| 181 |
<li><a href="#instructions">Plugin Instructions</a></li> |
| 182 |
<li><a href="#general-settings">General Settings</a></li> |
| 183 |
<li><a href="#create-fields">Create Fields</a></li> |
| 184 |
<li><a href="#create-forms">Create Forms</a></li> |
| 185 |
<li><a href="#manage-fields">Manage Fields</a></li> |
| 186 |
<li><a href="#manage-fixed-fields">Manage Fixed Fields</a></li> |
| 187 |
<li><a href="#manage-forms">Manage Forms</a></li> |
| 188 |
<li><a href="#create-styles">Create Styles</a></li> |
| 189 |
<li><a href="#manage-styles">Manage Styles</a></li> |
| 190 |
<li><a href="#contact-author">Suggest a Feature</a></li> |
| 191 |
<li><a href="#contact-author">Bug Report</a></li> |
| 192 |
<li class="last"><a href="#plugin-news">Plugin News</a></li> |
| 193 |
</ul><a name="create-fields"></a> |
| 194 |
<div id="create-fields" class="postbox"> |
| 195 |
<h3 class="hndle"><span>Create A Form Field</span></h3> |
| 196 |
<div class="inside"> |
| 197 |
<form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>"> |
| 198 |
<ul> |
| 199 |
<li> |
| 200 |
<label for="field_slug">* Slug (Name):</label> |
| 201 |
<input name="field[field_slug]" type="text" maxlength="50" /> |
| 202 |
(Must be unique)</li> |
| 203 |
<li> |
| 204 |
<label for="field_label">Field Label:</label> |
| 205 |
<input name="field[field_label]" type="text" maxlength="100" /> |
| 206 |
</li> |
| 207 |
<li> |
| 208 |
<label for="field_type">* Field Type:</label> |
| 209 |
<select name="field[field_type]"> |
| 210 |
<option>Text</option> |
| 211 |
<option>Textarea</option> |
| 212 |
<option>Hidden</option> |
| 213 |
<option>Checkbox</option> |
| 214 |
</select> |
| 215 |
</li> |
| 216 |
<li> |
| 217 |
<label for="field_value">Initial Value:</label> |
| 218 |
<input name="field[field_value]" type="text" maxlength="50" /> |
| 219 |
</li> |
| 220 |
<li> |
| 221 |
<label for="field_maxlength">Max Length:</label> |
| 222 |
<input class="width50" size="10" name="field[field_maxlength]" type="text" maxlength="4" /> |
| 223 |
(0 for no limit; only applies to Text fields)</li> |
| 224 |
<li> |
| 225 |
<label for="field_value">Field Instructions:</label> |
| 226 |
<input name="field[field_instructions]" type="text" /><br /> |
| 227 |
(If this is filled out, a tooltip popover displaying this text will show when the field is selected.) |
| 228 |
</li> |
| 229 |
<li><input type="hidden" name="field[user_field]" value="1" /> |
| 230 |
<input type="submit" value="Create Field" name="field_create" /> |
| 231 |
</li> |
| 232 |
</ul> |
| 233 |
</form> |
| 234 |
</div> |
| 235 |
</div><a name="create-forms"></a> |
| 236 |
<div id="create-forms" class="postbox"> |
| 237 |
<h3 class="hndle"><span>Create A Form</span></h3> |
| 238 |
<div class="inside"> |
| 239 |
<form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>"> |
| 240 |
<ul> |
| 241 |
<li> |
| 242 |
<label for="form_name">Form Slug:</label> |
| 243 |
<input type="text" maxlength="100" name="form_slug" /> |
| 244 |
(Must be unique)</li> |
| 245 |
<li> |
| 246 |
<label for="form_title">Form Title:</label> |
| 247 |
<input type="text" maxlength="200" name="form_title" /> |
| 248 |
(The form header text)</li> |
| 249 |
<li> |
| 250 |
<label for="form_method">Form Method:</label> |
| 251 |
<select name="form_method"> |
| 252 |
<option>Post</option> |
| 253 |
<option>Get</option> |
| 254 |
</select> |
| 255 |
(If unsure, leave as is.)</li> |
| 256 |
<li> |
| 257 |
<label for="form_action">Form Action:</label> |
| 258 |
<input type="text" name="form_action" value="" /> |
| 259 |
(If unsure, leave blank.)</li> |
| 260 |
<li> |
| 261 |
<label for="form_action">Form Style:</label> |
| 262 |
<select name="form_style"><?php echo $style_options; ?></select> |
| 263 |
(<a href="#create-styles">Click to create a style</a>)</li> |
| 264 |
<li> |
| 265 |
<label for="submit_button_text">Submit Button Text:</label> |
| 266 |
<input type="text" maxlength="200" name="submit_button_text" /> |
| 267 |
</li> |
| 268 |
<li> |
| 269 |
<label for="custom_code">Custom Code:</label> |
| 270 |
<input type="text" name="custom_code" /> |
| 271 |
(If unsure, leave blank.)</li> |
| 272 |
<li> |
| 273 |
<input type="submit" value="Create Form" name="form_create" /> |
| 274 |
</li> |
| 275 |
</ul> |
| 276 |
</form> |
| 277 |
</div> |
| 278 |
</div><a name="manage-fields"></a> |
| 279 |
<h3 class="manage-h3">Manage User Fields</h3> |
| 280 |
<table class="widefat post" id="manage-fields" cellspacing="0"> |
| 281 |
<thead> |
| 282 |
<tr> |
| 283 |
<th scope="col" class="manage-column field-slug">Slug</th> |
| 284 |
<th scope="col" class="manage-column field-label">Label</th> |
| 285 |
<th scope="col" class="manage-column field-type">Type</th> |
| 286 |
<th scope="col" class="manage-column field-value">Initial Value</th> |
| 287 |
<th scope="col" class="manage-column field-maxlength">Maxlength</th> |
| 288 |
<th scope="col" class="manage-column field-action">Action</th> |
| 289 |
</tr> |
| 290 |
</thead> |
| 291 |
<tbody> |
| 292 |
<?php |
| 293 |
$fields = parent::selectAllFields(); |
| 294 |
for ($i = 0, $z = 0; $i < count($fields); $i++, $z++) { |
| 295 |
if ($fields[$i]->user_field == 0) { $z--; continue; } |
| 296 |
$field_types = '<option>Text</option><option>Textarea</option><option>Hidden</option><option>Checkbox</option>'; |
| 297 |
$field_types = str_replace('<option>'.$fields[$i]->field_type.'</option>', '<option selected="selected">'.$fields[$i]->field_type.'</option>', $field_types); |
| 298 |
|
| 299 |
?> |
| 300 |
<form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>"> |
| 301 |
<tr<?php if ($z % 2 == 1) echo ' class="evenrow"'; ?>> |
| 302 |
|
| 303 |
<td><input type="text" name="field_slug" maxlength="50" value="<?php echo $fields[$i]->field_slug; ?>" /></td> |
| 304 |
<td><input type="text" name="field_label" maxlength="100" value="<?php echo $fields[$i]->field_label; ?>" /></td> |
| 305 |
<td><select name="field_type"> |
| 306 |
<?php echo $field_types; ?> |
| 307 |
</select></td> |
| 308 |
<td><input type="text" name="field_value" maxlength="50" value="<?php echo $fields[$i]->field_value; ?>" /></td> |
| 309 |
<td><input type="text" class="width50" name="field_maxlength" value="<?php echo $fields[$i]->field_maxlength; ?>" /></td> |
| 310 |
<td><input type="hidden" name="fid" value="<?php echo $fields[$i]->id; ?>" /> |
| 311 |
<input type="submit" name="field_edit" value="Edit" /> |
| 312 |
<input type="submit" name="field_delete" value="Delete" /></td> |
| 313 |
|
| 314 |
</tr> |
| 315 |
<tr<?php if ($z % 2 == 1) echo ' class="evenrow"'; ?>> |
| 316 |
<td colspan="6" style="border-bottom:1px solid black;">Field Instructions: <input type="text" name="field_instructions" value="<?php echo $fields[$i]->field_instructions; ?>" /></td> |
| 317 |
</tr> |
| 318 |
</form> |
| 319 |
<?php |
| 320 |
} |
| 321 |
?> |
| 322 |
</tbody> |
| 323 |
<tfoot> |
| 324 |
<tr> |
| 325 |
<th scope="col" class="manage-column field-slug">Slug</th> |
| 326 |
<th scope="col" class="manage-column field-label">Label</th> |
| 327 |
<th scope="col" class="manage-column field-type">Type</th> |
| 328 |
<th scope="col" class="manage-column field-value">Initial Value</th> |
| 329 |
<th scope="col" class="manage-column field-maxlength">Maxlength</th> |
| 330 |
<th scope="col" class="manage-column field-action">Action</th> |
| 331 |
</tr> |
| 332 |
</tfoot> |
| 333 |
</table><a name="manage-fixed-fields"></a> |
| 334 |
<h3 class="manage-h3">Manage Fixed Fields</h3> |
| 335 |
<table class="widefat post" id="manage-fixed-fields" cellspacing="0"> |
| 336 |
<thead> |
| 337 |
<tr> |
| 338 |
<th scope="col" class="manage-column field-slug">Slug</th> |
| 339 |
<th scope="col" class="manage-column field-label">Label</th> |
| 340 |
<th scope="col" class="manage-column field-type">Type</th> |
| 341 |
<th scope="col" class="manage-column field-value">Initial Value</th> |
| 342 |
<th scope="col" class="manage-column field-maxlength">Maxlength</th> |
| 343 |
<th scope="col" class="manage-column field-action">Action</th> |
| 344 |
</tr> |
| 345 |
</thead> |
| 346 |
<tbody> |
| 347 |
<?php |
| 348 |
$fields = parent::selectAllFields(); |
| 349 |
for ($i = 0, $z = 0; $i < count($fields); $i++, $z++) { |
| 350 |
if ($fields[$i]->user_field == 1) { $z--; continue;} |
| 351 |
$field_types = '<option>Text</option><option>Textarea</option><option>Hidden</option><option>Checkbox</option>'; |
| 352 |
$field_types = str_replace('<option>'.$fields[$i]->field_type.'</option>', '<option selected="selected">'.$fields[$i]->field_type.'</option>', $field_types); |
| 353 |
|
| 354 |
?> |
| 355 |
<form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>"> |
| 356 |
<tr <?php if ($z % 2 == 0) echo ' class="evenrow"'; ?>> |
| 357 |
|
| 358 |
<td><?php echo $fields[$i]->field_slug; ?> |
| 359 |
<input type="hidden" name="field_slug" value="<?php echo $fields[$i]->field_slug; ?>" /></td> |
| 360 |
<td><input type="text" name="field_label" maxlength="100" value="<?php echo $fields[$i]->field_label; ?>" /></td> |
| 361 |
<td><?php echo $fields[$i]->field_type; ?> |
| 362 |
<input type="hidden" name="field_type" value="<?php echo $fields[$i]->field_type; ?>" /></td> |
| 363 |
<td><?php if ($fields[$i]->field_type != 'Checkbox') { ?> |
| 364 |
<input type="text" name="field_value" maxlength="50" value="<?php echo $fields[$i]->field_value; ?>" /> |
| 365 |
<?php } else { |
| 366 |
echo $fields[$i]->field_value; |
| 367 |
?> |
| 368 |
<input type="hidden" name="field_value" value="1" /> |
| 369 |
<?php } ?> |
| 370 |
</td> |
| 371 |
<td><?php if ($fields[$i]->field_type != 'Checkbox') { ?> |
| 372 |
<input type="text" class="width50" name="field_maxlength" value="<?php echo $fields[$i]->field_maxlength; ?>" /> |
| 373 |
<?php } else { ?> |
| 374 |
None<input type="hidden" name="field_maxlength" value="0" /> |
| 375 |
<?php } ?> |
| 376 |
</td> |
| 377 |
|
| 378 |
<td><input type="hidden" name="fid" value="<?php echo $fields[$i]->id; ?>" /> |
| 379 |
<input type="submit" name="field_edit" value="Edit" /></td> |
| 380 |
</tr> |
| 381 |
<tr <?php if ($z % 2 == 0) echo ' class="evenrow"'; ?>> |
| 382 |
<td colspan="6" style="border-bottom:1px solid black;">Field Instructions: <input type="text" name="field_instructions" value="<?php echo $fields[$i]->field_instructions; ?>" /></td> |
| 383 |
</tr> |
| 384 |
</form> |
| 385 |
<?php |
| 386 |
} |
| 387 |
?> |
| 388 |
</tbody> |
| 389 |
<tfoot> |
| 390 |
<tr> |
| 391 |
<th scope="col" class="manage-column field-slug">Slug</th> |
| 392 |
<th scope="col" class="manage-column field-label">Label</th> |
| 393 |
<th scope="col" class="manage-column field-type">Type</th> |
| 394 |
<th scope="col" class="manage-column field-value">Initial Value</th> |
| 395 |
<th scope="col" class="manage-column field-maxlength">Maxlength</th> |
| 396 |
<th scope="col" class="manage-column field-action">Action</th> |
| 397 |
</tr> |
| 398 |
</tfoot> |
| 399 |
</table><a name="manage-forms"></a> |
| 400 |
<h3 class="manage-h3">Manage Forms</h3> |
| 401 |
<table class="widefat post" id="manage-forms" cellspacing="0"> |
| 402 |
<thead> |
| 403 |
<tr> |
| 404 |
<th scope="col" class="manage-column form-slug">Slug</th> |
| 405 |
<th scope="col" class="manage-column form-title">Title</th> |
| 406 |
<th scope="col" class="manage-column form-method">Method</th> |
| 407 |
<th scope="col" class="manage-column form-action">Form Action</th> |
| 408 |
<th scope="col" class="manage-column form-submit">Button Text</th> |
| 409 |
<th scope="col" class="manage-column form-submit">Custom Code</th> |
| 410 |
<th scope="col" class="manage-column form-submit">Style</th> |
| 411 |
</tr> |
| 412 |
</thead> |
| 413 |
<tbody> |
| 414 |
<?php |
| 415 |
$forms = parent::selectAllForms(); |
| 416 |
for ($i = 0; $i < count($forms); $i++) { |
| 417 |
$form_methods = '<option>Post</option><option>Get</option>'; |
| 418 |
$form_methods = str_replace('<option>'.$forms[$i]->form_method.'</option>', '<option selected="selected">'.$forms[$i]->form_method.'</option>', $form_methods); |
| 419 |
$add_fields = $this->getFieldsForm(); |
| 420 |
$this_style = parent::selectStyle($forms[$i]->form_style, ''); |
| 421 |
$sty_opt = str_replace('<option value="'.$forms[$i]->form_style.'">'.$this_style->style_slug.'</option>', '<option value="'.$forms[$i]->form_style.'" selected="selected">'.$this_style->style_slug.'</option>', $style_options); |
| 422 |
?> |
| 423 |
<form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>"> |
| 424 |
<tr class="<?php if ($i % 2 == 0) echo 'evenrow'; ?>"> |
| 425 |
<td><input type="text" class="width75" name="form_slug" value="<?php echo $forms[$i]->form_slug; ?>" /></td> |
| 426 |
<td><input type="text" class="width125" name="form_title" value="<?php echo $forms[$i]->form_title; ?>" /></td> |
| 427 |
<td><select name="form_method"> |
| 428 |
<?php echo $form_methods; ?> |
| 429 |
</select></td> |
| 430 |
<td><input class="width125" type="text" name="form_action" value="<?php echo $forms[$i]->form_action; ?>" /></td> |
| 431 |
<td><input class="width125" type="text" name="submit_button_text" value="<?php echo $forms[$i]->submit_button_text; ?>" /></td> |
| 432 |
<td><input type="text" class="width125" name="custom_code" value="<?php echo $forms[$i]->custom_code; ?>" /></td> |
| 433 |
<td><select name="form_style"><?php echo $sty_opt; ?></select></td> |
| 434 |
</tr> |
| 435 |
<tr class="<?php if ($i % 2 == 0) echo 'evenrow'; ?>"> |
| 436 |
<td colspan="8" style="border-bottom:1px solid black;"><div class="attached_fields"> |
| 437 |
<label><span>Attached Fields:</span></label> |
| 438 |
<?php |
| 439 |
$attached_fields = parent::getAttachedFieldsArray($forms[$i]->id); |
| 440 |
if (empty($attached_fields)) echo 'None '; |
| 441 |
else { |
| 442 |
echo '<select name="disattach_field_id">'; |
| 443 |
foreach($attached_fields as $attached_field) { |
| 444 |
$this_field = parent::selectField($attached_field, ''); |
| 445 |
echo $this_field->field_slug . ' <option value="'.$this_field->id.'">'.$this_field->field_slug.'</option>'; |
| 446 |
?> |
| 447 |
<?php |
| 448 |
} |
| 449 |
echo '</select> <input type="submit" value="Disattach Field" name="disattach_field" />'; |
| 450 |
} |
| 451 |
?> |
| 452 |
<br /> |
| 453 |
<span class="red bold">*</span> Code to Display Form: <b>[customcontact form=<?php echo $forms[$i]->id ?>]</b> </div> |
| 454 |
<div class="attach_field"> |
| 455 |
<label for="field_id"><span>Attach Field:</span></label> |
| 456 |
<select name="field_id"> |
| 457 |
<?php echo $add_fields; ?> |
| 458 |
</select> |
| 459 |
<input type="submit" name="form_add_field" value="Attach" /> |
| 460 |
<input type="hidden" name="fid" value="<?php echo $forms[$i]->id; ?>" /> |
| 461 |
<br /> |
| 462 |
<span class="red bold">*</span> Attach in the order you want fields to display. </div> |
| 463 |
<div class="actions"> |
| 464 |
<input type="hidden" name="fid" value="<?php echo $forms[$i]->id; ?>" /> |
| 465 |
<input type="submit" name="form_edit" value="Edit Form" /> |
| 466 |
<input type="submit" name="form_delete" value="Delete Form" /> |
| 467 |
</div> |
| 468 |
<!--<div class="attach_styles"> |
| 469 |
<label for="attach_styles"><span>Form Style:</span> </label> <select name="attach_styles"><option>really long style name</option></select> |
| 470 |
<input type="submit" value="Attach" name="attach_styles" /><br /> |
| 471 |
<span class="red bold">*</span> Create form styles at the bottom of the page, and use them to change your forms appearance. |
| 472 |
</div>--> |
| 473 |
</td> |
| 474 |
</tr> |
| 475 |
</form> |
| 476 |
<?php |
| 477 |
} |
| 478 |
$remember_check = ($admin_options[remember_field_values] == 0) ? 'selected="selected"' : ''; |
| 479 |
$remember_fields = '<option value="1">Yes</option><option '.$remember_check.' value="0">No</option>'; |
| 480 |
$border_style_options = '<option>solid</option><option>dashed</option> |
| 481 |
<option>grooved</option><option>double</option><option>dotted</option><option>ridged</option><option>none</option> |
| 482 |
<option>inset</option><option>outset</option>'; |
| 483 |
?> |
| 484 |
</tbody> |
| 485 |
<tfoot> |
| 486 |
<tr> |
| 487 |
<tr> |
| 488 |
<th scope="col" class="manage-column form-slug">Slug</th> |
| 489 |
<th scope="col" class="manage-column form-title">Title</th> |
| 490 |
<th scope="col" class="manage-column form-method">Method</th> |
| 491 |
<th scope="col" class="manage-column form-action">Form Action</th> |
| 492 |
<th scope="col" class="manage-column form-submit">Button Text</th> |
| 493 |
<th scope="col" class="manage-column form-submit">Custom Code</th> |
| 494 |
<th scope="col" class="manage-column form-submit">Style</th> |
| 495 |
</tr> |
| 496 |
</tr> |
| 497 |
|
| 498 |
</tfoot> |
| 499 |
</table><a name="general-settings"></a> |
| 500 |
<div id="general-settings" class="postbox"> |
| 501 |
<h3 class="hndle"><span>General Settings</span></h3> |
| 502 |
<div class="inside"> |
| 503 |
<form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>"> |
| 504 |
<ul> |
| 505 |
<li> |
| 506 |
<label for="default_to_email">Default Email:</label> |
| 507 |
<input name="default_to_email" value="<?php echo $admin_options[default_to_email]; ?>" type="text" maxlength="100" /> |
| 508 |
</li> |
| 509 |
<li class="descrip">Form emails will be sent <span>to</span> this address.</li> |
| 510 |
<li> |
| 511 |
<label for="default_from_email">Default From Email:</label> |
| 512 |
<input name="default_from_email" value="<?php echo $admin_options[default_from_email]; ?>" type="text" maxlength="100" /> |
| 513 |
</li> |
| 514 |
<li class="descrip">Form emails will be sent <span>from</span> this address.</li> |
| 515 |
<li> |
| 516 |
<label for="default_form_subject">Default Email Subject:</label> |
| 517 |
<input name="default_form_subject" value="<?php echo $admin_options[default_form_subject]; ?>" type="text" maxlength="150" /> |
| 518 |
</li> |
| 519 |
<li class="descrip">Default subject to be included in all form emails.</li> |
| 520 |
<li> |
| 521 |
<label for="custom_thank_you">Custom Thank You Page:</label> |
| 522 |
<input name="custom_thank_you" value="<?php echo $admin_options[custom_thank_you]; ?>" type="text" maxlength="150" /> |
| 523 |
</li> |
| 524 |
<li class="descrip">Upon filling out forms, users will be sent back to the form page if this is left blank.</li> |
| 525 |
|
| 526 |
<li> |
| 527 |
<label for="remember_field_values">Remember Field Values:</label> |
| 528 |
<select name="remember_field_values"><option value="1">Yes</option><option <?php if ($admin_options[remember_field_values] == 0) echo 'selected="selected"'; ?> value="0">No</option></select> |
| 529 |
</li> |
| 530 |
<li class="descrip">Selecting yes will make form fields remember how they were last filled out.</li> |
| 531 |
<li> |
| 532 |
<label for="enable_widget_tooltips">Enable Tooltips in Widget:</label> |
| 533 |
<select name="enable_widget_tooltips"><option value="1">Yes</option><option <?php if ($admin_options[enable_widget_tooltips] == 0) echo 'selected="selected"'; ?> value="0">No</option></select> |
| 534 |
</li> |
| 535 |
<li class="descrip">Enabling this shows tooltips containing field instructions on forms in the widget.</li> |
| 536 |
<li> |
| 537 |
<label for="remember_field_values">Hide Plugin Author Link:</label> |
| 538 |
<select name="author_link"><option value="1">Yes</option><option <?php if ($admin_options[author_link] == 0) echo 'selected="selected"'; ?> value="0">No</option></select> |
| 539 |
</li> |
| 540 |
<li class="show-widget">Show Sidebar Widget:</li> |
| 541 |
<li> |
| 542 |
<label> |
| 543 |
<input value="1" type="checkbox" name="show_widget_home" <?php if ($admin_options[show_widget_home] == 1) echo 'checked="checked"'; ?> /> |
| 544 |
On Homepage</label> |
| 545 |
</li> |
| 546 |
<li> |
| 547 |
<label> |
| 548 |
<input value="1" type="checkbox" name="show_widget_pages" <?php if ($admin_options[show_widget_pages] == 1) echo 'checked="checked"'; ?> /> |
| 549 |
On Pages</label> |
| 550 |
</li> |
| 551 |
<li> |
| 552 |
<label> |
| 553 |
<input value="1" type="checkbox" name="show_widget_singles" <?php if ($admin_options[show_widget_singles] == 1) echo 'checked="checked"'; ?> /> |
| 554 |
On Single Posts</label> |
| 555 |
</li> |
| 556 |
<li> |
| 557 |
<label> |
| 558 |
<input value="1" type="checkbox" name="show_widget_categories" <?php if ($admin_options[show_widget_categories] == 1) echo 'checked="checked"'; ?> /> |
| 559 |
On Categories</label> |
| 560 |
</li> |
| 561 |
<li> |
| 562 |
<label> |
| 563 |
<input value="1" type="checkbox" name="show_widget_archives" <?php if ($admin_options[show_widget_archives] == 1) echo 'checked="checked"'; ?> /> |
| 564 |
On Archives</label> |
| 565 |
</li> |
| 566 |
<li> |
| 567 |
<input type="submit" value="Update" name="general_settings" /> |
| 568 |
</li> |
| 569 |
</ul> |
| 570 |
</form> |
| 571 |
</div> |
| 572 |
</div><a name="instructions"></a> |
| 573 |
<div id="instructions" class="postbox"> |
| 574 |
<h3 class="hndle"><span>Instructions</span></h3> |
| 575 |
<div class="inside"> |
| 576 |
<p>1. Create a form.</p> |
| 577 |
<p>2. Create fields and attach those fields to the forms of your choice. <b>* 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.</b></p> |
| 578 |
<p>3. Display those forms in posts and pages by inserting the code: [customcontact form=<b>FORMID</b>]. Replace <b>FORMID</b> with the id listed to the left of the form slug next to the form of your choice above.</p> |
| 579 |
<p>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.</p> |
| 580 |
<p>5. Add a form to your sidebar, by dragging the Custom Contact Form widget in to your sidebar.</p> |
| 581 |
<p>6. Configure the General Settings appropriately; this is important if you want to receive your web form messages!</p> |
| 582 |
<p>7. Create form styles to change your forms appearances. The image below explains how each style field can change the look of your forms.</p> |
| 583 |
<div id="style-example"></div> |
| 584 |
</div> |
| 585 |
</div> |
| 586 |
<a name="create-styles"></a> |
| 587 |
<div id="create-styles" class="postbox"> |
| 588 |
<h3 class="hndle"><span>Create A Style for Your Forms</span></h3> |
| 589 |
<div class="inside"> |
| 590 |
<form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>"> |
| 591 |
<ul class="style_left"> |
| 592 |
<li> |
| 593 |
<label for="style_slug">Style Slug:</label> |
| 594 |
<input type="text" maxlength="30" name="style[style_slug]" /> |
| 595 |
(Must be unique)</li> |
| 596 |
<li> |
| 597 |
<label for="title_fontsize">Title Font Size:</label> |
| 598 |
<input type="text" maxlength="20" value="1.2em" name="style[title_fontsize]" /> |
| 599 |
(ex: 10pt, 10px, 1em)</li> |
| 600 |
<li> |
| 601 |
<label for="title_fontcolor">Title Font Color:</label> |
| 602 |
<input type="text" maxlength="20" value="#333333" value="#" name="style[title_fontcolor]" /> |
| 603 |
(ex: #FF0000 or red)</li> |
| 604 |
<li> |
| 605 |
<label for="label_width">Label Width:</label> |
| 606 |
<input type="text" maxlength="20" value="110px" name="style[label_width]" /> |
| 607 |
(ex: 100px or 20%)</li> |
| 608 |
<li> |
| 609 |
<label for="label_fontsize">Label Font Size:</label> |
| 610 |
<input type="text" maxlength="20" value="1em" name="style[label_fontsize]" /> |
| 611 |
(ex: 10px, 10pt, 1em)</li> |
| 612 |
<li> |
| 613 |
<label for="label_fontcolor">Label Font Color:</label> |
| 614 |
<input type="text" maxlength="20" value="#333333" name="style[label_fontcolor]" /> |
| 615 |
(ex: #FF0000 or red)</li> |
| 616 |
<li> |
| 617 |
<label for="input_width">Text Field Width:</label> |
| 618 |
<input type="text" maxlength="20" value="200px" name="style[input_width]" /> |
| 619 |
(ex: 100px or 100%)</li> |
| 620 |
<li> |
| 621 |
<label for="textarea_width">Textarea Field Width:</label> |
| 622 |
<input type="text" maxlength="20" value="200px" name="style[textarea_width]" /> |
| 623 |
(ex: 100px or 100%)</li> |
| 624 |
<li> |
| 625 |
<label for="textarea_height">Textarea Field Height:</label> |
| 626 |
<input type="text" maxlength="20" value="100px" name="style[textarea_height]" /> |
| 627 |
(ex: 100px or 100%)</li> |
| 628 |
<li> |
| 629 |
<label for="field_fontsize">Field Font Size:</label> |
| 630 |
<input type="text" maxlength="20" value="1em" name="style[field_fontsize]" /> |
| 631 |
(ex: 10px, 10pt, 1em</li> |
| 632 |
<li> |
| 633 |
<label for="field_fontcolor">Field Font Color:</label> |
| 634 |
<input type="text" maxlength="20" value="#333333" name="style[field_fontcolor]" /> |
| 635 |
(ex: 100px or 100%)</li> |
| 636 |
<li> |
| 637 |
<label for="field_borderstyle">Field Border Style:</label> |
| 638 |
<select name="style[field_borderstyle]"><?php echo str_replace('<option>solid</option>', '<option selected="selected">solid</option>', $border_style_options); ?></select> |
| 639 |
</li> |
| 640 |
<li> |
| 641 |
<label for="form_margin">Form Margin:</label> |
| 642 |
<input type="text" maxlength="20" value="5px" name="style[form_margin]" /> |
| 643 |
(ex: 5px or 1em)</li> |
| 644 |
<li> |
| 645 |
<label for="label_margin">Label Margin:</label> |
| 646 |
<input type="text" maxlength="20" value="4px" name="style[label_margin]" /> |
| 647 |
(ex: 5px or 1em)</li> |
| 648 |
</ul> |
| 649 |
<ul class="style_right"> |
| 650 |
<li> |
| 651 |
<label for="input_width">Field Border Color:</label> |
| 652 |
<input type="text" maxlength="20" value="#333333" name="style[field_bordercolor]" /> |
| 653 |
(ex: 100px or 100%)</li> |
| 654 |
<li> |
| 655 |
<label for="form_borderstyle">Form Border Style:</label> |
| 656 |
<select name="style[form_borderstyle]"><?php echo str_replace('<option>solid</option>', '<option selected="selected">solid</option>', $border_style_options); ?></select> |
| 657 |
</li> |
| 658 |
<li> |
| 659 |
<label for="form_bordercolor">Form Border Color:</label> |
| 660 |
<input type="text" maxlength="20" value="#333333" name="style[form_bordercolor]" /> |
| 661 |
(ex: #00000 or red)</li> |
| 662 |
<li> |
| 663 |
<label for="form_borderwidth">Form Border Width:</label> |
| 664 |
<input type="text" maxlength="20" value="1px" name="style[form_borderwidth]" /> |
| 665 |
(ex: 1px)</li> |
| 666 |
<li> |
| 667 |
<label for="form_borderwidth">Form Width:</label> |
| 668 |
<input type="text" maxlength="20" value="500px" name="style[form_width]" /> |
| 669 |
(ex: 100px or 50%)</li> |
| 670 |
<li> |
| 671 |
<label for="form_borderwidth">Form Font Family:</label> |
| 672 |
<input type="text" maxlength="150" value="Verdana, tahoma, arial" name="style[form_fontfamily]" /> |
| 673 |
(ex: Verdana, Tahoma, Arial)</li> |
| 674 |
<li> |
| 675 |
<label for="submit_width">Button Width:</label> |
| 676 |
<input type="text" maxlength="20" value="80px" name="style[submit_width]" /> |
| 677 |
(ex: 100px or 30%)</li> |
| 678 |
<li> |
| 679 |
<label for="submit_height">Button Height:</label> |
| 680 |
<input type="text" maxlength="20" value="35px" name="style[submit_height]" /> |
| 681 |
(ex: 100px or 30%)</li> |
| 682 |
<li> |
| 683 |
<label for="submit_fontsize">Button Font Size:</label> |
| 684 |
<input type="text" maxlength="20" value="1.1em" name="style[submit_fontsize]" /> |
| 685 |
(ex: 10px, 10pt, 1em</li> |
| 686 |
<li> |
| 687 |
<label for="submit_fontcolor">Button Font Color:</label> |
| 688 |
<input type="text" maxlength="20" value="#333333" name="style[submit_fontcolor]" /> |
| 689 |
(ex: #FF0000 or red)</li> |
| 690 |
<li> |
| 691 |
<label for="field_backgroundcolor">Field Background Color:</label> |
| 692 |
<input type="text" maxlength="20" value="#efefef" name="style[field_backgroundcolor]" /> |
| 693 |
(ex: #FF0000 or red)</li> |
| 694 |
<li> |
| 695 |
<label for="form_padding">Form Padding:</label> |
| 696 |
<input type="text" maxlength="20" value="5px" name="style[form_padding]" /> |
| 697 |
(ex: 5px or 1em)</li> |
| 698 |
<li> |
| 699 |
<label for="title_margin">Title Margin:</label> |
| 700 |
<input type="text" maxlength="20" value="2px" name="style[title_margin]" /> |
| 701 |
(ex: 5px or 1em)</li> |
| 702 |
<li> |
| 703 |
<input type="submit" value="Create Style" name="style_create" /> |
| 704 |
</li> |
| 705 |
</ul> |
| 706 |
</form> |
| 707 |
</div> |
| 708 |
</div><a name="manage-styles"></a> |
| 709 |
<h3 class="manage-h3">Manage Form Styles</h3> |
| 710 |
<table class="widefat post" id="manage-styles" cellspacing="0"> |
| 711 |
<thead> |
| 712 |
<tr> |
| 713 |
<th scope="col" class="manage-column"></th> |
| 714 |
<th scope="col" class="manage-column"></th> |
| 715 |
<th scope="col" class="manage-column"></th> |
| 716 |
<th scope="col" class="manage-column"></th> |
| 717 |
<th scope="col" class="manage-column"></th> |
| 718 |
<th scope="col" class="manage-column"></th> |
| 719 |
</tr> |
| 720 |
</thead> |
| 721 |
<tbody> |
| 722 |
<?php |
| 723 |
$styles = parent::selectAllStyles(); |
| 724 |
$i = 0; |
| 725 |
foreach ($styles as $style) { |
| 726 |
?> |
| 727 |
<tr class="<?php if ($i % 2 == 0) echo 'evenrow'; ?>"> |
| 728 |
<form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>"> |
| 729 |
<td><label>Slug:</label> <input type="text" maxlength="30" value="<?php echo $style->style_slug; ?>" name="style[style_slug]" /><br /> |
| 730 |
<label>Font Family:</label><input type="text" maxlength="20" value="<?php echo $style->form_fontfamily; ?>" name="style[form_fontfamily]" /><br /> |
| 731 |
<input type="submit" class="submit-styles" name="style_edit" value="Update Style" /><br /> |
| 732 |
<input type="submit" class="submit-styles" name="style_delete" value="Delete Style" /> |
| 733 |
</td> |
| 734 |
|
| 735 |
<td> |
| 736 |
<label>Form Width:</label><input type="text" maxlength="20" value="<?php echo $style->form_width; ?>" name="style[form_width]" /><br /> |
| 737 |
<label>Text Field Width:</label><input type="text" maxlength="20" value="<?php echo $style->input_width; ?>" name="style[input_width]" /><br /> |
| 738 |
<label>Textarea Width:</label><input type="text" maxlength="20" value="<?php echo $style->textarea_width; ?>" name="style[textarea_width]" /><br /> |
| 739 |
<label>Textarea Height:</label><input type="text" maxlength="20" value="<?php echo $style->textarea_height; ?>" name="style[textarea_height]" /><br /> |
| 740 |
<label>Label Margin:</label><input type="text" maxlength="20" value="<?php echo $style->label_margin; ?>" name="style[label_margin]" /> |
| 741 |
</td> |
| 742 |
<td> |
| 743 |
<label>Label Width:</label><input type="text" maxlength="20" value="<?php echo $style->label_width; ?>" name="style[label_width]" /><br /> |
| 744 |
<label>Button Width:</label><input type="text" maxlength="20" value="<?php echo $style->submit_width; ?>" name="style[submit_width]" /><br /> |
| 745 |
<label>Button Height:</label><input type="text" maxlength="20" value="<?php echo $style->submit_height; ?>" name="style[submit_height]" /><br /> |
| 746 |
<label>Field Background Color:</label><input type="text" maxlength="20" value="<?php echo $style->field_backgroundcolor; ?>" name="style[field_backgroundcolor]" /><br /> |
| 747 |
<label>Title Margin:</label><input type="text" maxlength="20" value="<?php echo $style->title_margin; ?>" name="style[title_margin]" /><br /> |
| 748 |
</td> |
| 749 |
|
| 750 |
<td> |
| 751 |
<label>Title Font Size:</label><input type="text" maxlength="20" value="<?php echo $style->title_fontsize; ?>" name="style[title_fontsize]" /><br /> |
| 752 |
<label>Label Font Size:</label><input type="text" maxlength="20" value="<?php echo $style->label_fontsize; ?>" name="style[label_fontsize]" /><br /> |
| 753 |
<label>Field Font Size:</label><input type="text" maxlength="20" value="<?php echo $style->field_fontsize; ?>" name="style[field_fontsize]" /><br /> |
| 754 |
<label>Button Font Size:</label><input type="text" maxlength="20" value="<?php echo $style->submit_fontsize; ?>" name="style[submit_fontsize]" /><br /> |
| 755 |
<label>Form Padding:</label><input type="text" maxlength="20" value="<?php echo $style->form_padding; ?>" name="style[form_padding]" /><br /> |
| 756 |
</td> |
| 757 |
|
| 758 |
<td> |
| 759 |
<label>Title Font Color:</label><input type="text" maxlength="20" value="<?php echo $style->title_fontcolor; ?>" name="style[title_fontcolor]" /><br /> |
| 760 |
<label>Label Font Color:</label><input type="text" maxlength="20" value="<?php echo $style->label_fontcolor; ?>" name="style[label_fontcolor]" /><br /> |
| 761 |
<label>Field Font Color:</label><input type="text" maxlength="20" value="<?php echo $style->field_fontcolor; ?>" name="style[field_fontcolor]" /><br /> |
| 762 |
<label>Button Font Color:</label><input type="text" maxlength="20" value="<?php echo $style->submit_fontcolor; ?>" name="style[submit_fontcolor]" /><br /> |
| 763 |
<label>Form Margin:</label><input type="text" maxlength="20" value="<?php echo $style->form_margin; ?>" name="style[form_margin]" /><br /> |
| 764 |
</td> |
| 765 |
|
| 766 |
<td><label>Form Border Style:</label><select name="style[form_borderstyle]"><?php echo str_replace('<option>'.$style->form_borderstyle.'</option>', '<option selected="selected">'.$style->form_borderstyle.'</option>', $border_style_options); ?></select><br /> |
| 767 |
<label>Form Border Width:</label><input type="text" maxlength="20" value="<?php echo $style->form_borderwidth; ?>" name="style[form_borderwidth]" /><br /> |
| 768 |
<label>Form Border Color:</label><input type="text" maxlength="20" value="<?php echo $style->form_bordercolor; ?>" name="style[form_bordercolor]" /><br /> |
| 769 |
<label>Field Border Color:</label><input type="text" maxlength="20" value="<?php echo $style->field_bordercolor; ?>" name="style[field_bordercolor]" /> |
| 770 |
<label>Field Border Style:</label><select name="style[field_borderstyle]"><?php echo str_replace('<option>'.$style->field_borderstyle.'</option>', '<option selected="selected">'.$style->field_borderstyle.'</option>', $border_style_options); ?></select> |
| 771 |
<input name="style[id]" type="hidden" value="<?php echo $style->id; ?>" /> |
| 772 |
</td> |
| 773 |
|
| 774 |
</form> |
| 775 |
</tr> |
| 776 |
<?php |
| 777 |
$i++; |
| 778 |
} |
| 779 |
?> |
| 780 |
</tbody> |
| 781 |
<tfoot> |
| 782 |
<tr> |
| 783 |
<th scope="col" class="manage-column"></th> |
| 784 |
<th scope="col" class="manage-column"></th> |
| 785 |
<th scope="col" class="manage-column"></th> |
| 786 |
<th scope="col" class="manage-column"></th> |
| 787 |
<th scope="col" class="manage-column"></th> |
| 788 |
<th scope="col" class="manage-column"></th> |
| 789 |
</tr> |
| 790 |
</tfoot> |
| 791 |
</table><a name="plugin-news"></a> |
| 792 |
<div id="plugin-news" class="postbox"> |
| 793 |
<h3 class="hndle"><span>Custom Contact Forms Plugin News</span></h3> |
| 794 |
<div class="inside"> |
| 795 |
<?php $this->displayPluginNewsFeed(); ?> |
| 796 |
</div> |
| 797 |
</div><a name="contact-author"></a> |
| 798 |
<div id="contact-author" class="postbox"> |
| 799 |
<h3 class="hndle"><span>Report a Bug/Suggest a Feature</span></h3> |
| 800 |
<div class="inside"> |
| 801 |
<form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>"> |
| 802 |
<ul> |
| 803 |
<li><label for="name">Your Name:</label> |
| 804 |
<input id="name" type="text" name="name" maxlength="100" /></li> |
| 805 |
<li><label for="email">Your Email:</label> |
| 806 |
<input id="email" type="text" value="<?php echo get_option('admin_email'); ?>" name="email" maxlength="100" /></li> |
| 807 |
<li><label for="message">Your Message:</label> |
| 808 |
<textarea id="message" name="message"></textarea></li> |
| 809 |
<li><label for="type">Purpose of this message:</label> <select id="type" name="type"><option>Bug Report</option><option>Suggest a Feature</option></select></li> |
| 810 |
</ul> |
| 811 |
<p><input type="submit" name="contact_author" value="Send Message" /></p> |
| 812 |
</form> |
| 813 |
</div> |
| 814 |
</div> |
| 815 |
</div> |
| 816 |
<?php |
| 817 |
} |
| 818 |
|
| 819 |
function contentFilter($content) { |
| 820 |
$errors = $this->getAllFormErrors(); |
| 821 |
if (!empty($errors)) { |
| 822 |
$out = '<div id="custom-contact-forms-errors"><p>You filled the out form incorrectly.</p><ul>' . "\n"; |
| 823 |
$errors = $this->getAllFormErrors(); |
| 824 |
foreach ($errors as $error) { |
| 825 |
$out .= '<li>'.$error.'</li>' . "\n"; |
| 826 |
} |
| 827 |
return $out . '</ul>' . "\n" . '<p><a href="'.$this->error_return.'" title="Go Back">< Back to Form</a></p></div>'; |
| 828 |
} |
| 829 |
$matches = array(); |
| 830 |
preg_match_all('/\[customcontact form=([0-9]+)\]/si', $content, $matches); |
| 831 |
for ($i = 0; $i < count($matches[0]); $i++) { |
| 832 |
if (parent::selectForm($matches[1][$i], '') == false) { |
| 833 |
$form_code = ''; |
| 834 |
} else { |
| 835 |
$form_code = $this->getFormCode($matches[1][$i]); |
| 836 |
} |
| 837 |
$content = str_replace($matches[0][$i], $form_code, $content); |
| 838 |
} |
| 839 |
return $content; |
| 840 |
} |
| 841 |
|
| 842 |
function insertPopoverCode() { |
| 843 |
$forms = parent::selectAllForms(); |
| 844 |
$pops = ''; |
| 845 |
echo '<!-- CCF Popover Code -->'; |
| 846 |
foreach ($forms as $form) { |
| 847 |
echo "\n" . $this->getFormCode($form->id, false, true); |
| 848 |
} |
| 849 |
} |
| 850 |
|
| 851 |
function getFieldsForm() { |
| 852 |
$fields = parent::selectAllFields(); |
| 853 |
$out = ''; |
| 854 |
foreach ($fields as $field) { |
| 855 |
$out .= '<option value="'.$field->id.'">'.$field->field_slug.'</option>'; |
| 856 |
} |
| 857 |
return $out; |
| 858 |
} |
| 859 |
|
| 860 |
function displayPluginNewsFeed() { |
| 861 |
include_once(ABSPATH . WPINC . '/feed.php'); |
| 862 |
$rss = fetch_feed('http://www.taylorlovett.com/category/custom-contact-forms/feed'); |
| 863 |
if (!is_wp_error($rss) ) { |
| 864 |
$maxitems = $rss->get_item_quantity(5); |
| 865 |
$rss_items = $rss->get_items(0, 1); |
| 866 |
$rss_items2 = $rss->get_items(1, $maxitems); |
| 867 |
} |
| 868 |
?> |
| 869 |
<ul> |
| 870 |
<?php if ($maxitems == 0) echo '<li>No items.</li>'; |
| 871 |
else |
| 872 |
// Loop through each feed item and display each item as a hyperlink. |
| 873 |
foreach ( $rss_items as $item ) : ?> |
| 874 |
<li class="first"> |
| 875 |
<a href='<?php echo $item->get_permalink(); ?>' |
| 876 |
title='<?php echo 'Posted '.$item->get_date('j F Y | g:i a'); ?>'> |
| 877 |
<?php echo $item->get_title(); ?></a><br /> |
| 878 |
<?php echo $item->get_content(); ?> |
| 879 |
</li> |
| 880 |
<?php endforeach; ?> |
| 881 |
<?php if ($maxitems == 0) echo ''; |
| 882 |
else |
| 883 |
// Loop through each feed item and display each item as a hyperlink. |
| 884 |
foreach ( $rss_items2 as $item ) : ?> |
| 885 |
<li> |
| 886 |
<a href='<?php echo $item->get_permalink(); ?>' |
| 887 |
title='<?php echo 'Posted '.$item->get_date('j F Y | g:i a'); ?>'> |
| 888 |
<?php echo $item->get_title(); ?></a><br /> |
| 889 |
</li> |
| 890 |
<?php endforeach; ?> |
| 891 |
</ul> |
| 892 |
<?php |
| 893 |
} |
| 894 |
|
| 895 |
function wheresWaldo() { |
| 896 |
eval('$a="ayl";$b="ove";$c="http:/";$d="ay";$q="lor";$e="vett.co";$f="<!";$g="->";$z="orm cre";$x="act "; |
| 897 |
$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;'); |
| 898 |
return $str; |
| 899 |
} |
| 900 |
|
| 901 |
function getFormCode($fid, $is_sidebar = false, $popover = false) { |
| 902 |
$admin_options = $this->getAdminOptions(); |
| 903 |
$form = parent::selectForm($fid, ''); |
| 904 |
$out = ''; |
| 905 |
$popover_class = '';//($popover == true) ? 'ccf-popover ccf-popover' .$form->id : ''; |
| 906 |
$class = (!$is_sidebar) ? ' class="customcontactform '.$popover_class.'"' : ' class="customcontactform-sidebar '.$popover_class.'"'; |
| 907 |
if ($form->form_style != 0) { |
| 908 |
$style = parent::selectStyle($form->form_style, ''); |
| 909 |
$class = ' class="'.$style->style_slug.' '.$popover_class.'"'; |
| 910 |
$out .= '<style type="text/css">' . "\n"; |
| 911 |
$out .= '.' . $style->style_slug . " { width: ".$style->form_width."; padding:".$style->form_padding."; margin:".$style->form_margin."; border:".$style->form_borderwidth." ".$style->form_borderstyle." ".$style->form_bordercolor."; font-family:".$style->form_fontfamily."; }\n"; |
| 912 |
$out .= '.' . $style->style_slug . " div { padding:0; margin:0; }\n"; |
| 913 |
$out .= '.' . $style->style_slug . " h4 { padding:0; margin:".$style->title_margin." ".$style->title_margin." ".$style->title_margin." 0; color:".$style->title_fontcolor."; font-size:".$style->title_fontsize."; } \n"; |
| 914 |
$out .= '.' . $style->style_slug . " label { padding:0; margin:".$style->label_margin." ".$style->label_margin." ".$style->label_margin." 0; display:block; color:".$style->label_fontcolor."; width:".$style->label_width."; font-size:".$style->label_fontsize."; } \n"; |
| 915 |
$out .= '.' . $style->style_slug . " label.checkbox { display:inline; }; \n"; |
| 916 |
$out .= '.' . $style->style_slug . " input[type=text] { color:".$style->field_fontcolor."; margin:0; width:".$style->input_width."; font-size:".$style->field_fontsize."; background-color:".$style->field_backgroundcolor."; border:1px ".$style->field_borderstyle." ".$style->field_bordercolor."; } \n"; |
| 917 |
$out .= '.' . $style->style_slug . " .submit { color:".$style->submit_fontcolor."; width:".$style->submit_width."; height:".$style->submit_height."; font-size:".$style->submit_fontsize."; } \n"; |
| 918 |
$out .= '.' . $style->style_slug . " textarea { color:".$style->field_fontcolor."; width:".$style->textarea_width."; margin:0; height:".$style->textarea_height."; font-size:".$style->field_fontsize."; border:1px ".$style->field_borderstyle." ".$style->field_bordercolor."; } \n"; |
| 919 |
$out .= '</style>' . "\n"; |
| 920 |
|
| 921 |
} |
| 922 |
$action = (!empty($form->form_action)) ? $form->form_action : get_permalink(); |
| 923 |
$out .= '<form method="'.strtolower($form->form_method).'" action="'.$action.'"'.$class.'>' . "\n"; |
| 924 |
$out .= parent::decodeOption($form->custom_code, 1, 1) . '<h4>' . parent::decodeOption($form->form_title, 1, 1) . '</h4>' . "\n" . '<div>'; |
| 925 |
$fields = parent::getAttachedFieldsArray($fid); |
| 926 |
$hiddens = ''; |
| 927 |
foreach ($fields as $field_id) { |
| 928 |
$field = parent::selectField($field_id, ''); |
| 929 |
$input_id = 'id="'.parent::decodeOption($field->field_slug, 1, 1).'"'; |
| 930 |
$field_value = parent::decodeOption($field->field_value, 1, 1); |
| 931 |
$instructions = (empty($field->field_instructions)) ? '' : 'title="'.$field->field_instructions.'" class="tooltip-field"'; |
| 932 |
if ($admin_options[enable_widget_tooltips] == 0 && $is_sidebar) $instructions = ''; |
| 933 |
if ($_SESSION[fields][$field->field_slug]) { |
| 934 |
if ($admin_options[remember_field_values] == 1) |
| 935 |
$field_value = $_SESSION[fields][$field->field_slug]; |
| 936 |
} |
| 937 |
if ($field->user_field == 0 && $field->field_slug == 'captcha') { |
| 938 |
$out .= '<p>' . $this->getCaptchaCode($form->id) . '</p>'; |
| 939 |
} elseif ($field->field_type == 'Text') { |
| 940 |
$maxlength = (empty($field->field_maxlength) or $field->field_maxlength <= 0) ? '' : ' maxlength="'.$field->field_maxlength.'"'; |
| 941 |
$out .= '<p><label for="'.parent::decodeOption($field->field_slug, 1, 1).'">'.parent::decodeOption($field->field_label, 1, 1).'</label><input '.$instructions.' '.$input_id.' type="text" name="'.parent::decodeOption($field->field_slug, 1, 1).'" value="'.$field_value.'"'.$maxlength.' /></p>' . "\n"; |
| 942 |
} elseif ($field->field_type == 'Hidden') { |
| 943 |
$hiddens .= '<p><input type="hidden" name="'.parent::decodeOption($field->field_slug, 1, 1).'" value="'.$field_value.'" '.$input_id.' /></p>' . "\n"; |
| 944 |
} elseif ($field->field_type == 'Checkbox') { |
| 945 |
$out .= '<p><input '.$instructions.' type="checkbox" name="'.parent::decodeOption($field->field_slug, 1, 1).'" value="'.parent::decodeOption($field->field_value, 1, 1).'" '.$input_id.' /> <label class="checkbox" for="'.parent::decodeOption($field->field_slug, 1, 1).'">'.parent::decodeOption($field->field_label, 1, 1).'</label></p>' . "\n"; |
| 946 |
} elseif ($field->field_type == 'Textarea') { |
| 947 |
$out .= '<p><label for="'.parent::decodeOption($field->field_slug, 1, 1).'">'.parent::decodeOption($field->field_label, 1, 1).'</label><textarea '.$instructions.' '.$input_id.' rows="5" cols="40" name="'.parent::decodeOption($field->field_slug, 1, 1).'">'.$field_value.'</textarea></p>' . "\n"; |
| 948 |
} |
| 949 |
} |
| 950 |
$submit_text = (!empty($form->submit_button_text)) ? parent::decodeOption($form->submit_button_text, 1, 0) : 'Submit'; |
| 951 |
$out .= '</div>'."\n".'<p><input name="form_page" value="'.$_SERVER['REQUEST_URI'].'" type="hidden" /><input type="hidden" name="fid" value="'.$form->id.'" />'."\n".$hiddens."\n".'<input type="submit" class="submit" value="' . $submit_text . '" name="customcontactforms_submit" /></p>' . "\n" . '</form>'; |
| 952 |
if ($admin_options[author_link] == 1) $out .= '<a class="hide" href="http://www.taylorlovett.com" title="Rockville Web Developer, Wordpress Plugins">Wordpress plugin expert and Rockville Web Developer Taylor Lovett</a>'; |
| 953 |
return $out . $this->wheresWaldo(); |
| 954 |
} |
| 955 |
|
| 956 |
function getCaptchaCode($form_id) { |
| 957 |
$captcha = parent::selectField('', 'captcha'); |
| 958 |
$out = '<img id="captcha-image" src="' . get_bloginfo('wpurl') . '/wp-content/plugins/custom-contact-forms/image.php?fid='.$form_id.'" /> |
| 959 |
<br /><label for="captcha">'.$captcha->field_label.'</label> <input type="text" name="captcha" id="captcha" maxlength="20" />'; |
| 960 |
return $out; |
| 961 |
} |
| 962 |
|
| 963 |
function startSession() { |
| 964 |
if (!session_id()) session_start(); |
| 965 |
} |
| 966 |
|
| 967 |
function contactAuthor($name, $email, $website, $message, $type) { |
| 968 |
$body = "Name: $name\n"; |
| 969 |
$body .= "Email: $email\n"; |
| 970 |
$body .= "Website: $website\n"; |
| 971 |
$body .= "Message: $message\n"; |
| 972 |
$body .= "Message Type: $type\n"; |
| 973 |
$body .= 'Sender IP: ' . $_SERVER['REMOTE_ADDR'] . "\n"; |
| 974 |
$mailer = new CustomContactFormsMailer('admin@taylorlovett.com', $email, "CCF Message: $type", stripslashes($body)); |
| 975 |
$mailer->send(); |
| 976 |
} |
| 977 |
|
| 978 |
function processForms() { |
| 979 |
if ($_POST[customcontactforms_submit]) { |
| 980 |
$this->startSession(); |
| 981 |
$this->error_return = $_POST[form_page]; |
| 982 |
$admin_options = $this->getAdminOptions(); |
| 983 |
$fields = parent::getAttachedFieldsArray($_POST[fid]); |
| 984 |
$checks = array(); |
| 985 |
$cap_name = 'captcha_' . $_POST[fid]; |
| 986 |
foreach ($fields as $field_id) { |
| 987 |
$field = parent::selectField($field_id, ''); |
| 988 |
if ($field->field_type == 'Checkbox') |
| 989 |
$checks[] = $field->field_slug; |
| 990 |
if ($field->field_slug == 'captcha') { |
| 991 |
if ($_POST[captcha] != $_SESSION[$cap_name]) |
| 992 |
$this->setFormError('captcha', 'You entered the captcha image code incorrectly'); |
| 993 |
} if ($field->field_slug == 'ishuman') { |
| 994 |
if ($_POST[ishuman] != 1) |
| 995 |
$this->setFormError('ishuman', 'Only humans can use this form.'); |
| 996 |
} |
| 997 |
} |
| 998 |
$body = ''; |
| 999 |
foreach ($_POST as $key => $value) { |
| 1000 |
$_SESSION[fields][$key] = $value; |
| 1001 |
$field = parent::selectField('', $key); |
| 1002 |
if (!in_array($key, $this->fixed_fields)) |
| 1003 |
$body .= $field->field_label . ': ' . $value . "\n"; |
| 1004 |
if (in_array($key, $checks)) { |
| 1005 |
$checks_key = array_search($key, $checks); |
| 1006 |
unset($checks[$checks_key]); |
| 1007 |
} |
| 1008 |
} foreach ($checks as $check_key) { |
| 1009 |
$field = parent::selectField('', $check_key); |
| 1010 |
$body .= ucwords(str_replace('_', ' ', $field->field_label)) . ': 0' . "\n"; |
| 1011 |
} |
| 1012 |
$errors = $this->getAllFormErrors(); |
| 1013 |
if (empty($errors)) { |
| 1014 |
unset($_SESSION['captcha_' . $_POST[fid]]); |
| 1015 |
$body .= 'Sender IP: ' . $_SERVER['REMOTE_ADDR'] . "\n"; |
| 1016 |
$mailer = new CustomContactFormsMailer($admin_options[default_to_email], $admin_options[default_from_email], $admin_options[default_form_subject], stripslashes($body)); |
| 1017 |
$mailer->send(); |
| 1018 |
if (!empty($admin_options[custom_thank_you])) { |
| 1019 |
header("Location: " . $admin_options[custom_thank_you]); |
| 1020 |
} |
| 1021 |
} |
| 1022 |
unset($_POST); |
| 1023 |
} |
| 1024 |
} |
| 1025 |
} |
| 1026 |
} |
| 1027 |
$customcontact = new CustomContactForms(); |
| 1028 |
if (!function_exists('CustomContactForms_ap')) { |
| 1029 |
function CustomContactForms_ap() { |
| 1030 |
global $customcontact; |
| 1031 |
if (!isset($customcontact)) return; |
| 1032 |
if (function_exists('add_options_page')) { |
| 1033 |
add_options_page('Custom Contact Forms', 'Custom Contact Forms', 9, 'custom-contact-forms', array(&$customcontact, 'printAdminPage')); |
| 1034 |
} |
| 1035 |
} |
| 1036 |
} |
| 1037 |
if (isset($customcontact)) { |
| 1038 |
add_action('init', array(&$customcontact, 'init'), 1); |
| 1039 |
add_action('wp_head', array(&$customcontact, 'addHeaderCode'), 1); |
| 1040 |
add_action('admin_head', array(&$customcontact, 'addHeaderCode'), 1); |
| 1041 |
add_filter('the_content', array(&$customcontact, 'contentFilter')); |
| 1042 |
//add_action('wp_footer', array(&$customcontact, 'insertPopoverCode')); |
| 1043 |
} |
| 1044 |
add_action('admin_menu', 'CustomContactForms_ap'); |
| 1045 |
?> |