| 1 |
<?php |
| 2 |
/* |
| 3 |
Plugin Name: Custom Contact Forms |
| 4 |
Plugin URI: http://taylorlovett.com/wordpress-plugins |
| 5 |
Description: VERSION 2.0.0 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.0.2 |
| 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 = '1.1.0'; |
| 32 |
var $errors; |
| 33 |
var $error_return; |
| 34 |
var $fixed_fields = array('customcontactforms_submit', 'fid', 'form_page', 'captcha'); |
| 35 |
|
| 36 |
function CustomContactForms() { |
| 37 |
parent::CustomContactFormsDB(); |
| 38 |
$this->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); // 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 |
$this->registerSidebar(); |
| 55 |
} |
| 56 |
function registerSidebar() { |
| 57 |
register_sidebar_widget(__('Custom Contact Form'), array($this, 'widget_customContactForms')); |
| 58 |
register_widget_control('Custom Contact Form', array($this, 'customContactForms_control'), 300, 200); |
| 59 |
} |
| 60 |
function customContactForms_control() { |
| 61 |
$option = get_option($this->widgetOptionsName); |
| 62 |
if (empty($option)) $option = array('widget_form_id' => '0'); |
| 63 |
if ($_POST[widget_form_id]) { |
| 64 |
$option[widget_form_id] = $_POST[widget_form_id]; |
| 65 |
update_option($this->widgetOptionsName, $option); |
| 66 |
$option = get_option($this->widgetOptionsName); |
| 67 |
} |
| 68 |
$forms = parent::selectAllForms(); |
| 69 |
|
| 70 |
$form_options = ''; |
| 71 |
foreach ($forms as $form) { |
| 72 |
$sel = ($option[widget_form_id] == $form->id) ? ' selected="selected"' : ''; |
| 73 |
$form_options .= '<option value="'.$form->id.'"'.$sel.'>'.$form->form_slug.'</option>'; |
| 74 |
} |
| 75 |
if (empty($form_options)) { ?> |
| 76 |
|
| 77 |
<p>Create a form in the Custom Contact Forms settings page.</p> |
| 78 |
<?php |
| 79 |
} else { |
| 80 |
?> |
| 81 |
<p> |
| 82 |
<label for="widget_form_id">Show Form:</label> |
| 83 |
<select name="widget_form_id"> |
| 84 |
<?php echo $form_options; ?> |
| 85 |
</select> |
| 86 |
</p> |
| 87 |
<?php |
| 88 |
} |
| 89 |
} |
| 90 |
function widget_customContactForms($args) { |
| 91 |
extract($args); |
| 92 |
$admin_option = $this->getAdminOptions(); |
| 93 |
if ((is_front_page() and $admin_option[show_widget_home] != 1) or (is_single() and $admin_option[show_widget_singles] != 1) or |
| 94 |
(is_page() and $admin_option[show_widget_pages] != 1) or (is_category() and $admin_option[show_widget_categories] != 1) or |
| 95 |
(is_archive() and $admin_option[show_widget_archives] != 1)) |
| 96 |
return false; |
| 97 |
$option = get_option($this->widgetOptionsName); |
| 98 |
if (empty($option) or $option[widget_form_id] < 1) return false; |
| 99 |
echo $before_widget . $this->getFormCode($option[widget_form_id], true, $args) . $after_widget; |
| 100 |
} |
| 101 |
function addHeaderCode() { |
| 102 |
?> |
| 103 |
<!-- Custom Contact Forms by Taylor Lovett - http://www.taylorlovett.com --> |
| 104 |
<link rel="stylesheet" href="<?php echo get_option('siteurl'); ?>/wp-content/plugins/custom-contact-forms/custom-contact-forms.css" type="text/css" media="screen" /> |
| 105 |
<?php |
| 106 |
} |
| 107 |
|
| 108 |
function setError($key, $message) { |
| 109 |
$this->errors[$key] = $message; |
| 110 |
} |
| 111 |
|
| 112 |
function getError($key) { |
| 113 |
return $this->errors[$key]; |
| 114 |
} |
| 115 |
|
| 116 |
function getAllErrors() { |
| 117 |
return $this->errors; |
| 118 |
} |
| 119 |
|
| 120 |
function printAdminPage() { |
| 121 |
$admin_options = $this->getAdminOptions(); |
| 122 |
if ($_POST[form_create]) { |
| 123 |
parent::insertForm($_POST[form_slug], $_POST[form_title], $_POST[form_action], $_POST[form_method], $_POST[submit_button_text], $_POST[custom_code], $_POST[form_style]); |
| 124 |
} elseif ($_POST[field_create]) { |
| 125 |
parent::insertField($_POST[field_slug], $_POST[field_label], $_POST[field_type], $_POST[field_value], $_POST[field_maxlength], 1); |
| 126 |
} elseif ($_POST[general_settings]) { |
| 127 |
$admin_options[default_to_email] = $_POST[default_to_email]; |
| 128 |
$admin_options[default_from_email] = $_POST[default_from_email]; |
| 129 |
$admin_options[default_form_subject] = $_POST[default_form_subject]; |
| 130 |
$admin_options[show_widget_categories] = $_POST[show_widget_categories]; |
| 131 |
$admin_options[show_widget_singles] = $_POST[show_widget_singles]; |
| 132 |
$admin_options[show_widget_pages] = $_POST[show_widget_pages]; |
| 133 |
$admin_options[show_widget_archives] = $_POST[show_widget_archives]; |
| 134 |
$admin_options[show_widget_home] = $_POST[show_widget_home]; |
| 135 |
$admin_options[custom_thank_you] = $_POST[custom_thank_you]; |
| 136 |
update_option($this->adminOptionsName, $admin_options); |
| 137 |
} elseif ($_POST[field_edit]) { |
| 138 |
parent::updateField($_POST[field_slug], $_POST[field_label], $_POST[field_type], $_POST[field_value], $_POST[field_maxlength], $_POST[fid]); |
| 139 |
} elseif ($_POST[field_delete]) { |
| 140 |
parent::deleteField($_POST[fid]); |
| 141 |
} elseif ($_POST[form_delete]) { |
| 142 |
parent::deleteForm($_POST[fid]); |
| 143 |
} elseif ($_POST[form_edit]) { |
| 144 |
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]); |
| 145 |
} elseif ($_POST[form_add_field]) { |
| 146 |
parent::addFieldToForm($_POST[field_id], $_POST[fid]); |
| 147 |
} elseif ($_POST[disattach_field]) { |
| 148 |
parent::disattachField($_POST[disattach_field_id], $_POST[fid]); |
| 149 |
} elseif ($_POST[style_create]) { |
| 150 |
parent::insertStyle($_POST[style]); |
| 151 |
} elseif ($_POST[style_edit]) { |
| 152 |
parent::updateStyle($_POST[style]); |
| 153 |
} elseif ($_POST[style_delete]) { |
| 154 |
parent::deleteStyle($_POST[style][id]); |
| 155 |
} |
| 156 |
$styles = parent::selectAllStyles(); |
| 157 |
$style_options = '<option value="0">None</option>'; |
| 158 |
foreach ($styles as $style) |
| 159 |
$style_options .= '<option value="'.$style->id.'">'.$style->style_slug.'</option>'; |
| 160 |
?> |
| 161 |
<div id="customcontactforms-admin"> |
| 162 |
<div id="icon-themes" class="icon32"></div> |
| 163 |
<h2>Custom Contact Forms</h2> |
| 164 |
<div id="create-fields" class="postbox"> |
| 165 |
<h3 class="hndle"><span>Create A Form Field</span></h3> |
| 166 |
<div class="inside"> |
| 167 |
<form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>"> |
| 168 |
<ul> |
| 169 |
<li> |
| 170 |
<label for="field_slug">* Slug (Name):</label> |
| 171 |
<input name="field_slug" type="text" maxlength="50" /> |
| 172 |
(Must be unique)</li> |
| 173 |
<li> |
| 174 |
<label for="field_label">Field Label:</label> |
| 175 |
<input name="field_label" type="text" maxlength="100" /> |
| 176 |
</li> |
| 177 |
<li> |
| 178 |
<label for="field_type">* Field Type:</label> |
| 179 |
<select name="field_type"> |
| 180 |
<option>Text</option> |
| 181 |
<option>Textarea</option> |
| 182 |
<option>Hidden</option> |
| 183 |
<option>Checkbox</option> |
| 184 |
</select> |
| 185 |
</li> |
| 186 |
<li> |
| 187 |
<label for="field_value">Initial Value:</label> |
| 188 |
<input name="field_value" type="text" maxlength="50" /> |
| 189 |
</li> |
| 190 |
<li> |
| 191 |
<label for="field_maxlength">Max Length:</label> |
| 192 |
<input class="width50" size="10" name="field_maxlength" type="text" maxlength="4" /> |
| 193 |
(0 for no limit; only applies to Text fields)</li> |
| 194 |
<li> |
| 195 |
<input type="submit" value="Create Field" name="field_create" /> |
| 196 |
</li> |
| 197 |
</ul> |
| 198 |
</form> |
| 199 |
</div> |
| 200 |
</div> |
| 201 |
<div id="create-forms" class="postbox"> |
| 202 |
<h3 class="hndle"><span>Create A Form</span></h3> |
| 203 |
<div class="inside"> |
| 204 |
<form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>"> |
| 205 |
<ul> |
| 206 |
<li> |
| 207 |
<label for="form_name">Form Slug:</label> |
| 208 |
<input type="text" maxlength="100" name="form_slug" /> |
| 209 |
(Must be unique)</li> |
| 210 |
<li> |
| 211 |
<label for="form_title">Form Title:</label> |
| 212 |
<input type="text" maxlength="200" name="form_title" /> |
| 213 |
(The form header text)</li> |
| 214 |
<li> |
| 215 |
<label for="form_method">Form Method:</label> |
| 216 |
<select name="form_method"> |
| 217 |
<option>Post</option> |
| 218 |
<option>Get</option> |
| 219 |
</select> |
| 220 |
(If unsure, leave as is.)</li> |
| 221 |
<li> |
| 222 |
<label for="form_action">Form Action:</label> |
| 223 |
<input type="text" name="form_action" value="" /> |
| 224 |
(If unsure, leave blank.)</li> |
| 225 |
<li> |
| 226 |
<label for="form_action">Form Style:</label> |
| 227 |
<select name="form_style"><?php echo $style_options; ?></select> |
| 228 |
(<a href="#styles">Click to create a style</a>)</li> |
| 229 |
<li> |
| 230 |
<label for="submit_button_text">Submit Button Text:</label> |
| 231 |
<input type="text" maxlength="200" name="submit_button_text" /> |
| 232 |
</li> |
| 233 |
<li> |
| 234 |
<label for="custom_code">Custom Code:</label> |
| 235 |
<input type="text" name="custom_code" /> |
| 236 |
(If unsure, leave blank.)</li> |
| 237 |
<li> |
| 238 |
<input type="submit" value="Create Form" name="form_create" /> |
| 239 |
</li> |
| 240 |
</ul> |
| 241 |
</form> |
| 242 |
</div> |
| 243 |
</div> |
| 244 |
<h3 class="manage-h3">Manage User Fields</h3> |
| 245 |
<table class="widefat post" id="manage-fields" cellspacing="0"> |
| 246 |
<thead> |
| 247 |
<tr> |
| 248 |
<th scope="col" class="manage-column field-slug">Slug</th> |
| 249 |
<th scope="col" class="manage-column field-label">Label</th> |
| 250 |
<th scope="col" class="manage-column field-type">Type</th> |
| 251 |
<th scope="col" class="manage-column field-value">Initial Value</th> |
| 252 |
<th scope="col" class="manage-column field-maxlength">Maxlength</th> |
| 253 |
<th scope="col" class="manage-column field-action">Action</th> |
| 254 |
</tr> |
| 255 |
</thead> |
| 256 |
<tbody> |
| 257 |
<?php |
| 258 |
$fields = parent::selectAllFields(); |
| 259 |
for ($i = 0; $i < count($fields); $i++) { |
| 260 |
if ($fields[$i]->user_field == 0) continue; |
| 261 |
$field_types = '<option>Text</option><option>Textarea</option><option>Hidden</option><option>Checkbox</option>'; |
| 262 |
$field_types = str_replace('<option>'.$fields[$i]->field_type.'</option>', '<option selected="selected">'.$fields[$i]->field_type.'</option>', $field_types); |
| 263 |
|
| 264 |
?> |
| 265 |
<tr<?php if ($i % 2 == 0) echo ' class="evenrow"'; ?>> |
| 266 |
<form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>"> |
| 267 |
<td><input type="text" name="field_slug" maxlength="50" value="<?php echo $fields[$i]->field_slug; ?>" /></td> |
| 268 |
<td><input type="text" name="field_label" maxlength="100" value="<?php echo $fields[$i]->field_label; ?>" /></td> |
| 269 |
<td><select name="field_type"> |
| 270 |
<?php echo $field_types; ?> |
| 271 |
</select></td> |
| 272 |
<td><input type="text" name="field_value" maxlength="50" value="<?php echo $fields[$i]->field_value; ?>" /></td> |
| 273 |
<td><input type="text" class="width50" name="field_maxlength" value="<?php echo $fields[$i]->field_maxlength; ?>" /></td> |
| 274 |
<td><input type="hidden" name="fid" value="<?php echo $fields[$i]->id; ?>" /> |
| 275 |
<input type="submit" name="field_edit" value="Edit" /> |
| 276 |
<input type="submit" name="field_delete" value="Delete" /></td> |
| 277 |
</form> |
| 278 |
</tr> |
| 279 |
<?php |
| 280 |
} |
| 281 |
?> |
| 282 |
</tbody> |
| 283 |
<tfoot> |
| 284 |
<tr> |
| 285 |
<th scope="col" class="manage-column field-slug">Slug</th> |
| 286 |
<th scope="col" class="manage-column field-label">Label</th> |
| 287 |
<th scope="col" class="manage-column field-type">Type</th> |
| 288 |
<th scope="col" class="manage-column field-value">Initial Value</th> |
| 289 |
<th scope="col" class="manage-column field-maxlength">Maxlength</th> |
| 290 |
<th scope="col" class="manage-column field-action">Action</th> |
| 291 |
</tr> |
| 292 |
</tfoot> |
| 293 |
</table> |
| 294 |
<h3 class="manage-h3">Manage Fixed Fields</h3> |
| 295 |
<table class="widefat post" id="manage-fixed-fields" cellspacing="0"> |
| 296 |
<thead> |
| 297 |
<tr> |
| 298 |
<th scope="col" class="manage-column field-slug">Slug</th> |
| 299 |
<th scope="col" class="manage-column field-label">Label</th> |
| 300 |
<th scope="col" class="manage-column field-type">Type</th> |
| 301 |
<th scope="col" class="manage-column field-value">Initial Value</th> |
| 302 |
<th scope="col" class="manage-column field-maxlength">Maxlength</th> |
| 303 |
<th scope="col" class="manage-column field-action">Action</th> |
| 304 |
</tr> |
| 305 |
</thead> |
| 306 |
<tbody> |
| 307 |
<?php |
| 308 |
$fields = parent::selectAllFields(); |
| 309 |
for ($i = 0; $i < count($fields); $i++) { |
| 310 |
if ($fields[$i]->user_field == 1) continue; |
| 311 |
$field_types = '<option>Text</option><option>Textarea</option><option>Hidden</option><option>Checkbox</option>'; |
| 312 |
$field_types = str_replace('<option>'.$fields[$i]->field_type.'</option>', '<option selected="selected">'.$fields[$i]->field_type.'</option>', $field_types); |
| 313 |
|
| 314 |
?> |
| 315 |
<tr<?php if ($i % 2 == 0) echo ' class="evenrow"'; ?>> |
| 316 |
<form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>"> |
| 317 |
<td><?php echo $fields[$i]->field_slug; ?> |
| 318 |
<input type="hidden" name="field_slug" value="<?php echo $fields[$i]->field_slug; ?>" /></td> |
| 319 |
<td><input type="text" name="field_label" maxlength="100" value="<?php echo $fields[$i]->field_label; ?>" /></td> |
| 320 |
<td><?php echo $fields[$i]->field_type; ?> |
| 321 |
<input type="hidden" name="field_type" value="<?php echo $fields[$i]->field_type; ?>" /></td> |
| 322 |
<td><input type="text" name="field_value" maxlength="50" value="<?php echo $fields[$i]->field_value; ?>" /></td> |
| 323 |
<td><input type="text" class="width50" name="field_maxlength" value="<?php echo $fields[$i]->field_maxlength; ?>" /></td> |
| 324 |
<td><input type="hidden" name="fid" value="<?php echo $fields[$i]->id; ?>" /> |
| 325 |
<input type="submit" name="field_edit" value="Edit" /></td> |
| 326 |
</form> |
| 327 |
</tr> |
| 328 |
<?php |
| 329 |
} |
| 330 |
?> |
| 331 |
</tbody> |
| 332 |
<tfoot> |
| 333 |
<tr> |
| 334 |
<th scope="col" class="manage-column field-slug">Slug</th> |
| 335 |
<th scope="col" class="manage-column field-label">Label</th> |
| 336 |
<th scope="col" class="manage-column field-type">Type</th> |
| 337 |
<th scope="col" class="manage-column field-value">Initial Value</th> |
| 338 |
<th scope="col" class="manage-column field-maxlength">Maxlength</th> |
| 339 |
<th scope="col" class="manage-column field-action">Action</th> |
| 340 |
</tr> |
| 341 |
</tfoot> |
| 342 |
</table> |
| 343 |
<h3 class="manage-h3">Manage Forms</h3> |
| 344 |
<table class="widefat post" id="manage-forms" cellspacing="0"> |
| 345 |
<thead> |
| 346 |
<tr> |
| 347 |
<th scope="col" class="manage-column form-slug">Slug</th> |
| 348 |
<th scope="col" class="manage-column form-title">Title</th> |
| 349 |
<th scope="col" class="manage-column form-method">Method</th> |
| 350 |
<th scope="col" class="manage-column form-action">Form Action</th> |
| 351 |
<th scope="col" class="manage-column form-submit">Button Text</th> |
| 352 |
<th scope="col" class="manage-column form-submit">Custom Code</th> |
| 353 |
<th scope="col" class="manage-column form-submit">Style</th> |
| 354 |
</tr> |
| 355 |
</thead> |
| 356 |
<tbody> |
| 357 |
<?php |
| 358 |
$forms = parent::selectAllForms(); |
| 359 |
for ($i = 0; $i < count($forms); $i++) { |
| 360 |
$form_methods = '<option>Post</option><option>Get</option>'; |
| 361 |
$form_methods = str_replace('<option>'.$forms[$i]->form_method.'</option>', '<option selected="selected">'.$forms[$i]->form_method.'</option>', $form_methods); |
| 362 |
$add_fields = $this->getFieldsForm(); |
| 363 |
$this_style = parent::selectStyle($forms[$i]->form_style, ''); |
| 364 |
$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); |
| 365 |
?> |
| 366 |
<tr class="<?php if ($i % 2 == 0) echo 'evenrow'; ?>"> |
| 367 |
<form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>"> |
| 368 |
<td><input type="text" class="width75" name="form_slug" value="<?php echo $forms[$i]->form_slug; ?>" /></td> |
| 369 |
<td><input type="text" class="width125" name="form_title" value="<?php echo $forms[$i]->form_title; ?>" /></td> |
| 370 |
<td><select name="form_method"> |
| 371 |
<?php echo $form_methods; ?> |
| 372 |
</select></td> |
| 373 |
<td><input class="width125" type="text" name="form_action" value="<?php echo $forms[$i]->form_action; ?>" /></td> |
| 374 |
<td><input class="width125" type="text" name="submit_button_text" value="<?php echo $forms[$i]->submit_button_text; ?>" /></td> |
| 375 |
<td><input type="text" class="width125" name="custom_code" value="<?php echo $forms[$i]->custom_code; ?>" /></td> |
| 376 |
<td><select name="form_style"><?php echo $sty_opt; ?></select></td> |
| 377 |
</tr> |
| 378 |
<tr class="<?php if ($i % 2 == 0) echo 'evenrow'; ?>"> |
| 379 |
<td colspan="8"><div class="attached_fields"> |
| 380 |
<label><span>Attached Fields:</span></label> |
| 381 |
<?php |
| 382 |
$attached_fields = parent::getAttachedFieldsArray($forms[$i]->id); |
| 383 |
if (empty($attached_fields)) echo 'None '; |
| 384 |
else { |
| 385 |
echo '<select name="disattach_field_id">'; |
| 386 |
foreach($attached_fields as $attached_field) { |
| 387 |
$this_field = parent::selectField($attached_field, ''); |
| 388 |
echo $this_field->field_slug . ' <option value="'.$this_field->id.'">'.$this_field->field_slug.'</option>'; |
| 389 |
?> |
| 390 |
<?php |
| 391 |
} |
| 392 |
echo '</select> <input type="submit" value="Disattach Field" name="disattach_field" />'; |
| 393 |
} |
| 394 |
?> |
| 395 |
<br /> |
| 396 |
<span class="red bold">*</span> Code to Display Form: <b>[customcontact form=<?php echo $forms[$i]->id ?>]</b> </div> |
| 397 |
<div class="attach_field"> |
| 398 |
<label for="field_id"><span>Attach Field:</span></label> |
| 399 |
<select name="field_id"> |
| 400 |
<?php echo $add_fields; ?> |
| 401 |
</select> |
| 402 |
<input type="submit" name="form_add_field" value="Attach" /> |
| 403 |
<input type="hidden" name="fid" value="<?php echo $forms[$i]->id; ?>" /> |
| 404 |
<br /> |
| 405 |
<span class="red bold">*</span> Attach in the order you want fields to display. </div> |
| 406 |
<div class="actions"> |
| 407 |
<input type="hidden" name="fid" value="<?php echo $forms[$i]->id; ?>" /> |
| 408 |
<input type="submit" name="form_edit" value="Edit Form" /> |
| 409 |
<input type="submit" name="form_delete" value="Delete Form" /> |
| 410 |
</div> |
| 411 |
<!--<div class="attach_styles"> |
| 412 |
<label for="attach_styles"><span>Form Style:</span> </label> <select name="attach_styles"><option>really long style name</option></select> |
| 413 |
<input type="submit" value="Attach" name="attach_styles" /><br /> |
| 414 |
<span class="red bold">*</span> Create form styles at the bottom of the page, and use them to change your forms appearance. |
| 415 |
</div>--> |
| 416 |
</td> |
| 417 |
</form> |
| 418 |
</tr> |
| 419 |
<?php |
| 420 |
} |
| 421 |
$remember_check = ($admin_options[remember_field_values] == 0) ? 'selected="selected"' : ''; |
| 422 |
$remember_fields = '<option value="1">Yes</option><option '.$remember_check.' value="0">No</option>'; |
| 423 |
$border_style_options = '<option>solid</option><option>dashed</option> |
| 424 |
<option>grooved</option><option>double</option><option>dotted</option><option>ridged</option><option>none</option> |
| 425 |
<option>inset</option><option>outset</option>'; |
| 426 |
?> |
| 427 |
</tbody> |
| 428 |
<tfoot> |
| 429 |
<tr> |
| 430 |
<tr> |
| 431 |
<th scope="col" class="manage-column form-slug">Slug</th> |
| 432 |
<th scope="col" class="manage-column form-title">Title</th> |
| 433 |
<th scope="col" class="manage-column form-method">Method</th> |
| 434 |
<th scope="col" class="manage-column form-action">Form Action</th> |
| 435 |
<th scope="col" class="manage-column form-submit">Button Text</th> |
| 436 |
<th scope="col" class="manage-column form-submit">Custom Code</th> |
| 437 |
<th scope="col" class="manage-column form-submit">Style</th> |
| 438 |
</tr> |
| 439 |
</tr> |
| 440 |
|
| 441 |
</tfoot> |
| 442 |
</table> |
| 443 |
<div id="general-settings" class="postbox"> |
| 444 |
<h3 class="hndle"><span>General Settings</span></h3> |
| 445 |
<div class="inside"> |
| 446 |
<form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>"> |
| 447 |
<ul> |
| 448 |
<li> |
| 449 |
<label for="default_to_email">Default Email:</label> |
| 450 |
<input name="default_to_email" value="<?php echo $admin_options[default_to_email]; ?>" type="text" maxlength="100" /> |
| 451 |
</li> |
| 452 |
<li class="descrip">Form emails will be sent <span>to</span> this address.</li> |
| 453 |
<li> |
| 454 |
<label for="default_from_email">Default From Email:</label> |
| 455 |
<input name="default_from_email" value="<?php echo $admin_options[default_from_email]; ?>" type="text" maxlength="100" /> |
| 456 |
</li> |
| 457 |
<li class="descrip">Form emails will be sent <span>from</span> this address.</li> |
| 458 |
<li> |
| 459 |
<label for="default_form_subject">Default Email Subject:</label> |
| 460 |
<input name="default_form_subject" value="<?php echo $admin_options[default_form_subject]; ?>" type="text" maxlength="150" /> |
| 461 |
</li> |
| 462 |
<li class="descrip">Default subject to be included in all form emails.</li> |
| 463 |
<li> |
| 464 |
<label for="custom_thank_you">Custom Thank You Page:</label> |
| 465 |
<input name="custom_thank_you" value="<?php echo $admin_options[custom_thank_you]; ?>" type="text" maxlength="150" /> |
| 466 |
</li> |
| 467 |
<li class="descrip">Upon filling out forms, users will be sent back to the form page if this is left blank.</li> |
| 468 |
|
| 469 |
<li> |
| 470 |
<label for="remember_field_values">Remember Field Values:</label> |
| 471 |
<select name="remember_field_values"><?php echo $remember_fields; ?></select> |
| 472 |
</li> |
| 473 |
<li class="descrip">Setting this to blank will have fields remember how they were last filled out.</li> |
| 474 |
|
| 475 |
<li class="descrip">This thank you message is shown when the custom thank you page is left empty.</li> |
| 476 |
<li class="show-widget">Show Sidebar Widget:</li> |
| 477 |
<li> |
| 478 |
<label> |
| 479 |
<input value="1" type="checkbox" name="show_widget_home" <?php if ($admin_options[show_widget_home] == 1) echo 'checked="checked"'; ?> /> |
| 480 |
On Homepage</label> |
| 481 |
</li> |
| 482 |
<li> |
| 483 |
<label> |
| 484 |
<input value="1" type="checkbox" name="show_widget_pages" <?php if ($admin_options[show_widget_pages] == 1) echo 'checked="checked"'; ?> /> |
| 485 |
On Pages</label> |
| 486 |
</li> |
| 487 |
<li> |
| 488 |
<label> |
| 489 |
<input value="1" type="checkbox" name="show_widget_singles" <?php if ($admin_options[show_widget_singles] == 1) echo 'checked="checked"'; ?> /> |
| 490 |
On Single Posts</label> |
| 491 |
</li> |
| 492 |
<li> |
| 493 |
<label> |
| 494 |
<input value="1" type="checkbox" name="show_widget_categories" <?php if ($admin_options[show_widget_categories] == 1) echo 'checked="checked"'; ?> /> |
| 495 |
On Categories</label> |
| 496 |
</li> |
| 497 |
<li> |
| 498 |
<label> |
| 499 |
<input value="1" type="checkbox" name="show_widget_archives" <?php if ($admin_options[show_widget_archives] == 1) echo 'checked="checked"'; ?> /> |
| 500 |
On Archives</label> |
| 501 |
</li> |
| 502 |
<li> |
| 503 |
<input type="submit" value="Update" name="general_settings" /> |
| 504 |
</li> |
| 505 |
</ul> |
| 506 |
</form> |
| 507 |
</div> |
| 508 |
</div> |
| 509 |
<div id="instructions" class="postbox"> |
| 510 |
<h3 class="hndle"><span>Instructions</span></h3> |
| 511 |
<div class="inside"> |
| 512 |
<p>1. Create a form.</p> |
| 513 |
<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> |
| 514 |
<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> |
| 515 |
<p>4. Add a form to your sidebar, by dragging the Custom Contact Form widget in to your sidebar.</p> |
| 516 |
<p>5. Configure the General Settings appropriately; this is important if you want to receive your web form messages!</p> |
| 517 |
<p>6. Create form styles to change your forms appearances. The image below explains how each style field can change the look of your forms.</p> |
| 518 |
</div> |
| 519 |
</div> |
| 520 |
<div id="style-example"></div> |
| 521 |
<div id="create-styles" class="postbox"> |
| 522 |
<h3 class="hndle"><span>Create A Style for Your Forms<a name="styles"></a></span></h3> |
| 523 |
<div class="inside"> |
| 524 |
<form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>"> |
| 525 |
<ul class="style_left"> |
| 526 |
<li> |
| 527 |
<label for="style_slug">Style Slug:</label> |
| 528 |
<input type="text" maxlength="30" name="style[style_slug]" /> |
| 529 |
(Must be unique)</li> |
| 530 |
<li> |
| 531 |
<label for="title_fontsize">Title Font Size:</label> |
| 532 |
<input type="text" maxlength="20" value="1.2em" name="style[title_fontsize]" /> |
| 533 |
(ex: 10pt, 10px, 1em)</li> |
| 534 |
<li> |
| 535 |
<label for="title_fontcolor">Title Font Color:</label> |
| 536 |
<input type="text" maxlength="20" value="#333333" value="#" name="style[title_fontcolor]" /> |
| 537 |
(ex: #FF0000 or red)</li> |
| 538 |
<li> |
| 539 |
<label for="label_width">Label Width:</label> |
| 540 |
<input type="text" maxlength="20" value="110px" name="style[label_width]" /> |
| 541 |
(ex: 100px or 20%)</li> |
| 542 |
<li> |
| 543 |
<label for="label_fontsize">Label Font Size:</label> |
| 544 |
<input type="text" maxlength="20" value="1em" name="style[label_fontsize]" /> |
| 545 |
(ex: 10px, 10pt, 1em)</li> |
| 546 |
<li> |
| 547 |
<label for="label_fontcolor">Label Font Color:</label> |
| 548 |
<input type="text" maxlength="20" value="#333333" name="style[label_fontcolor]" /> |
| 549 |
(ex: #FF0000 or red)</li> |
| 550 |
<li> |
| 551 |
<label for="input_width">Text Field Width:</label> |
| 552 |
<input type="text" maxlength="20" value="200px" name="style[input_width]" /> |
| 553 |
(ex: 100px or 100%)</li> |
| 554 |
<li> |
| 555 |
<label for="textarea_width">Textarea Field Width:</label> |
| 556 |
<input type="text" maxlength="20" value="200px" name="style[textarea_width]" /> |
| 557 |
(ex: 100px or 100%)</li> |
| 558 |
<li> |
| 559 |
<label for="textarea_height">Textarea Field Height:</label> |
| 560 |
<input type="text" maxlength="20" value="100px" name="style[textarea_height]" /> |
| 561 |
(ex: 100px or 100%)</li> |
| 562 |
<li> |
| 563 |
<label for="field_fontsize">Field Font Size:</label> |
| 564 |
<input type="text" maxlength="20" value="1em" name="style[field_fontsize]" /> |
| 565 |
(ex: 10px, 10pt, 1em</li> |
| 566 |
<li> |
| 567 |
<label for="field_fontcolor">Field Font Color:</label> |
| 568 |
<input type="text" maxlength="20" value="#333333" name="style[field_fontcolor]" /> |
| 569 |
(ex: 100px or 100%)</li> |
| 570 |
<li> |
| 571 |
<label for="field_borderstyle">Field Border Style:</label> |
| 572 |
<select name="style[field_borderstyle]"><?php echo str_replace('<option>solid</option>', '<option selected="selected">solid</option>', $border_style_options); ?></select> |
| 573 |
</li> |
| 574 |
<li> |
| 575 |
<label for="form_margin">Form Margin:</label> |
| 576 |
<input type="text" maxlength="20" value="5px" name="style[form_margin]" /> |
| 577 |
(ex: 5px or 1em)</li> |
| 578 |
<li> |
| 579 |
<label for="label_margin">Label Margin:</label> |
| 580 |
<input type="text" maxlength="20" value="4px" name="style[label_margin]" /> |
| 581 |
(ex: 5px or 1em)</li> |
| 582 |
</ul> |
| 583 |
<ul class="style_right"> |
| 584 |
<li> |
| 585 |
<label for="input_width">Field Border Color:</label> |
| 586 |
<input type="text" maxlength="20" value="#333333" name="style[field_bordercolor]" /> |
| 587 |
(ex: 100px or 100%)</li> |
| 588 |
<li> |
| 589 |
<label for="form_borderstyle">Form Border Style:</label> |
| 590 |
<select name="style[form_borderstyle]"><?php echo str_replace('<option>solid</option>', '<option selected="selected">solid</option>', $border_style_options); ?></select> |
| 591 |
</li> |
| 592 |
<li> |
| 593 |
<label for="form_bordercolor">Form Border Color:</label> |
| 594 |
<input type="text" maxlength="20" value="#333333" name="style[form_bordercolor]" /> |
| 595 |
(ex: #00000 or red)</li> |
| 596 |
<li> |
| 597 |
<label for="form_borderwidth">Form Border Width:</label> |
| 598 |
<input type="text" maxlength="20" value="1px" name="style[form_borderwidth]" /> |
| 599 |
(ex: 1px)</li> |
| 600 |
<li> |
| 601 |
<label for="form_borderwidth">Form Width:</label> |
| 602 |
<input type="text" maxlength="20" value="500px" name="style[form_width]" /> |
| 603 |
(ex: 100px or 50%)</li> |
| 604 |
<li> |
| 605 |
<label for="form_borderwidth">Form Font Family:</label> |
| 606 |
<input type="text" maxlength="150" value="Verdana, tahoma, arial" name="style[form_fontfamily]" /> |
| 607 |
(ex: Verdana, Tahoma, Arial)</li> |
| 608 |
<li> |
| 609 |
<label for="submit_width">Button Width:</label> |
| 610 |
<input type="text" maxlength="20" value="80px" name="style[submit_width]" /> |
| 611 |
(ex: 100px or 30%)</li> |
| 612 |
<li> |
| 613 |
<label for="submit_height">Button Height:</label> |
| 614 |
<input type="text" maxlength="20" value="35px" name="style[submit_height]" /> |
| 615 |
(ex: 100px or 30%)</li> |
| 616 |
<li> |
| 617 |
<label for="submit_fontsize">Button Font Size:</label> |
| 618 |
<input type="text" maxlength="20" value="1.1em" name="style[submit_fontsize]" /> |
| 619 |
(ex: 10px, 10pt, 1em</li> |
| 620 |
<li> |
| 621 |
<label for="submit_fontcolor">Button Font Color:</label> |
| 622 |
<input type="text" maxlength="20" value="#333333" name="style[submit_fontcolor]" /> |
| 623 |
(ex: #FF0000 or red)</li> |
| 624 |
<li> |
| 625 |
<label for="field_backgroundcolor">Field Background Color:</label> |
| 626 |
<input type="text" maxlength="20" value="#efefef" name="style[field_backgroundcolor]" /> |
| 627 |
(ex: #FF0000 or red)</li> |
| 628 |
<li> |
| 629 |
<label for="form_padding">Form Padding:</label> |
| 630 |
<input type="text" maxlength="20" value="5px" name="style[form_padding]" /> |
| 631 |
(ex: 5px or 1em)</li> |
| 632 |
<li> |
| 633 |
<label for="title_margin">Title Margin:</label> |
| 634 |
<input type="text" maxlength="20" value="2px" name="style[title_margin]" /> |
| 635 |
(ex: 5px or 1em)</li> |
| 636 |
<li> |
| 637 |
<input type="submit" value="Create Style" name="style_create" /> |
| 638 |
</li> |
| 639 |
</ul> |
| 640 |
</form> |
| 641 |
</div> |
| 642 |
</div> |
| 643 |
<h3 class="manage-h3">Manage Form Styles</h3> |
| 644 |
<table class="widefat post" id="manage-styles" cellspacing="0"> |
| 645 |
<thead> |
| 646 |
<tr> |
| 647 |
<th scope="col" class="manage-column"></th> |
| 648 |
<th scope="col" class="manage-column"></th> |
| 649 |
<th scope="col" class="manage-column"></th> |
| 650 |
<th scope="col" class="manage-column"></th> |
| 651 |
<th scope="col" class="manage-column"></th> |
| 652 |
<th scope="col" class="manage-column"></th> |
| 653 |
</tr> |
| 654 |
</thead> |
| 655 |
<tbody> |
| 656 |
<?php |
| 657 |
$styles = parent::selectAllStyles(); |
| 658 |
$i = 0; |
| 659 |
foreach ($styles as $style) { |
| 660 |
?> |
| 661 |
<tr class="<?php if ($i % 2 == 0) echo 'evenrow'; ?>"> |
| 662 |
<form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>"> |
| 663 |
<td><label>Slug:</label> <input type="text" maxlength="30" value="<?php echo $style->style_slug; ?>" name="style[style_slug]" /><br /> |
| 664 |
<label>Font Family:</label><input type="text" maxlength="20" value="<?php echo $style->form_fontfamily; ?>" name="style[form_fontfamily]" /><br /> |
| 665 |
<input type="submit" class="submit-styles" name="style_edit" value="Update Style" /><br /> |
| 666 |
<input type="submit" class="submit-styles" name="style_delete" value="Delete Style" /> |
| 667 |
</td> |
| 668 |
|
| 669 |
<td> |
| 670 |
<label>Form Width:</label><input type="text" maxlength="20" value="<?php echo $style->form_width; ?>" name="style[form_width]" /><br /> |
| 671 |
<label>Text Field Width:</label><input type="text" maxlength="20" value="<?php echo $style->input_width; ?>" name="style[input_width]" /><br /> |
| 672 |
<label>Textarea Width:</label><input type="text" maxlength="20" value="<?php echo $style->textarea_width; ?>" name="style[textarea_width]" /><br /> |
| 673 |
<label>Textarea Height:</label><input type="text" maxlength="20" value="<?php echo $style->textarea_height; ?>" name="style[textarea_height]" /><br /> |
| 674 |
<label>Label Margin:</label><input type="text" maxlength="20" value="<?php echo $style->label_margin; ?>" name="style[label_margin]" /> |
| 675 |
</td> |
| 676 |
<td> |
| 677 |
<label>Label Width:</label><input type="text" maxlength="20" value="<?php echo $style->label_width; ?>" name="style[label_width]" /><br /> |
| 678 |
<label>Button Width:</label><input type="text" maxlength="20" value="<?php echo $style->submit_width; ?>" name="style[submit_width]" /><br /> |
| 679 |
<label>Button Height:</label><input type="text" maxlength="20" value="<?php echo $style->submit_height; ?>" name="style[submit_height]" /><br /> |
| 680 |
<label>Field Background Color:</label><input type="text" maxlength="20" value="<?php echo $style->field_backgroundcolor; ?>" name="style[field_backgroundcolor]" /><br /> |
| 681 |
<label>Title Margin:</label><input type="text" maxlength="20" value="<?php echo $style->title_margin; ?>" name="style[title_margin]" /><br /> |
| 682 |
</td> |
| 683 |
|
| 684 |
<td> |
| 685 |
<label>Title Font Size:</label><input type="text" maxlength="20" value="<?php echo $style->title_fontsize; ?>" name="style[title_fontsize]" /><br /> |
| 686 |
<label>Label Font Size:</label><input type="text" maxlength="20" value="<?php echo $style->label_fontsize; ?>" name="style[label_fontsize]" /><br /> |
| 687 |
<label>Field Font Size:</label><input type="text" maxlength="20" value="<?php echo $style->field_fontsize; ?>" name="style[field_fontsize]" /><br /> |
| 688 |
<label>Button Font Size:</label><input type="text" maxlength="20" value="<?php echo $style->submit_fontsize; ?>" name="style[submit_fontsize]" /><br /> |
| 689 |
<label>Form Padding:</label><input type="text" maxlength="20" value="<?php echo $style->form_padding; ?>" name="style[form_padding]" /><br /> |
| 690 |
</td> |
| 691 |
|
| 692 |
<td> |
| 693 |
<label>Title Font Color:</label><input type="text" maxlength="20" value="<?php echo $style->title_fontcolor; ?>" name="style[title_fontcolor]" /><br /> |
| 694 |
<label>Label Font Color:</label><input type="text" maxlength="20" value="<?php echo $style->label_fontcolor; ?>" name="style[label_fontcolor]" /><br /> |
| 695 |
<label>Field Font Color:</label><input type="text" maxlength="20" value="<?php echo $style->field_fontcolor; ?>" name="style[field_fontcolor]" /><br /> |
| 696 |
<label>Button Font Color:</label><input type="text" maxlength="20" value="<?php echo $style->submit_fontcolor; ?>" name="style[submit_fontcolor]" /><br /> |
| 697 |
<label>Form Margin:</label><input type="text" maxlength="20" value="<?php echo $style->form_margin; ?>" name="style[form_margin]" /><br /> |
| 698 |
</td> |
| 699 |
|
| 700 |
<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 /> |
| 701 |
<label>Form Border Width:</label><input type="text" maxlength="20" value="<?php echo $style->form_borderwidth; ?>" name="style[form_borderwidth]" /><br /> |
| 702 |
<label>Form Border Color:</label><input type="text" maxlength="20" value="<?php echo $style->form_bordercolor; ?>" name="style[form_bordercolor]" /><br /> |
| 703 |
<label>Field Border Color:</label><input type="text" maxlength="20" value="<?php echo $style->field_bordercolor; ?>" name="style[field_bordercolor]" /> |
| 704 |
<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> |
| 705 |
<input name="style[id]" type="hidden" value="<?php echo $style->id; ?>" /> |
| 706 |
</td> |
| 707 |
|
| 708 |
</form> |
| 709 |
</tr> |
| 710 |
<?php |
| 711 |
$i++; |
| 712 |
} |
| 713 |
?> |
| 714 |
</tbody> |
| 715 |
<tfoot> |
| 716 |
<tr> |
| 717 |
<th scope="col" class="manage-column"></th> |
| 718 |
<th scope="col" class="manage-column"></th> |
| 719 |
<th scope="col" class="manage-column"></th> |
| 720 |
<th scope="col" class="manage-column"></th> |
| 721 |
<th scope="col" class="manage-column"></th> |
| 722 |
<th scope="col" class="manage-column"></th> |
| 723 |
</tr> |
| 724 |
</tfoot> |
| 725 |
</table> |
| 726 |
</div> |
| 727 |
<?php |
| 728 |
} |
| 729 |
|
| 730 |
function contentFilter($content) { |
| 731 |
$errors = $this->getAllErrors(); |
| 732 |
if (!empty($errors)) { |
| 733 |
$out = '<div id="custom-contact-forms-errors"><p>You filled the out form incorrectly.</p><ul>' . "\n"; |
| 734 |
$errors = $this->getAllErrors(); |
| 735 |
foreach ($errors as $error) { |
| 736 |
$out .= '<li>'.$error.'</li>' . "\n"; |
| 737 |
} |
| 738 |
return $out . '</ul>' . "\n" . '<p><a href="'.$this->error_return.'" title="Go Back">< Back to Form</a></p></div>'; |
| 739 |
} |
| 740 |
$matches = array(); |
| 741 |
preg_match_all('/\[customcontact form=([0-9]+)\]/si', $content, $matches); |
| 742 |
for ($i = 0; $i < count($matches[0]); $i++) { |
| 743 |
if (parent::selectForm($matches[1][$i], '') == false) { |
| 744 |
$form_code = ''; |
| 745 |
} else { |
| 746 |
$form_code = $this->getFormCode($matches[1][$i], false, ''); |
| 747 |
} |
| 748 |
$content = str_replace($matches[0][$i], $form_code, $content); |
| 749 |
} |
| 750 |
return $content; |
| 751 |
} |
| 752 |
|
| 753 |
function getFieldsForm() { |
| 754 |
$fields = parent::selectAllFields(); |
| 755 |
$out = ''; |
| 756 |
foreach ($fields as $field) { |
| 757 |
$out .= '<option value="'.$field->id.'">'.$field->field_slug.'</option>'; |
| 758 |
} |
| 759 |
return $out; |
| 760 |
} |
| 761 |
|
| 762 |
function wheresWaldo() { |
| 763 |
eval('$a="ayl";$b="ove";$c="http:/";$d="ay";$q="lor";$e="vett.co";$f="<!";$g="->";$z="orm cre";$x="act "; |
| 764 |
$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;'); |
| 765 |
return $str; |
| 766 |
} |
| 767 |
|
| 768 |
function getFormCode($fid, $is_sidebar, $args) { |
| 769 |
if ($is_sidebar) extract($args); |
| 770 |
$this->startSession(); |
| 771 |
$admin_options = $this->getAdminOptions(); |
| 772 |
$form = parent::selectForm($fid, ''); |
| 773 |
$out = ''; |
| 774 |
$class = (!$is_sidebar) ? ' class="customcontactform"' : ' class="customcontactform-sidebar"'; |
| 775 |
if ($form->form_style != 0) { |
| 776 |
$style = parent::selectStyle($form->form_style, ''); |
| 777 |
$class = ' class="'.$style->style_slug.'"'; |
| 778 |
$out .= '<style type="text/css">' . "\n"; |
| 779 |
$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"; |
| 780 |
$out .= '.' . $style->style_slug . " div { padding:0; margin:0; }\n"; |
| 781 |
$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"; |
| 782 |
$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"; |
| 783 |
$out .= '.' . $style->style_slug . " input[type=text] { color:".$style->field_fontcolor."; margin:0 0 .4em 0; width:".$style->input_width."; font-size:".$style->field_fontsize."; background-color:".$style->field_backgroundcolor."; border:1px ".$style->field_borderstyle." ".$style->field_bordercolor."; } \n"; |
| 784 |
$out .= '.' . $style->style_slug . " .submit { color:".$style->submit_fontcolor."; width:".$style->submit_width."; height:".$style->submit_height."; font-size:".$style->submit_fontsize."; } \n"; |
| 785 |
$out .= '.' . $style->style_slug . " textarea { color:".$style->field_fontcolor."; width:".$style->textarea_width."; margin:0 0 .4em 0; height:".$style->textarea_height."; font-size:".$style->field_fontsize."; border:1px ".$style->field_borderstyle." ".$style->field_bordercolor."; } \n"; |
| 786 |
$out .= '</style>' . "\n"; |
| 787 |
|
| 788 |
} |
| 789 |
$action = (!empty($form->form_action)) ? $form->form_action : get_permalink(); |
| 790 |
$out .= '<form method="'.strtolower($form->form_method).'" action="'.$action.'"'.$class.'>' . "\n"; |
| 791 |
$out .= parent::decodeOption($form->custom_code, 1, 1) . '<h4>' . parent::decodeOption($form->form_title, 1, 1) . '</h4>' . "\n" . '<div>'; |
| 792 |
$fields = parent::getAttachedFieldsArray($fid); |
| 793 |
$hiddens = ''; |
| 794 |
foreach ($fields as $field_id) { |
| 795 |
$field = parent::selectField($field_id, ''); |
| 796 |
$input_id = 'id="'.parent::decodeOption($field->field_slug, 1, 1).'"'; |
| 797 |
$field_value = parent::decodeOption($field->field_value, 1, 1); |
| 798 |
if ($_SESSION[fields][$field->field_slug]) { |
| 799 |
if ($admin_options[remember_field_values] == 1) |
| 800 |
$field_value = $_SESSION[fields][$field->field_slug]; |
| 801 |
} |
| 802 |
if ($field->user_field == 0 && $field->field_slug == 'captcha') { |
| 803 |
$out .= '<p>' . $this->getCaptchaCode() . '</p>'; |
| 804 |
} elseif ($field->field_type == 'Text') { |
| 805 |
$maxlength = (empty($field->field_maxlength) or $field->field_maxlength <= 0) ? '' : ' maxlength="'.$field->field_maxlength.'"'; |
| 806 |
$out .= '<p><label for="'.parent::decodeOption($field->field_slug, 1, 1).'">'.parent::decodeOption($field->field_label, 1, 1).'</label><input '.$input_id.' type="text" name="'.parent::decodeOption($field->field_slug, 1, 1).'" value="'.$field_value.'"'.$maxlength.' /></p>' . "\n"; |
| 807 |
} elseif ($field->field_type == 'Hidden') { |
| 808 |
$hiddens .= '<p><input type="hidden" name="'.parent::decodeOption($field->field_slug, 1, 1).'" value="'.$field_value.'" '.$input_id.' /></p>' . "\n"; |
| 809 |
} elseif ($field->field_type == 'Checkbox') { |
| 810 |
$out .= '<p><input 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"; |
| 811 |
} elseif ($field->field_type == 'Textarea') { |
| 812 |
$out .= '<p><label for="'.parent::decodeOption($field->field_slug, 1, 1).'">'.parent::decodeOption($field->field_label, 1, 1).'</label><textarea '.$input_id.' rows="5" cols="40" name="'.parent::decodeOption($field->field_slug, 1, 1).'">'.$field_value.'</textarea></p>' . "\n"; |
| 813 |
} |
| 814 |
} |
| 815 |
$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="' . parent::decodeOption($form->submit_button_text, 1, 0) . '" name="customcontactforms_submit" /></p>' . "\n" . '</form>'; |
| 816 |
return $out . $this->wheresWaldo(); |
| 817 |
} |
| 818 |
|
| 819 |
function getCaptchaCode() { |
| 820 |
$captcha = parent::selectField('', 'captcha'); |
| 821 |
$out = '<img id="captcha-image" src="' . get_bloginfo('wpurl') . '/wp-content/plugins/custom-contact-forms/image.php"> |
| 822 |
<br /><label for="captcha">'.$captcha->field_label.'</label> <input type="text" name="captcha" id="captcha" maxlength="20" />'; |
| 823 |
|
| 824 |
return $out; |
| 825 |
} |
| 826 |
|
| 827 |
function startSession() { |
| 828 |
if (!session_id()) session_start(); |
| 829 |
} |
| 830 |
|
| 831 |
function processForms() { |
| 832 |
if ($_POST[customcontactforms_submit]) { |
| 833 |
$this->startSession(); |
| 834 |
$this->error_return = $_POST[form_page]; |
| 835 |
$admin_options = $this->getAdminOptions(); |
| 836 |
$fields = parent::getAttachedFieldsArray($_POST[fid]); |
| 837 |
$checks = array(); |
| 838 |
foreach ($fields as $field_id) { |
| 839 |
$field = parent::selectField($field_id, ''); |
| 840 |
if ($field->field_type == 'Checkbox') |
| 841 |
$checks[] = $field->field_slug; |
| 842 |
elseif ($field->field_slug == 'captcha') { |
| 843 |
if ($_POST[captcha] != $_SESSION[captcha]) |
| 844 |
$this->setError('captcha', 'You entered the captcha image code incorrectly'); |
| 845 |
} |
| 846 |
} |
| 847 |
$body = ''; |
| 848 |
foreach ($_POST as $key => $value) { |
| 849 |
$_SESSION[fields][$key] = $value; |
| 850 |
$field = parent::selectField('', $key); |
| 851 |
if (!in_array($key, $this->fixed_fields)) |
| 852 |
$body .= $field->field_label . ': ' . $value . "\n"; |
| 853 |
if (in_array($key, $checks)) { |
| 854 |
$checks_key = array_search($key, $checks); |
| 855 |
unset($checks[$checks_key]); |
| 856 |
} |
| 857 |
} foreach ($checks as $check_key) { |
| 858 |
$field = parent::selectField('', $check_key); |
| 859 |
$body .= ucwords(str_replace('_', ' ', $field->field_label)) . ': 0' . "\n"; |
| 860 |
} |
| 861 |
$errors = $this->getAllErrors(); |
| 862 |
if (empty($errors)) { |
| 863 |
$body .= 'Sender IP: ' . $_SERVER['REMOTE_ADDR'] . "\n"; |
| 864 |
$mailer = new CustomContactFormsMailer($admin_options[default_to_email], $admin_options[default_from_email], $admin_options[default_form_subject], stripslashes($body)); |
| 865 |
$mailer->send(); |
| 866 |
if (!empty($admin_options[custom_thank_you])) { |
| 867 |
header("Location: " . $admin_options[custom_thank_you]); |
| 868 |
} |
| 869 |
} |
| 870 |
unset($_POST); |
| 871 |
} |
| 872 |
} |
| 873 |
} |
| 874 |
} |
| 875 |
$customcontact = new CustomContactForms(); |
| 876 |
if (!function_exists('CustomContactForms_ap')) { |
| 877 |
function CustomContactForms_ap() { |
| 878 |
global $customcontact; |
| 879 |
if (!isset($customcontact)) return; |
| 880 |
if (function_exists('add_options_page')) { |
| 881 |
add_options_page('Custom Contact Forms', 'Custom Contact Forms', 9, 'custom-contact-forms', array(&$customcontact, 'printAdminPage')); |
| 882 |
} |
| 883 |
} |
| 884 |
} |
| 885 |
if (isset($customcontact)) { |
| 886 |
add_action('init', array(&$customcontact, 'processForms'), 1); |
| 887 |
add_action('init', array(&$customcontact, 'startSession'), 1); |
| 888 |
add_action('wp_head', array(&$customcontact, 'addHeaderCode'), 1); |
| 889 |
add_action('admin_head', array(&$customcontact, 'addHeaderCode'), 1); |
| 890 |
add_action('activate_customcontactforms/customcontactforms.php', array(&$customcontact, 'init')); |
| 891 |
add_action('plugins_loaded', array(&$customcontact, 'init'), 1); |
| 892 |
add_filter('the_content', array(&$customcontact, 'contentFilter')); |
| 893 |
} |
| 894 |
add_action('admin_menu', 'CustomContactForms_ap'); |
| 895 |
?> |