PluginProbe
Custom Contact Forms / 2.1.0
Custom Contact Forms v2.1.0
7.16.1 7.16 7.15.2 7.15.0 7.14.0 7.13.0 7.11.0 trunk 1.0.0 1.0.1 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.2.1 2.0.1 2.0.2 2.0.3 2.1.0 2.2.0 2.2.3 2.2.4 2.2.5 3.0.0 All 171 releases
custom-contact-forms / custom-contact-forms.php

custom-contact-forms.php in Custom Contact Forms 2.1.0, at custom-contact-forms.php

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