PluginProbe
Custom Contact Forms / 2.2.0
Custom Contact Forms v2.2.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.2.0, at custom-contact-forms.php

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