PluginProbe
Custom Contact Forms / 2.2.5
Custom Contact Forms v2.2.5
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.5, at custom-contact-forms.php

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