Version Description
Required fields option will be added in mid-August 2010
Download this release
Release Info
Developer | tlovett1 |
Plugin | Custom Contact Forms |
Version | 1.1.0 |
Comparing to | |
See all releases |
Code changes from version 1.0.1 to 1.1.0
- custom-contact-forms-db.php +43 -15
- custom-contact-forms-images.php +23 -0
- custom-contact-forms-mailer.php +1 -1
- custom-contact-forms.css +25 -9
- custom-contact-forms.php +150 -40
- image.php +16 -0
- images/_notes/dwsync.xml +7 -0
- images/gd1.png +0 -0
- images/gd2.png +0 -0
- images/gd3.png +0 -0
- images/gd4.png +0 -0
- readme.txt +17 -4
custom-contact-forms-db.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
-
Custom Contact Forms
|
4 |
By Taylor Lovett - http://www.taylorlovett.com
|
5 |
Plugin URL: http://www.taylorlovett.com/wordpress-plugins
|
6 |
*/
|
@@ -14,6 +14,8 @@ if (!class_exists('CustomContactFormsDB')) {
|
|
14 |
$this->forms_table = $wpdb->prefix . 'customcontactforms_forms';
|
15 |
$this->fields_table = $wpdb->prefix . 'customcontactforms_fields';
|
16 |
$this->createTables();
|
|
|
|
|
17 |
}
|
18 |
|
19 |
function encodeOption($option) {
|
@@ -50,6 +52,7 @@ if (!class_exists('CustomContactFormsDB')) {
|
|
50 |
`field_type` VARCHAR( 25 ) NOT NULL ,
|
51 |
`field_value` TEXT NOT NULL ,
|
52 |
`field_maxlength` INT ( 5 ) NOT NULL DEFAULT '0',
|
|
|
53 |
PRIMARY KEY ( `id` )
|
54 |
) ENGINE = MYISAM AUTO_INCREMENT=1 ";
|
55 |
dbDelta($sql2);
|
@@ -57,25 +60,40 @@ if (!class_exists('CustomContactFormsDB')) {
|
|
57 |
return true;
|
58 |
}
|
59 |
|
60 |
-
function
|
61 |
global $wpdb;
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
}
|
67 |
-
return false;
|
68 |
}
|
69 |
|
70 |
-
function
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
global $wpdb;
|
72 |
-
$
|
|
|
73 |
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
}
|
80 |
|
81 |
function fieldsTableExists() {
|
@@ -177,6 +195,16 @@ if (!class_exists('CustomContactFormsDB')) {
|
|
177 |
$slug = preg_replace('/[^a-zA-Z0-9\s]/', '', $slug);
|
178 |
return str_replace(' ', '_', $slug);
|
179 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
180 |
}
|
181 |
}
|
182 |
?>
|
1 |
<?php
|
2 |
/*
|
3 |
+
Custom Contact Forms Plugin
|
4 |
By Taylor Lovett - http://www.taylorlovett.com
|
5 |
Plugin URL: http://www.taylorlovett.com/wordpress-plugins
|
6 |
*/
|
14 |
$this->forms_table = $wpdb->prefix . 'customcontactforms_forms';
|
15 |
$this->fields_table = $wpdb->prefix . 'customcontactforms_fields';
|
16 |
$this->createTables();
|
17 |
+
$this->insertFixedFields();
|
18 |
+
$this->updateTables();
|
19 |
}
|
20 |
|
21 |
function encodeOption($option) {
|
52 |
`field_type` VARCHAR( 25 ) NOT NULL ,
|
53 |
`field_value` TEXT NOT NULL ,
|
54 |
`field_maxlength` INT ( 5 ) NOT NULL DEFAULT '0',
|
55 |
+
`user_field` INT ( 1 ) NOT NULL DEFAULT '1',
|
56 |
PRIMARY KEY ( `id` )
|
57 |
) ENGINE = MYISAM AUTO_INCREMENT=1 ";
|
58 |
dbDelta($sql2);
|
60 |
return true;
|
61 |
}
|
62 |
|
63 |
+
function updateTables() {
|
64 |
global $wpdb;
|
65 |
+
if (!$this->columnExists('user_field', $this->fields_table))
|
66 |
+
$wpdb->query("ALTER TABLE `" . $this->fields_table . "` ADD `user_field` INT( 1 ) NOT NULL DEFAULT '1'");
|
67 |
+
|
68 |
+
$this->insertFixedFields();
|
|
|
|
|
69 |
}
|
70 |
|
71 |
+
function insertFixedFields() {
|
72 |
+
if (!$this->fieldSlugExists('captcha'))
|
73 |
+
$this->insertField('captcha', 'Type the text', 'Text', '', '100', 0);
|
74 |
+
|
75 |
+
}
|
76 |
+
|
77 |
+
function columnExists($column, $table) {
|
78 |
global $wpdb;
|
79 |
+
$tests = $wpdb->get_results("SELECT * FROM INFORMATION_SCHEMA.columns WHERE table_name = '$table' AND column_name = '$column' LIMIT 0 , 30");
|
80 |
+
//echo "SELECT * FROM INFORMATION_SCHEMA.columns WHERE table_name = '$table' AND column_name = '$column' LIMIT 0 , 30";
|
81 |
|
82 |
+
return (!empty($test[0]) && $test[0]->COLUMN_NAME == $column);
|
83 |
+
}
|
84 |
+
|
85 |
+
function insertForm($form_slug, $form_title, $form_action, $form_method, $submit_button_text, $custom_code) {
|
86 |
+
global $wpdb;
|
87 |
+
if ($this->formSlugExists($field_slug)) return false;
|
88 |
+
$wpdb->insert($this->forms_table, array('form_slug' => $this->formatSlug($form_slug), 'form_title' => $this->encodeOption($form_title), 'form_action' => $this->encodeOption($form_action), 'form_method' => $form_method, 'submit_button_text' => $this->encodeOption($submit_button_text), 'custom_code' => $this->encodeOption($custom_code)));
|
89 |
+
return true;
|
90 |
+
}
|
91 |
+
|
92 |
+
function insertField($field_slug, $field_label, $field_type, $field_value, $field_maxlength, $user_field) {
|
93 |
+
global $wpdb;
|
94 |
+
if ($this->fieldSlugExists($field_slug)) return false;
|
95 |
+
$wpdb->insert($this->fields_table, array('field_slug' => $this->formatSlug($field_slug), 'field_label' => $this->encodeOption($field_label), 'field_type' => $field_type, 'field_value' => $this->encodeOption($field_value), 'field_maxlength' => $this->encodeOption($field_maxlength), 'user_field' => $user_field));
|
96 |
+
return true;
|
97 |
}
|
98 |
|
99 |
function fieldsTableExists() {
|
195 |
$slug = preg_replace('/[^a-zA-Z0-9\s]/', '', $slug);
|
196 |
return str_replace(' ', '_', $slug);
|
197 |
}
|
198 |
+
|
199 |
+
function fieldSlugExists($slug) {
|
200 |
+
$test = $this->selectField('', $slug);
|
201 |
+
return (!empty($test));
|
202 |
+
}
|
203 |
+
|
204 |
+
function formSlugExists($slug) {
|
205 |
+
$test = $this->selectForm('', $slug);
|
206 |
+
return (!empty($test));
|
207 |
+
}
|
208 |
}
|
209 |
}
|
210 |
?>
|
custom-contact-forms-images.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Custom Contact Forms Plugin
|
4 |
+
By Taylor Lovett - http://www.taylorlovett.com
|
5 |
+
Plugin URL: http://www.taylorlovett.com/wordpress-plugins
|
6 |
+
*/
|
7 |
+
if (!class_exists('CustomContactFormsImages')) {
|
8 |
+
class CustomContactFormsImages {
|
9 |
+
function createImageWithText($str){
|
10 |
+
$image = imagecreate(96,24);
|
11 |
+
$src = imagecreatefrompng('images/gd' . rand(1, 4) . '.png');
|
12 |
+
$textcolor = imagecolorallocate($src, 10, 0, 0);
|
13 |
+
imagestring($src, 14, 5, 1, $str, $textcolor);
|
14 |
+
imagecopyresampled($image, $src, 0, 0, 0, 0, 96, 24, 63, 18);
|
15 |
+
header('Content-Type: image/gif');
|
16 |
+
imagepng($image);
|
17 |
+
imagedestroy($image);
|
18 |
+
imagedestroy($src);
|
19 |
+
return $str;
|
20 |
+
}
|
21 |
+
}
|
22 |
+
}
|
23 |
+
?>
|
custom-contact-forms-mailer.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
-
Custom Contact Forms
|
4 |
By Taylor Lovett - http://www.taylorlovett.com
|
5 |
Plugin URL: http://www.taylorlovett.com/wordpress-plugins
|
6 |
*/
|
1 |
<?php
|
2 |
/*
|
3 |
+
Custom Contact Forms Plugin
|
4 |
By Taylor Lovett - http://www.taylorlovett.com
|
5 |
Plugin URL: http://www.taylorlovett.com/wordpress-plugins
|
6 |
*/
|
custom-contact-forms.css
CHANGED
@@ -1,26 +1,29 @@
|
|
1 |
/* Custom Contact Forms CSS */
|
2 |
form.customcontactform {
|
3 |
-
border:1px solid #ccc;
|
4 |
margin:8px;
|
5 |
width:95%;
|
6 |
-
max-width:
|
7 |
font-size:1em;
|
8 |
padding:4px;
|
9 |
color:#333333;
|
10 |
}
|
11 |
form.customcontactform-sidebar {
|
12 |
width:100%;
|
13 |
-
max-width:
|
14 |
padding:4px;
|
15 |
color:#333333;
|
16 |
-
font-size
|
17 |
}
|
18 |
form.customcontactform ul, form.customcontactform-sidebar ul {
|
19 |
list-style-type:none;
|
20 |
}
|
21 |
form.customcontactform ul li, form.customcontactform-sidebar ul li {
|
22 |
-
margin:.3em 0
|
23 |
-
padding:0;
|
|
|
|
|
|
|
|
|
24 |
}
|
25 |
form.customcontactform h4, form.customcontactform-sidebar h4 {
|
26 |
font-size:1.4em;
|
@@ -29,9 +32,11 @@ form.customcontactform h4, form.customcontactform-sidebar h4 {
|
|
29 |
form.customcontactform ul li label, form.customcontactform-sidebar ul li label {
|
30 |
display:block;
|
31 |
padding:0;
|
|
|
32 |
}
|
33 |
form.customcontactform ul li label.checkbox, form.customcontactform-sidebar ul li label.checkbox {
|
34 |
display:inline;
|
|
|
35 |
}
|
36 |
form.customcontactform ul li input[type=text], form.customcontactform ul li textarea, form.customcontactform-sidebar ul li input[type=text], form.customcontactform-sidebar ul li textarea {
|
37 |
border-width:1px;
|
@@ -42,12 +47,13 @@ form.customcontactform ul li input[type=text], form.customcontactform ul li text
|
|
42 |
padding:2px;
|
43 |
clear:both;
|
44 |
margin:0;
|
|
|
|
|
45 |
-moz-border-radius:4px;
|
46 |
-khtml-border-radius:4px;
|
47 |
-webkit-border-radius:4px;
|
48 |
border-radius:4px;
|
49 |
word-wrap:break-word;
|
50 |
-
font-size:.9em;
|
51 |
}
|
52 |
form.customcontactform p, form.customcontactform-sidebar p { padding:0 0 4px 17px; margin:0; }
|
53 |
form.customcontactform ul li input[type=submit], form.customcontactform ul li .submit, form.customcontactform-sidebar ul li .submit {
|
@@ -60,12 +66,19 @@ form.customcontactform ul li input[type=checkbox], form.customcontactform-sideba
|
|
60 |
}
|
61 |
form.customcontactform-sidebar ul li input[type=text], form.customcontactform-sidebar ul li textarea {
|
62 |
width:90%;
|
|
|
63 |
}
|
64 |
-
|
|
|
65 |
#customcontactforms-admin {
|
66 |
vertical-align:top;
|
67 |
margin:1em 0 30px 25px;
|
68 |
}
|
|
|
|
|
|
|
|
|
|
|
69 |
#customcontactforms-admin .icon32 {
|
70 |
margin:-6px 6px 9px 5px;
|
71 |
}
|
@@ -90,7 +103,7 @@ form.customcontactform-sidebar ul li input[type=text], form.customcontactform-si
|
|
90 |
#customcontactforms-admin #general-settings {
|
91 |
float:left;
|
92 |
clear:both;
|
93 |
-
height:
|
94 |
width:29em;
|
95 |
margin:20px 1em 1em 5px;
|
96 |
}
|
@@ -127,6 +140,9 @@ form.customcontactform-sidebar ul li input[type=text], form.customcontactform-si
|
|
127 |
#customcontactforms-admin #manage-fields {
|
128 |
width:1000px;
|
129 |
}
|
|
|
|
|
|
|
130 |
#customcontactforms-admin .evenrow {
|
131 |
background-color:#f5f5f5;
|
132 |
}
|
1 |
/* Custom Contact Forms CSS */
|
2 |
form.customcontactform {
|
|
|
3 |
margin:8px;
|
4 |
width:95%;
|
5 |
+
max-width:600px;
|
6 |
font-size:1em;
|
7 |
padding:4px;
|
8 |
color:#333333;
|
9 |
}
|
10 |
form.customcontactform-sidebar {
|
11 |
width:100%;
|
12 |
+
max-width:600px;
|
13 |
padding:4px;
|
14 |
color:#333333;
|
15 |
+
font-size:1em;
|
16 |
}
|
17 |
form.customcontactform ul, form.customcontactform-sidebar ul {
|
18 |
list-style-type:none;
|
19 |
}
|
20 |
form.customcontactform ul li, form.customcontactform-sidebar ul li {
|
21 |
+
margin:.3em 0 .3em 0;
|
22 |
+
padding:4px 0 4px 0;
|
23 |
+
overflow:hidden;
|
24 |
+
}
|
25 |
+
form.customcontactform ul li {
|
26 |
+
border-bottom:1px dashed #999;
|
27 |
}
|
28 |
form.customcontactform h4, form.customcontactform-sidebar h4 {
|
29 |
font-size:1.4em;
|
32 |
form.customcontactform ul li label, form.customcontactform-sidebar ul li label {
|
33 |
display:block;
|
34 |
padding:0;
|
35 |
+
width:20%;
|
36 |
}
|
37 |
form.customcontactform ul li label.checkbox, form.customcontactform-sidebar ul li label.checkbox {
|
38 |
display:inline;
|
39 |
+
width:20%;
|
40 |
}
|
41 |
form.customcontactform ul li input[type=text], form.customcontactform ul li textarea, form.customcontactform-sidebar ul li input[type=text], form.customcontactform-sidebar ul li textarea {
|
42 |
border-width:1px;
|
47 |
padding:2px;
|
48 |
clear:both;
|
49 |
margin:0;
|
50 |
+
font-size:1.1em;
|
51 |
+
font-family:Verdana, Arial, Helvetica, sans-serif;
|
52 |
-moz-border-radius:4px;
|
53 |
-khtml-border-radius:4px;
|
54 |
-webkit-border-radius:4px;
|
55 |
border-radius:4px;
|
56 |
word-wrap:break-word;
|
|
|
57 |
}
|
58 |
form.customcontactform p, form.customcontactform-sidebar p { padding:0 0 4px 17px; margin:0; }
|
59 |
form.customcontactform ul li input[type=submit], form.customcontactform ul li .submit, form.customcontactform-sidebar ul li .submit {
|
66 |
}
|
67 |
form.customcontactform-sidebar ul li input[type=text], form.customcontactform-sidebar ul li textarea {
|
68 |
width:90%;
|
69 |
+
font-size:12px;
|
70 |
}
|
71 |
+
|
72 |
+
/* ------------------ custom contact forms admin panel ---------------- */
|
73 |
#customcontactforms-admin {
|
74 |
vertical-align:top;
|
75 |
margin:1em 0 30px 25px;
|
76 |
}
|
77 |
+
|
78 |
+
#customcontactforms-admin input, textarea, select {
|
79 |
+
font-size:1em;
|
80 |
+
}
|
81 |
+
|
82 |
#customcontactforms-admin .icon32 {
|
83 |
margin:-6px 6px 9px 5px;
|
84 |
}
|
103 |
#customcontactforms-admin #general-settings {
|
104 |
float:left;
|
105 |
clear:both;
|
106 |
+
height:48em;
|
107 |
width:29em;
|
108 |
margin:20px 1em 1em 5px;
|
109 |
}
|
140 |
#customcontactforms-admin #manage-fields {
|
141 |
width:1000px;
|
142 |
}
|
143 |
+
#customcontactforms-admin #manage-fixed-fields {
|
144 |
+
width:1000px;
|
145 |
+
}
|
146 |
#customcontactforms-admin .evenrow {
|
147 |
background-color:#f5f5f5;
|
148 |
}
|
custom-contact-forms.php
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
/*
|
3 |
Plugin Name: Custom Contact Forms
|
4 |
Plugin URI: http://taylorlovett.com/wordpress-plugins
|
5 |
-
Description: 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
|
6 |
-
Version: 1.0
|
7 |
Author: <a href="http://www.taylorlovett.com" title="Maryland Wordpress Developer">Taylor Lovett</a>
|
8 |
Author URI: http://www.taylorlovett.com
|
9 |
*/
|
@@ -21,22 +21,26 @@
|
|
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 |
-
|
25 |
-
require('custom-contact-forms-db.php');
|
26 |
require_once('custom-contact-forms-mailer.php');
|
|
|
27 |
if (!class_exists('CustomContactForms')) {
|
28 |
class CustomContactForms extends CustomContactFormsDB {
|
29 |
var $adminOptionsName = 'customContactFormsAdminOptions';
|
30 |
var $widgetOptionsName = 'widget_customContactForms';
|
31 |
-
var $version = '1.
|
|
|
|
|
|
|
32 |
|
33 |
function CustomContactForms() {
|
34 |
parent::CustomContactFormsDB();
|
|
|
35 |
}
|
36 |
|
37 |
function getAdminOptions() {
|
38 |
$admin_email = get_option('admin_email');
|
39 |
-
$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!', '
|
40 |
$customcontactOptions = get_option($this->adminOptionsName);
|
41 |
if (!empty($customcontactOptions)) {
|
42 |
foreach ($customcontactOptions as $key => $option)
|
@@ -69,6 +73,7 @@ if (!class_exists('CustomContactForms')) {
|
|
69 |
$form_options .= '<option value="'.$form->id.'"'.$sel.'>'.$form->form_slug.'</option>';
|
70 |
}
|
71 |
if (empty($form_options)) { ?>
|
|
|
72 |
<p>Create a form in the Custom Contact Forms settings page.</p>
|
73 |
<?php
|
74 |
} else {
|
@@ -95,17 +100,30 @@ if (!class_exists('CustomContactForms')) {
|
|
95 |
}
|
96 |
function addHeaderCode() {
|
97 |
?>
|
98 |
-
<!--
|
99 |
<link rel="stylesheet" href="<?php echo get_option('siteurl'); ?>/wp-content/plugins/custom-contact-forms/custom-contact-forms.css" type="text/css" media="screen" />
|
100 |
<?php
|
101 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
function printAdminPage() {
|
103 |
parent::encodeOption('sfsfd');
|
104 |
$admin_options = $this->getAdminOptions();
|
105 |
if ($_POST[form_create]) {
|
106 |
parent::insertForm($_POST[form_slug], $_POST[form_title], $_POST[form_action], $_POST[form_method], $_POST[submit_button_text], $_POST[custom_code]);
|
107 |
} elseif ($_POST[field_create]) {
|
108 |
-
parent::insertField($_POST[field_slug], $_POST[field_label], $_POST[field_type], $_POST[field_value], $_POST[field_maxlength]);
|
109 |
} elseif ($_POST[general_settings]) {
|
110 |
$admin_options[default_to_email] = $_POST[default_to_email];
|
111 |
$admin_options[default_from_email] = $_POST[default_from_email];
|
@@ -115,7 +133,8 @@ if (!class_exists('CustomContactForms')) {
|
|
115 |
$admin_options[show_widget_pages] = $_POST[show_widget_pages];
|
116 |
$admin_options[show_widget_archives] = $_POST[show_widget_archives];
|
117 |
$admin_options[show_widget_home] = $_POST[show_widget_home];
|
118 |
-
$admin_options[
|
|
|
119 |
update_option($this->adminOptionsName, $admin_options);
|
120 |
} elseif ($_POST[field_edit]) {
|
121 |
parent::updateField($_POST[field_slug], $_POST[field_label], $_POST[field_type], $_POST[field_value], $_POST[field_maxlength], $_POST[fid]);
|
@@ -210,7 +229,7 @@ if (!class_exists('CustomContactForms')) {
|
|
210 |
</form>
|
211 |
</div>
|
212 |
</div>
|
213 |
-
<h3 class="manage-h3">Manage Fields</h3>
|
214 |
<table class="widefat post" id="manage-fields" cellspacing="0">
|
215 |
<thead>
|
216 |
<tr>
|
@@ -226,6 +245,7 @@ if (!class_exists('CustomContactForms')) {
|
|
226 |
<?php
|
227 |
$fields = parent::selectAllFields();
|
228 |
for ($i = 0; $i < count($fields); $i++) {
|
|
|
229 |
$field_types = '<option>Text</option><option>Textarea</option><option>Hidden</option><option>Checkbox</option>';
|
230 |
$field_types = str_replace('<option>'.$fields[$i]->field_type.'</option>', '<option selected="selected">'.$fields[$i]->field_type.'</option>', $field_types);
|
231 |
|
@@ -259,6 +279,55 @@ if (!class_exists('CustomContactForms')) {
|
|
259 |
</tr>
|
260 |
</tfoot>
|
261 |
</table>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
262 |
<h3 class="manage-h3">Manage Forms</h3>
|
263 |
<table class="widefat post" id="manage-fields" cellspacing="0">
|
264 |
<thead>
|
@@ -321,9 +390,9 @@ if (!class_exists('CustomContactForms')) {
|
|
321 |
<?php echo $add_fields; ?>
|
322 |
</select>
|
323 |
<input type="submit" name="form_add_field" value="Attach" />
|
324 |
-
<input type="hidden" name="fid" value="<?php echo $forms[$i]->id; ?>"
|
325 |
-
<
|
326 |
-
|
327 |
</form>
|
328 |
</tr>
|
329 |
<?php
|
@@ -341,7 +410,7 @@ if (!class_exists('CustomContactForms')) {
|
|
341 |
<th scope="col" class="manage-column form-submit">Custom Code</th>
|
342 |
<th scope="col" class="manage-column field-action">Action</th>
|
343 |
</tr>
|
344 |
-
|
345 |
|
346 |
</tfoot>
|
347 |
</table>
|
@@ -366,35 +435,40 @@ if (!class_exists('CustomContactForms')) {
|
|
366 |
</li>
|
367 |
<li class="descrip">Default subject to be included in all form emails.</li>
|
368 |
<li>
|
369 |
-
<label for="
|
370 |
-
<input name="
|
|
|
|
|
|
|
|
|
|
|
371 |
</li>
|
372 |
-
<li class="descrip">
|
373 |
<li class="show-widget">Show Sidebar Widget:</li>
|
374 |
<li>
|
375 |
<label>
|
376 |
-
|
377 |
-
|
378 |
</li>
|
379 |
<li>
|
380 |
<label>
|
381 |
-
|
382 |
-
|
383 |
</li>
|
384 |
<li>
|
385 |
<label>
|
386 |
-
|
387 |
-
|
388 |
</li>
|
389 |
<li>
|
390 |
<label>
|
391 |
-
|
392 |
-
|
393 |
</li>
|
394 |
<li>
|
395 |
<label>
|
396 |
-
|
397 |
-
|
398 |
</li>
|
399 |
<li>
|
400 |
<input type="submit" value="Update" name="general_settings" />
|
@@ -418,6 +492,15 @@ if (!class_exists('CustomContactForms')) {
|
|
418 |
}
|
419 |
|
420 |
function contentFilter($content) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
421 |
$matches = array();
|
422 |
preg_match_all('/\[customcontact form=([0-9]+)\]/si', $content, $matches);
|
423 |
for ($i = 0; $i < count($matches[0]); $i++) {
|
@@ -448,6 +531,7 @@ if (!class_exists('CustomContactForms')) {
|
|
448 |
|
449 |
function getFormCode($fid, $is_sidebar, $args) {
|
450 |
if ($is_sidebar) extract($args);
|
|
|
451 |
$form = parent::selectForm($fid, '');
|
452 |
$class = (!$is_sidebar) ? 'customcontactform' : 'customcontactform-sidebar';
|
453 |
$action = (!empty($form->form_action)) ? $form->form_action : get_permalink();
|
@@ -457,23 +541,40 @@ if (!class_exists('CustomContactForms')) {
|
|
457 |
$hiddens = '';
|
458 |
foreach ($fields as $field_id) {
|
459 |
$field = parent::selectField($field_id, '');
|
460 |
-
|
|
|
|
|
|
|
|
|
461 |
$maxlength = (empty($field->field_maxlength) or $field->field_maxlength <= 0) ? '' : ' maxlength="'.$field->field_maxlength.'"';
|
462 |
-
$out .= '<li><label for="'.parent::decodeOption($field->field_slug, 1, 1).'">'.parent::decodeOption($field->field_label, 1, 1).'</label><input type="text" name="'.parent::decodeOption($field->field_slug, 1, 1).'" value="'
|
463 |
} elseif ($field->field_type == 'Hidden') {
|
464 |
-
$hiddens .= '<li><input type="hidden" name="'.parent::decodeOption($field->field_slug, 1, 1).'" value="'
|
465 |
} elseif ($field->field_type == 'Checkbox') {
|
466 |
-
$out .= '<li><input type="checkbox" name="'.parent::decodeOption($field->field_slug, 1, 1).'" value="'.parent::decodeOption($field->field_value, 1, 1).'" /> <label class="checkbox" for="'.parent::decodeOption($field->field_slug, 1, 1).'">'.parent::decodeOption($field->field_label, 1, 1).'</label></li>' . "\n";
|
467 |
} elseif ($field->field_type == 'Textarea') {
|
468 |
-
$out .= '<li><label for="'.parent::decodeOption($field->field_slug, 1, 1).'">'.parent::decodeOption($field->field_label, 1, 1).'</label><textarea name="'.parent::decodeOption($field->field_slug, 1, 1).'">'
|
469 |
}
|
470 |
}
|
471 |
-
$out .= '</ul>'."\n".'<p><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>';
|
472 |
return $out . $this->wheresWaldo();
|
473 |
}
|
474 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
475 |
function processForms() {
|
476 |
if ($_POST[customcontactforms_submit]) {
|
|
|
|
|
477 |
$admin_options = $this->getAdminOptions();
|
478 |
$fields = parent::getAttachedFieldsArray($_POST[fid]);
|
479 |
$checks = array();
|
@@ -481,11 +582,16 @@ if (!class_exists('CustomContactForms')) {
|
|
481 |
$field = parent::selectField($field_id, '');
|
482 |
if ($field->field_type == 'Checkbox')
|
483 |
$checks[] = $field->field_slug;
|
|
|
|
|
|
|
|
|
484 |
}
|
485 |
$body = '';
|
486 |
foreach ($_POST as $key => $value) {
|
|
|
487 |
$field = parent::selectField('', $key);
|
488 |
-
if ($key
|
489 |
$body .= $field->field_label . ': ' . $value . "\n";
|
490 |
if (in_array($key, $checks)) {
|
491 |
$checks_key = array_search($key, $checks);
|
@@ -495,13 +601,16 @@ if (!class_exists('CustomContactForms')) {
|
|
495 |
$field = parent::selectField('', $check_key);
|
496 |
$body .= ucwords(str_replace('_', ' ', $field->field_label)) . ': 0' . "\n";
|
497 |
}
|
498 |
-
$
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
|
|
|
|
504 |
}
|
|
|
505 |
}
|
506 |
}
|
507 |
}
|
@@ -518,6 +627,7 @@ if (!function_exists('CustomContactForms_ap')) {
|
|
518 |
}
|
519 |
if (isset($customcontact)) {
|
520 |
add_action('init', array(&$customcontact, 'processForms'), 1);
|
|
|
521 |
add_action('wp_head', array(&$customcontact, 'addHeaderCode'), 1);
|
522 |
add_action('admin_head', array(&$customcontact, 'addHeaderCode'), 1);
|
523 |
add_action('activate_customcontactforms/customcontactforms.php', array(&$customcontact, 'init'));
|
2 |
/*
|
3 |
Plugin Name: Custom Contact Forms
|
4 |
Plugin URI: http://taylorlovett.com/wordpress-plugins
|
5 |
+
Description: 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: 1.1.0
|
7 |
Author: <a href="http://www.taylorlovett.com" title="Maryland Wordpress Developer">Taylor Lovett</a>
|
8 |
Author URI: http://www.taylorlovett.com
|
9 |
*/
|
21 |
You should have received a copy of the GNU General Public License
|
22 |
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
23 |
*/
|
24 |
+
require_once('custom-contact-forms-db.php');
|
|
|
25 |
require_once('custom-contact-forms-mailer.php');
|
26 |
+
require_once('custom-contact-forms-images.php');
|
27 |
if (!class_exists('CustomContactForms')) {
|
28 |
class CustomContactForms extends CustomContactFormsDB {
|
29 |
var $adminOptionsName = 'customContactFormsAdminOptions';
|
30 |
var $widgetOptionsName = 'widget_customContactForms';
|
31 |
+
var $version = '1.1.0';
|
32 |
+
var $errors;
|
33 |
+
var $error_return;
|
34 |
+
var $fixed_fields = array('customcontactforms_submit', 'fid', 'form_page', 'captcha');
|
35 |
|
36 |
function CustomContactForms() {
|
37 |
parent::CustomContactFormsDB();
|
38 |
+
$this->errors = array();
|
39 |
}
|
40 |
|
41 |
function getAdminOptions() {
|
42 |
$admin_email = get_option('admin_email');
|
43 |
+
$customcontactAdminOptions = array('show_widget_home' => 1, 'show_widget_pages' => 1, 'show_widget_singles' => 1, 'show_widget_categories' => 1, 'show_widget_archives' => 1, 'default_to_email' => $admin_email, 'default_from_email' => $admin_email, 'default_form_subject' => 'Someone Filled Out Your Contact Form!', 'custom_thank_you' => '', 'thank_you_message' => 'Thank you for filling out our form. We will respond to your inquiry ASAP.'); // defaults
|
44 |
$customcontactOptions = get_option($this->adminOptionsName);
|
45 |
if (!empty($customcontactOptions)) {
|
46 |
foreach ($customcontactOptions as $key => $option)
|
73 |
$form_options .= '<option value="'.$form->id.'"'.$sel.'>'.$form->form_slug.'</option>';
|
74 |
}
|
75 |
if (empty($form_options)) { ?>
|
76 |
+
|
77 |
<p>Create a form in the Custom Contact Forms settings page.</p>
|
78 |
<?php
|
79 |
} else {
|
100 |
}
|
101 |
function addHeaderCode() {
|
102 |
?>
|
103 |
+
<!-- Custom Contact Forms by Taylor Lovett - http://www.taylorlovett.com -->
|
104 |
<link rel="stylesheet" href="<?php echo get_option('siteurl'); ?>/wp-content/plugins/custom-contact-forms/custom-contact-forms.css" type="text/css" media="screen" />
|
105 |
<?php
|
106 |
}
|
107 |
+
|
108 |
+
function setError($key, $message) {
|
109 |
+
$this->errors[$key] = $message;
|
110 |
+
}
|
111 |
+
|
112 |
+
function getError($key) {
|
113 |
+
return $this->errors[$key];
|
114 |
+
}
|
115 |
+
|
116 |
+
function getAllErrors() {
|
117 |
+
return $this->errors;
|
118 |
+
}
|
119 |
+
|
120 |
function printAdminPage() {
|
121 |
parent::encodeOption('sfsfd');
|
122 |
$admin_options = $this->getAdminOptions();
|
123 |
if ($_POST[form_create]) {
|
124 |
parent::insertForm($_POST[form_slug], $_POST[form_title], $_POST[form_action], $_POST[form_method], $_POST[submit_button_text], $_POST[custom_code]);
|
125 |
} elseif ($_POST[field_create]) {
|
126 |
+
parent::insertField($_POST[field_slug], $_POST[field_label], $_POST[field_type], $_POST[field_value], $_POST[field_maxlength], 1);
|
127 |
} elseif ($_POST[general_settings]) {
|
128 |
$admin_options[default_to_email] = $_POST[default_to_email];
|
129 |
$admin_options[default_from_email] = $_POST[default_from_email];
|
133 |
$admin_options[show_widget_pages] = $_POST[show_widget_pages];
|
134 |
$admin_options[show_widget_archives] = $_POST[show_widget_archives];
|
135 |
$admin_options[show_widget_home] = $_POST[show_widget_home];
|
136 |
+
$admin_options[custom_thank_you] = $_POST[custom_thank_you];
|
137 |
+
$admin_options[thank_you_message] = $_POST[thank_you_message];
|
138 |
update_option($this->adminOptionsName, $admin_options);
|
139 |
} elseif ($_POST[field_edit]) {
|
140 |
parent::updateField($_POST[field_slug], $_POST[field_label], $_POST[field_type], $_POST[field_value], $_POST[field_maxlength], $_POST[fid]);
|
229 |
</form>
|
230 |
</div>
|
231 |
</div>
|
232 |
+
<h3 class="manage-h3">Manage User Fields</h3>
|
233 |
<table class="widefat post" id="manage-fields" cellspacing="0">
|
234 |
<thead>
|
235 |
<tr>
|
245 |
<?php
|
246 |
$fields = parent::selectAllFields();
|
247 |
for ($i = 0; $i < count($fields); $i++) {
|
248 |
+
if ($fields[$i]->user_field == 0) continue;
|
249 |
$field_types = '<option>Text</option><option>Textarea</option><option>Hidden</option><option>Checkbox</option>';
|
250 |
$field_types = str_replace('<option>'.$fields[$i]->field_type.'</option>', '<option selected="selected">'.$fields[$i]->field_type.'</option>', $field_types);
|
251 |
|
279 |
</tr>
|
280 |
</tfoot>
|
281 |
</table>
|
282 |
+
<h3 class="manage-h3">Manage Fixed Fields</h3>
|
283 |
+
<table class="widefat post" id="manage-fixed-fields" cellspacing="0">
|
284 |
+
<thead>
|
285 |
+
<tr>
|
286 |
+
<th scope="col" class="manage-column field-slug">Slug</th>
|
287 |
+
<th scope="col" class="manage-column field-label">Label</th>
|
288 |
+
<th scope="col" class="manage-column field-type">Type</th>
|
289 |
+
<th scope="col" class="manage-column field-value">Initial Value</th>
|
290 |
+
<th scope="col" class="manage-column field-maxlength">Maxlength</th>
|
291 |
+
<th scope="col" class="manage-column field-action">Action</th>
|
292 |
+
</tr>
|
293 |
+
</thead>
|
294 |
+
<tbody>
|
295 |
+
<?php
|
296 |
+
$fields = parent::selectAllFields();
|
297 |
+
for ($i = 0; $i < count($fields); $i++) {
|
298 |
+
if ($fields[$i]->user_field == 1) continue;
|
299 |
+
$field_types = '<option>Text</option><option>Textarea</option><option>Hidden</option><option>Checkbox</option>';
|
300 |
+
$field_types = str_replace('<option>'.$fields[$i]->field_type.'</option>', '<option selected="selected">'.$fields[$i]->field_type.'</option>', $field_types);
|
301 |
+
|
302 |
+
?>
|
303 |
+
<tr<?php if ($i % 2 == 0) echo ' class="evenrow"'; ?>>
|
304 |
+
<form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
|
305 |
+
<td><?php echo $fields[$i]->field_slug; ?>
|
306 |
+
<input type="hidden" name="field_slug" value="<?php echo $fields[$i]->field_slug; ?>" /></td>
|
307 |
+
<td><input type="text" name="field_label" maxlength="100" value="<?php echo $fields[$i]->field_label; ?>" /></td>
|
308 |
+
<td><?php echo $fields[$i]->field_type; ?>
|
309 |
+
<input type="hidden" name="field_type" value="<?php echo $fields[$i]->field_type; ?>" /></td>
|
310 |
+
<td><input type="text" name="field_value" maxlength="50" value="<?php echo $fields[$i]->field_value; ?>" /></td>
|
311 |
+
<td><input type="text" class="width50" name="field_maxlength" value="<?php echo $fields[$i]->field_maxlength; ?>" /></td>
|
312 |
+
<td><input type="hidden" name="fid" value="<?php echo $fields[$i]->id; ?>" />
|
313 |
+
<input type="submit" name="field_edit" value="Edit" /></td>
|
314 |
+
</form>
|
315 |
+
</tr>
|
316 |
+
<?php
|
317 |
+
}
|
318 |
+
?>
|
319 |
+
</tbody>
|
320 |
+
<tfoot>
|
321 |
+
<tr>
|
322 |
+
<th scope="col" class="manage-column field-slug">Slug</th>
|
323 |
+
<th scope="col" class="manage-column field-label">Label</th>
|
324 |
+
<th scope="col" class="manage-column field-type">Type</th>
|
325 |
+
<th scope="col" class="manage-column field-value">Initial Value</th>
|
326 |
+
<th scope="col" class="manage-column field-maxlength">Maxlength</th>
|
327 |
+
<th scope="col" class="manage-column field-action">Action</th>
|
328 |
+
</tr>
|
329 |
+
</tfoot>
|
330 |
+
</table>
|
331 |
<h3 class="manage-h3">Manage Forms</h3>
|
332 |
<table class="widefat post" id="manage-fields" cellspacing="0">
|
333 |
<thead>
|
390 |
<?php echo $add_fields; ?>
|
391 |
</select>
|
392 |
<input type="submit" name="form_add_field" value="Attach" />
|
393 |
+
<input type="hidden" name="fid" value="<?php echo $forms[$i]->id; ?>" />
|
394 |
+
<br />
|
395 |
+
<span class="red bold">*</span> Attach in the order you want fields to display. </div></td>
|
396 |
</form>
|
397 |
</tr>
|
398 |
<?php
|
410 |
<th scope="col" class="manage-column form-submit">Custom Code</th>
|
411 |
<th scope="col" class="manage-column field-action">Action</th>
|
412 |
</tr>
|
413 |
+
</tr>
|
414 |
|
415 |
</tfoot>
|
416 |
</table>
|
435 |
</li>
|
436 |
<li class="descrip">Default subject to be included in all form emails.</li>
|
437 |
<li>
|
438 |
+
<label for="custom_thank_you">Custom Thank You Page:</label>
|
439 |
+
<input name="custom_thank_you" value="<?php echo $admin_options[custom_thank_you]; ?>" type="text" maxlength="150" />
|
440 |
+
</li>
|
441 |
+
<li class="descrip">Leaving this blank will show the default thank you message on form completion.</li>
|
442 |
+
<li>
|
443 |
+
<label for="thank_you_message">Default Thank You Message:</label><br />
|
444 |
+
<textarea rows="6" cols="47" name="thank_you_message"><?php echo $admin_options[thank_you_message]; ?></textarea>
|
445 |
</li>
|
446 |
+
<li class="descrip">This thank you message is shown when a custom.</li>
|
447 |
<li class="show-widget">Show Sidebar Widget:</li>
|
448 |
<li>
|
449 |
<label>
|
450 |
+
<input value="1" type="checkbox" name="show_widget_home" <?php if ($admin_options[show_widget_home] == 1) echo 'checked="checked"'; ?> />
|
451 |
+
On Homepage</label>
|
452 |
</li>
|
453 |
<li>
|
454 |
<label>
|
455 |
+
<input value="1" type="checkbox" name="show_widget_pages" <?php if ($admin_options[show_widget_pages] == 1) echo 'checked="checked"'; ?> />
|
456 |
+
On Pages</label>
|
457 |
</li>
|
458 |
<li>
|
459 |
<label>
|
460 |
+
<input value="1" type="checkbox" name="show_widget_singles" <?php if ($admin_options[show_widget_singles] == 1) echo 'checked="checked"'; ?> />
|
461 |
+
On Single Posts</label>
|
462 |
</li>
|
463 |
<li>
|
464 |
<label>
|
465 |
+
<input value="1" type="checkbox" name="show_widget_categories" <?php if ($admin_options[show_widget_categories] == 1) echo 'checked="checked"'; ?> />
|
466 |
+
On Categories</label>
|
467 |
</li>
|
468 |
<li>
|
469 |
<label>
|
470 |
+
<input value="1" type="checkbox" name="show_widget_archives" <?php if ($admin_options[show_widget_archives] == 1) echo 'checked="checked"'; ?> />
|
471 |
+
On Archives</label>
|
472 |
</li>
|
473 |
<li>
|
474 |
<input type="submit" value="Update" name="general_settings" />
|
492 |
}
|
493 |
|
494 |
function contentFilter($content) {
|
495 |
+
$errors = $this->getAllErrors();
|
496 |
+
if (!empty($errors)) {
|
497 |
+
$out = '<div id="custom-contact-forms-errors"><p>You filled the out form incorrectly.</p><ul>' . "\n";
|
498 |
+
$errors = $this->getAllErrors();
|
499 |
+
foreach ($errors as $error) {
|
500 |
+
$out .= '<li>'.$error.'</li>' . "\n";
|
501 |
+
}
|
502 |
+
return $out . '</ul>' . "\n" . '<p><a href="'.$this->error_return.'" title="Go Back">< Back to Form</a></p></div>';
|
503 |
+
}
|
504 |
$matches = array();
|
505 |
preg_match_all('/\[customcontact form=([0-9]+)\]/si', $content, $matches);
|
506 |
for ($i = 0; $i < count($matches[0]); $i++) {
|
531 |
|
532 |
function getFormCode($fid, $is_sidebar, $args) {
|
533 |
if ($is_sidebar) extract($args);
|
534 |
+
$this->startSession();
|
535 |
$form = parent::selectForm($fid, '');
|
536 |
$class = (!$is_sidebar) ? 'customcontactform' : 'customcontactform-sidebar';
|
537 |
$action = (!empty($form->form_action)) ? $form->form_action : get_permalink();
|
541 |
$hiddens = '';
|
542 |
foreach ($fields as $field_id) {
|
543 |
$field = parent::selectField($field_id, '');
|
544 |
+
$input_id = 'id="'.parent::decodeOption($field->field_slug, 1, 1).'"';
|
545 |
+
$field_value = ($_SESSION[fields][$field->field_slug]) ? $_SESSION[fields][$field->field_slug] : parent::decodeOption($field->field_value, 1, 1);
|
546 |
+
if ($field->user_field == 0 && $field->field_slug == 'captcha') {
|
547 |
+
$out .= '<li>' . $this->getCaptchaCode() . '</li>';
|
548 |
+
} elseif ($field->field_type == 'Text') {
|
549 |
$maxlength = (empty($field->field_maxlength) or $field->field_maxlength <= 0) ? '' : ' maxlength="'.$field->field_maxlength.'"';
|
550 |
+
$out .= '<li><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.' /></li>' . "\n";
|
551 |
} elseif ($field->field_type == 'Hidden') {
|
552 |
+
$hiddens .= '<li><input type="hidden" name="'.parent::decodeOption($field->field_slug, 1, 1).'" value="'.$field_value.'" '.$input_id.' /></li>' . "\n";
|
553 |
} elseif ($field->field_type == 'Checkbox') {
|
554 |
+
$out .= '<li><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></li>' . "\n";
|
555 |
} elseif ($field->field_type == 'Textarea') {
|
556 |
+
$out .= '<li><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></li>' . "\n";
|
557 |
}
|
558 |
}
|
559 |
+
$out .= '</ul>'."\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>';
|
560 |
return $out . $this->wheresWaldo();
|
561 |
}
|
562 |
|
563 |
+
function getCaptchaCode() {
|
564 |
+
$out = '<img id="captcha-image" src="' . get_bloginfo('wpurl') . '/wp-content/plugins/custom-contact-forms/image.php">
|
565 |
+
<br /><input type="text" name="captcha" id="captcha" maxlength="20" />';
|
566 |
+
|
567 |
+
return $out;
|
568 |
+
}
|
569 |
+
|
570 |
+
function startSession() {
|
571 |
+
if (!session_id()) session_start();
|
572 |
+
}
|
573 |
+
|
574 |
function processForms() {
|
575 |
if ($_POST[customcontactforms_submit]) {
|
576 |
+
$this->startSession();
|
577 |
+
$this->error_return = $_POST[form_page];
|
578 |
$admin_options = $this->getAdminOptions();
|
579 |
$fields = parent::getAttachedFieldsArray($_POST[fid]);
|
580 |
$checks = array();
|
582 |
$field = parent::selectField($field_id, '');
|
583 |
if ($field->field_type == 'Checkbox')
|
584 |
$checks[] = $field->field_slug;
|
585 |
+
elseif ($field->field_slug == 'captcha') {
|
586 |
+
if ($_POST[captcha] != $_SESSION[captcha])
|
587 |
+
$this->setError('captcha', 'You entered the captcha image code incorrectly');
|
588 |
+
}
|
589 |
}
|
590 |
$body = '';
|
591 |
foreach ($_POST as $key => $value) {
|
592 |
+
$_SESSION[fields][$key] = $value;
|
593 |
$field = parent::selectField('', $key);
|
594 |
+
if (!in_array($key, $this->fixed_fields))
|
595 |
$body .= $field->field_label . ': ' . $value . "\n";
|
596 |
if (in_array($key, $checks)) {
|
597 |
$checks_key = array_search($key, $checks);
|
601 |
$field = parent::selectField('', $check_key);
|
602 |
$body .= ucwords(str_replace('_', ' ', $field->field_label)) . ': 0' . "\n";
|
603 |
}
|
604 |
+
$errors = $this->getAllErrors();
|
605 |
+
if (empty($errors)) {
|
606 |
+
$body .= 'Sender IP: ' . $_SERVER['REMOTE_ADDR'] . "\n";
|
607 |
+
$mailer = new CustomContactFormsMailer($admin_options[default_to_email], $admin_options[default_from_email], $admin_options[default_form_subject], $body);
|
608 |
+
$mailer->send();
|
609 |
+
if (!empty($admin_options[custom_thank_you])) {
|
610 |
+
header("Location: " . $admin_options[custom_thank_you]);
|
611 |
+
}
|
612 |
}
|
613 |
+
unset($_POST);
|
614 |
}
|
615 |
}
|
616 |
}
|
627 |
}
|
628 |
if (isset($customcontact)) {
|
629 |
add_action('init', array(&$customcontact, 'processForms'), 1);
|
630 |
+
add_action('init', array(&$customcontact, 'startSession'), 1);
|
631 |
add_action('wp_head', array(&$customcontact, 'addHeaderCode'), 1);
|
632 |
add_action('admin_head', array(&$customcontact, 'addHeaderCode'), 1);
|
633 |
add_action('activate_customcontactforms/customcontactforms.php', array(&$customcontact, 'init'));
|
image.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Custom Contact Forms Plugin
|
4 |
+
By Taylor Lovett - http://www.taylorlovett.com
|
5 |
+
Plugin URL: http://www.taylorlovett.com/wordpress-plugins
|
6 |
+
*/
|
7 |
+
header("Content-type: image/png");
|
8 |
+
require_once('custom-contact-forms-images.php');
|
9 |
+
$image = new CustomContactFormsImages();
|
10 |
+
$str = rand(10000, 99999);
|
11 |
+
if (!session_id())
|
12 |
+
session_start();
|
13 |
+
$_SESSION[captcha] = $str;
|
14 |
+
$image->createImageWithText($str);
|
15 |
+
|
16 |
+
?>
|
images/_notes/dwsync.xml
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="utf-8" ?>
|
2 |
+
<dwsync>
|
3 |
+
<file name="gd1.png" server="ftp.taylorlovett.com/www/" local="129244226400000000" remote="129244781400000000" />
|
4 |
+
<file name="gd2.png" server="ftp.taylorlovett.com/www/" local="129244226400000000" remote="129244781400000000" />
|
5 |
+
<file name="gd3.png" server="ftp.taylorlovett.com/www/" local="129244226400000000" remote="129244781400000000" />
|
6 |
+
<file name="gd4.png" server="ftp.taylorlovett.com/www/" local="129244227000000000" remote="129244781400000000" />
|
7 |
+
</dwsync>
|
images/gd1.png
ADDED
Binary file
|
images/gd2.png
ADDED
Binary file
|
images/gd3.png
ADDED
Binary file
|
images/gd4.png
ADDED
Binary file
|
readme.txt
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
=== Custom Contact Forms ===
|
2 |
Plugin Name: Custom Contact Forms
|
3 |
-
Tags: contact form, web form, custom contact form, custom forms, contact fields, form mailers
|
4 |
Requires at least: 2.7.1
|
5 |
Tested up to: 3.0
|
6 |
-
Stable tag: 1.0
|
7 |
Contributors: Taylor Lovett
|
8 |
Download link: http://www.taylorlovett.com/wordpress-plugins/
|
9 |
Author: Taylor Lovett
|
@@ -27,7 +27,20 @@ A plugin for handling and displaying custom web forms in any page, post, or side
|
|
27 |
|
28 |
== Support ==
|
29 |
For questions, feature requests, and support concerning the Custom Contact Forms plugin, please email me at:
|
30 |
-
|
31 |
admin@taylorlovett.com
|
|
|
|
|
|
|
|
|
32 |
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
=== Custom Contact Forms ===
|
2 |
Plugin Name: Custom Contact Forms
|
3 |
+
Tags: contact form, web form, custom contact form, custom forms, captcha form, contact fields, form mailers
|
4 |
Requires at least: 2.7.1
|
5 |
Tested up to: 3.0
|
6 |
+
Stable tag: 1.1.0
|
7 |
Contributors: Taylor Lovett
|
8 |
Download link: http://www.taylorlovett.com/wordpress-plugins/
|
9 |
Author: Taylor Lovett
|
27 |
|
28 |
== Support ==
|
29 |
For questions, feature requests, and support concerning the Custom Contact Forms plugin, please email me at:
|
|
|
30 |
admin@taylorlovett.com
|
31 |
+
I respond to emails same-day!
|
32 |
+
|
33 |
+
== Upgrade Notice ==
|
34 |
+
Required fields option will be added in mid-August 2010
|
35 |
|
36 |
+
== Change Log ==
|
37 |
+
1.0.0:
|
38 |
+
* Plugin Release
|
39 |
+
1.0.1:
|
40 |
+
* custom-contact-forms.css - Form style changes
|
41 |
+
1.1.0:
|
42 |
+
* custom-contact-forms-db.php - Table upgrade functions added
|
43 |
+
* custom-contact-forms.php - New functions for error handling and captcha
|
44 |
+
* custom-contact-forms.css - Forms restyled
|
45 |
+
* custom-contact-forms-images.php - Image handling class added
|
46 |
+
* image.php, images/ - Image for captcha displaying
|