MW WP Form - Version 4.0.0

Version Description

  • Refactoring
  • Update redirect process.
  • Changed that admin and reply Mail settings are required.
  • Changed to be able to set the form besides $post and main template.
  • Each input fields can overwrite from themes.
  • Deprecated action hook mwform_exec_shortcode. Please use this instead mwform_start_main_process
  • The hook to mwform_validation_rules is no longer needed to add your own validation rule.
  • Deprecated MW_WP_Form_Contact_Data_Setting::get_posts(). Please use this instead MW_WP_Form_Contact_Data_Setting::get_form_post_types()
  • Added method MW_WP_Form_Data::get_saved_mail_id();
  • Added method MW_WP_Form_Data::set_saved_mail_id();
  • Deprecated MW_WP_Form_Data::getInstance(). Please use this instead MW_WP_Form_Data::connect()
  • Deprecated MW_WP_Form_Form::remove_linefeed_space(). Please use this instead MW_WP_Form_Form::remove_newline_space()
  • Deprecated MW_WP_Form_Validation::check(). Please use this instead MW_WP_Form_Validation::is_valid()
  • Deprecated MW_WP_Form_Validation::single_check(). Please use this instead MW_WP_Form_Validation::is_valid_field()
Download this release

Release Info

Developer inc2734
Plugin Icon wp plugin MW WP Form
Version 4.0.0
Comparing to
See all releases

Code changes from version 3.2.3 to 4.0.0

Files changed (123) hide show
  1. classes/abstract/class.controller.php +32 -0
  2. classes/abstract/class.form-field.php +353 -0
  3. classes/abstract/class.validation-rule.php +101 -0
  4. classes/config.php +21 -16
  5. classes/controllers/class.admin-list.php +33 -29
  6. classes/controllers/class.admin.php +363 -183
  7. classes/controllers/class.chart.php +109 -50
  8. classes/controllers/class.contact-data-list.php +123 -100
  9. classes/controllers/class.contact-data.php +114 -56
  10. classes/controllers/class.controller.php +0 -44
  11. classes/controllers/class.main.php +213 -306
  12. classes/controllers/class.stores-inquiry-data-form-list.php +49 -38
  13. classes/deprecated.php +17 -0
  14. classes/form-fields/class.akismet_error.php +19 -15
  15. classes/form-fields/class.back-button.php +24 -17
  16. classes/form-fields/class.button-back.php +24 -17
  17. classes/form-fields/class.button-button.php +24 -17
  18. classes/form-fields/class.button-confirm.php +24 -17
  19. classes/form-fields/class.button-submit.php +25 -18
  20. classes/form-fields/class.button.php +24 -17
  21. classes/form-fields/class.checkbox.php +28 -21
  22. classes/form-fields/class.confirm-button.php +24 -17
  23. classes/form-fields/class.custom-mail-tag.php +28 -47
  24. classes/form-fields/class.datepicker.php +26 -19
  25. classes/form-fields/class.email.php +28 -21
  26. classes/form-fields/class.error.php +24 -17
  27. classes/form-fields/class.file.php +26 -19
  28. classes/form-fields/class.hidden.php +24 -17
  29. classes/form-fields/class.image.php +26 -19
  30. classes/form-fields/class.monthpicker.php +27 -20
  31. classes/form-fields/class.number.php +27 -20
  32. classes/form-fields/class.password.php +25 -18
  33. classes/form-fields/class.radio.php +29 -22
  34. classes/form-fields/class.range.php +27 -20
  35. classes/form-fields/class.select.php +29 -22
  36. classes/form-fields/class.submit-button.php +25 -18
  37. classes/form-fields/class.submit.php +24 -17
  38. classes/form-fields/class.tel.php +43 -19
  39. classes/form-fields/class.text.php +28 -21
  40. classes/form-fields/class.textarea.php +28 -21
  41. classes/form-fields/class.url.php +28 -21
  42. classes/form-fields/class.zip.php +43 -19
  43. classes/functions.php +216 -157
  44. classes/models/class.abstract-form-field.php +0 -351
  45. classes/models/class.abstract-validation-rule.php +0 -69
  46. classes/models/class.admin.php +12 -110
  47. classes/models/class.akismet.php +56 -47
  48. classes/models/class.contact-data-setting.php +113 -105
  49. classes/models/class.contact-data.php +0 -49
  50. classes/models/class.csv.php +78 -63
  51. classes/models/class.data.php +402 -240
  52. classes/models/class.error.php +0 -53
  53. classes/models/class.file.php +91 -94
  54. classes/models/class.form-fields.php +67 -0
  55. classes/models/class.form.php +401 -418
  56. classes/models/class.json-parser.php +43 -33
  57. classes/models/class.mail.php +162 -201
  58. classes/models/class.parser.php +284 -0
  59. classes/models/class.session.php +68 -46
  60. classes/models/class.setting.php +81 -57
  61. classes/models/class.validation-rules.php +116 -0
  62. classes/models/class.validation.php +133 -96
  63. classes/services/class.exec-shortcode.php +261 -459
  64. classes/services/class.mail-parser.php +52 -134
  65. classes/services/class.mail.php +65 -53
  66. classes/services/class.redirected.php +128 -105
  67. classes/validation-rules/class.akismet.php +13 -13
  68. classes/validation-rules/class.alpha.php +28 -23
  69. classes/validation-rules/class.alphanumeric.php +28 -23
  70. classes/validation-rules/class.between.php +42 -39
  71. classes/validation-rules/class.date.php +41 -35
  72. classes/validation-rules/class.eq.php +29 -25
  73. classes/validation-rules/class.filesize.php +23 -23
  74. classes/validation-rules/class.filetype.php +33 -30
  75. classes/validation-rules/class.hiragana.php +28 -23
  76. classes/validation-rules/class.in.php +31 -27
  77. classes/validation-rules/class.kana.php +26 -21
  78. classes/validation-rules/class.katakana.php +27 -23
  79. classes/validation-rules/class.mail.php +28 -23
  80. classes/validation-rules/class.maximagesize.php +28 -34
  81. classes/validation-rules/class.minimagesize.php +28 -34
  82. classes/validation-rules/class.minlength.php +29 -26
  83. classes/validation-rules/class.month.php +38 -33
  84. classes/validation-rules/class.noempty.php +24 -21
  85. classes/validation-rules/class.nofalse.php +23 -20
  86. classes/validation-rules/class.numeric.php +28 -23
  87. classes/validation-rules/class.required.php +18 -17
  88. classes/validation-rules/class.tel.php +51 -30
  89. classes/validation-rules/class.url.php +27 -22
  90. classes/validation-rules/class.zip.php +46 -25
  91. css/style.css +6 -5
  92. js/scroll.js +2 -2
  93. languages/mw-wp-form-ja.mo +0 -0
  94. languages/mw-wp-form-ja.po +0 -984
  95. languages/mw-wp-form.pot +0 -918
  96. mw-wp-form.php +84 -281
  97. readme.txt +23 -16
  98. templates/admin/admin-mail-options.php +18 -19
  99. templates/admin/complete-message.php +17 -0
  100. templates/admin/mail-options.php +12 -9
  101. templates/admin/validation-rule.php +1 -1
  102. templates/chart/index.php +15 -16
  103. templates/contact-data/detail.php +10 -10
  104. templates/form-fields/button.php +5 -0
  105. templates/form-fields/button_button.php +5 -0
  106. templates/form-fields/button_submit.php +5 -0
  107. templates/form-fields/checkbox.php +21 -0
  108. templates/form-fields/datepicker.php +15 -0
  109. templates/form-fields/email.php +10 -0
  110. templates/form-fields/file.php +6 -0
  111. templates/form-fields/hidden.php +1 -0
  112. templates/form-fields/monthpicker.php +15 -0
  113. templates/form-fields/number.php +10 -0
  114. templates/form-fields/password.php +9 -0
  115. templates/form-fields/radio.php +21 -0
  116. templates/form-fields/range.php +9 -0
  117. templates/form-fields/select.php +10 -0
  118. templates/form-fields/submit.php +5 -0
  119. templates/form-fields/tel.php +28 -0
  120. templates/form-fields/text.php +10 -0
  121. templates/form-fields/textarea.php +8 -0
  122. templates/form-fields/url.php +10 -0
  123. templates/form-fields/zip.php +20 -0
classes/abstract/class.controller.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Name : MW WP Form Controller
4
+ * Version : 1.0.0
5
+ * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
+ * Created : March 28, 2015
8
+ * Modified :
9
+ * License : GPLv2 or later
10
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
+ */
12
+ class MW_WP_Form_Controller {
13
+
14
+ /**
15
+ * Rendering template
16
+ *
17
+ * @param string $template {directory name}/{file name (no need extension)}
18
+ * @param array Array of data you want to assign
19
+ * @return void
20
+ */
21
+ protected function _render( $template, array $args = array() ) {
22
+ extract( $args );
23
+ $template_dir = plugin_dir_path( __FILE__ ) . '../../templates/';
24
+ $template_path = $template_dir . $template . '.php';
25
+
26
+ if ( ! file_exists( $template_path ) ) {
27
+ return;
28
+ }
29
+
30
+ include( $template_path );
31
+ }
32
+ }
classes/abstract/class.form-field.php ADDED
@@ -0,0 +1,353 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Name : MW WP Form Abstract Form Field
4
+ * Version : 2.0.0
5
+ * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
+ * Created : December 14, 2012
8
+ * Modified : May 30, 2017
9
+ * License : GPLv2 or later
10
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
+ */
12
+ abstract class MW_WP_Form_Abstract_Form_Field {
13
+
14
+ /**
15
+ * Shortcode name
16
+ * @var string
17
+ */
18
+ protected $shortcode_name;
19
+
20
+ /**
21
+ * Display name
22
+ * @var string
23
+ */
24
+ protected $display_name;
25
+
26
+ /**
27
+ * @var MW_WP_Form_Form
28
+ */
29
+ protected $Form;
30
+
31
+ /**
32
+ * @var MW_WP_Form_Data
33
+ */
34
+ protected $Data;
35
+
36
+ /**
37
+ * Default attributes
38
+ * @var array
39
+ */
40
+ protected $defaults = array();
41
+
42
+ /**
43
+ * Attirbutes of shortcode
44
+ * @var array
45
+ */
46
+ protected $atts = array();
47
+
48
+ /**
49
+ * Form key
50
+ * @var string
51
+ */
52
+ protected $form_key;
53
+
54
+ /**
55
+ * Types of form type.
56
+ * input|select|button|input_button|error|other
57
+ * @var string
58
+ */
59
+ protected $type = 'other';
60
+
61
+ /**
62
+ * Content of shortcode
63
+ * @var string
64
+ */
65
+ protected $element_content = null;
66
+
67
+ public function __construct() {
68
+ $this->_set_names();
69
+ $this->_set_defaults();
70
+ add_filter( 'mwform_form_fields' , array( $this, '_mwform_form_fields' ) );
71
+ }
72
+
73
+ /**
74
+ * Add form field shortcodes
75
+ *
76
+ * @param MW_WP_Form_Form $Form
77
+ * @param string $form_key
78
+ * @param string $view_flg
79
+ * @return bool
80
+ */
81
+ public function initialize( MW_WP_Form_Form $Form, $form_key, $view_flg ) {
82
+ if ( empty( $this->shortcode_name ) ) {
83
+ return false;
84
+ }
85
+
86
+ $this->Form = $Form;
87
+ $this->form_key = $form_key;
88
+ $this->Data = MW_WP_Form_Data::connect( $form_key );
89
+
90
+ switch( $view_flg ) {
91
+ case 'input' :
92
+ add_shortcode( $this->shortcode_name, array( $this, '_input_page' ) );
93
+ break;
94
+ case 'confirm' :
95
+ add_shortcode( $this->shortcode_name, array( $this, '_confirm_page' ) );
96
+ break;
97
+ case 'complete' :
98
+ break;
99
+ default :
100
+ exit( '$view_flg is not right value. $view_flg is ' . $view_flg . ' now.' );
101
+ }
102
+
103
+ return true;
104
+ }
105
+
106
+ /**
107
+ * Set shortcode_name and display_name
108
+ * Overwrite required for each child class
109
+ *
110
+ * @return array(shortcode_name, display_name)
111
+ */
112
+ abstract protected function set_names();
113
+ private function _set_names() {
114
+ $args = $this->set_names();
115
+
116
+ if ( empty( $args['shortcode_name'] ) || empty( $args['display_name'] ) ) {
117
+ exit( get_class() . '::set_names() returns not right values. Returned values is ' . serialize( $args ) . ' now.' );
118
+ }
119
+
120
+ $this->shortcode_name = $args['shortcode_name'];
121
+ $this->display_name = $args['display_name'];
122
+ }
123
+
124
+ /**
125
+ * Set default attributes
126
+ *
127
+ * @return array defaults
128
+ */
129
+ abstract protected function set_defaults();
130
+ private function _set_defaults() {
131
+ $this->defaults = $this->set_defaults();
132
+ }
133
+
134
+ /**
135
+ * Return HTML of error message
136
+ *
137
+ * @param string $name
138
+ * @return string HTML of error message
139
+ */
140
+ protected function get_error( $name ) {
141
+ if ( ! is_array( $this->Data->get_validation_error( $name ) ) ) {
142
+ return;
143
+ }
144
+
145
+ $error_html = '';
146
+ $start_tag = '<span class="error">';
147
+ $end_tag = '</span>';
148
+ foreach ( $this->Data->get_validation_error( $name ) as $rule => $error ) {
149
+ $rule = strtolower( $rule );
150
+ $error = apply_filters(
151
+ 'mwform_error_message_' . $this->form_key,
152
+ $error,
153
+ $name,
154
+ $rule
155
+ );
156
+
157
+ $error_html .= apply_filters( 'mwform_error_message_html',
158
+ $start_tag . esc_html( $error ) . $end_tag,
159
+ $error,
160
+ $start_tag,
161
+ $end_tag,
162
+ $this->form_key,
163
+ $name,
164
+ $rule
165
+ );
166
+ }
167
+
168
+ if ( $error_html ) {
169
+ return apply_filters( 'mwform_error_message_wrapper', $error_html, $this->form_key );
170
+ }
171
+ }
172
+
173
+ /**
174
+ * Callback of add shortcode for input page
175
+ *
176
+ * @param array $atts
177
+ * @param string $element_content
178
+ * @return string HTML
179
+ */
180
+ abstract protected function input_page();
181
+ public function _input_page( $atts, $element_content = null ) {
182
+ $this->element_content = $element_content;
183
+
184
+ if ( isset( $this->defaults['value'] ) && isset( $atts['name'] ) && ! isset( $atts['value'] ) ) {
185
+ $atts['value'] = apply_filters(
186
+ 'mwform_value_' . $this->form_key,
187
+ $this->defaults['value'],
188
+ $atts['name']
189
+ );
190
+ }
191
+ $this->atts = shortcode_atts( $this->defaults, $atts );
192
+
193
+ return $this->input_page();
194
+ }
195
+
196
+ /**
197
+ * Callback of add shortcode for confirm page
198
+ *
199
+ * @param array $atts
200
+ * @param string $element_content
201
+ * @return string HTML
202
+ */
203
+ abstract protected function confirm_page();
204
+ public function _confirm_page( $atts, $element_content = null ) {
205
+ $this->element_content = $element_content;
206
+ $this->atts = shortcode_atts( $this->defaults, $atts );
207
+
208
+ return $this->confirm_page();
209
+ }
210
+
211
+ /**
212
+ * Return array for children of select, checkbox and radio
213
+ * If including ":", Split and use the before as the name and the after as the label
214
+ *
215
+ * @param string|array $_children
216
+ * @return array
217
+ */
218
+ public function get_children( $_children ) {
219
+ $children = array();
220
+ if ( ! empty( $_children ) && ! is_array( $_children ) ) {
221
+ $_children = explode( ',', $_children );
222
+ }
223
+
224
+ if ( is_array( $_children ) ) {
225
+ foreach ( $_children as $child ) {
226
+ $temp_replacement = '@-[_-_]-@';
227
+ if ( preg_match( '/(^:[^:])|([^:]:[^:])/', $child ) ) {
228
+ $child = str_replace( '::', $temp_replacement, $child );
229
+ $child = explode( ':', $child, 2 );
230
+ } else {
231
+ $child = str_replace( '::', $temp_replacement, $child );
232
+ $child = array( $child );
233
+ }
234
+ foreach ( $child as $child_key => $child_value ) {
235
+ $child[ $child_key ] = str_replace( $temp_replacement, ':', $child_value );
236
+ }
237
+ if ( count( $child ) === 1 ) {
238
+ $children[ $child[0] ] = $child[0] ;
239
+ } else {
240
+ $children[ $child[0] ] = $child[1];
241
+ }
242
+ }
243
+ }
244
+
245
+ if ( $this->form_key ) {
246
+ $children = apply_filters( 'mwform_choices_' . $this->form_key, $children, $this->atts );
247
+ }
248
+
249
+ return $children;
250
+ }
251
+
252
+ /**
253
+ * Generate tag generator
254
+ *
255
+ * @return void
256
+ */
257
+ public function add_tag_generator() {
258
+ add_action( 'mwform_tag_generator_dialog', array( $this, '_mwform_tag_generator_dialog' ) );
259
+
260
+ if ( 'other' !== $this->type ) {
261
+ $tag = 'mwform_tag_generator_' . $this->type . '_option';
262
+ } else {
263
+ $tag = 'mwform_tag_generator_option';
264
+ }
265
+
266
+ add_action( $tag, array( $this, '_mwform_tag_generator_option' ) );
267
+ }
268
+
269
+ /**
270
+ * Display tag generator wrapper
271
+ *
272
+ * @return void
273
+ */
274
+ public function _mwform_tag_generator_dialog() {
275
+ ?>
276
+ <div id="dialog-<?php echo esc_attr( $this->shortcode_name ); ?>" class="mwform-dialog" title="<?php echo esc_attr( $this->shortcode_name ); ?>">
277
+ <div class="form">
278
+ <?php $this->mwform_tag_generator_dialog( $this->defaults ); ?>
279
+ </div>
280
+ </div>
281
+ <?php
282
+ }
283
+
284
+ /**
285
+ * Display tag generator dialog
286
+ * Overwrite required for each child class
287
+ *
288
+ * @param array $options
289
+ * @return void
290
+ */
291
+ public function mwform_tag_generator_dialog( array $options = array() ) {}
292
+
293
+ /**
294
+ * Display tag generator selectbox
295
+ *
296
+ * @return void
297
+ */
298
+ public function _mwform_tag_generator_option() {
299
+ ?>
300
+ <option value="<?php echo esc_attr( $this->shortcode_name ); ?>"><?php echo esc_html( $this->display_name ); ?></option>
301
+ <?php
302
+ }
303
+
304
+ /**
305
+ * Generate array of form fields
306
+ *
307
+ * @param array $form_fields array of MW_WP_Form_Abstract_Form_Field
308
+ * @return array
309
+ */
310
+ public function _mwform_form_fields( array $form_fields ) {
311
+ return array_merge( $form_fields, array( $this->shortcode_name => $this ) );
312
+ }
313
+
314
+ /**
315
+ * Return display name
316
+ *
317
+ * @return string
318
+ */
319
+ public function get_display_name() {
320
+ return $this->display_name;
321
+ }
322
+
323
+ /**
324
+ * Return shortcode name
325
+ *
326
+ * @return string
327
+ */
328
+ public function get_shortcode_name() {
329
+ return $this->shortcode_name;
330
+ }
331
+
332
+ /**
333
+ * Return value for setting field of Tag generator dialog
334
+ *
335
+ * @param string $key
336
+ * @param array $options
337
+ * @return string
338
+ */
339
+ public function get_value_for_generator( $key, $options ) {
340
+ $attributes = array_keys( $this->defaults );
341
+ $attributes = array_flip( $attributes );
342
+
343
+ if ( ! isset( $attributes[ $key ] ) ) {
344
+ return;
345
+ }
346
+
347
+ if ( isset( $options[ $key ] ) ) {
348
+ return $options[ $key ];
349
+ } else {
350
+ return '';
351
+ }
352
+ }
353
+ }
classes/abstract/class.validation-rule.php ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Name : MW WP Form Abstract Validation Rule
4
+ * Version : 2.0.0
5
+ * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
+ * Created : July 19, 2014
8
+ * Modified : May 30, 2017
9
+ * License : GPLv2 or later
10
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
+ */
12
+ abstract class MW_WP_Form_Abstract_Validation_Rule {
13
+
14
+ /**
15
+ * Validation rule name
16
+ * @var string
17
+ */
18
+ protected $name;
19
+
20
+ /**
21
+ * @var MW_WP_Form_Data
22
+ */
23
+ protected $Data;
24
+
25
+ public function __construct( MW_WP_Form_Data $Data = null ) {
26
+ if ( ! $this->get_name() ) {
27
+ exit( 'MW_WP_Form_Abstract_Validation_Rule::$name must override.' );
28
+ }
29
+
30
+ if ( ! is_null( $Data ) ) {
31
+ $this->Data = $Data;
32
+ }
33
+
34
+ add_filter( 'mwform_validation_rules', array( $this, '_mwform_validation_rules' ) );
35
+ }
36
+
37
+ /**
38
+ * Generate array of validation rules
39
+ *
40
+ * @param array $validation_rules rray of MW_WP_Form_Abstract_Validation_Rule
41
+ * @return array
42
+ */
43
+ public function _mwform_validation_rules( array $validation_rules ) {
44
+ $validation_rules[ $this->get_name() ] = $this;
45
+ return $validation_rules;
46
+ }
47
+
48
+ /**
49
+ * Inject MW_WP_Form_Data
50
+ *
51
+ * @deprecated
52
+ * @param MW_WP_Form_Data $Data
53
+ * @return void
54
+ */
55
+ public function set_Data( MW_WP_Form_Data $Data ) {
56
+ $this->Data = $Data;
57
+ }
58
+
59
+ /**
60
+ * Return true when set $this->Data
61
+ *
62
+ * @return bool
63
+ */
64
+ public function is_set_Data() {
65
+ return ( is_a( $this->Data, 'MW_WP_Form_Data' ) );
66
+ }
67
+
68
+ /**
69
+ * Return validation rule name
70
+ *
71
+ * @return string Validation rule name
72
+ */
73
+ public function get_name() {
74
+ return $this->name;
75
+ }
76
+ public function getName() {
77
+ MWF_Functions::deprecated_message(
78
+ get_class() . '::getName()',
79
+ get_class() . '::get_name()'
80
+ );
81
+ return $this->get_name();
82
+ }
83
+
84
+ /**
85
+ * Validation process
86
+ *
87
+ * @param string $name
88
+ * @param array $option
89
+ * @return string Error message
90
+ */
91
+ abstract public function rule( $name, array $options = array() );
92
+
93
+ /**
94
+ * Add setting field to validation rule setting panel
95
+ *
96
+ * @param numeric $key ID of validation rule
97
+ * @param array $value Content of validation rule
98
+ * @return void
99
+ */
100
+ abstract public function admin( $key, $value );
101
+ }
classes/config.php CHANGED
@@ -1,39 +1,38 @@
1
  <?php
2
  /**
3
  * Name : MWF Config
4
- * Description: 設定ファイル
5
- * Version : 1.3.0
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : May 29, 2013
9
- * Modified : January 2, 2015
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MWF_Config {
14
 
15
  /**
16
- * プラグイン識別子
17
  */
18
  const NAME = 'mw-wp-form';
19
 
20
  /**
21
- * ネームスペース
22
  */
23
  const DOMAIN = 'mw-wp-form';
24
 
25
  /**
26
- * DBに保存する問い合わせデータの post_type名 の接頭辞
27
  */
28
  const DBDATA = 'mwf_';
29
 
30
  /**
31
- * アップロードファイルを示す name属性 を保存する配列、メタデータの名前
32
  */
33
  const UPLOAD_FILE_KEYS = 'mwf_upload_files';
34
 
35
  /**
36
- * カスタムメールタグを示す name属性 を保存する配列、メタデータの名前
37
  */
38
  const CUSTOM_MAIL_TAG_KEYS = 'mwf_custom_mail_tags';
39
 
@@ -43,37 +42,43 @@ class MWF_Config {
43
  const UPLOAD_FILES = 'mwf_files';
44
 
45
  /**
46
- * akismetのエラーを格納するValidationのキー
47
  */
48
  const AKISMET = 'mwf_akismet';
49
 
50
  /**
51
- * 権限
52
  */
53
  const CAPABILITY = 'edit_pages';
54
 
55
  /**
56
- * お問い合せ番号用のキー名
57
  */
58
  const TRACKINGNUMBER = 'tracking_number';
59
 
60
  /**
61
- * 確認ボタンの名前
62
  */
63
  const CONFIRM_BUTTON = 'submitConfirm';
64
 
65
  /**
66
- * 戻るボタンの名前
67
  */
68
  const BACK_BUTTON = 'submitBack';
69
 
70
  /**
71
- * CONTACT_DATA_NAME
72
  */
73
  const CONTACT_DATA_NAME = '_mw-wp-form_data';
 
74
 
75
  /**
76
- * 送信エラーかどうかを判定する MW_WP_Form_Data のキー
77
  */
78
  const SEND_ERROR = 'mw-wp-form-send-error';
 
 
 
 
 
79
  }
1
  <?php
2
  /**
3
  * Name : MWF Config
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : May 29, 2013
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MWF_Config {
13
 
14
  /**
15
+ * Plugin ID
16
  */
17
  const NAME = 'mw-wp-form';
18
 
19
  /**
20
+ * Text Domain
21
  */
22
  const DOMAIN = 'mw-wp-form';
23
 
24
  /**
25
+ * Prefix of post type of saved inquiry data
26
  */
27
  const DBDATA = 'mwf_';
28
 
29
  /**
30
+ * The name of field that array of uploaded file names
31
  */
32
  const UPLOAD_FILE_KEYS = 'mwf_upload_files';
33
 
34
  /**
35
+ * The name of field that array of custom mail tag names
36
  */
37
  const CUSTOM_MAIL_TAG_KEYS = 'mwf_custom_mail_tags';
38
 
42
  const UPLOAD_FILES = 'mwf_files';
43
 
44
  /**
45
+ * Field name of Akismet
46
  */
47
  const AKISMET = 'mwf_akismet';
48
 
49
  /**
50
+ * Capability
51
  */
52
  const CAPABILITY = 'edit_pages';
53
 
54
  /**
55
+ * Name of tracking number
56
  */
57
  const TRACKINGNUMBER = 'tracking_number';
58
 
59
  /**
60
+ * Field name of confirm button
61
  */
62
  const CONFIRM_BUTTON = 'submitConfirm';
63
 
64
  /**
65
+ * Field name of back button
66
  */
67
  const BACK_BUTTON = 'submitBack';
68
 
69
  /**
70
+ * Name of meta data of saved inquiry data
71
  */
72
  const CONTACT_DATA_NAME = '_mw-wp-form_data';
73
+ const INQUIRY_DATA_NAME = self::CONTACT_DATA_NAME;
74
 
75
  /**
76
+ * Name of sending error data
77
  */
78
  const SEND_ERROR = 'mw-wp-form-send-error';
79
+
80
+ /**
81
+ * Nonce field name
82
+ */
83
+ const TOKEN_NAME = 'mw_wp_form_token';
84
  }
classes/controllers/class.admin-list.php CHANGED
@@ -1,33 +1,30 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Admin List Controller
4
- * Version : 1.1.0
5
  * Author : Takashi Kitajima
6
- * Author URI : http://2inc.org
7
  * Created : January 1, 2015
8
- * Modified : March 27, 2015
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Admin_List_Controller extends MW_WP_Form_Controller {
13
-
14
- /**
15
- * initialize
16
- */
17
- public function initialize() {
18
  $screen = get_current_screen();
19
- add_filter( 'views_' . $screen->id , array( $this, 'donate_link' ) );
20
- add_action( 'admin_head' , array( $this, 'add_columns' ) );
21
- add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
22
  }
23
 
24
  /**
25
- * 寄付リンクを出力
26
  *
27
  * @param array $views
28
  * @return array
29
  */
30
- public function donate_link( $views ) {
31
  $donation = array(
32
  'donation' =>
33
  '<div class="donation"><p>' .
@@ -40,27 +37,32 @@ class MW_WP_Form_Admin_List_Controller extends MW_WP_Form_Controller {
40
  }
41
 
42
  /**
43
- * admin_enqueue_scripts
 
 
44
  */
45
- public function admin_enqueue_scripts() {
46
- $url = plugins_url( MWF_Config::NAME );
47
- wp_enqueue_style( MWF_Config::NAME . '-admin-list', $url . '/css/admin-list.css' );
48
  }
49
 
50
  /**
51
- * add_columns
 
 
52
  */
53
- public function add_columns() {
54
- add_filter( 'manage_posts_columns' , array( $this, 'manage_posts_columns' ) );
55
- add_action( 'manage_posts_custom_column', array( $this, 'manage_posts_custom_column' ), 10, 2 );
56
  }
57
 
58
  /**
59
- * manage_posts_columns
 
60
  * @param array $columns
61
- * @return array $columns
62
  */
63
- public function manage_posts_columns( $columns ) {
64
  $date = $columns['date'];
65
  unset( $columns['date'] );
66
  $columns['mwform_form_key'] = __( 'Form Key', 'mw-wp-form' );
@@ -69,14 +71,16 @@ class MW_WP_Form_Admin_List_Controller extends MW_WP_Form_Controller {
69
  }
70
 
71
  /**
72
- * manage_posts_custom_column
 
73
  * @param string $column_name
74
  * @param int $post_id
75
  */
76
- public function manage_posts_custom_column( $column_name, $post_id ) {
77
- $this->assign( 'post_id', get_the_ID() );
78
- if ( $column_name === 'mwform_form_key' ) {
79
- $this->render( 'admin-list/form-key' );
 
80
  }
81
  }
82
  }
1
  <?php
2
  /**
3
  * Name : MW WP Form Admin List Controller
4
+ * Version : 2.0.0
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : January 1, 2015
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Admin_List_Controller extends MW_WP_Form_Controller {
13
+
14
+ public function __construct() {
 
 
 
15
  $screen = get_current_screen();
16
+ add_filter( 'views_' . $screen->id , array( $this, '_donate_link' ) );
17
+ add_action( 'admin_head' , array( $this, '_add_columns' ) );
18
+ add_action( 'admin_enqueue_scripts', array( $this, '_admin_enqueue_scripts' ) );
19
  }
20
 
21
  /**
22
+ * Return Donate link html
23
  *
24
  * @param array $views
25
  * @return array
26
  */
27
+ public function _donate_link( $views ) {
28
  $donation = array(
29
  'donation' =>
30
  '<div class="donation"><p>' .
37
  }
38
 
39
  /**
40
+ * Hooked for adding columns
41
+ *
42
+ * @return void
43
  */
44
+ public function _add_columns() {
45
+ add_filter( 'manage_posts_columns' , array( $this, '_manage_posts_columns' ) );
46
+ add_action( 'manage_posts_custom_column', array( $this, '_manage_posts_custom_column' ), 10, 2 );
47
  }
48
 
49
  /**
50
+ * Enqueue assets
51
+ *
52
+ * @return void
53
  */
54
+ public function _admin_enqueue_scripts() {
55
+ $url = plugins_url( MWF_Config::NAME );
56
+ wp_enqueue_style( MWF_Config::NAME . '-admin-list', $url . '/css/admin-list.css' );
57
  }
58
 
59
  /**
60
+ * Add columns
61
+ *
62
  * @param array $columns
63
+ * @return array
64
  */
65
+ public function _manage_posts_columns( $columns ) {
66
  $date = $columns['date'];
67
  unset( $columns['date'] );
68
  $columns['mwform_form_key'] = __( 'Form Key', 'mw-wp-form' );
71
  }
72
 
73
  /**
74
+ * Render column for form key
75
+ *
76
  * @param string $column_name
77
  * @param int $post_id
78
  */
79
+ public function _manage_posts_custom_column( $column_name, $post_id ) {
80
+ if ( 'mwform_form_key' === $column_name ) {
81
+ $this->_render( 'admin-list/form-key', array(
82
+ 'post_id' => get_the_ID(),
83
+ ) );
84
  }
85
  }
86
  }
classes/controllers/class.admin.php CHANGED
@@ -1,315 +1,495 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Admin Controller
4
- * Version : 1.2.0
5
  * Author : Takashi Kitajima
6
- * Author URI : http://2inc.org
7
  * Created : December 31, 2014
8
- * Modified : August 22, 2016
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Admin_Controller extends MW_WP_Form_Controller {
13
 
14
  /**
15
- * バリデーションルールの配列
16
  * @var array
17
  */
18
- protected $validation_rules = array();
19
-
20
- /**
21
- * フォームスタイルの配列
22
- */
23
  protected $styles = array();
24
 
25
- /**
26
- * __construct
27
- * @param array $validation_rules
28
- */
29
- public function __construct( array $validation_rules ) {
30
- foreach ( $validation_rules as $validation_name => $instance ) {
31
- if ( is_callable( array( $instance, 'admin' ) ) ) {
32
- $this->validation_rules[$instance->getName()] = $instance;
33
- }
34
- }
35
- $this->styles = apply_filters( 'mwform_styles', $this->styles );
36
  }
37
 
38
  /**
39
- * initialize
 
 
40
  */
41
- public function initialize() {
42
- $Admin = new MW_WP_Form_Admin();
43
- add_action( 'add_meta_boxes' , array( $this , 'add_meta_boxes' ) );
44
- add_filter( 'default_content' , array( $this , 'default_content' ) );
45
- add_action( 'media_buttons' , array( $this , 'tag_generator' ) );
46
- add_action( 'admin_enqueue_scripts', array( $this , 'admin_enqueue_scripts' ) );
47
- add_action( 'save_post' , array( $Admin, 'save_post' ) );
48
- }
 
 
49
 
50
- /**
51
- * カスタムフィールドを出力
52
- */
53
- public function add_meta_boxes() {
54
- // 完了画面内容
55
  add_meta_box(
56
  MWF_Config::NAME . '_complete_message_metabox',
57
  __( 'Complete Message', 'mw-wp-form' ),
58
- array( $this, 'complete_message' ),
59
- MWF_Config::NAME, 'normal'
 
60
  );
61
 
62
- // URL設定
63
  add_meta_box(
64
  MWF_Config::NAME . '_url',
65
  __( 'URL Options', 'mw-wp-form' ),
66
- array( $this, 'url' ),
67
- MWF_Config::NAME, 'normal'
 
68
  );
69
 
70
- // バリデーション
71
  add_meta_box(
72
  MWF_Config::NAME . '_validation',
73
  __( 'Validation Rule', 'mw-wp-form' ),
74
- array( $this, 'validation_rule' ),
75
- MWF_Config::NAME, 'normal'
 
76
  );
77
 
78
- // アドオン
79
  add_meta_box(
80
  MWF_Config::NAME . '_addon',
81
  __( 'Add-ons', 'mw-wp-form' ),
82
- array( $this, 'add_ons' ),
83
- MWF_Config::NAME, 'side'
 
84
  );
85
 
86
- // フォーム識別子
87
  add_meta_box(
88
  MWF_Config::NAME . '_formkey',
89
  __( 'Form Key', 'mw-wp-form' ),
90
- array( $this, 'form_key' ),
91
- MWF_Config::NAME, 'side'
 
92
  );
93
 
94
- // 自動返信メール設定
95
  add_meta_box(
96
  MWF_Config::NAME . '_mail',
97
  __( 'Automatic Reply Email Options', 'mw-wp-form' ),
98
- array( $this, 'mail_options' ),
99
- MWF_Config::NAME, 'side'
 
100
  );
101
 
102
- // 管理者メール設定
103
  add_meta_box(
104
  MWF_Config::NAME . '_admin_mail',
105
  __( 'Admin Email Options', 'mw-wp-form' ),
106
- array( $this, 'admin_mail_options' ),
107
- MWF_Config::NAME, 'side'
 
108
  );
109
 
110
- // 設定
111
  add_meta_box(
112
  MWF_Config::NAME . '_settings',
113
  __( 'settings', 'mw-wp-form' ),
114
- array( $this, 'settings' ),
115
- MWF_Config::NAME, 'side'
 
116
  );
117
 
118
- // スタイル
119
  if ( $this->styles ) {
120
  add_meta_box(
121
  MWF_Config::NAME . '_styles',
122
  __( 'Style setting', 'mw-wp-form' ),
123
- array( $this, 'style' ),
124
- MWF_Config::NAME, 'side'
 
125
  );
126
  }
127
  }
128
 
129
  /**
130
- * 完了画面内容
 
 
 
131
  */
132
- public function complete_message() {
133
- wp_editor(
134
- $this->get_option( 'complete_message' ), MWF_Config::NAME . '_complete_message',
135
- array(
136
- 'textarea_name' => MWF_Config::NAME . '[complete_message]',
137
- 'textarea_rows' => 7,
138
- )
139
- );
140
  }
141
 
142
  /**
143
- * URL設定
 
 
 
144
  */
145
- public function url() {
146
- $this->assign( 'input_url' , $this->get_option( 'input_url' ) );
147
- $this->assign( 'confirmation_url' , $this->get_option( 'confirmation_url' ) );
148
- $this->assign( 'complete_url' , $this->get_option( 'complete_url' ) );
149
- $this->assign( 'validation_error_url', $this->get_option( 'validation_error_url' ) );
150
- $this->render( 'admin/url' );
 
 
 
 
 
151
  }
152
 
153
  /**
154
- * バリデーション
 
 
155
  */
156
- public function validation_rule() {
157
- $validation = $this->get_option( 'validation' );
158
- if ( !$validation ) {
159
- $validation = array();
160
- }
161
- $validation_keys = array(
162
- 'target' => '',
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
163
  );
164
- foreach ( $this->validation_rules as $validation_rule => $instance ) {
165
- $validation_keys[$instance->getName()] = '';
166
- }
167
- // 空の隠れバリデーションフィールド(コピー元)を挿入
168
- array_unshift( $validation, $validation_keys );
169
- $this->assign( 'validation' , $validation );
170
- $this->assign( 'validation_rules', $this->validation_rules );
171
- $this->assign( 'validation_keys' , $validation_keys );
172
- $this->render( 'admin/validation-rule' );
173
  }
174
 
175
  /**
176
- * アドオン
 
 
 
177
  */
178
- public function add_ons() {
179
- $this->render( 'admin/add-ons' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
180
  }
181
 
182
  /**
183
- * フォーム識別子
 
 
184
  */
185
- public function form_key() {
186
- $this->assign( 'post_id', get_the_ID() );
187
- $this->render( 'admin/form-key' );
 
188
  }
189
 
190
  /**
191
- * 自動返信メール設定
 
 
192
  */
193
- public function mail_options() {
194
- $this->assign( 'mail_subject' , $this->get_option( 'mail_subject' ) );
195
- $this->assign( 'mail_sender' , $this->get_option( 'mail_sender' ) );
196
- $this->assign( 'mail_from' , $this->get_option( 'mail_from' ) );
197
- $this->assign( 'mail_content' , $this->get_option( 'mail_content' ) );
198
- $this->assign( 'automatic_reply_email', $this->get_option( 'automatic_reply_email' ) );
199
- $this->render( 'admin/mail-options' );
200
  }
201
 
202
  /**
203
- * 管理者メール設定
 
 
204
  */
205
- public function admin_mail_options() {
206
- $this->assign( 'mail_to' , $this->get_option( 'mail_to' ) );
207
- $this->assign( 'mail_cc' , $this->get_option( 'mail_cc' ) );
208
- $this->assign( 'mail_bcc' , $this->get_option( 'mail_bcc' ) );
209
- $this->assign( 'admin_mail_subject' , $this->get_option( 'admin_mail_subject' ) );
210
- $this->assign( 'admin_mail_sender' , $this->get_option( 'admin_mail_sender' ) );
211
- $this->assign( 'mail_return_path' , $this->get_option( 'mail_return_path' ) );
212
- $this->assign( 'admin_mail_from' , $this->get_option( 'admin_mail_from' ) );
213
- $this->assign( 'admin_mail_content' , $this->get_option( 'admin_mail_content' ) );
214
- $this->render( 'admin/admin-mail-options' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
215
  }
216
 
217
  /**
218
- * 設定
 
 
219
  */
220
- public function settings() {
221
- $this->assign( 'querystring' , $this->get_option( 'querystring' ) );
222
- $this->assign( 'usedb' , $this->get_option( 'usedb' ) );
223
- $this->assign( 'scroll' , $this->get_option( 'scroll' ) );
224
- $this->assign( 'akismet_author' , $this->get_option( 'akismet_author' ) );
225
- $this->assign( 'akismet_author_email', $this->get_option( 'akismet_author_email' ) );
226
- $this->assign( 'akismet_author_url' , $this->get_option( 'akismet_author_url' ) );
227
- $this->assign( 'tracking_number' , $this->get_option( MWF_Config::TRACKINGNUMBER ) );
228
- $this->render( 'admin/settings' );
229
  }
230
 
231
  /**
232
- * スタイル
 
 
233
  */
234
- public function style() {
235
- $this->assign( 'styles', $this->styles );
236
- $this->assign( 'style' , $this->get_option( 'style' ) );
237
- $this->render( 'admin/style' );
238
  }
239
 
240
  /**
241
- * 本文の初期値を設定
242
  *
243
- * @param string $content
244
- * @return string
245
  */
246
- public function default_content( $content ) {
247
- return apply_filters( 'mwform_default_content', '' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
248
  }
249
 
250
  /**
251
- * タグジェネレータを出力
252
  *
253
- * @param string $editor_id
254
  */
255
- public function tag_generator( $editor_id ) {
256
- $post_type = get_post_type();
257
- if ( $post_type !== MWF_Config::NAME ) {
258
- return;
259
  }
260
- if ( $editor_id !== 'content' ) {
261
- return;
 
 
262
  }
263
- $this->render( 'admin/tag-generator' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
264
  }
265
 
266
  /**
267
- * get_option
268
- * フォームの設定データを返す
269
- * @param string $key 設定データのキー
270
- * @return mixed 設定データ
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
271
  */
272
- protected function get_option( $key ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
273
  global $post;
274
  $Setting = new MW_WP_Form_Setting( $post->ID );
275
 
276
- if ( $key === MWF_Config::TRACKINGNUMBER ) {
277
  $value = $Setting->get_tracking_number();
278
  } else {
279
  $value = $Setting->get( $key );
280
  }
281
 
282
- if ( !empty( $value ) ) {
283
  return $value;
284
- } else {
285
- $date = $post->post_date;
286
- $modified = $post->post_modified;
287
- if ( $date === $modified ){
288
- return apply_filters( 'mwform_default_settings', '', $key );
289
- }
290
  }
291
- }
292
-
293
- /**
294
- * admin_enqueue_scripts
295
- */
296
- public function admin_enqueue_scripts() {
297
- $post_type = get_post_type();
298
- $url = plugins_url( MWF_Config::NAME );
299
- wp_enqueue_style( MWF_Config::NAME . '-admin', $url . '/css/admin.css' );
300
- wp_enqueue_style( MWF_Config::NAME . '-admin-repeatable', $url . '/css/admin-repeatable.css' );
301
- wp_enqueue_script( MWF_Config::NAME . '-repeatable', $url . '/js/mw-wp-form-repeatable.js' );
302
- wp_enqueue_script( MWF_Config::NAME . '-admin', $url . '/js/admin.js', array( 'jquery-ui-dialog', 'jquery-ui-sortable' ) );
303
- wp_enqueue_script( 'jquery-ui-dialog' );
304
- wp_enqueue_script( 'jquery-ui-sortable' );
305
 
306
- global $wp_scripts;
307
- $ui = $wp_scripts->query( 'jquery-ui-core' );
308
- wp_enqueue_style(
309
- 'jquery.ui',
310
- '//ajax.googleapis.com/ajax/libs/jqueryui/' . $ui->ver . '/themes/smoothness/jquery-ui.min.css',
311
- array(),
312
- $ui->ver
313
- );
314
  }
315
  }
1
  <?php
2
  /**
3
  * Name : MW WP Form Admin Controller
4
+ * Version : 2.0.0
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : December 31, 2014
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Admin_Controller extends MW_WP_Form_Controller {
13
 
14
  /**
 
15
  * @var array
16
  */
 
 
 
 
 
17
  protected $styles = array();
18
 
19
+ public function __construct() {
20
+ add_action( 'add_meta_boxes' , array( $this, '_add_meta_boxes' ) );
21
+ add_filter( 'default_content' , array( $this, '_default_content' ) );
22
+ add_action( 'media_buttons' , array( $this, '_tag_generator' ) );
23
+ add_action( 'admin_enqueue_scripts', array( $this, '_admin_enqueue_scripts' ) );
24
+ add_action( 'save_post' , array( $this, '_save_post' ) );
 
 
 
 
 
25
  }
26
 
27
  /**
28
+ * Add meta boxes
29
+ *
30
+ * @return void
31
  */
32
+ public function _add_meta_boxes() {
33
+ global $post;
34
+
35
+ $this->styles = apply_filters( 'mwform_styles', $this->styles );
36
+ $form_key = MWF_Functions::get_form_key_from_form_id( $post->ID );
37
+ $Form_Fields = MW_WP_Form_Form_Fields::instantiation( $form_key );
38
+ $form_fields = $Form_Fields->get_form_fields();
39
+ foreach ( $form_fields as $form_field ) {
40
+ $form_field->add_tag_generator();
41
+ }
42
 
 
 
 
 
 
43
  add_meta_box(
44
  MWF_Config::NAME . '_complete_message_metabox',
45
  __( 'Complete Message', 'mw-wp-form' ),
46
+ array( $this, '_complete_message' ),
47
+ MWF_Config::NAME,
48
+ 'normal'
49
  );
50
 
 
51
  add_meta_box(
52
  MWF_Config::NAME . '_url',
53
  __( 'URL Options', 'mw-wp-form' ),
54
+ array( $this, '_url' ),
55
+ MWF_Config::NAME,
56
+ 'normal'
57
  );
58
 
 
59
  add_meta_box(
60
  MWF_Config::NAME . '_validation',
61
  __( 'Validation Rule', 'mw-wp-form' ),
62
+ array( $this, '_validation_rule' ),
63
+ MWF_Config::NAME,
64
+ 'normal'
65
  );
66
 
 
67
  add_meta_box(
68
  MWF_Config::NAME . '_addon',
69
  __( 'Add-ons', 'mw-wp-form' ),
70
+ array( $this, '_add_ons' ),
71
+ MWF_Config::NAME,
72
+ 'side'
73
  );
74
 
 
75
  add_meta_box(
76
  MWF_Config::NAME . '_formkey',
77
  __( 'Form Key', 'mw-wp-form' ),
78
+ array( $this, '_form_key' ),
79
+ MWF_Config::NAME,
80
+ 'side'
81
  );
82
 
 
83
  add_meta_box(
84
  MWF_Config::NAME . '_mail',
85
  __( 'Automatic Reply Email Options', 'mw-wp-form' ),
86
+ array( $this, '_mail_options' ),
87
+ MWF_Config::NAME,
88
+ 'side'
89
  );
90
 
 
91
  add_meta_box(
92
  MWF_Config::NAME . '_admin_mail',
93
  __( 'Admin Email Options', 'mw-wp-form' ),
94
+ array( $this, '_admin_mail_options' ),
95
+ MWF_Config::NAME,
96
+ 'side'
97
  );
98
 
 
99
  add_meta_box(
100
  MWF_Config::NAME . '_settings',
101
  __( 'settings', 'mw-wp-form' ),
102
+ array( $this, '_settings' ),
103
+ MWF_Config::NAME,
104
+ 'side'
105
  );
106
 
 
107
  if ( $this->styles ) {
108
  add_meta_box(
109
  MWF_Config::NAME . '_styles',
110
  __( 'Style setting', 'mw-wp-form' ),
111
+ array( $this, '_style' ),
112
+ MWF_Config::NAME,
113
+ 'side'
114
  );
115
  }
116
  }
117
 
118
  /**
119
+ * Set default form html
120
+ *
121
+ * @param string $content
122
+ * @return string
123
  */
124
+ public function _default_content( $content ) {
125
+ return apply_filters( 'mwform_default_content', '' );
 
 
 
 
 
 
126
  }
127
 
128
  /**
129
+ * Render tag generator
130
+ *
131
+ * @param string $editor_id
132
+ * @return void
133
  */
134
+ public function _tag_generator( $editor_id ) {
135
+ $post_type = get_post_type();
136
+ if ( MWF_Config::NAME !== $post_type ) {
137
+ return;
138
+ }
139
+
140
+ if ( 'content' !== $editor_id ) {
141
+ return;
142
+ }
143
+
144
+ $this->_render( 'admin/tag-generator' );
145
  }
146
 
147
  /**
148
+ * Enqueue assets
149
+ *
150
+ * @return void
151
  */
152
+ public function _admin_enqueue_scripts() {
153
+ $url = plugins_url( MWF_Config::NAME );
154
+
155
+ wp_enqueue_style(
156
+ MWF_Config::NAME . '-admin',
157
+ $url . '/css/admin.css'
158
+ );
159
+
160
+ wp_enqueue_style(
161
+ MWF_Config::NAME . '-admin-repeatable',
162
+ $url . '/css/admin-repeatable.css'
163
+ );
164
+
165
+ wp_enqueue_script(
166
+ MWF_Config::NAME . '-repeatable',
167
+ $url . '/js/mw-wp-form-repeatable.js'
168
+ );
169
+
170
+ wp_enqueue_script(
171
+ MWF_Config::NAME . '-admin',
172
+ $url . '/js/admin.js',
173
+ array( 'jquery-ui-dialog', 'jquery-ui-sortable' )
174
+ );
175
+
176
+ wp_enqueue_script( 'jquery-ui-dialog' );
177
+ wp_enqueue_script( 'jquery-ui-sortable' );
178
+
179
+ global $wp_scripts;
180
+ $ui = $wp_scripts->query( 'jquery-ui-core' );
181
+ wp_enqueue_style(
182
+ 'jquery.ui',
183
+ '//ajax.googleapis.com/ajax/libs/jqueryui/' . $ui->ver . '/themes/smoothness/jquery-ui.min.css',
184
+ array(),
185
+ $ui->ver
186
  );
 
 
 
 
 
 
 
 
 
187
  }
188
 
189
  /**
190
+ * Save
191
+ *
192
+ * @param int $post_id
193
+ * @return void
194
  */
195
+ public function _save_post( $post_id ) {
196
+ if ( ! isset( $_POST['post_type'] ) || MWF_Config::NAME !== $_POST['post_type'] ) {
197
+ return;
198
+ }
199
+
200
+ if ( ! isset( $_POST[ MWF_Config::NAME . '_nonce' ] ) ) {
201
+ return;
202
+ }
203
+
204
+ if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
205
+ return;
206
+ }
207
+
208
+ if ( ! wp_verify_nonce( $_POST[ MWF_Config::NAME . '_nonce' ], MWF_Config::NAME ) ) {
209
+ return;
210
+ }
211
+
212
+ if ( ! current_user_can( MWF_Config::CAPABILITY ) ) {
213
+ return;
214
+ }
215
+
216
+ $data = $_POST[ MWF_Config::NAME ];
217
+
218
+ $triminglists = array(
219
+ 'mail_from',
220
+ 'mail_return_path',
221
+ 'mail_to',
222
+ 'mail_cc',
223
+ 'mail_bcc',
224
+ 'admin_mail_from',
225
+ 'mail_reply_to',
226
+ 'admin_mail_reply_to',
227
+ );
228
+ foreach ( $triminglists as $name ) {
229
+ if ( function_exists( 'mb_convert_kana' ) ) {
230
+ $data[ $name ] = trim( mb_convert_kana( $data[ $name ], 's', get_option( 'blog_charset' ) ) );
231
+ } else {
232
+ $data[ $name ] = trim( $data[ $name ] );
233
+ }
234
+ }
235
+
236
+ if ( ! empty( $data['validation'] ) && is_array( $data['validation'] ) ) {
237
+ $validation = array();
238
+ foreach ( $data['validation'] as $_validation ) {
239
+ if ( empty( $_validation['target'] ) ) {
240
+ continue;
241
+ }
242
+
243
+ foreach ( $_validation as $key => $value ) {
244
+ if ( 'between' === $key ) {
245
+ if ( ! MWF_Functions::is_numeric( $value['min'] ) ) {
246
+ unset( $_validation[ $key ]['min'] );
247
+ }
248
+ if ( ! MWF_Functions::is_numeric( $value['max'] ) ) {
249
+ unset( $_validation[ $key ]['max'] );
250
+ }
251
+ }
252
+
253
+ if ( 'minlength' === $key && ! MWF_Functions::is_numeric( $value['min'] ) ) {
254
+ unset( $_validation[ $key ] );
255
+ }
256
+
257
+ if ( 'fileType' === $key && isset( $value['types'] ) && ! preg_match( '/^[0-9A-Za-z,]+$/', $value['types'] ) ) {
258
+ unset( $_validation[ $key ] );
259
+ }
260
+
261
+ if ( 'fileSize' === $key && ! MWF_Functions::is_numeric( $value['bytes'] ) ) {
262
+ unset( $_validation[ $key ] );
263
+ }
264
+
265
+ if ( empty( $value ) ) {
266
+ unset( $_validation[ $key ] );
267
+ }
268
+
269
+ if ( is_array( $value ) && ! array_diff( $value, array( '' ) ) ) {
270
+ unset( $_validation[ $key ] );
271
+ }
272
+ }
273
+
274
+ $validation[] = $_validation;
275
+ }
276
+
277
+ $data['validation'] = $validation;
278
+ }
279
+
280
+ if ( empty( $data['querystring'] ) ) {
281
+ $data['querystring'] = false;
282
+ }
283
+
284
+ if ( empty( $data['usedb'] ) ) {
285
+ $data['usedb'] = false;
286
+ }
287
+
288
+ if ( empty( $data['scroll'] ) ) {
289
+ $data['scroll'] = false;
290
+ }
291
+
292
+ $Setting = new MW_WP_Form_Setting( $post_id );
293
+ $Setting->sets( $data );
294
+
295
+ if ( isset( $_POST[ MWF_Config::TRACKINGNUMBER ] ) ) {
296
+ $tracking_number = $_POST[ MWF_Config::TRACKINGNUMBER ];
297
+ $Setting->update_tracking_number( $tracking_number );
298
+ }
299
+
300
+ $Setting->save();
301
  }
302
 
303
  /**
304
+ * Render complete message meta box
305
+ *
306
+ * @return void
307
  */
308
+ public function _complete_message() {
309
+ $this->_render( 'admin/complete-message', array(
310
+ 'content' => $this->_get_option( 'complete_message' ),
311
+ ) );
312
  }
313
 
314
  /**
315
+ * Render URL setting meta box
316
+ *
317
+ * @return void
318
  */
319
+ public function _url() {
320
+ $this->_render( 'admin/url', array(
321
+ 'input_url' => $this->_get_option( 'input_url' ),
322
+ 'confirmation_url' => $this->_get_option( 'confirmation_url' ),
323
+ 'complete_url' => $this->_get_option( 'complete_url' ),
324
+ 'validation_error_url' => $this->_get_option( 'validation_error_url' ),
325
+ ) );
326
  }
327
 
328
  /**
329
+ * Render validation meta box
330
+ *
331
+ * @return void
332
  */
333
+ public function _validation_rule() {
334
+ global $post;
335
+
336
+ $validation = $this->_get_option( 'validation' );
337
+ if ( ! $validation ) {
338
+ $validation = array();
339
+ }
340
+
341
+ $validation_keys = array(
342
+ 'target' => '',
343
+ );
344
+
345
+ $form_key = MWF_Functions::get_form_key_from_form_id( $post->ID );
346
+ $Validation_Rules = MW_WP_Form_Validation_Rules::instantiation( $form_key );
347
+
348
+ foreach ( $Validation_Rules->get_validation_rules() as $validation_rule => $instance ) {
349
+ $validation_keys[ $instance->getName() ] = '';
350
+ }
351
+
352
+ // 空の隠れバリデーションフィールド(コピー元)を挿入
353
+ array_unshift( $validation, $validation_keys );
354
+ $this->_render( 'admin/validation-rule', array(
355
+ 'validation' => $validation,
356
+ 'validation_rules' => $Validation_Rules->get_validation_rules(),
357
+ 'validation_keys' => $validation_keys,
358
+ ) );
359
  }
360
 
361
  /**
362
+ * Render add-on meta box
363
+ *
364
+ * @return void
365
  */
366
+ public function _add_ons() {
367
+ $this->_render( 'admin/add-ons' );
 
 
 
 
 
 
 
368
  }
369
 
370
  /**
371
+ * Render form key meta box
372
+ *
373
+ * @return void
374
  */
375
+ public function _form_key() {
376
+ $this->_render( 'admin/form-key', array(
377
+ 'post_id' => get_the_ID(),
378
+ ) );
379
  }
380
 
381
  /**
382
+ * Render reply mail meta box
383
  *
384
+ * @return void
 
385
  */
386
+ public function _mail_options() {
387
+ $mail_sender = $this->_get_option( 'mail_sender' );
388
+ if ( is_null( $mail_sender ) ) {
389
+ $mail_sender = get_bloginfo( 'name' );
390
+ }
391
+
392
+ $mail_reply_to = $this->_get_option( 'mail_reply_to' );
393
+ if ( is_null( $mail_reply_to ) ) {
394
+ $mail_reply_to = get_bloginfo( 'admin_email' );
395
+ }
396
+
397
+ $this->_render( 'admin/mail-options', array(
398
+ 'mail_subject' => $this->_get_option( 'mail_subject' ),
399
+ 'mail_sender' => $mail_sender,
400
+ 'mail_reply_to' => $mail_reply_to,
401
+ 'mail_from' => $this->_get_option( 'mail_from' ),
402
+ 'mail_content' => $this->_get_option( 'mail_content' ),
403
+ 'automatic_reply_email' => $this->_get_option( 'automatic_reply_email' ),
404
+ ) );
405
  }
406
 
407
  /**
408
+ * Render admin mail meta box
409
  *
410
+ * @return void
411
  */
412
+ public function _admin_mail_options() {
413
+ $mail_to = $this->_get_option( 'mail_to' );
414
+ if ( is_null( $mail_to ) ) {
415
+ $mail_to = get_bloginfo( 'admin_email' );
416
  }
417
+
418
+ $admin_mail_sender = $this->_get_option( 'admin_mail_sender' );
419
+ if ( is_null( $admin_mail_sender ) ) {
420
+ $admin_mail_sender = get_bloginfo( 'name' );
421
  }
422
+
423
+ $admin_mail_reply_to = $this->_get_option( 'admin_mail_reply_to' );
424
+ if ( is_null( $admin_mail_reply_to ) ) {
425
+ $admin_mail_reply_to = get_bloginfo( 'admin_email' );
426
+ }
427
+
428
+ $this->_render( 'admin/admin-mail-options', array(
429
+ 'mail_to' => $mail_to,
430
+ 'mail_cc' => $this->_get_option( 'mail_cc' ),
431
+ 'mail_bcc' => $this->_get_option( 'mail_bcc' ),
432
+ 'admin_mail_subject' => $this->_get_option( 'admin_mail_subject' ),
433
+ 'admin_mail_sender' => $admin_mail_sender,
434
+ 'admin_mail_reply_to' => $admin_mail_reply_to,
435
+ 'mail_return_path' => $this->_get_option( 'mail_return_path' ),
436
+ 'admin_mail_from' => $this->_get_option( 'admin_mail_from' ),
437
+ 'admin_mail_content' => $this->_get_option( 'admin_mail_content' ),
438
+ ) );
439
  }
440
 
441
  /**
442
+ * Render settings meta box
443
+ *
444
+ * @return void
445
+ */
446
+ public function _settings() {
447
+ $this->_render( 'admin/settings', array(
448
+ 'querystring' => $this->_get_option( 'querystring' ),
449
+ 'usedb' => $this->_get_option( 'usedb' ),
450
+ 'scroll' => $this->_get_option( 'scroll' ),
451
+ 'akismet_author' => $this->_get_option( 'akismet_author' ),
452
+ 'akismet_author_email' => $this->_get_option( 'akismet_author_email' ),
453
+ 'akismet_author_url' => $this->_get_option( 'akismet_author_url' ),
454
+ 'tracking_number' => $this->_get_option( MWF_Config::TRACKINGNUMBER ),
455
+ ) );
456
+ }
457
+
458
+ /**
459
+ * Render styles meta box
460
+ *
461
+ * @return void
462
  */
463
+ public function _style() {
464
+ $this->_render( 'admin/style', array(
465
+ 'styles' => $this->styles,
466
+ 'style' => $this->_get_option( 'style' ),
467
+ ) );
468
+ }
469
+
470
+ /**
471
+ * Get form option
472
+ *
473
+ * @param string $key Key of option
474
+ * @return mixed
475
+ */
476
+ protected function _get_option( $key ) {
477
  global $post;
478
  $Setting = new MW_WP_Form_Setting( $post->ID );
479
 
480
+ if ( MWF_Config::TRACKINGNUMBER === $key ) {
481
  $value = $Setting->get_tracking_number();
482
  } else {
483
  $value = $Setting->get( $key );
484
  }
485
 
486
+ if ( ! empty( $value ) ) {
487
  return $value;
 
 
 
 
 
 
488
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
489
 
490
+ if ( 'auto-draft' === $post->post_status ) {
491
+ return apply_filters( 'mwform_default_settings', null, $key );
492
+ }
493
+ return '';
 
 
 
 
494
  }
495
  }
classes/controllers/class.chart.php CHANGED
@@ -1,60 +1,52 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Chart Controller
4
- * Version : 1.1.0
5
  * Author : Takashi Kitajima
6
- * Author URI : http://2inc.org
7
  * Created : January 1, 2015
8
- * Modified : March 27, 2015
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Chart_Controller extends MW_WP_Form_Controller {
13
 
14
  /**
15
- * URL引数で渡される、そのグラフに使う投稿タイプ名
16
  * @var string
17
  */
18
  protected $formkey;
19
 
20
  /**
21
- * フォームの設定データ
22
  * @var array
23
  */
24
  protected $postdata = array();
25
 
26
- /**
27
- * Settings API グループ名
28
- * @var string
29
- */
30
- protected $option_group;
31
-
32
- /**
33
- * __construct
34
- */
35
  public function __construct() {
36
- $this->option_group = MWF_Config::NAME . '-' . 'chart-group';
37
- if ( !empty( $_GET['formkey'] ) ) {
38
  $this->formkey = $_GET['formkey'];
39
  }
40
- }
41
 
42
- /**
43
- * initialize
44
- */
45
- public function initialize() {
46
- $contact_data_post_types = MW_WP_Form_Contact_Data_Setting::get_posts();
47
- if ( !in_array( $this->formkey, $contact_data_post_types ) ) {
48
  exit;
49
  }
50
- add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts') );
 
 
 
 
51
  }
52
 
53
  /**
54
- * CSS、JSの読み込み
 
 
55
  */
56
- public function admin_enqueue_scripts() {
57
  global $wp_scripts;
 
58
  $ui = $wp_scripts->query( 'jquery-ui-core' );
59
  wp_enqueue_style(
60
  'jquery.ui',
@@ -62,11 +54,21 @@ class MW_WP_Form_Chart_Controller extends MW_WP_Form_Controller {
62
  array( 'jquery' ),
63
  $ui->ver
64
  );
 
65
  wp_enqueue_script( 'jquery-ui-sortable' );
66
 
67
  $url = plugins_url( MWF_Config::NAME );
68
- wp_enqueue_style( MWF_Config::NAME . '-admin-repeatable', $url . '/css/admin-repeatable.css' );
69
- wp_enqueue_script( 'jsapi', 'https://www.google.com/jsapi' );
 
 
 
 
 
 
 
 
 
70
  wp_enqueue_script(
71
  MWF_Config::NAME . '-repeatable',
72
  $url . '/js/mw-wp-form-repeatable.js',
@@ -74,6 +76,7 @@ class MW_WP_Form_Chart_Controller extends MW_WP_Form_Controller {
74
  null,
75
  true
76
  );
 
77
  wp_enqueue_script(
78
  MWF_Config::NAME . '-google-chart',
79
  $url . '/js/mw-wp-form-google-chart.js',
@@ -81,6 +84,7 @@ class MW_WP_Form_Chart_Controller extends MW_WP_Form_Controller {
81
  null,
82
  true
83
  );
 
84
  wp_enqueue_script(
85
  MWF_Config::NAME . '-admin-chart',
86
  $url . '/js/admin-chart.js',
@@ -91,24 +95,55 @@ class MW_WP_Form_Chart_Controller extends MW_WP_Form_Controller {
91
  }
92
 
93
  /**
94
- * グラフページを表示
 
 
95
  */
96
- public function index() {
97
- $post_type = $this->formkey;
 
 
98
 
99
- // form_posts
100
- $default_args = array(
101
- 'posts_per_page' => -1,
102
- );
103
- $_args = apply_filters( 'mwform_get_inquiry_data_args-' . $post_type, $default_args );
104
- $args = array(
105
- 'post_type' => $post_type,
 
 
 
 
 
 
 
 
 
 
 
 
106
  );
107
- if ( !empty( $_args ) && is_array( $_args ) ) {
108
- $args = array_merge( $_args, $args );
109
- } else {
110
- $args = array_merge( $_args, $default_args );
 
 
 
 
 
 
 
 
 
 
111
  }
 
 
 
 
 
112
  $form_posts = get_posts( $args );
113
 
114
  // custom_keys
@@ -121,7 +156,7 @@ class MW_WP_Form_Chart_Controller extends MW_WP_Form_Controller {
121
  continue;
122
  }
123
  $post_meta = get_post_meta( $post->ID, $post_custom_key, true );
124
- $custom_keys[$post_custom_key][$post_meta][] = $post->ID;
125
  }
126
  }
127
  }
@@ -140,11 +175,35 @@ class MW_WP_Form_Chart_Controller extends MW_WP_Form_Controller {
140
  // 空の隠れフィールド(コピー元)を挿入
141
  array_unshift( $postdata, $default_keys );
142
 
143
- $this->assign( 'post_type' , $post_type );
144
- $this->assign( 'option_group', $this->option_group );
145
- $this->assign( 'form_posts' , $form_posts );
146
- $this->assign( 'custom_keys' , $custom_keys );
147
- $this->assign( 'postdata' , $postdata );
148
- $this->render( 'chart/index' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
149
  }
150
- }
1
  <?php
2
  /**
3
  * Name : MW WP Form Chart Controller
4
+ * Version : 2.0.0
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : January 1, 2015
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Chart_Controller extends MW_WP_Form_Controller {
13
 
14
  /**
15
+ * Post type of saved inquiry data to display in this chart
16
  * @var string
17
  */
18
  protected $formkey;
19
 
20
  /**
21
+ * Settings of the form
22
  * @var array
23
  */
24
  protected $postdata = array();
25
 
 
 
 
 
 
 
 
 
 
26
  public function __construct() {
27
+ if ( ! empty( $_GET['formkey'] ) ) {
 
28
  $this->formkey = $_GET['formkey'];
29
  }
 
30
 
31
+ $contact_data_post_types = MW_WP_Form_Contact_Data_Setting::get_form_post_types();
32
+ if ( ! in_array( $this->formkey, $contact_data_post_types ) ) {
 
 
 
 
33
  exit;
34
  }
35
+ add_action( 'admin_enqueue_scripts', array( $this, '_admin_enqueue_scripts') );
36
+
37
+ $screen = get_current_screen();
38
+ add_action( 'load-' . $screen->id, array( $this, '_save' ) );
39
+ add_action( $screen->id , array( $this, '_index' ) );
40
  }
41
 
42
  /**
43
+ * Enqueue assets
44
+ *
45
+ * @return void
46
  */
47
+ public function _admin_enqueue_scripts() {
48
  global $wp_scripts;
49
+
50
  $ui = $wp_scripts->query( 'jquery-ui-core' );
51
  wp_enqueue_style(
52
  'jquery.ui',
54
  array( 'jquery' ),
55
  $ui->ver
56
  );
57
+
58
  wp_enqueue_script( 'jquery-ui-sortable' );
59
 
60
  $url = plugins_url( MWF_Config::NAME );
61
+
62
+ wp_enqueue_style(
63
+ MWF_Config::NAME . '-admin-repeatable',
64
+ $url . '/css/admin-repeatable.css'
65
+ );
66
+
67
+ wp_enqueue_script(
68
+ 'jsapi',
69
+ 'https://www.google.com/jsapi'
70
+ );
71
+
72
  wp_enqueue_script(
73
  MWF_Config::NAME . '-repeatable',
74
  $url . '/js/mw-wp-form-repeatable.js',
76
  null,
77
  true
78
  );
79
+
80
  wp_enqueue_script(
81
  MWF_Config::NAME . '-google-chart',
82
  $url . '/js/mw-wp-form-google-chart.js',
84
  null,
85
  true
86
  );
87
+
88
  wp_enqueue_script(
89
  MWF_Config::NAME . '-admin-chart',
90
  $url . '/js/admin-chart.js',
95
  }
96
 
97
  /**
98
+ * Save
99
+ *
100
+ * @return void
101
  */
102
+ public function _save() {
103
+ if ( ! isset( $_POST[ MWF_Config::NAME . '-chart-nonce-field' ] ) ) {
104
+ return;
105
+ }
106
 
107
+ if ( empty( $_POST[ MWF_Config::NAME . '-chart-nonce-field' ] ) ) {
108
+ return;
109
+ }
110
+
111
+ if ( ! check_admin_referer( MWF_Config::NAME . '-chart-action', MWF_Config::NAME . '-chart-nonce-field' ) ) {
112
+ return;
113
+ }
114
+
115
+ if ( ! $this->formkey ) {
116
+ return;
117
+ }
118
+
119
+ $option_name = MWF_Config::NAME . '-chart-' . $this->formkey;
120
+ $sanitized_values = $this->_sanitize( $_POST[ $option_name ] );
121
+ update_option( $option_name, $sanitized_values );
122
+ wp_redirect(
123
+ admin_url(
124
+ 'edit.php?post_type=' . MWF_Config::NAME . '&page=' . MWF_Config::NAME . '-chart&formkey=' . $this->formkey
125
+ )
126
  );
127
+ exit;
128
+ }
129
+
130
+ /**
131
+ * Display chart page
132
+ *
133
+ * @return void
134
+ */
135
+ public function _index() {
136
+ $post_type = $this->formkey;
137
+
138
+ $args = apply_filters( 'mwform_get_inquiry_data_args-' . $post_type, array() );
139
+ if ( empty( $args ) || ! is_array( $args ) ) {
140
+ $args = array();
141
  }
142
+ $args = array_merge( $args, array(
143
+ 'posts_per_page' => -1,
144
+ 'post_type' => $post_type,
145
+ ) );
146
+
147
  $form_posts = get_posts( $args );
148
 
149
  // custom_keys
156
  continue;
157
  }
158
  $post_meta = get_post_meta( $post->ID, $post_custom_key, true );
159
+ $custom_keys[ $post_custom_key ][ $post_meta ][] = $post->ID;
160
  }
161
  }
162
  }
175
  // 空の隠れフィールド(コピー元)を挿入
176
  array_unshift( $postdata, $default_keys );
177
 
178
+ $this->_render( 'chart/index', array(
179
+ 'post_type' => $post_type,
180
+ 'form_posts' => $form_posts,
181
+ 'custom_keys' => $custom_keys,
182
+ 'postdata' => $postdata,
183
+ ) );
184
+ }
185
+
186
+ /**
187
+ * Sanitize for settings
188
+ *
189
+ * @param array $input Posted data from chart settings page
190
+ * @return array
191
+ */
192
+ public function _sanitize( $input ) {
193
+ if ( ! is_array( $input ) || ! isset( $input['chart'] ) || ! is_array( $input['chart'] ) ) {
194
+ return array();
195
+ }
196
+
197
+ $new_input = array();
198
+
199
+ foreach ( $input['chart'] as $key => $value ) {
200
+ if ( empty( $value['target'] ) ) {
201
+ continue;
202
+ }
203
+
204
+ $new_input['chart'][ $key ] = $value;
205
+ }
206
+
207
+ return $new_input;
208
  }
209
+ }
classes/controllers/class.contact-data-list.php CHANGED
@@ -1,11 +1,11 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Contact Data List Controller
4
- * Version : 1.2.0
5
  * Author : Takashi Kitajima
6
- * Author URI : http://2inc.org
7
  * Created : January 1, 2015
8
- * Modified : March 26, 2016
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
@@ -16,122 +16,167 @@ class MW_WP_Form_Contact_Data_List_Controller extends MW_WP_Form_Controller {
16
  */
17
  protected $post_type;
18
 
19
- /**
20
- * initialize
21
- */
22
- public function initialize() {
23
- $contact_data_post_types = MW_WP_Form_Contact_Data_Setting::get_posts();
24
- if ( !isset( $_GET['post_type'] ) ) {
25
  exit;
26
  }
 
27
  $this->post_type = $_GET['post_type'];
28
- if ( !in_array( $this->post_type, $contact_data_post_types ) ) {
29
  exit;
30
  }
31
 
32
- $CSV = new MW_WP_Form_CSV( $this->post_type );
33
- $CSV->download();
 
 
 
 
 
 
 
 
 
 
 
 
 
34
 
35
- add_action( 'pre_get_posts' , array( $this, 'pre_get_posts' ) );
36
- add_action( 'admin_head' , array( $this, 'add_columns' ) );
37
- add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
38
- add_action( 'admin_print_styles' , array( $this, 'admin_print_styles' ) );
39
- add_action( 'in_admin_footer' , array( $this, 'add_csv_download_button' ) );
40
- add_filter( 'wp_count_posts' , array( $this, 'wp_count_posts' ), 10, 2 );
41
  }
42
 
43
  /**
44
- * フックで表示するレコードに変更があれば変更
45
  *
46
  * @param WP_Query $wp_query
 
47
  */
48
- public function pre_get_posts( $wp_query ) {
49
- if ( $wp_query->is_main_query() ) {
50
- $post_type = $wp_query->get( 'post_type' );
51
- $args = apply_filters( 'mwform_get_inquiry_data_args-' . $post_type, array() );
52
- if ( !empty( $args ) && is_array( $args ) ) {
53
- foreach ( $args as $key => $value ) {
54
- $wp_query->set( $key, $value );
55
- }
56
- }
 
 
 
 
 
 
 
 
57
  }
58
  }
59
 
60
  /**
61
- * CSS と JS の読み込み
 
 
62
  */
63
- public function admin_enqueue_scripts() {
64
  $url = plugins_url( MWF_Config::NAME );
65
  wp_enqueue_style( MWF_Config::NAME . '-admin-data-list', $url . '/css/admin-data-list.css' );
66
  wp_enqueue_script( MWF_Config::NAME . '-admin-data-list', $url . '/js/admin-data-list.js' );
67
  }
68
 
69
  /**
70
- * DB登録データの一覧で新規追加のリンクを消す
 
 
71
  */
72
- public function admin_print_styles() {
73
- $this->render( 'contact-data-list/admin-print-styles' );
74
  }
75
 
76
  /**
77
- * CSVダウンロードボタンを表示
 
 
78
  */
79
- public function add_csv_download_button() {
80
  if ( true !== apply_filters( 'mwform_csv_button_' . $this->post_type, true ) ) {
81
  return;
82
  }
83
  $page = ( basename( $_SERVER['PHP_SELF'] ) );
84
- if ( $page !== 'edit.php' ) {
85
  return;
86
  }
87
  $action = $_SERVER['REQUEST_URI'];
88
- $this->assign( 'action', $action );
89
- $this->render( 'contact-data-list/csv-button' );
 
90
  }
91
 
92
  /**
93
- * DB登録使用時に問い合わせデータ一覧にカラムを追加
 
 
 
 
94
  */
95
- public function add_columns() {
96
- add_filter(
97
- 'manage_' . $this->post_type . '_posts_columns',
98
- array( $this, 'add_form_columns_name' )
99
- );
100
- add_action(
101
- 'manage_' . $this->post_type . '_posts_custom_column',
102
- array( $this, 'add_form_columns' ),
103
- 10,
104
- 2
105
- );
 
 
 
 
 
 
 
106
  }
107
 
108
  /**
109
- * カラム名を取得
110
  *
111
  * @param array $columns
112
- * @return array $columns
113
  */
114
- public function add_form_columns_name( $columns ) {
115
  global $posts;
 
116
  unset( $columns['date'] );
117
  $columns['post_date'] = __( 'Registed Date', 'mw-wp-form' );
118
  $columns['response_status'] = __( 'Response Status', 'mw-wp-form' );
119
  $_columns = array();
 
120
  foreach ( $posts as $post ) {
121
  $post_custom_keys = get_post_custom_keys( $post->ID );
122
- if ( !empty( $post_custom_keys ) && is_array( $post_custom_keys ) ) {
123
- foreach ( $post_custom_keys as $key ) {
124
- if ( preg_match( '/^_/', $key ) ) {
125
- continue;
126
- }
127
- if ( $key === MWF_Config::TRACKINGNUMBER ) {
128
- $columns[$key] = MWF_Functions::get_tracking_number_title( $this->post_type );
129
- continue;
130
- }
131
- $_columns[$key] = $key;
 
 
132
  }
 
 
133
  }
134
  }
 
135
  ksort( $_columns );
136
  $_columns = apply_filters( 'mwform_inquiry_data_columns-' . $this->post_type, $_columns );
137
  $columns = array_merge( $columns, $_columns );
@@ -139,63 +184,41 @@ class MW_WP_Form_Contact_Data_List_Controller extends MW_WP_Form_Controller {
139
  }
140
 
141
  /**
142
- * 各カラムのデータを出力
143
  *
144
- * @param string $column カラム名
145
- * @param int $post_id
146
  */
147
- public function add_form_columns( $column, $post_id ) {
148
  $post = get_post( $post_id );
149
  $post_custom_keys = get_post_custom_keys( $post_id );
150
  $Contact_Data_Setting = new MW_WP_Form_Contact_Data_Setting( $post_id );
151
 
152
- if ( $column === 'post_date' ) {
153
  $value = esc_html( $post->post_date );
154
- } elseif ( $column === 'response_status' ) {
155
  $response_statuses = $Contact_Data_Setting->get_response_statuses();
156
  $response_status = $Contact_Data_Setting->get( 'response_status' );
157
- $value = isset( $response_statuses[ $response_status ] ) ? $response_statuses[ $response_status ] : $response_statuses[ key( $response_statuses ) ];
158
  } elseif ( is_array( $post_custom_keys ) && in_array( $column, $post_custom_keys ) ) {
159
  $post_meta = get_post_meta( $post_id, $column, true );
160
- if ( $Contact_Data_Setting->is_upload_file_key( $post, $column ) ) {
161
  // 過去バージョンでの不具合でメタデータが空になっていることがあるのでその場合は代替処理
162
- if ( $post_meta === '' ) {
163
  $post_meta = MWF_Functions::get_multimedia_id__fallback( $post, $column );
164
  }
165
  $value = MWF_Functions::get_multimedia_data( $post_meta );
166
- } elseif ( $post_meta ) {
167
- $value = esc_html( $post_meta );
168
- } else {
169
  $value = '&nbsp;';
 
 
170
  }
171
  } else {
172
  $value = '&nbsp;';
173
  }
174
 
175
- $this->assign( 'column', $value );
176
- $this->render( 'contact-data-list/column' );
177
- }
178
-
179
- /**
180
- * 件数をカスタマイズ
181
- *
182
- * @param object $counts
183
- * @param string $type 投稿タイプ名
184
- * @return object
185
- */
186
- public function wp_count_posts( $counts, $type ) {
187
- $args = apply_filters( 'mwform_get_inquiry_data_args-' . $type, array() );
188
- if ( !empty( $args ) && is_array( $args ) ) {
189
- $args = array_merge( $args, array(
190
- 'post_type' => $type,
191
- 'posts_per_page' => 1,
192
- ) );
193
-
194
- foreach ( $counts as $key => $count ) {
195
- $query = new WP_Query( array_merge( $args, array( 'post_status' => $key ) ) );
196
- $counts->$key = $query->found_posts;
197
- }
198
- }
199
- return $counts;
200
  }
201
  }
1
  <?php
2
  /**
3
  * Name : MW WP Form Contact Data List Controller
4
+ * Version : 2.0.1
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : January 1, 2015
8
+ * Modified : June 26, 2018
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
16
  */
17
  protected $post_type;
18
 
19
+ public function __construct() {
20
+ $contact_data_post_types = MW_WP_Form_Contact_Data_Setting::get_form_post_types();
21
+ if ( ! isset( $_GET['post_type'] ) ) {
 
 
 
22
  exit;
23
  }
24
+
25
  $this->post_type = $_GET['post_type'];
26
+ if ( ! in_array( $this->post_type, $contact_data_post_types ) ) {
27
  exit;
28
  }
29
 
30
+ if ( ! empty( $_POST ) ) {
31
+ $CSV = new MW_WP_Form_CSV( $this->post_type );
32
+ $CSV->download();
33
+ }
34
+
35
+ add_action( 'pre_get_posts' , array( $this, '_pre_get_posts' ) );
36
+ add_action( 'admin_enqueue_scripts', array( $this, '_admin_enqueue_scripts' ) );
37
+ add_action( 'admin_print_styles' , array( $this, '_admin_print_styles' ) );
38
+ add_action( 'in_admin_footer' , array( $this, '_add_csv_download_button' ) );
39
+ add_filter( 'wp_count_posts' , array( $this, '_wp_count_posts' ), 10, 2 );
40
+
41
+ add_filter(
42
+ 'manage_' . $this->post_type . '_posts_columns',
43
+ array( $this, '_add_form_columns_name' )
44
+ );
45
 
46
+ add_action(
47
+ 'manage_' . $this->post_type . '_posts_custom_column',
48
+ array( $this, '_add_form_columns' ),
49
+ 10,
50
+ 2
51
+ );
52
  }
53
 
54
  /**
55
+ * Change if there is a necessity of change in the inquiry data displayed by hook
56
  *
57
  * @param WP_Query $wp_query
58
+ * @return void
59
  */
60
+ public function _pre_get_posts( $wp_query ) {
61
+ if ( ! $wp_query->is_main_query() ) {
62
+ return;
63
+ }
64
+
65
+ $post_type = $wp_query->get( 'post_type' );
66
+ $args = apply_filters( 'mwform_get_inquiry_data_args-' . $post_type, array() );
67
+ if ( empty( $args ) || ! is_array( $args ) ) {
68
+ $args = array();
69
+ }
70
+ $args = array_merge( $args, array(
71
+ 'post_type' => $post_type,
72
+ 'post_status' => 'any',
73
+ ) );
74
+
75
+ foreach ( $args as $key => $value ) {
76
+ $wp_query->set( $key, $value );
77
  }
78
  }
79
 
80
  /**
81
+ * Enqueue assets
82
+ *
83
+ * @return void
84
  */
85
+ public function _admin_enqueue_scripts() {
86
  $url = plugins_url( MWF_Config::NAME );
87
  wp_enqueue_style( MWF_Config::NAME . '-admin-data-list', $url . '/css/admin-data-list.css' );
88
  wp_enqueue_script( MWF_Config::NAME . '-admin-data-list', $url . '/js/admin-data-list.js' );
89
  }
90
 
91
  /**
92
+ * Delete add new link
93
+ *
94
+ * @return void
95
  */
96
+ public function _admin_print_styles() {
97
+ $this->_render( 'contact-data-list/admin-print-styles' );
98
  }
99
 
100
  /**
101
+ * Render csv download button
102
+ *
103
+ * @return void
104
  */
105
+ public function _add_csv_download_button() {
106
  if ( true !== apply_filters( 'mwform_csv_button_' . $this->post_type, true ) ) {
107
  return;
108
  }
109
  $page = ( basename( $_SERVER['PHP_SELF'] ) );
110
+ if ( 'edit.php' !== $page ) {
111
  return;
112
  }
113
  $action = $_SERVER['REQUEST_URI'];
114
+ $this->_render( 'contact-data-list/csv-button', array(
115
+ 'action' => $action
116
+ ) );
117
  }
118
 
119
  /**
120
+ * Edit wp count posts
121
+ *
122
+ * @param object $counts
123
+ * @param string $type Post type
124
+ * @return object
125
  */
126
+ public function _wp_count_posts( $counts, $type ) {
127
+ $args = apply_filters( 'mwform_get_inquiry_data_args-' . $type, array() );
128
+ if ( empty( $args ) || ! is_array( $args ) ) {
129
+ $args = array();
130
+ }
131
+
132
+ $args = array_merge( $args, array(
133
+ 'post_type' => $type,
134
+ 'posts_per_page' => 1,
135
+ 'post_status' => 'any',
136
+ ) );
137
+
138
+ foreach ( $counts as $key => $count ) {
139
+ $query = new WP_Query( array_merge( $args, array( 'post_status' => $key ) ) );
140
+ $counts->$key = $query->found_posts;
141
+ }
142
+
143
+ return $counts;
144
  }
145
 
146
  /**
147
+ * Set displayed columns name
148
  *
149
  * @param array $columns
150
+ * @return array
151
  */
152
+ public function _add_form_columns_name( $columns ) {
153
  global $posts;
154
+
155
  unset( $columns['date'] );
156
  $columns['post_date'] = __( 'Registed Date', 'mw-wp-form' );
157
  $columns['response_status'] = __( 'Response Status', 'mw-wp-form' );
158
  $_columns = array();
159
+
160
  foreach ( $posts as $post ) {
161
  $post_custom_keys = get_post_custom_keys( $post->ID );
162
+ if ( empty( $post_custom_keys ) || ! is_array( $post_custom_keys ) ) {
163
+ continue;
164
+ }
165
+
166
+ foreach ( $post_custom_keys as $key ) {
167
+ if ( preg_match( '/^_/', $key ) ) {
168
+ continue;
169
+ }
170
+
171
+ if ( MWF_Config::TRACKINGNUMBER === $key ) {
172
+ $_columns[ $key ] = MWF_Functions::get_tracking_number_title( $this->post_type );
173
+ continue;
174
  }
175
+
176
+ $_columns[ $key ] = $key;
177
  }
178
  }
179
+
180
  ksort( $_columns );
181
  $_columns = apply_filters( 'mwform_inquiry_data_columns-' . $this->post_type, $_columns );
182
  $columns = array_merge( $columns, $_columns );
184
  }
185
 
186
  /**
187
+ * Render each columns
188
  *
189
+ * @param string $column Column name
190
+ * @param int void
191
  */
192
+ public function _add_form_columns( $column, $post_id ) {
193
  $post = get_post( $post_id );
194
  $post_custom_keys = get_post_custom_keys( $post_id );
195
  $Contact_Data_Setting = new MW_WP_Form_Contact_Data_Setting( $post_id );
196
 
197
+ if ( 'post_date' === $column ) {
198
  $value = esc_html( $post->post_date );
199
+ } elseif ( 'response_status' === $column ) {
200
  $response_statuses = $Contact_Data_Setting->get_response_statuses();
201
  $response_status = $Contact_Data_Setting->get( 'response_status' );
202
+ $value = $response_statuses[ $response_status ];
203
  } elseif ( is_array( $post_custom_keys ) && in_array( $column, $post_custom_keys ) ) {
204
  $post_meta = get_post_meta( $post_id, $column, true );
205
+ if ( $Contact_Data_Setting->is_upload_file_key( $column ) ) {
206
  // 過去バージョンでの不具合でメタデータが空になっていることがあるのでその場合は代替処理
207
+ if ( '' === $post_meta ) {
208
  $post_meta = MWF_Functions::get_multimedia_id__fallback( $post, $column );
209
  }
210
  $value = MWF_Functions::get_multimedia_data( $post_meta );
211
+ } elseif ( '' === $post_meta || null === $post_meta || false === $post_meta ) {
 
 
212
  $value = '&nbsp;';
213
+ } else {
214
+ $value = esc_html( $post_meta );
215
  }
216
  } else {
217
  $value = '&nbsp;';
218
  }
219
 
220
+ $this->_render( 'contact-data-list/column', array(
221
+ 'column' => $value,
222
+ ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
223
  }
224
  }
classes/controllers/class.contact-data.php CHANGED
@@ -1,97 +1,155 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Contact Data Controller
4
- * Version : 1.1.0
5
  * Author : Takashi Kitajima
6
- * Author URI : http://2inc.org
7
  * Created : December 31, 2014
8
- * Modified : March 27, 2015
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Contact_Data_Controller extends MW_WP_Form_Controller {
13
 
14
- /**
15
- * initialize
16
- */
17
- public function initialize() {
18
  $screen = get_current_screen();
19
- $contact_data_post_types = MW_WP_Form_Contact_Data_Setting::get_posts();
20
- if ( $screen->base ==='post' && !in_array( $screen->id, $contact_data_post_types ) ) {
21
  exit;
22
  }
23
- if ( $screen->base ==='post' && in_array( $screen->id, $contact_data_post_types ) ) {
24
- $_args = apply_filters( 'mwform_get_inquiry_data_args-' . $screen->post_type, array() );
25
- if ( !empty( $_args ) && is_array( $_args ) ) {
26
- $args = array(
27
- 'post_type' => $screen->post_type,
28
- 'post_status' => 'publish',
29
- 'posts_per_page' => 1,
30
- 'p' => $_GET['post'],
31
- );
32
- $args = array_merge( $_args, $args );
33
- $permit_posts = get_posts( $args );
34
- if ( empty( $permit_posts ) ) {
35
- exit;
36
- }
37
- }
38
  }
39
 
40
- $Contact_Data = new MW_WP_Form_Contact_Data();
41
- add_action( 'add_meta_boxes' , array( $this, 'add_meta_boxes' ) );
42
- add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
43
- add_action( 'admin_print_styles' , array( $this, 'admin_print_styles' ) );
44
- add_action( 'edit_form_top' , array( $this, 'edit_form_top' ) );
45
- add_action( 'save_post' , array( $Contact_Data, 'save_post' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  }
47
 
48
  /**
49
- * CSSの読み込み
 
 
50
  */
51
- public function admin_enqueue_scripts() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  $url = plugins_url( MWF_Config::NAME );
53
  wp_enqueue_style( MWF_Config::NAME . '-admin-data', $url . '/css/admin-data.css' );
54
  }
55
 
56
  /**
57
- * 詳細画面で新規追加のリンクを消す
 
 
58
  */
59
- public function admin_print_styles() {
60
- $this->render( 'contact-data/admin-print-styles' );
61
  }
62
 
63
  /**
64
- * メタボックスを追加
 
 
 
65
  */
66
- public function add_meta_boxes() {
67
  $post_type = get_post_type();
68
- add_meta_box(
69
- substr( MWF_Config::CONTACT_DATA_NAME, 1 ) . '_custom_fields',
70
- __( 'Custom Fields', 'mw-wp-form' ),
71
- array( $this, 'detail' ),
72
- $post_type
73
- );
74
  }
75
 
76
  /**
77
- * 詳細
 
 
 
78
  */
79
- public function detail( $post ) {
80
- $this->assign( 'post', $post );
81
- $this->assign( 'post_type', $post->post_type );
82
- $this->assign( 'Contact_Data_Setting', new MW_WP_Form_Contact_Data_Setting( get_the_ID() ) );
83
- $this->render( 'contact-data/detail' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  }
85
 
86
  /**
87
- * 問い合わせデータ詳細画面で一覧に戻るリンクを表示
88
  *
89
- * @param object $post
 
90
  */
91
- public function edit_form_top( $post ) {
92
- $post_type = get_post_type();
93
- $link = admin_url( '/edit.php?post_type=' . $post_type );
94
- $this->assign( 'link', $link );
95
- $this->render( 'contact-data/returning-link' );
 
96
  }
97
  }
1
  <?php
2
  /**
3
  * Name : MW WP Form Contact Data Controller
4
+ * Version : 2.0.0
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : December 31, 2014
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Contact_Data_Controller extends MW_WP_Form_Controller {
13
 
14
+ public function __construct() {
 
 
 
15
  $screen = get_current_screen();
16
+ if ( 'post' !== $screen->base ) {
 
17
  exit;
18
  }
19
+
20
+ $contact_data_post_types = MW_WP_Form_Contact_Data_Setting::get_form_post_types();
21
+ if ( ! in_array( $screen->id, $contact_data_post_types ) ) {
22
+ exit;
 
 
 
 
 
 
 
 
 
 
 
23
  }
24
 
25
+ $args = apply_filters( 'mwform_get_inquiry_data_args-' . $screen->post_type, array() );
26
+ if ( empty( $args ) || ! is_array( $args ) ) {
27
+ $args = array();
28
+ }
29
+
30
+ $args = array_merge( $args, array(
31
+ 'post_type' => $screen->post_type,
32
+ 'posts_per_page' => 1,
33
+ 'post_status' => 'any',
34
+ 'p' => $_GET['post'],
35
+ ) );
36
+ $permit_posts = get_posts( $args );
37
+ if ( empty( $permit_posts ) ) {
38
+ return;
39
+ }
40
+
41
+ add_action( 'add_meta_boxes' , array( $this, '_add_meta_boxes' ) );
42
+ add_action( 'admin_enqueue_scripts', array( $this, '_admin_enqueue_scripts' ) );
43
+ add_action( 'admin_print_styles' , array( $this, '_admin_print_styles' ) );
44
+ add_action( 'edit_form_top' , array( $this, '_edit_form_top' ) );
45
+ add_action( 'save_post' , array( $this, '_save_post' ) );
46
  }
47
 
48
  /**
49
+ * Add meta boxes
50
+ *
51
+ * @return void
52
  */
53
+ public function _add_meta_boxes() {
54
+ $post_type = get_post_type();
55
+ add_meta_box(
56
+ substr( MWF_Config::INQUIRY_DATA_NAME, 1 ) . '_custom_fields',
57
+ __( 'Custom Fields', 'mw-wp-form' ),
58
+ array( $this, '_detail' ),
59
+ $post_type
60
+ );
61
+ }
62
+
63
+ /**
64
+ * Enqueue assets
65
+ *
66
+ * @return void
67
+ */
68
+ public function _admin_enqueue_scripts() {
69
  $url = plugins_url( MWF_Config::NAME );
70
  wp_enqueue_style( MWF_Config::NAME . '-admin-data', $url . '/css/admin-data.css' );
71
  }
72
 
73
  /**
74
+ * Delete add new link
75
+ *
76
+ * @return void
77
  */
78
+ public function _admin_print_styles() {
79
+ $this->_render( 'contact-data/admin-print-styles' );
80
  }
81
 
82
  /**
83
+ * Render back to list link
84
+ *
85
+ * @param object $post
86
+ * @return void
87
  */
88
+ public function _edit_form_top( $post ) {
89
  $post_type = get_post_type();
90
+ $link = admin_url( '/edit.php?post_type=' . $post_type );
91
+ $this->_render( 'contact-data/returning-link', array(
92
+ 'link' => $link,
93
+ ) );
 
 
94
  }
95
 
96
  /**
97
+ * Save
98
+ *
99
+ * @param int $post_id
100
+ * @return void
101
  */
102
+ public function _save_post( $post_id ) {
103
+ if ( ! isset( $_POST['post_type'] ) ) {
104
+ return;
105
+ }
106
+
107
+ $contact_data_post_types = MW_WP_Form_Contact_Data_setting::get_form_post_types();
108
+ if ( ! in_array( $_POST['post_type'], $contact_data_post_types ) ) {
109
+ return;
110
+ }
111
+
112
+ if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
113
+ return;
114
+ }
115
+
116
+ if ( ! wp_verify_nonce( $_POST[ MWF_Config::NAME . '_nonce' ], MWF_Config::NAME ) ) {
117
+ return;
118
+ }
119
+
120
+ if ( ! current_user_can( MWF_Config::CAPABILITY ) ) {
121
+ return;
122
+ }
123
+
124
+ $Contact_Data_Setting = new MW_WP_Form_Contact_Data_setting( $post_id );
125
+ $permit_keys = $Contact_Data_Setting->get_permit_keys();
126
+ $data = array();
127
+ foreach ( $permit_keys as $key ) {
128
+ if ( isset( $_POST[ MWF_Config::INQUIRY_DATA_NAME ][ $key ] ) ) {
129
+ $value = $_POST[ MWF_Config::INQUIRY_DATA_NAME ][ $key ];
130
+ if ( 'response_status' === $key ) {
131
+ if ( ! array_key_exists( $value, $Contact_Data_Setting->get_response_statuses() ) ) {
132
+ continue;
133
+ }
134
+ }
135
+ $data[ $key ] = $value;
136
+ }
137
+ }
138
+ $Contact_Data_Setting->sets( $data );
139
+ $Contact_Data_Setting->save();
140
  }
141
 
142
  /**
143
+ * Render detail meta box
144
  *
145
+ * @param WP_Post $post
146
+ * @return void
147
  */
148
+ public function _detail( $post ) {
149
+ $this->_render( 'contact-data/detail', array(
150
+ 'post' => $post,
151
+ 'post_type' => $post->post_type,
152
+ 'Contact_Data_Setting' => new MW_WP_Form_Contact_Data_Setting( get_the_ID() ),
153
+ ) );
154
  }
155
  }
classes/controllers/class.controller.php DELETED
@@ -1,44 +0,0 @@
1
- <?php
2
- /**
3
- * Name : MW WP Form Controller
4
- * Version : 1.0.0
5
- * Author : Takashi Kitajima
6
- * Author URI : http://2inc.org
7
- * Created : March 28, 2015
8
- * Modified :
9
- * License : GPLv2 or later
10
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
- */
12
- class MW_WP_Form_Controller {
13
-
14
- /**
15
- * assign したデータを保持する配列
16
- * @var array
17
- */
18
- protected $assign_data = array();
19
-
20
- /**
21
- * 任意のデータを assign
22
- *
23
- * @param string $key
24
- * @param mixed $value
25
- */
26
- protected function assign( $key, $value ) {
27
- $this->assign_data[$key] = $value;
28
- }
29
-
30
- /**
31
- * テンプレートを読み込んで表示
32
- *
33
- * @param string $template ディレクトリ名/ファイル名(拡張子無し)
34
- */
35
- protected function render( $template ) {
36
- extract( $this->assign_data );
37
- $template_dir = plugin_dir_path( __FILE__ ) . '../../templates/';
38
- $template_path = $template_dir . $template . '.php';
39
- if ( file_exists( $template_path ) ) {
40
- include( $template_path );
41
- $this->assign_data = array();
42
- }
43
- }
44
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/controllers/class.main.php CHANGED
@@ -1,12 +1,11 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Main Controller
4
- * Description: フロントエンドにおいて、適切な画面にリダイレクトさせる
5
- * Version : 1.5.1
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : December 23, 2014
9
- * Modified : April 28, 2017
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
@@ -17,405 +16,313 @@ class MW_WP_Form_Main_Controller {
17
  */
18
  protected $Data;
19
 
20
- /**
21
- * @var MW_WP_Form_Exec_Shortcode
22
- */
23
- protected $ExecShortcode;
24
-
25
- /**
26
- * @var MW_WP_Form_Redrected
27
- */
28
- protected $Redirected;
29
-
30
  /**
31
  * @var MW_WP_Form_Setting
32
  */
33
  protected $Setting;
34
 
35
  /**
36
- * @var array
37
  */
38
- protected $validation_rules = array();
39
 
40
- /**
41
- * @var string
42
- */
43
- protected $token_name = 'mw_wp_form_token';
 
44
 
45
  /**
46
- * リダイレクトされてからの complete であれば true
47
- * @var bool
 
 
48
  */
49
- protected $complete_twice = false;
 
 
 
50
 
51
- /**
52
- * __construct
53
- * @param array $validation_rules
54
- */
55
- public function __construct( array $validation_rules ) {
56
- $this->validation_rules = $validation_rules;
57
- }
58
 
59
- /**
60
- * initialize
61
- */
62
- public function initialize() {
63
- add_filter( 'nocache_headers' , array( $this, 'nocache_headers' ) , 1 );
64
- add_action( 'parse_request' , array( $this, 'remove_query_vars_from_post' ) );
65
- add_filter( 'template_include' , array( $this, 'template_include' ), 10000 );
66
- add_filter( 'mwform_form_end_html', array( $this, 'mwform_form_end_html' ) );
 
 
 
 
67
  }
68
 
69
  /**
70
- * WordPressへのリクエストに含まれている、$_POSTの値を削除
 
 
 
71
  */
72
- public function remove_query_vars_from_post( $wp_query ) {
73
- if ( isset( $_POST[$this->token_name] ) ) {
74
- $request_token = $_POST[$this->token_name];
75
- }
76
- if ( isset( $request_token ) ) {
77
- foreach ( $_POST as $key => $value ) {
78
- if ( $key == 'token' ) {
79
- continue;
80
- }
81
- if ( isset( $wp_query->query_vars[$key] ) &&
82
- $wp_query->query_vars[$key] === $value &&
83
- !empty( $value ) ) {
84
-
85
- $wp_query->query_vars[$key] = '';
86
- }
87
- }
88
- }
89
  }
90
 
91
  /**
92
- * 表示画面でのプラグインの処理等
93
  *
94
  * @param string $template
95
  * @return string $template
96
  */
97
- public function template_include( $template ) {
98
  global $post;
99
 
100
- $this->ExecShortcode = new MW_WP_Form_Exec_Shortcode( $post, $template );
101
- $has_shortcode = $this->ExecShortcode->has_shortcode();
102
- if ( !$has_shortcode ) {
103
- return $template;
104
- }
 
 
 
 
 
 
 
 
105
 
106
- $form_key = $this->ExecShortcode->get( 'key' );
107
- $form_id = $this->ExecShortcode->get_form_id();
108
- $this->Setting = new MW_WP_Form_Setting( $form_id );
109
- $this->Data = MW_WP_Form_Data::getInstance( $form_key, $_POST, $_FILES );
110
 
111
- foreach ( $this->validation_rules as $validation_name => $validation_rule ) {
112
- if ( is_callable( array( $validation_rule, 'set_Data' ) ) ) {
113
- $validation_rule->set_Data( $this->Data );
114
- }
115
- }
116
 
117
- nocache_headers();
118
-
119
- $Error = new MW_WP_Form_Error();
120
- $this->Validation = new MW_WP_Form_Validation( $Error );
121
- $this->Validation->set_validation_rules( $this->validation_rules );
122
- $this->Validation->set_rules( $this->Setting );
123
- $this->Validation = apply_filters(
124
- 'mwform_validation_' . $form_key,
125
- $this->Validation,
126
- $this->Data->gets(),
127
- clone $this->Data
128
- );
129
-
130
- $token_check = $this->token_check();
131
- $post_condition = $this->Data->get_post_condition( $token_check );
132
- $is_valid = $this->Validation->check();
133
- $this->Redirected = new MW_WP_Form_Redirected(
134
- $this->ExecShortcode->get( 'input_url' ),
135
- $this->ExecShortcode->get( 'confirmation_url' ),
136
- $this->ExecShortcode->get( 'complete_url' ),
137
- $this->ExecShortcode->get( 'validation_error_url' ),
138
- $is_valid,
139
- $post_condition,
140
- $this->Setting->get( 'querystring' )
141
- );
142
- $view_flg = $this->Redirected->get_view_flg();
143
- $this->Data->set_view_flg( $view_flg );
144
-
145
- // confirm もしくは complete のとき
146
- if ( in_array( $post_condition, array( 'confirm', 'complete' ) ) ) {
147
- $this->file_upload();
148
- }
149
- // complete のとき
150
- if ( $view_flg === 'complete' ) {
151
- if ( !$this->is_complete_twice() ) {
152
- $is_mail_sended = $this->send();
153
  }
154
- // 手動フォームの場合は完了画面に ExecShortcode が無く footer の clear_values が
155
- // 効かないためここで消す
156
- if ( !$form_id ) {
157
- $this->Data->clear_values();
158
  }
159
- }
160
 
161
- if ( isset( $is_mail_sended ) && false === $is_mail_sended ) {
162
- $this->Data->set_send_error();
163
- } elseif ( isset( $is_mail_sended ) && true === $is_mail_sended ) {
164
- do_action(
165
- 'mwform_after_send_' . $form_key,
166
- $this->Data
167
- );
168
- }
169
 
170
- do_action( 'mwform_before_redirect_' . $form_key );
171
- $url = apply_filters( 'mwform_redirect_url_' . $form_key, $this->Redirected->get_url(), $this->Data );
172
- $this->redirect( $url );
173
 
174
- // スクロール用スクリプトのロード
175
- if ( $this->Setting->get( 'scroll' ) ) {
176
- if ( $post_condition !== 'input' ) {
177
- add_action( 'wp_enqueue_scripts', array( $this, 'scroll_script' ) );
 
 
 
178
  }
179
- }
180
 
181
- // 画面表示用のショートコードを登録
182
- do_action(
183
- 'mwform_add_shortcode',
184
- new MW_WP_Form_Form(),
185
- $view_flg,
186
- $Error,
187
- $form_key,
188
- $this->Data
189
- );
190
 
191
- $Form = new MW_WP_Form_Form();
192
- $this->ExecShortcode->add_shortcode( $view_flg, $this->Setting, $Form );
 
 
 
 
 
193
 
194
- add_action( 'wp_footer' , array( $this->Data, 'clear_values' ) );
195
- add_action( 'wp_enqueue_scripts', array( $this , 'wp_enqueue_scripts' ) );
 
 
 
 
 
196
 
197
  return $template;
198
  }
199
 
200
  /**
201
- * 現在のURLと引数で渡されたリダイレクトURLが同じであればリダイレクトしない
202
  *
203
- * @param string リダイレクトURL
 
 
204
  */
205
- private function redirect( $url ) {
206
- $redirect = ( empty( $url ) ) ? $this->Redirected->get_request_uri() : $url;
207
- $REQUEST_URI = $this->Redirected->get_request_uri();
208
- if ( !empty( $_POST ) || $redirect != $REQUEST_URI ) {
209
- $redirect = wp_sanitize_redirect( $redirect );
210
- $redirect = wp_validate_redirect( $redirect, home_url() );
211
- wp_redirect( $redirect );
212
- exit();
213
- }
214
  }
215
 
216
  /**
217
- * wp_enqueue_scripts
 
 
218
  */
219
- public function wp_enqueue_scripts() {
220
  global $post;
221
 
222
- $url = plugin_dir_url( __FILE__ );
223
- wp_enqueue_style( MWF_Config::NAME, $url . '../../css/style.css' );
 
224
 
225
- $style = $this->Setting->get( 'style' );
226
- $styles = apply_filters( 'mwform_styles', array() );
227
- if ( is_array( $styles ) && isset( $styles[$style] ) ) {
228
- $css = $styles[$style];
229
- wp_enqueue_style( MWF_Config::NAME . '_style', $css );
230
  }
231
 
232
- do_action( 'mwform_enqueue_scripts_' . $this->ExecShortcode->get( 'key' ) );
233
- wp_enqueue_script( MWF_Config::NAME, $url . '../../js/form.js', array( 'jquery' ), false, true );
234
- }
 
235
 
236
- /**
237
- * scroll_script
238
- */
239
- public function scroll_script() {
240
- $url = plugin_dir_url( __FILE__ );
241
- wp_register_script(
242
- MWF_Config::NAME . '-scroll',
243
- $url . '../../js/scroll.js',
244
- array( 'jquery' ),
245
- false,
246
- true
247
- );
248
- wp_localize_script( MWF_Config::NAME . '-scroll', 'mwform_scroll', array(
249
- 'offset' => apply_filters( 'mwform_scroll_offset_' . $this->ExecShortcode->get( 'key' ), 0 ),
250
- ) );
251
- wp_enqueue_script( MWF_Config::NAME . '-scroll' );
252
- }
253
 
254
- /**
255
- * Nginx Cache Controller 用に header をカスタマイズ
256
- *
257
- * @param array $headers
258
- * @return array $headers
259
- */
260
- public function nocache_headers( $headers ) {
261
- $headers['X-Accel-Expires'] = 0;
262
- return $headers;
263
  }
264
 
265
  /**
266
- * メール送信
267
  *
268
  * @return boolean
269
  */
270
- protected function send() {
271
  $Mail = new MW_WP_Form_Mail();
272
  $form_key = $this->Data->get_form_key();
273
- $attachments = $this->get_attachments();
274
  $Mail_Service = new MW_WP_Form_Mail_Service( $Mail, $form_key, $this->Setting, $attachments );
275
 
276
- // 管理画面で作成した場合だけ自動で送信
277
- if ( $this->ExecShortcode->is_generated_by_formkey() ) {
278
- // データベース非保存の場合はファイルも保存されないので、メールで URL が飛ばないように消す
279
- if ( !$this->Setting->get( 'usedb' ) ) {
280
- foreach ( $attachments as $key => $attachment ) {
281
- $this->Data->clear_value( $key );
282
- }
283
  }
 
284
 
285
- $is_admin_mail_sended = $Mail_Service->send_admin_mail();
 
286
 
287
- if ( ! $is_admin_mail_sended ) {
288
- return false;
289
- }
290
 
291
- // 自動返信メールの送信
292
- $automatic_reply_email = $this->Setting->get( 'automatic_reply_email' );
293
- if ( $automatic_reply_email ) {
294
- $automatic_reply_email = $this->Data->get_post_value_by_key( $automatic_reply_email );
295
- $is_invalid_mail_address = $this->validation_rules['mail']->rule(
296
- $automatic_reply_email
297
- );
298
- if ( $automatic_reply_email && !$is_invalid_mail_address ) {
299
- $is_reply_mail_sended = $Mail_Service->send_reply_mail();
300
- }
 
 
301
  }
 
302
 
303
- // 問い合わせ番号を加算
304
- $Mail_Service->update_tracking_number();
305
 
306
- return true;
307
- }
308
  }
309
 
310
  /**
311
- * 送信されたデータをもとに添付ファイル用の配列を生成して返す
312
  *
313
  * @return array $attachments pathの配列
314
  */
315
- protected function get_attachments() {
316
- $attachments = array();
317
  $upload_file_keys = $this->Data->get_post_value_by_key( MWF_Config::UPLOAD_FILE_KEYS );
318
- if ( $upload_file_keys !== null && is_array( $upload_file_keys ) ) {
319
- $wp_upload_dir = wp_upload_dir();
320
- foreach ( $upload_file_keys as $key ) {
321
- $upload_file_url = $this->Data->get_post_value_by_key( $key );
322
- if ( !$upload_file_url ) {
323
- continue;
324
- }
325
- $filepath = MWF_Functions::fileurl_to_path( $upload_file_url );
326
- if ( file_exists( $filepath ) ) {
327
- $form_key = $this->Data->get_form_key();
328
- $new_upload_dir = apply_filters(
329
- 'mwform_upload_dir_' . $form_key,
330
- '',
331
- $this->Data,
332
- $key
333
- );
334
- $new_filename = apply_filters(
335
- 'mwform_upload_filename_' . $form_key,
336
- '',
337
- $this->Data,
338
- $key
339
- );
340
- $filepath = MWF_Functions::move_temp_file_to_upload_dir(
341
- $filepath,
342
- $new_upload_dir,
343
- $new_filename
344
- );
345
- $new_upload_file_url = MWF_Functions::filepath_to_url( $filepath );
346
- $this->Data->set( $key, $new_upload_file_url );
347
- $attachments[$key] = $filepath;
348
- }
349
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
350
  }
 
351
  return $attachments;
352
  }
353
 
354
  /**
355
- * ファイルアップロード処理。実際のアップロード状況に合わせてフォームデータも再生成する。
 
356
  */
357
- protected function file_upload() {
358
  $File = new MW_WP_Form_File();
359
  $files = array();
360
  $upload_files = $this->Data->get_post_value_by_key( MWF_Config::UPLOAD_FILES );
361
- if ( !is_array( $upload_files ) ) {
362
  $upload_files = array();
363
  }
364
  foreach ( $upload_files as $key => $file ) {
365
- if ( $this->Validation->single_check( $key ) ) {
366
- $files[$key] = $file;
367
- } elseif ( isset( $files[$key] ) ) {
368
- unset( $files[$key] );
369
  }
370
  }
371
  $uploaded_files = $File->upload( $files );
372
  $this->Data->push_uploaded_file_keys( $uploaded_files );
373
  $this->Data->regenerate_upload_file_keys();
374
  }
375
-
376
- /**
377
- * トークンチェック
378
- *
379
- * @return bool
380
- */
381
- protected function token_check() {
382
- if ( isset( $_POST[$this->token_name] ) ) {
383
- $request_token = $_POST[$this->token_name];
384
- }
385
- $values = $this->Data->gets();
386
- $form_key = $this->Data->get_form_key();
387
- if ( isset( $request_token ) && wp_verify_nonce( $request_token, $form_key ) ) {
388
- return true;
389
- } elseif ( empty( $_POST ) && $values ) {
390
- $this->complete_twice = true;
391
- return true;
392
- }
393
- return false;
394
- }
395
-
396
- /**
397
- * トークンを挿入
398
- *
399
- * @param string $html
400
- * @return string
401
- */
402
- public function mwform_form_end_html( $html ) {
403
- if ( is_a( $this->ExecShortcode, 'MW_WP_Form_Exec_Shortcode' ) ) {
404
- $form_key = $this->Data->get_form_key();
405
- $html .= wp_nonce_field( $form_key, $this->token_name, true, false );
406
- return $html;
407
- }
408
- }
409
-
410
- /**
411
- * リダイレクト後の complete かチェック
412
- *
413
- * @return bool
414
- */
415
- protected function is_complete_twice() {
416
- if ( $this->complete_twice === true ) {
417
- return true;
418
- }
419
- return false;
420
- }
421
  }
1
  <?php
2
  /**
3
  * Name : MW WP Form Main Controller
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : December 23, 2014
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
16
  */
17
  protected $Data;
18
 
 
 
 
 
 
 
 
 
 
 
19
  /**
20
  * @var MW_WP_Form_Setting
21
  */
22
  protected $Setting;
23
 
24
  /**
25
+ * @var MW_WP_Form_Validation
26
  */
27
+ protected $Validation;
28
 
29
+ public function __construct() {
30
+ add_action( 'parse_request' , array( $this, '_remove_query_vars_from_post' ) );
31
+ add_filter( 'nocache_headers' , array( $this, '_nocache_headers' ) , 1 );
32
+ add_filter( 'template_include', array( $this, '_template_include' ), 10000 );
33
+ }
34
 
35
  /**
36
+ * Delete the value of $_POST included in the request to WordPress
37
+ *
38
+ * @param WP_Query $wp_query
39
+ * @return void
40
  */
41
+ public function _remove_query_vars_from_post( $wp_query ) {
42
+ if ( isset( $_POST[ MWF_Config::TOKEN_NAME ] ) ) {
43
+ $request_token = $_POST[ MWF_Config::TOKEN_NAME ];
44
+ }
45
 
46
+ if ( ! isset( $request_token ) ) {
47
+ return;
48
+ }
 
 
 
 
49
 
50
+ foreach ( $_POST as $key => $value ) {
51
+ if ( 'token' === $key ) {
52
+ continue;
53
+ }
54
+
55
+ if ( isset( $wp_query->query_vars[ $key ] )
56
+ && $wp_query->query_vars[ $key ] === $value
57
+ && ! empty( $value ) ) {
58
+
59
+ $wp_query->query_vars[ $key ] = '';
60
+ }
61
+ }
62
  }
63
 
64
  /**
65
+ * Customize request header for Nginx Cache Controller
66
+ *
67
+ * @param array $headers
68
+ * @return array $headers
69
  */
70
+ public function _nocache_headers( $headers ) {
71
+ $headers['X-Accel-Expires'] = 0;
72
+ return $headers;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  }
74
 
75
  /**
76
+ * Main process for form displaying
77
  *
78
  * @param string $template
79
  * @return string $template
80
  */
81
+ public function _template_include( $template ) {
82
  global $post;
83
 
84
+ /**
85
+ * - 送信時はバリデーションチェック、トークンチェックを行い、リダイレクト先を決定する
86
+ * - 決定したリダイレクト先にリダイレクトする
87
+ * - リダイレクト先が現在表示しようとしているページと同じ場合は無視する
88
+ */
89
+ if ( ! empty( $_POST ) && ! empty( $_POST[ MWF_Config::NAME . '-form-id' ] ) ) {
90
+ nocache_headers();
91
+
92
+ $form_id = $_POST[ MWF_Config::NAME . '-form-id' ];
93
+ if ( MWF_Config::NAME !== get_post_type( $form_id ) ) {
94
+ wp_safe_redirect( home_url() );
95
+ exit;
96
+ }
97
 
98
+ $form_key = MWF_Functions::get_form_key_from_form_id( $form_id );
 
 
 
99
 
100
+ /**
101
+ * @deprecated since v4.0.0
102
+ * Because refactoring changed the timing to execute the shortcode
103
+ */
104
+ do_action( 'mwform_after_exec_shortcode', $form_key );
105
 
106
+ do_action( 'mwform_start_main_process', $form_key );
107
+
108
+ $form_verify_token = $_POST[ MWF_Config::NAME . '-form-verify-token' ];
109
+ $this->Setting = new MW_WP_Form_Setting( (int) $form_id );
110
+ $this->Data = MW_WP_Form_Data::connect( $form_key, $_POST, $_FILES );
111
+ $post_condition = $this->Data->get_post_condition();
112
+ $this->Validation = new MW_WP_Form_Validation( $form_key );
113
+ $Redirected = new MW_WP_Form_Redirected( $form_key, $this->Setting, $this->Validation->is_valid(), $post_condition );
114
+
115
+ if ( $this->Setting->generate_form_verify_token() !== $form_verify_token ) {
116
+ wp_safe_redirect( $Redirected->redirect() );
117
+ exit;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
  }
119
+
120
+ if ( in_array( $post_condition, array( 'confirm', 'complete' ) ) ) {
121
+ $this->_file_upload();
 
122
  }
 
123
 
124
+ $view_flg = $Redirected->get_view_flg();
125
+ $this->Data->set_view_flg( $view_flg );
 
 
 
 
 
 
126
 
127
+ if ( 'complete' === $view_flg ) {
128
+ $is_mail_sended = $this->_send();
129
+ }
130
 
131
+ if ( isset( $is_mail_sended ) && false === $is_mail_sended ) {
132
+ $this->Data->set_send_error();
133
+ } elseif ( isset( $is_mail_sended ) && true === $is_mail_sended ) {
134
+ do_action(
135
+ 'mwform_after_send_' . $form_key,
136
+ clone $this->Data
137
+ );
138
  }
 
139
 
140
+ $Redirected->redirect();
141
+
142
+ } else {
 
 
 
 
 
 
143
 
144
+ /**
145
+ * [mwform], [mwform_formkey] の登録
146
+ * - 確認・完了画面に直接アクセスされた場合はエラーメッセージを表示しフォームを表示しない
147
+ * - スクロールスクリプトのロードには Setting ← Post ID が必要。そのため Exec_Shortcode 内で実行させる
148
+ * - mwform_add_shortcode と入力フィールドショートコードの実行も Exec_Shortcode 内で行う
149
+ */
150
+ add_shortcode( 'mwform_formkey', array( $this, '_mwform_formkey' ) );
151
 
152
+ /**
153
+ * If [mwform_formkey] in $post, enqueue assets here.
154
+ * If not in, enqueue in footer.
155
+ */
156
+ $this->_mwform_enqueue_scripts();
157
+
158
+ }
159
 
160
  return $template;
161
  }
162
 
163
  /**
164
+ * Add shortcode for [mwform_formkey]
165
  *
166
+ * @param array $attributes
167
+ * @return string html
168
+ * @example [mwform_formkey key="post_id"]
169
  */
170
+ public function _mwform_formkey( $attributes ) {
171
+ $Exec_Shortcode = new MW_WP_Form_Exec_Shortcode();
172
+ return $Exec_Shortcode->initialize( $attributes );
 
 
 
 
 
 
173
  }
174
 
175
  /**
176
+ * If [mwform_formkey] in $post, enqueue assets.
177
+ *
178
+ * @return boid
179
  */
180
+ protected function _mwform_enqueue_scripts() {
181
  global $post;
182
 
183
+ if ( ! is_a( $post, 'WP_Post' ) || ! has_shortcode( $post->post_content, 'mwform_formkey' ) ) {
184
+ return;
185
+ }
186
 
187
+ preg_match_all( '/' . get_shortcode_regex() . '/s', $post->post_content, $matches, PREG_SET_ORDER );
188
+ if ( ! is_array( $matches ) || empty( $matches ) ) {
189
+ return;
 
 
190
  }
191
 
192
+ foreach ( $matches as $match ) {
193
+ if ( ! isset( $match[2] ) || 'mwform_formkey' !== $match[2] ) {
194
+ continue;
195
+ }
196
 
197
+ if ( ! preg_match( '/key=["\']?(\d+)["\']?/', $match[0], $reg ) ) {
198
+ continue;
199
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
200
 
201
+ if ( is_array( $reg ) ) {
202
+ MWF_Functions::mwform_enqueue_scripts( $reg[1] );
203
+ }
204
+ }
 
 
 
 
 
205
  }
206
 
207
  /**
208
+ * Send mail
209
  *
210
  * @return boolean
211
  */
212
+ protected function _send() {
213
  $Mail = new MW_WP_Form_Mail();
214
  $form_key = $this->Data->get_form_key();
215
+ $attachments = $this->_get_attachments();
216
  $Mail_Service = new MW_WP_Form_Mail_Service( $Mail, $form_key, $this->Setting, $attachments );
217
 
218
+ // データベース非保存の場合はファイルも保存されないので、メールで URL が飛ばないように消す
219
+ if ( ! $this->Setting->get( 'usedb' ) ) {
220
+ foreach ( $attachments as $key => $attachment ) {
221
+ $this->Data->clear_value( $key );
 
 
 
222
  }
223
+ }
224
 
225
+ // Send admin mail
226
+ $is_admin_mail_sended = $Mail_Service->send_admin_mail();
227
 
228
+ if ( ! $is_admin_mail_sended ) {
229
+ return false;
230
+ }
231
 
232
+ // Send reply mail
233
+ $automatic_reply_email = $this->Setting->get( 'automatic_reply_email' );
234
+ if ( $automatic_reply_email ) {
235
+ $automatic_reply_email = $this->Data->get_post_value_by_key( $automatic_reply_email );
236
+ $Validation_Rules = MW_WP_Form_Validation_Rules::instantiation( $form_key );
237
+ $validation_rules = $Validation_Rules->get_validation_rules();
238
+ $is_invalid_mail_address = $validation_rules['mail']->rule(
239
+ $automatic_reply_email
240
+ );
241
+
242
+ if ( $automatic_reply_email && ! $is_invalid_mail_address ) {
243
+ $is_reply_mail_sended = $Mail_Service->send_reply_mail();
244
  }
245
+ }
246
 
247
+ $Mail_Service->update_tracking_number();
 
248
 
249
+ return true;
 
250
  }
251
 
252
  /**
253
+ * Return that generate an array for the attached file based on the transmitted data
254
  *
255
  * @return array $attachments pathの配列
256
  */
257
+ protected function _get_attachments() {
258
+ $attachments = array();
259
  $upload_file_keys = $this->Data->get_post_value_by_key( MWF_Config::UPLOAD_FILE_KEYS );
260
+
261
+ if ( is_null( $upload_file_keys ) || ! is_array( $upload_file_keys ) ) {
262
+ return array();
263
+ }
264
+
265
+ $wp_upload_dir = wp_upload_dir();
266
+ foreach ( $upload_file_keys as $key ) {
267
+ $upload_file_url = $this->Data->get_post_value_by_key( $key );
268
+ if ( ! $upload_file_url ) {
269
+ continue;
270
+ }
271
+
272
+ $filepath = MWF_Functions::fileurl_to_path( $upload_file_url );
273
+ if ( ! file_exists( $filepath ) ) {
274
+ continue;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
275
  }
276
+
277
+ $form_key = $this->Data->get_form_key();
278
+ $new_upload_dir = apply_filters(
279
+ 'mwform_upload_dir_' . $form_key,
280
+ '',
281
+ clone $this->Data,
282
+ $key
283
+ );
284
+
285
+ $new_filename = apply_filters(
286
+ 'mwform_upload_filename_' . $form_key,
287
+ '',
288
+ clone $this->Data,
289
+ $key
290
+ );
291
+
292
+ $filepath = MWF_Functions::move_temp_file_to_upload_dir(
293
+ $filepath,
294
+ $new_upload_dir,
295
+ $new_filename
296
+ );
297
+
298
+ $new_upload_file_url = MWF_Functions::filepath_to_url( $filepath );
299
+ $this->Data->set( $key, $new_upload_file_url );
300
+ $attachments[ $key ] = $filepath;
301
  }
302
+
303
  return $attachments;
304
  }
305
 
306
  /**
307
+ * File upload processing.
308
+ * Regenerate form data according to the actual upload situation.
309
  */
310
+ protected function _file_upload() {
311
  $File = new MW_WP_Form_File();
312
  $files = array();
313
  $upload_files = $this->Data->get_post_value_by_key( MWF_Config::UPLOAD_FILES );
314
+ if ( ! is_array( $upload_files ) ) {
315
  $upload_files = array();
316
  }
317
  foreach ( $upload_files as $key => $file ) {
318
+ if ( $this->Validation->is_valid_field( $key ) ) {
319
+ $files[ $key ] = $file;
320
+ } elseif ( isset( $files[ $key ] ) ) {
321
+ unset( $files[ $key ] );
322
  }
323
  }
324
  $uploaded_files = $File->upload( $files );
325
  $this->Data->push_uploaded_file_keys( $uploaded_files );
326
  $this->Data->regenerate_upload_file_keys();
327
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
328
  }
classes/controllers/class.stores-inquiry-data-form-list.php CHANGED
@@ -1,70 +1,69 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Stores Inquiry Data Form List Controller
4
- * Version : 1.0.0
5
  * Author : Takashi Kitajima
6
- * Author URI : http://2inc.org
7
  * Created : March 27, 2015
8
- * Modified :
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Stores_Inquiry_Data_Form_List_Controller extends MW_WP_Form_Controller {
13
 
14
- public function index() {
15
- $contact_data_post_types = MW_WP_Form_Contact_Data_Setting::get_posts();
 
 
 
 
 
 
 
 
16
  $form_list = array();
17
  foreach ( $contact_data_post_types as $post_type ) {
18
  $post_type_object = get_post_type_object( $post_type );
19
- $form_list[$post_type] = array(
20
  'title' => $post_type_object->labels->singular_name,
21
- 'count' => $this->get_count( $post_type ),
22
- 'modified_datetime' => $this->get_modified_datetime( $post_type ),
23
- 'created_datetime' => $this->get_created_datetime( $post_type )
24
  );
25
  }
26
- $this->assign( 'form_list', $form_list );
27
- $this->render( 'stores-inquiry-data-form-list/index' );
 
 
28
  }
29
 
30
  /**
31
- * データ件数を取得
32
  *
33
- * @param string $post_type 投稿タイプ名
34
- * @return numeric 投稿数
35
  */
36
- protected function get_count( $post_type ) {
37
- $_args = apply_filters( 'mwform_get_inquiry_data_args-' . $post_type, array() );
38
- $args = array(
 
 
 
39
  'post_type' => $post_type,
40
  'posts_per_page' => 1,
41
- );
42
- if ( !empty( $_args ) && is_array( $_args ) ) {
43
- $args = array_merge( $_args, $args );
44
- }
45
  $query = new WP_Query( $args );
46
  return $query->found_posts;
47
  }
48
 
49
  /**
50
- * フォームの作成日時を取得
51
  *
52
- * @param string $post_type 投稿タイプ名
53
- * @return string 作成日
54
  */
55
- protected function get_created_datetime( $post_type ) {
56
- $post_id = preg_replace( '/^mwf_(.+?)$/', '$1', $post_type );
57
- $post_date = get_the_date( get_option( 'date_format' ), $post_id );
58
- return $post_date;
59
- }
60
-
61
- /**
62
- * 問い合わせデータの最新保存日を取得
63
- *
64
- * @param string $post_type 投稿タイプ名
65
- * @return string 問い合わせデータの最新保存日
66
- */
67
- protected function get_modified_datetime( $post_type ) {
68
  global $post;
69
  $inquiry_posts = get_posts( array(
70
  'post_type' => $post_type,
@@ -81,4 +80,16 @@ class MW_WP_Form_Stores_Inquiry_Data_Form_List_Controller extends MW_WP_Form_Con
81
  wp_reset_postdata();
82
  return $modified_datetime;
83
  }
84
- }
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
  /**
3
  * Name : MW WP Form Stores Inquiry Data Form List Controller
4
+ * Version : 2.0.0
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : March 27, 2015
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Stores_Inquiry_Data_Form_List_Controller extends MW_WP_Form_Controller {
13
 
14
+ public function __construct() {
15
+ $screen = get_current_screen();
16
+ add_action( $screen->id , array( $this, '_index' ) );
17
+ }
18
+
19
+ /**
20
+ * Render the page
21
+ */
22
+ public function _index() {
23
+ $contact_data_post_types = MW_WP_Form_Contact_Data_Setting::get_form_post_types();
24
  $form_list = array();
25
  foreach ( $contact_data_post_types as $post_type ) {
26
  $post_type_object = get_post_type_object( $post_type );
27
+ $form_list[ $post_type ] = array(
28
  'title' => $post_type_object->labels->singular_name,
29
+ 'count' => $this->_get_count( $post_type ),
30
+ 'modified_datetime' => $this->_get_modified_datetime( $post_type ),
31
+ 'created_datetime' => $this->_get_created_datetime( $post_type )
32
  );
33
  }
34
+
35
+ $this->_render( 'stores-inquiry-data-form-list/index', array(
36
+ 'form_list' => $form_list,
37
+ ) );
38
  }
39
 
40
  /**
41
+ * Return data count
42
  *
43
+ * @param string $post_type
44
+ * @return int
45
  */
46
+ protected function _get_count( $post_type ) {
47
+ $args = apply_filters( 'mwform_get_inquiry_data_args-' . $post_type, array() );
48
+ if ( empty( $args ) || ! is_array( $args ) ) {
49
+ $args = array();
50
+ }
51
+ $args = array_merge( $args, array(
52
  'post_type' => $post_type,
53
  'posts_per_page' => 1,
54
+ 'post_status' => 'any',
55
+ ) );
 
 
56
  $query = new WP_Query( $args );
57
  return $query->found_posts;
58
  }
59
 
60
  /**
61
+ * Return the latest saved date of saved inquiry data
62
  *
63
+ * @param string $post_type
64
+ * @return string
65
  */
66
+ protected function _get_modified_datetime( $post_type ) {
 
 
 
 
 
 
 
 
 
 
 
 
67
  global $post;
68
  $inquiry_posts = get_posts( array(
69
  'post_type' => $post_type,
80
  wp_reset_postdata();
81
  return $modified_datetime;
82
  }
83
+
84
+ /**
85
+ * Return date of creating form
86
+ *
87
+ * @param string $post_type
88
+ * @return string
89
+ */
90
+ protected function _get_created_datetime( $post_type ) {
91
+ $post_id = preg_replace( '/^mwf_(.+?)$/', '$1', $post_type );
92
+ $post_date = get_the_date( get_option( 'date_format' ), $post_id );
93
+ return $post_date;
94
+ }
95
+ }
classes/deprecated.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class MWF_Deprecated {
3
+
4
+ public function __construct() {
5
+ add_action( 'mwform_after_exec_shortcode', array( $this, '_mwform_after_exec_shortcode' ), 10000 );
6
+ }
7
+
8
+ public function _mwform_after_exec_shortcode() {
9
+ if ( has_filter( 'mwform_after_exec_shortcode' ) ) {
10
+ MWF_Functions::deprecated_message(
11
+ 'mwform_after_exec_shortcode',
12
+ 'mwform_start_main_process'
13
+ );
14
+ }
15
+ }
16
+ }
17
+ new MWF_Deprecated();
classes/form-fields/class.akismet_error.php CHANGED
@@ -1,28 +1,28 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Field Akismet Error
4
- * Description: Akismetのエラーを出力
5
- * Version : 1.4.0
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : June 21, 2013
9
- * Modified : January 2, 2015
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Field_Akismet_Error extends MW_WP_Form_Abstract_Form_Field {
14
 
15
  /**
16
- * $type
17
- * フォームタグの種類 input|select|button|input_button|error|other
18
  * @var string
19
  */
20
  public $type = 'error';
21
 
22
  /**
23
- * set_names
24
- * shortcode_name、display_nameを定義。各子クラスで上書きする。
25
- * @return array shortcode_name, display_name
 
26
  */
27
  protected function set_names() {
28
  return array(
@@ -32,8 +32,8 @@ class MW_WP_Form_Field_Akismet_Error extends MW_WP_Form_Abstract_Form_Field {
32
  }
33
 
34
  /**
35
- * set_defaults
36
- * $this->defaultsを設定し返す
37
  * @return array defaults
38
  */
39
  protected function set_defaults() {
@@ -41,8 +41,10 @@ class MW_WP_Form_Field_Akismet_Error extends MW_WP_Form_Abstract_Form_Field {
41
  }
42
 
43
  /**
44
- * input_page
45
- * 入力ページでのフォーム項目を返す
 
 
46
  * @return string HTML
47
  */
48
  protected function input_page() {
@@ -56,8 +58,10 @@ class MW_WP_Form_Field_Akismet_Error extends MW_WP_Form_Abstract_Form_Field {
56
  }
57
 
58
  /**
59
- * confirm_page
60
- * 確認ページでのフォーム項目を返す
 
 
61
  * @return string HTML
62
  */
63
  protected function confirm_page() {
1
  <?php
2
  /**
3
  * Name : MW WP Form Field Akismet Error
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : June 21, 2013
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Field_Akismet_Error extends MW_WP_Form_Abstract_Form_Field {
13
 
14
  /**
15
+ * Types of form type.
16
+ * input|select|button|input_button|error|other
17
  * @var string
18
  */
19
  public $type = 'error';
20
 
21
  /**
22
+ * Set shortcode_name and display_name
23
+ * Overwrite required for each child class
24
+ *
25
+ * @return array(shortcode_name, display_name)
26
  */
27
  protected function set_names() {
28
  return array(
32
  }
33
 
34
  /**
35
+ * Set default attributes
36
+ *
37
  * @return array defaults
38
  */
39
  protected function set_defaults() {
41
  }
42
 
43
  /**
44
+ * Callback of add shortcode for input page
45
+ *
46
+ * @param array $atts
47
+ * @param string $element_content
48
  * @return string HTML
49
  */
50
  protected function input_page() {
58
  }
59
 
60
  /**
61
+ * Callback of add shortcode for confirm page
62
+ *
63
+ * @param array $atts
64
+ * @param string $element_content
65
  * @return string HTML
66
  */
67
  protected function confirm_page() {
classes/form-fields/class.back-button.php CHANGED
@@ -1,28 +1,28 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Field Back Button
4
- * Description: 戻るボタンを出力
5
- * Version : 1.6.1
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : December 14, 2012
9
- * Modified : December 26, 2016
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Field_Back_Button extends MW_WP_Form_Abstract_Form_Field {
14
 
15
  /**
16
- * $type
17
- * フォームタグの種類 input|select|button|input_button|error|other
18
  * @var string
19
  */
20
  public $type = 'input_button';
21
 
22
  /**
23
- * set_names
24
- * shortcode_name、display_nameを定義。各子クラスで上書きする。
25
- * @return array shortcode_name, display_name
 
26
  */
27
  protected function set_names() {
28
  return array(
@@ -32,8 +32,8 @@ class MW_WP_Form_Field_Back_Button extends MW_WP_Form_Abstract_Form_Field {
32
  }
33
 
34
  /**
35
- * set_defaults
36
- * $this->defaultsを設定し返す
37
  * @return array defaults
38
  */
39
  protected function set_defaults() {
@@ -44,16 +44,20 @@ class MW_WP_Form_Field_Back_Button extends MW_WP_Form_Abstract_Form_Field {
44
  }
45
 
46
  /**
47
- * input_page
48
- * 入力ページでのフォーム項目を返す
 
 
49
  * @return string HTML
50
  */
51
  protected function input_page() {
52
  }
53
 
54
  /**
55
- * confirm_page
56
- * 確認ページでのフォーム項目を返す
 
 
57
  * @return string HTML
58
  */
59
  protected function confirm_page() {
@@ -63,8 +67,11 @@ class MW_WP_Form_Field_Back_Button extends MW_WP_Form_Abstract_Form_Field {
63
  }
64
 
65
  /**
66
- * add_mwform_tag_generator
67
- * フォームタグジェネレーター
 
 
 
68
  */
69
  public function mwform_tag_generator_dialog( array $options = array() ) {
70
  ?>
1
  <?php
2
  /**
3
  * Name : MW WP Form Field Back Button
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : December 14, 2012
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Field_Back_Button extends MW_WP_Form_Abstract_Form_Field {
13
 
14
  /**
15
+ * Types of form type.
16
+ * input|select|button|input_button|error|other
17
  * @var string
18
  */
19
  public $type = 'input_button';
20
 
21
  /**
22
+ * Set shortcode_name and display_name
23
+ * Overwrite required for each child class
24
+ *
25
+ * @return array(shortcode_name, display_name)
26
  */
27
  protected function set_names() {
28
  return array(
32
  }
33
 
34
  /**
35
+ * Set default attributes
36
+ *
37
  * @return array defaults
38
  */
39
  protected function set_defaults() {
44
  }
45
 
46
  /**
47
+ * Callback of add shortcode for input page
48
+ *
49
+ * @param array $atts
50
+ * @param string $element_content
51
  * @return string HTML
52
  */
53
  protected function input_page() {
54
  }
55
 
56
  /**
57
+ * Callback of add shortcode for confirm page
58
+ *
59
+ * @param array $atts
60
+ * @param string $element_content
61
  * @return string HTML
62
  */
63
  protected function confirm_page() {
67
  }
68
 
69
  /**
70
+ * Display tag generator dialog
71
+ * Overwrite required for each child class
72
+ *
73
+ * @param array $options
74
+ * @return void
75
  */
76
  public function mwform_tag_generator_dialog( array $options = array() ) {
77
  ?>
classes/form-fields/class.button-back.php CHANGED
@@ -1,28 +1,28 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Field Button Back
4
- * Description: 戻るボタン(button)を出力
5
- * Version : 1.0.0
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : December 26, 2016
9
- * Modified :
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Field_Button_Back extends MW_WP_Form_Abstract_Form_Field {
14
 
15
  /**
16
- * $type
17
- * フォームタグの種類 input|select|button|input_button|error|other
18
  * @var string
19
  */
20
  public $type = 'button';
21
 
22
  /**
23
- * set_names
24
- * shortcode_name、display_nameを定義。各子クラスで上書きする。
25
- * @return array shortcode_name, display_name
 
26
  */
27
  protected function set_names() {
28
  return array(
@@ -32,8 +32,8 @@ class MW_WP_Form_Field_Button_Back extends MW_WP_Form_Abstract_Form_Field {
32
  }
33
 
34
  /**
35
- * set_defaults
36
- * $this->defaultsを設定し返す
37
  * @return array defaults
38
  */
39
  protected function set_defaults() {
@@ -45,16 +45,20 @@ class MW_WP_Form_Field_Button_Back extends MW_WP_Form_Abstract_Form_Field {
45
  }
46
 
47
  /**
48
- * input_page
49
- * 入力ページでのフォーム項目を返す
 
 
50
  * @return string HTML
51
  */
52
  protected function input_page() {
53
  }
54
 
55
  /**
56
- * confirm_page
57
- * 確認ページでのフォーム項目を返す
 
 
58
  * @return string HTML
59
  */
60
  protected function confirm_page() {
@@ -69,8 +73,11 @@ class MW_WP_Form_Field_Button_Back extends MW_WP_Form_Abstract_Form_Field {
69
  }
70
 
71
  /**
72
- * add_mwform_tag_generator
73
- * フォームタグジェネレーター
 
 
 
74
  */
75
  public function mwform_tag_generator_dialog( array $options = array() ) {
76
  ?>
1
  <?php
2
  /**
3
  * Name : MW WP Form Field Button Back
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : December 26, 2016
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Field_Button_Back extends MW_WP_Form_Abstract_Form_Field {
13
 
14
  /**
15
+ * Types of form type.
16
+ * input|select|button|input_button|error|other
17
  * @var string
18
  */
19
  public $type = 'button';
20
 
21
  /**
22
+ * Set shortcode_name and display_name
23
+ * Overwrite required for each child class
24
+ *
25
+ * @return array(shortcode_name, display_name)
26
  */
27
  protected function set_names() {
28
  return array(
32
  }
33
 
34
  /**
35
+ * Set default attributes
36
+ *
37
  * @return array defaults
38
  */
39
  protected function set_defaults() {
45
  }
46
 
47
  /**
48
+ * Callback of add shortcode for input page
49
+ *
50
+ * @param array $atts
51
+ * @param string $element_content
52
  * @return string HTML
53
  */
54
  protected function input_page() {
55
  }
56
 
57
  /**
58
+ * Callback of add shortcode for confirm page
59
+ *
60
+ * @param array $atts
61
+ * @param string $element_content
62
  * @return string HTML
63
  */
64
  protected function confirm_page() {
73
  }
74
 
75
  /**
76
+ * Display tag generator dialog
77
+ * Overwrite required for each child class
78
+ *
79
+ * @param array $options
80
+ * @return void
81
  */
82
  public function mwform_tag_generator_dialog( array $options = array() ) {
83
  ?>
classes/form-fields/class.button-button.php CHANGED
@@ -1,28 +1,28 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Field Button Button
4
- * Description: ボタン(button)を出力
5
- * Version : 1.0.0
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : December 26, 2016
9
- * Modified :
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Field_Button_Button extends MW_WP_Form_Abstract_Form_Field {
14
 
15
  /**
16
- * $type
17
- * フォームタグの種類 input|select|button|input_button|error|other
18
  * @var string
19
  */
20
  public $type = 'button';
21
 
22
  /**
23
- * set_names
24
- * shortcode_name、display_nameを定義。各子クラスで上書きする。
25
- * @return array shortcode_name, display_name
 
26
  */
27
  protected function set_names() {
28
  return array(
@@ -32,8 +32,8 @@ class MW_WP_Form_Field_Button_Button extends MW_WP_Form_Abstract_Form_Field {
32
  }
33
 
34
  /**
35
- * set_defaults
36
- * $this->defaultsを設定し返す
37
  * @return array defaults
38
  */
39
  protected function set_defaults() {
@@ -46,8 +46,10 @@ class MW_WP_Form_Field_Button_Button extends MW_WP_Form_Abstract_Form_Field {
46
  }
47
 
48
  /**
49
- * input_page
50
- * 入力ページでのフォーム項目を返す
 
 
51
  * @return string HTML
52
  */
53
  protected function input_page() {
@@ -62,8 +64,10 @@ class MW_WP_Form_Field_Button_Button extends MW_WP_Form_Abstract_Form_Field {
62
  }
63
 
64
  /**
65
- * confirm_page
66
- * 確認ページでのフォーム項目を返す
 
 
67
  * @return string HTML
68
  */
69
  protected function confirm_page() {
@@ -71,8 +75,11 @@ class MW_WP_Form_Field_Button_Button extends MW_WP_Form_Abstract_Form_Field {
71
  }
72
 
73
  /**
74
- * add_mwform_tag_generator
75
- * フォームタグジェネレーター
 
 
 
76
  */
77
  public function mwform_tag_generator_dialog( array $options = array() ) {
78
  ?>
1
  <?php
2
  /**
3
  * Name : MW WP Form Field Button Button
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : December 26, 2016
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Field_Button_Button extends MW_WP_Form_Abstract_Form_Field {
13
 
14
  /**
15
+ * Types of form type.
16
+ * input|select|button|input_button|error|other
17
  * @var string
18
  */
19
  public $type = 'button';
20
 
21
  /**
22
+ * Set shortcode_name and display_name
23
+ * Overwrite required for each child class
24
+ *
25
+ * @return array(shortcode_name, display_name)
26
  */
27
  protected function set_names() {
28
  return array(
32
  }
33
 
34
  /**
35
+ * Set default attributes
36
+ *
37
  * @return array defaults
38
  */
39
  protected function set_defaults() {
46
  }
47
 
48
  /**
49
+ * Callback of add shortcode for input page
50
+ *
51
+ * @param array $atts
52
+ * @param string $element_content
53
  * @return string HTML
54
  */
55
  protected function input_page() {
64
  }
65
 
66
  /**
67
+ * Callback of add shortcode for confirm page
68
+ *
69
+ * @param array $atts
70
+ * @param string $element_content
71
  * @return string HTML
72
  */
73
  protected function confirm_page() {
75
  }
76
 
77
  /**
78
+ * Display tag generator dialog
79
+ * Overwrite required for each child class
80
+ *
81
+ * @param array $options
82
+ * @return void
83
  */
84
  public function mwform_tag_generator_dialog( array $options = array() ) {
85
  ?>
classes/form-fields/class.button-confirm.php CHANGED
@@ -1,28 +1,28 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Field Button Confirm
4
- * Description: 確認ボタン(button)を出力
5
- * Version : 1.0.0
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : December 26, 2016
9
- * Modified :
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Field_Button_Confirm extends MW_WP_Form_Abstract_Form_Field {
14
 
15
  /**
16
- * $type
17
- * フォームタグの種類 input|select|button|input_button|error|other
18
  * @var string
19
  */
20
  public $type = 'button';
21
 
22
  /**
23
- * set_names
24
- * shortcode_name、display_nameを定義。各子クラスで上書きする。
25
- * @return array shortcode_name, display_name
 
26
  */
27
  protected function set_names() {
28
  return array(
@@ -32,8 +32,8 @@ class MW_WP_Form_Field_Button_Confirm extends MW_WP_Form_Abstract_Form_Field {
32
  }
33
 
34
  /**
35
- * set_defaults
36
- * $this->defaultsを設定し返す
37
  * @return array defaults
38
  */
39
  protected function set_defaults() {
@@ -45,8 +45,10 @@ class MW_WP_Form_Field_Button_Confirm extends MW_WP_Form_Abstract_Form_Field {
45
  }
46
 
47
  /**
48
- * input_page
49
- * 入力ページでのフォーム項目を返す
 
 
50
  * @return string HTML
51
  */
52
  protected function input_page() {
@@ -61,16 +63,21 @@ class MW_WP_Form_Field_Button_Confirm extends MW_WP_Form_Abstract_Form_Field {
61
  }
62
 
63
  /**
64
- * confirm_page
65
- * 確認ページでのフォーム項目を返す
 
 
66
  * @return string HTML
67
  */
68
  protected function confirm_page() {
69
  }
70
 
71
  /**
72
- * add_mwform_tag_generator
73
- * フォームタグジェネレーター
 
 
 
74
  */
75
  public function mwform_tag_generator_dialog( array $options = array() ) {
76
  ?>
1
  <?php
2
  /**
3
  * Name : MW WP Form Field Button Confirm
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : December 26, 2016
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Field_Button_Confirm extends MW_WP_Form_Abstract_Form_Field {
13
 
14
  /**
15
+ * Types of form type.
16
+ * input|select|button|input_button|error|other
17
  * @var string
18
  */
19
  public $type = 'button';
20
 
21
  /**
22
+ * Set shortcode_name and display_name
23
+ * Overwrite required for each child class
24
+ *
25
+ * @return array(shortcode_name, display_name)
26
  */
27
  protected function set_names() {
28
  return array(
32
  }
33
 
34
  /**
35
+ * Set default attributes
36
+ *
37
  * @return array defaults
38
  */
39
  protected function set_defaults() {
45
  }
46
 
47
  /**
48
+ * Callback of add shortcode for input page
49
+ *
50
+ * @param array $atts
51
+ * @param string $element_content
52
  * @return string HTML
53
  */
54
  protected function input_page() {
63
  }
64
 
65
  /**
66
+ * Callback of add shortcode for confirm page
67
+ *
68
+ * @param array $atts
69
+ * @param string $element_content
70
  * @return string HTML
71
  */
72
  protected function confirm_page() {
73
  }
74
 
75
  /**
76
+ * Display tag generator dialog
77
+ * Overwrite required for each child class
78
+ *
79
+ * @param array $options
80
+ * @return void
81
  */
82
  public function mwform_tag_generator_dialog( array $options = array() ) {
83
  ?>
classes/form-fields/class.button-submit.php CHANGED
@@ -1,28 +1,28 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Field Button Submit
4
- * Description: 送信ボタン(button)を出力
5
- * Version : 1.0.0
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : December 26, 2016
9
- * Modified :
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Field_Button_Submit extends MW_WP_Form_Abstract_Form_Field {
14
 
15
  /**
16
- * $type
17
- * フォームタグの種類 input|select|button|input_button|error|other
18
  * @var string
19
  */
20
  public $type = 'button';
21
 
22
  /**
23
- * set_names
24
- * shortcode_name、display_nameを定義。各子クラスで上書きする。
25
- * @return array shortcode_name, display_name
 
26
  */
27
  protected function set_names() {
28
  return array(
@@ -32,8 +32,8 @@ class MW_WP_Form_Field_Button_Submit extends MW_WP_Form_Abstract_Form_Field {
32
  }
33
 
34
  /**
35
- * set_defaults
36
- * $this->defaultsを設定し返す
37
  * @return array defaults
38
  */
39
  protected function set_defaults() {
@@ -47,12 +47,14 @@ class MW_WP_Form_Field_Button_Submit extends MW_WP_Form_Abstract_Form_Field {
47
  }
48
 
49
  /**
50
- * input_page
51
- * 入力ページでのフォーム項目を返す
 
 
52
  * @return string HTML
53
  */
54
  protected function input_page() {
55
- if ( $this->atts['display_input'] === 'false' ) {
56
  return;
57
  }
58
 
@@ -67,8 +69,10 @@ class MW_WP_Form_Field_Button_Submit extends MW_WP_Form_Abstract_Form_Field {
67
  }
68
 
69
  /**
70
- * confirm_page
71
- * 確認ページでのフォーム項目を返す
 
 
72
  * @return string HTML
73
  */
74
  protected function confirm_page() {
@@ -83,8 +87,11 @@ class MW_WP_Form_Field_Button_Submit extends MW_WP_Form_Abstract_Form_Field {
83
  }
84
 
85
  /**
86
- * add_mwform_tag_generator
87
- * フォームタグジェネレーター
 
 
 
88
  */
89
  public function mwform_tag_generator_dialog( array $options = array() ) {
90
  ?>
1
  <?php
2
  /**
3
  * Name : MW WP Form Field Button Submit
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : December 26, 2016
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Field_Button_Submit extends MW_WP_Form_Abstract_Form_Field {
13
 
14
  /**
15
+ * Types of form type.
16
+ * input|select|button|input_button|error|other
17
  * @var string
18
  */
19
  public $type = 'button';
20
 
21
  /**
22
+ * Set shortcode_name and display_name
23
+ * Overwrite required for each child class
24
+ *
25
+ * @return array(shortcode_name, display_name)
26
  */
27
  protected function set_names() {
28
  return array(
32
  }
33
 
34
  /**
35
+ * Set default attributes
36
+ *
37
  * @return array defaults
38
  */
39
  protected function set_defaults() {
47
  }
48
 
49
  /**
50
+ * Callback of add shortcode for input page
51
+ *
52
+ * @param array $atts
53
+ * @param string $element_content
54
  * @return string HTML
55
  */
56
  protected function input_page() {
57
+ if ( 'false' === $this->atts['display_input'] ) {
58
  return;
59
  }
60
 
69
  }
70
 
71
  /**
72
+ * Callback of add shortcode for confirm page
73
+ *
74
+ * @param array $atts
75
+ * @param string $element_content
76
  * @return string HTML
77
  */
78
  protected function confirm_page() {
87
  }
88
 
89
  /**
90
+ * Display tag generator dialog
91
+ * Overwrite required for each child class
92
+ *
93
+ * @param array $options
94
+ * @return void
95
  */
96
  public function mwform_tag_generator_dialog( array $options = array() ) {
97
  ?>
classes/form-fields/class.button.php CHANGED
@@ -1,28 +1,28 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Field Button
4
- * Description: ボタンを出力
5
- * Version : 1.6.1
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : December 14, 2012
9
- * Modified : December 26, 2016
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Field_Button extends MW_WP_Form_Abstract_Form_Field {
14
 
15
  /**
16
- * $type
17
- * フォームタグの種類 input|select|button|input_button|error|other
18
  * @var string
19
  */
20
  public $type = 'input_button';
21
 
22
  /**
23
- * set_names
24
- * shortcode_name、display_nameを定義。各子クラスで上書きする。
25
- * @return array shortcode_name, display_name
 
26
  */
27
  protected function set_names() {
28
  return array(
@@ -32,8 +32,8 @@ class MW_WP_Form_Field_Button extends MW_WP_Form_Abstract_Form_Field {
32
  }
33
 
34
  /**
35
- * set_defaults
36
- * $this->defaultsを設定し返す
37
  * @return array defaults
38
  */
39
  protected function set_defaults() {
@@ -45,8 +45,10 @@ class MW_WP_Form_Field_Button extends MW_WP_Form_Abstract_Form_Field {
45
  }
46
 
47
  /**
48
- * input_page
49
- * 入力ページでのフォーム項目を返す
 
 
50
  * @return string HTML
51
  */
52
  protected function input_page() {
@@ -56,8 +58,10 @@ class MW_WP_Form_Field_Button extends MW_WP_Form_Abstract_Form_Field {
56
  }
57
 
58
  /**
59
- * confirm_page
60
- * 確認ページでのフォーム項目を返す
 
 
61
  * @return string HTML
62
  */
63
  protected function confirm_page() {
@@ -65,8 +69,11 @@ class MW_WP_Form_Field_Button extends MW_WP_Form_Abstract_Form_Field {
65
  }
66
 
67
  /**
68
- * add_mwform_tag_generator
69
- * フォームタグジェネレーター
 
 
 
70
  */
71
  public function mwform_tag_generator_dialog( array $options = array() ) {
72
  ?>
1
  <?php
2
  /**
3
  * Name : MW WP Form Field Button
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : December 14, 2012
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Field_Button extends MW_WP_Form_Abstract_Form_Field {
13
 
14
  /**
15
+ * Types of form type.
16
+ * input|select|button|input_button|error|other
17
  * @var string
18
  */
19
  public $type = 'input_button';
20
 
21
  /**
22
+ * Set shortcode_name and display_name
23
+ * Overwrite required for each child class
24
+ *
25
+ * @return array(shortcode_name, display_name)
26
  */
27
  protected function set_names() {
28
  return array(
32
  }
33
 
34
  /**
35
+ * Set default attributes
36
+ *
37
  * @return array defaults
38
  */
39
  protected function set_defaults() {
45
  }
46
 
47
  /**
48
+ * Callback of add shortcode for input page
49
+ *
50
+ * @param array $atts
51
+ * @param string $element_content
52
  * @return string HTML
53
  */
54
  protected function input_page() {
58
  }
59
 
60
  /**
61
+ * Callback of add shortcode for confirm page
62
+ *
63
+ * @param array $atts
64
+ * @param string $element_content
65
  * @return string HTML
66
  */
67
  protected function confirm_page() {
69
  }
70
 
71
  /**
72
+ * Display tag generator dialog
73
+ * Overwrite required for each child class
74
+ *
75
+ * @param array $options
76
+ * @return void
77
  */
78
  public function mwform_tag_generator_dialog( array $options = array() ) {
79
  ?>
classes/form-fields/class.checkbox.php CHANGED
@@ -1,28 +1,28 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Field Checkbox
4
- * Description: チェックボックスを出力
5
- * Version : 1.6.0
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : December 14, 2012
9
- * Modified : November 14, 2015
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Field_Checkbox extends MW_WP_Form_Abstract_Form_Field {
14
 
15
  /**
16
- * $type
17
- * フォームタグの種類 input|select|button|input_button|error|other
18
  * @var string
19
  */
20
  public $type = 'select';
21
 
22
  /**
23
- * set_names
24
- * shortcode_name、display_nameを定義。各子クラスで上書きする。
25
- * @return array shortcode_name, display_name
 
26
  */
27
  protected function set_names() {
28
  return array(
@@ -32,8 +32,8 @@ class MW_WP_Form_Field_Checkbox extends MW_WP_Form_Abstract_Form_Field {
32
  }
33
 
34
  /**
35
- * set_defaults
36
- * $this->defaultsを設定し返す
37
  * @return array defaults
38
  */
39
  protected function set_defaults() {
@@ -51,8 +51,10 @@ class MW_WP_Form_Field_Checkbox extends MW_WP_Form_Abstract_Form_Field {
51
  }
52
 
53
  /**
54
- * input_page
55
- * 入力ページでのフォーム項目を返す
 
 
56
  * @return string HTML
57
  */
58
  protected function input_page() {
@@ -69,18 +71,20 @@ class MW_WP_Form_Field_Checkbox extends MW_WP_Form_Abstract_Form_Field {
69
  'value' => $value,
70
  'vertically' => $this->atts['vertically'],
71
  ), $separator );
72
- if ( $this->atts['post_raw'] === 'false' ) {
73
  $_ret .= $this->Form->children( $this->atts['name'], $children );
74
  }
75
- if ( $this->atts['show_error'] !== 'false' ) {
76
  $_ret .= $this->get_error( $this->atts['name'] );
77
  }
78
  return $_ret;
79
  }
80
 
81
  /**
82
- * confirm_page
83
- * 確認ページでのフォーム項目を返す
 
 
84
  * @return string HTML
85
  */
86
  protected function confirm_page() {
@@ -89,19 +93,22 @@ class MW_WP_Form_Field_Checkbox extends MW_WP_Form_Abstract_Form_Field {
89
  $posted_value = $this->Data->get_raw( $this->atts['name'] );
90
  $separator = $this->Data->get_separator_value( $this->atts['name'] );
91
  $_ret = esc_html( $value );
92
- if ( !is_null( $value ) ) {
93
  $_ret .= $this->Form->hidden( $this->atts['name'] . '[data]', $posted_value );
94
  $_ret .= $this->Form->separator( $this->atts['name'], $separator );
95
  }
96
- if ( $this->atts['post_raw'] === 'false' ) {
97
  $_ret .= $this->Form->children( $this->atts['name'], $children );
98
  }
99
  return $_ret;
100
  }
101
 
102
  /**
103
- * add_mwform_tag_generator
104
- * フォームタグジェネレーター
 
 
 
105
  */
106
  public function mwform_tag_generator_dialog( array $options = array() ) {
107
  ?>
1
  <?php
2
  /**
3
  * Name : MW WP Form Field Checkbox
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : December 14, 2012
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Field_Checkbox extends MW_WP_Form_Abstract_Form_Field {
13
 
14
  /**
15
+ * Types of form type.
16
+ * input|select|button|input_button|error|other
17
  * @var string
18
  */
19
  public $type = 'select';
20
 
21
  /**
22
+ * Set shortcode_name and display_name
23
+ * Overwrite required for each child class
24
+ *
25
+ * @return array(shortcode_name, display_name)
26
  */
27
  protected function set_names() {
28
  return array(
32
  }
33
 
34
  /**
35
+ * Set default attributes
36
+ *
37
  * @return array defaults
38
  */
39
  protected function set_defaults() {
51
  }
52
 
53
  /**
54
+ * Callback of add shortcode for input page
55
+ *
56
+ * @param array $atts
57
+ * @param string $element_content
58
  * @return string HTML
59
  */
60
  protected function input_page() {
71
  'value' => $value,
72
  'vertically' => $this->atts['vertically'],
73
  ), $separator );
74
+ if ( 'false' === $this->atts['post_raw'] ) {
75
  $_ret .= $this->Form->children( $this->atts['name'], $children );
76
  }
77
+ if ( 'false' !== $this->atts['show_error'] ) {
78
  $_ret .= $this->get_error( $this->atts['name'] );
79
  }
80
  return $_ret;
81
  }
82
 
83
  /**
84
+ * Callback of add shortcode for confirm page
85
+ *
86
+ * @param array $atts
87
+ * @param string $element_content
88
  * @return string HTML
89
  */
90
  protected function confirm_page() {
93
  $posted_value = $this->Data->get_raw( $this->atts['name'] );
94
  $separator = $this->Data->get_separator_value( $this->atts['name'] );
95
  $_ret = esc_html( $value );
96
+ if ( ! is_null( $value ) ) {
97
  $_ret .= $this->Form->hidden( $this->atts['name'] . '[data]', $posted_value );
98
  $_ret .= $this->Form->separator( $this->atts['name'], $separator );
99
  }
100
+ if ( 'false' === $this->atts['post_raw'] ) {
101
  $_ret .= $this->Form->children( $this->atts['name'], $children );
102
  }
103
  return $_ret;
104
  }
105
 
106
  /**
107
+ * Display tag generator dialog
108
+ * Overwrite required for each child class
109
+ *
110
+ * @param array $options
111
+ * @return void
112
  */
113
  public function mwform_tag_generator_dialog( array $options = array() ) {
114
  ?>
classes/form-fields/class.confirm-button.php CHANGED
@@ -1,28 +1,28 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Field Confirm Button
4
- * Description: 確認ボタンを出力
5
- * Version : 1.6.1
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : December 14, 2012
9
- * Modified : December 26, 2016
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Field_Confirm_Button extends MW_WP_Form_Abstract_Form_Field {
14
 
15
  /**
16
- * $type
17
- * フォームタグの種類 input|select|button|input_button|error|other
18
  * @var string
19
  */
20
  public $type = 'input_button';
21
 
22
  /**
23
- * set_names
24
- * shortcode_name、display_nameを定義。各子クラスで上書きする。
25
- * @return array shortcode_name, display_name
 
26
  */
27
  protected function set_names() {
28
  return array(
@@ -32,8 +32,8 @@ class MW_WP_Form_Field_Confirm_Button extends MW_WP_Form_Abstract_Form_Field {
32
  }
33
 
34
  /**
35
- * set_defaults
36
- * $this->defaultsを設定し返す
37
  * @return array defaults
38
  */
39
  protected function set_defaults() {
@@ -44,8 +44,10 @@ class MW_WP_Form_Field_Confirm_Button extends MW_WP_Form_Abstract_Form_Field {
44
  }
45
 
46
  /**
47
- * input_page
48
- * 入力ページでのフォーム項目を返す
 
 
49
  * @return string HTML
50
  */
51
  protected function input_page() {
@@ -55,16 +57,21 @@ class MW_WP_Form_Field_Confirm_Button extends MW_WP_Form_Abstract_Form_Field {
55
  }
56
 
57
  /**
58
- * confirm_page
59
- * 確認ページでのフォーム項目を返す
 
 
60
  * @return string HTML
61
  */
62
  protected function confirm_page() {
63
  }
64
 
65
  /**
66
- * add_mwform_tag_generator
67
- * フォームタグジェネレーター
 
 
 
68
  */
69
  public function mwform_tag_generator_dialog( array $options = array() ) {
70
  ?>
1
  <?php
2
  /**
3
  * Name : MW WP Form Field Confirm Button
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : December 14, 2012
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Field_Confirm_Button extends MW_WP_Form_Abstract_Form_Field {
13
 
14
  /**
15
+ * Types of form type.
16
+ * input|select|button|input_button|error|other
17
  * @var string
18
  */
19
  public $type = 'input_button';
20
 
21
  /**
22
+ * Set shortcode_name and display_name
23
+ * Overwrite required for each child class
24
+ *
25
+ * @return array(shortcode_name, display_name)
26
  */
27
  protected function set_names() {
28
  return array(
32
  }
33
 
34
  /**
35
+ * Set default attributes
36
+ *
37
  * @return array defaults
38
  */
39
  protected function set_defaults() {
44
  }
45
 
46
  /**
47
+ * Callback of add shortcode for input page
48
+ *
49
+ * @param array $atts
50
+ * @param string $element_content
51
  * @return string HTML
52
  */
53
  protected function input_page() {
57
  }
58
 
59
  /**
60
+ * Callback of add shortcode for confirm page
61
+ *
62
+ * @param array $atts
63
+ * @param string $element_content
64
  * @return string HTML
65
  */
66
  protected function confirm_page() {
67
  }
68
 
69
  /**
70
+ * Display tag generator dialog
71
+ * Overwrite required for each child class
72
+ *
73
+ * @param array $options
74
+ * @return void
75
  */
76
  public function mwform_tag_generator_dialog( array $options = array() ) {
77
  ?>
classes/form-fields/class.custom-mail-tag.php CHANGED
@@ -1,28 +1,28 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Field Custom Mail Tag
4
- * Description: mwform_custom_mail_tag_mw-wp-form-xxx で指定されたデータを出力
5
- * Version : 1.0.0
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : April 3, 2016
9
- * Modified :
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Field_Custom_Mail_Tag extends MW_WP_Form_Abstract_Form_Field {
14
 
15
  /**
16
- * $type
17
- * フォームタグの種類 input|select|button|input_button|error|other
18
  * @var string
19
  */
20
  public $type = 'other';
21
 
22
  /**
23
- * set_names
24
- * shortcode_name、display_nameを定義。各子クラスで上書きする。
25
- * @return array shortcode_name, display_name
 
26
  */
27
  protected function set_names() {
28
  return array(
@@ -32,9 +32,9 @@ class MW_WP_Form_Field_Custom_Mail_Tag extends MW_WP_Form_Abstract_Form_Field {
32
  }
33
 
34
  /**
35
- * set_defaults
36
- * $this->defaultsを設定し返す
37
- * @return array
38
  */
39
  protected function set_defaults() {
40
  return array(
@@ -45,9 +45,11 @@ class MW_WP_Form_Field_Custom_Mail_Tag extends MW_WP_Form_Abstract_Form_Field {
45
  }
46
 
47
  /**
48
- * input_page
49
- * 入力ページでのフォーム項目を返す
50
- * @return string html
 
 
51
  */
52
  protected function input_page() {
53
  $_ret = $this->custom_mail_tag_field( $this->atts['name'], array(
@@ -55,15 +57,17 @@ class MW_WP_Form_Field_Custom_Mail_Tag extends MW_WP_Form_Abstract_Form_Field {
55
  'class' => $this->atts['class'],
56
  ) );
57
  $_ret .= $this->Form->hidden( MWF_Config::CUSTOM_MAIL_TAG_KEYS . '[]', $this->atts['name'] );
58
- if ( $this->atts['show_error'] !== 'false' ) {
59
  $_ret .= $this->get_error( $this->atts['name'] );
60
  }
61
  return $_ret;
62
  }
63
 
64
  /**
65
- * confirm_page
66
- * 確認ページでのフォーム項目を返す
 
 
67
  * @return string HTML
68
  */
69
  protected function confirm_page() {
@@ -76,8 +80,11 @@ class MW_WP_Form_Field_Custom_Mail_Tag extends MW_WP_Form_Abstract_Form_Field {
76
  }
77
 
78
  /**
79
- * add_mwform_tag_generator
80
- * フォームタグジェネレーター
 
 
 
81
  */
82
  public function mwform_tag_generator_dialog( array $options = array() ) {
83
  ?>
@@ -121,33 +128,7 @@ class MW_WP_Form_Field_Custom_Mail_Tag extends MW_WP_Form_Abstract_Form_Field {
121
  '<span class="mwform-custom-mail-tag-field %s" %s>%s</span>',
122
  esc_attr( $class ),
123
  $attributes,
124
- esc_html( $this->apply_filters_mwform_custom_mail_tag( $this->form_key, '', $name ) )
125
- );
126
- }
127
-
128
- /**
129
- * フィルターフック mwform_custom_mail_tag を実行
130
- *
131
- * @param string $form_key
132
- * @param string|null $value
133
- * @param string $name
134
- * @return string
135
- */
136
- protected function apply_filters_mwform_custom_mail_tag( $form_key, $value, $name ) {
137
- $value = apply_filters(
138
- 'mwform_custom_mail_tag',
139
- $value,
140
- $name,
141
- null
142
- );
143
-
144
- $value = apply_filters(
145
- 'mwform_custom_mail_tag_' . $form_key,
146
- $value,
147
- $name,
148
- null
149
  );
150
-
151
- return $value;
152
  }
153
  }
1
  <?php
2
  /**
3
  * Name : MW WP Form Field Custom Mail Tag
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : April 3, 2016
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Field_Custom_Mail_Tag extends MW_WP_Form_Abstract_Form_Field {
13
 
14
  /**
15
+ * Types of form type.
16
+ * input|select|button|input_button|error|other
17
  * @var string
18
  */
19
  public $type = 'other';
20
 
21
  /**
22
+ * Set shortcode_name and display_name
23
+ * Overwrite required for each child class
24
+ *
25
+ * @return array(shortcode_name, display_name)
26
  */
27
  protected function set_names() {
28
  return array(
32
  }
33
 
34
  /**
35
+ * Set default attributes
36
+ *
37
+ * @return array defaults
38
  */
39
  protected function set_defaults() {
40
  return array(
45
  }
46
 
47
  /**
48
+ * Callback of add shortcode for input page
49
+ *
50
+ * @param array $atts
51
+ * @param string $element_content
52
+ * @return string HTML
53
  */
54
  protected function input_page() {
55
  $_ret = $this->custom_mail_tag_field( $this->atts['name'], array(
57
  'class' => $this->atts['class'],
58
  ) );
59
  $_ret .= $this->Form->hidden( MWF_Config::CUSTOM_MAIL_TAG_KEYS . '[]', $this->atts['name'] );
60
+ if ( 'false' !== $this->atts['show_error'] ) {
61
  $_ret .= $this->get_error( $this->atts['name'] );
62
  }
63
  return $_ret;
64
  }
65
 
66
  /**
67
+ * Callback of add shortcode for confirm page
68
+ *
69
+ * @param array $atts
70
+ * @param string $element_content
71
  * @return string HTML
72
  */
73
  protected function confirm_page() {
80
  }
81
 
82
  /**
83
+ * Display tag generator dialog
84
+ * Overwrite required for each child class
85
+ *
86
+ * @param array $options
87
+ * @return void
88
  */
89
  public function mwform_tag_generator_dialog( array $options = array() ) {
90
  ?>
128
  '<span class="mwform-custom-mail-tag-field %s" %s>%s</span>',
129
  esc_attr( $class ),
130
  $attributes,
131
+ esc_html( MW_WP_Form_Parser::apply_filters_mwform_custom_mail_tag( $this->form_key, '', $name ) )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
132
  );
 
 
133
  }
134
  }
classes/form-fields/class.datepicker.php CHANGED
@@ -1,28 +1,28 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Field Datepicker
4
- * Description: datepickerを出力
5
- * Version : 1.8.1
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : December 14, 2012
9
- * Modified : March 9, 2017
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Field_Datepicker extends MW_WP_Form_Abstract_Form_Field {
14
 
15
  /**
16
- * $type
17
- * フォームタグの種類 input|select|button|input_button|error|other
18
  * @var string
19
  */
20
  public $type = 'input';
21
 
22
  /**
23
- * set_names
24
- * shortcode_name、display_nameを定義。各子クラスで上書きする。
25
- * @return array shortcode_name, display_name
 
26
  */
27
  protected function set_names() {
28
  return array(
@@ -32,8 +32,8 @@ class MW_WP_Form_Field_Datepicker extends MW_WP_Form_Abstract_Form_Field {
32
  }
33
 
34
  /**
35
- * set_defaults
36
- * $this->defaultsを設定し返す
37
  * @return array defaults
38
  */
39
  protected function set_defaults() {
@@ -50,8 +50,10 @@ class MW_WP_Form_Field_Datepicker extends MW_WP_Form_Abstract_Form_Field {
50
  }
51
 
52
  /**
53
- * input_page
54
- * 入力ページでのフォーム項目を返す
 
 
55
  * @return string HTML
56
  */
57
  protected function input_page() {
@@ -74,7 +76,7 @@ class MW_WP_Form_Field_Datepicker extends MW_WP_Form_Abstract_Form_Field {
74
  }
75
 
76
  $translate_datepicker = apply_filters( 'mwform_translate_datepicker_' . $this->form_key, true );
77
- if ( $translate_datepicker && get_locale() == 'ja' ) {
78
  $js = array_merge( array(
79
  'yearSuffix' => '年',
80
  'dateFormat' => 'yy年mm月dd日',
@@ -102,15 +104,17 @@ class MW_WP_Form_Field_Datepicker extends MW_WP_Form_Abstract_Form_Field {
102
  'value' => $value,
103
  'placeholder' => $this->atts['placeholder'],
104
  ) );
105
- if ( $this->atts['show_error'] !== 'false' ) {
106
  $_ret .= $this->get_error( $this->atts['name'] );
107
  }
108
  return $_ret;
109
  }
110
 
111
  /**
112
- * confirm_page
113
- * 確認ページでのフォーム項目を返す
 
 
114
  * @return string HTML
115
  */
116
  protected function confirm_page() {
@@ -121,8 +125,11 @@ class MW_WP_Form_Field_Datepicker extends MW_WP_Form_Abstract_Form_Field {
121
  }
122
 
123
  /**
124
- * add_mwform_tag_generator
125
- * フォームタグジェネレーター
 
 
 
126
  */
127
  public function mwform_tag_generator_dialog( array $options = array() ) {
128
  ?>
1
  <?php
2
  /**
3
  * Name : MW WP Form Field Datepicker
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : December 14, 2012
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Field_Datepicker extends MW_WP_Form_Abstract_Form_Field {
13
 
14
  /**
15
+ * Types of form type.
16
+ * input|select|button|input_button|error|other
17
  * @var string
18
  */
19
  public $type = 'input';
20
 
21
  /**
22
+ * Set shortcode_name and display_name
23
+ * Overwrite required for each child class
24
+ *
25
+ * @return array(shortcode_name, display_name)
26
  */
27
  protected function set_names() {
28
  return array(
32
  }
33
 
34
  /**
35
+ * Set default attributes
36
+ *
37
  * @return array defaults
38
  */
39
  protected function set_defaults() {
50
  }
51
 
52
  /**
53
+ * Callback of add shortcode for input page
54
+ *
55
+ * @param array $atts
56
+ * @param string $element_content
57
  * @return string HTML
58
  */
59
  protected function input_page() {
76
  }
77
 
78
  $translate_datepicker = apply_filters( 'mwform_translate_datepicker_' . $this->form_key, true );
79
+ if ( $translate_datepicker && 'ja' === get_locale() ) {
80
  $js = array_merge( array(
81
  'yearSuffix' => '年',
82
  'dateFormat' => 'yy年mm月dd日',
104
  'value' => $value,
105
  'placeholder' => $this->atts['placeholder'],
106
  ) );
107
+ if ( 'false' !== $this->atts['show_error'] ) {
108
  $_ret .= $this->get_error( $this->atts['name'] );
109
  }
110
  return $_ret;
111
  }
112
 
113
  /**
114
+ * Callback of add shortcode for confirm page
115
+ *
116
+ * @param array $atts
117
+ * @param string $element_content
118
  * @return string HTML
119
  */
120
  protected function confirm_page() {
125
  }
126
 
127
  /**
128
+ * Display tag generator dialog
129
+ * Overwrite required for each child class
130
+ *
131
+ * @param array $options
132
+ * @return void
133
  */
134
  public function mwform_tag_generator_dialog( array $options = array() ) {
135
  ?>
classes/form-fields/class.email.php CHANGED
@@ -1,28 +1,28 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Field Email
4
- * Description: email フィールドを出力
5
- * Version : 1.1.0
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : July 20, 2015
9
- * Modified : November 14, 2015
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Field_Email extends MW_WP_Form_Abstract_Form_Field {
14
 
15
  /**
16
- * $type
17
- * フォームタグの種類 input|select|button|input_button|error|other
18
  * @var string
19
  */
20
  public $type = 'input';
21
 
22
  /**
23
- * set_names
24
- * shortcode_name、display_nameを定義。各子クラスで上書きする。
25
- * @return array shortcode_name, display_name
 
26
  */
27
  protected function set_names() {
28
  return array(
@@ -32,9 +32,9 @@ class MW_WP_Form_Field_Email extends MW_WP_Form_Abstract_Form_Field {
32
  }
33
 
34
  /**
35
- * set_defaults
36
- * $this->defaultsを設定し返す
37
- * @return array
38
  */
39
  protected function set_defaults() {
40
  return array(
@@ -51,13 +51,15 @@ class MW_WP_Form_Field_Email extends MW_WP_Form_Abstract_Form_Field {
51
  }
52
 
53
  /**
54
- * input_page
55
- * 入力ページでのフォーム項目を返す
56
- * @return string html
 
 
57
  */
58
  protected function input_page() {
59
  $conv_half_alphanumeric = 'true';
60
- if ( $this->atts['conv_half_alphanumeric'] !== 'true' ) {
61
  $conv_half_alphanumeric = null;
62
  }
63
  $value = $this->Data->get_raw( $this->atts['name'] );
@@ -74,15 +76,17 @@ class MW_WP_Form_Field_Email extends MW_WP_Form_Abstract_Form_Field {
74
  'placeholder' => $this->atts['placeholder'],
75
  'conv-half-alphanumeric' => $conv_half_alphanumeric,
76
  ) );
77
- if ( $this->atts['show_error'] !== 'false' ) {
78
  $_ret .= $this->get_error( $this->atts['name'] );
79
  }
80
  return $_ret;
81
  }
82
 
83
  /**
84
- * confirm_page
85
- * 確認ページでのフォーム項目を返す
 
 
86
  * @return string HTML
87
  */
88
  protected function confirm_page() {
@@ -93,8 +97,11 @@ class MW_WP_Form_Field_Email extends MW_WP_Form_Abstract_Form_Field {
93
  }
94
 
95
  /**
96
- * add_mwform_tag_generator
97
- * フォームタグジェネレーター
 
 
 
98
  */
99
  public function mwform_tag_generator_dialog( array $options = array() ) {
100
  ?>
1
  <?php
2
  /**
3
  * Name : MW WP Form Field Email
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : July 20, 2015
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Field_Email extends MW_WP_Form_Abstract_Form_Field {
13
 
14
  /**
15
+ * Types of form type.
16
+ * input|select|button|input_button|error|other
17
  * @var string
18
  */
19
  public $type = 'input';
20
 
21
  /**
22
+ * Set shortcode_name and display_name
23
+ * Overwrite required for each child class
24
+ *
25
+ * @return array(shortcode_name, display_name)
26
  */
27
  protected function set_names() {
28
  return array(
32
  }
33
 
34
  /**
35
+ * Set default attributes
36
+ *
37
+ * @return array defaults
38
  */
39
  protected function set_defaults() {
40
  return array(
51
  }
52
 
53
  /**
54
+ * Callback of add shortcode for input page
55
+ *
56
+ * @param array $atts
57
+ * @param string $element_content
58
+ * @return string HTML
59
  */
60
  protected function input_page() {
61
  $conv_half_alphanumeric = 'true';
62
+ if ( 'true' !== $this->atts['conv_half_alphanumeric'] ) {
63
  $conv_half_alphanumeric = null;
64
  }
65
  $value = $this->Data->get_raw( $this->atts['name'] );
76
  'placeholder' => $this->atts['placeholder'],
77
  'conv-half-alphanumeric' => $conv_half_alphanumeric,
78
  ) );
79
+ if ( 'false' !== $this->atts['show_error'] ) {
80
  $_ret .= $this->get_error( $this->atts['name'] );
81
  }
82
  return $_ret;
83
  }
84
 
85
  /**
86
+ * Callback of add shortcode for confirm page
87
+ *
88
+ * @param array $atts
89
+ * @param string $element_content
90
  * @return string HTML
91
  */
92
  protected function confirm_page() {
97
  }
98
 
99
  /**
100
+ * Display tag generator dialog
101
+ * Overwrite required for each child class
102
+ *
103
+ * @param array $options
104
+ * @return void
105
  */
106
  public function mwform_tag_generator_dialog( array $options = array() ) {
107
  ?>
classes/form-fields/class.error.php CHANGED
@@ -1,28 +1,28 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Field Error
4
- * Description: エラーを出力
5
- * Version : 1.5.0
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : December 14, 2012
9
- * Modified : January 2, 2015
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Field_Error extends MW_WP_Form_Abstract_Form_Field {
14
 
15
  /**
16
- * $type
17
- * フォームタグの種類 input|select|button|input_button|error|other
18
  * @var string
19
  */
20
  public $type = 'error';
21
 
22
  /**
23
- * set_names
24
- * shortcode_name、display_nameを定義。各子クラスで上書きする。
25
- * @return array shortcode_name, display_name
 
26
  */
27
  protected function set_names() {
28
  return array(
@@ -32,8 +32,8 @@ class MW_WP_Form_Field_Error extends MW_WP_Form_Abstract_Form_Field {
32
  }
33
 
34
  /**
35
- * set_defaults
36
- * $this->defaultsを設定し返す
37
  * @return array defaults
38
  */
39
  protected function set_defaults() {
@@ -43,8 +43,10 @@ class MW_WP_Form_Field_Error extends MW_WP_Form_Abstract_Form_Field {
43
  }
44
 
45
  /**
46
- * input_page
47
- * 入力ページでのフォーム項目を返す
 
 
48
  * @return string HTML
49
  */
50
  protected function input_page() {
@@ -57,16 +59,21 @@ class MW_WP_Form_Field_Error extends MW_WP_Form_Abstract_Form_Field {
57
  }
58
 
59
  /**
60
- * confirm_page
61
- * 確認ページでのフォーム項目を返す
 
 
62
  * @return string HTML
63
  */
64
  protected function confirm_page() {
65
  }
66
 
67
  /**
68
- * add_mwform_tag_generator
69
- * フォームタグジェネレーター
 
 
 
70
  */
71
  public function mwform_tag_generator_dialog( array $options = array() ) {
72
  ?>
1
  <?php
2
  /**
3
  * Name : MW WP Form Field Error
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : December 14, 2012
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Field_Error extends MW_WP_Form_Abstract_Form_Field {
13
 
14
  /**
15
+ * Types of form type.
16
+ * input|select|button|input_button|error|other
17
  * @var string
18
  */
19
  public $type = 'error';
20
 
21
  /**
22
+ * Set shortcode_name and display_name
23
+ * Overwrite required for each child class
24
+ *
25
+ * @return array(shortcode_name, display_name)
26
  */
27
  protected function set_names() {
28
  return array(
32
  }
33
 
34
  /**
35
+ * Set default attributes
36
+ *
37
  * @return array defaults
38
  */
39
  protected function set_defaults() {
43
  }
44
 
45
  /**
46
+ * Callback of add shortcode for input page
47
+ *
48
+ * @param array $atts
49
+ * @param string $element_content
50
  * @return string HTML
51
  */
52
  protected function input_page() {
59
  }
60
 
61
  /**
62
+ * Callback of add shortcode for confirm page
63
+ *
64
+ * @param array $atts
65
+ * @param string $element_content
66
  * @return string HTML
67
  */
68
  protected function confirm_page() {
69
  }
70
 
71
  /**
72
+ * Display tag generator dialog
73
+ * Overwrite required for each child class
74
+ *
75
+ * @param array $options
76
+ * @return void
77
  */
78
  public function mwform_tag_generator_dialog( array $options = array() ) {
79
  ?>
classes/form-fields/class.file.php CHANGED
@@ -1,28 +1,28 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Field File
4
- * Description: 画像アップロードフィールドを出力
5
- * Version : 1.6.0
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : May 17, 2013
9
- * Modified : November 14, 2015
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Field_File extends MW_WP_Form_Abstract_Form_Field {
14
 
15
  /**
16
- * $type
17
- * フォームタグの種類 input|select|button|input_button|error|other
18
  * @var string
19
  */
20
  public $type = 'input';
21
 
22
  /**
23
- * set_names
24
- * shortcode_name、display_nameを定義。各子クラスで上書きする。
25
- * @return array shortcode_name, display_name
 
26
  */
27
  protected function set_names() {
28
  return array(
@@ -32,8 +32,8 @@ class MW_WP_Form_Field_File extends MW_WP_Form_Abstract_Form_Field {
32
  }
33
 
34
  /**
35
- * set_defaults
36
- * $this->defaultsを設定し返す
37
  * @return array defaults
38
  */
39
  protected function set_defaults() {
@@ -46,8 +46,10 @@ class MW_WP_Form_Field_File extends MW_WP_Form_Abstract_Form_Field {
46
  }
47
 
48
  /**
49
- * input_page
50
- * 入力ページでのフォーム項目を返す
 
 
51
  * @return string HTML
52
  */
53
  protected function input_page() {
@@ -58,7 +60,7 @@ class MW_WP_Form_Field_File extends MW_WP_Form_Abstract_Form_Field {
58
  $value = $this->Data->get_raw( $this->atts['name'] );
59
 
60
  $upload_file_keys = $this->Data->get_post_value_by_key( MWF_Config::UPLOAD_FILE_KEYS );
61
- if ( !empty( $value ) && is_array( $upload_file_keys ) && in_array( $this->atts['name'], $upload_file_keys ) ) {
62
  $filepath = MWF_Functions::fileurl_to_path( $value );
63
  if ( file_exists( $filepath ) ) {
64
  $_ret .= sprintf(
@@ -73,15 +75,17 @@ class MW_WP_Form_Field_File extends MW_WP_Form_Abstract_Form_Field {
73
  );
74
  }
75
  }
76
- if ( $this->atts['show_error'] !== 'false' ) {
77
  $_ret .= $this->get_error( $this->atts['name'] );
78
  }
79
  return $_ret;
80
  }
81
 
82
  /**
83
- * confirm_page
84
- * 確認ページでのフォーム項目を返す
 
 
85
  * @return string HTML
86
  */
87
  protected function confirm_page() {
@@ -99,8 +103,11 @@ class MW_WP_Form_Field_File extends MW_WP_Form_Abstract_Form_Field {
99
  }
100
 
101
  /**
102
- * add_mwform_tag_generator
103
- * フォームタグジェネレーター
 
 
 
104
  */
105
  public function mwform_tag_generator_dialog( array $options = array() ) {
106
  ?>
1
  <?php
2
  /**
3
  * Name : MW WP Form Field File
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : May 17, 2013
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Field_File extends MW_WP_Form_Abstract_Form_Field {
13
 
14
  /**
15
+ * Types of form type.
16
+ * input|select|button|input_button|error|other
17
  * @var string
18
  */
19
  public $type = 'input';
20
 
21
  /**
22
+ * Set shortcode_name and display_name
23
+ * Overwrite required for each child class
24
+ *
25
+ * @return array(shortcode_name, display_name)
26
  */
27
  protected function set_names() {
28
  return array(
32
  }
33
 
34
  /**
35
+ * Set default attributes
36
+ *
37
  * @return array defaults
38
  */
39
  protected function set_defaults() {
46
  }
47
 
48
  /**
49
+ * Callback of add shortcode for input page
50
+ *
51
+ * @param array $atts
52
+ * @param string $element_content
53
  * @return string HTML
54
  */
55
  protected function input_page() {
60
  $value = $this->Data->get_raw( $this->atts['name'] );
61
 
62
  $upload_file_keys = $this->Data->get_post_value_by_key( MWF_Config::UPLOAD_FILE_KEYS );
63
+ if ( ! empty( $value ) && is_array( $upload_file_keys ) && in_array( $this->atts['name'], $upload_file_keys ) ) {
64
  $filepath = MWF_Functions::fileurl_to_path( $value );
65
  if ( file_exists( $filepath ) ) {
66
  $_ret .= sprintf(
75
  );
76
  }
77
  }
78
+ if ( 'false' !== $this->atts['show_error'] ) {
79
  $_ret .= $this->get_error( $this->atts['name'] );
80
  }
81
  return $_ret;
82
  }
83
 
84
  /**
85
+ * Callback of add shortcode for confirm page
86
+ *
87
+ * @param array $atts
88
+ * @param string $element_content
89
  * @return string HTML
90
  */
91
  protected function confirm_page() {
103
  }
104
 
105
  /**
106
+ * Display tag generator dialog
107
+ * Overwrite required for each child class
108
+ *
109
+ * @param array $options
110
+ * @return void
111
  */
112
  public function mwform_tag_generator_dialog( array $options = array() ) {
113
  ?>
classes/form-fields/class.hidden.php CHANGED
@@ -1,21 +1,21 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Hidden
4
- * Description: hiddenフィールドを出力
5
- * Version : 1.6.3
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : December 14, 2012
9
- * Modified : September 28, 2016
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Field_Hidden extends MW_WP_Form_Abstract_Form_Field {
14
 
15
  /**
16
- * set_names
17
- * shortcode_name、display_nameを定義。各子クラスで上書きする。
18
- * @return array shortcode_name, display_name
 
19
  */
20
  protected function set_names() {
21
  return array(
@@ -25,8 +25,8 @@ class MW_WP_Form_Field_Hidden extends MW_WP_Form_Abstract_Form_Field {
25
  }
26
 
27
  /**
28
- * set_defaults
29
- * $this->defaultsを設定し返す
30
  * @return array defaults
31
  */
32
  protected function set_defaults() {
@@ -38,8 +38,10 @@ class MW_WP_Form_Field_Hidden extends MW_WP_Form_Abstract_Form_Field {
38
  }
39
 
40
  /**
41
- * input_page
42
- * 入力ページでのフォーム項目を返す
 
 
43
  * @return string HTML
44
  */
45
  protected function input_page() {
@@ -49,29 +51,34 @@ class MW_WP_Form_Field_Hidden extends MW_WP_Form_Abstract_Form_Field {
49
  }
50
 
51
  $echo = '';
52
- if ( $this->atts['echo'] === 'true' ) {
53
  $echo = $value;
54
  }
55
  return esc_html( $echo ) . $this->Form->hidden( $this->atts['name'], $value );
56
  }
57
 
58
  /**
59
- * confirm_page
60
- * 確認ページでのフォーム項目を返す
 
 
61
  * @return string HTML
62
  */
63
  protected function confirm_page() {
64
  $value = $this->Data->get_raw( $this->atts['name'] );
65
  $echo = '';
66
- if ( $this->atts['echo'] === 'true' ) {
67
  $echo = $value;
68
  }
69
  return esc_html( $echo ) . $this->Form->hidden( $this->atts['name'], $value );
70
  }
71
 
72
  /**
73
- * add_mwform_tag_generator
74
- * フォームタグジェネレーター
 
 
 
75
  */
76
  public function mwform_tag_generator_dialog( array $options = array() ) {
77
  ?>
1
  <?php
2
  /**
3
  * Name : MW WP Form Hidden
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : December 14, 2012
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Field_Hidden extends MW_WP_Form_Abstract_Form_Field {
13
 
14
  /**
15
+ * Set shortcode_name and display_name
16
+ * Overwrite required for each child class
17
+ *
18
+ * @return array(shortcode_name, display_name)
19
  */
20
  protected function set_names() {
21
  return array(
25
  }
26
 
27
  /**
28
+ * Set default attributes
29
+ *
30
  * @return array defaults
31
  */
32
  protected function set_defaults() {
38
  }
39
 
40
  /**
41
+ * Callback of add shortcode for input page
42
+ *
43
+ * @param array $atts
44
+ * @param string $element_content
45
  * @return string HTML
46
  */
47
  protected function input_page() {
51
  }
52
 
53
  $echo = '';
54
+ if ( 'true' === $this->atts['echo'] ) {
55
  $echo = $value;
56
  }
57
  return esc_html( $echo ) . $this->Form->hidden( $this->atts['name'], $value );
58
  }
59
 
60
  /**
61
+ * Callback of add shortcode for confirm page
62
+ *
63
+ * @param array $atts
64
+ * @param string $element_content
65
  * @return string HTML
66
  */
67
  protected function confirm_page() {
68
  $value = $this->Data->get_raw( $this->atts['name'] );
69
  $echo = '';
70
+ if ( 'true' === $this->atts['echo'] ) {
71
  $echo = $value;
72
  }
73
  return esc_html( $echo ) . $this->Form->hidden( $this->atts['name'], $value );
74
  }
75
 
76
  /**
77
+ * Display tag generator dialog
78
+ * Overwrite required for each child class
79
+ *
80
+ * @param array $options
81
+ * @return void
82
  */
83
  public function mwform_tag_generator_dialog( array $options = array() ) {
84
  ?>
classes/form-fields/class.image.php CHANGED
@@ -1,28 +1,28 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Field Image
4
- * Description: 画像アップロードフィールドを出力
5
- * Version : 1.6.0
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : May 17, 2013
9
- * Modified : November 14, 2015
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Field_Image extends MW_WP_Form_Abstract_Form_Field {
14
 
15
  /**
16
- * $type
17
- * フォームタグの種類 input|select|button|input_button|error|other
18
  * @var string
19
  */
20
  public $type = 'input';
21
 
22
  /**
23
- * set_names
24
- * shortcode_name、display_nameを定義。各子クラスで上書きする。
25
- * @return array shortcode_name, display_name
 
26
  */
27
  protected function set_names() {
28
  return array(
@@ -32,8 +32,8 @@ class MW_WP_Form_Field_Image extends MW_WP_Form_Abstract_Form_Field {
32
  }
33
 
34
  /**
35
- * set_defaults
36
- * $this->defaultsを設定し返す
37
  * @return array defaults
38
  */
39
  protected function set_defaults() {
@@ -46,8 +46,10 @@ class MW_WP_Form_Field_Image extends MW_WP_Form_Abstract_Form_Field {
46
  }
47
 
48
  /**
49
- * input_page
50
- * 入力ページでのフォーム項目を返す
 
 
51
  * @return string HTML
52
  */
53
  protected function input_page() {
@@ -58,7 +60,7 @@ class MW_WP_Form_Field_Image extends MW_WP_Form_Abstract_Form_Field {
58
  $value = $this->Data->get_raw( $this->atts['name'] );
59
 
60
  $upload_file_keys = $this->Data->get_post_value_by_key( MWF_Config::UPLOAD_FILE_KEYS );
61
- if ( !empty( $value ) && is_array( $upload_file_keys ) && in_array( $this->atts['name'], $upload_file_keys ) ) {
62
  $filepath = MWF_Functions::fileurl_to_path( $value );
63
  if ( file_exists( $filepath ) ) {
64
  $_ret .= sprintf(
@@ -72,15 +74,17 @@ class MW_WP_Form_Field_Image extends MW_WP_Form_Abstract_Form_Field {
72
  );
73
  }
74
  }
75
- if ( $this->atts['show_error'] !== 'false' ) {
76
  $_ret .= $this->get_error( $this->atts['name'] );
77
  }
78
  return $_ret;
79
  }
80
 
81
  /**
82
- * confirm_page
83
- * 確認ページでのフォーム項目を返す
 
 
84
  * @return string HTML
85
  */
86
  protected function confirm_page() {
@@ -102,8 +106,11 @@ class MW_WP_Form_Field_Image extends MW_WP_Form_Abstract_Form_Field {
102
  }
103
 
104
  /**
105
- * add_mwform_tag_generator
106
- * フォームタグジェネレーター
 
 
 
107
  */
108
  public function mwform_tag_generator_dialog( array $options = array() ) {
109
  ?>
1
  <?php
2
  /**
3
  * Name : MW WP Form Field Image
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : May 17, 2013
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Field_Image extends MW_WP_Form_Abstract_Form_Field {
13
 
14
  /**
15
+ * Types of form type.
16
+ * input|select|button|input_button|error|other
17
  * @var string
18
  */
19
  public $type = 'input';
20
 
21
  /**
22
+ * Set shortcode_name and display_name
23
+ * Overwrite required for each child class
24
+ *
25
+ * @return array(shortcode_name, display_name)
26
  */
27
  protected function set_names() {
28
  return array(
32
  }
33
 
34
  /**
35
+ * Set default attributes
36
+ *
37
  * @return array defaults
38
  */
39
  protected function set_defaults() {
46
  }
47
 
48
  /**
49
+ * Callback of add shortcode for input page
50
+ *
51
+ * @param array $atts
52
+ * @param string $element_content
53
  * @return string HTML
54
  */
55
  protected function input_page() {
60
  $value = $this->Data->get_raw( $this->atts['name'] );
61
 
62
  $upload_file_keys = $this->Data->get_post_value_by_key( MWF_Config::UPLOAD_FILE_KEYS );
63
+ if ( ! empty( $value ) && is_array( $upload_file_keys ) && in_array( $this->atts['name'], $upload_file_keys ) ) {
64
  $filepath = MWF_Functions::fileurl_to_path( $value );
65
  if ( file_exists( $filepath ) ) {
66
  $_ret .= sprintf(
74
  );
75
  }
76
  }
77
+ if ( 'false' !== $this->atts['show_error'] ) {
78
  $_ret .= $this->get_error( $this->atts['name'] );
79
  }
80
  return $_ret;
81
  }
82
 
83
  /**
84
+ * Callback of add shortcode for confirm page
85
+ *
86
+ * @param array $atts
87
+ * @param string $element_content
88
  * @return string HTML
89
  */
90
  protected function confirm_page() {
106
  }
107
 
108
  /**
109
+ * Display tag generator dialog
110
+ * Overwrite required for each child class
111
+ *
112
+ * @param array $options
113
+ * @return void
114
  */
115
  public function mwform_tag_generator_dialog( array $options = array() ) {
116
  ?>
classes/form-fields/class.monthpicker.php CHANGED
@@ -1,28 +1,28 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Field Monthpicker
4
- * Description: monthpickerを出力
5
- * Version : 1.0.0
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
- * Created : December 14, 2012
9
- * Modified : March 9, 2017
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Field_Monthpicker extends MW_WP_Form_Abstract_Form_Field {
14
 
15
  /**
16
- * $type
17
- * フォームタグの種類 input|select|button|input_button|error|other
18
  * @var string
19
  */
20
  public $type = 'input';
21
 
22
  /**
23
- * set_names
24
- * shortcode_name、display_nameを定義。各子クラスで上書きする。
25
- * @return array shortcode_name, display_name
 
26
  */
27
  protected function set_names() {
28
  return array(
@@ -32,8 +32,8 @@ class MW_WP_Form_Field_Monthpicker extends MW_WP_Form_Abstract_Form_Field {
32
  }
33
 
34
  /**
35
- * set_defaults
36
- * $this->defaultsを設定し返す
37
  * @return array defaults
38
  */
39
  protected function set_defaults() {
@@ -50,8 +50,10 @@ class MW_WP_Form_Field_Monthpicker extends MW_WP_Form_Abstract_Form_Field {
50
  }
51
 
52
  /**
53
- * input_page
54
- * 入力ページでのフォーム項目を返す
 
 
55
  * @return string HTML
56
  */
57
  protected function input_page() {
@@ -87,7 +89,7 @@ class MW_WP_Form_Field_Monthpicker extends MW_WP_Form_Abstract_Form_Field {
87
  ) );
88
 
89
  $translate_monthpicker = apply_filters( 'mwform_translate_monthpicker_' . $this->form_key, true );
90
- if ( $translate_monthpicker && get_locale() == 'ja' ) {
91
  $js = array_merge( array(
92
  'i18n' => array(
93
  'year' => '',
@@ -113,15 +115,17 @@ class MW_WP_Form_Field_Monthpicker extends MW_WP_Form_Abstract_Form_Field {
113
  'value' => $value,
114
  'placeholder' => $this->atts['placeholder'],
115
  ) );
116
- if ( $this->atts['show_error'] !== 'false' ) {
117
  $_ret .= $this->get_error( $this->atts['name'] );
118
  }
119
  return $_ret;
120
  }
121
 
122
  /**
123
- * confirm_page
124
- * 確認ページでのフォーム項目を返す
 
 
125
  * @return string HTML
126
  */
127
  protected function confirm_page() {
@@ -132,8 +136,11 @@ class MW_WP_Form_Field_Monthpicker extends MW_WP_Form_Abstract_Form_Field {
132
  }
133
 
134
  /**
135
- * add_mwform_tag_generator
136
- * フォームタグジェネレーター
 
 
 
137
  */
138
  public function mwform_tag_generator_dialog( array $options = array() ) {
139
  ?>
1
  <?php
2
  /**
3
  * Name : MW WP Form Field Monthpicker
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
+ * Created : March 9, 2017
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Field_Monthpicker extends MW_WP_Form_Abstract_Form_Field {
13
 
14
  /**
15
+ * Types of form type.
16
+ * input|select|button|input_button|error|other
17
  * @var string
18
  */
19
  public $type = 'input';
20
 
21
  /**
22
+ * Set shortcode_name and display_name
23
+ * Overwrite required for each child class
24
+ *
25
+ * @return array(shortcode_name, display_name)
26
  */
27
  protected function set_names() {
28
  return array(
32
  }
33
 
34
  /**
35
+ * Set default attributes
36
+ *
37
  * @return array defaults
38
  */
39
  protected function set_defaults() {
50
  }
51
 
52
  /**
53
+ * Callback of add shortcode for input page
54
+ *
55
+ * @param array $atts
56
+ * @param string $element_content
57
  * @return string HTML
58
  */
59
  protected function input_page() {
89
  ) );
90
 
91
  $translate_monthpicker = apply_filters( 'mwform_translate_monthpicker_' . $this->form_key, true );
92
+ if ( 'ja' === $translate_monthpicker && get_locale() ) {
93
  $js = array_merge( array(
94
  'i18n' => array(
95
  'year' => '',
115
  'value' => $value,
116
  'placeholder' => $this->atts['placeholder'],
117
  ) );
118
+ if ( 'false' !== $this->atts['show_error'] ) {
119
  $_ret .= $this->get_error( $this->atts['name'] );
120
  }
121
  return $_ret;
122
  }
123
 
124
  /**
125
+ * Callback of add shortcode for confirm page
126
+ *
127
+ * @param array $atts
128
+ * @param string $element_content
129
  * @return string HTML
130
  */
131
  protected function confirm_page() {
136
  }
137
 
138
  /**
139
+ * Display tag generator dialog
140
+ * Overwrite required for each child class
141
+ *
142
+ * @param array $options
143
+ * @return void
144
  */
145
  public function mwform_tag_generator_dialog( array $options = array() ) {
146
  ?>
classes/form-fields/class.number.php CHANGED
@@ -1,28 +1,28 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Field Number
4
- * Description: number フィールドを出力
5
- * Version : 1.1.0
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : July 21, 2015
9
- * Modified : November 14, 2015
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Field_Number extends MW_WP_Form_Abstract_Form_Field {
14
 
15
  /**
16
- * $type
17
- * フォームタグの種類 input|select|button|input_button|error|other
18
  * @var string
19
  */
20
  public $type = 'input';
21
 
22
  /**
23
- * set_names
24
- * shortcode_name、display_nameを定義。各子クラスで上書きする。
25
- * @return array shortcode_name, display_name
 
26
  */
27
  protected function set_names() {
28
  return array(
@@ -32,9 +32,9 @@ class MW_WP_Form_Field_Number extends MW_WP_Form_Abstract_Form_Field {
32
  }
33
 
34
  /**
35
- * set_defaults
36
- * $this->defaultsを設定し返す
37
- * @return array
38
  */
39
  protected function set_defaults() {
40
  return array(
@@ -51,9 +51,11 @@ class MW_WP_Form_Field_Number extends MW_WP_Form_Abstract_Form_Field {
51
  }
52
 
53
  /**
54
- * input_page
55
- * 入力ページでのフォーム項目を返す
56
- * @return string html
 
 
57
  */
58
  protected function input_page() {
59
  $value = $this->Data->get_raw( $this->atts['name'] );
@@ -70,15 +72,17 @@ class MW_WP_Form_Field_Number extends MW_WP_Form_Abstract_Form_Field {
70
  'step' => $this->atts['step'],
71
  'placeholder' => $this->atts['placeholder'],
72
  ) );
73
- if ( $this->atts['show_error'] !== 'false' ) {
74
  $_ret .= $this->get_error( $this->atts['name'] );
75
  }
76
  return $_ret;
77
  }
78
 
79
  /**
80
- * confirm_page
81
- * 確認ページでのフォーム項目を返す
 
 
82
  * @return string HTML
83
  */
84
  protected function confirm_page() {
@@ -89,8 +93,11 @@ class MW_WP_Form_Field_Number extends MW_WP_Form_Abstract_Form_Field {
89
  }
90
 
91
  /**
92
- * add_mwform_tag_generator
93
- * フォームタグジェネレーター
 
 
 
94
  */
95
  public function mwform_tag_generator_dialog( array $options = array() ) {
96
  ?>
1
  <?php
2
  /**
3
  * Name : MW WP Form Field Number
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : July 21, 2015
8
+ * Modified : May 30, 2015
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Field_Number extends MW_WP_Form_Abstract_Form_Field {
13
 
14
  /**
15
+ * Types of form type.
16
+ * input|select|button|input_button|error|other
17
  * @var string
18
  */
19
  public $type = 'input';
20
 
21
  /**
22
+ * Set shortcode_name and display_name
23
+ * Overwrite required for each child class
24
+ *
25
+ * @return array(shortcode_name, display_name)
26
  */
27
  protected function set_names() {
28
  return array(
32
  }
33
 
34
  /**
35
+ * Set default attributes
36
+ *
37
+ * @return array defaults
38
  */
39
  protected function set_defaults() {
40
  return array(
51
  }
52
 
53
  /**
54
+ * Callback of add shortcode for input page
55
+ *
56
+ * @param array $atts
57
+ * @param string $element_content
58
+ * @return string HTML
59
  */
60
  protected function input_page() {
61
  $value = $this->Data->get_raw( $this->atts['name'] );
72
  'step' => $this->atts['step'],
73
  'placeholder' => $this->atts['placeholder'],
74
  ) );
75
+ if ( 'false' !== $this->atts['show_error'] ) {
76
  $_ret .= $this->get_error( $this->atts['name'] );
77
  }
78
  return $_ret;
79
  }
80
 
81
  /**
82
+ * Callback of add shortcode for confirm page
83
+ *
84
+ * @param array $atts
85
+ * @param string $element_content
86
  * @return string HTML
87
  */
88
  protected function confirm_page() {
93
  }
94
 
95
  /**
96
+ * Display tag generator dialog
97
+ * Overwrite required for each child class
98
+ *
99
+ * @param array $options
100
+ * @return void
101
  */
102
  public function mwform_tag_generator_dialog( array $options = array() ) {
103
  ?>
classes/form-fields/class.password.php CHANGED
@@ -1,28 +1,28 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Password
4
- * Description: パスワードフィールドを出力
5
- * Version : 1.6.0
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : December 14, 2012
9
- * Modified : November 14, 2015
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Field_Password extends MW_WP_Form_Abstract_Form_Field {
14
 
15
  /**
16
- * $type
17
- * フォームタグの種類 input|select|button|input_button|error|other
18
  * @var string
19
  */
20
  public $type = 'input';
21
 
22
  /**
23
- * set_names
24
- * shortcode_name、display_nameを定義。各子クラスで上書きする。
25
- * @return array shortcode_name, display_name
 
26
  */
27
  protected function set_names() {
28
  return array(
@@ -32,8 +32,8 @@ class MW_WP_Form_Field_Password extends MW_WP_Form_Abstract_Form_Field {
32
  }
33
 
34
  /**
35
- * set_defaults
36
- * $this->defaultsを設定し返す
37
  * @return array defaults
38
  */
39
  protected function set_defaults() {
@@ -50,8 +50,10 @@ class MW_WP_Form_Field_Password extends MW_WP_Form_Abstract_Form_Field {
50
  }
51
 
52
  /**
53
- * input_page
54
- * 入力ページでのフォーム項目を返す
 
 
55
  * @return string HTML
56
  */
57
  protected function input_page() {
@@ -68,15 +70,17 @@ class MW_WP_Form_Field_Password extends MW_WP_Form_Abstract_Form_Field {
68
  'value' => $value,
69
  'placeholder' => $this->atts['placeholder'],
70
  ) );
71
- if ( $this->atts['show_error'] !== 'false' ) {
72
  $_ret .= $this->get_error( $this->atts['name'] );
73
  }
74
  return $_ret;
75
  }
76
 
77
  /**
78
- * confirm_page
79
- * 確認ページでのフォーム項目を返す
 
 
80
  * @return string HTML
81
  */
82
  protected function confirm_page() {
@@ -85,8 +89,11 @@ class MW_WP_Form_Field_Password extends MW_WP_Form_Abstract_Form_Field {
85
  }
86
 
87
  /**
88
- * add_mwform_tag_generator
89
- * フォームタグジェネレーター
 
 
 
90
  */
91
  public function mwform_tag_generator_dialog( array $options = array() ) {
92
  ?>
1
  <?php
2
  /**
3
  * Name : MW WP Form Password
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : December 14, 2012
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Field_Password extends MW_WP_Form_Abstract_Form_Field {
13
 
14
  /**
15
+ * Types of form type.
16
+ * input|select|button|input_button|error|other
17
  * @var string
18
  */
19
  public $type = 'input';
20
 
21
  /**
22
+ * Set shortcode_name and display_name
23
+ * Overwrite required for each child class
24
+ *
25
+ * @return array(shortcode_name, display_name)
26
  */
27
  protected function set_names() {
28
  return array(
32
  }
33
 
34
  /**
35
+ * Set default attributes
36
+ *
37
  * @return array defaults
38
  */
39
  protected function set_defaults() {
50
  }
51
 
52
  /**
53
+ * Callback of add shortcode for input page
54
+ *
55
+ * @param array $atts
56
+ * @param string $element_content
57
  * @return string HTML
58
  */
59
  protected function input_page() {
70
  'value' => $value,
71
  'placeholder' => $this->atts['placeholder'],
72
  ) );
73
+ if ( 'false' !== $this->atts['show_error'] ) {
74
  $_ret .= $this->get_error( $this->atts['name'] );
75
  }
76
  return $_ret;
77
  }
78
 
79
  /**
80
+ * Callback of add shortcode for confirm page
81
+ *
82
+ * @param array $atts
83
+ * @param string $element_content
84
  * @return string HTML
85
  */
86
  protected function confirm_page() {
89
  }
90
 
91
  /**
92
+ * Display tag generator dialog
93
+ * Overwrite required for each child class
94
+ *
95
+ * @param array $options
96
+ * @return void
97
  */
98
  public function mwform_tag_generator_dialog( array $options = array() ) {
99
  ?>
classes/form-fields/class.radio.php CHANGED
@@ -1,28 +1,28 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Field Radio
4
- * Description: ラジオボタンを出力
5
- * Version : 1.6.0
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : December 14, 2012
9
- * Modified : November 14, 2015
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Field_Radio extends MW_WP_Form_Abstract_Form_Field {
14
 
15
  /**
16
- * $type
17
- * フォームタグの種類 input|select|button|input_button|error|other
18
  * @var string
19
  */
20
  public $type = 'select';
21
 
22
  /**
23
- * set_names
24
- * shortcode_name、display_nameを定義。各子クラスで上書きする。
25
- * @return array shortcode_name, display_name
 
26
  */
27
  protected function set_names() {
28
  return array(
@@ -32,8 +32,8 @@ class MW_WP_Form_Field_Radio extends MW_WP_Form_Abstract_Form_Field {
32
  }
33
 
34
  /**
35
- * set_defaults
36
- * $this->defaultsを設定し返す
37
  * @return array defaults
38
  */
39
  protected function set_defaults() {
@@ -50,9 +50,11 @@ class MW_WP_Form_Field_Radio extends MW_WP_Form_Abstract_Form_Field {
50
  }
51
 
52
  /**
53
- * input_page
54
- * 入力ページでのフォーム項目を返す
55
- * @return string html
 
 
56
  */
57
  protected function input_page() {
58
  $value = $this->Data->get_raw( $this->atts['name'] );
@@ -67,18 +69,20 @@ class MW_WP_Form_Field_Radio extends MW_WP_Form_Abstract_Form_Field {
67
  'value' => $value,
68
  'vertically' => $this->atts['vertically'],
69
  ) );
70
- if ( $this->atts['post_raw'] === 'false' ) {
71
  $_ret .= $this->Form->children( $this->atts['name'], $children );
72
  }
73
- if ( $this->atts['show_error'] !== 'false' ) {
74
  $_ret .= $this->get_error( $this->atts['name'] );
75
  }
76
  return $_ret;
77
  }
78
 
79
  /**
80
- * confirm_page
81
- * 確認ページでのフォーム項目を返す
 
 
82
  * @return string HTML
83
  */
84
  protected function confirm_page() {
@@ -86,18 +90,21 @@ class MW_WP_Form_Field_Radio extends MW_WP_Form_Abstract_Form_Field {
86
  $value = $this->Data->get( $this->atts['name'], $children );
87
  $posted_value = $this->Data->get_raw( $this->atts['name'] );
88
  $_ret = esc_html( $value );
89
- if ( !is_null( $value ) ) {
90
  $_ret .= $this->Form->hidden( $this->atts['name'], $posted_value );
91
  }
92
- if ( $this->atts['post_raw'] === 'false' ) {
93
  $_ret .= $this->Form->children( $this->atts['name'], $children );
94
  }
95
  return $_ret;
96
  }
97
 
98
  /**
99
- * add_mwform_tag_generator
100
- * フォームタグジェネレーター
 
 
 
101
  */
102
  public function mwform_tag_generator_dialog( array $options = array() ) {
103
  ?>
1
  <?php
2
  /**
3
  * Name : MW WP Form Field Radio
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : December 14, 2012
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Field_Radio extends MW_WP_Form_Abstract_Form_Field {
13
 
14
  /**
15
+ * Types of form type.
16
+ * input|select|button|input_button|error|other
17
  * @var string
18
  */
19
  public $type = 'select';
20
 
21
  /**
22
+ * Set shortcode_name and display_name
23
+ * Overwrite required for each child class
24
+ *
25
+ * @return array(shortcode_name, display_name)
26
  */
27
  protected function set_names() {
28
  return array(
32
  }
33
 
34
  /**
35
+ * Set default attributes
36
+ *
37
  * @return array defaults
38
  */
39
  protected function set_defaults() {
50
  }
51
 
52
  /**
53
+ * Callback of add shortcode for input page
54
+ *
55
+ * @param array $atts
56
+ * @param string $element_content
57
+ * @return string HTML
58
  */
59
  protected function input_page() {
60
  $value = $this->Data->get_raw( $this->atts['name'] );
69
  'value' => $value,
70
  'vertically' => $this->atts['vertically'],
71
  ) );
72
+ if ( 'false' === $this->atts['post_raw'] ) {
73
  $_ret .= $this->Form->children( $this->atts['name'], $children );
74
  }
75
+ if ( 'false' !== $this->atts['show_error'] ) {
76
  $_ret .= $this->get_error( $this->atts['name'] );
77
  }
78
  return $_ret;
79
  }
80
 
81
  /**
82
+ * Callback of add shortcode for confirm page
83
+ *
84
+ * @param array $atts
85
+ * @param string $element_content
86
  * @return string HTML
87
  */
88
  protected function confirm_page() {
90
  $value = $this->Data->get( $this->atts['name'], $children );
91
  $posted_value = $this->Data->get_raw( $this->atts['name'] );
92
  $_ret = esc_html( $value );
93
+ if ( ! is_null( $value ) ) {
94
  $_ret .= $this->Form->hidden( $this->atts['name'], $posted_value );
95
  }
96
+ if ( 'false' === $this->atts['post_raw'] ) {
97
  $_ret .= $this->Form->children( $this->atts['name'], $children );
98
  }
99
  return $_ret;
100
  }
101
 
102
  /**
103
+ * Display tag generator dialog
104
+ * Overwrite required for each child class
105
+ *
106
+ * @param array $options
107
+ * @return void
108
  */
109
  public function mwform_tag_generator_dialog( array $options = array() ) {
110
  ?>
classes/form-fields/class.range.php CHANGED
@@ -1,28 +1,28 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Field Range
4
- * Description: range フィールドを出力
5
- * Version : 1.1.0
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : July 21, 2015
9
- * Modified : November 14, 2015
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Field_Range extends MW_WP_Form_Abstract_Form_Field {
14
 
15
  /**
16
- * $type
17
- * フォームタグの種類 input|select|button|input_button|error|other
18
  * @var string
19
  */
20
  public $type = 'input';
21
 
22
  /**
23
- * set_names
24
- * shortcode_name、display_nameを定義。各子クラスで上書きする。
25
- * @return array shortcode_name, display_name
 
26
  */
27
  protected function set_names() {
28
  return array(
@@ -32,9 +32,9 @@ class MW_WP_Form_Field_Range extends MW_WP_Form_Abstract_Form_Field {
32
  }
33
 
34
  /**
35
- * set_defaults
36
- * $this->defaultsを設定し返す
37
- * @return array
38
  */
39
  protected function set_defaults() {
40
  return array(
@@ -50,9 +50,11 @@ class MW_WP_Form_Field_Range extends MW_WP_Form_Abstract_Form_Field {
50
  }
51
 
52
  /**
53
- * input_page
54
- * 入力ページでのフォーム項目を返す
55
- * @return string html
 
 
56
  */
57
  protected function input_page() {
58
  $value = $this->Data->get_raw( $this->atts['name'] );
@@ -68,15 +70,17 @@ class MW_WP_Form_Field_Range extends MW_WP_Form_Abstract_Form_Field {
68
  'max' => $this->atts['max'],
69
  'step' => $this->atts['step'],
70
  ) );
71
- if ( $this->atts['show_error'] !== 'false' ) {
72
  $_ret .= $this->get_error( $this->atts['name'] );
73
  }
74
  return $_ret;
75
  }
76
 
77
  /**
78
- * confirm_page
79
- * 確認ページでのフォーム項目を返す
 
 
80
  * @return string HTML
81
  */
82
  protected function confirm_page() {
@@ -87,8 +91,11 @@ class MW_WP_Form_Field_Range extends MW_WP_Form_Abstract_Form_Field {
87
  }
88
 
89
  /**
90
- * add_mwform_tag_generator
91
- * フォームタグジェネレーター
 
 
 
92
  */
93
  public function mwform_tag_generator_dialog( array $options = array() ) {
94
  ?>
1
  <?php
2
  /**
3
  * Name : MW WP Form Field Range
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : July 21, 2015
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Field_Range extends MW_WP_Form_Abstract_Form_Field {
13
 
14
  /**
15
+ * Types of form type.
16
+ * input|select|button|input_button|error|other
17
  * @var string
18
  */
19
  public $type = 'input';
20
 
21
  /**
22
+ * Set shortcode_name and display_name
23
+ * Overwrite required for each child class
24
+ *
25
+ * @return array(shortcode_name, display_name)
26
  */
27
  protected function set_names() {
28
  return array(
32
  }
33
 
34
  /**
35
+ * Set default attributes
36
+ *
37
+ * @return array defaults
38
  */
39
  protected function set_defaults() {
40
  return array(
50
  }
51
 
52
  /**
53
+ * Callback of add shortcode for input page
54
+ *
55
+ * @param array $atts
56
+ * @param string $element_content
57
+ * @return string HTML
58
  */
59
  protected function input_page() {
60
  $value = $this->Data->get_raw( $this->atts['name'] );
70
  'max' => $this->atts['max'],
71
  'step' => $this->atts['step'],
72
  ) );
73
+ if ( 'false' !== $this->atts['show_error'] ) {
74
  $_ret .= $this->get_error( $this->atts['name'] );
75
  }
76
  return $_ret;
77
  }
78
 
79
  /**
80
+ * Callback of add shortcode for confirm page
81
+ *
82
+ * @param array $atts
83
+ * @param string $element_content
84
  * @return string HTML
85
  */
86
  protected function confirm_page() {
91
  }
92
 
93
  /**
94
+ * Display tag generator dialog
95
+ * Overwrite required for each child class
96
+ *
97
+ * @param array $options
98
+ * @return void
99
  */
100
  public function mwform_tag_generator_dialog( array $options = array() ) {
101
  ?>
classes/form-fields/class.select.php CHANGED
@@ -1,28 +1,28 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Field Select
4
- * Description: セレクトボックスを出力
5
- * Version : 1.6.0
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : December 14, 2012
9
- * Modified : Novemver 14, 2015
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Field_Select extends MW_WP_Form_Abstract_Form_Field {
14
 
15
  /**
16
- * $type
17
- * フォームタグの種類 input|select|button|input_button|error|other
18
  * @var string
19
  */
20
  public $type = 'select';
21
 
22
  /**
23
- * set_names
24
- * shortcode_name、display_nameを定義。各子クラスで上書きする。
25
- * @return array shortcode_name, display_name
 
26
  */
27
  protected function set_names() {
28
  return array(
@@ -32,8 +32,8 @@ class MW_WP_Form_Field_Select extends MW_WP_Form_Abstract_Form_Field {
32
  }
33
 
34
  /**
35
- * set_defaults
36
- * $this->defaultsを設定し返す
37
  * @return array defaults
38
  */
39
  protected function set_defaults() {
@@ -49,9 +49,11 @@ class MW_WP_Form_Field_Select extends MW_WP_Form_Abstract_Form_Field {
49
  }
50
 
51
  /**
52
- * input_page
53
- * 入力ページでのフォーム項目を返す
54
- * @return string html
 
 
55
  */
56
  protected function input_page() {
57
  $value = $this->Data->get_raw( $this->atts['name'] );
@@ -59,24 +61,26 @@ class MW_WP_Form_Field_Select extends MW_WP_Form_Abstract_Form_Field {
59
  $value = $this->atts['value'];
60
  }
61
  $children = $this->get_children( $this->atts['children'] );
62
-
63
  $_ret = $this->Form->select( $this->atts['name'], $children, array(
64
  'id' => $this->atts['id'],
65
  'class' => $this->atts['class'],
66
  'value' => $value,
67
  ) );
68
- if ( $this->atts['post_raw'] === 'false' ) {
69
  $_ret .= $this->Form->children( $this->atts['name'], $children );
70
  }
71
- if ( $this->atts['show_error'] !== 'false' ) {
72
  $_ret .= $this->get_error( $this->atts['name'] );
73
  }
74
  return $_ret;
75
  }
76
 
77
  /**
78
- * confirm_page
79
- * 確認ページでのフォーム項目を返す
 
 
80
  * @return string HTML
81
  */
82
  protected function confirm_page() {
@@ -85,15 +89,18 @@ class MW_WP_Form_Field_Select extends MW_WP_Form_Abstract_Form_Field {
85
  $posted_value = $this->Data->get_raw( $this->atts['name'] );
86
  $_ret = esc_html( $value );
87
  $_ret .= $this->Form->hidden( $this->atts['name'], $posted_value );
88
- if ( $this->atts['post_raw'] === 'false' ) {
89
  $_ret .= $this->Form->children( $this->atts['name'], $children );
90
  }
91
  return $_ret;
92
  }
93
 
94
  /**
95
- * add_mwform_tag_generator
96
- * フォームタグジェネレーター
 
 
 
97
  */
98
  public function mwform_tag_generator_dialog( array $options = array() ) {
99
  ?>
1
  <?php
2
  /**
3
  * Name : MW WP Form Field Select
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : December 14, 2012
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Field_Select extends MW_WP_Form_Abstract_Form_Field {
13
 
14
  /**
15
+ * Types of form type.
16
+ * input|select|button|input_button|error|other
17
  * @var string
18
  */
19
  public $type = 'select';
20
 
21
  /**
22
+ * Set shortcode_name and display_name
23
+ * Overwrite required for each child class
24
+ *
25
+ * @return array(shortcode_name, display_name)
26
  */
27
  protected function set_names() {
28
  return array(
32
  }
33
 
34
  /**
35
+ * Set default attributes
36
+ *
37
  * @return array defaults
38
  */
39
  protected function set_defaults() {
49
  }
50
 
51
  /**
52
+ * Callback of add shortcode for input page
53
+ *
54
+ * @param array $atts
55
+ * @param string $element_content
56
+ * @return string HTML
57
  */
58
  protected function input_page() {
59
  $value = $this->Data->get_raw( $this->atts['name'] );
61
  $value = $this->atts['value'];
62
  }
63
  $children = $this->get_children( $this->atts['children'] );
64
+
65
  $_ret = $this->Form->select( $this->atts['name'], $children, array(
66
  'id' => $this->atts['id'],
67
  'class' => $this->atts['class'],
68
  'value' => $value,
69
  ) );
70
+ if ( 'false' === $this->atts['post_raw'] ) {
71
  $_ret .= $this->Form->children( $this->atts['name'], $children );
72
  }
73
+ if ( 'false' !== $this->atts['show_error'] ) {
74
  $_ret .= $this->get_error( $this->atts['name'] );
75
  }
76
  return $_ret;
77
  }
78
 
79
  /**
80
+ * Callback of add shortcode for confirm page
81
+ *
82
+ * @param array $atts
83
+ * @param string $element_content
84
  * @return string HTML
85
  */
86
  protected function confirm_page() {
89
  $posted_value = $this->Data->get_raw( $this->atts['name'] );
90
  $_ret = esc_html( $value );
91
  $_ret .= $this->Form->hidden( $this->atts['name'], $posted_value );
92
+ if ( 'false' === $this->atts['post_raw'] ) {
93
  $_ret .= $this->Form->children( $this->atts['name'], $children );
94
  }
95
  return $_ret;
96
  }
97
 
98
  /**
99
+ * Display tag generator dialog
100
+ * Overwrite required for each child class
101
+ *
102
+ * @param array $options
103
+ * @return void
104
  */
105
  public function mwform_tag_generator_dialog( array $options = array() ) {
106
  ?>
classes/form-fields/class.submit-button.php CHANGED
@@ -1,28 +1,28 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Field Submit Button
4
- * Description: 確認ボタンと送信ボタンを自動出力
5
- * Version : 1.6.1
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : December 14, 2012
9
- * Modified : December 26, 2016
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Field_Submit_Button extends MW_WP_Form_Abstract_Form_Field {
14
 
15
  /**
16
- * $type
17
- * フォームタグの種類 input|select|button|input_button|error|other
18
  * @var string
19
  */
20
  public $type = 'input_button';
21
 
22
  /**
23
- * set_names
24
- * shortcode_name、display_nameを定義。各子クラスで上書きする。
25
- * @return array shortcode_name, display_name
 
26
  */
27
  protected function set_names() {
28
  return array(
@@ -32,8 +32,8 @@ class MW_WP_Form_Field_Submit_Button extends MW_WP_Form_Abstract_Form_Field {
32
  }
33
 
34
  /**
35
- * set_defaults
36
- * $this->defaultsを設定し返す
37
  * @return array defaults
38
  */
39
  protected function set_defaults() {
@@ -46,12 +46,14 @@ class MW_WP_Form_Field_Submit_Button extends MW_WP_Form_Abstract_Form_Field {
46
  }
47
 
48
  /**
49
- * input_page
50
- * 入力ページでのフォーム項目を返す
 
 
51
  * @return string HTML
52
  */
53
  protected function input_page() {
54
- if ( !empty( $this->atts['confirm_value'] ) ) {
55
  return $this->Form->submit( MWF_Config::CONFIRM_BUTTON, $this->atts['confirm_value'], array(
56
  'class' => $this->atts['class'],
57
  ) );
@@ -62,8 +64,10 @@ class MW_WP_Form_Field_Submit_Button extends MW_WP_Form_Abstract_Form_Field {
62
  }
63
 
64
  /**
65
- * confirm_page
66
- * 確認ページでのフォーム項目を返す
 
 
67
  * @return string HTML
68
  */
69
  protected function confirm_page() {
@@ -73,8 +77,11 @@ class MW_WP_Form_Field_Submit_Button extends MW_WP_Form_Abstract_Form_Field {
73
  }
74
 
75
  /**
76
- * add_mwform_tag_generator
77
- * フォームタグジェネレーター
 
 
 
78
  */
79
  public function mwform_tag_generator_dialog( array $options = array() ) {
80
  ?>
1
  <?php
2
  /**
3
  * Name : MW WP Form Field Submit Button
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : December 14, 2012
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Field_Submit_Button extends MW_WP_Form_Abstract_Form_Field {
13
 
14
  /**
15
+ * Types of form type.
16
+ * input|select|button|input_button|error|other
17
  * @var string
18
  */
19
  public $type = 'input_button';
20
 
21
  /**
22
+ * Set shortcode_name and display_name
23
+ * Overwrite required for each child class
24
+ *
25
+ * @return array(shortcode_name, display_name)
26
  */
27
  protected function set_names() {
28
  return array(
32
  }
33
 
34
  /**
35
+ * Set default attributes
36
+ *
37
  * @return array defaults
38
  */
39
  protected function set_defaults() {
46
  }
47
 
48
  /**
49
+ * Callback of add shortcode for input page
50
+ *
51
+ * @param array $atts
52
+ * @param string $element_content
53
  * @return string HTML
54
  */
55
  protected function input_page() {
56
+ if ( ! empty( $this->atts['confirm_value'] ) ) {
57
  return $this->Form->submit( MWF_Config::CONFIRM_BUTTON, $this->atts['confirm_value'], array(
58
  'class' => $this->atts['class'],
59
  ) );
64
  }
65
 
66
  /**
67
+ * Callback of add shortcode for confirm page
68
+ *
69
+ * @param array $atts
70
+ * @param string $element_content
71
  * @return string HTML
72
  */
73
  protected function confirm_page() {
77
  }
78
 
79
  /**
80
+ * Display tag generator dialog
81
+ * Overwrite required for each child class
82
+ *
83
+ * @param array $options
84
+ * @return void
85
  */
86
  public function mwform_tag_generator_dialog( array $options = array() ) {
87
  ?>
classes/form-fields/class.submit.php CHANGED
@@ -1,28 +1,28 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Field Submit
4
- * Description: 送信ボタンを出力
5
- * Version : 1.6.1
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : December 14, 2012
9
- * Modified : December 26, 2016
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Field_Submit extends MW_WP_Form_Abstract_Form_Field {
14
 
15
  /**
16
- * $type
17
- * フォームタグの種類 input|select|button|input_button|error|other
18
  * @var string
19
  */
20
  public $type = 'input_button';
21
 
22
  /**
23
- * set_names
24
- * shortcode_name、display_nameを定義。各子クラスで上書きする。
25
- * @return array shortcode_name, display_name
 
26
  */
27
  protected function set_names() {
28
  return array(
@@ -32,8 +32,8 @@ class MW_WP_Form_Field_Submit extends MW_WP_Form_Abstract_Form_Field {
32
  }
33
 
34
  /**
35
- * set_defaults
36
- * $this->defaultsを設定し返す
37
  * @return array defaults
38
  */
39
  protected function set_defaults() {
@@ -45,8 +45,10 @@ class MW_WP_Form_Field_Submit extends MW_WP_Form_Abstract_Form_Field {
45
  }
46
 
47
  /**
48
- * input_page
49
- * 入力ページでのフォーム項目を返す
 
 
50
  * @return string HTML
51
  */
52
  protected function input_page() {
@@ -56,8 +58,10 @@ class MW_WP_Form_Field_Submit extends MW_WP_Form_Abstract_Form_Field {
56
  }
57
 
58
  /**
59
- * confirm_page
60
- * 確認ページでのフォーム項目を返す
 
 
61
  * @return string HTML
62
  */
63
  protected function confirm_page() {
@@ -65,8 +69,11 @@ class MW_WP_Form_Field_Submit extends MW_WP_Form_Abstract_Form_Field {
65
  }
66
 
67
  /**
68
- * add_mwform_tag_generator
69
- * フォームタグジェネレーター
 
 
 
70
  */
71
  public function mwform_tag_generator_dialog( array $options = array() ) {
72
  ?>
1
  <?php
2
  /**
3
  * Name : MW WP Form Field Submit
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : December 14, 2012
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Field_Submit extends MW_WP_Form_Abstract_Form_Field {
13
 
14
  /**
15
+ * Types of form type.
16
+ * input|select|button|input_button|error|other
17
  * @var string
18
  */
19
  public $type = 'input_button';
20
 
21
  /**
22
+ * Set shortcode_name and display_name
23
+ * Overwrite required for each child class
24
+ *
25
+ * @return array(shortcode_name, display_name)
26
  */
27
  protected function set_names() {
28
  return array(
32
  }
33
 
34
  /**
35
+ * Set default attributes
36
+ *
37
  * @return array defaults
38
  */
39
  protected function set_defaults() {
45
  }
46
 
47
  /**
48
+ * Callback of add shortcode for input page
49
+ *
50
+ * @param array $atts
51
+ * @param string $element_content
52
  * @return string HTML
53
  */
54
  protected function input_page() {
58
  }
59
 
60
  /**
61
+ * Callback of add shortcode for confirm page
62
+ *
63
+ * @param array $atts
64
+ * @param string $element_content
65
  * @return string HTML
66
  */
67
  protected function confirm_page() {
69
  }
70
 
71
  /**
72
+ * Display tag generator dialog
73
+ * Overwrite required for each child class
74
+ *
75
+ * @param array $options
76
+ * @return void
77
  */
78
  public function mwform_tag_generator_dialog( array $options = array() ) {
79
  ?>
classes/form-fields/class.tel.php CHANGED
@@ -1,28 +1,28 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Field Tel
4
- * Description: 電話番号フィールドを出力
5
- * Version : 1.6.0
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : December 14, 2012
9
- * Modified : November 14, 2015
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Field_Tel extends MW_WP_Form_Abstract_Form_Field {
14
 
15
  /**
16
- * $type
17
- * フォームタグの種類 input|select|button|input_button|error|other
18
  * @var string
19
  */
20
  public $type = 'input';
21
 
22
  /**
23
- * set_names
24
- * shortcode_name、display_nameを定義。各子クラスで上書きする。
25
- * @return array shortcode_name, display_name
 
26
  */
27
  protected function set_names() {
28
  return array(
@@ -32,8 +32,8 @@ class MW_WP_Form_Field_Tel extends MW_WP_Form_Abstract_Form_Field {
32
  }
33
 
34
  /**
35
- * set_defaults
36
- * $this->defaultsを設定し返す
37
  * @return array defaults
38
  */
39
  protected function set_defaults() {
@@ -47,8 +47,10 @@ class MW_WP_Form_Field_Tel extends MW_WP_Form_Abstract_Form_Field {
47
  }
48
 
49
  /**
50
- * input_page
51
- * 入力ページでのフォーム項目を返す
 
 
52
  * @return string HTML
53
  */
54
  protected function input_page() {
@@ -60,7 +62,7 @@ class MW_WP_Form_Field_Tel extends MW_WP_Form_Abstract_Form_Field {
60
  $value = $this->atts['value'];
61
  }
62
  $conv_half_alphanumeric = 'true';
63
- if ( $this->atts['conv_half_alphanumeric'] !== 'true' ) {
64
  $conv_half_alphanumeric = null;
65
  }
66
 
@@ -69,15 +71,17 @@ class MW_WP_Form_Field_Tel extends MW_WP_Form_Abstract_Form_Field {
69
  'conv-half-alphanumeric' => $conv_half_alphanumeric,
70
  'value' => $value,
71
  ) );
72
- if ( $this->atts['show_error'] !== 'false' ) {
73
  $_ret .= $this->get_error( $this->atts['name'] );
74
  }
75
  return $_ret;
76
  }
77
 
78
  /**
79
- * confirm_page
80
- * 確認ページでのフォーム項目を返す
 
 
81
  * @return string HTML
82
  */
83
  protected function confirm_page() {
@@ -90,8 +94,11 @@ class MW_WP_Form_Field_Tel extends MW_WP_Form_Abstract_Form_Field {
90
  }
91
 
92
  /**
93
- * add_mwform_tag_generator
94
- * フォームタグジェネレーター
 
 
 
95
  */
96
  public function mwform_tag_generator_dialog( array $options = array() ) {
97
  ?>
@@ -117,4 +124,21 @@ class MW_WP_Form_Field_Tel extends MW_WP_Form_Abstract_Form_Field {
117
  </p>
118
  <?php
119
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
120
  }
1
  <?php
2
  /**
3
  * Name : MW WP Form Field Tel
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : December 14, 2012
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Field_Tel extends MW_WP_Form_Abstract_Form_Field {
13
 
14
  /**
15
+ * Types of form type.
16
+ * input|select|button|input_button|error|other
17
  * @var string
18
  */
19
  public $type = 'input';
20
 
21
  /**
22
+ * Set shortcode_name and display_name
23
+ * Overwrite required for each child class
24
+ *
25
+ * @return array(shortcode_name, display_name)
26
  */
27
  protected function set_names() {
28
  return array(
32
  }
33
 
34
  /**
35
+ * Set default attributes
36
+ *
37
  * @return array defaults
38
  */
39
  protected function set_defaults() {
47
  }
48
 
49
  /**
50
+ * Callback of add shortcode for input page
51
+ *
52
+ * @param array $atts
53
+ * @param string $element_content
54
  * @return string HTML
55
  */
56
  protected function input_page() {
62
  $value = $this->atts['value'];
63
  }
64
  $conv_half_alphanumeric = 'true';
65
+ if ( 'true' !== $this->atts['conv_half_alphanumeric'] ) {
66
  $conv_half_alphanumeric = null;
67
  }
68
 
71
  'conv-half-alphanumeric' => $conv_half_alphanumeric,
72
  'value' => $value,
73
  ) );
74
+ if ( 'false' !== $this->atts['show_error'] ) {
75
  $_ret .= $this->get_error( $this->atts['name'] );
76
  }
77
  return $_ret;
78
  }
79
 
80
  /**
81
+ * Callback of add shortcode for confirm page
82
+ *
83
+ * @param array $atts
84
+ * @param string $element_content
85
  * @return string HTML
86
  */
87
  protected function confirm_page() {
94
  }
95
 
96
  /**
97
+ * Display tag generator dialog
98
+ * Overwrite required for each child class
99
+ *
100
+ * @param array $options
101
+ * @return void
102
  */
103
  public function mwform_tag_generator_dialog( array $options = array() ) {
104
  ?>
124
  </p>
125
  <?php
126
  }
127
+
128
+ /**
129
+ * This form field is for Japanese environments only
130
+ *
131
+ * @param array $validation_rules array of MW_WP_Form_Abstract_Form_Field
132
+ * @return array $form_fields
133
+ */
134
+ public function _mwform_form_fields( array $form_fields ) {
135
+ $form_fields = parent::_mwform_form_fields( $form_fields );
136
+
137
+ if ( 'ja' === get_locale() ) {
138
+ return $form_fields;
139
+ }
140
+
141
+ unset( $form_fields[ $this->get_shortcode_name() ] );
142
+ return $form_fields;
143
+ }
144
  }
classes/form-fields/class.text.php CHANGED
@@ -1,28 +1,28 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Field Text
4
- * Description: テキストフィールドを出力
5
- * Version : 1.6.0
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : December 14, 2012
9
- * Modified : November 14, 2015
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Field_Text extends MW_WP_Form_Abstract_Form_Field {
14
 
15
  /**
16
- * $type
17
- * フォームタグの種類 input|select|button|input_button|error|other
18
  * @var string
19
  */
20
  public $type = 'input';
21
 
22
  /**
23
- * set_names
24
- * shortcode_name、display_nameを定義。各子クラスで上書きする。
25
- * @return array shortcode_name, display_name
 
26
  */
27
  protected function set_names() {
28
  return array(
@@ -32,9 +32,9 @@ class MW_WP_Form_Field_Text extends MW_WP_Form_Abstract_Form_Field {
32
  }
33
 
34
  /**
35
- * set_defaults
36
- * $this->defaultsを設定し返す
37
- * @return array
38
  */
39
  protected function set_defaults() {
40
  return array(
@@ -51,13 +51,15 @@ class MW_WP_Form_Field_Text extends MW_WP_Form_Abstract_Form_Field {
51
  }
52
 
53
  /**
54
- * input_page
55
- * 入力ページでのフォーム項目を返す
56
- * @return string html
 
 
57
  */
58
  protected function input_page() {
59
  $conv_half_alphanumeric = 'true';
60
- if ( $this->atts['conv_half_alphanumeric'] !== 'true' ) {
61
  $conv_half_alphanumeric = null;
62
  }
63
  $value = $this->Data->get_raw( $this->atts['name'] );
@@ -74,15 +76,17 @@ class MW_WP_Form_Field_Text extends MW_WP_Form_Abstract_Form_Field {
74
  'placeholder' => $this->atts['placeholder'],
75
  'conv-half-alphanumeric' => $conv_half_alphanumeric,
76
  ) );
77
- if ( $this->atts['show_error'] !== 'false' ) {
78
  $_ret .= $this->get_error( $this->atts['name'] );
79
  }
80
  return $_ret;
81
  }
82
 
83
  /**
84
- * confirm_page
85
- * 確認ページでのフォーム項目を返す
 
 
86
  * @return string HTML
87
  */
88
  protected function confirm_page() {
@@ -93,8 +97,11 @@ class MW_WP_Form_Field_Text extends MW_WP_Form_Abstract_Form_Field {
93
  }
94
 
95
  /**
96
- * add_mwform_tag_generator
97
- * フォームタグジェネレーター
 
 
 
98
  */
99
  public function mwform_tag_generator_dialog( array $options = array() ) {
100
  ?>
1
  <?php
2
  /**
3
  * Name : MW WP Form Field Text
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : December 14, 2012
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Field_Text extends MW_WP_Form_Abstract_Form_Field {
13
 
14
  /**
15
+ * Types of form type.
16
+ * input|select|button|input_button|error|other
17
  * @var string
18
  */
19
  public $type = 'input';
20
 
21
  /**
22
+ * Set shortcode_name and display_name
23
+ * Overwrite required for each child class
24
+ *
25
+ * @return array(shortcode_name, display_name)
26
  */
27
  protected function set_names() {
28
  return array(
32
  }
33
 
34
  /**
35
+ * Set default attributes
36
+ *
37
+ * @return array defaults
38
  */
39
  protected function set_defaults() {
40
  return array(
51
  }
52
 
53
  /**
54
+ * Callback of add shortcode for input page
55
+ *
56
+ * @param array $atts
57
+ * @param string $element_content
58
+ * @return string HTML
59
  */
60
  protected function input_page() {
61
  $conv_half_alphanumeric = 'true';
62
+ if ( 'true' !== $this->atts['conv_half_alphanumeric'] ) {
63
  $conv_half_alphanumeric = null;
64
  }
65
  $value = $this->Data->get_raw( $this->atts['name'] );
76
  'placeholder' => $this->atts['placeholder'],
77
  'conv-half-alphanumeric' => $conv_half_alphanumeric,
78
  ) );
79
+ if ( 'false' !== $this->atts['show_error'] ) {
80
  $_ret .= $this->get_error( $this->atts['name'] );
81
  }
82
  return $_ret;
83
  }
84
 
85
  /**
86
+ * Callback of add shortcode for confirm page
87
+ *
88
+ * @param array $atts
89
+ * @param string $element_content
90
  * @return string HTML
91
  */
92
  protected function confirm_page() {
97
  }
98
 
99
  /**
100
+ * Display tag generator dialog
101
+ * Overwrite required for each child class
102
+ *
103
+ * @param array $options
104
+ * @return void
105
  */
106
  public function mwform_tag_generator_dialog( array $options = array() ) {
107
  ?>
classes/form-fields/class.textarea.php CHANGED
@@ -1,28 +1,28 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Field TextArea
4
- * Description: テキストエリアを出力
5
- * Version : 1.6.0
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : December 14, 2012
9
- * Modified : November 14, 2015
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Field_Textarea extends MW_WP_Form_Abstract_Form_Field {
14
 
15
  /**
16
- * $type
17
- * フォームタグの種類 input|select|button|input_button|error|other
18
  * @var string
19
  */
20
  public $type = 'input';
21
 
22
  /**
23
- * set_names
24
- * shortcode_name、display_nameを定義。各子クラスで上書きする。
25
- * @return array shortcode_name, display_name
 
26
  */
27
  protected function set_names() {
28
  return array(
@@ -32,9 +32,9 @@ class MW_WP_Form_Field_Textarea extends MW_WP_Form_Abstract_Form_Field {
32
  }
33
 
34
  /**
35
- * set_defaults
36
- * $this->defaultsを設定し返す
37
- * @return array
38
  */
39
  protected function set_defaults() {
40
  return array(
@@ -50,16 +50,18 @@ class MW_WP_Form_Field_Textarea extends MW_WP_Form_Abstract_Form_Field {
50
  }
51
 
52
  /**
53
- * input_page
54
- * 入力ページでのフォーム項目を返す
55
- * @return string html
 
 
56
  */
57
  protected function input_page() {
58
  $value = $this->Data->get_raw( $this->atts['name'] );
59
  if ( is_null( $value ) ) {
60
  $value = $this->atts['value'];
61
  }
62
-
63
  $_ret = $this->Form->textarea( $this->atts['name'], array(
64
  'id' => $this->atts['id'],
65
  'class' => $this->atts['class'],
@@ -68,15 +70,17 @@ class MW_WP_Form_Field_Textarea extends MW_WP_Form_Abstract_Form_Field {
68
  'value' => $value,
69
  'placeholder' => $this->atts['placeholder'],
70
  ) );
71
- if ( $this->atts['show_error'] !== 'false' ) {
72
  $_ret .= $this->get_error( $this->atts['name'] );
73
  }
74
  return $_ret;
75
  }
76
 
77
  /**
78
- * confirm_page
79
- * 確認ページでのフォーム項目を返す
 
 
80
  * @return string HTML
81
  */
82
  protected function confirm_page() {
@@ -87,8 +91,11 @@ class MW_WP_Form_Field_Textarea extends MW_WP_Form_Abstract_Form_Field {
87
  }
88
 
89
  /**
90
- * add_mwform_tag_generator
91
- * フォームタグジェネレーター
 
 
 
92
  */
93
  public function mwform_tag_generator_dialog( array $options = array() ) {
94
  ?>
1
  <?php
2
  /**
3
  * Name : MW WP Form Field TextArea
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : December 14, 2012
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Field_Textarea extends MW_WP_Form_Abstract_Form_Field {
13
 
14
  /**
15
+ * Types of form type.
16
+ * input|select|button|input_button|error|other
17
  * @var string
18
  */
19
  public $type = 'input';
20
 
21
  /**
22
+ * Set shortcode_name and display_name
23
+ * Overwrite required for each child class
24
+ *
25
+ * @return array(shortcode_name, display_name)
26
  */
27
  protected function set_names() {
28
  return array(
32
  }
33
 
34
  /**
35
+ * Set default attributes
36
+ *
37
+ * @return array defaults
38
  */
39
  protected function set_defaults() {
40
  return array(
50
  }
51
 
52
  /**
53
+ * Callback of add shortcode for input page
54
+ *
55
+ * @param array $atts
56
+ * @param string $element_content
57
+ * @return string HTML
58
  */
59
  protected function input_page() {
60
  $value = $this->Data->get_raw( $this->atts['name'] );
61
  if ( is_null( $value ) ) {
62
  $value = $this->atts['value'];
63
  }
64
+
65
  $_ret = $this->Form->textarea( $this->atts['name'], array(
66
  'id' => $this->atts['id'],
67
  'class' => $this->atts['class'],
70
  'value' => $value,
71
  'placeholder' => $this->atts['placeholder'],
72
  ) );
73
+ if ( 'false' !== $this->atts['show_error'] ) {
74
  $_ret .= $this->get_error( $this->atts['name'] );
75
  }
76
  return $_ret;
77
  }
78
 
79
  /**
80
+ * Callback of add shortcode for confirm page
81
+ *
82
+ * @param array $atts
83
+ * @param string $element_content
84
  * @return string HTML
85
  */
86
  protected function confirm_page() {
91
  }
92
 
93
  /**
94
+ * Display tag generator dialog
95
+ * Overwrite required for each child class
96
+ *
97
+ * @param array $options
98
+ * @return void
99
  */
100
  public function mwform_tag_generator_dialog( array $options = array() ) {
101
  ?>
classes/form-fields/class.url.php CHANGED
@@ -1,28 +1,28 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Field URL
4
- * Description: url フィールドを出力
5
- * Version : 1.1.0
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : July 20, 2015
9
- * Modified : November 14, 2015
10
  * License : GPLv2 or later or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Field_Url extends MW_WP_Form_Abstract_Form_Field {
14
 
15
  /**
16
- * $type
17
- * フォームタグの種類 input|select|button|input_button|error|other
18
  * @var string
19
  */
20
  public $type = 'input';
21
 
22
  /**
23
- * set_names
24
- * shortcode_name、display_nameを定義。各子クラスで上書きする。
25
- * @return array shortcode_name, display_name
 
26
  */
27
  protected function set_names() {
28
  return array(
@@ -32,9 +32,9 @@ class MW_WP_Form_Field_Url extends MW_WP_Form_Abstract_Form_Field {
32
  }
33
 
34
  /**
35
- * set_defaults
36
- * $this->defaultsを設定し返す
37
- * @return array
38
  */
39
  protected function set_defaults() {
40
  return array(
@@ -51,13 +51,15 @@ class MW_WP_Form_Field_Url extends MW_WP_Form_Abstract_Form_Field {
51
  }
52
 
53
  /**
54
- * input_page
55
- * 入力ページでのフォーム項目を返す
56
- * @return string html
 
 
57
  */
58
  protected function input_page() {
59
  $conv_half_alphanumeric = 'true';
60
- if ( $this->atts['conv_half_alphanumeric'] !== 'true' ) {
61
  $conv_half_alphanumeric = null;
62
  }
63
  $value = $this->Data->get_raw( $this->atts['name'] );
@@ -74,15 +76,17 @@ class MW_WP_Form_Field_Url extends MW_WP_Form_Abstract_Form_Field {
74
  'placeholder' => $this->atts['placeholder'],
75
  'conv-half-alphanumeric' => $conv_half_alphanumeric,
76
  ) );
77
- if ( $this->atts['show_error'] !== 'false' ) {
78
  $_ret .= $this->get_error( $this->atts['name'] );
79
  }
80
  return $_ret;
81
  }
82
 
83
  /**
84
- * confirm_page
85
- * 確認ページでのフォーム項目を返す
 
 
86
  * @return string HTML
87
  */
88
  protected function confirm_page() {
@@ -93,8 +97,11 @@ class MW_WP_Form_Field_Url extends MW_WP_Form_Abstract_Form_Field {
93
  }
94
 
95
  /**
96
- * add_mwform_tag_generator
97
- * フォームタグジェネレーター
 
 
 
98
  */
99
  public function mwform_tag_generator_dialog( array $options = array() ) {
100
  ?>
1
  <?php
2
  /**
3
  * Name : MW WP Form Field URL
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : July 20, 2015
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Field_Url extends MW_WP_Form_Abstract_Form_Field {
13
 
14
  /**
15
+ * Types of form type.
16
+ * input|select|button|input_button|error|other
17
  * @var string
18
  */
19
  public $type = 'input';
20
 
21
  /**
22
+ * Set shortcode_name and display_name
23
+ * Overwrite required for each child class
24
+ *
25
+ * @return array(shortcode_name, display_name)
26
  */
27
  protected function set_names() {
28
  return array(
32
  }
33
 
34
  /**
35
+ * Set default attributes
36
+ *
37
+ * @return array defaults
38
  */
39
  protected function set_defaults() {
40
  return array(
51
  }
52
 
53
  /**
54
+ * Callback of add shortcode for input page
55
+ *
56
+ * @param array $atts
57
+ * @param string $element_content
58
+ * @return string HTML
59
  */
60
  protected function input_page() {
61
  $conv_half_alphanumeric = 'true';
62
+ if ( 'true' !== $this->atts['conv_half_alphanumeric'] ) {
63
  $conv_half_alphanumeric = null;
64
  }
65
  $value = $this->Data->get_raw( $this->atts['name'] );
76
  'placeholder' => $this->atts['placeholder'],
77
  'conv-half-alphanumeric' => $conv_half_alphanumeric,
78
  ) );
79
+ if ( 'false' !== $this->atts['show_error'] ) {
80
  $_ret .= $this->get_error( $this->atts['name'] );
81
  }
82
  return $_ret;
83
  }
84
 
85
  /**
86
+ * Callback of add shortcode for confirm page
87
+ *
88
+ * @param array $atts
89
+ * @param string $element_content
90
  * @return string HTML
91
  */
92
  protected function confirm_page() {
97
  }
98
 
99
  /**
100
+ * Display tag generator dialog
101
+ * Overwrite required for each child class
102
+ *
103
+ * @param array $options
104
+ * @return void
105
  */
106
  public function mwform_tag_generator_dialog( array $options = array() ) {
107
  ?>
classes/form-fields/class.zip.php CHANGED
@@ -1,28 +1,28 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Field Zip
4
- * Description: 郵便番号フィールドを出力
5
- * Version : 1.6.0
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : December 14, 2012
9
- * Modified : November 14, 2015
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Field_Zip extends MW_WP_Form_Abstract_Form_Field {
14
 
15
  /**
16
- * $type
17
- * フォームタグの種類 input|select|button|input_button|error|other
18
  * @var string
19
  */
20
  public $type = 'input';
21
 
22
  /**
23
- * set_names
24
- * shortcode_name、display_nameを定義。各子クラスで上書きする。
25
- * @return array shortcode_name, display_name
 
26
  */
27
  protected function set_names() {
28
  return array(
@@ -32,8 +32,8 @@ class MW_WP_Form_Field_Zip extends MW_WP_Form_Abstract_Form_Field {
32
  }
33
 
34
  /**
35
- * set_defaults
36
- * $this->defaultsを設定し返す
37
  * @return array defaults
38
  */
39
  protected function set_defaults() {
@@ -47,8 +47,10 @@ class MW_WP_Form_Field_Zip extends MW_WP_Form_Abstract_Form_Field {
47
  }
48
 
49
  /**
50
- * input_page
51
- * 入力ページでのフォーム項目を返す
 
 
52
  * @return string HTML
53
  */
54
  protected function input_page() {
@@ -60,7 +62,7 @@ class MW_WP_Form_Field_Zip extends MW_WP_Form_Abstract_Form_Field {
60
  $value = $this->atts['value'];
61
  }
62
  $conv_half_alphanumeric = 'true';
63
- if ( $this->atts['conv_half_alphanumeric'] !== 'true' ) {
64
  $conv_half_alphanumeric = null;
65
  }
66
  $_ret = $this->Form->zip( $this->atts['name'], array(
@@ -68,15 +70,17 @@ class MW_WP_Form_Field_Zip extends MW_WP_Form_Abstract_Form_Field {
68
  'conv-half-alphanumeric' => $conv_half_alphanumeric,
69
  'value' => $value,
70
  ) );
71
- if ( $this->atts['show_error'] !== 'false' ) {
72
  $_ret .= $this->get_error( $this->atts['name'] );
73
  }
74
  return $_ret;
75
  }
76
 
77
  /**
78
- * confirm_page
79
- * 確認ページでのフォーム項目を返す
 
 
80
  * @return string HTML
81
  */
82
  protected function confirm_page() {
@@ -89,8 +93,11 @@ class MW_WP_Form_Field_Zip extends MW_WP_Form_Abstract_Form_Field {
89
  }
90
 
91
  /**
92
- * add_mwform_tag_generator
93
- * フォームタグジェネレーター
 
 
 
94
  */
95
  public function mwform_tag_generator_dialog( array $options = array() ) {
96
  ?>
@@ -116,4 +123,21 @@ class MW_WP_Form_Field_Zip extends MW_WP_Form_Abstract_Form_Field {
116
  </p>
117
  <?php
118
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
  }
1
  <?php
2
  /**
3
  * Name : MW WP Form Field Zip
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : December 14, 2012
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Field_Zip extends MW_WP_Form_Abstract_Form_Field {
13
 
14
  /**
15
+ * Types of form type.
16
+ * input|select|button|input_button|error|other
17
  * @var string
18
  */
19
  public $type = 'input';
20
 
21
  /**
22
+ * Set shortcode_name and display_name
23
+ * Overwrite required for each child class
24
+ *
25
+ * @return array(shortcode_name, display_name)
26
  */
27
  protected function set_names() {
28
  return array(
32
  }
33
 
34
  /**
35
+ * Set default attributes
36
+ *
37
  * @return array defaults
38
  */
39
  protected function set_defaults() {
47
  }
48
 
49
  /**
50
+ * Callback of add shortcode for input page
51
+ *
52
+ * @param array $atts
53
+ * @param string $element_content
54
  * @return string HTML
55
  */
56
  protected function input_page() {
62
  $value = $this->atts['value'];
63
  }
64
  $conv_half_alphanumeric = 'true';
65
+ if ( 'true' !== $this->atts['conv_half_alphanumeric'] ) {
66
  $conv_half_alphanumeric = null;
67
  }
68
  $_ret = $this->Form->zip( $this->atts['name'], array(
70
  'conv-half-alphanumeric' => $conv_half_alphanumeric,
71
  'value' => $value,
72
  ) );
73
+ if ( 'false' !== $this->atts['show_error'] ) {
74
  $_ret .= $this->get_error( $this->atts['name'] );
75
  }
76
  return $_ret;
77
  }
78
 
79
  /**
80
+ * Callback of add shortcode for confirm page
81
+ *
82
+ * @param array $atts
83
+ * @param string $element_content
84
  * @return string HTML
85
  */
86
  protected function confirm_page() {
93
  }
94
 
95
  /**
96
+ * Display tag generator dialog
97
+ * Overwrite required for each child class
98
+ *
99
+ * @param array $options
100
+ * @return void
101
  */
102
  public function mwform_tag_generator_dialog( array $options = array() ) {
103
  ?>
123
  </p>
124
  <?php
125
  }
126
+
127
+ /**
128
+ * This form field is for Japanese environments only
129
+ *
130
+ * @param array $validation_rules array of MW_WP_Form_Abstract_Form_Field
131
+ * @return array $form_fields
132
+ */
133
+ public function _mwform_form_fields( array $form_fields ) {
134
+ $form_fields = parent::_mwform_form_fields( $form_fields );
135
+
136
+ if ( 'ja' === get_locale() ) {
137
+ return $form_fields;
138
+ }
139
+
140
+ unset( $form_fields[ $this->get_shortcode_name() ] );
141
+ return $form_fields;
142
+ }
143
  }
classes/functions.php CHANGED
@@ -1,81 +1,80 @@
1
  <?php
2
  /**
3
  * Name : MWF Functions
4
- * Description: 関数
5
- * Version : 1.6.0
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : May 29, 2013
9
- * Modified : January 30, 2017
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MWF_Functions {
14
 
15
  /**
16
- * 引数で渡された変数が存在し、かつ数値であるなら true
17
  *
18
- * @param string $value 参照渡し
19
  * @return bool
20
  */
21
  public static function is_numeric( &$value ) {
22
- if ( isset( $value ) && preg_match( '/^\d+$/', $value ) ) {
23
- return true;
24
- }
25
- return false;
26
  }
27
 
28
  /**
29
- * 配列の空要素を削除
30
  *
31
  * @param array $array
32
  * @return array
33
  */
34
  public static function array_clean( $array ) {
35
- return array_merge( array_diff( $array, array( '' ) ) );
36
  }
37
 
38
  /**
39
- * 値が空(0は許可)
40
  *
41
  * @param mixed
42
  * @return bool
43
  */
44
  public static function is_empty( $value ) {
45
- if ( $value === array() || $value === '' || $value === null || $value === false ) {
46
- return true;
47
- } else {
48
- return false;
49
- }
50
  }
51
 
52
  /**
53
- * ファイルURLをファイルパスに変換
54
  *
55
  * @param string $fileurl
56
  * @return string
57
  */
58
  public static function fileurl_to_path( $fileurl ) {
59
- $wp_upload_dir = wp_upload_dir();
60
- if ( preg_match( '/^https?:\/\//', $fileurl ) ) {
61
- $baseurl = preg_replace( '/^https?:\/\/(.+)$/', '$1', $wp_upload_dir['baseurl'] );
62
- $fileurl = preg_replace( '/^https?:\/\/(.+)$/', '$1', $fileurl );
63
- $filepath = str_replace(
64
- $baseurl,
65
- $wp_upload_dir['basedir'],
66
- $fileurl
67
- );
68
- return $filepath;
69
  }
 
 
 
 
 
 
 
 
 
 
 
70
  }
71
 
72
  /**
73
- * ファイルパスをURLに変換
74
  *
75
  * @param string $filepath
76
  * @return string
77
  */
78
  public static function filepath_to_url( $filepath ) {
 
 
 
 
79
  $wp_upload_dir = wp_upload_dir();
80
  $fileurl = str_replace(
81
  $wp_upload_dir['basedir'],
@@ -85,11 +84,12 @@ class MWF_Functions {
85
  if ( is_ssl() ) {
86
  $fileurl = preg_replace( '/^https?:\/\//', 'https://', $fileurl );
87
  }
 
88
  return $fileurl;
89
  }
90
 
91
  /**
92
- * 改行コードを \n に統一
93
  *
94
  * @param sring $string
95
  * @return string $string
@@ -99,51 +99,56 @@ class MWF_Functions {
99
  }
100
 
101
  /**
102
- * 古いメソッドを使った場合にエラーを出力
103
  *
104
- * @param string $function_name メソッド名
105
- * @param string $new_function 代替のメソッド名
106
  */
107
  public static function deprecated_message( $function_name, $new_function = '' ) {
 
 
 
 
108
  global $mwform_deprecated_message;
109
  $mwform_deprecated_message .= '<div class="error ' . esc_attr( MWF_Config::NAME ) . '-deprecated-message">';
110
  $mwform_deprecated_message .= sprintf(
111
- 'MW WP Form dosen\'t support "%s" already. This method will be removed in the next version. ',
112
  $function_name
113
  );
114
  if ( $new_function ) {
115
- $mwform_deprecated_message .= sprintf( 'You should use "%s". ', $new_function );
116
  }
117
  $debug_backtrace = debug_backtrace();
118
  array_shift( $debug_backtrace );
119
  foreach ( $debug_backtrace as $value ) {
120
  if ( isset( $value['file'], $value['line'] ) ) {
121
- $mwform_deprecated_message .= sprintf( '%s line %d', $value['file'], $value['line'] );
122
  }
123
  break;
124
  }
125
  $mwform_deprecated_message .= '</div>';
126
  if ( is_admin() ) {
127
- if ( current_filter() === 'admin_notices' ) {
128
- self::display_deprecated_message();
129
  } else {
130
- add_action( 'admin_notices', 'MWF_Functions::display_deprecated_message' );
131
  }
132
  } else {
133
- if ( current_filter() === 'the_content' ) {
134
- self::display_deprecated_message();
135
  } else {
136
- add_filter( 'the_content', 'MWF_Functions::return_deprecated_message' );
 
137
  }
138
  }
139
  }
140
- public static function display_deprecated_message() {
141
  global $mwform_deprecated_message;
142
  $content = $mwform_deprecated_message;
143
  unset( $mwform_deprecated_message );
144
  echo $content;
145
  }
146
- public static function return_deprecated_message( $content ) {
147
  global $mwform_deprecated_message;
148
  $content = $mwform_deprecated_message . $content;
149
  unset( $mwform_deprecated_message );
@@ -151,28 +156,28 @@ class MWF_Functions {
151
  }
152
 
153
  /**
154
- * Tempディレクトリからuploadディレクトリにファイルを移動
155
  *
156
- * @param string Temp ファイルのパス
157
- * @param string 新しい保存先ディレクトリ
158
- * @param string 新しいファイル名
159
- * @return string 新しいファイルパス
160
  */
161
  public static function move_temp_file_to_upload_dir( $filepath, $upload_dir = '', $filename = '' ) {
162
  $wp_upload_dir = wp_upload_dir();
163
 
164
- if ( !$upload_dir ) {
165
  $upload_dir = $wp_upload_dir['path'];
166
  } else {
167
  $upload_dir = trailingslashit( $wp_upload_dir['basedir'] ) . ltrim( $upload_dir, '/\\' );
168
  $bool = wp_mkdir_p( $upload_dir );
169
  }
170
 
171
- if ( !$filename ) {
172
  $filename = basename( $filepath );
173
  }
174
 
175
- if ( !preg_match( '/(\..+?)$/', $filename ) ) {
176
  $extension = pathinfo( $filepath, PATHINFO_EXTENSION );
177
  $filename = $filename . '.' . $extension;
178
  }
@@ -185,12 +190,12 @@ class MWF_Functions {
185
  return $filepath;
186
  }
187
 
188
- // もし temp ファイルが存在しない場合、一応リネーム後のパスだけ返す
189
- if ( !file_exists( $filepath ) ) {
190
  return $new_filepath;
191
  }
192
 
193
- // 移動できれば移動、移動できなくてもリネーム後のパスだけ返す
194
  if ( rename( $filepath, $new_filepath ) ) {
195
  return $new_filepath;
196
  }
@@ -198,23 +203,24 @@ class MWF_Functions {
198
  }
199
 
200
  /**
201
- * 添付ファイルをメディアに保存、投稿データに添付ファイルのキー(配列)を保存
202
- * $this->settings が確定した後でのみ利用可能
203
  *
204
- * @param int post_id
205
- * @param array ( ファイルのname属性値 => ファイルパス, )
206
- * @param int 生成フォーム(usedb)の post_id
 
207
  */
208
- public static function save_attachments_in_media( $post_id, $attachments, $form_id ) {
209
  require_once( ABSPATH . 'wp-admin' . '/includes/media.php' );
210
  require_once( ABSPATH . 'wp-admin' . '/includes/image.php' );
211
  $save_attached_key = array();
212
  foreach ( $attachments as $key => $filepath ) {
213
- if ( !self::check_file_type( $filepath ) ) {
214
  continue;
215
  }
216
 
217
  $wp_check_filetype = wp_check_filetype( $filepath );
 
218
  $post_type = get_post_type_object( self::get_contact_data_post_type_from_form_id( $form_id ) );
219
  if ( empty( $post_type->label ) ) {
220
  continue;
@@ -225,30 +231,34 @@ class MWF_Functions {
225
  'post_status' => 'inherit',
226
  'post_content' => __( 'Uploaded from ', 'mw-wp-form' ) . $post_type->label,
227
  );
228
- $attach_id = wp_insert_attachment( $attachment, $filepath, $post_id );
229
  $attach_data = wp_generate_attachment_metadata( $attach_id, $filepath );
230
  $update_attachment_flg = wp_update_attachment_metadata( $attach_id, $attach_data );
231
  if ( $attach_id ) {
232
  // 代わりにここで attachment_id を保存
233
- update_post_meta( $post_id, $key, $attach_id );
234
  // $key が 添付ファイルのキーであるとわかるように隠し設定を保存
235
  $save_attached_key[] = $key;
236
  }
237
  }
238
  if ( $save_attached_key ) {
239
- update_post_meta( $post_id, '_' . MWF_Config::UPLOAD_FILE_KEYS, $save_attached_key );
240
  }
241
  }
242
 
243
  /**
244
- * ファイルタイプのチェック
245
  *
246
- * @param string $filepath アップロードされたファイルのパス
247
- * @param string $filename ファイル名(未アップロード時の$_FILEの検査の場合、temp_nameは乱数になっているため)
248
  * @return bool
249
  */
250
  public static function check_file_type( $filepath, $filename = '' ) {
251
- // WordPress( get_allowed_mime_types ) で許可されたファイルタイプ限定
 
 
 
 
252
  if ( $filename ) {
253
  $wp_check_filetype = wp_check_filetype( $filename );
254
  } else {
@@ -258,69 +268,67 @@ class MWF_Functions {
258
  return false;
259
  }
260
 
261
- // 1つの拡張子に対し複数のMIMEタイプを持つファイルの対応
262
- switch ( $wp_check_filetype['ext'] ) {
263
- case 'avi' :
264
- $wp_check_filetype['type'] = array(
265
- 'application/x-troff-msvideo',
266
- 'video/avi',
267
- 'video/msvideo',
268
- 'video/x-msvideo',
269
- );
270
- break;
271
- case 'mp3' :
272
- $wp_check_filetype['type'] = array(
273
- 'audio/mpeg3',
274
- 'audio/x-mpeg3',
275
- 'video/mpeg',
276
- 'video/x-mpeg',
277
- 'audio/mpeg',
278
- );
279
- break;
280
- case 'mpg' :
281
- $wp_check_filetype['type'] = array(
282
- 'audio/mpeg',
283
- 'video/mpeg',
284
- );
285
- break;
286
- case 'docx' :
287
- $wp_check_filetype['type'] = array(
288
- $wp_check_filetype['type'],
289
- 'application/zip',
290
- 'application/msword',
291
- );
292
- break;
293
- case 'xlsx' :
294
- $wp_check_filetype['type'] = array(
295
- $wp_check_filetype['type'],
296
- 'application/zip',
297
- 'application/excel',
298
- 'application/msexcel',
299
- 'application/vnd.ms-excel',
300
- );
301
- break;
302
- case 'pptx' :
303
- $wp_check_filetype['type'] = array(
304
- $wp_check_filetype['type'],
305
- 'application/zip',
306
- 'application/mspowerpoint',
307
- 'application/powerpoint',
308
- 'application/ppt',
309
- );
310
- break;
311
- }
312
-
313
- if ( version_compare( phpversion(), '5.3.0' ) >= 0 && defined( 'FILEINFO_MIME_TYPE ' ) ) {
314
- if ( !file_exists( $filepath ) ) {
315
- return false;
316
- }
317
  $finfo = new finfo( FILEINFO_MIME_TYPE );
318
- $type = $finfo->file( $filepath );
319
- if ( $finfo === false ) {
320
  return false;
321
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
322
  if ( is_array( $wp_check_filetype['type'] ) ) {
323
- if ( !in_array( $type, $wp_check_filetype['type'] ) ) {
324
  return false;
325
  }
326
  } else {
@@ -329,13 +337,14 @@ class MWF_Functions {
329
  }
330
  }
331
  }
 
332
  return true;
333
  }
334
 
335
  /**
336
- * 問い合わせ番号の表示名を取得
337
  *
338
- * @param string $post_type 問い合わせデータの投稿タイプ名
339
  * @return string
340
  */
341
  public static function get_tracking_number_title( $post_type ) {
@@ -351,10 +360,10 @@ class MWF_Functions {
351
  }
352
 
353
  /**
354
- * 問い合わせデータの投稿タイプ名をフォーム識別子に変換
355
  *
356
- * @param string $post_type 問い合わせデータの投稿タイプ名
357
- * @return string|null フォーム識別子
358
  */
359
  public static function contact_data_post_type_to_form_key( $post_type ) {
360
  if ( self::is_contact_data_post_type( $post_type ) ) {
@@ -366,52 +375,54 @@ class MWF_Functions {
366
  }
367
 
368
  /**
369
- * フォームの投稿 ID をフォーム識別子に変換
370
  *
371
  * @param int $form_id
372
- * @return string フォーム識別子
373
  */
374
  public static function get_form_key_from_form_id( $form_id ) {
375
- $form_key = MWF_Config::NAME . '-' . $form_id;
376
- return $form_key;
 
377
  }
378
 
379
  /**
380
- * フォーム識別子をフォームの投稿 ID に変換
381
  *
382
  * @param string $form_key
383
- * @return int
384
  */
385
  public static function get_form_id_from_form_key( $form_key ) {
386
- return preg_replace( '/^' . MWF_Config::NAME . '-(\d+)$/', '$1', $form_key );
 
 
387
  }
388
 
389
  /**
390
- * フォームの投稿 ID を問い合わせデータの投稿タイプに変換
391
  *
392
  * @param int $form_id
393
- * @return string フォーム識別子
394
  */
395
  public static function get_contact_data_post_type_from_form_id( $form_id ) {
396
- $contact_data_post_type = MWF_Config::DBDATA . $form_id;
397
- return $contact_data_post_type;
 
 
398
  }
399
 
400
  /**
401
- * 問い合わせデータ投稿タイプかどうか
402
  *
403
  * @param string $post_type
404
  * @return bool
405
  */
406
  public static function is_contact_data_post_type( $post_type ) {
407
- if ( preg_match( '/^' . MWF_Config::DBDATA . '\d+$/', $post_type ) ) {
408
- return true;
409
- }
410
- return false;
411
  }
412
 
413
  /**
414
- * 添付データを適切なHTMLに変換して返す
415
  *
416
  * @param string $value
417
  * @return string
@@ -419,7 +430,7 @@ class MWF_Functions {
419
  public static function get_multimedia_data( $value ) {
420
  $mimetype = get_post_mime_type( $value );
421
  if ( $mimetype ) {
422
- // 画像だったら
423
  if ( in_array( $mimetype, array( 'image/jpeg', 'image/gif', 'image/png', 'image/bmp' ) ) ) {
424
  $src_thumbnail = wp_get_attachment_image_src( $value, 'thumbnail' );
425
  $src_full = wp_get_attachment_image_src( $value, 'full' );
@@ -429,7 +440,7 @@ class MWF_Functions {
429
  esc_url( $src_thumbnail[0] )
430
  );
431
  }
432
- // 画像以外
433
  else {
434
  $src = wp_mime_type_icon( $mimetype );
435
  return sprintf(
@@ -439,14 +450,14 @@ class MWF_Functions {
439
  );
440
  }
441
  }
442
- // 添付されているけど、フック等でメタ情報が書き換えられて添付ファイルID以外になってしまった場合
443
  else {
444
  return esc_html( $value );
445
  }
446
  }
447
 
448
  /**
449
- * 添付データのIDを返す
450
  * 過去バージョンでの不具合でアップロードファイルを示すメタデータが空になっていることがあるのでその場合の代替処理
451
  *
452
  * @param WP_Post $post
@@ -455,15 +466,63 @@ class MWF_Functions {
455
  */
456
  public static function get_multimedia_id__fallback( $post, $meta_key ) {
457
  $Contact_Data_Setting = new MW_WP_Form_Contact_Data_Setting( $post->ID );
458
- $key = $Contact_Data_Setting->get_key_in_upload_file_keys( $post, $meta_key );
 
 
 
 
 
459
  $attachments = get_posts( array(
460
  'post_type' => 'attachment',
461
  'post_parent' => $post->ID,
462
  'posts_per_page' => 1,
463
- 'offset' => $key,
464
  ) );
 
465
  if ( isset( $attachments[0] ) ) {
466
  return $attachments[0]->ID;
467
  }
468
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
469
  }
1
  <?php
2
  /**
3
  * Name : MWF Functions
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : May 29, 2013
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MWF_Functions {
13
 
14
  /**
15
+ * Return true when the variable passed as an argument exists and the numeric value
16
  *
17
+ * @param variable $value Pass by reference
18
  * @return bool
19
  */
20
  public static function is_numeric( &$value ) {
21
+ return ( isset( $value ) && preg_match( '/^\d+$/', $value ) );
 
 
 
22
  }
23
 
24
  /**
25
+ * Delete empty element of array
26
  *
27
  * @param array $array
28
  * @return array
29
  */
30
  public static function array_clean( $array ) {
31
+ return array_filter( $array );
32
  }
33
 
34
  /**
35
+ * If the value is empty (0 is permitted)
36
  *
37
  * @param mixed
38
  * @return bool
39
  */
40
  public static function is_empty( $value ) {
41
+ return ( array() === $value || '' === $value || is_null( $value ) || false === $value );
 
 
 
 
42
  }
43
 
44
  /**
45
+ * Convert file URL to file path
46
  *
47
  * @param string $fileurl
48
  * @return string
49
  */
50
  public static function fileurl_to_path( $fileurl ) {
51
+ if ( ! preg_match( '/^https?:\/\//', $fileurl ) ) {
52
+ return;
 
 
 
 
 
 
 
 
53
  }
54
+
55
+ $wp_upload_dir = wp_upload_dir();
56
+ $baseurl = preg_replace( '/^https?:\/\/(.+)$/', '$1', $wp_upload_dir['baseurl'] );
57
+ $fileurl = preg_replace( '/^https?:\/\/(.+)$/', '$1', $fileurl );
58
+ $filepath = str_replace(
59
+ $baseurl,
60
+ $wp_upload_dir['basedir'],
61
+ $fileurl
62
+ );
63
+
64
+ return $filepath;
65
  }
66
 
67
  /**
68
+ * Convert file path to file URL
69
  *
70
  * @param string $filepath
71
  * @return string
72
  */
73
  public static function filepath_to_url( $filepath ) {
74
+ if ( preg_match( '/^https?:\/\//', $filepath ) ) {
75
+ return;
76
+ }
77
+
78
  $wp_upload_dir = wp_upload_dir();
79
  $fileurl = str_replace(
80
  $wp_upload_dir['basedir'],
84
  if ( is_ssl() ) {
85
  $fileurl = preg_replace( '/^https?:\/\//', 'https://', $fileurl );
86
  }
87
+
88
  return $fileurl;
89
  }
90
 
91
  /**
92
+ * Unify line feed code to \n
93
  *
94
  * @param sring $string
95
  * @return string $string
99
  }
100
 
101
  /**
102
+ * Display deprecated error message
103
  *
104
+ * @param string $function_name
105
+ * @param string $new_function_name
106
  */
107
  public static function deprecated_message( $function_name, $new_function = '' ) {
108
+ if ( ! defined( 'WP_DEBUG' ) || true !== WP_DEBUG || ! current_user_can( 'manage_options' ) ) {
109
+ return;
110
+ }
111
+
112
  global $mwform_deprecated_message;
113
  $mwform_deprecated_message .= '<div class="error ' . esc_attr( MWF_Config::NAME ) . '-deprecated-message">';
114
  $mwform_deprecated_message .= sprintf(
115
+ 'MW WP Form dosen\'t support "<b>%s</b>" already. This will be removed in the next version. ',
116
  $function_name
117
  );
118
  if ( $new_function ) {
119
+ $mwform_deprecated_message .= sprintf( 'You should use "<b>%s</b>". ', $new_function );
120
  }
121
  $debug_backtrace = debug_backtrace();
122
  array_shift( $debug_backtrace );
123
  foreach ( $debug_backtrace as $value ) {
124
  if ( isset( $value['file'], $value['line'] ) ) {
125
+ $mwform_deprecated_message .= sprintf( '<b>%s line %d</b>', $value['file'], $value['line'] );
126
  }
127
  break;
128
  }
129
  $mwform_deprecated_message .= '</div>';
130
  if ( is_admin() ) {
131
+ if ( 'admin_notices' === current_filter() ) {
132
+ self::_display_deprecated_message();
133
  } else {
134
+ add_action( 'admin_notices', 'MWF_Functions::_display_deprecated_message' );
135
  }
136
  } else {
137
+ if ( 'the_content' === current_filter() ) {
138
+ self::_display_deprecated_message();
139
  } else {
140
+ add_filter( 'the_content', 'MWF_Functions::_return_deprecated_message' );
141
+ error_log( strip_tags( self::_return_deprecated_message() ) );
142
  }
143
  }
144
  }
145
+ protected static function _display_deprecated_message() {
146
  global $mwform_deprecated_message;
147
  $content = $mwform_deprecated_message;
148
  unset( $mwform_deprecated_message );
149
  echo $content;
150
  }
151
+ protected static function _return_deprecated_message( $content = '' ) {
152
  global $mwform_deprecated_message;
153
  $content = $mwform_deprecated_message . $content;
154
  unset( $mwform_deprecated_message );
156
  }
157
 
158
  /**
159
+ * Move files from Temp directory to upload directory
160
  *
161
+ * @param string $filepath Path of temp file
162
+ * @param string $upload_dir Directory path of new file
163
+ * @param string $filename new fine name
164
+ * @return string New file path
165
  */
166
  public static function move_temp_file_to_upload_dir( $filepath, $upload_dir = '', $filename = '' ) {
167
  $wp_upload_dir = wp_upload_dir();
168
 
169
+ if ( ! $upload_dir ) {
170
  $upload_dir = $wp_upload_dir['path'];
171
  } else {
172
  $upload_dir = trailingslashit( $wp_upload_dir['basedir'] ) . ltrim( $upload_dir, '/\\' );
173
  $bool = wp_mkdir_p( $upload_dir );
174
  }
175
 
176
+ if ( ! $filename ) {
177
  $filename = basename( $filepath );
178
  }
179
 
180
+ if ( ! preg_match( '/(\..+?)$/', $filename ) ) {
181
  $extension = pathinfo( $filepath, PATHINFO_EXTENSION );
182
  $filename = $filename . '.' . $extension;
183
  }
190
  return $filepath;
191
  }
192
 
193
+ // If the temp file doesn't exist, return only the path after the rename
194
+ if ( ! file_exists( $filepath ) ) {
195
  return $new_filepath;
196
  }
197
 
198
+ // If it can move, even if it can not move, return only the path after rename
199
  if ( rename( $filepath, $new_filepath ) ) {
200
  return $new_filepath;
201
  }
203
  }
204
 
205
  /**
206
+ * Save attached file on media, save attachment key (array) in posting data
 
207
  *
208
+ * @param int $saved_mail_id
209
+ * @param array $attachments (name => file path)
210
+ * @param int $form_id
211
+ * @return void
212
  */
213
+ public static function save_attachments_in_media( $saved_mail_id, $attachments, $form_id ) {
214
  require_once( ABSPATH . 'wp-admin' . '/includes/media.php' );
215
  require_once( ABSPATH . 'wp-admin' . '/includes/image.php' );
216
  $save_attached_key = array();
217
  foreach ( $attachments as $key => $filepath ) {
218
+ if ( ! self::check_file_type( $filepath ) ) {
219
  continue;
220
  }
221
 
222
  $wp_check_filetype = wp_check_filetype( $filepath );
223
+ global $wp_post_types;
224
  $post_type = get_post_type_object( self::get_contact_data_post_type_from_form_id( $form_id ) );
225
  if ( empty( $post_type->label ) ) {
226
  continue;
231
  'post_status' => 'inherit',
232
  'post_content' => __( 'Uploaded from ', 'mw-wp-form' ) . $post_type->label,
233
  );
234
+ $attach_id = wp_insert_attachment( $attachment, $filepath, $saved_mail_id );
235
  $attach_data = wp_generate_attachment_metadata( $attach_id, $filepath );
236
  $update_attachment_flg = wp_update_attachment_metadata( $attach_id, $attach_data );
237
  if ( $attach_id ) {
238
  // 代わりにここで attachment_id を保存
239
+ update_post_meta( $saved_mail_id, $key, $attach_id );
240
  // $key が 添付ファイルのキーであるとわかるように隠し設定を保存
241
  $save_attached_key[] = $key;
242
  }
243
  }
244
  if ( $save_attached_key ) {
245
+ update_post_meta( $saved_mail_id, '_' . MWF_Config::UPLOAD_FILE_KEYS, $save_attached_key );
246
  }
247
  }
248
 
249
  /**
250
+ * Return true when correct file type
251
  *
252
+ * @param string $filepath Uploaded file path
253
+ * @param string $filename File name
254
  * @return bool
255
  */
256
  public static function check_file_type( $filepath, $filename = '' ) {
257
+ if ( ! file_exists( $filepath ) ) {
258
+ return false;
259
+ }
260
+
261
+ // File type restricted by WordPress (get_allowed_mime_types)
262
  if ( $filename ) {
263
  $wp_check_filetype = wp_check_filetype( $filename );
264
  } else {
268
  return false;
269
  }
270
 
271
+ if ( version_compare( phpversion(), '5.3.0' ) >= 0 && defined( 'FILEINFO_MIME_TYPE' ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
272
  $finfo = new finfo( FILEINFO_MIME_TYPE );
273
+ if ( false === $finfo ) {
 
274
  return false;
275
  }
276
+
277
+ // For files have multi mime types
278
+ switch ( $wp_check_filetype['ext'] ) {
279
+ case 'avi' :
280
+ $wp_check_filetype['type'] = array(
281
+ 'application/x-troff-msvideo',
282
+ 'video/avi',
283
+ 'video/msvideo',
284
+ 'video/x-msvideo',
285
+ );
286
+ break;
287
+ case 'mp3' :
288
+ $wp_check_filetype['type'] = array(
289
+ 'audio/mpeg3',
290
+ 'audio/x-mpeg3',
291
+ 'video/mpeg',
292
+ 'video/x-mpeg',
293
+ 'audio/mpeg',
294
+ );
295
+ break;
296
+ case 'mpg' :
297
+ $wp_check_filetype['type'] = array(
298
+ 'audio/mpeg',
299
+ 'video/mpeg',
300
+ );
301
+ break;
302
+ case 'docx' :
303
+ $wp_check_filetype['type'] = array(
304
+ $wp_check_filetype['type'],
305
+ 'application/zip',
306
+ 'application/msword',
307
+ );
308
+ break;
309
+ case 'xlsx' :
310
+ $wp_check_filetype['type'] = array(
311
+ $wp_check_filetype['type'],
312
+ 'application/zip',
313
+ 'application/excel',
314
+ 'application/msexcel',
315
+ 'application/vnd.ms-excel',
316
+ );
317
+ break;
318
+ case 'pptx' :
319
+ $wp_check_filetype['type'] = array(
320
+ $wp_check_filetype['type'],
321
+ 'application/zip',
322
+ 'application/mspowerpoint',
323
+ 'application/powerpoint',
324
+ 'application/ppt',
325
+ );
326
+ break;
327
+ }
328
+
329
+ $type = $finfo->file( $filepath );
330
  if ( is_array( $wp_check_filetype['type'] ) ) {
331
+ if ( ! in_array( $type, $wp_check_filetype['type'] ) ) {
332
  return false;
333
  }
334
  } else {
337
  }
338
  }
339
  }
340
+
341
  return true;
342
  }
343
 
344
  /**
345
+ * Return display name of the tracking number
346
  *
347
+ * @param string $post_type Post type of inquiry data
348
  * @return string
349
  */
350
  public static function get_tracking_number_title( $post_type ) {
360
  }
361
 
362
  /**
363
+ * Return form key from inquiry data post type
364
  *
365
+ * @param string $post_type Post type of inquiry data
366
+ * @return string|null Form key
367
  */
368
  public static function contact_data_post_type_to_form_key( $post_type ) {
369
  if ( self::is_contact_data_post_type( $post_type ) ) {
375
  }
376
 
377
  /**
378
+ * Return form key from form ID
379
  *
380
  * @param int $form_id
381
+ * @return string Form key
382
  */
383
  public static function get_form_key_from_form_id( $form_id ) {
384
+ if ( MWF_Functions::is_numeric( $form_id ) ) {
385
+ return MWF_Config::NAME . '-' . $form_id;
386
+ }
387
  }
388
 
389
  /**
390
+ * Return form ID from form key
391
  *
392
  * @param string $form_key
393
+ * @return int Form ID
394
  */
395
  public static function get_form_id_from_form_key( $form_key ) {
396
+ if ( preg_match( '/^' . MWF_Config::NAME . '-(\d+)$/', $form_key, $reg ) ) {
397
+ return $reg[1];
398
+ }
399
  }
400
 
401
  /**
402
+ * Return inquiry data post type from form ID
403
  *
404
  * @param int $form_id
405
+ * @return string Form key
406
  */
407
  public static function get_contact_data_post_type_from_form_id( $form_id ) {
408
+ if ( MWF_Functions::is_numeric( $form_id ) ) {
409
+ $contact_data_post_type = MWF_Config::DBDATA . $form_id;
410
+ return $contact_data_post_type;
411
+ }
412
  }
413
 
414
  /**
415
+ * Whether the inquiry data post type
416
  *
417
  * @param string $post_type
418
  * @return bool
419
  */
420
  public static function is_contact_data_post_type( $post_type ) {
421
+ return (bool) ( preg_match( '/^' . MWF_Config::DBDATA . '\d+$/', $post_type ) );
 
 
 
422
  }
423
 
424
  /**
425
+ * Return converting attached data to appropriate HTML
426
  *
427
  * @param string $value
428
  * @return string
430
  public static function get_multimedia_data( $value ) {
431
  $mimetype = get_post_mime_type( $value );
432
  if ( $mimetype ) {
433
+ // Image
434
  if ( in_array( $mimetype, array( 'image/jpeg', 'image/gif', 'image/png', 'image/bmp' ) ) ) {
435
  $src_thumbnail = wp_get_attachment_image_src( $value, 'thumbnail' );
436
  $src_full = wp_get_attachment_image_src( $value, 'full' );
440
  esc_url( $src_thumbnail[0] )
441
  );
442
  }
443
+ // Other
444
  else {
445
  $src = wp_mime_type_icon( $mimetype );
446
  return sprintf(
450
  );
451
  }
452
  }
453
+ // Attached, but $value is not file ID because changed meta data by hook
454
  else {
455
  return esc_html( $value );
456
  }
457
  }
458
 
459
  /**
460
+ * Return attachment file ID
461
  * 過去バージョンでの不具合でアップロードファイルを示すメタデータが空になっていることがあるのでその場合の代替処理
462
  *
463
  * @param WP_Post $post
466
  */
467
  public static function get_multimedia_id__fallback( $post, $meta_key ) {
468
  $Contact_Data_Setting = new MW_WP_Form_Contact_Data_Setting( $post->ID );
469
+ $index = $Contact_Data_Setting->get_index_of_key_in_upload_file_keys( $meta_key );
470
+
471
+ if ( false === $index ) {
472
+ return;
473
+ }
474
+
475
  $attachments = get_posts( array(
476
  'post_type' => 'attachment',
477
  'post_parent' => $post->ID,
478
  'posts_per_page' => 1,
479
+ 'offset' => $index,
480
  ) );
481
+
482
  if ( isset( $attachments[0] ) ) {
483
  return $attachments[0]->ID;
484
  }
485
  }
486
+
487
+ /**
488
+ * Enqueue MW WP Form assets
489
+ *
490
+ * @param int $form_id
491
+ * @return void
492
+ */
493
+ public static function mwform_enqueue_scripts( $form_id ) {
494
+ $Setting = new MW_WP_Form_Setting( $form_id );
495
+ $form_key = MWF_Functions::get_form_key_from_form_id( $form_id );
496
+ $url = plugins_url( MWF_Config::NAME );
497
+ wp_enqueue_style( MWF_Config::NAME, $url . '/css/style.css' );
498
+
499
+ $style = $Setting->get( 'style' );
500
+ $styles = apply_filters( 'mwform_styles', array() );
501
+ if ( is_array( $styles ) && isset( $styles[ $style ] ) ) {
502
+ $css = $styles[ $style ];
503
+ wp_enqueue_style( MWF_Config::NAME . '_style_' . $form_key, $css );
504
+ }
505
+
506
+ wp_enqueue_script( MWF_Config::NAME, $url . '/js/form.js', array( 'jquery' ), false, true );
507
+ do_action( 'mwform_enqueue_scripts_' . $form_key );
508
+ }
509
+
510
+ /**
511
+ * Generate input field's attribute and attribute value pair
512
+ *
513
+ * @param string $attribute_name
514
+ * @param string $attribute_value
515
+ * @return string
516
+ */
517
+ public static function generate_input_attribute( $attribute_name, $attribute_value ) {
518
+ if ( is_null( $attribute_value ) ) {
519
+ return;
520
+ }
521
+
522
+ return sprintf(
523
+ '%1$s="%2$s"',
524
+ esc_html( $attribute_name ),
525
+ esc_attr( $attribute_value )
526
+ );
527
+ }
528
  }
classes/models/class.abstract-form-field.php DELETED
@@ -1,351 +0,0 @@
1
- <?php
2
- /**
3
- * Name : MW WP Form Abstract Form Field
4
- * Description: フォームフィールドの抽象クラス
5
- * Version : 1.7.6
6
- * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
- * Created : December 14, 2012
9
- * Modified : December 26, 2016
10
- * License : GPLv2 or later
11
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
- */
13
- abstract class MW_WP_Form_Abstract_Form_Field {
14
-
15
- /**
16
- * $shortcode_name
17
- * @var string
18
- */
19
- protected $shortcode_name;
20
-
21
- /**
22
- * $display_name
23
- * @var string
24
- */
25
- protected $display_name;
26
-
27
- /**
28
- * $Form
29
- * @var MW_WP_Form_Form
30
- */
31
- protected $Form;
32
-
33
- /**
34
- * @var MW_WP_Form_Data
35
- */
36
- protected $Data;
37
-
38
- /**
39
- * $defaults
40
- * 属性値等初期値
41
- * @var array
42
- */
43
- protected $defaults = array();
44
-
45
- /**
46
- * $atts
47
- * 属性値
48
- * @var array
49
- */
50
- protected $atts = array();
51
-
52
- /**
53
- * $Error
54
- * エラーオブジェクト
55
- * @var Error
56
- */
57
- protected $Error;
58
-
59
- /**
60
- * $form_key
61
- * フォーム識別子
62
- * @var string
63
- */
64
- protected $form_key;
65
-
66
- /**
67
- * $type
68
- * フォームタグの種類 input|select|button|input_button|error|other
69
- * @var string
70
- */
71
- protected $type = 'other';
72
-
73
- /**
74
- * $qtags
75
- * qtagsの引数
76
- * @var array
77
- */
78
- protected $qtags = array(
79
- 'id' => '',
80
- 'display' => '',
81
- 'arg1' => '',
82
- 'arg2' => '',
83
- );
84
-
85
- /**
86
- * 囲み型ショートコードのコンテンツ
87
- * @var string
88
- */
89
- protected $element_content = null;
90
-
91
- /**
92
- * __construct
93
- */
94
- public function __construct() {
95
- $this->_set_names();
96
- $this->defaults = $this->set_defaults();
97
- $this->_add_mwform_tag_generator();
98
- add_action( 'mwform_add_shortcode', array( $this, 'add_shortcode' ), 10, 5 );
99
- add_filter( 'mwform_form_fields' , array( $this, 'mwform_form_fields' ) );
100
- }
101
-
102
- /**
103
- * set_names
104
- * shortcode_name、display_nameを定義。各子クラスで上書きする。
105
- * @return array shortcode_name, display_name
106
- */
107
- protected function set_names() {
108
- return array(
109
- 'shortcode_name' => $this->shortcode_name,
110
- 'display_name' => $this->display_name,
111
- );
112
- }
113
- private function _set_names() {
114
- $args = $this->set_names();
115
- $this->shortcode_name = $args['shortcode_name'];
116
- $this->display_name = $args['display_name'];
117
- }
118
-
119
- /**
120
- * get_error
121
- * @param string $key name属性
122
- * @return string エラーHTML
123
- */
124
- protected function get_error( $key ) {
125
- $_ret = '';
126
- if ( is_array( $this->Error->get_error( $key ) ) ) {
127
- $start_tag = '<span class="error">';
128
- $end_tag = '</span>';
129
- foreach ( $this->Error->get_error( $key ) as $rule => $error ) {
130
- $rule = strtolower( $rule );
131
- $error = apply_filters(
132
- 'mwform_error_message_' . $this->form_key,
133
- $error,
134
- $key,
135
- $rule
136
- );
137
- $error_html = apply_filters( 'mwform_error_message_html',
138
- $start_tag . esc_html( $error ) . $end_tag,
139
- $error,
140
- $start_tag,
141
- $end_tag,
142
- $this->form_key,
143
- $key,
144
- $rule
145
- );
146
- $_ret .= $error_html;
147
- }
148
- }
149
- if ( $_ret ) {
150
- return apply_filters( 'mwform_error_message_wrapper', $_ret, $this->form_key );
151
- }
152
- }
153
-
154
- /**
155
- * set_defaults
156
- * $this->defaultsを設定し返す
157
- * @return array defaults
158
- */
159
- abstract protected function set_defaults();
160
-
161
- /**
162
- * input_page
163
- * 入力ページでのフォーム項目を返す
164
- * @param array $atts
165
- * @param string $element_content
166
- * @return string HTML
167
- */
168
- abstract protected function input_page();
169
- public function _input_page( $atts, $element_content = null ) {
170
- $this->element_content = $element_content;
171
- if ( array_key_exists( 'value', $this->defaults ) && isset( $atts['name'] ) && !isset( $atts['value'] ) ) {
172
- $atts['value'] = apply_filters(
173
- 'mwform_value_' . $this->form_key,
174
- $this->defaults['value'],
175
- $atts['name']
176
- );
177
- }
178
- $this->atts = shortcode_atts( $this->defaults, $atts );
179
- return $this->input_page();
180
- }
181
-
182
- /**
183
- * confirm_page
184
- * 確認ページでのフォーム項目を返す
185
- * @param array $atts
186
- * @param string $element_content
187
- * @return string HTML
188
- */
189
- abstract protected function confirm_page();
190
- public function _confirm_page( $atts, $element_content = null ) {
191
- $this->element_content = $element_content;
192
- $this->atts = shortcode_atts( $this->defaults, $atts );
193
- return $this->confirm_page();
194
- }
195
-
196
- /**
197
- * add_shortcode
198
- * フォーム項目を返す
199
- * @param MW_WP_Form_Form $Form
200
- * @param string $view_flg
201
- * @param MW_WP_Form_Error $Error
202
- * @param string $form_key
203
- */
204
- public function add_shortcode( MW_WP_Form_Form $Form, $view_flg, MW_WP_Form_Error $Error, $form_key ) {
205
- if ( !empty( $this->shortcode_name ) ) {
206
- $this->Form = $Form;
207
- $this->Error = $Error;
208
- $this->form_key = $form_key;
209
- $this->Data = MW_WP_Form_Data::getInstance();
210
- switch( $view_flg ) {
211
- case 'input' :
212
- add_shortcode( $this->shortcode_name, array( $this, '_input_page' ) );
213
- break;
214
- case 'confirm' :
215
- add_shortcode( $this->shortcode_name, array( $this, '_confirm_page' ) );
216
- break;
217
- case 'complete' :
218
- break;
219
- default :
220
- exit( '$view_flg is not right value. $view_flg is ' . $view_flg . ' now.' );
221
- }
222
- }
223
- }
224
-
225
- /**
226
- * 選択肢の配列を返す(:が含まれている場合は分割して前をキーに、後ろを表示名にする)
227
- *
228
- * @param string $_children
229
- * @return array $children
230
- */
231
- public function get_children( $_children ) {
232
- $children = array();
233
- if ( !empty( $_children ) && !is_array( $_children ) ) {
234
- $_children = explode( ',', $_children );
235
- }
236
- if ( is_array( $_children ) ) {
237
- foreach ( $_children as $child ) {
238
- $temp_replacement = '@-[_-_]-@';
239
- if ( preg_match( '/(^:[^:])|([^:]:[^:])/', $child ) ) {
240
- $child = str_replace( '::', $temp_replacement, $child );
241
- $child = explode( ':', $child, 2 );
242
- } else {
243
- $child = str_replace( '::', $temp_replacement, $child );
244
- $child = array( $child );
245
- }
246
- foreach ( $child as $child_key => $child_value ) {
247
- $child[$child_key] = str_replace( $temp_replacement, ':', $child_value );
248
- }
249
- if ( count( $child ) === 1 ) {
250
- $children[$child[0]] = $child[0];
251
- } else {
252
- $children[$child[0]] = $child[1];
253
- }
254
- }
255
- }
256
- if ( $this->form_key ) {
257
- $children = apply_filters( 'mwform_choices_' . $this->form_key, $children, $this->atts );
258
- }
259
- return $children;
260
- }
261
-
262
- /**
263
- * _add_mwform_tag_generator
264
- * フォームタグジェネレータのタグ選択肢とダイアログを設定
265
- */
266
- protected function _add_mwform_tag_generator() {
267
- add_action( 'mwform_tag_generator_dialog', array( $this, 'add_mwform_tag_generator' ) );
268
- if ( $this->type !== 'other' ) {
269
- $tag = 'mwform_tag_generator_' . $this->type . '_option';
270
- } else {
271
- $tag = 'mwform_tag_generator_option';
272
- }
273
- add_action( $tag, array( $this, 'mwform_tag_generator_option' ) );
274
- }
275
-
276
- /**
277
- * add_mwform_tag_generator
278
- * タグジェネレータのダイアログ枠を出力
279
- */
280
- public function add_mwform_tag_generator() {
281
- ?>
282
- <div id="dialog-<?php echo esc_attr( $this->shortcode_name ); ?>" class="mwform-dialog" title="<?php echo esc_attr( $this->shortcode_name ); ?>">
283
- <div class="form">
284
- <?php $this->mwform_tag_generator_dialog( $this->defaults ); ?>
285
- </div>
286
- </div>
287
- <?php
288
- }
289
-
290
- /**
291
- * add_mwform_tag_generator
292
- * タグジェネレータのダイアログを出力。各フォーム項目クラスでオーバーライド
293
- */
294
- public function mwform_tag_generator_dialog( array $options = array() ) {}
295
-
296
- /**
297
- * mwform_tag_generator_option
298
- * フォームタグ挿入ボタンのセレクトボックスに選択項目を追加
299
- */
300
- public function mwform_tag_generator_option() {
301
- $display_name = $this->qtags['display'];
302
- if ( $this->display_name ) {
303
- $display_name = $this->display_name;
304
- }
305
- ?>
306
- <option value="<?php echo esc_attr( $this->shortcode_name ); ?>"><?php echo esc_html( $display_name ); ?></option>
307
- <?php
308
- }
309
-
310
- /**
311
- * mwform_form_fields
312
- * @param array $form_fields MW_WP_Form_Abstract_Form_Field を継承したオブジェクトの一覧
313
- * @return array $form_fields
314
- */
315
- public function mwform_form_fields( array $form_fields ) {
316
- $form_fields = array_merge( $form_fields, array( $this->shortcode_name => $this ) );
317
- return $form_fields;
318
- }
319
-
320
- /**
321
- * get_display_name
322
- * @return string 表示名
323
- */
324
- public function get_display_name() {
325
- return $this->display_name;
326
- }
327
-
328
- /**
329
- * get_shortcode_name
330
- * @return string ショートコード名
331
- */
332
- public function get_shortcode_name() {
333
- return $this->shortcode_name;
334
- }
335
-
336
- /**
337
- * get_value_for_generator
338
- * MW WP Fomr Generator 用
339
- */
340
- public function get_value_for_generator( $key, $options ) {
341
- $attributes = array_keys( $this->defaults );
342
- $attributes = array_flip( $attributes );
343
- if ( isset( $attributes[$key] ) ) {
344
- if ( isset( $options[$key] ) ) {
345
- return $options[$key];
346
- } else {
347
- return '';
348
- }
349
- }
350
- }
351
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/models/class.abstract-validation-rule.php DELETED
@@ -1,69 +0,0 @@
1
- <?php
2
- /**
3
- * Name : MW WP Form Abstract Validation Rule
4
- * Description: バリデーションルールの抽象クラス
5
- * Version : 1.1.1
6
- * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
- * Created : July 19, 2014
9
- * Modified : March 26, 2015
10
- * License : GPLv2 or later
11
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
- */
13
- abstract class MW_WP_Form_Abstract_Validation_Rule {
14
-
15
- /**
16
- * バリデーションルール名を指定
17
- * @var string
18
- */
19
- protected $name;
20
-
21
- /**
22
- * @var MW_WP_Form_Data
23
- */
24
- protected $Data;
25
-
26
- /**
27
- * __construct
28
- */
29
- public function __construct() {
30
- if ( !$this->getName() ) {
31
- exit( 'MW_WP_Form_Abstract_Validation_Rule::$name must override.' );
32
- }
33
- }
34
-
35
- /**
36
- * MW_WP_Form_Data を注入
37
- *
38
- * @param MW_WP_Form_Data $Data
39
- */
40
- public function set_Data( MW_WP_Form_Data $Data ) {
41
- $this->Data = $Data;
42
- }
43
-
44
- /**
45
- * バリデーションルール名を返す
46
- *
47
- * @return string $this->name バリデーションルール名
48
- */
49
- public function getName() {
50
- return $this->name;
51
- }
52
-
53
- /**
54
- * バリデーションチェック
55
- *
56
- * @param string $key name属性
57
- * @param array $option
58
- * @return string エラーメッセージ
59
- */
60
- abstract public function rule( $key, array $options = array() );
61
-
62
- /**
63
- * 設定パネルに追加
64
- *
65
- * @param numeric $key バリデーションルールセットの識別番号
66
- * @param array $value バリデーションルールセットの内容
67
- */
68
- abstract public function admin( $key, $value );
69
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/models/class.admin.php CHANGED
@@ -1,140 +1,42 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Admin
4
- * Description: 管理画面クラス
5
- * Version : 2.1.1
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : February 21, 2013
9
- * Modified : March 25, 2017
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Admin {
14
 
15
  /**
16
- * save_post
17
- * @param int $post_id
18
- */
19
- public function save_post( $post_id ) {
20
- if ( !( isset( $_POST['post_type'] ) && $_POST['post_type'] === MWF_Config::NAME ) )
21
- return $post_id;
22
- if ( !isset( $_POST[MWF_Config::NAME . '_nonce'] ) )
23
- return $post_id;
24
- if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
25
- return $post_id;
26
- if ( !wp_verify_nonce( $_POST[MWF_Config::NAME . '_nonce'], MWF_Config::NAME ) )
27
- return $post_id;
28
- if ( !current_user_can( MWF_Config::CAPABILITY ) )
29
- return $post_id;
30
-
31
- $data = $_POST[MWF_Config::NAME];
32
-
33
- $triminglists = array(
34
- 'mail_from',
35
- 'mail_return_path',
36
- 'mail_to',
37
- 'mail_cc',
38
- 'mail_bcc',
39
- 'admin_mail_from',
40
- );
41
- foreach ( $triminglists as $name ) {
42
- if ( function_exists( 'mb_convert_kana' ) ) {
43
- $data[$name] = trim( mb_convert_kana( $data[$name], 's', get_option( 'blog_charset' ) ) );
44
- } else {
45
- $data[$name] = trim( $data[$name] );
46
- }
47
- }
48
-
49
- if ( !empty( $data['validation'] ) && is_array( $data['validation'] ) ) {
50
- $validation = array();
51
- foreach ( $data['validation'] as $_validation ) {
52
- if ( empty( $_validation['target'] ) ) continue;
53
- foreach ( $_validation as $key => $value ) {
54
- // between min, max
55
- if ( $key == 'between' ) {
56
- if ( !MWF_Functions::is_numeric( $value['min'] ) ) {
57
- unset( $_validation[$key]['min'] );
58
- }
59
- if ( !MWF_Functions::is_numeric( $value['max'] ) ) {
60
- unset( $_validation[$key]['max'] );
61
- }
62
- }
63
- // minlength min
64
- elseif ( $key == 'minlength' && !MWF_Functions::is_numeric( $value['min'] ) ) {
65
- unset( $_validation[$key] );
66
- }
67
- // fileType types
68
- elseif ( $key == 'fileType' && isset( $value['types'] ) && !preg_match( '/^[0-9A-Za-z,]+$/', $value['types'] ) ) {
69
- unset( $_validation[$key] );
70
- }
71
- // fileSize bytes
72
- elseif ( $key == 'fileSize' && !MWF_Functions::is_numeric( $value['bytes'] ) ) {
73
- unset( $_validation[$key] );
74
- }
75
-
76
- // 要素が空のときは削除
77
- // 単一項目のとき
78
- if ( empty( $value ) ) {
79
- unset( $_validation[$key] );
80
- }
81
- // 配列のとき
82
- elseif ( is_array( $value ) && !array_diff( $value, array( '' ) ) ) {
83
- unset( $_validation[$key] );
84
- }
85
- }
86
- $validation[] = $_validation;
87
- }
88
- $data['validation'] = $validation;
89
- }
90
-
91
- // チェックボックスの項目は、未設定のときはデータが来ないのでここで処理する
92
- if ( empty( $data['querystring'] ) ) {
93
- $data['querystring'] = false;
94
- }
95
- if ( empty( $data['usedb'] ) ) {
96
- $data['usedb'] = false;
97
- }
98
- if ( empty( $data['scroll'] ) ) {
99
- $data['scroll'] = false;
100
- }
101
-
102
- $Setting = new MW_WP_Form_Setting( $post_id );
103
- $Setting->sets( $data );
104
-
105
- if ( isset( $_POST[MWF_Config::TRACKINGNUMBER] ) ) {
106
- $tracking_number = $_POST[MWF_Config::TRACKINGNUMBER];
107
- $Setting->update_tracking_number( $tracking_number );
108
- }
109
-
110
- $Setting->save();
111
- }
112
-
113
- /**
114
- * get_forms
115
- * @return array フォーム(WP_Post)の配列
116
  */
117
  public function get_forms() {
118
- $forms = get_posts( array(
119
  'post_type' => MWF_Config::NAME,
120
  'posts_per_page' => -1,
121
  ) );
122
- return $forms;
123
  }
124
 
125
  /**
126
- * get_forms_using_database
127
- * @return array データベースに保存が有効なフォーム(WP_Post)の配列
 
128
  */
129
  public function get_forms_using_database() {
130
  $forms_using_database = array();
131
  $forms = $this->get_forms();
132
  foreach ( $forms as $form ) {
133
  $Setting = new MW_WP_Form_Setting( $form->ID );
134
- if ( !$Setting->get( 'usedb' ) ) {
135
  continue;
136
  }
137
- $forms_using_database[$form->ID] = $form;
138
  }
139
  return $forms_using_database;
140
  }
1
  <?php
2
  /**
3
  * Name : MW WP Form Admin
4
+ * Version : 3.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : February 21, 2013
8
+ * Modified : June 1, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Admin {
13
 
14
  /**
15
+ * Return all forms
16
+ *
17
+ * @return array Array of WP_Post
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  */
19
  public function get_forms() {
20
+ return get_posts( array(
21
  'post_type' => MWF_Config::NAME,
22
  'posts_per_page' => -1,
23
  ) );
 
24
  }
25
 
26
  /**
27
+ * Return forms that using database
28
+ *
29
+ * @return array Array of WP_Post
30
  */
31
  public function get_forms_using_database() {
32
  $forms_using_database = array();
33
  $forms = $this->get_forms();
34
  foreach ( $forms as $form ) {
35
  $Setting = new MW_WP_Form_Setting( $form->ID );
36
+ if ( ! $Setting->get( 'usedb' ) ) {
37
  continue;
38
  }
39
+ $forms_using_database[ $form->ID ] = $form;
40
  }
41
  return $forms_using_database;
42
  }
classes/models/class.akismet.php CHANGED
@@ -1,43 +1,46 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Akismet
4
- * Description: Akismetクラス
5
- * Version : 1.0.1
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : April 30, 2014
9
- * Modified : July 24, 2014
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Akismet {
14
 
15
  /**
16
- * is_enable
17
- * @return string APIキー
 
18
  */
19
- private function is_enable() {
20
  if ( is_callable( array( 'Akismet', 'get_api_key' ) ) ) {
21
  return Akismet::get_api_key();
22
  }
 
23
  if ( function_exists( 'akismet_get_key' ) ) {
24
  return akismet_get_key();
25
  }
 
26
  return false;
27
  }
28
 
29
  /**
30
- * check
 
31
  * @param string $akismet_author
32
  * @param string $akismet_author_email
33
  * @param string $akismet_author_url
34
  * @param MW_WP_Form_Data $Data
35
  * @return bool
36
  */
37
- public function check( $akismet_author, $akismet_author_email, $akismet_author_url, $Data ) {
38
  global $akismet_api_host, $akismet_api_port;
39
 
40
- if ( !$this->is_enable() ) {
41
  return false;
42
  }
43
 
@@ -61,45 +64,51 @@ class MW_WP_Form_Akismet {
61
  $doAkismet = true;
62
  }
63
 
64
- if ( $doAkismet ) {
65
- $content = '';
66
- foreach ( $Data->gets() as $key => $value ) {
67
- $value = $Data->get( $key );
68
- $content .= $value . "\n\n";
69
- }
70
- $permalink = get_permalink();
71
- $akismet = array();
72
- $akismet['blog'] = home_url();
73
- $akismet['blog_lang'] = get_locale();
74
- $akismet['blog_charset'] = get_option( 'blog_charset' );
75
- $akismet['user_ip'] = preg_replace( '/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR'] );
76
- $akismet['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
77
- $akismet['referrer'] = $_SERVER['HTTP_REFERER'];
78
- $akismet['comment_type'] = MWF_Config::NAME;
79
- if ( $permalink ) $akismet['permalink'] = $permalink;
80
- if ( $author ) $akismet['comment_author'] = $author;
81
- if ( $author_email ) $akismet['comment_author_email'] = $author_email;
82
- if ( $author_url ) $akismet['comment_author_url'] = $author_url;
83
- if ( $content ) $akismet['comment_content'] = $content;
84
-
85
- foreach ( $_SERVER as $key => $value ) {
86
- if ( !in_array( $key, array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' ) ) ) {
87
- $akismet[$key] = $value;
88
- }
89
- }
90
 
91
- $query_string = http_build_query( $akismet, null, '&' );
92
- if ( is_callable( array( 'Akismet', 'http_post' ) ) ) {
93
- $response = Akismet::http_post( $query_string, 'comment-check' );
94
- } else {
95
- $response = akismet_http_post(
96
- $query_string,
97
- $akismet_api_host, '/1.1/comment-check',
98
- $akismet_api_port
99
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  }
101
- $response = apply_filters( 'mwform_akismet_responce', $response );
102
- return ( $response[1] == 'true' ) ? true : false;
 
 
 
 
 
 
 
 
 
 
103
  }
 
 
104
  }
105
  }
1
  <?php
2
  /**
3
  * Name : MW WP Form Akismet
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : April 30, 2014
8
+ * Modified : June 1, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Akismet {
13
 
14
  /**
15
+ * Return akismet api key when akismet is active
16
+ *
17
+ * @return string API Key
18
  */
19
+ private function _is_enable() {
20
  if ( is_callable( array( 'Akismet', 'get_api_key' ) ) ) {
21
  return Akismet::get_api_key();
22
  }
23
+
24
  if ( function_exists( 'akismet_get_key' ) ) {
25
  return akismet_get_key();
26
  }
27
+
28
  return false;
29
  }
30
 
31
  /**
32
+ * Return true when through akismet check
33
+ *
34
  * @param string $akismet_author
35
  * @param string $akismet_author_email
36
  * @param string $akismet_author_url
37
  * @param MW_WP_Form_Data $Data
38
  * @return bool
39
  */
40
+ public function is_valid( $akismet_author, $akismet_author_email, $akismet_author_url, $Data ) {
41
  global $akismet_api_host, $akismet_api_port;
42
 
43
+ if ( ! $this->_is_enable() ) {
44
  return false;
45
  }
46
 
64
  $doAkismet = true;
65
  }
66
 
67
+ if ( ! $doAkismet ) {
68
+ return false;
69
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
 
71
+ $content = '';
72
+ foreach ( $Data->gets() as $key => $value ) {
73
+ $value = $Data->get( $key );
74
+ $content .= $value . "\n\n";
75
+ }
76
+
77
+ $permalink = get_permalink();
78
+ $akismet = array();
79
+
80
+ $akismet['blog'] = home_url();
81
+ $akismet['blog_lang'] = get_locale();
82
+ $akismet['blog_charset'] = get_option( 'blog_charset' );
83
+ $akismet['user_ip'] = preg_replace( '/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR'] );
84
+ $akismet['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
85
+ $akismet['referrer'] = $_SERVER['HTTP_REFERER'];
86
+ $akismet['comment_type'] = MWF_Config::NAME;
87
+
88
+ if ( $permalink ) $akismet['permalink'] = $permalink;
89
+ if ( $author ) $akismet['comment_author'] = $author;
90
+ if ( $author_email ) $akismet['comment_author_email'] = $author_email;
91
+ if ( $author_url ) $akismet['comment_author_url'] = $author_url;
92
+ if ( $content ) $akismet['comment_content'] = $content;
93
+
94
+ foreach ( $_SERVER as $key => $value ) {
95
+ if ( in_array( $key, array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' ) ) ) {
96
+ continue;
97
  }
98
+ $akismet[ $key ] = $value;
99
+ }
100
+
101
+ $query_string = http_build_query( $akismet, null, '&' );
102
+ if ( is_callable( array( 'Akismet', 'http_post' ) ) ) {
103
+ $response = Akismet::http_post( $query_string, 'comment-check' );
104
+ } else {
105
+ $response = akismet_http_post(
106
+ $query_string,
107
+ $akismet_api_host, '/1.1/comment-check',
108
+ $akismet_api_port
109
+ );
110
  }
111
+ $response = apply_filters( 'mwform_akismet_responce', $response );
112
+ return ( 'true' === $response[1] ) ? true : false;
113
  }
114
  }
classes/models/class.contact-data-setting.php CHANGED
@@ -1,160 +1,167 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Contact Data Setting
4
- * Description: 管理画面クラス
5
- * Version : 1.0.4
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : January 1, 2015
9
- * Modified : February 2, 2017
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Contact_Data_Setting {
14
 
15
  /**
16
- * 問い合わせデータを保存しているフォームの投稿タイプの一覧
17
- * @var array
18
- */
19
- protected static $contact_data_post_types;
20
-
21
- /**
22
- * 保存された問い合わせデータの Post ID
23
  * @var int
24
  */
25
  protected $post_id;
26
 
27
  /**
28
- * 各フォーム項目から送信された値を格納
29
  * @var array
30
  */
31
  protected $options = array();
32
 
33
  /**
34
- * 問い合わせデータのステータス
35
  * @var string not-supported|reservation|supported
36
  */
37
  protected $response_status = 'not-supported';
38
 
39
  /**
40
- * メモ
41
  * @var string
42
  */
43
  protected $memo = '';
44
 
45
  /**
46
- * 対応状況種別の一覧
47
- * @var array
48
- */
49
- protected $response_statuses = array();
50
-
51
- /**
52
- * __construct
53
- *
54
  * @param int $post_id
55
  */
56
  public function __construct( $post_id ) {
57
- if ( MWF_Functions::is_contact_data_post_type( get_post_type( $post_id ) ) ) {
58
- $this->post_id = $post_id;
59
- $this->response_statuses = array(
60
- 'not-supported' => esc_html__( 'Not supported', 'mw-wp-form' ),
61
- 'reservation' => esc_html__( 'Reservation', 'mw-wp-form' ),
62
- 'supported' => esc_html__( 'Supported', 'mw-wp-form' ),
63
- );
64
-
65
- $post_custom = get_post_custom( $post_id );
66
- $post_meta = array();
67
- foreach ( $post_custom as $key => $value ) {
68
- if ( preg_match( '/^_/', $key ) ) {
69
- continue;
70
- }
71
- $post_meta[$key] = $value[0];
72
- }
73
 
74
- $permit_values = get_post_meta( $this->post_id, MWF_config::CONTACT_DATA_NAME, true );
75
- if ( !$permit_values ) {
76
- $permit_values = array();
77
- }
78
 
79
- $values = array_merge( $post_meta, $permit_values );
80
- if ( is_array( $values ) ) {
81
- $this->sets( $values );
 
 
82
  }
 
 
 
 
 
 
 
 
 
 
 
83
  }
84
  }
85
 
86
  /**
87
- * 問い合わせステータスの種類を取得
88
  *
89
  * @return array
90
  */
91
  public function get_response_statuses() {
92
  $contact_data_post_type = get_post_type( $this->post_id );
93
- return apply_filters( 'mwform_response_statuses_' . $contact_data_post_type, $this->response_statuses );
 
 
 
 
 
 
 
94
  }
95
 
96
  /**
97
- * 更新可能なキーを返す
98
  *
99
  * @return array
100
  */
101
  public function get_permit_keys() {
102
- return array( 'response_status', 'memo' );
 
 
 
103
  }
104
 
105
  /**
106
- * 全てのメタデータを取得
 
 
107
  */
108
  public function gets() {
109
  $options = $this->options;
110
  $permit_keys = $this->get_permit_keys();
111
- foreach ( $permit_keys as $value ) {
112
- $options[$value] = $this->$value;
113
  }
114
  return $options;
115
  }
116
 
117
  /**
118
- * メタデータの取得
119
  *
120
  * @param string $key
121
  * @return mixed|null
122
  */
123
  public function get( $key ) {
124
- $permit_keys = $this->get_permit_keys();
125
- if ( in_array( $key, $permit_keys ) ) {
126
- $value = $this->$key;
127
- if ( $key === 'response_status' ) {
128
- if ( isset( $this->response_statuses[$value] ) ) {
129
- return $value;
 
 
 
130
  }
131
- return $value;
132
  }
133
- return $value;
134
- } elseif ( isset( $this->options[$key] ) ) {
135
- return $this->options[$key];
136
  }
137
  }
138
 
139
  /**
140
- * 属性をセット
141
  *
142
  * @param string $key
143
- * @param mixed $value
 
144
  */
145
  public function set( $key, $value ) {
146
  $permit_keys = $this->get_permit_keys();
147
- if ( in_array( $key, $permit_keys ) ) {
 
 
 
 
 
148
  $this->$key = $value;
149
- } else {
150
- $this->options[$key] = $value;
 
 
 
 
151
  }
152
  }
153
 
154
  /**
155
- * 属性をセット
156
  *
157
  * @param array $values
 
158
  */
159
  public function sets( array $values ) {
160
  foreach ( $values as $key => $value ) {
@@ -163,39 +170,35 @@ class MW_WP_Form_Contact_Data_Setting {
163
  }
164
 
165
  /**
166
- * 保存
167
  *
168
- * @param bool $is_save_no_permit_value permit_keys以外のメタデータも更新する
169
  */
170
- public function save( $is_save_no_permit_value = false ) {
171
  $permit_keys = $this->get_permit_keys();
172
  $permit_values = array();
173
  foreach ( $permit_keys as $key ) {
174
- $permit_values[$key] = $this->$key;
175
- }
176
- update_post_meta( $this->post_id, MWF_config::CONTACT_DATA_NAME, $permit_values );
177
-
178
- $contact_data_post_type = get_post_type( $this->post_id );
179
- do_action( 'mwform_contact_data_save-' . $contact_data_post_type, $this->post_id );
180
-
181
- if ( $is_save_no_permit_value !== true ) {
182
- return;
183
  }
 
184
 
185
  foreach ( $this->options as $key => $value ) {
 
 
 
186
  update_post_meta( $this->post_id, $key, $value );
187
  }
 
 
 
188
  }
189
 
190
  /**
191
- * データベースに保存に設定されているフォーム(投稿)を取得
192
  *
193
  * @return array
194
  */
195
- public static function get_posts() {
196
- if ( self::$contact_data_post_types !== null ) {
197
- return self::$contact_data_post_types;
198
- }
199
  $contact_data_post_types = array();
200
  $Admin = new MW_WP_Form_Admin();
201
  $forms = $Admin->get_forms_using_database();
@@ -203,46 +206,52 @@ class MW_WP_Form_Contact_Data_Setting {
203
  $post_type = MWF_Functions::get_contact_data_post_type_from_form_id( $form->ID );
204
  $contact_data_post_types[] = $post_type;
205
  }
 
206
  $raw_post_types = $contact_data_post_types;
207
  $new_post_types = array();
208
  $contact_data_post_types = apply_filters(
209
  'mwform_contact_data_post_types',
210
  $contact_data_post_types
211
  );
 
212
  // もともとの配列に含まれていない値は削除する
213
  foreach ( $contact_data_post_types as $post_type ) {
214
  if ( in_array( $post_type, $raw_post_types ) ) {
215
  $new_post_types[] = $post_type;
216
  }
217
  }
218
- self::$contact_data_post_types = $new_post_types;
219
- return self::$contact_data_post_types;
 
 
 
 
 
 
 
 
 
220
  }
221
 
222
  /**
223
- * $meta_key $post upload_file_key かどうか
224
  *
225
- * @param WP_Post $post
226
  * @param string $meta_key
227
  * @return bool
228
  */
229
- public function is_upload_file_key( $post, $meta_key ) {
230
- $upload_file_keys = $this->get_upload_file_keys( $post );
231
- if ( is_array( $upload_file_keys ) && in_array( $meta_key, $upload_file_keys ) ) {
232
- return true;
233
- }
234
- return false;
235
  }
236
 
237
  /**
238
- * $meta_key upload_file_key に含まれている場合にキーを返す
239
  *
240
- * @param WP_Post $post
241
  * @param string $meta_key
242
  * @return int|false
243
  */
244
- public function get_key_in_upload_file_keys( $post, $meta_key ) {
245
- $upload_file_keys = $this->get_upload_file_keys( $post );
246
  if ( is_array( $upload_file_keys ) ) {
247
  return array_search( $meta_key, $upload_file_keys );
248
  }
@@ -250,18 +259,17 @@ class MW_WP_Form_Contact_Data_Setting {
250
  }
251
 
252
  /**
253
- * その投稿がもつ upload_file_key を取得
254
  *
255
- * @param WP_Post $post
256
  * @return array $upload_file_keys
257
  */
258
- protected function get_upload_file_keys( $post ) {
259
  // 前のバージョンでは MWF_Config::UPLOAD_FILE_KEYS を配列で保持していなかったので分岐させる
260
- $_upload_file_keys = get_post_meta( $post->ID, '_' . MWF_Config::UPLOAD_FILE_KEYS, true );
261
  if ( is_array( $_upload_file_keys ) ) {
262
  $upload_file_keys = $_upload_file_keys;
263
  } else {
264
- $upload_file_keys = get_post_custom_values( '_' . MWF_Config::UPLOAD_FILE_KEYS, $post->ID );
265
  }
266
  return $upload_file_keys;
267
  }
1
  <?php
2
  /**
3
  * Name : MW WP Form Contact Data Setting
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : January 1, 2015
8
+ * Modified : June 1, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Contact_Data_Setting {
13
 
14
  /**
15
+ * Inquiry data ID
 
 
 
 
 
 
16
  * @var int
17
  */
18
  protected $post_id;
19
 
20
  /**
21
+ * Array of posted data
22
  * @var array
23
  */
24
  protected $options = array();
25
 
26
  /**
27
+ * Status of inquiry data
28
  * @var string not-supported|reservation|supported
29
  */
30
  protected $response_status = 'not-supported';
31
 
32
  /**
33
+ * Memo
34
  * @var string
35
  */
36
  protected $memo = '';
37
 
38
  /**
 
 
 
 
 
 
 
 
39
  * @param int $post_id
40
  */
41
  public function __construct( $post_id ) {
42
+ if ( ! MWF_Functions::is_contact_data_post_type( get_post_type( $post_id ) ) ) {
43
+ return;
44
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
45
 
46
+ $this->post_id = $post_id;
 
 
 
47
 
48
+ $post_custom = get_post_custom( $post_id );
49
+ $post_meta = array();
50
+ foreach ( $post_custom as $key => $value ) {
51
+ if ( preg_match( '/^_/', $key ) ) {
52
+ continue;
53
  }
54
+ $post_meta[ $key ] = $value[0];
55
+ }
56
+
57
+ $permit_values = get_post_meta( $this->post_id, MWF_config::INQUIRY_DATA_NAME, true );
58
+ if ( ! $permit_values ) {
59
+ $permit_values = array();
60
+ }
61
+
62
+ $values = array_merge( $post_meta, $permit_values );
63
+ if ( is_array( $values ) ) {
64
+ $this->sets( $values );
65
  }
66
  }
67
 
68
  /**
69
+ * Return statuses
70
  *
71
  * @return array
72
  */
73
  public function get_response_statuses() {
74
  $contact_data_post_type = get_post_type( $this->post_id );
75
+
76
+ $response_statuses = array(
77
+ 'not-supported' => esc_html__( 'Not supported', 'mw-wp-form' ),
78
+ 'reservation' => esc_html__( 'Reservation', 'mw-wp-form' ),
79
+ 'supported' => esc_html__( 'Supported', 'mw-wp-form' ),
80
+ );
81
+
82
+ return apply_filters( 'mwform_response_statuses_' . $contact_data_post_type, $response_statuses );
83
  }
84
 
85
  /**
86
+ * Return updatable keys
87
  *
88
  * @return array
89
  */
90
  public function get_permit_keys() {
91
+ $vars = get_object_vars( $this );
92
+ unset( $vars[ 'post_id' ] );
93
+ unset( $vars[ 'options' ] );
94
+ return array_keys( $vars );
95
  }
96
 
97
  /**
98
+ * Return all data
99
+ *
100
+ * @return array
101
  */
102
  public function gets() {
103
  $options = $this->options;
104
  $permit_keys = $this->get_permit_keys();
105
+ foreach ( $permit_keys as $permit_key ) {
106
+ $options[ $permit_key ] = $this->$permit_key;
107
  }
108
  return $options;
109
  }
110
 
111
  /**
112
+ * Return specify data
113
  *
114
  * @param string $key
115
  * @return mixed|null
116
  */
117
  public function get( $key ) {
118
+ $vars = get_object_vars( $this );
119
+ unset( $vars['options'] );
120
+ $attributes = array_keys( $vars );
121
+
122
+ if ( in_array( $key, $attributes ) ) {
123
+ if ( 'response_status' === $key ) {
124
+ $response_statuses = $this->get_response_statuses();
125
+ if ( isset( $response_statuses[ $this->response_status ] ) ) {
126
+ return $this->response_status;
127
  }
 
128
  }
129
+ return $this->$key;
130
+ } elseif ( isset( $this->options[ $key ] ) ) {
131
+ return $this->options[ $key ];
132
  }
133
  }
134
 
135
  /**
136
+ * Set a option
137
  *
138
  * @param string $key
139
+ * @param mixed
140
+ * @return void
141
  */
142
  public function set( $key, $value ) {
143
  $permit_keys = $this->get_permit_keys();
144
+ if ( ! in_array( $key, $permit_keys ) ) {
145
+ $this->options[ $key ] = $value;
146
+ return;
147
+ }
148
+
149
+ if ( 'response_status' !== $key ) {
150
  $this->$key = $value;
151
+ return;
152
+ }
153
+
154
+ if ( array_key_exists( $value, $this->get_response_statuses() ) ) {
155
+ $this->$key = $value;
156
+ return;
157
  }
158
  }
159
 
160
  /**
161
+ * Set options
162
  *
163
  * @param array $values
164
+ * @return void
165
  */
166
  public function sets( array $values ) {
167
  foreach ( $values as $key => $value ) {
170
  }
171
 
172
  /**
173
+ * Save values of permit keys and options
174
  *
175
+ * @return void
176
  */
177
+ public function save() {
178
  $permit_keys = $this->get_permit_keys();
179
  $permit_values = array();
180
  foreach ( $permit_keys as $key ) {
181
+ $permit_values[ $key ] = $this->$key;
 
 
 
 
 
 
 
 
182
  }
183
+ update_post_meta( $this->post_id, MWF_config::INQUIRY_DATA_NAME, $permit_values );
184
 
185
  foreach ( $this->options as $key => $value ) {
186
+ if ( is_null( $value ) ) {
187
+ $value = '';
188
+ }
189
  update_post_meta( $this->post_id, $key, $value );
190
  }
191
+
192
+ $contact_data_post_type = get_post_type( $this->post_id );
193
+ do_action( 'mwform_contact_data_save-' . $contact_data_post_type, $this->post_id );
194
  }
195
 
196
  /**
197
+ * Return post types of inquiry data
198
  *
199
  * @return array
200
  */
201
+ public static function get_form_post_types() {
 
 
 
202
  $contact_data_post_types = array();
203
  $Admin = new MW_WP_Form_Admin();
204
  $forms = $Admin->get_forms_using_database();
206
  $post_type = MWF_Functions::get_contact_data_post_type_from_form_id( $form->ID );
207
  $contact_data_post_types[] = $post_type;
208
  }
209
+
210
  $raw_post_types = $contact_data_post_types;
211
  $new_post_types = array();
212
  $contact_data_post_types = apply_filters(
213
  'mwform_contact_data_post_types',
214
  $contact_data_post_types
215
  );
216
+
217
  // もともとの配列に含まれていない値は削除する
218
  foreach ( $contact_data_post_types as $post_type ) {
219
  if ( in_array( $post_type, $raw_post_types ) ) {
220
  $new_post_types[] = $post_type;
221
  }
222
  }
223
+
224
+ return $new_post_types;
225
+ }
226
+
227
+ public static function get_posts() {
228
+ MWF_Functions::deprecated_message(
229
+ 'MW_WP_Form_Contact_Data_Setting::get_posts()',
230
+ 'MW_WP_Form_Contact_Data_Setting::get_form_post_types()'
231
+ );
232
+
233
+ return self::get_form_post_types();
234
  }
235
 
236
  /**
237
+ * Return true if $meta_key is upload_file_key
238
  *
 
239
  * @param string $meta_key
240
  * @return bool
241
  */
242
+ public function is_upload_file_key( $meta_key ) {
243
+ $upload_file_keys = $this->_get_upload_file_keys();
244
+ return ( is_array( $upload_file_keys ) && in_array( $meta_key, $upload_file_keys ) );
 
 
 
245
  }
246
 
247
  /**
248
+ * Return index when $meta_key is included in upload_file_key
249
  *
 
250
  * @param string $meta_key
251
  * @return int|false
252
  */
253
+ public function get_index_of_key_in_upload_file_keys( $meta_key ) {
254
+ $upload_file_keys = $this->_get_upload_file_keys();
255
  if ( is_array( $upload_file_keys ) ) {
256
  return array_search( $meta_key, $upload_file_keys );
257
  }
259
  }
260
 
261
  /**
262
+ * Return the upload_file_key that the post has
263
  *
 
264
  * @return array $upload_file_keys
265
  */
266
+ protected function _get_upload_file_keys() {
267
  // 前のバージョンでは MWF_Config::UPLOAD_FILE_KEYS を配列で保持していなかったので分岐させる
268
+ $_upload_file_keys = get_post_meta( $this->post_id, '_' . MWF_Config::UPLOAD_FILE_KEYS, true );
269
  if ( is_array( $_upload_file_keys ) ) {
270
  $upload_file_keys = $_upload_file_keys;
271
  } else {
272
+ $upload_file_keys = get_post_custom_values( '_' . MWF_Config::UPLOAD_FILE_KEYS, $this->post_id );
273
  }
274
  return $upload_file_keys;
275
  }
classes/models/class.contact-data.php DELETED
@@ -1,49 +0,0 @@
1
- <?php
2
- /**
3
- * Name : MW WP Form Contact Data
4
- * Version : 1.0.0
5
- * Author : Takashi Kitajima
6
- * Author URI : http://2inc.org
7
- * Created : January 1, 2015
8
- * Modified :
9
- * License : GPLv2 or later
10
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
- */
12
- class MW_WP_Form_Contact_Data {
13
-
14
- /**
15
- * save_post
16
- *
17
- * @param int $post_id
18
- */
19
- public function save_post( $post_id ) {
20
- $contact_data_post_types = MW_WP_Form_Contact_Data_setting::get_posts();
21
- if ( !isset( $_POST['post_type'] ) )
22
- return $post_id;
23
- if ( !in_array( $_POST['post_type'], $contact_data_post_types ) )
24
- return $post_id;
25
- if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
26
- return $post_id;
27
- if ( !wp_verify_nonce( $_POST[MWF_Config::NAME . '_nonce'], MWF_Config::NAME ) )
28
- return $post_id;
29
- if ( !current_user_can( MWF_Config::CAPABILITY ) )
30
- return $post_id;
31
-
32
- $Contact_Data_Setting = new MW_WP_Form_Contact_Data_setting( $post_id );
33
- $permit_keys = $Contact_Data_Setting->get_permit_keys();
34
- $data = array();
35
- foreach ( $permit_keys as $key ) {
36
- if ( isset( $_POST[MWF_Config::CONTACT_DATA_NAME][$key] ) ) {
37
- $value = $_POST[MWF_Config::CONTACT_DATA_NAME][$key];
38
- if ( $key === 'response_status' ) {
39
- if ( !array_key_exists( $value, $Contact_Data_Setting->get_response_statuses() ) ) {
40
- continue;
41
- }
42
- }
43
- $data[$key] = $value;
44
- }
45
- }
46
- $Contact_Data_Setting->sets( $data );
47
- $Contact_Data_Setting->save();
48
- }
49
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/models/class.csv.php CHANGED
@@ -1,11 +1,11 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form CSV
4
- * Version : 1.1.0
5
  * Author : Takashi Kitajima
6
- * Author URI : http://2inc.org
7
  * Created : April 3, 2015
8
- * Modified : March 26, 2016
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
@@ -16,107 +16,115 @@ class MW_WP_Form_CSV {
16
  */
17
  protected $post_type;
18
 
19
- /**
20
- * __construct
21
- */
22
  public function __construct( $post_type ) {
23
  $this->post_type = $post_type;
24
  }
25
 
26
  /**
27
- * CSVを生成、出力
 
 
28
  */
29
  public function download() {
30
  $key_of_csv_download = MWF_Config::NAME . '-csv-download';
31
 
32
- if ( !isset( $_POST[$key_of_csv_download] ) || !check_admin_referer( MWF_Config::NAME ) ) {
33
  return;
34
  }
35
 
36
- $posts_per_page = $this->get_posts_per_page();
37
- $paged = $this->get_paged();
38
 
39
- $_args = apply_filters( 'mwform_get_inquiry_data_args-' . $this->post_type, array() );
40
- $args = array(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  'post_type' => $this->post_type,
42
  'posts_per_page' => $posts_per_page,
43
  'paged' => $paged,
44
  'post_status' => 'any',
45
- );
46
- if ( !empty( $_args ) && is_array( $_args ) ) {
47
- $args = array_merge( $_args, $args );
48
- }
49
  $posts_mwf = get_posts( $args );
50
 
51
  // CSVの内容を貯める
52
  $csv = '';
53
 
54
  // 見出しを追加
55
- $rows[0] = $this->get_csv_headings( $posts_mwf );
56
 
57
  // 各データを追加
58
- $rows = array_merge( $rows, $this->get_rows( $posts_mwf, $rows[0] ) );
59
 
60
  // エンコード
61
  foreach ( $rows as $key => $row ) {
62
  foreach ( $row as $column_name => $column ) {
63
- $row[$column_name] = $this->escape_double_quote( $column );
64
  }
65
  $csv .= implode( ',', $row ) . "\r\n";
66
  }
67
  $to_encoding = apply_filters( 'mwform_csv_encoding-' . $this->post_type, 'sjis-win' );
68
- $csv = mb_convert_encoding( $csv, $to_encoding, get_option( 'blog_charset' ) );
69
 
70
- $file_name = 'mw_wp_form_' . date( 'YmdHis' ) . '.csv';
71
- header( 'Content-Type: application/octet-stream' );
72
- header( 'Content-Disposition: attachment; filename=' . $file_name );
73
- echo $csv;
74
- exit;
75
  }
76
 
77
  /**
78
- * CSVで出力する件数を取得
79
  *
80
  * @return int
81
  */
82
- public function get_posts_per_page() {
83
- $posts_per_page = -1;
84
- if ( ( isset( $_POST['download-all'] ) && $_POST['download-all'] === 'true' ) === false ) {
85
- $current_user = wp_get_current_user();
86
- $_posts_per_page = get_user_meta( $current_user->ID, 'edit_' . $this->post_type . '_per_page', true );
87
- if ( !empty( $_posts_per_page ) ) {
88
- $posts_per_page = $_posts_per_page;
89
- } else {
90
- $posts_per_page = 20;
91
- }
92
  }
93
- return $posts_per_page;
 
94
  }
95
 
96
  /**
97
- * CSVで出力するページ番号を取得
98
  *
99
  * @return int
100
  */
101
- public function get_paged() {
102
- $posts_per_page = $this->get_posts_per_page();
103
- $paged = 1;
104
  if ( isset( $_GET['paged'] ) ) {
105
- $_paged = $_GET['paged'];
106
- if ( MWF_Functions::is_numeric( $_paged ) && $posts_per_page > 0 ) {
107
- $paged = $_paged;
108
  }
109
  }
110
- return $paged;
111
  }
112
 
113
  /**
114
- * CSVの見出しを生成
115
  *
116
  * @param array $posts
117
  * @return array
118
  */
119
- protected function get_csv_headings( array $posts ) {
120
  $columns = array(
121
  'ID' => 'ID',
122
  'response_status' => __( 'Response Status', 'mw-wp-form' ),
@@ -127,20 +135,24 @@ class MW_WP_Form_CSV {
127
  $_columns = array();
128
  foreach ( $posts as $post ) {
129
  $post_custom_keys = get_post_custom_keys( $post->ID );
130
- if ( !is_array( $post_custom_keys ) ) {
131
  continue;
132
  }
 
133
  foreach ( $post_custom_keys as $key ) {
134
  if ( preg_match( '/^_/', $key ) ) {
135
  continue;
136
  }
137
- if ( $key === MWF_Config::TRACKINGNUMBER ) {
138
- $columns[$key] = MWF_Functions::get_tracking_number_title( $this->post_type );
 
139
  continue;
140
  }
141
- $_columns[$key] = $key;
 
142
  }
143
  }
 
144
  ksort( $_columns );
145
  $_columns = apply_filters( 'mwform_inquiry_data_columns-' . $this->post_type, $_columns );
146
  $columns = array_merge( $columns, $_columns );
@@ -149,14 +161,15 @@ class MW_WP_Form_CSV {
149
  }
150
 
151
  /**
152
- * CSVの各行を生成
153
  *
154
  * @param array $posts
155
  * @param array $headings
156
  * @return array
157
  */
158
- protected function get_rows( array $posts, array $headings ) {
159
  global $post;
 
160
  $rows = array();
161
  foreach ( $posts as $post ) {
162
  setup_postdata( $post );
@@ -165,26 +178,28 @@ class MW_WP_Form_CSV {
165
  $Contact_Data_Setting = new MW_WP_Form_Contact_Data_Setting( $post->ID );
166
  $response_statuses = $Contact_Data_Setting->get_response_statuses();
167
  $column = '';
168
- if ( $key === 'response_status' ) {
 
169
  $response_status = $Contact_Data_Setting->get( 'response_status' );
170
- $column = $response_statuses[$response_status];
171
- } elseif ( $key === 'memo' ) {
172
  $column = $Contact_Data_Setting->get( 'memo' );
173
- } elseif ( $key === MWF_Config::TRACKINGNUMBER ) {
174
  $column = get_post_meta( get_the_ID(), MWF_Config::TRACKINGNUMBER, true );
175
  } elseif ( isset( $post->$key ) ) {
176
  $post_meta = $post->$key;
177
- if ( $Contact_Data_Setting->is_upload_file_key( $post, $key ) ) {
 
178
  // 過去バージョンでの不具合でメタデータが空になっていることがあるのでその場合は代替処理
179
- if ( $post_meta === '' ) {
180
  $post_meta = MWF_Functions::get_multimedia_id__fallback( $post, $key );
181
  }
182
  $column = wp_get_attachment_url( $post_meta );
183
  } else {
184
- $column = ( $post_meta ) ? $post_meta : '';
185
  }
186
  }
187
- $columns[$key] = $column;
188
  }
189
  $rows[] = $columns;
190
  }
@@ -193,12 +208,12 @@ class MW_WP_Form_CSV {
193
  }
194
 
195
  /**
196
- * CSVのダブルクオートのエスケープ
197
  *
198
  * @param string $value
199
  * @return string
200
  */
201
- protected function escape_double_quote( $value ) {
202
  $value = str_replace( '"', '""', $value );
203
  return '"' . $value . '"';
204
  }
1
  <?php
2
  /**
3
  * Name : MW WP Form CSV
4
+ * Version : 2.0.1
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : April 3, 2015
8
+ * Modified : June 26, 2018
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
16
  */
17
  protected $post_type;
18
 
 
 
 
19
  public function __construct( $post_type ) {
20
  $this->post_type = $post_type;
21
  }
22
 
23
  /**
24
+ * Download CSV
25
+ *
26
+ * @return void
27
  */
28
  public function download() {
29
  $key_of_csv_download = MWF_Config::NAME . '-csv-download';
30
 
31
+ if ( ! isset( $_POST[ $key_of_csv_download ] ) || ! check_admin_referer( MWF_Config::NAME ) ) {
32
  return;
33
  }
34
 
35
+ $csv = $this->_generate_csv();
 
36
 
37
+ $file_name = 'mw_wp_form_' . date( 'YmdHis' ) . '.csv';
38
+ header( 'Content-Type: application/octet-stream' );
39
+ header( 'Content-Disposition: attachment; filename=' . $file_name );
40
+ echo $csv;
41
+ exit;
42
+ }
43
+
44
+ /**
45
+ * Generate CSV
46
+ *
47
+ * @return string CSV
48
+ */
49
+ protected function _generate_csv() {
50
+ $posts_per_page = $this->_get_posts_per_page();
51
+ $paged = $this->_get_paged();
52
+
53
+ $args = apply_filters( 'mwform_get_inquiry_data_args-' . $this->post_type, array() );
54
+ if ( empty( $args ) || ! is_array( $args ) ) {
55
+ $args = array();
56
+ }
57
+ $args = array_merge( $args, array(
58
  'post_type' => $this->post_type,
59
  'posts_per_page' => $posts_per_page,
60
  'paged' => $paged,
61
  'post_status' => 'any',
62
+ ) );
63
+
 
 
64
  $posts_mwf = get_posts( $args );
65
 
66
  // CSVの内容を貯める
67
  $csv = '';
68
 
69
  // 見出しを追加
70
+ $rows[0] = $this->_get_csv_headings( $posts_mwf );
71
 
72
  // 各データを追加
73
+ $rows = array_merge( $rows, $this->_get_rows( $posts_mwf, $rows[0] ) );
74
 
75
  // エンコード
76
  foreach ( $rows as $key => $row ) {
77
  foreach ( $row as $column_name => $column ) {
78
+ $row[ $column_name ] = $this->_escape_double_quote( $column );
79
  }
80
  $csv .= implode( ',', $row ) . "\r\n";
81
  }
82
  $to_encoding = apply_filters( 'mwform_csv_encoding-' . $this->post_type, 'sjis-win' );
 
83
 
84
+ return mb_convert_encoding( $csv, $to_encoding, get_option( 'blog_charset' ) );
 
 
 
 
85
  }
86
 
87
  /**
88
+ * Return number of CSV output
89
  *
90
  * @return int
91
  */
92
+ public function _get_posts_per_page() {
93
+ if ( isset( $_POST['download-all'] ) && 'true' === $_POST['download-all'] ) {
94
+ return -1;
95
+ }
96
+
97
+ $current_user = wp_get_current_user();
98
+ $posts_per_page = get_user_meta( $current_user->ID, 'edit_' . $this->post_type . '_per_page', true );
99
+ if ( ! empty( $posts_per_page ) ) {
100
+ return $posts_per_page;
 
101
  }
102
+
103
+ return 20;
104
  }
105
 
106
  /**
107
+ * Return page number of CSV output
108
  *
109
  * @return int
110
  */
111
+ public function _get_paged() {
112
+ $posts_per_page = $this->_get_posts_per_page();
 
113
  if ( isset( $_GET['paged'] ) ) {
114
+ if ( MWF_Functions::is_numeric( $_GET['paged'] ) && $posts_per_page > 0 ) {
115
+ return $_GET['paged'];
 
116
  }
117
  }
118
+ return 1;
119
  }
120
 
121
  /**
122
+ * Genrate headings of CSV
123
  *
124
  * @param array $posts
125
  * @return array
126
  */
127
+ protected function _get_csv_headings( array $posts ) {
128
  $columns = array(
129
  'ID' => 'ID',
130
  'response_status' => __( 'Response Status', 'mw-wp-form' ),
135
  $_columns = array();
136
  foreach ( $posts as $post ) {
137
  $post_custom_keys = get_post_custom_keys( $post->ID );
138
+ if ( ! is_array( $post_custom_keys ) ) {
139
  continue;
140
  }
141
+
142
  foreach ( $post_custom_keys as $key ) {
143
  if ( preg_match( '/^_/', $key ) ) {
144
  continue;
145
  }
146
+
147
+ if ( MWF_Config::TRACKINGNUMBER === $key ) {
148
+ $columns[ $key ] = MWF_Functions::get_tracking_number_title( $this->post_type );
149
  continue;
150
  }
151
+
152
+ $_columns[ $key ] = $key;
153
  }
154
  }
155
+
156
  ksort( $_columns );
157
  $_columns = apply_filters( 'mwform_inquiry_data_columns-' . $this->post_type, $_columns );
158
  $columns = array_merge( $columns, $_columns );
161
  }
162
 
163
  /**
164
+ * Generate rows of CSV
165
  *
166
  * @param array $posts
167
  * @param array $headings
168
  * @return array
169
  */
170
+ protected function _get_rows( array $posts, array $headings ) {
171
  global $post;
172
+
173
  $rows = array();
174
  foreach ( $posts as $post ) {
175
  setup_postdata( $post );
178
  $Contact_Data_Setting = new MW_WP_Form_Contact_Data_Setting( $post->ID );
179
  $response_statuses = $Contact_Data_Setting->get_response_statuses();
180
  $column = '';
181
+
182
+ if ( 'response_status' === $key ) {
183
  $response_status = $Contact_Data_Setting->get( 'response_status' );
184
+ $column = $response_statuses[ $response_status ];
185
+ } elseif ( 'memo' === $key ) {
186
  $column = $Contact_Data_Setting->get( 'memo' );
187
+ } elseif ( MWF_Config::TRACKINGNUMBER === $key) {
188
  $column = get_post_meta( get_the_ID(), MWF_Config::TRACKINGNUMBER, true );
189
  } elseif ( isset( $post->$key ) ) {
190
  $post_meta = $post->$key;
191
+
192
+ if ( $Contact_Data_Setting->is_upload_file_key( $key ) ) {
193
  // 過去バージョンでの不具合でメタデータが空になっていることがあるのでその場合は代替処理
194
+ if ( '' === $post_meta ) {
195
  $post_meta = MWF_Functions::get_multimedia_id__fallback( $post, $key );
196
  }
197
  $column = wp_get_attachment_url( $post_meta );
198
  } else {
199
+ $column = ( '' === $post_meta || null === $post_meta || false === $post_meta ) ? '' : $post_meta;
200
  }
201
  }
202
+ $columns[ $key ] = $column;
203
  }
204
  $rows[] = $columns;
205
  }
208
  }
209
 
210
  /**
211
+ * Escape double quotes
212
  *
213
  * @param string $value
214
  * @return string
215
  */
216
+ protected function _escape_double_quote( $value ) {
217
  $value = str_replace( '"', '""', $value );
218
  return '"' . $value . '"';
219
  }
classes/models/class.data.php CHANGED
@@ -1,38 +1,27 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Data
4
- * Description: MW WP Form のデータ操作用
5
- * Version : 1.6.0
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : October 10, 2013
9
- * Modified : December 27, 2016
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Data {
14
 
15
  /**
16
- * @var MW_WP_Form_Data
17
  */
18
- protected static $Instance;
19
-
20
- /**
21
- * フォーム識別子
22
- * @var string
23
- */
24
- protected $form_key;
25
-
26
- /**
27
- * フォームから送信された内容を保存した配列
28
- * @var array
29
- */
30
- protected $data = array();
31
 
32
  /**
33
  * @var MW_WP_Form_Sesion
34
  */
35
  protected $Session;
 
 
36
 
37
  /**
38
  * @var array
@@ -45,71 +34,99 @@ class MW_WP_Form_Data {
45
  protected $FILES = array();
46
 
47
  /**
48
- * @var string null|input|confirm|complete
49
  */
50
- protected $view_flg = null;
 
 
51
 
52
  /**
53
- * __construct
54
- *
55
- * @param string $form_key フォーム識別子
56
- * @param array $POST $_POSTを想定
57
- * @param array $FILES $_FILESを想定
58
  */
59
  private function __construct( $form_key, array $POST = array(), array $FILES = array() ) {
60
- $this->form_key = $form_key;
61
- $this->POST = $POST;
62
- $this->FILES = $FILES;
63
- $this->Session = new MW_WP_Form_Session( $form_key );
64
- $this->data = $this->Session->gets();
65
- $this->set_request_valiables( $this->POST );
66
- $this->set_files_valiables( $this->POST, $this->FILES );
 
 
 
 
 
 
 
67
 
68
  if ( isset( $POST[ MWF_Config::CUSTOM_MAIL_TAG_KEYS ] ) ) {
69
  foreach ( $POST[ MWF_Config::CUSTOM_MAIL_TAG_KEYS ] as $custom_mail_tag_key ) {
70
- $value = apply_filters(
71
- 'mwform_custom_mail_tag',
72
- null,
73
- $custom_mail_tag_key,
74
- null
75
- );
76
-
77
- $value = apply_filters(
78
- 'mwform_custom_mail_tag_' . $form_key,
79
- $value,
80
- $custom_mail_tag_key,
81
- null
82
- );
83
-
84
- if ( ! is_null( $value ) ) {
85
  $this->set( $custom_mail_tag_key, $value );
86
  }
87
  }
88
  }
 
 
89
  }
90
 
91
  /**
92
- * getInstance
93
  *
94
- * @param null|string $form_key フォーム識別子
95
- * @param null|array $POST $_POSTを想定
96
- * @param null|array $FILES $_FILESを想定
97
  */
98
- public static function getInstance( $form_key = null, $POST = null, $FILES = null ) {
99
- if ( is_null( $POST ) || !is_array( $POST ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  $POST = array();
101
  }
102
- if ( is_null( $FILES ) || !is_array( $FILES ) ) {
 
103
  $FILES = array();
104
  }
105
- if ( is_null( $form_key ) && !is_null( self::$Instance ) ) {
106
- return self::$Instance;
107
- }
108
- if ( !is_null( $form_key ) ) {
109
- self::$Instance = new self( $form_key, $POST, $FILES );
110
- return self::$Instance;
 
 
 
 
 
 
 
 
 
111
  }
112
- exit( 'MW_WP_Form_Data instantiation error.' );
 
113
  }
114
 
115
  /**
@@ -118,40 +135,53 @@ class MW_WP_Form_Data {
118
  * @return string
119
  */
120
  public function get_form_key() {
121
- return $this->form_key;
 
 
122
  }
123
 
124
  /**
125
- * $_POST をセット
126
  *
127
- * @param array $POST $_POSTを想定
 
128
  */
129
- protected function set_request_valiables( array $POST ) {
130
- if ( !empty( $POST ) ) {
131
- $this->sets( stripslashes_deep( $POST ) );
 
 
 
 
 
 
 
 
 
132
  }
133
  }
134
 
135
  /**
136
- * $_FILES をセット
137
  *
138
- * @param array $POST $_POSTを想定
139
- * @param array $FILES $_FILESを想定
140
  */
141
- protected function set_files_valiables( array $POST, array $FILES ) {
142
  $files = array();
143
- foreach ( $FILES as $key => $file ) {
144
- if ( !isset( $POST[$key] ) || !empty( $file['name'] ) ) {
145
  if ( $file['error'] == UPLOAD_ERR_OK && is_uploaded_file( $file['tmp_name'] ) ) {
146
- $this->set( $key, $file['name'] );
147
  } else {
148
- $this->set( $key, '' );
149
  }
150
- if ( !empty( $file['name'] ) ) {
151
- $files[$key] = $file;
 
152
  }
153
  }
154
  }
 
155
  // この条件判定がないと fileSize チェックが正しく動作しない
156
  if ( $files ) {
157
  $this->set( MWF_Config::UPLOAD_FILES, $files );
@@ -160,154 +190,185 @@ class MW_WP_Form_Data {
160
 
161
  /**
162
  * 送信データからどのページを表示すべきかの状態を判定して返す
163
- * ただし実際に表示するページと同じとは限らない(バリデーション通らないとかあるので)
 
164
  *
165
- * @param bool $token_check
166
  * @return string back|confirm|complete|input
167
  */
168
- public function get_post_condition( $token_check ) {
169
  $backButton = $this->get_post_value_by_key( MWF_Config::BACK_BUTTON );
170
  $confirmButton = $this->get_post_value_by_key( MWF_Config::CONFIRM_BUTTON );
 
171
  if ( $backButton ) {
172
  return 'back';
173
  } elseif ( $confirmButton ) {
174
  return 'confirm';
175
- } elseif ( !$confirmButton && !$backButton && $token_check ) {
176
  return 'complete';
177
  }
 
178
  return 'input';
179
  }
180
 
181
  /**
182
- * 全ての送信データを取得
183
  *
184
  * @return array
185
  */
186
  public function gets() {
187
- if ( $this->data === null ) {
188
- $this->data = array();
189
- }
190
- return $this->data;
191
  }
192
 
193
  /**
194
- * データを追加
195
  *
196
- * @param string $key データのキー
197
- * @param string $value
 
198
  */
199
- public function set( $key, $value ){
200
- $this->data[$key] = $value;
201
- $this->Session->set( $key, $value );
202
  }
203
 
204
  /**
205
- * 複数のデータを一括で追加
206
  *
207
- * @param array
 
208
  */
209
  public function sets( array $array ) {
210
- foreach ( $array as $key => $value ) {
211
- $this->data[$key] = $value;
212
- $this->Session->set( $key, $value );
213
  }
214
  }
215
 
216
  /**
217
- * データを消す
218
  *
219
- * @param string $key データのキー
 
220
  */
221
- public function clear_value( $key ) {
222
- unset( $this->data[$key] );
223
- $this->Session->clear_value( $key );
 
224
  }
225
 
226
  /**
227
- * 全てのデータを消す
228
  *
229
- * @param string $key データのキー
230
  */
231
  public function clear_values() {
232
- $this->data = array();
233
- $this->Session->clear_values();
 
234
  }
235
 
236
  /**
237
- * 指定した $key をキーと配列にデータを追加
238
  *
239
- * @param string $key データのキー
240
- * @param string $value
 
241
  */
242
- public function push( $key, $value ) {
243
- $this->data[$key][] = $value;
244
- $this->Session->push( $key, $value );
 
 
 
 
 
 
 
 
245
  }
246
 
247
  /**
248
- * 整形済み(メール送信可能な)データを取得。送信値、表示値を自動判別
249
  *
250
- * @param string $key データのキー
251
  * @param array $children
252
  * @return string|null
253
  */
254
- public function get( $key, array $children = array() ) {
255
- $post_value = $this->get_post_value_by_key( $key );
256
 
257
  if ( is_null( $post_value ) ) {
258
  return;
259
  }
260
 
261
- if ( empty( $children ) && isset( $this->data['__children'][$key] ) && is_array( $this->data['__children'][$key] ) ) {
262
- $_children = $this->data['__children'][$key];
263
- foreach ( $_children as $_child ) {
264
- $_child = json_decode( $_child, true );
265
- foreach ( $_child as $_child_key => $_child_value ) {
266
- $children[$_child_key] = $_child_value;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
267
  }
268
  }
269
  }
270
 
271
  if ( is_array( $post_value ) ) {
272
- if ( !array_key_exists( 'data', $post_value ) ) {
273
- return;
274
- }
275
  if ( $children ) {
276
- return $this->get_separated_value( $key, $children );
277
  }
278
- return $this->get_separated_value_not_children_set( $key );
279
  } else {
280
  if ( $children ) {
281
- return $this->get_in_children( $key, $children );
282
  }
283
- return $this->get_raw( $key );
284
  }
285
  }
286
 
287
  /**
288
- * 送信データを取得
289
  *
290
- * @param string $key データのキー
291
  * @return string|null
292
  */
293
- public function get_raw( $key ) {
294
- $post_value = $this->get_post_value_by_key( $key );
295
 
296
  if ( is_null( $post_value ) ) {
297
  return;
298
  }
299
- if ( is_array( $post_value ) && !array_key_exists( 'data', $post_value ) ) {
 
300
  return;
301
  }
302
 
 
 
303
  $children = array();
304
- if ( isset( $this->data['__children'][$key] ) && is_array( $this->data['__children'][$key] ) ) {
305
- $_children = $this->data['__children'][$key];
306
  if ( is_array( $_children ) ) {
307
  foreach ( $_children as $_child ) {
 
 
 
308
  $_child = json_decode( $_child, true );
 
 
 
309
  foreach ( $_child as $_child_key => $_child_value ) {
310
- $children[$_child_key] = $_child_value;
311
  }
312
  }
313
  }
@@ -315,202 +376,219 @@ class MW_WP_Form_Data {
315
 
316
  if ( is_array( $post_value ) ) {
317
  if ( $children ) {
318
- return $this->get_separated_raw_value( $key, $children );
319
  }
320
- return $this->get_separated_value_not_children_set( $key );
321
  } else {
322
  if ( $children ) {
323
- return $this->get_raw_in_children( $key, $children );
324
  }
325
- return $this->get_post_value_by_key( $key );
326
  }
327
  }
328
 
329
  /**
330
- * そのキーに紐づく送信データを取得(通常の value 以外に separator data などが紐づく)
331
  *
332
- * @param string $key name 属性値
333
  * @return mixed
334
  */
335
- public function get_post_value_by_key( $key ) {
336
- if ( isset( $this->data[$key] ) ) {
337
- return $this->data[$key];
338
  }
339
  }
340
 
341
  /**
342
- * $children の中に値が含まれているときだけ返す
343
- * 本当は protected 後方互換
344
  *
345
- * @param string $key name属性
346
  * @param array $children
347
  * @return string
348
  */
349
- public function get_in_children( $key, array $children ) {
350
- $value = $this->get_post_value_by_key( $key );
351
- if ( !is_null( $value ) && !is_array( $value ) ) {
352
- if ( isset( $children[$value] ) ) {
353
- return $children[$value];
354
- } else {
355
- return '';
356
- }
357
  }
 
 
 
 
 
 
358
  }
359
 
360
  /**
361
- * $children の中に値が含まれているときだけ返す
362
- * 本当は protected 後方互換
363
  *
364
- * @param string $key name属性
365
  * @param array $children
366
  * @return string
367
  */
368
- public function get_raw_in_children( $key, array $children ) {
369
- $value = $this->get_post_value_by_key( $key );
370
- if ( !is_null( $value ) && !is_array( $value ) ) {
371
- if ( isset( $children[$value] ) ) {
372
- return $value;
373
- } else {
374
- return '';
375
- }
376
  }
 
 
377
  }
378
 
379
  /**
380
- * 送られてきたseparatorを返す
381
  *
382
- * @param string $key name属性
383
  * @return string
384
  */
385
- public function get_separator_value( $key ) {
386
- $value = $this->get_post_value_by_key( $key );
387
  if ( is_array( $value ) && isset( $value['separator'] ) ) {
388
  return $value['separator'];
389
  }
390
  }
391
 
392
  /**
393
- * 配列データを整形して表示値を返す。separator が送信されていない場合は null
394
- * 本当は protected 後方互換
395
  *
396
- * @param string $key name属性
397
- * @param array $children 選択肢
398
  * @return string|null
399
  */
400
- public function get_separated_value( $key, array $children ) {
401
- $separator = $this->get_separator_value( $key );
402
- $value = $this->get_post_value_by_key( $key );
403
 
404
- if ( !is_array( $value ) ) {
405
  return;
406
  }
407
- if ( !isset( $value['data'] ) ) {
 
408
  return;
409
  }
410
- if ( !$separator ) {
 
 
 
 
 
411
  return;
412
  }
413
 
414
  // 入力 -> 確認のときは配列、確認 -> 入力のときは文字列
415
- if ( !is_array( $value['data'] ) ) {
416
  $value['data'] = explode( $separator, $value['data'] );
417
  }
418
- if ( $children ) {
419
- $rightData = array();
420
- foreach ( $value['data'] as $child ) {
421
- if ( isset( $children[$child] ) && !in_array( $children[$child], $rightData ) ) {
422
- $rightData[] = $children[$child];
423
- }
424
  }
425
- return implode( $separator, $rightData );
426
  }
 
 
427
  }
428
 
429
  /**
430
- * 配列データを整形して送信値を返す。separator が送信されていない場合は null
431
- * 本当は protected 後方互換
432
  *
433
- * @param string $key name属性
434
  * @param array $children 選択肢
435
  * @return string|null
436
  */
437
- public function get_separated_raw_value( $key, array $children ) {
438
- $separator = $this->get_separator_value( $key );
439
- $value = $this->get_post_value_by_key( $key );
440
 
441
- if ( !is_array( $value ) ) {
442
  return;
443
  }
444
- if ( !isset( $value['data'] ) ) {
 
445
  return;
446
  }
447
- if ( !$separator ) {
 
 
 
 
 
448
  return;
449
  }
450
 
451
  // 入力 -> 確認のときは配列、確認 -> 入力のときは文字列
452
- if ( !is_array( $value['data'] ) ) {
453
  $value['data'] = explode( $separator, $value['data'] );
454
  }
455
- if ( $children ) {
456
- $rightData = array();
457
- foreach ( $value['data'] as $child ) {
458
- if ( isset( $children[$child] ) && !in_array( $child, $rightData ) ) {
459
- $rightData[] = $child;
460
- }
461
  }
462
- return implode( $separator, $rightData );
463
  }
 
464
  }
465
 
466
  /**
467
- * すべて空のからのときはimplodeしないように(---がいってしまうため)= 一個でも値ありがあれば返す
 
468
  *
469
- * @param array $data
470
  * @param string $separator
471
  * @return string|null
472
  */
473
- protected function get_separated_value_not_children_set( $key ) {
474
- $separator = $this->get_separator_value( $key );
475
- $value = $this->get_post_value_by_key( $key );
476
 
477
- if ( !is_array( $value ) ) {
478
  return;
479
  }
480
- if ( !isset( $value['data'] ) ) {
 
481
  return;
482
  }
483
- if ( !$separator ) {
 
484
  return;
485
  }
486
 
487
- if ( !is_array( $value['data'] ) ) {
488
  $value['data'] = explode( $separator, $value['data'] );
489
  }
490
 
491
  foreach ( $value['data'] as $child ) {
492
- if ( $child !== '' && $child !== null ) {
493
  return implode( $separator, $value['data'] );
494
  }
495
  }
 
496
  return '';
497
  }
498
 
499
  /**
500
- * アップロードに失敗、もしくはファイルが削除されている key UPLOAD_FILE_KEYS から削除
 
 
501
  */
502
  public function regenerate_upload_file_keys() {
503
  $upload_file_keys = $this->get_post_value_by_key( MWF_Config::UPLOAD_FILE_KEYS );
504
- if ( !is_array( $upload_file_keys ) ) {
505
  $upload_file_keys = array();
506
  }
507
 
508
  $upload_file_keys = apply_filters(
509
- 'mwform_upload_file_keys_' . $this->form_key,
510
  $upload_file_keys,
511
  clone $this
512
  );
513
- if ( !is_array( $upload_file_keys ) ) {
514
  $upload_file_keys = array();
515
  }
516
  $upload_file_keys = array_values( array_unique( $upload_file_keys ) );
@@ -518,65 +596,149 @@ class MW_WP_Form_Data {
518
  $wp_upload_dir = wp_upload_dir();
519
  foreach ( $upload_file_keys as $key => $upload_file_key ) {
520
  $upload_file_url = $this->get_post_value_by_key( $upload_file_key );
521
- if ( $upload_file_url ) {
522
- $filepath = MWF_Functions::fileurl_to_path( $upload_file_url );
523
- if ( !file_exists( $filepath ) ) {
524
- unset( $upload_file_keys[$key] );
525
- }
526
  }
527
  }
 
528
  $this->set( MWF_Config::UPLOAD_FILE_KEYS, $upload_file_keys );
529
  }
530
 
531
  /**
532
- * アップロードに成功したファイルを UPLOAD_FILE_KEYS に格納
533
  *
534
- * @param array $uploaded_files アップロード済みファイルのパスの配列
535
  */
536
  public function push_uploaded_file_keys( array $uploaded_files = array() ) {
537
  $upload_file_keys = $this->get_post_value_by_key( MWF_Config::UPLOAD_FILE_KEYS );
538
- if ( !is_array( $upload_file_keys ) ) {
539
  $upload_file_keys = array();
 
540
  }
 
541
  foreach ( $uploaded_files as $key => $upload_file ) {
542
  $this->set( $key, $upload_file );
543
- if ( is_array( $upload_file_keys ) && !in_array( $key, $upload_file_keys ) ) {
544
  $this->push( MWF_Config::UPLOAD_FILE_KEYS, $key );
545
  }
546
  }
547
  }
548
 
549
  /**
550
- * 表示すべき画面を示すフラグを設定
551
  *
552
- * @param string $this->view_flg
 
553
  */
554
  public function set_view_flg( $view_flg ) {
555
- $this->view_flg = $view_flg;
556
  }
557
 
558
  /**
559
- * 表示すべき画面を示すフラグを返す
560
  *
561
- * @return string $this->view_flg
562
  */
563
  public function get_view_flg() {
564
- return $this->view_flg;
 
 
565
  }
566
 
567
  /**
568
- * 送信エラーを示すフラグをセット
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
569
  */
570
  public function set_send_error() {
571
- $this->set( MWF_Config::SEND_ERROR, true );
572
  }
573
 
574
  /**
575
- * 送信エラーを示すフラグを返す
576
  *
577
  * @return boolean
578
  */
579
  public function get_send_error() {
580
- return $this->get( MWF_Config::SEND_ERROR );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
581
  }
582
  }
1
  <?php
2
  /**
3
  * Name : MW WP Form Data
4
+ * Version : 3.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : October 10, 2013
8
+ * Modified : June 1, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Data {
13
 
14
  /**
15
+ * @var array Array of MW_WP_Form_Data
16
  */
17
+ protected static $Instances;
 
 
 
 
 
 
 
 
 
 
 
 
18
 
19
  /**
20
  * @var MW_WP_Form_Sesion
21
  */
22
  protected $Session;
23
+ protected $Session_meta;
24
+ protected $Session_validation_error;
25
 
26
  /**
27
  * @var array
34
  protected $FILES = array();
35
 
36
  /**
37
+ * @var array
38
  */
39
+ protected $variables = array();
40
+ protected $meta = array();
41
+ protected $validation_errors = array();
42
 
43
  /**
44
+ * @param string $form_key
45
+ * @param array $POST $_POST
46
+ * @param array $FILES $_FILES
 
 
47
  */
48
  private function __construct( $form_key, array $POST = array(), array $FILES = array() ) {
49
+ $this->Session = new MW_WP_Form_Session( $form_key );
50
+ $this->Session_meta = new MW_WP_Form_Session( $form_key . '-meta' );
51
+ $this->Session_validation_error = new MW_WP_Form_Session( $form_key . '-validation-error' );
52
+
53
+ $this->variables = $this->Session->gets();
54
+ $this->meta = $this->Session_meta->gets();
55
+ $this->validation_errors = $this->Session_validation_error->gets();
56
+
57
+ $this->POST = $POST;
58
+ $this->FILES = $FILES;
59
+
60
+ $this->_set_form_key( $form_key );
61
+ $this->_set_request_valiables();
62
+ $this->_set_files_valiables();
63
 
64
  if ( isset( $POST[ MWF_Config::CUSTOM_MAIL_TAG_KEYS ] ) ) {
65
  foreach ( $POST[ MWF_Config::CUSTOM_MAIL_TAG_KEYS ] as $custom_mail_tag_key ) {
66
+ $value = MW_WP_Form_Parser::apply_filters_mwform_custom_mail_tag( $form_key, '', $custom_mail_tag_key );
67
+ if ( '' !== $value ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  $this->set( $custom_mail_tag_key, $value );
69
  }
70
  }
71
  }
72
+
73
+ add_action( 'shutdown', array( $this, '_save_to_session' ) );
74
  }
75
 
76
  /**
77
+ * Save posted data to session
78
  *
79
+ * @return void
 
 
80
  */
81
+ public function _save_to_session() {
82
+ $this->Session->clear_values();
83
+ $this->Session->save( $this->variables );
84
+
85
+ $this->Session_meta->clear_values();
86
+ $this->Session_meta->save( $this->meta );
87
+
88
+ $this->Session_validation_error->clear_values();
89
+ $this->Session_validation_error->save( $this->validation_errors );
90
+ }
91
+
92
+ /**
93
+ * Instantiation MW_WP_Form_Data
94
+ *
95
+ * @param string $form_key
96
+ * @param array $POST $_POST
97
+ * @param array $FILES $_FILES
98
+ * @return MW_WP_Form_Data
99
+ */
100
+ public static function connect( $form_key, $POST = null, $FILES = null ) {
101
+ if ( isset( self::$Instances[ $form_key ] ) && is_null( $POST ) && is_null( $FILES ) ) {
102
+ return self::$Instances[ $form_key ];
103
+ }
104
+
105
+ if ( ! is_array( $POST ) ) {
106
  $POST = array();
107
  }
108
+
109
+ if ( ! is_array( $FILES ) ) {
110
  $FILES = array();
111
  }
112
+
113
+ self::$Instances[ $form_key ] = new self( $form_key, $POST, $FILES );
114
+ return self::$Instances[ $form_key ];
115
+ }
116
+
117
+ public static function getInstance( $form_key = null, $POST = null, $FILES = null ) {
118
+ MWF_Functions::deprecated_message(
119
+ 'MW_WP_Form_Data::getInstance()',
120
+ 'MW_WP_Form_Data::connect()'
121
+ );
122
+
123
+ if ( is_null( $form_key ) ) {
124
+ if ( 1 === count( self::$Instances ) ) {
125
+ $form_key = key( array_slice( self::$Instances, 0, 1 ) );
126
+ }
127
  }
128
+
129
+ return self::connect( $form_key, $POST, $FILES );
130
  }
131
 
132
  /**
135
  * @return string
136
  */
137
  public function get_form_key() {
138
+ if ( isset( $this->meta['form_key'] ) ) {
139
+ return $this->meta['form_key'];
140
+ }
141
  }
142
 
143
  /**
144
+ * Set form key
145
  *
146
+ * @param string $form_key
147
+ * @return void
148
  */
149
+ protected function _set_form_key( $form_key ) {
150
+ $this->meta['form_key'] = $form_key;
151
+ }
152
+
153
+ /**
154
+ * Set $_POST variables
155
+ *
156
+ * @return void
157
+ */
158
+ protected function _set_request_valiables() {
159
+ if ( ! empty( $this->POST ) ) {
160
+ $this->sets( stripslashes_deep( $this->POST ) );
161
  }
162
  }
163
 
164
  /**
165
+ * Set $_FILES variables
166
  *
167
+ * @return void
 
168
  */
169
+ protected function _set_files_valiables() {
170
  $files = array();
171
+ foreach ( $this->FILES as $name => $file ) {
172
+ if ( ! isset( $this->POST[ $name ] ) || ! empty( $file['name'] ) ) {
173
  if ( $file['error'] == UPLOAD_ERR_OK && is_uploaded_file( $file['tmp_name'] ) ) {
174
+ $this->set( $name, $file['name'] );
175
  } else {
176
+ $this->set( $name, '' );
177
  }
178
+
179
+ if ( ! empty( $file['name'] ) ) {
180
+ $files[ $name ] = $file;
181
  }
182
  }
183
  }
184
+
185
  // この条件判定がないと fileSize チェックが正しく動作しない
186
  if ( $files ) {
187
  $this->set( MWF_Config::UPLOAD_FILES, $files );
190
 
191
  /**
192
  * 送信データからどのページを表示すべきかの状態を判定して返す
193
+ * Return post condition based on posted data
194
+ * But this post condition is not the page to actually display (e.g. validation error)
195
  *
 
196
  * @return string back|confirm|complete|input
197
  */
198
+ public function get_post_condition() {
199
  $backButton = $this->get_post_value_by_key( MWF_Config::BACK_BUTTON );
200
  $confirmButton = $this->get_post_value_by_key( MWF_Config::CONFIRM_BUTTON );
201
+
202
  if ( $backButton ) {
203
  return 'back';
204
  } elseif ( $confirmButton ) {
205
  return 'confirm';
206
+ } elseif ( ! $confirmButton && ! $backButton && $this->_is_valid_token() ) {
207
  return 'complete';
208
  }
209
+
210
  return 'input';
211
  }
212
 
213
  /**
214
+ * Get values
215
  *
216
  * @return array
217
  */
218
  public function gets() {
219
+ return $this->variables;
 
 
 
220
  }
221
 
222
  /**
223
+ * Set the value
224
  *
225
+ * @param string $name
226
+ * @param string $value
227
+ * @return void
228
  */
229
+ public function set( $name, $value ){
230
+ $this->variables[ $name ] = $value;
 
231
  }
232
 
233
  /**
234
+ * Set values
235
  *
236
+ * @param array $array
237
+ * @return void
238
  */
239
  public function sets( array $array ) {
240
+ foreach ( $array as $name => $value ) {
241
+ $this->set( $name, $value );
 
242
  }
243
  }
244
 
245
  /**
246
+ * Clear the value
247
  *
248
+ * @param string $name
249
+ * @return void
250
  */
251
+ public function clear_value( $name ) {
252
+ if ( isset( $this->variables[ $name ] ) ) {
253
+ unset( $this->variables[ $name ] );
254
+ }
255
  }
256
 
257
  /**
258
+ * Clear all values
259
  *
260
+ * @return void
261
  */
262
  public function clear_values() {
263
+ $this->variables = array();
264
+ $this->meta = array();
265
+ $this->validation_errors = array();
266
  }
267
 
268
  /**
269
+ * Push the value
270
  *
271
+ * @param string $name
272
+ * @param string $value
273
+ * @return void
274
  */
275
+ public function push( $name, $value ) {
276
+ if ( ! isset( $this->variables[ $name ] ) ) {
277
+ $this->variables[ $name ] = array( $value );
278
+ } else {
279
+ if ( is_array( $this->variables[ $name ] ) ) {
280
+ $this->variables[ $name ][] = $value;
281
+ } else {
282
+ $this->variables[ $name ] = array( $this->variables[ $name ] );
283
+ $this->variables[ $name ][] = $value;
284
+ }
285
+ }
286
  }
287
 
288
  /**
289
+ * Return Formatted (transmittable) data. Auto discrimination name value or label
290
  *
291
+ * @param string $name
292
  * @param array $children
293
  * @return string|null
294
  */
295
+ public function get( $name, array $children = array() ) {
296
+ $post_value = $this->get_post_value_by_key( $name );
297
 
298
  if ( is_null( $post_value ) ) {
299
  return;
300
  }
301
 
302
+ if ( is_array( $post_value ) && ! array_key_exists( 'data', $post_value ) ) {
303
+ return;
304
+ }
305
+
306
+ $__children = $this->get_post_value_by_key( '__children' );
307
+
308
+ if ( empty( $children ) && isset( $__children[ $name ] ) ) {
309
+ if ( is_array( $__children[ $name ] ) ) {
310
+ $_children = $__children[ $name ];
311
+ foreach ( $_children as $_child ) {
312
+ if ( is_array( $_child ) ) {
313
+ continue;
314
+ }
315
+ $_child = json_decode( $_child, true );
316
+ if ( ! is_array( $_child ) ) {
317
+ continue;
318
+ }
319
+ foreach ( $_child as $_child_key => $_child_value ) {
320
+ $children[ $_child_key ] = $_child_value;
321
+ }
322
  }
323
  }
324
  }
325
 
326
  if ( is_array( $post_value ) ) {
 
 
 
327
  if ( $children ) {
328
+ return $this->get_separated_value( $name, $children );
329
  }
330
+ return $this->get_separated_value_not_children_set( $name );
331
  } else {
332
  if ( $children ) {
333
+ return $this->get_in_children( $name, $children );
334
  }
335
+ return $this->get_raw( $name );
336
  }
337
  }
338
 
339
  /**
340
+ * Get the raw value
341
  *
342
+ * @param string $name
343
  * @return string|null
344
  */
345
+ public function get_raw( $name ) {
346
+ $post_value = $this->get_post_value_by_key( $name );
347
 
348
  if ( is_null( $post_value ) ) {
349
  return;
350
  }
351
+
352
+ if ( is_array( $post_value ) && ! array_key_exists( 'data', $post_value ) ) {
353
  return;
354
  }
355
 
356
+ $__children = $this->get_post_value_by_key( '__children' );
357
+
358
  $children = array();
359
+ if ( isset( $__children[ $name ] ) && is_array( $__children[ $name ] ) ) {
360
+ $_children = $__children[ $name ];
361
  if ( is_array( $_children ) ) {
362
  foreach ( $_children as $_child ) {
363
+ if ( is_array( $_child ) ) {
364
+ continue;
365
+ }
366
  $_child = json_decode( $_child, true );
367
+ if ( ! is_array( $_child ) ) {
368
+ continue;
369
+ }
370
  foreach ( $_child as $_child_key => $_child_value ) {
371
+ $children[ $_child_key ] = $_child_value;
372
  }
373
  }
374
  }
376
 
377
  if ( is_array( $post_value ) ) {
378
  if ( $children ) {
379
+ return $this->get_separated_raw_value( $name, $children );
380
  }
381
+ return $this->get_separated_value_not_children_set( $name );
382
  } else {
383
  if ( $children ) {
384
+ return $this->get_raw_in_children( $name, $children );
385
  }
386
+ return $this->get_post_value_by_key( $name );
387
  }
388
  }
389
 
390
  /**
391
+ * Return posted data specify the name (In addition to value, separator and data etc are linked)
392
  *
393
+ * @param string $name
394
  * @return mixed
395
  */
396
+ public function get_post_value_by_key( $name ) {
397
+ if ( isset( $this->variables[ $name ] ) ) {
398
+ return $this->variables[ $name ];
399
  }
400
  }
401
 
402
  /**
403
+ * Return value when only in $children
 
404
  *
405
+ * @param string $name
406
  * @param array $children
407
  * @return string
408
  */
409
+ public function get_in_children( $name, array $children ) {
410
+ $value = $this->get_post_value_by_key( $name );
411
+ if ( is_null( $value ) || is_array( $value ) ) {
412
+ return;
 
 
 
 
413
  }
414
+
415
+ if ( isset( $children[ $value ] ) ) {
416
+ return $children[ $value ];
417
+ }
418
+
419
+ return '';
420
  }
421
 
422
  /**
423
+ * Return raw value when only in $children
 
424
  *
425
+ * @param string $name
426
  * @param array $children
427
  * @return string
428
  */
429
+ public function get_raw_in_children( $name, array $children ) {
430
+ $value = $this->get_post_value_by_key( $name );
431
+ if ( is_null( $value ) || is_array( $value ) ) {
432
+ return;
433
+ }
434
+
435
+ if ( isset( $children[ $value ] ) ) {
436
+ return $value;
437
  }
438
+
439
+ return '';
440
  }
441
 
442
  /**
443
+ * Return posted separator value
444
  *
445
+ * @param string $name
446
  * @return string
447
  */
448
+ public function get_separator_value( $name ) {
449
+ $value = $this->get_post_value_by_key( $name );
450
  if ( is_array( $value ) && isset( $value['separator'] ) ) {
451
  return $value['separator'];
452
  }
453
  }
454
 
455
  /**
456
+ * Return formatted label from array. If doesn't have separator, return null
 
457
  *
458
+ * @param string $name
459
+ * @param array $children
460
  * @return string|null
461
  */
462
+ public function get_separated_value( $name, array $children ) {
463
+ $separator = $this->get_separator_value( $name );
464
+ $value = $this->get_post_value_by_key( $name );
465
 
466
+ if ( ! $children ) {
467
  return;
468
  }
469
+
470
+ if ( ! is_array( $value ) ) {
471
  return;
472
  }
473
+
474
+ if ( ! isset( $value['data'] ) ) {
475
+ return;
476
+ }
477
+
478
+ if ( ! $separator ) {
479
  return;
480
  }
481
 
482
  // 入力 -> 確認のときは配列、確認 -> 入力のときは文字列
483
+ if ( ! is_array( $value['data'] ) ) {
484
  $value['data'] = explode( $separator, $value['data'] );
485
  }
486
+
487
+ $rightData = array();
488
+ foreach ( $value['data'] as $child ) {
489
+ if ( isset( $children[ $child ] ) && !in_array( $children[ $child ], $rightData ) ) {
490
+ $rightData[] = $children[ $child ];
 
491
  }
 
492
  }
493
+
494
+ return implode( $separator, $rightData );
495
  }
496
 
497
  /**
498
+ * Return formatted name value from array. If doesn't have separator, return null
 
499
  *
500
+ * @param string $name
501
  * @param array $children 選択肢
502
  * @return string|null
503
  */
504
+ public function get_separated_raw_value( $name, array $children ) {
505
+ $separator = $this->get_separator_value( $name );
506
+ $value = $this->get_post_value_by_key( $name );
507
 
508
+ if ( ! $children ) {
509
  return;
510
  }
511
+
512
+ if ( ! is_array( $value ) ) {
513
  return;
514
  }
515
+
516
+ if ( ! isset( $value['data'] ) ) {
517
+ return;
518
+ }
519
+
520
+ if ( ! $separator ) {
521
  return;
522
  }
523
 
524
  // 入力 -> 確認のときは配列、確認 -> 入力のときは文字列
525
+ if ( ! is_array( $value['data'] ) ) {
526
  $value['data'] = explode( $separator, $value['data'] );
527
  }
528
+
529
+ $rightData = array();
530
+ foreach ( $value['data'] as $child ) {
531
+ if ( isset( $children[ $child ] ) && !in_array( $child, $rightData ) ) {
532
+ $rightData[] = $child;
 
533
  }
 
534
  }
535
+ return implode( $separator, $rightData );
536
  }
537
 
538
  /**
539
+ * Return formatted label from array. If doesn't have separator, return null
540
+ * If it is all empty don't implode, even if there is even one value return
541
  *
542
+ * @param string $name
543
  * @param string $separator
544
  * @return string|null
545
  */
546
+ protected function get_separated_value_not_children_set( $name ) {
547
+ $separator = $this->get_separator_value( $name );
548
+ $value = $this->get_post_value_by_key( $name );
549
 
550
+ if ( ! is_array( $value ) ) {
551
  return;
552
  }
553
+
554
+ if ( ! isset( $value['data'] ) ) {
555
  return;
556
  }
557
+
558
+ if ( ! $separator ) {
559
  return;
560
  }
561
 
562
+ if ( ! is_array( $value['data'] ) ) {
563
  $value['data'] = explode( $separator, $value['data'] );
564
  }
565
 
566
  foreach ( $value['data'] as $child ) {
567
+ if ( '' !== $child && ! is_null( $child ) ) {
568
  return implode( $separator, $value['data'] );
569
  }
570
  }
571
+
572
  return '';
573
  }
574
 
575
  /**
576
+ * Delete name of upload failed file or name of deleted file from UPLOAD_FILE_KEYS
577
+ *
578
+ * @return void
579
  */
580
  public function regenerate_upload_file_keys() {
581
  $upload_file_keys = $this->get_post_value_by_key( MWF_Config::UPLOAD_FILE_KEYS );
582
+ if ( ! is_array( $upload_file_keys ) ) {
583
  $upload_file_keys = array();
584
  }
585
 
586
  $upload_file_keys = apply_filters(
587
+ 'mwform_upload_file_keys_' . $this->get_form_key(),
588
  $upload_file_keys,
589
  clone $this
590
  );
591
+ if ( ! is_array( $upload_file_keys ) ) {
592
  $upload_file_keys = array();
593
  }
594
  $upload_file_keys = array_values( array_unique( $upload_file_keys ) );
596
  $wp_upload_dir = wp_upload_dir();
597
  foreach ( $upload_file_keys as $key => $upload_file_key ) {
598
  $upload_file_url = $this->get_post_value_by_key( $upload_file_key );
599
+ $filepath = MWF_Functions::fileurl_to_path( $upload_file_url );
600
+ if ( ! $upload_file_url || ! file_exists( $filepath ) ) {
601
+ unset( $upload_file_keys[ $key ] );
 
 
602
  }
603
  }
604
+
605
  $this->set( MWF_Config::UPLOAD_FILE_KEYS, $upload_file_keys );
606
  }
607
 
608
  /**
609
+ * Store uploaded files in UPLOAD_FILE_KEYS
610
  *
611
+ * @param array $uploaded_files Array of uploaded file url
612
  */
613
  public function push_uploaded_file_keys( array $uploaded_files = array() ) {
614
  $upload_file_keys = $this->get_post_value_by_key( MWF_Config::UPLOAD_FILE_KEYS );
615
+ if ( ! is_array( $upload_file_keys ) ) {
616
  $upload_file_keys = array();
617
+ $this->set( MWF_Config::UPLOAD_FILE_KEYS, $upload_file_keys );
618
  }
619
+
620
  foreach ( $uploaded_files as $key => $upload_file ) {
621
  $this->set( $key, $upload_file );
622
+ if ( is_array( $upload_file_keys ) && ! in_array( $key, $upload_file_keys ) ) {
623
  $this->push( MWF_Config::UPLOAD_FILE_KEYS, $key );
624
  }
625
  }
626
  }
627
 
628
  /**
629
+ * Set view flg that is shows the screen to be displayed
630
  *
631
+ * @param string null|input|confirm|complete
632
+ * @return void
633
  */
634
  public function set_view_flg( $view_flg ) {
635
+ $this->meta['view_flg'] = $view_flg;
636
  }
637
 
638
  /**
639
+ * Return view flg that is shows the screen to be displayed
640
  *
641
+ * @return string null|input|confirm|complete
642
  */
643
  public function get_view_flg() {
644
+ if ( isset( $this->meta['view_flg'] ) ) {
645
+ return $this->meta['view_flg'];
646
+ }
647
  }
648
 
649
  /**
650
+ * Set saved mail id
651
+ *
652
+ * @param int $saved_mail_id
653
+ * @return void
654
+ */
655
+ public function set_saved_mail_id( $saved_mail_id ) {
656
+ $this->meta['saved_mail_id'] = $saved_mail_id;
657
+ }
658
+
659
+ /**
660
+ * Return saved mail id
661
+ *
662
+ * @return int|null
663
+ */
664
+ public function get_saved_mail_id() {
665
+ if ( isset( $this->meta['saved_mail_id'] ) ) {
666
+ return $this->meta['saved_mail_id'];
667
+ }
668
+ }
669
+
670
+ /**
671
+ * Set send error flg
672
+ *
673
+ * @return void
674
  */
675
  public function set_send_error() {
676
+ $this->meta[ MWF_Config::SEND_ERROR ] = true;
677
  }
678
 
679
  /**
680
+ * Return send error flg
681
  *
682
  * @return boolean
683
  */
684
  public function get_send_error() {
685
+ if ( isset( $this->meta[ MWF_Config::SEND_ERROR ] ) ) {
686
+ return $this->meta[ MWF_Config::SEND_ERROR ];
687
+ }
688
+ }
689
+
690
+ /**
691
+ * Nonce check
692
+ *
693
+ * @return bool
694
+ */
695
+ protected function _is_valid_token() {
696
+ $request_token = $this->get_post_value_by_key( MWF_Config::TOKEN_NAME );
697
+ $values = $this->gets();
698
+ $form_key = $this->get_form_key();
699
+ return ( isset( $request_token ) && wp_verify_nonce( $request_token, $form_key ) );
700
+ }
701
+
702
+ /**
703
+ * Set the error message
704
+ *
705
+ * @param string $name
706
+ * @param string $rule
707
+ * @param string $message
708
+ */
709
+ public function set_validation_error( $name, $rule, $message ) {
710
+ if ( ! is_string( $message ) ) {
711
+ exit( 'The Validate error message must be string!' );
712
+ }
713
+ $errors = $this->get_validation_error( $name );
714
+ $errors[ $rule ] = $message;
715
+ $this->validation_errors[ $name ] = $errors;
716
+ }
717
+
718
+ /**
719
+ * Return error messages the one form field
720
+ *
721
+ * @param string $name
722
+ * @return array
723
+ */
724
+ public function get_validation_error( $name ) {
725
+ if ( isset( $this->validation_errors[ $name ] ) ) {
726
+ $errors = $this->validation_errors[ $name ];
727
+ } else {
728
+ $errors = array();
729
+ }
730
+ if ( is_null( $errors ) || ! is_array( $errors ) ) {
731
+ return array();
732
+ }
733
+ return $errors;
734
+ }
735
+
736
+ /**
737
+ * Return all error messages
738
+ *
739
+ * @return array
740
+ */
741
+ public function get_validation_errors() {
742
+ return $this->validation_errors;
743
  }
744
  }
classes/models/class.error.php DELETED
@@ -1,53 +0,0 @@
1
- <?php
2
- /**
3
- * Name : MW WP Form Error
4
- * Version : 1.1.0
5
- * Author : Takashi Kitajima
6
- * Author URI : http://2inc.org
7
- * Created : July 17, 2012
8
- * Modified : December 31, 2014
9
- * License : GPLv2 or later
10
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
- */
12
- class MW_WP_Form_Error {
13
-
14
- /**
15
- * エラー格納用の配列
16
- * @var array [key => rule = message]
17
- */
18
- protected $errors = array();
19
-
20
- /**
21
- * エラーメッセージをセット
22
- *
23
- * @param string $key name属性
24
- * @param string $rule
25
- * @param string $message
26
- */
27
- public function set_error( $key, $rule, $message ) {
28
- if ( !is_string( $message ) ) exit( 'The Validate error message must be string!');
29
- $this->errors[$key][$rule] = $message;
30
- }
31
-
32
- /**
33
- * エラーメッセージを返す
34
- *
35
- * @param string $key name属性
36
- * @return array
37
- */
38
- public function get_error( $key ) {
39
- if ( isset( $this->errors[$key] ) ) {
40
- return $this->errors[$key];
41
- }
42
- return array();
43
- }
44
-
45
- /**
46
- * 全てのエラーメッセージを返す
47
- *
48
- * @return array
49
- */
50
- public function get_errors() {
51
- return $this->errors;
52
- }
53
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/models/class.file.php CHANGED
@@ -1,30 +1,26 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form File
4
- * Description: Tempディレクトリ、ファイルアップロードの処理を行うクラス
5
- * Version : 1.0.9
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : October 10, 2013
9
- * Modified : September 28, 2016
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_File {
14
 
15
- /**
16
- * __construct
17
- */
18
  public function __construct() {
19
- add_filter( 'upload_mimes', array( $this, 'upload_mimes' ) );
20
  }
21
 
22
  /**
23
- * 独自の mimes を追加
24
  *
25
- * @param array $t MIMEタイプの配列
26
  */
27
- public function upload_mimes( $t ) {
28
  $t['psd'] = 'image/vnd.adobe.photoshop';
29
  $t['eps'] = 'application/octet-stream';
30
  $t['ai'] = 'application/pdf';
@@ -32,101 +28,102 @@ class MW_WP_Form_File {
32
  }
33
 
34
  /**
35
- * 全てのファイルをアップロード
36
  *
37
- * @param array $files アップロードするファイルの配列
38
- * @return array ( name属性値 => アップロードできたファイルのURL, )
39
  */
40
  public function upload( array $files = array() ) {
41
- $this->clean_temp_dir();
42
 
43
  $uploaded_files = array();
44
- foreach ( $files as $key => $file ) {
45
- $uploaded_file = $this->single_file_upload( $key );
46
- if ( $uploaded_file ) {
47
- $uploaded_files[$key] = $uploaded_file;
48
  }
 
49
  }
 
50
  return $uploaded_files;
51
  }
52
 
53
  /**
54
  * 指定したファイルをアップロード
55
  *
56
- * @param string $key アップロードしたいファイルの name 属性
57
- * @return string アップロードできたファイルのURL
58
  */
59
- protected function single_file_upload( $key ) {
60
  $this->create_temp_dir();
61
 
62
- $file = '';
63
- if ( is_array( $_FILES ) && isset( $_FILES[$key] ) ) {
64
- $file = $_FILES[$key];
65
- return $this->_file_upload( $file );
66
  }
 
 
 
67
  }
68
 
69
  /**
70
- * ファイルアップロードの実処理
71
  *
72
- * @param arary $file $_FILES['hoge'] の配列
73
- * @return string アップロードしたファイルの URL
74
  */
75
  protected function _file_upload( $file ) {
76
  if ( empty( $file['tmp_name'] ) ) {
77
- return;
78
  }
79
 
80
- $is_uploaded = false;
81
- if ( MWF_Functions::check_file_type( $file['tmp_name'], $file['name'] )
82
- && $file['error'] == UPLOAD_ERR_OK
83
- && is_uploaded_file( $file['tmp_name'] ) ) {
84
 
85
- $extension = pathinfo( $file['name'], PATHINFO_EXTENSION );
86
- $uploadfile = $this->set_upload_file_name( $extension );
87
 
88
- $is_uploaded = move_uploaded_file( $file['tmp_name'], $uploadfile['file'] );
89
- if ( $is_uploaded ) {
90
- return $uploadfile['url'];
91
- }
 
92
  }
 
 
93
  }
94
 
95
  /**
96
- * 一時ファイル名を生成。Tempディレクトリの生成に失敗していた場合はUploadディレクトリを使用
 
97
  *
98
- * @param string 拡張子 ( ex: jpg )
99
- * @return array ( file =>, url => )
100
  */
101
- protected function set_upload_file_name( $extension ) {
102
  $count = 0;
103
  $basename = uniqid( rand() );
104
  $temp_dir = $this->get_temp_dir();
105
  $upload_dir = $temp_dir['dir'];
106
  $upload_url = $temp_dir['url'];
107
- if ( !is_writable( $temp_dir['dir'] ) ) {
 
108
  $wp_upload_dir = wp_upload_dir();
109
  $upload_dir = $wp_upload_dir['path'];
110
  $upload_url = $wp_upload_dir['url'];
111
  }
112
 
113
- $filename_no_exension = $basename;
114
- $filepath_no_exension = trailingslashit( $upload_dir ) . $filename_no_exension;
115
- while ( glob( $filepath_no_exension . '.*' ) ) {
116
- $count ++;
117
- $filename_no_exension = $basename . '-' . $count;
118
- $filepath_no_exension = trailingslashit( $upload_dir ) . $filename_no_exension;
119
- }
120
- $filename = $filename_no_exension . '.' . $extension;
121
  $uploadfile['file'] = trailingslashit( $upload_dir ) . $filename;
122
  $uploadfile['url'] = trailingslashit( $upload_url ) . $filename;
 
123
  return $uploadfile;
124
  }
125
 
126
  /**
127
- * Temp ディレクトリ名(パス、URL)を返す。ディレクトリの存在可否は関係なし
128
  *
129
- * @return array ( dir => Tempディレクトリのパス, url => Tempディレクトリのurl )
130
  */
131
  public function get_temp_dir() {
132
  $wp_upload_dir = wp_upload_dir();
@@ -137,26 +134,28 @@ class MW_WP_Form_File {
137
  }
138
 
139
  /**
140
- * Temp ディレクトリを作成
141
  *
142
  * @return bool
143
  */
144
  public function create_temp_dir() {
145
- $_ret = false;
146
  $temp_dir = $this->get_temp_dir();
147
  $temp_dir = $temp_dir['dir'];
148
- if ( !file_exists( $temp_dir ) && !is_writable( $temp_dir ) ) {
149
- $_ret = wp_mkdir_p( trailingslashit( $temp_dir ) );
150
- @chmod( $temp_dir, 0733 );
151
- return $_ret;
152
  }
153
- return $_ret;
 
 
 
 
154
  }
155
 
156
  /**
157
- * Temp ディレクトリを削除
158
  *
159
- * @param string $sub_dir サブディレクトリ名
160
  */
161
  public function remove_temp_dir( $sub_dir = '' ) {
162
  $temp_dir = $this->get_temp_dir();
@@ -165,62 +164,60 @@ class MW_WP_Form_File {
165
  $temp_dir = trailingslashit( $temp_dir ) . $sub_dir;
166
  }
167
 
168
- if ( !file_exists( $temp_dir ) ) {
169
  return;
170
  }
 
171
  $handle = opendir( $temp_dir );
172
- if ( $handle === false ) {
173
  return;
174
  }
175
 
176
  while ( false !== ( $file = readdir( $handle ) ) ) {
177
- if ( $file !== '.' && $file !== '..' ) {
178
- if ( is_dir( trailingslashit( $temp_dir ) . $file ) ) {
179
- $this->remove_temp_dir( $file );
180
- } else {
181
- unlink( trailingslashit( $temp_dir ) . $file );
182
- }
 
 
183
  }
184
  }
 
185
  closedir( $handle );
186
  rmdir( $temp_dir );
187
  }
188
 
189
  /**
190
- * Tempディレクトリ内のファイルを削除
 
 
191
  */
192
- protected function clean_temp_dir() {
193
  $temp_dir = $this->get_temp_dir();
194
  $temp_dir = $temp_dir['dir'];
195
- if ( !file_exists( $temp_dir ) ) {
 
196
  return;
197
  }
 
198
  $handle = opendir( $temp_dir );
199
- if ( $handle === false ) {
200
  return;
201
  }
 
202
  while ( false !== ( $filename = readdir( $handle ) ) ) {
203
- if ( $filename !== '.' && $filename !== '..' &&
204
- !is_dir( trailingslashit( $temp_dir ) . $filename ) ) {
205
- $stat = stat( trailingslashit( $temp_dir ) . $filename );
206
- if ( $stat['mtime'] + 3600 < time() ) {
207
- unlink( trailingslashit( $temp_dir ) . $filename );
208
- }
209
  }
210
- }
211
- closedir( $handle );
212
- }
213
 
214
- /**
215
- * 指定したパスのファイルを削除
216
- *
217
- * @param array $attachments 消去するファイルパスの配列
218
- */
219
- public function delete_files( array $files ) {
220
- foreach ( $files as $file ) {
221
- if ( file_exists( $file ) ) {
222
- unlink( $file );
223
  }
224
  }
 
 
225
  }
226
  }
1
  <?php
2
  /**
3
  * Name : MW WP Form File
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : October 10, 2013
8
+ * Modified : June 1, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_File {
13
 
 
 
 
14
  public function __construct() {
15
+ add_filter( 'upload_mimes', array( $this, '_upload_mimes' ) );
16
  }
17
 
18
  /**
19
+ * Add mimes
20
  *
21
+ * @param array $t array of MIME types
22
  */
23
+ public function _upload_mimes( $t ) {
24
  $t['psd'] = 'image/vnd.adobe.photoshop';
25
  $t['eps'] = 'application/octet-stream';
26
  $t['ai'] = 'application/pdf';
28
  }
29
 
30
  /**
31
+ * Upload all files
32
  *
33
+ * @param array $files array of upload files
34
+ * @return array (name => uploaded file url)
35
  */
36
  public function upload( array $files = array() ) {
37
+ $this->_clean_temp_dir();
38
 
39
  $uploaded_files = array();
40
+ foreach ( $files as $name => $file ) {
41
+ $uploaded_file = $this->_single_file_upload( $name );
42
+ if ( ! $uploaded_file ) {
43
+ continue;
44
  }
45
+ $uploaded_files[ $name ] = $uploaded_file;
46
  }
47
+
48
  return $uploaded_files;
49
  }
50
 
51
  /**
52
  * 指定したファイルをアップロード
53
  *
54
+ * @param string $name
55
+ * @return string Uploaded file URL
56
  */
57
+ protected function _single_file_upload( $name ) {
58
  $this->create_temp_dir();
59
 
60
+ if ( ! is_array( $_FILES ) || ! isset( $_FILES[ $name ] ) ) {
61
+ return;
 
 
62
  }
63
+
64
+ $file = $_FILES[ $name ];
65
+ return $this->_file_upload( $file );
66
  }
67
 
68
  /**
69
+ * Upload process
70
  *
71
+ * @param arary $file $_FILES['name']
72
+ * @return string Uploaded file URL
73
  */
74
  protected function _file_upload( $file ) {
75
  if ( empty( $file['tmp_name'] ) ) {
76
+ return false;
77
  }
78
 
79
+ if ( ! MWF_Functions::check_file_type( $file['tmp_name'], $file['name'] )
80
+ || ! $file['error'] == UPLOAD_ERR_OK
81
+ || ! is_uploaded_file( $file['tmp_name'] ) ) {
 
82
 
83
+ return false;
84
+ }
85
 
86
+ $extension = pathinfo( $file['name'], PATHINFO_EXTENSION );
87
+ $uploadfile = $this->_set_upload_file_name( $extension );
88
+ $is_uploaded = move_uploaded_file( $file['tmp_name'], $uploadfile['file'] );
89
+ if ( ! $is_uploaded ) {
90
+ return false;
91
  }
92
+
93
+ return $uploadfile['url'];
94
  }
95
 
96
  /**
97
+ * Generate temp file name
98
+ * If doesn't generate temp directory, using upload directory
99
  *
100
+ * @param string ext
101
+ * @return array (file =>, url =>)
102
  */
103
+ protected function _set_upload_file_name( $extension ) {
104
  $count = 0;
105
  $basename = uniqid( rand() );
106
  $temp_dir = $this->get_temp_dir();
107
  $upload_dir = $temp_dir['dir'];
108
  $upload_url = $temp_dir['url'];
109
+
110
+ if ( ! is_writable( $temp_dir['dir'] ) ) {
111
  $wp_upload_dir = wp_upload_dir();
112
  $upload_dir = $wp_upload_dir['path'];
113
  $upload_url = $wp_upload_dir['url'];
114
  }
115
 
116
+ $filename = wp_unique_filename( trailingslashit( $upload_dir ), $basename . '.' . $extension );
 
 
 
 
 
 
 
117
  $uploadfile['file'] = trailingslashit( $upload_dir ) . $filename;
118
  $uploadfile['url'] = trailingslashit( $upload_url ) . $filename;
119
+
120
  return $uploadfile;
121
  }
122
 
123
  /**
124
+ * Return array of temp directory. Return directory even if it does not exist
125
  *
126
+ * @return array (dir => temp directory path, url => temp directory url)
127
  */
128
  public function get_temp_dir() {
129
  $wp_upload_dir = wp_upload_dir();
134
  }
135
 
136
  /**
137
+ * Create temp directory
138
  *
139
  * @return bool
140
  */
141
  public function create_temp_dir() {
 
142
  $temp_dir = $this->get_temp_dir();
143
  $temp_dir = $temp_dir['dir'];
144
+
145
+ if ( file_exists( $temp_dir ) ) {
146
+ return is_writable( $temp_dir );
 
147
  }
148
+
149
+ $is_created = wp_mkdir_p( trailingslashit( $temp_dir ) );
150
+ $is_created = chmod( $temp_dir, 0733 );
151
+
152
+ return $is_created;
153
  }
154
 
155
  /**
156
+ * Delete temp directory
157
  *
158
+ * @param string $sub_dir
159
  */
160
  public function remove_temp_dir( $sub_dir = '' ) {
161
  $temp_dir = $this->get_temp_dir();
164
  $temp_dir = trailingslashit( $temp_dir ) . $sub_dir;
165
  }
166
 
167
+ if ( ! file_exists( $temp_dir ) ) {
168
  return;
169
  }
170
+
171
  $handle = opendir( $temp_dir );
172
+ if ( false === $handle ) {
173
  return;
174
  }
175
 
176
  while ( false !== ( $file = readdir( $handle ) ) ) {
177
+ if ( '.' === $file || '..' === $file ) {
178
+ continue;
179
+ }
180
+
181
+ if ( is_dir( trailingslashit( $temp_dir ) . $file ) ) {
182
+ $this->remove_temp_dir( $file );
183
+ } else {
184
+ unlink( trailingslashit( $temp_dir ) . $file );
185
  }
186
  }
187
+
188
  closedir( $handle );
189
  rmdir( $temp_dir );
190
  }
191
 
192
  /**
193
+ * Delete files in temp directory
194
+ *
195
+ * @return void
196
  */
197
+ protected function _clean_temp_dir() {
198
  $temp_dir = $this->get_temp_dir();
199
  $temp_dir = $temp_dir['dir'];
200
+
201
+ if ( ! file_exists( $temp_dir ) ) {
202
  return;
203
  }
204
+
205
  $handle = opendir( $temp_dir );
206
+ if ( false === $handle ) {
207
  return;
208
  }
209
+
210
  while ( false !== ( $filename = readdir( $handle ) ) ) {
211
+ if ( '.' === $filename && '..' === $filename || is_dir( trailingslashit( $temp_dir ) . $filename ) ) {
212
+ continue;
 
 
 
 
213
  }
 
 
 
214
 
215
+ $stat = stat( trailingslashit( $temp_dir ) . $filename );
216
+ if ( $stat['mtime'] + 3600 < time() ) {
217
+ unlink( trailingslashit( $temp_dir ) . $filename );
 
 
 
 
 
 
218
  }
219
  }
220
+
221
+ closedir( $handle );
222
  }
223
  }
classes/models/class.form-fields.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Name : MW WP Form Form Fields
4
+ * Version : 1.0.0
5
+ * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
+ * Created : June 1, 2017
8
+ * Modified :
9
+ * License : GPLv2 or later
10
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
+ */
12
+ class MW_WP_Form_Form_Fields {
13
+
14
+ /**
15
+ * @var array Array of MW_WP_Form_Form_Fields
16
+ */
17
+ protected static $Instances;
18
+
19
+ /**
20
+ * @var array
21
+ */
22
+ protected static $form_fields = array();
23
+
24
+ private function __construct() {
25
+ foreach ( glob( plugin_dir_path( __FILE__ ) . '../form-fields/*.php' ) as $filename ) {
26
+ $class_name = self::_get_class_name_from_form_field_filename( $filename );
27
+ if ( ! class_exists( $class_name ) ) {
28
+ continue;
29
+ }
30
+
31
+ new $class_name();
32
+ }
33
+
34
+ self::$form_fields = apply_filters( 'mwform_form_fields', self::$form_fields );
35
+ }
36
+
37
+ public static function instantiation( $form_key ) {
38
+ if ( isset( self::$Instances[ $form_key ] ) ) {
39
+ return self::$Instances[ $form_key ];
40
+ }
41
+
42
+ self::$Instances[ $form_key ] = new self();
43
+ return self::$Instances[ $form_key ];
44
+ }
45
+
46
+ /**
47
+ * Return all form fields
48
+ *
49
+ * @return array
50
+ */
51
+ public function get_form_fields() {
52
+ return self::$form_fields;
53
+ }
54
+
55
+ /**
56
+ * Return class name from filename of input form field
57
+ *
58
+ * @param string $filename
59
+ * @return string
60
+ */
61
+ protected static function _get_class_name_from_form_field_filename( $filename ) {
62
+ $class_name = preg_replace( '/^class\./', '', basename( $filename, '.php' ) );
63
+ $class_name = str_replace( '-', '_', $class_name );
64
+ $class_name = 'MW_WP_Form_Field_' . $class_name;
65
+ return $class_name;
66
+ }
67
+ }
classes/models/class.form.php CHANGED
@@ -1,193 +1,201 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Form
4
- * Description: フォームヘルパー
5
- * Version : 1.11.0
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : September 25, 2012
9
- * Modified : March 9, 2017
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Form {
14
 
15
  /**
16
- * データを返す
17
  *
18
- * @param string $key name属性値
19
  * @return mixed
20
  */
21
- public function get_raw( $key ) {
22
  MWF_Functions::deprecated_message(
23
  'MW_WP_Form_Form::get_raw()',
24
  'MW_WP_Form_Data::get_raw()'
25
  );
26
- $Data = MW_WP_Form_Data::getInstance();
27
- return $Data->get_raw( $key );
28
  }
29
 
30
  /**
31
- * $children の中に値が含まれているときだけ返す
32
  *
33
- * @param string $key name属性
34
  * @param array $children
35
  * @return string
36
  */
37
- public function get_raw_in_children( $key, array $children ) {
38
  MWF_Functions::deprecated_message(
39
  'MW_WP_Form_Form::get_raw_in_children()',
40
  'MW_WP_Form_Data::get_raw_in_children()'
41
  );
42
- $Data = MW_WP_Form_Data::getInstance();
43
- return $Data->get_raw_in_children( $key, $children );
44
  }
45
 
46
  /**
47
- * データを返す ( 郵便番号用 )
48
  *
49
- * @param string $key name属性
50
- * @return string データ
51
  */
52
- public function get_zip_value( $key ) {
53
  MWF_Functions::deprecated_message(
54
  'MW_WP_Form_Form::get_zip_value()',
55
  'MW_WP_Form_Data::get_separated_value()'
56
  );
57
- $Data = MW_WP_Form_Data::getInstance();
58
- return $Data->get_separated_value( $key );
59
  }
60
 
61
  /**
62
- * データを返す ( 電話番号用 )
63
  *
64
- * @param string $key name属性
65
- * @return string データ
66
  */
67
- public function get_tel_value( $key ) {
68
  MWF_Functions::deprecated_message(
69
  'MW_WP_Form_Form::get_tel_value()',
70
  'MW_WP_Form_Data::get_separated_value()'
71
  );
72
- $Data = MW_WP_Form_Data::getInstance();
73
- return $Data->get_separated_value( $key );
74
  }
75
 
76
  /**
77
- * データを返す( checkbox用 )。$dataに含まれる値のみ返す
78
  *
79
- * @param string $key name属性
80
  * @param array $data
81
- * @return string データ
82
  */
83
- public function get_checked_value( $key, array $data ) {
84
  MWF_Functions::deprecated_message(
85
  'MW_WP_Form_Form::get_checked_value()',
86
  'MW_WP_Form_Data::get_separated_value()'
87
  );
88
- $Data = MW_WP_Form_Data::getInstance();
89
- return $Data->get_separated_value( $key, $data );
90
  }
91
 
92
  /**
93
- * データを返す( radio用 )。$dataに含まれる値のみ返す
94
  *
95
- * @param string name属性値
96
- * @param array $data データ
97
  * @return string
98
  */
99
- public function get_radio_value( $key, array $data ) {
100
  MWF_Functions::deprecated_message(
101
  'MW_WP_Form_Form::get_radio_value()',
102
  'MW_WP_Form_Data::get_in_children()'
103
  );
104
- $Data = MW_WP_Form_Data::getInstance();
105
- return $Data->get_in_children( $key, $data );
106
  }
107
 
108
  /**
109
- * データを返す( selectbox用 )。$dataに含まれる値のみ返す
110
  *
111
- * @param string $key name属性
112
- * @param array $data データ
113
- * @return string データ
114
  */
115
- public function get_selected_value( $key, array $data ) {
116
  MWF_Functions::deprecated_message(
117
  'MW_WP_Form_Form::get_selected_value()',
118
  'MW_WP_Form_Data::get_in_children()'
119
  );
120
- $Data = MW_WP_Form_Data::getInstance();
121
- return $Data->get_in_children( $key, $data );
122
  }
123
 
124
  /**
125
- * 配列データを整形して返す ( チェックボックス等用 )。配列の場合はpost値を連結して返す
126
  *
127
- * @param string $key name属性
128
- * @param array $children 選択肢
129
- * @return string データ
130
  */
131
- public function get_separated_raw_value( $key, array $children = array() ) {
132
  MWF_Functions::deprecated_message(
133
  'MW_WP_Form_Form::get_separated_raw_value()',
134
  'MW_WP_Form_Data::get_separated_raw_value()'
135
  );
136
- $Data = MW_WP_Form_Data::getInstance();
137
- return $Data->get_separated_raw_value( $key, $children );
138
  }
139
 
140
  /**
141
- * separator を設定するためのhiddenを返す
142
  *
143
- * @param string $key name属性
144
- * @param string $separator 区切り文字
145
- * @return string HTML
146
  */
147
- public function separator( $key, $separator ) {
148
  if ( $separator ) {
149
- return $this->hidden( $key . '[separator]', $separator );
150
  }
151
  }
152
 
153
  /**
154
- * 送られてきた separator を返す
155
  *
156
- * @param string $key name属性
157
  * @return string
158
  */
159
- public function get_separator_value( $key ) {
160
  MWF_Functions::deprecated_message(
161
  'MW_WP_Form_Form::get_separator_value()',
162
  'MW_WP_Form_Data::get_separator_value()'
163
  );
164
- return $Data->get_separator_value( $key );
165
  }
166
 
167
  /**
168
- * children を設定するための hidden を返す
169
  *
170
- * @param string $key name属性
171
- * @param array $children 選択肢の配列(必ず MW_WP_Form_Abstract_Form_Field::get_children の値 )
172
- * @return string HTML
173
  */
174
- public function children( $key, array $children ) {
175
- $name = sprintf( '__children[%s][]', $key );
176
  return $this->hidden( $name, json_encode( $children ) );
177
  }
178
 
179
  /**
180
- * フォームタグ生成
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
181
  *
182
  * @param array $options
183
- * @return string form開始タグ
184
  */
185
  public function start( $options = array() ) {
186
- $defaults = array(
187
  'action' => '',
188
  'enctype' => 'multipart/form-data',
189
- );
190
- $options = array_merge( $defaults, $options );
191
  return sprintf(
192
  '<form method="post" action="%s" enctype="%s">',
193
  esc_attr( $options['action'] ),
@@ -196,9 +204,9 @@ class MW_WP_Form_Form {
196
  }
197
 
198
  /**
199
- * トークンタグ、閉じタグ生成
200
  *
201
- * @return string input[type=hidden]
202
  */
203
  public function end() {
204
  $html = '';
@@ -208,11 +216,11 @@ class MW_WP_Form_Form {
208
  }
209
 
210
  /**
211
- * input[type=text]タグ生成
212
  *
213
- * @param string $name name属性
214
- * @param array
215
- * @return string html
216
  */
217
  public function text( $name, $options = array() ) {
218
  $defaults = array(
@@ -224,22 +232,23 @@ class MW_WP_Form_Form {
224
  'placeholder' => null,
225
  'conv-half-alphanumeric' => null,
226
  );
227
- $options = array_merge( $defaults, $options );
228
- $attributes = $this->generate_attributes( $options );
229
 
230
- return self::remove_linefeed_space( sprintf(
231
- '<input type="text" name="%s"%s />',
232
- esc_attr( $name ),
233
- $attributes
234
  ) );
 
 
 
 
235
  }
236
 
237
  /**
238
- * input[type=email]タグ生成
239
  *
240
- * @param string $name name属性
241
- * @param array
242
- * @return string html
243
  */
244
  public function email( $name, $options = array() ) {
245
  $defaults = array(
@@ -251,22 +260,22 @@ class MW_WP_Form_Form {
251
  'placeholder' => null,
252
  'conv-half-alphanumeric' => null,
253
  );
254
- $options = array_merge( $defaults, $options );
255
- $attributes = $this->generate_attributes( $options );
256
-
257
- return self::remove_linefeed_space( sprintf(
258
- '<input type="email" name="%s"%s />',
259
- esc_attr( $name ),
260
- $attributes
261
  ) );
 
 
 
 
262
  }
263
 
264
  /**
265
- * input[type=url]タグ生成
266
  *
267
- * @param string $name name属性
268
- * @param array
269
- * @return string html
270
  */
271
  public function url( $name, $options = array() ) {
272
  $defaults = array(
@@ -278,22 +287,22 @@ class MW_WP_Form_Form {
278
  'placeholder' => null,
279
  'conv-half-alphanumeric' => null,
280
  );
281
- $options = array_merge( $defaults, $options );
282
- $attributes = $this->generate_attributes( $options );
283
-
284
- return self::remove_linefeed_space( sprintf(
285
- '<input type="url" name="%s"%s />',
286
- esc_attr( $name ),
287
- $attributes
288
  ) );
 
 
 
 
289
  }
290
 
291
  /**
292
- * input[type=range]タグ生成
293
  *
294
- * @param string $name name属性
295
- * @param array
296
- * @return string html
297
  */
298
  public function range( $name, $options = array() ) {
299
  $defaults = array(
@@ -304,22 +313,22 @@ class MW_WP_Form_Form {
304
  'max' => 100,
305
  'step' => 1,
306
  );
307
- $options = array_merge( $defaults, $options );
308
- $attributes = $this->generate_attributes( $options );
309
-
310
- return self::remove_linefeed_space( sprintf(
311
- '<input type="range" name="%s"%s />',
312
- esc_attr( $name ),
313
- $attributes
314
  ) );
 
 
 
 
315
  }
316
 
317
  /**
318
- * input[type=number]タグ生成
319
  *
320
- * @param string $name name属性
321
- * @param array
322
- * @return string html
323
  */
324
  public function number( $name, $options = array() ) {
325
  $defaults = array(
@@ -331,37 +340,36 @@ class MW_WP_Form_Form {
331
  'step' => 1,
332
  'placeholder' => null,
333
  );
334
- $options = array_merge( $defaults, $options );
335
- $attributes = $this->generate_attributes( $options );
336
-
337
- return self::remove_linefeed_space( sprintf(
338
- '<input type="number" name="%s"%s />',
339
- esc_attr( $name ),
340
- $attributes
341
  ) );
 
 
 
 
342
  }
343
 
344
  /**
345
- * input[type=hidden]タグ生成
346
  *
347
- * @param string $name name属性
348
- * @param string $value
349
- * @return string HTML
350
  */
351
  public function hidden( $name, $value ) {
352
- return self::remove_linefeed_space( sprintf(
353
- '<input type="hidden" name="%s" value="%s" />',
354
- esc_attr( $name ),
355
- esc_attr( $value )
356
  ) );
357
  }
358
 
359
  /**
360
- * input[type=password]タグ生成
361
  *
362
- * @param string $name name属性
363
  * @param array $options
364
- * @return string HTML
365
  */
366
  public function password( $name, $options = array() ) {
367
  $defaults = array(
@@ -372,22 +380,22 @@ class MW_WP_Form_Form {
372
  'value' => '',
373
  'placeholder' => null,
374
  );
375
- $options = array_merge( $defaults, $options );
376
- $attributes = $this->generate_attributes( $options );
377
-
378
- return self::remove_linefeed_space( sprintf(
379
- '<input type="password" name="%s"%s />',
380
- esc_attr( $name ),
381
- $attributes
382
  ) );
 
 
 
 
383
  }
384
 
385
  /**
386
- * 郵便番号フィールド生成
387
  *
388
- * @param string $name name属性
389
  * @param array $options
390
- * @return string HTML
391
  */
392
  public function zip( $name, $options = array() ) {
393
  $defaults = array(
@@ -395,7 +403,7 @@ class MW_WP_Form_Form {
395
  'conv-half-alphanumeric' => null,
396
  'value' => '',
397
  );
398
- $options = array_merge( $defaults, $options );
399
 
400
  $children = array();
401
  $separator = '-';
@@ -408,39 +416,43 @@ class MW_WP_Form_Form {
408
 
409
  $values = array( '', '' );
410
  foreach ( $children as $key => $val ) {
411
- if ( $key === 0 || $key === 1 ) {
412
- $values[$key] = $val;
413
  }
414
  }
415
 
416
- $_ret = '<span class="mwform-zip-field">';
417
- $_ret .= '';
418
- $_ret .= $this->text( $name . '[data][0]', array(
419
- 'class' => $options['class'],
420
- 'size' => 4,
421
- 'maxlength' => 3,
422
- 'value' => $values[0],
423
- 'conv-half-alphanumeric' => $options['conv-half-alphanumeric'],
424
- ) );
425
- $_ret .= ' ' . $separator . ' ';
426
- $_ret .= $this->text( $name . '[data][1]', array(
427
- 'class' => $options['class'],
428
- 'size' => 5,
429
- 'maxlength' => 4,
430
- 'value' => $values[1],
431
- 'conv-half-alphanumeric' => $options['conv-half-alphanumeric'],
432
- ) );
433
- $_ret .= $this->separator( $name, $separator );
434
- $_ret .= '</span>';
435
- return self::remove_linefeed_space( $_ret );
436
- }
437
-
438
- /**
439
- * 電話番号フィールド生成
440
- *
441
- * @param string $name name属性
 
 
 
 
442
  * @param array $options
443
- * @return string HTML
444
  */
445
  public function tel( $name, $options = array() ) {
446
  $defaults = array(
@@ -448,7 +460,7 @@ class MW_WP_Form_Form {
448
  'conv-half-alphanumeric' => null,
449
  'value' => '',
450
  );
451
- $options = array_merge( $defaults, $options );
452
 
453
  $children = array();
454
  $separator = '-';
@@ -462,45 +474,50 @@ class MW_WP_Form_Form {
462
  $values = array( '', '', '' );
463
  foreach ( $children as $key => $val ) {
464
  if ( $key === 0 || $key === 1 || $key === 2 ) {
465
- $values[$key] = $val;
466
  }
467
  }
468
 
469
- $_ret = '<span class="mwform-tel-field">';
470
- $_ret .= $this->text( $name . '[data][0]', array(
471
- 'class' => $options['class'],
472
- 'size' => 6,
473
- 'maxlength' => 5,
474
- 'value' => $values[0],
475
- 'conv-half-alphanumeric' => $options['conv-half-alphanumeric'],
476
- ) );
477
- $_ret .= ' ' . $separator . ' ';
478
- $_ret .= $this->text( $name . '[data][1]', array(
479
- 'class' => $options['class'],
480
- 'size' => 5,
481
- 'maxlength' => 4,
482
- 'value' => $values[1],
483
- 'conv-half-alphanumeric' => $options['conv-half-alphanumeric'],
484
- ) );
485
- $_ret .= ' ' . $separator . ' ';
486
- $_ret .= $this->text( $name . '[data][2]', array(
487
- 'class' => $options['class'],
488
- 'size' => 5,
489
- 'maxlength' => 4,
490
- 'value' => $values[2],
491
- 'conv-half-alphanumeric' => $options['conv-half-alphanumeric'],
492
- ) );
493
- $_ret .= $this->separator( $name, $separator );
494
- $_ret .= '</span>';
495
- return self::remove_linefeed_space( $_ret );
496
- }
497
-
498
- /**
499
- * textareaタグ生成
500
- *
501
- * @param string $name name属性
 
 
 
 
 
502
  * @param array $options
503
- * @return string html
504
  */
505
  public function textarea( $name, $options = array() ) {
506
  $defaults = array(
@@ -511,26 +528,23 @@ class MW_WP_Form_Form {
511
  'value' => '',
512
  'placeholder' => null,
513
  );
514
- $options = array_merge( $defaults, $options );
515
- $_options = $options;
516
- unset( $_options['value'] );
517
- $attributes = $this->generate_attributes( $_options );
518
-
519
- return self::remove_linefeed_space( sprintf(
520
- '<textarea name="%s"%s>%s</textarea>',
521
- esc_attr( $name ),
522
- $attributes,
523
- esc_html( $options['value'] )
524
  ) );
 
 
 
 
525
  }
526
 
527
  /**
528
- * selectタグ生成
529
  *
530
- * @param string $name name属性
531
  * @param array $children
532
  * @param array $options
533
- * @return string HTML
534
  */
535
  public function select( $name, $children = array(), $options = array() ) {
536
  $defaults = array(
@@ -538,36 +552,24 @@ class MW_WP_Form_Form {
538
  'id' => null,
539
  'value' => '',
540
  );
541
- $options = array_merge( $defaults, $options );
 
 
 
 
542
 
543
- $_options = $options;
544
- unset( $_options['value'] );
545
- $attributes = $this->generate_attributes( $_options );
546
- $_ret = sprintf(
547
- '<select name="%s"%s>',
548
- esc_attr( $name ),
549
- $attributes
550
  );
551
-
552
- foreach ( $children as $key => $_value ) {
553
- $_ret .= sprintf(
554
- '<option value="%s" %s>%s</option>',
555
- esc_attr( $key ),
556
- selected( $key, $options['value'], false ),
557
- esc_html( $_value )
558
- );
559
- }
560
- $_ret .= '</select>';
561
- return self::remove_linefeed_space( $_ret );
562
  }
563
 
564
  /**
565
- * radioタグ生成
566
  *
567
- * @param string $name name属性
568
  * @param array $children
569
  * @param array $options
570
- * @return string HTML
571
  */
572
  public function radio( $name, $children = array(), $options = array() ) {
573
  $defaults = array(
@@ -576,47 +578,37 @@ class MW_WP_Form_Form {
576
  'value' => '',
577
  'vertically' => null,
578
  );
579
- $options = array_merge( $defaults, $options );
580
 
581
- $i = 0;
582
- $_ret = '';
583
- foreach ( $children as $key => $_value ) {
584
  $i ++;
585
- $vertically = ( $options['vertically'] === 'true' ) ? 'vertical-item' : 'horizontal-item';
586
- $attributes_for_label = $this->generate_attributes( array(
587
- 'for' => $this->get_attr_id( $options['id'], $i ),
588
- ) );
589
- $attributes = $this->generate_attributes( array(
590
- 'id' => $this->get_attr_id( $options['id'], $i ),
591
  'class' => $options['class'],
592
- ) );
593
- $_ret .= sprintf(
594
- '<span class="mwform-radio-field %s">
595
- <label%s>
596
- <input type="radio" name="%s" value="%s"%s %s />
597
- <span class="mwform-radio-field-text">%s</span>
598
- </label>
599
- </span>',
600
- $vertically,
601
- $attributes_for_label,
602
- esc_attr( $name ),
603
- esc_attr( $key ),
604
- checked( $key, $options['value'], false ),
605
- $attributes,
606
- esc_html( $_value )
607
  );
608
  }
609
- return self::remove_linefeed_space( $_ret );
 
 
 
 
 
 
 
610
  }
611
 
612
  /**
613
- * checkboxタグ生成
614
  *
615
- * @param string $name name属性
616
  * @param array $children
617
  * @param array $options
618
- * @param string $separator 区切り文字
619
- * @return string HTML
620
  */
621
  public function checkbox( $name, $children = array(), $options = array(), $separator = ',' ) {
622
  $defaults = array(
@@ -625,143 +617,139 @@ class MW_WP_Form_Form {
625
  'value' => '',
626
  'vertically' => null,
627
  );
628
- $options = array_merge( $defaults, $options );
629
 
630
- $value = $options['value'];
631
- if ( !is_array( $options['value'] ) ) {
632
- $value = explode( $separator, $options['value'] );
 
 
 
633
  }
634
 
635
- $i = 0;
636
- $_ret = '';
637
- foreach ( $children as $key => $_value ) {
638
  $i ++;
639
- $vertically = ( $options['vertically'] === 'true' ) ? 'vertical-item' : 'horizontal-item';
640
- $attributes_for_label = $this->generate_attributes( array(
641
- 'for' => $this->get_attr_id( $options['id'], $i ),
642
- ) );
643
- $attributes = $this->generate_attributes( array(
644
- 'id' => $this->get_attr_id( $options['id'], $i ),
645
  'class' => $options['class'],
646
- ) );
647
- $_ret .= sprintf(
648
- '<span class="mwform-checkbox-field %s">
649
- <label%s>
650
- <input type="checkbox" name="%s" value="%s"%s %s />
651
- <span class="mwform-checkbox-field-text">%s</span>
652
- </label>
653
- </span>',
654
- $vertically,
655
- $attributes_for_label,
656
- esc_attr( $name . '[data][]' ),
657
- esc_attr( $key ),
658
- $attributes,
659
- checked( ( is_array( $value ) && in_array( $key, $value ) ), true, false ),
660
- esc_html( $_value )
661
  );
662
  }
663
- $_ret .= $this->separator( $name, $separator );
664
- return self::remove_linefeed_space( $_ret );
 
 
 
 
 
 
665
  }
666
 
667
  /**
668
- * submitボタン生成
669
  *
670
- * @param string $name name属性
671
- * @param string $value value属性
672
  * @param array $options
673
- * @return string submitボタン
674
  */
675
  public function submit( $name, $value, $options = array() ) {
676
  $defaults = array(
677
  'class' => null,
678
  );
679
- $options = array_merge( $defaults, $options );
680
- $attributes = $this->generate_attributes( $options );
681
- return self::remove_linefeed_space( sprintf(
682
- '<input type="submit" name="%s" value="%s"%s />',
683
- esc_attr( $name ),
684
- esc_attr( $value ),
685
- $attributes
686
  ) );
 
 
 
 
687
  }
688
 
689
  /**
690
- * submitボタン(button)生成
691
  *
692
- * @param string $name name属性
693
- * @param string $value value属性
694
  * @param array $options
695
  * @param string $element_content
696
- * @return string submitボタン(button)
697
  */
698
  public function button_submit( $name, $value, $options = array(), $element_content = '' ) {
699
  $defaults = array(
700
  'class' => null,
701
  );
702
- $options = array_merge( $defaults, $options );
703
- $attributes = $this->generate_attributes( $options );
704
- return self::remove_linefeed_space( sprintf(
705
- '<button type="submit" name="%1$s" value="%2$s"%3$s>%4$s</button>',
706
- esc_attr( $name ),
707
- esc_attr( $value ),
708
- $attributes,
709
- wp_kses_post( $element_content )
710
  ) );
 
 
 
 
711
  }
712
 
713
  /**
714
- * ボタン生成
715
  *
716
- * @param string $name name属性
717
- * @param string $value value属性
718
  * @param array $options
719
- * @return string ボタン
720
  */
721
  public function button( $name, $value, $options = array() ) {
722
  $defaults = array(
723
  'class' => null,
724
  );
725
- $options = array_merge( $defaults, $options );
726
- $attributes = $this->generate_attributes( $options );
727
- return self::remove_linefeed_space( sprintf(
728
- '<input type="button" name="%s" value="%s"%s />',
729
- esc_attr( $name ),
730
- esc_attr( $value ),
731
- $attributes
732
  ) );
 
 
 
 
733
  }
734
 
735
  /**
736
- * ボタン(button)生成
737
  *
738
- * @param string $name name属性
739
- * @param string $value value属性
740
  * @param array $options
741
  * @param string $element_content
742
- * @return string ボタン(button)
743
  */
744
  public function button_button( $name, $value, $options = array(), $element_content = '' ) {
745
  $defaults = array(
746
  'class' => null,
747
  );
748
- $options = array_merge( $defaults, $options );
749
- $attributes = $this->generate_attributes( $options );
750
- return self::remove_linefeed_space( sprintf(
751
- '<button type="button" name="%1$s" value="%2$s"%3$s>%4$s</button>',
752
- esc_attr( $name ),
753
- esc_attr( $value ),
754
- $attributes,
755
- wp_kses_post( $element_content )
756
  ) );
 
 
 
 
757
  }
758
 
759
  /**
760
- * datepicker生成
761
  *
762
- * @param string $name name属性
763
  * @param string $options
764
- * @return string HTML
765
  */
766
  public function datepicker( $name, $options = array() ) {
767
  $defaults = array(
@@ -772,30 +760,22 @@ class MW_WP_Form_Form {
772
  'value' => '',
773
  'placeholder' => null,
774
  );
775
- $options = array_merge( $defaults, $options );
776
- $_options = $options;
777
- unset( $_options['js'] );
778
- $attributes = $this->generate_attributes( $_options );
779
 
780
- $_ret = sprintf(
781
- '<input type="text" name="%s"%s />',
782
- esc_attr( $name ),
783
- $attributes
784
  );
785
- $_ret .= sprintf(
786
- '<script type="text/javascript">jQuery( function( $ ) { $("input[name=\'%s\']").datepicker( { %s } ); } );</script>',
787
- esc_js( $name ),
788
- trim( $options['js'], '{}' )
789
- );
790
- return self::remove_linefeed_space( $_ret );
791
  }
792
 
793
  /**
794
- * monthpicker生成
795
  *
796
- * @param string $name name属性
797
  * @param string $options
798
- * @return string HTML
799
  */
800
  public function monthpicker( $name, $options = array() ) {
801
  $defaults = array(
@@ -806,52 +786,42 @@ class MW_WP_Form_Form {
806
  'value' => '',
807
  'placeholder' => null,
808
  );
809
- $options = array_merge( $defaults, $options );
810
- $_options = $options;
811
- unset( $_options['js'] );
812
- $attributes = $this->generate_attributes( $_options );
813
-
814
- $_ret = sprintf(
815
- '<input type="text" name="%s"%s />',
816
- esc_attr( $name ),
817
- $attributes
818
- );
819
- if ( $name ) {
820
- $_ret .= sprintf(
821
- '<script type="text/javascript">jQuery( function( $ ) { $("input[name=\'%s\']").MonthPicker( { %s } ); } );</script>',
822
- esc_js( $name ),
823
- trim( $options['js'], '{}' )
824
- );
825
- }
826
- return self::remove_linefeed_space( $_ret );
827
  }
828
 
829
  /**
830
- * input[type=file]タグ生成
831
  *
832
- * @param string $name name属性
833
- * @param $options array
834
- * @return string HTML
835
  */
836
  public function file( $name, $options = array() ) {
837
  $defaults = array(
838
  'id' => null,
839
  'class' => null,
840
  );
841
- $options = array_merge( $defaults, $options );
842
- $attributes = $this->generate_attributes( $options );
843
-
844
- return self::remove_linefeed_space( sprintf(
845
- '<input type="file" name="%1$s"%2$s /><span data-mwform-file-delete="%1$s" class="mwform-file-delete">&times;</span>',
846
- esc_attr( $name ),
847
- $attributes
848
  ) );
 
 
 
 
849
  }
850
 
851
  /**
852
  * タグの属性を最適化して生成する
853
- * ※テストしやすいようにアクセス修飾子を public に
854
  *
 
855
  * @param array $_attributes キーが属性名、要素が属性値の配列。要素が null のときは無視する
856
  */
857
  public function generate_attributes( array $_attributes ) {
@@ -860,7 +830,7 @@ class MW_WP_Form_Form {
860
  if ( is_null( $value ) ) {
861
  continue;
862
  }
863
- if ( $key === 'conv-half-alphanumeric' ) {
864
  $key = 'data-conv-half-alphanumeric';
865
  }
866
  $attributes[] = sprintf( '%s="%s"', $key, esc_attr( $value ) );
@@ -872,19 +842,21 @@ class MW_WP_Form_Form {
872
  }
873
 
874
  /**
875
- * id属性を返す
876
  *
877
  * @param string $id
878
  * @param string $suffix
879
  * @return string
880
  */
881
- protected function get_attr_id( $id, $suffix = '' ) {
882
- if ( !MWF_Functions::is_empty( $id ) ) {
883
- if ( $suffix ) {
884
- $id .= '-' . $suffix;
885
- }
886
- return $id;
 
887
  }
 
888
  }
889
 
890
  /**
@@ -893,9 +865,20 @@ class MW_WP_Form_Form {
893
  * @param string $string
894
  * @return string
895
  */
 
 
 
 
 
 
 
 
896
  public static function remove_linefeed_space( $string ) {
897
- $string = preg_replace( '/\s+\/>/', ' />', $string );
898
- $string = preg_replace( '/>\s*</ms', '><', $string );
899
- return $string;
 
 
 
900
  }
901
  }
1
  <?php
2
  /**
3
  * Name : MW WP Form Form
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : September 25, 2012
8
+ * Modified : June 1, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Form {
13
 
14
  /**
15
+ * Return raw value
16
  *
17
+ * @param string $name
18
  * @return mixed
19
  */
20
+ public function get_raw( $name ) {
21
  MWF_Functions::deprecated_message(
22
  'MW_WP_Form_Form::get_raw()',
23
  'MW_WP_Form_Data::get_raw()'
24
  );
 
 
25
  }
26
 
27
  /**
28
+ * Return raw value if it is in $children
29
  *
30
+ * @param string $name
31
  * @param array $children
32
  * @return string
33
  */
34
+ public function get_raw_in_children( $name, array $children ) {
35
  MWF_Functions::deprecated_message(
36
  'MW_WP_Form_Form::get_raw_in_children()',
37
  'MW_WP_Form_Data::get_raw_in_children()'
38
  );
 
 
39
  }
40
 
41
  /**
42
+ * Return value for zip
43
  *
44
+ * @param string $name
45
+ * @return string
46
  */
47
+ public function get_zip_value( $name ) {
48
  MWF_Functions::deprecated_message(
49
  'MW_WP_Form_Form::get_zip_value()',
50
  'MW_WP_Form_Data::get_separated_value()'
51
  );
 
 
52
  }
53
 
54
  /**
55
+ * Return value for tel
56
  *
57
+ * @param string $name
58
+ * @return string
59
  */
60
+ public function get_tel_value( $name ) {
61
  MWF_Functions::deprecated_message(
62
  'MW_WP_Form_Form::get_tel_value()',
63
  'MW_WP_Form_Data::get_separated_value()'
64
  );
 
 
65
  }
66
 
67
  /**
68
+ * Return value for checkbox
69
  *
70
+ * @param string $name
71
  * @param array $data
72
+ * @return string
73
  */
74
+ public function get_checked_value( $name, array $data ) {
75
  MWF_Functions::deprecated_message(
76
  'MW_WP_Form_Form::get_checked_value()',
77
  'MW_WP_Form_Data::get_separated_value()'
78
  );
 
 
79
  }
80
 
81
  /**
82
+ * Return value for radio
83
  *
84
+ * @param string $name
85
+ * @param array $data
86
  * @return string
87
  */
88
+ public function get_radio_value( $name, array $data ) {
89
  MWF_Functions::deprecated_message(
90
  'MW_WP_Form_Form::get_radio_value()',
91
  'MW_WP_Form_Data::get_in_children()'
92
  );
 
 
93
  }
94
 
95
  /**
96
+ * Return value for selectbox
97
  *
98
+ * @param string $name
99
+ * @param array $data
100
+ * @return string
101
  */
102
+ public function get_selected_value( $name, array $data ) {
103
  MWF_Functions::deprecated_message(
104
  'MW_WP_Form_Form::get_selected_value()',
105
  'MW_WP_Form_Data::get_in_children()'
106
  );
 
 
107
  }
108
 
109
  /**
110
+ * Return formatted raw value (e.g. for checkbox)
111
  *
112
+ * @param string $name
113
+ * @param array $children
114
+ * @return string
115
  */
116
+ public function get_separated_raw_value( $name, array $children = array() ) {
117
  MWF_Functions::deprecated_message(
118
  'MW_WP_Form_Form::get_separated_raw_value()',
119
  'MW_WP_Form_Data::get_separated_raw_value()'
120
  );
 
 
121
  }
122
 
123
  /**
124
+ * Return hidden field for separator
125
  *
126
+ * @param string $name
127
+ * @param string $separator
128
+ * @return string
129
  */
130
+ public function separator( $name, $separator ) {
131
  if ( $separator ) {
132
+ return $this->hidden( $name . '[separator]', $separator );
133
  }
134
  }
135
 
136
  /**
137
+ * Return separator value
138
  *
139
+ * @param string $name
140
  * @return string
141
  */
142
+ public function get_separator_value( $name ) {
143
  MWF_Functions::deprecated_message(
144
  'MW_WP_Form_Form::get_separator_value()',
145
  'MW_WP_Form_Data::get_separator_value()'
146
  );
 
147
  }
148
 
149
  /**
150
+ * Return hidden field for setting children
151
  *
152
+ * @param string $name
153
+ * @param array $children
154
+ * @return string
155
  */
156
+ public function children( $name, array $children ) {
157
+ $name = sprintf( '__children[%s][]', $name );
158
  return $this->hidden( $name, json_encode( $children ) );
159
  }
160
 
161
  /**
162
+ * Render template
163
+ *
164
+ * @param string $template directory/filename (no extension)
165
+ * @return string
166
+ */
167
+ protected function _render( $template, array $args = array() ) {
168
+ $template_path = locate_template( 'mw-wp-form/form-fields/' . $template . '.php' );
169
+ if ( ! $template_path ) {
170
+ $template_path = plugin_dir_path( __FILE__ ) . '../../templates/form-fields/' . $template . '.php';
171
+ if ( ! file_exists( $template_path ) ) {
172
+ return;
173
+ }
174
+ }
175
+
176
+ foreach ( $args as $key => $val) {
177
+ unset( $args[ $key ] );
178
+ $args[ str_replace( '-', '_', $key ) ] = $val;
179
+ }
180
+
181
+ extract( $args );
182
+ ob_start();
183
+ include( $template_path );
184
+ return ob_get_clean();
185
+ }
186
+
187
+ /**
188
+ * Return form staring tag
189
  *
190
  * @param array $options
191
+ * @return string
192
  */
193
  public function start( $options = array() ) {
194
+ $options = array_merge( array(
195
  'action' => '',
196
  'enctype' => 'multipart/form-data',
197
+ ), $options );
198
+
199
  return sprintf(
200
  '<form method="post" action="%s" enctype="%s">',
201
  esc_attr( $options['action'] ),
204
  }
205
 
206
  /**
207
+ * Return form ending tag
208
  *
209
+ * @return string
210
  */
211
  public function end() {
212
  $html = '';
216
  }
217
 
218
  /**
219
+ * Return input[type=text]
220
  *
221
+ * @param string $name
222
+ * @param array $options
223
+ * @return string
224
  */
225
  public function text( $name, $options = array() ) {
226
  $defaults = array(
232
  'placeholder' => null,
233
  'conv-half-alphanumeric' => null,
234
  );
 
 
235
 
236
+ $options = shortcode_atts( $defaults, $options );
237
+ $options = array_merge( $options, array(
238
+ 'name' => $name,
 
239
  ) );
240
+
241
+ return $this->remove_newline_space(
242
+ $this->_render( 'text', $options )
243
+ );
244
  }
245
 
246
  /**
247
+ * Return input[type=email]
248
  *
249
+ * @param string $name
250
+ * @param array $options
251
+ * @return string
252
  */
253
  public function email( $name, $options = array() ) {
254
  $defaults = array(
260
  'placeholder' => null,
261
  'conv-half-alphanumeric' => null,
262
  );
263
+ $options = shortcode_atts( $defaults, $options );
264
+ $options = array_merge( $options, array(
265
+ 'name' => $name,
 
 
 
 
266
  ) );
267
+
268
+ return $this->remove_newline_space(
269
+ $this->_render( 'email', $options )
270
+ );
271
  }
272
 
273
  /**
274
+ * Return input[type=url]
275
  *
276
+ * @param string $name
277
+ * @param array $options
278
+ * @return string
279
  */
280
  public function url( $name, $options = array() ) {
281
  $defaults = array(
287
  'placeholder' => null,
288
  'conv-half-alphanumeric' => null,
289
  );
290
+ $options = shortcode_atts( $defaults, $options );
291
+ $options = array_merge( $options, array(
292
+ 'name' => $name,
 
 
 
 
293
  ) );
294
+
295
+ return $this->remove_newline_space(
296
+ $this->_render( 'url', $options )
297
+ );
298
  }
299
 
300
  /**
301
+ * Return input[type=range]
302
  *
303
+ * @param string $name
304
+ * @param array $options
305
+ * @return string
306
  */
307
  public function range( $name, $options = array() ) {
308
  $defaults = array(
313
  'max' => 100,
314
  'step' => 1,
315
  );
316
+ $options = shortcode_atts( $defaults, $options );
317
+ $options = array_merge( $options, array(
318
+ 'name' => $name,
 
 
 
 
319
  ) );
320
+
321
+ return $this->remove_newline_space(
322
+ $this->_render( 'range', $options )
323
+ );
324
  }
325
 
326
  /**
327
+ * Return input[type=number]
328
  *
329
+ * @param string $name
330
+ * @param array $options
331
+ * @return string
332
  */
333
  public function number( $name, $options = array() ) {
334
  $defaults = array(
340
  'step' => 1,
341
  'placeholder' => null,
342
  );
343
+ $options = shortcode_atts( $defaults, $options );
344
+ $options = array_merge( $options, array(
345
+ 'name' => $name,
 
 
 
 
346
  ) );
347
+
348
+ return $this->remove_newline_space(
349
+ $this->_render( 'number', $options )
350
+ );
351
  }
352
 
353
  /**
354
+ * Return input[type=hidden]
355
  *
356
+ * @param string $name
357
+ * @param string $value
358
+ * @return string
359
  */
360
  public function hidden( $name, $value ) {
361
+ return $this->_render( 'hidden', array(
362
+ 'name' => $name,
363
+ 'value' => $value,
 
364
  ) );
365
  }
366
 
367
  /**
368
+ * Return input[type=password]
369
  *
370
+ * @param string $name
371
  * @param array $options
372
+ * @return string
373
  */
374
  public function password( $name, $options = array() ) {
375
  $defaults = array(
380
  'value' => '',
381
  'placeholder' => null,
382
  );
383
+ $options = shortcode_atts( $defaults, $options );
384
+ $options = array_merge( $options, array(
385
+ 'name' => $name,
 
 
 
 
386
  ) );
387
+
388
+ return $this->remove_newline_space(
389
+ $this->_render( 'password', $options )
390
+ );
391
  }
392
 
393
  /**
394
+ * Return zip field
395
  *
396
+ * @param string $name
397
  * @param array $options
398
+ * @return string
399
  */
400
  public function zip( $name, $options = array() ) {
401
  $defaults = array(
403
  'conv-half-alphanumeric' => null,
404
  'value' => '',
405
  );
406
+ $options = shortcode_atts( $defaults, $options );
407
 
408
  $children = array();
409
  $separator = '-';
416
 
417
  $values = array( '', '' );
418
  foreach ( $children as $key => $val ) {
419
+ if ( 0 === $key || 1 === $key ) {
420
+ $values[ $key ] = $val;
421
  }
422
  }
423
 
424
+ return $this->remove_newline_space(
425
+ $this->_render( 'zip', array(
426
+ 'separator' => $separator,
427
+ 'fields' => array(
428
+ array(
429
+ 'name' => $name . '[data][0]',
430
+ 'class' => $options['class'],
431
+ 'size' => 4,
432
+ 'maxlength' => 3,
433
+ 'value' => $values[0],
434
+ 'conv-half-alphanumeric' => $options['conv-half-alphanumeric'],
435
+ ),
436
+ array(
437
+ 'name' => $name . '[data][1]',
438
+ 'class' => $options['class'],
439
+ 'size' => 5,
440
+ 'maxlength' => 4,
441
+ 'value' => $values[1],
442
+ 'conv-half-alphanumeric' => $options['conv-half-alphanumeric'],
443
+ ),
444
+ ),
445
+ ) )
446
+ . $this->separator( $name, $separator )
447
+ );
448
+ }
449
+
450
+ /**
451
+ * Return tel field
452
+ *
453
+ * @param string $name
454
  * @param array $options
455
+ * @return string
456
  */
457
  public function tel( $name, $options = array() ) {
458
  $defaults = array(
460
  'conv-half-alphanumeric' => null,
461
  'value' => '',
462
  );
463
+ $options = shortcode_atts( $defaults, $options );
464
 
465
  $children = array();
466
  $separator = '-';
474
  $values = array( '', '', '' );
475
  foreach ( $children as $key => $val ) {
476
  if ( $key === 0 || $key === 1 || $key === 2 ) {
477
+ $values[ $key ] = $val;
478
  }
479
  }
480
 
481
+ return $this->remove_newline_space(
482
+ $this->_render( 'tel', array(
483
+ 'separator' => $separator,
484
+ 'fields' => array(
485
+ array(
486
+ 'name' => $name . '[data][0]',
487
+ 'class' => $options['class'],
488
+ 'size' => 6,
489
+ 'maxlength' => 5,
490
+ 'value' => $values[0],
491
+ 'conv-half-alphanumeric' => $options['conv-half-alphanumeric'],
492
+ ),
493
+ array(
494
+ 'name' => $name . '[data][1]',
495
+ 'class' => $options['class'],
496
+ 'size' => 5,
497
+ 'maxlength' => 4,
498
+ 'value' => $values[1],
499
+ 'conv-half-alphanumeric' => $options['conv-half-alphanumeric'],
500
+ ),
501
+ array(
502
+ 'name' => $name . '[data][2]',
503
+ 'class' => $options['class'],
504
+ 'size' => 5,
505
+ 'maxlength' => 4,
506
+ 'value' => $values[2],
507
+ 'conv-half-alphanumeric' => $options['conv-half-alphanumeric'],
508
+ ),
509
+ ),
510
+ ) )
511
+ . $this->separator( $name, $separator )
512
+ );
513
+ }
514
+
515
+ /**
516
+ * Return textarea
517
+ *
518
+ * @param string $name
519
  * @param array $options
520
+ * @return string
521
  */
522
  public function textarea( $name, $options = array() ) {
523
  $defaults = array(
528
  'value' => '',
529
  'placeholder' => null,
530
  );
531
+ $options = shortcode_atts( $defaults, $options );
532
+ $options = array_merge( $options, array(
533
+ 'name' => $name,
 
 
 
 
 
 
 
534
  ) );
535
+
536
+ return $this->remove_newline_space(
537
+ $this->_render( 'textarea', $options )
538
+ );
539
  }
540
 
541
  /**
542
+ * Return selectbox
543
  *
544
+ * @param string $name
545
  * @param array $children
546
  * @param array $options
547
+ * @return string
548
  */
549
  public function select( $name, $children = array(), $options = array() ) {
550
  $defaults = array(
552
  'id' => null,
553
  'value' => '',
554
  );
555
+ $options = shortcode_atts( $defaults, $options );
556
+ $options = array_merge( $options, array(
557
+ 'name' => $name,
558
+ 'children' => $children,
559
+ ) );
560
 
561
+ return $this->remove_newline_space(
562
+ $this->_render( 'select', $options )
 
 
 
 
 
563
  );
 
 
 
 
 
 
 
 
 
 
 
564
  }
565
 
566
  /**
567
+ * Return input[type=radio]
568
  *
569
+ * @param string $name
570
  * @param array $children
571
  * @param array $options
572
+ * @return string
573
  */
574
  public function radio( $name, $children = array(), $options = array() ) {
575
  $defaults = array(
578
  'value' => '',
579
  'vertically' => null,
580
  );
581
+ $options = shortcode_atts( $defaults, $options );
582
 
583
+ $i = 0;
584
+ $fields = array();
585
+ foreach ( $children as $key => $label ) {
586
  $i ++;
587
+ $fields[ $key ] = array(
588
+ 'name' => $name,
589
+ 'label' => $label,
590
+ 'id' => $this->_get_attr_id( $options['id'], $i ),
 
 
591
  'class' => $options['class'],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
592
  );
593
  }
594
+
595
+ $options = array_merge( $options, array(
596
+ 'fields' => $fields,
597
+ ) );
598
+
599
+ return $this->remove_newline_space(
600
+ $this->_render( 'radio', $options )
601
+ );
602
  }
603
 
604
  /**
605
+ * Return input[checkbox]
606
  *
607
+ * @param string $name
608
  * @param array $children
609
  * @param array $options
610
+ * @param string $separator
611
+ * @return string
612
  */
613
  public function checkbox( $name, $children = array(), $options = array(), $separator = ',' ) {
614
  $defaults = array(
617
  'value' => '',
618
  'vertically' => null,
619
  );
620
+ $options = shortcode_atts( $defaults, $options );
621
 
622
+ if ( ! is_array( $options['value'] ) ) {
623
+ if ( MWF_Functions::is_empty( $options['value'] ) ) {
624
+ $options['value'] = array();
625
+ } else {
626
+ $options['value'] = explode( $separator, $options['value'] );
627
+ }
628
  }
629
 
630
+ $i = 0;
631
+ $fields = array();
632
+ foreach ( $children as $key => $label ) {
633
  $i ++;
634
+ $fields[ $key ] = array(
635
+ 'name' => $name . '[data][]',
636
+ 'label' => $label,
637
+ 'id' => $this->_get_attr_id( $options['id'], $i ),
 
 
638
  'class' => $options['class'],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
639
  );
640
  }
641
+
642
+ $options = array_merge( $options, array(
643
+ 'fields' => $fields,
644
+ ) );
645
+
646
+ return $this->remove_newline_space(
647
+ $this->_render( 'checkbox', $options ) . $this->separator( $name, $separator )
648
+ );
649
  }
650
 
651
  /**
652
+ * Return input[type=submit]
653
  *
654
+ * @param string $name
655
+ * @param string $value
656
  * @param array $options
657
+ * @return string
658
  */
659
  public function submit( $name, $value, $options = array() ) {
660
  $defaults = array(
661
  'class' => null,
662
  );
663
+ $options = shortcode_atts( $defaults, $options );
664
+ $options = array_merge( $options, array(
665
+ 'name' => $name,
666
+ 'value' => $value,
 
 
 
667
  ) );
668
+
669
+ return $this->remove_newline_space(
670
+ $this->_render( 'submit', $options )
671
+ );
672
  }
673
 
674
  /**
675
+ * Return button[type=submit]
676
  *
677
+ * @param string $name
678
+ * @param string $value
679
  * @param array $options
680
  * @param string $element_content
681
+ * @return string
682
  */
683
  public function button_submit( $name, $value, $options = array(), $element_content = '' ) {
684
  $defaults = array(
685
  'class' => null,
686
  );
687
+ $options = shortcode_atts( $defaults, $options );
688
+ $options = array_merge( $options, array(
689
+ 'name' => $name,
690
+ 'value' => $value,
691
+ 'element_content' => $element_content,
 
 
 
692
  ) );
693
+
694
+ return $this->remove_newline_space(
695
+ $this->_render( 'button_submit', $options )
696
+ );
697
  }
698
 
699
  /**
700
+ * Return input[type=button]
701
  *
702
+ * @param string $name
703
+ * @param string $value
704
  * @param array $options
705
+ * @return string
706
  */
707
  public function button( $name, $value, $options = array() ) {
708
  $defaults = array(
709
  'class' => null,
710
  );
711
+ $options = shortcode_atts( $defaults, $options );
712
+ $options = array_merge( $options, array(
713
+ 'name' => $name,
714
+ 'value' => $value,
 
 
 
715
  ) );
716
+
717
+ return $this->remove_newline_space(
718
+ $this->_render( 'button', $options )
719
+ );
720
  }
721
 
722
  /**
723
+ * Return button
724
  *
725
+ * @param string $name
726
+ * @param string $value
727
  * @param array $options
728
  * @param string $element_content
729
+ * @return string
730
  */
731
  public function button_button( $name, $value, $options = array(), $element_content = '' ) {
732
  $defaults = array(
733
  'class' => null,
734
  );
735
+ $options = shortcode_atts( $defaults, $options );
736
+ $options = array_merge( $options, array(
737
+ 'name' => $name,
738
+ 'value' => $value,
739
+ 'element_content' => $element_content,
 
 
 
740
  ) );
741
+
742
+ return $this->remove_newline_space(
743
+ $this->_render( 'button_button', $options )
744
+ );
745
  }
746
 
747
  /**
748
+ * Return datepicker
749
  *
750
+ * @param string $name
751
  * @param string $options
752
+ * @return string
753
  */
754
  public function datepicker( $name, $options = array() ) {
755
  $defaults = array(
760
  'value' => '',
761
  'placeholder' => null,
762
  );
763
+ $options = shortcode_atts( $defaults, $options );
764
+ $options = array_merge( $options, array(
765
+ 'name' => $name,
766
+ ) );
767
 
768
+ return $this->remove_newline_space(
769
+ $this->_render( 'datepicker', $options )
 
 
770
  );
 
 
 
 
 
 
771
  }
772
 
773
  /**
774
+ * Return monthpicker
775
  *
776
+ * @param string $name
777
  * @param string $options
778
+ * @return string
779
  */
780
  public function monthpicker( $name, $options = array() ) {
781
  $defaults = array(
786
  'value' => '',
787
  'placeholder' => null,
788
  );
789
+ $options = shortcode_atts( $defaults, $options );
790
+ $options = array_merge( $options, array(
791
+ 'name' => $name,
792
+ ) );
793
+
794
+ return $this->remove_newline_space(
795
+ $this->_render( 'monthpicker', $options )
796
+ );
 
 
 
 
 
 
 
 
 
 
797
  }
798
 
799
  /**
800
+ * Return input[type=file]
801
  *
802
+ * @param string $name
803
+ * @param array $options
804
+ * @return string
805
  */
806
  public function file( $name, $options = array() ) {
807
  $defaults = array(
808
  'id' => null,
809
  'class' => null,
810
  );
811
+ $options = shortcode_atts( $defaults, $options );
812
+ $options = array_merge( $options, array(
813
+ 'name' => $name,
 
 
 
 
814
  ) );
815
+
816
+ return $this->remove_newline_space(
817
+ $this->_render( 'file', $options )
818
+ );
819
  }
820
 
821
  /**
822
  * タグの属性を最適化して生成する
 
823
  *
824
+ * @deprecated
825
  * @param array $_attributes キーが属性名、要素が属性値の配列。要素が null のときは無視する
826
  */
827
  public function generate_attributes( array $_attributes ) {
830
  if ( is_null( $value ) ) {
831
  continue;
832
  }
833
+ if ( 'conv-half-alphanumeric' === $key ) {
834
  $key = 'data-conv-half-alphanumeric';
835
  }
836
  $attributes[] = sprintf( '%s="%s"', $key, esc_attr( $value ) );
842
  }
843
 
844
  /**
845
+ * Return ID attribute
846
  *
847
  * @param string $id
848
  * @param string $suffix
849
  * @return string
850
  */
851
+ protected function _get_attr_id( $id, $suffix = '' ) {
852
+ if ( MWF_Functions::is_empty( $id ) ) {
853
+ return;
854
+ }
855
+
856
+ if ( $suffix ) {
857
+ $id .= '-' . $suffix;
858
  }
859
+ return $id;
860
  }
861
 
862
  /**
865
  * @param string $string
866
  * @return string
867
  */
868
+ public function remove_newline_space( $string ) {
869
+ return preg_replace_callback('/<([^<>]+?)>/', array( $this, '_remove_newline_space_callback' ), $string );
870
+ }
871
+ protected function _remove_newline_space_callback( $matches ) {
872
+ $matches[0] = str_replace( array( "\r\n", "\r", "\n", "\t" ), ' ', $matches[0] );
873
+ $matches[0] = preg_replace( '/[\t ]+/', ' ', $matches[0] );
874
+ return $matches[0];
875
+ }
876
  public static function remove_linefeed_space( $string ) {
877
+ MWF_Functions::deprecated_message(
878
+ 'MW_WP_Form_Form::remove_linefeed_space()',
879
+ 'MW_WP_Form_Form::remove_newline_space()'
880
+ );
881
+ $Form = new MW_WP_Form_Form();
882
+ return $Form->remove_newline_space( $string );
883
  }
884
  }
classes/models/class.json-parser.php CHANGED
@@ -1,61 +1,60 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Json Parser
4
- * Description: ショートコードから渡される json を正しい形式に変換
5
- * Version : 1.0.1
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : April 3, 2016
9
- * Modified : April 5, 2016
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Json_Parser {
14
 
15
  /**
16
- * ショートコードから渡される json
17
  * @var string
18
  */
19
  protected $maybe_json;
20
 
21
  /**
22
- * シングルクォーテーションの待ち状態
23
  * @var bool
24
  */
25
  protected $s_quote_stay = false;
26
 
27
  /**
28
- * ダブルクォーテーションの待ち状態
29
  * @var bool
30
  */
31
  protected $d_quote_stay = false;
32
 
33
  /**
34
- * コロンの待ち状態
35
  * @var bool
36
  */
37
  protected $colon_stay = true;
38
 
39
  /**
40
- * 正しい json を生成するための配列の添字
41
  * @var int
42
  */
43
  protected $index = 0;
44
 
45
  /**
46
- * セットする文字が json のキーにあたるのか値にあたるのかを識別するフラグ
47
  * @var string key|value
48
  */
49
  protected $key = 'key';
50
 
51
  /**
52
- * json 生成用の配列
53
  * @var array
54
  */
55
  protected $temp = array();
56
 
57
  /**
58
- * @param string $maybe_json json
59
  */
60
  public function __construct( $maybe_json ) {
61
  $this->maybe_json = $maybe_json;
@@ -63,7 +62,9 @@ class MW_WP_Form_Json_Parser {
63
  }
64
 
65
  /**
66
- * 各プロパティの初期値を設定
 
 
67
  */
68
  protected function set_default_params() {
69
  $this->s_quote_stay = false;
@@ -75,23 +76,26 @@ class MW_WP_Form_Json_Parser {
75
  }
76
 
77
  /**
78
- * 文字を json 生成用の配列に追加する
79
  *
80
  * @param string $character
 
81
  */
82
  public function push_character( $character ) {
83
- if ( !isset( $this->temp[$this->index][$this->key] ) ) {
84
- $this->temp[$this->index][$this->key] = '';
85
  }
86
- $this->temp[$this->index][$this->key] .= $character;
87
  }
88
 
89
  /**
90
- * シングルクォーテーション用の処理
 
 
91
  */
92
  protected function proccess_single_quote() {
93
- if ( !$this->d_quote_stay ) {
94
- if ( !$this->s_quote_stay ) {
95
  $this->s_quote_stay = true;
96
  } else {
97
  $this->s_quote_stay = false;
@@ -102,11 +106,13 @@ class MW_WP_Form_Json_Parser {
102
  }
103
 
104
  /**
105
- * ダブルクォーテーション用の処理
 
 
106
  */
107
  protected function proccess_double_quote() {
108
- if ( !$this->s_quote_stay ) {
109
- if ( !$this->d_quote_stay ) {
110
  $this->d_quote_stay = true;
111
  } else {
112
  $this->d_quote_stay = false;
@@ -117,10 +123,12 @@ class MW_WP_Form_Json_Parser {
117
  }
118
 
119
  /**
120
- * カンマ用の処理
 
 
121
  */
122
  protected function proccess_comma() {
123
- if ( !$this->s_quote_stay || !$this->d_quote_stay ) {
124
  $this->index ++;
125
  $this->colon_stay = true;
126
  $this->key = 'key';
@@ -130,9 +138,9 @@ class MW_WP_Form_Json_Parser {
130
  }
131
 
132
  /**
133
- * コロン用の処理
134
  *
135
- * @param string $character
136
  */
137
  protected function proccess_colon() {
138
  if ( $this->colon_stay ) {
@@ -144,14 +152,14 @@ class MW_WP_Form_Json_Parser {
144
  }
145
 
146
  /**
147
- * json 生成用の配列を元に json を返す
148
  *
149
  * @return json
150
  */
151
  public function json_encode() {
152
  $js = array();
153
  foreach ( $this->temp as $param ) {
154
- if ( !isset( $param['key'] ) ) {
155
  continue;
156
  }
157
  $key = $param['key'];
@@ -175,6 +183,8 @@ class MW_WP_Form_Json_Parser {
175
  }
176
 
177
  /**
 
 
178
  * @return json
179
  */
180
  public function create_json() {
@@ -183,19 +193,19 @@ class MW_WP_Form_Json_Parser {
183
 
184
  foreach ( $_js as $character ) {
185
  // シングルクォーテーション
186
- if ( $character === "'" ) {
187
  $this->proccess_single_quote();
188
  }
189
  // ダブルクォーテーション
190
- elseif ( $character === '"' ) {
191
  $this->proccess_double_quote();
192
  }
193
  // カンマ
194
- elseif ( $character === ',' ) {
195
  $this->proccess_comma();
196
  }
197
  // コロン
198
- elseif ( $character === ':' ) {
199
  $this->proccess_colon();
200
  }
201
  // その他の文字
1
  <?php
2
  /**
3
  * Name : MW WP Form Json Parser
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : April 3, 2016
8
+ * Modified : June 1, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Json_Parser {
13
 
14
  /**
15
+ * Json from shortcode
16
  * @var string
17
  */
18
  protected $maybe_json;
19
 
20
  /**
21
+ * Waiting for single quotation
22
  * @var bool
23
  */
24
  protected $s_quote_stay = false;
25
 
26
  /**
27
+ * Waiting for double quotation
28
  * @var bool
29
  */
30
  protected $d_quote_stay = false;
31
 
32
  /**
33
+ * Waiting for colon
34
  * @var bool
35
  */
36
  protected $colon_stay = true;
37
 
38
  /**
39
+ * Array index to generate correct json
40
  * @var int
41
  */
42
  protected $index = 0;
43
 
44
  /**
45
+ * A flag that identifies whether the character to be set is key or value
46
  * @var string key|value
47
  */
48
  protected $key = 'key';
49
 
50
  /**
51
+ * Array of generating json
52
  * @var array
53
  */
54
  protected $temp = array();
55
 
56
  /**
57
+ * @param string $maybe_json json
58
  */
59
  public function __construct( $maybe_json ) {
60
  $this->maybe_json = $maybe_json;
62
  }
63
 
64
  /**
65
+ * Set initial value of each property
66
+ *
67
+ * @return void
68
  */
69
  protected function set_default_params() {
70
  $this->s_quote_stay = false;
76
  }
77
 
78
  /**
79
+ * Add a character to an array for generating json
80
  *
81
  * @param string $character
82
+ * @return void
83
  */
84
  public function push_character( $character ) {
85
+ if ( ! isset( $this->temp[ $this->index ][ $this->key ] ) ) {
86
+ $this->temp[ $this->index ][ $this->key ] = '';
87
  }
88
+ $this->temp[ $this->index ][ $this->key ] .= $character;
89
  }
90
 
91
  /**
92
+ * Proccess for single quotation
93
+ *
94
+ * @return void
95
  */
96
  protected function proccess_single_quote() {
97
+ if ( ! $this->d_quote_stay ) {
98
+ if ( ! $this->s_quote_stay ) {
99
  $this->s_quote_stay = true;
100
  } else {
101
  $this->s_quote_stay = false;
106
  }
107
 
108
  /**
109
+ * Proccess for double quotation
110
+ *
111
+ * @return void
112
  */
113
  protected function proccess_double_quote() {
114
+ if ( ! $this->s_quote_stay ) {
115
+ if ( ! $this->d_quote_stay ) {
116
  $this->d_quote_stay = true;
117
  } else {
118
  $this->d_quote_stay = false;
123
  }
124
 
125
  /**
126
+ * Proccess for connma
127
+ *
128
+ * @return void
129
  */
130
  protected function proccess_comma() {
131
+ if ( ! $this->s_quote_stay || ! $this->d_quote_stay ) {
132
  $this->index ++;
133
  $this->colon_stay = true;
134
  $this->key = 'key';
138
  }
139
 
140
  /**
141
+ * Proccess for colon
142
  *
143
+ * @return void
144
  */
145
  protected function proccess_colon() {
146
  if ( $this->colon_stay ) {
152
  }
153
 
154
  /**
155
+ * Return json based on the array for generating json
156
  *
157
  * @return json
158
  */
159
  public function json_encode() {
160
  $js = array();
161
  foreach ( $this->temp as $param ) {
162
+ if ( ! isset( $param['key'] ) ) {
163
  continue;
164
  }
165
  $key = $param['key'];
183
  }
184
 
185
  /**
186
+ * Return json based on the array for generating json
187
+ *
188
  * @return json
189
  */
190
  public function create_json() {
193
 
194
  foreach ( $_js as $character ) {
195
  // シングルクォーテーション
196
+ if ( "'" === $character ) {
197
  $this->proccess_single_quote();
198
  }
199
  // ダブルクォーテーション
200
+ elseif ( '"' === $character ) {
201
  $this->proccess_double_quote();
202
  }
203
  // カンマ
204
+ elseif ( ',' === $character ) {
205
  $this->proccess_comma();
206
  }
207
  // コロン
208
+ elseif ( ':' === $character ) {
209
  $this->proccess_colon();
210
  }
211
  // その他の文字
classes/models/class.mail.php CHANGED
@@ -1,67 +1,62 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Mail
4
- * Description: メールクラス
5
- * Version : 2.2.1
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : July 20, 2012
9
- * Modified : May 4, 2017
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Mail {
14
 
15
  /**
16
- * 宛先
17
  * @var string
18
  */
19
  public $to;
20
 
21
  /**
22
- * CC
23
  * @var string
24
  */
25
  public $cc;
26
 
27
  /**
28
- * BCC
29
  * @var string
30
  */
31
  public $bcc;
32
 
33
  /**
34
- * 送信元
 
 
 
 
35
  * @var string
36
  */
37
  public $from;
38
 
39
  /**
40
- * Return-Path
41
  * @var string
42
  */
43
  public $return_path;
44
 
45
  /**
46
- * 送信者
47
  * @var string
48
  */
49
  public $sender;
50
 
51
  /**
52
- * 件名
53
  * @var string
54
  */
55
  public $subject;
56
 
57
  /**
58
- * 本文
59
  * @var string
60
  */
61
  public $body;
62
 
63
  /**
64
- * 添付
65
  * @var array
66
  */
67
  public $attachments = array();
@@ -72,104 +67,104 @@ class MW_WP_Form_Mail {
72
  protected $Mail_Parser;
73
 
74
  /**
75
- * メール送信
76
  *
77
  * @return boolean
78
  */
79
  public function send() {
 
 
 
 
 
80
  if ( ! $this->to ) {
81
  return apply_filters( 'mwform_is_mail_sended', false );
82
  }
83
 
84
- $sender = $this->sender;
85
- $from = $this->from;
86
- $return_path = $this->return_path;
87
- $subject = $this->subject;
88
- $body = $this->body;
89
-
90
- add_action( 'phpmailer_init' , array( $this, 'set_return_path' ) );
91
- add_filter( 'wp_mail_from' , array( $this, 'set_mail_from' ) );
92
- add_filter( 'wp_mail_from_name', array( $this, 'set_mail_from_name' ) );
93
-
94
- if ( defined( 'MWFORM_DEBUG' ) && MWFORM_DEBUG === true ) {
95
- $File = new MW_WP_Form_File();
96
- $File->create_temp_dir();
97
- $temp_dir = $File->get_temp_dir();
98
- $temp_dir = trailingslashit( $temp_dir['dir'] );
99
- $temp_dir = apply_filters( 'mwform_log_directory', $temp_dir );
100
- }
101
 
102
  $headers = array();
 
103
  if ( $this->cc ) {
104
  $headers[] = 'Cc: ' . $this->cc;
105
  }
 
106
  if ( $this->bcc ) {
107
  $headers[] = 'Bcc: ' . $this->bcc;
108
  }
109
- $to = trim( $this->to );
110
- if ( !empty( $File ) ) {
111
- $contents = sprintf(
112
- "====================\n\nSend Date: %s\nTo: %s\nSender: %s\nFrom: %s\nReturn-Path: %s\nSubject: %s\nheaders:%s\n-----\n%s\n-----\nattachments:\n%s\n\n",
113
- date( 'M j Y, H:i:s' ),
114
- $to,
115
- $sender,
116
- $from,
117
- $return_path,
118
- $subject,
119
- implode( "\n", $headers ),
120
- $body,
121
- implode( "\n", $this->attachments )
122
- );
123
- $is_mail_sended = file_put_contents( $temp_dir . '/mw-wp-form-debug.log', $contents, FILE_APPEND );
124
  } else {
125
- $is_mail_sended = wp_mail( $to, $subject, $body, $headers, $this->attachments );
126
  }
127
 
128
- remove_action( 'phpmailer_init' , array( $this, 'set_return_path' ) );
129
- remove_filter( 'wp_mail_from' , array( $this, 'set_mail_from' ) );
130
- remove_filter( 'wp_mail_from_name', array( $this, 'set_mail_from_name' ) );
131
 
132
  return apply_filters( 'mwform_is_mail_sended', $is_mail_sended );
133
  }
134
 
135
  /**
136
- * 送信元を設定
137
  *
138
- * @param string $email fromメールアドレス
139
  * @return string
140
  */
141
- public function set_mail_from( $email ) {
142
  if ( filter_var( $this->from, FILTER_VALIDATE_EMAIL ) ) {
143
  return $this->from;
144
  }
 
145
  return $email;
146
  }
147
 
148
  /**
149
- * 送信者名を設定
150
  *
151
- * @param string $sender 送信者名
152
  * @return string
153
  */
154
- public function set_mail_from_name( $sender ) {
155
- return $this->sender;
 
 
 
 
156
  }
157
 
158
  /**
159
- * Return-Path を設定
160
  *
161
  * @param phpmailer $phpmailer
 
162
  */
163
- public function set_return_path( $phpmailer ) {
164
- $phpmailer->Sender = $this->return_path;
 
 
 
 
165
  }
166
 
167
  /**
168
- * 配列からbodyを生成
169
  *
170
- * @param array ( 見出し => 内容, … )
171
- * @param array ( 'exclude' => array( 除外したいキー1, … ) )
172
- * @return string メール本文
173
  */
174
  public function createBody( array $array, array $options = array() ) {
175
  $_ret = '';
@@ -184,7 +179,7 @@ class MW_WP_Form_Mail {
184
  $_value = '';
185
  if ( is_array( $value['data'] ) ) {
186
  foreach ( $value['data'] as $_val ) {
187
- if ( !( $_val === '' || $_val === null ) ) {
188
  $_value = implode( $value['separator'], $value['data'] );
189
  break;
190
  }
@@ -202,78 +197,28 @@ class MW_WP_Form_Mail {
202
  }
203
 
204
  /**
205
- * 管理者メール用に初期値を設定
206
  *
207
  * @param MW_WP_Form_Setting $Setting
 
208
  */
209
  public function set_admin_mail_raw_params( MW_WP_Form_Setting $Setting ) {
210
- // タイトルを指定
211
- $admin_mail_subject = $Setting->get( 'mail_subject' );
212
- if ( $Setting->get( 'admin_mail_subject' ) ) {
213
- $admin_mail_subject = $Setting->get( 'admin_mail_subject' );
214
- }
215
- $this->subject = $admin_mail_subject;
216
-
217
- // 本文を指定
218
- $admin_mail_content = $Setting->get( 'mail_content' );
219
- if ( $Setting->get( 'admin_mail_content' ) ) {
220
- $admin_mail_content = $Setting->get( 'admin_mail_content' );
221
- }
222
- $this->body = $admin_mail_content;
223
-
224
- // 送信先を指定
225
- $admin_mail_to = get_bloginfo( 'admin_email' );
226
- if ( $Setting->get( 'mail_to' ) ) {
227
- $admin_mail_to = $Setting->get( 'mail_to' );
228
- }
229
- $this->to = $admin_mail_to;
230
-
231
- // CCを指定
232
- $admin_mail_cc = '';
233
- if ( $Setting->get( 'mail_cc' ) ) {
234
- $admin_mail_cc = $Setting->get( 'mail_cc' );
235
- }
236
- $this->cc = $admin_mail_cc;
237
-
238
- // BCCを指定
239
- $admin_mail_bcc = '';
240
- if ( $Setting->get( 'mail_bcc' ) ) {
241
- $admin_mail_bcc = $Setting->get( 'mail_bcc' );
242
- }
243
- $this->bcc = $admin_mail_bcc;
244
-
245
- // 送信元を指定
246
- $admin_mail_from = get_bloginfo( 'admin_email' );
247
- if ( $Setting->get( 'mail_from' ) ) {
248
- $admin_mail_from = $Setting->get( 'mail_from' );
249
- }
250
- if ( $Setting->get( 'admin_mail_from' ) ) {
251
- $admin_mail_from = $Setting->get( 'admin_mail_from' );
252
- }
253
- $this->from = $admin_mail_from;
254
-
255
- // Return-Path を指定
256
- $mail_return_path = get_bloginfo( 'admin_email' );
257
- if ( $Setting->get( 'mail_return_path' ) ) {
258
- $mail_return_path = $Setting->get( 'mail_return_path' );
259
- }
260
- $this->return_path = $mail_return_path;
261
-
262
- // 送信者を指定
263
- $admin_mail_sender = get_bloginfo( 'name' );
264
- if ( $Setting->get( 'mail_sender' ) ) {
265
- $admin_mail_sender = $Setting->get( 'mail_sender' );
266
- }
267
- if ( $Setting->get( 'admin_mail_sender' ) ) {
268
- $admin_mail_sender = $Setting->get( 'admin_mail_sender' );
269
- }
270
- $this->sender = $admin_mail_sender;
271
  }
272
 
273
  /**
274
- * 自動返信メール用に初期値を設定
275
  *
276
  * @param MW_WP_Form_Setting $Setting
 
277
  */
278
  public function set_reply_mail_raw_params( MW_WP_Form_Setting $Setting ) {
279
  $this->to = '';
@@ -281,89 +226,37 @@ class MW_WP_Form_Mail {
281
  $this->bcc = '';
282
  $this->attachments = array();
283
 
284
- $Data = MW_WP_Form_Data::getInstance();
 
 
285
  $automatic_reply_email = $Setting->get( 'automatic_reply_email' );
286
 
287
- $form_id = $Setting->get( 'post_id' );
288
- if ( $form_id ) {
289
- $Validation = new MW_WP_Form_Validation_Rule_Mail();
290
- $Validation->set_Data( $Data );
291
- $is_invalid_mail_address = $Validation->rule(
292
- $automatic_reply_email
293
- );
294
-
295
- // 送信先を指定
296
- if ( $automatic_reply_email && !$is_invalid_mail_address ) {
297
- $this->to = $Data->get_post_value_by_key( $automatic_reply_email );
298
- }
299
-
300
- // Return-Path を指定
301
- $mail_return_path = get_bloginfo( 'admin_email' );
302
- if ( $Setting->get( 'mail_return_path' ) ) {
303
- $mail_return_path = $Setting->get( 'mail_return_path' );
304
- }
305
- $this->return_path = $mail_return_path;
306
-
307
- // 送信元を指定
308
- $reply_mail_from = get_bloginfo( 'admin_email' );
309
- if ( $Setting->get( 'mail_from' ) ) {
310
- $reply_mail_from = $Setting->get( 'mail_from' );
311
- }
312
- $this->from = $reply_mail_from;
313
-
314
- // 送信者を指定
315
- $reply_mail_sender = get_bloginfo( 'name' );
316
- if ( $Setting->get( 'mail_sender' ) ) {
317
- $reply_mail_sender = $Setting->get( 'mail_sender' );
318
- }
319
- $this->sender = $reply_mail_sender;
320
-
321
- // タイトルを指定
322
- $this->subject = $Setting->get( 'mail_subject' );
323
-
324
- // 本文を指定
325
- $this->body = $Setting->get( 'mail_content' );
326
  }
327
- }
328
 
329
- /**
330
- * 管理者メールに必須の項目を設定
331
- */
332
- public function set_admin_mail_reaquire_params() {
333
- $admin_mail_to = get_bloginfo( 'admin_email' );
334
- $admin_mail_from = get_bloginfo( 'admin_email' );
335
- $admin_mail_sender = get_bloginfo( 'name' );
336
 
337
- if ( !$this->to ) {
338
- $this->to = $admin_mail_to;
339
- }
340
- if ( !$this->from ) {
341
- $this->from = $admin_mail_from;
342
- }
343
- if ( !$this->sender ) {
344
- $this->sender = $admin_mail_sender;
345
  }
346
- }
347
-
348
- /**
349
- * 自動返信メールに必須の項目を設定
350
- */
351
- public function set_reply_mail_reaquire_params() {
352
- $reply_mail_from = get_bloginfo( 'admin_email' );
353
- $reply_mail_sender = get_bloginfo( 'name' );
354
 
355
- if ( !$this->from ) {
356
- $this->from = $reply_mail_from;;
357
- }
358
- if ( !$this->sender ) {
359
- $this->sender = $reply_mail_sender;;
360
- }
361
  }
362
 
363
  /**
364
- * メールを送信内容に置換
365
  *
366
  * @param MW_WP_Form_Setting $Setting
 
367
  */
368
  public function parse( $Setting ) {
369
  $this->Mail_Parser = new MW_WP_Form_Mail_Parser( $this, $Setting );
@@ -374,7 +267,7 @@ class MW_WP_Form_Mail {
374
  }
375
 
376
  /**
377
- * メールをデータベースに保存
378
  *
379
  * @param MW_WP_Form_Setting $Setting
380
  * @return int
@@ -386,7 +279,7 @@ class MW_WP_Form_Mail {
386
  }
387
 
388
  /**
389
- * 保存した問い合わせデータの Post IDを取得する
390
  *
391
  * @return int
392
  */
@@ -395,4 +288,72 @@ class MW_WP_Form_Mail {
395
  return $this->Mail_Parser->get_saved_mail_id();
396
  }
397
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
398
  }
1
  <?php
2
  /**
3
  * Name : MW WP Form Mail
4
+ * Version : 3.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : July 20, 2012
8
+ * Modified : May 31, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Mail {
13
 
14
  /**
 
15
  * @var string
16
  */
17
  public $to;
18
 
19
  /**
 
20
  * @var string
21
  */
22
  public $cc;
23
 
24
  /**
 
25
  * @var string
26
  */
27
  public $bcc;
28
 
29
  /**
30
+ * @var string
31
+ */
32
+ public $reply_to;
33
+
34
+ /**
35
  * @var string
36
  */
37
  public $from;
38
 
39
  /**
 
40
  * @var string
41
  */
42
  public $return_path;
43
 
44
  /**
 
45
  * @var string
46
  */
47
  public $sender;
48
 
49
  /**
 
50
  * @var string
51
  */
52
  public $subject;
53
 
54
  /**
 
55
  * @var string
56
  */
57
  public $body;
58
 
59
  /**
 
60
  * @var array
61
  */
62
  public $attachments = array();
67
  protected $Mail_Parser;
68
 
69
  /**
70
+ * Send mail
71
  *
72
  * @return boolean
73
  */
74
  public function send() {
75
+ $this->to = trim( $this->to );
76
+ $this->cc = trim( $this->cc );
77
+ $this->bcc = trim( $this->bcc );
78
+ $this->reply_to = trim( $this->reply_to );
79
+
80
  if ( ! $this->to ) {
81
  return apply_filters( 'mwform_is_mail_sended', false );
82
  }
83
 
84
+ add_action( 'phpmailer_init' , array( $this, '_set_return_path' ) );
85
+ add_filter( 'wp_mail_from' , array( $this, '_set_mail_from' ) );
86
+ add_filter( 'wp_mail_from_name', array( $this, '_set_mail_from_name' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
 
88
  $headers = array();
89
+
90
  if ( $this->cc ) {
91
  $headers[] = 'Cc: ' . $this->cc;
92
  }
93
+
94
  if ( $this->bcc ) {
95
  $headers[] = 'Bcc: ' . $this->bcc;
96
  }
97
+
98
+ if ( $this->reply_to ) {
99
+ $headers[] = 'Reply-To: ' . $this->reply_to;
100
+ }
101
+
102
+ if ( ! $this->body ) {
103
+ // wp_mail do not send mail when message is empty.
104
+ $this->body = ' ';
105
+ }
106
+
107
+ if ( defined( 'MWFORM_DEBUG' ) && true === MWFORM_DEBUG ) {
108
+ $is_mail_sended = $this->_put_mail_log( $headers );
 
 
 
109
  } else {
110
+ $is_mail_sended = wp_mail( $this->to, $this->subject, $this->body, $headers, $this->attachments );
111
  }
112
 
113
+ remove_action( 'phpmailer_init' , array( $this, '_set_return_path' ) );
114
+ remove_filter( 'wp_mail_from' , array( $this, '_set_mail_from' ) );
115
+ remove_filter( 'wp_mail_from_name', array( $this, '_set_mail_from_name' ) );
116
 
117
  return apply_filters( 'mwform_is_mail_sended', $is_mail_sended );
118
  }
119
 
120
  /**
121
+ * Set mail from
122
  *
123
+ * @param string $email
124
  * @return string
125
  */
126
+ public function _set_mail_from( $email ) {
127
  if ( filter_var( $this->from, FILTER_VALIDATE_EMAIL ) ) {
128
  return $this->from;
129
  }
130
+ $this->from = $email;
131
  return $email;
132
  }
133
 
134
  /**
135
+ * Set sender (from name)
136
  *
137
+ * @param string $sender
138
  * @return string
139
  */
140
+ public function _set_mail_from_name( $sender ) {
141
+ if ( $this->sender ) {
142
+ return $this->sender;
143
+ }
144
+ $this->sender = $sender;
145
+ return $sender;
146
  }
147
 
148
  /**
149
+ * Set Return-Path
150
  *
151
  * @param phpmailer $phpmailer
152
+ * @return void
153
  */
154
+ public function _set_return_path( $phpmailer ) {
155
+ if ( $this->return_path ) {
156
+ if ( filter_var( $this->return_path, FILTER_VALIDATE_EMAIL ) ) {
157
+ $phpmailer->Sender = $this->return_path;
158
+ }
159
+ }
160
  }
161
 
162
  /**
163
+ * Create mail content from array
164
  *
165
+ * @param array
166
+ * @param array
167
+ * @return string
168
  */
169
  public function createBody( array $array, array $options = array() ) {
170
  $_ret = '';
179
  $_value = '';
180
  if ( is_array( $value['data'] ) ) {
181
  foreach ( $value['data'] as $_val ) {
182
+ if ( '' !== $_val && ! is_null ( $_val ) ) {
183
  $_value = implode( $value['separator'], $value['data'] );
184
  break;
185
  }
197
  }
198
 
199
  /**
200
+ * Set defaults setting for admin mail
201
  *
202
  * @param MW_WP_Form_Setting $Setting
203
+ * @return void
204
  */
205
  public function set_admin_mail_raw_params( MW_WP_Form_Setting $Setting ) {
206
+ $this->subject = $Setting->get( 'admin_mail_subject' );
207
+ $this->body = $Setting->get( 'admin_mail_content' );
208
+ $this->to = $Setting->get( 'mail_to' );
209
+ $this->cc = $Setting->get( 'mail_cc' );
210
+ $this->bcc = $Setting->get( 'mail_bcc' );
211
+ $this->reply_to = $Setting->get( 'admin_mail_reply_to' );
212
+ $this->from = $Setting->get( 'admin_mail_from' );
213
+ $this->return_path = $Setting->get( 'mail_return_path' );
214
+ $this->sender = $Setting->get( 'admin_mail_sender' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
215
  }
216
 
217
  /**
218
+ * Set defaults setting for reply mail
219
  *
220
  * @param MW_WP_Form_Setting $Setting
221
+ * @return void
222
  */
223
  public function set_reply_mail_raw_params( MW_WP_Form_Setting $Setting ) {
224
  $this->to = '';
226
  $this->bcc = '';
227
  $this->attachments = array();
228
 
229
+ $form_id = $Setting->get( 'post_id' );
230
+ $form_key = MWF_Functions::get_form_key_from_form_id( $form_id );
231
+ $Data = MW_WP_Form_Data::connect( $form_key );
232
  $automatic_reply_email = $Setting->get( 'automatic_reply_email' );
233
 
234
+ if ( ! $form_id ) {
235
+ return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
236
  }
 
237
 
238
+ $Validation = new MW_WP_Form_Validation_Rule_Mail( $Data );
239
+ $is_invalid_mail_address = $Validation->rule(
240
+ $automatic_reply_email
241
+ );
 
 
 
242
 
243
+ if ( $automatic_reply_email && ! $is_invalid_mail_address ) {
244
+ $this->to = $Data->get_post_value_by_key( $automatic_reply_email );
 
 
 
 
 
 
245
  }
 
 
 
 
 
 
 
 
246
 
247
+ $this->reply_to = $Setting->get( 'mail_reply_to' );
248
+ $this->return_path = $Setting->get( 'mail_return_path' );
249
+ $this->from = $Setting->get( 'mail_from' );
250
+ $this->sender = $Setting->get( 'mail_sender' );
251
+ $this->subject = $Setting->get( 'mail_subject' );
252
+ $this->body = $Setting->get( 'mail_content' );
253
  }
254
 
255
  /**
256
+ * Replace {name} to content in mail content
257
  *
258
  * @param MW_WP_Form_Setting $Setting
259
+ * @return void
260
  */
261
  public function parse( $Setting ) {
262
  $this->Mail_Parser = new MW_WP_Form_Mail_Parser( $this, $Setting );
267
  }
268
 
269
  /**
270
+ * Save to database
271
  *
272
  * @param MW_WP_Form_Setting $Setting
273
  * @return int
279
  }
280
 
281
  /**
282
+ * Return saved mail ID
283
  *
284
  * @return int
285
  */
288
  return $this->Mail_Parser->get_saved_mail_id();
289
  }
290
  }
291
+
292
+ /**
293
+ * Logging that MW WP Form sending mail
294
+ *
295
+ * @return bool
296
+ */
297
+ protected function _put_mail_log( $headers ) {
298
+ // Update properties
299
+ wp_mail( '', $this->subject, '', $headers, array() );
300
+
301
+ $File = new MW_WP_Form_File();
302
+ $File->create_temp_dir();
303
+
304
+ $temp_dir = $File->get_temp_dir();
305
+ $temp_dir = trailingslashit( $temp_dir['dir'] );
306
+ $temp_dir = apply_filters( 'mwform_log_directory', $temp_dir );
307
+
308
+ $contents = "====================";
309
+ $contents .= "\n\n";
310
+ $contents .= 'Send Date: %1$s';
311
+ $contents .= "\n";
312
+ $contents .= 'To: %2$s';
313
+ $contents .= "\n";
314
+ $contents .= 'Sender: %3$s';
315
+ $contents .= "\n";
316
+ $contents .= 'Reply-to: %4$s';
317
+ $contents .= "\n";
318
+ $contents .= 'From: %5$s';
319
+ $contents .= "\n";
320
+ $contents .= 'Return-Path: %6$s';
321
+ $contents .= "\n";
322
+ $contents .= 'Subject: %7$s';
323
+ $contents .= "\n";
324
+ $contents .= 'headers:%8$s';
325
+ $contents .= "\n";
326
+ $contents .= '-----';
327
+ $contents .= "\n";
328
+ $contents .= '%9$s';
329
+ $contents .= "\n";
330
+ $contents .= '-----';
331
+ $contents .= "\n";
332
+ $contents .= 'attachments:';
333
+ $contents .= "\n";
334
+ $contents .= '%10$s';
335
+ $contents .= "\n\n";
336
+
337
+ $contents = sprintf(
338
+ $contents,
339
+ date( 'M j Y, H:i:s' ),
340
+ $this->to,
341
+ $this->sender,
342
+ $this->reply_to,
343
+ $this->from,
344
+ $this->return_path,
345
+ $this->subject,
346
+ implode( "\n", $headers ),
347
+ $this->body,
348
+ implode( "\n", $this->attachments )
349
+ );
350
+
351
+ $is_mail_sended = file_put_contents( $temp_dir . '/mw-wp-form-debug.log', $contents, FILE_APPEND );
352
+
353
+ if ( false === $is_mail_sended) {
354
+ return false;
355
+ }
356
+
357
+ return true;
358
+ }
359
  }
classes/models/class.parser.php ADDED
@@ -0,0 +1,284 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Name : MW WP Form Parser
4
+ * Version : 1.0.0
5
+ * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
+ * Created : July 10, 2017
8
+ * Modified :
9
+ * License : GPLv2 or later
10
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
+ */
12
+ class MW_WP_Form_Parser {
13
+
14
+ /**
15
+ * @var string
16
+ */
17
+ protected $form_key;
18
+
19
+ /**
20
+ * @var MW_WP_Form_Setting
21
+ */
22
+ protected $Setting;
23
+
24
+ /**
25
+ * @var MW_WP_Form_Data
26
+ */
27
+ protected $Data;
28
+
29
+ /**
30
+ * @var string
31
+ */
32
+ protected static $pattern = '/{(.+?)}/';
33
+
34
+ /**
35
+ * @param MW_WP_Form_Setting
36
+ */
37
+ public function __construct( $Setting ) {
38
+ $this->Setting = $Setting;
39
+ $form_id = $Setting->get( 'post_id' );
40
+ $this->form_key = MWF_Functions::get_form_key_from_form_id( $form_id );
41
+ $this->Data = MW_WP_Form_Data::connect( $this->form_key );
42
+ }
43
+
44
+ /**
45
+ * Replace {name} for mail destination
46
+ *
47
+ * @param string $value
48
+ * @return string
49
+ */
50
+ public function replace_for_mail_destination( $value ) {
51
+ return $this->_replace( $value, array( $this, '_replace_for_mail_destination_callback' ) );
52
+ }
53
+ protected function _replace_for_mail_destination_callback( $matches ) {
54
+ $match = $matches[1];
55
+ $value = MW_WP_Form_Parser::apply_filters_mwform_custom_mail_tag( $this->form_key, null, $match );
56
+
57
+ // Return blank when custom mail tag isn't use(= null)
58
+ if ( is_null( $value ) ) {
59
+ return '';
60
+ }
61
+ return $value;
62
+ }
63
+
64
+ /**
65
+ * Replace {name} for mail content
66
+ *
67
+ * @param string $value
68
+ * @return string
69
+ */
70
+ public function replace_for_mail_content( $value ) {
71
+ return $this->_replace( $value, array( $this, '_replace_for_mail_content_callback' ) );
72
+ }
73
+ protected function _replace_for_mail_content_callback( $matches ) {
74
+ $match = $matches[1];
75
+ return $this->parse( $match );
76
+ }
77
+
78
+ /**
79
+ * Replace {name} for input and confirm page
80
+ *
81
+ * @param string $value
82
+ * @return string
83
+ */
84
+ public function replace_for_page( $value ) {
85
+ $value = $this->_replace_user_property( $value );
86
+ $value = $this->_replace_post_property( $value );
87
+ return $value;
88
+ }
89
+
90
+ /**
91
+ * Replace {foo} in the form. e.g. $post->foo
92
+ *
93
+ * @param string $value
94
+ * @return string
95
+ */
96
+ protected function _replace_post_property( $value ) {
97
+ if ( $this->Setting->get( 'querystring' ) ) {
98
+ $callback = array( $this, '_get_post_property_from_querystring' );
99
+ } else {
100
+ $callback = array( $this, '_get_post_property_from_this' );
101
+ }
102
+
103
+ return $this->_replace( $value, $callback );
104
+ }
105
+
106
+ /**
107
+ * Callback from preg_replace_callback when enabled querystring setting
108
+ *
109
+ * @param array $matches
110
+ * @return string|null
111
+ */
112
+ protected function _get_post_property_from_querystring( $matches ) {
113
+ if ( ! isset( $_GET['post_id'] ) || ! MWF_Functions::is_numeric( $_GET['post_id'] ) ) {
114
+ return;
115
+ }
116
+
117
+ $post = get_post( $_GET['post_id'] );
118
+ if ( empty( $post->ID ) ) {
119
+ return;
120
+ }
121
+
122
+ return $this->_get_post_property( $post, $matches[1] );
123
+ }
124
+
125
+ /**
126
+ * Callback from preg_replace_callback when disabled querystring setting
127
+ *
128
+ * @param array $matches
129
+ * @return string|null
130
+ */
131
+ protected function _get_post_property_from_this( $matches ) {
132
+ global $post;
133
+ global $wp_query;
134
+
135
+ if ( ! is_singular() ) {
136
+ return;
137
+ }
138
+
139
+ if ( empty( $post->ID ) ) {
140
+ return;
141
+ }
142
+
143
+ return $this->_get_post_property( $post, $matches[1] );
144
+ }
145
+
146
+ /**
147
+ * Get WP_Post property
148
+ *
149
+ * @param WP_Post|null $post
150
+ * @param string $meta_key
151
+ * @return string|null
152
+ */
153
+ protected function _get_post_property( $post, $meta_key ) {
154
+ if ( ! is_a( $post, 'WP_Post' ) ) {
155
+ return;
156
+ }
157
+
158
+ if ( isset( $post->$meta_key ) ) {
159
+ return $post->$meta_key;
160
+ }
161
+
162
+ $post_meta = get_post_meta( $post->ID, $meta_key, true );
163
+ if ( is_array( $post_meta ) ) {
164
+ return;
165
+ }
166
+
167
+ return $post_meta;
168
+ }
169
+
170
+ /**
171
+ * Replace {property of user} when logged in
172
+ *
173
+ * @param string $content
174
+ * @return string
175
+ */
176
+ protected function _replace_user_property( $content ) {
177
+ $user = wp_get_current_user();
178
+ $search = array(
179
+ '{user_id}',
180
+ '{user_login}',
181
+ '{user_email}',
182
+ '{user_url}',
183
+ '{user_registered}',
184
+ '{display_name}',
185
+ );
186
+
187
+ if ( ! empty( $user ) ) {
188
+ $content = str_replace( $search, array(
189
+ $user->get( 'ID' ),
190
+ $user->get( 'user_login' ),
191
+ $user->get( 'user_email' ),
192
+ $user->get( 'user_url' ),
193
+ $user->get( 'user_registered' ),
194
+ $user->get( 'display_name' ),
195
+ ), $content );
196
+ } else {
197
+ $content = str_replace( $search, '', $content );
198
+ }
199
+
200
+ return $content;
201
+ }
202
+
203
+ /**
204
+ * Search {$name}
205
+ *
206
+ * @param string $value
207
+ * @return array $matches
208
+ */
209
+ public static function search( $value ) {
210
+ preg_match_all(
211
+ self::$pattern,
212
+ $value,
213
+ $matches
214
+ );
215
+
216
+ return $matches;
217
+ }
218
+
219
+ /**
220
+ * そのキーについて送信された値を返す
221
+ *
222
+ * @param string $name
223
+ * @return string
224
+ */
225
+ public function parse( $name ) {
226
+ $form_id = $this->Setting->get( 'post_id' );
227
+
228
+ // MWF_Config::TRACKINGNUMBER のときはお問い合せ番号を参照する
229
+ if ( MWF_Config::TRACKINGNUMBER === $name ) {
230
+ if ( $form_id ) {
231
+ return $this->Setting->get_tracking_number( $form_id );
232
+ }
233
+ }
234
+
235
+ $value = $this->Data->get( $name );
236
+ $value = MW_WP_Form_Parser::apply_filters_mwform_custom_mail_tag(
237
+ $this->Data->get_form_key(),
238
+ $value,
239
+ $name,
240
+ $this->Data->get_saved_mail_id()
241
+ );
242
+ return $value;
243
+ }
244
+
245
+ /**
246
+ * Apply mwform_custom_mail_tag filter hook
247
+ *
248
+ * @param string $form_key
249
+ * @param string|null $value
250
+ * @param string $name
251
+ * @param string $saved_mail_id
252
+ * @return string
253
+ */
254
+ public static function apply_filters_mwform_custom_mail_tag( $form_key, $value, $name, $saved_mail_id = null ) {
255
+ $value = apply_filters(
256
+ 'mwform_custom_mail_tag',
257
+ $value,
258
+ $name,
259
+ $saved_mail_id
260
+ );
261
+
262
+ $value = apply_filters(
263
+ 'mwform_custom_mail_tag_' . $form_key,
264
+ $value,
265
+ $name,
266
+ $saved_mail_id
267
+ );
268
+ return $value;
269
+ }
270
+
271
+ /**
272
+ * Replace {name} for mail content
273
+ *
274
+ * @param string $value
275
+ * @return string
276
+ */
277
+ protected static function _replace( $value, $callback ) {
278
+ return preg_replace_callback(
279
+ self::$pattern,
280
+ $callback,
281
+ $value
282
+ );
283
+ }
284
+ }
classes/models/class.session.php CHANGED
@@ -1,19 +1,18 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Session
4
- * Description: 永続的にデータを保存するためのクラス。Transient API を使用
5
- * Version : 2.1.0
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : July 17, 2012
9
- * Modified : December 31, 2014
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Session {
14
 
15
  /**
16
- * セッション名
17
  * @var string
18
  */
19
  protected $name;
@@ -24,95 +23,113 @@ class MW_WP_Form_Session {
24
  protected $session_id;
25
 
26
  /**
27
- * Transient の生存時間
28
  * @var int
29
  */
30
  protected $expiration = 1440;
31
 
32
  /**
33
- * __construct
34
- *
35
- * @param string $name 識別子
36
  */
37
  public function __construct( $name ) {
38
  $this->name = MWF_Config::NAME . '_session_' . $name;
39
- if ( isset( $_COOKIE[$this->name] ) ) {
40
- $session_id = $_COOKIE[$this->name];
 
41
  } else {
42
  $session_id = sha1( wp_create_nonce( $this->name ) . ip2long( $this->get_remote_addr() ) . uniqid() );
43
  $secure = apply_filters( 'mwform_secure_cookie', is_ssl() );
44
- @setcookie( $this->name, $session_id, 0, COOKIEPATH, COOKIE_DOMAIN, $secure, true );
 
 
 
 
45
  }
 
46
  $this->session_id = $session_id;
47
  }
48
 
 
 
 
49
  /**
50
- * セッション変数にセット
51
  *
52
  * @param array $data
 
53
  */
54
  public function save( array $data ) {
55
  $transient_data = get_transient( $this->session_id );
56
- if ( is_array( $transient_data ) ) {
57
- foreach ( $data as $key => $value ) {
58
- $transient_data[$key] = $value;
59
- }
60
- } else {
61
- $transient_data = $data;
62
  }
63
  set_transient( $this->session_id, $transient_data, $this->expiration );
64
  }
65
 
66
  /**
67
- * セッション変数にセット
68
  *
69
- * @param string $key キー
70
- * @param mixed $value 値
 
71
  */
72
  public function set( $key, $value ) {
73
  $transient_data = get_transient( $this->session_id );
74
- if ( is_array( $transient_data ) ) {
75
- $transient_data[$key] = $value;
76
- } else {
77
- $transient_data = array( $key => $value );
78
  }
 
 
79
  set_transient( $this->session_id, $transient_data, $this->expiration );
80
  }
81
 
82
  /**
83
- * セッション変数にセット
84
  *
85
- * @param string $key キー
86
- * @param mixed $value
 
87
  */
88
  public function push( $key, $value ) {
89
  $transient_data = get_transient( $this->session_id );
90
- if ( is_array( $transient_data ) ) {
91
- $transient_data[$key][] = $value;
 
 
 
 
92
  } else {
93
- $transient_data = array( $key => array( $value ) );
 
 
 
 
 
94
  }
95
  set_transient( $this->session_id, $transient_data, $this->expiration );
96
  }
97
 
98
  /**
99
- * セッション変数から取得
100
  *
101
- * @param string $key キー
102
- * @return mixed セッション値
103
  */
104
  public function get( $key ) {
105
  $transient_data = get_transient( $this->session_id );
106
- if ( is_array( $transient_data ) && isset( $transient_data[$key] ) ) {
107
- return $transient_data[$key];
108
  }
109
- return null;
110
  }
111
 
112
  /**
113
- * セッション変数から取得
114
  *
115
- * @return array セッション値
116
  */
117
  public function gets() {
118
  $transient_data = get_transient( $this->session_id );
@@ -123,27 +140,32 @@ class MW_WP_Form_Session {
123
  }
124
 
125
  /**
126
- * セッション変数を空に
127
  *
128
- * @param string $key キー
 
129
  */
130
  public function clear_value( $key ) {
131
  $transient_data = get_transient( $this->session_id );
132
- if ( is_array( $transient_data ) && isset( $transient_data[$key] ) ) {
133
- unset( $transient_data[$key] );
134
  set_transient( $this->session_id, $transient_data, $this->expiration );
135
  }
136
  }
137
 
138
  /**
139
- * セッション変数を空に
 
 
140
  */
141
  public function clear_values() {
142
  delete_transient( $this->session_id );
143
  }
144
 
145
  /**
146
- * $_SERVER['REMOTE_ADDR'] を取得
 
 
147
  */
148
  protected function get_remote_addr() {
149
  if ( isset( $_SERVER['REMOTE_ADDR'] ) ) {
1
  <?php
2
  /**
3
  * Name : MW WP Form Session
4
+ * Version : 3.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : July 17, 2012
8
+ * Modified : June 1, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Session {
13
 
14
  /**
15
+ * Session name
16
  * @var string
17
  */
18
  protected $name;
23
  protected $session_id;
24
 
25
  /**
26
+ * Transient's survival time
27
  * @var int
28
  */
29
  protected $expiration = 1440;
30
 
31
  /**
32
+ * @param string $name
 
 
33
  */
34
  public function __construct( $name ) {
35
  $this->name = MWF_Config::NAME . '_session_' . $name;
36
+
37
+ if ( isset( $_COOKIE[ $this->name ] ) ) {
38
+ $session_id = $_COOKIE[ $this->name ];
39
  } else {
40
  $session_id = sha1( wp_create_nonce( $this->name ) . ip2long( $this->get_remote_addr() ) . uniqid() );
41
  $secure = apply_filters( 'mwform_secure_cookie', is_ssl() );
42
+ try {
43
+ set_error_handler( array( 'self', 'error_handler' ) );
44
+ setcookie( $this->name, $session_id, 0, COOKIEPATH, COOKIE_DOMAIN, $secure, true );
45
+ } catch ( ErrorException $e ) {
46
+ }
47
  }
48
+
49
  $this->session_id = $session_id;
50
  }
51
 
52
+ public static function error_handler( $errno, $errstr, $errfile, $errline ) {
53
+ }
54
+
55
  /**
56
+ * Save values
57
  *
58
  * @param array $data
59
+ * @return void
60
  */
61
  public function save( array $data ) {
62
  $transient_data = get_transient( $this->session_id );
63
+ if ( ! is_array( $transient_data ) ) {
64
+ $transient_data = array();
65
+ }
66
+
67
+ foreach ( $data as $key => $value ) {
68
+ $transient_data[ $key ] = $value;
69
  }
70
  set_transient( $this->session_id, $transient_data, $this->expiration );
71
  }
72
 
73
  /**
74
+ * Save a value
75
  *
76
+ * @param string
77
+ * @param mixed
78
+ * @return void
79
  */
80
  public function set( $key, $value ) {
81
  $transient_data = get_transient( $this->session_id );
82
+ if ( ! is_array( $transient_data ) ) {
83
+ $transient_data = array();
 
 
84
  }
85
+
86
+ $transient_data[ $key ] = $value;
87
  set_transient( $this->session_id, $transient_data, $this->expiration );
88
  }
89
 
90
  /**
91
+ * Push a value
92
  *
93
+ * @param string $key
94
+ * @param mixed $value
95
+ * @return void
96
  */
97
  public function push( $key, $value ) {
98
  $transient_data = get_transient( $this->session_id );
99
+ if ( ! is_array( $transient_data ) ) {
100
+ $transient_data = array();
101
+ }
102
+
103
+ if ( ! isset( $transient_data[ $key ] ) ) {
104
+ $transient_data[ $key ] = array( $value );
105
  } else {
106
+ if ( is_array( $transient_data[ $key ] ) ) {
107
+ $transient_data[ $key ][] = $value;
108
+ } else {
109
+ $transient_data[ $key ] = array( $transient_data[ $key ] );
110
+ $transient_data[ $key ][] = $value;
111
+ }
112
  }
113
  set_transient( $this->session_id, $transient_data, $this->expiration );
114
  }
115
 
116
  /**
117
+ * Return a value
118
  *
119
+ * @param string $key
120
+ * @return mixed
121
  */
122
  public function get( $key ) {
123
  $transient_data = get_transient( $this->session_id );
124
+ if ( is_array( $transient_data ) && isset( $transient_data[ $key ] ) ) {
125
+ return $transient_data[ $key ];
126
  }
 
127
  }
128
 
129
  /**
130
+ * Return all values
131
  *
132
+ * @return array
133
  */
134
  public function gets() {
135
  $transient_data = get_transient( $this->session_id );
140
  }
141
 
142
  /**
143
+ * Clear a value
144
  *
145
+ * @param string $key
146
+ * @return void
147
  */
148
  public function clear_value( $key ) {
149
  $transient_data = get_transient( $this->session_id );
150
+ if ( is_array( $transient_data ) && isset( $transient_data[ $key ] ) ) {
151
+ unset( $transient_data[ $key ] );
152
  set_transient( $this->session_id, $transient_data, $this->expiration );
153
  }
154
  }
155
 
156
  /**
157
+ * Clear values
158
+ *
159
+ * @return void
160
  */
161
  public function clear_values() {
162
  delete_transient( $this->session_id );
163
  }
164
 
165
  /**
166
+ * Return $_SERVER['REMOTE_ADDR']
167
+ *
168
+ * @return string
169
  */
170
  protected function get_remote_addr() {
171
  if ( isset( $_SERVER['REMOTE_ADDR'] ) ) {
classes/models/class.setting.php CHANGED
@@ -1,84 +1,96 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Setting
4
- * Version : 1.3.0
5
  * Author : Takashi Kitajima
6
- * Author URI : http://2inc.org
7
  * Created : December 31, 2014
8
- * Modified : January 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Setting {
13
 
14
  /**
15
- * フォームの Post ID
16
  * @var int
17
  */
18
  protected $post_id;
19
 
20
  /**
21
- * URL引数を有効にするかどうか
22
  * @var false|1
23
  */
24
  protected $querystring = false;
25
 
26
  /**
27
- * 問い合わせデータを保存するかどうか
28
  * @var false|1
29
  */
30
  protected $usedb = false;
31
 
32
  /**
33
- * 自動返信メールの題名
34
  * @var string
35
  */
36
  protected $mail_subject = '';
37
 
38
  /**
39
- * 自動返信メールの送信元
40
  * @var string
41
  */
42
  protected $mail_from = '';
43
 
44
  /**
45
- * 自動返信メールの送信者
46
  * @var string
47
  */
48
  protected $mail_sender = '';
49
 
50
  /**
51
- * 自動返信メールの本文
 
 
 
 
 
 
52
  * @var string
53
  */
54
  protected $mail_content = '';
55
 
56
  /**
57
- * 自動返信メールの送信先を格納したフォームフィールドのname属性
58
  * @var string
59
  */
60
  protected $automatic_reply_email = '';
61
 
62
  /**
63
- * 管理者メールの送信先
64
  * @var string
65
  */
66
  protected $mail_to = '';
67
 
68
  /**
69
- * 管理者メールのCC
70
  * @var string
71
  */
72
  protected $mail_cc = '';
73
 
74
  /**
75
- * 管理者メールのBCC
76
  * @var string
77
  */
78
  protected $mail_bcc = '';
79
 
80
  /**
81
- * 管理者メールの題名
 
 
 
 
 
 
82
  * @var string
83
  */
84
  protected $admin_mail_subject = '';
@@ -90,106 +102,108 @@ class MW_WP_Form_Setting {
90
  protected $mail_return_path = '';
91
 
92
  /**
93
- * 管理者メールの送信元
94
  * @var string
95
  */
96
  protected $admin_mail_from = '';
97
 
98
  /**
99
- * 管理者メールの送信者
100
  * @var string
101
  */
102
  protected $admin_mail_sender = '';
103
 
104
  /**
105
- * 管理者メールの本文
106
  * @var string
107
  */
108
  protected $admin_mail_content = '';
109
 
110
  /**
111
- * akismet送信者の対象とするフォームフィールドのname属性
112
  * @var string
113
  */
114
  protected $akismet_author = '';
115
 
116
  /**
117
- * akismetメールアドレスの対象とするフォームフィールドのname属性
118
  * @var string
119
  */
120
  protected $akismet_author_email = '';
121
 
122
  /**
123
- * akismet url の対象とするフォームフィールドのname属性
124
  * @var string
125
  */
126
  protected $akismet_author_url = '';
127
 
128
  /**
129
- * 完了画面メッセージ
130
  * @var string
131
  */
132
  protected $complete_message = '';
133
 
134
  /**
135
- * 入力画面URL
136
  * @var string
137
  */
138
  protected $input_url = '';
139
 
140
  /**
141
- * 確認画面URL
142
  * @var string
143
  */
144
  protected $confirmation_url = '';
145
 
146
  /**
147
- * 完了画面URL
148
  * @var string
149
  */
150
  protected $complete_url = '';
151
 
152
  /**
153
- * バリデーションエラー画面URL
154
  * @var string
155
  */
156
  protected $validation_error_url = '';
157
 
158
  /**
159
- * フォームに設定されたバリデーションルールの配列
160
  * @var array
161
  */
162
  protected $validation = array();
163
 
164
  /**
165
- * フォームに設定されたスタイル
166
  * @var string
167
  */
168
  protected $style = '';
169
 
170
  /**
171
- * 入力画面以外を表示したときにフォームの位置までスクロールするかどうか
172
  * @var false|1
173
  */
174
  protected $scroll = false;
175
 
176
  /**
177
- * __construct
178
- *
179
  * @param int $post_id
180
  */
181
  public function __construct( $post_id ) {
182
- if ( get_post_type( $post_id ) === MWF_Config::NAME ) {
183
- $this->post_id = $post_id;
184
- $values = get_post_meta( $post_id, MWF_Config::NAME, true );
185
- if ( is_array( $values ) ) {
186
- $this->sets( $values );
187
- }
188
  }
 
 
 
 
 
 
 
 
189
  }
190
 
191
  /**
192
- * 属性の取得
193
  *
194
  * @param string $key
195
  * @return mixed|null
@@ -201,10 +215,11 @@ class MW_WP_Form_Setting {
201
  }
202
 
203
  /**
204
- * 属性をセット
205
  *
206
  * @param string $key
207
  * @param mixed $value
 
208
  */
209
  public function set( $key, $value ) {
210
  if ( isset( $this->$key ) ) {
@@ -213,7 +228,7 @@ class MW_WP_Form_Setting {
213
  }
214
 
215
  /**
216
- * 属性をセット
217
  *
218
  * @param array $values
219
  */
@@ -224,16 +239,18 @@ class MW_WP_Form_Setting {
224
  }
225
 
226
  /**
227
- * 保持しているデータでアップデート
 
 
228
  */
229
  public function save() {
230
  $values = get_object_vars( $this );
231
  $new_values = array();
232
  foreach ( $values as $key => $value ) {
233
- if ( $key === 'post_id' ) {
234
  continue;
235
  }
236
- $new_values[$key] = $value;
237
  }
238
  update_post_meta( $this->post_id, MWF_Config::NAME, $new_values );
239
  $form_key = MWF_Functions::get_form_key_from_form_id( $this->post_id );
@@ -241,23 +258,17 @@ class MW_WP_Form_Setting {
241
  }
242
 
243
  /**
244
- * 全ての設定(投稿)を取得
245
  *
246
- * @return array フォーム(WP_Post)の配列
247
  */
248
  public function get_posts() {
249
- $forms = get_posts( array(
250
- 'post_type' => MWF_Config::NAME,
251
- 'posts_per_page' => -1,
252
- ) );
253
- if ( !is_array( $forms ) ) {
254
- return array();
255
- }
256
- return $forms;
257
  }
258
 
259
  /**
260
- * 問い合わせ番号を取得
261
  *
262
  * @return int $tracking_number
263
  */
@@ -270,9 +281,9 @@ class MW_WP_Form_Setting {
270
  }
271
 
272
  /**
273
- * 問い合わせ番号を更新
274
  *
275
- * @param null|int $count 指定があればそれに更新
276
  */
277
  public function update_tracking_number( $count = null ) {
278
  $new_tracking_number = null;
@@ -282,8 +293,21 @@ class MW_WP_Form_Setting {
282
  } elseif ( MWF_Functions::is_numeric( $count ) ) {
283
  $new_tracking_number = $count;
284
  }
285
- if ( !is_null( $new_tracking_number ) ) {
286
  update_post_meta( $this->post_id, MWF_Config::TRACKINGNUMBER, $new_tracking_number );
287
  }
288
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
289
  }
1
  <?php
2
  /**
3
  * Name : MW WP Form Setting
4
+ * Version : 2.0.0
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : December 31, 2014
8
+ * Modified : June 1, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Setting {
13
 
14
  /**
15
+ * Form ID
16
  * @var int
17
  */
18
  protected $post_id;
19
 
20
  /**
21
+ * Whether to enable URL querystring
22
  * @var false|1
23
  */
24
  protected $querystring = false;
25
 
26
  /**
27
+ * Whether to use database
28
  * @var false|1
29
  */
30
  protected $usedb = false;
31
 
32
  /**
33
+ * Reply mail subject
34
  * @var string
35
  */
36
  protected $mail_subject = '';
37
 
38
  /**
39
+ * Reply mail from
40
  * @var string
41
  */
42
  protected $mail_from = '';
43
 
44
  /**
45
+ * Reply mail sender
46
  * @var string
47
  */
48
  protected $mail_sender = '';
49
 
50
  /**
51
+ * Reply mail Reply-to
52
+ * @var string
53
+ */
54
+ protected $mail_reply_to = '';
55
+
56
+ /**
57
+ * Reply mail content
58
  * @var string
59
  */
60
  protected $mail_content = '';
61
 
62
  /**
63
+ * The name of the form field storing the destination of the automatic reply e-mail
64
  * @var string
65
  */
66
  protected $automatic_reply_email = '';
67
 
68
  /**
69
+ * Admin mail To
70
  * @var string
71
  */
72
  protected $mail_to = '';
73
 
74
  /**
75
+ * Admin mail CC
76
  * @var string
77
  */
78
  protected $mail_cc = '';
79
 
80
  /**
81
+ * Admin mail BCC
82
  * @var string
83
  */
84
  protected $mail_bcc = '';
85
 
86
  /**
87
+ * Admin mail Reply-to
88
+ * @var string
89
+ */
90
+ protected $admin_mail_reply_to = '';
91
+
92
+ /**
93
+ * Admin mail subject
94
  * @var string
95
  */
96
  protected $admin_mail_subject = '';
102
  protected $mail_return_path = '';
103
 
104
  /**
105
+ * Admin mail from
106
  * @var string
107
  */
108
  protected $admin_mail_from = '';
109
 
110
  /**
111
+ * Admin mail sender
112
  * @var string
113
  */
114
  protected $admin_mail_sender = '';
115
 
116
  /**
117
+ * Admin mail content
118
  * @var string
119
  */
120
  protected $admin_mail_content = '';
121
 
122
  /**
123
+ * Input field name that targeted akismet author
124
  * @var string
125
  */
126
  protected $akismet_author = '';
127
 
128
  /**
129
+ * Input field name that targeted akismet e-mail
130
  * @var string
131
  */
132
  protected $akismet_author_email = '';
133
 
134
  /**
135
+ * Input field name that targeted akismet URL
136
  * @var string
137
  */
138
  protected $akismet_author_url = '';
139
 
140
  /**
141
+ * Complete screen message
142
  * @var string
143
  */
144
  protected $complete_message = '';
145
 
146
  /**
147
+ * Input screen URL
148
  * @var string
149
  */
150
  protected $input_url = '';
151
 
152
  /**
153
+ * Confirm screen URL
154
  * @var string
155
  */
156
  protected $confirmation_url = '';
157
 
158
  /**
159
+ * Complete screen URL
160
  * @var string
161
  */
162
  protected $complete_url = '';
163
 
164
  /**
165
+ * Validation error screen url
166
  * @var string
167
  */
168
  protected $validation_error_url = '';
169
 
170
  /**
171
+ * Array of validation rules set in the form
172
  * @var array
173
  */
174
  protected $validation = array();
175
 
176
  /**
177
+ * Style set in the form
178
  * @var string
179
  */
180
  protected $style = '';
181
 
182
  /**
183
+ * Whether to scroll to the position of the form
184
  * @var false|1
185
  */
186
  protected $scroll = false;
187
 
188
  /**
 
 
189
  * @param int $post_id
190
  */
191
  public function __construct( $post_id ) {
192
+ if ( MWF_Config::NAME !== get_post_type( $post_id ) ) {
193
+ return;
 
 
 
 
194
  }
195
+
196
+ $this->post_id = $post_id;
197
+ $values = get_post_meta( $post_id, MWF_Config::NAME, true );
198
+ if ( ! is_array( $values ) ) {
199
+ return;
200
+ }
201
+
202
+ $this->sets( $values );
203
  }
204
 
205
  /**
206
+ * Return a attribute
207
  *
208
  * @param string $key
209
  * @return mixed|null
215
  }
216
 
217
  /**
218
+ * Set a attribute
219
  *
220
  * @param string $key
221
  * @param mixed $value
222
+ * @return void
223
  */
224
  public function set( $key, $value ) {
225
  if ( isset( $this->$key ) ) {
228
  }
229
 
230
  /**
231
+ * Set attributes
232
  *
233
  * @param array $values
234
  */
239
  }
240
 
241
  /**
242
+ * Update with retained data
243
+ *
244
+ * @return void
245
  */
246
  public function save() {
247
  $values = get_object_vars( $this );
248
  $new_values = array();
249
  foreach ( $values as $key => $value ) {
250
+ if ( 'post_id' == $key ) {
251
  continue;
252
  }
253
+ $new_values[ $key ] = $value;
254
  }
255
  update_post_meta( $this->post_id, MWF_Config::NAME, $new_values );
256
  $form_key = MWF_Functions::get_form_key_from_form_id( $this->post_id );
258
  }
259
 
260
  /**
261
+ * Return all forms
262
  *
263
+ * @return array Array of WP_Post
264
  */
265
  public function get_posts() {
266
+ $Admin = new MW_WP_Form_Admin();
267
+ return $Admin->get_forms();
 
 
 
 
 
 
268
  }
269
 
270
  /**
271
+ * Return tracking number
272
  *
273
  * @return int $tracking_number
274
  */
281
  }
282
 
283
  /**
284
+ * Update traking number
285
  *
286
+ * @param null|int $count Update to it if specified
287
  */
288
  public function update_tracking_number( $count = null ) {
289
  $new_tracking_number = null;
293
  } elseif ( MWF_Functions::is_numeric( $count ) ) {
294
  $new_tracking_number = $count;
295
  }
296
+ if ( ! is_null( $new_tracking_number ) ) {
297
  update_post_meta( $this->post_id, MWF_Config::TRACKINGNUMBER, $new_tracking_number );
298
  }
299
  }
300
+
301
+ /**
302
+ * Generate verify token for form posts data correct checking
303
+ *
304
+ * @return string
305
+ */
306
+ public function generate_form_verify_token() {
307
+ $vars = get_object_vars( $this );
308
+ $token = serialize( $vars );
309
+ $token = base64_encode( $token );
310
+ $token = sha1( $token );
311
+ return $token;
312
+ }
313
  }
classes/models/class.validation-rules.php ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Name : MW WP Form Validation Rules
4
+ * Version : 1.0.0
5
+ * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
+ * Created : June 1, 2017
8
+ * Modified :
9
+ * License : GPLv2 or later
10
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
+ */
12
+ class MW_WP_Form_Validation_Rules {
13
+
14
+ /**
15
+ * @var array Array of MW_WP_Form_Validation_Rules
16
+ */
17
+ protected static $Instances;
18
+
19
+ /**
20
+ * @var string
21
+ */
22
+ protected $form_key;
23
+
24
+ /**
25
+ * Array of validation rules. Definition is necessary to fix the order
26
+ * @var array
27
+ */
28
+ protected static $validation_rules = array(
29
+ 'akismet_check' => '',
30
+ 'noempty' => '',
31
+ 'required' => '',
32
+ 'numeric' => '',
33
+ 'alpha' => '',
34
+ 'alphanumeric' => '',
35
+ 'katakana' => '',
36
+ 'hiragana' => '',
37
+ 'kana' => '',
38
+ 'zip' => '',
39
+ 'tel' => '',
40
+ 'mail' => '',
41
+ 'date' => '',
42
+ 'month' => '',
43
+ 'url' => '',
44
+ 'eq' => '',
45
+ 'between' => '',
46
+ 'minlength' => '',
47
+ 'filetype' => '',
48
+ 'filesize' => '',
49
+ 'maxfilesize' => '',
50
+ 'minfilesize' => '',
51
+ );
52
+
53
+ /**
54
+ * @param string $form_key
55
+ */
56
+ private function __construct( $form_key ) {
57
+ $this->form_key = $form_key;
58
+
59
+ foreach ( glob( plugin_dir_path( __FILE__ ) . '../validation-rules/*.php' ) as $filename ) {
60
+ $class_name = self::_get_class_name_from_validation_rule_filename( $filename );
61
+ if ( ! class_exists( $class_name ) ) {
62
+ continue;
63
+ }
64
+
65
+ new $class_name( MW_WP_Form_Data::connect( $this->form_key ) );
66
+ }
67
+ }
68
+
69
+ public static function instantiation( $form_key ) {
70
+ if ( isset( self::$Instances[ $form_key ] ) ) {
71
+ return self::$Instances[ $form_key ];
72
+ }
73
+
74
+ self::$Instances[ $form_key ] = new self( $form_key );
75
+ return self::$Instances[ $form_key ];
76
+ }
77
+
78
+ /**
79
+ * Instantiation of validation rules. Set in the array through the hook.
80
+ *
81
+ * @return $validation_rules Array of MW_WP_Form_Abstract_Validation_Rule
82
+ */
83
+ public function get_validation_rules() {
84
+ self::$validation_rules = apply_filters(
85
+ 'mwform_validation_rules',
86
+ self::$validation_rules,
87
+ null // backward compatibility
88
+ );
89
+
90
+ foreach ( self::$validation_rules as $validation_rule => $validation_rule_object ) {
91
+ if ( is_a( $validation_rule_object, 'MW_WP_Form_Abstract_Validation_Rule' ) ) {
92
+ // For backward compatibility (< 4.0.0)
93
+ if ( method_exists( $validation_rule_object, 'set_Data' ) && ! $validation_rule_object->is_set_Data() ) {
94
+ $validation_rule_object->set_Data( MW_WP_Form_Data::connect( $this->form_key ) );
95
+ }
96
+ } else {
97
+ unset( self::$validation_rules[ $validation_rule ] );
98
+ }
99
+ }
100
+
101
+ return self::$validation_rules;
102
+ }
103
+
104
+ /**
105
+ * Return class name from filename of validation rule
106
+ *
107
+ * @param string $filename
108
+ * @return string
109
+ */
110
+ protected static function _get_class_name_from_validation_rule_filename( $filename ) {
111
+ $class_name = preg_replace( '/^class\./', '', basename( $filename, '.php' ) );
112
+ $class_name = str_replace( '-', '_', $class_name );
113
+ $class_name = 'MW_WP_Form_Validation_Rule_' . $class_name;
114
+ return $class_name;
115
+ }
116
+ }
classes/models/class.validation.php CHANGED
@@ -1,120 +1,95 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Validation
4
- * Description: 与えられたデータに対してバリデーションエラーがあるかチェックする
5
- * Version : 1.8.5
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : July 20, 2012
9
- * Modified : April 15, 2015
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Validation {
14
 
15
  /**
16
- * @var MW_WP_Form_Error
17
  */
18
- protected $Error;
19
 
20
  /**
21
- * バリデートをかける項目(name属性)と、それにかけるバリデーションの配列
22
- * @var array
23
  */
24
- protected $validate = array();
25
 
26
  /**
27
- * バリデーションルールの配列
28
- * @var array
29
  */
30
- protected $validation_rules = array();
31
 
32
  /**
33
- * __construct
34
- *
35
- * @param MW_WP_Form_Error $Error
36
  */
37
- public function __construct( MW_WP_Form_Error $Error ) {
38
- $this->Error = $Error;
39
- }
40
 
41
  /**
42
- * 各バリデーションルールクラスのインスタンスをセット
43
- *
44
- * @param array $validation_rules
45
  */
46
- public function set_validation_rules( array $validation_rules ) {
47
- foreach ( $validation_rules as $validation_name => $instance ) {
48
- if ( is_callable( array( $instance, 'rule' ) ) ) {
49
- $this->validation_rules[$instance->getName()] = $instance;
50
- }
51
- }
52
- }
53
 
54
- /**
55
- * セットされたバリデーションルールクラスを取得
56
- *
57
- * @return array
58
- */
59
- public function get_validation_rules() {
60
- return $this->validation_rules;
61
  }
62
 
63
  /**
64
- * バリデートが通っているかチェック
65
  *
66
- * @return bool
67
  */
68
- protected function is_valid() {
69
- $errors = $this->Error->get_errors();
70
- if ( empty( $errors ) ) {
71
- return true;
72
- } else {
73
- return false;
74
- }
75
- }
76
-
77
- /**
78
- * set_rules
79
- *
80
- * @param MW_WP_Form_Setting $Setting
81
- */
82
- public function set_rules( MW_WP_Form_Setting $Setting ) {
83
- $Data = MW_WP_Form_Data::getInstance();
84
-
85
- $rules = array();
86
- $validations = $Setting->get('validation' );
87
  if ( $validations ) {
88
  foreach ( $validations as $validation ) {
89
  foreach ( $validation as $rule => $options ) {
90
- if ( $rule == 'target' ) {
91
  continue;
92
  }
93
- if ( !is_array( $options ) ) {
94
  $options = array();
95
  }
96
  $this->set_rule( $validation['target'], $rule, $options );
97
  }
98
  }
99
  }
 
100
  $Akismet = new MW_WP_Form_Akismet();
101
- $akismet_check = $Akismet->check(
102
- $Setting->get( 'akismet_author' ),
103
- $Setting->get( 'akismet_author_email' ),
104
- $Setting->get( 'akismet_author_url' ),
105
- $Data
106
  );
107
  if ( $akismet_check ) {
108
  $this->set_rule( MWF_Config::AKISMET, 'akismet_check' );
109
  }
 
 
 
 
 
 
 
110
  }
111
 
112
  /**
113
- * set_rule
114
  *
115
- * @param string ターゲットのname属性
116
- * @param string バリデーションルール名
117
- * @param array オプション
118
  * @return MW_WP_Form_Validation
119
  */
120
  public function set_rule( $key, $rule, array $options = array() ) {
@@ -122,66 +97,128 @@ class MW_WP_Form_Validation {
122
  'rule' => strtolower( $rule ),
123
  'options' => $options
124
  );
125
- $this->validate[$key][] = $rules;
126
  return $this;
127
  }
128
 
129
  /**
130
- * validate実行
131
  *
132
- * @return bool エラーがなければ true
133
  */
134
- public function check() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
  foreach ( $this->validate as $key => $rules ) {
136
- $this->_check( $key, $rules );
137
  }
 
 
 
 
 
 
 
 
 
 
138
  return $this->is_valid();
139
  }
140
 
141
  /**
142
- * 特定の項目のvalidate実行
143
  *
144
  * @param string $key
145
- * @return bool エラーがなければ true
146
  */
147
- public function single_check( $key ) {
148
- $rules = array();
149
- if ( is_array( $this->validate ) && isset( $this->validate[$key] ) ) {
150
- $rules = $this->validate[$key];
151
- $this->_check( $key, $rules );
152
  }
153
- if ( $this->Error->get_error( $key ) ) {
154
- return false;
155
- }
156
- return true;
 
 
 
 
 
 
 
157
  }
158
 
159
  /**
160
- * validate実行の実体
161
  *
162
  * @param string $key
163
  * @param array $rules
164
  */
165
- protected function _check( $key, array $rules ) {
 
 
 
166
  foreach ( $rules as $rule_set ) {
167
- if ( !isset( $rule_set['rule'] ) ) {
168
- continue;
169
- }
170
- $rule = $rule_set['rule'];
171
- if ( !isset( $this->validation_rules[$rule] ) ) {
172
  continue;
173
  }
 
174
  $options = array();
175
  if ( isset( $rule_set['options'] ) ) {
176
  $options = $rule_set['options'];
177
  }
178
- $validation_rule = $this->validation_rules[$rule];
179
- if ( is_callable( array( $validation_rule, 'rule' ) ) ) {
180
- $message = $validation_rule->rule( $key, $options );
181
- if ( !empty( $message ) ) {
182
- $this->Error->set_error( $key, $rule, $message );
183
- }
 
 
 
184
  }
 
 
 
 
 
 
 
185
  }
186
  }
187
  }
1
  <?php
2
  /**
3
  * Name : MW WP Form Validation
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : July 20, 2012
8
+ * Modified : June 1, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Validation {
13
 
14
  /**
15
+ * @var string
16
  */
17
+ protected $form_key;
18
 
19
  /**
20
+ * @var MW_WP_Form_Data
 
21
  */
22
+ protected $Data;
23
 
24
  /**
25
+ * @var MW_WP_Form_Setting
 
26
  */
27
+ protected $Setting;
28
 
29
  /**
30
+ * Array of name of validated and array of validation rules for it pairs
31
+ * @var array
 
32
  */
33
+ protected $validate = array();
 
 
34
 
35
  /**
36
+ * @param string $form_key
 
 
37
  */
38
+ public function __construct( $form_key ) {
39
+ $this->form_key = $form_key;
40
+ $this->Data = MW_WP_Form_Data::connect( $form_key );
41
+ $form_id = MWF_Functions::get_form_id_from_form_key( $form_key );
42
+ $this->Setting = new MW_WP_Form_Setting( $form_id );
 
 
43
 
44
+ $this->_set_rules();
 
 
 
 
 
 
45
  }
46
 
47
  /**
48
+ * Set validation rules of this form
49
  *
50
+ * @return void
51
  */
52
+ protected function _set_rules() {
53
+ $validations = $this->Setting->get( 'validation' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  if ( $validations ) {
55
  foreach ( $validations as $validation ) {
56
  foreach ( $validation as $rule => $options ) {
57
+ if ( 'target' === $rule ) {
58
  continue;
59
  }
60
+ if ( ! is_array( $options ) ) {
61
  $options = array();
62
  }
63
  $this->set_rule( $validation['target'], $rule, $options );
64
  }
65
  }
66
  }
67
+
68
  $Akismet = new MW_WP_Form_Akismet();
69
+ $akismet_check = $Akismet->is_valid(
70
+ $this->Setting->get( 'akismet_author' ),
71
+ $this->Setting->get( 'akismet_author_email' ),
72
+ $this->Setting->get( 'akismet_author_url' ),
73
+ $this->Data
74
  );
75
  if ( $akismet_check ) {
76
  $this->set_rule( MWF_Config::AKISMET, 'akismet_check' );
77
  }
78
+
79
+ $Validation = apply_filters(
80
+ 'mwform_validation_' . $this->form_key,
81
+ $this,
82
+ $this->Data->gets(),
83
+ clone $this->Data
84
+ );
85
  }
86
 
87
  /**
88
+ * Set validation rule of the form field.
89
  *
90
+ * @param string $key
91
+ * @param string $rule
92
+ * @param array $options
93
  * @return MW_WP_Form_Validation
94
  */
95
  public function set_rule( $key, $rule, array $options = array() ) {
97
  'rule' => strtolower( $rule ),
98
  'options' => $options
99
  );
100
+ $this->validate[ $key ][] = $rules;
101
  return $this;
102
  }
103
 
104
  /**
105
+ * for unit tests
106
  *
107
+ * @return bool
108
  */
109
+ public function is_valid_validation_settings() {
110
+ if ( ! is_array( $this->validate ) ) {
111
+ return false;
112
+ }
113
+
114
+ foreach ( $this->validate as $validate ) {
115
+ if ( ! is_array( $validate ) ) {
116
+ return false;
117
+ }
118
+
119
+ foreach ( $validate as $key => $validation_rule ) {
120
+ if ( ! is_array( $validation_rule ) ) {
121
+ return false;
122
+ }
123
+
124
+ if ( ! isset( $validation_rule['rule'] ) ) {
125
+ return false;
126
+ }
127
+
128
+ if ( ! isset( $validation_rule['options'] ) ) {
129
+ return false;
130
+ }
131
+
132
+ if ( ! is_array( $validation_rule['options'] ) ) {
133
+ return false;
134
+ }
135
+ }
136
+ }
137
+
138
+ return true;
139
+ }
140
+
141
+ /**
142
+ * Validation check form fields
143
+ *
144
+ * @return bool Return true when nothing errors
145
+ */
146
+ public function is_valid() {
147
  foreach ( $this->validate as $key => $rules ) {
148
+ $this->_is_valid( $key, $rules );
149
  }
150
+
151
+ return (bool) ! $this->Data->get_validation_errors();
152
+ }
153
+
154
+ public function check() {
155
+ MWF_Functions::deprecated_message(
156
+ 'MW_WP_Form_Validation::check()',
157
+ 'MW_WP_Form_Validation::is_valid()'
158
+ );
159
+
160
  return $this->is_valid();
161
  }
162
 
163
  /**
164
+ * Validation check the one form field
165
  *
166
  * @param string $key
167
+ * @return bool Return true when nothing errors
168
  */
169
+ public function is_valid_field( $key ) {
170
+ if ( isset( $this->validate[ $key ] ) ) {
171
+ $this->_is_valid( $key, $this->validate[ $key ] );
 
 
172
  }
173
+
174
+ return (bool) ! $this->Data->get_validation_error( $key );
175
+ }
176
+
177
+ public function single_check( $key ) {
178
+ MWF_Functions::deprecated_message(
179
+ 'MW_WP_Form_Validation::single_check()',
180
+ 'MW_WP_Form_Validation::is_valid_field()'
181
+ );
182
+
183
+ return $this->is_valid_field();
184
  }
185
 
186
  /**
187
+ * Set varidation errors into MW_WP_Form_Data
188
  *
189
  * @param string $key
190
  * @param array $rules
191
  */
192
+ protected function _is_valid( $key, array $rules ) {
193
+ $Validation_Rules = MW_WP_Form_Validation_Rules::instantiation( $this->form_key );
194
+ $validation_rules = $Validation_Rules->get_validation_rules();
195
+
196
  foreach ( $rules as $rule_set ) {
197
+ if ( ! isset( $rule_set['rule'] ) ) {
 
 
 
 
198
  continue;
199
  }
200
+
201
  $options = array();
202
  if ( isset( $rule_set['options'] ) ) {
203
  $options = $rule_set['options'];
204
  }
205
+
206
+ $rule = $rule_set['rule'];
207
+ if ( ! isset( $validation_rules[ $rule ] ) ) {
208
+ continue;
209
+ }
210
+
211
+ $validation_rule = $validation_rules[ $rule ];
212
+ if ( ! is_callable( array( $validation_rule, 'rule' ) ) ) {
213
+ continue;
214
  }
215
+
216
+ $message = $validation_rule->rule( $key, $options );
217
+ if ( empty( $message ) ) {
218
+ continue;
219
+ }
220
+
221
+ $this->Data->set_validation_error( $key, $rule, $message );
222
  }
223
  }
224
  }
classes/services/class.exec-shortcode.php CHANGED
@@ -1,48 +1,32 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Exec Shortcode
4
- * Version : 1.3.0
5
- * Description: ExecShortcode(mwform、mwform_formkey)の存在有無のチェックとそれらの抽象化レイヤー
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : December 31, 2014
9
- * Modified : January 30, 2017
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Exec_Shortcode {
14
 
15
  /**
16
- * フォームの Post ID
17
  * @var int
18
  */
19
- protected $post_id;
20
 
21
  /**
22
- * ショートコードが埋め込まれた投稿のオブジェクト
23
- * @var WP_Post|null
24
- */
25
- protected $post;
26
-
27
- /**
28
- * @var string 表示中のテンプレート
29
  */
30
- protected $template;
31
 
32
  /**
33
- * フォームの実行に必須なデータの配列
34
- * @var array
35
  */
36
- protected $settings = array(
37
- 'input_url' => '',
38
- 'confirmation_url' => '',
39
- 'complete_url' => '',
40
- 'validation_error_url' => '',
41
- 'key' => null,
42
- );
43
 
44
  /**
45
- * 表示すべき画面を示すフラグ
46
  * @var string
47
  */
48
  protected $view_flg;
@@ -52,586 +36,404 @@ class MW_WP_Form_Exec_Shortcode {
52
  */
53
  protected $Setting;
54
 
55
- /**
56
- * @var MW_WP_Form_Form
57
- */
58
- protected $Form;
59
 
60
- /**
61
- * @var MW_WP_Form_Data
62
- */
63
- protected $Data;
64
 
65
  /**
66
- * __construct
67
  *
68
- * @param WP_Post|null $post
69
- * @param string $template 使用テンプレートのパス
 
70
  */
71
- public function __construct( $post, $template ) {
72
- $this->post = $post;
73
- $this->template = $template;
74
-
75
- add_shortcode( 'mwform' , array( $this, 'set_settings_by_mwform' ) );
76
- add_shortcode( 'mwform_formkey', array( $this, 'set_settings_by_mwform_formkey' ) );
77
 
78
- $exec_shortcode = $this->get_exec_shortcode();
79
- if ( $exec_shortcode ) {
80
- // ここで set_settings_by_mwform(), set_settings_by_mwform_formkey() が実行される
81
- do_shortcode( $exec_shortcode );
82
- }
83
 
84
- do_action( 'mwform_after_exec_shortcode', $this->get( 'key' ) );
85
 
86
- remove_shortcode( 'mwform' );
87
- remove_shortcode( 'mwform_formkey' );
88
- }
89
 
90
- /**
91
- * 必要な設定が完了していたらtrue
92
- *
93
- * @return bool
94
- */
95
- public function has_shortcode() {
96
- if ( is_null( $this->settings['key'] ) ) {
97
- return false;
98
- }
99
- return true;
100
- }
101
 
102
- /**
103
- * 設定データを取得
104
- *
105
- * @param string $key
106
- * @return string
107
- */
108
- public function get( $key ) {
109
- if ( isset( $this->settings[$key] ) ) {
110
- return $this->settings[$key];
111
- }
112
- }
113
 
114
- /**
115
- * ExecShortcode が含まれていればそのショートコードを返す
116
- *
117
- * @return string [hoge xxx="xxx"]
118
- */
119
- protected function get_exec_shortcode() {
120
- $exec_shortcode = '';
121
- if ( is_singular() && !empty( $this->post->ID ) ) {
122
- $exec_shortcode = $this->get_in_content( $this->post->post_content );
123
- }
124
- if ( empty( $exec_shortcode ) ) {
125
- $exec_shortcode = $this->get_in_template();
126
  }
127
- return $exec_shortcode;
128
- }
129
 
130
- /**
131
- * テンプレートファイル(絶対パス)に ExecShortcode が含まれていればそのショートコードを返す
132
- *
133
- * @return string [hoge xxx="xxx"]
134
- */
135
- protected function get_in_template() {
136
- if ( !( defined( 'MWFORM_NOT_USE_TEMPLATE' ) && MWFORM_NOT_USE_TEMPLATE === true ) ) {
137
- $template_data = @file_get_contents( $this->template );
138
- if ( $template_data ) {
139
- $exec_shortcode = $this->get_in_content( $template_data );
140
- return $exec_shortcode;
141
- }
142
- }
143
- }
144
 
145
- /**
146
- * ExecShortcode が含まれていればそのショートコードを返す
147
- *
148
- * @param string $content
149
- * @return string [hoge xxx="xxx"]
150
- */
151
- protected function get_in_content( $content ) {
152
- preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER );
153
- if ( $matches ) {
154
- foreach ( $matches as $shortcode ) {
155
- if ( in_array( $shortcode[2], array( 'mwform', 'mwform_formkey' ) ) ) {
156
- return $shortcode[0];
157
- } else {
158
- $shortcode = $this->get_in_content( $shortcode[5] );
159
- if ( !empty( $shortcode ) ) {
160
- return $shortcode;
161
- }
162
- }
163
- }
164
  }
165
- }
166
 
167
- /**
168
- * ショートコード mwform をもとにフォームの実行に必須のデータを設定
169
- *
170
- * @param array|'' $attributes
171
- */
172
- public function set_settings_by_mwform( $attributes ) {
173
- $attributes = shortcode_atts( array(
174
- 'key' => 'mwform',
175
- 'input' => '',
176
- 'confirm' => '',
177
- 'complete' => '',
178
- 'validation_error' => '',
179
- ), $attributes );
180
- $this->set_settings( $attributes );
181
- }
182
 
183
- /**
184
- * ショートコード mwform_formkey をもとにフォームの実行に必須のデータを設定
185
- *
186
- * @param array $attributes|''
187
- */
188
- public function set_settings_by_mwform_formkey( $attributes ) {
189
- $post_id = $this->get_form_id_by_mwform_formkey( $attributes );
190
- $this->post_id = $post_id;
191
- $settings = array();
192
- if ( !empty( $post_id ) ) {
193
- $Setting = new MW_WP_Form_Setting( $post_id );
194
- foreach ( $this->settings as $key => $value ) {
195
- $settings[$key] = $Setting->get( $key );
196
  }
197
- $settings['key'] = MWF_Functions::get_form_key_from_form_id( $post_id );
198
  }
199
- $this->set_settings( $settings );
200
- }
201
-
202
- /**
203
- * ショートコード mwform_formkey をもとにフォームの ID を取得
204
- *
205
- * @param array|'' $attributes
206
- * @return string|null Post ID
207
- */
208
- protected function get_form_id_by_mwform_formkey( $attributes ) {
209
- $attributes = shortcode_atts( array(
210
- 'key' => '',
211
- 'slug' => '',
212
- ), $attributes );
213
 
214
- if ( !empty( $attributes['slug'] ) ) {
215
- $post = get_page_by_path( $attributes['slug'], OBJECT, MWF_Config::NAME );
216
- } elseif ( !empty( $attributes['key'] ) ) {
217
- $post = get_post( $attributes['key'] );
218
  }
219
 
220
- if ( !empty( $post ) && isset( $post->ID ) ) {
221
- return $post->ID;
222
- }
223
  }
224
 
225
  /**
226
- * フォームの実行に必須のデータを設定
227
  *
228
- * @param array $attributes
 
229
  */
230
- protected function set_settings( array $attributes ) {
231
- foreach ( $attributes as $key => $value ) {
232
- if ( $key === 'key' ) {
233
- $this->settings['key'] = $value;
234
- }
235
- if ( $key === 'input_url' || $key === 'input' ) {
236
- $this->settings['input_url'] = $value;
237
- }
238
- if ( $key === 'confirmation_url' || $key === 'confirm' ) {
239
- $this->settings['confirmation_url'] = $value;
240
- }
241
- if ( $key === 'complete_url' || $key === 'complete' ) {
242
- $this->settings['complete_url'] = $value;
243
- }
244
- if ( $key === 'validation_error_url' || $key === 'validation_error' ) {
245
- $this->settings['validation_error_url'] = $value;
246
- }
247
- }
248
- }
249
 
250
- /**
251
- * 管理画面で作成されたフォームであれば true
252
- *
253
- * @return bool
254
- */
255
- public function is_generated_by_formkey() {
256
- if ( $this->post_id ) {
257
- return true;
258
- }
259
- return false;
260
- }
261
 
262
- /**
263
- * フォームの ID を取得
264
- *
265
- * @return int
266
- */
267
- public function get_form_id() {
268
- if ( $this->post_id ) {
269
- return $this->post_id;
 
270
  }
271
  }
272
 
273
  /**
274
- * フォームを表示するためのショートコードを登録
275
- *
276
- * @param string $view_flg
277
- * @param MW_WP_Form_Setting $Setting
278
- * @param MW_WP_Form_Form $Form
279
- */
280
- public function add_shortcode( $view_flg, MW_WP_Form_Setting $Setting, MW_WP_Form_Form $Form ) {
281
- $this->view_flg = $view_flg;
282
- $this->Setting = $Setting;
283
- $this->Form = $Form;
284
- $this->Data = MW_WP_Form_Data::getInstance();
285
- add_shortcode( 'mwform_formkey' , array( $this, 'mwform_formkey' ) );
286
- add_shortcode( 'mwform' , array( $this, 'mwform' ) );
287
- add_shortcode( 'mwform_complete_message', array( $this, 'mwform_complete_message' ) );
288
- }
289
-
290
- /**
291
- * 管理画面で作成したフォームを出力(実際の出力は mwform )
292
  *
293
  * @param array $attributes
294
  * @return string html
295
- * @example [mwform_formkey key="post_id"]
296
  */
297
- public function mwform_formkey( $attributes ) {
298
- $view_flg = $this->view_flg;
299
- $form_id = $this->get_form_id_by_mwform_formkey( $attributes );
300
- $form_key = MWF_Functions::get_form_key_from_form_id( $form_id );
301
-
302
- do_action( 'mwform_before_load_content_' . $form_key );
303
-
304
- // 送信エラー画面
305
- if ( $this->Data->get_send_error() ) {
306
- $content = $this->get_send_error_page_content( $form_id );
307
- }
308
- // 入力画面
309
- elseif ( $view_flg === 'input' ) {
310
- $content = $this->get_input_page_content( $form_id );
311
- }
312
- // 確認画面
313
- elseif ( $view_flg == 'confirm' ) {
314
- $content = $this->get_confirm_page_content( $form_id );
315
- }
316
- // 完了画面
317
- elseif ( $view_flg === 'complete' ) {
318
- $content = $this->get_complete_page_content();
319
- } else {
320
- $content = '';
321
- }
322
-
323
- do_action( 'mwform_after_load_content_' . $form_key );
324
-
325
- return do_shortcode( $content );
326
  }
327
 
328
  /**
329
- * 入力画面を表示
330
  *
331
- * @param int $form_id
332
  * @return string $content
333
  */
334
- protected function get_input_page_content( $form_id ) {
335
  global $post;
336
- $form_key = $this->get( 'key' );
337
- $post = get_post( $form_id );
338
  setup_postdata( $post );
339
- $content = apply_filters( 'mwform_post_content_raw_' . $form_key, get_the_content(), $this->Data );
340
- $content = $this->wpautop( $content );
341
  $content = sprintf(
342
  '[mwform]%s[/mwform]',
343
- apply_filters( 'mwform_post_content_' . $form_key, $content, $this->Data )
344
  );
345
  wp_reset_postdata();
346
  return $content;
347
  }
348
 
349
  /**
350
- * wpautop の設定に応じてコンテンツを改行する
351
  *
352
- * @param string $content
353
- * @return string
354
  */
355
- protected function wpautop( $content ) {
356
- $form_key = $this->get( 'key' );
357
- $has_wpautop = false;
358
- if ( has_filter( 'the_content', 'wpautop' ) ) {
359
- $has_wpautop = true;
360
- }
361
- $has_wpautop = apply_filters(
362
- 'mwform_content_wpautop_' . $form_key,
363
- $has_wpautop,
364
- $this->view_flg
365
- );
366
-
367
- if ( $has_wpautop ) {
368
- $content = wpautop( $content );
369
- }
370
-
371
- return $content;
372
  }
373
 
374
  /**
375
- * 確認画面を表示
376
  *
377
- * @param int $form_id
378
  * @return string $content
379
  */
380
- protected function get_confirm_page_content( $form_id ) {
381
- return $this->get_input_page_content( $form_id );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
382
  }
383
 
384
  /**
385
- * 完了画面を表示
386
  *
387
  * @return string $content
388
  */
389
- protected function get_complete_page_content() {
390
- $form_key = $this->get( 'key' );
391
- $Setting = $this->Setting;
392
- $content = apply_filters( 'mwform_complete_content_raw_' . $form_key, $Setting->get( 'complete_message' ), $this->Data );
393
- $content = $this->wpautop( $content );
394
  $content = sprintf(
395
- '[mwform_complete_message]%s[/mwform_complete_message]',
396
- apply_filters( 'mwform_complete_content_' . $form_key, $content, $this->Data )
 
 
 
397
  );
 
 
 
398
  return $content;
399
  }
400
 
401
  /**
402
- * 送信エラー画面を表示
403
  *
404
  * @return string $content
405
  */
406
- public function get_send_error_page_content() {
407
- $form_key = $this->get( 'key' );
408
  $content = sprintf(
409
- '<div id="mw_wp_form_%s" class="mw_wp_form mw_wp_form_send_error">
410
  %s
411
  <!-- end .mw_wp_form --></div>',
412
- esc_attr( $form_key ),
413
- __( 'There was an error trying to send your message. Please try again later.', 'mw-wp-form' )
414
  );
415
- $content = apply_filters( 'mwform_send_error_content_raw_' . $form_key, $content, $this->Data );
416
- $content = $this->wpautop( $content );
417
- $content = apply_filters( 'mwform_send_error_content_' . $form_key, $content, $this->Data );
418
  return $content;
419
  }
420
 
421
  /**
422
- * フォームを出力
423
  *
424
- * @param array $attributes
425
- * @return string html
426
  */
427
- public function mwform( $attributes, $content = '' ) {
428
- $form_key = $this->get( 'key' );
429
- $view_flg = $this->view_flg;
430
- $Form = $this->Form;
431
- $Data = $this->Data;
432
-
433
- if ( in_array( $view_flg, array( 'input', 'confirm' ) ) ) {
434
- $content = $this->get_the_content( $content );
435
- $upload_file_keys = $Data->get_post_value_by_key( MWF_Config::UPLOAD_FILE_KEYS );
436
- $upload_file_hidden = $this->get_upload_file_hidden( $upload_file_keys );
437
- $old_confirm_class = $this->get_old_confirm_class();
438
- $class_by_style = $this->get_class_by_style();
439
 
440
- return sprintf(
441
- '<div id="mw_wp_form_%s" class="mw_wp_form mw_wp_form_%s %s">
442
- %s
443
- <!-- end .mw_wp_form --></div>',
444
- esc_attr( $form_key ),
445
- esc_attr( $view_flg . ' ' . $old_confirm_class ),
446
- $class_by_style,
447
- $Form->start() . do_shortcode( $content ) . $upload_file_hidden . $Form->end()
448
- );
 
 
 
 
 
449
  }
 
 
450
  }
451
 
452
  /**
453
- * フォームのコンテンツを整形して返す
454
  *
455
  * @param string $content
456
- * @return string $content
457
  */
458
- public function get_the_content( $content ) {
459
- $content = $this->replace_user_property( $content );
460
- $content = $this->replace_post_property( $content );
461
- return $content;
462
- }
463
 
464
- /**
465
- * ユーザーがログイン中の場合、{ユーザー情報のプロパティ}を置換する。
466
- *
467
- * @param string フォーム内容
468
- * @return string フォーム内容
469
- */
470
- protected function replace_user_property( $content ) {
471
- $user = wp_get_current_user();
472
- $search = array(
473
- '{user_id}',
474
- '{user_login}',
475
- '{user_email}',
476
- '{user_url}',
477
- '{user_registered}',
478
- '{display_name}',
479
  );
480
- if ( !empty( $user ) ) {
481
- $content = str_replace( $search, array(
482
- $user->get( 'ID' ),
483
- $user->get( 'user_login' ),
484
- $user->get( 'user_email' ),
485
- $user->get( 'user_url' ),
486
- $user->get( 'user_registered' ),
487
- $user->get( 'display_name' ),
488
- ), $content );
489
- } else {
490
- $content = str_replace( $search, '', $content );
491
  }
 
492
  return $content;
493
  }
494
 
495
  /**
496
- * {投稿情報($post->hoge)}を置換する。
497
  *
498
- * @param string フォーム内容
499
- * @return string フォーム内容
500
  */
501
- protected function replace_post_property( $content ) {
502
- $Setting = $this->Setting;
503
- if ( $Setting->get( 'querystring' ) ) {
504
- $content = preg_replace_callback(
505
- '/{(.+?)}/',
506
- array( $this, 'get_post_property_from_querystring' ),
507
- $content
508
- );
509
- } else {
510
- $content = preg_replace_callback(
511
- '/{(.+?)}/',
512
- array( $this, 'get_post_property_from_this' ),
513
- $content
514
- );
515
- }
516
  return $content;
517
  }
518
 
519
  /**
520
- * 引数 post_id が有効の場合、投稿情報を取得するために preg_replace_callback から呼び出される。
521
  *
522
- * @param array $matches
523
- * @return string|null
524
  */
525
- protected function get_post_property_from_querystring( $matches ) {
526
- $Setting = $this->Setting;
527
- if ( $Setting->get( 'querystring' ) &&
528
- isset( $_GET['post_id'] ) &&
529
- MWF_Functions::is_numeric( $_GET['post_id'] ) ) {
530
-
531
- $post = get_post( $_GET['post_id'] );
532
- if ( empty( $post->ID ) ) {
533
- return;
534
- }
535
- return $this->get_post_property( $post, $matches[1] );
536
  }
 
 
537
  }
538
 
539
  /**
540
- * 引数 post_id が無効の場合、投稿情報を取得するために preg_replace_callback から呼び出される。
541
  *
542
- * @param array $matches
543
- * @return string|null
544
  */
545
- protected function get_post_property_from_this( $matches ) {
546
- global $post;
547
- if ( !is_singular() ) {
548
- return;
549
- }
550
- if ( isset( $post->ID ) && MWF_Functions::is_numeric( $post->ID ) ) {
551
- return $this->get_post_property( $post, $matches[1] );
552
  }
553
  }
554
 
555
  /**
556
- * 投稿のプロパティを取得
557
  *
558
- * @param WP_Post|null $post
559
- * @param string $meta_key
560
- * @return string|null
561
  */
562
- protected function get_post_property( $post, $meta_key ) {
563
- if ( !is_a( $post, 'WP_Post' ) ) {
564
- return;
565
- }
566
- if ( isset( $post->$meta_key ) ) {
567
- return $post->$meta_key;
568
- }
569
- $post_meta = get_post_meta( $post->ID, $meta_key, true );
570
- if ( !is_array( $post_meta ) ) {
571
- return $post_meta;
572
  }
573
  }
574
 
575
  /**
576
- * ファイルアップロードのname属性を hidden で出力
577
  *
578
- * @param array|string $upload_file_keys
 
579
  */
580
- protected function get_upload_file_hidden( $upload_file_keys ) {
581
- $Form = $this->Form;
582
- $upload_file_hidden = '';
583
- if ( !is_array( $upload_file_keys ) ) {
584
- return $upload_file_hidden;
 
 
 
 
 
585
  }
586
- foreach ( $upload_file_keys as $value ) {
587
- $upload_file_hidden .= $Form->hidden( MWF_Config::UPLOAD_FILE_KEYS . '[]', $value );
 
588
  }
589
- return $upload_file_hidden;
590
  }
591
 
592
  /**
593
- * 下位互換性のための class を付与
594
  *
595
- * @return string mw_wp_form_preview
 
596
  */
597
- protected function get_old_confirm_class() {
598
- $old_confirm_class = '';
599
- if ( $this->view_flg === 'confirm' ) {
600
- $old_confirm_class = 'mw_wp_form_preview';
601
  }
602
- return $old_confirm_class;
 
 
 
 
 
 
 
 
 
 
 
 
 
603
  }
604
 
605
  /**
606
- * スタイル機能用の class を付与
607
  *
608
- * @return string
609
  */
610
- protected function get_class_by_style() {
611
- $Setting = $this->Setting;
612
- $style = $Setting->get( 'style' );
613
- $class_by_style = '';
614
- if ( $style ) {
615
- $class_by_style = 'mw_wp_form_' . $style;
616
  }
617
- return $class_by_style;
 
618
  }
619
 
620
  /**
621
- * 完了後のメッセージ
622
  *
623
- * @param array $attributes
624
- * @return string html
625
- */
626
- public function mwform_complete_message( $attributes, $content = '' ) {
627
- $form_key = $this->get( 'key' );
628
- return sprintf(
629
- '<div id="mw_wp_form_%s" class="mw_wp_form mw_wp_form_%s">
630
- %s
631
- <!-- end .mw_wp_form --></div>',
632
- esc_attr( $form_key ),
633
- esc_attr( $this->view_flg ),
634
- $content
635
  );
 
 
 
 
636
  }
637
  }
1
  <?php
2
  /**
3
  * Name : MW WP Form Exec Shortcode
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : December 31, 2014
8
+ * Modified : May 17, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Exec_Shortcode {
13
 
14
  /**
 
15
  * @var int
16
  */
17
+ protected $form_id;
18
 
19
  /**
20
+ * @var string
 
 
 
 
 
 
21
  */
22
+ protected $form_key;
23
 
24
  /**
25
+ * @param MW_WP_Form_Data
 
26
  */
27
+ protected $Data;
 
 
 
 
 
 
28
 
29
  /**
 
30
  * @var string
31
  */
32
  protected $view_flg;
36
  */
37
  protected $Setting;
38
 
39
+ public function __construct() {
40
+ add_shortcode( 'mwform' , array( $this, '_mwform' ) );
41
+ add_shortcode( 'mwform_complete_message', array( $this, '_mwform_complete_message' ) );
 
42
 
43
+ add_filter( 'mwform_form_end_html', array( $this, '_mwform_form_end_html' ) );
44
+
45
+ add_action( 'wp_footer', array( $this, '_enqueue_scripts' ) );
46
+ }
47
 
48
  /**
49
+ * Add shortcode for [mwform_formkey]
50
  *
51
+ * @param array $attributes
52
+ * @return string html
53
+ * @example [mwform_formkey key="post_id"]
54
  */
55
+ public function initialize( $attributes ) {
56
+ $this->form_id = $this->_get_form_id_by_mwform_formkey( $attributes );
57
+ $this->form_key = MWF_Functions::get_form_key_from_form_id( $this->form_id );
 
 
 
58
 
59
+ /**
60
+ * @deprecated since v4.0.0
61
+ * Because refactoring changed the timing to execute the shortcode
62
+ */
63
+ do_action( 'mwform_after_exec_shortcode', $this->form_key );
64
 
65
+ do_action( 'mwform_start_main_process', $this->form_key );
66
 
67
+ $this->Data = MW_WP_Form_Data::connect( $this->form_key );
68
+ $this->view_flg = ( $this->Data->get_view_flg() ) ? $this->Data->get_view_flg() : 'input';
69
+ $this->Setting = new MW_WP_Form_Setting( $this->form_id );
70
 
71
+ add_action( 'wp_footer', array( $this->Data, 'clear_values' ) );
 
 
 
 
 
 
 
 
 
 
72
 
73
+ $Validation = new MW_WP_Form_Validation( $this->form_key );
74
+ $is_valid = $Validation->is_valid();
 
 
 
 
 
 
 
 
 
75
 
76
+ $Redirected = new MW_WP_Form_Redirected( $this->form_key, $this->Setting, $is_valid, $this->Data->get_post_condition() );
77
+ if ( $Redirected->get_request_uri() !== $Redirected->get_url() && $Redirected->get_url() ) {
78
+ $Redirected->redirect_js();
 
 
 
 
 
 
 
 
 
79
  }
 
 
80
 
81
+ do_action( 'mwform_before_load_content_' . $this->form_key );
 
 
 
 
 
 
 
 
 
 
 
 
 
82
 
83
+ if ( $this->_is_direct_access() ) {
84
+ $content = $this->_get_direct_access_error_page_content();
85
+ } elseif ( $this->Data->get_send_error() ) {
86
+ $content = $this->_get_send_error_page_content();
87
+ } elseif ( 'input' === $this->view_flg ) {
88
+ $content = $this->_get_input_page_content();
89
+ } elseif ( 'confirm' === $this->view_flg ) {
90
+ $content = $this->_get_confirm_page_content();
91
+ } elseif ( 'complete' === $this->view_flg ) {
92
+ $content = $this->_get_complete_page_content();
93
+ } else {
94
+ $content = '';
 
 
 
 
 
 
 
95
  }
 
96
 
97
+ do_action( 'mwform_after_load_content_' . $this->form_key );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
 
99
+ // Enqueue scroll to MW WP Form script
100
+ if ( $this->Setting->get( 'scroll' ) ) {
101
+ if ( 'input' !== $this->view_flg || in_array( $this->Data->get_post_condition(), array( 'back', 'confirm', 'complete' ) ) ) {
102
+ add_action( 'wp_footer', array( $this, '_enqueue_scroll_script' ) );
 
 
 
 
 
 
 
 
 
103
  }
 
104
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
 
106
+ $Form_Fields = MW_WP_Form_Form_Fields::instantiation( $this->form_key );
107
+ foreach ( $Form_Fields->get_form_fields() as $form_field ) {
108
+ $form_field->initialize( new MW_WP_Form_Form(), $this->form_key, $this->view_flg );
 
109
  }
110
 
111
+ return do_shortcode( $content );
 
 
112
  }
113
 
114
  /**
115
+ * Add shortcode for [mwform]
116
  *
117
+ * @param null $attributes
118
+ * @return string html
119
  */
120
+ public function _mwform( $attributes, $content = '' ) {
121
+ $Form = new MW_WP_Form_Form();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
 
123
+ if ( in_array( $this->view_flg, array( 'input', 'confirm' ) ) ) {
124
+ $content = $this->_get_the_content( $content );
125
+ $upload_file_keys = $this->Data->get_post_value_by_key( MWF_Config::UPLOAD_FILE_KEYS );
126
+ $upload_file_hidden = $this->_get_upload_file_hidden( $upload_file_keys );
127
+ $old_confirm_class = $this->_get_old_confirm_class();
128
+ $class_by_style = $this->_get_class_by_style();
 
 
 
 
 
129
 
130
+ return sprintf(
131
+ '<div id="mw_wp_form_%s" class="mw_wp_form mw_wp_form_%s %s">
132
+ %s
133
+ <!-- end .mw_wp_form --></div>',
134
+ esc_attr( $this->form_key ),
135
+ esc_attr( $this->view_flg . ' ' . $old_confirm_class ),
136
+ $class_by_style,
137
+ $Form->start() . do_shortcode( $content ) . $upload_file_hidden . $Form->end()
138
+ );
139
  }
140
  }
141
 
142
  /**
143
+ * Add shortcode for [mwform_complete_message]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
144
  *
145
  * @param array $attributes
146
  * @return string html
 
147
  */
148
+ public function _mwform_complete_message( $attributes, $content = '' ) {
149
+ return sprintf(
150
+ '<div id="mw_wp_form_%s" class="mw_wp_form mw_wp_form_%s">
151
+ %s
152
+ <!-- end .mw_wp_form --></div>',
153
+ esc_attr( $this->form_key ),
154
+ esc_attr( $this->view_flg ),
155
+ $content
156
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
  }
158
 
159
  /**
160
+ * Display input page
161
  *
 
162
  * @return string $content
163
  */
164
+ protected function _get_input_page_content() {
165
  global $post;
166
+ $post = get_post( $this->form_id );
 
167
  setup_postdata( $post );
168
+ $content = apply_filters( 'mwform_post_content_raw_' . $this->form_key, get_the_content(), $this->Data );
169
+ $content = $this->_wpautop( $content );
170
  $content = sprintf(
171
  '[mwform]%s[/mwform]',
172
+ apply_filters( 'mwform_post_content_' . $this->form_key, $content, $this->Data )
173
  );
174
  wp_reset_postdata();
175
  return $content;
176
  }
177
 
178
  /**
179
+ * Display confirm page
180
  *
181
+ * @return string $content
 
182
  */
183
+ protected function _get_confirm_page_content( ) {
184
+ return $this->_get_input_page_content();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
185
  }
186
 
187
  /**
188
+ * Display complete page
189
  *
 
190
  * @return string $content
191
  */
192
+ protected function _get_complete_page_content() {
193
+ $Parser = new MW_WP_Form_Parser( $this->Setting );
194
+
195
+ $content = apply_filters(
196
+ 'mwform_complete_content_raw_' . $this->form_key,
197
+ $this->Setting->get( 'complete_message' ),
198
+ $this->Data
199
+ );
200
+
201
+ $content = $this->_wpautop( $content );
202
+ $content = $Parser->replace_for_mail_content( $content );
203
+
204
+ $content = sprintf(
205
+ '[mwform_complete_message]%s[/mwform_complete_message]',
206
+ apply_filters( 'mwform_complete_content_' . $this->form_key, $content, $this->Data )
207
+ );
208
+ return $content;
209
  }
210
 
211
  /**
212
+ * Display validation error page
213
  *
214
  * @return string $content
215
  */
216
+ protected function _get_send_error_page_content() {
 
 
 
 
217
  $content = sprintf(
218
+ '<div id="mw_wp_form_%s" class="mw_wp_form mw_wp_form_send_error">
219
+ %s
220
+ <!-- end .mw_wp_form --></div>',
221
+ esc_attr( $this->form_key ),
222
+ __( 'There was an error trying to send your message. Please try again later.', 'mw-wp-form' )
223
  );
224
+ $content = apply_filters( 'mwform_send_error_content_raw_' . $this->form_key, $content, $this->Data );
225
+ $content = $this->_wpautop( $content );
226
+ $content = apply_filters( 'mwform_send_error_content_' . $this->form_key, $content, $this->Data );
227
  return $content;
228
  }
229
 
230
  /**
231
+ * Display direct access error page
232
  *
233
  * @return string $content
234
  */
235
+ protected function _get_direct_access_error_page_content() {
 
236
  $content = sprintf(
237
+ '<div id="mw_wp_form_%s" class="mw_wp_form mw_wp_form_direct_access_error">
238
  %s
239
  <!-- end .mw_wp_form --></div>',
240
+ esc_attr( $this->form_key ),
241
+ __( 'You can not access this page directly.', 'mw-wp-form' )
242
  );
243
+ $content = apply_filters( 'mwform_direct_access_error_content_raw_' . $this->form_key, $content, $this->Data );
244
+ $content = $this->_wpautop( $content );
245
+ $content = apply_filters( 'mwform_direct_access_error_content_' . $this->form_key, $content, $this->Data );
246
  return $content;
247
  }
248
 
249
  /**
250
+ * Return true when direct access to confirm or complete or validation error page.
251
  *
252
+ * @return bool
 
253
  */
254
+ protected function _is_direct_access() {
255
+ if ( 'input' !== $this->view_flg ) {
256
+ return false;
257
+ }
 
 
 
 
 
 
 
 
258
 
259
+ $confirm = $this->Setting->get( 'confirmation_url' );
260
+ $complete = $this->Setting->get( 'complete_url' );
261
+ $error = $this->Setting->get( 'validation_error_url' );
262
+
263
+ if ( ! $confirm && ! $complete && ! $error ) {
264
+ return false;
265
+ }
266
+
267
+ $Validation = new MW_WP_Form_Validation( $this->form_key );
268
+ $is_valid = $Validation->is_valid();
269
+
270
+ $Redirected = new MW_WP_Form_Redirected( $this->form_key, $this->Setting, $is_valid, $this->Data->get_post_condition() );
271
+ if ( $Redirected->get_request_uri() === $Redirected->get_url() ) {
272
+ return false;
273
  }
274
+
275
+ return true;
276
  }
277
 
278
  /**
279
+ * Line breaks content according to wpautop()
280
  *
281
  * @param string $content
282
+ * @return string
283
  */
284
+ protected function _wpautop( $content ) {
285
+ $has_wpautop = false;
286
+ if ( has_filter( 'the_content', 'wpautop' ) ) {
287
+ $has_wpautop = true;
288
+ }
289
 
290
+ $has_wpautop = apply_filters(
291
+ 'mwform_content_wpautop_' . $this->form_key,
292
+ $has_wpautop,
293
+ $this->view_flg
 
 
 
 
 
 
 
 
 
 
 
294
  );
295
+
296
+ if ( $has_wpautop ) {
297
+ $content = wpautop( $content );
 
 
 
 
 
 
 
 
298
  }
299
+
300
  return $content;
301
  }
302
 
303
  /**
304
+ * Replace {key} in the form
305
  *
306
+ * @param string $content
307
+ * @return string
308
  */
309
+ public function _get_the_content( $content ) {
310
+ $Parser = new MW_WP_Form_Parser( $this->Setting );
311
+ $content = $Parser->replace_for_page( $content );
 
 
 
 
 
 
 
 
 
 
 
 
312
  return $content;
313
  }
314
 
315
  /**
316
+ * Hidden field for file upload name attribute
317
  *
318
+ * @param array|string $upload_file_keys
 
319
  */
320
+ protected function _get_upload_file_hidden( $upload_file_keys ) {
321
+ $Form = new MW_WP_Form_Form();
322
+
323
+ if ( ! is_array( $upload_file_keys ) ) {
324
+ return;
325
+ }
326
+
327
+ $upload_file_hidden = '';
328
+ foreach ( $upload_file_keys as $value ) {
329
+ $upload_file_hidden .= $Form->hidden( MWF_Config::UPLOAD_FILE_KEYS . '[]', $value );
 
330
  }
331
+
332
+ return $upload_file_hidden;
333
  }
334
 
335
  /**
336
+ * Get classes for backward compatibility
337
  *
338
+ * @return string mw_wp_form_preview
 
339
  */
340
+ protected function _get_old_confirm_class() {
341
+ if ( 'confirm' === $this->view_flg ) {
342
+ return 'mw_wp_form_preview';
 
 
 
 
343
  }
344
  }
345
 
346
  /**
347
+ * Get classes for style feature
348
  *
349
+ * @return string
 
 
350
  */
351
+ protected function _get_class_by_style() {
352
+ $style = $this->Setting->get( 'style' );
353
+ if ( $style ) {
354
+ return 'mw_wp_form_' . $style;
 
 
 
 
 
 
355
  }
356
  }
357
 
358
  /**
359
+ * ショートコード mwform_formkey をもとにフォームの ID を取得
360
  *
361
+ * @param array $attributes
362
+ * @return string Post ID
363
  */
364
+ protected function _get_form_id_by_mwform_formkey( $attributes ) {
365
+ $attributes = shortcode_atts( array(
366
+ 'key' => '',
367
+ 'slug' => '',
368
+ ), $attributes );
369
+
370
+ if ( ! empty( $attributes['slug'] ) ) {
371
+ $post = get_page_by_path( $attributes['slug'], OBJECT, MWF_Config::NAME );
372
+ } elseif ( ! empty( $attributes['key'] ) ) {
373
+ $post = get_post( $attributes['key'] );
374
  }
375
+
376
+ if ( ! empty( $post ) && isset( $post->ID ) ) {
377
+ return $post->ID;
378
  }
 
379
  }
380
 
381
  /**
382
+ * Add nonce field and form meta data
383
  *
384
+ * @param string $html
385
+ * @return string
386
  */
387
+ public function _mwform_form_end_html( $html ) {
388
+ if ( ! $this->form_key ) {
389
+ return $html;
 
390
  }
391
+
392
+ $html .= wp_nonce_field( $this->form_key, MWF_Config::TOKEN_NAME, true, false );
393
+ $html .= sprintf(
394
+ '<input type="hidden" name="%1$s" value="%2$s" />',
395
+ esc_attr( MWF_Config::NAME . '-form-id' ),
396
+ esc_attr( $this->form_id )
397
+ );
398
+
399
+ $html .= sprintf(
400
+ '<input type="hidden" name="%1$s" value="%2$s" />',
401
+ esc_attr( MWF_Config::NAME . '-form-verify-token' ),
402
+ esc_attr( $this->Setting->generate_form_verify_token() )
403
+ );
404
+ return $html;
405
  }
406
 
407
  /**
408
+ * Enqueue MW WP Form assets
409
  *
410
+ * @return void
411
  */
412
+ public function _enqueue_scripts() {
413
+ if ( wp_style_is( MWF_Config::NAME ) ) {
414
+ return;
 
 
 
415
  }
416
+
417
+ MWF_Functions::mwform_enqueue_scripts( $this->form_id );
418
  }
419
 
420
  /**
421
+ * Enqueue scroll to form script
422
  *
423
+ * @return void
424
+ */
425
+ public function _enqueue_scroll_script() {
426
+ $url = plugin_dir_url( __FILE__ );
427
+ wp_register_script(
428
+ MWF_Config::NAME . '-scroll',
429
+ $url . '../../js/scroll.js',
430
+ array( 'jquery' ),
431
+ false,
432
+ true
 
 
433
  );
434
+ wp_localize_script( MWF_Config::NAME . '-scroll', 'mwform_scroll', array(
435
+ 'offset' => apply_filters( 'mwform_scroll_offset_' . $this->form_key, 0 ),
436
+ ) );
437
+ wp_enqueue_script( MWF_Config::NAME . '-scroll' );
438
  }
439
  }
classes/services/class.mail-parser.php CHANGED
@@ -1,23 +1,16 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Mail Parser
4
- * Description: メールパーサー
5
- * Version : 1.3.0
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : April 14, 2015
9
- * Modified : April 29, 2017
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Mail_Parser {
14
 
15
- /**
16
- * 保存した問い合わせデータの Post ID
17
- * @var int
18
- */
19
- protected $saved_mail_id;
20
-
21
  /**
22
  * @var MW_WP_Form_Mail
23
  */
@@ -39,109 +32,75 @@ class MW_WP_Form_Mail_Parser {
39
  */
40
  public function __construct( MW_WP_Form_Mail $Mail, MW_WP_Form_Setting $Setting ) {
41
  $this->Mail = $Mail;
42
- $this->Data = MW_WP_Form_Data::getInstance();
43
  $this->Setting = $Setting;
 
 
 
44
  }
45
 
46
  /**
47
- * パースした Mail オブジェクトの取得
48
  *
49
  * @return MW_WP_Form_Mail
50
  */
51
  public function get_parsed_mail_object() {
52
- return $this->parse_mail_object();
53
  }
54
 
55
  /**
56
- * Getter : $this->saved_mail_id
57
  *
58
- * @return int
59
  */
60
  public function get_saved_mail_id(){
61
- return $this->saved_mail_id;
62
  }
63
 
64
  /**
65
- * メールオブジェクトの各プロパティを変換
66
  *
67
  * @return MW_WP_Form_Mail $Mail
68
  */
69
- protected function parse_mail_object() {
70
  $parsed_Mail_vars = get_object_vars( $this->Mail );
71
  foreach ( $parsed_Mail_vars as $key => $value ) {
72
  if ( is_array( $value ) ) {
73
  continue;
74
  }
75
 
76
- if ( $key == 'to' || $key == 'cc' || $key == 'bcc' ) {
77
- $this->Mail->$key = $this->parse_mail_destination( $value );
 
 
78
  continue;
79
  }
80
- $this->Mail->$key = $this->parse_mail_content( $value );
81
- }
82
- return $this->Mail;
83
- }
84
 
85
- /**
86
- * メール送信先用に {name属性} を置換。Data からの取得は行わない
87
- *
88
- * @param string $value
89
- * @return string
90
- */
91
- protected function parse_mail_destination( $value ) {
92
- return preg_replace_callback(
93
- '/{(.+?)}/',
94
- array( $this, '_parse_mail_destination' ),
95
- $value
96
- );
97
- }
98
- protected function _parse_mail_destination( $matches ) {
99
- $match = $matches[1];
100
- $form_id = $this->Setting->get( 'post_id' );
101
- $form_key = MWF_Functions::get_form_key_from_form_id( $form_id );
102
- $value = $this->apply_filters_mwform_custom_mail_tag( $form_key, null, $match );
103
-
104
- // カスタムメールタグが利用されていない = null ときは送信先の初期値である空白を返す
105
- if ( !is_null( $value ) ) {
106
- return $value;
107
  }
108
- return '';
109
- }
110
-
111
- /**
112
- * メール本文用に {name属性} を置換
113
- *
114
- * @param string $value
115
- * @return string
116
- */
117
- protected function parse_mail_content( $value ) {
118
- return preg_replace_callback(
119
- '/{(.+?)}/',
120
- array( $this, '_parse_mail_content' ),
121
- $value
122
- );
123
- }
124
- protected function _parse_mail_content( $matches ) {
125
- $match = $matches[1];
126
- return $this->_parse( $match );
127
  }
128
 
129
  /**
130
- * メール本文・添付ファイルを保存、保存したメール(投稿)の ID をプロパティにセット
 
131
  */
132
  public function save() {
133
  $form_id = $this->Setting->get( 'post_id' );
 
134
  $saved_mail_id = wp_insert_post( array(
135
- 'post_title' => $this->parse_mail_content( $this->Mail->subject ),
136
  'post_status' => 'publish',
137
  'post_type' => MWF_Functions::get_contact_data_post_type_from_form_id( $form_id ),
138
  ) );
139
 
140
- // 添付ファイルをメディアに保存
141
- // save_mail_body 内のフックで添付ファイルの情報を使えるように、
142
- // save_mail_body より前にこのブロックを実行する
143
- // ここでポストメタとしてURLではなくファイルのIDを保存
144
- if ( !empty( $saved_mail_id ) ) {
 
 
145
  MWF_Functions::save_attachments_in_media(
146
  $saved_mail_id,
147
  $this->Mail->attachments,
@@ -149,31 +108,28 @@ class MW_WP_Form_Mail_Parser {
149
  );
150
  }
151
 
152
- $this->saved_mail_id = $saved_mail_id;
153
-
154
  $parsed_Mail_vars = get_object_vars( $this->Mail );
155
  foreach ( $parsed_Mail_vars as $key => $value ) {
156
  if ( is_array( $value ) ) {
157
  continue;
158
  }
159
 
160
- if ( $key == 'body' ) {
161
  $this->_save( $value );
162
  }
163
  }
164
  }
165
 
166
  /**
167
- * {キー}の部分を検索し、その値をデータベースに保存
 
168
  *
169
  * @param string $value
 
170
  */
171
  protected function _save( $value ) {
172
- preg_match_all(
173
- '/{(.+?)}/',
174
- $value,
175
- $matches
176
- );
177
 
178
  if ( ! isset( $matches[1] ) ) {
179
  return;
@@ -182,64 +138,26 @@ class MW_WP_Form_Mail_Parser {
182
  $form_id = $this->Setting->get( 'post_id' );
183
  $form_key = MWF_Functions::get_form_key_from_form_id( $form_id );
184
 
185
- foreach ( $matches[1] as $key ) {
186
- $value = $this->_parse( $key );
187
- // 値が null でも保存(チェッボックス未チェックで直送信でも保存させるため)
 
188
  $ignore_keys = apply_filters( 'mwform_no_save_keys_' . $form_key, array() );
189
- if ( ! in_array( $key, $ignore_keys ) ) {
190
- // ファイルは MWF_Functions::save_attachments_in_media() で ID が保存されるため
191
- // ここで送信された値(URL)は保存しない
192
- if ( ! array_key_exists( $key, $this->Mail->attachments ) ) {
193
- update_post_meta( $this->saved_mail_id, $key, $value );
194
- }
195
  }
196
- }
197
- }
198
 
199
- /**
200
- * そのキーについて送信された値を返す
201
- *
202
- * @param string $key
203
- * @return string
204
- */
205
- protected function _parse( $key ) {
206
- $form_id = $this->Setting->get( 'post_id' );
207
- $form_key = MWF_Functions::get_form_key_from_form_id( $form_id );
208
- // MWF_Config::TRACKINGNUMBER のときはお問い合せ番号を参照する
209
- if ( $key === MWF_Config::TRACKINGNUMBER ) {
210
- if ( $form_id ) {
211
- $value = $this->Setting->get_tracking_number( $form_id );
212
  }
213
- } else {
214
- $value = $this->Data->get( $key );
215
- $value = $this->apply_filters_mwform_custom_mail_tag( $form_key, $value, $key );
216
  }
217
- return $value;
218
- }
219
 
220
- /**
221
- * フィルターフック mwform_custom_mail_tag を実行
222
- *
223
- * @param string $form_key
224
- * @param string|null $value
225
- * @param string $match
226
- * @return string
227
- */
228
- protected function apply_filters_mwform_custom_mail_tag( $form_key, $value, $match ) {
229
- $value = apply_filters(
230
- 'mwform_custom_mail_tag',
231
- $value,
232
- $match,
233
- $this->saved_mail_id
234
- );
235
-
236
- $value = apply_filters(
237
- 'mwform_custom_mail_tag_' . $form_key,
238
- $value,
239
- $match,
240
- $this->saved_mail_id
241
- );
242
-
243
- return $value;
244
  }
245
  }
1
  <?php
2
  /**
3
  * Name : MW WP Form Mail Parser
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : April 14, 2015
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Mail_Parser {
13
 
 
 
 
 
 
 
14
  /**
15
  * @var MW_WP_Form_Mail
16
  */
32
  */
33
  public function __construct( MW_WP_Form_Mail $Mail, MW_WP_Form_Setting $Setting ) {
34
  $this->Mail = $Mail;
 
35
  $this->Setting = $Setting;
36
+ $form_id = $Setting->get( 'post_id' );
37
+ $form_key = MWF_Functions::get_form_key_from_form_id( $form_id );
38
+ $this->Data = MW_WP_Form_Data::connect( $form_key );
39
  }
40
 
41
  /**
42
+ * Return parsed Mail object
43
  *
44
  * @return MW_WP_Form_Mail
45
  */
46
  public function get_parsed_mail_object() {
47
+ return $this->_parse_mail_object();
48
  }
49
 
50
  /**
51
+ * Return saved mail ID
52
  *
53
+ * @return int|null
54
  */
55
  public function get_saved_mail_id(){
56
+ return $this->Data->get_saved_mail_id();
57
  }
58
 
59
  /**
60
+ * Convert each properties of Mail object
61
  *
62
  * @return MW_WP_Form_Mail $Mail
63
  */
64
+ protected function _parse_mail_object() {
65
  $parsed_Mail_vars = get_object_vars( $this->Mail );
66
  foreach ( $parsed_Mail_vars as $key => $value ) {
67
  if ( is_array( $value ) ) {
68
  continue;
69
  }
70
 
71
+ // To, CC, BCC, Return-Path can not use {name}. But they can use {custom_mail_tag}
72
+ if ( 'to' === $key || 'cc' === $key || 'bcc' === $key || 'return_path' === $key ) {
73
+ $Parser = new MW_WP_Form_Parser( $this->Setting );
74
+ $this->Mail->$key = $Parser->replace_for_mail_destination( $value );
75
  continue;
76
  }
 
 
 
 
77
 
78
+ $Parser = new MW_WP_Form_Parser( $this->Setting );
79
+ $this->Mail->$key = $Parser->replace_for_mail_content( $value );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  }
81
+ return $this->Mail;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
  }
83
 
84
  /**
85
+ * Save Mail content and attachment files
86
+ * Set property of saved mail ID
87
  */
88
  public function save() {
89
  $form_id = $this->Setting->get( 'post_id' );
90
+ $Parser = new MW_WP_Form_Parser( $this->Setting );
91
  $saved_mail_id = wp_insert_post( array(
92
+ 'post_title' => $Parser->replace_for_mail_content( $this->Mail->subject ),
93
  'post_status' => 'publish',
94
  'post_type' => MWF_Functions::get_contact_data_post_type_from_form_id( $form_id ),
95
  ) );
96
 
97
+ if ( ! empty( $saved_mail_id ) ) {
98
+ $this->Data->set_saved_mail_id( $saved_mail_id );
99
+
100
+ // 添付ファイルをメディアに保存
101
+ // save_mail_body 内のフックで添付ファイルの情報を使えるように、
102
+ // save_mail_body より前にこのブロックを実行する
103
+ // ここでポストメタとしてURLではなくファイルのIDを保存
104
  MWF_Functions::save_attachments_in_media(
105
  $saved_mail_id,
106
  $this->Mail->attachments,
108
  );
109
  }
110
 
 
 
111
  $parsed_Mail_vars = get_object_vars( $this->Mail );
112
  foreach ( $parsed_Mail_vars as $key => $value ) {
113
  if ( is_array( $value ) ) {
114
  continue;
115
  }
116
 
117
+ if ( 'body' === $key ) {
118
  $this->_save( $value );
119
  }
120
  }
121
  }
122
 
123
  /**
124
+ * Search {name} and save value to database
125
+ * Save value even if it is null (e.g. posting which checkbox isn't check)
126
  *
127
  * @param string $value
128
+ * @return void
129
  */
130
  protected function _save( $value ) {
131
+ $Parser = new MW_WP_Form_Parser( $this->Setting );
132
+ $matches = MW_WP_Form_Parser::search( $value );
 
 
 
133
 
134
  if ( ! isset( $matches[1] ) ) {
135
  return;
138
  $form_id = $this->Setting->get( 'post_id' );
139
  $form_key = MWF_Functions::get_form_key_from_form_id( $form_id );
140
 
141
+ $data = array();
142
+
143
+ foreach ( $matches[1] as $name ) {
144
+ $value = $Parser->parse( $name );
145
  $ignore_keys = apply_filters( 'mwform_no_save_keys_' . $form_key, array() );
146
+ if ( in_array( $name, $ignore_keys ) ) {
147
+ continue;
 
 
 
 
148
  }
 
 
149
 
150
+ // ファイルは MWF_Functions::save_attachments_in_media() で ID が保存されるため
151
+ // ここで送信された値(URL)は保存しない
152
+ if ( array_key_exists( $name, $this->Mail->attachments ) ) {
153
+ continue;
 
 
 
 
 
 
 
 
 
154
  }
155
+
156
+ $data[ $name ] = ( is_null( $value ) ) ? '' : $value;
 
157
  }
 
 
158
 
159
+ $Contact_Data_Setting = new MW_WP_Form_Contact_Data_Setting( $this->Data->get_saved_mail_id() );
160
+ $Contact_Data_Setting->sets( $data );
161
+ $Contact_Data_Setting->save();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
162
  }
163
  }
classes/services/class.mail.php CHANGED
@@ -1,11 +1,11 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Mail Service
4
- * Version : 1.4.1
5
  * Author : Takashi Kitajima
6
- * Author URI : http://2inc.org
7
  * Created : January 1, 2015
8
- * Modified : May 4, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
@@ -32,7 +32,6 @@ class MW_WP_Form_Mail_Service {
32
  protected $Data;
33
 
34
  /**
35
- * フォーム識別子
36
  * @var string
37
  */
38
  protected $form_key;
@@ -48,8 +47,6 @@ class MW_WP_Form_Mail_Service {
48
  protected $Setting;
49
 
50
  /**
51
- * __construct
52
- *
53
  * @param MW_WP_Form_Mail $Mail
54
  * @param strign $form_key
55
  * @param MW_WP_Form_Setting $Setting
@@ -57,7 +54,7 @@ class MW_WP_Form_Mail_Service {
57
  */
58
  public function __construct( MW_WP_Form_Mail $Mail, $form_key, MW_WP_Form_Setting $Setting, array $attachments = array() ) {
59
  $this->form_key = $form_key;
60
- $this->Data = MW_WP_Form_Data::getInstance();
61
  $this->Mail_raw = $Mail;
62
  $this->Mail_admin_raw = clone $Mail;
63
  $this->Mail_auto_raw = clone $Mail;
@@ -65,32 +62,31 @@ class MW_WP_Form_Mail_Service {
65
  $this->Setting = $Setting;
66
 
67
  if ( $this->Setting->get( 'post_id' ) ) {
68
- $this->set_admin_mail_raw_params();
69
- // 管理者宛メールにだけ添付ファイルを添付
70
- $this->set_attachments( $this->Mail_admin_raw );
71
- $this->Mail_admin_raw = $this->apply_filters_mwform_admin_mail_raw( $this->Mail_admin_raw );
72
 
73
- $this->set_reply_mail_raw_params();
74
- $this->Mail_auto_raw = $this->apply_filters_mwform_auto_mail_raw( $this->Mail_auto_raw );
75
  } else {
76
- $Mail = $this->apply_filters_mwform_mail( $Mail );
77
  }
78
  }
79
 
80
  /**
81
- * 管理者メールの送信とデータベースへの保存
82
  *
83
  * @return boolean
84
  */
85
  public function send_admin_mail() {
86
- $Mail_admin = $this->get_parsed_mail_object( $this->Mail_admin_raw );
87
  if ( $this->Setting->get( 'usedb' ) ) {
88
  $Mail_admin_for_save = clone $this->Mail_admin_raw;
89
  }
90
 
91
- $Mail_admin->set_admin_mail_reaquire_params();
92
- $Mail_admin = $this->apply_filters_mwform_mail( $Mail_admin );
93
- $Mail_admin = $this->apply_filters_mwform_admin_mail( $Mail_admin );
94
  do_action(
95
  'mwform_before_send_admin_mail_' . $this->form_key,
96
  clone $Mail_admin,
@@ -100,56 +96,52 @@ class MW_WP_Form_Mail_Service {
100
 
101
  // to が false の場合は意図的に送信していない(例えばDB保存だけおこないたい等)ということなので
102
  // 送信エラー画面が表示されるのはおかしい。そのためここでは true を返す
103
- if ( ! $Mail_admin->to ) {
104
  $is_admin_mail_sended = true;
105
  }
106
 
107
  if ( isset( $Mail_admin_for_save ) && $is_admin_mail_sended ) {
108
- $saved_mail_id = $this->save( $Mail_admin_for_save );
109
- $Contact_Data_Setting = new MW_WP_Form_Contact_Data_Setting( $saved_mail_id );
110
- $Contact_Data_Setting->save();
111
  }
112
 
113
- // DB非保存時は管理者メール送信後、ファイルを削除
114
- if ( !$this->Setting->get( 'usedb' ) ) {
115
- $File = new MW_WP_Form_File();
116
- $File->delete_files( $this->attachments );
117
  }
118
 
119
  return $is_admin_mail_sended;
120
  }
121
 
122
  /**
123
- * パースしたMailオブジェクトの取得とデータベースへの保存
124
  *
125
  * @param MW_WP_Form_Mail $_Mail
126
  * @return MW_WP_Form_Mail
127
  */
128
- protected function get_parsed_mail_object( MW_WP_Form_Mail $_Mail ) {
129
  $Mail = clone $_Mail;
130
  $Mail->parse( $this->Setting );
131
  return $Mail;
132
  }
133
 
134
  /**
135
- * メールをデータベースに保存し、保存されたメール(投稿)の ID を返す
136
  *
137
  * @param MW_WP_Form_Mail $Mail
138
- * @return int 保存されたメール(投稿)の ID
139
  */
140
- protected function save( MW_WP_Form_Mail $Mail ) {
141
  return $Mail->save( $this->Setting );
142
  }
143
 
144
  /**
145
- * 自動返信メールの送信
146
  *
147
  * @return boolean
148
  */
149
  public function send_reply_mail() {
150
- $Mail_auto = $this->get_parsed_mail_object( $this->Mail_auto_raw );
151
- $Mail_auto->set_reply_mail_reaquire_params();
152
- $Mail_auto = $this->apply_filters_mwform_auto_mail( $Mail_auto );
153
  do_action(
154
  'mwform_before_send_reply_mail_' . $this->form_key,
155
  clone $Mail_auto,
@@ -160,35 +152,40 @@ class MW_WP_Form_Mail_Service {
160
  }
161
 
162
  /**
163
- * メールオブジェクトに添付ファイルを添付
164
  *
165
  * @param MW_WP_Form_Mail $Mail
 
166
  */
167
- protected function set_attachments( MW_WP_Form_Mail $Mail ) {
168
  $Mail->attachments = $this->attachments;
169
  }
170
 
171
  /**
172
- * 管理者メールに項目を設定
 
 
173
  */
174
- protected function set_admin_mail_raw_params() {
175
  $this->Mail_admin_raw->set_admin_mail_raw_params( $this->Setting );
176
  }
177
 
178
  /**
179
- * 自動返信メールに項目を設定
 
 
180
  */
181
- private function set_reply_mail_raw_params() {
182
  $this->Mail_auto_raw->set_reply_mail_raw_params( $this->Setting );
183
  }
184
 
185
  /**
186
- * apply_filters_mwform_admin_mail_raw
187
  *
188
  * @param MW_WP_Form_Mail $Mail
189
  * @return MW_WP_Form_Mail $Mail
190
  */
191
- protected function apply_filters_mwform_admin_mail_raw( MW_WP_Form_Mail $Mail ) {
192
  return apply_filters(
193
  'mwform_admin_mail_raw_' . $this->form_key,
194
  $Mail,
@@ -198,12 +195,12 @@ class MW_WP_Form_Mail_Service {
198
  }
199
 
200
  /**
201
- * apply_filters_mwform_mail
202
  *
203
  * @param MW_WP_Form_Mail $Mail
204
  * @return MW_WP_Form_Mail $Mail
205
  */
206
- protected function apply_filters_mwform_mail( MW_WP_Form_Mail $Mail ) {
207
  return apply_filters(
208
  'mwform_mail_' . $this->form_key,
209
  $Mail,
@@ -213,12 +210,12 @@ class MW_WP_Form_Mail_Service {
213
  }
214
 
215
  /**
216
- * apply_filters_mwform_admin_mail
217
  *
218
  * @param MW_WP_Form_Mail $Mail
219
  * @return MW_WP_Form_Mail $Mail
220
  */
221
- protected function apply_filters_mwform_admin_mail( MW_WP_Form_Mail $Mail ) {
222
  return apply_filters(
223
  'mwform_admin_mail_' . $this->form_key,
224
  $Mail,
@@ -228,12 +225,12 @@ class MW_WP_Form_Mail_Service {
228
  }
229
 
230
  /**
231
- * apply_filters_mwform_auto_mail_raw
232
  *
233
  * @param MW_WP_Form_Mail $Mail
234
  * @return MW_WP_Form_Mail $Mail
235
  */
236
- protected function apply_filters_mwform_auto_mail_raw( MW_WP_Form_Mail $Mail ) {
237
  return apply_filters(
238
  'mwform_auto_mail_raw_' . $this->form_key,
239
  $Mail,
@@ -243,12 +240,12 @@ class MW_WP_Form_Mail_Service {
243
  }
244
 
245
  /**
246
- * apply_filters_mwform_auto_mail
247
  *
248
  * @param MW_WP_Form_Mail $Mail
249
  * @return MW_WP_Form_Mail $Mail
250
  */
251
- protected function apply_filters_mwform_auto_mail( MW_WP_Form_Mail $Mail ) {
252
  return apply_filters(
253
  'mwform_auto_mail_' . $this->form_key,
254
  $Mail,
@@ -258,7 +255,22 @@ class MW_WP_Form_Mail_Service {
258
  }
259
 
260
  /**
261
- * 問い合わせ番号を更新
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
262
  */
263
  public function update_tracking_number() {
264
  if ( preg_match( '{' . MWF_Config::TRACKINGNUMBER . '}', $this->Mail_admin_raw->body ) ) {
1
  <?php
2
  /**
3
  * Name : MW WP Form Mail Service
4
+ * Version : 2.0.0
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : January 1, 2015
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
32
  protected $Data;
33
 
34
  /**
 
35
  * @var string
36
  */
37
  protected $form_key;
47
  protected $Setting;
48
 
49
  /**
 
 
50
  * @param MW_WP_Form_Mail $Mail
51
  * @param strign $form_key
52
  * @param MW_WP_Form_Setting $Setting
54
  */
55
  public function __construct( MW_WP_Form_Mail $Mail, $form_key, MW_WP_Form_Setting $Setting, array $attachments = array() ) {
56
  $this->form_key = $form_key;
57
+ $this->Data = MW_WP_Form_Data::connect( $form_key );
58
  $this->Mail_raw = $Mail;
59
  $this->Mail_admin_raw = clone $Mail;
60
  $this->Mail_auto_raw = clone $Mail;
62
  $this->Setting = $Setting;
63
 
64
  if ( $this->Setting->get( 'post_id' ) ) {
65
+ $this->_set_admin_mail_raw_params();
66
+ // Attach attachment only to e-mail addressed to administrator
67
+ $this->_set_attachments_to( $this->Mail_admin_raw );
68
+ $this->Mail_admin_raw = $this->_apply_filters_mwform_admin_mail_raw( $this->Mail_admin_raw );
69
 
70
+ $this->_set_reply_mail_raw_params();
71
+ $this->Mail_auto_raw = $this->_apply_filters_mwform_auto_mail_raw( $this->Mail_auto_raw );
72
  } else {
73
+ $Mail = $this->_apply_filters_mwform_mail( $Mail );
74
  }
75
  }
76
 
77
  /**
78
+ * Send admin mail and save to database
79
  *
80
  * @return boolean
81
  */
82
  public function send_admin_mail() {
83
+ $Mail_admin = $this->_get_parsed_mail_object( $this->Mail_admin_raw );
84
  if ( $this->Setting->get( 'usedb' ) ) {
85
  $Mail_admin_for_save = clone $this->Mail_admin_raw;
86
  }
87
 
88
+ $Mail_admin = $this->_apply_filters_mwform_mail( $Mail_admin );
89
+ $Mail_admin = $this->_apply_filters_mwform_admin_mail( $Mail_admin );
 
90
  do_action(
91
  'mwform_before_send_admin_mail_' . $this->form_key,
92
  clone $Mail_admin,
96
 
97
  // to が false の場合は意図的に送信していない(例えばDB保存だけおこないたい等)ということなので
98
  // 送信エラー画面が表示されるのはおかしい。そのためここでは true を返す
99
+ if ( ! $Mail_admin->to && $this->Setting->get( 'usedb' ) ) {
100
  $is_admin_mail_sended = true;
101
  }
102
 
103
  if ( isset( $Mail_admin_for_save ) && $is_admin_mail_sended ) {
104
+ $saved_mail_id = $this->_save( $Mail_admin_for_save );
 
 
105
  }
106
 
107
+ // If not usedb, remove files after sending admin mail
108
+ if ( ! $this->Setting->get( 'usedb' ) ) {
109
+ $this->_delete_files();
 
110
  }
111
 
112
  return $is_admin_mail_sended;
113
  }
114
 
115
  /**
116
+ * Return parsed Mail object and save to database
117
  *
118
  * @param MW_WP_Form_Mail $_Mail
119
  * @return MW_WP_Form_Mail
120
  */
121
+ protected function _get_parsed_mail_object( MW_WP_Form_Mail $_Mail ) {
122
  $Mail = clone $_Mail;
123
  $Mail->parse( $this->Setting );
124
  return $Mail;
125
  }
126
 
127
  /**
128
+ * Save to database and return saved mail ID
129
  *
130
  * @param MW_WP_Form_Mail $Mail
131
+ * @return int
132
  */
133
+ protected function _save( MW_WP_Form_Mail $Mail ) {
134
  return $Mail->save( $this->Setting );
135
  }
136
 
137
  /**
138
+ * Send reply mail
139
  *
140
  * @return boolean
141
  */
142
  public function send_reply_mail() {
143
+ $Mail_auto = $this->_get_parsed_mail_object( $this->Mail_auto_raw );
144
+ $Mail_auto = $this->_apply_filters_mwform_auto_mail( $Mail_auto );
 
145
  do_action(
146
  'mwform_before_send_reply_mail_' . $this->form_key,
147
  clone $Mail_auto,
152
  }
153
 
154
  /**
155
+ * Set attachment files to Mail object
156
  *
157
  * @param MW_WP_Form_Mail $Mail
158
+ * @return void
159
  */
160
+ protected function _set_attachments_to( MW_WP_Form_Mail $Mail ) {
161
  $Mail->attachments = $this->attachments;
162
  }
163
 
164
  /**
165
+ * Set admin mail params
166
+ *
167
+ * @return void
168
  */
169
+ protected function _set_admin_mail_raw_params() {
170
  $this->Mail_admin_raw->set_admin_mail_raw_params( $this->Setting );
171
  }
172
 
173
  /**
174
+ * Set reply mail params
175
+ *
176
+ * @return void
177
  */
178
+ private function _set_reply_mail_raw_params() {
179
  $this->Mail_auto_raw->set_reply_mail_raw_params( $this->Setting );
180
  }
181
 
182
  /**
183
+ * Apply mwform_admin_mail_raw filter hook
184
  *
185
  * @param MW_WP_Form_Mail $Mail
186
  * @return MW_WP_Form_Mail $Mail
187
  */
188
+ protected function _apply_filters_mwform_admin_mail_raw( MW_WP_Form_Mail $Mail ) {
189
  return apply_filters(
190
  'mwform_admin_mail_raw_' . $this->form_key,
191
  $Mail,
195
  }
196
 
197
  /**
198
+ * Apply mwform_mail filter hook
199
  *
200
  * @param MW_WP_Form_Mail $Mail
201
  * @return MW_WP_Form_Mail $Mail
202
  */
203
+ protected function _apply_filters_mwform_mail( MW_WP_Form_Mail $Mail ) {
204
  return apply_filters(
205
  'mwform_mail_' . $this->form_key,
206
  $Mail,
210
  }
211
 
212
  /**
213
+ * Apply mwform_admin_mail filter hook
214
  *
215
  * @param MW_WP_Form_Mail $Mail
216
  * @return MW_WP_Form_Mail $Mail
217
  */
218
+ protected function _apply_filters_mwform_admin_mail( MW_WP_Form_Mail $Mail ) {
219
  return apply_filters(
220
  'mwform_admin_mail_' . $this->form_key,
221
  $Mail,
225
  }
226
 
227
  /**
228
+ * Apply mwform_auto_mail_raw filter hook
229
  *
230
  * @param MW_WP_Form_Mail $Mail
231
  * @return MW_WP_Form_Mail $Mail
232
  */
233
+ protected function _apply_filters_mwform_auto_mail_raw( MW_WP_Form_Mail $Mail ) {
234
  return apply_filters(
235
  'mwform_auto_mail_raw_' . $this->form_key,
236
  $Mail,
240
  }
241
 
242
  /**
243
+ * Apply mwform_auto_mail filter hook
244
  *
245
  * @param MW_WP_Form_Mail $Mail
246
  * @return MW_WP_Form_Mail $Mail
247
  */
248
+ protected function _apply_filters_mwform_auto_mail( MW_WP_Form_Mail $Mail ) {
249
  return apply_filters(
250
  'mwform_auto_mail_' . $this->form_key,
251
  $Mail,
255
  }
256
 
257
  /**
258
+ * Delete attachment files
259
+ *
260
+ * @return void
261
+ */
262
+ protected function _delete_files() {
263
+ foreach ( $this->attachments as $file ) {
264
+ if ( file_exists( $file ) ) {
265
+ unlink( $file );
266
+ }
267
+ }
268
+ }
269
+
270
+ /**
271
+ * Update tracking number
272
+ *
273
+ * @return void
274
  */
275
  public function update_tracking_number() {
276
  if ( preg_match( '{' . MWF_Config::TRACKINGNUMBER . '}', $this->Mail_admin_raw->body ) ) {
classes/services/class.redirected.php CHANGED
@@ -1,21 +1,25 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Redirected
4
- * Version : 1.0.2
5
  * Author : Takashi Kitajima
6
- * Author URI : http://2inc.org
7
  * Created : December 31, 2014
8
- * Modified : April 28, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Redirected {
13
 
14
  /**
15
- * 現在のモード
16
- * @var string input|confirm|complete|back
17
  */
18
- protected $mode_check = 'input';
 
 
 
 
 
19
 
20
  /**
21
  * @var string input|confirm|complete
@@ -27,117 +31,71 @@ class MW_WP_Form_Redirected {
27
  */
28
  protected $url;
29
 
30
- /**
31
- * @var bool
32
- */
33
- protected $querystring;
34
 
35
- /**
36
- * __construct
37
- *
38
- * @param string $input
39
- * @param string $confirm
40
- * @param string $complete
41
- * @param string $valdation_error
42
- * @param bool $is_valid
43
- * @param bool $post_condition
44
- * @param bool $querystring
45
- */
46
- public function __construct( $input, $confirm, $complete, $valdation_error, $is_valid, $post_condition, $querystring ) {
47
- $this->querystring = $querystring; // parse_url
48
 
49
- $this->initialize( $input, $confirm, $complete, $valdation_error, $is_valid, $post_condition );
50
- }
51
-
52
- /**
53
- * initialize
54
- *
55
- * @param string $input
56
- * @param string $confirm
57
- * @param string $complete
58
- * @param string $valdation_error
59
- * @param bool $is_valid
60
- * @param bool $post_condition
61
- */
62
- protected function initialize( $input, $confirm, $complete, $valdation_error, $is_valid, $post_condition ) {
63
- $input = $this->parse_url( $input );
64
- $confirm = $this->parse_url( $confirm );
65
- $complete = $this->parse_url( $complete );
66
- $validation_error = $this->parse_url( $valdation_error );
67
- $REQUEST_URI = $this->parse_url( $this->get_request_uri() );
68
-
69
- // 入力画面(戻る)のとき
70
- if ( $post_condition === 'back' ) {
71
- $this->url = $input;
72
  return;
73
  }
74
- // 確認画面のとき
75
- elseif ( $post_condition === 'confirm' ) {
76
  if ( $is_valid ) {
77
  $this->view_flg = 'confirm';
78
  $this->url = $confirm;
79
- return;
80
  } else {
81
- if ( $validation_error ) {
82
- $this->url = $validation_error;
83
- return;
84
  } else {
85
  $this->url = $input;
86
- return;
87
  }
88
  }
 
89
  }
90
- // 完了画面のとき
91
- elseif ( $post_condition === 'complete' ) {
92
  if ( $is_valid ) {
93
  $this->view_flg = 'complete';
94
  $this->url = $complete;
95
- return;
96
  } else {
97
- if ( $validation_error ) {
98
- $this->url = $validation_error;
99
- return;
100
  } else {
101
  $this->url = $input;
102
- return;
103
- }
104
- }
105
- }
106
- // 完了 or 確認画面 or エラーURLが設定済みで
107
- // 完了 or 確認画面 or エラーに直接アクセスした場合、
108
- // 入力画面に戻れれば戻る。戻れない場合はトップに戻す
109
- else {
110
- $check_urls = array(
111
- $confirm, $complete,
112
- );
113
- $back_url = ( $input ) ? $input : home_url();
114
- foreach ( $check_urls as $check_url ) {
115
- if ( $REQUEST_URI === $check_url ) {
116
- $this->url = $back_url;
117
- return;
118
  }
119
  }
120
- $this->url = $input;
121
  return;
122
-
123
- if ( $is_valid && $REQUEST_URI == $validation_error ) {
124
- $this->url = $back_url;
125
- return;
126
- }
127
  }
 
 
128
  }
129
 
130
  /**
131
- * リダイレクト先の URL を返す
132
  *
133
  * @return string
134
  */
135
  public function get_url() {
136
- return $this->url;
 
137
  }
138
 
139
  /**
140
- * 表示すべき画面を示すフラグを返す
141
  *
142
  * @return string $this->view_flg
143
  */
@@ -146,46 +104,51 @@ class MW_WP_Form_Redirected {
146
  }
147
 
148
  /**
149
- * $_SERVER['REQUEST_URI'] http:// からはじまるURLに変換する
150
  *
151
  * @return string URL
152
  */
153
  public function get_request_uri() {
154
- $_REQUEST_URI = $_SERVER['REQUEST_URI'];
155
- if ( !preg_match( '/^https?:\/\//', $_REQUEST_URI ) ) {
156
- $REQUEST_URI = home_url() . $_REQUEST_URI;
157
- $parse_url = parse_url( home_url() );
158
- // サブディレクトリ型の場合
159
- if ( !empty( $parse_url['path'] ) ) {
160
- $pettern = preg_quote( $parse_url['path'], '/' );
161
- if ( preg_match( '/^' . $pettern . '/', $_REQUEST_URI ) ) {
162
- $REQUEST_URI = preg_replace( '/' . $pettern . '$/', $_REQUEST_URI, home_url() );
163
- }
164
- }
165
- } else {
166
- $REQUEST_URI = $_REQUEST_URI;
167
  }
 
 
 
 
 
 
 
 
 
 
168
  return $REQUEST_URI;
169
  }
170
 
171
  /**
172
- * http:// からはじまるURLに変換する
173
  *
174
  * @param string URL
175
  * @return string URL
176
  */
177
- protected function parse_url( $url ) {
178
  if ( empty( $url ) ) {
179
  return '';
180
  }
181
 
182
  $query_string = array();
183
  preg_match( '/\?(.*)$/', $url, $reg );
184
- if ( !empty( $reg[1] ) ) {
185
  $url = str_replace( '?' . $reg[1], '', $url );
186
  parse_str( $reg[1], $query_string );
187
  }
188
- if ( !preg_match( '/^https?:\/\//', $url ) ) {
189
  $home_url = home_url();
190
  $url = $home_url . $url;
191
  }
@@ -193,16 +156,76 @@ class MW_WP_Form_Redirected {
193
 
194
  // URL設定でURL引数が使用されている場合はそれを使う。
195
  // 「URL引数を有効にする」が有効の場合は $_GET を利用する(重複するURL引数はURL設定のものが優先される ※post_id除く)
196
- if ( $this->querystring ) {
197
  $query_string = array_merge( $_GET, $query_string );
198
  if ( isset( $_GET['post_id'] ) && MWF_Functions::is_numeric( $_GET['post_id'] ) ) {
199
  $query_string['post_id'] = $_GET['post_id'];
200
  }
201
  }
202
 
203
- if ( !empty( $query_string ) ) {
204
- $url = $url . '?' . http_build_query( $query_string, null, '&' );
205
  }
 
206
  return $url;
207
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
208
  }
1
  <?php
2
  /**
3
  * Name : MW WP Form Redirected
4
+ * Version : 2.0.0
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : December 31, 2014
8
+ * Modified : May 21, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Redirected {
13
 
14
  /**
15
+ * @var string
 
16
  */
17
+ protected $form_key;
18
+
19
+ /**
20
+ * @var MW_WP_Form_Setting
21
+ */
22
+ protected $Setting;
23
 
24
  /**
25
  * @var string input|confirm|complete
31
  */
32
  protected $url;
33
 
34
+ public function __construct( $form_key, $Setting, $is_valid, $post_condition ) {
35
+ $this->form_key = $form_key;
36
+ $this->Setting = $Setting;
 
37
 
38
+ $input = $this->_parse_url( $this->Setting->get( 'input_url' ) );
39
+ $confirm = $this->_parse_url( $this->Setting->get( 'confirmation_url' ) );
40
+ $complete = $this->_parse_url( $this->Setting->get( 'complete_url' ) );
41
+ $error = $this->_parse_url( $this->Setting->get( 'validation_error_url' ) );
 
 
 
 
 
 
 
 
 
42
 
43
+ if ( 'back' === $post_condition ) {
44
+ if ( $is_valid ) {
45
+ $this->url = $input;
46
+ } else {
47
+ if ( $error ) {
48
+ $this->url = $error;
49
+ } else {
50
+ $this->url = $input;
51
+ }
52
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  return;
54
  }
55
+
56
+ if ( 'confirm' === $post_condition ) {
57
  if ( $is_valid ) {
58
  $this->view_flg = 'confirm';
59
  $this->url = $confirm;
 
60
  } else {
61
+ if ( $error ) {
62
+ $this->url = $error;
 
63
  } else {
64
  $this->url = $input;
 
65
  }
66
  }
67
+ return;
68
  }
69
+
70
+ if ( 'complete' === $post_condition ) {
71
  if ( $is_valid ) {
72
  $this->view_flg = 'complete';
73
  $this->url = $complete;
 
74
  } else {
75
+ if ( $error ) {
76
+ $this->url = $error;
 
77
  } else {
78
  $this->url = $input;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  }
80
  }
 
81
  return;
 
 
 
 
 
82
  }
83
+
84
+ $this->url = ( $input ) ? $input : $this->get_request_uri();
85
  }
86
 
87
  /**
88
+ * Return URL of redirect destination
89
  *
90
  * @return string
91
  */
92
  public function get_url() {
93
+ $Data = MW_WP_Form_Data::connect( $this->form_key );
94
+ return apply_filters( 'mwform_redirect_url_' . $this->form_key, $this->url, $Data );
95
  }
96
 
97
  /**
98
+ * Returns a flg indicating the screen to be displayed
99
  *
100
  * @return string $this->view_flg
101
  */
104
  }
105
 
106
  /**
107
+ * Return $_SERVER['REQUEST_URI'] that converted https?://...
108
  *
109
  * @return string URL
110
  */
111
  public function get_request_uri() {
112
+ $REQUEST_URI = $_SERVER['REQUEST_URI'];
113
+
114
+ if ( ! $REQUEST_URI ) {
115
+ return;
116
+ }
117
+
118
+ if ( preg_match( '/^https?:\/\//', $REQUEST_URI ) ) {
119
+ return $REQUEST_URI;
 
 
 
 
 
120
  }
121
+
122
+ $parse_url = parse_url( home_url() );
123
+
124
+ // For WP installed in subdirectory
125
+ if ( ! empty( $parse_url['path'] ) ) {
126
+ $pettern = preg_quote( $parse_url['path'], '/' );
127
+ return preg_replace( '/' . $pettern . '$/', $REQUEST_URI, home_url() );
128
+ }
129
+
130
+ return trailingslashit( home_url() ) . ltrim( $REQUEST_URI, '/' );
131
  return $REQUEST_URI;
132
  }
133
 
134
  /**
135
+ * Convert URL to https?://...
136
  *
137
  * @param string URL
138
  * @return string URL
139
  */
140
+ protected function _parse_url( $url ) {
141
  if ( empty( $url ) ) {
142
  return '';
143
  }
144
 
145
  $query_string = array();
146
  preg_match( '/\?(.*)$/', $url, $reg );
147
+ if ( ! empty( $reg[1] ) ) {
148
  $url = str_replace( '?' . $reg[1], '', $url );
149
  parse_str( $reg[1], $query_string );
150
  }
151
+ if ( ! preg_match( '/^https?:\/\//', $url ) ) {
152
  $home_url = home_url();
153
  $url = $home_url . $url;
154
  }
156
 
157
  // URL設定でURL引数が使用されている場合はそれを使う。
158
  // 「URL引数を有効にする」が有効の場合は $_GET を利用する(重複するURL引数はURL設定のものが優先される ※post_id除く)
159
+ if ( $this->Setting->get( 'querystring' ) ) {
160
  $query_string = array_merge( $_GET, $query_string );
161
  if ( isset( $_GET['post_id'] ) && MWF_Functions::is_numeric( $_GET['post_id'] ) ) {
162
  $query_string['post_id'] = $_GET['post_id'];
163
  }
164
  }
165
 
166
+ if ( ! empty( $query_string ) ) {
167
+ return $url . '?' . http_build_query( $query_string, null, '&' );
168
  }
169
+
170
  return $url;
171
  }
172
+
173
+ /**
174
+ * Redirect
175
+ * Don't redirect if the current URL and the redirect URL are the same
176
+ *
177
+ * @return void
178
+ */
179
+ public function redirect() {
180
+ $redirect = $this->_get_real_redirect_url();
181
+ if ( ! $redirect ) {
182
+ return;
183
+ }
184
+
185
+ do_action( 'mwform_before_redirect_' . $this->form_key );
186
+
187
+ $redirect = wp_sanitize_redirect( $redirect );
188
+ $redirect = wp_validate_redirect( $redirect, home_url() );
189
+ wp_safe_redirect( $redirect );
190
+ exit();
191
+ }
192
+
193
+ /**
194
+ * Redirect using JavaScript
195
+ * Don't redirect if the current URL and the redirect URL are the same
196
+ *
197
+ * @return void
198
+ */
199
+ public function redirect_js() {
200
+ $redirect = $this->_get_real_redirect_url();
201
+ if ( ! $redirect ) {
202
+ return;
203
+ }
204
+
205
+ do_action( 'mwform_before_redirect_' . $this->form_key );
206
+ ?>
207
+ <script type="text/javascript">
208
+ window.location = "<?php echo esc_js( $redirect ); ?>";
209
+ </script>
210
+ <?php
211
+ }
212
+
213
+ /**
214
+ * Return redirect url that sanitize and validate
215
+ *
216
+ * @return string
217
+ */
218
+ protected function _get_real_redirect_url() {
219
+ $redirect = ( $this->get_url() ) ? $this->get_url() : $this->get_request_uri();
220
+ $REQUEST_URI = $this->get_request_uri();
221
+
222
+ if ( empty( $_POST ) && $redirect === $REQUEST_URI ) {
223
+ return;
224
+ }
225
+
226
+ $redirect = wp_sanitize_redirect( $redirect );
227
+ $redirect = wp_validate_redirect( $redirect, home_url() );
228
+
229
+ return $redirect;
230
+ }
231
  }
classes/validation-rules/class.akismet.php CHANGED
@@ -1,31 +1,30 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Validation Rule Akismet
4
- * Description: Akismetのエラー。常にtrue
5
- * Version : 1.1.1
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : July 21, 2014
9
- * Modified : April 3, 2014
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Validation_Rule_Akismet extends MW_WP_Form_Abstract_Validation_Rule {
14
 
15
  /**
16
- * バリデーションルール名を指定
17
  * @var string
18
  */
19
  protected $name = 'akismet_check';
20
 
21
  /**
22
- * バリデーションチェック
23
  *
24
- * @param string $key name属性
25
  * @param array $option
26
- * @return string エラーメッセージ
27
  */
28
- public function rule( $key, array $options = array() ) {
29
  $defaults = array(
30
  'message' => __( 'The contents which you input were judged with spam.', 'mw-wp-form' )
31
  );
@@ -34,11 +33,12 @@ class MW_WP_Form_Validation_Rule_Akismet extends MW_WP_Form_Abstract_Validation_
34
  }
35
 
36
  /**
37
- * 設定パネルに追加
38
  *
39
- * @param numeric $key バリデーションルールセットの識別番号
40
- * @param array $value バリデーションルールセットの内容
 
41
  */
42
  public function admin( $key, $value ) {
43
  }
44
- }
1
  <?php
2
  /**
3
  * Name : MW WP Form Validation Rule Akismet
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : July 21, 2014
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Validation_Rule_Akismet extends MW_WP_Form_Abstract_Validation_Rule {
13
 
14
  /**
15
+ * Validation rule name
16
  * @var string
17
  */
18
  protected $name = 'akismet_check';
19
 
20
  /**
21
+ * Validation process
22
  *
23
+ * @param string $name
24
  * @param array $option
25
+ * @return string Error message
26
  */
27
+ public function rule( $name, array $options = array() ) {
28
  $defaults = array(
29
  'message' => __( 'The contents which you input were judged with spam.', 'mw-wp-form' )
30
  );
33
  }
34
 
35
  /**
36
+ * Add setting field to validation rule setting panel
37
  *
38
+ * @param numeric $key ID of validation rule
39
+ * @param array $value Content of validation rule
40
+ * @return void
41
  */
42
  public function admin( $key, $value ) {
43
  }
44
+ }
classes/validation-rules/class.alpha.php CHANGED
@@ -1,52 +1,57 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Validation Rule Alpha
4
- * Description: 値がアルファベット
5
- * Version : 1.1.1
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : July 21, 2014
9
- * Modified : April 1, 2015
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Validation_Rule_Alpha extends MW_WP_Form_Abstract_Validation_Rule {
14
 
15
  /**
16
- * バリデーションルール名を指定
17
  * @var string
18
  */
19
  protected $name = 'alpha';
20
 
21
  /**
22
- * バリデーションチェック
23
  *
24
- * @param string $key name属性
25
  * @param array $option
26
- * @return string エラーメッセージ
27
  */
28
- public function rule( $key, array $options = array() ) {
29
- $value = $this->Data->get( $key );
30
- if ( !MWF_Functions::is_empty( $value ) ) {
31
- if ( !preg_match( '/^[A-Za-z]+$/', $value ) ) {
32
- $defaults = array(
33
- 'message' => __( 'Please enter with a half-width alphabetic character.', 'mw-wp-form' )
34
- );
35
- $options = array_merge( $defaults, $options );
36
- return $options['message'];
37
- }
38
  }
 
 
 
 
 
 
39
  }
40
 
41
  /**
42
- * 設定パネルに追加
43
  *
44
- * @param numeric $key バリデーションルールセットの識別番号
45
- * @param array $value バリデーションルールセットの内容
 
46
  */
47
  public function admin( $key, $value ) {
48
  ?>
49
- <label><input type="checkbox" <?php checked( $value[$this->getName()], 1 ); ?> name="<?php echo MWF_Config::NAME; ?>[validation][<?php echo $key; ?>][<?php echo esc_attr( $this->getName() ); ?>]" value="1" /><?php esc_html_e( 'Alphabet', 'mw-wp-form' ); ?></label>
50
  <?php
51
  }
52
- }
1
  <?php
2
  /**
3
  * Name : MW WP Form Validation Rule Alpha
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : July 21, 2014
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Validation_Rule_Alpha extends MW_WP_Form_Abstract_Validation_Rule {
13
 
14
  /**
15
+ * Validation rule name
16
  * @var string
17
  */
18
  protected $name = 'alpha';
19
 
20
  /**
21
+ * Validation process
22
  *
23
+ * @param string $name
24
  * @param array $option
25
+ * @return string Error message
26
  */
27
+ public function rule( $name, array $options = array() ) {
28
+ $value = $this->Data->get( $name );
29
+
30
+ if ( MWF_Functions::is_empty( $value ) ) {
31
+ return;
32
+ }
33
+
34
+ if ( preg_match( '/^[A-Za-z]+$/', $value ) ) {
35
+ return;
 
36
  }
37
+
38
+ $defaults = array(
39
+ 'message' => __( 'Please enter with a half-width alphabetic character.', 'mw-wp-form' )
40
+ );
41
+ $options = array_merge( $defaults, $options );
42
+ return $options['message'];
43
  }
44
 
45
  /**
46
+ * Add setting field to validation rule setting panel
47
  *
48
+ * @param numeric $key ID of validation rule
49
+ * @param array $value Content of validation rule
50
+ * @return void
51
  */
52
  public function admin( $key, $value ) {
53
  ?>
54
+ <label><input type="checkbox" <?php checked( $value[ $this->getName() ], 1 ); ?> name="<?php echo MWF_Config::NAME; ?>[validation][<?php echo $key; ?>][<?php echo esc_attr( $this->getName() ); ?>]" value="1" /><?php esc_html_e( 'Alphabet', 'mw-wp-form' ); ?></label>
55
  <?php
56
  }
57
+ }
classes/validation-rules/class.alphanumeric.php CHANGED
@@ -1,52 +1,57 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Validation Rule AlphaNumeric
4
- * Description: 値が英数字
5
- * Version : 1.1.1
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : July 21, 2014
9
- * Modified : April 1, 2015
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Validation_Rule_AlphaNumeric extends MW_WP_Form_Abstract_Validation_Rule {
14
 
15
  /**
16
- * バリデーションルール名を指定
17
  * @var string
18
  */
19
  protected $name = 'alphanumeric';
20
 
21
  /**
22
- * バリデーションチェック
23
  *
24
- * @param string $key name属性
25
  * @param array $option
26
- * @return string エラーメッセージ
27
  */
28
- public function rule( $key, array $options = array() ) {
29
- $value = $this->Data->get( $key );
30
- if ( !MWF_Functions::is_empty( $value ) ) {
31
- if ( !preg_match( '/^[0-9A-Za-z]+$/', $value ) ) {
32
- $defaults = array(
33
- 'message' => __( 'Please enter with a half-width alphanumeric character.', 'mw-wp-form' )
34
- );
35
- $options = array_merge( $defaults, $options );
36
- return $options['message'];
37
- }
38
  }
 
 
 
 
 
 
39
  }
40
 
41
  /**
42
- * 設定パネルに追加
43
  *
44
- * @param numeric $key バリデーションルールセットの識別番号
45
- * @param array $value バリデーションルールセットの内容
 
46
  */
47
  public function admin( $key, $value ) {
48
  ?>
49
- <label><input type="checkbox" <?php checked( $value[$this->getName()], 1 ); ?> name="<?php echo MWF_Config::NAME; ?>[validation][<?php echo $key; ?>][<?php echo esc_attr( $this->getName() ); ?>]" value="1" /><?php esc_html_e( 'Alphabet and Numeric', 'mw-wp-form' ); ?></label>
50
  <?php
51
  }
52
- }
1
  <?php
2
  /**
3
  * Name : MW WP Form Validation Rule AlphaNumeric
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : July 21, 2014
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Validation_Rule_AlphaNumeric extends MW_WP_Form_Abstract_Validation_Rule {
13
 
14
  /**
15
+ * Validation rule name
16
  * @var string
17
  */
18
  protected $name = 'alphanumeric';
19
 
20
  /**
21
+ * Validation process
22
  *
23
+ * @param string $name
24
  * @param array $option
25
+ * @return string Error message
26
  */
27
+ public function rule( $name, array $options = array() ) {
28
+ $value = $this->Data->get( $name );
29
+
30
+ if ( MWF_Functions::is_empty( $value ) ) {
31
+ return;
32
+ }
33
+
34
+ if ( preg_match( '/^[0-9A-Za-z]+$/', $value ) ) {
35
+ return;
 
36
  }
37
+
38
+ $defaults = array(
39
+ 'message' => __( 'Please enter with a half-width alphanumeric character.', 'mw-wp-form' )
40
+ );
41
+ $options = array_merge( $defaults, $options );
42
+ return $options['message'];
43
  }
44
 
45
  /**
46
+ * Add setting field to validation rule setting panel
47
  *
48
+ * @param numeric $key ID of validation rule
49
+ * @param array $value Content of validation rule
50
+ * @return void
51
  */
52
  public function admin( $key, $value ) {
53
  ?>
54
+ <label><input type="checkbox" <?php checked( $value[ $this->getName() ], 1 ); ?> name="<?php echo MWF_Config::NAME; ?>[validation][<?php echo $key; ?>][<?php echo esc_attr( $this->getName() ); ?>]" value="1" /><?php esc_html_e( 'Alphabet and Numeric', 'mw-wp-form' ); ?></label>
55
  <?php
56
  }
57
+ }
classes/validation-rules/class.between.php CHANGED
@@ -1,74 +1,77 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Validation Rule Between
4
- * Description: 値の文字数が範囲内
5
- * Version : 1.1.1
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : July 21, 2014
9
- * Modified : April 1, 2015
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Validation_Rule_Between extends MW_WP_Form_Abstract_Validation_Rule {
14
 
15
  /**
16
- * バリデーションルール名を指定
17
  * @var string
18
  */
19
  protected $name = 'between';
20
 
21
  /**
22
- * バリデーションチェック
23
  *
24
- * @param string $key name属性
25
  * @param array $option
26
- * @return string エラーメッセージ
27
  */
28
- public function rule( $key, array $options = array() ) {
29
- $value = $this->Data->get( $key );
30
  $value = MWF_Functions::convert_eol( $value );
31
- if ( !MWF_Functions::is_empty( $value ) ) {
32
- $defaults = array(
33
- 'min' => 0,
34
- 'max' => 0,
35
- 'message' => __( 'The number of characters is invalid.', 'mw-wp-form' )
36
- );
37
- $options = array_merge( $defaults, $options );
38
- $length = mb_strlen( $value, get_bloginfo( 'charset' ) );
39
- if ( MWF_Functions::is_numeric( $options['min'] ) ) {
40
- if ( MWF_Functions::is_numeric( $options['max'] ) ) {
41
- if ( !( $options['min'] <= $length && $length <= $options['max'] ) ) {
42
- return $options['message'];
43
- }
44
- } else {
45
- if ( $options['min'] > $length ) {
46
- return $options['message'];
47
- }
48
- }
49
- } elseif ( MWF_Functions::is_numeric( $options['max'] ) ) {
50
- if ( $options['max'] < $length ) {
51
  return $options['message'];
52
  }
53
  }
 
 
 
 
 
 
 
 
54
  }
55
  }
56
 
57
  /**
58
- * 設定パネルに追加
59
  *
60
- * @param numeric $key バリデーションルールセットの識別番号
61
- * @param array $value バリデーションルールセットの内容
 
62
  */
63
  public function admin( $key, $value ) {
64
  $min = '';
65
  $max = '';
66
- if ( is_array( $value[$this->getName()] ) ) {
67
- if ( isset( $value[$this->getName()]['min'] ) ) {
68
- $min = $value[$this->getName()]['min'];
69
  }
70
- if ( isset( $value[$this->getName()]['max'] ) ) {
71
- $max = $value[$this->getName()]['max'];
72
  }
73
  }
74
  ?>
@@ -84,4 +87,4 @@ class MW_WP_Form_Validation_Rule_Between extends MW_WP_Form_Abstract_Validation_
84
  </table>
85
  <?php
86
  }
87
- }
1
  <?php
2
  /**
3
  * Name : MW WP Form Validation Rule Between
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : July 21, 2014
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Validation_Rule_Between extends MW_WP_Form_Abstract_Validation_Rule {
13
 
14
  /**
15
+ * Validation rule name
16
  * @var string
17
  */
18
  protected $name = 'between';
19
 
20
  /**
21
+ * Validation process
22
  *
23
+ * @param string $name
24
  * @param array $option
25
+ * @return string Error message
26
  */
27
+ public function rule( $name, array $options = array() ) {
28
+ $value = $this->Data->get( $name );
29
  $value = MWF_Functions::convert_eol( $value );
30
+
31
+ if ( MWF_Functions::is_empty( $value ) ) {
32
+ return;
33
+ }
34
+
35
+ $defaults = array(
36
+ 'min' => 0,
37
+ 'max' => 0,
38
+ 'message' => __( 'The number of characters is invalid.', 'mw-wp-form' )
39
+ );
40
+ $options = array_merge( $defaults, $options );
41
+ $length = mb_strlen( $value, get_bloginfo( 'charset' ) );
42
+ if ( MWF_Functions::is_numeric( $options['min'] ) ) {
43
+ if ( MWF_Functions::is_numeric( $options['max'] ) ) {
44
+ if ( $options['min'] > $length || $length > $options['max'] ) {
 
 
 
 
 
45
  return $options['message'];
46
  }
47
  }
48
+
49
+ if ( $options['min'] > $length ) {
50
+ return $options['message'];
51
+ }
52
+ } elseif ( MWF_Functions::is_numeric( $options['max'] ) ) {
53
+ if ( $options['max'] < $length ) {
54
+ return $options['message'];
55
+ }
56
  }
57
  }
58
 
59
  /**
60
+ * Add setting field to validation rule setting panel
61
  *
62
+ * @param numeric $key ID of validation rule
63
+ * @param array $value Content of validation rule
64
+ * @return void
65
  */
66
  public function admin( $key, $value ) {
67
  $min = '';
68
  $max = '';
69
+ if ( is_array( $value[ $this->getName() ] ) ) {
70
+ if ( isset( $value[ $this->getName() ]['min'] ) ) {
71
+ $min = $value[ $this->getName() ]['min'];
72
  }
73
+ if ( isset( $value[ $this->getName() ]['max'] ) ) {
74
+ $max = $value[ $this->getName() ]['max'];
75
  }
76
  }
77
  ?>
87
  </table>
88
  <?php
89
  }
90
+ }
classes/validation-rules/class.date.php CHANGED
@@ -1,56 +1,61 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Validation Rule Date
4
- * Description: 日付が正しいかどうか
5
- * Version : 1.1.2
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : July 21, 2014
9
- * Modified : October 16, 2015
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Validation_Rule_Date extends MW_WP_Form_Abstract_Validation_Rule {
14
 
15
  /**
16
- * バリデーションルール名を指定
17
  * @var string
18
  */
19
  protected $name = 'date';
20
 
21
  /**
22
- * バリデーションチェック
23
  *
24
- * @param string $key name属性
25
  * @param array $option
26
- * @return string エラーメッセージ
27
  */
28
- public function rule( $key, array $options = array() ) {
29
- $value = $this->Data->get( $key );
30
- if ( !MWF_Functions::is_empty( $value ) ) {
31
- $defaults = array(
32
- 'message' => __( 'This is not the format of a date.', 'mw-wp-form' )
33
- );
34
- $options = array_merge( $defaults, $options );
35
- $timestamp = strtotime( $value );
36
- if ( !$timestamp ) {
37
- $timestamp = $this->convert_jpdate_to_timestamp( $value );
38
- }
39
- if ( !$timestamp ) {
40
- return $options['message'];
41
- }
42
- $year = date( 'Y', $timestamp );
43
- $month = date( 'm', $timestamp );
44
- $day = date( 'd', $timestamp );
45
- $checkdate = checkdate( $month, $day, $year );
46
- if ( !$timestamp || !$checkdate || preg_match( '/^[a-zA-Z]$/', $value ) || preg_match( '/^\s+$/', $value ) ) {
47
- return $options['message'];
48
- }
 
 
 
 
 
 
49
  }
50
  }
51
-
52
  /**
53
- * 日本語表記の日付をタイムスタンプに変換する
54
  *
55
  * @param string $jpdate yyyy年mm月dd日
56
  * @return string|false
@@ -64,14 +69,15 @@ class MW_WP_Form_Validation_Rule_Date extends MW_WP_Form_Abstract_Validation_Rul
64
  }
65
 
66
  /**
67
- * 設定パネルに追加
68
  *
69
- * @param numeric $key バリデーションルールセットの識別番号
70
- * @param array $value バリデーションルールセットの内容
 
71
  */
72
  public function admin( $key, $value ) {
73
  ?>
74
- <label><input type="checkbox" <?php checked( $value[$this->getName()], 1 ); ?> name="<?php echo MWF_Config::NAME; ?>[validation][<?php echo $key; ?>][<?php echo esc_attr( $this->getName() ); ?>]" value="1" /><?php esc_html_e( 'Date', 'mw-wp-form' ); ?></label>
75
  <?php
76
  }
77
  }
1
  <?php
2
  /**
3
  * Name : MW WP Form Validation Rule Date
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : July 21, 2014
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Validation_Rule_Date extends MW_WP_Form_Abstract_Validation_Rule {
13
 
14
  /**
15
+ * Validation rule name
16
  * @var string
17
  */
18
  protected $name = 'date';
19
 
20
  /**
21
+ * Validation process
22
  *
23
+ * @param string $name
24
  * @param array $option
25
+ * @return string Error message
26
  */
27
+ public function rule( $name, array $options = array() ) {
28
+ $value = $this->Data->get( $name );
29
+
30
+ if ( MWF_Functions::is_empty( $value ) ) {
31
+ return;
32
+ }
33
+
34
+ $defaults = array(
35
+ 'message' => __( 'This is not the format of a date.', 'mw-wp-form' )
36
+ );
37
+ $options = array_merge( $defaults, $options );
38
+
39
+ $timestamp = strtotime( $value );
40
+ if ( ! $timestamp ) {
41
+ $timestamp = $this->convert_jpdate_to_timestamp( $value );
42
+ }
43
+ if ( ! $timestamp ) {
44
+ return $options['message'];
45
+ }
46
+
47
+ $year = date( 'Y', $timestamp );
48
+ $month = date( 'm', $timestamp );
49
+ $day = date( 'd', $timestamp );
50
+ $checkdate = checkdate( $month, $day, $year );
51
+
52
+ if ( ! $timestamp || ! $checkdate || preg_match( '/^[a-zA-Z]$/', $value ) || preg_match( '/^\s+$/', $value ) ) {
53
+ return $options['message'];
54
  }
55
  }
56
+
57
  /**
58
+ * Convert Japanese notation date to time stamp
59
  *
60
  * @param string $jpdate yyyy年mm月dd日
61
  * @return string|false
69
  }
70
 
71
  /**
72
+ * Add setting field to validation rule setting panel
73
  *
74
+ * @param numeric $key ID of validation rule
75
+ * @param array $value Content of validation rule
76
+ * @return void
77
  */
78
  public function admin( $key, $value ) {
79
  ?>
80
+ <label><input type="checkbox" <?php checked( $value[ $this->getName() ], 1 ); ?> name="<?php echo MWF_Config::NAME; ?>[validation][<?php echo $key; ?>][<?php echo esc_attr( $this->getName() ); ?>]" value="1" /><?php esc_html_e( 'Date', 'mw-wp-form' ); ?></label>
81
  <?php
82
  }
83
  }
classes/validation-rules/class.eq.php CHANGED
@@ -1,55 +1,59 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Validation Rule Eq
4
- * Description: 値が一致している
5
- * Version : 1.1.2
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : July 21, 2014
9
- * Modified : December 3, 2015
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Validation_Rule_Eq extends MW_WP_Form_Abstract_Validation_Rule {
14
 
15
  /**
16
- * バリデーションルール名を指定
17
  * @var string
18
  */
19
  protected $name = 'eq';
20
 
21
  /**
22
- * バリデーションチェック
23
  *
24
- * @param string $key name属性
25
  * @param array $option
26
- * @return string エラーメッセージ
27
  */
28
- public function rule( $key, array $options = array() ) {
29
- $value = $this->Data->get( $key );
30
- if ( !is_null( $value ) ) {
31
- $defaults = array(
32
- 'target' => null,
33
- 'message' => __( 'This is not in agreement.', 'mw-wp-form' )
34
- );
35
- $options = array_merge( $defaults, $options );
36
- $target_value = $this->Data->get( $options['target'] );
37
- if ( ( string ) $value !== ( string ) $target_value ) {
38
- return $options['message'];
39
- }
 
 
 
 
40
  }
41
  }
42
 
43
  /**
44
- * 設定パネルに追加
45
  *
46
- * @param numeric $key バリデーションルールセットの識別番号
47
- * @param array $value バリデーションルールセットの内容
 
48
  */
49
  public function admin( $key, $value ) {
50
  $target = '';
51
- if ( is_array( $value[$this->getName()] ) && isset( $value[$this->getName()]['target'] ) ) {
52
- $target = $value[$this->getName()]['target'];
53
  }
54
  ?>
55
  <table>
1
  <?php
2
  /**
3
  * Name : MW WP Form Validation Rule Eq
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : July 21, 2014
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Validation_Rule_Eq extends MW_WP_Form_Abstract_Validation_Rule {
13
 
14
  /**
15
+ * Validation rule name
16
  * @var string
17
  */
18
  protected $name = 'eq';
19
 
20
  /**
21
+ * Validation process
22
  *
23
+ * @param string $name
24
  * @param array $option
25
+ * @return string Error message
26
  */
27
+ public function rule( $name, array $options = array() ) {
28
+ $value = $this->Data->get( $name );
29
+
30
+ if ( is_null( $value ) ) {
31
+ return;
32
+ }
33
+
34
+ $defaults = array(
35
+ 'target' => null,
36
+ 'message' => __( 'This is not in agreement.', 'mw-wp-form' )
37
+ );
38
+ $options = array_merge( $defaults, $options );
39
+ $target_value = $this->Data->get( $options['target'] );
40
+
41
+ if ( ( string ) $value !== ( string ) $target_value ) {
42
+ return $options['message'];
43
  }
44
  }
45
 
46
  /**
47
+ * Add setting field to validation rule setting panel
48
  *
49
+ * @param numeric $key ID of validation rule
50
+ * @param array $value Content of validation rule
51
+ * @return void
52
  */
53
  public function admin( $key, $value ) {
54
  $target = '';
55
+ if ( is_array( $value[ $this->getName() ] ) && isset( $value[ $this->getName() ]['target'] ) ) {
56
+ $target = $value[ $this->getName() ]['target'];
57
  }
58
  ?>
59
  <table>
classes/validation-rules/class.filesize.php CHANGED
@@ -1,39 +1,38 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Validation Rule FileSize
4
- * Description: ファイルサイズが指定したサイズ以内
5
- * Version : 2.0.0
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : July 21, 2014
9
- * Modified : September 28, 2016
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Validation_Rule_FileSize extends MW_WP_Form_Abstract_Validation_Rule {
14
 
15
  /**
16
- * バリデーションルール名を指定
17
  * @var string
18
  */
19
  protected $name = 'filesize';
20
 
21
  /**
22
- * バリデーションチェック
23
  *
24
- * @param string $key name属性
25
- * @param array $options
26
- * @return string エラーメッセージ
27
  */
28
- public function rule( $key, array $options = array() ) {
29
  $data = $this->Data->get_post_value_by_key( MWF_Config::UPLOAD_FILES );
30
 
31
  if ( ! is_null( $data ) ) {
32
 
33
- if ( is_array( $data ) && array_key_exists( $key, $data ) ) {
34
- $file = $data[$key];
35
  if ( ! empty( $file['size'] ) ) {
36
- return $this->filesize_validate( $file['size'], $options );
37
  } elseif ( ! empty( $file['error'] ) && $file['error'] == 1 ) {
38
  return __( 'Failed to upload the file.', 'mw-wp-form' );
39
  }
@@ -42,11 +41,11 @@ class MW_WP_Form_Validation_Rule_FileSize extends MW_WP_Form_Abstract_Validation
42
  } else {
43
 
44
  $upload_file_keys = $this->Data->get_post_value_by_key( MWF_Config::UPLOAD_FILE_KEYS );
45
- $filepath = MWF_Functions::fileurl_to_path( $this->Data->get( $key ) );
46
- if ( is_array( $upload_file_keys ) && in_array( $key, $upload_file_keys ) && file_exists( $filepath ) ) {
47
- $error_message = $this->filesize_validate( filesize( $filepath ), $options );
48
  if ( $error_message ) {
49
- // バリデーションは送信ボタン押下時、ページ遷移の後画面表示時にも発火するため
50
  // 普通に削除すると画面表示時のチェックが発火せずエラーメッセージが表示されない
51
  // そのため、非 POST 時(= リダイレクト = 画面表示時)にのみ削除する
52
  if ( empty( $_POST ) ) {
@@ -66,7 +65,7 @@ class MW_WP_Form_Validation_Rule_FileSize extends MW_WP_Form_Abstract_Validation
66
  * @param array $options
67
  * @return string Error message
68
  */
69
- protected function filesize_validate( $byte, $options ) {
70
  $defaults = array(
71
  'bytes' => '0',
72
  'message' => __( 'This file size is too big.', 'mw-wp-form' )
@@ -78,15 +77,16 @@ class MW_WP_Form_Validation_Rule_FileSize extends MW_WP_Form_Abstract_Validation
78
  }
79
 
80
  /**
81
- * 設定パネルに追加
82
  *
83
- * @param numeric $key バリデーションルールセットの識別番号
84
- * @param array $value バリデーションルールセットの内容
 
85
  */
86
  public function admin( $key, $value ) {
87
  $bytes = '';
88
- if ( is_array( $value[$this->getName()] ) && isset( $value[$this->getName()]['bytes'] ) ) {
89
- $bytes = $value[$this->getName()]['bytes'];
90
  }
91
  ?>
92
  <table>
1
  <?php
2
  /**
3
  * Name : MW WP Form Validation Rule FileSize
4
+ * Version : 3.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : July 21, 2014
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Validation_Rule_FileSize extends MW_WP_Form_Abstract_Validation_Rule {
13
 
14
  /**
15
+ * Validation rule name
16
  * @var string
17
  */
18
  protected $name = 'filesize';
19
 
20
  /**
21
+ * Validation process
22
  *
23
+ * @param string $name
24
+ * @param array $option
25
+ * @return string Error message
26
  */
27
+ public function rule( $name, array $options = array() ) {
28
  $data = $this->Data->get_post_value_by_key( MWF_Config::UPLOAD_FILES );
29
 
30
  if ( ! is_null( $data ) ) {
31
 
32
+ if ( is_array( $data ) && array_key_exists( $name, $data ) ) {
33
+ $file = $data[ $name ];
34
  if ( ! empty( $file['size'] ) ) {
35
+ return $this->_filesize_validate( $file['size'], $options );
36
  } elseif ( ! empty( $file['error'] ) && $file['error'] == 1 ) {
37
  return __( 'Failed to upload the file.', 'mw-wp-form' );
38
  }
41
  } else {
42
 
43
  $upload_file_keys = $this->Data->get_post_value_by_key( MWF_Config::UPLOAD_FILE_KEYS );
44
+ $filepath = MWF_Functions::fileurl_to_path( $this->Data->get( $name ) );
45
+ if ( is_array( $upload_file_keys ) && in_array( $name, $upload_file_keys ) && file_exists( $filepath ) ) {
46
+ $error_message = $this->_filesize_validate( filesize( $filepath ), $options );
47
  if ( $error_message ) {
48
+ // バリデーションは送信ボタン押下時に発火するため
49
  // 普通に削除すると画面表示時のチェックが発火せずエラーメッセージが表示されない
50
  // そのため、非 POST 時(= リダイレクト = 画面表示時)にのみ削除する
51
  if ( empty( $_POST ) ) {
65
  * @param array $options
66
  * @return string Error message
67
  */
68
+ protected function _filesize_validate( $byte, $options ) {
69
  $defaults = array(
70
  'bytes' => '0',
71
  'message' => __( 'This file size is too big.', 'mw-wp-form' )
77
  }
78
 
79
  /**
80
+ * Add setting field to validation rule setting panel
81
  *
82
+ * @param numeric $key ID of validation rule
83
+ * @param array $value Content of validation rule
84
+ * @return void
85
  */
86
  public function admin( $key, $value ) {
87
  $bytes = '';
88
+ if ( is_array( $value[ $this->getName() ] ) && isset( $value[ $this->getName() ]['bytes'] ) ) {
89
+ $bytes = $value[ $this->getName() ]['bytes'];
90
  }
91
  ?>
92
  <table>
classes/validation-rules/class.filetype.php CHANGED
@@ -1,60 +1,63 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Validation Rule FileType
4
- * Description: ファイル名が指定した拡張子を含む。types は , 区切り
5
- * Version : 1.1.1
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : July 21, 2014
9
- * Modified : April 1, 2015
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Validation_Rule_FileType extends MW_WP_Form_Abstract_Validation_Rule {
14
 
15
  /**
16
- * バリデーションルール名を指定
17
  * @var string
18
  */
19
  protected $name = 'filetype';
20
 
21
  /**
22
- * バリデーションチェック
23
  *
24
- * @param string $key name属性
25
  * @param array $option
26
- * @return string エラーメッセージ
27
  */
28
- public function rule( $key, array $options = array() ) {
29
- $value = $this->Data->get( $key );
30
- if ( !MWF_Functions::is_empty( $value ) ) {
31
- $defaults = array(
32
- 'types' => '',
33
- 'message' => __( 'This file is invalid.', 'mw-wp-form' )
34
- );
35
- $options = array_merge( $defaults, $options );
36
- $_types = explode( ',', $options['types'] );
37
- foreach ( $_types as $type ) {
38
- $types[] = preg_quote( trim( $type ), '/' );
39
- }
40
- $types = implode( '|', MWF_Functions::array_clean( $types ) );
41
- $pattern = '/\.(' . $types . ')$/i';
42
- if ( !preg_match( $pattern, $value ) ) {
43
- return $options['message'];
44
- }
 
 
 
45
  }
46
  }
47
 
48
  /**
49
- * 設定パネルに追加
50
  *
51
- * @param numeric $key バリデーションルールセットの識別番号
52
- * @param array $value バリデーションルールセットの内容
 
53
  */
54
  public function admin( $key, $value ) {
55
  $types = '';
56
- if ( is_array( $value[$this->getName()] ) && isset( $value[$this->getName()]['types'] ) ) {
57
- $types = $value[$this->getName()]['types'];
58
  }
59
  ?>
60
  <table>
1
  <?php
2
  /**
3
  * Name : MW WP Form Validation Rule FileType
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : July 21, 2014
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Validation_Rule_FileType extends MW_WP_Form_Abstract_Validation_Rule {
13
 
14
  /**
15
+ * Validation rule name
16
  * @var string
17
  */
18
  protected $name = 'filetype';
19
 
20
  /**
21
+ * Validation process
22
  *
23
+ * @param string $name
24
  * @param array $option
25
+ * @return string Error message
26
  */
27
+ public function rule( $name, array $options = array() ) {
28
+ $value = $this->Data->get( $name );
29
+
30
+ if ( MWF_Functions::is_empty( $value ) ) {
31
+ return;
32
+ }
33
+
34
+ $defaults = array(
35
+ 'types' => '',
36
+ 'message' => __( 'This file is invalid.', 'mw-wp-form' )
37
+ );
38
+ $options = array_merge( $defaults, $options );
39
+ $_types = explode( ',', $options['types'] );
40
+ foreach ( $_types as $type ) {
41
+ $types[] = preg_quote( trim( $type ), '/' );
42
+ }
43
+ $types = implode( '|', MWF_Functions::array_clean( $types ) );
44
+ $pattern = '/\.(' . $types . ')$/i';
45
+ if ( ! preg_match( $pattern, $value ) ) {
46
+ return $options['message'];
47
  }
48
  }
49
 
50
  /**
51
+ * Add setting field to validation rule setting panel
52
  *
53
+ * @param numeric $key ID of validation rule
54
+ * @param array $value Content of validation rule
55
+ * @return void
56
  */
57
  public function admin( $key, $value ) {
58
  $types = '';
59
+ if ( is_array( $value[ $this->getName() ] ) && isset( $value[ $this->getName() ]['types'] ) ) {
60
+ $types = $value[ $this->getName() ]['types'];
61
  }
62
  ?>
63
  <table>
classes/validation-rules/class.hiragana.php CHANGED
@@ -1,52 +1,57 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Validation Rule Hiragana
4
- * Description: 値がひらがな
5
- * Version : 1.1.1
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : July 21, 2014
9
- * Modified : April 1, 2015
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Validation_Rule_Hiragana extends MW_WP_Form_Abstract_Validation_Rule {
14
 
15
  /**
16
- * バリデーションルール名を指定
17
  * @var string
18
  */
19
  protected $name = 'hiragana';
20
 
21
  /**
22
- * バリデーションチェック
23
  *
24
- * @param string $key name属性
25
  * @param array $option
26
- * @return string エラーメッセージ
27
  */
28
- public function rule( $key, array $options = array() ) {
29
- $value = $this->Data->get( $key );
30
- if ( !MWF_Functions::is_empty( $value ) ) {
31
- if ( !preg_match( '/^[ぁ-ゞ  ]*?[ぁ-ゞ]+?[ぁ-ゞ  ]*?$/u', $value ) ) {
32
- $defaults = array(
33
- 'message' => __( 'Please enter with a Japanese Hiragana.', 'mw-wp-form' )
34
- );
35
- $options = array_merge( $defaults, $options );
36
- return $options['message'];
37
- }
38
  }
 
 
 
 
 
 
39
  }
40
 
41
  /**
42
- * 設定パネルに追加
43
  *
44
- * @param numeric $key バリデーションルールセットの識別番号
45
- * @param array $value バリデーションルールセットの内容
 
46
  */
47
  public function admin( $key, $value ) {
48
  ?>
49
- <label><input type="checkbox" <?php checked( $value[$this->getName()], 1 ); ?> name="<?php echo MWF_Config::NAME; ?>[validation][<?php echo $key; ?>][<?php echo esc_attr( $this->getName() ); ?>]" value="1" /><?php esc_html_e( 'Japanese Hiragana', 'mw-wp-form' ); ?></label>
50
  <?php
51
  }
52
- }
1
  <?php
2
  /**
3
  * Name : MW WP Form Validation Rule Hiragana
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : July 21, 2014
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Validation_Rule_Hiragana extends MW_WP_Form_Abstract_Validation_Rule {
13
 
14
  /**
15
+ * Validation rule name
16
  * @var string
17
  */
18
  protected $name = 'hiragana';
19
 
20
  /**
21
+ * Validation process
22
  *
23
+ * @param string $name
24
  * @param array $option
25
+ * @return string Error message
26
  */
27
+ public function rule( $name, array $options = array() ) {
28
+ $value = $this->Data->get( $name );
29
+
30
+ if ( MWF_Functions::is_empty( $value ) ) {
31
+ return;
32
+ }
33
+
34
+ if ( preg_match( '/^[ぁ-ゞ  ]*?[ぁ-ゞ]+?[ぁ-ゞ  ]*?$/u', $value ) ) {
35
+ return;
 
36
  }
37
+
38
+ $defaults = array(
39
+ 'message' => __( 'Please enter with a Japanese Hiragana.', 'mw-wp-form' )
40
+ );
41
+ $options = array_merge( $defaults, $options );
42
+ return $options['message'];
43
  }
44
 
45
  /**
46
+ * Add setting field to validation rule setting panel
47
  *
48
+ * @param numeric $key ID of validation rule
49
+ * @param array $value Content of validation rule
50
+ * @return void
51
  */
52
  public function admin( $key, $value ) {
53
  ?>
54
+ <label><input type="checkbox" <?php checked( $value[ $this->getName() ], 1 ); ?> name="<?php echo MWF_Config::NAME; ?>[validation][<?php echo $key; ?>][<?php echo esc_attr( $this->getName() ); ?>]" value="1" /><?php esc_html_e( 'Japanese Hiragana', 'mw-wp-form' ); ?></label>
55
  <?php
56
  }
57
+ }
classes/validation-rules/class.in.php CHANGED
@@ -1,57 +1,61 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Validation Rule In
4
- * Description: 値が、配列で指定された中に含まれている
5
- * Version : 1.1.2
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : July 21, 2014
9
- * Modified : April 1, 2015
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Validation_Rule_In extends MW_WP_Form_Abstract_Validation_Rule {
14
 
15
  /**
16
- * バリデーションルール名を指定
17
  * @var string
18
  */
19
  protected $name = 'in';
20
 
21
  /**
22
- * バリデーションチェック
23
  *
24
- * @param string $key name属性
25
  * @param array $option
26
- * @return string エラーメッセージ
27
  */
28
- public function rule( $key, array $options = array() ) {
29
- $value = $this->Data->get( $key );
30
  $value = ( string ) $value;
31
- if ( !MWF_Functions::is_empty( $value ) ) {
32
- $defaults = array(
33
- 'options' => array(),
34
- 'message' => __( 'This value is invalid.', 'mw-wp-form' )
35
- );
36
- $options = array_merge( $defaults, $options );
37
- if ( is_array( $options['options'] ) ) {
38
- foreach ( $options['options'] as $option ) {
39
- $option = ( string ) $option;
40
- if ( $value === $option ) {
41
- return;
42
- }
 
 
 
43
  }
44
  }
45
- return $options['message'];
46
  }
 
 
47
  }
48
 
49
  /**
50
- * 設定パネルに追加
51
  *
52
- * @param numeric $key バリデーションルールセットの識別番号
53
- * @param array $value バリデーションルールセットの内容
 
54
  */
55
  public function admin( $key, $value ) {
56
  }
57
- }
1
  <?php
2
  /**
3
  * Name : MW WP Form Validation Rule In
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : July 21, 2014
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Validation_Rule_In extends MW_WP_Form_Abstract_Validation_Rule {
13
 
14
  /**
15
+ * Validation rule name
16
  * @var string
17
  */
18
  protected $name = 'in';
19
 
20
  /**
21
+ * Validation process
22
  *
23
+ * @param string $name
24
  * @param array $option
25
+ * @return string Error message
26
  */
27
+ public function rule( $name, array $options = array() ) {
28
+ $value = $this->Data->get( $name );
29
  $value = ( string ) $value;
30
+
31
+ if ( MWF_Functions::is_empty( $value ) ) {
32
+ return;
33
+ }
34
+
35
+ $defaults = array(
36
+ 'options' => array(),
37
+ 'message' => __( 'This value is invalid.', 'mw-wp-form' )
38
+ );
39
+ $options = array_merge( $defaults, $options );
40
+ if ( is_array( $options['options'] ) ) {
41
+ foreach ( $options['options'] as $option ) {
42
+ $option = ( string ) $option;
43
+ if ( $value === $option ) {
44
+ return;
45
  }
46
  }
 
47
  }
48
+
49
+ return $options['message'];
50
  }
51
 
52
  /**
53
+ * Add setting field to validation rule setting panel
54
  *
55
+ * @param numeric $key ID of validation rule
56
+ * @param array $value Content of validation rule
57
+ * @return void
58
  */
59
  public function admin( $key, $value ) {
60
  }
61
+ }
classes/validation-rules/class.kana.php CHANGED
@@ -1,52 +1,57 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Validation Rule Kana
4
- * Description: 値がひらがな or カタカナ
5
- * Version : 1.0.1
6
  * Author : Key Nomura, Takashi Kitajima
7
  * Author URI : http://mypacecreator.net/
8
  * Created : September 1, 2015
9
- * Modified : September 1, 2015
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Validation_Rule_Kana extends MW_WP_Form_Abstract_Validation_Rule {
14
 
15
  /**
16
- * バリデーションルール名を指定
17
  * @var string
18
  */
19
  protected $name = 'kana';
20
 
21
  /**
22
- * バリデーションチェック
23
  *
24
- * @param string $key name属性
25
  * @param array $option
26
- * @return string エラーメッセージ
27
  */
28
- public function rule( $key, array $options = array() ) {
29
- $value = $this->Data->get( $key );
30
- if ( !MWF_Functions::is_empty( $value ) ) {
31
- if ( !preg_match( '/^[ぁ-ゞァ-ヾ  ]*?[ぁ-ゞァ-ヾ]+?[ぁ-ゞァ-ヾ  ]*?$/u', $value ) ) {
32
- $defaults = array(
33
- 'message' => __( 'Please enter with a Japanese Hiragana or Katakana.', 'mw-wp-form' )
34
- );
35
- $options = array_merge( $defaults, $options );
36
- return $options['message'];
37
- }
38
  }
 
 
 
 
 
 
39
  }
40
 
41
  /**
42
- * 設定パネルに追加
43
  *
44
- * @param numeric $key バリデーションルールセットの識別番号
45
- * @param array $value バリデーションルールセットの内容
 
46
  */
47
  public function admin( $key, $value ) {
48
  ?>
49
- <label><input type="checkbox" <?php checked( $value[$this->getName()], 1 ); ?> name="<?php echo MWF_Config::NAME; ?>[validation][<?php echo $key; ?>][<?php echo esc_attr( $this->getName() ); ?>]" value="1" /><?php esc_html_e( 'Japanese Hiragana or Katakana', 'mw-wp-form' ); ?></label>
50
  <?php
51
  }
52
  }
1
  <?php
2
  /**
3
  * Name : MW WP Form Validation Rule Kana
4
+ * Version : 2.0.0
 
5
  * Author : Key Nomura, Takashi Kitajima
6
  * Author URI : http://mypacecreator.net/
7
  * Created : September 1, 2015
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Validation_Rule_Kana extends MW_WP_Form_Abstract_Validation_Rule {
13
 
14
  /**
15
+ * Validation rule name
16
  * @var string
17
  */
18
  protected $name = 'kana';
19
 
20
  /**
21
+ * Validation process
22
  *
23
+ * @param string $name
24
  * @param array $option
25
+ * @return string Error message
26
  */
27
+ public function rule( $name, array $options = array() ) {
28
+ $value = $this->Data->get( $name );
29
+
30
+ if ( MWF_Functions::is_empty( $value ) ) {
31
+ return;
32
+ }
33
+
34
+ if ( preg_match( '/^[ぁ-ゞァ-ヾ  ]*?[ぁ-ゞァ-ヾ]+?[ぁ-ゞァ-ヾ  ]*?$/u', $value ) ) {
35
+ return;
 
36
  }
37
+
38
+ $defaults = array(
39
+ 'message' => __( 'Please enter with a Japanese Hiragana or Katakana.', 'mw-wp-form' )
40
+ );
41
+ $options = array_merge( $defaults, $options );
42
+ return $options['message'];
43
  }
44
 
45
  /**
46
+ * Add setting field to validation rule setting panel
47
  *
48
+ * @param numeric $key ID of validation rule
49
+ * @param array $value Content of validation rule
50
+ * @return void
51
  */
52
  public function admin( $key, $value ) {
53
  ?>
54
+ <label><input type="checkbox" <?php checked( $value[ $this->getName() ], 1 ); ?> name="<?php echo MWF_Config::NAME; ?>[validation][<?php echo $key; ?>][<?php echo esc_attr( $this->getName() ); ?>]" value="1" /><?php esc_html_e( 'Japanese Hiragana or Katakana', 'mw-wp-form' ); ?></label>
55
  <?php
56
  }
57
  }
classes/validation-rules/class.katakana.php CHANGED
@@ -1,52 +1,56 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Validation Rule Katakana
4
- * Description: 値がカタカナ
5
- * Version : 1.1.1
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : July 21, 2014
9
- * Modified : April 1, 2015
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Validation_Rule_Katakana extends MW_WP_Form_Abstract_Validation_Rule {
14
 
15
  /**
16
- * バリデーションルール名を指定
17
  * @var string
18
  */
19
  protected $name = 'katakana';
20
 
21
  /**
22
- * バリデーションチェック
23
  *
24
- * @param string $key name属性
25
  * @param array $option
26
- * @return string エラーメッセージ
27
  */
28
- public function rule( $key, array $options = array() ) {
29
- $value = $this->Data->get( $key );
30
- if ( !MWF_Functions::is_empty( $value ) ) {
31
- if ( !preg_match( '/^[ァ-ヾ  ]*?[ァ-ヾ]+?[ァ-ヾ  ]*?$/u', $value ) ) {
32
- $defaults = array(
33
- 'message' => __( 'Please enter with a Japanese Katakana.', 'mw-wp-form' )
34
- );
35
- $options = array_merge( $defaults, $options );
36
- return $options['message'];
37
- }
38
  }
 
 
 
 
 
 
 
 
 
 
39
  }
40
 
41
  /**
42
- * 設定パネルに追加
43
  *
44
- * @param numeric $key バリデーションルールセットの識別番号
45
- * @param array $value バリデーションルールセットの内容
 
46
  */
47
  public function admin( $key, $value ) {
48
  ?>
49
- <label><input type="checkbox" <?php checked( $value[$this->getName()], 1 ); ?> name="<?php echo MWF_Config::NAME; ?>[validation][<?php echo $key; ?>][<?php echo esc_attr( $this->getName() ); ?>]" value="1" /><?php esc_html_e( 'Japanese Katakana', 'mw-wp-form' ); ?></label>
50
  <?php
51
  }
52
- }
1
  <?php
2
  /**
3
  * Name : MW WP Form Validation Rule Katakana
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : July 21, 2014
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Validation_Rule_Katakana extends MW_WP_Form_Abstract_Validation_Rule {
13
 
14
  /**
15
+ * Validation rule name
16
  * @var string
17
  */
18
  protected $name = 'katakana';
19
 
20
  /**
21
+ * Validation process
22
  *
23
+ * @param string $name
24
  * @param array $option
25
+ * @return string Error message
26
  */
27
+ public function rule( $name, array $options = array() ) {
28
+ $value = $this->Data->get( $name );
29
+ if ( MWF_Functions::is_empty( $value ) ) {
30
+ return;
 
 
 
 
 
 
31
  }
32
+
33
+ if ( preg_match( '/^[ァ-ヾ  ]*?[ァ-ヾ]+?[ァ-ヾ  ]*?$/u', $value ) ) {
34
+ return;
35
+ }
36
+
37
+ $defaults = array(
38
+ 'message' => __( 'Please enter with a Japanese Katakana.', 'mw-wp-form' )
39
+ );
40
+ $options = array_merge( $defaults, $options );
41
+ return $options['message'];
42
  }
43
 
44
  /**
45
+ * Add setting field to validation rule setting panel
46
  *
47
+ * @param numeric $key ID of validation rule
48
+ * @param array $value Content of validation rule
49
+ * @return void
50
  */
51
  public function admin( $key, $value ) {
52
  ?>
53
+ <label><input type="checkbox" <?php checked( $value[ $this->getName() ], 1 ); ?> name="<?php echo MWF_Config::NAME; ?>[validation][<?php echo $key; ?>][<?php echo esc_attr( $this->getName() ); ?>]" value="1" /><?php esc_html_e( 'Japanese Katakana', 'mw-wp-form' ); ?></label>
54
  <?php
55
  }
56
+ }
classes/validation-rules/class.mail.php CHANGED
@@ -1,52 +1,57 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Validation Rule Mail
4
- * Description: 値がメールアドレス
5
- * Version : 1.1.1
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : July 21, 2014
9
- * Modified : April 1, 2015
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Validation_Rule_Mail extends MW_WP_Form_Abstract_Validation_Rule {
14
 
15
  /**
16
- * バリデーションルール名を指定
17
  * @var string
18
  */
19
  protected $name = 'mail';
20
 
21
  /**
22
- * バリデーションチェック
23
  *
24
- * @param string $key name属性
25
  * @param array $option
26
- * @return string エラーメッセージ
27
  */
28
- public function rule( $key, array $options = array() ) {
29
- $value = $this->Data->get( $key );
30
- if ( !MWF_Functions::is_empty( $value ) ) {
31
- if ( !preg_match( '/^[^@]+@([^@^\.]+\.)+[^@^\.]+$/', $value ) ) {
32
- $defaults = array(
33
- 'message' => __( 'This is not the format of a mail address.', 'mw-wp-form' )
34
- );
35
- $options = array_merge( $defaults, $options );
36
- return $options['message'];
37
- }
38
  }
 
 
 
 
 
 
39
  }
40
 
41
  /**
42
- * 設定パネルに追加
43
  *
44
- * @param numeric $key バリデーションルールセットの識別番号
45
- * @param array $value バリデーションルールセットの内容
 
46
  */
47
  public function admin( $key, $value ) {
48
  ?>
49
- <label><input type="checkbox" <?php checked( $value[$this->getName()], 1 ); ?> name="<?php echo MWF_Config::NAME; ?>[validation][<?php echo $key; ?>][<?php echo esc_attr( $this->getName() ); ?>]" value="1" /><?php esc_html_e( 'E-mail', 'mw-wp-form' ); ?></label>
50
  <?php
51
  }
52
- }
1
  <?php
2
  /**
3
  * Name : MW WP Form Validation Rule Mail
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : July 21, 2014
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Validation_Rule_Mail extends MW_WP_Form_Abstract_Validation_Rule {
13
 
14
  /**
15
+ * Validation rule name
16
  * @var string
17
  */
18
  protected $name = 'mail';
19
 
20
  /**
21
+ * Validation process
22
  *
23
+ * @param string $name
24
  * @param array $option
25
+ * @return string Error message
26
  */
27
+ public function rule( $name, array $options = array() ) {
28
+ $value = $this->Data->get( $name );
29
+
30
+ if ( MWF_Functions::is_empty( $value ) ) {
31
+ return;
32
+ }
33
+
34
+ if ( preg_match( '/^[^@]+@([^@^\.]+\.)+[^@^\.]+$/', $value ) ) {
35
+ return;
 
36
  }
37
+
38
+ $defaults = array(
39
+ 'message' => __( 'This is not the format of a mail address.', 'mw-wp-form' )
40
+ );
41
+ $options = array_merge( $defaults, $options );
42
+ return $options['message'];
43
  }
44
 
45
  /**
46
+ * Add setting field to validation rule setting panel
47
  *
48
+ * @param numeric $key ID of validation rule
49
+ * @param array $value Content of validation rule
50
+ * @return void
51
  */
52
  public function admin( $key, $value ) {
53
  ?>
54
+ <label><input type="checkbox" <?php checked( $value[ $this->getName() ], 1 ); ?> name="<?php echo MWF_Config::NAME; ?>[validation][<?php echo $key; ?>][<?php echo esc_attr( $this->getName() ); ?>]" value="1" /><?php esc_html_e( 'E-mail', 'mw-wp-form' ); ?></label>
55
  <?php
56
  }
57
+ }
classes/validation-rules/class.maximagesize.php CHANGED
@@ -1,64 +1,57 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Validation Rule MaxImageSize
4
- * Description: 画像サイズが指定したサイズ以内
5
- * Version : 1.0.0
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : April 4, 2016
9
- * Modified :
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Validation_Rule_MaxImageSize extends MW_WP_Form_Abstract_Validation_Rule {
14
 
15
  /**
16
- * バリデーションルール名を指定
17
  * @var string
18
  */
19
  protected $name = 'maxfilesize';
20
 
21
  /**
22
- * バリデーションチェック
23
  *
24
- * @param string $key name属性
25
  * @param array $option
26
- * @return string エラーメッセージ
27
  */
28
- public function rule( $key, array $options = array() ) {
29
- $value = $this->Data->get( $key );
30
- if ( !$value ) {
 
31
  return;
32
  }
33
 
34
- if ( !MWF_Functions::is_numeric( $options['width'] ) || !MWF_Functions::is_numeric( $options['width'] ) ) {
35
  return;
36
  }
37
 
38
- /**
39
- * 送信ボタンを押して次のページが表示されるまでの間、
40
- * 1.そのページに post されてチェック
41
- * 2.リダイレクト先でチェック
42
- * の2度チェックされる。画像サイズのチェックは画像が存在しないとできないが、1.でエラーだった場合
43
- * ファイルがアップロードされないので 2.でスルーされ画面表示時にはエラーも出ない。
44
- */
45
  $upload_file_keys = $this->Data->get_post_value_by_key( MWF_Config::UPLOAD_FILE_KEYS );
46
  $upload_files = $this->Data->get_post_value_by_key( MWF_Config::UPLOAD_FILES );
47
  $is_error = false;
48
 
49
- if ( !is_array( $upload_file_keys ) ) {
50
  $upload_file_keys = array();
51
  }
52
 
53
- if ( !is_array( $upload_files ) ) {
54
  $upload_files = array();
55
  }
56
 
57
- // アップロード直後のチェック
58
- if ( !in_array( $key, $upload_file_keys ) && array_key_exists( $key, $upload_files ) ) {
59
- $file_path = $upload_files[$key]['tmp_name'];
60
  }
61
- // アップロード済みの場合のチェック
62
  else {
63
  $file_path = MWF_Functions::fileurl_to_path( $value );
64
  }
@@ -66,7 +59,7 @@ class MW_WP_Form_Validation_Rule_MaxImageSize extends MW_WP_Form_Abstract_Valida
66
  if ( file_exists( $file_path ) && exif_imagetype( $file_path ) ) {
67
  $imagesize = getimagesize( $file_path );
68
  } else {
69
- if ( !in_array( $key, $upload_file_keys ) ) {
70
  $is_error = true;
71
  }
72
  }
@@ -83,20 +76,21 @@ class MW_WP_Form_Validation_Rule_MaxImageSize extends MW_WP_Form_Abstract_Valida
83
  }
84
 
85
  /**
86
- * 設定パネルに追加
87
  *
88
- * @param numeric $key バリデーションルールセットの識別番号
89
- * @param array $value バリデーションルールセットの内容
 
90
  */
91
  public function admin( $key, $value ) {
92
  $width = '';
93
  $height = '';
94
- if ( is_array( $value[$this->getName()] ) ) {
95
- if ( isset( $value[$this->getName()]['width'] ) ) {
96
- $width = $value[$this->getName()]['width'];
97
  }
98
- if ( isset( $value[$this->getName()]['height'] ) ) {
99
- $height = $value[$this->getName()]['height'];
100
  }
101
  }
102
  ?>
1
  <?php
2
  /**
3
  * Name : MW WP Form Validation Rule MaxImageSize
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : April 4, 2016
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Validation_Rule_MaxImageSize extends MW_WP_Form_Abstract_Validation_Rule {
13
 
14
  /**
15
+ * Validation rule name
16
  * @var string
17
  */
18
  protected $name = 'maxfilesize';
19
 
20
  /**
21
+ * Validation process
22
  *
23
+ * @param string $name
24
  * @param array $option
25
+ * @return string Error message
26
  */
27
+ public function rule( $name, array $options = array() ) {
28
+ $value = $this->Data->get( $name );
29
+
30
+ if ( ! $value ) {
31
  return;
32
  }
33
 
34
+ if ( ! MWF_Functions::is_numeric( $options['width'] ) || ! MWF_Functions::is_numeric( $options['width'] ) ) {
35
  return;
36
  }
37
 
 
 
 
 
 
 
 
38
  $upload_file_keys = $this->Data->get_post_value_by_key( MWF_Config::UPLOAD_FILE_KEYS );
39
  $upload_files = $this->Data->get_post_value_by_key( MWF_Config::UPLOAD_FILES );
40
  $is_error = false;
41
 
42
+ if ( ! is_array( $upload_file_keys ) ) {
43
  $upload_file_keys = array();
44
  }
45
 
46
+ if ( ! is_array( $upload_files ) ) {
47
  $upload_files = array();
48
  }
49
 
50
+ // Check after upload
51
+ if ( ! in_array( $name, $upload_file_keys ) && array_key_exists( $name, $upload_files ) ) {
52
+ $file_path = $upload_files[ $name ]['tmp_name'];
53
  }
54
+ // Check if uploaded
55
  else {
56
  $file_path = MWF_Functions::fileurl_to_path( $value );
57
  }
59
  if ( file_exists( $file_path ) && exif_imagetype( $file_path ) ) {
60
  $imagesize = getimagesize( $file_path );
61
  } else {
62
+ if ( ! in_array( $name, $upload_file_keys ) ) {
63
  $is_error = true;
64
  }
65
  }
76
  }
77
 
78
  /**
79
+ * Add setting field to validation rule setting panel
80
  *
81
+ * @param numeric $key ID of validation rule
82
+ * @param array $value Content of validation rule
83
+ * @return void
84
  */
85
  public function admin( $key, $value ) {
86
  $width = '';
87
  $height = '';
88
+ if ( is_array( $value[ $this->getName() ] ) ) {
89
+ if ( isset( $value[ $this->getName() ]['width'] ) ) {
90
+ $width = $value[ $this->getName() ]['width'];
91
  }
92
+ if ( isset( $value[ $this->getName() ]['height'] ) ) {
93
+ $height = $value[ $this->getName() ]['height'];
94
  }
95
  }
96
  ?>
classes/validation-rules/class.minimagesize.php CHANGED
@@ -1,64 +1,57 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Validation Rule MinImageSize
4
- * Description: 画像サイズが指定したサイズ以内
5
- * Version : 1.0.0
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : April 4, 2016
9
- * Modified :
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Validation_Rule_MinImageSize extends MW_WP_Form_Abstract_Validation_Rule {
14
 
15
  /**
16
- * バリデーションルール名を指定
17
  * @var string
18
  */
19
  protected $name = 'minfilesize';
20
 
21
  /**
22
- * バリデーションチェック
23
  *
24
- * @param string $key name属性
25
  * @param array $option
26
- * @return string エラーメッセージ
27
  */
28
- public function rule( $key, array $options = array() ) {
29
- $value = $this->Data->get( $key );
30
- if ( !$value ) {
 
31
  return;
32
  }
33
 
34
- if ( !MWF_Functions::is_numeric( $options['width'] ) || !MWF_Functions::is_numeric( $options['width'] ) ) {
35
  return;
36
  }
37
 
38
- /**
39
- * 送信ボタンを押して次のページが表示されるまでの間、
40
- * 1.そのページに post されてチェック
41
- * 2.リダイレクト先でチェック
42
- * の2度チェックされる。画像サイズのチェックは画像が存在しないとできないが、1.でエラーだった場合
43
- * ファイルがアップロードされないので 2.でスルーされ画面表示時にはエラーも出ない。
44
- */
45
  $upload_file_keys = $this->Data->get_post_value_by_key( MWF_Config::UPLOAD_FILE_KEYS );
46
  $upload_files = $this->Data->get_post_value_by_key( MWF_Config::UPLOAD_FILES );
47
  $is_error = false;
48
 
49
- if ( !is_array( $upload_file_keys ) ) {
50
  $upload_file_keys = array();
51
  }
52
 
53
- if ( !is_array( $upload_files ) ) {
54
  $upload_files = array();
55
  }
56
 
57
- // アップロード直後のチェック
58
- if ( !in_array( $key, $upload_file_keys ) && array_key_exists( $key, $upload_files ) ) {
59
- $file_path = $upload_files[$key]['tmp_name'];
60
  }
61
- // アップロード済みの場合のチェック
62
  else {
63
  $file_path = MWF_Functions::fileurl_to_path( $value );
64
  }
@@ -66,7 +59,7 @@ class MW_WP_Form_Validation_Rule_MinImageSize extends MW_WP_Form_Abstract_Valida
66
  if ( file_exists( $file_path ) && exif_imagetype( $file_path ) ) {
67
  $imagesize = getimagesize( $file_path );
68
  } else {
69
- if ( !in_array( $key, $upload_file_keys ) ) {
70
  $is_error = true;
71
  }
72
  }
@@ -83,20 +76,21 @@ class MW_WP_Form_Validation_Rule_MinImageSize extends MW_WP_Form_Abstract_Valida
83
  }
84
 
85
  /**
86
- * 設定パネルに追加
87
  *
88
- * @param numeric $key バリデーションルールセットの識別番号
89
- * @param array $value バリデーションルールセットの内容
 
90
  */
91
  public function admin( $key, $value ) {
92
  $width = '';
93
  $height = '';
94
- if ( is_array( $value[$this->getName()] ) ) {
95
- if ( isset( $value[$this->getName()]['width'] ) ) {
96
- $width = $value[$this->getName()]['width'];
97
  }
98
- if ( isset( $value[$this->getName()]['height'] ) ) {
99
- $height = $value[$this->getName()]['height'];
100
  }
101
  }
102
  ?>
1
  <?php
2
  /**
3
  * Name : MW WP Form Validation Rule MinImageSize
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : April 4, 2016
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Validation_Rule_MinImageSize extends MW_WP_Form_Abstract_Validation_Rule {
13
 
14
  /**
15
+ * Validation rule name
16
  * @var string
17
  */
18
  protected $name = 'minfilesize';
19
 
20
  /**
21
+ * Validation process
22
  *
23
+ * @param string $name
24
  * @param array $option
25
+ * @return string Error message
26
  */
27
+ public function rule( $name, array $options = array() ) {
28
+ $value = $this->Data->get( $name );
29
+
30
+ if ( ! $value ) {
31
  return;
32
  }
33
 
34
+ if ( ! MWF_Functions::is_numeric( $options['width'] ) || ! MWF_Functions::is_numeric( $options['width'] ) ) {
35
  return;
36
  }
37
 
 
 
 
 
 
 
 
38
  $upload_file_keys = $this->Data->get_post_value_by_key( MWF_Config::UPLOAD_FILE_KEYS );
39
  $upload_files = $this->Data->get_post_value_by_key( MWF_Config::UPLOAD_FILES );
40
  $is_error = false;
41
 
42
+ if ( ! is_array( $upload_file_keys ) ) {
43
  $upload_file_keys = array();
44
  }
45
 
46
+ if ( ! is_array( $upload_files ) ) {
47
  $upload_files = array();
48
  }
49
 
50
+ // Check after upload
51
+ if ( ! in_array( $name, $upload_file_keys ) && array_key_exists( $name, $upload_files ) ) {
52
+ $file_path = $upload_files[ $name ]['tmp_name'];
53
  }
54
+ // Check if uploaded
55
  else {
56
  $file_path = MWF_Functions::fileurl_to_path( $value );
57
  }
59
  if ( file_exists( $file_path ) && exif_imagetype( $file_path ) ) {
60
  $imagesize = getimagesize( $file_path );
61
  } else {
62
+ if ( ! in_array( $name, $upload_file_keys ) ) {
63
  $is_error = true;
64
  }
65
  }
76
  }
77
 
78
  /**
79
+ * Add setting field to validation rule setting panel
80
  *
81
+ * @param numeric $key ID of validation rule
82
+ * @param array $value Content of validation rule
83
+ * @return void
84
  */
85
  public function admin( $key, $value ) {
86
  $width = '';
87
  $height = '';
88
+ if ( is_array( $value[ $this->getName() ] ) ) {
89
+ if ( isset( $value[ $this->getName() ]['width'] ) ) {
90
+ $width = $value[ $this->getName() ]['width'];
91
  }
92
+ if ( isset( $value[ $this->getName() ]['height'] ) ) {
93
+ $height = $value[ $this->getName() ]['height'];
94
  }
95
  }
96
  ?>
classes/validation-rules/class.minlength.php CHANGED
@@ -1,56 +1,59 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Validation Rule MinLength
4
- * Description: 値の文字数が範囲内
5
- * Version : 1.1.1
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : July 21, 2014
9
- * Modified : April 1, 2015
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Validation_Rule_MinLength extends MW_WP_Form_Abstract_Validation_Rule {
14
 
15
  /**
16
- * バリデーションルール名を指定
17
  * @var string
18
  */
19
  protected $name = 'minlength';
20
 
21
  /**
22
- * バリデーションチェック
23
  *
24
- * @param string $key name属性
25
  * @param array $option
26
- * @return string エラーメッセージ
27
  */
28
- public function rule( $key, array $options = array() ) {
29
- $value = $this->Data->get( $key );
30
  $value = MWF_Functions::convert_eol( $value );
31
- if ( !MWF_Functions::is_empty( $value ) ) {
32
- $defaults = array(
33
- 'min' => 0,
34
- 'message' => __( 'The number of characters is a few.', 'mw-wp-form' )
35
- );
36
- $options = array_merge( $defaults, $options );
37
- $length = mb_strlen( $value, get_bloginfo( 'charset' ) );
38
- if ( MWF_Functions::is_numeric( $options['min'] ) && $options['min'] > $length ) {
39
- return $options['message'];
40
- }
 
 
 
41
  }
42
  }
43
 
44
  /**
45
- * 設定パネルに追加
46
  *
47
- * @param numeric $key バリデーションルールセットの識別番号
48
- * @param array $value バリデーションルールセットの内容
 
49
  */
50
  public function admin( $key, $value ) {
51
  $min = '';
52
- if ( is_array( $value[$this->getName()] ) && isset( $value[$this->getName()]['min'] ) ) {
53
- $min = $value[$this->getName()]['min'];
54
  }
55
  ?>
56
  <table>
@@ -61,4 +64,4 @@ class MW_WP_Form_Validation_Rule_MinLength extends MW_WP_Form_Abstract_Validatio
61
  </table>
62
  <?php
63
  }
64
- }
1
  <?php
2
  /**
3
  * Name : MW WP Form Validation Rule MinLength
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : July 21, 2014
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Validation_Rule_MinLength extends MW_WP_Form_Abstract_Validation_Rule {
13
 
14
  /**
15
+ * Validation rule name
16
  * @var string
17
  */
18
  protected $name = 'minlength';
19
 
20
  /**
21
+ * Validation process
22
  *
23
+ * @param string $name
24
  * @param array $option
25
+ * @return string Error message
26
  */
27
+ public function rule( $name, array $options = array() ) {
28
+ $value = $this->Data->get( $name );
29
  $value = MWF_Functions::convert_eol( $value );
30
+
31
+ if ( MWF_Functions::is_empty( $value ) ) {
32
+ return;
33
+ }
34
+
35
+ $defaults = array(
36
+ 'min' => 0,
37
+ 'message' => __( 'The number of characters is a few.', 'mw-wp-form' )
38
+ );
39
+ $options = array_merge( $defaults, $options );
40
+ $length = mb_strlen( $value, get_bloginfo( 'charset' ) );
41
+ if ( MWF_Functions::is_numeric( $options['min'] ) && $options['min'] > $length ) {
42
+ return $options['message'];
43
  }
44
  }
45
 
46
  /**
47
+ * Add setting field to validation rule setting panel
48
  *
49
+ * @param numeric $key ID of validation rule
50
+ * @param array $value Content of validation rule
51
+ * @return void
52
  */
53
  public function admin( $key, $value ) {
54
  $min = '';
55
+ if ( is_array( $value[ $this->getName() ] ) && isset( $value[ $this->getName() ]['min'] ) ) {
56
+ $min = $value[ $this->getName() ]['min'];
57
  }
58
  ?>
59
  <table>
64
  </table>
65
  <?php
66
  }
67
+ }
classes/validation-rules/class.month.php CHANGED
@@ -1,55 +1,59 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Validation Rule Month
4
- * Description: 日付(年月)が正しいかどうか
5
- * Version : 1.0.0
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : March 25, 2017
9
- * Modified :
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Validation_Rule_Month extends MW_WP_Form_Abstract_Validation_Rule {
14
 
15
  /**
16
- * バリデーションルール名を指定
17
  * @var string
18
  */
19
  protected $name = 'month';
20
 
21
  /**
22
- * バリデーションチェック
23
  *
24
- * @param string $key name属性
25
  * @param array $option
26
- * @return string エラーメッセージ
27
  */
28
- public function rule( $key, array $options = array() ) {
29
- $value = $this->Data->get( $key );
30
- if ( !MWF_Functions::is_empty( $value ) ) {
31
- $defaults = array(
32
- 'message' => __( 'This is not the format of a date (Year/Month).', 'mw-wp-form' )
33
- );
34
- $options = array_merge( $defaults, $options );
35
- $timestamp = strtotime( $value );
36
- if ( !$timestamp ) {
37
- $timestamp = $this->convert_jpdate_to_timestamp( $value );
38
- }
39
- if ( !$timestamp ) {
40
- return $options['message'];
41
- }
42
- $year = date( 'Y', $timestamp );
43
- $month = date( 'm', $timestamp );
44
- $checkdate = checkdate( $month, 1, $year );
45
- if ( !$timestamp || !$checkdate || preg_match( '/^[a-zA-Z]$/', $value ) || preg_match( '/^\s+$/', $value ) ) {
46
- return $options['message'];
47
- }
 
 
 
 
 
48
  }
49
  }
50
 
51
  /**
52
- * 日本語表記の日付をタイムスタンプに変換する
53
  *
54
  * @param string $jpdate yyyy年mm月
55
  * @return string|false
@@ -63,14 +67,15 @@ class MW_WP_Form_Validation_Rule_Month extends MW_WP_Form_Abstract_Validation_Ru
63
  }
64
 
65
  /**
66
- * 設定パネルに追加
67
  *
68
- * @param numeric $key バリデーションルールセットの識別番号
69
- * @param array $value バリデーションルールセットの内容
 
70
  */
71
  public function admin( $key, $value ) {
72
  ?>
73
- <label><input type="checkbox" <?php checked( $value[$this->getName()], 1 ); ?> name="<?php echo MWF_Config::NAME; ?>[validation][<?php echo $key; ?>][<?php echo esc_attr( $this->getName() ); ?>]" value="1" /><?php esc_html_e( 'Date(Year/Month)', 'mw-wp-form' ); ?></label>
74
  <?php
75
  }
76
  }
1
  <?php
2
  /**
3
  * Name : MW WP Form Validation Rule Month
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : March 25, 2017
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Validation_Rule_Month extends MW_WP_Form_Abstract_Validation_Rule {
13
 
14
  /**
15
+ * Validation rule name
16
  * @var string
17
  */
18
  protected $name = 'month';
19
 
20
  /**
21
+ * Validation process
22
  *
23
+ * @param string $name
24
  * @param array $option
25
+ * @return string Error message
26
  */
27
+ public function rule( $name, array $options = array() ) {
28
+ $value = $this->Data->get( $name );
29
+
30
+ if ( MWF_Functions::is_empty( $value ) ) {
31
+ return;
32
+ }
33
+
34
+ $defaults = array(
35
+ 'message' => __( 'This is not the format of a date (Year/Month).', 'mw-wp-form' )
36
+ );
37
+ $options = array_merge( $defaults, $options );
38
+ $timestamp = strtotime( $value );
39
+ if ( ! $timestamp ) {
40
+ $timestamp = $this->convert_jpdate_to_timestamp( $value );
41
+ }
42
+ if ( ! $timestamp ) {
43
+ return $options['message'];
44
+ }
45
+
46
+ $year = date( 'Y', $timestamp );
47
+ $month = date( 'm', $timestamp );
48
+ $checkdate = checkdate( $month, 1, $year );
49
+
50
+ if ( ! $timestamp || ! $checkdate || preg_match( '/^[a-zA-Z]$/', $value ) || preg_match( '/^\s+$/', $value ) ) {
51
+ return $options['message'];
52
  }
53
  }
54
 
55
  /**
56
+ * Convert Japanese notation date to time stamp
57
  *
58
  * @param string $jpdate yyyy年mm月
59
  * @return string|false
67
  }
68
 
69
  /**
70
+ * Add setting field to validation rule setting panel
71
  *
72
+ * @param numeric $key ID of validation rule
73
+ * @param array $value Content of validation rule
74
+ * @return void
75
  */
76
  public function admin( $key, $value ) {
77
  ?>
78
+ <label><input type="checkbox" <?php checked( $value[ $this->getName() ], 1 ); ?> name="<?php echo MWF_Config::NAME; ?>[validation][<?php echo $key; ?>][<?php echo esc_attr( $this->getName() ); ?>]" value="1" /><?php esc_html_e( 'Date(Year/Month)', 'mw-wp-form' ); ?></label>
79
  <?php
80
  }
81
  }
classes/validation-rules/class.noempty.php CHANGED
@@ -1,50 +1,53 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Validation Rule noEmpty
4
- * Description: 値が空ではない(0は許可)
5
- * Version : 1.1.1
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : July 21, 2014
9
- * Modified : April 1, 2015
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Validation_Rule_noEmpty extends MW_WP_Form_Abstract_Validation_Rule {
14
 
15
  /**
16
- * バリデーションルール名を指定
17
  * @var string
18
  */
19
  protected $name = 'noempty';
20
 
21
  /**
22
- * バリデーションチェック
23
  *
24
- * @param string $key name属性
25
  * @param array $option
26
- * @return string エラーメッセージ
27
  */
28
- public function rule( $key, array $options = array() ) {
29
- $value = $this->Data->get( $key );
30
- if ( !is_null( $value ) && MWF_Functions::is_empty( $value ) ) {
31
- $defaults = array(
32
- 'message' => __( 'Please enter.', 'mw-wp-form' )
33
- );
34
- $options = array_merge( $defaults, $options );
35
- return $options['message'];
36
  }
 
 
 
 
 
 
37
  }
38
 
39
  /**
40
- * 設定パネルに追加
41
  *
42
- * @param numeric $key バリデーションルールセットの識別番号
43
- * @param array $value バリデーションルールセットの内容
 
44
  */
45
  public function admin( $key, $value ) {
46
  ?>
47
- <label><input type="checkbox" <?php checked( $value[$this->getName()], 1 ); ?> name="<?php echo MWF_Config::NAME; ?>[validation][<?php echo $key; ?>][<?php echo esc_attr( $this->getName() ); ?>]" value="1" /><?php esc_html_e( 'No empty', 'mw-wp-form' ); ?></label>
48
  <?php
49
  }
50
- }
1
  <?php
2
  /**
3
  * Name : MW WP Form Validation Rule noEmpty
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : July 21, 2014
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Validation_Rule_noEmpty extends MW_WP_Form_Abstract_Validation_Rule {
13
 
14
  /**
15
+ * Validation rule name
16
  * @var string
17
  */
18
  protected $name = 'noempty';
19
 
20
  /**
21
+ * Validation process
22
  *
23
+ * @param string $name
24
  * @param array $option
25
+ * @return string Error message
26
  */
27
+ public function rule( $name, array $options = array() ) {
28
+ $value = $this->Data->get( $name );
29
+
30
+ if ( is_null( $value ) || ! MWF_Functions::is_empty( $value ) ) {
31
+ return;
 
 
 
32
  }
33
+
34
+ $defaults = array(
35
+ 'message' => __( 'Please enter.', 'mw-wp-form' )
36
+ );
37
+ $options = array_merge( $defaults, $options );
38
+ return $options['message'];
39
  }
40
 
41
  /**
42
+ * Add setting field to validation rule setting panel
43
  *
44
+ * @param numeric $key ID of validation rule
45
+ * @param array $value Content of validation rule
46
+ * @return void
47
  */
48
  public function admin( $key, $value ) {
49
  ?>
50
+ <label><input type="checkbox" <?php checked( $value[ $this->getName() ], 1 ); ?> name="<?php echo MWF_Config::NAME; ?>[validation][<?php echo $key; ?>][<?php echo esc_attr( $this->getName() ); ?>]" value="1" /><?php esc_html_e( 'No empty', 'mw-wp-form' ); ?></label>
51
  <?php
52
  }
53
+ }
classes/validation-rules/class.nofalse.php CHANGED
@@ -1,47 +1,50 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Validation Rule noFalse
4
- * Description: 値が空ではない(0も不可)
5
- * Version : 1.1.1
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : July 21, 2014
9
- * Modified : April 1, 2015
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Validation_Rule_noFalse extends MW_WP_Form_Abstract_Validation_Rule {
14
 
15
  /**
16
- * バリデーションルール名を指定
17
  * @var string
18
  */
19
  protected $name = 'nofalse';
20
 
21
  /**
22
- * バリデーションチェック
23
  *
24
- * @param string $key name属性
25
  * @param array $option
26
- * @return string エラーメッセージ
27
  */
28
- public function rule( $key, array $options = array() ) {
29
- $value = $this->Data->get( $key );
30
- if ( !is_null( $value ) && empty( $value ) ) {
31
- $defaults = array(
32
- 'message' => __( 'Please enter.', 'mw-wp-form' )
33
- );
34
- $options = array_merge( $defaults, $options );
35
- return $options['message'];
36
  }
 
 
 
 
 
 
37
  }
38
 
39
  /**
40
- * 設定パネルに追加
41
  *
42
- * @param numeric $key バリデーションルールセットの識別番号
43
- * @param array $value バリデーションルールセットの内容
 
44
  */
45
  public function admin( $key, $value ) {
46
  }
47
- }
1
  <?php
2
  /**
3
  * Name : MW WP Form Validation Rule noFalse
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : July 21, 2014
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Validation_Rule_noFalse extends MW_WP_Form_Abstract_Validation_Rule {
13
 
14
  /**
15
+ * Validation rule name
16
  * @var string
17
  */
18
  protected $name = 'nofalse';
19
 
20
  /**
21
+ * Validation process
22
  *
23
+ * @param string $name
24
  * @param array $option
25
+ * @return string Error message
26
  */
27
+ public function rule( $name, array $options = array() ) {
28
+ $value = $this->Data->get( $name );
29
+
30
+ if ( is_null( $value ) || ! empty( $value ) ) {
31
+ return;
 
 
 
32
  }
33
+
34
+ $defaults = array(
35
+ 'message' => __( 'Please enter.', 'mw-wp-form' )
36
+ );
37
+ $options = array_merge( $defaults, $options );
38
+ return $options['message'];
39
  }
40
 
41
  /**
42
+ * Add setting field to validation rule setting panel
43
  *
44
+ * @param numeric $key ID of validation rule
45
+ * @param array $value Content of validation rule
46
+ * @return void
47
  */
48
  public function admin( $key, $value ) {
49
  }
50
+ }
classes/validation-rules/class.numeric.php CHANGED
@@ -1,52 +1,57 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Validation Rule Numeric
4
- * Description: 値が数値
5
- * Version : 1.1.1
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : July 21, 2014
9
- * Modified : April 1, 2015
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Validation_Rule_Numeric extends MW_WP_Form_Abstract_Validation_Rule {
14
 
15
  /**
16
- * バリデーションルール名を指定
17
  * @var string
18
  */
19
  protected $name = 'numeric';
20
 
21
  /**
22
- * バリデーションチェック
23
  *
24
- * @param string $key name属性
25
  * @param array $option
26
- * @return string エラーメッセージ
27
  */
28
- public function rule( $key, array $options = array() ) {
29
- $value = $this->Data->get( $key );
30
- if ( !MWF_Functions::is_empty( $value ) ) {
31
- if ( !preg_match( '/^[0-9]+$/', $value ) ) {
32
- $defaults = array(
33
- 'message' => __( 'Please enter with a half-width number.', 'mw-wp-form' )
34
- );
35
- $options = array_merge( $defaults, $options );
36
- return $options['message'];
37
- }
38
  }
 
 
 
 
 
 
39
  }
40
 
41
  /**
42
- * 設定パネルに追加
43
  *
44
- * @param numeric $key バリデーションルールセットの識別番号
45
- * @param array $value バリデーションルールセットの内容
 
46
  */
47
  public function admin( $key, $value ) {
48
  ?>
49
- <label><input type="checkbox" <?php checked( $value[$this->getName()], 1 ); ?> name="<?php echo MWF_Config::NAME; ?>[validation][<?php echo $key; ?>][<?php echo esc_attr( $this->getName() ); ?>]" value="1" /><?php esc_html_e( 'Numeric', 'mw-wp-form' ); ?></label>
50
  <?php
51
  }
52
- }
1
  <?php
2
  /**
3
  * Name : MW WP Form Validation Rule Numeric
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : July 21, 2014
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Validation_Rule_Numeric extends MW_WP_Form_Abstract_Validation_Rule {
13
 
14
  /**
15
+ * Validation rule name
16
  * @var string
17
  */
18
  protected $name = 'numeric';
19
 
20
  /**
21
+ * Validation process
22
  *
23
+ * @param string $name
24
  * @param array $option
25
+ * @return string Error message
26
  */
27
+ public function rule( $name, array $options = array() ) {
28
+ $value = $this->Data->get( $name );
29
+
30
+ if ( MWF_Functions::is_empty( $value ) ) {
31
+ return;
32
+ }
33
+
34
+ if ( preg_match( '/^[0-9]+$/', $value ) ) {
35
+ return;
 
36
  }
37
+
38
+ $defaults = array(
39
+ 'message' => __( 'Please enter with a half-width number.', 'mw-wp-form' )
40
+ );
41
+ $options = array_merge( $defaults, $options );
42
+ return $options['message'];
43
  }
44
 
45
  /**
46
+ * Add setting field to validation rule setting panel
47
  *
48
+ * @param numeric $key ID of validation rule
49
+ * @param array $value Content of validation rule
50
+ * @return void
51
  */
52
  public function admin( $key, $value ) {
53
  ?>
54
+ <label><input type="checkbox" <?php checked( $value[ $this->getName() ], 1 ); ?> name="<?php echo MWF_Config::NAME; ?>[validation][<?php echo $key; ?>][<?php echo esc_attr( $this->getName() ); ?>]" value="1" /><?php esc_html_e( 'Numeric', 'mw-wp-form' ); ?></label>
55
  <?php
56
  }
57
+ }
classes/validation-rules/class.required.php CHANGED
@@ -1,36 +1,36 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Validation Rule Required
4
- * Description: 値が存在する
5
- * Version : 1.1.0
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : July 21, 2014
9
- * Modified : December 31, 2014
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Validation_Rule_Required extends MW_WP_Form_Abstract_Validation_Rule {
14
 
15
  /**
16
- * バリデーションルール名を指定
17
  * @var string
18
  */
19
  protected $name = 'required';
20
 
21
  /**
22
- * バリデーションチェック
23
  *
24
- * @param string $key name属性
25
  * @param array $option
26
- * @return string エラーメッセージ
27
  */
28
- public function rule( $key, array $options = array() ) {
29
- $value = $this->Data->get( $key );
30
- // 値が存在するとき、もしくは存在しないけど他のデータもない(=フォーム送信自体されていない)ときはエラーではない
31
- if ( !is_null( $value ) || is_null( $value ) && !$this->Data->gets() ) {
32
  return;
33
  }
 
34
  $defaults = array(
35
  'message' => __( 'This is required.', 'mw-wp-form' )
36
  );
@@ -39,14 +39,15 @@ class MW_WP_Form_Validation_Rule_Required extends MW_WP_Form_Abstract_Validation
39
  }
40
 
41
  /**
42
- * 設定パネルに追加
43
  *
44
- * @param numeric $key バリデーションルールセットの識別番号
45
- * @param array $value バリデーションルールセットの内容
 
46
  */
47
  public function admin( $key, $value ) {
48
  ?>
49
- <label><input type="checkbox" <?php checked( $value[$this->getName()], 1 ); ?> name="<?php echo MWF_Config::NAME; ?>[validation][<?php echo $key; ?>][<?php echo esc_attr( $this->getName() ); ?>]" value="1" /><?php esc_html_e( 'No empty( with checkbox )', 'mw-wp-form' ); ?></label>
50
  <?php
51
  }
52
- }
1
  <?php
2
  /**
3
  * Name : MW WP Form Validation Rule Required
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : July 21, 2014
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Validation_Rule_Required extends MW_WP_Form_Abstract_Validation_Rule {
13
 
14
  /**
15
+ * Validation rule name
16
  * @var string
17
  */
18
  protected $name = 'required';
19
 
20
  /**
21
+ * Validation process
22
  *
23
+ * @param string $name
24
  * @param array $option
25
+ * @return string Error message
26
  */
27
+ public function rule( $name, array $options = array() ) {
28
+ $value = $this->Data->get( $name );
29
+ // When value exist, or value not exist but other values also not exist(= Not posted)
30
+ if ( ! is_null( $value ) || is_null( $value ) && ! $this->Data->gets() ) {
31
  return;
32
  }
33
+
34
  $defaults = array(
35
  'message' => __( 'This is required.', 'mw-wp-form' )
36
  );
39
  }
40
 
41
  /**
42
+ * Add setting field to validation rule setting panel
43
  *
44
+ * @param numeric $key ID of validation rule
45
+ * @param array $value Content of validation rule
46
+ * @return void
47
  */
48
  public function admin( $key, $value ) {
49
  ?>
50
+ <label><input type="checkbox" <?php checked( $value[ $this->getName() ], 1 ); ?> name="<?php echo MWF_Config::NAME; ?>[validation][<?php echo $key; ?>][<?php echo esc_attr( $this->getName() ); ?>]" value="1" /><?php esc_html_e( 'No empty( with checkbox )', 'mw-wp-form' ); ?></label>
51
  <?php
52
  }
53
+ }
classes/validation-rules/class.tel.php CHANGED
@@ -1,59 +1,80 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Validation Rule Tel
4
- * Description: 値が電話番号
5
- * Version : 1.1.2
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : July 21, 2014
9
- * Modified : April 1, 2015
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Validation_Rule_Tel extends MW_WP_Form_Abstract_Validation_Rule {
14
 
15
  /**
16
- * バリデーションルール名を指定
17
  * @var string
18
  */
19
  protected $name = 'tel';
20
 
21
  /**
22
- * バリデーションチェック
23
  *
24
- * @param string $key name属性
25
  * @param array $option
26
- * @return string エラーメッセージ
27
  */
28
- public function rule( $key, array $options = array() ) {
29
- $value = $this->Data->get( $key );
30
- if ( !MWF_Functions::is_empty( $value ) ) {
31
- $defaults = array(
32
- 'message' => __( 'This is not the format of a tel number.', 'mw-wp-form' )
33
- );
34
- $options = array_merge( $defaults, $options );
35
- if ( ! (
36
- preg_match( '/^\d{2}-\d{4}-\d{4}$/', $value ) ||
37
- preg_match( '/^\d{3}-\d{3,4}-\d{4}$/', $value ) ||
38
- preg_match( '/^\d{4}-\d{2}-\d{4}$/', $value ) ||
39
- preg_match( '/^\d{4}-\d{3}-\d{3}$/', $value ) ||
40
- preg_match( '/^\d{5}-\d{1}-\d{4}$/', $value ) ||
41
- preg_match( '/^\d{10,11}$/', $value )
42
- ) ) {
43
- return $options['message'];
44
- }
 
 
45
  }
 
 
46
  }
47
 
48
  /**
49
- * 設定パネルに追加
50
  *
51
- * @param numeric $key バリデーションルールセットの識別番号
52
- * @param array $value バリデーションルールセットの内容
 
53
  */
54
  public function admin( $key, $value ) {
55
  ?>
56
- <label><input type="checkbox" <?php checked( $value[$this->getName()], 1 ); ?> name="<?php echo MWF_Config::NAME; ?>[validation][<?php echo $key; ?>][<?php echo esc_attr( $this->getName() ); ?>]" value="1" /><?php esc_html_e( 'Tel', 'mw-wp-form' ); ?></label>
57
  <?php
58
  }
59
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
  /**
3
  * Name : MW WP Form Validation Rule Tel
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : July 21, 2014
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Validation_Rule_Tel extends MW_WP_Form_Abstract_Validation_Rule {
13
 
14
  /**
15
+ * Validation rule name
16
  * @var string
17
  */
18
  protected $name = 'tel';
19
 
20
  /**
21
+ * Validation process
22
  *
23
+ * @param string $name
24
  * @param array $option
25
+ * @return string Error message
26
  */
27
+ public function rule( $name, array $options = array() ) {
28
+ $value = $this->Data->get( $name );
29
+
30
+ if ( MWF_Functions::is_empty( $value ) ) {
31
+ return;
32
+ }
33
+
34
+ $defaults = array(
35
+ 'message' => __( 'This is not the format of a tel number.', 'mw-wp-form' )
36
+ );
37
+ $options = array_merge( $defaults, $options );
38
+ if ( preg_match( '/^\d{2}-\d{4}-\d{4}$/', $value )
39
+ || preg_match( '/^\d{3}-\d{3,4}-\d{4}$/', $value )
40
+ || preg_match( '/^\d{4}-\d{2}-\d{4}$/', $value )
41
+ || preg_match( '/^\d{4}-\d{3}-\d{3}$/', $value )
42
+ || preg_match( '/^\d{5}-\d{1}-\d{4}$/', $value )
43
+ || preg_match( '/^\d{10,11}$/', $value ) ) {
44
+
45
+ return;
46
  }
47
+
48
+ return $options['message'];
49
  }
50
 
51
  /**
52
+ * Add setting field to validation rule setting panel
53
  *
54
+ * @param numeric $key ID of validation rule
55
+ * @param array $value Content of validation rule
56
+ * @return void
57
  */
58
  public function admin( $key, $value ) {
59
  ?>
60
+ <label><input type="checkbox" <?php checked( $value[ $this->getName() ], 1 ); ?> name="<?php echo MWF_Config::NAME; ?>[validation][<?php echo $key; ?>][<?php echo esc_attr( $this->getName() ); ?>]" value="1" /><?php esc_html_e( 'Tel', 'mw-wp-form' ); ?></label>
61
  <?php
62
  }
63
+
64
+ /**
65
+ * This validation rule is for Japanese environments only
66
+ *
67
+ * @param array $validation_rules array of MW_WP_Form_Abstract_Validation_Rule
68
+ * @return array $validation_rules
69
+ */
70
+ public function _mwform_validation_rules( array $validation_rules ) {
71
+ $validation_rules = parent::_mwform_validation_rules( $validation_rules );
72
+
73
+ if ( 'ja' === get_locale() ) {
74
+ return $validation_rules;
75
+ }
76
+
77
+ $validation_rules[ $this->getName() ] = '';
78
+ return $validation_rules;
79
+ }
80
+ }
classes/validation-rules/class.url.php CHANGED
@@ -1,52 +1,57 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Validation Rule Url
4
- * Description: 値がURL
5
- * Version : 1.1.1
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : July 21, 2014
9
- * Modified : April 1, 2015
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Validation_Rule_Url extends MW_WP_Form_Abstract_Validation_Rule {
14
 
15
  /**
16
- * バリデーションルール名を指定
17
  * @var string
18
  */
19
  protected $name = 'url';
20
 
21
  /**
22
- * バリデーションチェック
23
  *
24
- * @param string $key name属性
25
  * @param array $option
26
- * @return string エラーメッセージ
27
  */
28
- public function rule( $key, array $options = array() ) {
29
- $value = $this->Data->get( $key );
30
- if ( !MWF_Functions::is_empty( $value ) ) {
31
- if ( !preg_match( '/^https{0,1}:\/\/[^\/]+\.[^\.]+/', $value ) ) {
32
- $defaults = array(
33
- 'message' => __( 'This is not the format of a url.', 'mw-wp-form' )
34
- );
35
- $options = array_merge( $defaults, $options );
36
- return $options['message'];
37
- }
38
  }
 
 
 
 
 
 
39
  }
40
 
41
  /**
42
- * 設定パネルに追加
43
  *
44
- * @param numeric $key バリデーションルールセットの識別番号
45
- * @param array $value バリデーションルールセットの内容
 
46
  */
47
  public function admin( $key, $value ) {
48
  ?>
49
- <label><input type="checkbox" <?php checked( $value[$this->getName()], 1 ); ?> name="<?php echo MWF_Config::NAME; ?>[validation][<?php echo $key; ?>][<?php echo esc_attr( $this->getName() ); ?>]" value="1" /><?php echo esc_html_x( 'URL', 'validatioin', 'mw-wp-form' ); ?></label>
50
  <?php
51
  }
52
  }
1
  <?php
2
  /**
3
  * Name : MW WP Form Validation Rule Url
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : July 21, 2014
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Validation_Rule_Url extends MW_WP_Form_Abstract_Validation_Rule {
13
 
14
  /**
15
+ * Validation rule name
16
  * @var string
17
  */
18
  protected $name = 'url';
19
 
20
  /**
21
+ * Validation process
22
  *
23
+ * @param string $name
24
  * @param array $option
25
+ * @return string Error message
26
  */
27
+ public function rule( $name, array $options = array() ) {
28
+ $value = $this->Data->get( $name );
29
+
30
+ if ( MWF_Functions::is_empty( $value ) ) {
31
+ return;
32
+ }
33
+
34
+ if ( preg_match( '/^https{0,1}:\/\/[^\/]+\.[^\.]+/', $value ) ) {
35
+ return;
 
36
  }
37
+
38
+ $defaults = array(
39
+ 'message' => __( 'This is not the format of a url.', 'mw-wp-form' )
40
+ );
41
+ $options = array_merge( $defaults, $options );
42
+ return $options['message'];
43
  }
44
 
45
  /**
46
+ * Add setting field to validation rule setting panel
47
  *
48
+ * @param numeric $key ID of validation rule
49
+ * @param array $value Content of validation rule
50
+ * @return void
51
  */
52
  public function admin( $key, $value ) {
53
  ?>
54
+ <label><input type="checkbox" <?php checked( $value[ $this->getName() ], 1 ); ?> name="<?php echo MWF_Config::NAME; ?>[validation][<?php echo $key; ?>][<?php echo esc_attr( $this->getName() ); ?>]" value="1" /><?php echo esc_html_x( 'URL', 'validatioin', 'mw-wp-form' ); ?></label>
55
  <?php
56
  }
57
  }
classes/validation-rules/class.zip.php CHANGED
@@ -1,55 +1,76 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Validation Rule Zip
4
- * Description: 値が郵便番号
5
- * Version : 1.1.3
6
  * Author : Takashi Kitajima
7
- * Author URI : http://2inc.org
8
  * Created : July 21, 2014
9
- * Modified : September 23, 2015
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
  class MW_WP_Form_Validation_Rule_Zip extends MW_WP_Form_Abstract_Validation_Rule {
14
 
15
  /**
16
- * バリデーションルール名を指定
17
  * @var string
18
  */
19
  protected $name = 'zip';
20
 
21
  /**
22
- * バリデーションチェック
23
  *
24
- * @param string $key name属性
25
  * @param array $option
26
- * @return string エラーメッセージ
27
  */
28
- public function rule( $key, array $options = array() ) {
29
- $value = $this->Data->get( $key );
30
- if ( !MWF_Functions::is_empty( $value ) ) {
31
- $defaults = array(
32
- 'message' => __( 'This is not the format of a zip code.', 'mw-wp-form' )
33
- );
34
- $options = array_merge( $defaults, $options );
35
- if ( ! (
36
- preg_match( '/^\d{3}-\d{4}$/', $value ) ||
37
- preg_match( '/^\d{7}$/', $value )
38
- ) ) {
39
- return $options['message'];
40
- }
 
 
41
  }
 
 
42
  }
43
 
44
  /**
45
- * 設定パネルに追加
46
  *
47
- * @param numeric $key バリデーションルールセットの識別番号
48
- * @param array $value バリデーションルールセットの内容
 
49
  */
50
  public function admin( $key, $value ) {
51
  ?>
52
- <label><input type="checkbox" <?php checked( $value[$this->getName()], 1 ); ?> name="<?php echo MWF_Config::NAME; ?>[validation][<?php echo $key; ?>][<?php echo esc_attr( $this->getName() ); ?>]" value="1" /><?php esc_html_e( 'Zip Code', 'mw-wp-form' ); ?></label>
53
  <?php
54
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  }
1
  <?php
2
  /**
3
  * Name : MW WP Form Validation Rule Zip
4
+ * Version : 2.0.0
 
5
  * Author : Takashi Kitajima
6
+ * Author URI : https://2inc.org
7
  * Created : July 21, 2014
8
+ * Modified : May 30, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  class MW_WP_Form_Validation_Rule_Zip extends MW_WP_Form_Abstract_Validation_Rule {
13
 
14
  /**
15
+ * Validation rule name
16
  * @var string
17
  */
18
  protected $name = 'zip';
19
 
20
  /**
21
+ * Validation process
22
  *
23
+ * @param string $name
24
  * @param array $option
25
+ * @return string Error message
26
  */
27
+ public function rule( $name, array $options = array() ) {
28
+ $value = $this->Data->get( $name );
29
+
30
+ if ( MWF_Functions::is_empty( $value ) ) {
31
+ return;
32
+ }
33
+
34
+ $defaults = array(
35
+ 'message' => __( 'This is not the format of a zip code.', 'mw-wp-form' )
36
+ );
37
+ $options = array_merge( $defaults, $options );
38
+ if ( preg_match( '/^\d{3}-\d{4}$/', $value )
39
+ || preg_match( '/^\d{7}$/', $value ) ) {
40
+
41
+ return;
42
  }
43
+
44
+ return $options['message'];
45
  }
46
 
47
  /**
48
+ * Add setting field to validation rule setting panel
49
  *
50
+ * @param numeric $key ID of validation rule
51
+ * @param array $value Content of validation rule
52
+ * @return void
53
  */
54
  public function admin( $key, $value ) {
55
  ?>
56
+ <label><input type="checkbox" <?php checked( $value[ $this->getName() ], 1 ); ?> name="<?php echo MWF_Config::NAME; ?>[validation][<?php echo $key; ?>][<?php echo esc_attr( $this->getName() ); ?>]" value="1" /><?php esc_html_e( 'Zip Code', 'mw-wp-form' ); ?></label>
57
  <?php
58
  }
59
+
60
+ /**
61
+ * This validation rule is for Japanese environments only
62
+ *
63
+ * @param array $validation_rules array of MW_WP_Form_Abstract_Validation_Rule
64
+ * @return array $validation_rules
65
+ */
66
+ public function _mwform_validation_rules( array $validation_rules ) {
67
+ $validation_rules = parent::_mwform_validation_rules( $validation_rules );
68
+
69
+ if ( 'ja' === get_locale() ) {
70
+ return $validation_rules;
71
+ }
72
+
73
+ $validation_rules[ $this->getName() ] = '';
74
+ return $validation_rules;
75
+ }
76
  }
css/style.css CHANGED
@@ -59,13 +59,14 @@
59
  * deprecated message
60
  */
61
  .mw-wp-form-deprecated-message {
62
- background: #F5A9A9;
63
- border: #B40404 solid 2px;
64
  border-radius: 5px;
65
- font-size: 10px;
 
66
  line-height: 1.6;
67
- margin: 0 0 5px;
68
- padding: 5px;
69
  }
70
 
71
  /**
59
  * deprecated message
60
  */
61
  .mw-wp-form-deprecated-message {
62
+ background: #fdeeee;
63
+ border: 1px solid #f7bdb8;
64
  border-radius: 5px;
65
+ color: #af4040;
66
+ font-size: 13px;
67
  line-height: 1.6;
68
+ margin: 0 0 10px;
69
+ padding: 1em;
70
  }
71
 
72
  /**
js/scroll.js CHANGED
@@ -1,5 +1,5 @@
1
  jQuery( function( $ ) {
2
- var posy = $( '.mw_wp_form_input, .mw_wp_form_confirm, .mw_wp_form_complete' ).offset().top;
3
  posy = posy + parseInt( mwform_scroll.offset );
4
  $( window ).scrollTop( posy );
5
- } );
1
  jQuery( function( $ ) {
2
+ var posy = $( '.mw_wp_form' ).offset().top;
3
  posy = posy + parseInt( mwform_scroll.offset );
4
  $( window ).scrollTop( posy );
5
+ } );
languages/mw-wp-form-ja.mo DELETED
Binary file
languages/mw-wp-form-ja.po DELETED
@@ -1,984 +0,0 @@
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 3.2.0\n"
6
- "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/mw-wp-form\n"
7
- "POT-Creation-Date: 2017-04-29 22:29+0900\n"
8
- "PO-Revision-Date: 2017-04-29 22:29+0900\n"
9
- "Last-Translator: inc2734 <inc@2inc.org>\n"
10
- "Language-Team: Takashi Kitajima <inc@2inc.org>\n"
11
- "Language: ja\n"
12
- "MIME-Version: 1.0\n"
13
- "Content-Type: text/plain; charset=UTF-8\n"
14
- "Content-Transfer-Encoding: 8bit\n"
15
- "Plural-Forms: nplurals=1; plural=0;\n"
16
- "X-Poedit-SourceCharset: UTF-8\n"
17
- "X-Poedit-Basepath: .\n"
18
- "X-Generator: Poedit 1.8.4\n"
19
- "X-Poedit-KeywordsList: __;_e;_x;esc_html_e;esc_html__;esc_html_x\n"
20
- "X-Poedit-SearchPath-0: ..\n"
21
-
22
- #: classes/controllers/class.admin-list.php:34
23
- msgid "Your contribution is needed for making this plugin better."
24
- msgstr "あなたの貢献があればこのプラグインをもっと良くすることができます。"
25
-
26
- #: classes/controllers/class.admin-list.php:36
27
- msgid "Donate"
28
- msgstr "寄付する"
29
-
30
- #: classes/controllers/class.admin-list.php:66
31
- #: classes/controllers/class.admin.php:89
32
- msgid "Form Key"
33
- msgstr "フォーム識別子"
34
-
35
- #: classes/controllers/class.admin.php:57
36
- msgid "Complete Message"
37
- msgstr "完了画面メッセージ"
38
-
39
- #: classes/controllers/class.admin.php:65
40
- msgid "URL Options"
41
- msgstr "URL設定"
42
-
43
- #: classes/controllers/class.admin.php:73
44
- msgid "Validation Rule"
45
- msgstr "バリデーションルール"
46
-
47
- #: classes/controllers/class.admin.php:81
48
- msgid "Add-ons"
49
- msgstr "アドオン"
50
-
51
- #: classes/controllers/class.admin.php:97
52
- msgid "Automatic Reply Email Options"
53
- msgstr "自動返信メール設定"
54
-
55
- #: classes/controllers/class.admin.php:105
56
- msgid "Admin Email Options"
57
- msgstr "管理者宛メール設定"
58
-
59
- #: classes/controllers/class.admin.php:113
60
- msgid "settings"
61
- msgstr "設定"
62
-
63
- #: classes/controllers/class.admin.php:122
64
- msgid "Style setting"
65
- msgstr "スタイル設定"
66
-
67
- #: classes/controllers/class.contact-data-list.php:117
68
- msgid "Registed Date"
69
- msgstr "登録日時"
70
-
71
- #: classes/controllers/class.contact-data-list.php:118
72
- #: classes/models/class.csv.php:122 templates/contact-data/detail.php:50
73
- msgid "Response Status"
74
- msgstr "対応状況"
75
-
76
- #: classes/controllers/class.contact-data.php:70
77
- msgid "Custom Fields"
78
- msgstr "カスタムフィールド"
79
-
80
- #: classes/form-fields/class.akismet_error.php:30
81
- msgid "Akismet Error"
82
- msgstr "Akismetエラー"
83
-
84
- #: classes/form-fields/class.back-button.php:30
85
- #: classes/form-fields/class.button-back.php:30
86
- msgid "Back Button"
87
- msgstr "戻るボタン"
88
-
89
- #: classes/form-fields/class.back-button.php:42
90
- #: classes/form-fields/class.button-back.php:43
91
- msgid "Back"
92
- msgstr "戻る"
93
-
94
- #: classes/form-fields/class.back-button.php:77
95
- #: classes/form-fields/class.button-back.php:88
96
- #: classes/form-fields/class.button-button.php:95
97
- #: classes/form-fields/class.button-confirm.php:88
98
- #: classes/form-fields/class.button-submit.php:107
99
- #: classes/form-fields/class.button.php:84
100
- #: classes/form-fields/class.confirm-button.php:77
101
- #: classes/form-fields/class.submit.php:84
102
- msgid "String on the button"
103
- msgstr "ボタンに表示する文字列"
104
-
105
- #: classes/form-fields/class.button-back.php:83
106
- #: classes/form-fields/class.button-button.php:90
107
- #: classes/form-fields/class.button-confirm.php:83
108
- #: classes/form-fields/class.button-submit.php:102
109
- msgid "Value"
110
- msgstr "value"
111
-
112
- #: classes/form-fields/class.button-button.php:30
113
- #: classes/form-fields/class.button.php:30
114
- msgid "Button"
115
- msgstr "ボタン"
116
-
117
- #: classes/form-fields/class.button-button.php:44
118
- msgid "button"
119
- msgstr "ボタン"
120
-
121
- #: classes/form-fields/class.button-confirm.php:30
122
- #: classes/form-fields/class.confirm-button.php:30
123
- msgid "Confirm Button"
124
- msgstr "確認ボタン"
125
-
126
- #: classes/form-fields/class.button-confirm.php:43
127
- #: classes/form-fields/class.confirm-button.php:42
128
- #: classes/form-fields/class.submit-button.php:43
129
- msgid "Confirm"
130
- msgstr "確認画面へ"
131
-
132
- #: classes/form-fields/class.button-submit.php:30
133
- #: classes/form-fields/class.submit.php:30
134
- msgid "Submit Button"
135
- msgstr "送信ボタン"
136
-
137
- #: classes/form-fields/class.button-submit.php:44
138
- #: classes/form-fields/class.submit-button.php:44
139
- #: classes/form-fields/class.submit.php:43
140
- msgid "Send"
141
- msgstr "送信する"
142
-
143
- #: classes/form-fields/class.button-submit.php:112
144
- msgid "Display on input page"
145
- msgstr "入力画面での表示"
146
-
147
- #: classes/form-fields/class.button-submit.php:115
148
- #: classes/form-fields/class.hidden.php:89
149
- msgid "Display"
150
- msgstr "表示する"
151
-
152
- #: classes/form-fields/class.checkbox.php:30
153
- msgid "Checkbox"
154
- msgstr "チェックボックス"
155
-
156
- #: classes/form-fields/class.checkbox.php:124
157
- #: classes/form-fields/class.radio.php:120
158
- #: classes/form-fields/class.select.php:116
159
- msgid "Choices"
160
- msgstr "選択肢"
161
-
162
- #: classes/form-fields/class.checkbox.php:128
163
- #: classes/form-fields/class.error.php:78
164
- #: classes/form-fields/class.radio.php:124
165
- #: classes/form-fields/class.select.php:120
166
- msgid "Input one line about one item."
167
- msgstr "1項目につき1行で入力してください。"
168
-
169
- #: classes/form-fields/class.checkbox.php:129
170
- #: classes/form-fields/class.radio.php:125
171
- #: classes/form-fields/class.select.php:121
172
- msgid "Example: value1&crarr;value2 or key1:value1&crarr;key2:value2"
173
- msgstr "例:値1&crarr;値2 もしくは キー1:値1&crarr;キー2:値2"
174
-
175
- #: classes/form-fields/class.checkbox.php:130
176
- #: classes/form-fields/class.radio.php:126
177
- #: classes/form-fields/class.select.php:122
178
- msgid ""
179
- "You can split the post value and display value by \":\". But display value "
180
- "is sent in e-mail."
181
- msgstr ""
182
- "送信値と表示値を「:」で分割できます。ただし、メールでは表示値が送信されます。"
183
-
184
- #: classes/form-fields/class.checkbox.php:131
185
- #: classes/form-fields/class.radio.php:127
186
- #: classes/form-fields/class.select.php:123
187
- msgid "When you want to use \":\", please enter \"::\"."
188
- msgstr "「:」を使いたいときは「::」と入力してください。"
189
-
190
- #: classes/form-fields/class.checkbox.php:135
191
- #: classes/form-fields/class.radio.php:131
192
- #: classes/form-fields/class.select.php:127
193
- msgid "Send value by e-mail"
194
- msgstr "メールで送信する値"
195
-
196
- #: classes/form-fields/class.checkbox.php:138
197
- #: classes/form-fields/class.radio.php:134
198
- #: classes/form-fields/class.select.php:130
199
- msgid ""
200
- "Send post value when you split the post value and display value by \":\" in "
201
- "choices."
202
- msgstr "選択肢を「:」で送信値と表示値に分割したとき、送信値をメールで送信"
203
-
204
- #: classes/form-fields/class.checkbox.php:141
205
- #: classes/form-fields/class.datepicker.php:155
206
- #: classes/form-fields/class.email.php:127
207
- #: classes/form-fields/class.hidden.php:84
208
- #: classes/form-fields/class.monthpicker.php:166
209
- #: classes/form-fields/class.password.php:119
210
- #: classes/form-fields/class.radio.php:137
211
- #: classes/form-fields/class.select.php:133
212
- #: classes/form-fields/class.text.php:127
213
- #: classes/form-fields/class.textarea.php:121
214
- #: classes/form-fields/class.url.php:127
215
- msgid "Default value"
216
- msgstr "初期値"
217
-
218
- #: classes/form-fields/class.checkbox.php:146
219
- msgid "Separator string"
220
- msgstr "区切り文字"
221
-
222
- #: classes/form-fields/class.checkbox.php:151
223
- #: classes/form-fields/class.radio.php:142
224
- msgid "Display method"
225
- msgstr "表示方法"
226
-
227
- #: classes/form-fields/class.checkbox.php:153
228
- #: classes/form-fields/class.radio.php:144
229
- msgid "Arranged vertically."
230
- msgstr "垂直に配置する"
231
-
232
- #: classes/form-fields/class.checkbox.php:156
233
- #: classes/form-fields/class.datepicker.php:165
234
- #: classes/form-fields/class.email.php:137
235
- #: classes/form-fields/class.file.php:123
236
- #: classes/form-fields/class.image.php:126
237
- #: classes/form-fields/class.monthpicker.php:176
238
- #: classes/form-fields/class.number.php:133
239
- #: classes/form-fields/class.password.php:129
240
- #: classes/form-fields/class.radio.php:147
241
- #: classes/form-fields/class.range.php:126
242
- #: classes/form-fields/class.select.php:138
243
- #: classes/form-fields/class.tel.php:109 classes/form-fields/class.text.php:137
244
- #: classes/form-fields/class.textarea.php:131
245
- #: classes/form-fields/class.url.php:137 classes/form-fields/class.zip.php:108
246
- msgid "Dsiplay error"
247
- msgstr "エラー表示"
248
-
249
- #: classes/form-fields/class.checkbox.php:158
250
- #: classes/form-fields/class.datepicker.php:167
251
- #: classes/form-fields/class.email.php:139
252
- #: classes/form-fields/class.file.php:125
253
- #: classes/form-fields/class.image.php:128
254
- #: classes/form-fields/class.monthpicker.php:178
255
- #: classes/form-fields/class.number.php:135
256
- #: classes/form-fields/class.password.php:131
257
- #: classes/form-fields/class.radio.php:149
258
- #: classes/form-fields/class.range.php:128
259
- #: classes/form-fields/class.select.php:140
260
- #: classes/form-fields/class.tel.php:111 classes/form-fields/class.text.php:139
261
- #: classes/form-fields/class.textarea.php:133
262
- #: classes/form-fields/class.url.php:139 classes/form-fields/class.zip.php:110
263
- msgid "Don't display error."
264
- msgstr "エラーを表示しない"
265
-
266
- #: classes/form-fields/class.custom-mail-tag.php:30
267
- msgid "Custom Mail Tag"
268
- msgstr "カスタムメールタグ"
269
-
270
- #: classes/form-fields/class.datepicker.php:30
271
- msgid "Datepicker"
272
- msgstr "日付"
273
-
274
- #: classes/form-fields/class.email.php:30
275
- msgid "Email"
276
- msgstr "Email フィールド"
277
-
278
- #: classes/form-fields/class.email.php:142
279
- #: classes/form-fields/class.tel.php:114 classes/form-fields/class.text.php:142
280
- #: classes/form-fields/class.url.php:142 classes/form-fields/class.zip.php:113
281
- msgid "Convert half alphanumeric"
282
- msgstr "半角英数字に変換"
283
-
284
- #: classes/form-fields/class.email.php:144
285
- #: classes/form-fields/class.tel.php:116 classes/form-fields/class.url.php:144
286
- #: classes/form-fields/class.zip.php:115
287
- msgid "Don't Convert."
288
- msgstr "変換しない"
289
-
290
- #: classes/form-fields/class.error.php:30
291
- msgid "Error Message"
292
- msgstr "エラーメッセージ"
293
-
294
- #: classes/form-fields/class.error.php:74
295
- msgid "name of the element which wants to display error"
296
- msgstr "エラーを表示したい要素のname属性"
297
-
298
- #: classes/form-fields/class.file.php:30
299
- msgid "File"
300
- msgstr "ファイルフィールド"
301
-
302
- #: classes/form-fields/class.file.php:71 classes/form-fields/class.file.php:93
303
- msgid "Uploaded."
304
- msgstr "アップロードしました。"
305
-
306
- #: classes/form-fields/class.hidden.php:23
307
- msgid "Hidden"
308
- msgstr "hiddenフィールド"
309
-
310
- #: classes/form-fields/class.hidden.php:91
311
- msgid "Display hidden value."
312
- msgstr "hiddenの値を表示"
313
-
314
- #: classes/form-fields/class.image.php:30
315
- msgid "Image"
316
- msgstr "画像フィールド"
317
-
318
- #: classes/form-fields/class.monthpicker.php:30
319
- msgid "Monthpicker"
320
- msgstr "年月"
321
-
322
- #: classes/form-fields/class.number.php:30
323
- msgid "Number"
324
- msgstr "Number フィールド"
325
-
326
- #: classes/form-fields/class.password.php:30
327
- msgid "Password"
328
- msgstr "パスワードフィールド"
329
-
330
- #: classes/form-fields/class.radio.php:30
331
- msgid "Radio"
332
- msgstr "ラジオボタン"
333
-
334
- #: classes/form-fields/class.range.php:30
335
- msgid "Range"
336
- msgstr "Range フィールド"
337
-
338
- #: classes/form-fields/class.select.php:30
339
- msgid "Select"
340
- msgstr "セレクトボックス"
341
-
342
- #: classes/form-fields/class.submit-button.php:30
343
- msgid "Confirm &amp; Submit"
344
- msgstr "確認・送信"
345
-
346
- #: classes/form-fields/class.submit-button.php:92
347
- msgid "String on the confirm button"
348
- msgstr "確認ボタンに表示する文字列"
349
-
350
- #: classes/form-fields/class.submit-button.php:97
351
- msgid "String on the submit button"
352
- msgstr "送信ボタンに表示する文字列"
353
-
354
- #: classes/form-fields/class.tel.php:30
355
- #: classes/validation-rules/class.tel.php:56
356
- msgid "Tel"
357
- msgstr "電話番号"
358
-
359
- #: classes/form-fields/class.text.php:30
360
- msgid "Text"
361
- msgstr "テキストフィールド"
362
-
363
- #: classes/form-fields/class.text.php:144
364
- msgid "Convert."
365
- msgstr "変換する"
366
-
367
- #: classes/form-fields/class.textarea.php:30
368
- msgid "Textarea"
369
- msgstr "テキストエリア"
370
-
371
- #: classes/form-fields/class.url.php:30
372
- msgctxt "form-field"
373
- msgid "URL"
374
- msgstr "URL フィールド"
375
-
376
- #: classes/form-fields/class.zip.php:30
377
- #: classes/validation-rules/class.zip.php:52
378
- msgid "Zip Code"
379
- msgstr "郵便番号"
380
-
381
- #: classes/functions.php:226
382
- msgid "Uploaded from "
383
- msgstr "Uploaded from "
384
-
385
- #: classes/functions.php:342
386
- msgid "Tracking Number"
387
- msgstr "問い合わせ番号"
388
-
389
- #: classes/models/class.contact-data-setting.php:60
390
- msgid "Not supported"
391
- msgstr "未対応"
392
-
393
- #: classes/models/class.contact-data-setting.php:61
394
- msgid "Reservation"
395
- msgstr "保留"
396
-
397
- #: classes/models/class.contact-data-setting.php:62
398
- msgid "Supported"
399
- msgstr "対応済み"
400
-
401
- #: classes/models/class.csv.php:147 templates/contact-data/detail.php:62
402
- msgid "Memo"
403
- msgstr "メモ"
404
-
405
- #: classes/services/class.exec-shortcode.php:413
406
- msgid "There was an error trying to send your message. Please try again later."
407
- msgstr "エラーが発生しました、後ほど、もう一度お試しください"
408
-
409
- #: classes/validation-rules/class.akismet.php:30
410
- msgid "The contents which you input were judged with spam."
411
- msgstr "あなたの入力した内容はスパムと判定されました。"
412
-
413
- #: classes/validation-rules/class.alpha.php:33
414
- msgid "Please enter with a half-width alphabetic character."
415
- msgstr "半角英字で入力してください。"
416
-
417
- #: classes/validation-rules/class.alpha.php:49
418
- msgid "Alphabet"
419
- msgstr "半角英字"
420
-
421
- #: classes/validation-rules/class.alphanumeric.php:33
422
- msgid "Please enter with a half-width alphanumeric character."
423
- msgstr "半角英数字で入力してください。"
424
-
425
- #: classes/validation-rules/class.alphanumeric.php:49
426
- msgid "Alphabet and Numeric"
427
- msgstr "半角英数字"
428
-
429
- #: classes/validation-rules/class.between.php:35
430
- msgid "The number of characters is invalid."
431
- msgstr "文字数が正しくありません。"
432
-
433
- #: classes/validation-rules/class.between.php:77
434
- msgid "The range of the number of characters"
435
- msgstr "文字数の範囲"
436
-
437
- #: classes/validation-rules/class.date.php:32
438
- msgid "This is not the format of a date."
439
- msgstr "日付の形式ではありません。"
440
-
441
- #: classes/validation-rules/class.date.php:74
442
- msgid "Date"
443
- msgstr "日付"
444
-
445
- #: classes/validation-rules/class.eq.php:33
446
- msgid "This is not in agreement."
447
- msgstr "一致しません。"
448
-
449
- #: classes/validation-rules/class.eq.php:57
450
- msgid "The key at same value"
451
- msgstr "一致する項目"
452
-
453
- #: classes/validation-rules/class.filesize.php:38
454
- msgid "Failed to upload the file."
455
- msgstr "ファイルのアップロードに失敗しました。"
456
-
457
- #: classes/validation-rules/class.filesize.php:72
458
- msgid "This file size is too big."
459
- msgstr "ファイルサイズが大きすぎます。"
460
-
461
- #: classes/validation-rules/class.filesize.php:94
462
- msgid "Permitted file size"
463
- msgstr "サイズ制限"
464
-
465
- #: classes/validation-rules/class.filesize.php:95
466
- msgid "bytes"
467
- msgstr "バイト"
468
-
469
- #: classes/validation-rules/class.filetype.php:33
470
- msgid "This file is invalid."
471
- msgstr "許可されたファイルではありません。"
472
-
473
- #: classes/validation-rules/class.filetype.php:62
474
- msgid "Permitted Extension"
475
- msgstr "拡張子制限"
476
-
477
- #: classes/validation-rules/class.filetype.php:63
478
- msgid "Example:jpg or jpg,txt,…"
479
- msgstr "例:jpg もしくは jpg,txt…"
480
-
481
- #: classes/validation-rules/class.hiragana.php:33
482
- msgid "Please enter with a Japanese Hiragana."
483
- msgstr "ひらがなで入力してください。"
484
-
485
- #: classes/validation-rules/class.hiragana.php:49
486
- msgid "Japanese Hiragana"
487
- msgstr "ひらがな"
488
-
489
- #: classes/validation-rules/class.in.php:34
490
- msgid "This value is invalid."
491
- msgstr "値が不正です。"
492
-
493
- #: classes/validation-rules/class.kana.php:33
494
- msgid "Please enter with a Japanese Hiragana or Katakana."
495
- msgstr "ひらがな または カタカナで入力してください。"
496
-
497
- #: classes/validation-rules/class.kana.php:49
498
- msgid "Japanese Hiragana or Katakana"
499
- msgstr "ひらがな または カタカナ"
500
-
501
- #: classes/validation-rules/class.katakana.php:33
502
- msgid "Please enter with a Japanese Katakana."
503
- msgstr "カタカナで入力してください。"
504
-
505
- #: classes/validation-rules/class.katakana.php:49
506
- msgid "Japanese Katakana"
507
- msgstr "カタカナ"
508
-
509
- #: classes/validation-rules/class.mail.php:33
510
- msgid "This is not the format of a mail address."
511
- msgstr "メールアドレスの形式ではありません。"
512
-
513
- #: classes/validation-rules/class.mail.php:49
514
- msgid "E-mail"
515
- msgstr "メールアドレス"
516
-
517
- #: classes/validation-rules/class.maximagesize.php:77
518
- msgid "This image size is too big."
519
- msgstr "画像サイズが大きすぎます。"
520
-
521
- #: classes/validation-rules/class.maximagesize.php:105
522
- msgid "Maximum image size"
523
- msgstr "最大画像サイズ"
524
-
525
- #: classes/validation-rules/class.minimagesize.php:77
526
- msgid "This image size is too small."
527
- msgstr "画像サイズが小さすぎます。"
528
-
529
- #: classes/validation-rules/class.minimagesize.php:105
530
- msgid "Minimum image size"
531
- msgstr "最小画像サイズ"
532
-
533
- #: classes/validation-rules/class.minlength.php:34
534
- msgid "The number of characters is a few."
535
- msgstr "文字数が足りません。"
536
-
537
- #: classes/validation-rules/class.minlength.php:58
538
- msgid "The number of the minimum characters"
539
- msgstr "最小文字数"
540
-
541
- #: classes/validation-rules/class.month.php:32
542
- msgid "This is not the format of a date (Year/Month)."
543
- msgstr "日付(年月)の形式ではありません。"
544
-
545
- #: classes/validation-rules/class.month.php:73
546
- msgid "Date(Year/Month)"
547
- msgstr "日付(年月)"
548
-
549
- #: classes/validation-rules/class.noempty.php:32
550
- #: classes/validation-rules/class.nofalse.php:32
551
- msgid "Please enter."
552
- msgstr "未入力です。"
553
-
554
- #: classes/validation-rules/class.noempty.php:47
555
- msgid "No empty"
556
- msgstr "必須項目"
557
-
558
- #: classes/validation-rules/class.numeric.php:33
559
- msgid "Please enter with a half-width number."
560
- msgstr "半角数字で入力してください。"
561
-
562
- #: classes/validation-rules/class.numeric.php:49
563
- msgid "Numeric"
564
- msgstr "半角数字"
565
-
566
- #: classes/validation-rules/class.required.php:35
567
- msgid "This is required."
568
- msgstr "必須項目です。"
569
-
570
- #: classes/validation-rules/class.required.php:49
571
- msgid "No empty( with checkbox )"
572
- msgstr "必須項目(チェックボックス)"
573
-
574
- #: classes/validation-rules/class.tel.php:32
575
- msgid "This is not the format of a tel number."
576
- msgstr "電話番号の形式ではありません。"
577
-
578
- #: classes/validation-rules/class.url.php:33
579
- msgid "This is not the format of a url."
580
- msgstr "URLの形式ではありません。"
581
-
582
- #: classes/validation-rules/class.url.php:49
583
- msgctxt "validatioin"
584
- msgid "URL"
585
- msgstr "URL"
586
-
587
- #: classes/validation-rules/class.zip.php:32
588
- msgid "This is not the format of a zip code."
589
- msgstr "郵便番号の形式ではありません。"
590
-
591
- #: mw-wp-form.php:169 mw-wp-form.php:170 templates/chart/index.php:4
592
- msgid "Chart"
593
- msgstr "グラフ"
594
-
595
- #: mw-wp-form.php:198 mw-wp-form.php:199
596
- #: templates/stores-inquiry-data-form-list/index.php:2
597
- msgid "Inquiry data"
598
- msgstr "問い合わせデータ"
599
-
600
- #: mw-wp-form.php:293
601
- msgid "Add New Form"
602
- msgstr "フォームを追加"
603
-
604
- #: mw-wp-form.php:294
605
- msgid "Edit Form"
606
- msgstr "フォームを編集"
607
-
608
- #: mw-wp-form.php:295
609
- msgid "New Form"
610
- msgstr "新しいフォーム"
611
-
612
- #: mw-wp-form.php:296
613
- msgid "View Form"
614
- msgstr "フォームを表示"
615
-
616
- #: mw-wp-form.php:297
617
- msgid "Search Forms"
618
- msgstr "フォームを検索"
619
-
620
- #: mw-wp-form.php:298
621
- msgid "No Forms found"
622
- msgstr "フォームがありません"
623
-
624
- #: mw-wp-form.php:299
625
- msgid "No Forms found in Trash"
626
- msgstr "ゴミ箱にフォームはありません"
627
-
628
- #: mw-wp-form.php:316
629
- msgid "Edit "
630
- msgstr "編集"
631
-
632
- #: mw-wp-form.php:317
633
- msgid "View"
634
- msgstr "表示"
635
-
636
- #: mw-wp-form.php:318
637
- msgid "Search"
638
- msgstr "検索"
639
-
640
- #: mw-wp-form.php:319
641
- msgid "No data found"
642
- msgstr "データがありません"
643
-
644
- #: mw-wp-form.php:320
645
- msgid "No data found in Trash"
646
- msgstr "ゴミ箱にデータはありません"
647
-
648
- #: templates/admin/add-ons.php:2
649
- msgid "You can use more easy and useful to the MW WP Form in add-on!"
650
- msgstr "アドオンで MW WP Form をもっと簡単・便利に使うことができます!"
651
-
652
- #: templates/admin/add-ons.php:3
653
- msgid "View Add-ons"
654
- msgstr "アドオンを見る"
655
-
656
- #: templates/admin/admin-mail-options.php:2 templates/admin/mail-options.php:2
657
- msgid "{key} is converted form data."
658
- msgstr "{キー}でそのフォーム項目に変換されます。"
659
-
660
- #: templates/admin/admin-mail-options.php:4 templates/admin/mail-options.php:4
661
- msgid "It is automatically converted to Tracking number when you input {%s}."
662
- msgstr "{%s} と入力すると問い合わせ番号に自動的に変換されます。"
663
-
664
- #: templates/admin/admin-mail-options.php:9
665
- msgid ""
666
- "If Admin Email Options is a blank, Automatic Replay Email Options is used as "
667
- "Admin Email Options."
668
- msgstr ""
669
- "管理者宛メール設定が空のときは自動返信メール設定が管理者宛メール設定として使"
670
- "用されます。"
671
-
672
- #: templates/admin/admin-mail-options.php:12
673
- msgid "To ( E-mail address )"
674
- msgstr "送信先(E-mailアドレス)"
675
-
676
- #: templates/admin/admin-mail-options.php:14
677
- #: templates/admin/admin-mail-options.php:31
678
- #: templates/admin/admin-mail-options.php:36
679
- #: templates/admin/admin-mail-options.php:41
680
- #: templates/admin/mail-options.php:15 templates/admin/mail-options.php:20
681
- msgid "If empty:"
682
- msgstr "未入力の場合:"
683
-
684
- #: templates/admin/admin-mail-options.php:17
685
- msgid "CC ( E-mail address )"
686
- msgstr "CC(E-mailアドレス)"
687
-
688
- #: templates/admin/admin-mail-options.php:21
689
- msgid "BCC ( E-mail address )"
690
- msgstr "BCC(E-mailアドレス)"
691
-
692
- #: templates/admin/admin-mail-options.php:25 templates/admin/mail-options.php:9
693
- msgid "Subject"
694
- msgstr "件名"
695
-
696
- #: templates/admin/admin-mail-options.php:29
697
- #: templates/admin/mail-options.php:13
698
- msgid "Sender"
699
- msgstr "送信者"
700
-
701
- #: templates/admin/admin-mail-options.php:34
702
- msgid "Return-Path ( E-mail address )"
703
- msgstr "Return-Path(E-mailアドレス)"
704
-
705
- #: templates/admin/admin-mail-options.php:39
706
- #: templates/admin/mail-options.php:18
707
- msgid "From ( E-mail address )"
708
- msgstr "送信元(E-mailアドレス)"
709
-
710
- #: templates/admin/admin-mail-options.php:44
711
- #: templates/admin/mail-options.php:23
712
- msgid "Content"
713
- msgstr "本文"
714
-
715
- #: templates/admin/form-key.php:4
716
- msgid "Copy and Paste this shortcode."
717
- msgstr "このショートコードをコピー&ペーストしてください。"
718
-
719
- #: templates/admin/form-key.php:5
720
- msgid "The key to use with hook is "
721
- msgstr "各フックで使用する修飾子は"
722
-
723
- #: templates/admin/mail-options.php:27
724
- msgid "Automatic reply email"
725
- msgstr "自動返信メール"
726
-
727
- #: templates/admin/mail-options.php:29
728
- msgid ""
729
- "Input the key to use as transmission to automatic reply email. {} is "
730
- "unnecessary."
731
- msgstr "自動返信メールに使用する項目のキーを入力してください。{ }は不要です。"
732
-
733
- #: templates/admin/settings.php:9
734
- msgid "Activate Query string of post"
735
- msgstr "URL引数を有効にする"
736
-
737
- #: templates/admin/settings.php:13
738
- msgid ""
739
- "If this field is active, MW WP Form get query string. And get post data from "
740
- "query string \"post_id\". You can use $post's property in editor."
741
- msgstr ""
742
- "有効にした場合、MW WP FormはURL引数を取得します。また、URL引数 ”post_id” をも"
743
- "とに投稿を取得します。その投稿($post) のプロパティを使用できるようになりま"
744
- "す。"
745
-
746
- #: templates/admin/settings.php:15
747
- msgid "Example: {ID}, {post_title}, {post_meta} etc..."
748
- msgstr "例:{ID}、{post_title}、{post_meta}など…"
749
-
750
- #: templates/admin/settings.php:27
751
- msgid "Saving inquiry data in database"
752
- msgstr "問い合わせデータをデータベースに保存"
753
-
754
- #: templates/admin/settings.php:39
755
- msgid "Enable scrolling of screen transition."
756
- msgstr "画面変遷時のスクロールを有効にする"
757
-
758
- #: templates/admin/settings.php:44
759
- msgid "Next Tracking Number"
760
- msgstr "次の問い合わせ番号"
761
-
762
- #: templates/admin/settings.php:57
763
- msgid "I want to change."
764
- msgstr "変更する"
765
-
766
- #: templates/admin/settings.php:63
767
- msgid "Akismet Setting"
768
- msgstr "Akismet 設定"
769
-
770
- #: templates/admin/settings.php:78
771
- msgid "Input the key to use Akismet."
772
- msgstr "Akismetを使用する項目のキーを入力してください。"
773
-
774
- #: templates/admin/style.php:3
775
- msgid "Select Style"
776
- msgstr "スタイルを選択"
777
-
778
- #: templates/admin/tag-generator.php:6 templates/chart/index.php:25
779
- msgid "Select this."
780
- msgstr "選択してください"
781
-
782
- #: templates/admin/tag-generator.php:7
783
- msgid "Input fields"
784
- msgstr "入力項目"
785
-
786
- #: templates/admin/tag-generator.php:10
787
- msgid "Select fields"
788
- msgstr "選択項目"
789
-
790
- #: templates/admin/tag-generator.php:13
791
- msgid "Button fields (button)"
792
- msgstr "ボタン項目(button)"
793
-
794
- #: templates/admin/tag-generator.php:16
795
- msgid "Button fields (input)"
796
- msgstr "ボタン項目(input)"
797
-
798
- #: templates/admin/tag-generator.php:19
799
- msgid "Error fields"
800
- msgstr "エラー項目"
801
-
802
- #: templates/admin/tag-generator.php:22
803
- msgid "Other fields"
804
- msgstr "その他の項目"
805
-
806
- #: templates/admin/tag-generator.php:26
807
- msgid "Add form tag"
808
- msgstr "フォームタグを追加"
809
-
810
- #: templates/admin/url.php:4
811
- msgid "Input Page URL"
812
- msgstr "入力画面URL"
813
-
814
- #: templates/admin/url.php:10
815
- msgid "Confirmation Page URL"
816
- msgstr "確認画面URL"
817
-
818
- #: templates/admin/url.php:16
819
- msgid "Complete Page URL"
820
- msgstr "完了画面URL"
821
-
822
- #: templates/admin/url.php:22
823
- msgid "Validation Error Page URL"
824
- msgstr "エラー画面URL"
825
-
826
- #: templates/admin/url.php:29
827
- msgid ""
828
- "This urls are the redirection urls at the time of button press. When URL "
829
- "setting is empty, The page redirect on the same page."
830
- msgstr ""
831
- "上記URLはボタン押下時のリダイレクトURLです。URLの設定が空のときは、同一ページ"
832
- "上でリダイレクトします。"
833
-
834
- #: templates/admin/url.php:30
835
- msgid "When a URL doesn't begin http or https, %s is complemented."
836
- msgstr "URLが http または https で始まっていない場合は %s が補完されます。"
837
-
838
- #: templates/admin/validation-rule.php:1
839
- msgid "Add Validation rule"
840
- msgstr "バリデーションルールを追加"
841
-
842
- #: templates/admin/validation-rule.php:9
843
- msgid "The key which applies validation"
844
- msgstr "バリデーションを適用する項目"
845
-
846
- #: templates/chart/index.php:15
847
- msgid "Add Chart"
848
- msgstr "グラフを追加"
849
-
850
- #: templates/chart/index.php:23
851
- msgid "Item that create chart"
852
- msgstr "グラフを作成する項目"
853
-
854
- #: templates/chart/index.php:31
855
- msgid "Chart type"
856
- msgstr "グラフの種類"
857
-
858
- #: templates/chart/index.php:35
859
- msgid "Pie chart"
860
- msgstr "円グラフ"
861
-
862
- #: templates/chart/index.php:36
863
- msgid "Bar chart"
864
- msgstr "棒グラフ"
865
-
866
- #: templates/chart/index.php:49
867
- msgid ""
868
- "Separator string (If the check box. If the separator attribute is not set to "
869
- "\",\")"
870
- msgstr ""
871
- "区切り文字(チェックボックスの場合。separator 属性が未設定の場合は「,」)"
872
-
873
- #: templates/chart/index.php:71
874
- #: templates/stores-inquiry-data-form-list/index.php:10
875
- msgid "The number of inquiries"
876
- msgstr "問い合わせ件数"
877
-
878
- #: templates/contact-data/returning-link.php:2
879
- msgid "&laquo; Back to the list"
880
- msgstr "&laquo; 一覧に戻る"
881
-
882
- #: templates/contact-data-list/csv-button.php:2
883
- msgid "CSV Download"
884
- msgstr "CSVダウンロード"
885
-
886
- #: templates/stores-inquiry-data-form-list/index.php:4
887
- msgid ""
888
- "You can see the inquiry data that are saved in the database by clicking on "
889
- "the link below."
890
- msgstr ""
891
- "リンクをクリックすることでデータベースに保存された問い合わせデータを見ること"
892
- "ができます。"
893
-
894
- #: templates/stores-inquiry-data-form-list/index.php:8
895
- msgid "Form title"
896
- msgstr "フォーム名"
897
-
898
- #: templates/stores-inquiry-data-form-list/index.php:9
899
- #: templates/stores-inquiry-data-form-list/index.php:18
900
- msgid "Display Chart"
901
- msgstr "グラフを表示"
902
-
903
- #: templates/stores-inquiry-data-form-list/index.php:11
904
- msgid "Updated date"
905
- msgstr "更新日"
906
-
907
- #: templates/stores-inquiry-data-form-list/index.php:12
908
- msgid "Created date"
909
- msgstr "作成日"
910
-
911
- #: templates/stores-inquiry-data-form-list/index.php:19
912
- msgid "cases"
913
- msgstr "件"
914
-
915
- #. Plugin Name of the plugin/theme
916
- msgid "MW WP Form"
917
- msgstr "MW WP Form"
918
-
919
- #. Plugin URI of the plugin/theme
920
- msgid "http://plugins.2inc.org/mw-wp-form/"
921
- msgstr "http://plugins.2inc.org/mw-wp-form/"
922
-
923
- #. Description of the plugin/theme
924
- msgid ""
925
- "MW WP Form is shortcode base contact form plugin. This plugin have many "
926
- "feature. For example you can use many validation rules, contact data saving, "
927
- "and chart aggregation using saved contact data."
928
- msgstr ""
929
- "MW WP Form はショートコードベースのフォームプラグインです。多くの機能を持って"
930
- "おり、例えば、多くのバリデーションルール、問い合わせデータの保存、そしてグラ"
931
- "フ機能集計などを使用することができます。"
932
-
933
- #. Author of the plugin/theme
934
- msgid "Takashi Kitajima"
935
- msgstr "Takashi Kitajima"
936
-
937
- #. Author URI of the plugin/theme
938
- msgid "http://2inc.org"
939
- msgstr "http://2inc.org"
940
-
941
- #, fuzzy
942
- #~ msgctxt "value"
943
- #~ msgid "Back"
944
- #~ msgstr "戻る"
945
-
946
- #~ msgid "Button (button)"
947
- #~ msgstr "ボタン(button)"
948
-
949
- #~ msgid "Confirm Button (button)"
950
- #~ msgstr "確認ボタン(button)"
951
-
952
- #~ msgid "Submit Button (button)"
953
- #~ msgstr "送信ボタン(button)"
954
-
955
- #~ msgid "MW WP Form can create mail form with a confirmation screen."
956
- #~ msgstr ""
957
- #~ "MW WP Formは確認画面付きのフォームを作成しメールを送信することができます。"
958
-
959
- #~ msgid "option"
960
- #~ msgstr "オプション"
961
-
962
- #~ msgid "Shortcodes"
963
- #~ msgstr "ショートコード"
964
-
965
- #~ msgid "Inquiry count"
966
- #~ msgstr "問い合わせ件数"
967
-
968
- #~ msgid "Title"
969
- #~ msgstr "タイトル"
970
-
971
- #~ msgid "If empty: Using admin E-mail address."
972
- #~ msgstr "未入力の場合:管理者のE-mailアドレスを使用します。"
973
-
974
- #~ msgid "Zip code"
975
- #~ msgstr "郵便番号"
976
-
977
- #~ msgid "Submit"
978
- #~ msgstr "送信"
979
-
980
- #~ msgid "Active"
981
- #~ msgstr "有効にする"
982
-
983
- #~ msgid "Zip"
984
- #~ msgstr "郵便番号"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
languages/mw-wp-form.pot DELETED
@@ -1,918 +0,0 @@
1
- # Copyright (C) 2017 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 3.2.0\n"
6
- "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/mw-wp-form\n"
7
- "POT-Creation-Date: 2017-04-29 13:28:37+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: 2017-MO-DA HO:MI+ZONE\n"
12
- "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
- "Language-Team: LANGUAGE <LL@li.org>\n"
14
-
15
- #: classes/controllers/class.admin-list.php:34
16
- msgid "Your contribution is needed for making this plugin better."
17
- msgstr ""
18
-
19
- #: classes/controllers/class.admin-list.php:36
20
- msgid "Donate"
21
- msgstr ""
22
-
23
- #: classes/controllers/class.admin-list.php:66
24
- #: classes/controllers/class.admin.php:89
25
- msgid "Form Key"
26
- msgstr ""
27
-
28
- #: classes/controllers/class.admin.php:57
29
- msgid "Complete Message"
30
- msgstr ""
31
-
32
- #: classes/controllers/class.admin.php:65
33
- msgid "URL Options"
34
- msgstr ""
35
-
36
- #: classes/controllers/class.admin.php:73
37
- msgid "Validation Rule"
38
- msgstr ""
39
-
40
- #: classes/controllers/class.admin.php:81
41
- msgid "Add-ons"
42
- msgstr ""
43
-
44
- #: classes/controllers/class.admin.php:97
45
- msgid "Automatic Reply Email Options"
46
- msgstr ""
47
-
48
- #: classes/controllers/class.admin.php:105
49
- msgid "Admin Email Options"
50
- msgstr ""
51
-
52
- #: classes/controllers/class.admin.php:113
53
- msgid "settings"
54
- msgstr ""
55
-
56
- #: classes/controllers/class.admin.php:122
57
- msgid "Style setting"
58
- msgstr ""
59
-
60
- #: classes/controllers/class.contact-data-list.php:117
61
- msgid "Registed Date"
62
- msgstr ""
63
-
64
- #: classes/controllers/class.contact-data-list.php:118
65
- #: classes/models/class.csv.php:122 templates/contact-data/detail.php:50
66
- msgid "Response Status"
67
- msgstr ""
68
-
69
- #: classes/controllers/class.contact-data.php:70
70
- msgid "Custom Fields"
71
- msgstr ""
72
-
73
- #: classes/form-fields/class.akismet_error.php:30
74
- msgid "Akismet Error"
75
- msgstr ""
76
-
77
- #: classes/form-fields/class.back-button.php:30
78
- #: classes/form-fields/class.button-back.php:30
79
- msgid "Back Button"
80
- msgstr ""
81
-
82
- #: classes/form-fields/class.back-button.php:42
83
- #: classes/form-fields/class.button-back.php:43
84
- msgid "Back"
85
- msgstr ""
86
-
87
- #: classes/form-fields/class.back-button.php:77
88
- #: classes/form-fields/class.button-back.php:88
89
- #: classes/form-fields/class.button-button.php:95
90
- #: classes/form-fields/class.button-confirm.php:88
91
- #: classes/form-fields/class.button-submit.php:107
92
- #: classes/form-fields/class.button.php:84
93
- #: classes/form-fields/class.confirm-button.php:77
94
- #: classes/form-fields/class.submit.php:84
95
- msgid "String on the button"
96
- msgstr ""
97
-
98
- #: classes/form-fields/class.button-back.php:83
99
- #: classes/form-fields/class.button-button.php:90
100
- #: classes/form-fields/class.button-confirm.php:83
101
- #: classes/form-fields/class.button-submit.php:102
102
- msgid "Value"
103
- msgstr ""
104
-
105
- #: classes/form-fields/class.button-button.php:30
106
- #: classes/form-fields/class.button.php:30
107
- msgid "Button"
108
- msgstr ""
109
-
110
- #: classes/form-fields/class.button-button.php:44
111
- msgid "button"
112
- msgstr ""
113
-
114
- #: classes/form-fields/class.button-confirm.php:30
115
- #: classes/form-fields/class.confirm-button.php:30
116
- msgid "Confirm Button"
117
- msgstr ""
118
-
119
- #: classes/form-fields/class.button-confirm.php:43
120
- #: classes/form-fields/class.confirm-button.php:42
121
- #: classes/form-fields/class.submit-button.php:43
122
- msgid "Confirm"
123
- msgstr ""
124
-
125
- #: classes/form-fields/class.button-submit.php:30
126
- #: classes/form-fields/class.submit.php:30
127
- msgid "Submit Button"
128
- msgstr ""
129
-
130
- #: classes/form-fields/class.button-submit.php:44
131
- #: classes/form-fields/class.submit-button.php:44
132
- #: classes/form-fields/class.submit.php:43
133
- msgid "Send"
134
- msgstr ""
135
-
136
- #: classes/form-fields/class.button-submit.php:112
137
- msgid "Display on input page"
138
- msgstr ""
139
-
140
- #: classes/form-fields/class.button-submit.php:115
141
- #: classes/form-fields/class.hidden.php:89
142
- msgid "Display"
143
- msgstr ""
144
-
145
- #: classes/form-fields/class.checkbox.php:30
146
- msgid "Checkbox"
147
- msgstr ""
148
-
149
- #: classes/form-fields/class.checkbox.php:124
150
- #: classes/form-fields/class.radio.php:120
151
- #: classes/form-fields/class.select.php:116
152
- msgid "Choices"
153
- msgstr ""
154
-
155
- #: classes/form-fields/class.checkbox.php:128
156
- #: classes/form-fields/class.error.php:78
157
- #: classes/form-fields/class.radio.php:124
158
- #: classes/form-fields/class.select.php:120
159
- msgid "Input one line about one item."
160
- msgstr ""
161
-
162
- #: classes/form-fields/class.checkbox.php:129
163
- #: classes/form-fields/class.radio.php:125
164
- #: classes/form-fields/class.select.php:121
165
- msgid "Example: value1&crarr;value2 or key1:value1&crarr;key2:value2"
166
- msgstr ""
167
-
168
- #: classes/form-fields/class.checkbox.php:130
169
- #: classes/form-fields/class.radio.php:126
170
- #: classes/form-fields/class.select.php:122
171
- msgid ""
172
- "You can split the post value and display value by \":\". But display value "
173
- "is sent in e-mail."
174
- msgstr ""
175
-
176
- #: classes/form-fields/class.checkbox.php:131
177
- #: classes/form-fields/class.radio.php:127
178
- #: classes/form-fields/class.select.php:123
179
- msgid "When you want to use \":\", please enter \"::\"."
180
- msgstr ""
181
-
182
- #: classes/form-fields/class.checkbox.php:135
183
- #: classes/form-fields/class.radio.php:131
184
- #: classes/form-fields/class.select.php:127
185
- msgid "Send value by e-mail"
186
- msgstr ""
187
-
188
- #: classes/form-fields/class.checkbox.php:138
189
- #: classes/form-fields/class.radio.php:134
190
- #: classes/form-fields/class.select.php:130
191
- msgid ""
192
- "Send post value when you split the post value and display value by \":\" in "
193
- "choices."
194
- msgstr ""
195
-
196
- #: classes/form-fields/class.checkbox.php:141
197
- #: classes/form-fields/class.datepicker.php:155
198
- #: classes/form-fields/class.email.php:127
199
- #: classes/form-fields/class.hidden.php:84
200
- #: classes/form-fields/class.monthpicker.php:166
201
- #: classes/form-fields/class.password.php:119
202
- #: classes/form-fields/class.radio.php:137
203
- #: classes/form-fields/class.select.php:133
204
- #: classes/form-fields/class.text.php:127
205
- #: classes/form-fields/class.textarea.php:121
206
- #: classes/form-fields/class.url.php:127
207
- msgid "Default value"
208
- msgstr ""
209
-
210
- #: classes/form-fields/class.checkbox.php:146
211
- msgid "Separator string"
212
- msgstr ""
213
-
214
- #: classes/form-fields/class.checkbox.php:151
215
- #: classes/form-fields/class.radio.php:142
216
- msgid "Display method"
217
- msgstr ""
218
-
219
- #: classes/form-fields/class.checkbox.php:153
220
- #: classes/form-fields/class.radio.php:144
221
- msgid "Arranged vertically."
222
- msgstr ""
223
-
224
- #: classes/form-fields/class.checkbox.php:156
225
- #: classes/form-fields/class.datepicker.php:165
226
- #: classes/form-fields/class.email.php:137
227
- #: classes/form-fields/class.file.php:123
228
- #: classes/form-fields/class.image.php:126
229
- #: classes/form-fields/class.monthpicker.php:176
230
- #: classes/form-fields/class.number.php:133
231
- #: classes/form-fields/class.password.php:129
232
- #: classes/form-fields/class.radio.php:147
233
- #: classes/form-fields/class.range.php:126
234
- #: classes/form-fields/class.select.php:138
235
- #: classes/form-fields/class.tel.php:109 classes/form-fields/class.text.php:137
236
- #: classes/form-fields/class.textarea.php:131
237
- #: classes/form-fields/class.url.php:137 classes/form-fields/class.zip.php:108
238
- msgid "Dsiplay error"
239
- msgstr ""
240
-
241
- #: classes/form-fields/class.checkbox.php:158
242
- #: classes/form-fields/class.datepicker.php:167
243
- #: classes/form-fields/class.email.php:139
244
- #: classes/form-fields/class.file.php:125
245
- #: classes/form-fields/class.image.php:128
246
- #: classes/form-fields/class.monthpicker.php:178
247
- #: classes/form-fields/class.number.php:135
248
- #: classes/form-fields/class.password.php:131
249
- #: classes/form-fields/class.radio.php:149
250
- #: classes/form-fields/class.range.php:128
251
- #: classes/form-fields/class.select.php:140
252
- #: classes/form-fields/class.tel.php:111 classes/form-fields/class.text.php:139
253
- #: classes/form-fields/class.textarea.php:133
254
- #: classes/form-fields/class.url.php:139 classes/form-fields/class.zip.php:110
255
- msgid "Don't display error."
256
- msgstr ""
257
-
258
- #: classes/form-fields/class.custom-mail-tag.php:30
259
- msgid "Custom Mail Tag"
260
- msgstr ""
261
-
262
- #: classes/form-fields/class.datepicker.php:30
263
- msgid "Datepicker"
264
- msgstr ""
265
-
266
- #: classes/form-fields/class.email.php:30
267
- msgid "Email"
268
- msgstr ""
269
-
270
- #: classes/form-fields/class.email.php:142
271
- #: classes/form-fields/class.tel.php:114 classes/form-fields/class.text.php:142
272
- #: classes/form-fields/class.url.php:142 classes/form-fields/class.zip.php:113
273
- msgid "Convert half alphanumeric"
274
- msgstr ""
275
-
276
- #: classes/form-fields/class.email.php:144
277
- #: classes/form-fields/class.tel.php:116 classes/form-fields/class.url.php:144
278
- #: classes/form-fields/class.zip.php:115
279
- msgid "Don't Convert."
280
- msgstr ""
281
-
282
- #: classes/form-fields/class.error.php:30
283
- msgid "Error Message"
284
- msgstr ""
285
-
286
- #: classes/form-fields/class.error.php:74
287
- msgid "name of the element which wants to display error"
288
- msgstr ""
289
-
290
- #: classes/form-fields/class.file.php:30
291
- msgid "File"
292
- msgstr ""
293
-
294
- #: classes/form-fields/class.file.php:71 classes/form-fields/class.file.php:93
295
- msgid "Uploaded."
296
- msgstr ""
297
-
298
- #: classes/form-fields/class.hidden.php:23
299
- msgid "Hidden"
300
- msgstr ""
301
-
302
- #: classes/form-fields/class.hidden.php:91
303
- msgid "Display hidden value."
304
- msgstr ""
305
-
306
- #: classes/form-fields/class.image.php:30
307
- msgid "Image"
308
- msgstr ""
309
-
310
- #: classes/form-fields/class.monthpicker.php:30
311
- msgid "Monthpicker"
312
- msgstr ""
313
-
314
- #: classes/form-fields/class.number.php:30
315
- msgid "Number"
316
- msgstr ""
317
-
318
- #: classes/form-fields/class.password.php:30
319
- msgid "Password"
320
- msgstr ""
321
-
322
- #: classes/form-fields/class.radio.php:30
323
- msgid "Radio"
324
- msgstr ""
325
-
326
- #: classes/form-fields/class.range.php:30
327
- msgid "Range"
328
- msgstr ""
329
-
330
- #: classes/form-fields/class.select.php:30
331
- msgid "Select"
332
- msgstr ""
333
-
334
- #: classes/form-fields/class.submit-button.php:30
335
- msgid "Confirm &amp; Submit"
336
- msgstr ""
337
-
338
- #: classes/form-fields/class.submit-button.php:92
339
- msgid "String on the confirm button"
340
- msgstr ""
341
-
342
- #: classes/form-fields/class.submit-button.php:97
343
- msgid "String on the submit button"
344
- msgstr ""
345
-
346
- #: classes/form-fields/class.tel.php:30
347
- #: classes/validation-rules/class.tel.php:56
348
- msgid "Tel"
349
- msgstr ""
350
-
351
- #: classes/form-fields/class.text.php:30
352
- msgid "Text"
353
- msgstr ""
354
-
355
- #: classes/form-fields/class.text.php:144
356
- msgid "Convert."
357
- msgstr ""
358
-
359
- #: classes/form-fields/class.textarea.php:30
360
- msgid "Textarea"
361
- msgstr ""
362
-
363
- #: classes/form-fields/class.url.php:30
364
- msgctxt "form-field"
365
- msgid "URL"
366
- msgstr ""
367
-
368
- #: classes/form-fields/class.zip.php:30
369
- #: classes/validation-rules/class.zip.php:52
370
- msgid "Zip Code"
371
- msgstr ""
372
-
373
- #: classes/functions.php:226
374
- msgid "Uploaded from "
375
- msgstr ""
376
-
377
- #: classes/functions.php:342
378
- msgid "Tracking Number"
379
- msgstr ""
380
-
381
- #: classes/models/class.contact-data-setting.php:60
382
- msgid "Not supported"
383
- msgstr ""
384
-
385
- #: classes/models/class.contact-data-setting.php:61
386
- msgid "Reservation"
387
- msgstr ""
388
-
389
- #: classes/models/class.contact-data-setting.php:62
390
- msgid "Supported"
391
- msgstr ""
392
-
393
- #: classes/models/class.csv.php:147 templates/contact-data/detail.php:62
394
- msgid "Memo"
395
- msgstr ""
396
-
397
- #: classes/services/class.exec-shortcode.php:413
398
- msgid "There was an error trying to send your message. Please try again later."
399
- msgstr ""
400
-
401
- #: classes/validation-rules/class.akismet.php:30
402
- msgid "The contents which you input were judged with spam."
403
- msgstr ""
404
-
405
- #: classes/validation-rules/class.alpha.php:33
406
- msgid "Please enter with a half-width alphabetic character."
407
- msgstr ""
408
-
409
- #: classes/validation-rules/class.alpha.php:49
410
- msgid "Alphabet"
411
- msgstr ""
412
-
413
- #: classes/validation-rules/class.alphanumeric.php:33
414
- msgid "Please enter with a half-width alphanumeric character."
415
- msgstr ""
416
-
417
- #: classes/validation-rules/class.alphanumeric.php:49
418
- msgid "Alphabet and Numeric"
419
- msgstr ""
420
-
421
- #: classes/validation-rules/class.between.php:35
422
- msgid "The number of characters is invalid."
423
- msgstr ""
424
-
425
- #: classes/validation-rules/class.between.php:77
426
- msgid "The range of the number of characters"
427
- msgstr ""
428
-
429
- #: classes/validation-rules/class.date.php:32
430
- msgid "This is not the format of a date."
431
- msgstr ""
432
-
433
- #: classes/validation-rules/class.date.php:74
434
- msgid "Date"
435
- msgstr ""
436
-
437
- #: classes/validation-rules/class.eq.php:33
438
- msgid "This is not in agreement."
439
- msgstr ""
440
-
441
- #: classes/validation-rules/class.eq.php:57
442
- msgid "The key at same value"
443
- msgstr ""
444
-
445
- #: classes/validation-rules/class.filesize.php:38
446
- msgid "Failed to upload the file."
447
- msgstr ""
448
-
449
- #: classes/validation-rules/class.filesize.php:72
450
- msgid "This file size is too big."
451
- msgstr ""
452
-
453
- #: classes/validation-rules/class.filesize.php:94
454
- msgid "Permitted file size"
455
- msgstr ""
456
-
457
- #: classes/validation-rules/class.filesize.php:95
458
- msgid "bytes"
459
- msgstr ""
460
-
461
- #: classes/validation-rules/class.filetype.php:33
462
- msgid "This file is invalid."
463
- msgstr ""
464
-
465
- #: classes/validation-rules/class.filetype.php:62
466
- msgid "Permitted Extension"
467
- msgstr ""
468
-
469
- #: classes/validation-rules/class.filetype.php:63
470
- msgid "Example:jpg or jpg,txt,…"
471
- msgstr ""
472
-
473
- #: classes/validation-rules/class.hiragana.php:33
474
- msgid "Please enter with a Japanese Hiragana."
475
- msgstr ""
476
-
477
- #: classes/validation-rules/class.hiragana.php:49
478
- msgid "Japanese Hiragana"
479
- msgstr ""
480
-
481
- #: classes/validation-rules/class.in.php:34
482
- msgid "This value is invalid."
483
- msgstr ""
484
-
485
- #: classes/validation-rules/class.kana.php:33
486
- msgid "Please enter with a Japanese Hiragana or Katakana."
487
- msgstr ""
488
-
489
- #: classes/validation-rules/class.kana.php:49
490
- msgid "Japanese Hiragana or Katakana"
491
- msgstr ""
492
-
493
- #: classes/validation-rules/class.katakana.php:33
494
- msgid "Please enter with a Japanese Katakana."
495
- msgstr ""
496
-
497
- #: classes/validation-rules/class.katakana.php:49
498
- msgid "Japanese Katakana"
499
- msgstr ""
500
-
501
- #: classes/validation-rules/class.mail.php:33
502
- msgid "This is not the format of a mail address."
503
- msgstr ""
504
-
505
- #: classes/validation-rules/class.mail.php:49
506
- msgid "E-mail"
507
- msgstr ""
508
-
509
- #: classes/validation-rules/class.maximagesize.php:77
510
- msgid "This image size is too big."
511
- msgstr ""
512
-
513
- #: classes/validation-rules/class.maximagesize.php:105
514
- msgid "Maximum image size"
515
- msgstr ""
516
-
517
- #: classes/validation-rules/class.minimagesize.php:77
518
- msgid "This image size is too small."
519
- msgstr ""
520
-
521
- #: classes/validation-rules/class.minimagesize.php:105
522
- msgid "Minimum image size"
523
- msgstr ""
524
-
525
- #: classes/validation-rules/class.minlength.php:34
526
- msgid "The number of characters is a few."
527
- msgstr ""
528
-
529
- #: classes/validation-rules/class.minlength.php:58
530
- msgid "The number of the minimum characters"
531
- msgstr ""
532
-
533
- #: classes/validation-rules/class.month.php:32
534
- msgid "This is not the format of a date (Year/Month)."
535
- msgstr ""
536
-
537
- #: classes/validation-rules/class.month.php:73
538
- msgid "Date(Year/Month)"
539
- msgstr ""
540
-
541
- #: classes/validation-rules/class.noempty.php:32
542
- #: classes/validation-rules/class.nofalse.php:32
543
- msgid "Please enter."
544
- msgstr ""
545
-
546
- #: classes/validation-rules/class.noempty.php:47
547
- msgid "No empty"
548
- msgstr ""
549
-
550
- #: classes/validation-rules/class.numeric.php:33
551
- msgid "Please enter with a half-width number."
552
- msgstr ""
553
-
554
- #: classes/validation-rules/class.numeric.php:49
555
- msgid "Numeric"
556
- msgstr ""
557
-
558
- #: classes/validation-rules/class.required.php:35
559
- msgid "This is required."
560
- msgstr ""
561
-
562
- #: classes/validation-rules/class.required.php:49
563
- msgid "No empty( with checkbox )"
564
- msgstr ""
565
-
566
- #: classes/validation-rules/class.tel.php:32
567
- msgid "This is not the format of a tel number."
568
- msgstr ""
569
-
570
- #: classes/validation-rules/class.url.php:33
571
- msgid "This is not the format of a url."
572
- msgstr ""
573
-
574
- #: classes/validation-rules/class.url.php:49
575
- msgctxt "validatioin"
576
- msgid "URL"
577
- msgstr ""
578
-
579
- #: classes/validation-rules/class.zip.php:32
580
- msgid "This is not the format of a zip code."
581
- msgstr ""
582
-
583
- #: mw-wp-form.php:169 mw-wp-form.php:170 templates/chart/index.php:4
584
- msgid "Chart"
585
- msgstr ""
586
-
587
- #: mw-wp-form.php:198 mw-wp-form.php:199
588
- #: templates/stores-inquiry-data-form-list/index.php:2
589
- msgid "Inquiry data"
590
- msgstr ""
591
-
592
- #: mw-wp-form.php:293
593
- msgid "Add New Form"
594
- msgstr ""
595
-
596
- #: mw-wp-form.php:294
597
- msgid "Edit Form"
598
- msgstr ""
599
-
600
- #: mw-wp-form.php:295
601
- msgid "New Form"
602
- msgstr ""
603
-
604
- #: mw-wp-form.php:296
605
- msgid "View Form"
606
- msgstr ""
607
-
608
- #: mw-wp-form.php:297
609
- msgid "Search Forms"
610
- msgstr ""
611
-
612
- #: mw-wp-form.php:298
613
- msgid "No Forms found"
614
- msgstr ""
615
-
616
- #: mw-wp-form.php:299
617
- msgid "No Forms found in Trash"
618
- msgstr ""
619
-
620
- #: mw-wp-form.php:316
621
- msgid "Edit "
622
- msgstr ""
623
-
624
- #: mw-wp-form.php:317
625
- msgid "View"
626
- msgstr ""
627
-
628
- #: mw-wp-form.php:318
629
- msgid "Search"
630
- msgstr ""
631
-
632
- #: mw-wp-form.php:319
633
- msgid "No data found"
634
- msgstr ""
635
-
636
- #: mw-wp-form.php:320
637
- msgid "No data found in Trash"
638
- msgstr ""
639
-
640
- #: templates/admin/add-ons.php:2
641
- msgid "You can use more easy and useful to the MW WP Form in add-on!"
642
- msgstr ""
643
-
644
- #: templates/admin/add-ons.php:3
645
- msgid "View Add-ons"
646
- msgstr ""
647
-
648
- #: templates/admin/admin-mail-options.php:2 templates/admin/mail-options.php:2
649
- msgid "{key} is converted form data."
650
- msgstr ""
651
-
652
- #: templates/admin/admin-mail-options.php:4 templates/admin/mail-options.php:4
653
- msgid "It is automatically converted to Tracking number when you input {%s}."
654
- msgstr ""
655
-
656
- #: templates/admin/admin-mail-options.php:9
657
- msgid ""
658
- "If Admin Email Options is a blank, Automatic Replay Email Options is used as "
659
- "Admin Email Options."
660
- msgstr ""
661
-
662
- #: templates/admin/admin-mail-options.php:12
663
- msgid "To ( E-mail address )"
664
- msgstr ""
665
-
666
- #: templates/admin/admin-mail-options.php:14
667
- #: templates/admin/admin-mail-options.php:31
668
- #: templates/admin/admin-mail-options.php:36
669
- #: templates/admin/admin-mail-options.php:41
670
- #: templates/admin/mail-options.php:15 templates/admin/mail-options.php:20
671
- msgid "If empty:"
672
- msgstr ""
673
-
674
- #: templates/admin/admin-mail-options.php:17
675
- msgid "CC ( E-mail address )"
676
- msgstr ""
677
-
678
- #: templates/admin/admin-mail-options.php:21
679
- msgid "BCC ( E-mail address )"
680
- msgstr ""
681
-
682
- #: templates/admin/admin-mail-options.php:25 templates/admin/mail-options.php:9
683
- msgid "Subject"
684
- msgstr ""
685
-
686
- #: templates/admin/admin-mail-options.php:29
687
- #: templates/admin/mail-options.php:13
688
- msgid "Sender"
689
- msgstr ""
690
-
691
- #: templates/admin/admin-mail-options.php:34
692
- msgid "Return-Path ( E-mail address )"
693
- msgstr ""
694
-
695
- #: templates/admin/admin-mail-options.php:39
696
- #: templates/admin/mail-options.php:18
697
- msgid "From ( E-mail address )"
698
- msgstr ""
699
-
700
- #: templates/admin/admin-mail-options.php:44
701
- #: templates/admin/mail-options.php:23
702
- msgid "Content"
703
- msgstr ""
704
-
705
- #: templates/admin/form-key.php:4
706
- msgid "Copy and Paste this shortcode."
707
- msgstr ""
708
-
709
- #: templates/admin/form-key.php:5
710
- msgid "The key to use with hook is "
711
- msgstr ""
712
-
713
- #: templates/admin/mail-options.php:27
714
- msgid "Automatic reply email"
715
- msgstr ""
716
-
717
- #: templates/admin/mail-options.php:29
718
- msgid ""
719
- "Input the key to use as transmission to automatic reply email. {} is "
720
- "unnecessary."
721
- msgstr ""
722
-
723
- #: templates/admin/settings.php:9
724
- msgid "Activate Query string of post"
725
- msgstr ""
726
-
727
- #: templates/admin/settings.php:13
728
- msgid ""
729
- "If this field is active, MW WP Form get query string. And get post data from "
730
- "query string \"post_id\". You can use $post's property in editor."
731
- msgstr ""
732
-
733
- #: templates/admin/settings.php:15
734
- msgid "Example: {ID}, {post_title}, {post_meta} etc..."
735
- msgstr ""
736
-
737
- #: templates/admin/settings.php:27
738
- msgid "Saving inquiry data in database"
739
- msgstr ""
740
-
741
- #: templates/admin/settings.php:39
742
- msgid "Enable scrolling of screen transition."
743
- msgstr ""
744
-
745
- #: templates/admin/settings.php:44
746
- msgid "Next Tracking Number"
747
- msgstr ""
748
-
749
- #: templates/admin/settings.php:57
750
- msgid "I want to change."
751
- msgstr ""
752
-
753
- #: templates/admin/settings.php:63
754
- msgid "Akismet Setting"
755
- msgstr ""
756
-
757
- #: templates/admin/settings.php:78
758
- msgid "Input the key to use Akismet."
759
- msgstr ""
760
-
761
- #: templates/admin/style.php:3
762
- msgid "Select Style"
763
- msgstr ""
764
-
765
- #: templates/admin/tag-generator.php:6 templates/chart/index.php:25
766
- msgid "Select this."
767
- msgstr ""
768
-
769
- #: templates/admin/tag-generator.php:7
770
- msgid "Input fields"
771
- msgstr ""
772
-
773
- #: templates/admin/tag-generator.php:10
774
- msgid "Select fields"
775
- msgstr ""
776
-
777
- #: templates/admin/tag-generator.php:13
778
- msgid "Button fields (button)"
779
- msgstr ""
780
-
781
- #: templates/admin/tag-generator.php:16
782
- msgid "Button fields (input)"
783
- msgstr ""
784
-
785
- #: templates/admin/tag-generator.php:19
786
- msgid "Error fields"
787
- msgstr ""
788
-
789
- #: templates/admin/tag-generator.php:22
790
- msgid "Other fields"
791
- msgstr ""
792
-
793
- #: templates/admin/tag-generator.php:26
794
- msgid "Add form tag"
795
- msgstr ""
796
-
797
- #: templates/admin/url.php:4
798
- msgid "Input Page URL"
799
- msgstr ""
800
-
801
- #: templates/admin/url.php:10
802
- msgid "Confirmation Page URL"
803
- msgstr ""
804
-
805
- #: templates/admin/url.php:16
806
- msgid "Complete Page URL"
807
- msgstr ""
808
-
809
- #: templates/admin/url.php:22
810
- msgid "Validation Error Page URL"
811
- msgstr ""
812
-
813
- #: templates/admin/url.php:29
814
- msgid ""
815
- "This urls are the redirection urls at the time of button press. When URL "
816
- "setting is empty, The page redirect on the same page."
817
- msgstr ""
818
-
819
- #: templates/admin/url.php:30
820
- msgid "When a URL doesn't begin http or https, %s is complemented."
821
- msgstr ""
822
-
823
- #: templates/admin/validation-rule.php:1
824
- msgid "Add Validation rule"
825
- msgstr ""
826
-
827
- #: templates/admin/validation-rule.php:9
828
- msgid "The key which applies validation"
829
- msgstr ""
830
-
831
- #: templates/chart/index.php:15
832
- msgid "Add Chart"
833
- msgstr ""
834
-
835
- #: templates/chart/index.php:23
836
- msgid "Item that create chart"
837
- msgstr ""
838
-
839
- #: templates/chart/index.php:31
840
- msgid "Chart type"
841
- msgstr ""
842
-
843
- #: templates/chart/index.php:35
844
- msgid "Pie chart"
845
- msgstr ""
846
-
847
- #: templates/chart/index.php:36
848
- msgid "Bar chart"
849
- msgstr ""
850
-
851
- #: templates/chart/index.php:49
852
- msgid ""
853
- "Separator string (If the check box. If the separator attribute is not set to "
854
- "\",\")"
855
- msgstr ""
856
-
857
- #: templates/chart/index.php:71
858
- #: templates/stores-inquiry-data-form-list/index.php:10
859
- msgid "The number of inquiries"
860
- msgstr ""
861
-
862
- #: templates/contact-data/returning-link.php:2
863
- msgid "&laquo; Back to the list"
864
- msgstr ""
865
-
866
- #: templates/contact-data-list/csv-button.php:2
867
- msgid "CSV Download"
868
- msgstr ""
869
-
870
- #: templates/stores-inquiry-data-form-list/index.php:4
871
- msgid ""
872
- "You can see the inquiry data that are saved in the database by clicking on "
873
- "the link below."
874
- msgstr ""
875
-
876
- #: templates/stores-inquiry-data-form-list/index.php:8
877
- msgid "Form title"
878
- msgstr ""
879
-
880
- #: templates/stores-inquiry-data-form-list/index.php:9
881
- #: templates/stores-inquiry-data-form-list/index.php:18
882
- msgid "Display Chart"
883
- msgstr ""
884
-
885
- #: templates/stores-inquiry-data-form-list/index.php:11
886
- msgid "Updated date"
887
- msgstr ""
888
-
889
- #: templates/stores-inquiry-data-form-list/index.php:12
890
- msgid "Created date"
891
- msgstr ""
892
-
893
- #: templates/stores-inquiry-data-form-list/index.php:19
894
- msgid "cases"
895
- msgstr ""
896
-
897
- #. Plugin Name of the plugin/theme
898
- msgid "MW WP Form"
899
- msgstr ""
900
-
901
- #. Plugin URI of the plugin/theme
902
- msgid "http://plugins.2inc.org/mw-wp-form/"
903
- msgstr ""
904
-
905
- #. Description of the plugin/theme
906
- msgid ""
907
- "MW WP Form is shortcode base contact form plugin. This plugin have many "
908
- "feature. For example you can use many validation rules, contact data saving, "
909
- "and chart aggregation using saved contact data."
910
- msgstr ""
911
-
912
- #. Author of the plugin/theme
913
- msgid "Takashi Kitajima"
914
- msgstr ""
915
-
916
- #. Author URI of the plugin/theme
917
- msgid "http://2inc.org"
918
- msgstr ""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
mw-wp-form.php CHANGED
@@ -2,164 +2,96 @@
2
  /**
3
  * Plugin Name: MW WP Form
4
  * Plugin URI: http://plugins.2inc.org/mw-wp-form/
5
- * Description: MW WP Form is shortcode base contact form plugin. This plugin have many feature. For example you can use many validation rules, contact data saving, and chart aggregation using saved contact data.
6
- * Version: 3.2.3
7
  * Author: Takashi Kitajima
8
- * Author URI: http://2inc.org
9
  * Created : September 25, 2012
10
- * Modified: August 9, 2018
11
  * Text Domain: mw-wp-form
12
- * Domain Path: /languages/
13
  * License: GPLv2 or later
14
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
15
  */
16
  include_once( plugin_dir_path( __FILE__ ) . 'classes/functions.php' );
17
  include_once( plugin_dir_path( __FILE__ ) . 'classes/config.php' );
 
18
 
19
  class MW_WP_Form {
20
 
21
- /**
22
- * フォームフィールドの配列
23
- * @var array
24
- */
25
- protected $form_fields = array();
26
-
27
- /**
28
- * バリデーションルールの配列。順番を固定するために定義が必要
29
- * @var array
30
- */
31
- protected $validation_rules = array(
32
- 'akismet_check' => '',
33
- 'noempty' => '',
34
- 'required' => '',
35
- 'numeric' => '',
36
- 'alpha' => '',
37
- 'alphanumeric' => '',
38
- 'katakana' => '',
39
- 'hiragana' => '',
40
- 'kana' => '',
41
- 'zip' => '',
42
- 'tel' => '',
43
- 'mail' => '',
44
- 'date' => '',
45
- 'month' => '',
46
- 'url' => '',
47
- 'eq' => '',
48
- 'between' => '',
49
- 'minlength' => '',
50
- 'filetype' => '',
51
- 'filesize' => '',
52
- );
53
-
54
- /**
55
- * 日本語の時のみ使用できるバリデーションルール
56
- * @var array
57
- */
58
- protected $validation_rules_only_jp = array(
59
- 'MW_WP_Form_Validation_Rule_Zip',
60
- 'MW_WP_Form_Validation_Rule_Tel',
61
- );
62
-
63
- /**
64
- * 日本語の時のみ使用できるフォーム項目
65
- * @var array
66
- */
67
- protected $form_fields_only_jp = array(
68
- 'MW_WP_Form_Field_Zip',
69
- 'MW_WP_Form_Field_Tel',
70
- );
71
-
72
- /**
73
- * __construct
74
- */
75
  public function __construct() {
76
- add_action( 'plugins_loaded', array( $this, 'load_initialize_files' ), 9 );
77
- add_action( 'plugins_loaded', array( $this, 'initialize' ), 11 );
78
- // 有効化した時の処理
79
- register_activation_hook( __FILE__, array( __CLASS__, 'activation' ) );
80
- // アンインストールした時の処理
81
- register_uninstall_hook( __FILE__, array( __CLASS__, 'uninstall' ) );
82
  }
83
 
84
  /**
85
- * initialize に必要なファイルをロード
 
 
86
  */
87
- public function load_initialize_files() {
88
  $plugin_dir_path = plugin_dir_path( __FILE__ );
89
- include_once( $plugin_dir_path . 'classes/controllers/class.controller.php' );
90
- include_once( $plugin_dir_path . 'classes/controllers/class.admin.php' );
91
- include_once( $plugin_dir_path . 'classes/controllers/class.admin-list.php' );
92
- include_once( $plugin_dir_path . 'classes/controllers/class.stores-inquiry-data-form-list.php' );
93
- include_once( $plugin_dir_path . 'classes/controllers/class.contact-data.php' );
94
- include_once( $plugin_dir_path . 'classes/controllers/class.contact-data-list.php' );
95
- include_once( $plugin_dir_path . 'classes/controllers/class.chart.php' );
96
- include_once( $plugin_dir_path . 'classes/controllers/class.main.php' );
97
- include_once( $plugin_dir_path . 'classes/models/class.abstract-validation-rule.php' );
98
- include_once( $plugin_dir_path . 'classes/models/class.csv.php' );
99
- include_once( $plugin_dir_path . 'classes/models/class.admin.php' );
100
- include_once( $plugin_dir_path . 'classes/models/class.akismet.php' );
101
- include_once( $plugin_dir_path . 'classes/models/class.contact-data.php' );
102
- include_once( $plugin_dir_path . 'classes/models/class.contact-data-setting.php' );
103
- include_once( $plugin_dir_path . 'classes/models/class.data.php' );
104
- include_once( $plugin_dir_path . 'classes/models/class.error.php' );
105
- include_once( $plugin_dir_path . 'classes/models/class.file.php' );
106
- include_once( $plugin_dir_path . 'classes/models/class.abstract-form-field.php' );
107
- include_once( $plugin_dir_path . 'classes/models/class.form.php' );
108
- include_once( $plugin_dir_path . 'classes/models/class.mail.php' );
109
- include_once( $plugin_dir_path . 'classes/models/class.session.php' );
110
- include_once( $plugin_dir_path . 'classes/models/class.setting.php' );
111
- include_once( $plugin_dir_path . 'classes/models/class.validation.php' );
112
- include_once( $plugin_dir_path . 'classes/models/class.json-parser.php' );
113
- include_once( $plugin_dir_path . 'classes/services/class.mail-parser.php' );
114
- include_once( $plugin_dir_path . 'classes/services/class.exec-shortcode.php' );
115
- include_once( $plugin_dir_path . 'classes/services/class.mail.php' );
116
- include_once( $plugin_dir_path . 'classes/services/class.redirected.php' );
117
  }
118
 
119
  /**
120
- * initialize
 
 
121
  */
122
- public function initialize() {
123
- load_plugin_textdomain( 'mw-wp-form', false, basename( dirname( __FILE__ ) ) . '/languages' );
124
 
125
- add_action( 'after_setup_theme', array( $this, 'after_setup_theme' ), 11 );
126
- add_action( 'init', array( $this, 'register_post_type' ) );
127
  }
128
 
129
  /**
130
- * 各管理画面の初期化、もしくはフロント画面の初期化
 
 
131
  */
132
- public function after_setup_theme() {
133
- // フォームフィールドの読み込み、インスタンス化
134
- $this->instantiate_form_fields();
135
-
136
- $plugin_dir_path = plugin_dir_path( __FILE__ );
137
  if ( current_user_can( MWF_Config::CAPABILITY ) && is_admin() ) {
138
- add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
139
- add_action( 'admin_menu' , array( $this, 'admin_menu_for_chart' ) );
140
- add_action( 'admin_menu' , array( $this, 'admin_menu_for_contact_data_list' ) );
141
- add_action( 'admin_init' , array( $this, 'register_setting' ) );
142
- add_action( 'current_screen' , array( $this, 'current_screen' ) );
143
- } elseif ( !is_admin() ) {
144
- $validation_rules = $this->get_validation_rules();
145
- $Controller = new MW_WP_Form_Main_Controller( $validation_rules );
146
- $Controller->initialize();
147
  }
148
  }
149
 
150
  /**
151
- * 共通CSSの読み込み
 
 
152
  */
153
- public function admin_enqueue_scripts() {
154
  $url = plugins_url( MWF_Config::NAME );
155
  wp_enqueue_style( MWF_Config::NAME . '-admin-common', $url . '/css/admin-common.css' );
156
  }
157
 
158
  /**
159
- * グラフページのメニューを追加
 
 
160
  */
161
- public function admin_menu_for_chart() {
162
- $contact_data_post_types = MW_WP_Form_Contact_Data_Setting::get_posts();
163
  if ( empty( $contact_data_post_types ) ) {
164
  return;
165
  }
@@ -170,25 +102,17 @@ class MW_WP_Form {
170
  esc_html__( 'Chart', 'mw-wp-form' ),
171
  MWF_Config::CAPABILITY,
172
  MWF_Config::NAME . '-chart',
173
- array( $this, 'display_chart' )
174
  );
175
  }
176
 
177
  /**
178
- * グラフページを表示
179
- */
180
- public function display_chart() {
181
- // ここでは画面の呼び出しだけ。
182
- // JSの読み込みや画面の表示可否判定は current_screen() で行う(ここでは遅い)。
183
- $Controller = new MW_WP_Form_Chart_Controller();
184
- $Controller->index();
185
- }
186
-
187
- /**
188
- * 問い合わせデータ閲覧ページのメニューを追加
189
  */
190
- public function admin_menu_for_contact_data_list() {
191
- $contact_data_post_types = MW_WP_Form_Contact_Data_Setting::get_posts();
192
  if ( empty( $contact_data_post_types ) ) {
193
  return;
194
  }
@@ -199,88 +123,44 @@ class MW_WP_Form {
199
  __( 'Inquiry data', 'mw-wp-form' ),
200
  MWF_Config::CAPABILITY,
201
  MWF_Config::NAME . '-save-data',
202
- array( $this, 'display_stores_inquiry_data_form_list' )
203
  );
204
  }
205
 
206
  /**
207
- * 問い合わせデータ閲覧ページを表示
208
- */
209
- public function display_stores_inquiry_data_form_list() {
210
- $Controller = new MW_WP_Form_Stores_Inquiry_Data_Form_List_Controller();
211
- $Controller->index();
212
- }
213
-
214
- /**
215
- * グラフページ用の register_setting
216
- */
217
- public function register_setting() {
218
- $formkey = ( !empty( $_GET['formkey'] ) ) ? $_GET['formkey'] : '';
219
- if ( !empty( $_POST[MWF_Config::NAME . '-formkey'] ) ) {
220
- $formkey = $_POST[MWF_Config::NAME . '-formkey'];
221
- }
222
- if ( !empty( $formkey ) ) {
223
- $option_group = MWF_Config::NAME . '-' . 'chart-group';
224
- register_setting(
225
- $option_group,
226
- MWF_Config::NAME . '-chart-' . $formkey,
227
- array( $this, 'sanitize' )
228
- );
229
- }
230
- }
231
-
232
- /**
233
- * グラフページ設定データのサニタイズ
234
- *
235
- * @param array $input フォームから送信されたデータ
236
- * @return array
237
- */
238
- public function sanitize( $input ) {
239
- $new_input = array();
240
- if ( is_array( $input ) && isset( $input['chart'] ) && is_array( $input['chart'] ) ) {
241
- foreach ( $input['chart'] as $key => $value ) {
242
- if ( !empty( $value['target'] ) ) {
243
- $new_input['chart'][$key] = $value;
244
- }
245
- }
246
- }
247
- return $new_input;
248
- }
249
-
250
- /**
251
- * 各画面のコントローラーの呼び出し
252
  *
253
  * @param WP_Screen $screen
 
254
  */
255
- public function current_screen( $screen ) {
256
  if ( $screen->id === MWF_Config::NAME ) {
257
- $validation_rules = $this->get_validation_rules();
258
- $Controller = new MW_WP_Form_Admin_Controller( $validation_rules );
259
- $Controller->initialize();
260
  }
261
- elseif ( $screen->id === 'edit-' . MWF_Config::NAME ) {
262
  $Controller = new MW_WP_Form_Admin_List_Controller();
263
- $Controller->initialize();
264
  }
265
  elseif ( MWF_Functions::is_contact_data_post_type( $screen->id ) ) {
266
  $Controller = new MW_WP_Form_Contact_Data_Controller();
267
- $Controller->initialize();
268
  }
269
  elseif ( preg_match( '/^edit-' . MWF_Config::DBDATA . '\d+$/', $screen->id ) ) {
270
  $Controller = new MW_WP_Form_Contact_Data_List_Controller();
271
- $Controller->initialize();
272
  }
273
  elseif ( $screen->id === MWF_Config::NAME . '_page_' . MWF_Config::NAME . '-chart' ) {
274
  $Controller = new MW_WP_Form_Chart_Controller();
275
- $Controller->initialize();
 
 
276
  }
277
  }
278
 
279
  /**
280
- * 管理画面(カスタム投稿タイプ)の設定
 
 
281
  */
282
- public function register_post_type() {
283
- if ( !current_user_can( MWF_Config::CAPABILITY ) && is_admin() ) {
284
  return;
285
  }
286
 
@@ -303,7 +183,6 @@ class MW_WP_Form {
303
  'show_ui' => true,
304
  ) );
305
 
306
- // MW WP Form のデータベースに保存される問い合わせデータを管理する投稿タイプ
307
  $Admin = new MW_WP_Form_Admin();
308
  $forms = $Admin->get_forms_using_database();
309
  foreach ( $forms as $form ) {
@@ -329,17 +208,15 @@ class MW_WP_Form {
329
  }
330
 
331
  /**
332
- * 有効化した時の処理
333
- */
334
- public static function activation() {
335
- }
336
-
337
- /**
338
- * アンインストールした時の処理
339
  */
340
- public static function uninstall() {
341
  $plugin_dir_path = plugin_dir_path( __FILE__ );
342
  include_once( $plugin_dir_path . 'classes/models/class.admin.php' );
 
 
343
  $Admin = new MW_WP_Form_Admin();
344
  $forms = $Admin->get_forms();
345
 
@@ -351,99 +228,25 @@ class MW_WP_Form {
351
 
352
  foreach ( $data_post_ids as $data_post_id ) {
353
  delete_option( MWF_Config::NAME . '-chart-' . $data_post_id );
 
354
  $data_posts = get_posts( array(
355
  'post_type' => MWF_Functions::get_contact_data_post_type_from_form_id( $data_post_id ),
356
  'posts_per_page' => -1,
357
  ) );
358
- if ( empty( $data_posts ) ) continue;
 
 
 
359
  foreach ( $data_posts as $data_post ) {
360
  wp_delete_post( $data_post->ID, true );
361
  }
362
  }
363
 
364
- include_once( plugin_dir_path( __FILE__ ) . 'classes/models/class.file.php' );
365
  $File = new MW_WP_Form_File();
366
  $File->remove_temp_dir();
367
 
368
  delete_option( MWF_Config::NAME );
369
  }
370
-
371
- /**
372
- * フォームフィールドのインスタンス化。配列にはフックを通して格納する。
373
- */
374
- protected function instantiate_form_fields() {
375
- $plugin_dir_path = plugin_dir_path( __FILE__ );
376
- foreach ( $this->form_fields_only_jp as $key => $value ) {
377
- $this->form_fields_only_jp[$key] = strtolower( $value );
378
- }
379
- foreach ( glob( $plugin_dir_path . './classes/form-fields/*.php' ) as $filename ) {
380
- include_once $filename;
381
- $class_name = $this->get_class_name_from_form_field_filename( $filename );
382
- if ( class_exists( $class_name ) ) {
383
- if ( get_locale() !== 'ja' && in_array( strtolower( $class_name ), $this->form_fields_only_jp ) ) {
384
- continue;
385
- }
386
- new $class_name();
387
- }
388
- }
389
- $this->form_fields = apply_filters( 'mwform_form_fields', $this->form_fields );
390
- }
391
-
392
- /**
393
- * フォーム項目クラスのファイル名からクラス名を取得
394
- *
395
- * @param string $filename ファイル名
396
- * @return string クラス名
397
- */
398
- protected function get_class_name_from_form_field_filename( $filename ) {
399
- $class_name = preg_replace( '/^class\./', '', basename( $filename, '.php' ) );
400
- $class_name = str_replace( '-', '_', $class_name );
401
- $class_name = 'MW_WP_Form_Field_' . $class_name;
402
- return $class_name;
403
- }
404
-
405
- /**
406
- * バリデーションルールのインスタンス化。配列にはフックを通して格納する。
407
- *
408
- * @param string $key フォーム識別子
409
- * @return $validation_rules バリデーションルールオブジェクトの配列
410
- */
411
- protected function get_validation_rules() {
412
- $validation_rules = array();
413
- $plugin_dir_path = plugin_dir_path( __FILE__ );
414
- foreach ( $this->validation_rules_only_jp as $key => $value ) {
415
- $this->validation_rules_only_jp[$key] = strtolower( $value );
416
- }
417
- foreach ( glob( $plugin_dir_path . './classes/validation-rules/*.php' ) as $filename ) {
418
- include_once $filename;
419
- $class_name = $this->get_class_name_from_validation_rule_filename( $filename );
420
- if ( class_exists( $class_name ) ) {
421
- if ( get_locale() !== 'ja' && in_array( strtolower( $class_name ), $this->validation_rules_only_jp ) ) {
422
- continue;
423
- }
424
- $instance = new $class_name();
425
- $this->validation_rules[$instance->getName()] = $instance;
426
- }
427
- }
428
- $this->validation_rules = apply_filters(
429
- 'mwform_validation_rules',
430
- $this->validation_rules,
431
- null // 後方互換性のために残してるだけ
432
- );
433
- return $this->validation_rules;
434
- }
435
-
436
- /**
437
- * バリデーションルールクラスのファイル名からクラス名を取得
438
- *
439
- * @param string $filename ファイル名
440
- * @return string クラス名
441
- */
442
- protected function get_class_name_from_validation_rule_filename( $filename ) {
443
- $class_name = preg_replace( '/^class\./', '', basename( $filename, '.php' ) );
444
- $class_name = str_replace( '-', '_', $class_name );
445
- $class_name = 'MW_WP_Form_Validation_Rule_' . $class_name;
446
- return $class_name;
447
- }
448
  }
 
449
  $MW_WP_Form = new MW_WP_Form();
2
  /**
3
  * Plugin Name: MW WP Form
4
  * Plugin URI: http://plugins.2inc.org/mw-wp-form/
5
+ * Description: MW WP Form is shortcode base contact form plugin. This plugin have many features. For example you can use many validation rules, inquiry data saving, and chart aggregation using saved inquiry data.
6
+ * Version: 4.0.0
7
  * Author: Takashi Kitajima
8
+ * Author URI: https://2inc.org
9
  * Created : September 25, 2012
10
+ * Modified: September 1, 2019
11
  * Text Domain: mw-wp-form
 
12
  * License: GPLv2 or later
13
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
14
  */
15
  include_once( plugin_dir_path( __FILE__ ) . 'classes/functions.php' );
16
  include_once( plugin_dir_path( __FILE__ ) . 'classes/config.php' );
17
+ include_once( plugin_dir_path( __FILE__ ) . 'classes/deprecated.php' );
18
 
19
  class MW_WP_Form {
20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  public function __construct() {
22
+ add_action( 'plugins_loaded', array( $this, '_load_initialize_files' ), 9 );
23
+ add_action( 'plugins_loaded', array( $this, '_initialize' ), 11 );
24
+
25
+ register_uninstall_hook( __FILE__ , array( __CLASS__, '_uninstall' ) );
 
 
26
  }
27
 
28
  /**
29
+ * Load classes
30
+ *
31
+ * @return void
32
  */
33
+ public function _load_initialize_files() {
34
  $plugin_dir_path = plugin_dir_path( __FILE__ );
35
+ $includes = array(
36
+ '/classes/abstract',
37
+ '/classes/controllers',
38
+ '/classes/models',
39
+ '/classes/services',
40
+ '/classes/validation-rules',
41
+ '/classes/form-fields'
42
+ );
43
+ foreach ( $includes as $include ) {
44
+ foreach ( glob( $plugin_dir_path . $include . '/*.php' ) as $file ) {
45
+ require_once( $file );
46
+ }
47
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  }
49
 
50
  /**
51
+ * Load text domain, The starting point of the process
52
+ *
53
+ * @return void
54
  */
55
+ public function _initialize() {
56
+ load_plugin_textdomain( 'mw-wp-form' );
57
 
58
+ add_action( 'after_setup_theme', array( $this, '_after_setup_theme' ), 11 );
59
+ add_action( 'init' , array( $this, '_register_post_type' ) );
60
  }
61
 
62
  /**
63
+ * Initialize each screens
64
+ *
65
+ * @return void
66
  */
67
+ public function _after_setup_theme() {
 
 
 
 
68
  if ( current_user_can( MWF_Config::CAPABILITY ) && is_admin() ) {
69
+ add_action( 'admin_enqueue_scripts', array( $this, '_admin_enqueue_scripts' ) );
70
+ add_action( 'admin_menu' , array( $this, '_admin_menu_for_chart' ) );
71
+ add_action( 'admin_menu' , array( $this, '_admin_menu_for_inquiry_data_list' ) );
72
+ add_action( 'current_screen' , array( $this, '_current_screen' ) );
73
+ } elseif ( ! is_admin() ) {
74
+ $Controller = new MW_WP_Form_Main_Controller();
 
 
 
75
  }
76
  }
77
 
78
  /**
79
+ * Enqueue assets
80
+ *
81
+ * @return void
82
  */
83
+ public function _admin_enqueue_scripts() {
84
  $url = plugins_url( MWF_Config::NAME );
85
  wp_enqueue_style( MWF_Config::NAME . '-admin-common', $url . '/css/admin-common.css' );
86
  }
87
 
88
  /**
89
+ * Add admin menu for chart
90
+ *
91
+ * @return void
92
  */
93
+ public function _admin_menu_for_chart() {
94
+ $contact_data_post_types = MW_WP_Form_Contact_Data_Setting::get_form_post_types();
95
  if ( empty( $contact_data_post_types ) ) {
96
  return;
97
  }
102
  esc_html__( 'Chart', 'mw-wp-form' ),
103
  MWF_Config::CAPABILITY,
104
  MWF_Config::NAME . '-chart',
105
+ '__return_false'
106
  );
107
  }
108
 
109
  /**
110
+ * Add admin menu for saved inquiry data
111
+ *
112
+ * @return void
 
 
 
 
 
 
 
 
113
  */
114
+ public function _admin_menu_for_inquiry_data_list() {
115
+ $contact_data_post_types = MW_WP_Form_Contact_Data_Setting::get_form_post_types();
116
  if ( empty( $contact_data_post_types ) ) {
117
  return;
118
  }
123
  __( 'Inquiry data', 'mw-wp-form' ),
124
  MWF_Config::CAPABILITY,
125
  MWF_Config::NAME . '-save-data',
126
+ '__return_false'
127
  );
128
  }
129
 
130
  /**
131
+ * Front controller
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
132
  *
133
  * @param WP_Screen $screen
134
+ * @return void
135
  */
136
+ public function _current_screen( $screen ) {
137
  if ( $screen->id === MWF_Config::NAME ) {
138
+ $Controller = new MW_WP_Form_Admin_Controller();
 
 
139
  }
140
+ elseif ( 'edit-' . MWF_Config::NAME === $screen->id ) {
141
  $Controller = new MW_WP_Form_Admin_List_Controller();
 
142
  }
143
  elseif ( MWF_Functions::is_contact_data_post_type( $screen->id ) ) {
144
  $Controller = new MW_WP_Form_Contact_Data_Controller();
 
145
  }
146
  elseif ( preg_match( '/^edit-' . MWF_Config::DBDATA . '\d+$/', $screen->id ) ) {
147
  $Controller = new MW_WP_Form_Contact_Data_List_Controller();
 
148
  }
149
  elseif ( $screen->id === MWF_Config::NAME . '_page_' . MWF_Config::NAME . '-chart' ) {
150
  $Controller = new MW_WP_Form_Chart_Controller();
151
+ }
152
+ elseif ( $screen->id === MWF_Config::NAME . '_page_' . MWF_Config::NAME . '-save-data' ) {
153
+ $Controller = new MW_WP_Form_Stores_Inquiry_Data_Form_List_Controller();
154
  }
155
  }
156
 
157
  /**
158
+ * Register post types for MW WP Form and inquiry data
159
+ *
160
+ * @return void
161
  */
162
+ public function _register_post_type() {
163
+ if ( ! current_user_can( MWF_Config::CAPABILITY ) && is_admin() ) {
164
  return;
165
  }
166
 
183
  'show_ui' => true,
184
  ) );
185
 
 
186
  $Admin = new MW_WP_Form_Admin();
187
  $forms = $Admin->get_forms_using_database();
188
  foreach ( $forms as $form ) {
208
  }
209
 
210
  /**
211
+ * Uninstall processes
212
+ *
213
+ * @return void
 
 
 
 
214
  */
215
+ public static function _uninstall() {
216
  $plugin_dir_path = plugin_dir_path( __FILE__ );
217
  include_once( $plugin_dir_path . 'classes/models/class.admin.php' );
218
+ include_once( $plugin_dir_path . 'classes/models/class.file.php' );
219
+
220
  $Admin = new MW_WP_Form_Admin();
221
  $forms = $Admin->get_forms();
222
 
228
 
229
  foreach ( $data_post_ids as $data_post_id ) {
230
  delete_option( MWF_Config::NAME . '-chart-' . $data_post_id );
231
+
232
  $data_posts = get_posts( array(
233
  'post_type' => MWF_Functions::get_contact_data_post_type_from_form_id( $data_post_id ),
234
  'posts_per_page' => -1,
235
  ) );
236
+ if ( empty( $data_posts ) ) {
237
+ continue;
238
+ }
239
+
240
  foreach ( $data_posts as $data_post ) {
241
  wp_delete_post( $data_post->ID, true );
242
  }
243
  }
244
 
 
245
  $File = new MW_WP_Form_File();
246
  $File->remove_temp_dir();
247
 
248
  delete_option( MWF_Config::NAME );
249
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
250
  }
251
+
252
  $MW_WP_Form = new MW_WP_Form();
readme.txt CHANGED
@@ -3,12 +3,12 @@ Contributors: inc2734, ryu263, tomothumb, nanniku, mt8.biz, NExt-Season, kuck1u,
3
  Donate link: http://www.amazon.co.jp/registry/wishlist/39ANKRNSTNW40
4
  Tags: plugin, form, confirm, preview, shortcode, mail, chart, graph, html, contact form, form creation, form creator, form manager, form builder, custom form
5
  Requires at least: 4.0
6
- Tested up to: 4.9.7
7
- Stable tag: 3.2.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
- MW WP Form is shortcode base contact form plugin. This plugin have many feature. For example you can use many validation rules, contact data saving, and chart aggregation using saved contact data.
12
 
13
  == Description ==
14
 
@@ -18,21 +18,12 @@ MW WP Form can create mail form with a confirmation screen using shortcode.
18
  * Using confirmation page is possible.
19
  * The page changes by the same URL or individual URL are possible.
20
  * Many validation rules
21
- * Saving contact data is possible.
22
- * Displaying Chart using saved contact data is possible.
23
-
24
- MW WP Form はショートコードを使って確認画面付きのメールフォームを作成することができるプラグインです。
25
-
26
- * ショートコードを使用したフォーム生成
27
- * 確認画面が表示可能
28
- * 同一URL・個別URLでの画面変遷が可能
29
- * 豊富なバリデーションルール
30
- * 問い合わせデータを保存可能
31
- * 保存した問い合わせデータをグラフ可能
32
 
33
  = Official =
34
 
35
- http://plugins.2inc.org/mw-wp-form/
36
 
37
  = GitHub =
38
 
@@ -45,7 +36,7 @@ Source: https://developers.google.com/chart/
45
 
46
  = Contributors =
47
 
48
- * [Takashi Kitajima](http://2inc.org) ( [inc2734](http://profiles.wordpress.org/inc2734) )
49
  * [Ryujiro Yamamoto](http://webcre-archive.com) ( [ryu263](http://profiles.wordpress.org/ryu263) )
50
  * [Tsujimoto Tomoyuki](http://kee-non.com) ( [tomothumb](http://profiles.wordpress.org/tomothumb) )
51
  * [Naoyuki Ohata] ( [nanniku](http://profiles.wordpress.org/nanniku) )
@@ -80,6 +71,22 @@ Do you have questions or issues with MW WP Form? Use these support channels appr
80
 
81
  == Changelog ==
82
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  = 3.2.3 =
84
  * Added : Added filter hook mwform_response_statuses_mwf_xxx
85
 
3
  Donate link: http://www.amazon.co.jp/registry/wishlist/39ANKRNSTNW40
4
  Tags: plugin, form, confirm, preview, shortcode, mail, chart, graph, html, contact form, form creation, form creator, form manager, form builder, custom form
5
  Requires at least: 4.0
6
+ Tested up to: 4.9.8
7
+ Stable tag: 4.0.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
+ MW WP Form is shortcode base contact form plugin. This plugin have many features. For example you can use many validation rules, inquiry data saving, and chart aggregation using saved inquiry data.
12
 
13
  == Description ==
14
 
18
  * Using confirmation page is possible.
19
  * The page changes by the same URL or individual URL are possible.
20
  * Many validation rules
21
+ * Saving inquiry data is possible.
22
+ * Displaying Chart using saved inquiry data is possible.
 
 
 
 
 
 
 
 
 
23
 
24
  = Official =
25
 
26
+ https://plugins.2inc.org/mw-wp-form/
27
 
28
  = GitHub =
29
 
36
 
37
  = Contributors =
38
 
39
+ * [Takashi Kitajima](https://2inc.org) ( [inc2734](http://profiles.wordpress.org/inc2734) )
40
  * [Ryujiro Yamamoto](http://webcre-archive.com) ( [ryu263](http://profiles.wordpress.org/ryu263) )
41
  * [Tsujimoto Tomoyuki](http://kee-non.com) ( [tomothumb](http://profiles.wordpress.org/tomothumb) )
42
  * [Naoyuki Ohata] ( [nanniku](http://profiles.wordpress.org/nanniku) )
71
 
72
  == Changelog ==
73
 
74
+ = 4.0.0 =
75
+ * Refactoring
76
+ * Update redirect process.
77
+ * Changed that admin and reply Mail settings are required.
78
+ * Changed to be able to set the form besides $post and main template.
79
+ * Each input fields can overwrite from themes.
80
+ * Deprecated action hook `mwform_exec_shortcode`. Please use this instead `mwform_start_main_process`
81
+ * The hook to `mwform_validation_rules` is no longer needed to add your own validation rule.
82
+ * Deprecated `MW_WP_Form_Contact_Data_Setting::get_posts()`. Please use this instead `MW_WP_Form_Contact_Data_Setting::get_form_post_types()`
83
+ * Added method MW_WP_Form_Data::get_saved_mail_id();
84
+ * Added method MW_WP_Form_Data::set_saved_mail_id();
85
+ * Deprecated `MW_WP_Form_Data::getInstance()`. Please use this instead `MW_WP_Form_Data::connect()`
86
+ * Deprecated `MW_WP_Form_Form::remove_linefeed_space()`. Please use this instead `MW_WP_Form_Form::remove_newline_space()`
87
+ * Deprecated `MW_WP_Form_Validation::check()`. Please use this instead `MW_WP_Form_Validation::is_valid()`
88
+ * Deprecated `MW_WP_Form_Validation::single_check()`. Please use this instead `MW_WP_Form_Validation::is_valid_field()`
89
+
90
  = 3.2.3 =
91
  * Added : Added filter hook mwform_response_statuses_mwf_xxx
92
 
templates/admin/admin-mail-options.php CHANGED
@@ -1,46 +1,45 @@
1
  <p>
2
- <?php esc_html_e( '{key} is converted form data.', 'mw-wp-form' ); ?>
3
  <?php echo sprintf(
4
  esc_html__( 'It is automatically converted to Tracking number when you input {%s}.', 'mw-wp-form' ),
5
  MWF_Config::TRACKINGNUMBER
6
  ); ?>
7
  </p>
8
- <p>
9
- <?php esc_html_e( 'If Admin Email Options is a blank, Automatic Replay Email Options is used as Admin Email Options.', 'mw-wp-form' ); ?>
10
- </p>
11
  <p>
12
  <b><?php esc_html_e( 'To ( E-mail address )', 'mw-wp-form' ); ?></b><br />
13
- <input type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[mail_to]" value="<?php echo esc_attr( $mail_to ); ?>" /><br />
14
- <span class="mwf_note"><?php esc_html_e( 'If empty:', 'mw-wp-form' ); ?> <?php bloginfo( 'admin_email' ); ?></span>
15
  </p>
16
  <p>
17
  <b><?php esc_html_e( 'CC ( E-mail address )', 'mw-wp-form' ); ?></b><br />
18
- <input type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[mail_cc]" value="<?php echo esc_attr( $mail_cc ); ?>" />
19
  </p>
20
  <p>
21
  <b><?php esc_html_e( 'BCC ( E-mail address )', 'mw-wp-form' ); ?></b><br />
22
- <input type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[mail_bcc]" value="<?php echo esc_attr( $mail_bcc ); ?>" />
23
  </p>
24
  <p>
25
  <b><?php esc_html_e( 'Subject', 'mw-wp-form' ); ?></b><br />
26
- <input type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[admin_mail_subject]" value="<?php echo esc_attr( $admin_mail_subject ); ?>" />
27
  </p>
28
  <p>
29
  <b><?php esc_html_e( 'Sender', 'mw-wp-form' ); ?></b><br />
30
- <input type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[admin_mail_sender]" value="<?php echo esc_attr( $admin_mail_sender ); ?>" /><br />
31
- <span class="mwf_note"><?php esc_html_e( 'If empty:', 'mw-wp-form' ); ?> <?php bloginfo( 'name' ); ?></span>
32
  </p>
33
  <p>
34
- <b><?php esc_html_e( 'Return-Path ( E-mail address )', 'mw-wp-form' ); ?></b><br />
35
- <input type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[mail_return_path]" value="<?php echo esc_attr( $mail_return_path ); ?>" /><br />
36
- <span class="mwf_note"><?php esc_html_e( 'If empty:', 'mw-wp-form' ); ?> <?php bloginfo( 'admin_email' ); ?></span>
37
  </p>
38
  <p>
39
- <b><?php esc_html_e( 'From ( E-mail address )', 'mw-wp-form' ); ?></b><br />
40
- <input type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[admin_mail_from]" value="<?php echo esc_attr( $admin_mail_from ); ?>" /><br />
41
- <span class="mwf_note"><?php esc_html_e( 'If empty:', 'mw-wp-form' ); ?> <?php bloginfo( 'admin_email' ); ?></span>
42
  </p>
43
  <p>
44
- <b><?php esc_html_e( 'Content', 'mw-wp-form' ); ?></b><br />
45
- <textarea name="<?php echo esc_attr( MWF_Config::NAME ); ?>[admin_mail_content]" cols="30" rows="10"><?php echo esc_attr( $admin_mail_content ); ?></textarea>
 
 
 
 
 
 
46
  </p>
1
  <p>
2
+ <?php esc_html_e( '{name of form tag} is converted to posted data.', 'mw-wp-form' ); ?>
3
  <?php echo sprintf(
4
  esc_html__( 'It is automatically converted to Tracking number when you input {%s}.', 'mw-wp-form' ),
5
  MWF_Config::TRACKINGNUMBER
6
  ); ?>
7
  </p>
 
 
 
8
  <p>
9
  <b><?php esc_html_e( 'To ( E-mail address )', 'mw-wp-form' ); ?></b><br />
10
+ <input class="widefat" type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[mail_to]" value="<?php echo esc_attr( $mail_to ); ?>" />
 
11
  </p>
12
  <p>
13
  <b><?php esc_html_e( 'CC ( E-mail address )', 'mw-wp-form' ); ?></b><br />
14
+ <input class="widefat" type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[mail_cc]" value="<?php echo esc_attr( $mail_cc ); ?>" />
15
  </p>
16
  <p>
17
  <b><?php esc_html_e( 'BCC ( E-mail address )', 'mw-wp-form' ); ?></b><br />
18
+ <input class="widefat" type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[mail_bcc]" value="<?php echo esc_attr( $mail_bcc ); ?>" />
19
  </p>
20
  <p>
21
  <b><?php esc_html_e( 'Subject', 'mw-wp-form' ); ?></b><br />
22
+ <input class="widefat" type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[admin_mail_subject]" value="<?php echo esc_attr( $admin_mail_subject ); ?>" />
23
  </p>
24
  <p>
25
  <b><?php esc_html_e( 'Sender', 'mw-wp-form' ); ?></b><br />
26
+ <input class="widefat" type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[admin_mail_sender]" value="<?php echo esc_attr( $admin_mail_sender ); ?>" />
 
27
  </p>
28
  <p>
29
+ <b><?php esc_html_e( 'Reply-to ( E-mail address )', 'mw-wp-form' ); ?></b><br />
30
+ <input class="widefat" type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[admin_mail_reply_to]" value="<?php echo esc_attr( $admin_mail_reply_to ); ?>" />
 
31
  </p>
32
  <p>
33
+ <b><?php esc_html_e( 'Content', 'mw-wp-form' ); ?></b><br />
34
+ <textarea class="widefat" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[admin_mail_content]" cols="30" rows="10"><?php echo esc_attr( $admin_mail_content ); ?></textarea>
 
35
  </p>
36
  <p>
37
+ <b><?php esc_html_e( 'Return-Path ( E-mail address )', 'mw-wp-form' ); ?></b><br />
38
+ <input class="widefat" type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[mail_return_path]" value="<?php echo esc_attr( $mail_return_path ); ?>" />
39
+ <span class="mwf_note"><?php esc_html_e( 'Optional. You should specify an email address in the same domain as your server.', 'mw-wp-form' ); ?></span>
40
+ </p>
41
+ <p>
42
+ <b><?php esc_html_e( 'From ( E-mail address )', 'mw-wp-form' ); ?></b><br />
43
+ <input class="widefat" type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[admin_mail_from]" value="<?php echo esc_attr( $admin_mail_from ); ?>" />
44
+ <span class="mwf_note"><?php esc_html_e( 'Optional. You should specify an email address in the same domain as your server.', 'mw-wp-form' ); ?></span>
45
  </p>
templates/admin/complete-message.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ wp_editor(
3
+ $this->_get_option( 'complete_message' ),
4
+ MWF_Config::NAME . '_complete_message',
5
+ array(
6
+ 'textarea_name' => MWF_Config::NAME . '[complete_message]',
7
+ 'textarea_rows' => 7,
8
+ )
9
+ );
10
+ ?>
11
+ <p class="mwf_note">
12
+ <?php esc_html_e( '{name of form tag} is converted to posted data.', 'mw-wp-form' ); ?>
13
+ <?php echo sprintf(
14
+ esc_html__( 'It is automatically converted to Tracking number when you input {%s}.', 'mw-wp-form' ),
15
+ MWF_Config::TRACKINGNUMBER
16
+ ); ?>
17
+ </p>
templates/admin/mail-options.php CHANGED
@@ -1,5 +1,5 @@
1
  <p>
2
- <?php esc_html_e( '{key} is converted form data.', 'mw-wp-form' ); ?>
3
  <?php echo sprintf(
4
  esc_html__( 'It is automatically converted to Tracking number when you input {%s}.', 'mw-wp-form' ),
5
  MWF_Config::TRACKINGNUMBER
@@ -7,24 +7,27 @@
7
  </p>
8
  <p>
9
  <b><?php esc_html_e( 'Subject', 'mw-wp-form' ); ?></b><br />
10
- <input type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[mail_subject]" value="<?php echo esc_attr( $mail_subject ); ?>" />
11
  </p>
12
  <p>
13
  <b><?php esc_html_e( 'Sender', 'mw-wp-form' ); ?></b><br />
14
- <input type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[mail_sender]" value="<?php echo esc_attr( $mail_sender ); ?>" /><br />
15
- <span class="mwf_note"><?php esc_html_e( 'If empty:', 'mw-wp-form' ); ?> <?php bloginfo( 'name' ); ?></span>
16
  </p>
17
  <p>
18
- <b><?php esc_html_e( 'From ( E-mail address )', 'mw-wp-form' ); ?></b><br />
19
- <input type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[mail_from]" value="<?php echo esc_attr( $mail_from ); ?>" /><br />
20
- <span class="mwf_note"><?php esc_html_e( 'If empty:', 'mw-wp-form' ); ?> <?php bloginfo( 'admin_email' ); ?></span>
21
  </p>
22
  <p>
23
  <b><?php esc_html_e( 'Content', 'mw-wp-form' ); ?></b><br />
24
- <textarea name="<?php echo esc_attr( MWF_Config::NAME ); ?>[mail_content]" cols="30" rows="10"><?php echo esc_attr( $mail_content ); ?></textarea>
25
  </p>
26
  <p>
27
  <b><?php esc_html_e( 'Automatic reply email', 'mw-wp-form' ); ?></b><br />
28
- <input type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[automatic_reply_email]" value="<?php echo esc_attr( $automatic_reply_email ); ?>" /><br />
29
  <span class="mwf_note"><?php esc_html_e( 'Input the key to use as transmission to automatic reply email. {} is unnecessary.', 'mw-wp-form' ); ?></span>
30
  </p>
 
 
 
 
 
1
  <p>
2
+ <?php esc_html_e( '{name of form tag} is converted to posted data.', 'mw-wp-form' ); ?>
3
  <?php echo sprintf(
4
  esc_html__( 'It is automatically converted to Tracking number when you input {%s}.', 'mw-wp-form' ),
5
  MWF_Config::TRACKINGNUMBER
7
  </p>
8
  <p>
9
  <b><?php esc_html_e( 'Subject', 'mw-wp-form' ); ?></b><br />
10
+ <input class="widefat" type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[mail_subject]" value="<?php echo esc_attr( $mail_subject ); ?>" />
11
  </p>
12
  <p>
13
  <b><?php esc_html_e( 'Sender', 'mw-wp-form' ); ?></b><br />
14
+ <input class="widefat" type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[mail_sender]" value="<?php echo esc_attr( $mail_sender ); ?>" />
 
15
  </p>
16
  <p>
17
+ <b><?php esc_html_e( 'Reply-to ( E-mail address )', 'mw-wp-form' ); ?></b><br />
18
+ <input class="widefat" type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[mail_reply_to]" value="<?php echo esc_attr( $mail_reply_to ); ?>" />
 
19
  </p>
20
  <p>
21
  <b><?php esc_html_e( 'Content', 'mw-wp-form' ); ?></b><br />
22
+ <textarea class="widefat" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[mail_content]" cols="30" rows="10"><?php echo esc_attr( $mail_content ); ?></textarea>
23
  </p>
24
  <p>
25
  <b><?php esc_html_e( 'Automatic reply email', 'mw-wp-form' ); ?></b><br />
26
+ <input class="widefat" type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[automatic_reply_email]" value="<?php echo esc_attr( $automatic_reply_email ); ?>" /><br />
27
  <span class="mwf_note"><?php esc_html_e( 'Input the key to use as transmission to automatic reply email. {} is unnecessary.', 'mw-wp-form' ); ?></span>
28
  </p>
29
+ <p>
30
+ <b><?php esc_html_e( 'From ( E-mail address )', 'mw-wp-form' ); ?></b><br />
31
+ <input class="widefat" type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[mail_from]" value="<?php echo esc_attr( $mail_from ); ?>" />
32
+ <span class="mwf_note"><?php esc_html_e( 'Optional. You should specify an email address in the same domain as your server.', 'mw-wp-form' ); ?></span>
33
+ </p>
templates/admin/validation-rule.php CHANGED
@@ -19,4 +19,4 @@
19
  <!-- end .repeatable-box-content --></div>
20
  <!-- end .repeatable-box --></div>
21
  <?php endforeach; ?>
22
- <!-- end .repeatable-boxes --></div>
19
  <!-- end .repeatable-box-content --></div>
20
  <!-- end .repeatable-box --></div>
21
  <?php endforeach; ?>
22
+ <!-- end .repeatable-boxes --></div>
templates/chart/index.php CHANGED
@@ -5,10 +5,9 @@
5
  :
6
  <?php echo esc_html( get_the_title( $post_id ) ); ?>
7
  </h2>
8
- <form method="post" action="options.php">
9
  <?php
10
- settings_fields( $option_group );
11
- do_settings_sections( $option_group );
12
  ?>
13
  <div id="<?php echo esc_attr( MWF_Config::NAME . '_chart' ); ?>" class="postbox">
14
  <div class="inside">
@@ -60,8 +59,8 @@
60
 
61
  <?php
62
  foreach ( $postdata as $postdata_key => $chart ) {
63
- if ( !isset( $custom_keys[$chart['target']] ) ) {
64
- unset( $postdata[$postdata_key] );
65
  continue;
66
  }
67
  printf(
@@ -78,35 +77,35 @@
78
  foreach ( $postdata as $postdata_key => $chart ) {
79
  $data = array();
80
  $raw_data = array();
81
- foreach ( $custom_keys[$chart['target']] as $item => $values ) {
82
  if ( $chart['separator'] && strstr( $item, $chart['separator'] ) ) {
83
  $item = explode( $chart['separator'] , $item );
84
  }
85
  if ( is_array( $item ) ) {
86
  foreach ( $item as $_item ) {
87
- if ( $_item === '' ) {
88
  $_item = '(Empty)';
89
  }
90
- if ( empty( $raw_data[$_item] ) ) {
91
- $raw_data[$_item] = count( $values );
92
  } else {
93
- $raw_data[$_item] += count( $values );
94
  }
95
  }
96
  } else {
97
- if ( $item === '' ) {
98
  $item = '(Empty)';
99
  }
100
- if ( empty( $raw_data[$item] ) ) {
101
- $raw_data[$item] = count( $values );
102
  } else {
103
- $raw_data[$item] += count( $values );
104
  }
105
  }
106
  }
107
  $data[] = array( '', '' );
108
  foreach ( $raw_data as $raw_data_key => $raw_data_value ) {
109
- if ( $chart['chart'] === 'bar' ) {
110
  $value = $raw_data_value / count( $form_posts );
111
  } else {
112
  $value = $raw_data_value;
@@ -116,7 +115,7 @@
116
  $value,
117
  );
118
  }
119
- $chart_data[$postdata_key] = array(
120
  'chart' => $chart['chart'],
121
  'data' => $data,
122
  );
5
  :
6
  <?php echo esc_html( get_the_title( $post_id ) ); ?>
7
  </h2>
8
+ <form method="post" action="">
9
  <?php
10
+ wp_nonce_field( MWF_Config::NAME . '-chart-action', MWF_Config::NAME . '-chart-nonce-field' );
 
11
  ?>
12
  <div id="<?php echo esc_attr( MWF_Config::NAME . '_chart' ); ?>" class="postbox">
13
  <div class="inside">
59
 
60
  <?php
61
  foreach ( $postdata as $postdata_key => $chart ) {
62
+ if ( ! isset( $custom_keys[ $chart['target'] ] ) ) {
63
+ unset( $postdata[ $postdata_key ] );
64
  continue;
65
  }
66
  printf(
77
  foreach ( $postdata as $postdata_key => $chart ) {
78
  $data = array();
79
  $raw_data = array();
80
+ foreach ( $custom_keys[ $chart['target'] ] as $item => $values ) {
81
  if ( $chart['separator'] && strstr( $item, $chart['separator'] ) ) {
82
  $item = explode( $chart['separator'] , $item );
83
  }
84
  if ( is_array( $item ) ) {
85
  foreach ( $item as $_item ) {
86
+ if ( '' === $_item ) {
87
  $_item = '(Empty)';
88
  }
89
+ if ( empty( $raw_data[ $_item ] ) ) {
90
+ $raw_data[ $_item ] = count( $values );
91
  } else {
92
+ $raw_data[ $_item ] += count( $values );
93
  }
94
  }
95
  } else {
96
+ if ( '' === $item ) {
97
  $item = '(Empty)';
98
  }
99
+ if ( empty( $raw_data[ $item ] ) ) {
100
+ $raw_data[ $item ] = count( $values );
101
  } else {
102
+ $raw_data[ $item ] += count( $values );
103
  }
104
  }
105
  }
106
  $data[] = array( '', '' );
107
  foreach ( $raw_data as $raw_data_key => $raw_data_value ) {
108
+ if ( 'bar' === $chart['chart'] ) {
109
  $value = $raw_data_value / count( $form_posts );
110
  } else {
111
  $value = $raw_data_value;
115
  $value,
116
  );
117
  }
118
+ $chart_data[ $postdata_key ] = array(
119
  'chart' => $chart['chart'],
120
  'data' => $data,
121
  );
templates/contact-data/detail.php CHANGED
@@ -6,20 +6,20 @@
6
  $_columns = array();
7
  foreach ( $values as $key => $value ) {
8
  if ( $key === MWF_Config::TRACKINGNUMBER ) {
9
- $columns[$key] = MWF_Functions::get_tracking_number_title( $post_type );
10
  continue;
11
  }
12
  if ( in_array( $key, $Contact_Data_Setting->get_permit_keys() ) ) {
13
  continue;
14
  }
15
- $_columns[$key] = $key;
16
  }
17
  $_columns = apply_filters( 'mwform_inquiry_data_columns-' . $post_type, $_columns );
18
  $columns = array_merge( $columns, $_columns );
19
  ?>
20
 
21
  <?php foreach ( $columns as $key => $label ) : ?>
22
- <?php if ( isset( $values[$key] ) ) : ?>
23
  <tr>
24
  <th>
25
  <?php
@@ -32,14 +32,14 @@
32
  </th>
33
  <td>
34
  <?php
35
- if ( $Contact_Data_Setting->is_upload_file_key( $post, $key ) ) {
36
  // 過去バージョンでの不具合でメタデータが空になっていることがあるのでその場合は代替処理
37
- if ( $values[$key] === '' ) {
38
- $values[$key] = MWF_Functions::get_multimedia_id__fallback( $post, $key );
39
  }
40
- echo MWF_Functions::get_multimedia_data( $values[$key] );
41
  } else {
42
- echo nl2br( esc_html( $values[$key] ) );
43
  }
44
  ?>
45
  </td>
@@ -49,7 +49,7 @@
49
  <tr>
50
  <th><?php esc_html_e( 'Response Status', 'mw-wp-form' ); ?></th>
51
  <td>
52
- <select name="<?php echo esc_attr( MWF_Config::CONTACT_DATA_NAME ); ?>[response_status]">
53
  <?php foreach ( $Contact_Data_Setting->get_response_statuses() as $key => $value ) : ?>
54
  <option value="<?php echo esc_attr( $key ); ?>" <?php selected( $key, $Contact_Data_Setting->get( 'response_status' ) ); ?>>
55
  <?php echo esc_html( $value ); ?>
@@ -60,6 +60,6 @@
60
  </tr>
61
  <tr>
62
  <th><?php esc_html_e( 'Memo', 'mw-wp-form' ); ?></th>
63
- <td><textarea name="<?php echo esc_attr( MWF_Config::CONTACT_DATA_NAME ); ?>[memo]" cols="50" rows="5"><?php echo $Contact_Data_Setting->get( 'memo' ); ?></textarea></td>
64
  </tr>
65
  </table>
6
  $_columns = array();
7
  foreach ( $values as $key => $value ) {
8
  if ( $key === MWF_Config::TRACKINGNUMBER ) {
9
+ $columns[ $key ] = MWF_Functions::get_tracking_number_title( $post_type );
10
  continue;
11
  }
12
  if ( in_array( $key, $Contact_Data_Setting->get_permit_keys() ) ) {
13
  continue;
14
  }
15
+ $_columns[ $key ] = $key;
16
  }
17
  $_columns = apply_filters( 'mwform_inquiry_data_columns-' . $post_type, $_columns );
18
  $columns = array_merge( $columns, $_columns );
19
  ?>
20
 
21
  <?php foreach ( $columns as $key => $label ) : ?>
22
+ <?php if ( isset( $values[ $key ] ) ) : ?>
23
  <tr>
24
  <th>
25
  <?php
32
  </th>
33
  <td>
34
  <?php
35
+ if ( $Contact_Data_Setting->is_upload_file_key( $key ) ) {
36
  // 過去バージョンでの不具合でメタデータが空になっていることがあるのでその場合は代替処理
37
+ if ( '' === $values[ $key ] ) {
38
+ $values[ $key ] = MWF_Functions::get_multimedia_id__fallback( $post, $key );
39
  }
40
+ echo MWF_Functions::get_multimedia_data( $values[ $key ] );
41
  } else {
42
+ echo nl2br( esc_html( $values[ $key ] ) );
43
  }
44
  ?>
45
  </td>
49
  <tr>
50
  <th><?php esc_html_e( 'Response Status', 'mw-wp-form' ); ?></th>
51
  <td>
52
+ <select name="<?php echo esc_attr( MWF_Config::INQUIRY_DATA_NAME ); ?>[response_status]">
53
  <?php foreach ( $Contact_Data_Setting->get_response_statuses() as $key => $value ) : ?>
54
  <option value="<?php echo esc_attr( $key ); ?>" <?php selected( $key, $Contact_Data_Setting->get( 'response_status' ) ); ?>>
55
  <?php echo esc_html( $value ); ?>
60
  </tr>
61
  <tr>
62
  <th><?php esc_html_e( 'Memo', 'mw-wp-form' ); ?></th>
63
+ <td><textarea name="<?php echo esc_attr( MWF_Config::INQUIRY_DATA_NAME ); ?>[memo]" cols="50" rows="5"><?php echo $Contact_Data_Setting->get( 'memo' ); ?></textarea></td>
64
  </tr>
65
  </table>
templates/form-fields/button.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <input type="button"
2
+ name="<?php echo esc_attr( $name ); ?>"
3
+ value="<?php echo esc_attr( $value ); ?>"
4
+ <?php echo MWF_Functions::generate_input_attribute( 'class', $class ); ?>
5
+ />
templates/form-fields/button_button.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <button type="button"
2
+ name="<?php echo esc_attr( $name ); ?>"
3
+ value="<?php echo esc_attr( $value ); ?>"
4
+ <?php echo MWF_Functions::generate_input_attribute( 'class', $class ); ?>
5
+ ><?php echo wp_kses_post( $element_content ); ?></button>
templates/form-fields/button_submit.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <button type="submit"
2
+ name="<?php echo esc_attr( $name ); ?>"
3
+ value="<?php echo esc_attr( $value ); ?>"
4
+ <?php echo MWF_Functions::generate_input_attribute( 'class', $class ); ?>
5
+ ><?php echo wp_kses_post( $element_content ); ?></button>
templates/form-fields/checkbox.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( 'true' === $vertically ) {
3
+ $vertically_class = 'vertical-item';
4
+ } else {
5
+ $vertically_class = 'horizontal-item';
6
+ }
7
+ ?>
8
+ <?php foreach ( $fields as $field_value => $field ) : ?>
9
+ <span class="mwform-checkbox-field <?php echo esc_attr( $vertically_class ); ?>">
10
+ <label <?php echo MWF_Functions::generate_input_attribute( 'for', $field['id'] ); ?>>
11
+ <input type="checkbox"
12
+ name="<?php echo esc_attr( $field['name'] ); ?>"
13
+ value="<?php echo esc_attr( $field_value ); ?>"
14
+ <?php checked( in_array( $field_value, $value ), true, true ); ?>
15
+ <?php echo MWF_Functions::generate_input_attribute( 'id', $field['id'] ); ?>
16
+ <?php echo MWF_Functions::generate_input_attribute( 'class', $field['class'] ); ?>
17
+ />
18
+ <span class="mwform-checkbox-field-text"><?php echo esc_attr( $field['label'] ); ?></span>
19
+ </label>
20
+ </span>
21
+ <?php endforeach; ?>
templates/form-fields/datepicker.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <input type="text"
2
+ name="<?php echo esc_attr( $name ); ?>"
3
+ <?php echo MWF_Functions::generate_input_attribute( 'id', $id ); ?>
4
+ <?php echo MWF_Functions::generate_input_attribute( 'class', $class ); ?>
5
+ <?php echo MWF_Functions::generate_input_attribute( 'size', $size ); ?>
6
+ <?php echo MWF_Functions::generate_input_attribute( 'value', $value ); ?>
7
+ <?php echo MWF_Functions::generate_input_attribute( 'placeholder', $placeholder ); ?>
8
+ />
9
+ <script type="text/javascript">
10
+ jQuery(function($) {
11
+ $("input[name='<?php echo esc_js( $name ); ?>']").datepicker({
12
+ <?php echo trim( $js, '{}' ); ?>
13
+ });
14
+ });
15
+ </script>
templates/form-fields/email.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <input type="email"
2
+ name="<?php echo esc_attr( $name ); ?>"
3
+ <?php echo MWF_Functions::generate_input_attribute( 'id', $id ); ?>
4
+ <?php echo MWF_Functions::generate_input_attribute( 'class', $class ); ?>
5
+ <?php echo MWF_Functions::generate_input_attribute( 'size', $size ); ?>
6
+ <?php echo MWF_Functions::generate_input_attribute( 'maxlength', $maxlength ); ?>
7
+ <?php echo MWF_Functions::generate_input_attribute( 'value', $value ); ?>
8
+ <?php echo MWF_Functions::generate_input_attribute( 'placeholder', $placeholder ); ?>
9
+ <?php echo MWF_Functions::generate_input_attribute( 'data-conv-half-alphanumeric', $conv_half_alphanumeric ); ?>
10
+ />
templates/form-fields/file.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <input type="file"
2
+ name="<?php echo esc_attr( $name ); ?>"
3
+ <?php echo MWF_Functions::generate_input_attribute( 'id', $id ); ?>
4
+ <?php echo MWF_Functions::generate_input_attribute( 'class', $class ); ?>
5
+ />
6
+ <span data-mwform-file-delete="<?php echo esc_attr( $name ); ?>" class="mwform-file-delete">&times;</span>
templates/form-fields/hidden.php ADDED
@@ -0,0 +1 @@
 
1
+ <input type="hidden" name="<?php echo esc_attr( $name ); ?>" value="<?php echo esc_attr( $value ); ?>" />
templates/form-fields/monthpicker.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <input type="text"
2
+ name="<?php echo esc_attr( $name ); ?>"
3
+ <?php echo MWF_Functions::generate_input_attribute( 'id', $id ); ?>
4
+ <?php echo MWF_Functions::generate_input_attribute( 'class', $class ); ?>
5
+ <?php echo MWF_Functions::generate_input_attribute( 'size', $size ); ?>
6
+ <?php echo MWF_Functions::generate_input_attribute( 'value', $value ); ?>
7
+ <?php echo MWF_Functions::generate_input_attribute( 'placeholder', $placeholder ); ?>
8
+ />
9
+ <script type="text/javascript">
10
+ jQuery(function($) {
11
+ $("input[name='<?php echo esc_js( $name ); ?>']").MonthPicker({
12
+ <?php echo trim( $js, '{}' ); ?>
13
+ });
14
+ });
15
+ </script>
templates/form-fields/number.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <input type="number"
2
+ name="<?php echo esc_attr( $name ); ?>"
3
+ <?php echo MWF_Functions::generate_input_attribute( 'id', $id ); ?>
4
+ <?php echo MWF_Functions::generate_input_attribute( 'class', $class ); ?>
5
+ <?php echo MWF_Functions::generate_input_attribute( 'value', $value ); ?>
6
+ <?php echo MWF_Functions::generate_input_attribute( 'min', $min ); ?>
7
+ <?php echo MWF_Functions::generate_input_attribute( 'max', $max ); ?>
8
+ <?php echo MWF_Functions::generate_input_attribute( 'step', $step ); ?>
9
+ <?php echo MWF_Functions::generate_input_attribute( 'placeholder', $placeholder ); ?>
10
+ />
templates/form-fields/password.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <input type="password"
2
+ name="<?php echo esc_attr( $name ); ?>"
3
+ <?php echo MWF_Functions::generate_input_attribute( 'id', $id ); ?>
4
+ <?php echo MWF_Functions::generate_input_attribute( 'class', $class ); ?>
5
+ <?php echo MWF_Functions::generate_input_attribute( 'size', $size ); ?>
6
+ <?php echo MWF_Functions::generate_input_attribute( 'maxlength', $maxlength ); ?>
7
+ <?php echo MWF_Functions::generate_input_attribute( 'value', $value ); ?>
8
+ <?php echo MWF_Functions::generate_input_attribute( 'placeholder', $placeholder ); ?>
9
+ />
templates/form-fields/radio.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( 'true' === $vertically ) {
3
+ $vertically_class = 'vertical-item';
4
+ } else {
5
+ $vertically_class = 'horizontal-item';
6
+ }
7
+ ?>
8
+ <?php foreach ( $fields as $field_value => $field ) : ?>
9
+ <span class="mwform-radio-field <?php echo esc_attr( $vertically_class ); ?>">
10
+ <label <?php echo MWF_Functions::generate_input_attribute( 'for', $field['id'] ); ?>>
11
+ <input type="radio"
12
+ name="<?php echo esc_attr( $field['name'] ); ?>"
13
+ value="<?php echo esc_attr( $field_value ); ?>"
14
+ <?php checked( $field_value, $value, true ); ?>
15
+ <?php echo MWF_Functions::generate_input_attribute( 'id', $field['id'] ); ?>
16
+ <?php echo MWF_Functions::generate_input_attribute( 'class', $field['class'] ); ?>
17
+ />
18
+ <span class="mwform-radio-field-text"><?php echo esc_attr( $field['label'] ); ?></span>
19
+ </label>
20
+ </span>
21
+ <?php endforeach; ?>
templates/form-fields/range.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <input type="range"
2
+ name="<?php echo esc_attr( $name ); ?>"
3
+ <?php echo MWF_Functions::generate_input_attribute( 'id', $id ); ?>
4
+ <?php echo MWF_Functions::generate_input_attribute( 'class', $class ); ?>
5
+ <?php echo MWF_Functions::generate_input_attribute( 'value', $value ); ?>
6
+ <?php echo MWF_Functions::generate_input_attribute( 'min', $min ); ?>
7
+ <?php echo MWF_Functions::generate_input_attribute( 'max', $max ); ?>
8
+ <?php echo MWF_Functions::generate_input_attribute( 'step', $step ); ?>
9
+ />
templates/form-fields/select.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <select name="<?php echo esc_attr( $name ); ?>"
2
+ <?php echo MWF_Functions::generate_input_attribute( 'id', $id ); ?>
3
+ <?php echo MWF_Functions::generate_input_attribute( 'class', $class ); ?>
4
+ >
5
+ <?php foreach ( $children as $option_value => $option_label ) : ?>
6
+ <option value="<?php echo esc_attr( $option_value ); ?>" <?php selected( $option_value, $value, true ); ?>>
7
+ <?php echo esc_html( $option_label ); ?>
8
+ </option>
9
+ <?php endforeach; ?>
10
+ </select>
templates/form-fields/submit.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <input type="submit"
2
+ name="<?php echo esc_attr( $name ); ?>"
3
+ value="<?php echo esc_attr( $value ); ?>"
4
+ <?php echo MWF_Functions::generate_input_attribute( 'class', $class ); ?>
5
+ />
templates/form-fields/tel.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <span class="mwform-tel-field">
2
+ <input type="text"
3
+ name="<?php echo esc_attr( $fields[0]['name'] ); ?>"
4
+ <?php echo MWF_Functions::generate_input_attribute( 'class', $fields[0]['class'] ); ?>
5
+ <?php echo MWF_Functions::generate_input_attribute( 'size', $fields[0]['size'] ); ?>
6
+ <?php echo MWF_Functions::generate_input_attribute( 'maxlength', $fields[0]['maxlength'] ); ?>
7
+ <?php echo MWF_Functions::generate_input_attribute( 'value', $fields[0]['value'] ); ?>
8
+ <?php echo MWF_Functions::generate_input_attribute( 'data-conv-half-alphanumeric', $fields[0]['conv-half-alphanumeric'] ); ?>
9
+ />
10
+ <?php echo esc_html( $separator ); ?>
11
+ <input type="text"
12
+ name="<?php echo esc_attr( $fields[1]['name'] ); ?>"
13
+ <?php echo MWF_Functions::generate_input_attribute( 'class', $fields[1]['class'] ); ?>
14
+ <?php echo MWF_Functions::generate_input_attribute( 'size', $fields[1]['size'] ); ?>
15
+ <?php echo MWF_Functions::generate_input_attribute( 'maxlength', $fields[1]['maxlength'] ); ?>
16
+ <?php echo MWF_Functions::generate_input_attribute( 'value', $fields[1]['value'] ); ?>
17
+ <?php echo MWF_Functions::generate_input_attribute( 'data-conv-half-alphanumeric', $fields[1]['conv-half-alphanumeric'] ); ?>
18
+ />
19
+ <?php echo esc_html( $separator ); ?>
20
+ <input type="text"
21
+ name="<?php echo esc_attr( $fields[2]['name'] ); ?>"
22
+ <?php echo MWF_Functions::generate_input_attribute( 'class', $fields[2]['class'] ); ?>
23
+ <?php echo MWF_Functions::generate_input_attribute( 'size', $fields[2]['size'] ); ?>
24
+ <?php echo MWF_Functions::generate_input_attribute( 'maxlength', $fields[2]['maxlength'] ); ?>
25
+ <?php echo MWF_Functions::generate_input_attribute( 'value', $fields[2]['value'] ); ?>
26
+ <?php echo MWF_Functions::generate_input_attribute( 'data-conv-half-alphanumeric', $fields[2]['conv-half-alphanumeric'] ); ?>
27
+ />
28
+ </span>
templates/form-fields/text.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <input type="text"
2
+ name="<?php echo esc_attr( $name ); ?>"
3
+ <?php echo MWF_Functions::generate_input_attribute( 'id', $id ); ?>
4
+ <?php echo MWF_Functions::generate_input_attribute( 'class', $class ); ?>
5
+ <?php echo MWF_Functions::generate_input_attribute( 'size', $size ); ?>
6
+ <?php echo MWF_Functions::generate_input_attribute( 'maxlength', $maxlength ); ?>
7
+ <?php echo MWF_Functions::generate_input_attribute( 'value', $value ); ?>
8
+ <?php echo MWF_Functions::generate_input_attribute( 'placeholder', $placeholder ); ?>
9
+ <?php echo MWF_Functions::generate_input_attribute( 'data-conv-half-alphanumeric', $conv_half_alphanumeric ); ?>
10
+ />
templates/form-fields/textarea.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <textarea
2
+ name="<?php echo esc_attr( $name ); ?>"
3
+ <?php echo MWF_Functions::generate_input_attribute( 'id', $id ); ?>
4
+ <?php echo MWF_Functions::generate_input_attribute( 'class', $class ); ?>
5
+ <?php echo MWF_Functions::generate_input_attribute( 'cols', $cols ); ?>
6
+ <?php echo MWF_Functions::generate_input_attribute( 'rows', $rows ); ?>
7
+ <?php echo MWF_Functions::generate_input_attribute( 'placeholder', $placeholder ); ?>
8
+ ><?php echo esc_html( $value ); ?></textarea>
templates/form-fields/url.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <input type="url"
2
+ name="<?php echo esc_attr( $name ); ?>"
3
+ <?php echo MWF_Functions::generate_input_attribute( 'id', $id ); ?>
4
+ <?php echo MWF_Functions::generate_input_attribute( 'class', $class ); ?>
5
+ <?php echo MWF_Functions::generate_input_attribute( 'size', $size ); ?>
6
+ <?php echo MWF_Functions::generate_input_attribute( 'maxlength', $maxlength ); ?>
7
+ <?php echo MWF_Functions::generate_input_attribute( 'value', $value ); ?>
8
+ <?php echo MWF_Functions::generate_input_attribute( 'placeholder', $placeholder ); ?>
9
+ <?php echo MWF_Functions::generate_input_attribute( 'data-conv-half-alphanumeric', $conv_half_alphanumeric ); ?>
10
+ />
templates/form-fields/zip.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <span class="mwform-zip-field">
2
+
3
+ <input type="text"
4
+ name="<?php echo esc_attr( $fields[0]['name'] ); ?>"
5
+ <?php echo MWF_Functions::generate_input_attribute( 'class', $fields[0]['class'] ); ?>
6
+ <?php echo MWF_Functions::generate_input_attribute( 'size', $fields[0]['size'] ); ?>
7
+ <?php echo MWF_Functions::generate_input_attribute( 'maxlength', $fields[0]['maxlength'] ); ?>
8
+ <?php echo MWF_Functions::generate_input_attribute( 'value', $fields[0]['value'] ); ?>
9
+ <?php echo MWF_Functions::generate_input_attribute( 'data-conv-half-alphanumeric', $fields[0]['conv-half-alphanumeric'] ); ?>
10
+ />
11
+ <?php echo esc_html( $separator ); ?>
12
+ <input type="text"
13
+ name="<?php echo esc_attr( $fields[1]['name'] ); ?>"
14
+ <?php echo MWF_Functions::generate_input_attribute( 'class', $fields[1]['class'] ); ?>
15
+ <?php echo MWF_Functions::generate_input_attribute( 'size', $fields[1]['size'] ); ?>
16
+ <?php echo MWF_Functions::generate_input_attribute( 'maxlength', $fields[1]['maxlength'] ); ?>
17
+ <?php echo MWF_Functions::generate_input_attribute( 'value', $fields[1]['value'] ); ?>
18
+ <?php echo MWF_Functions::generate_input_attribute( 'data-conv-half-alphanumeric', $fields[1]['conv-half-alphanumeric'] ); ?>
19
+ />
20
+ </span>