Contact Form 7 - Version 1.3

Version Description

Download this release

Release Info

Developer takayukister
Plugin Icon 128x128 Contact Form 7
Version 1.3
Comparing to
See all releases

Code changes from version 1.2 to 1.3

README.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: takayukister
3
Tags: contact form, email, ajax
4
Requires at least: 2.2
5
Tested up to: 2.3-alpha
6
- Stable tag: 1.2
7
8
Just another contact form plugin. Simple but flexible.
9
3
Tags: contact form, email, ajax
4
Requires at least: 2.2
5
Tested up to: 2.3-alpha
6
+ Stable tag: 1.3
7
8
Just another contact form plugin. Simple but flexible.
9
admin-stylesheet.css CHANGED
@@ -74,7 +74,6 @@ div#quick-panel {
74
margin: 0 0 4px;
75
padding: 4px;
76
width: 99%;
77
- background: #aaecf5;
78
}
79
div#quick-panel div.close {
80
float: right;
@@ -86,8 +85,9 @@ div#quick-panel div.close {
86
padding: 1px 3px;
87
cursor: pointer;
88
}
89
- div#quick-panel input {
90
background: #fff;
91
}
92
div#quick-panel input.qp-button {
93
background: #fff url( images/fade-butt.png ) repeat-x 0 -2px;
@@ -97,7 +97,10 @@ div#quick-panel input.qp-button {
97
div#quick-panel input.required {
98
border: 1px solid #777;
99
}
100
- div#quick-panel table td {
101
text-align: right;
102
- padding: 0 1em;
103
}
74
margin: 0 0 4px;
75
padding: 4px;
76
width: 99%;
77
}
78
div#quick-panel div.close {
79
float: right;
85
padding: 1px 3px;
86
cursor: pointer;
87
}
88
+ div#quick-panel input, div#quick-panel textarea {
89
background: #fff;
90
+ width: 200px;
91
}
92
div#quick-panel input.qp-button {
93
background: #fff url( images/fade-butt.png ) repeat-x 0 -2px;
97
div#quick-panel input.required {
98
border: 1px solid #777;
99
}
100
+ div#quick-panel table th {
101
text-align: right;
102
+ padding-left: 1em;
103
+ }
104
+ div#quick-panel table td {
105
+ text-align: left;
106
}
images/ajax-loader.gif ADDED
Binary file
includes/admin-panel.php CHANGED
@@ -32,7 +32,7 @@
32
33
<div class="fieldset">
34
<label for="wpcf7-title"><?php _e('Title', 'wpcf7'); ?></label>
35
- <input type="text" id="wpcf7-title" name="wpcf7-title" size="40" value="<?php echo htmlspecialchars($cf['title']); ?>" onchange="update_anchor(this.value);" />
36
37
<?php if (! $initial) : ?>
38
<p class="important">
@@ -43,15 +43,16 @@
43
</div>
44
45
<div class="fieldset"><div class="legend"><?php _e('Form content', 'wpcf7'); ?></div>
46
- <input type="button" value="text" class="quick-button" onclick="quick_panel('text');" />
47
- <input type="button" value="text*" class="quick-button" onclick="quick_panel('text*');" />
48
- <input type="button" value="email" class="quick-button" onclick="quick_panel('email');" />
49
- <input type="button" value="email*" class="quick-button" onclick="quick_panel('email*');" />
50
- <input type="button" value="textarea" class="quick-button" onclick="quick_panel('textarea');" />
51
- <input type="button" value="textarea*" class="quick-button" onclick="quick_panel('textarea*');" />
52
- <input type="button" value="submit" class="quick-button" onclick="quick_panel('submit');" />
53
- <div id="quick-panel"></div>
54
<textarea id="wpcf7-form" name="wpcf7-form" cols="100" rows="16"><?php echo htmlspecialchars($cf['form']); ?></textarea>
55
</div>
56
57
<div class="fieldset"><div class="legend"><?php _e('Mail template', 'wpcf7'); ?></div>
@@ -85,14 +86,40 @@
85
<script type="text/javascript">
86
//<![CDATA[
87
88
- function quick_panel(type) {
89
var quick_panel = document.getElementById('quick-panel');
90
if (! quick_panel) return;
91
92
- var valid_types = /^(text[*]?|email[*]?|textarea[*]?|submit)#x2F;;
93
- if (! valid_types.test(type)) return;
94
95
- quick_panel.innerHTML = '<div class="close" style="float: right;"><span onclick="document.getElementById(\'quick-panel\').style.display = \'none\';">X</span></div>';
96
quick_panel.innerHTML += '<div style="text-align: center; font-weight: bold; color: #555;"><code>[' + type + ']</code></div>';
97
quick_panel.innerHTML += '<input type="hidden" name="qp-type" value="' + type + '" />';
98
@@ -102,44 +129,53 @@
102
case 'email':
103
case 'email*':
104
quick_panel.innerHTML += '<table><tbody>'
105
- + '<tr><td>name= <input type="text" name="qp-name" id="qp-name" class="required" onchange="create_tag();" /></td></tr>'
106
- + '<tr><td>size= <input type="text" name="qp-size" onchange="create_tag();" /></td>'
107
- + '<td>maxlength= <input type="text" name="qp-maxlength" onchange="create_tag();" /></td></tr>'
108
- + '<tr><td>id= <input type="text" name="qp-id" onchange="create_tag();" /></td>'
109
- + '<td>class= <input type="text" name="qp-class" onchange="create_tag();" /></td></tr>'
110
- + '<td><?php _e('Default value', 'wpcf7'); ?> <input type="text" name="qp-default" onchange="create_tag();" /></td></tr>'
111
+ '</tbody></table>';
112
break;
113
case 'textarea':
114
case 'textarea*':
115
quick_panel.innerHTML += '<table><tbody>'
116
- + '<tr><td>name= <input type="text" name="qp-name" id="qp-name" class="required" onchange="create_tag();" /></td></tr>'
117
- + '<tr><td>cols= <input type="text" name="qp-cols" onchange="create_tag();" /></td>'
118
- + '<td>rows= <input type="text" name="qp-rows" onchange="create_tag();" /></td></tr>'
119
- + '<tr><td>id= <input type="text" name="qp-id" onchange="create_tag();" /></td>'
120
- + '<td>class= <input type="text" name="qp-class" onchange="create_tag();" /></td></tr>'
121
- + '<td><?php _e('Default value', 'wpcf7'); ?> <input type="text" name="qp-default" onchange="create_tag();" /></td></tr>'
122
+ '</tbody></table>';
123
break;
124
case 'submit':
125
quick_panel.innerHTML += '<table><tbody>'
126
- + '<tr><td><?php _e('Label', 'wpcf7'); ?> <input type="text" name="qp-label" onchange="create_tag();" /></td></tr>'
127
+ '</tbody></table>';
128
break;
129
}
130
131
quick_panel.innerHTML += '<div style="margin: 10px 0 0; text-align: center;">'
132
- + '<input type="text" name="qp-insert" style="width: 80%; border: none; font-family: monospace;" /> '
133
- + '<input type="button" value="<?php _e('Insert', 'wpcf7'); ?>" class="qp-button" onclick="insert_tag(this.form.elements[\'qp-insert\'].value);" />'
134
+ '</div>';
135
quick_panel.style.display = 'block';
136
- create_tag(true);
137
var qp_name = document.getElementById('qp-name');
138
if (qp_name)
139
qp_name.focus();
140
}
141
142
- function create_tag(initial) {
143
var form = document.getElementById('wpcf7-admin-form-element');
144
if (! form) return;
145
@@ -150,73 +186,66 @@
150
if (! type) return;
151
152
type = type.value;
153
- var valid_types = /^(text[*]?|email[*]?|textarea[*]?|submit)#x2F;;
154
- if (! valid_types.test(type)) return;
155
156
var tag = '[' + type;
157
158
if ('submit' == type) {
159
var label = form.elements['qp-label'];
160
if (label && '' != label.value)
161
- tag += ' ' + wrap_quote(label.value);
162
} else {
163
var name = form.elements['qp-name'];
164
- if (name && ! initial) {
165
name.value = name.value.replace(/[^0-9a-zA-Z:._-]/g, '');
166
name.value = name.value.replace(/^[^a-zA-Z]+/, '');
167
if ('' == name.value)
168
- name.value = 'form_' + Math.floor(Math.random() * 1000);
169
tag += ' ' + name.value;
170
}
171
172
- var has_option = 0;
173
-
174
- if (/^(text[*]?|email[*]?)#x2F;.test(type)) {
175
-
176
- var size = form.elements['qp-size'];
177
- if (size)
178
- size.value = integer(size.value);
179
- var maxlength = form.elements['qp-maxlength'];
180
- if (maxlength)
181
- maxlength.value = integer(maxlength.value);
182
- if (size && '' != size.value && maxlength && '' != maxlength.value) {
183
- tag += ' ' + size.value + '/' + maxlength.value;
184
- has_option = 1;
185
- } else if (size && '' != size.value) {
186
- tag += ' ' + size.value + '/';
187
- has_option = 1;
188
- } else if (maxlength && '' != maxlength.value) {
189
- tag += ' ' + '/' + maxlength.value;
190
- has_option = 1;
191
- }
192
-
193
- } else if (/^textarea[*]?#x2F;.test(type)) {
194
-
195
- var cols = form.elements['qp-cols'];
196
- if (cols)
197
- cols.value = integer(cols.value);
198
- var rows = form.elements['qp-rows'];
199
- if (rows)
200
- rows.value = integer(rows.value);
201
- if (cols && '' != cols.value && rows && '' != rows.value) {
202
- tag += ' ' + cols.value + 'x' + rows.value;
203
- has_option = 1;
204
- } else if (cols && '' != cols.value) {
205
- tag += ' ' + cols.value + 'x';
206
- has_option = 1;
207
- } else if (rows && '' != rows.value) {
208
- tag += ' ' + 'x' + rows.value;
209
- has_option = 1;
210
- }
211
-
212
}
213
214
var id = form.elements['qp-id'];
215
if (id) {
216
- id.value = cdata(id.value);
217
if ('' != id.value) {
218
tag += ' id:' + id.value;
219
- has_option = 1;
220
}
221
}
222
@@ -224,20 +253,21 @@
224
if (klass) {
225
var klass_list = klass.value.split(' ');
226
for (var i = 0; i < klass_list.length; i++) {
227
- var klass_value = cdata(klass_list[i]);
228
if ('' != klass_value) {
229
tag += ' class:' + klass_value;
230
- has_option = 1;
231
}
232
}
233
}
234
235
var default_value = form.elements['qp-default'];
236
if (default_value && '' != default_value.value) {
237
- if (has_option)
238
- tag += ' ' + wrap_quote(default_value.value);
239
- else
240
- tag += ' default ' + wrap_quote(default_value.value);
241
}
242
}
243
@@ -245,15 +275,15 @@
245
insert.value = tag;
246
}
247
248
- function integer(str) {
249
return str.replace(/[^0-9]/g, '');
250
}
251
252
- function cdata(str) {
253
return str.replace(/[^-0-9a-zA-Z_]/g, '');
254
}
255
256
- function wrap_quote(str) {
257
if (-1 == str.indexOf('"'))
258
return '"' + str + '"';
259
else if (-1 == str.indexOf("'"))
@@ -262,7 +292,7 @@
262
return '"' + str.replace('"', '') + '"';
263
}
264
265
- function insert_tag(tag) {
266
var f = document.getElementById('wpcf7-form');
267
if (! f) return;
268
@@ -287,7 +317,7 @@
287
}
288
}
289
290
- function update_anchor(title) {
291
if (title == null) title = document.getElementById('wpcf7-title').value;
292
var anchor = document.getElementById('contact-form-anchor-text');
293
if (anchor) {
@@ -297,7 +327,7 @@
297
}
298
}
299
300
- update_anchor();
301
//]]>
302
</script>
303
32
33
<div class="fieldset">
34
<label for="wpcf7-title"><?php _e('Title', 'wpcf7'); ?></label>
35
+ <input type="text" id="wpcf7-title" name="wpcf7-title" size="40" value="<?php echo htmlspecialchars($cf['title']); ?>" onchange="wpcf7UpdateAnchor(this.value);" />
36
37
<?php if (! $initial) : ?>
38
<p class="important">
43
</div>
44
45
<div class="fieldset"><div class="legend"><?php _e('Form content', 'wpcf7'); ?></div>
46
<textarea id="wpcf7-form" name="wpcf7-form" cols="100" rows="16"><?php echo htmlspecialchars($cf['form']); ?></textarea>
47
+ <input type="button" value="text" class="quick-button" onclick="wpcf7QuickPanel('text');" style="background-color: #cee4d4;" />
48
+ <input type="button" value="text*" class="quick-button" onclick="wpcf7QuickPanel('text*');" style="background-color: #cee4d4;" />
49
+ <input type="button" value="email" class="quick-button" onclick="wpcf7QuickPanel('email');" style="background-color: #e6edb4;" />
50
+ <input type="button" value="email*" class="quick-button" onclick="wpcf7QuickPanel('email*');" style="background-color: #e6edb4;" />
51
+ <input type="button" value="textarea" class="quick-button" onclick="wpcf7QuickPanel('textarea');" style="background-color: #bfe7e5;" />
52
+ <input type="button" value="textarea*" class="quick-button" onclick="wpcf7QuickPanel('textarea*');" style="background-color: #bfe7e5;" />
53
+ <input type="button" value="select" class="quick-button" onclick="wpcf7QuickPanel('select');" style="background-color: #cbd5e8;" />
54
+ <input type="button" value="submit" class="quick-button" onclick="wpcf7QuickPanel('submit');" style="background-color: #e5d6c2;" />
55
+ <div id="quick-panel"></div>
56
</div>
57
58
<div class="fieldset"><div class="legend"><?php _e('Mail template', 'wpcf7'); ?></div>
86
<script type="text/javascript">
87
//<![CDATA[
88
89
+ function wpcf7ValidateType(type) {
90
+ var valid_types = /^(text[*]?|email[*]?|textarea[*]?|select|submit)#x2F;;
91
+ return valid_types.test(type);
92
+ }
93
+
94
+ function wpcf7QuickPanel(type) {
95
var quick_panel = document.getElementById('quick-panel');
96
if (! quick_panel) return;
97
98
+ if (! wpcf7ValidateType(type)) return;
99
+
100
+ // Style
101
+ switch (type) {
102
+ case 'text':
103
+ case 'text*':
104
+ quick_panel.style.backgroundColor = '#cee4d4';
105
+ break;
106
+ case 'email':
107
+ case 'email*':
108
+ quick_panel.style.backgroundColor = '#e6edb4';
109
+ break;
110
+ case 'textarea':
111
+ case 'textarea*':
112
+ quick_panel.style.backgroundColor = '#bfe7e5';
113
+ break;
114
+ case 'select':
115
+ quick_panel.style.backgroundColor = '#cbd5e8';
116
+ break;
117
+ case 'submit':
118
+ quick_panel.style.backgroundColor = '#e5d6c2';
119
+ break;
120
+ }
121
122
+ quick_panel.innerHTML = '<div class="close" style="float: right;"><span onclick="document.getElementById(\'quick-panel\').style.display = \'none\';">&#215;</span></div>';
123
quick_panel.innerHTML += '<div style="text-align: center; font-weight: bold; color: #555;"><code>[' + type + ']</code></div>';
124
quick_panel.innerHTML += '<input type="hidden" name="qp-type" value="' + type + '" />';
125
129
case 'email':
130
case 'email*':
131
quick_panel.innerHTML += '<table><tbody>'
132
+ + '<tr><th>name=</th><td><input type="text" name="qp-name" id="qp-name" class="required" value="edit-me" onchange="wpcf7CreateTag();" /></td></tr>'
133
+ + '<tr><th>size=</th><td><input type="text" name="qp-size" onchange="wpcf7CreateTag();" /></td>'
134
+ + '<th>maxlength=</th><td><input type="text" name="qp-maxlength" onchange="wpcf7CreateTag();" /></td></tr>'
135
+ + '<tr><th>id=</th><td><input type="text" name="qp-id" onchange="wpcf7CreateTag();" /></td>'
136
+ + '<th>class=</th><td><input type="text" name="qp-class" onchange="wpcf7CreateTag();" /></td></tr>'
137
+ + '<tr><th><?php _e('Default value', 'wpcf7'); ?></th><td><input type="text" name="qp-default" onchange="wpcf7CreateTag();" /></td></tr>'
138
+ '</tbody></table>';
139
break;
140
case 'textarea':
141
case 'textarea*':
142
quick_panel.innerHTML += '<table><tbody>'
143
+ + '<tr><th>name=</th><td><input type="text" name="qp-name" id="qp-name" class="required" value="edit-me" onchange="wpcf7CreateTag();" /></td></tr>'
144
+ + '<tr><th>cols=</th><td><input type="text" name="qp-cols" onchange="wpcf7CreateTag();" /></td>'
145
+ + '<th>rows=</th><td><input type="text" name="qp-rows" onchange="wpcf7CreateTag();" /></td></tr>'
146
+ + '<tr><th>id=</th><td><input type="text" name="qp-id" onchange="wpcf7CreateTag();" /></td>'
147
+ + '<th>class=</th><td><input type="text" name="qp-class" onchange="wpcf7CreateTag();" /></td></tr>'
148
+ + '<tr><th><?php _e('Default value', 'wpcf7'); ?></th><td><input type="text" name="qp-default" onchange="wpcf7CreateTag();" /></td></tr>'
149
+ + '</tbody></table>';
150
+ break;
151
+ case 'select':
152
+ quick_panel.innerHTML += '<table><tbody>'
153
+ + '<tr><th>name=</th><td><input type="text" name="qp-name" id="qp-name" class="required" value="edit-me" onchange="wpcf7CreateTag();" /></td></tr>'
154
+ + '<tr><th>id=</th><td><input type="text" name="qp-id" onchange="wpcf7CreateTag();" /></td>'
155
+ + '<th>class=</th><td><input type="text" name="qp-class" onchange="wpcf7CreateTag();" /></td></tr>'
156
+ + '<tr><th><?php _e('Choices', 'wpcf7'); ?></th><td><textarea name="qp-default" onchange="wpcf7CreateTag();" rows="6"></textarea><br />'
157
+ + '<span style="font-size: smaller;"><?php _e('* One choice per line.', 'wpcf7'); ?></span></td></tr>'
158
+ '</tbody></table>';
159
break;
160
case 'submit':
161
quick_panel.innerHTML += '<table><tbody>'
162
+ + '<tr><th><?php _e('Label', 'wpcf7'); ?></th><td><input type="text" name="qp-label" onchange="wpcf7CreateTag();" /></td></tr>'
163
+ '</tbody></table>';
164
break;
165
}
166
167
quick_panel.innerHTML += '<div style="margin: 10px 0 0; text-align: center;">'
168
+ + '<input type="text" name="qp-insert" style="width: 80%; border: none; font-family: monospace;" tabindex="32767" /> '
169
+ + '<input type="button" value="<?php _e('Insert', 'wpcf7'); ?>" class="qp-button" onclick="wpcf7InsertTag(this.form.elements[\'qp-insert\'].value);" style="width: auto;" />'
170
+ '</div>';
171
quick_panel.style.display = 'block';
172
+ wpcf7CreateTag();
173
var qp_name = document.getElementById('qp-name');
174
if (qp_name)
175
qp_name.focus();
176
}
177
178
+ function wpcf7CreateTag() {
179
var form = document.getElementById('wpcf7-admin-form-element');
180
if (! form) return;
181
186
if (! type) return;
187
188
type = type.value;
189
+ if (! wpcf7ValidateType(type)) return;
190
191
var tag = '[' + type;
192
193
if ('submit' == type) {
194
var label = form.elements['qp-label'];
195
if (label && '' != label.value)
196
+ tag += ' ' + wpcf7WrapQuote(label.value);
197
} else {
198
var name = form.elements['qp-name'];
199
+ if (name) {
200
name.value = name.value.replace(/[^0-9a-zA-Z:._-]/g, '');
201
name.value = name.value.replace(/^[^a-zA-Z]+/, '');
202
if ('' == name.value)
203
+ name.value = type.replace(/[*]#x2F;, '') + '_' + Math.floor(Math.random() * 1000);
204
tag += ' ' + name.value;
205
}
206
207
+ switch (type) {
208
+ case 'text':
209
+ case 'text*':
210
+ case 'email':
211
+ case 'email*':
212
+ var size = form.elements['qp-size'];
213
+ if (size)
214
+ size.value = wpcf7Integer(size.value);
215
+ var maxlength = form.elements['qp-maxlength'];
216
+ if (maxlength)
217
+ maxlength.value = wpcf7Integer(maxlength.value);
218
+ if (size && '' != size.value && maxlength && '' != maxlength.value) {
219
+ tag += ' ' + size.value + '/' + maxlength.value;
220
+ } else if (size && '' != size.value) {
221
+ tag += ' ' + size.value + '/';
222
+ } else if (maxlength && '' != maxlength.value) {
223
+ tag += ' ' + '/' + maxlength.value;
224
+ }
225
+ break;
226
+ case 'textarea':
227
+ case 'textarea*':
228
+ var cols = form.elements['qp-cols'];
229
+ if (cols)
230
+ cols.value = wpcf7Integer(cols.value);
231
+ var rows = form.elements['qp-rows'];
232
+ if (rows)
233
+ rows.value = wpcf7Integer(rows.value);
234
+ if (cols && '' != cols.value && rows && '' != rows.value) {
235
+ tag += ' ' + cols.value + 'x' + rows.value;
236
+ } else if (cols && '' != cols.value) {
237
+ tag += ' ' + cols.value + 'x';
238
+ } else if (rows && '' != rows.value) {
239
+ tag += ' ' + 'x' + rows.value;
240
+ }
241
+ break;
242
}
243
244
var id = form.elements['qp-id'];
245
if (id) {
246
+ id.value = wpcf7Cdata(id.value);
247
if ('' != id.value) {
248
tag += ' id:' + id.value;
249
}
250
}
251
253
if (klass) {
254
var klass_list = klass.value.split(' ');
255
for (var i = 0; i < klass_list.length; i++) {
256
+ var klass_value = wpcf7Cdata(klass_list[i]);
257
if ('' != klass_value) {
258
tag += ' class:' + klass_value;
259
}
260
}
261
}
262
263
var default_value = form.elements['qp-default'];
264
if (default_value && '' != default_value.value) {
265
+ var default_values = default_value.value.split("\n");
266
+ for (var i = 0; i < default_values.length; i++) {
267
+ default_values[i] = default_values[i].replace(/^\s+/, '').replace(/\s+#x2F;, '');
268
+ if ('' != default_values[i])
269
+ tag += ' ' + wpcf7WrapQuote(default_values[i]);
270
+ }
271
}
272
}
273
275
insert.value = tag;
276
}
277
278
+ function wpcf7Integer(str) {
279
return str.replace(/[^0-9]/g, '');
280
}
281
282
+ function wpcf7Cdata(str) {
283
return str.replace(/[^-0-9a-zA-Z_]/g, '');
284
}
285
286
+ function wpcf7WrapQuote(str) {
287
if (-1 == str.indexOf('"'))
288
return '"' + str + '"';
289
else if (-1 == str.indexOf("'"))
292
return '"' + str.replace('"', '') + '"';
293
}
294
295
+ function wpcf7InsertTag(tag) {
296
var f = document.getElementById('wpcf7-form');
297
if (! f) return;
298
317
}
318
}
319
320
+ function wpcf7UpdateAnchor(title) {
321
if (title == null) title = document.getElementById('wpcf7-title').value;
322
var anchor = document.getElementById('contact-form-anchor-text');
323
if (anchor) {
327
}
328
}
329
330
+ wpcf7UpdateAnchor();
331
//]]>
332
</script>
333
languages/wpcf7-ja.mo CHANGED
Binary file
languages/wpcf7-ja.po CHANGED
@@ -2,7 +2,7 @@ msgid ""
2
msgstr ""
3
"Project-Id-Version: WP Contact Form 7\n"
4
"POT-Creation-Date: \n"
5
- "PO-Revision-Date: 2007-08-16 19:20+0900\n"
6
"Last-Translator: Takayuki Miyoshi <takayukister@gmail.com>\n"
7
"Language-Team: Takayuki Miyoshi <takayukister@gmail.com>\n"
8
"MIME-Version: 1.0\n"
@@ -15,79 +15,76 @@ msgstr ""
15
"X-Poedit-Basepath: ../..\n"
16
"X-Poedit-SearchPath-0: contact-form-7\n"
17
18
- #: contact-form-7/wp-contact-form-7.php:88
19
- #: contact-form-7/wp-contact-form-7.php:161
20
msgid "Contact form"
21
msgstr "コンタクトフォーム"
22
23
- #: contact-form-7/wp-contact-form-7.php:117
24
#: contact-form-7/includes/admin-panel.php:5
25
msgid "Contact Form 7"
26
msgstr "Contact Form 7"
27
28
- #: contact-form-7/wp-contact-form-7.php:137
29
#, php-format
30
msgid "Contact form \"%s\" deleted. "
31
msgstr "コンタクトフォーム \"%s\" が削除されました。"
32
33
- #: contact-form-7/wp-contact-form-7.php:153
34
#, php-format
35
msgid "Contact form \"%s\" saved. "
36
msgstr "コンタクトフォーム \"%s\" が保存されました。"
37
38
- #: contact-form-7/wp-contact-form-7.php:182
39
msgid "Your Name"
40
msgstr "お名前"
41
42
- #: contact-form-7/wp-contact-form-7.php:182
43
- #: contact-form-7/wp-contact-form-7.php:184
44
msgid "(required)"
45
msgstr "(必須)"
46
47
- #: contact-form-7/wp-contact-form-7.php:184
48
msgid "Your Email"
49
msgstr "メールアドレス"
50
51
- #: contact-form-7/wp-contact-form-7.php:186
52
msgid "Subject"
53
msgstr "題名"
54
55
- #: contact-form-7/wp-contact-form-7.php:188
56
msgid "Your Message"
57
msgstr "メッセージ本文"
58
59
- #: contact-form-7/wp-contact-form-7.php:190
60
- #: contact-form-7/wp-contact-form-7.php:514
61
msgid "Send"
62
msgstr "送信"
63
64
- #: contact-form-7/wp-contact-form-7.php:296
65
- #: contact-form-7/wp-contact-form-7.php:303
66
- #, php-format
67
- msgid "Please fill the required field: %s "
68
- msgstr "必須項目に記入もれがあります: %s"
69
-
70
- #: contact-form-7/wp-contact-form-7.php:306
71
- #, php-format
72
- msgid "Email address seems invalid: %s "
73
- msgstr "メールアドレスの形式が正しくないようです: %s "
74
-
75
- #: contact-form-7/wp-contact-form-7.php:315
76
msgid "Your message was sent successfully. Thanks."
77
msgstr "あなたのメッセージは送信されました。ありがとうございました。"
78
79
- #: contact-form-7/wp-contact-form-7.php:317
80
msgid "Failed to send your message. Please try later or contact administrator by other way."
81
msgstr "メッセージの送信に失敗しました。間をおいてもう一度お試しいただくか、別の手段で管理者にお問い合わせ下さい。"
82
83
- #: contact-form-7/wp-contact-form-7.php:361
84
- msgid "Email address seems invalid."
85
- msgstr "メールアドレスの形式が正しくないようです。"
86
87
- #: contact-form-7/wp-contact-form-7.php:368
88
msgid "Please fill the required field."
89
msgstr "必須項目に記入もれがあります。"
90
91
#: contact-form-7/includes/admin-panel.php:19
92
#: contact-form-7/includes/admin-panel.php:22
93
msgid "Add new"
@@ -105,39 +102,39 @@ msgstr "次のコードをコピーして投稿の本文中にペーストして
105
msgid "Form content"
106
msgstr "フォームの内容"
107
108
- #: contact-form-7/includes/admin-panel.php:57
109
msgid "Mail template"
110
msgstr "メールのテンプレート"
111
112
- #: contact-form-7/includes/admin-panel.php:58
113
msgid "Subject field:"
114
msgstr "題名欄:"
115
116
- #: contact-form-7/includes/admin-panel.php:60
117
msgid "Sender field:"
118
msgstr "送信者欄:"
119
120
- #: contact-form-7/includes/admin-panel.php:62
121
msgid "Message body:"
122
msgstr "メッセージ本文:"
123
124
- #: contact-form-7/includes/admin-panel.php:66
125
msgid "Options"
126
msgstr "オプション"
127
128
- #: contact-form-7/includes/admin-panel.php:67
129
msgid "Recipient address:"
130
msgstr "受信者アドレス:"
131
132
- #: contact-form-7/includes/admin-panel.php:72
133
msgid "Save"
134
msgstr "保存"
135
136
- #: contact-form-7/includes/admin-panel.php:79
137
msgid "Delete this contact form"
138
msgstr "このコンタクトフォームを削除"
139
140
- #: contact-form-7/includes/admin-panel.php:80
141
msgid ""
142
"You are about to delete this contact form.\n"
143
" 'Cancel' to stop, 'OK' to delete."
@@ -145,16 +142,24 @@ msgstr ""
145
"このコンタクトフォームを削除しようとしています。\n"
146
" 'キャンセル' で中止、 'OK' で削除します。"
147
148
- #: contact-form-7/includes/admin-panel.php:110
149
- #: contact-form-7/includes/admin-panel.php:121
150
msgid "Default value"
151
msgstr "デフォルト値"
152
153
- #: contact-form-7/includes/admin-panel.php:126
154
msgid "Label"
155
msgstr "ラベル"
156
157
- #: contact-form-7/includes/admin-panel.php:133
158
msgid "Insert"
159
msgstr "挿入"
160
2
msgstr ""
3
"Project-Id-Version: WP Contact Form 7\n"
4
"POT-Creation-Date: \n"
5
+ "PO-Revision-Date: 2007-08-25 23:33+0900\n"
6
"Last-Translator: Takayuki Miyoshi <takayukister@gmail.com>\n"
7
"Language-Team: Takayuki Miyoshi <takayukister@gmail.com>\n"
8
"MIME-Version: 1.0\n"
15
"X-Poedit-Basepath: ../..\n"
16
"X-Poedit-SearchPath-0: contact-form-7\n"
17
18
+ #: contact-form-7/wp-contact-form-7.php:128
19
+ #: contact-form-7/wp-contact-form-7.php:201
20
msgid "Contact form"
21
msgstr "コンタクトフォーム"
22
23
+ #: contact-form-7/wp-contact-form-7.php:157
24
#: contact-form-7/includes/admin-panel.php:5
25
msgid "Contact Form 7"
26
msgstr "Contact Form 7"
27
28
+ #: contact-form-7/wp-contact-form-7.php:177
29
#, php-format
30
msgid "Contact form \"%s\" deleted. "
31
msgstr "コンタクトフォーム \"%s\" が削除されました。"
32
33
+ #: contact-form-7/wp-contact-form-7.php:193
34
#, php-format
35
msgid "Contact form \"%s\" saved. "
36
msgstr "コンタクトフォーム \"%s\" が保存されました。"
37
38
+ #: contact-form-7/wp-contact-form-7.php:222
39
msgid "Your Name"
40
msgstr "お名前"
41
42
+ #: contact-form-7/wp-contact-form-7.php:222
43
+ #: contact-form-7/wp-contact-form-7.php:224
44
msgid "(required)"
45
msgstr "(必須)"
46
47
+ #: contact-form-7/wp-contact-form-7.php:224
48
msgid "Your Email"
49
msgstr "メールアドレス"
50
51
+ #: contact-form-7/wp-contact-form-7.php:226
52
msgid "Subject"
53
msgstr "題名"
54
55
+ #: contact-form-7/wp-contact-form-7.php:228
56
msgid "Your Message"
57
msgstr "メッセージ本文"
58
59
+ #: contact-form-7/wp-contact-form-7.php:230
60
+ #: contact-form-7/wp-contact-form-7.php:593
61
msgid "Send"
62
msgstr "送信"
63
64
+ #: contact-form-7/wp-contact-form-7.php:249
65
msgid "Your message was sent successfully. Thanks."
66
msgstr "あなたのメッセージは送信されました。ありがとうございました。"
67
68
+ #: contact-form-7/wp-contact-form-7.php:251
69
msgid "Failed to send your message. Please try later or contact administrator by other way."
70
msgstr "メッセージの送信に失敗しました。間をおいてもう一度お試しいただくか、別の手段で管理者にお問い合わせ下さい。"
71
72
+ #: contact-form-7/wp-contact-form-7.php:324
73
+ #: contact-form-7/wp-contact-form-7.php:424
74
+ msgid "Validation errors occurred. Please confirm the fields and submit it again."
75
+ msgstr "入力内容に不備があります。確認してもう一度送信してください。"
76
77
+ #: contact-form-7/wp-contact-form-7.php:351
78
+ #: contact-form-7/wp-contact-form-7.php:358
79
+ #: contact-form-7/wp-contact-form-7.php:409
80
msgid "Please fill the required field."
81
msgstr "必須項目に記入もれがあります。"
82
83
+ #: contact-form-7/wp-contact-form-7.php:361
84
+ #: contact-form-7/wp-contact-form-7.php:402
85
+ msgid "Email address seems invalid."
86
+ msgstr "メールアドレスの形式が正しくないようです。"
87
+
88
#: contact-form-7/includes/admin-panel.php:19
89
#: contact-form-7/includes/admin-panel.php:22
90
msgid "Add new"
102
msgid "Form content"
103
msgstr "フォームの内容"
104
105
+ #: contact-form-7/includes/admin-panel.php:58
106
msgid "Mail template"
107
msgstr "メールのテンプレート"
108
109
+ #: contact-form-7/includes/admin-panel.php:59
110
msgid "Subject field:"
111
msgstr "題名欄:"
112
113
+ #: contact-form-7/includes/admin-panel.php:61
114
msgid "Sender field:"
115
msgstr "送信者欄:"
116
117
+ #: contact-form-7/includes/admin-panel.php:63
118
msgid "Message body:"
119
msgstr "メッセージ本文:"
120
121
+ #: contact-form-7/includes/admin-panel.php:67
122
msgid "Options"
123
msgstr "オプション"
124
125
+ #: contact-form-7/includes/admin-panel.php:68
126
msgid "Recipient address:"
127
msgstr "受信者アドレス:"
128
129
+ #: contact-form-7/includes/admin-panel.php:73
130
msgid "Save"
131
msgstr "保存"
132
133
+ #: contact-form-7/includes/admin-panel.php:80
134
msgid "Delete this contact form"
135
msgstr "このコンタクトフォームを削除"
136
137
+ #: contact-form-7/includes/admin-panel.php:81
138
msgid ""
139
"You are about to delete this contact form.\n"
140
" 'Cancel' to stop, 'OK' to delete."
142
"このコンタクトフォームを削除しようとしています。\n"
143
" 'キャンセル' で中止、 'OK' で削除します。"
144
145
+ #: contact-form-7/includes/admin-panel.php:137
146
+ #: contact-form-7/includes/admin-panel.php:148
147
msgid "Default value"
148
msgstr "デフォルト値"
149
150
+ #: contact-form-7/includes/admin-panel.php:156
151
+ msgid "Choices"
152
+ msgstr "選択項目"
153
+
154
+ #: contact-form-7/includes/admin-panel.php:157
155
+ msgid "* One choice per line."
156
+ msgstr "* 1行ごとに分けて入力してください。"
157
+
158
+ #: contact-form-7/includes/admin-panel.php:162
159
msgid "Label"
160
msgstr "ラベル"
161
162
+ #: contact-form-7/includes/admin-panel.php:169
163
msgid "Insert"
164
msgstr "挿入"
165
stylesheet.css CHANGED
@@ -1,24 +1,23 @@
1
div.wpcf7 {
2
- padding: 1em 0;
3
}
4
5
- div#wpcf7-response-output {
6
- margin: 0.5em;
7
}
8
9
div.wpcf7-mail-sent-ok {
10
- border: 1px solid #398f14;
11
- padding: 0.2em 1em;
12
}
13
14
div.wpcf7-mail-sent-ng {
15
- border: 1px solid #ff0000;
16
- padding: 0.2em 1em;
17
}
18
19
div.wpcf7-validation-errors {
20
- border: 1px solid #f7e700;
21
- padding: 0.2em 1em;
22
}
23
24
span.wpcf7-not-valid-tip {
@@ -33,6 +32,12 @@ span.wpcf7-not-valid-tip {
33
padding: 2px;
34
}
35
36
input.wpcf7-email-not-valid {
37
}
38
1
div.wpcf7 {
2
+ margin: 0;
3
+ padding: 0;
4
}
5
6
+ div.wpcf7-response-output {
7
+ margin: 2em 0.5em 1em;
8
+ padding: 0.2em 1em;
9
}
10
11
div.wpcf7-mail-sent-ok {
12
+ border: 2px solid #398f14;
13
}
14
15
div.wpcf7-mail-sent-ng {
16
+ border: 2px solid #ff0000;
17
}
18
19
div.wpcf7-validation-errors {
20
+ border: 2px solid #f7e700;
21
}
22
23
span.wpcf7-not-valid-tip {
32
padding: 2px;
33
}
34
35
+ span.wpcf7-not-valid-tip-no-ajax {
36
+ color: #f00;
37
+ font-size: 10pt;
38
+ display: block;
39
+ }
40
+
41
input.wpcf7-email-not-valid {
42
}
43
wp-contact-form-7.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Contact Form 7
4
Plugin URI: http://ideasilo.wordpress.com/2007/04/30/contact-form-7/
5
Description: Just another contact form plugin. Simple but flexible.
6
Author: Takayuki Miyoshi
7
- Version: 1.2
8
Author URI: http://ideasilo.wordpress.com/
9
*/
10
@@ -30,28 +30,68 @@ class tam_contact_form_seven {
30
var $contact_forms;
31
32
function tam_contact_form_seven() {
33
add_action('activate_' . strtr(plugin_basename(__FILE__), '\\', '/'), array(&$this, 'set_initial'));
34
add_action('plugins_loaded', array(&$this, 'load_plugin_textdomain'), 20);
35
add_action('admin_menu', array(&$this, 'add_pages'));
36
add_action('admin_head', array(&$this, 'admin_page_stylesheet'));
37
- add_action('wp_head', array(&$this, 'stylesheet'));
38
- add_action('wp_head', array(&$this, 'javascript'));
39
add_action('wp_print_scripts', array(&$this, 'load_js'));
40
add_action('init', array(&$this, 'ajax_json_echo'));
41
- add_filter('the_content', array(&$this, 'the_content_filter'));
42
}
43
44
function ajax_json_echo() {
45
if ('POST' == $_SERVER['REQUEST_METHOD'] && isset($_GET['wpcf7']) && 'json' == $_GET['wpcf7']) {
46
if (isset($_POST['_wpcf7'])) {
47
$id = (int) $_POST['_wpcf7'];
48
$contact_forms = $this->contact_forms();
49
if ($cf = $contact_forms[$id]) {
50
$cf = stripslashes_deep($cf);
51
if ($this->mail($cf)) {
52
- echo '{ mailSent: 1, message: "' . $this->default_mail_result_message(true) . '" }';
53
} else {
54
- echo '{ mailSent: 0, message: "' . $this->default_mail_result_message(false) . '" }';
55
}
56
}
57
}
@@ -187,7 +227,7 @@ class tam_contact_form_seven {
187
$template .= ' [text your-subject] </label></p>' . "\n\n";
188
$template .= '<p><label>' . __('Your Message', 'wpcf7') . '<br />' . "\n";
189
$template .= ' [textarea your-message] </label></p>' . "\n\n";
190
- $template .= '[submit "' . __('Send', 'wpcf7') . '"]';
191
return $template;
192
}
193
@@ -202,9 +242,20 @@ class tam_contact_form_seven {
202
$recipient = get_option('admin_email');
203
return compact('recipient');
204
}
205
206
/* Post content filtering */
207
208
function the_content_filter($content) {
209
// Form submitted?
210
if (isset($_POST['_wpcf7'])) {
@@ -216,67 +267,72 @@ class tam_contact_form_seven {
216
$validation = $this->validate_form_elements($fes);
217
if ($validation['valid']) {
218
if ($this->mail($cf)) {
219
- $_POST['_wpcf7_mail_sent'] = array('id' => $id, 'ok' => true, 'message' => $this->default_mail_result_message(true));
220
} else {
221
- $_POST['_wpcf7_mail_sent'] = array('id' => $id, 'ok' => false, 'message' => $this->default_mail_result_message(false));
222
}
223
} else {
224
$_POST['_wpcf7_validation_errors'] = array('id' => $id, 'messages' => $validation['reason']);
225
}
226
}
227
}
228
229
$regex = '/\[\s*contact-form\s+(\d+)(?:\s+.*?)?\s*\]/';
230
- if (is_singular())
231
- return preg_replace_callback($regex, array(&$this, 'the_content_filter_callback'), $content, 1);
232
- else
233
- return preg_replace($regex, '', $content);
234
}
235
236
function the_content_filter_callback($matches) {
237
$contact_forms = $this->contact_forms();
238
239
$id = (int) $matches[1];
240
if (! ($cf = $contact_forms[$id])) return $matches[0];
241
-
242
- if (isset($_POST['_wpcf7'])) {
243
- if ((int) $_POST['_wpcf7'] == $id)
244
- $_POST['_wpcf7_submitted'] = 1;
245
- else
246
- unset($_POST['_wpcf7_submitted']);
247
- }
248
-
249
$cf = stripslashes_deep($cf);
250
251
- $form_content = $this->form_elements($cf['form']);
252
253
- $form = '<div class="wpcf7" id="wpcf7_' . $id . '">';
254
255
- $form .= '<form action="' . get_permalink() . '#wpcf7_' . $id . '" method="post" id="wpcf7_the_form">';
256
$form .= '<input type="hidden" name="_wpcf7" value="' . $id . '" />';
257
- $form .= $form_content;
258
$form .= '</form>';
259
260
- if (isset($_POST['_wpcf7_mail_sent']) && $_POST['_wpcf7_mail_sent']['id'] == $id) {
261
- if ($_POST['_wpcf7_mail_sent']['ok']) {
262
- $clsss = ' class="wpcf7-mail-sent-ok"';
263
- $content = '<ul><li>' . $_POST['_wpcf7_mail_sent']['message'] . '</li></ul>';
264
- } else {
265
- $class = ' class="wpcf7-mail-sent-ng"';
266
- $content = '<ul><li>' . $_POST['_wpcf7_mail_sent']['message'] . '</li></ul>';
267
- }
268
- } elseif (isset($_POST['_wpcf7_validation_errors']) && $_POST['_wpcf7_validation_errors']['id'] == $id) {
269
- $class = ' class="wpcf7-validation-errors"';
270
- $content = '';
271
- foreach ($_POST['_wpcf7_validation_errors']['messages'] as $err) {
272
- $content .= '<li>' . $err . '</li>';
273
}
274
- $content = '<ul>' . $content . '</ul>';
275
}
276
277
- $form .= '<div id="wpcf7-response-output"' . $class . '>' . $content . '</div>';
278
279
$form .= '</div>';
280
return $form;
281
}
282
@@ -287,61 +343,44 @@ class tam_contact_form_seven {
287
foreach ($form_elements as $fe) {
288
$type = $fe['type'];
289
$name = $fe['name'];
290
- $title = $fe['title'] ? $fe['title'] : $name;
291
292
// Required item (*)
293
if (preg_match('/^(?:text|textarea)[*]#x2F;', $type)) {
294
if (empty($_POST[$name])) {
295
$valid = false;
296
- $reason[] = sprintf(__('Please fill the required field: %s ', 'wpcf7'), $title);
297
}
298
}
299
300
if (preg_match('/^email[*]?#x2F;', $type)) {
301
if ('*' == substr($type, -1) && empty($_POST[$name])) {
302
$valid = false;
303
- $reason[] = sprintf(__('Please fill the required field: %s ', 'wpcf7'), $title);
304
} elseif (! is_email($_POST[$name])) {
305
$valid = false;
306
- $reason[] = sprintf(__('Email address seems invalid: %s ', 'wpcf7'), $title);
307
}
308
}
309
}
310
return compact('valid', 'reason');
311
}
312
313
- function default_mail_result_message($ok = true) {
314
- if ($ok)
315
- return __('Your message was sent successfully. Thanks.', 'wpcf7');
316
- else
317
- return __('Failed to send your message. Please try later or contact administrator by other way.', 'wpcf7');
318
- }
319
-
320
- function stylesheet() {
321
- if (! is_singular())
322
- return;
323
-
324
$stylesheet_url = get_option('siteurl') . '/wp-content/plugins/contact-form-7/stylesheet.css';
325
echo '<link rel="stylesheet" href="' . $stylesheet_url . '" type="text/css" />';
326
- }
327
-
328
- function javascript() {
329
- if (! is_singular())
330
- return;
331
332
- $override_url = get_permalink();
333
- if (false === strrchr($override_url, '?')) {
334
- $override_url .= '?wpcf7=json';
335
- } else {
336
- $override_url .= '&wpcf7=json';
337
- }
338
339
?>
340
<script type="text/javascript">
341
//<![CDATA[
342
343
$(document).ready(function() {
344
- $('#wpcf7_the_form').ajaxForm({
345
beforeSubmit: validate,
346
url: '<?php echo $override_url; ?>',
347
dataType: 'json',
@@ -352,7 +391,9 @@ $(document).ready(function() {
352
});
353
354
function validate(formData, jqForm, options) {
355
- $('#wpcf7-response-output').hide().empty().removeClass('wpcf7-mail-sent-ok wpcf7-mail-sent-ng');
356
var valid = true;
357
358
$('.wpcf7-validates-as-email', jqForm[0]).each(function() {
@@ -377,6 +418,12 @@ function validate(formData, jqForm, options) {
377
}
378
});
379
380
return valid;
381
}
382
@@ -396,13 +443,20 @@ function notValidTip(input, message) {
396
}
397
398
function processJson(data) {
399
- $('#wpcf7-response-output').hide().empty().removeClass('wpcf7-mail-sent-ok wpcf7-mail-sent-ng');
400
if (1 == data.mailSent) {
401
- $('#wpcf7-response-output').addClass('wpcf7-mail-sent-ok');
402
} else {
403
- $('#wpcf7-response-output').addClass('wpcf7-mail-sent-ng');
404
}
405
- $('#wpcf7-response-output').append(data.message).fadeIn('fast');
406
}
407
408
//]]>
@@ -411,18 +465,19 @@ function processJson(data) {
411
}
412
413
function load_js() {
414
- if (is_singular())
415
wp_enqueue_script('jquery-form');
416
}
417
418
/* Processing form element placeholders */
419
420
function form_elements($form, $replace = true) {
421
- $regex = '%\[\s*([a-z]+[*]?)(\s+[a-zA-Z][0-9a-zA-Z:._-]*)(\s*(?:"[^"]*"|\'[^\']*\'))?([-0-9a-zA-Z:_/\s]*)?(\s*(?:"[^"]*"|\'[^\']*\'))*\]%';
422
if ($replace) {
423
$form = preg_replace_callback($regex, array(&$this, 'form_element_replace_callback'), $form);
424
// Submit button
425
- $form = preg_replace_callback('/\[\s*submit(\s+(?:"[^"]*"|\'[^\']*\'))?\s*\]/', array(&$this, 'submit_replace_callback'), $form);
426
return $form;
427
} else {
428
$results = array();
@@ -435,7 +490,15 @@ function processJson(data) {
435
}
436
437
function form_element_replace_callback($matches) {
438
- extract((array) $this->form_element_parse($matches));
439
$atts = '';
440
if (is_array($options)) {
441
$id_array = preg_grep('%^id:[-0-9a-zA-Z_]+$%', $options);
@@ -461,48 +524,64 @@ function processJson(data) {
461
if ($class_att)
462
$atts .= ' class="' . trim($class_att) . '"';
463
}
464
$type = preg_replace('/[*]#x2F;', '', $type);
465
switch ($type) {
466
case 'text':
467
case 'email':
468
if (is_array($options)) {
469
- $size_maxlength_array = preg_grep('%^[0-9]*/[0-9]*$%', $options);
470
if ($size_maxlength = array_shift($size_maxlength_array)) {
471
- preg_match('%^([0-9]*)/([0-9]*)$%', $size_maxlength, $sm_matches);
472
if ($size = (int) $sm_matches[1])
473
$atts .= ' size="' . $size . '"';
474
if ($maxlength = (int) $sm_matches[2])
475
$atts .= ' maxlength="' . $maxlength . '"';
476
}
477
}
478
- if (isset($_POST['_wpcf7_mail_sent']) && $_POST['_wpcf7_mail_sent']['ok']) {
479
- $value = '';
480
- } elseif (isset($_POST['_wpcf7_submitted'])) {
481
- $value = $_POST[$name];
482
- } else {
483
- $value = array_shift($values);
484
- }
485
- return '<span style="position: relative;"><input type="text" name="' . $name . '" value="' . $value . '"' . $atts . ' /></span>';
486
break;
487
case 'textarea':
488
if (is_array($options)) {
489
- $cols_rows_array = preg_grep('%^[0-9]*x[0-9]*$%', $options);
490
if ($cols_rows = array_shift($cols_rows_array)) {
491
- preg_match('%^([0-9]*)x([0-9]*)$%', $cols_rows, $cr_matches);
492
if ($cols = (int) $cr_matches[1])
493
$atts .= ' cols="' . $cols . '"';
494
if ($rows = (int) $cr_matches[2])
495
$atts .= ' rows="' . $rows . '"';
496
}
497
}
498
- if (isset($_POST['_wpcf7_mail_sent']) && $_POST['_wpcf7_mail_sent']['ok']) {
499
- $value = '';
500
- } elseif (isset($_POST['_wpcf7_submitted'])) {
501
- $value = $_POST[$name];
502
- } else {
503
- $value = array_shift($values);
504
}
505
- return '<span style="position: relative;"><textarea name="' . $name . '"' . $atts . '>' . $value . '</textarea></span>';
506
break;
507
}
508
}
@@ -512,16 +591,19 @@ function processJson(data) {
512
$value = $this->strip_quote($matches[1]);
513
if (empty($value))
514
$value = __('Send', 'wpcf7');
515
- return '<input type="submit" value="' . $value . '" />';
516
}
517
518
function form_element_parse($element) {
519
$type = trim($element[1]);
520
$name = trim($element[2]);
521
- $title = $this->strip_quote($element[3]);
522
- $options = preg_split('/[\s]+/', trim($element[4]));
523
- $values = $this->strip_quote_deep(array_slice($element, 5));
524
- return compact('type', 'name', 'title', 'options', 'values');
525
}
526
527
function strip_quote($text) {
@@ -544,7 +626,7 @@ function processJson(data) {
544
return $result;
545
}
546
}
547
-
548
}
549
550
new tam_contact_form_seven();
4
Plugin URI: http://ideasilo.wordpress.com/2007/04/30/contact-form-7/
5
Description: Just another contact form plugin. Simple but flexible.
6
Author: Takayuki Miyoshi
7
+ Version: 1.3
8
Author URI: http://ideasilo.wordpress.com/
9
*/
10
30
var $contact_forms;
31
32
function tam_contact_form_seven() {
33
+ // This backslash replacement for Win32 will be unnecessary. See http://trac.wordpress.org/ticket/3002
34
add_action('activate_' . strtr(plugin_basename(__FILE__), '\\', '/'), array(&$this, 'set_initial'));
35
add_action('plugins_loaded', array(&$this, 'load_plugin_textdomain'), 20);
36
add_action('admin_menu', array(&$this, 'add_pages'));
37
add_action('admin_head', array(&$this, 'admin_page_stylesheet'));
38
+ add_action('wp_head', array(&$this, 'wp_head'));
39
add_action('wp_print_scripts', array(&$this, 'load_js'));
40
add_action('init', array(&$this, 'ajax_json_echo'));
41
+ add_filter('the_content', array(&$this, 'the_content_filter'), 9);
42
+ remove_filter('the_content', 'wpautop');
43
+ add_filter('the_content', array(&$this, 'wpautop_substitute'));
44
+ }
45
+
46
+ // Original wpautop function has harmful effect on formatting of form elements.
47
+ // This wpautop_substitute is a temporary substitution until original is patched.
48
+ // See http://trac.wordpress.org/ticket/4605
49
+ function wpautop_substitute($pee, $br = 1) {
50
+ $pee = $pee . "\n"; // just to make things a little easier, pad the end
51
+ $pee = preg_replace('|<br />\s*<br />|', "\n\n", $pee);
52
+ // Space things out a little
53
+ $allblocks = '(?:address|area|blockquote|caption|colgroup|dd|div|dl|dt|form|h[1-6]|li|map|math|ol|p|pre|table|tbody|td|tfoot|th|thead|tr|ul)';
54
+ $pee = preg_replace('!(<' . $allblocks . '[^>]*>)!', "\n$1", $pee);
55
+ $pee = preg_replace('!(</' . $allblocks . '>)!', "$1\n\n", $pee);
56
+ $pee = str_replace(array("\r\n", "\r"), "\n", $pee); // cross-platform newlines
57
+ $pee = preg_replace("/\n\n+/", "\n\n", $pee); // take care of duplicates
58
+ $pee = preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', "<p>$1</p>\n", $pee); // make paragraphs, including one at the end
59
+ $pee = preg_replace('|<p>\s*?</p>|', '', $pee); // under certain strange conditions it could create a P of entirely whitespace
60
+ $pee = preg_replace('!<p>([^<]+)\s*?(</(?:div|address|form)[^>]*>)!', "<p>$1</p>$2", $pee);
61
+ $pee = preg_replace( '|<p>|', "$1<p>", $pee );
62
+ $pee = preg_replace('!<p>\s*(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", $pee); // don't pee all over a tag
63
+ $pee = preg_replace("|<p>(<li.+?)</p>|", "$1", $pee); // problem with nested lists
64
+ $pee = preg_replace('|<p><blockquote([^>]*)>|i', "<blockquote$1><p>", $pee);
65
+ $pee = str_replace('</blockquote></p>', '</p></blockquote>', $pee);
66
+ $pee = preg_replace('!<p>\s*(</?' . $allblocks . '[^>]*>)!', "$1", $pee);
67
+ $pee = preg_replace('!(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", $pee);
68
+ if ($br) {
69
+ $pee = preg_replace('/<(script|style).*?<\/\\1>/se', 'str_replace("\n", "<WPPreserveNewline />", "\\0")', $pee);
70
+ $pee = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $pee); // optionally make line breaks
71
+ $pee = str_replace('<WPPreserveNewline />', "\n", $pee);
72
+ }
73
+ $pee = preg_replace('!(</?' . $allblocks . '[^>]*>)\s*<br />!', "$1", $pee);
74
+ $pee = preg_replace('!<br />(\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)!', '$1', $pee);
75
+ if (strpos($pee, '<pre') !== false)
76
+ $pee = preg_replace('!(<pre.*?>)(.*?)</pre>!ise', " stripslashes('$1') . stripslashes(clean_pre('$2')) . '</pre>' ", $pee);
77
+ $pee = preg_replace( "|\n</p>$|", '</p>', $pee );
78
+
79
+ return $pee;
80
}
81
82
function ajax_json_echo() {
83
if ('POST' == $_SERVER['REQUEST_METHOD'] && isset($_GET['wpcf7']) && 'json' == $_GET['wpcf7']) {
84
if (isset($_POST['_wpcf7'])) {
85
$id = (int) $_POST['_wpcf7'];
86
+ $unit_tag = $_POST['_wpcf7_unit_tag'];
87
$contact_forms = $this->contact_forms();
88
if ($cf = $contact_forms[$id]) {
89
$cf = stripslashes_deep($cf);
90
+ $into = '#' . $unit_tag . ' div.wpcf7-response-output';
91
if ($this->mail($cf)) {
92
+ echo '{ mailSent: 1, message: "' . $this->message('mail_sent_ok') . '", into: "' . $into . '" }';
93
} else {
94
+ echo '{ mailSent: 0, message: "' . $this->message('mail_sent_ng') . '", into: "' . $into . '" }';
95
}
96
}
97
}
227
$template .= ' [text your-subject] </label></p>' . "\n\n";
228
$template .= '<p><label>' . __('Your Message', 'wpcf7') . '<br />' . "\n";
229
$template .= ' [textarea your-message] </label></p>' . "\n\n";
230
+ $template .= '<p>[submit "' . __('Send', 'wpcf7') . '"]</p>';
231
return $template;
232
}
233
242
$recipient = get_option('admin_email');
243
return compact('recipient');
244
}
245
+
246
+ function message($status) {
247
+ switch ($status) {
248
+ case 'mail_sent_ok':
249
+ return __('Your message was sent successfully. Thanks.', 'wpcf7');
250
+ case 'mail_sent_ng':
251
+ return __('Failed to send your message. Please try later or contact administrator by other way.', 'wpcf7');
252
+ }
253
+ }
254
255
/* Post content filtering */
256
257
+ var $order_in_post; // Which contact form unit now you are processing. Integer value used in $unit_tag.
258
+
259
function the_content_filter($content) {
260
// Form submitted?
261
if (isset($_POST['_wpcf7'])) {
267
$validation = $this->validate_form_elements($fes);
268
if ($validation['valid']) {
269
if ($this->mail($cf)) {
270
+ $_POST['_wpcf7_mail_sent'] = array('id' => $id, 'ok' => true, 'message' => $this->message('mail_sent_ok'));
271
} else {
272
+ $_POST['_wpcf7_mail_sent'] = array('id' => $id, 'ok' => false, 'message' => $this->message('mail_sent_ng'));
273
}
274
} else {
275
$_POST['_wpcf7_validation_errors'] = array('id' => $id, 'messages' => $validation['reason']);
276
}
277
}
278
}
279
+
280
+ $this->order_in_post = 1;
281
282
$regex = '/\[\s*contact-form\s+(\d+)(?:\s+.*?)?\s*\]/';
283
+ return preg_replace_callback($regex, array(&$this, 'the_content_filter_callback'), $content);
284
}
285
286
+ var $processing_unit_tag;
287
+
288
function the_content_filter_callback($matches) {
289
$contact_forms = $this->contact_forms();
290
291
$id = (int) $matches[1];
292
if (! ($cf = $contact_forms[$id])) return $matches[0];
293
+
294
$cf = stripslashes_deep($cf);
295
296
+ $unit_tag = 'wpcf7-f' . $id . '-p' . get_the_ID() . '-o' . $this->order_in_post;
297
+ $this->processing_unit_tag = $unit_tag;
298
299
+ $form = '<div class="wpcf7" id="' . $unit_tag . '">';
300
+
301
+ $url = parse_url($_SERVER['REQUEST_URI']);
302
+ $url = $url['path'] . (empty($url['query']) ? '' : '?' . $url['query']) . '#' . $unit_tag;
303
304
+ $form .= '<form action="' . $url . '" method="post">';
305
$form .= '<input type="hidden" name="_wpcf7" value="' . $id . '" />';
306
+ $form .= '<input type="hidden" name="_wpcf7_unit_tag" value="' . $unit_tag . '" />';
307
+ $form .= $this->form_elements($cf['form']);
308
$form .= '</form>';
309
310
+ // Post response output for non-AJAX
311
+ $class = 'wpcf7-response-output';
312
+
313
+ if ($this->processing_unit_tag == $_POST['_wpcf7_unit_tag']) {
314
+ if (isset($_POST['_wpcf7_mail_sent']) && $_POST['_wpcf7_mail_sent']['id'] == $id) {
315
+ if ($_POST['_wpcf7_mail_sent']['ok']) {
316
+ $clsss .= ' wpcf7-mail-sent-ok';
317
+ $content = $_POST['_wpcf7_mail_sent']['message'];
318
+ } else {
319
+ $class .= ' wpcf7-mail-sent-ng';
320
+ $content = $_POST['_wpcf7_mail_sent']['message'];
321
+ }
322
+ } elseif (isset($_POST['_wpcf7_validation_errors']) && $_POST['_wpcf7_validation_errors']['id'] == $id) {
323
+ $class .= ' wpcf7-validation-errors';
324
+ $content = __('Validation errors occurred. Please confirm the fields and submit it again.', 'wpcf7');
325
}
326
}
327
328
+ $class = ' class="' . $class . '"';
329
+
330
+ $form .= '<div' . $class . '>' . $content . '</div>';
331
332
$form .= '</div>';
333
+
334
+ $this->order_in_post += 1;
335
+ $this->processing_unit_tag = null;
336
return $form;
337
}
338
343
foreach ($form_elements as $fe) {
344
$type = $fe['type'];
345
$name = $fe['name'];
346
347
// Required item (*)
348
if (preg_match('/^(?:text|textarea)[*]#x2F;', $type)) {
349
if (empty($_POST[$name])) {
350
$valid = false;
351
+ $reason[$name] = __('Please fill the required field.', 'wpcf7');
352
}
353
}
354
355
if (preg_match('/^email[*]?#x2F;', $type)) {
356
if ('*' == substr($type, -1) && empty($_POST[$name])) {
357
$valid = false;
358
+ $reason[$name] = __('Please fill the required field.', 'wpcf7');
359
} elseif (! is_email($_POST[$name])) {
360
$valid = false;
361
+ $reason[$name] = __('Email address seems invalid.', 'wpcf7');
362
}
363
}
364
}
365
return compact('valid', 'reason');
366
}
367
368
+ function wp_head() {
369
$stylesheet_url = get_option('siteurl') . '/wp-content/plugins/contact-form-7/stylesheet.css';
370
echo '<link rel="stylesheet" href="' . $stylesheet_url . '" type="text/css" />';
371
372
+ $url = parse_url($_SERVER['REQUEST_URI']);
373
+ if (empty($url['query']))
374
+ $override_url = $url['path'] . '?wpcf7=json';
375
+ else
376
+ $override_url = $url['path'] . '?' . $url['query'] . '&wpcf7=json';
377
378
?>
379
<script type="text/javascript">
380
//<![CDATA[
381
382
$(document).ready(function() {
383
+ $('div.wpcf7 > form').ajaxForm({
384
beforeSubmit: validate,
385
url: '<?php echo $override_url; ?>',
386
dataType: 'json',
391
});
392
393
function validate(formData, jqForm, options) {
394
+ var wpcf7ResponseOutput = $('div.wpcf7-response-output', jqForm.parents('div.wpcf7')).lt(1);
395
+ clearResponseOutput();
396
+ $('img.ajax-loader', jqForm[0]).css({ visibility: 'visible' });
397
var valid = true;
398
399
$('.wpcf7-validates-as-email', jqForm[0]).each(function() {
418
}
419
});
420
421
+ if (! valid) {
422
+ $('img.ajax-loader', jqForm[0]).css({ visibility: 'hidden' });
423
+ wpcf7ResponseOutput.addClass('wpcf7-validation-errors');
424
+ wpcf7ResponseOutput.append('<?php _e('Validation errors occurred. Please confirm the fields and submit it again.', 'wpcf7'); ?>').fadeIn('fast');
425
+ }
426
+
427
return valid;
428
}
429
443
}
444
445
function processJson(data) {
446
+ var wpcf7ResponseOutput = $(data.into);
447
+ clearResponseOutput();
448
if (1 == data.mailSent) {
449
+ wpcf7ResponseOutput.addClass('wpcf7-mail-sent-ok');
450
} else {
451
+ wpcf7ResponseOutput.addClass('wpcf7-mail-sent-ng');
452
}
453
+ wpcf7ResponseOutput.append(data.message).fadeIn('fast');
454
+ }
455
+
456
+ function clearResponseOutput() {
457
+ $('div.wpcf7-response-output').hide().empty().removeClass('wpcf7-mail-sent-ok wpcf7-mail-sent-ng wpcf7-validation-errors');
458
+ $('span.wpcf7-not-valid-tip').remove();
459
+ $('img.ajax-loader').css({ visibility: 'hidden' });
460
}
461
462
//]]>
465
}
466
467
function load_js() {
468
+ if (! is_admin())
469
wp_enqueue_script('jquery-form');
470
}
471
472
/* Processing form element placeholders */
473
474
function form_elements($form, $replace = true) {
475
+ $regex = '%\[\s*((?:text|email|textarea|select)[*]?)(\s+[a-zA-Z][0-9a-zA-Z:._-]*)([-0-9a-zA-Z:_/\s]*)?((?:\s*(?:"[^"]*"|\'[^\']*\'))*)?\s*\]%';
476
+ $submit_regex = '/\[\s*submit(\s+(?:"[^"]*"|\'[^\']*\'))?\s*\]/';
477
if ($replace) {
478
$form = preg_replace_callback($regex, array(&$this, 'form_element_replace_callback'), $form);
479
// Submit button
480
+ $form = preg_replace_callback($submit_regex, array(&$this, 'submit_replace_callback'), $form);
481
return $form;
482
} else {
483
$results = array();
490
}
491
492
function form_element_replace_callback($matches) {
493
+ extract((array) $this->form_element_parse($matches)); // $type, $name, $options, $values
494
+
495
+ if ($this->processing_unit_tag == $_POST['_wpcf7_unit_tag']) {
496
+ $validation_error = $_POST['_wpcf7_validation_errors']['messages'][$name];
497
+ $validation_error = $validation_error ? '<span class="wpcf7-not-valid-tip-no-ajax">' . $validation_error . '</span>' : '';
498
+ } else {
499
+ $validation_error = '';
500
+ }
501
+
502
$atts = '';
503
if (is_array($options)) {
504
$id_array = preg_grep('%^id:[-0-9a-zA-Z_]+$%', $options);
524
if ($class_att)
525
$atts .= ' class="' . trim($class_att) . '"';
526
}
527
+
528
+ // Value.
529
+ if ($this->processing_unit_tag == $_POST['_wpcf7_unit_tag']) {
530
+ if (isset($_POST['_wpcf7_mail_sent']) && $_POST['_wpcf7_mail_sent']['ok'])
531
+ $value = '';
532
+ else
533
+ $value = $_POST[$name];
534
+ } else {
535
+ $value = $values[0];
536
+ }
537
+
538
$type = preg_replace('/[*]#x2F;', '', $type);
539
switch ($type) {
540
case 'text':
541
case 'email':
542
if (is_array($options)) {
543
+ $size_maxlength_array = preg_grep('%^[0-9]*[/x][0-9]*$%', $options);
544
if ($size_maxlength = array_shift($size_maxlength_array)) {
545
+ preg_match('%^([0-9]*)[/x]([0-9]*)$%', $size_maxlength, $sm_matches);
546
if ($size = (int) $sm_matches[1])
547
$atts .= ' size="' . $size . '"';
548
if ($maxlength = (int) $sm_matches[2])
549
$atts .= ' maxlength="' . $maxlength . '"';
550
}
551
}
552
+ $html = '<input type="text" name="' . $name . '" value="' . attribute_escape($value) . '"' . $atts . ' />';
553
+ $html = '<span style="position: relative;">' . $html . $validation_error . '</span>';
554
+ return $html;
555
break;
556
case 'textarea':
557
if (is_array($options)) {
558
+ $cols_rows_array = preg_grep('%^[0-9]*[x/][0-9]*$%', $options);
559
if ($cols_rows = array_shift($cols_rows_array)) {
560
+ preg_match('%^([0-9]*)[x/]([0-9]*)$%', $cols_rows, $cr_matches);
561
if ($cols = (int) $cr_matches[1])
562
$atts .= ' cols="' . $cols . '"';
563
if ($rows = (int) $cr_matches[2])
564
$atts .= ' rows="' . $rows . '"';
565
}
566
}
567
+ $html = '<textarea name="' . $name . '"' . $atts . '>' . $value . '</textarea>';
568
+ $html = '<span style="position: relative;">' . $html . $validation_error . '</span>';
569
+ return $html;
570
+ break;
571
+ case 'select':
572
+ if (empty($values))
573
+ array_push($values, '---');
574
+ $html = '';
575
+ foreach ($values as $value) {
576
+ if ($this->processing_unit_tag == $_POST['_wpcf7_unit_tag'] && $_POST[$name] == $value)
577
+ $selected = ' selected="selected"';
578
+ else
579
+ $selected = '';
580
+ $html .= '<option value="' . attribute_escape($value) . '"' . $selected . '>' . $value . '</option>';
581
}
582
+ $html = '<select name="' . $name . '"' . $atts . '>' . $html . '</select>';
583
+ $html = '<span style="position: relative;">' . $html . $validation_error . '</span>';
584
+ return $html;
585
break;
586
}
587
}
591
$value = $this->strip_quote($matches[1]);
592
if (empty($value))
593
$value = __('Send', 'wpcf7');
594
+ $ajax_loader_image_url = get_option('siteurl') . '/wp-content/plugins/contact-form-7/images/ajax-loader.gif';
595
+ return '<input type="submit" value="' . $value . '" /> <img class="ajax-loader" style="visibility: hidden;" src="' . $ajax_loader_image_url . '" />';
596
}
597
598
function form_element_parse($element) {
599
$type = trim($element[1]);
600
$name = trim($element[2]);
601
+ $options = preg_split('/[\s]+/', trim($element[3]));
602
+
603
+ preg_match_all('/"[^"]*"|\'[^\']*\'/', $element[4], $matches);
604
+ $values = $this->strip_quote_deep($matches[0]);
605
+
606
+ return compact('type', 'name', 'options', 'values');
607
}
608
609
function strip_quote($text) {
626
return $result;
627
}
628
}
629
+
630
}
631
632
new tam_contact_form_seven();