Version Description
- Added settings page.
- Deprecated: acton hook mwform_mail_{$key}. This hook is removed when next version up.
- Added filter hook mwform_mail_{$key}.
- Bug fix: Validations.
Download this release
Release Info
Developer | inc2734 |
Plugin | MW WP Form |
Version | 0.6 |
Comparing to | |
See all releases |
Code changes from version 0.5.5 to 0.6
- css/admin.css +109 -0
- css/style.css +1 -1
- js/admin.js +51 -0
- languages/mw-wp-form-ja.mo +0 -0
- languages/mw-wp-form-ja.po +230 -47
- languages/mw-wp-form.pot +201 -9
- mw-wp-form.php +266 -112
- readme.txt +17 -6
- system/mw_form.php +13 -13
- system/mw_mail.php +5 -5
- system/mw_validation.php +23 -9
- system/mw_wp_form_admin_page.php +469 -0
css/admin.css
ADDED
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
@charset "utf-8";
|
2 |
+
|
3 |
+
/**
|
4 |
+
* 投稿ステータス等
|
5 |
+
*/
|
6 |
+
#minor-publishing-actions {
|
7 |
+
display: none;
|
8 |
+
}
|
9 |
+
|
10 |
+
/**
|
11 |
+
* URL設定
|
12 |
+
*/
|
13 |
+
#mw-wp-form_url table {
|
14 |
+
width: 100%;
|
15 |
+
}
|
16 |
+
#mw-wp-form_url table th {
|
17 |
+
padding-right: 10px;
|
18 |
+
text-align: left;
|
19 |
+
width: 33%;
|
20 |
+
}
|
21 |
+
#mw-wp-form_url table td input {
|
22 |
+
width: 100%;
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* メール設定
|
27 |
+
*/
|
28 |
+
#mw-wp-form_mail textarea {
|
29 |
+
width: 100%;
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* バリデーションルール
|
34 |
+
*/
|
35 |
+
#mw-wp-form_validation .validation-box {
|
36 |
+
border: #ddd solid 1px;
|
37 |
+
border-radius: 5px;
|
38 |
+
margin: 10px 0;
|
39 |
+
padding: 10px;
|
40 |
+
}
|
41 |
+
#mw-wp-form_validation .validation-box .validation-content {
|
42 |
+
border-top: #ddd solid 1px;
|
43 |
+
margin: 10px 0 0;
|
44 |
+
padding: 10px 0 0;
|
45 |
+
}
|
46 |
+
#mw-wp-form_validation .validation-box table {
|
47 |
+
margin: 10px 0 0;
|
48 |
+
}
|
49 |
+
#mw-wp-form_validation .validation-box table td {
|
50 |
+
padding: 0 10px 5px 0;
|
51 |
+
overflow: hidden;
|
52 |
+
zoom: 1;
|
53 |
+
}
|
54 |
+
#mw-wp-form_validation .validation-box table td label {
|
55 |
+
margin: 0 10px 5px 0;
|
56 |
+
display: block;
|
57 |
+
float: left;
|
58 |
+
}
|
59 |
+
#mw-wp-form_validation .validation-box table td label input {
|
60 |
+
margin: 0 2px 0 0;
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* バリデーションルールを追加
|
65 |
+
*/
|
66 |
+
#mw-wp-form_validation b#add-validation-btn {
|
67 |
+
cursor: pointer;
|
68 |
+
margin: 2px 1px 4px;
|
69 |
+
line-height: 18px;
|
70 |
+
display: inline-block;
|
71 |
+
min-width: 26px;
|
72 |
+
padding: 2px 4px;
|
73 |
+
color: #464646;
|
74 |
+
border: 1px solid #c3c3c3;
|
75 |
+
border-radius: 3px;
|
76 |
+
background: #f5f5f5;
|
77 |
+
}
|
78 |
+
#mw-wp-form_validation b#add-validation-btn:hover {
|
79 |
+
background: #eee;
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* 開閉ボタン
|
84 |
+
*/
|
85 |
+
#mw-wp-form_validation .validation-box .validation-btn {
|
86 |
+
overflow: hidden;
|
87 |
+
zoom: 1;
|
88 |
+
}
|
89 |
+
#mw-wp-form_validation .validation-box .validation-btn span {
|
90 |
+
font-weight: bold;
|
91 |
+
}
|
92 |
+
#mw-wp-form_validation .validation-box .validation-btn b {
|
93 |
+
cursor: pointer;
|
94 |
+
display: block;
|
95 |
+
float: right;
|
96 |
+
margin: 0 0 0 10px;
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* 削除ボタン
|
101 |
+
*/
|
102 |
+
#mw-wp-form_validation .validation-box .validation-remove {
|
103 |
+
float: left;
|
104 |
+
margin: 0 5px 0 0;
|
105 |
+
}
|
106 |
+
#mw-wp-form_validation .validation-box .validation-remove b {
|
107 |
+
cursor: pointer;
|
108 |
+
display: block;
|
109 |
+
}
|
css/style.css
CHANGED
@@ -4,4 +4,4 @@
|
|
4 |
font-size : 93%;
|
5 |
color : #B70000;
|
6 |
display : block;
|
7 |
-
}
|
4 |
font-size : 93%;
|
5 |
color : #B70000;
|
6 |
display : block;
|
7 |
+
}
|
js/admin.js
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
jQuery( function( $ ) {
|
2 |
+
|
3 |
+
var cnt = $( '.validation-box' ).length;
|
4 |
+
|
5 |
+
/**
|
6 |
+
* 開閉ボタン
|
7 |
+
*/
|
8 |
+
$( '.validation-btn b' ).on( 'click', function() {
|
9 |
+
$( this ).parent().siblings( '.validation-content' ).slideToggle( 'high' );
|
10 |
+
} );
|
11 |
+
|
12 |
+
/**
|
13 |
+
* 削除ボタン
|
14 |
+
*/
|
15 |
+
$( '.validation-remove b' ).on( 'click', function() {
|
16 |
+
cnt++;
|
17 |
+
$( this ).closest( '.validation-box' ).fadeOut( function() {
|
18 |
+
$( this ).remove();
|
19 |
+
} );
|
20 |
+
} );
|
21 |
+
|
22 |
+
/**
|
23 |
+
* 追加ボタン
|
24 |
+
*/
|
25 |
+
$( '#mw-wp-form_validation b' ).click( function() {
|
26 |
+
cnt++;
|
27 |
+
var clone = $( this ).parent().find( '.validation-box:first' ).clone( true );
|
28 |
+
clone.find( 'input' ).each( function() {
|
29 |
+
$( this ).attr( 'name', $( this ).attr( 'name' ).replace( /\[\d+\]/, '[' + cnt + ']' ) );
|
30 |
+
} );
|
31 |
+
clone.hide();
|
32 |
+
$( this ).siblings( '.validation-box:first' ).after( clone.fadeIn() );
|
33 |
+
} );
|
34 |
+
|
35 |
+
/**
|
36 |
+
* ターゲット名をラベルとして表示
|
37 |
+
*/
|
38 |
+
$( '.targetKey' ).on( 'keyup', function() {
|
39 |
+
var val = $( this ).val();
|
40 |
+
console.log( val );
|
41 |
+
$( this ).parent().parent().find( '.validation-btn span' ).text( val );
|
42 |
+
} );
|
43 |
+
|
44 |
+
/**
|
45 |
+
* 完了ページの入力エリアからオリジナルボタンを消去
|
46 |
+
*/
|
47 |
+
$( window ).on( 'load', function() {
|
48 |
+
$( '#mw-wp-form_complete_message_metabox input[id^="qt_mw-wp-form_complete_message_mw-wp-form_"]' ).remove();
|
49 |
+
} );
|
50 |
+
|
51 |
+
} );
|
languages/mw-wp-form-ja.mo
CHANGED
Binary file
|
languages/mw-wp-form-ja.po
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
-
# Copyright (C)
|
2 |
# This file is distributed under the same license as the MW WP Form package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
-
"Project-Id-Version: MW WP Form 0.
|
6 |
"Report-Msgid-Bugs-To: http://wordpress.org/tag/mw-wp-form\n"
|
7 |
-
"POT-Creation-Date:
|
8 |
-
"PO-Revision-Date:
|
9 |
-
"Last-Translator:
|
10 |
"Language-Team: Takashi Kitajima <inc@2inc.org>\n"
|
11 |
"MIME-Version: 1.0\n"
|
12 |
"Content-Type: text/plain; charset=UTF-8\n"
|
@@ -14,102 +14,285 @@ msgstr ""
|
|
14 |
"Plural-Forms: nplurals=1; plural=0;\n"
|
15 |
"X-Poedit-SourceCharset: UTF-8\n"
|
16 |
"X-Poedit-Basepath: .\n"
|
17 |
-
"X-Generator: Poedit 1.5.
|
18 |
-
"X-Poedit-KeywordsList: __;_e\n"
|
19 |
"X-Poedit-SearchPath-0: ..\n"
|
20 |
|
21 |
-
#:
|
|
|
|
|
|
|
|
|
|
|
22 |
msgid "Back"
|
23 |
msgstr "戻る"
|
24 |
|
25 |
-
#: form_fields/mw_form_field_preview_button.php:36
|
26 |
-
#: form_fields/mw_form_field_submit.php:37
|
27 |
msgid "Confirm"
|
28 |
msgstr "確認画面へ"
|
29 |
|
30 |
-
#: form_fields/mw_form_field_submit.php:38
|
31 |
-
#: form_fields/mw_form_field_submit_button.php:37
|
32 |
msgid "Send"
|
33 |
msgstr "送信する"
|
34 |
|
35 |
-
#:
|
36 |
-
msgid "Validation Object is not a MW Validation Class."
|
37 |
-
msgstr ""
|
38 |
-
|
39 |
-
#: system/mw_validation.php:75
|
40 |
msgid "This is required."
|
41 |
msgstr "必須項目です。"
|
42 |
|
43 |
-
#: system/mw_validation.php:95 system/mw_validation.php:117
|
44 |
msgid "Please enter."
|
45 |
msgstr "未入力です。"
|
46 |
|
47 |
-
#: system/mw_validation.php:139
|
48 |
msgid "Please enter with a half-width alphabetic character."
|
49 |
msgstr "半角英字で入力してください。"
|
50 |
|
51 |
-
#: system/mw_validation.php:161
|
52 |
msgid "Please enter with a half-width number."
|
53 |
msgstr "半角数字で入力してください。"
|
54 |
|
55 |
-
#: system/mw_validation.php:183
|
56 |
msgid "Please enter with a half-width alphanumeric character."
|
57 |
msgstr "半角英数字で入力してください。"
|
58 |
|
59 |
-
#: system/mw_validation.php:205
|
60 |
msgid "This is not the format of a zip code."
|
61 |
msgstr "郵便番号の形式ではありません。"
|
62 |
|
63 |
-
#: system/mw_validation.php:232
|
64 |
msgid "This is not the format of a tel number."
|
65 |
msgstr "電話番号の形式ではありません。"
|
66 |
|
67 |
-
#: system/mw_validation.php:259
|
68 |
msgid "This is not the format of a mail address."
|
69 |
msgstr "メールアドレスの形式ではありません。"
|
70 |
|
71 |
-
#: system/mw_validation.php:281
|
72 |
msgid "This is not the format of a url."
|
73 |
msgstr "URLの形式ではありません。"
|
74 |
|
75 |
-
#: system/mw_validation.php:304
|
76 |
msgid "This is not in agreement."
|
77 |
msgstr "一致しません。"
|
78 |
|
79 |
-
#: system/mw_validation.php:328
|
80 |
msgid "The number of characters is invalid."
|
81 |
msgstr "文字数が正しくありません。"
|
82 |
|
83 |
-
#: system/mw_validation.php:352
|
84 |
msgid "The number of characters is a few."
|
85 |
msgstr "文字数が足りません。"
|
86 |
|
87 |
-
#: system/mw_validation.php:376
|
88 |
msgid "This value is invalid."
|
89 |
msgstr "値が不正です。"
|
90 |
|
91 |
-
#: system/mw_validation.php:398
|
92 |
msgid "This is not the format of a date."
|
93 |
msgstr "日付の形式ではありません。"
|
94 |
|
95 |
-
|
96 |
-
msgid "
|
97 |
-
msgstr ""
|
98 |
|
99 |
-
|
100 |
-
msgid "
|
101 |
-
msgstr ""
|
102 |
|
103 |
-
|
104 |
-
msgid ""
|
105 |
-
|
106 |
-
"validation can be specified at functions.php."
|
107 |
-
msgstr ""
|
108 |
|
109 |
-
|
110 |
-
msgid "
|
111 |
-
msgstr ""
|
112 |
|
113 |
-
|
114 |
-
msgid "
|
115 |
-
msgstr ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright (C) 2013 MW WP Form
|
2 |
# This file is distributed under the same license as the MW WP Form package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
+
"Project-Id-Version: MW WP Form 0.6\n"
|
6 |
"Report-Msgid-Bugs-To: http://wordpress.org/tag/mw-wp-form\n"
|
7 |
+
"POT-Creation-Date: 2013-02-23 01:19+0900\n"
|
8 |
+
"PO-Revision-Date: 2013-02-23 01:20+0900\n"
|
9 |
+
"Last-Translator: Takashi Kitajima <inc@2inc.org>\n"
|
10 |
"Language-Team: Takashi Kitajima <inc@2inc.org>\n"
|
11 |
"MIME-Version: 1.0\n"
|
12 |
"Content-Type: text/plain; charset=UTF-8\n"
|
14 |
"Plural-Forms: nplurals=1; plural=0;\n"
|
15 |
"X-Poedit-SourceCharset: UTF-8\n"
|
16 |
"X-Poedit-Basepath: .\n"
|
17 |
+
"X-Generator: Poedit 1.5.5\n"
|
18 |
+
"X-Poedit-KeywordsList: __;_e;_x\n"
|
19 |
"X-Poedit-SearchPath-0: ..\n"
|
20 |
|
21 |
+
#: ../mw-wp-form.php:279
|
22 |
+
msgid "Validation Object is not a MW Validation Class."
|
23 |
+
msgstr ""
|
24 |
+
|
25 |
+
#: ../form_fields/mw_form_field_back_button.php:36
|
26 |
+
#: ../system/mw_wp_form_admin_page.php:206
|
27 |
msgid "Back"
|
28 |
msgstr "戻る"
|
29 |
|
30 |
+
#: ../form_fields/mw_form_field_preview_button.php:36
|
31 |
+
#: ../form_fields/mw_form_field_submit.php:37
|
32 |
msgid "Confirm"
|
33 |
msgstr "確認画面へ"
|
34 |
|
35 |
+
#: ../form_fields/mw_form_field_submit.php:38
|
36 |
+
#: ../form_fields/mw_form_field_submit_button.php:37
|
37 |
msgid "Send"
|
38 |
msgstr "送信する"
|
39 |
|
40 |
+
#: ../system/mw_validation.php:75
|
|
|
|
|
|
|
|
|
41 |
msgid "This is required."
|
42 |
msgstr "必須項目です。"
|
43 |
|
44 |
+
#: ../system/mw_validation.php:95 ../system/mw_validation.php:117
|
45 |
msgid "Please enter."
|
46 |
msgstr "未入力です。"
|
47 |
|
48 |
+
#: ../system/mw_validation.php:139
|
49 |
msgid "Please enter with a half-width alphabetic character."
|
50 |
msgstr "半角英字で入力してください。"
|
51 |
|
52 |
+
#: ../system/mw_validation.php:161
|
53 |
msgid "Please enter with a half-width number."
|
54 |
msgstr "半角数字で入力してください。"
|
55 |
|
56 |
+
#: ../system/mw_validation.php:183
|
57 |
msgid "Please enter with a half-width alphanumeric character."
|
58 |
msgstr "半角英数字で入力してください。"
|
59 |
|
60 |
+
#: ../system/mw_validation.php:205
|
61 |
msgid "This is not the format of a zip code."
|
62 |
msgstr "郵便番号の形式ではありません。"
|
63 |
|
64 |
+
#: ../system/mw_validation.php:232
|
65 |
msgid "This is not the format of a tel number."
|
66 |
msgstr "電話番号の形式ではありません。"
|
67 |
|
68 |
+
#: ../system/mw_validation.php:259
|
69 |
msgid "This is not the format of a mail address."
|
70 |
msgstr "メールアドレスの形式ではありません。"
|
71 |
|
72 |
+
#: ../system/mw_validation.php:281
|
73 |
msgid "This is not the format of a url."
|
74 |
msgstr "URLの形式ではありません。"
|
75 |
|
76 |
+
#: ../system/mw_validation.php:304
|
77 |
msgid "This is not in agreement."
|
78 |
msgstr "一致しません。"
|
79 |
|
80 |
+
#: ../system/mw_validation.php:328
|
81 |
msgid "The number of characters is invalid."
|
82 |
msgstr "文字数が正しくありません。"
|
83 |
|
84 |
+
#: ../system/mw_validation.php:352
|
85 |
msgid "The number of characters is a few."
|
86 |
msgstr "文字数が足りません。"
|
87 |
|
88 |
+
#: ../system/mw_validation.php:376
|
89 |
msgid "This value is invalid."
|
90 |
msgstr "値が不正です。"
|
91 |
|
92 |
+
#: ../system/mw_validation.php:398
|
93 |
msgid "This is not the format of a date."
|
94 |
msgstr "日付の形式ではありません。"
|
95 |
|
96 |
+
#: ../system/mw_wp_form_admin_page.php:64
|
97 |
+
msgid "Add New Form"
|
98 |
+
msgstr "フォームを追加"
|
99 |
|
100 |
+
#: ../system/mw_wp_form_admin_page.php:65
|
101 |
+
msgid "Edit Form"
|
102 |
+
msgstr "フォームを編集"
|
103 |
|
104 |
+
#: ../system/mw_wp_form_admin_page.php:66
|
105 |
+
msgid "New Form"
|
106 |
+
msgstr "新しいフォーム"
|
|
|
|
|
107 |
|
108 |
+
#: ../system/mw_wp_form_admin_page.php:67
|
109 |
+
msgid "View Form"
|
110 |
+
msgstr "フォームを表示"
|
111 |
|
112 |
+
#: ../system/mw_wp_form_admin_page.php:68
|
113 |
+
msgid "Search Forms"
|
114 |
+
msgstr "フォームを検索"
|
115 |
+
|
116 |
+
#: ../system/mw_wp_form_admin_page.php:69
|
117 |
+
msgid "No Forms found"
|
118 |
+
msgstr "フォームがありません"
|
119 |
+
|
120 |
+
#: ../system/mw_wp_form_admin_page.php:70
|
121 |
+
msgid "No Forms found in Trash"
|
122 |
+
msgstr "ゴミ箱にフォームはありません"
|
123 |
+
|
124 |
+
#: ../system/mw_wp_form_admin_page.php:108
|
125 |
+
msgid "Complete Message"
|
126 |
+
msgstr "完了画面メッセージ"
|
127 |
+
|
128 |
+
#: ../system/mw_wp_form_admin_page.php:115
|
129 |
+
msgid "URL Options"
|
130 |
+
msgstr "URL設定"
|
131 |
+
|
132 |
+
#: ../system/mw_wp_form_admin_page.php:122
|
133 |
+
msgid "Validation Rule"
|
134 |
+
msgstr "バリデーションルール"
|
135 |
+
|
136 |
+
#: ../system/mw_wp_form_admin_page.php:129
|
137 |
+
msgid "Form Key"
|
138 |
+
msgstr "フォーム識別子"
|
139 |
+
|
140 |
+
#: ../system/mw_wp_form_admin_page.php:136
|
141 |
+
msgid "Mail Options"
|
142 |
+
msgstr "メール設定"
|
143 |
+
|
144 |
+
#: ../system/mw_wp_form_admin_page.php:152
|
145 |
+
msgid "Text"
|
146 |
+
msgstr "テキストフィールド"
|
147 |
+
|
148 |
+
#: ../system/mw_wp_form_admin_page.php:158
|
149 |
+
msgid "Textarea"
|
150 |
+
msgstr "テキストエリア"
|
151 |
+
|
152 |
+
#: ../system/mw_wp_form_admin_page.php:164
|
153 |
+
#, fuzzy
|
154 |
+
msgid "Zip Code"
|
155 |
+
msgstr "郵便番号"
|
156 |
+
|
157 |
+
#: ../system/mw_wp_form_admin_page.php:170
|
158 |
+
#: ../system/mw_wp_form_admin_page.php:430
|
159 |
+
msgid "Tel"
|
160 |
+
msgstr "電話番号"
|
161 |
+
|
162 |
+
#: ../system/mw_wp_form_admin_page.php:176
|
163 |
+
msgid "Select"
|
164 |
+
msgstr "セレクトボックス"
|
165 |
+
|
166 |
+
#: ../system/mw_wp_form_admin_page.php:182
|
167 |
+
msgid "Radio"
|
168 |
+
msgstr "ラジオボタン"
|
169 |
+
|
170 |
+
#: ../system/mw_wp_form_admin_page.php:188
|
171 |
+
msgid "Checkbox"
|
172 |
+
msgstr "チェックボックス"
|
173 |
+
|
174 |
+
#: ../system/mw_wp_form_admin_page.php:194
|
175 |
+
msgid "Datepicker"
|
176 |
+
msgstr "日付"
|
177 |
+
|
178 |
+
#: ../system/mw_wp_form_admin_page.php:200
|
179 |
+
msgid "Password"
|
180 |
+
msgstr "パスワードフィールド"
|
181 |
+
|
182 |
+
#: ../system/mw_wp_form_admin_page.php:212
|
183 |
+
msgid "Confirm & Submit"
|
184 |
+
msgstr "確認・送信"
|
185 |
+
|
186 |
+
#: ../system/mw_wp_form_admin_page.php:218
|
187 |
+
msgid "Submit"
|
188 |
+
msgstr "送信"
|
189 |
+
|
190 |
+
#: ../system/mw_wp_form_admin_page.php:224
|
191 |
+
msgid "Button"
|
192 |
+
msgstr "ボタン"
|
193 |
+
|
194 |
+
#: ../system/mw_wp_form_admin_page.php:230
|
195 |
+
msgid "Hidden"
|
196 |
+
msgstr "hiddenフィールド"
|
197 |
+
|
198 |
+
#: ../system/mw_wp_form_admin_page.php:236
|
199 |
+
msgid "Error Message"
|
200 |
+
msgstr "エラーメッセージ"
|
201 |
+
|
202 |
+
#: ../system/mw_wp_form_admin_page.php:314
|
203 |
+
msgid "Copy and Paste this shortcode."
|
204 |
+
msgstr "このショートコードをコピー&ペーストしてください。"
|
205 |
+
|
206 |
+
#: ../system/mw_wp_form_admin_page.php:341
|
207 |
+
msgid "Subject"
|
208 |
+
msgstr "件名"
|
209 |
+
|
210 |
+
#: ../system/mw_wp_form_admin_page.php:345
|
211 |
+
msgid "Ccontent"
|
212 |
+
msgstr "本文"
|
213 |
+
|
214 |
+
#: ../system/mw_wp_form_admin_page.php:347
|
215 |
+
msgid "{key} is converted form data."
|
216 |
+
msgstr "{キー}でそのフォーム項目に変換されます。"
|
217 |
+
|
218 |
+
#: ../system/mw_wp_form_admin_page.php:350
|
219 |
+
msgid "Automatic reply email"
|
220 |
+
msgstr "自動返信メール"
|
221 |
+
|
222 |
+
#: ../system/mw_wp_form_admin_page.php:352
|
223 |
+
msgid "Please input the key to use as transmission to automatic reply email."
|
224 |
+
msgstr "自動返信メールに使用する項目のキーを入力してください。"
|
225 |
+
|
226 |
+
#: ../system/mw_wp_form_admin_page.php:367
|
227 |
+
msgid "Input Page URL"
|
228 |
+
msgstr "入力画面URL"
|
229 |
+
|
230 |
+
#: ../system/mw_wp_form_admin_page.php:373
|
231 |
+
msgid "Confirmation Page URL"
|
232 |
+
msgstr "確認画面URL"
|
233 |
+
|
234 |
+
#: ../system/mw_wp_form_admin_page.php:379
|
235 |
+
msgid "Complete Page URL"
|
236 |
+
msgstr "完了画面URL"
|
237 |
+
|
238 |
+
#: ../system/mw_wp_form_admin_page.php:414
|
239 |
+
msgid "Add Validation rule"
|
240 |
+
msgstr "バリデーションルールを追加"
|
241 |
+
|
242 |
+
#: ../system/mw_wp_form_admin_page.php:420
|
243 |
+
msgid "The key which applies validation"
|
244 |
+
msgstr "バリデーションを適用する項目"
|
245 |
+
|
246 |
+
#: ../system/mw_wp_form_admin_page.php:424
|
247 |
+
msgid "No empty"
|
248 |
+
msgstr "必須項目"
|
249 |
+
|
250 |
+
#: ../system/mw_wp_form_admin_page.php:425
|
251 |
+
msgid "No empty( with checkbox )"
|
252 |
+
msgstr "必須項目(チェックボックス)"
|
253 |
+
|
254 |
+
#: ../system/mw_wp_form_admin_page.php:426
|
255 |
+
msgid "Numeric"
|
256 |
+
msgstr "半角数字"
|
257 |
+
|
258 |
+
#: ../system/mw_wp_form_admin_page.php:427
|
259 |
+
msgid "Alphabet"
|
260 |
+
msgstr "半角英字"
|
261 |
+
|
262 |
+
#: ../system/mw_wp_form_admin_page.php:428
|
263 |
+
msgid "Alphabet and Numeric"
|
264 |
+
msgstr "半角英数字"
|
265 |
+
|
266 |
+
#: ../system/mw_wp_form_admin_page.php:429
|
267 |
+
msgid "Zip code"
|
268 |
+
msgstr "郵便番号"
|
269 |
+
|
270 |
+
#: ../system/mw_wp_form_admin_page.php:431
|
271 |
+
msgid "E-mail"
|
272 |
+
msgstr "メールアドレス"
|
273 |
+
|
274 |
+
#: ../system/mw_wp_form_admin_page.php:432
|
275 |
+
msgid "Date"
|
276 |
+
msgstr "日付"
|
277 |
+
|
278 |
+
#: ../system/mw_wp_form_admin_page.php:436
|
279 |
+
msgid "The key at same value"
|
280 |
+
msgstr "一致する項目"
|
281 |
+
|
282 |
+
#: ../system/mw_wp_form_admin_page.php:440
|
283 |
+
msgid "The range of the number of characters"
|
284 |
+
msgstr "文字数の範囲"
|
285 |
+
|
286 |
+
#: ../system/mw_wp_form_admin_page.php:448
|
287 |
+
msgid "The number of the minimum characters"
|
288 |
+
msgstr "最小文字数"
|
289 |
+
|
290 |
+
#~ msgid ""
|
291 |
+
#~ "MW WP Form can create mail form with a confirmation screen using "
|
292 |
+
#~ "shortcode."
|
293 |
+
#~ msgstr ""
|
294 |
+
#~ "MW WP Formはショートコードを使って確認画面付きのフォームを作成しメールを送"
|
295 |
+
#~ "信することができます。"
|
296 |
+
|
297 |
+
#~ msgid "Zip"
|
298 |
+
#~ msgstr "郵便番号"
|
languages/mw-wp-form.pot
CHANGED
@@ -1,16 +1,16 @@
|
|
1 |
-
# Copyright (C)
|
2 |
# This file is distributed under the same license as the MW WP Form package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
-
"Project-Id-Version: MW WP Form 0.
|
6 |
"Report-Msgid-Bugs-To: http://wordpress.org/tag/mw-wp-form\n"
|
7 |
-
"POT-Creation-Date:
|
8 |
-
"PO-Revision-Date: 2012-12-14 15:42+0900\n"
|
9 |
-
"Last-Translator: Takashi Kitajima <inc@2inc.org>\n"
|
10 |
-
"Language-Team: Takashi Kitajima <inc@2inc.org>\n"
|
11 |
"MIME-Version: 1.0\n"
|
12 |
"Content-Type: text/plain; charset=UTF-8\n"
|
13 |
"Content-Transfer-Encoding: 8bit\n"
|
|
|
|
|
|
|
14 |
"Plural-Forms: nplurals=1; plural=0;\n"
|
15 |
"X-Poedit-SourceCharset: UTF-8\n"
|
16 |
"X-Poedit-Basepath: .\n"
|
@@ -19,6 +19,7 @@ msgstr ""
|
|
19 |
"X-Poedit-SearchPath-0: ..\n"
|
20 |
|
21 |
#: form_fields/mw_form_field_back_button.php:36
|
|
|
22 |
msgid "Back"
|
23 |
msgstr ""
|
24 |
|
@@ -32,7 +33,7 @@ msgstr ""
|
|
32 |
msgid "Send"
|
33 |
msgstr ""
|
34 |
|
35 |
-
#: mw-wp-form.php:
|
36 |
msgid "Validation Object is not a MW Validation Class."
|
37 |
msgstr ""
|
38 |
|
@@ -92,6 +93,198 @@ msgstr ""
|
|
92 |
msgid "This is not the format of a date."
|
93 |
msgstr ""
|
94 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
#. Plugin Name of the plugin/theme
|
96 |
msgid "MW WP Form"
|
97 |
msgstr ""
|
@@ -102,8 +295,7 @@ msgstr ""
|
|
102 |
|
103 |
#. Description of the plugin/theme
|
104 |
msgid ""
|
105 |
-
"
|
106 |
-
"validation can be specified at functions.php."
|
107 |
msgstr ""
|
108 |
|
109 |
#. Author of the plugin/theme
|
1 |
+
# Copyright (C) 2013 MW WP Form
|
2 |
# This file is distributed under the same license as the MW WP Form package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
+
"Project-Id-Version: MW WP Form 0.6\n"
|
6 |
"Report-Msgid-Bugs-To: http://wordpress.org/tag/mw-wp-form\n"
|
7 |
+
"POT-Creation-Date: 2013-02-22 16:16:54+00:00\n"
|
|
|
|
|
|
|
8 |
"MIME-Version: 1.0\n"
|
9 |
"Content-Type: text/plain; charset=UTF-8\n"
|
10 |
"Content-Transfer-Encoding: 8bit\n"
|
11 |
+
"PO-Revision-Date: 2013-MO-DA HO:MI+ZONE\n"
|
12 |
+
"Last-Translator: Takashi Kitajima <inc@2inc.org>\n"
|
13 |
+
"Language-Team: Takashi Kitajima <inc@2inc.org>\n"
|
14 |
"Plural-Forms: nplurals=1; plural=0;\n"
|
15 |
"X-Poedit-SourceCharset: UTF-8\n"
|
16 |
"X-Poedit-Basepath: .\n"
|
19 |
"X-Poedit-SearchPath-0: ..\n"
|
20 |
|
21 |
#: form_fields/mw_form_field_back_button.php:36
|
22 |
+
#: system/mw_wp_form_admin_page.php:206
|
23 |
msgid "Back"
|
24 |
msgstr ""
|
25 |
|
33 |
msgid "Send"
|
34 |
msgstr ""
|
35 |
|
36 |
+
#: mw-wp-form.php:279
|
37 |
msgid "Validation Object is not a MW Validation Class."
|
38 |
msgstr ""
|
39 |
|
93 |
msgid "This is not the format of a date."
|
94 |
msgstr ""
|
95 |
|
96 |
+
#: system/mw_wp_form_admin_page.php:64
|
97 |
+
msgid "Add New Form"
|
98 |
+
msgstr ""
|
99 |
+
|
100 |
+
#: system/mw_wp_form_admin_page.php:65
|
101 |
+
msgid "Edit Form"
|
102 |
+
msgstr ""
|
103 |
+
|
104 |
+
#: system/mw_wp_form_admin_page.php:66
|
105 |
+
msgid "New Form"
|
106 |
+
msgstr ""
|
107 |
+
|
108 |
+
#: system/mw_wp_form_admin_page.php:67
|
109 |
+
msgid "View Form"
|
110 |
+
msgstr ""
|
111 |
+
|
112 |
+
#: system/mw_wp_form_admin_page.php:68
|
113 |
+
msgid "Search Forms"
|
114 |
+
msgstr ""
|
115 |
+
|
116 |
+
#: system/mw_wp_form_admin_page.php:69
|
117 |
+
msgid "No Forms found"
|
118 |
+
msgstr ""
|
119 |
+
|
120 |
+
#: system/mw_wp_form_admin_page.php:70
|
121 |
+
msgid "No Forms found in Trash"
|
122 |
+
msgstr ""
|
123 |
+
|
124 |
+
#: system/mw_wp_form_admin_page.php:108
|
125 |
+
msgid "Complete Message"
|
126 |
+
msgstr ""
|
127 |
+
|
128 |
+
#: system/mw_wp_form_admin_page.php:115
|
129 |
+
msgid "URL Options"
|
130 |
+
msgstr ""
|
131 |
+
|
132 |
+
#: system/mw_wp_form_admin_page.php:122
|
133 |
+
msgid "Validation Rule"
|
134 |
+
msgstr ""
|
135 |
+
|
136 |
+
#: system/mw_wp_form_admin_page.php:129
|
137 |
+
msgid "Form Key"
|
138 |
+
msgstr ""
|
139 |
+
|
140 |
+
#: system/mw_wp_form_admin_page.php:136
|
141 |
+
msgid "Mail Options"
|
142 |
+
msgstr ""
|
143 |
+
|
144 |
+
#: system/mw_wp_form_admin_page.php:152
|
145 |
+
msgid "Text"
|
146 |
+
msgstr ""
|
147 |
+
|
148 |
+
#: system/mw_wp_form_admin_page.php:158
|
149 |
+
msgid "Textarea"
|
150 |
+
msgstr ""
|
151 |
+
|
152 |
+
#: system/mw_wp_form_admin_page.php:164
|
153 |
+
msgid "Zip Code"
|
154 |
+
msgstr ""
|
155 |
+
|
156 |
+
#: system/mw_wp_form_admin_page.php:170 system/mw_wp_form_admin_page.php:430
|
157 |
+
msgid "Tel"
|
158 |
+
msgstr ""
|
159 |
+
|
160 |
+
#: system/mw_wp_form_admin_page.php:176
|
161 |
+
msgid "Select"
|
162 |
+
msgstr ""
|
163 |
+
|
164 |
+
#: system/mw_wp_form_admin_page.php:182
|
165 |
+
msgid "Radio"
|
166 |
+
msgstr ""
|
167 |
+
|
168 |
+
#: system/mw_wp_form_admin_page.php:188
|
169 |
+
msgid "Checkbox"
|
170 |
+
msgstr ""
|
171 |
+
|
172 |
+
#: system/mw_wp_form_admin_page.php:194
|
173 |
+
msgid "Datepicker"
|
174 |
+
msgstr ""
|
175 |
+
|
176 |
+
#: system/mw_wp_form_admin_page.php:200
|
177 |
+
msgid "Password"
|
178 |
+
msgstr ""
|
179 |
+
|
180 |
+
#: system/mw_wp_form_admin_page.php:212
|
181 |
+
msgid "Confirm & Submit"
|
182 |
+
msgstr ""
|
183 |
+
|
184 |
+
#: system/mw_wp_form_admin_page.php:218
|
185 |
+
msgid "Submit"
|
186 |
+
msgstr ""
|
187 |
+
|
188 |
+
#: system/mw_wp_form_admin_page.php:224
|
189 |
+
msgid "Button"
|
190 |
+
msgstr ""
|
191 |
+
|
192 |
+
#: system/mw_wp_form_admin_page.php:230
|
193 |
+
msgid "Hidden"
|
194 |
+
msgstr ""
|
195 |
+
|
196 |
+
#: system/mw_wp_form_admin_page.php:236
|
197 |
+
msgid "Error Message"
|
198 |
+
msgstr ""
|
199 |
+
|
200 |
+
#: system/mw_wp_form_admin_page.php:314
|
201 |
+
msgid "Copy and Paste this shortcode."
|
202 |
+
msgstr ""
|
203 |
+
|
204 |
+
#: system/mw_wp_form_admin_page.php:341
|
205 |
+
msgid "Subject"
|
206 |
+
msgstr ""
|
207 |
+
|
208 |
+
#: system/mw_wp_form_admin_page.php:345
|
209 |
+
msgid "Ccontent"
|
210 |
+
msgstr ""
|
211 |
+
|
212 |
+
#: system/mw_wp_form_admin_page.php:347
|
213 |
+
msgid "{key} is converted form data."
|
214 |
+
msgstr ""
|
215 |
+
|
216 |
+
#: system/mw_wp_form_admin_page.php:350
|
217 |
+
msgid "Automatic reply email"
|
218 |
+
msgstr ""
|
219 |
+
|
220 |
+
#: system/mw_wp_form_admin_page.php:352
|
221 |
+
msgid "Please input the key to use as transmission to automatic reply email."
|
222 |
+
msgstr ""
|
223 |
+
|
224 |
+
#: system/mw_wp_form_admin_page.php:367
|
225 |
+
msgid "Input Page URL"
|
226 |
+
msgstr ""
|
227 |
+
|
228 |
+
#: system/mw_wp_form_admin_page.php:373
|
229 |
+
msgid "Confirmation Page URL"
|
230 |
+
msgstr ""
|
231 |
+
|
232 |
+
#: system/mw_wp_form_admin_page.php:379
|
233 |
+
msgid "Complete Page URL"
|
234 |
+
msgstr ""
|
235 |
+
|
236 |
+
#: system/mw_wp_form_admin_page.php:414
|
237 |
+
msgid "Add Validation rule"
|
238 |
+
msgstr ""
|
239 |
+
|
240 |
+
#: system/mw_wp_form_admin_page.php:420
|
241 |
+
msgid "The key which applies validation"
|
242 |
+
msgstr ""
|
243 |
+
|
244 |
+
#: system/mw_wp_form_admin_page.php:424
|
245 |
+
msgid "No empty"
|
246 |
+
msgstr ""
|
247 |
+
|
248 |
+
#: system/mw_wp_form_admin_page.php:425
|
249 |
+
msgid "No empty( with checkbox )"
|
250 |
+
msgstr ""
|
251 |
+
|
252 |
+
#: system/mw_wp_form_admin_page.php:426
|
253 |
+
msgid "Numeric"
|
254 |
+
msgstr ""
|
255 |
+
|
256 |
+
#: system/mw_wp_form_admin_page.php:427
|
257 |
+
msgid "Alphabet"
|
258 |
+
msgstr ""
|
259 |
+
|
260 |
+
#: system/mw_wp_form_admin_page.php:428
|
261 |
+
msgid "Alphabet and Numeric"
|
262 |
+
msgstr ""
|
263 |
+
|
264 |
+
#: system/mw_wp_form_admin_page.php:429
|
265 |
+
msgid "Zip code"
|
266 |
+
msgstr ""
|
267 |
+
|
268 |
+
#: system/mw_wp_form_admin_page.php:431
|
269 |
+
msgid "E-mail"
|
270 |
+
msgstr ""
|
271 |
+
|
272 |
+
#: system/mw_wp_form_admin_page.php:432
|
273 |
+
msgid "Date"
|
274 |
+
msgstr ""
|
275 |
+
|
276 |
+
#: system/mw_wp_form_admin_page.php:436
|
277 |
+
msgid "The key at same value"
|
278 |
+
msgstr ""
|
279 |
+
|
280 |
+
#: system/mw_wp_form_admin_page.php:440
|
281 |
+
msgid "The range of the number of characters"
|
282 |
+
msgstr ""
|
283 |
+
|
284 |
+
#: system/mw_wp_form_admin_page.php:448
|
285 |
+
msgid "The number of the minimum characters"
|
286 |
+
msgstr ""
|
287 |
+
|
288 |
#. Plugin Name of the plugin/theme
|
289 |
msgid "MW WP Form"
|
290 |
msgstr ""
|
295 |
|
296 |
#. Description of the plugin/theme
|
297 |
msgid ""
|
298 |
+
"MW WP Form can create mail form with a confirmation screen using shortcode."
|
|
|
299 |
msgstr ""
|
300 |
|
301 |
#. Author of the plugin/theme
|
mw-wp-form.php
CHANGED
@@ -2,27 +2,27 @@
|
|
2 |
/**
|
3 |
* Plugin Name: MW WP Form
|
4 |
* Plugin URI: http://2inc.org/blog/category/products/wordpress_plugins/mw-wp-form/
|
5 |
-
* Description:
|
6 |
-
* Version: 0.
|
7 |
* Author: Takashi Kitajima
|
8 |
* Author URI: http://2inc.org
|
9 |
* Created: September 25, 2012
|
10 |
-
* Modified: February
|
11 |
* Text Domain: mw-wp-form
|
12 |
* Domain Path: /languages/
|
13 |
* License: GPL2
|
14 |
*
|
15 |
* Copyright 2013 Takashi Kitajima (email : inc@2inc.org)
|
16 |
-
*
|
17 |
* This program is free software; you can redistribute it and/or modify
|
18 |
* it under the terms of the GNU General Public License, version 2, as
|
19 |
* published by the Free Software Foundation.
|
20 |
-
*
|
21 |
* This program is distributed in the hope that it will be useful,
|
22 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
23 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
24 |
* GNU General Public License for more details.
|
25 |
-
*
|
26 |
* You should have received a copy of the GNU General Public License
|
27 |
* along with this program; if not, write to the Free Software
|
28 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
@@ -32,7 +32,6 @@ class mw_wp_form {
|
|
32 |
|
33 |
const NAME = 'mw-wp-form';
|
34 |
const DOMAIN = 'mw-wp-form';
|
35 |
-
const CUSTOM_FIELD_NAME = '_mwform';
|
36 |
protected $key;
|
37 |
protected $input;
|
38 |
protected $preview;
|
@@ -43,13 +42,22 @@ class mw_wp_form {
|
|
43 |
protected $Error;
|
44 |
protected $Session;
|
45 |
protected $viewFlg = 'input';
|
46 |
-
|
|
|
|
|
47 |
/**
|
48 |
* __construct
|
49 |
*/
|
50 |
public function __construct() {
|
51 |
-
// ファイルロード
|
52 |
load_plugin_textdomain( self::DOMAIN, false, basename( dirname( __FILE__ ) ) . '/languages' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
include_once( plugin_dir_path( __FILE__ ) . 'system/mw_error.php' );
|
54 |
include_once( plugin_dir_path( __FILE__ ) . 'system/mw_form.php' );
|
55 |
include_once( plugin_dir_path( __FILE__ ) . 'system/mw_mail.php' );
|
@@ -59,87 +67,55 @@ class mw_wp_form {
|
|
59 |
foreach( glob( plugin_dir_path( __FILE__ ) . 'form_fields/*.php' ) as $form_field ) {
|
60 |
include_once $form_field;
|
61 |
}
|
62 |
-
add_action( '
|
63 |
-
add_action( 'save_post', array( $this, 'save_post' ) );
|
64 |
add_action( 'wp_print_styles', array( $this, 'original_style' ) );
|
65 |
}
|
66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
/**
|
68 |
* original_style
|
69 |
* CSS適用
|
70 |
*/
|
71 |
public function original_style() {
|
|
|
72 |
$url = plugin_dir_url( __FILE__ );
|
73 |
wp_register_style( self::DOMAIN, $url.'css/style.css' );
|
74 |
wp_enqueue_style( self::DOMAIN );
|
75 |
}
|
76 |
-
|
77 |
-
/**
|
78 |
-
* save_post
|
79 |
-
* 編集・保存時にカスタムフィールドに[mwform〜]を保存
|
80 |
-
* @param Int 投稿ID
|
81 |
-
*/
|
82 |
-
public function save_post( $id ) {
|
83 |
-
$post = get_post( $id );
|
84 |
-
preg_match( '/(\[mwform .+?\])/msi', $post->post_content, $reg );
|
85 |
-
if ( !empty( $reg[1] ) ) {
|
86 |
-
delete_post_meta( $id, self::CUSTOM_FIELD_NAME );
|
87 |
-
add_post_meta( $id, self::CUSTOM_FIELD_NAME, $reg[1], true );
|
88 |
-
}
|
89 |
-
}
|
90 |
-
|
91 |
-
/**
|
92 |
-
* _meta_mwform
|
93 |
-
* [mwform〜]を解析し、プロパティを設定
|
94 |
-
* @param Array ( input, preview, complete, key )
|
95 |
-
*/
|
96 |
-
public function _meta_mwform( $atts ) {
|
97 |
-
$atts = shortcode_atts( array(
|
98 |
-
'input' => '',
|
99 |
-
'preview' => '',
|
100 |
-
'complete' => '',
|
101 |
-
'key' => 'mwform'
|
102 |
-
), $atts );
|
103 |
-
$this->key = $atts['key'];
|
104 |
-
$this->input = $atts['input'];
|
105 |
-
$this->preview = $atts['preview'];
|
106 |
-
$this->complete = $atts['complete'];
|
107 |
-
}
|
108 |
-
|
109 |
/**
|
110 |
* init
|
111 |
-
*
|
112 |
*/
|
113 |
public function init() {
|
114 |
global $post;
|
|
|
115 |
if ( empty( $post->ID ) ) return;
|
116 |
-
|
117 |
-
//
|
118 |
-
if ( empty( $_mwform ) ) return;
|
119 |
-
// カスタムフィールドから設定を取得
|
120 |
add_shortcode( 'mwform', array( $this, '_meta_mwform' ) );
|
121 |
-
do_shortcode( $
|
122 |
remove_shortcode( 'mwform' );
|
123 |
-
|
124 |
-
|
125 |
-
add_shortcode( '
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
add_shortcode( 'mwform_tel', array( $this, '_mwform_tel' ) );
|
137 |
-
add_shortcode( 'mwform_textarea', array( $this, '_mwform_textarea' ) );
|
138 |
-
add_shortcode( 'mwform_select', array( $this, '_mwform_select' ) );
|
139 |
-
add_shortcode( 'mwform_radio', array( $this, '_mwform_radio' ) );
|
140 |
-
add_shortcode( 'mwform_checkbox', array( $this, '_mwform_checkbox' ) );
|
141 |
-
add_shortcode( 'mwform_datepicker', array( $this, '_mwform_datepicker' ) );
|
142 |
-
|
143 |
// セッション初期化
|
144 |
$this->Session = MW_Session::start( $this->key );
|
145 |
// $_POSTがあるときは$_POST、無いときは$this->Session->getValues()
|
@@ -149,12 +125,12 @@ class mw_wp_form {
|
|
149 |
// セッションデータ設定
|
150 |
$this->Session->clearValues();
|
151 |
if ( !empty( $_POST ) ) $this->Session->save( $_POST );
|
152 |
-
|
153 |
// バリデーションオブジェクト生成
|
154 |
$this->Validation = new MW_Validation( $this->data );
|
155 |
// バリデーション実行(Validation->dataに値がないと$Errorは返さない(true))
|
156 |
$this->apply_filters_mwform_validation();
|
157 |
-
|
158 |
// 入力画面(戻る)のとき
|
159 |
if ( $this->Form->isInput() ) {
|
160 |
$this->redirect( $this->input );
|
@@ -172,16 +148,100 @@ class mw_wp_form {
|
|
172 |
elseif ( $this->Form->isComplete() ) {
|
173 |
if ( $this->Validation->check() ) {
|
174 |
$this->viewFlg = 'complete';
|
175 |
-
|
176 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
177 |
$this->redirect( $this->complete );
|
|
|
178 |
} else {
|
179 |
$this->redirect( $this->input );
|
180 |
}
|
181 |
}
|
182 |
$this->Session->clearValues();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
183 |
}
|
184 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
185 |
/**
|
186 |
* apply_filters_mwform_validation
|
187 |
* バリデーション用フィルタ。フィルタの実行結果としてValidationオブジェクトが返ってこなければエラー
|
@@ -196,19 +256,33 @@ class mw_wp_form {
|
|
196 |
*/
|
197 |
protected function apply_filters_mwform_validation() {
|
198 |
$filterName = 'mwform_validation_'.$this->key;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
199 |
$this->Validation = apply_filters( $filterName, $this->Validation );
|
200 |
if ( !is_a( $this->Validation, 'MW_Validation' ) ) {
|
201 |
exit( __( 'Validation Object is not a MW Validation Class.', self::DOMAIN ) );
|
202 |
}
|
203 |
}
|
204 |
-
|
205 |
/**
|
206 |
-
*
|
207 |
-
*
|
208 |
* @example
|
209 |
* // hoge識別子のフォームのメール送信を行う場合
|
210 |
* // $dataにフォームから送信された内容が配列で格納されている。
|
211 |
-
*
|
212 |
* function mwform_mail_hoge( $m, $data ) {
|
213 |
* $m->to = $data['your_email']; // 宛先
|
214 |
* $m->from = 'inc@2inc.org'; // 送信元
|
@@ -216,14 +290,55 @@ class mw_wp_form {
|
|
216 |
* $m->subject = '送信ありがとうございます。'; // 題名
|
217 |
* $m->body = '本文'; // 本文
|
218 |
* $m->send(); // 送信
|
|
|
219 |
* }
|
220 |
*/
|
221 |
-
protected function
|
222 |
$Mail = new MW_Mail();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
223 |
$actionName = 'mwform_mail_'.$this->key;
|
224 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
225 |
}
|
226 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
227 |
/**
|
228 |
* redirect
|
229 |
* 現在のURLと引数で渡されたリダイレクトURLが同じであればリダイレクトしない
|
@@ -231,12 +346,59 @@ class mw_wp_form {
|
|
231 |
*/
|
232 |
private function redirect( $url ) {
|
233 |
$redirect = ( empty( $url ) ) ? $_SERVER['REQUEST_URI'] : $url;
|
234 |
-
|
|
|
|
|
235 |
wp_redirect( $redirect );
|
236 |
exit();
|
237 |
}
|
238 |
}
|
239 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
240 |
/**
|
241 |
* _mwform
|
242 |
* @example
|
@@ -250,17 +412,9 @@ class mw_wp_form {
|
|
250 |
* 入力画面 : [mwform complete="/form_complete/" key="hoge"]〜[/mwform]
|
251 |
*/
|
252 |
public function _mwform( $atts, $content = '' ) {
|
253 |
-
// 完了画面ではフォームは表示しない
|
254 |
-
$atts = shortcode_atts( array(
|
255 |
-
'input' => '',
|
256 |
-
'preview' => '',
|
257 |
-
'complete' => '',
|
258 |
-
'key' => 'mwform'
|
259 |
-
), $atts );
|
260 |
-
|
261 |
if ( $this->viewFlg == 'input' || $this->viewFlg == 'preview' ) {
|
262 |
$this->Error = $this->Validation->Error();
|
263 |
-
|
264 |
$user = wp_get_current_user();
|
265 |
$search = array(
|
266 |
'{user_id}',
|
@@ -282,16 +436,16 @@ class mw_wp_form {
|
|
282 |
} else {
|
283 |
$content = str_replace( $search, '', $content );
|
284 |
}
|
285 |
-
|
286 |
return
|
287 |
-
'<div id="mw_wp_form_' . $
|
288 |
$this->Form->start() .
|
289 |
do_shortcode( $content ) .
|
290 |
$this->Form->end() .
|
291 |
'<!-- end .mw_wp_form --></div>';
|
292 |
}
|
293 |
}
|
294 |
-
|
295 |
/**
|
296 |
* _mwform_complete_message
|
297 |
* 完了後のメッセージ。同一ページで画面変遷したときだけ実行する
|
@@ -304,7 +458,7 @@ class mw_wp_form {
|
|
304 |
return $content;
|
305 |
}
|
306 |
}
|
307 |
-
|
308 |
/**
|
309 |
* _mwform_error
|
310 |
* エラーを出力。
|
@@ -315,7 +469,7 @@ class mw_wp_form {
|
|
315 |
$form_field = new mw_form_field_error( $this->Form, $atts, $this->viewFlg, $this->Error );
|
316 |
return $form_field->getField();
|
317 |
}
|
318 |
-
|
319 |
/**
|
320 |
* _mwform_text
|
321 |
* テキストフィールドを出力。
|
@@ -326,7 +480,7 @@ class mw_wp_form {
|
|
326 |
$form_field = new mw_form_field_text( $this->Form, $atts, $this->viewFlg, $this->Error );
|
327 |
return $form_field->getField();
|
328 |
}
|
329 |
-
|
330 |
/**
|
331 |
* _mwform_submitButton
|
332 |
* 確認ボタンと送信ボタンを自動出力。同一ページ変遷の場合に利用。
|
@@ -345,7 +499,7 @@ class mw_wp_form {
|
|
345 |
$form_field = new mw_form_field_submit_button( $this->Form, $atts, $this->viewFlg, $this->Error );
|
346 |
return $form_field->getField();
|
347 |
}
|
348 |
-
|
349 |
/**
|
350 |
* _mwform_submit
|
351 |
* サブミットボタンを出力。
|
@@ -356,7 +510,7 @@ class mw_wp_form {
|
|
356 |
$form_field = new mw_form_field_submit( $this->Form, $atts, $this->viewFlg, $this->Error );
|
357 |
return $form_field->getField();
|
358 |
}
|
359 |
-
|
360 |
/**
|
361 |
* _mwform_previewButton
|
362 |
* 確認ボタンを出力。
|
@@ -367,7 +521,7 @@ class mw_wp_form {
|
|
367 |
$form_field = new mw_form_field_preview_button( $this->Form, $atts, $this->viewFlg, $this->Error );
|
368 |
return $form_field->getField();
|
369 |
}
|
370 |
-
|
371 |
/**
|
372 |
* _mwform_backButton
|
373 |
* 戻るボタンを出力。
|
@@ -378,7 +532,7 @@ class mw_wp_form {
|
|
378 |
$form_field = new mw_form_field_back_button( $this->Form, $atts, $this->viewFlg, $this->Error );
|
379 |
return $form_field->getField();
|
380 |
}
|
381 |
-
|
382 |
/**
|
383 |
* _mwform_button
|
384 |
* ボタンを出力。
|
@@ -389,7 +543,7 @@ class mw_wp_form {
|
|
389 |
$form_field = new mw_form_field_button( $this->Form, $atts, $this->viewFlg, $this->Error );
|
390 |
return $form_field->getField();
|
391 |
}
|
392 |
-
|
393 |
/**
|
394 |
* _mwform_hidden
|
395 |
* hiddenフィールドを出力。
|
@@ -400,7 +554,7 @@ class mw_wp_form {
|
|
400 |
$form_field = new mw_form_field_hidden( $this->Form, $atts, $this->viewFlg, $this->Error );
|
401 |
return $form_field->getField();
|
402 |
}
|
403 |
-
|
404 |
/**
|
405 |
* _mwform_password
|
406 |
* パスワードフィールドを出力。
|
@@ -411,7 +565,7 @@ class mw_wp_form {
|
|
411 |
$form_field = new mw_form_field_password( $this->Form, $atts, $this->viewFlg, $this->Error );
|
412 |
return $form_field->getField();
|
413 |
}
|
414 |
-
|
415 |
/**
|
416 |
* _mwform_zip
|
417 |
* 郵便番号フィールドを出力。確認画面からの送信時は-区切りに変換されるが、
|
@@ -423,7 +577,7 @@ class mw_wp_form {
|
|
423 |
$form_field = new mw_form_field_zip( $this->Form, $atts, $this->viewFlg, $this->Error );
|
424 |
return $form_field->getField();
|
425 |
}
|
426 |
-
|
427 |
/**
|
428 |
* _mwform_tel
|
429 |
* 電話番号フィールドを出力。確認画面からの送信時は-区切りに返還されるが、
|
@@ -435,7 +589,7 @@ class mw_wp_form {
|
|
435 |
$form_field = new mw_form_field_tel( $this->Form, $atts, $this->viewFlg, $this->Error );
|
436 |
return $form_field->getField();
|
437 |
}
|
438 |
-
|
439 |
/**
|
440 |
* _mwform_textarea
|
441 |
* テキストエリアを出力。
|
@@ -446,7 +600,7 @@ class mw_wp_form {
|
|
446 |
$form_field = new mw_form_field_textarea( $this->Form, $atts, $this->viewFlg, $this->Error );
|
447 |
return $form_field->getField();
|
448 |
}
|
449 |
-
|
450 |
/**
|
451 |
* _mwform_select
|
452 |
* セレクトボックスを出力。
|
@@ -457,7 +611,7 @@ class mw_wp_form {
|
|
457 |
$form_field = new mw_form_field_select( $this->Form, $atts, $this->viewFlg, $this->Error );
|
458 |
return $form_field->getField();
|
459 |
}
|
460 |
-
|
461 |
/**
|
462 |
* _mwform_radio
|
463 |
* ラジオボタンを出力。
|
@@ -468,7 +622,7 @@ class mw_wp_form {
|
|
468 |
$form_field = new mw_form_field_radio( $this->Form, $atts, $this->viewFlg, $this->Error );
|
469 |
return $form_field->getField();
|
470 |
}
|
471 |
-
|
472 |
/**
|
473 |
* _mwform_checkbox
|
474 |
* チェックボックスを出力。
|
@@ -479,7 +633,7 @@ class mw_wp_form {
|
|
479 |
$form_field = new mw_form_field_checkbox( $this->Form, $atts, $this->viewFlg, $this->Error );
|
480 |
return $form_field->getField();
|
481 |
}
|
482 |
-
|
483 |
/**
|
484 |
* _mwform_datepicker
|
485 |
* datepickerを出力。
|
2 |
/**
|
3 |
* Plugin Name: MW WP Form
|
4 |
* Plugin URI: http://2inc.org/blog/category/products/wordpress_plugins/mw-wp-form/
|
5 |
+
* Description: MW WP Form can create mail form with a confirmation screen using shortcode.
|
6 |
+
* Version: 0.6
|
7 |
* Author: Takashi Kitajima
|
8 |
* Author URI: http://2inc.org
|
9 |
* Created: September 25, 2012
|
10 |
+
* Modified: February 21, 2013
|
11 |
* Text Domain: mw-wp-form
|
12 |
* Domain Path: /languages/
|
13 |
* License: GPL2
|
14 |
*
|
15 |
* Copyright 2013 Takashi Kitajima (email : inc@2inc.org)
|
16 |
+
*
|
17 |
* This program is free software; you can redistribute it and/or modify
|
18 |
* it under the terms of the GNU General Public License, version 2, as
|
19 |
* published by the Free Software Foundation.
|
20 |
+
*
|
21 |
* This program is distributed in the hope that it will be useful,
|
22 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
23 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
24 |
* GNU General Public License for more details.
|
25 |
+
*
|
26 |
* You should have received a copy of the GNU General Public License
|
27 |
* along with this program; if not, write to the Free Software
|
28 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
32 |
|
33 |
const NAME = 'mw-wp-form';
|
34 |
const DOMAIN = 'mw-wp-form';
|
|
|
35 |
protected $key;
|
36 |
protected $input;
|
37 |
protected $preview;
|
42 |
protected $Error;
|
43 |
protected $Session;
|
44 |
protected $viewFlg = 'input';
|
45 |
+
protected $MW_WP_Form_Admin_Page;
|
46 |
+
protected $options_by_formkey;
|
47 |
+
|
48 |
/**
|
49 |
* __construct
|
50 |
*/
|
51 |
public function __construct() {
|
|
|
52 |
load_plugin_textdomain( self::DOMAIN, false, basename( dirname( __FILE__ ) ) . '/languages' );
|
53 |
+
|
54 |
+
// 管理画面の実行
|
55 |
+
include_once( plugin_dir_path( __FILE__ ) . 'system/mw_wp_form_admin_page.php' );
|
56 |
+
$this->MW_WP_Form_Admin_Page = new MW_WP_Form_Admin_Page();
|
57 |
+
add_action( 'init', array( $this, 'register_post_type' ) );
|
58 |
+
|
59 |
+
if ( is_admin() ) return;
|
60 |
+
|
61 |
include_once( plugin_dir_path( __FILE__ ) . 'system/mw_error.php' );
|
62 |
include_once( plugin_dir_path( __FILE__ ) . 'system/mw_form.php' );
|
63 |
include_once( plugin_dir_path( __FILE__ ) . 'system/mw_mail.php' );
|
67 |
foreach( glob( plugin_dir_path( __FILE__ ) . 'form_fields/*.php' ) as $form_field ) {
|
68 |
include_once $form_field;
|
69 |
}
|
70 |
+
add_action( 'wp', array( $this, 'init' ) );
|
|
|
71 |
add_action( 'wp_print_styles', array( $this, 'original_style' ) );
|
72 |
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* register_post_type
|
76 |
+
* 管理画面(カスタム投稿タイプ)の設定
|
77 |
+
*/
|
78 |
+
public function register_post_type() {
|
79 |
+
$this->MW_WP_Form_Admin_Page->register_post_type();
|
80 |
+
}
|
81 |
+
|
82 |
/**
|
83 |
* original_style
|
84 |
* CSS適用
|
85 |
*/
|
86 |
public function original_style() {
|
87 |
+
if ( is_admin() ) return;
|
88 |
$url = plugin_dir_url( __FILE__ );
|
89 |
wp_register_style( self::DOMAIN, $url.'css/style.css' );
|
90 |
wp_enqueue_style( self::DOMAIN );
|
91 |
}
|
92 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
/**
|
94 |
* init
|
95 |
+
* 表示画面でのプラグインの初期化処理等。
|
96 |
*/
|
97 |
public function init() {
|
98 |
global $post;
|
99 |
+
|
100 |
if ( empty( $post->ID ) ) return;
|
101 |
+
|
102 |
+
// URL設定を取得
|
|
|
|
|
103 |
add_shortcode( 'mwform', array( $this, '_meta_mwform' ) );
|
104 |
+
do_shortcode( $post->post_content );
|
105 |
remove_shortcode( 'mwform' );
|
106 |
+
|
107 |
+
// formkeyでのフォーム生成の場合はそれをもとに設定を取得
|
108 |
+
add_shortcode( 'mwform_formkey', array( $this, '_meta_mwform_formkey' ) );
|
109 |
+
do_shortcode( $post->post_content );
|
110 |
+
remove_shortcode( 'mwform_formkey' );
|
111 |
+
|
112 |
+
// フォームが定義されていない場合は終了
|
113 |
+
if ( is_null( $this->key ) ||
|
114 |
+
is_null( $this->input ) ||
|
115 |
+
is_null( $this->preview ) ||
|
116 |
+
is_null( $this->complete ) )
|
117 |
+
return;
|
118 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
// セッション初期化
|
120 |
$this->Session = MW_Session::start( $this->key );
|
121 |
// $_POSTがあるときは$_POST、無いときは$this->Session->getValues()
|
125 |
// セッションデータ設定
|
126 |
$this->Session->clearValues();
|
127 |
if ( !empty( $_POST ) ) $this->Session->save( $_POST );
|
128 |
+
|
129 |
// バリデーションオブジェクト生成
|
130 |
$this->Validation = new MW_Validation( $this->data );
|
131 |
// バリデーション実行(Validation->dataに値がないと$Errorは返さない(true))
|
132 |
$this->apply_filters_mwform_validation();
|
133 |
+
|
134 |
// 入力画面(戻る)のとき
|
135 |
if ( $this->Form->isInput() ) {
|
136 |
$this->redirect( $this->input );
|
148 |
elseif ( $this->Form->isComplete() ) {
|
149 |
if ( $this->Validation->check() ) {
|
150 |
$this->viewFlg = 'complete';
|
151 |
+
|
152 |
+
// 管理画面作成・個別URL・現在画面と完了画面が同じとき以外はメール送信
|
153 |
+
$REQUEST_URI = $this->parse_url( $_SERVER['REQUEST_URI'] );
|
154 |
+
if ( ! ( $this->is_management_different_url() && $REQUEST_URI == $this->complete ) )
|
155 |
+
$this->apply_filters_mwform_mail();
|
156 |
+
|
157 |
+
// 管理画面作成・個別URLのとき以外はクリア
|
158 |
+
if ( ! $this->is_management_different_url() )
|
159 |
+
$this->Form->clearToken();
|
160 |
+
|
161 |
$this->redirect( $this->complete );
|
162 |
+
$this->Form->clearToken();
|
163 |
} else {
|
164 |
$this->redirect( $this->input );
|
165 |
}
|
166 |
}
|
167 |
$this->Session->clearValues();
|
168 |
+
|
169 |
+
// ショートコード有効化
|
170 |
+
add_shortcode( 'mwform_formkey', array( $this, '_mwform_formkey' ) );
|
171 |
+
add_shortcode( 'mwform', array( $this, '_mwform' ) );
|
172 |
+
add_shortcode( 'mwform_complete_message', array( $this, '_mwform_complete_message' ) );
|
173 |
+
add_shortcode( 'mwform_error', array( $this, '_mwform_error' ) );
|
174 |
+
add_shortcode( 'mwform_text', array( $this, '_mwform_text' ) );
|
175 |
+
add_shortcode( 'mwform_submitButton', array( $this, '_mwform_submitButton' ) );
|
176 |
+
add_shortcode( 'mwform_submit', array( $this, '_mwform_submit' ) );
|
177 |
+
add_shortcode( 'mwform_previewButton', array( $this, '_mwform_previewButton' ) );
|
178 |
+
add_shortcode( 'mwform_backButton', array( $this, '_mwform_backButton' ) );
|
179 |
+
add_shortcode( 'mwform_button', array( $this, '_mwform_button' ) );
|
180 |
+
add_shortcode( 'mwform_hidden', array( $this, '_mwform_hidden' ) );
|
181 |
+
add_shortcode( 'mwform_password', array( $this, '_mwform_password' ) );
|
182 |
+
add_shortcode( 'mwform_zip', array( $this, '_mwform_zip' ) );
|
183 |
+
add_shortcode( 'mwform_tel', array( $this, '_mwform_tel' ) );
|
184 |
+
add_shortcode( 'mwform_textarea', array( $this, '_mwform_textarea' ) );
|
185 |
+
add_shortcode( 'mwform_select', array( $this, '_mwform_select' ) );
|
186 |
+
add_shortcode( 'mwform_radio', array( $this, '_mwform_radio' ) );
|
187 |
+
add_shortcode( 'mwform_checkbox', array( $this, '_mwform_checkbox' ) );
|
188 |
+
add_shortcode( 'mwform_datepicker', array( $this, '_mwform_datepicker' ) );
|
189 |
}
|
190 |
|
191 |
+
/**
|
192 |
+
* is_management_different_url
|
193 |
+
* 管理画面作成・個別URLのときtrueを返す
|
194 |
+
* @return Boolean
|
195 |
+
*/
|
196 |
+
protected function is_management_different_url() {
|
197 |
+
if ( !empty( $this->options_by_formkey ) && ( $this->input !== $this->complete || $this->preview !== $this->complete ) ) {
|
198 |
+
return true;
|
199 |
+
} else {
|
200 |
+
return false;
|
201 |
+
}
|
202 |
+
}
|
203 |
+
|
204 |
+
/**
|
205 |
+
* _meta_mwform
|
206 |
+
* [mwform〜]を解析し、プロパティを設定
|
207 |
+
* @param Array ( input, preview, complete, key )
|
208 |
+
*/
|
209 |
+
public function _meta_mwform( $atts ) {
|
210 |
+
$atts = shortcode_atts( array(
|
211 |
+
'input' => '',
|
212 |
+
'preview' => '',
|
213 |
+
'complete' => '',
|
214 |
+
'key' => 'mwform'
|
215 |
+
), $atts );
|
216 |
+
$this->key = $atts['key'];
|
217 |
+
$this->input = $this->parse_url( $atts['input'] );
|
218 |
+
$this->preview = $this->parse_url( $atts['preview'] );
|
219 |
+
$this->complete = $this->parse_url( $atts['complete'] );
|
220 |
+
}
|
221 |
+
|
222 |
+
/**
|
223 |
+
* _meta_mwform_formkey
|
224 |
+
* formkeyをもとにフォームの設定を取得
|
225 |
+
*/
|
226 |
+
public function _meta_mwform_formkey( $atts ) {
|
227 |
+
global $post;
|
228 |
+
$atts = shortcode_atts( array(
|
229 |
+
'key' => ''
|
230 |
+
), $atts );
|
231 |
+
$post = get_post( $atts['key'] );
|
232 |
+
if ( !empty( $post ) ) {
|
233 |
+
setup_postdata( $post );
|
234 |
+
if ( get_post_type() === self::NAME ) {
|
235 |
+
$this->options_by_formkey = get_post_meta( $post->ID, self::NAME, true );
|
236 |
+
$this->key = self::NAME.'-'.$atts['key'];
|
237 |
+
$this->input = $this->options_by_formkey['input_url'];
|
238 |
+
$this->preview = $this->options_by_formkey['confirmation_url'];
|
239 |
+
$this->complete = $this->options_by_formkey['complete_url'];
|
240 |
+
}
|
241 |
+
}
|
242 |
+
wp_reset_postdata();
|
243 |
+
}
|
244 |
+
|
245 |
/**
|
246 |
* apply_filters_mwform_validation
|
247 |
* バリデーション用フィルタ。フィルタの実行結果としてValidationオブジェクトが返ってこなければエラー
|
256 |
*/
|
257 |
protected function apply_filters_mwform_validation() {
|
258 |
$filterName = 'mwform_validation_'.$this->key;
|
259 |
+
|
260 |
+
if ( $this->options_by_formkey ) {
|
261 |
+
foreach ( $this->options_by_formkey['validation'] as $validation ) {
|
262 |
+
foreach ( $validation as $key => $val ) {
|
263 |
+
if ( $key == 'target' ) continue;
|
264 |
+
if ( is_array( $val ) ) {
|
265 |
+
$this->Validation->setRule( $validation['target'], $key, $val );
|
266 |
+
} else {
|
267 |
+
$this->Validation->setRule( $validation['target'], $key );
|
268 |
+
}
|
269 |
+
}
|
270 |
+
}
|
271 |
+
}
|
272 |
+
|
273 |
$this->Validation = apply_filters( $filterName, $this->Validation );
|
274 |
if ( !is_a( $this->Validation, 'MW_Validation' ) ) {
|
275 |
exit( __( 'Validation Object is not a MW Validation Class.', self::DOMAIN ) );
|
276 |
}
|
277 |
}
|
278 |
+
|
279 |
/**
|
280 |
+
* apply_filters_mwform_mail
|
281 |
+
* メール送信フィルター
|
282 |
* @example
|
283 |
* // hoge識別子のフォームのメール送信を行う場合
|
284 |
* // $dataにフォームから送信された内容が配列で格納されている。
|
285 |
+
* add_filters( 'mwform_mail_hoge', 'mwform_mail_hoge', 10, 2 );
|
286 |
* function mwform_mail_hoge( $m, $data ) {
|
287 |
* $m->to = $data['your_email']; // 宛先
|
288 |
* $m->from = 'inc@2inc.org'; // 送信元
|
290 |
* $m->subject = '送信ありがとうございます。'; // 題名
|
291 |
* $m->body = '本文'; // 本文
|
292 |
* $m->send(); // 送信
|
293 |
+
* return $m;
|
294 |
* }
|
295 |
*/
|
296 |
+
protected function apply_filters_mwform_mail() {
|
297 |
$Mail = new MW_Mail();
|
298 |
+
|
299 |
+
if ( $this->options_by_formkey ) {
|
300 |
+
// 送信先を指定
|
301 |
+
$Mail->to = get_bloginfo( 'admin_email' );
|
302 |
+
// 送信元を指定
|
303 |
+
$Mail->from = get_bloginfo( 'admin_email' );
|
304 |
+
// 送信者を指定
|
305 |
+
$Mail->sender = get_bloginfo( 'name' );
|
306 |
+
// タイトルを指定
|
307 |
+
$Mail->subject = $this->options_by_formkey['mail_subject'];
|
308 |
+
// 本文を指定
|
309 |
+
$body = $this->options_by_formkey['mail_content'];
|
310 |
+
$Mail->body = preg_replace_callback(
|
311 |
+
'/{(.+?)}/',
|
312 |
+
array( $this, 'create_mail_body' ),
|
313 |
+
$body
|
314 |
+
);
|
315 |
+
}
|
316 |
+
|
317 |
$actionName = 'mwform_mail_'.$this->key;
|
318 |
+
$Mail = apply_filters( $actionName, $Mail, $this->data );
|
319 |
+
|
320 |
+
if ( $this->options_by_formkey && !empty( $Mail ) ) {
|
321 |
+
$Mail->send();
|
322 |
+
if ( isset( $this->options_by_formkey['automatic_reply_email'], $this->data[$this->options_by_formkey['automatic_reply_email']] ) && !$this->Validation->mail( $this->data[$this->options_by_formkey['automatic_reply_email']] ) ) {
|
323 |
+
$Mail->to = $this->data[$this->options_by_formkey['automatic_reply_email']];
|
324 |
+
$Mail->send();
|
325 |
+
}
|
326 |
+
}
|
327 |
}
|
328 |
+
public function create_mail_body( $matches ) {
|
329 |
+
if ( !isset( $this->data[$matches[1]] ) )
|
330 |
+
return;
|
331 |
+
if ( is_array( $this->data[$matches[1]] ) ) {
|
332 |
+
if ( !array_key_exists( 'data', $this->data[$matches[1]] ) )
|
333 |
+
return;
|
334 |
+
if ( is_array( $this->data[$matches[1]]['data'] ) )
|
335 |
+
return $this->Form->getZipValue( $matches[1] );
|
336 |
+
return $this->data[$matches[1]]['data'];
|
337 |
+
} else {
|
338 |
+
return $this->data[$matches[1]];
|
339 |
+
}
|
340 |
+
}
|
341 |
+
|
342 |
/**
|
343 |
* redirect
|
344 |
* 現在のURLと引数で渡されたリダイレクトURLが同じであればリダイレクトしない
|
346 |
*/
|
347 |
private function redirect( $url ) {
|
348 |
$redirect = ( empty( $url ) ) ? $_SERVER['REQUEST_URI'] : $url;
|
349 |
+
$redirect = $this->parse_url( $redirect );
|
350 |
+
$REQUEST_URI = $this->parse_url( $_SERVER['REQUEST_URI'] );
|
351 |
+
if ( $redirect != $REQUEST_URI || $this->Form->isInput() && !empty( $_POST ) ) {
|
352 |
wp_redirect( $redirect );
|
353 |
exit();
|
354 |
}
|
355 |
}
|
356 |
+
|
357 |
+
/**
|
358 |
+
* parse_url
|
359 |
+
* http:// からはじまるURLに変換する
|
360 |
+
* @param String URL
|
361 |
+
* @return String URL
|
362 |
+
*/
|
363 |
+
protected function parse_url( $url ) {
|
364 |
+
if ( empty( $url ) ) {
|
365 |
+
return '';
|
366 |
+
}
|
367 |
+
if ( !preg_match( '/^https?:\/\//', $url ) ) {
|
368 |
+
$url = home_url() . '/' . $url;
|
369 |
+
}
|
370 |
+
$url = preg_replace( '/([^:])\/+/', '$1/', $url );
|
371 |
+
$url = trailingslashit( $url );
|
372 |
+
return $url;
|
373 |
+
}
|
374 |
+
|
375 |
+
/**
|
376 |
+
* _mwform_formkey
|
377 |
+
* 管理画面で作成したフォームを出力
|
378 |
+
* @example
|
379 |
+
* [mwform_formkey keys="post_id"]
|
380 |
+
*/
|
381 |
+
public function _mwform_formkey( $atts ) {
|
382 |
+
global $post;
|
383 |
+
$atts = shortcode_atts( array(
|
384 |
+
'key' => ''
|
385 |
+
), $atts );
|
386 |
+
$_mwform = '[mwform key="'.$this->key.'" input="'.$this->input.'" preview="'.$this->preview.'" complete="'.$this->complete.'"]';
|
387 |
+
$post = get_post( $atts['key'] );
|
388 |
+
setup_postdata( $post );
|
389 |
+
|
390 |
+
// 入力画面・確認画面
|
391 |
+
if ( $this->viewFlg == 'input' || $this->viewFlg == 'preview' ) {
|
392 |
+
$_ret = do_shortcode( $_mwform . get_the_content() . '[/mwform]' );
|
393 |
+
}
|
394 |
+
// 完了画面
|
395 |
+
elseif( $this->viewFlg == 'complete' ) {
|
396 |
+
$_ret = do_shortcode( '[mwform_complete_message]'.$this->options_by_formkey['complete_message'].'[/mwform_complete_message]' );
|
397 |
+
}
|
398 |
+
wp_reset_postdata();
|
399 |
+
return $_ret;
|
400 |
+
}
|
401 |
+
|
402 |
/**
|
403 |
* _mwform
|
404 |
* @example
|
412 |
* 入力画面 : [mwform complete="/form_complete/" key="hoge"]〜[/mwform]
|
413 |
*/
|
414 |
public function _mwform( $atts, $content = '' ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
415 |
if ( $this->viewFlg == 'input' || $this->viewFlg == 'preview' ) {
|
416 |
$this->Error = $this->Validation->Error();
|
417 |
+
|
418 |
$user = wp_get_current_user();
|
419 |
$search = array(
|
420 |
'{user_id}',
|
436 |
} else {
|
437 |
$content = str_replace( $search, '', $content );
|
438 |
}
|
439 |
+
|
440 |
return
|
441 |
+
'<div id="mw_wp_form_' . $this->key . '" class="mw_wp_form">' .
|
442 |
$this->Form->start() .
|
443 |
do_shortcode( $content ) .
|
444 |
$this->Form->end() .
|
445 |
'<!-- end .mw_wp_form --></div>';
|
446 |
}
|
447 |
}
|
448 |
+
|
449 |
/**
|
450 |
* _mwform_complete_message
|
451 |
* 完了後のメッセージ。同一ページで画面変遷したときだけ実行する
|
458 |
return $content;
|
459 |
}
|
460 |
}
|
461 |
+
|
462 |
/**
|
463 |
* _mwform_error
|
464 |
* エラーを出力。
|
469 |
$form_field = new mw_form_field_error( $this->Form, $atts, $this->viewFlg, $this->Error );
|
470 |
return $form_field->getField();
|
471 |
}
|
472 |
+
|
473 |
/**
|
474 |
* _mwform_text
|
475 |
* テキストフィールドを出力。
|
480 |
$form_field = new mw_form_field_text( $this->Form, $atts, $this->viewFlg, $this->Error );
|
481 |
return $form_field->getField();
|
482 |
}
|
483 |
+
|
484 |
/**
|
485 |
* _mwform_submitButton
|
486 |
* 確認ボタンと送信ボタンを自動出力。同一ページ変遷の場合に利用。
|
499 |
$form_field = new mw_form_field_submit_button( $this->Form, $atts, $this->viewFlg, $this->Error );
|
500 |
return $form_field->getField();
|
501 |
}
|
502 |
+
|
503 |
/**
|
504 |
* _mwform_submit
|
505 |
* サブミットボタンを出力。
|
510 |
$form_field = new mw_form_field_submit( $this->Form, $atts, $this->viewFlg, $this->Error );
|
511 |
return $form_field->getField();
|
512 |
}
|
513 |
+
|
514 |
/**
|
515 |
* _mwform_previewButton
|
516 |
* 確認ボタンを出力。
|
521 |
$form_field = new mw_form_field_preview_button( $this->Form, $atts, $this->viewFlg, $this->Error );
|
522 |
return $form_field->getField();
|
523 |
}
|
524 |
+
|
525 |
/**
|
526 |
* _mwform_backButton
|
527 |
* 戻るボタンを出力。
|
532 |
$form_field = new mw_form_field_back_button( $this->Form, $atts, $this->viewFlg, $this->Error );
|
533 |
return $form_field->getField();
|
534 |
}
|
535 |
+
|
536 |
/**
|
537 |
* _mwform_button
|
538 |
* ボタンを出力。
|
543 |
$form_field = new mw_form_field_button( $this->Form, $atts, $this->viewFlg, $this->Error );
|
544 |
return $form_field->getField();
|
545 |
}
|
546 |
+
|
547 |
/**
|
548 |
* _mwform_hidden
|
549 |
* hiddenフィールドを出力。
|
554 |
$form_field = new mw_form_field_hidden( $this->Form, $atts, $this->viewFlg, $this->Error );
|
555 |
return $form_field->getField();
|
556 |
}
|
557 |
+
|
558 |
/**
|
559 |
* _mwform_password
|
560 |
* パスワードフィールドを出力。
|
565 |
$form_field = new mw_form_field_password( $this->Form, $atts, $this->viewFlg, $this->Error );
|
566 |
return $form_field->getField();
|
567 |
}
|
568 |
+
|
569 |
/**
|
570 |
* _mwform_zip
|
571 |
* 郵便番号フィールドを出力。確認画面からの送信時は-区切りに変換されるが、
|
577 |
$form_field = new mw_form_field_zip( $this->Form, $atts, $this->viewFlg, $this->Error );
|
578 |
return $form_field->getField();
|
579 |
}
|
580 |
+
|
581 |
/**
|
582 |
* _mwform_tel
|
583 |
* 電話番号フィールドを出力。確認画面からの送信時は-区切りに返還されるが、
|
589 |
$form_field = new mw_form_field_tel( $this->Form, $atts, $this->viewFlg, $this->Error );
|
590 |
return $form_field->getField();
|
591 |
}
|
592 |
+
|
593 |
/**
|
594 |
* _mwform_textarea
|
595 |
* テキストエリアを出力。
|
600 |
$form_field = new mw_form_field_textarea( $this->Form, $atts, $this->viewFlg, $this->Error );
|
601 |
return $form_field->getField();
|
602 |
}
|
603 |
+
|
604 |
/**
|
605 |
* _mwform_select
|
606 |
* セレクトボックスを出力。
|
611 |
$form_field = new mw_form_field_select( $this->Form, $atts, $this->viewFlg, $this->Error );
|
612 |
return $form_field->getField();
|
613 |
}
|
614 |
+
|
615 |
/**
|
616 |
* _mwform_radio
|
617 |
* ラジオボタンを出力。
|
622 |
$form_field = new mw_form_field_radio( $this->Form, $atts, $this->viewFlg, $this->Error );
|
623 |
return $form_field->getField();
|
624 |
}
|
625 |
+
|
626 |
/**
|
627 |
* _mwform_checkbox
|
628 |
* チェックボックスを出力。
|
633 |
$form_field = new mw_form_field_checkbox( $this->Form, $atts, $this->viewFlg, $this->Error );
|
634 |
return $form_field->getField();
|
635 |
}
|
636 |
+
|
637 |
/**
|
638 |
* _mwform_datepicker
|
639 |
* datepickerを出力。
|
readme.txt
CHANGED
@@ -1,29 +1,40 @@
|
|
1 |
=== Plugin Name ===
|
2 |
Contributors: Takashi Kitajima
|
3 |
-
Donate link:
|
4 |
Tags: plugin, form, confirm, preview
|
5 |
Requires at least: 3.4
|
6 |
Tested up to: 3.5
|
7 |
-
Stable tag: 0.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
11 |
-
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
-
|
|
|
|
|
|
|
|
|
16 |
http://2inc.org/blog/category/products/wordpress_plugins/mw-wp-form/
|
17 |
|
18 |
== Installation ==
|
19 |
|
20 |
1. Upload `MW WP Form` to the `/wp-content/plugins/` directory
|
21 |
1. Activate the plugin through the 'Plugins' menu in WordPress
|
22 |
-
1.
|
23 |
-
1.
|
|
|
24 |
|
25 |
== Changelog ==
|
26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
= 0.5.5 =
|
28 |
* Added tag to show login user meta.
|
29 |
{user_id}, {user_login}, {user_email}, {user_url}, {user_registered}, {display_name}
|
1 |
=== Plugin Name ===
|
2 |
Contributors: Takashi Kitajima
|
3 |
+
Donate link:
|
4 |
Tags: plugin, form, confirm, preview
|
5 |
Requires at least: 3.4
|
6 |
Tested up to: 3.5
|
7 |
+
Stable tag: 0.6
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
11 |
+
MW WP Form can create mail form with a confirmation screen using shortcode.
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
+
MW WP Form can create mail form with a confirmation screen using shortcode.
|
16 |
+
* Form created using short codes
|
17 |
+
* Using confirmation page.
|
18 |
+
* The page changes by the same URL or individual URL are possible.
|
19 |
+
* Many validation rules
|
20 |
http://2inc.org/blog/category/products/wordpress_plugins/mw-wp-form/
|
21 |
|
22 |
== Installation ==
|
23 |
|
24 |
1. Upload `MW WP Form` to the `/wp-content/plugins/` directory
|
25 |
1. Activate the plugin through the 'Plugins' menu in WordPress
|
26 |
+
1. You can create a form by settings page or using functions.php.
|
27 |
+
1. If you using functions.php, place `<?php add_filter( 'mwform_validation_{$key}', array( $this, 'my_validation_filter_name' ) ); ?>` in your functions.php
|
28 |
+
1. If you using functions.php, place `<?php add_filter( 'mwform_mail_{$key}', array( $this, 'my_mail_action_name' ) ); ?>` in your functions.php
|
29 |
|
30 |
== Changelog ==
|
31 |
|
32 |
+
= 0.6 =
|
33 |
+
* Added settings page.
|
34 |
+
* Deprecated: acton hook mwform_mail_{$key}. This hook is removed when next version up.
|
35 |
+
* Added filter hook mwform_mail_{$key}.
|
36 |
+
* Bug fix: Validations.
|
37 |
+
|
38 |
= 0.5.5 =
|
39 |
* Added tag to show login user meta.
|
40 |
{user_id}, {user_login}, {user_email}, {user_url}, {user_registered}, {display_name}
|
system/mw_form.php
CHANGED
@@ -3,24 +3,24 @@
|
|
3 |
* Name: MW Form
|
4 |
* URI: http://2inc.org
|
5 |
* Description: フォームクラス
|
6 |
-
* Version: 1.2.
|
7 |
* Author: Takashi Kitajima
|
8 |
* Author URI: http://2inc.org
|
9 |
* Created: September 25, 2012
|
10 |
-
* Modified:
|
11 |
* License: GPL2
|
12 |
*
|
13 |
-
* Copyright
|
14 |
-
*
|
15 |
* This program is free software; you can redistribute it and/or modify
|
16 |
* it under the terms of the GNU General Public License, version 2, as
|
17 |
* published by the Free Software Foundation.
|
18 |
-
*
|
19 |
* This program is distributed in the hope that it will be useful,
|
20 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
21 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
22 |
* GNU General Public License for more details.
|
23 |
-
*
|
24 |
* You should have received a copy of the GNU General Public License
|
25 |
* along with this program; if not, write to the Free Software
|
26 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
@@ -61,7 +61,7 @@ class MW_Form {
|
|
61 |
$this->data = array();
|
62 |
}
|
63 |
}
|
64 |
-
|
65 |
/**
|
66 |
* clearToken
|
67 |
* トークン用のセッションを破棄
|
@@ -137,12 +137,12 @@ class MW_Form {
|
|
137 |
* @return Boolean
|
138 |
*/
|
139 |
protected function check() {
|
140 |
-
if ( isset( $
|
|
|
141 |
$_ret = false;
|
142 |
$s_token = $this->Session->getValue( $this->tokenName );
|
143 |
-
if ( isset( $requestToken ) && !empty( $s_token ) && $requestToken == $s_token )
|
144 |
$_ret = true;
|
145 |
-
}
|
146 |
return $_ret;
|
147 |
}
|
148 |
|
@@ -221,7 +221,7 @@ class MW_Form {
|
|
221 |
public function getCheckedValue( $key, Array $data ) {
|
222 |
$_ret = null;
|
223 |
$separator = $this->getSeparatorValue( $key );
|
224 |
-
if ( is_array( $this->data[$key]['data'] ) && array_key_exists( 'data', $this->data[$key] ) && !empty( $separator ) ) {
|
225 |
foreach ( $this->data[$key]['data'] as $val ) {
|
226 |
if ( isset( $data[$val] ) ) {
|
227 |
$_ret = implode( $separator, $this->data[$key]['data'] );
|
@@ -513,7 +513,7 @@ class MW_Form {
|
|
513 |
'value' => array()
|
514 |
);
|
515 |
$options = array_merge( $defaults, $options );
|
516 |
-
|
517 |
$value = $options['value'];
|
518 |
if ( isset( $this->data[$name]['data'] ) ) {
|
519 |
$value = $this->data[$name]['data'];
|
@@ -585,7 +585,7 @@ class MW_Form {
|
|
585 |
',$this->e( $name ), $options['js'] );
|
586 |
return $_ret;
|
587 |
}
|
588 |
-
|
589 |
/**
|
590 |
* e
|
591 |
* htmlサニタイズ
|
3 |
* Name: MW Form
|
4 |
* URI: http://2inc.org
|
5 |
* Description: フォームクラス
|
6 |
+
* Version: 1.2.7
|
7 |
* Author: Takashi Kitajima
|
8 |
* Author URI: http://2inc.org
|
9 |
* Created: September 25, 2012
|
10 |
+
* Modified: February 20, 2013
|
11 |
* License: GPL2
|
12 |
*
|
13 |
+
* Copyright 2013 Takashi Kitajima (email : inc@2inc.org)
|
14 |
+
*
|
15 |
* This program is free software; you can redistribute it and/or modify
|
16 |
* it under the terms of the GNU General Public License, version 2, as
|
17 |
* published by the Free Software Foundation.
|
18 |
+
*
|
19 |
* This program is distributed in the hope that it will be useful,
|
20 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
21 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
22 |
* GNU General Public License for more details.
|
23 |
+
*
|
24 |
* You should have received a copy of the GNU General Public License
|
25 |
* along with this program; if not, write to the Free Software
|
26 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
61 |
$this->data = array();
|
62 |
}
|
63 |
}
|
64 |
+
|
65 |
/**
|
66 |
* clearToken
|
67 |
* トークン用のセッションを破棄
|
137 |
* @return Boolean
|
138 |
*/
|
139 |
protected function check() {
|
140 |
+
if ( isset( $this->data[$this->tokenName] ) )
|
141 |
+
$requestToken = $this->data[$this->tokenName];
|
142 |
$_ret = false;
|
143 |
$s_token = $this->Session->getValue( $this->tokenName );
|
144 |
+
if ( isset( $requestToken ) && !empty( $s_token ) && $requestToken == $s_token )
|
145 |
$_ret = true;
|
|
|
146 |
return $_ret;
|
147 |
}
|
148 |
|
221 |
public function getCheckedValue( $key, Array $data ) {
|
222 |
$_ret = null;
|
223 |
$separator = $this->getSeparatorValue( $key );
|
224 |
+
if ( isset( $this->data[$key]['data'] ) && is_array( $this->data[$key]['data'] ) && array_key_exists( 'data', $this->data[$key] ) && !empty( $separator ) ) {
|
225 |
foreach ( $this->data[$key]['data'] as $val ) {
|
226 |
if ( isset( $data[$val] ) ) {
|
227 |
$_ret = implode( $separator, $this->data[$key]['data'] );
|
513 |
'value' => array()
|
514 |
);
|
515 |
$options = array_merge( $defaults, $options );
|
516 |
+
|
517 |
$value = $options['value'];
|
518 |
if ( isset( $this->data[$name]['data'] ) ) {
|
519 |
$value = $this->data[$name]['data'];
|
585 |
',$this->e( $name ), $options['js'] );
|
586 |
return $_ret;
|
587 |
}
|
588 |
+
|
589 |
/**
|
590 |
* e
|
591 |
* htmlサニタイズ
|
system/mw_mail.php
CHANGED
@@ -11,16 +11,16 @@
|
|
11 |
* License: GPL2
|
12 |
*
|
13 |
* Copyright 2012 Takashi Kitajima (email : inc@2inc.org)
|
14 |
-
*
|
15 |
* This program is free software; you can redistribute it and/or modify
|
16 |
* it under the terms of the GNU General Public License, version 2, as
|
17 |
* published by the Free Software Foundation.
|
18 |
-
*
|
19 |
* This program is distributed in the hope that it will be useful,
|
20 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
21 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
22 |
* GNU General Public License for more details.
|
23 |
-
*
|
24 |
* You should have received a copy of the GNU General Public License
|
25 |
* along with this program; if not, write to the Free Software
|
26 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
@@ -73,7 +73,7 @@ class MW_Mail {
|
|
73 |
wp_mail( $this->to, $subject, $body, $header );
|
74 |
// mail( $this->to, $subject, $body, $header );
|
75 |
}
|
76 |
-
|
77 |
/**
|
78 |
* createBody
|
79 |
* 配列からbodyを生成
|
@@ -105,7 +105,7 @@ class MW_Mail {
|
|
105 |
}
|
106 |
return $_ret;
|
107 |
}
|
108 |
-
|
109 |
/**
|
110 |
* e
|
111 |
* htmlサニタイズ
|
11 |
* License: GPL2
|
12 |
*
|
13 |
* Copyright 2012 Takashi Kitajima (email : inc@2inc.org)
|
14 |
+
*
|
15 |
* This program is free software; you can redistribute it and/or modify
|
16 |
* it under the terms of the GNU General Public License, version 2, as
|
17 |
* published by the Free Software Foundation.
|
18 |
+
*
|
19 |
* This program is distributed in the hope that it will be useful,
|
20 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
21 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
22 |
* GNU General Public License for more details.
|
23 |
+
*
|
24 |
* You should have received a copy of the GNU General Public License
|
25 |
* along with this program; if not, write to the Free Software
|
26 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
73 |
wp_mail( $this->to, $subject, $body, $header );
|
74 |
// mail( $this->to, $subject, $body, $header );
|
75 |
}
|
76 |
+
|
77 |
/**
|
78 |
* createBody
|
79 |
* 配列からbodyを生成
|
105 |
}
|
106 |
return $_ret;
|
107 |
}
|
108 |
+
|
109 |
/**
|
110 |
* e
|
111 |
* htmlサニタイズ
|
system/mw_validation.php
CHANGED
@@ -3,14 +3,14 @@
|
|
3 |
* Name: MW Validation
|
4 |
* URI: http://2inc.org
|
5 |
* Description: バリデーションクラス
|
6 |
-
* Version: 1.2.
|
7 |
* Author: Takashi Kitajima
|
8 |
* Author URI: http://2inc.org
|
9 |
* Created: July 20, 2012
|
10 |
-
* Modified:
|
11 |
* License: GPL2
|
12 |
*
|
13 |
-
* Copyright
|
14 |
*
|
15 |
* This program is free software; you can redistribute it and/or modify
|
16 |
* it under the terms of the GNU General Public License, version 2, as
|
@@ -95,7 +95,7 @@ class MW_Validation {
|
|
95 |
'message' => __( 'Please enter.', self::DOMAIN )
|
96 |
);
|
97 |
$options = array_merge( $defaults, $options );
|
98 |
-
if ( $
|
99 |
$_ret = $options['message'];
|
100 |
}
|
101 |
}
|
@@ -139,7 +139,7 @@ class MW_Validation {
|
|
139 |
'message' => __( 'Please enter with a half-width alphabetic character.', self::DOMAIN )
|
140 |
);
|
141 |
$options = array_merge( $defaults, $options );
|
142 |
-
if ( !preg_match( '/^[A-Za-z]+$/', $value ) ) {
|
143 |
$_ret = $options['message'];
|
144 |
}
|
145 |
}
|
@@ -161,7 +161,7 @@ class MW_Validation {
|
|
161 |
'message' => __( 'Please enter with a half-width number.', self::DOMAIN )
|
162 |
);
|
163 |
$options = array_merge( $defaults, $options );
|
164 |
-
if ( !preg_match( '/^[0-9]+$/', $value ) ) {
|
165 |
$_ret = $options['message'];
|
166 |
}
|
167 |
}
|
@@ -183,7 +183,7 @@ class MW_Validation {
|
|
183 |
'message' => __( 'Please enter with a half-width alphanumeric character.', self::DOMAIN )
|
184 |
);
|
185 |
$options = array_merge( $defaults, $options );
|
186 |
-
if ( !preg_match( '/^[0-9A-Za-z]+$/', $value ) ) {
|
187 |
$_ret = $options['message'];
|
188 |
}
|
189 |
}
|
@@ -259,7 +259,7 @@ class MW_Validation {
|
|
259 |
'message' => __( 'This is not the format of a mail address.', self::DOMAIN )
|
260 |
);
|
261 |
$options = array_merge( $defaults, $options );
|
262 |
-
if ( !preg_match( '/^.+@.+$/', $value ) ) {
|
263 |
$_ret = $options['message'];
|
264 |
}
|
265 |
}
|
@@ -281,7 +281,7 @@ class MW_Validation {
|
|
281 |
'message' => __( 'This is not the format of a url.', self::DOMAIN )
|
282 |
);
|
283 |
$options = array_merge( $defaults, $options );
|
284 |
-
if ( !preg_match( '/^https{0,1}:\/\//', $value ) ) {
|
285 |
$_ret = $options['message'];
|
286 |
}
|
287 |
}
|
@@ -485,5 +485,19 @@ class MW_Validation {
|
|
485 |
protected function array_clean( $array ) {
|
486 |
return array_merge( array_diff( $array, array( '' ) ) );
|
487 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
488 |
}
|
489 |
?>
|
3 |
* Name: MW Validation
|
4 |
* URI: http://2inc.org
|
5 |
* Description: バリデーションクラス
|
6 |
+
* Version: 1.2.2
|
7 |
* Author: Takashi Kitajima
|
8 |
* Author URI: http://2inc.org
|
9 |
* Created: July 20, 2012
|
10 |
+
* Modified: February 20, 2013
|
11 |
* License: GPL2
|
12 |
*
|
13 |
+
* Copyright 2013 Takashi Kitajima (email : inc@2inc.org)
|
14 |
*
|
15 |
* This program is free software; you can redistribute it and/or modify
|
16 |
* it under the terms of the GNU General Public License, version 2, as
|
95 |
'message' => __( 'Please enter.', self::DOMAIN )
|
96 |
);
|
97 |
$options = array_merge( $defaults, $options );
|
98 |
+
if ( $this->isEmpty( $value ) ) {
|
99 |
$_ret = $options['message'];
|
100 |
}
|
101 |
}
|
139 |
'message' => __( 'Please enter with a half-width alphabetic character.', self::DOMAIN )
|
140 |
);
|
141 |
$options = array_merge( $defaults, $options );
|
142 |
+
if ( !preg_match( '/^[A-Za-z]+$/', $value ) && !$this->isEmpty( $value ) ) {
|
143 |
$_ret = $options['message'];
|
144 |
}
|
145 |
}
|
161 |
'message' => __( 'Please enter with a half-width number.', self::DOMAIN )
|
162 |
);
|
163 |
$options = array_merge( $defaults, $options );
|
164 |
+
if ( !preg_match( '/^[0-9]+$/', $value ) && !$this->isEmpty( $value ) ) {
|
165 |
$_ret = $options['message'];
|
166 |
}
|
167 |
}
|
183 |
'message' => __( 'Please enter with a half-width alphanumeric character.', self::DOMAIN )
|
184 |
);
|
185 |
$options = array_merge( $defaults, $options );
|
186 |
+
if ( !preg_match( '/^[0-9A-Za-z]+$/', $value ) && !$this->isEmpty( $value ) ) {
|
187 |
$_ret = $options['message'];
|
188 |
}
|
189 |
}
|
259 |
'message' => __( 'This is not the format of a mail address.', self::DOMAIN )
|
260 |
);
|
261 |
$options = array_merge( $defaults, $options );
|
262 |
+
if ( !preg_match( '/^.+@.+$/', $value ) && !$this->isEmpty( $value ) ) {
|
263 |
$_ret = $options['message'];
|
264 |
}
|
265 |
}
|
281 |
'message' => __( 'This is not the format of a url.', self::DOMAIN )
|
282 |
);
|
283 |
$options = array_merge( $defaults, $options );
|
284 |
+
if ( !preg_match( '/^https{0,1}:\/\//', $value ) && !$this->isEmpty( $value ) ) {
|
285 |
$_ret = $options['message'];
|
286 |
}
|
287 |
}
|
485 |
protected function array_clean( $array ) {
|
486 |
return array_merge( array_diff( $array, array( '' ) ) );
|
487 |
}
|
488 |
+
|
489 |
+
/**
|
490 |
+
* noempty
|
491 |
+
* 値が空(0は許可)
|
492 |
+
* @param Mixed
|
493 |
+
* @return Boolean
|
494 |
+
*/
|
495 |
+
protected function isEmpty( $value ) {
|
496 |
+
if ( $value == array() || $value === '' || $value === null ) {
|
497 |
+
return true;
|
498 |
+
} else {
|
499 |
+
return false;
|
500 |
+
}
|
501 |
+
}
|
502 |
}
|
503 |
?>
|
system/mw_wp_form_admin_page.php
ADDED
@@ -0,0 +1,469 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Name: MW WP Form Admin Page
|
4 |
+
* URI: http://2inc.org
|
5 |
+
* Description: 管理画面クラス
|
6 |
+
* Version: 1.0
|
7 |
+
* Author: Takashi Kitajima
|
8 |
+
* Author URI: http://2inc.org
|
9 |
+
* Created: February 21, 2013
|
10 |
+
* License: GPL2
|
11 |
+
*
|
12 |
+
* Copyright 2013 Takashi Kitajima (email : inc@2inc.org)
|
13 |
+
*
|
14 |
+
* This program is free software; you can redistribute it and/or modify
|
15 |
+
* it under the terms of the GNU General Public License, version 2, as
|
16 |
+
* published by the Free Software Foundation.
|
17 |
+
*
|
18 |
+
* This program is distributed in the hope that it will be useful,
|
19 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
20 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
21 |
+
* GNU General Public License for more details.
|
22 |
+
*
|
23 |
+
* You should have received a copy of the GNU General Public License
|
24 |
+
* along with this program; if not, write to the Free Software
|
25 |
+
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
26 |
+
*/
|
27 |
+
class MW_WP_Form_Admin_Page {
|
28 |
+
|
29 |
+
const NAME = 'mw-wp-form';
|
30 |
+
const DOMAIN = 'mw-wp-form';
|
31 |
+
private $postmeta;
|
32 |
+
|
33 |
+
/**
|
34 |
+
* __construct
|
35 |
+
*/
|
36 |
+
public function __construct() {
|
37 |
+
add_action( 'admin_head', array( $this, 'cpt_public_false' ) );
|
38 |
+
add_action( 'admin_head', array( $this, 'add_meta_box' ) );
|
39 |
+
add_action( 'admin_print_footer_scripts', array( $this, 'add_quicktag' ) );
|
40 |
+
add_action( 'admin_print_styles', array( $this, 'admin_style' ) );
|
41 |
+
add_action( 'admin_print_scripts', array( $this, 'admin_scripts' ) );
|
42 |
+
add_action( 'save_post', array( $this, 'save_post' ) );
|
43 |
+
add_filter( 'user_can_richedit', array( $this, 'disable_visual_editor' ) );
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* get_post_data
|
48 |
+
*/
|
49 |
+
protected function get_post_data( $key ) {
|
50 |
+
if ( isset( $this->postdata[$key] ) ) {
|
51 |
+
return $this->postdata[$key];
|
52 |
+
}
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* register_post_type
|
57 |
+
*/
|
58 |
+
public function register_post_type() {
|
59 |
+
register_post_type( self::NAME, array(
|
60 |
+
'label' => 'MW WP Form',
|
61 |
+
'labels' => array(
|
62 |
+
'name' => 'MW WP Form',
|
63 |
+
'singular_name' => 'MW WP Form',
|
64 |
+
'add_new_item' => __( 'Add New Form', self::DOMAIN ),
|
65 |
+
'edit_item' => __( 'Edit Form', self::DOMAIN ),
|
66 |
+
'new_item' => __( 'New Form', self::DOMAIN ),
|
67 |
+
'view_item' => __( 'View Form', self::DOMAIN ),
|
68 |
+
'search_items' => __( 'Search Forms', self::DOMAIN ),
|
69 |
+
'not_found' => __( 'No Forms found', self::DOMAIN ),
|
70 |
+
'not_found_in_trash' => __( 'No Forms found in Trash', self::DOMAIN ),
|
71 |
+
),
|
72 |
+
'public' => false,
|
73 |
+
'show_ui' => true,
|
74 |
+
) );
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* cpt_public_false
|
79 |
+
*/
|
80 |
+
public function cpt_public_false() {
|
81 |
+
if ( self::NAME == get_post_type() ) : ?>
|
82 |
+
<style type="text/css">
|
83 |
+
#misc-publishing-actions {
|
84 |
+
display: none;
|
85 |
+
}
|
86 |
+
.post-php #message a {
|
87 |
+
display: none;
|
88 |
+
}
|
89 |
+
.wp-list-table .post-title span.hide-if-no-js {
|
90 |
+
display: none;
|
91 |
+
}
|
92 |
+
</style>
|
93 |
+
<?php
|
94 |
+
endif;
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* add_meta_box
|
99 |
+
*/
|
100 |
+
public function add_meta_box() {
|
101 |
+
if ( self::NAME == get_post_type() ) {
|
102 |
+
global $post;
|
103 |
+
// 設定データ取得
|
104 |
+
$this->postdata = get_post_meta( $post->ID, self::NAME, true );
|
105 |
+
// 完了画面内容
|
106 |
+
add_meta_box(
|
107 |
+
self::NAME.'_complete_message_metabox',
|
108 |
+
__( 'Complete Message', self::DOMAIN ),
|
109 |
+
array( $this, 'add_complete_message' ),
|
110 |
+
self::NAME, 'normal'
|
111 |
+
);
|
112 |
+
// 入力画面URL
|
113 |
+
add_meta_box(
|
114 |
+
self::NAME.'_url',
|
115 |
+
__( 'URL Options', self::DOMAIN ),
|
116 |
+
array( $this, 'add_url' ),
|
117 |
+
self::NAME, 'normal'
|
118 |
+
);
|
119 |
+
// バリデーション
|
120 |
+
add_meta_box(
|
121 |
+
self::NAME.'_validation',
|
122 |
+
__( 'Validation Rule', self::DOMAIN ),
|
123 |
+
array( $this, 'add_validation_rule' ),
|
124 |
+
self::NAME, 'normal'
|
125 |
+
);
|
126 |
+
// フォーム識別子
|
127 |
+
add_meta_box(
|
128 |
+
self::NAME.'_formkey',
|
129 |
+
__( 'Form Key', self::DOMAIN ),
|
130 |
+
array( $this, 'display_form_key' ),
|
131 |
+
self::NAME, 'side'
|
132 |
+
);
|
133 |
+
// メール設定
|
134 |
+
add_meta_box(
|
135 |
+
self::NAME.'_mail',
|
136 |
+
__( 'Mail Options', self::DOMAIN ),
|
137 |
+
array( $this, 'add_mail_options' ),
|
138 |
+
self::NAME, 'side'
|
139 |
+
);
|
140 |
+
}
|
141 |
+
}
|
142 |
+
|
143 |
+
/**
|
144 |
+
* add_quicktag
|
145 |
+
* HTMLエディタにクイックタグを追加
|
146 |
+
*/
|
147 |
+
public function add_quicktag() {
|
148 |
+
if ( self::NAME == get_post_type() ) : ?>
|
149 |
+
<script type="text/javascript">
|
150 |
+
QTags.addButton(
|
151 |
+
'<?php echo self::NAME; ?>_text',
|
152 |
+
'<?php _e( 'Text', self::DOMAIN ); ?>',
|
153 |
+
'[mwform_text name=""]',
|
154 |
+
''
|
155 |
+
);
|
156 |
+
QTags.addButton(
|
157 |
+
'<?php echo self::NAME; ?>_textarea',
|
158 |
+
'<?php _e( 'Textarea', self::DOMAIN ); ?>',
|
159 |
+
'[mwform_textarea name=""]',
|
160 |
+
''
|
161 |
+
);
|
162 |
+
QTags.addButton(
|
163 |
+
'<?php echo self::NAME; ?>_zip',
|
164 |
+
'<?php _e( 'Zip Code', self::DOMAIN ); ?>',
|
165 |
+
'[mwform_zip name=""]',
|
166 |
+
''
|
167 |
+
);
|
168 |
+
QTags.addButton(
|
169 |
+
'<?php echo self::NAME; ?>_tel',
|
170 |
+
'<?php _e( 'Tel', self::DOMAIN ); ?>',
|
171 |
+
'[mwform_tel name=""]',
|
172 |
+
''
|
173 |
+
);
|
174 |
+
QTags.addButton(
|
175 |
+
'<?php echo self::NAME; ?>_select',
|
176 |
+
'<?php _e( 'Select', self::DOMAIN ); ?>',
|
177 |
+
'[mwform_select name="" children=""]',
|
178 |
+
''
|
179 |
+
);
|
180 |
+
QTags.addButton(
|
181 |
+
'<?php echo self::NAME; ?>_radio',
|
182 |
+
'<?php _e( 'Radio', self::DOMAIN ); ?>',
|
183 |
+
'[mwform_radio name="" children=""]',
|
184 |
+
''
|
185 |
+
);
|
186 |
+
QTags.addButton(
|
187 |
+
'<?php echo self::NAME; ?>_checkbox',
|
188 |
+
'<?php _e( 'Checkbox', self::DOMAIN ); ?>',
|
189 |
+
'[mwform_checkbox name="" children=""]',
|
190 |
+
''
|
191 |
+
);
|
192 |
+
QTags.addButton(
|
193 |
+
'<?php echo self::NAME; ?>_datepicker',
|
194 |
+
'<?php _e( 'Datepicker', self::DOMAIN ); ?>',
|
195 |
+
'[mwform_datepicker name=""]',
|
196 |
+
''
|
197 |
+
);
|
198 |
+
QTags.addButton(
|
199 |
+
'<?php echo self::NAME; ?>_password',
|
200 |
+
'<?php _e( 'Password', self::DOMAIN ); ?>',
|
201 |
+
'[mwform_password name=""]',
|
202 |
+
''
|
203 |
+
);
|
204 |
+
QTags.addButton(
|
205 |
+
'<?php echo self::NAME; ?>_backButton',
|
206 |
+
'<?php _e( 'Back', self::DOMAIN ); ?>',
|
207 |
+
'[mwform_backButton]',
|
208 |
+
''
|
209 |
+
);
|
210 |
+
QTags.addButton(
|
211 |
+
'<?php echo self::NAME; ?>_submitButton',
|
212 |
+
'<?php _e( 'Confirm & Submit', self::DOMAIN ); ?>',
|
213 |
+
'[mwform_submitButton]',
|
214 |
+
''
|
215 |
+
);
|
216 |
+
QTags.addButton(
|
217 |
+
'<?php echo self::NAME; ?>_submit',
|
218 |
+
'<?php _e( 'Submit', self::DOMAIN ); ?>',
|
219 |
+
'[mwform_submit name="submit"]',
|
220 |
+
''
|
221 |
+
);
|
222 |
+
QTags.addButton(
|
223 |
+
'<?php echo self::NAME; ?>_button',
|
224 |
+
'<?php _e( 'Button', self::DOMAIN ); ?>',
|
225 |
+
'[mwform_button name=""]',
|
226 |
+
''
|
227 |
+
);
|
228 |
+
QTags.addButton(
|
229 |
+
'<?php echo self::NAME; ?>_hidden',
|
230 |
+
'<?php _e( 'Hidden', self::DOMAIN ); ?>',
|
231 |
+
'[mwform_hidden name=""]',
|
232 |
+
''
|
233 |
+
);
|
234 |
+
QTags.addButton(
|
235 |
+
'<?php echo self::NAME; ?>_error',
|
236 |
+
'<?php _e( 'Error Message', self::DOMAIN ); ?>',
|
237 |
+
'[mwform_error keys=""]',
|
238 |
+
''
|
239 |
+
);
|
240 |
+
</script>
|
241 |
+
<?php
|
242 |
+
endif;
|
243 |
+
}
|
244 |
+
|
245 |
+
/**
|
246 |
+
* admin_style
|
247 |
+
* CSS適用
|
248 |
+
*/
|
249 |
+
public function admin_style() {
|
250 |
+
if ( self::NAME == get_post_type() ) {
|
251 |
+
$url = plugin_dir_url( __FILE__ );
|
252 |
+
wp_register_style( self::DOMAIN.'-admin', $url.'../css/admin.css' );
|
253 |
+
wp_enqueue_style( self::DOMAIN.'-admin' );
|
254 |
+
}
|
255 |
+
}
|
256 |
+
|
257 |
+
/**
|
258 |
+
* admin_scripts
|
259 |
+
* JavaScript適用
|
260 |
+
*/
|
261 |
+
public function admin_scripts() {
|
262 |
+
if ( self::NAME == get_post_type() ) {
|
263 |
+
$url = plugin_dir_url( __FILE__ );
|
264 |
+
wp_register_script( self::DOMAIN.'-admin', $url.'../js/admin.js' );
|
265 |
+
wp_enqueue_script( self::DOMAIN.'-admin' );
|
266 |
+
}
|
267 |
+
}
|
268 |
+
|
269 |
+
/**
|
270 |
+
* save_post
|
271 |
+
* @param $post_ID
|
272 |
+
*/
|
273 |
+
public function save_post( $post_ID ) {
|
274 |
+
if ( ! isset( $_POST[self::NAME.'_nonce'] ) )
|
275 |
+
return $post_ID;
|
276 |
+
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
|
277 |
+
return $post_ID;
|
278 |
+
if ( !wp_verify_nonce( $_POST[self::NAME.'_nonce'], self::NAME ) )
|
279 |
+
return $post_ID;
|
280 |
+
if ( !current_user_can( 'manage_options', $post_ID ) )
|
281 |
+
return $post_ID;
|
282 |
+
|
283 |
+
$data = $_POST[self::NAME];
|
284 |
+
if ( !empty( $data['validation'] ) && is_array( $data['validation'] ) ) {
|
285 |
+
$validation = array();
|
286 |
+
foreach ( $data['validation'] as $_validation ) {
|
287 |
+
if ( empty( $_validation['target'] ) ) continue;
|
288 |
+
foreach ( $_validation as $key => $val ) {
|
289 |
+
// 単一項目のとき
|
290 |
+
if ( empty( $val ) ) {
|
291 |
+
unset( $_validation[$key] );
|
292 |
+
}
|
293 |
+
// 配列のとき
|
294 |
+
elseif ( is_array( $val ) && !array_diff( $val, array( '' ) ) ) {
|
295 |
+
unset( $_validation[$key] );
|
296 |
+
}
|
297 |
+
}
|
298 |
+
$validation[] = $_validation;
|
299 |
+
}
|
300 |
+
$data['validation'] = $validation;
|
301 |
+
}
|
302 |
+
$old_data = get_post_meta( $post_ID, self::NAME, true );
|
303 |
+
update_post_meta( $post_ID, self::NAME, $data, $old_data );
|
304 |
+
}
|
305 |
+
|
306 |
+
/**
|
307 |
+
* display_form_key
|
308 |
+
* formkeyのテキストフィールドを表示
|
309 |
+
*/
|
310 |
+
public function display_form_key() {
|
311 |
+
global $post;
|
312 |
+
?>
|
313 |
+
<p>
|
314 |
+
<?php _e( 'Copy and Paste this shortcode.', self::DOMAIN ); ?><br />
|
315 |
+
<input type="text" disabled="disabled" value='[mwform_formkey key="<?php the_ID(); ?>"]' size="30" />
|
316 |
+
</p>
|
317 |
+
<?php
|
318 |
+
}
|
319 |
+
|
320 |
+
/**
|
321 |
+
* add_complete_message
|
322 |
+
* 完了画面内容の入力画面を表示
|
323 |
+
*/
|
324 |
+
public function add_complete_message() {
|
325 |
+
global $post;
|
326 |
+
$content = $this->get_post_data( 'complete_message' );
|
327 |
+
wp_editor( $content, self::NAME.'_complete_message', array(
|
328 |
+
'textarea_name' => self::NAME.'[complete_message]',
|
329 |
+
'textarea_rows' => 7,
|
330 |
+
) );
|
331 |
+
}
|
332 |
+
|
333 |
+
/**
|
334 |
+
* add_mail_options
|
335 |
+
* メール設定フォームを表示
|
336 |
+
*/
|
337 |
+
public function add_mail_options() {
|
338 |
+
global $post;
|
339 |
+
?>
|
340 |
+
<p>
|
341 |
+
<b><?php _e( 'Subject', self::DOMAIN ); ?></b><br />
|
342 |
+
<input type="text" name="<?php echo esc_attr( self::NAME ); ?>[mail_subject]" value="<?php echo esc_attr( $this->get_post_data( 'mail_subject' ) ); ?>" />
|
343 |
+
</p>
|
344 |
+
<p>
|
345 |
+
<b><?php _e( 'Ccontent', self::DOMAIN ); ?></b><br />
|
346 |
+
<textarea name="<?php echo esc_attr( self::NAME ); ?>[mail_content]" cols="30" rows="10"><?php echo esc_attr( $this->get_post_data( 'mail_content' ) ); ?></textarea><br />
|
347 |
+
<?php _e( '{key} is converted form data.', self::DOMAIN ); ?>
|
348 |
+
</p>
|
349 |
+
<p>
|
350 |
+
<b><?php _e( 'Automatic reply email', self::DOMAIN ); ?></b><br />
|
351 |
+
<input type="text" name="<?php echo esc_attr( self::NAME ); ?>[automatic_reply_email]" value="<?php echo esc_attr( $this->get_post_data( 'automatic_reply_email') ); ?>" /><br />
|
352 |
+
<?php _e( 'Please input the key to use as transmission to automatic reply email.', self::DOMAIN ); ?>
|
353 |
+
</p>
|
354 |
+
<?php
|
355 |
+
}
|
356 |
+
|
357 |
+
/**
|
358 |
+
* add_url
|
359 |
+
* URL設定フォームを表示
|
360 |
+
*/
|
361 |
+
public function add_url() {
|
362 |
+
global $post;
|
363 |
+
?>
|
364 |
+
<input type="hidden" name="<?php echo esc_attr( self::NAME ); ?>_nonce" value="<?php echo wp_create_nonce( self::NAME ); ?>" />
|
365 |
+
<table border="0" cellpadding="0" cellspacing="0">
|
366 |
+
<tr>
|
367 |
+
<th><?php _e( 'Input Page URL', self::DOMAIN ); ?></th>
|
368 |
+
<td>
|
369 |
+
<input type="text" name="<?php echo esc_attr( self::NAME ); ?>[input_url]" value="<?php echo esc_attr( $this->get_post_data( 'input_url' ) ); ?>" />
|
370 |
+
</td>
|
371 |
+
</tr>
|
372 |
+
<tr>
|
373 |
+
<th><?php _e( 'Confirmation Page URL', self::DOMAIN ); ?></th>
|
374 |
+
<td>
|
375 |
+
<input type="text" name="<?php echo esc_attr( self::NAME ); ?>[confirmation_url]" value="<?php echo esc_attr( $this->get_post_data( 'confirmation_url' ) ); ?>" />
|
376 |
+
</td>
|
377 |
+
</tr>
|
378 |
+
<tr>
|
379 |
+
<th><?php _e( 'Complete Page URL', self::DOMAIN ); ?></th>
|
380 |
+
<td>
|
381 |
+
<input type="text" name="<?php echo esc_attr( self::NAME ); ?>[complete_url]" value="<?php echo esc_attr( $this->get_post_data( 'complete_url' ) ); ?>" />
|
382 |
+
</td>
|
383 |
+
</tr>
|
384 |
+
</table>
|
385 |
+
<?php
|
386 |
+
}
|
387 |
+
|
388 |
+
/**
|
389 |
+
* add_validation_rule
|
390 |
+
* バリデーションルール設定フォームを表示
|
391 |
+
*/
|
392 |
+
public function add_validation_rule() {
|
393 |
+
global $post;
|
394 |
+
if ( ! $postdata = $this->get_post_data( 'validation' ) )
|
395 |
+
$postdata = array();
|
396 |
+
$validation_keys = array(
|
397 |
+
'target' => '',
|
398 |
+
'noempty' => '',
|
399 |
+
'required' => '',
|
400 |
+
'numeric' => '',
|
401 |
+
'alpha' => '',
|
402 |
+
'alphanumeric' => '',
|
403 |
+
'zip' => '',
|
404 |
+
'tel' => '',
|
405 |
+
'mail' => '',
|
406 |
+
'date' => '',
|
407 |
+
'eq' => array(),
|
408 |
+
'between' => array(),
|
409 |
+
'minlength' => array(),
|
410 |
+
);
|
411 |
+
// 空の隠れバリデーションフィールド(コピー元)を挿入
|
412 |
+
array_unshift( $postdata, $validation_keys );
|
413 |
+
?>
|
414 |
+
<b id="add-validation-btn"><?php _e( 'Add Validation rule', self::DOMAIN ); ?></b>
|
415 |
+
<?php foreach ( $postdata as $key => $val ) : $val = array_merge( $validation_keys, $val ); ?>
|
416 |
+
<div class="validation-box"<?php if ( $key === 0 ) : ?> style="display:none"<?php endif; ?>>
|
417 |
+
<div class="validation-remove"><b>×</b></div>
|
418 |
+
<div class="validation-btn"><span><?php echo esc_attr( $val['target'] ); ?></span><b>▼</b></div>
|
419 |
+
<div class="validation-content">
|
420 |
+
<?php _e( 'The key which applies validation', self::DOMAIN ); ?>:<input type="text" class="targetKey" value="<?php echo esc_attr( $val['target'] ); ?>" name="<?php echo self::NAME; ?>[validation][<?php echo $key; ?>][target]" />
|
421 |
+
<table border="0" cellpadding="0" cellspacing="0">
|
422 |
+
<tr>
|
423 |
+
<td colspan="2">
|
424 |
+
<label><input type="checkbox" <?php checked( $val['noempty'], 1 ); ?> name="<?php echo self::NAME; ?>[validation][<?php echo $key; ?>][noempty]" value="1" /><?php _e( 'No empty', self::DOMAIN ); ?></label>
|
425 |
+
<label><input type="checkbox" <?php checked( $val['required'], 1 ); ?> name="<?php echo self::NAME; ?>[validation][<?php echo $key; ?>][required]" value="1" /><?php _e( 'No empty( with checkbox )', self::DOMAIN ); ?></label>
|
426 |
+
<label><input type="checkbox" <?php checked( $val['numeric'], 1 ); ?> name="<?php echo self::NAME; ?>[validation][<?php echo $key; ?>][numeric]" value="1" /><?php _e( 'Numeric', self::DOMAIN ); ?></label>
|
427 |
+
<label><input type="checkbox" <?php checked( $val['alpha'], 1 ); ?> name="<?php echo self::NAME; ?>[validation][<?php echo $key; ?>][alpha]" value="1" /><?php _e( 'Alphabet', self::DOMAIN ); ?></label>
|
428 |
+
<label><input type="checkbox" <?php checked( $val['alphanumeric'], 1 ); ?> name="<?php echo self::NAME; ?>[validation][<?php echo $key; ?>][alphanumeric]" value="1" /><?php _e( 'Alphabet and Numeric', self::DOMAIN ); ?></label>
|
429 |
+
<label><input type="checkbox" <?php checked( $val['zip'], 1 ); ?> name="<?php echo self::NAME; ?>[validation][<?php echo $key; ?>][zip]" value="1" /><?php _e( 'Zip code', self::DOMAIN ); ?></label>
|
430 |
+
<label><input type="checkbox" <?php checked( $val['tel'], 1 ); ?> name="<?php echo self::NAME; ?>[validation][<?php echo $key; ?>][tel]" value="1" /><?php _e( 'Tel', self::DOMAIN ); ?></label>
|
431 |
+
<label><input type="checkbox" <?php checked( $val['mail'], 1 ); ?> name="<?php echo self::NAME; ?>[validation][<?php echo $key; ?>][mail]" value="1" /><?php _e( 'E-mail', self::DOMAIN ); ?></label>
|
432 |
+
<label><input type="checkbox" <?php checked( $val['date'], 1 ); ?> name="<?php echo self::NAME; ?>[validation][<?php echo $key; ?>][date]" value="1" /><?php _e( 'Date', self::DOMAIN ); ?></label>
|
433 |
+
</td>
|
434 |
+
</tr>
|
435 |
+
<tr>
|
436 |
+
<td style="width:20%"><?php _e( 'The key at same value', self::DOMAIN ); ?></td>
|
437 |
+
<td><input type="text" value="<?php echo esc_attr( @$val['eq']['target'] ); ?>" name="<?php echo self::NAME; ?>[validation][<?php echo $key; ?>][eq][target]" /></td>
|
438 |
+
</tr>
|
439 |
+
<tr>
|
440 |
+
<td><?php _e( 'The range of the number of characters', self::DOMAIN ); ?></td>
|
441 |
+
<td>
|
442 |
+
<input type="text" value="<?php echo esc_attr( @$val['between']['min'] ); ?>" size="3" name="<?php echo self::NAME; ?>[validation][<?php echo $key; ?>][between][min]" />
|
443 |
+
〜
|
444 |
+
<input type="text" value="<?php echo esc_attr( @$val['between']['max'] ); ?>" size="3" name="<?php echo self::NAME; ?>[validation][<?php echo $key; ?>][between][max]" />
|
445 |
+
</td>
|
446 |
+
</tr>
|
447 |
+
<tr>
|
448 |
+
<td><?php _e( 'The number of the minimum characters', self::DOMAIN ); ?></td>
|
449 |
+
<td><input type="text" value="<?php echo esc_attr( @$val['minlength']['min'] ); ?>" size="3" name="<?php echo self::NAME; ?>[validation][<?php echo $key; ?>][minlength][min]" /></td>
|
450 |
+
</tr>
|
451 |
+
</table>
|
452 |
+
<!-- end .validation-content --></div>
|
453 |
+
<!-- end .validatioin-box --></div>
|
454 |
+
<?php endforeach; ?>
|
455 |
+
<?php
|
456 |
+
}
|
457 |
+
|
458 |
+
/**
|
459 |
+
* disable_visual_editor
|
460 |
+
* ビジュアルエディタを無効に
|
461 |
+
*/
|
462 |
+
public function disable_visual_editor() {
|
463 |
+
if ( self::NAME == get_post_type() ) {
|
464 |
+
return false;
|
465 |
+
}
|
466 |
+
return true;
|
467 |
+
}
|
468 |
+
}
|
469 |
+
?>
|