Version Description
- Some fix for
mwform_settings_extend_fields
. - Some fix for
mwform_settings_extend_fields_mw-wp-form-xxx
.
Download this release
Release Info
Developer | inc2734 |
Plugin | MW WP Form |
Version | 4.3.1 |
Comparing to | |
See all releases |
Code changes from version 4.2.0 to 4.3.1
- classes/abstract/class.controller.php +21 -12
- classes/abstract/class.form-field.php +99 -70
- classes/abstract/class.validation-rule.php +38 -26
- classes/config.php +55 -22
- classes/controllers/class.admin-list.php +32 -32
- classes/controllers/class.admin.php +135 -108
- classes/controllers/class.chart.php +41 -36
- classes/controllers/class.contact-data-list.php +65 -58
- classes/controllers/class.contact-data.php +55 -55
- classes/controllers/class.main.php +33 -32
- classes/controllers/class.stores-inquiry-data-form-list.php +42 -32
- classes/deprecated.php +20 -3
- classes/form-fields/class.akismet_error.php +17 -23
- classes/form-fields/class.back-button.php +27 -30
- classes/form-fields/class.button-back.php +20 -27
- classes/form-fields/class.button-button.php +21 -26
- classes/form-fields/class.button-confirm.php +20 -27
- classes/form-fields/class.button-submit.php +21 -26
- classes/form-fields/class.button.php +28 -29
- classes/form-fields/class.checkbox.php +32 -32
- classes/form-fields/class.confirm-button.php +27 -30
- classes/form-fields/class.custom-mail-tag.php +42 -41
- classes/form-fields/class.datepicker.php +46 -45
- classes/form-fields/class.email.php +41 -43
- classes/form-fields/class.error.php +20 -27
- classes/form-fields/class.file.php +36 -34
- classes/form-fields/class.hidden.php +20 -26
- classes/form-fields/class.image.php +36 -34
- classes/form-fields/class.monthpicker.php +52 -47
- classes/form-fields/class.number.php +33 -35
- classes/form-fields/class.password.php +32 -34
- classes/form-fields/class.radio.php +31 -32
- classes/form-fields/class.range.php +32 -34
- classes/form-fields/class.select.php +30 -31
- classes/form-fields/class.submit-button.php +44 -37
- classes/form-fields/class.submit.php +28 -28
- classes/form-fields/class.tel.php +39 -41
- classes/form-fields/class.text.php +41 -43
- classes/form-fields/class.textarea.php +32 -34
- classes/form-fields/class.url.php +41 -43
- classes/form-fields/class.zip.php +39 -41
- classes/functions.php +111 -101
- classes/models/class.admin.php +18 -17
- classes/models/class.akismet.php +33 -23
- classes/models/class.contact-data-setting.php +58 -49
- classes/models/class.csv.php +50 -44
- classes/models/class.data.php +112 -108
- classes/models/class.file.php +45 -39
- classes/models/class.form-fields.php +18 -11
- classes/models/class.form.php +416 -298
- classes/models/class.json-parser.php +41 -48
- classes/models/class.mail.php +48 -51
- classes/models/class.parser.php +66 -47
- classes/models/class.session.php +48 -35
- classes/models/class.setting.php +98 -59
- classes/models/class.validation-rules.php +22 -14
- classes/models/class.validation.php +46 -27
- classes/services/class.exec-shortcode.php +72 -57
- classes/services/class.mail-parser.php +33 -33
- classes/services/class.mail.php +40 -50
- classes/services/class.redirected.php +35 -32
- classes/validation-rules/class.akismet.php +24 -19
- classes/validation-rules/class.alpha.php +18 -18
- classes/validation-rules/class.alphanumeric.php +18 -18
- classes/validation-rules/class.between.php +19 -19
- classes/validation-rules/class.date.php +23 -23
- classes/validation-rules/class.eq.php +20 -20
- classes/validation-rules/class.filesize.php +30 -30
- classes/validation-rules/class.filetype.php +21 -20
- classes/validation-rules/class.hiragana.php +18 -18
- classes/validation-rules/class.in.php +26 -21
- classes/validation-rules/class.kana.php +18 -18
- classes/validation-rules/class.katakana.php +18 -18
- classes/validation-rules/class.mail.php +18 -18
- classes/validation-rules/class.maximagesize.php +24 -25
- classes/validation-rules/class.minimagesize.php +24 -25
- classes/validation-rules/class.minlength.php +20 -20
- classes/validation-rules/class.month.php +23 -23
- classes/validation-rules/class.noempty.php +18 -18
- classes/validation-rules/class.nofalse.php +24 -19
- classes/validation-rules/class.numeric.php +18 -18
- classes/validation-rules/class.required.php +18 -18
- classes/validation-rules/class.tel.php +21 -21
- classes/validation-rules/class.url.php +18 -18
- classes/validation-rules/class.zip.php +21 -22
- mw-wp-form.php +95 -100
- readme.txt +14 -2
- templates/admin-list/form-key.php +9 -1
- templates/admin/add-ons.php +8 -0
- templates/admin/admin-mail-options.php +13 -2
- templates/admin/complete-message.php +11 -2
- templates/admin/form-key.php +9 -1
- templates/admin/mail-options.php +13 -2
- templates/admin/settings.php +8 -0
- templates/admin/style.php +9 -1
- templates/admin/tag-generator.php +6 -0
- templates/admin/url.php +16 -2
- templates/admin/validation-rule.php +17 -2
- templates/chart/index.php +17 -5
- templates/contact-data-list/admin-print-styles.php +9 -1
- templates/contact-data-list/column.php +8 -1
- templates/contact-data-list/csv-button.php +9 -1
- templates/contact-data/admin-print-styles.php +9 -1
- templates/contact-data/detail.php +19 -11
- templates/contact-data/returning-link.php +9 -1
- templates/form-fields/button.php +8 -0
- templates/form-fields/button_button.php +8 -0
- templates/form-fields/button_submit.php +8 -0
- templates/form-fields/checkbox.php +13 -1
- templates/form-fields/datepicker.php +8 -0
- templates/form-fields/email.php +8 -0
- templates/form-fields/file.php +8 -0
- templates/form-fields/hidden.php +8 -0
- templates/form-fields/monthpicker.php +8 -0
- templates/form-fields/number.php +8 -0
- templates/form-fields/password.php +8 -0
- templates/form-fields/radio.php +6 -0
- templates/form-fields/range.php +8 -0
- templates/form-fields/select.php +8 -0
- templates/form-fields/submit.php +8 -0
- templates/form-fields/tel.php +8 -0
- templates/form-fields/text.php +8 -0
- templates/form-fields/textarea.php +8 -0
- templates/form-fields/url.php +8 -0
- templates/form-fields/zip.php +8 -0
- templates/stores-inquiry-data-form-list/index.php +21 -4
classes/abstract/class.controller.php
CHANGED
@@ -1,25 +1,27 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
19 |
-
* @
|
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 |
|
@@ -27,6 +29,13 @@ class MW_WP_Form_Controller {
|
|
27 |
return;
|
28 |
}
|
29 |
|
|
|
30 |
include( $template_path );
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
}
|
32 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Controller
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Controller {
|
12 |
|
13 |
/**
|
14 |
* Rendering template
|
15 |
*
|
16 |
+
* @param string $template {directory name}/{file name (no need extension)}.
|
17 |
+
* @param array $args Array of data you want to assign.
|
18 |
+
* @param string $form_key Form key.
|
19 |
*/
|
20 |
+
protected function _render( $template, array $args = array(), $form_key = null ) {
|
21 |
+
// phpcs:disable WordPress.PHP.DontExtract.extract_extract
|
22 |
extract( $args );
|
23 |
+
// phpcs:enable
|
24 |
+
|
25 |
$template_dir = plugin_dir_path( __FILE__ ) . '../../templates/';
|
26 |
$template_path = $template_dir . $template . '.php';
|
27 |
|
29 |
return;
|
30 |
}
|
31 |
|
32 |
+
ob_start();
|
33 |
include( $template_path );
|
34 |
+
$html = ob_get_clean();
|
35 |
+
$html = apply_filters( 'mwform_template_render', $html, $template, $args );
|
36 |
+
if ( $form_key ) {
|
37 |
+
$html = apply_filters( 'mwform_template_render_' . $form_key, $html, $template, $args );
|
38 |
+
}
|
39 |
+
echo $html;
|
40 |
}
|
41 |
}
|
classes/abstract/class.form-field.php
CHANGED
@@ -1,24 +1,25 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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;
|
@@ -34,36 +35,44 @@ abstract class MW_WP_Form_Abstract_Form_Field {
|
|
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();
|
@@ -72,12 +81,12 @@ abstract class MW_WP_Form_Abstract_Form_Field {
|
|
72 |
}
|
73 |
|
74 |
/**
|
75 |
-
* Add form field shortcodes
|
76 |
*
|
77 |
-
* @param MW_WP_Form_Form $Form
|
78 |
-
* @param string
|
79 |
-
* @param string
|
80 |
-
* @return
|
81 |
*/
|
82 |
public function initialize( MW_WP_Form_Form $Form, $form_key, $view_flg ) {
|
83 |
if ( empty( $this->shortcode_name ) ) {
|
@@ -88,16 +97,16 @@ abstract class MW_WP_Form_Abstract_Form_Field {
|
|
88 |
$this->form_key = $form_key;
|
89 |
$this->Data = MW_WP_Form_Data::connect( $form_key );
|
90 |
|
91 |
-
switch( $view_flg ) {
|
92 |
-
case 'input'
|
93 |
add_shortcode( $this->shortcode_name, array( $this, '_input_page' ) );
|
94 |
break;
|
95 |
-
case 'confirm'
|
96 |
add_shortcode( $this->shortcode_name, array( $this, '_confirm_page' ) );
|
97 |
break;
|
98 |
-
case 'complete'
|
99 |
break;
|
100 |
-
default
|
101 |
exit( '$view_flg is not right value. $view_flg is ' . $view_flg . ' now.' );
|
102 |
}
|
103 |
|
@@ -105,12 +114,17 @@ abstract class MW_WP_Form_Abstract_Form_Field {
|
|
105 |
}
|
106 |
|
107 |
/**
|
108 |
-
* Set shortcode_name and display_name
|
109 |
-
* Overwrite required for each child class
|
110 |
*
|
111 |
-
* @return array
|
112 |
*/
|
113 |
abstract protected function set_names();
|
|
|
|
|
|
|
|
|
|
|
114 |
private function _set_names() {
|
115 |
$args = $this->set_names();
|
116 |
|
@@ -123,20 +137,24 @@ abstract class MW_WP_Form_Abstract_Form_Field {
|
|
123 |
}
|
124 |
|
125 |
/**
|
126 |
-
* Set default attributes
|
127 |
*
|
128 |
-
* @return array
|
129 |
*/
|
130 |
abstract protected function set_defaults();
|
|
|
|
|
|
|
|
|
131 |
private function _set_defaults() {
|
132 |
$this->defaults = $this->set_defaults();
|
133 |
}
|
134 |
|
135 |
/**
|
136 |
-
* Return HTML of error message
|
137 |
*
|
138 |
-
* @param string $name
|
139 |
-
* @return string
|
140 |
*/
|
141 |
protected function get_error( $name ) {
|
142 |
if ( ! is_array( $this->Data->get_validation_error( $name ) ) ) {
|
@@ -147,7 +165,7 @@ abstract class MW_WP_Form_Abstract_Form_Field {
|
|
147 |
$start_tag = '<span class="error">';
|
148 |
$end_tag = '</span>';
|
149 |
foreach ( $this->Data->get_validation_error( $name ) as $rule => $error ) {
|
150 |
-
$rule
|
151 |
$error = apply_filters(
|
152 |
'mwform_error_message_' . $this->form_key,
|
153 |
$error,
|
@@ -155,7 +173,8 @@ abstract class MW_WP_Form_Abstract_Form_Field {
|
|
155 |
$rule
|
156 |
);
|
157 |
|
158 |
-
$error_html .= apply_filters(
|
|
|
159 |
$start_tag . esc_html( $error ) . $end_tag,
|
160 |
$error,
|
161 |
$start_tag,
|
@@ -172,13 +191,19 @@ abstract class MW_WP_Form_Abstract_Form_Field {
|
|
172 |
}
|
173 |
|
174 |
/**
|
175 |
-
* Callback of add shortcode for input page
|
176 |
*
|
177 |
-
* @
|
178 |
-
* @param string $element_content
|
179 |
-
* @return string HTML
|
180 |
*/
|
181 |
abstract protected function input_page();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
182 |
public function _input_page( $atts, $element_content = null ) {
|
183 |
$this->element_content = $element_content;
|
184 |
|
@@ -195,25 +220,31 @@ abstract class MW_WP_Form_Abstract_Form_Field {
|
|
195 |
}
|
196 |
|
197 |
/**
|
198 |
-
* Callback of add shortcode for confirm page
|
199 |
*
|
200 |
-
* @
|
201 |
-
* @param string $element_content
|
202 |
-
* @return string HTML
|
203 |
*/
|
204 |
abstract protected function confirm_page();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
205 |
public function _confirm_page( $atts, $element_content = null ) {
|
206 |
$this->element_content = $element_content;
|
207 |
-
$this->atts
|
208 |
|
209 |
return $this->confirm_page();
|
210 |
}
|
211 |
|
212 |
/**
|
213 |
-
* Return array for children of select, checkbox and radio
|
214 |
-
* If including ":", Split and use the before as the name and the after as the label
|
215 |
*
|
216 |
-
* @param string|array $_children
|
217 |
* @return array
|
218 |
*/
|
219 |
public function get_children( $_children ) {
|
@@ -236,7 +267,7 @@ abstract class MW_WP_Form_Abstract_Form_Field {
|
|
236 |
$child[ $child_key ] = str_replace( $temp_replacement, ':', $child_value );
|
237 |
}
|
238 |
if ( count( $child ) === 1 ) {
|
239 |
-
$children[ $child[0] ] = $child[0]
|
240 |
} else {
|
241 |
$children[ $child[0] ] = $child[1];
|
242 |
}
|
@@ -251,9 +282,7 @@ abstract class MW_WP_Form_Abstract_Form_Field {
|
|
251 |
}
|
252 |
|
253 |
/**
|
254 |
-
* Generate tag generator
|
255 |
-
*
|
256 |
-
* @return void
|
257 |
*/
|
258 |
public function add_tag_generator() {
|
259 |
add_action( 'mwform_tag_generator_dialog', array( $this, '_mwform_tag_generator_dialog' ) );
|
@@ -268,9 +297,7 @@ abstract class MW_WP_Form_Abstract_Form_Field {
|
|
268 |
}
|
269 |
|
270 |
/**
|
271 |
-
* Display tag generator wrapper
|
272 |
-
*
|
273 |
-
* @return void
|
274 |
*/
|
275 |
public function _mwform_tag_generator_dialog() {
|
276 |
?>
|
@@ -283,18 +310,14 @@ abstract class MW_WP_Form_Abstract_Form_Field {
|
|
283 |
}
|
284 |
|
285 |
/**
|
286 |
-
* Display tag generator dialog
|
287 |
-
* Overwrite required for each child class
|
288 |
-
*
|
289 |
-
* @param array $options
|
290 |
-
* @return void
|
291 |
*/
|
292 |
-
public function mwform_tag_generator_dialog(
|
|
|
293 |
|
294 |
/**
|
295 |
-
* Display tag generator selectbox
|
296 |
-
*
|
297 |
-
* @return void
|
298 |
*/
|
299 |
public function _mwform_tag_generator_option() {
|
300 |
?>
|
@@ -303,22 +326,28 @@ abstract class MW_WP_Form_Abstract_Form_Field {
|
|
303 |
}
|
304 |
|
305 |
/**
|
306 |
-
* Generate array of form fields
|
307 |
*
|
308 |
-
* @param array $form_fields
|
309 |
* @return array
|
310 |
*/
|
311 |
public function _mwform_form_fields( array $form_fields ) {
|
312 |
return array_merge( $form_fields, array( $this->shortcode_name => $this ) );
|
313 |
}
|
314 |
|
|
|
|
|
|
|
|
|
|
|
|
|
315 |
public function _mwform_tag_generator_group( $group ) {
|
316 |
$group[ $this->type ] = $this->type;
|
317 |
return $group;
|
318 |
}
|
319 |
|
320 |
/**
|
321 |
-
* Return display name
|
322 |
*
|
323 |
* @return string
|
324 |
*/
|
@@ -327,7 +356,7 @@ abstract class MW_WP_Form_Abstract_Form_Field {
|
|
327 |
}
|
328 |
|
329 |
/**
|
330 |
-
* Return shortcode name
|
331 |
*
|
332 |
* @return string
|
333 |
*/
|
@@ -336,10 +365,10 @@ abstract class MW_WP_Form_Abstract_Form_Field {
|
|
336 |
}
|
337 |
|
338 |
/**
|
339 |
-
* Return value for setting field of Tag generator dialog
|
340 |
*
|
341 |
-
* @param string $key
|
342 |
-
* @param array
|
343 |
* @return string
|
344 |
*/
|
345 |
public function get_value_for_generator( $key, $options ) {
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Abstract_Form_Field
|
|
|
10 |
*/
|
11 |
abstract class MW_WP_Form_Abstract_Form_Field {
|
12 |
|
13 |
/**
|
14 |
+
* Shortcode name.
|
15 |
+
*
|
16 |
* @var string
|
17 |
*/
|
18 |
protected $shortcode_name;
|
19 |
|
20 |
/**
|
21 |
+
* Display name.
|
22 |
+
*
|
23 |
* @var string
|
24 |
*/
|
25 |
protected $display_name;
|
35 |
protected $Data;
|
36 |
|
37 |
/**
|
38 |
+
* Default attributes.
|
39 |
+
*
|
40 |
* @var array
|
41 |
*/
|
42 |
protected $defaults = array();
|
43 |
|
44 |
/**
|
45 |
+
* Attirbutes of shortcode.
|
46 |
+
*
|
47 |
* @var array
|
48 |
*/
|
49 |
protected $atts = array();
|
50 |
|
51 |
/**
|
52 |
+
* Form key.
|
53 |
+
*
|
54 |
* @var string
|
55 |
*/
|
56 |
protected $form_key;
|
57 |
|
58 |
/**
|
59 |
* Types of form type.
|
60 |
+
* input|select|button|input_button|error|other.
|
61 |
+
*
|
62 |
* @var string
|
63 |
*/
|
64 |
protected $type = 'other';
|
65 |
|
66 |
/**
|
67 |
+
* Content of shortcode.
|
68 |
+
*
|
69 |
* @var string
|
70 |
*/
|
71 |
protected $element_content = null;
|
72 |
|
73 |
+
/**
|
74 |
+
* Constructor.
|
75 |
+
*/
|
76 |
public function __construct() {
|
77 |
$this->_set_names();
|
78 |
$this->_set_defaults();
|
81 |
}
|
82 |
|
83 |
/**
|
84 |
+
* Add form field shortcodes.
|
85 |
*
|
86 |
+
* @param MW_WP_Form_Form $Form MW_WP_Form_Form object.
|
87 |
+
* @param string $form_key Form key.
|
88 |
+
* @param string $view_flg View flg.
|
89 |
+
* @return boolean
|
90 |
*/
|
91 |
public function initialize( MW_WP_Form_Form $Form, $form_key, $view_flg ) {
|
92 |
if ( empty( $this->shortcode_name ) ) {
|
97 |
$this->form_key = $form_key;
|
98 |
$this->Data = MW_WP_Form_Data::connect( $form_key );
|
99 |
|
100 |
+
switch ( $view_flg ) {
|
101 |
+
case 'input':
|
102 |
add_shortcode( $this->shortcode_name, array( $this, '_input_page' ) );
|
103 |
break;
|
104 |
+
case 'confirm':
|
105 |
add_shortcode( $this->shortcode_name, array( $this, '_confirm_page' ) );
|
106 |
break;
|
107 |
+
case 'complete':
|
108 |
break;
|
109 |
+
default:
|
110 |
exit( '$view_flg is not right value. $view_flg is ' . $view_flg . ' now.' );
|
111 |
}
|
112 |
|
114 |
}
|
115 |
|
116 |
/**
|
117 |
+
* Set shortcode_name and display_name.
|
118 |
+
* Overwrite required for each child class.
|
119 |
*
|
120 |
+
* @return array
|
121 |
*/
|
122 |
abstract protected function set_names();
|
123 |
+
|
124 |
+
/**
|
125 |
+
* Set shortcode_name and display_name.
|
126 |
+
* Overwrite required for each child class.
|
127 |
+
*/
|
128 |
private function _set_names() {
|
129 |
$args = $this->set_names();
|
130 |
|
137 |
}
|
138 |
|
139 |
/**
|
140 |
+
* Set default attributes.
|
141 |
*
|
142 |
+
* @return array
|
143 |
*/
|
144 |
abstract protected function set_defaults();
|
145 |
+
|
146 |
+
/**
|
147 |
+
* Set default attributes.
|
148 |
+
*/
|
149 |
private function _set_defaults() {
|
150 |
$this->defaults = $this->set_defaults();
|
151 |
}
|
152 |
|
153 |
/**
|
154 |
+
* Return HTML of error message.
|
155 |
*
|
156 |
+
* @param string $name Field name.
|
157 |
+
* @return string
|
158 |
*/
|
159 |
protected function get_error( $name ) {
|
160 |
if ( ! is_array( $this->Data->get_validation_error( $name ) ) ) {
|
165 |
$start_tag = '<span class="error">';
|
166 |
$end_tag = '</span>';
|
167 |
foreach ( $this->Data->get_validation_error( $name ) as $rule => $error ) {
|
168 |
+
$rule = strtolower( $rule );
|
169 |
$error = apply_filters(
|
170 |
'mwform_error_message_' . $this->form_key,
|
171 |
$error,
|
173 |
$rule
|
174 |
);
|
175 |
|
176 |
+
$error_html .= apply_filters(
|
177 |
+
'mwform_error_message_html',
|
178 |
$start_tag . esc_html( $error ) . $end_tag,
|
179 |
$error,
|
180 |
$start_tag,
|
191 |
}
|
192 |
|
193 |
/**
|
194 |
+
* Callback of add shortcode for input page.
|
195 |
*
|
196 |
+
* @return string
|
|
|
|
|
197 |
*/
|
198 |
abstract protected function input_page();
|
199 |
+
|
200 |
+
/**
|
201 |
+
* Callback of add shortcode for input page.
|
202 |
+
*
|
203 |
+
* @param array $atts Attributes of shortcode.
|
204 |
+
* @param string $element_content Content of shortcode.
|
205 |
+
* @return string
|
206 |
+
*/
|
207 |
public function _input_page( $atts, $element_content = null ) {
|
208 |
$this->element_content = $element_content;
|
209 |
|
220 |
}
|
221 |
|
222 |
/**
|
223 |
+
* Callback of add shortcode for confirm page.
|
224 |
*
|
225 |
+
* @return string
|
|
|
|
|
226 |
*/
|
227 |
abstract protected function confirm_page();
|
228 |
+
|
229 |
+
/**
|
230 |
+
* Callback of add shortcode for confirm page.
|
231 |
+
*
|
232 |
+
* @param array $atts Attributes of shortcode.
|
233 |
+
* @param string $element_content Content of shortcode.
|
234 |
+
* @return string
|
235 |
+
*/
|
236 |
public function _confirm_page( $atts, $element_content = null ) {
|
237 |
$this->element_content = $element_content;
|
238 |
+
$this->atts = shortcode_atts( $this->defaults, $atts );
|
239 |
|
240 |
return $this->confirm_page();
|
241 |
}
|
242 |
|
243 |
/**
|
244 |
+
* Return array for children of select, checkbox and radio.
|
245 |
+
* If including ":", Split and use the before as the name and the after as the label.
|
246 |
*
|
247 |
+
* @param string|array $_children Children.
|
248 |
* @return array
|
249 |
*/
|
250 |
public function get_children( $_children ) {
|
267 |
$child[ $child_key ] = str_replace( $temp_replacement, ':', $child_value );
|
268 |
}
|
269 |
if ( count( $child ) === 1 ) {
|
270 |
+
$children[ $child[0] ] = $child[0];
|
271 |
} else {
|
272 |
$children[ $child[0] ] = $child[1];
|
273 |
}
|
282 |
}
|
283 |
|
284 |
/**
|
285 |
+
* Generate tag generator.
|
|
|
|
|
286 |
*/
|
287 |
public function add_tag_generator() {
|
288 |
add_action( 'mwform_tag_generator_dialog', array( $this, '_mwform_tag_generator_dialog' ) );
|
297 |
}
|
298 |
|
299 |
/**
|
300 |
+
* Display tag generator wrapper.
|
|
|
|
|
301 |
*/
|
302 |
public function _mwform_tag_generator_dialog() {
|
303 |
?>
|
310 |
}
|
311 |
|
312 |
/**
|
313 |
+
* Display tag generator dialog.
|
314 |
+
* Overwrite required for each child class.
|
|
|
|
|
|
|
315 |
*/
|
316 |
+
public function mwform_tag_generator_dialog() {
|
317 |
+
}
|
318 |
|
319 |
/**
|
320 |
+
* Display tag generator selectbox.
|
|
|
|
|
321 |
*/
|
322 |
public function _mwform_tag_generator_option() {
|
323 |
?>
|
326 |
}
|
327 |
|
328 |
/**
|
329 |
+
* Generate array of form fields.
|
330 |
*
|
331 |
+
* @param array $form_fields Array of MW_WP_Form_Abstract_Form_Field.
|
332 |
* @return array
|
333 |
*/
|
334 |
public function _mwform_form_fields( array $form_fields ) {
|
335 |
return array_merge( $form_fields, array( $this->shortcode_name => $this ) );
|
336 |
}
|
337 |
|
338 |
+
/**
|
339 |
+
* Add tag generator group.
|
340 |
+
*
|
341 |
+
* @param array $group Tag generator group.
|
342 |
+
* @return array
|
343 |
+
*/
|
344 |
public function _mwform_tag_generator_group( $group ) {
|
345 |
$group[ $this->type ] = $this->type;
|
346 |
return $group;
|
347 |
}
|
348 |
|
349 |
/**
|
350 |
+
* Return display name.
|
351 |
*
|
352 |
* @return string
|
353 |
*/
|
356 |
}
|
357 |
|
358 |
/**
|
359 |
+
* Return shortcode name.
|
360 |
*
|
361 |
* @return string
|
362 |
*/
|
365 |
}
|
366 |
|
367 |
/**
|
368 |
+
* Return value for setting field of Tag generator dialog.
|
369 |
*
|
370 |
+
* @param string $key Attribute name.
|
371 |
+
* @param array $options Options.
|
372 |
* @return string
|
373 |
*/
|
374 |
public function get_value_for_generator( $key, $options ) {
|
classes/abstract/class.validation-rule.php
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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;
|
@@ -22,6 +22,11 @@ abstract class MW_WP_Form_Abstract_Validation_Rule {
|
|
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.' );
|
@@ -35,9 +40,9 @@ abstract class MW_WP_Form_Abstract_Validation_Rule {
|
|
35 |
}
|
36 |
|
37 |
/**
|
38 |
-
* Generate array of validation rules
|
39 |
*
|
40 |
-
* @param array $validation_rules
|
41 |
* @return array
|
42 |
*/
|
43 |
public function _mwform_validation_rules( array $validation_rules ) {
|
@@ -46,33 +51,41 @@ abstract class MW_WP_Form_Abstract_Validation_Rule {
|
|
46 |
}
|
47 |
|
48 |
/**
|
49 |
-
* Inject MW_WP_Form_Data
|
50 |
*
|
51 |
* @deprecated
|
52 |
-
*
|
53 |
-
* @
|
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
|
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
|
72 |
*/
|
73 |
public function get_name() {
|
74 |
return $this->name;
|
75 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
public function getName() {
|
77 |
MWF_Functions::deprecated_message(
|
78 |
get_class() . '::getName()',
|
@@ -82,20 +95,19 @@ abstract class MW_WP_Form_Abstract_Validation_Rule {
|
|
82 |
}
|
83 |
|
84 |
/**
|
85 |
-
* Validation process
|
86 |
*
|
87 |
-
* @param string $name
|
88 |
-
* @param array
|
89 |
-
* @return string
|
90 |
*/
|
91 |
abstract public function rule( $name, array $options = array() );
|
92 |
|
93 |
/**
|
94 |
-
* Add setting field to validation rule setting panel
|
95 |
*
|
96 |
-
* @param
|
97 |
-
* @param array $value Content of validation rule
|
98 |
-
* @return void
|
99 |
*/
|
100 |
abstract public function admin( $key, $value );
|
101 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Abstract_Validation_Rule
|
|
|
10 |
*/
|
11 |
abstract class MW_WP_Form_Abstract_Validation_Rule {
|
12 |
|
13 |
/**
|
14 |
+
* Validation rule name.
|
15 |
+
*
|
16 |
* @var string
|
17 |
*/
|
18 |
protected $name;
|
22 |
*/
|
23 |
protected $Data;
|
24 |
|
25 |
+
/**
|
26 |
+
* Constructor.
|
27 |
+
*
|
28 |
+
* @param MW_WP_Form_Data $Data MW_WP_Form_Data object.
|
29 |
+
*/
|
30 |
public function __construct( MW_WP_Form_Data $Data = null ) {
|
31 |
if ( ! $this->get_name() ) {
|
32 |
exit( 'MW_WP_Form_Abstract_Validation_Rule::$name must override.' );
|
40 |
}
|
41 |
|
42 |
/**
|
43 |
+
* Generate array of validation rules.
|
44 |
*
|
45 |
+
* @param array $validation_rules Array of MW_WP_Form_Abstract_Validation_Rule.
|
46 |
* @return array
|
47 |
*/
|
48 |
public function _mwform_validation_rules( array $validation_rules ) {
|
51 |
}
|
52 |
|
53 |
/**
|
54 |
+
* Inject MW_WP_Form_Data.
|
55 |
*
|
56 |
* @deprecated
|
57 |
+
*
|
58 |
+
* @param MW_WP_Form_Data $Data MW_WP_Form_Data object.
|
59 |
*/
|
60 |
public function set_Data( MW_WP_Form_Data $Data ) {
|
61 |
$this->Data = $Data;
|
62 |
}
|
63 |
|
64 |
/**
|
65 |
+
* Return true when set $this->Data.
|
66 |
*
|
67 |
+
* @return boolean
|
68 |
*/
|
69 |
public function is_set_Data() {
|
70 |
return ( is_a( $this->Data, 'MW_WP_Form_Data' ) );
|
71 |
}
|
72 |
|
73 |
/**
|
74 |
+
* Return validation rule name.
|
75 |
*
|
76 |
+
* @return string
|
77 |
*/
|
78 |
public function get_name() {
|
79 |
return $this->name;
|
80 |
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Return validation rule name.
|
84 |
+
*
|
85 |
+
* @deprecated
|
86 |
+
*
|
87 |
+
* @return string
|
88 |
+
*/
|
89 |
public function getName() {
|
90 |
MWF_Functions::deprecated_message(
|
91 |
get_class() . '::getName()',
|
95 |
}
|
96 |
|
97 |
/**
|
98 |
+
* Validation process.
|
99 |
*
|
100 |
+
* @param string $name Validation name.
|
101 |
+
* @param array $options Validation options.
|
102 |
+
* @return string
|
103 |
*/
|
104 |
abstract public function rule( $name, array $options = array() );
|
105 |
|
106 |
/**
|
107 |
+
* Add setting field to validation rule setting panel.
|
108 |
*
|
109 |
+
* @param int $key ID of validation rule.
|
110 |
+
* @param array $value Content of validation rule.
|
|
|
111 |
*/
|
112 |
abstract public function admin( $key, $value );
|
113 |
}
|
classes/config.php
CHANGED
@@ -1,84 +1,117 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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 |
|
39 |
/**
|
40 |
-
* $_FILES
|
|
|
|
|
41 |
*/
|
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 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MWF_Config
|
|
|
10 |
*/
|
11 |
class MWF_Config {
|
12 |
|
13 |
/**
|
14 |
+
* Plugin ID.
|
15 |
+
*
|
16 |
+
* @var string
|
17 |
*/
|
18 |
const NAME = 'mw-wp-form';
|
19 |
|
20 |
/**
|
21 |
+
* Text Domain.
|
22 |
+
*
|
23 |
+
* @var string
|
24 |
*/
|
25 |
const DOMAIN = 'mw-wp-form';
|
26 |
|
27 |
/**
|
28 |
+
* Prefix of post type of saved inquiry data.
|
29 |
+
*
|
30 |
+
* @var string
|
31 |
*/
|
32 |
const DBDATA = 'mwf_';
|
33 |
|
34 |
/**
|
35 |
+
* The name of field that array of uploaded file names.
|
36 |
+
*
|
37 |
+
* @var string
|
38 |
*/
|
39 |
const UPLOAD_FILE_KEYS = 'mwf_upload_files';
|
40 |
|
41 |
/**
|
42 |
+
* The name of field that array of custom mail tag names.
|
43 |
+
*
|
44 |
+
* @var string
|
45 |
*/
|
46 |
const CUSTOM_MAIL_TAG_KEYS = 'mwf_custom_mail_tags';
|
47 |
|
48 |
/**
|
49 |
+
* $_FILES.
|
50 |
+
*
|
51 |
+
* @var string
|
52 |
*/
|
53 |
const UPLOAD_FILES = 'mwf_files';
|
54 |
|
55 |
/**
|
56 |
+
* Field name of Akismet.
|
57 |
+
*
|
58 |
+
* @var string
|
59 |
*/
|
60 |
const AKISMET = 'mwf_akismet';
|
61 |
|
62 |
/**
|
63 |
+
* Capability.
|
64 |
+
*
|
65 |
+
* @var string
|
66 |
*/
|
67 |
const CAPABILITY = 'edit_pages';
|
68 |
|
69 |
/**
|
70 |
+
* Name of tracking number.
|
71 |
+
*
|
72 |
+
* @var string
|
73 |
*/
|
74 |
const TRACKINGNUMBER = 'tracking_number';
|
75 |
|
76 |
/**
|
77 |
+
* Field name of confirm button.
|
78 |
+
*
|
79 |
+
* @var string
|
80 |
*/
|
81 |
const CONFIRM_BUTTON = 'submitConfirm';
|
82 |
|
83 |
/**
|
84 |
+
* Field name of back button.
|
85 |
+
*
|
86 |
+
* @var string
|
87 |
*/
|
88 |
const BACK_BUTTON = 'submitBack';
|
89 |
|
90 |
/**
|
91 |
+
* Name of meta data of saved inquiry data.
|
92 |
+
*
|
93 |
+
* @var string
|
94 |
*/
|
95 |
const CONTACT_DATA_NAME = '_mw-wp-form_data';
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Name of meta data of saved inquiry data.
|
99 |
+
*
|
100 |
+
* @var string
|
101 |
+
*/
|
102 |
const INQUIRY_DATA_NAME = self::CONTACT_DATA_NAME;
|
103 |
|
104 |
/**
|
105 |
+
* Name of sending error data.
|
106 |
+
*
|
107 |
+
* @var string
|
108 |
*/
|
109 |
const SEND_ERROR = 'mw-wp-form-send-error';
|
110 |
|
111 |
/**
|
112 |
+
* Nonce field name.
|
113 |
+
*
|
114 |
+
* @var string
|
115 |
*/
|
116 |
const TOKEN_NAME = 'mw_wp_form_token';
|
117 |
}
|
classes/controllers/class.admin-list.php
CHANGED
@@ -1,27 +1,29 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
17 |
-
add_action( 'admin_head'
|
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 ) {
|
@@ -30,26 +32,22 @@ class MW_WP_Form_Admin_List_Controller extends MW_WP_Form_Controller {
|
|
30 |
'<div class="donation"><p>' .
|
31 |
__( 'Your contribution is needed for making this plugin better.', 'mw-wp-form' ) .
|
32 |
' <a href="https://www.amazon.co.jp/registry/wishlist/39ANKRNSTNW40" class="button">' .
|
33 |
-
__( 'Donate', 'mw-wp-form' ) . '</a></p></div>'
|
34 |
);
|
35 |
-
$views
|
36 |
return $views;
|
37 |
}
|
38 |
|
39 |
/**
|
40 |
-
* Hooked for adding columns
|
41 |
-
*
|
42 |
-
* @return void
|
43 |
*/
|
44 |
public function _add_columns() {
|
45 |
-
add_filter( 'manage_posts_columns'
|
46 |
-
add_action( 'manage_posts_custom_column', array( $this, '_manage_posts_custom_column' )
|
47 |
}
|
48 |
|
49 |
/**
|
50 |
-
* Enqueue assets
|
51 |
-
*
|
52 |
-
* @return void
|
53 |
*/
|
54 |
public function _admin_enqueue_scripts() {
|
55 |
$url = plugins_url( MWF_Config::NAME );
|
@@ -57,30 +55,32 @@ class MW_WP_Form_Admin_List_Controller extends MW_WP_Form_Controller {
|
|
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' );
|
69 |
-
$columns['date']
|
70 |
return $columns;
|
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
|
80 |
if ( 'mwform_form_key' === $column_name ) {
|
81 |
-
$this->_render(
|
82 |
-
'
|
83 |
-
|
|
|
|
|
|
|
84 |
}
|
85 |
}
|
86 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Admin_List_Controller
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Admin_List_Controller extends MW_WP_Form_Controller {
|
12 |
|
13 |
+
/**
|
14 |
+
* Constructor.
|
15 |
+
*/
|
16 |
public function __construct() {
|
17 |
$screen = get_current_screen();
|
18 |
+
add_filter( 'views_' . $screen->id, array( $this, '_donate_link' ) );
|
19 |
+
add_action( 'admin_head', array( $this, '_add_columns' ) );
|
20 |
add_action( 'admin_enqueue_scripts', array( $this, '_admin_enqueue_scripts' ) );
|
21 |
}
|
22 |
|
23 |
/**
|
24 |
+
* Return Donate link html.
|
25 |
*
|
26 |
+
* @param array $views An array of available list table views.
|
27 |
* @return array
|
28 |
*/
|
29 |
public function _donate_link( $views ) {
|
32 |
'<div class="donation"><p>' .
|
33 |
__( 'Your contribution is needed for making this plugin better.', 'mw-wp-form' ) .
|
34 |
' <a href="https://www.amazon.co.jp/registry/wishlist/39ANKRNSTNW40" class="button">' .
|
35 |
+
__( 'Donate', 'mw-wp-form' ) . '</a></p></div>',
|
36 |
);
|
37 |
+
$views = array_merge( $donation, $views );
|
38 |
return $views;
|
39 |
}
|
40 |
|
41 |
/**
|
42 |
+
* Hooked for adding columns.
|
|
|
|
|
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' ) );
|
47 |
}
|
48 |
|
49 |
/**
|
50 |
+
* Enqueue assets.
|
|
|
|
|
51 |
*/
|
52 |
public function _admin_enqueue_scripts() {
|
53 |
$url = plugins_url( MWF_Config::NAME );
|
55 |
}
|
56 |
|
57 |
/**
|
58 |
+
* Add columns.
|
59 |
*
|
60 |
+
* @param array $columns An associative array of column headings.
|
61 |
* @return array
|
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' );
|
67 |
+
$columns['date'] = $date;
|
68 |
return $columns;
|
69 |
}
|
70 |
|
71 |
/**
|
72 |
+
* Render column for form key.
|
73 |
*
|
74 |
+
* @param string $column_name An associative array of column headings.
|
|
|
75 |
*/
|
76 |
+
public function _manage_posts_custom_column( $column_name ) {
|
77 |
if ( 'mwform_form_key' === $column_name ) {
|
78 |
+
$this->_render(
|
79 |
+
'admin-list/form-key',
|
80 |
+
array(
|
81 |
+
'post_id' => get_the_ID(),
|
82 |
+
)
|
83 |
+
);
|
84 |
}
|
85 |
}
|
86 |
}
|
classes/controllers/class.admin.php
CHANGED
@@ -1,13 +1,12 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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 |
|
@@ -16,18 +15,19 @@ class MW_WP_Form_Admin_Controller extends MW_WP_Form_Controller {
|
|
16 |
*/
|
17 |
protected $styles = array();
|
18 |
|
|
|
|
|
|
|
19 |
public function __construct() {
|
20 |
-
add_action( 'add_meta_boxes'
|
21 |
-
add_filter( 'default_content'
|
22 |
-
add_action( 'media_buttons'
|
23 |
add_action( 'admin_enqueue_scripts', array( $this, '_admin_enqueue_scripts' ) );
|
24 |
-
add_action( 'save_post'
|
25 |
}
|
26 |
|
27 |
/**
|
28 |
-
* Add meta boxes
|
29 |
-
*
|
30 |
-
* @return void
|
31 |
*/
|
32 |
public function _add_meta_boxes() {
|
33 |
global $post;
|
@@ -116,20 +116,18 @@ class MW_WP_Form_Admin_Controller extends MW_WP_Form_Controller {
|
|
116 |
}
|
117 |
|
118 |
/**
|
119 |
-
* Set default form html
|
120 |
*
|
121 |
-
* @param string $content
|
122 |
* @return string
|
123 |
*/
|
124 |
-
public function _default_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();
|
@@ -145,9 +143,7 @@ class MW_WP_Form_Admin_Controller extends MW_WP_Form_Controller {
|
|
145 |
}
|
146 |
|
147 |
/**
|
148 |
-
* Enqueue assets
|
149 |
-
*
|
150 |
-
* @return void
|
151 |
*/
|
152 |
public function _admin_enqueue_scripts() {
|
153 |
$url = plugins_url( MWF_Config::NAME );
|
@@ -187,10 +183,9 @@ class MW_WP_Form_Admin_Controller extends MW_WP_Form_Controller {
|
|
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'] ) {
|
@@ -250,7 +245,7 @@ class MW_WP_Form_Admin_Controller extends MW_WP_Form_Controller {
|
|
250 |
}
|
251 |
}
|
252 |
|
253 |
-
if ( 'minlength' === $key
|
254 |
unset( $_validation[ $key ] );
|
255 |
}
|
256 |
|
@@ -301,34 +296,44 @@ class MW_WP_Form_Admin_Controller extends MW_WP_Form_Controller {
|
|
301 |
}
|
302 |
|
303 |
/**
|
304 |
-
* Render complete message meta box
|
305 |
-
*
|
306 |
-
* @return void
|
307 |
*/
|
308 |
public function _complete_message() {
|
309 |
-
$
|
310 |
-
|
311 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
312 |
}
|
313 |
|
314 |
/**
|
315 |
-
* Render URL setting meta box
|
316 |
-
*
|
317 |
-
* @return void
|
318 |
*/
|
319 |
public function _url() {
|
320 |
-
$
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
326 |
}
|
327 |
|
328 |
/**
|
329 |
-
* Render validation meta box
|
330 |
-
*
|
331 |
-
* @return void
|
332 |
*/
|
333 |
public function _validation_rule() {
|
334 |
global $post;
|
@@ -342,48 +347,53 @@ class MW_WP_Form_Admin_Controller extends MW_WP_Form_Controller {
|
|
342 |
'target' => '',
|
343 |
);
|
344 |
|
345 |
-
$form_key
|
346 |
$Validation_Rules = MW_WP_Form_Validation_Rules::instantiation( $form_key );
|
347 |
|
348 |
-
foreach ( $Validation_Rules->get_validation_rules() as $
|
349 |
$validation_keys[ $instance->getName() ] = '';
|
350 |
}
|
351 |
|
352 |
// 空の隠れバリデーションフィールド(コピー元)を挿入
|
353 |
array_unshift( $validation, $validation_keys );
|
354 |
-
$this->_render(
|
355 |
-
'validation'
|
356 |
-
|
357 |
-
|
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(
|
377 |
-
'
|
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' );
|
@@ -394,22 +404,28 @@ class MW_WP_Form_Admin_Controller extends MW_WP_Form_Controller {
|
|
394 |
$mail_reply_to = get_bloginfo( 'admin_email' );
|
395 |
}
|
396 |
|
397 |
-
$this->_render(
|
398 |
-
'
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
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' );
|
@@ -425,52 +441,63 @@ class MW_WP_Form_Admin_Controller extends MW_WP_Form_Controller {
|
|
425 |
$admin_mail_reply_to = get_bloginfo( 'admin_email' );
|
426 |
}
|
427 |
|
428 |
-
$this->_render(
|
429 |
-
'
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
|
|
|
|
|
|
|
|
439 |
}
|
440 |
|
441 |
/**
|
442 |
-
* Render settings meta box
|
443 |
-
*
|
444 |
-
* @return void
|
445 |
*/
|
446 |
public function _settings() {
|
447 |
-
$
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
'
|
453 |
-
|
454 |
-
|
455 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
456 |
}
|
457 |
|
458 |
/**
|
459 |
-
* Render styles meta box
|
460 |
-
*
|
461 |
-
* @return void
|
462 |
*/
|
463 |
public function _style() {
|
464 |
-
$this->_render(
|
465 |
-
'
|
466 |
-
|
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 ) {
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Admin_Controller
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Admin_Controller extends MW_WP_Form_Controller {
|
12 |
|
15 |
*/
|
16 |
protected $styles = array();
|
17 |
|
18 |
+
/**
|
19 |
+
* Constructor.
|
20 |
+
*/
|
21 |
public function __construct() {
|
22 |
+
add_action( 'add_meta_boxes', array( $this, '_add_meta_boxes' ) );
|
23 |
+
add_filter( 'default_content', array( $this, '_default_content' ) );
|
24 |
+
add_action( 'media_buttons', array( $this, '_tag_generator' ) );
|
25 |
add_action( 'admin_enqueue_scripts', array( $this, '_admin_enqueue_scripts' ) );
|
26 |
+
add_action( 'save_post', array( $this, '_save_post' ) );
|
27 |
}
|
28 |
|
29 |
/**
|
30 |
+
* Add meta boxes.
|
|
|
|
|
31 |
*/
|
32 |
public function _add_meta_boxes() {
|
33 |
global $post;
|
116 |
}
|
117 |
|
118 |
/**
|
119 |
+
* Set default form html.
|
120 |
*
|
|
|
121 |
* @return string
|
122 |
*/
|
123 |
+
public function _default_content() {
|
124 |
return apply_filters( 'mwform_default_content', '' );
|
125 |
}
|
126 |
|
127 |
/**
|
128 |
+
* Render tag generator.
|
129 |
*
|
130 |
+
* @param string $editor_id Editor ID.
|
|
|
131 |
*/
|
132 |
public function _tag_generator( $editor_id ) {
|
133 |
$post_type = get_post_type();
|
143 |
}
|
144 |
|
145 |
/**
|
146 |
+
* Enqueue assets.
|
|
|
|
|
147 |
*/
|
148 |
public function _admin_enqueue_scripts() {
|
149 |
$url = plugins_url( MWF_Config::NAME );
|
183 |
}
|
184 |
|
185 |
/**
|
186 |
+
* Save.
|
187 |
*
|
188 |
+
* @param int $post_id Post ID.
|
|
|
189 |
*/
|
190 |
public function _save_post( $post_id ) {
|
191 |
if ( ! isset( $_POST['post_type'] ) || MWF_Config::NAME !== $_POST['post_type'] ) {
|
245 |
}
|
246 |
}
|
247 |
|
248 |
+
if ( 'minlength' === $key && ! MWF_Functions::is_numeric( $value['min'] ) ) {
|
249 |
unset( $_validation[ $key ] );
|
250 |
}
|
251 |
|
296 |
}
|
297 |
|
298 |
/**
|
299 |
+
* Render complete message meta box.
|
|
|
|
|
300 |
*/
|
301 |
public function _complete_message() {
|
302 |
+
global $post;
|
303 |
+
|
304 |
+
$form_key = MWF_Functions::get_form_key_from_form_id( $post->ID );
|
305 |
+
|
306 |
+
$this->_render(
|
307 |
+
'admin/complete-message',
|
308 |
+
array(
|
309 |
+
'content' => $this->_get_option( 'complete_message' ),
|
310 |
+
),
|
311 |
+
$form_key
|
312 |
+
);
|
313 |
}
|
314 |
|
315 |
/**
|
316 |
+
* Render URL setting meta box.
|
|
|
|
|
317 |
*/
|
318 |
public function _url() {
|
319 |
+
global $post;
|
320 |
+
|
321 |
+
$form_key = MWF_Functions::get_form_key_from_form_id( $post->ID );
|
322 |
+
|
323 |
+
$this->_render(
|
324 |
+
'admin/url',
|
325 |
+
array(
|
326 |
+
'input_url' => $this->_get_option( 'input_url' ),
|
327 |
+
'confirmation_url' => $this->_get_option( 'confirmation_url' ),
|
328 |
+
'complete_url' => $this->_get_option( 'complete_url' ),
|
329 |
+
'validation_error_url' => $this->_get_option( 'validation_error_url' ),
|
330 |
+
),
|
331 |
+
$form_key
|
332 |
+
);
|
333 |
}
|
334 |
|
335 |
/**
|
336 |
+
* Render validation meta box.
|
|
|
|
|
337 |
*/
|
338 |
public function _validation_rule() {
|
339 |
global $post;
|
347 |
'target' => '',
|
348 |
);
|
349 |
|
350 |
+
$form_key = MWF_Functions::get_form_key_from_form_id( $post->ID );
|
351 |
$Validation_Rules = MW_WP_Form_Validation_Rules::instantiation( $form_key );
|
352 |
|
353 |
+
foreach ( $Validation_Rules->get_validation_rules() as $instance ) {
|
354 |
$validation_keys[ $instance->getName() ] = '';
|
355 |
}
|
356 |
|
357 |
// 空の隠れバリデーションフィールド(コピー元)を挿入
|
358 |
array_unshift( $validation, $validation_keys );
|
359 |
+
$this->_render(
|
360 |
+
'admin/validation-rule',
|
361 |
+
array(
|
362 |
+
'validation' => $validation,
|
363 |
+
'validation_rules' => $Validation_Rules->get_validation_rules(),
|
364 |
+
'validation_keys' => $validation_keys,
|
365 |
+
),
|
366 |
+
$form_key
|
367 |
+
);
|
368 |
}
|
369 |
|
370 |
/**
|
371 |
+
* Render add-on meta box.
|
|
|
|
|
372 |
*/
|
373 |
public function _add_ons() {
|
374 |
$this->_render( 'admin/add-ons' );
|
375 |
}
|
376 |
|
377 |
/**
|
378 |
+
* Render form key meta box.
|
|
|
|
|
379 |
*/
|
380 |
public function _form_key() {
|
381 |
+
$this->_render(
|
382 |
+
'admin/form-key',
|
383 |
+
array(
|
384 |
+
'post_id' => get_the_ID(),
|
385 |
+
)
|
386 |
+
);
|
387 |
}
|
388 |
|
389 |
/**
|
390 |
+
* Render reply mail meta box.
|
|
|
|
|
391 |
*/
|
392 |
public function _mail_options() {
|
393 |
+
global $post;
|
394 |
+
|
395 |
+
$form_key = MWF_Functions::get_form_key_from_form_id( $post->ID );
|
396 |
+
|
397 |
$mail_sender = $this->_get_option( 'mail_sender' );
|
398 |
if ( is_null( $mail_sender ) ) {
|
399 |
$mail_sender = get_bloginfo( 'name' );
|
404 |
$mail_reply_to = get_bloginfo( 'admin_email' );
|
405 |
}
|
406 |
|
407 |
+
$this->_render(
|
408 |
+
'admin/mail-options',
|
409 |
+
array(
|
410 |
+
'mail_subject' => $this->_get_option( 'mail_subject' ),
|
411 |
+
'mail_sender' => $mail_sender,
|
412 |
+
'mail_reply_to' => $mail_reply_to,
|
413 |
+
'mail_from' => $this->_get_option( 'mail_from' ),
|
414 |
+
'mail_content' => $this->_get_option( 'mail_content' ),
|
415 |
+
'automatic_reply_email' => $this->_get_option( 'automatic_reply_email' ),
|
416 |
+
),
|
417 |
+
$form_key
|
418 |
+
);
|
419 |
}
|
420 |
|
421 |
/**
|
422 |
+
* Render admin mail meta box.
|
|
|
|
|
423 |
*/
|
424 |
public function _admin_mail_options() {
|
425 |
+
global $post;
|
426 |
+
|
427 |
+
$form_key = MWF_Functions::get_form_key_from_form_id( $post->ID );
|
428 |
+
|
429 |
$mail_to = $this->_get_option( 'mail_to' );
|
430 |
if ( is_null( $mail_to ) ) {
|
431 |
$mail_to = get_bloginfo( 'admin_email' );
|
441 |
$admin_mail_reply_to = get_bloginfo( 'admin_email' );
|
442 |
}
|
443 |
|
444 |
+
$this->_render(
|
445 |
+
'admin/admin-mail-options',
|
446 |
+
array(
|
447 |
+
'mail_to' => $mail_to,
|
448 |
+
'mail_cc' => $this->_get_option( 'mail_cc' ),
|
449 |
+
'mail_bcc' => $this->_get_option( 'mail_bcc' ),
|
450 |
+
'admin_mail_subject' => $this->_get_option( 'admin_mail_subject' ),
|
451 |
+
'admin_mail_sender' => $admin_mail_sender,
|
452 |
+
'admin_mail_reply_to' => $admin_mail_reply_to,
|
453 |
+
'mail_return_path' => $this->_get_option( 'mail_return_path' ),
|
454 |
+
'admin_mail_from' => $this->_get_option( 'admin_mail_from' ),
|
455 |
+
'admin_mail_content' => $this->_get_option( 'admin_mail_content' ),
|
456 |
+
),
|
457 |
+
$form_key
|
458 |
+
);
|
459 |
}
|
460 |
|
461 |
/**
|
462 |
+
* Render settings meta box.
|
|
|
|
|
463 |
*/
|
464 |
public function _settings() {
|
465 |
+
global $post;
|
466 |
+
|
467 |
+
$form_key = MWF_Functions::get_form_key_from_form_id( $post->ID );
|
468 |
+
|
469 |
+
$this->_render(
|
470 |
+
'admin/settings',
|
471 |
+
array(
|
472 |
+
'querystring' => $this->_get_option( 'querystring' ),
|
473 |
+
'usedb' => $this->_get_option( 'usedb' ),
|
474 |
+
'scroll' => $this->_get_option( 'scroll' ),
|
475 |
+
'akismet_author' => $this->_get_option( 'akismet_author' ),
|
476 |
+
'akismet_author_email' => $this->_get_option( 'akismet_author_email' ),
|
477 |
+
'akismet_author_url' => $this->_get_option( 'akismet_author_url' ),
|
478 |
+
'tracking_number' => $this->_get_option( MWF_Config::TRACKINGNUMBER ),
|
479 |
+
),
|
480 |
+
$form_key
|
481 |
+
);
|
482 |
}
|
483 |
|
484 |
/**
|
485 |
+
* Render styles meta box.
|
|
|
|
|
486 |
*/
|
487 |
public function _style() {
|
488 |
+
$this->_render(
|
489 |
+
'admin/style',
|
490 |
+
array(
|
491 |
+
'styles' => $this->styles,
|
492 |
+
'style' => $this->_get_option( 'style' ),
|
493 |
+
)
|
494 |
+
);
|
495 |
}
|
496 |
|
497 |
/**
|
498 |
+
* Get form option.
|
499 |
*
|
500 |
+
* @param string $key Key of option.
|
501 |
* @return mixed
|
502 |
*/
|
503 |
protected function _get_option( $key ) {
|
classes/controllers/class.chart.php
CHANGED
@@ -1,48 +1,50 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
40 |
}
|
41 |
|
42 |
/**
|
43 |
-
* Enqueue assets
|
44 |
-
*
|
45 |
-
* @return void
|
46 |
*/
|
47 |
public function _admin_enqueue_scripts() {
|
48 |
global $wp_scripts;
|
@@ -95,9 +97,7 @@ class MW_WP_Form_Chart_Controller extends MW_WP_Form_Controller {
|
|
95 |
}
|
96 |
|
97 |
/**
|
98 |
-
* Save
|
99 |
-
*
|
100 |
-
* @return void
|
101 |
*/
|
102 |
public function _save() {
|
103 |
if ( ! isset( $_POST[ MWF_Config::NAME . '-chart-nonce-field' ] ) ) {
|
@@ -116,7 +116,7 @@ class MW_WP_Form_Chart_Controller extends MW_WP_Form_Controller {
|
|
116 |
return;
|
117 |
}
|
118 |
|
119 |
-
$option_name
|
120 |
$sanitized_values = $this->_sanitize( $_POST[ $option_name ] );
|
121 |
update_option( $option_name, $sanitized_values );
|
122 |
wp_redirect(
|
@@ -128,9 +128,7 @@ class MW_WP_Form_Chart_Controller extends MW_WP_Form_Controller {
|
|
128 |
}
|
129 |
|
130 |
/**
|
131 |
-
* Display chart page
|
132 |
-
*
|
133 |
-
* @return void
|
134 |
*/
|
135 |
public function _index() {
|
136 |
$post_type = $this->formkey;
|
@@ -139,10 +137,13 @@ class MW_WP_Form_Chart_Controller extends MW_WP_Form_Controller {
|
|
139 |
if ( empty( $args ) || ! is_array( $args ) ) {
|
140 |
$args = array();
|
141 |
}
|
142 |
-
$args = array_merge(
|
143 |
-
|
144 |
-
|
145 |
-
|
|
|
|
|
|
|
146 |
|
147 |
$form_posts = get_posts( $args );
|
148 |
|
@@ -155,7 +156,7 @@ class MW_WP_Form_Chart_Controller extends MW_WP_Form_Controller {
|
|
155 |
if ( preg_match( '/^_/', $post_custom_key ) ) {
|
156 |
continue;
|
157 |
}
|
158 |
-
$post_meta
|
159 |
$custom_keys[ $post_custom_key ][ $post_meta ][] = $post->ID;
|
160 |
}
|
161 |
}
|
@@ -175,18 +176,22 @@ class MW_WP_Form_Chart_Controller extends MW_WP_Form_Controller {
|
|
175 |
// 空の隠れフィールド(コピー元)を挿入
|
176 |
array_unshift( $postdata, $default_keys );
|
177 |
|
178 |
-
$this->_render(
|
179 |
-
'
|
180 |
-
|
181 |
-
|
182 |
-
|
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 ) {
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Chart_Controller
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Chart_Controller extends MW_WP_Form_Controller {
|
12 |
|
13 |
/**
|
14 |
+
* Post type of saved inquiry data to display in this chart.
|
15 |
+
*
|
16 |
* @var string
|
17 |
*/
|
18 |
protected $formkey;
|
19 |
|
20 |
/**
|
21 |
+
* Settings of the form.
|
22 |
+
*
|
23 |
* @var array
|
24 |
*/
|
25 |
protected $postdata = array();
|
26 |
|
27 |
+
/**
|
28 |
+
* Constructor.
|
29 |
+
*/
|
30 |
public function __construct() {
|
31 |
if ( ! empty( $_GET['formkey'] ) ) {
|
32 |
$this->formkey = $_GET['formkey'];
|
33 |
}
|
34 |
|
35 |
$contact_data_post_types = MW_WP_Form_Contact_Data_Setting::get_form_post_types();
|
36 |
+
if ( ! in_array( $this->formkey, $contact_data_post_types, true ) ) {
|
37 |
exit;
|
38 |
}
|
39 |
+
add_action( 'admin_enqueue_scripts', array( $this, '_admin_enqueue_scripts' ) );
|
40 |
|
41 |
$screen = get_current_screen();
|
42 |
add_action( 'load-' . $screen->id, array( $this, '_save' ) );
|
43 |
+
add_action( $screen->id, array( $this, '_index' ) );
|
44 |
}
|
45 |
|
46 |
/**
|
47 |
+
* Enqueue assets.
|
|
|
|
|
48 |
*/
|
49 |
public function _admin_enqueue_scripts() {
|
50 |
global $wp_scripts;
|
97 |
}
|
98 |
|
99 |
/**
|
100 |
+
* Save.
|
|
|
|
|
101 |
*/
|
102 |
public function _save() {
|
103 |
if ( ! isset( $_POST[ MWF_Config::NAME . '-chart-nonce-field' ] ) ) {
|
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(
|
128 |
}
|
129 |
|
130 |
/**
|
131 |
+
* Display chart page.
|
|
|
|
|
132 |
*/
|
133 |
public function _index() {
|
134 |
$post_type = $this->formkey;
|
137 |
if ( empty( $args ) || ! is_array( $args ) ) {
|
138 |
$args = array();
|
139 |
}
|
140 |
+
$args = array_merge(
|
141 |
+
$args,
|
142 |
+
array(
|
143 |
+
'posts_per_page' => -1,
|
144 |
+
'post_type' => $post_type,
|
145 |
+
)
|
146 |
+
);
|
147 |
|
148 |
$form_posts = get_posts( $args );
|
149 |
|
156 |
if ( preg_match( '/^_/', $post_custom_key ) ) {
|
157 |
continue;
|
158 |
}
|
159 |
+
$post_meta = get_post_meta( $post->ID, $post_custom_key, true );
|
160 |
$custom_keys[ $post_custom_key ][ $post_meta ][] = $post->ID;
|
161 |
}
|
162 |
}
|
176 |
// 空の隠れフィールド(コピー元)を挿入
|
177 |
array_unshift( $postdata, $default_keys );
|
178 |
|
179 |
+
$this->_render(
|
180 |
+
'chart/index',
|
181 |
+
array(
|
182 |
+
'post_type' => $post_type,
|
183 |
+
'form_posts' => $form_posts,
|
184 |
+
'custom_keys' => $custom_keys,
|
185 |
+
'postdata' => $postdata,
|
186 |
+
),
|
187 |
+
$this->formkey
|
188 |
+
);
|
189 |
}
|
190 |
|
191 |
/**
|
192 |
+
* Sanitize for settings.
|
193 |
*
|
194 |
+
* @param array $input Posted data from chart settings page.
|
195 |
* @return array
|
196 |
*/
|
197 |
public function _sanitize( $input ) {
|
classes/controllers/class.contact-data-list.php
CHANGED
@@ -1,13 +1,12 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
10 |
-
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
*/
|
12 |
class MW_WP_Form_Contact_Data_List_Controller extends MW_WP_Form_Controller {
|
13 |
|
@@ -16,6 +15,9 @@ class MW_WP_Form_Contact_Data_List_Controller extends MW_WP_Form_Controller {
|
|
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'] ) ) {
|
@@ -23,7 +25,7 @@ class MW_WP_Form_Contact_Data_List_Controller extends MW_WP_Form_Controller {
|
|
23 |
}
|
24 |
|
25 |
$this->post_type = $_GET['post_type'];
|
26 |
-
if ( ! in_array( $this->post_type, $contact_data_post_types ) ) {
|
27 |
exit;
|
28 |
}
|
29 |
|
@@ -32,11 +34,11 @@ class MW_WP_Form_Contact_Data_List_Controller extends MW_WP_Form_Controller {
|
|
32 |
$CSV->download();
|
33 |
}
|
34 |
|
35 |
-
add_action( 'pre_get_posts'
|
36 |
add_action( 'admin_enqueue_scripts', array( $this, '_admin_enqueue_scripts' ) );
|
37 |
-
add_action( 'admin_print_styles'
|
38 |
-
add_action( 'in_admin_footer'
|
39 |
-
add_filter( 'wp_count_posts'
|
40 |
|
41 |
add_filter(
|
42 |
'manage_' . $this->post_type . '_posts_columns',
|
@@ -52,10 +54,9 @@ class MW_WP_Form_Contact_Data_List_Controller extends MW_WP_Form_Controller {
|
|
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() ) {
|
@@ -69,10 +70,13 @@ class MW_WP_Form_Contact_Data_List_Controller extends MW_WP_Form_Controller {
|
|
69 |
if ( empty( $args ) || ! is_array( $args ) ) {
|
70 |
$args = array();
|
71 |
}
|
72 |
-
$args = array_merge(
|
73 |
-
|
74 |
-
|
75 |
-
|
|
|
|
|
|
|
76 |
|
77 |
foreach ( $args as $key => $value ) {
|
78 |
$wp_query->set( $key, $value );
|
@@ -80,9 +84,7 @@ class MW_WP_Form_Contact_Data_List_Controller extends MW_WP_Form_Controller {
|
|
80 |
}
|
81 |
|
82 |
/**
|
83 |
-
* Enqueue assets
|
84 |
-
*
|
85 |
-
* @return void
|
86 |
*/
|
87 |
public function _admin_enqueue_scripts() {
|
88 |
$url = plugins_url( MWF_Config::NAME );
|
@@ -91,38 +93,37 @@ class MW_WP_Form_Contact_Data_List_Controller extends MW_WP_Form_Controller {
|
|
91 |
}
|
92 |
|
93 |
/**
|
94 |
-
* Delete add new link
|
95 |
-
*
|
96 |
-
* @return void
|
97 |
*/
|
98 |
public function _admin_print_styles() {
|
99 |
$this->_render( 'contact-data-list/admin-print-styles' );
|
100 |
}
|
101 |
|
102 |
/**
|
103 |
-
* Render csv download button
|
104 |
-
*
|
105 |
-
* @return void
|
106 |
*/
|
107 |
public function _add_csv_download_button() {
|
108 |
if ( true !== apply_filters( 'mwform_csv_button_' . $this->post_type, true ) ) {
|
109 |
return;
|
110 |
}
|
111 |
$page = ( basename( $_SERVER['PHP_SELF'] ) );
|
112 |
-
if ( 'edit.php' !== $page
|
113 |
return;
|
114 |
}
|
115 |
$action = $_SERVER['REQUEST_URI'];
|
116 |
-
$this->_render(
|
117 |
-
'
|
118 |
-
|
|
|
|
|
|
|
119 |
}
|
120 |
|
121 |
/**
|
122 |
-
* Edit wp count posts
|
123 |
*
|
124 |
-
* @param object $counts
|
125 |
-
* @param string $type
|
126 |
* @return object
|
127 |
*/
|
128 |
public function _wp_count_posts( $counts, $type ) {
|
@@ -131,14 +132,17 @@ class MW_WP_Form_Contact_Data_List_Controller extends MW_WP_Form_Controller {
|
|
131 |
$args = array();
|
132 |
}
|
133 |
|
134 |
-
$args = array_merge(
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
|
|
|
|
|
|
139 |
|
140 |
foreach ( $counts as $key => $count ) {
|
141 |
-
$query
|
142 |
$counts->$key = $query->found_posts;
|
143 |
}
|
144 |
|
@@ -146,9 +150,9 @@ class MW_WP_Form_Contact_Data_List_Controller extends MW_WP_Form_Controller {
|
|
146 |
}
|
147 |
|
148 |
/**
|
149 |
-
* Set displayed columns name
|
150 |
*
|
151 |
-
* @param array $columns
|
152 |
* @return array
|
153 |
*/
|
154 |
public function _add_form_columns_name( $columns ) {
|
@@ -158,7 +162,7 @@ class MW_WP_Form_Contact_Data_List_Controller extends MW_WP_Form_Controller {
|
|
158 |
$columns['post_date'] = __( 'Registed Date', 'mw-wp-form' );
|
159 |
$columns['admin_mail_to'] = __( 'Admin Email To', 'mw-wp-form' );
|
160 |
$columns['response_status'] = __( 'Response Status', 'mw-wp-form' );
|
161 |
-
$_columns
|
162 |
|
163 |
foreach ( $posts as $post ) {
|
164 |
$post_custom_keys = get_post_custom_keys( $post->ID );
|
@@ -187,27 +191,27 @@ class MW_WP_Form_Contact_Data_List_Controller extends MW_WP_Form_Controller {
|
|
187 |
}
|
188 |
|
189 |
/**
|
190 |
-
* Render each columns
|
191 |
*
|
192 |
-
* @param string $column
|
193 |
-
* @param int
|
194 |
*/
|
195 |
public function _add_form_columns( $column, $post_id ) {
|
196 |
$post = get_post( $post_id );
|
197 |
$post_custom_keys = get_post_custom_keys( $post_id );
|
198 |
-
$
|
199 |
|
200 |
if ( 'post_date' === $column ) {
|
201 |
$value = esc_html( $post->post_date );
|
202 |
} elseif ( 'response_status' === $column ) {
|
203 |
-
$response_statuses = $
|
204 |
-
$response_status = $
|
205 |
-
$value
|
206 |
} elseif ( 'admin_mail_to' === $column ) {
|
207 |
-
$value = $
|
208 |
-
} elseif ( is_array( $post_custom_keys ) && in_array( $column, $post_custom_keys ) ) {
|
209 |
$post_meta = get_post_meta( $post_id, $column, true );
|
210 |
-
if ( $
|
211 |
// 過去バージョンでの不具合でメタデータが空になっていることがあるのでその場合は代替処理
|
212 |
if ( '' === $post_meta ) {
|
213 |
$post_meta = MWF_Functions::get_multimedia_id__fallback( $post, $column );
|
@@ -222,8 +226,11 @@ class MW_WP_Form_Contact_Data_List_Controller extends MW_WP_Form_Controller {
|
|
222 |
$value = ' ';
|
223 |
}
|
224 |
|
225 |
-
$this->_render(
|
226 |
-
'column'
|
227 |
-
|
|
|
|
|
|
|
228 |
}
|
229 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Contact_Data_List_Controller
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Contact_Data_List_Controller extends MW_WP_Form_Controller {
|
12 |
|
15 |
*/
|
16 |
protected $post_type;
|
17 |
|
18 |
+
/**
|
19 |
+
* Constructor.
|
20 |
+
*/
|
21 |
public function __construct() {
|
22 |
$contact_data_post_types = MW_WP_Form_Contact_Data_Setting::get_form_post_types();
|
23 |
if ( ! isset( $_GET['post_type'] ) ) {
|
25 |
}
|
26 |
|
27 |
$this->post_type = $_GET['post_type'];
|
28 |
+
if ( ! in_array( $this->post_type, $contact_data_post_types, true ) ) {
|
29 |
exit;
|
30 |
}
|
31 |
|
34 |
$CSV->download();
|
35 |
}
|
36 |
|
37 |
+
add_action( 'pre_get_posts', array( $this, '_pre_get_posts' ) );
|
38 |
add_action( 'admin_enqueue_scripts', array( $this, '_admin_enqueue_scripts' ) );
|
39 |
+
add_action( 'admin_print_styles', array( $this, '_admin_print_styles' ) );
|
40 |
+
add_action( 'in_admin_footer', array( $this, '_add_csv_download_button' ) );
|
41 |
+
add_filter( 'wp_count_posts', array( $this, '_wp_count_posts' ), 10, 2 );
|
42 |
|
43 |
add_filter(
|
44 |
'manage_' . $this->post_type . '_posts_columns',
|
54 |
}
|
55 |
|
56 |
/**
|
57 |
+
* Change if there is a necessity of change in the inquiry data displayed by hook.
|
58 |
*
|
59 |
+
* @param WP_Query $wp_query WP_Query object.
|
|
|
60 |
*/
|
61 |
public function _pre_get_posts( $wp_query ) {
|
62 |
if ( ! $wp_query->is_main_query() ) {
|
70 |
if ( empty( $args ) || ! is_array( $args ) ) {
|
71 |
$args = array();
|
72 |
}
|
73 |
+
$args = array_merge(
|
74 |
+
$args,
|
75 |
+
array(
|
76 |
+
'post_type' => $post_type,
|
77 |
+
'post_status' => $post_status,
|
78 |
+
)
|
79 |
+
);
|
80 |
|
81 |
foreach ( $args as $key => $value ) {
|
82 |
$wp_query->set( $key, $value );
|
84 |
}
|
85 |
|
86 |
/**
|
87 |
+
* Enqueue assets.
|
|
|
|
|
88 |
*/
|
89 |
public function _admin_enqueue_scripts() {
|
90 |
$url = plugins_url( MWF_Config::NAME );
|
93 |
}
|
94 |
|
95 |
/**
|
96 |
+
* Delete add new link.
|
|
|
|
|
97 |
*/
|
98 |
public function _admin_print_styles() {
|
99 |
$this->_render( 'contact-data-list/admin-print-styles' );
|
100 |
}
|
101 |
|
102 |
/**
|
103 |
+
* Render csv download button.
|
|
|
|
|
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(
|
115 |
+
'contact-data-list/csv-button',
|
116 |
+
array(
|
117 |
+
'action' => $action,
|
118 |
+
)
|
119 |
+
);
|
120 |
}
|
121 |
|
122 |
/**
|
123 |
+
* Edit wp count posts.
|
124 |
*
|
125 |
+
* @param object $counts An object containing the current post_type's post counts by status.
|
126 |
+
* @param string $type Post type.
|
127 |
* @return object
|
128 |
*/
|
129 |
public function _wp_count_posts( $counts, $type ) {
|
132 |
$args = array();
|
133 |
}
|
134 |
|
135 |
+
$args = array_merge(
|
136 |
+
$args,
|
137 |
+
array(
|
138 |
+
'post_type' => $type,
|
139 |
+
'posts_per_page' => 1,
|
140 |
+
'post_status' => 'any',
|
141 |
+
)
|
142 |
+
);
|
143 |
|
144 |
foreach ( $counts as $key => $count ) {
|
145 |
+
$query = new WP_Query( array_merge( $args, array( 'post_status' => $key ) ) );
|
146 |
$counts->$key = $query->found_posts;
|
147 |
}
|
148 |
|
150 |
}
|
151 |
|
152 |
/**
|
153 |
+
* Set displayed columns name.
|
154 |
*
|
155 |
+
* @param array $columns An associative array of column headings.
|
156 |
* @return array
|
157 |
*/
|
158 |
public function _add_form_columns_name( $columns ) {
|
162 |
$columns['post_date'] = __( 'Registed Date', 'mw-wp-form' );
|
163 |
$columns['admin_mail_to'] = __( 'Admin Email To', 'mw-wp-form' );
|
164 |
$columns['response_status'] = __( 'Response Status', 'mw-wp-form' );
|
165 |
+
$_columns = array();
|
166 |
|
167 |
foreach ( $posts as $post ) {
|
168 |
$post_custom_keys = get_post_custom_keys( $post->ID );
|
191 |
}
|
192 |
|
193 |
/**
|
194 |
+
* Render each columns.
|
195 |
*
|
196 |
+
* @param string $column An associative array of column headings.
|
197 |
+
* @param int $post_id Post ID.
|
198 |
*/
|
199 |
public function _add_form_columns( $column, $post_id ) {
|
200 |
$post = get_post( $post_id );
|
201 |
$post_custom_keys = get_post_custom_keys( $post_id );
|
202 |
+
$contact_data_setting = new MW_WP_Form_Contact_Data_Setting( $post_id );
|
203 |
|
204 |
if ( 'post_date' === $column ) {
|
205 |
$value = esc_html( $post->post_date );
|
206 |
} elseif ( 'response_status' === $column ) {
|
207 |
+
$response_statuses = $contact_data_setting->get_response_statuses();
|
208 |
+
$response_status = $contact_data_setting->get( 'response_status' );
|
209 |
+
$value = $response_statuses[ $response_status ];
|
210 |
} elseif ( 'admin_mail_to' === $column ) {
|
211 |
+
$value = $contact_data_setting->get( 'admin_mail_to' );
|
212 |
+
} elseif ( is_array( $post_custom_keys ) && in_array( $column, $post_custom_keys, true ) ) {
|
213 |
$post_meta = get_post_meta( $post_id, $column, true );
|
214 |
+
if ( $contact_data_setting->is_upload_file_key( $column ) ) {
|
215 |
// 過去バージョンでの不具合でメタデータが空になっていることがあるのでその場合は代替処理
|
216 |
if ( '' === $post_meta ) {
|
217 |
$post_meta = MWF_Functions::get_multimedia_id__fallback( $post, $column );
|
226 |
$value = ' ';
|
227 |
}
|
228 |
|
229 |
+
$this->_render(
|
230 |
+
'contact-data-list/column',
|
231 |
+
array(
|
232 |
+
'column' => $value,
|
233 |
+
)
|
234 |
+
);
|
235 |
}
|
236 |
}
|
classes/controllers/class.contact-data.php
CHANGED
@@ -1,16 +1,18 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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 ) {
|
@@ -18,7 +20,7 @@ class MW_WP_Form_Contact_Data_Controller extends MW_WP_Form_Controller {
|
|
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 |
|
@@ -34,28 +36,29 @@ class MW_WP_Form_Contact_Data_Controller extends MW_WP_Form_Controller {
|
|
34 |
$_post_id = $_POST['post_ID'];
|
35 |
}
|
36 |
|
37 |
-
$args
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
|
|
|
|
|
|
43 |
$permit_posts = get_posts( $args );
|
44 |
if ( empty( $permit_posts ) ) {
|
45 |
return;
|
46 |
}
|
47 |
|
48 |
-
add_action( 'add_meta_boxes'
|
49 |
add_action( 'admin_enqueue_scripts', array( $this, '_admin_enqueue_scripts' ) );
|
50 |
-
add_action( 'admin_print_styles'
|
51 |
-
add_action( 'edit_form_top'
|
52 |
-
add_action( 'save_post'
|
53 |
}
|
54 |
|
55 |
/**
|
56 |
-
* Add meta boxes
|
57 |
-
*
|
58 |
-
* @return void
|
59 |
*/
|
60 |
public function _add_meta_boxes() {
|
61 |
$post_type = get_post_type();
|
@@ -68,9 +71,7 @@ class MW_WP_Form_Contact_Data_Controller extends MW_WP_Form_Controller {
|
|
68 |
}
|
69 |
|
70 |
/**
|
71 |
-
* Enqueue assets
|
72 |
-
*
|
73 |
-
* @return void
|
74 |
*/
|
75 |
public function _admin_enqueue_scripts() {
|
76 |
$url = plugins_url( MWF_Config::NAME );
|
@@ -78,33 +79,30 @@ class MW_WP_Form_Contact_Data_Controller extends MW_WP_Form_Controller {
|
|
78 |
}
|
79 |
|
80 |
/**
|
81 |
-
* Delete add new link
|
82 |
-
*
|
83 |
-
* @return void
|
84 |
*/
|
85 |
public function _admin_print_styles() {
|
86 |
$this->_render( 'contact-data/admin-print-styles' );
|
87 |
}
|
88 |
|
89 |
/**
|
90 |
-
* Render back to list link
|
91 |
-
*
|
92 |
-
* @param object $post
|
93 |
-
* @return void
|
94 |
*/
|
95 |
-
public function _edit_form_top(
|
96 |
$post_type = get_post_type();
|
97 |
-
$link
|
98 |
-
$this->_render(
|
99 |
-
'link'
|
100 |
-
|
|
|
|
|
|
|
101 |
}
|
102 |
|
103 |
/**
|
104 |
-
* Save
|
105 |
*
|
106 |
-
* @param int $post_id
|
107 |
-
* @return void
|
108 |
*/
|
109 |
public function _save_post( $post_id ) {
|
110 |
if ( ! isset( $_POST['post_type'] ) ) {
|
@@ -112,7 +110,7 @@ class MW_WP_Form_Contact_Data_Controller extends MW_WP_Form_Controller {
|
|
112 |
}
|
113 |
|
114 |
$contact_data_post_types = MW_WP_Form_Contact_Data_setting::get_form_post_types();
|
115 |
-
if ( ! in_array( $_POST['post_type'], $contact_data_post_types ) ) {
|
116 |
return;
|
117 |
}
|
118 |
|
@@ -128,35 +126,37 @@ class MW_WP_Form_Contact_Data_Controller extends MW_WP_Form_Controller {
|
|
128 |
return;
|
129 |
}
|
130 |
|
131 |
-
$
|
132 |
-
$permit_keys
|
133 |
-
$data
|
134 |
foreach ( $permit_keys as $key ) {
|
135 |
if ( isset( $_POST[ MWF_Config::INQUIRY_DATA_NAME ][ $key ] ) ) {
|
136 |
$value = $_POST[ MWF_Config::INQUIRY_DATA_NAME ][ $key ];
|
137 |
if ( 'response_status' === $key ) {
|
138 |
-
if ( ! array_key_exists( $value, $
|
139 |
continue;
|
140 |
}
|
141 |
}
|
142 |
$data[ $key ] = $value;
|
143 |
}
|
144 |
}
|
145 |
-
$
|
146 |
-
$
|
147 |
}
|
148 |
|
149 |
/**
|
150 |
-
* Render detail meta box
|
151 |
*
|
152 |
-
* @param WP_Post $post
|
153 |
-
* @return void
|
154 |
*/
|
155 |
public function _detail( $post ) {
|
156 |
-
$this->_render(
|
157 |
-
'
|
158 |
-
|
159 |
-
|
160 |
-
|
|
|
|
|
|
|
161 |
}
|
162 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Contact_Data_Controller
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Contact_Data_Controller extends MW_WP_Form_Controller {
|
12 |
|
13 |
+
/**
|
14 |
+
* Constructor.
|
15 |
+
*/
|
16 |
public function __construct() {
|
17 |
$screen = get_current_screen();
|
18 |
if ( 'post' !== $screen->base ) {
|
20 |
}
|
21 |
|
22 |
$contact_data_post_types = MW_WP_Form_Contact_Data_Setting::get_form_post_types();
|
23 |
+
if ( ! in_array( $screen->id, $contact_data_post_types, true ) ) {
|
24 |
exit;
|
25 |
}
|
26 |
|
36 |
$_post_id = $_POST['post_ID'];
|
37 |
}
|
38 |
|
39 |
+
$args = array_merge(
|
40 |
+
$args,
|
41 |
+
array(
|
42 |
+
'post_type' => $screen->post_type,
|
43 |
+
'posts_per_page' => 1,
|
44 |
+
'post_status' => 'any',
|
45 |
+
'p' => $_post_id,
|
46 |
+
)
|
47 |
+
);
|
48 |
$permit_posts = get_posts( $args );
|
49 |
if ( empty( $permit_posts ) ) {
|
50 |
return;
|
51 |
}
|
52 |
|
53 |
+
add_action( 'add_meta_boxes', array( $this, '_add_meta_boxes' ) );
|
54 |
add_action( 'admin_enqueue_scripts', array( $this, '_admin_enqueue_scripts' ) );
|
55 |
+
add_action( 'admin_print_styles', array( $this, '_admin_print_styles' ) );
|
56 |
+
add_action( 'edit_form_top', array( $this, '_edit_form_top' ) );
|
57 |
+
add_action( 'save_post', array( $this, '_save_post' ) );
|
58 |
}
|
59 |
|
60 |
/**
|
61 |
+
* Add meta boxes.
|
|
|
|
|
62 |
*/
|
63 |
public function _add_meta_boxes() {
|
64 |
$post_type = get_post_type();
|
71 |
}
|
72 |
|
73 |
/**
|
74 |
+
* Enqueue assets.
|
|
|
|
|
75 |
*/
|
76 |
public function _admin_enqueue_scripts() {
|
77 |
$url = plugins_url( MWF_Config::NAME );
|
79 |
}
|
80 |
|
81 |
/**
|
82 |
+
* Delete add new link.
|
|
|
|
|
83 |
*/
|
84 |
public function _admin_print_styles() {
|
85 |
$this->_render( 'contact-data/admin-print-styles' );
|
86 |
}
|
87 |
|
88 |
/**
|
89 |
+
* Render back to list link.
|
|
|
|
|
|
|
90 |
*/
|
91 |
+
public function _edit_form_top() {
|
92 |
$post_type = get_post_type();
|
93 |
+
$link = admin_url( '/edit.php?post_type=' . $post_type );
|
94 |
+
$this->_render(
|
95 |
+
'contact-data/returning-link',
|
96 |
+
array(
|
97 |
+
'link' => $link,
|
98 |
+
)
|
99 |
+
);
|
100 |
}
|
101 |
|
102 |
/**
|
103 |
+
* Save.
|
104 |
*
|
105 |
+
* @param int $post_id Post ID.
|
|
|
106 |
*/
|
107 |
public function _save_post( $post_id ) {
|
108 |
if ( ! isset( $_POST['post_type'] ) ) {
|
110 |
}
|
111 |
|
112 |
$contact_data_post_types = MW_WP_Form_Contact_Data_setting::get_form_post_types();
|
113 |
+
if ( ! in_array( $_POST['post_type'], $contact_data_post_types, true ) ) {
|
114 |
return;
|
115 |
}
|
116 |
|
126 |
return;
|
127 |
}
|
128 |
|
129 |
+
$contact_data_setting = new MW_WP_Form_Contact_Data_setting( $post_id );
|
130 |
+
$permit_keys = $contact_data_setting->get_permit_keys();
|
131 |
+
$data = array();
|
132 |
foreach ( $permit_keys as $key ) {
|
133 |
if ( isset( $_POST[ MWF_Config::INQUIRY_DATA_NAME ][ $key ] ) ) {
|
134 |
$value = $_POST[ MWF_Config::INQUIRY_DATA_NAME ][ $key ];
|
135 |
if ( 'response_status' === $key ) {
|
136 |
+
if ( ! array_key_exists( $value, $contact_data_setting->get_response_statuses() ) ) {
|
137 |
continue;
|
138 |
}
|
139 |
}
|
140 |
$data[ $key ] = $value;
|
141 |
}
|
142 |
}
|
143 |
+
$contact_data_setting->sets( $data );
|
144 |
+
$contact_data_setting->save();
|
145 |
}
|
146 |
|
147 |
/**
|
148 |
+
* Render detail meta box.
|
149 |
*
|
150 |
+
* @param WP_Post $post WP_Post object.
|
|
|
151 |
*/
|
152 |
public function _detail( $post ) {
|
153 |
+
$this->_render(
|
154 |
+
'contact-data/detail',
|
155 |
+
array(
|
156 |
+
'post' => $post,
|
157 |
+
'post_type' => $post->post_type,
|
158 |
+
'Contact_Data_Setting' => new MW_WP_Form_Contact_Data_Setting( get_the_ID() ),
|
159 |
+
)
|
160 |
+
);
|
161 |
}
|
162 |
}
|
classes/controllers/class.main.php
CHANGED
@@ -1,13 +1,12 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
10 |
-
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
*/
|
12 |
class MW_WP_Form_Main_Controller {
|
13 |
|
@@ -26,20 +25,22 @@ class MW_WP_Form_Main_Controller {
|
|
26 |
*/
|
27 |
protected $Validation;
|
28 |
|
|
|
|
|
|
|
29 |
public function __construct() {
|
30 |
add_filter( 'nocache_headers', array( $this, '_nocache_headers' ), 1 );
|
31 |
add_filter( 'nginxchampuru_caching_headers', array( $this, '_nginxchampuru_caching_headers' ) );
|
32 |
|
33 |
-
add_action( 'parse_request'
|
34 |
add_action( 'template_redirect', array( $this, '_send_headers' ), 10000 );
|
35 |
add_action( 'template_redirect', array( $this, '_template_redirect' ), 10000 );
|
36 |
}
|
37 |
|
38 |
/**
|
39 |
-
* Delete the value of $_POST included in the request to WordPress
|
40 |
*
|
41 |
-
* @param WP_Query $wp_query
|
42 |
-
* @return void
|
43 |
*/
|
44 |
public function _remove_query_vars_from_post( $wp_query ) {
|
45 |
if ( isset( $_POST[ MWF_Config::TOKEN_NAME ] ) ) {
|
@@ -65,9 +66,11 @@ class MW_WP_Form_Main_Controller {
|
|
65 |
}
|
66 |
|
67 |
/**
|
68 |
-
* Cache control for Nginx Cache Controller plugin
|
69 |
*
|
70 |
* @todo NOT WORKING
|
|
|
|
|
71 |
*/
|
72 |
public function _nginxchampuru_caching_headers( $headers ) {
|
73 |
$headers = $this->_nocache_headers( $headers );
|
@@ -75,10 +78,10 @@ class MW_WP_Form_Main_Controller {
|
|
75 |
}
|
76 |
|
77 |
/**
|
78 |
-
* Customize request header for Nginx Cache Controller
|
79 |
*
|
80 |
-
* @param array $headers
|
81 |
-
* @return array
|
82 |
*/
|
83 |
public function _nocache_headers( $headers ) {
|
84 |
$headers['X-Accel-Expires'] = 0;
|
@@ -87,7 +90,7 @@ class MW_WP_Form_Main_Controller {
|
|
87 |
}
|
88 |
|
89 |
/**
|
90 |
-
* Proxy cache measures
|
91 |
*
|
92 |
* @todo NOT WORKING
|
93 |
*/
|
@@ -109,7 +112,7 @@ class MW_WP_Form_Main_Controller {
|
|
109 |
}
|
110 |
|
111 |
/**
|
112 |
-
* Main process for form displaying
|
113 |
*/
|
114 |
public function _template_redirect() {
|
115 |
/**
|
@@ -146,7 +149,7 @@ class MW_WP_Form_Main_Controller {
|
|
146 |
exit;
|
147 |
}
|
148 |
|
149 |
-
if ( in_array( $post_condition, array( 'confirm', 'complete' ) ) ) {
|
150 |
$this->_file_upload();
|
151 |
}
|
152 |
|
@@ -188,11 +191,12 @@ class MW_WP_Form_Main_Controller {
|
|
188 |
}
|
189 |
|
190 |
/**
|
191 |
-
* Add shortcode for [mwform_formkey]
|
192 |
*
|
193 |
-
* @param array $attributes
|
194 |
-
* @return string html
|
195 |
* @example [mwform_formkey key="post_id"]
|
|
|
|
|
|
|
196 |
*/
|
197 |
public function _mwform_formkey( $attributes ) {
|
198 |
$Exec_Shortcode = new MW_WP_Form_Exec_Shortcode();
|
@@ -201,8 +205,6 @@ class MW_WP_Form_Main_Controller {
|
|
201 |
|
202 |
/**
|
203 |
* If [mwform_formkey] in $post, enqueue assets.
|
204 |
-
*
|
205 |
-
* @return boid
|
206 |
*/
|
207 |
protected function _mwform_enqueue_scripts() {
|
208 |
global $post;
|
@@ -217,7 +219,7 @@ class MW_WP_Form_Main_Controller {
|
|
217 |
}
|
218 |
|
219 |
foreach ( $matches as $match ) {
|
220 |
-
if ( ! isset( $match[2] ) || 'mwform_formkey' !==
|
221 |
continue;
|
222 |
}
|
223 |
|
@@ -232,7 +234,7 @@ class MW_WP_Form_Main_Controller {
|
|
232 |
}
|
233 |
|
234 |
/**
|
235 |
-
* Send mail
|
236 |
*
|
237 |
* @return boolean
|
238 |
*/
|
@@ -281,9 +283,9 @@ class MW_WP_Form_Main_Controller {
|
|
281 |
}
|
282 |
|
283 |
/**
|
284 |
-
* Return that generate an array for the attached file based on the transmitted data
|
285 |
*
|
286 |
-
* @return array
|
287 |
*/
|
288 |
protected function _get_attachments() {
|
289 |
$attachments = array();
|
@@ -293,7 +295,6 @@ class MW_WP_Form_Main_Controller {
|
|
293 |
return array();
|
294 |
}
|
295 |
|
296 |
-
$wp_upload_dir = wp_upload_dir();
|
297 |
foreach ( $upload_file_keys as $key ) {
|
298 |
$upload_file_url = $this->Data->get_post_value_by_key( $key );
|
299 |
if ( ! $upload_file_url ) {
|
@@ -305,7 +306,7 @@ class MW_WP_Form_Main_Controller {
|
|
305 |
continue;
|
306 |
}
|
307 |
|
308 |
-
$form_key
|
309 |
$new_upload_dir = apply_filters(
|
310 |
'mwform_upload_dir_' . $form_key,
|
311 |
'',
|
@@ -339,8 +340,8 @@ class MW_WP_Form_Main_Controller {
|
|
339 |
* Regenerate form data according to the actual upload situation.
|
340 |
*/
|
341 |
protected function _file_upload() {
|
342 |
-
$File
|
343 |
-
$files
|
344 |
$upload_files = $this->Data->get_post_value_by_key( MWF_Config::UPLOAD_FILES );
|
345 |
if ( ! is_array( $upload_files ) ) {
|
346 |
$upload_files = array();
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Main_Controller
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Main_Controller {
|
12 |
|
25 |
*/
|
26 |
protected $Validation;
|
27 |
|
28 |
+
/**
|
29 |
+
* Constructor.
|
30 |
+
*/
|
31 |
public function __construct() {
|
32 |
add_filter( 'nocache_headers', array( $this, '_nocache_headers' ), 1 );
|
33 |
add_filter( 'nginxchampuru_caching_headers', array( $this, '_nginxchampuru_caching_headers' ) );
|
34 |
|
35 |
+
add_action( 'parse_request', array( $this, '_remove_query_vars_from_post' ) );
|
36 |
add_action( 'template_redirect', array( $this, '_send_headers' ), 10000 );
|
37 |
add_action( 'template_redirect', array( $this, '_template_redirect' ), 10000 );
|
38 |
}
|
39 |
|
40 |
/**
|
41 |
+
* Delete the value of $_POST included in the request to WordPress.
|
42 |
*
|
43 |
+
* @param WP_Query $wp_query WP_Query object.
|
|
|
44 |
*/
|
45 |
public function _remove_query_vars_from_post( $wp_query ) {
|
46 |
if ( isset( $_POST[ MWF_Config::TOKEN_NAME ] ) ) {
|
66 |
}
|
67 |
|
68 |
/**
|
69 |
+
* Cache control for Nginx Cache Controller plugin.
|
70 |
*
|
71 |
* @todo NOT WORKING
|
72 |
+
*
|
73 |
+
* @param array $headers HTTP headers.
|
74 |
*/
|
75 |
public function _nginxchampuru_caching_headers( $headers ) {
|
76 |
$headers = $this->_nocache_headers( $headers );
|
78 |
}
|
79 |
|
80 |
/**
|
81 |
+
* Customize request header for Nginx Cache Controller.
|
82 |
*
|
83 |
+
* @param array $headers HTTP headers.
|
84 |
+
* @return array
|
85 |
*/
|
86 |
public function _nocache_headers( $headers ) {
|
87 |
$headers['X-Accel-Expires'] = 0;
|
90 |
}
|
91 |
|
92 |
/**
|
93 |
+
* Proxy cache measures.
|
94 |
*
|
95 |
* @todo NOT WORKING
|
96 |
*/
|
112 |
}
|
113 |
|
114 |
/**
|
115 |
+
* Main process for form displaying.
|
116 |
*/
|
117 |
public function _template_redirect() {
|
118 |
/**
|
149 |
exit;
|
150 |
}
|
151 |
|
152 |
+
if ( in_array( $post_condition, array( 'confirm', 'complete' ), true ) ) {
|
153 |
$this->_file_upload();
|
154 |
}
|
155 |
|
191 |
}
|
192 |
|
193 |
/**
|
194 |
+
* Add shortcode for [mwform_formkey].
|
195 |
*
|
|
|
|
|
196 |
* @example [mwform_formkey key="post_id"]
|
197 |
+
*
|
198 |
+
* @param array $attributes Attributes of [mwform_formkey].
|
199 |
+
* @return string
|
200 |
*/
|
201 |
public function _mwform_formkey( $attributes ) {
|
202 |
$Exec_Shortcode = new MW_WP_Form_Exec_Shortcode();
|
205 |
|
206 |
/**
|
207 |
* If [mwform_formkey] in $post, enqueue assets.
|
|
|
|
|
208 |
*/
|
209 |
protected function _mwform_enqueue_scripts() {
|
210 |
global $post;
|
219 |
}
|
220 |
|
221 |
foreach ( $matches as $match ) {
|
222 |
+
if ( ! isset( $match[2] ) || 'mwform_formkey' !== $match[2] ) {
|
223 |
continue;
|
224 |
}
|
225 |
|
234 |
}
|
235 |
|
236 |
/**
|
237 |
+
* Send mail.
|
238 |
*
|
239 |
* @return boolean
|
240 |
*/
|
283 |
}
|
284 |
|
285 |
/**
|
286 |
+
* Return that generate an array for the attached file based on the transmitted data.
|
287 |
*
|
288 |
+
* @return array
|
289 |
*/
|
290 |
protected function _get_attachments() {
|
291 |
$attachments = array();
|
295 |
return array();
|
296 |
}
|
297 |
|
|
|
298 |
foreach ( $upload_file_keys as $key ) {
|
299 |
$upload_file_url = $this->Data->get_post_value_by_key( $key );
|
300 |
if ( ! $upload_file_url ) {
|
306 |
continue;
|
307 |
}
|
308 |
|
309 |
+
$form_key = $this->Data->get_form_key();
|
310 |
$new_upload_dir = apply_filters(
|
311 |
'mwform_upload_dir_' . $form_key,
|
312 |
'',
|
340 |
* Regenerate form data according to the actual upload situation.
|
341 |
*/
|
342 |
protected function _file_upload() {
|
343 |
+
$File = new MW_WP_Form_File();
|
344 |
+
$files = array();
|
345 |
$upload_files = $this->Data->get_post_value_by_key( MWF_Config::UPLOAD_FILES );
|
346 |
if ( ! is_array( $upload_files ) ) {
|
347 |
$upload_files = array();
|
classes/controllers/class.stores-inquiry-data-form-list.php
CHANGED
@@ -1,46 +1,51 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
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
|
25 |
foreach ( $contact_data_post_types as $post_type ) {
|
26 |
-
$post_type_object
|
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(
|
36 |
-
'
|
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 ) {
|
@@ -48,28 +53,33 @@ class MW_WP_Form_Stores_Inquiry_Data_Form_List_Controller extends MW_WP_Form_Con
|
|
48 |
if ( empty( $args ) || ! is_array( $args ) ) {
|
49 |
$args = array();
|
50 |
}
|
51 |
-
$args
|
52 |
-
|
53 |
-
|
54 |
-
|
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(
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
|
|
|
|
73 |
|
74 |
$modified_datetime = '';
|
75 |
foreach ( $inquiry_posts as $post ) {
|
@@ -82,9 +92,9 @@ class MW_WP_Form_Stores_Inquiry_Data_Form_List_Controller extends MW_WP_Form_Con
|
|
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 ) {
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Stores_Inquiry_Data_Form_List_Controller
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Stores_Inquiry_Data_Form_List_Controller extends MW_WP_Form_Controller {
|
12 |
|
13 |
+
/**
|
14 |
+
* Constructor.
|
15 |
+
*/
|
16 |
public function __construct() {
|
17 |
$screen = get_current_screen();
|
18 |
+
add_action( $screen->id, array( $this, '_index' ) );
|
19 |
}
|
20 |
|
21 |
/**
|
22 |
+
* Render the page.
|
23 |
*/
|
24 |
public function _index() {
|
25 |
$contact_data_post_types = MW_WP_Form_Contact_Data_Setting::get_form_post_types();
|
26 |
+
$form_list = array();
|
27 |
foreach ( $contact_data_post_types as $post_type ) {
|
28 |
+
$post_type_object = get_post_type_object( $post_type );
|
29 |
$form_list[ $post_type ] = array(
|
30 |
'title' => $post_type_object->labels->singular_name,
|
31 |
'count' => $this->_get_count( $post_type ),
|
32 |
'modified_datetime' => $this->_get_modified_datetime( $post_type ),
|
33 |
+
'created_datetime' => $this->_get_created_datetime( $post_type ),
|
34 |
);
|
35 |
}
|
36 |
|
37 |
+
$this->_render(
|
38 |
+
'stores-inquiry-data-form-list/index',
|
39 |
+
array(
|
40 |
+
'form_list' => $form_list,
|
41 |
+
)
|
42 |
+
);
|
43 |
}
|
44 |
|
45 |
/**
|
46 |
+
* Return data count.
|
47 |
*
|
48 |
+
* @param string $post_type Post type.
|
49 |
* @return int
|
50 |
*/
|
51 |
protected function _get_count( $post_type ) {
|
53 |
if ( empty( $args ) || ! is_array( $args ) ) {
|
54 |
$args = array();
|
55 |
}
|
56 |
+
$args = array_merge(
|
57 |
+
$args,
|
58 |
+
array(
|
59 |
+
'post_type' => $post_type,
|
60 |
+
'posts_per_page' => 1,
|
61 |
+
'post_status' => 'any',
|
62 |
+
)
|
63 |
+
);
|
64 |
$query = new WP_Query( $args );
|
65 |
return $query->found_posts;
|
66 |
}
|
67 |
|
68 |
/**
|
69 |
+
* Return the latest saved date of saved inquiry data.
|
70 |
*
|
71 |
+
* @param string $post_type Post type.
|
72 |
* @return string
|
73 |
*/
|
74 |
protected function _get_modified_datetime( $post_type ) {
|
75 |
global $post;
|
76 |
+
$inquiry_posts = get_posts(
|
77 |
+
array(
|
78 |
+
'post_type' => $post_type,
|
79 |
+
'posts_per_page' => 1,
|
80 |
+
'orderby' => 'modified',
|
81 |
+
)
|
82 |
+
);
|
83 |
|
84 |
$modified_datetime = '';
|
85 |
foreach ( $inquiry_posts as $post ) {
|
92 |
}
|
93 |
|
94 |
/**
|
95 |
+
* Return date of creating form.
|
96 |
*
|
97 |
+
* @param string $post_type Post type.
|
98 |
* @return string
|
99 |
*/
|
100 |
protected function _get_created_datetime( $post_type ) {
|
classes/deprecated.php
CHANGED
@@ -1,14 +1,31 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
class MWF_Deprecated {
|
3 |
|
|
|
|
|
|
|
4 |
public function __construct() {
|
5 |
add_action( 'mwform_after_exec_shortcode', array( $this, '_mwform_after_exec_shortcode2' ), 10000 );
|
6 |
}
|
7 |
|
|
|
|
|
|
|
8 |
public function _mwform_after_exec_shortcode2() {
|
9 |
-
|
10 |
-
|
11 |
-
|
|
|
|
|
12 |
|
13 |
if ( has_action( 'mwform_after_exec_shortcode' ) ) {
|
14 |
MWF_Functions::deprecated_message(
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MWF_Deprecated
|
10 |
+
*/
|
11 |
class MWF_Deprecated {
|
12 |
|
13 |
+
/**
|
14 |
+
* Constructor.
|
15 |
+
*/
|
16 |
public function __construct() {
|
17 |
add_action( 'mwform_after_exec_shortcode', array( $this, '_mwform_after_exec_shortcode2' ), 10000 );
|
18 |
}
|
19 |
|
20 |
+
/**
|
21 |
+
* Deprecated message for mwform_after_exec_shortcode.
|
22 |
+
*/
|
23 |
public function _mwform_after_exec_shortcode2() {
|
24 |
+
remove_action(
|
25 |
+
'mwform_after_exec_shortcode',
|
26 |
+
array( $this, '_mwform_after_exec_shortcode2' ),
|
27 |
+
10000
|
28 |
+
);
|
29 |
|
30 |
if ( has_action( 'mwform_after_exec_shortcode' ) ) {
|
31 |
MWF_Functions::deprecated_message(
|
classes/form-fields/class.akismet_error.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
@@ -32,20 +32,18 @@ class MW_WP_Form_Field_Akismet_Error extends MW_WP_Form_Abstract_Form_Field {
|
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
-
* Set default attributes
|
36 |
*
|
37 |
-
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array();
|
41 |
}
|
42 |
|
43 |
/**
|
44 |
-
* Callback of add shortcode for input page
|
45 |
*
|
46 |
-
* @
|
47 |
-
* @param string $element_content
|
48 |
-
* @return string HTML
|
49 |
*/
|
50 |
protected function input_page() {
|
51 |
$error = $this->get_error( MWF_Config::AKISMET );
|
@@ -58,11 +56,7 @@ class MW_WP_Form_Field_Akismet_Error extends MW_WP_Form_Abstract_Form_Field {
|
|
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 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Field_Akismet_Error
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Field_Akismet_Error extends MW_WP_Form_Abstract_Form_Field {
|
12 |
|
13 |
/**
|
14 |
* Types of form type.
|
15 |
+
* input|select|button|input_button|error|other.
|
16 |
+
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* Set default attributes.
|
36 |
*
|
37 |
+
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array();
|
41 |
}
|
42 |
|
43 |
/**
|
44 |
+
* Callback of add shortcode for input page.
|
45 |
*
|
46 |
+
* @return string
|
|
|
|
|
47 |
*/
|
48 |
protected function input_page() {
|
49 |
$error = $this->get_error( MWF_Config::AKISMET );
|
56 |
}
|
57 |
|
58 |
/**
|
59 |
+
* Callback of add shortcode for confirm page.
|
|
|
|
|
|
|
|
|
60 |
*/
|
61 |
protected function confirm_page() {
|
62 |
}
|
classes/form-fields/class.back-button.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
@@ -32,9 +32,9 @@ class MW_WP_Form_Field_Back_Button extends MW_WP_Form_Abstract_Form_Field {
|
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
-
* Set default attributes
|
36 |
*
|
37 |
-
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
@@ -44,34 +44,31 @@ class MW_WP_Form_Field_Back_Button extends MW_WP_Form_Abstract_Form_Field {
|
|
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 |
-
* @
|
60 |
-
* @param string $element_content
|
61 |
-
* @return string HTML
|
62 |
*/
|
63 |
protected function confirm_page() {
|
64 |
-
return $this->Form->submit(
|
65 |
-
|
66 |
-
|
|
|
|
|
|
|
|
|
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 |
?>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Field_Back_Button
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Field_Back_Button extends MW_WP_Form_Abstract_Form_Field {
|
12 |
|
13 |
/**
|
14 |
* Types of form type.
|
15 |
+
* input|select|button|input_button|error|other.
|
16 |
+
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* Set default attributes.
|
36 |
*
|
37 |
+
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
44 |
}
|
45 |
|
46 |
/**
|
47 |
+
* Callback of add shortcode for input page.
|
|
|
|
|
|
|
|
|
48 |
*/
|
49 |
protected function input_page() {
|
50 |
}
|
51 |
|
52 |
/**
|
53 |
+
* Callback of add shortcode for confirm page.
|
54 |
*
|
55 |
+
* @return string
|
|
|
|
|
56 |
*/
|
57 |
protected function confirm_page() {
|
58 |
+
return $this->Form->submit(
|
59 |
+
MWF_Config::BACK_BUTTON,
|
60 |
+
$this->atts['value'],
|
61 |
+
array(
|
62 |
+
'class' => $this->atts['class'],
|
63 |
+
)
|
64 |
+
);
|
65 |
}
|
66 |
|
67 |
/**
|
68 |
+
* Display tag generator dialog.
|
69 |
+
* Overwrite required for each child class.
|
70 |
*
|
71 |
+
* @param array $options Options.
|
|
|
72 |
*/
|
73 |
public function mwform_tag_generator_dialog( array $options = array() ) {
|
74 |
?>
|
classes/form-fields/class.button-back.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
@@ -32,9 +32,9 @@ class MW_WP_Form_Field_Button_Back extends MW_WP_Form_Abstract_Form_Field {
|
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
-
* Set default attributes
|
36 |
*
|
37 |
-
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
@@ -45,21 +45,15 @@ class MW_WP_Form_Field_Button_Back extends MW_WP_Form_Abstract_Form_Field {
|
|
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 |
-
* @
|
61 |
-
* @param string $element_content
|
62 |
-
* @return string HTML
|
63 |
*/
|
64 |
protected function confirm_page() {
|
65 |
return $this->Form->button_submit(
|
@@ -73,11 +67,10 @@ class MW_WP_Form_Field_Button_Back extends MW_WP_Form_Abstract_Form_Field {
|
|
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 |
?>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Field_Button_Back
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Field_Button_Back extends MW_WP_Form_Abstract_Form_Field {
|
12 |
|
13 |
/**
|
14 |
* Types of form type.
|
15 |
+
* input|select|button|input_button|error|other.
|
16 |
+
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* Set default attributes.
|
36 |
*
|
37 |
+
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
45 |
}
|
46 |
|
47 |
/**
|
48 |
+
* Callback of add shortcode for input page.
|
|
|
|
|
|
|
|
|
49 |
*/
|
50 |
protected function input_page() {
|
51 |
}
|
52 |
|
53 |
/**
|
54 |
+
* Callback of add shortcode for confirm page.
|
55 |
*
|
56 |
+
* @return string
|
|
|
|
|
57 |
*/
|
58 |
protected function confirm_page() {
|
59 |
return $this->Form->button_submit(
|
67 |
}
|
68 |
|
69 |
/**
|
70 |
+
* Display tag generator dialog.
|
71 |
+
* Overwrite required for each child class.
|
72 |
*
|
73 |
+
* @param array $options Options.
|
|
|
74 |
*/
|
75 |
public function mwform_tag_generator_dialog( array $options = array() ) {
|
76 |
?>
|
classes/form-fields/class.button-button.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
@@ -32,9 +32,9 @@ class MW_WP_Form_Field_Button_Button extends MW_WP_Form_Abstract_Form_Field {
|
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
-
* Set default attributes
|
36 |
*
|
37 |
-
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
@@ -46,11 +46,9 @@ class MW_WP_Form_Field_Button_Button extends MW_WP_Form_Abstract_Form_Field {
|
|
46 |
}
|
47 |
|
48 |
/**
|
49 |
-
* Callback of add shortcode for input page
|
50 |
*
|
51 |
-
* @
|
52 |
-
* @param string $element_content
|
53 |
-
* @return string HTML
|
54 |
*/
|
55 |
protected function input_page() {
|
56 |
return $this->Form->button_button(
|
@@ -64,22 +62,19 @@ class MW_WP_Form_Field_Button_Button extends MW_WP_Form_Abstract_Form_Field {
|
|
64 |
}
|
65 |
|
66 |
/**
|
67 |
-
* Callback of add shortcode for confirm page
|
68 |
*
|
69 |
-
* @
|
70 |
-
* @param string $element_content
|
71 |
-
* @return string HTML
|
72 |
*/
|
73 |
protected function confirm_page() {
|
74 |
return $this->input_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 |
?>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Field_Button_Button
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Field_Button_Button extends MW_WP_Form_Abstract_Form_Field {
|
12 |
|
13 |
/**
|
14 |
* Types of form type.
|
15 |
+
* input|select|button|input_button|error|other.
|
16 |
+
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* Set default attributes.
|
36 |
*
|
37 |
+
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
46 |
}
|
47 |
|
48 |
/**
|
49 |
+
* Callback of add shortcode for input page.
|
50 |
*
|
51 |
+
* @return string
|
|
|
|
|
52 |
*/
|
53 |
protected function input_page() {
|
54 |
return $this->Form->button_button(
|
62 |
}
|
63 |
|
64 |
/**
|
65 |
+
* Callback of add shortcode for confirm page.
|
66 |
*
|
67 |
+
* @return string
|
|
|
|
|
68 |
*/
|
69 |
protected function confirm_page() {
|
70 |
return $this->input_page();
|
71 |
}
|
72 |
|
73 |
/**
|
74 |
+
* Display tag generator dialog.
|
75 |
+
* Overwrite required for each child class.
|
76 |
*
|
77 |
+
* @param array $options Options.
|
|
|
78 |
*/
|
79 |
public function mwform_tag_generator_dialog( array $options = array() ) {
|
80 |
?>
|
classes/form-fields/class.button-confirm.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
@@ -32,9 +32,9 @@ class MW_WP_Form_Field_Button_Confirm extends MW_WP_Form_Abstract_Form_Field {
|
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
-
* Set default attributes
|
36 |
*
|
37 |
-
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
@@ -45,11 +45,9 @@ class MW_WP_Form_Field_Button_Confirm extends MW_WP_Form_Abstract_Form_Field {
|
|
45 |
}
|
46 |
|
47 |
/**
|
48 |
-
* Callback of add shortcode for input page
|
49 |
*
|
50 |
-
* @
|
51 |
-
* @param string $element_content
|
52 |
-
* @return string HTML
|
53 |
*/
|
54 |
protected function input_page() {
|
55 |
return $this->Form->button_submit(
|
@@ -63,21 +61,16 @@ class MW_WP_Form_Field_Button_Confirm extends MW_WP_Form_Abstract_Form_Field {
|
|
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 |
?>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Field_Button_Confirm
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Field_Button_Confirm extends MW_WP_Form_Abstract_Form_Field {
|
12 |
|
13 |
/**
|
14 |
* Types of form type.
|
15 |
+
* input|select|button|input_button|error|other.
|
16 |
+
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* Set default attributes.
|
36 |
*
|
37 |
+
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
45 |
}
|
46 |
|
47 |
/**
|
48 |
+
* Callback of add shortcode for input page.
|
49 |
*
|
50 |
+
* @return string
|
|
|
|
|
51 |
*/
|
52 |
protected function input_page() {
|
53 |
return $this->Form->button_submit(
|
61 |
}
|
62 |
|
63 |
/**
|
64 |
+
* Callback of add shortcode for confirm page.
|
|
|
|
|
|
|
|
|
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 Options.
|
|
|
74 |
*/
|
75 |
public function mwform_tag_generator_dialog( array $options = array() ) {
|
76 |
?>
|
classes/form-fields/class.button-submit.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
@@ -32,9 +32,9 @@ class MW_WP_Form_Field_Button_Submit extends MW_WP_Form_Abstract_Form_Field {
|
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
-
* Set default attributes
|
36 |
*
|
37 |
-
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
@@ -47,11 +47,9 @@ class MW_WP_Form_Field_Button_Submit extends MW_WP_Form_Abstract_Form_Field {
|
|
47 |
}
|
48 |
|
49 |
/**
|
50 |
-
* Callback of add shortcode for input page
|
51 |
*
|
52 |
-
* @
|
53 |
-
* @param string $element_content
|
54 |
-
* @return string HTML
|
55 |
*/
|
56 |
protected function input_page() {
|
57 |
if ( 'false' === $this->atts['display_input'] ) {
|
@@ -69,11 +67,9 @@ class MW_WP_Form_Field_Button_Submit extends MW_WP_Form_Abstract_Form_Field {
|
|
69 |
}
|
70 |
|
71 |
/**
|
72 |
-
* Callback of add shortcode for confirm page
|
73 |
*
|
74 |
-
* @
|
75 |
-
* @param string $element_content
|
76 |
-
* @return string HTML
|
77 |
*/
|
78 |
protected function confirm_page() {
|
79 |
return $this->Form->button_submit(
|
@@ -87,11 +83,10 @@ class MW_WP_Form_Field_Button_Submit extends MW_WP_Form_Abstract_Form_Field {
|
|
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 |
?>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Field_Button_Submit
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Field_Button_Submit extends MW_WP_Form_Abstract_Form_Field {
|
12 |
|
13 |
/**
|
14 |
* Types of form type.
|
15 |
+
* input|select|button|input_button|error|other.
|
16 |
+
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* Set default attributes.
|
36 |
*
|
37 |
+
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
47 |
}
|
48 |
|
49 |
/**
|
50 |
+
* Callback of add shortcode for input page.
|
51 |
*
|
52 |
+
* @return string
|
|
|
|
|
53 |
*/
|
54 |
protected function input_page() {
|
55 |
if ( 'false' === $this->atts['display_input'] ) {
|
67 |
}
|
68 |
|
69 |
/**
|
70 |
+
* Callback of add shortcode for confirm page.
|
71 |
*
|
72 |
+
* @return string
|
|
|
|
|
73 |
*/
|
74 |
protected function confirm_page() {
|
75 |
return $this->Form->button_submit(
|
83 |
}
|
84 |
|
85 |
/**
|
86 |
+
* Display tag generator dialog.
|
87 |
+
* Overwrite required for each child class.
|
88 |
*
|
89 |
+
* @param array $options Options.
|
|
|
90 |
*/
|
91 |
public function mwform_tag_generator_dialog( array $options = array() ) {
|
92 |
?>
|
classes/form-fields/class.button.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
@@ -32,9 +32,9 @@ class MW_WP_Form_Field_Button extends MW_WP_Form_Abstract_Form_Field {
|
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
-
* Set default attributes
|
36 |
*
|
37 |
-
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
@@ -45,35 +45,34 @@ class MW_WP_Form_Field_Button extends MW_WP_Form_Abstract_Form_Field {
|
|
45 |
}
|
46 |
|
47 |
/**
|
48 |
-
* Callback of add shortcode for input page
|
49 |
*
|
50 |
-
* @
|
51 |
-
* @param string $element_content
|
52 |
-
* @return string HTML
|
53 |
*/
|
54 |
protected function input_page() {
|
55 |
-
return $this->Form->button(
|
56 |
-
|
57 |
-
|
|
|
|
|
|
|
|
|
58 |
}
|
59 |
|
60 |
/**
|
61 |
-
* Callback of add shortcode for confirm page
|
62 |
*
|
63 |
-
* @
|
64 |
-
* @param string $element_content
|
65 |
-
* @return string HTML
|
66 |
*/
|
67 |
protected function confirm_page() {
|
68 |
return $this->input_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 |
?>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Field_Button
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Field_Button extends MW_WP_Form_Abstract_Form_Field {
|
12 |
|
13 |
/**
|
14 |
* Types of form type.
|
15 |
+
* input|select|button|input_button|error|other.
|
16 |
+
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* Set default attributes.
|
36 |
*
|
37 |
+
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
45 |
}
|
46 |
|
47 |
/**
|
48 |
+
* Callback of add shortcode for input page.
|
49 |
*
|
50 |
+
* @return string
|
|
|
|
|
51 |
*/
|
52 |
protected function input_page() {
|
53 |
+
return $this->Form->button(
|
54 |
+
$this->atts['name'],
|
55 |
+
$this->atts['value'],
|
56 |
+
array(
|
57 |
+
'class' => $this->atts['class'],
|
58 |
+
)
|
59 |
+
);
|
60 |
}
|
61 |
|
62 |
/**
|
63 |
+
* Callback of add shortcode for confirm page.
|
64 |
*
|
65 |
+
* @return string
|
|
|
|
|
66 |
*/
|
67 |
protected function confirm_page() {
|
68 |
return $this->input_page();
|
69 |
}
|
70 |
|
71 |
/**
|
72 |
+
* Display tag generator dialog.
|
73 |
+
* Overwrite required for each child class.
|
74 |
*
|
75 |
+
* @param array $options Options.
|
|
|
76 |
*/
|
77 |
public function mwform_tag_generator_dialog( array $options = array() ) {
|
78 |
?>
|
classes/form-fields/class.checkbox.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
@@ -32,9 +32,9 @@ class MW_WP_Form_Field_Checkbox extends MW_WP_Form_Abstract_Form_Field {
|
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
-
* Set default attributes
|
36 |
*
|
37 |
-
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
@@ -51,11 +51,9 @@ class MW_WP_Form_Field_Checkbox extends MW_WP_Form_Abstract_Form_Field {
|
|
51 |
}
|
52 |
|
53 |
/**
|
54 |
-
* Callback of add shortcode for input page
|
55 |
*
|
56 |
-
* @
|
57 |
-
* @param string $element_content
|
58 |
-
* @return string HTML
|
59 |
*/
|
60 |
protected function input_page() {
|
61 |
$value = $this->Data->get_raw( $this->atts['name'] );
|
@@ -65,12 +63,17 @@ class MW_WP_Form_Field_Checkbox extends MW_WP_Form_Abstract_Form_Field {
|
|
65 |
$children = $this->get_children( $this->atts['children'] );
|
66 |
$separator = ( $this->atts['separator'] ) ? $this->atts['separator'] : $this->defaults['separator'];
|
67 |
|
68 |
-
$_ret = $this->Form->checkbox(
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
|
|
|
|
|
|
|
|
|
|
74 |
if ( 'false' === $this->atts['post_raw'] ) {
|
75 |
$_ret .= $this->Form->children( $this->atts['name'], $children );
|
76 |
}
|
@@ -81,11 +84,9 @@ class MW_WP_Form_Field_Checkbox extends MW_WP_Form_Abstract_Form_Field {
|
|
81 |
}
|
82 |
|
83 |
/**
|
84 |
-
* Callback of add shortcode for confirm page
|
85 |
*
|
86 |
-
* @
|
87 |
-
* @param string $element_content
|
88 |
-
* @return string HTML
|
89 |
*/
|
90 |
protected function confirm_page() {
|
91 |
$children = $this->get_children( $this->atts['children'] );
|
@@ -104,11 +105,10 @@ class MW_WP_Form_Field_Checkbox extends MW_WP_Form_Abstract_Form_Field {
|
|
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 |
?>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Field_Checkbox
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Field_Checkbox extends MW_WP_Form_Abstract_Form_Field {
|
12 |
|
13 |
/**
|
14 |
* Types of form type.
|
15 |
+
* input|select|button|input_button|error|other.
|
16 |
+
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* Set default attributes.
|
36 |
*
|
37 |
+
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
51 |
}
|
52 |
|
53 |
/**
|
54 |
+
* Callback of add shortcode for input page.
|
55 |
*
|
56 |
+
* @return string
|
|
|
|
|
57 |
*/
|
58 |
protected function input_page() {
|
59 |
$value = $this->Data->get_raw( $this->atts['name'] );
|
63 |
$children = $this->get_children( $this->atts['children'] );
|
64 |
$separator = ( $this->atts['separator'] ) ? $this->atts['separator'] : $this->defaults['separator'];
|
65 |
|
66 |
+
$_ret = $this->Form->checkbox(
|
67 |
+
$this->atts['name'],
|
68 |
+
$children,
|
69 |
+
array(
|
70 |
+
'id' => $this->atts['id'],
|
71 |
+
'class' => $this->atts['class'],
|
72 |
+
'value' => $value,
|
73 |
+
'vertically' => $this->atts['vertically'],
|
74 |
+
),
|
75 |
+
$separator
|
76 |
+
);
|
77 |
if ( 'false' === $this->atts['post_raw'] ) {
|
78 |
$_ret .= $this->Form->children( $this->atts['name'], $children );
|
79 |
}
|
84 |
}
|
85 |
|
86 |
/**
|
87 |
+
* Callback of add shortcode for confirm page.
|
88 |
*
|
89 |
+
* @return string
|
|
|
|
|
90 |
*/
|
91 |
protected function confirm_page() {
|
92 |
$children = $this->get_children( $this->atts['children'] );
|
105 |
}
|
106 |
|
107 |
/**
|
108 |
+
* Display tag generator dialog.
|
109 |
+
* Overwrite required for each child class.
|
110 |
*
|
111 |
+
* @param array $options Options.
|
|
|
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 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
@@ -32,9 +32,9 @@ class MW_WP_Form_Field_Confirm_Button extends MW_WP_Form_Abstract_Form_Field {
|
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
-
* Set default attributes
|
36 |
*
|
37 |
-
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
@@ -44,34 +44,31 @@ class MW_WP_Form_Field_Confirm_Button extends MW_WP_Form_Abstract_Form_Field {
|
|
44 |
}
|
45 |
|
46 |
/**
|
47 |
-
* Callback of add shortcode for input page
|
48 |
*
|
49 |
-
* @
|
50 |
-
* @param string $element_content
|
51 |
-
* @return string HTML
|
52 |
*/
|
53 |
protected function input_page() {
|
54 |
-
return $this->Form->submit(
|
55 |
-
|
56 |
-
|
|
|
|
|
|
|
|
|
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 |
?>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Field_Confirm_Button
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Field_Confirm_Button extends MW_WP_Form_Abstract_Form_Field {
|
12 |
|
13 |
/**
|
14 |
* Types of form type.
|
15 |
+
* input|select|button|input_button|error|other.
|
16 |
+
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* Set default attributes.
|
36 |
*
|
37 |
+
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
44 |
}
|
45 |
|
46 |
/**
|
47 |
+
* Callback of add shortcode for input page.
|
48 |
*
|
49 |
+
* @return string
|
|
|
|
|
50 |
*/
|
51 |
protected function input_page() {
|
52 |
+
return $this->Form->submit(
|
53 |
+
MWF_Config::CONFIRM_BUTTON,
|
54 |
+
$this->atts['value'],
|
55 |
+
array(
|
56 |
+
'class' => $this->atts['class'],
|
57 |
+
)
|
58 |
+
);
|
59 |
}
|
60 |
|
61 |
/**
|
62 |
+
* Callback of add shortcode for confirm page.
|
|
|
|
|
|
|
|
|
63 |
*/
|
64 |
protected function confirm_page() {
|
65 |
}
|
66 |
|
67 |
/**
|
68 |
+
* Display tag generator dialog.
|
69 |
+
* Overwrite required for each child class.
|
70 |
*
|
71 |
+
* @param array $options Options.
|
|
|
72 |
*/
|
73 |
public function mwform_tag_generator_dialog( array $options = array() ) {
|
74 |
?>
|
classes/form-fields/class.custom-mail-tag.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
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 default attributes
|
36 |
*
|
37 |
-
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
@@ -46,19 +46,20 @@ class MW_WP_Form_Field_Custom_Mail_Tag extends MW_WP_Form_Abstract_Form_Field {
|
|
46 |
}
|
47 |
|
48 |
/**
|
49 |
-
* Callback of add shortcode for input page
|
50 |
*
|
51 |
-
* @
|
52 |
-
* @param string $element_content
|
53 |
-
* @return string HTML
|
54 |
*/
|
55 |
protected function input_page() {
|
56 |
$_ret = '';
|
57 |
if ( 'true' === $this->atts['echo'] ) {
|
58 |
-
$_ret .= $this->custom_mail_tag_field(
|
59 |
-
|
60 |
-
|
61 |
-
|
|
|
|
|
|
|
62 |
}
|
63 |
$_ret .= $this->Form->hidden( MWF_Config::CUSTOM_MAIL_TAG_KEYS . '[]', $this->atts['name'] );
|
64 |
if ( 'false' !== $this->atts['show_error'] ) {
|
@@ -68,30 +69,30 @@ class MW_WP_Form_Field_Custom_Mail_Tag extends MW_WP_Form_Abstract_Form_Field {
|
|
68 |
}
|
69 |
|
70 |
/**
|
71 |
-
* Callback of add shortcode for confirm page
|
72 |
*
|
73 |
-
* @
|
74 |
-
* @param string $element_content
|
75 |
-
* @return string HTML
|
76 |
*/
|
77 |
protected function confirm_page() {
|
78 |
$_ret = '';
|
79 |
if ( 'true' === $this->atts['echo'] ) {
|
80 |
-
$_ret .= $this->custom_mail_tag_field(
|
81 |
-
|
82 |
-
|
83 |
-
|
|
|
|
|
|
|
84 |
}
|
85 |
$_ret .= $this->Form->hidden( MWF_Config::CUSTOM_MAIL_TAG_KEYS . '[]', $this->atts['name'] );
|
86 |
return $_ret;
|
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 |
?>
|
@@ -119,21 +120,21 @@ class MW_WP_Form_Field_Custom_Mail_Tag extends MW_WP_Form_Abstract_Form_Field {
|
|
119 |
}
|
120 |
|
121 |
/**
|
122 |
-
*
|
123 |
*
|
124 |
-
* @param string $name name
|
125 |
-
* @param array
|
126 |
-
* @return string
|
127 |
*/
|
128 |
public function custom_mail_tag_field( $name, $options = array() ) {
|
129 |
$defaults = array(
|
130 |
'id' => null,
|
131 |
'class' => null,
|
132 |
);
|
133 |
-
$options
|
134 |
-
$class
|
135 |
unset( $options['class'] );
|
136 |
-
$Form
|
137 |
$attributes = $Form->generate_attributes( $options );
|
138 |
|
139 |
return sprintf(
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Field_Custom_Mail_Tag
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Field_Custom_Mail_Tag extends MW_WP_Form_Abstract_Form_Field {
|
12 |
|
13 |
/**
|
14 |
* Types of form type.
|
15 |
+
* input|select|button|input_button|error|other.
|
16 |
+
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* Set default attributes.
|
36 |
*
|
37 |
+
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
46 |
}
|
47 |
|
48 |
/**
|
49 |
+
* Callback of add shortcode for input page.
|
50 |
*
|
51 |
+
* @return string
|
|
|
|
|
52 |
*/
|
53 |
protected function input_page() {
|
54 |
$_ret = '';
|
55 |
if ( 'true' === $this->atts['echo'] ) {
|
56 |
+
$_ret .= $this->custom_mail_tag_field(
|
57 |
+
$this->atts['name'],
|
58 |
+
array(
|
59 |
+
'id' => $this->atts['id'],
|
60 |
+
'class' => $this->atts['class'],
|
61 |
+
)
|
62 |
+
);
|
63 |
}
|
64 |
$_ret .= $this->Form->hidden( MWF_Config::CUSTOM_MAIL_TAG_KEYS . '[]', $this->atts['name'] );
|
65 |
if ( 'false' !== $this->atts['show_error'] ) {
|
69 |
}
|
70 |
|
71 |
/**
|
72 |
+
* Callback of add shortcode for confirm page.
|
73 |
*
|
74 |
+
* @return string
|
|
|
|
|
75 |
*/
|
76 |
protected function confirm_page() {
|
77 |
$_ret = '';
|
78 |
if ( 'true' === $this->atts['echo'] ) {
|
79 |
+
$_ret .= $this->custom_mail_tag_field(
|
80 |
+
$this->atts['name'],
|
81 |
+
array(
|
82 |
+
'id' => $this->atts['id'],
|
83 |
+
'class' => $this->atts['class'],
|
84 |
+
)
|
85 |
+
);
|
86 |
}
|
87 |
$_ret .= $this->Form->hidden( MWF_Config::CUSTOM_MAIL_TAG_KEYS . '[]', $this->atts['name'] );
|
88 |
return $_ret;
|
89 |
}
|
90 |
|
91 |
/**
|
92 |
+
* Display tag generator dialog.
|
93 |
+
* Overwrite required for each child class.
|
94 |
*
|
95 |
+
* @param array $options Options.
|
|
|
96 |
*/
|
97 |
public function mwform_tag_generator_dialog( array $options = array() ) {
|
98 |
?>
|
120 |
}
|
121 |
|
122 |
/**
|
123 |
+
* 任意のデータを表示する要素を生成.
|
124 |
*
|
125 |
+
* @param string $name Field name.
|
126 |
+
* @param array $options Options.
|
127 |
+
* @return string
|
128 |
*/
|
129 |
public function custom_mail_tag_field( $name, $options = array() ) {
|
130 |
$defaults = array(
|
131 |
'id' => null,
|
132 |
'class' => null,
|
133 |
);
|
134 |
+
$options = array_merge( $defaults, $options );
|
135 |
+
$class = $options['class'];
|
136 |
unset( $options['class'] );
|
137 |
+
$Form = new MW_WP_Form_Form();
|
138 |
$attributes = $Form->generate_attributes( $options );
|
139 |
|
140 |
return sprintf(
|
classes/form-fields/class.datepicker.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
@@ -32,9 +32,9 @@ class MW_WP_Form_Field_Datepicker extends MW_WP_Form_Abstract_Form_Field {
|
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
-
* Set default attributes
|
36 |
*
|
37 |
-
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
@@ -50,11 +50,9 @@ class MW_WP_Form_Field_Datepicker extends MW_WP_Form_Abstract_Form_Field {
|
|
50 |
}
|
51 |
|
52 |
/**
|
53 |
-
* Callback of add shortcode for input page
|
54 |
*
|
55 |
-
* @
|
56 |
-
* @param string $element_content
|
57 |
-
* @return string HTML
|
58 |
*/
|
59 |
protected function input_page() {
|
60 |
global $wp_scripts;
|
@@ -62,9 +60,9 @@ class MW_WP_Form_Field_Datepicker extends MW_WP_Form_Abstract_Form_Field {
|
|
62 |
wp_enqueue_style( 'jquery.ui', '//ajax.googleapis.com/ajax/libs/jqueryui/' . $ui->ver . '/themes/smoothness/jquery-ui.min.css', array(), $ui->ver );
|
63 |
wp_enqueue_script( 'jquery-ui-datepicker' );
|
64 |
|
65 |
-
$Json_Parser
|
66 |
$this->atts['js'] = $Json_Parser->create_json();
|
67 |
-
$js
|
68 |
|
69 |
// jsの指定がないときはデフォルトで年付き変更機能追加
|
70 |
if ( empty( $js ) ) {
|
@@ -77,15 +75,18 @@ class MW_WP_Form_Field_Datepicker extends MW_WP_Form_Abstract_Form_Field {
|
|
77 |
|
78 |
$translate_datepicker = apply_filters( 'mwform_translate_datepicker_' . $this->form_key, true );
|
79 |
if ( $translate_datepicker && 'ja' === get_locale() ) {
|
80 |
-
$js = array_merge(
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
|
|
|
|
|
|
89 |
}
|
90 |
|
91 |
$this->atts['js'] = json_encode( $js );
|
@@ -96,14 +97,17 @@ class MW_WP_Form_Field_Datepicker extends MW_WP_Form_Abstract_Form_Field {
|
|
96 |
}
|
97 |
|
98 |
$_ret = '';
|
99 |
-
$_ret .= $this->Form->datepicker(
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
|
|
|
|
|
|
107 |
if ( 'false' !== $this->atts['show_error'] ) {
|
108 |
$_ret .= $this->get_error( $this->atts['name'] );
|
109 |
}
|
@@ -111,11 +115,9 @@ class MW_WP_Form_Field_Datepicker extends MW_WP_Form_Abstract_Form_Field {
|
|
111 |
}
|
112 |
|
113 |
/**
|
114 |
-
* Callback of add shortcode for confirm page
|
115 |
*
|
116 |
-
* @
|
117 |
-
* @param string $element_content
|
118 |
-
* @return string HTML
|
119 |
*/
|
120 |
protected function confirm_page() {
|
121 |
$value = $this->Data->get_raw( $this->atts['name'] );
|
@@ -125,11 +127,10 @@ class MW_WP_Form_Field_Datepicker extends MW_WP_Form_Abstract_Form_Field {
|
|
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 |
?>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Field_Datepicker
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Field_Datepicker extends MW_WP_Form_Abstract_Form_Field {
|
12 |
|
13 |
/**
|
14 |
* Types of form type.
|
15 |
+
* input|select|button|input_button|error|other.
|
16 |
+
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* Set default attributes.
|
36 |
*
|
37 |
+
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
50 |
}
|
51 |
|
52 |
/**
|
53 |
+
* Callback of add shortcode for input page.
|
54 |
*
|
55 |
+
* @return string
|
|
|
|
|
56 |
*/
|
57 |
protected function input_page() {
|
58 |
global $wp_scripts;
|
60 |
wp_enqueue_style( 'jquery.ui', '//ajax.googleapis.com/ajax/libs/jqueryui/' . $ui->ver . '/themes/smoothness/jquery-ui.min.css', array(), $ui->ver );
|
61 |
wp_enqueue_script( 'jquery-ui-datepicker' );
|
62 |
|
63 |
+
$Json_Parser = new MW_WP_Form_Json_Parser( $this->atts['js'] );
|
64 |
$this->atts['js'] = $Json_Parser->create_json();
|
65 |
+
$js = json_decode( $this->atts['js'], true );
|
66 |
|
67 |
// jsの指定がないときはデフォルトで年付き変更機能追加
|
68 |
if ( empty( $js ) ) {
|
75 |
|
76 |
$translate_datepicker = apply_filters( 'mwform_translate_datepicker_' . $this->form_key, true );
|
77 |
if ( $translate_datepicker && 'ja' === get_locale() ) {
|
78 |
+
$js = array_merge(
|
79 |
+
array(
|
80 |
+
'yearSuffix' => '年',
|
81 |
+
'dateFormat' => 'yy年mm月dd日',
|
82 |
+
'dayNames' => array( '日曜日', '月曜日', '火曜日', '水曜日', '木曜日', '金曜日', '土曜日' ),
|
83 |
+
'dayNamesMin' => array( '日', '月', '火', '水', '木', '金', '土' ),
|
84 |
+
'dayNamesShort' => array( '日曜', '月曜', '火曜', '水曜', '木曜', '金曜', '土曜' ),
|
85 |
+
'monthNames' => array( '1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月' ),
|
86 |
+
'monthNamesShort' => array( '1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月' ),
|
87 |
+
),
|
88 |
+
$js
|
89 |
+
);
|
90 |
}
|
91 |
|
92 |
$this->atts['js'] = json_encode( $js );
|
97 |
}
|
98 |
|
99 |
$_ret = '';
|
100 |
+
$_ret .= $this->Form->datepicker(
|
101 |
+
$this->atts['name'],
|
102 |
+
array(
|
103 |
+
'id' => $this->atts['id'],
|
104 |
+
'class' => $this->atts['class'],
|
105 |
+
'size' => $this->atts['size'],
|
106 |
+
'js' => $this->atts['js'],
|
107 |
+
'value' => $value,
|
108 |
+
'placeholder' => $this->atts['placeholder'],
|
109 |
+
)
|
110 |
+
);
|
111 |
if ( 'false' !== $this->atts['show_error'] ) {
|
112 |
$_ret .= $this->get_error( $this->atts['name'] );
|
113 |
}
|
115 |
}
|
116 |
|
117 |
/**
|
118 |
+
* Callback of add shortcode for confirm page.
|
119 |
*
|
120 |
+
* @return string
|
|
|
|
|
121 |
*/
|
122 |
protected function confirm_page() {
|
123 |
$value = $this->Data->get_raw( $this->atts['name'] );
|
127 |
}
|
128 |
|
129 |
/**
|
130 |
+
* Display tag generator dialog.
|
131 |
+
* Overwrite required for each child class.
|
132 |
*
|
133 |
+
* @param array $options Options.
|
|
|
134 |
*/
|
135 |
public function mwform_tag_generator_dialog( array $options = array() ) {
|
136 |
?>
|
classes/form-fields/class.email.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
@@ -32,30 +32,28 @@ class MW_WP_Form_Field_Email extends MW_WP_Form_Abstract_Form_Field {
|
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
-
* Set default attributes
|
36 |
*
|
37 |
-
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
41 |
-
'name'
|
42 |
-
'id'
|
43 |
-
'class'
|
44 |
-
'size'
|
45 |
-
'maxlength'
|
46 |
-
'value'
|
47 |
-
'placeholder'
|
48 |
-
'show_error'
|
49 |
'conv_half_alphanumeric' => 'true',
|
50 |
);
|
51 |
}
|
52 |
|
53 |
/**
|
54 |
-
* Callback of add shortcode for input page
|
55 |
*
|
56 |
-
* @
|
57 |
-
* @param string $element_content
|
58 |
-
* @return string HTML
|
59 |
*/
|
60 |
protected function input_page() {
|
61 |
$conv_half_alphanumeric = 'true';
|
@@ -67,15 +65,18 @@ class MW_WP_Form_Field_Email extends MW_WP_Form_Abstract_Form_Field {
|
|
67 |
$value = $this->atts['value'];
|
68 |
}
|
69 |
|
70 |
-
$_ret = $this->Form->email(
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
|
|
|
|
|
|
79 |
if ( 'false' !== $this->atts['show_error'] ) {
|
80 |
$_ret .= $this->get_error( $this->atts['name'] );
|
81 |
}
|
@@ -83,11 +84,9 @@ class MW_WP_Form_Field_Email extends MW_WP_Form_Abstract_Form_Field {
|
|
83 |
}
|
84 |
|
85 |
/**
|
86 |
-
* Callback of add shortcode for confirm page
|
87 |
*
|
88 |
-
* @
|
89 |
-
* @param string $element_content
|
90 |
-
* @return string HTML
|
91 |
*/
|
92 |
protected function confirm_page() {
|
93 |
$value = $this->Data->get_raw( $this->atts['name'] );
|
@@ -97,11 +96,10 @@ class MW_WP_Form_Field_Email extends MW_WP_Form_Abstract_Form_Field {
|
|
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 |
?>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Field_Email
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Field_Email extends MW_WP_Form_Abstract_Form_Field {
|
12 |
|
13 |
/**
|
14 |
* Types of form type.
|
15 |
+
* input|select|button|input_button|error|other.
|
16 |
+
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* Set default attributes.
|
36 |
*
|
37 |
+
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
41 |
+
'name' => '',
|
42 |
+
'id' => null,
|
43 |
+
'class' => null,
|
44 |
+
'size' => 60,
|
45 |
+
'maxlength' => null,
|
46 |
+
'value' => '',
|
47 |
+
'placeholder' => null,
|
48 |
+
'show_error' => 'true',
|
49 |
'conv_half_alphanumeric' => 'true',
|
50 |
);
|
51 |
}
|
52 |
|
53 |
/**
|
54 |
+
* Callback of add shortcode for input page.
|
55 |
*
|
56 |
+
* @return string
|
|
|
|
|
57 |
*/
|
58 |
protected function input_page() {
|
59 |
$conv_half_alphanumeric = 'true';
|
65 |
$value = $this->atts['value'];
|
66 |
}
|
67 |
|
68 |
+
$_ret = $this->Form->email(
|
69 |
+
$this->atts['name'],
|
70 |
+
array(
|
71 |
+
'id' => $this->atts['id'],
|
72 |
+
'class' => $this->atts['class'],
|
73 |
+
'size' => $this->atts['size'],
|
74 |
+
'maxlength' => $this->atts['maxlength'],
|
75 |
+
'value' => $value,
|
76 |
+
'placeholder' => $this->atts['placeholder'],
|
77 |
+
'conv-half-alphanumeric' => $conv_half_alphanumeric,
|
78 |
+
)
|
79 |
+
);
|
80 |
if ( 'false' !== $this->atts['show_error'] ) {
|
81 |
$_ret .= $this->get_error( $this->atts['name'] );
|
82 |
}
|
84 |
}
|
85 |
|
86 |
/**
|
87 |
+
* Callback of add shortcode for confirm page.
|
88 |
*
|
89 |
+
* @return string
|
|
|
|
|
90 |
*/
|
91 |
protected function confirm_page() {
|
92 |
$value = $this->Data->get_raw( $this->atts['name'] );
|
96 |
}
|
97 |
|
98 |
/**
|
99 |
+
* Display tag generator dialog.
|
100 |
+
* Overwrite required for each child class.
|
101 |
*
|
102 |
+
* @param array $options Options.
|
|
|
103 |
*/
|
104 |
public function mwform_tag_generator_dialog( array $options = array() ) {
|
105 |
?>
|
classes/form-fields/class.error.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
@@ -32,9 +32,9 @@ class MW_WP_Form_Field_Error extends MW_WP_Form_Abstract_Form_Field {
|
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
-
* Set default attributes
|
36 |
*
|
37 |
-
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
@@ -43,11 +43,9 @@ class MW_WP_Form_Field_Error extends MW_WP_Form_Abstract_Form_Field {
|
|
43 |
}
|
44 |
|
45 |
/**
|
46 |
-
* Callback of add shortcode for input page
|
47 |
*
|
48 |
-
* @
|
49 |
-
* @param string $element_content
|
50 |
-
* @return string HTML
|
51 |
*/
|
52 |
protected function input_page() {
|
53 |
$keys = explode( ',', $this->atts['keys'] );
|
@@ -59,21 +57,16 @@ class MW_WP_Form_Field_Error extends MW_WP_Form_Abstract_Form_Field {
|
|
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 |
?>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Field_Error
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Field_Error extends MW_WP_Form_Abstract_Form_Field {
|
12 |
|
13 |
/**
|
14 |
* Types of form type.
|
15 |
+
* input|select|button|input_button|error|other.
|
16 |
+
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* Set default attributes.
|
36 |
*
|
37 |
+
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
43 |
}
|
44 |
|
45 |
/**
|
46 |
+
* Callback of add shortcode for input page.
|
47 |
*
|
48 |
+
* @return string
|
|
|
|
|
49 |
*/
|
50 |
protected function input_page() {
|
51 |
$keys = explode( ',', $this->atts['keys'] );
|
57 |
}
|
58 |
|
59 |
/**
|
60 |
+
* Callback of add shortcode for confirm page.
|
|
|
|
|
|
|
|
|
61 |
*/
|
62 |
protected function confirm_page() {
|
63 |
}
|
64 |
|
65 |
/**
|
66 |
+
* Display tag generator dialog.
|
67 |
+
* Overwrite required for each child class.
|
68 |
*
|
69 |
+
* @param array $options Options.
|
|
|
70 |
*/
|
71 |
public function mwform_tag_generator_dialog( array $options = array() ) {
|
72 |
?>
|
classes/form-fields/class.file.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
@@ -32,35 +32,40 @@ class MW_WP_Form_Field_File extends MW_WP_Form_Abstract_Form_Field {
|
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
-
* Set default attributes
|
36 |
*
|
37 |
-
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
41 |
-
'name'
|
42 |
-
'id'
|
43 |
-
'class'
|
44 |
'show_error' => 'true',
|
45 |
);
|
46 |
}
|
47 |
|
48 |
/**
|
49 |
-
* Callback of add shortcode for input page
|
50 |
*
|
51 |
-
* @
|
52 |
-
* @param string $element_content
|
53 |
-
* @return string HTML
|
54 |
*/
|
55 |
protected function input_page() {
|
56 |
-
$_ret
|
57 |
-
|
58 |
-
|
59 |
-
|
|
|
|
|
|
|
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 (
|
|
|
|
|
|
|
|
|
64 |
$filepath = MWF_Functions::fileurl_to_path( $value );
|
65 |
if ( file_exists( $filepath ) ) {
|
66 |
$_ret .= sprintf(
|
@@ -82,11 +87,9 @@ class MW_WP_Form_Field_File extends MW_WP_Form_Abstract_Form_Field {
|
|
82 |
}
|
83 |
|
84 |
/**
|
85 |
-
* Callback of add shortcode for confirm page
|
86 |
*
|
87 |
-
* @
|
88 |
-
* @param string $element_content
|
89 |
-
* @return string HTML
|
90 |
*/
|
91 |
protected function confirm_page() {
|
92 |
$value = $this->Data->get_raw( $this->atts['name'] );
|
@@ -103,11 +106,10 @@ class MW_WP_Form_Field_File extends MW_WP_Form_Abstract_Form_Field {
|
|
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 |
?>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Field_File
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Field_File extends MW_WP_Form_Abstract_Form_Field {
|
12 |
|
13 |
/**
|
14 |
* Types of form type.
|
15 |
+
* input|select|button|input_button|error|other.
|
16 |
+
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* Set default attributes.
|
36 |
*
|
37 |
+
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
41 |
+
'name' => '',
|
42 |
+
'id' => null,
|
43 |
+
'class' => null,
|
44 |
'show_error' => 'true',
|
45 |
);
|
46 |
}
|
47 |
|
48 |
/**
|
49 |
+
* Callback of add shortcode for input page.
|
50 |
*
|
51 |
+
* @return string
|
|
|
|
|
52 |
*/
|
53 |
protected function input_page() {
|
54 |
+
$_ret = $this->Form->file(
|
55 |
+
$this->atts['name'],
|
56 |
+
array(
|
57 |
+
'id' => $this->atts['id'],
|
58 |
+
'class' => $this->atts['class'],
|
59 |
+
)
|
60 |
+
);
|
61 |
$value = $this->Data->get_raw( $this->atts['name'] );
|
62 |
|
63 |
$upload_file_keys = $this->Data->get_post_value_by_key( MWF_Config::UPLOAD_FILE_KEYS );
|
64 |
+
if (
|
65 |
+
! empty( $value )
|
66 |
+
&& is_array( $upload_file_keys )
|
67 |
+
&& in_array( $this->atts['name'], $upload_file_keys, true )
|
68 |
+
) {
|
69 |
$filepath = MWF_Functions::fileurl_to_path( $value );
|
70 |
if ( file_exists( $filepath ) ) {
|
71 |
$_ret .= sprintf(
|
87 |
}
|
88 |
|
89 |
/**
|
90 |
+
* Callback of add shortcode for confirm page.
|
91 |
*
|
92 |
+
* @return string
|
|
|
|
|
93 |
*/
|
94 |
protected function confirm_page() {
|
95 |
$value = $this->Data->get_raw( $this->atts['name'] );
|
106 |
}
|
107 |
|
108 |
/**
|
109 |
+
* Display tag generator dialog.
|
110 |
+
* Overwrite required for each child class.
|
111 |
*
|
112 |
+
* @param array $options Options.
|
|
|
113 |
*/
|
114 |
public function mwform_tag_generator_dialog( array $options = array() ) {
|
115 |
?>
|
classes/form-fields/class.hidden.php
CHANGED
@@ -1,21 +1,20 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
19 |
*/
|
20 |
protected function set_names() {
|
21 |
return array(
|
@@ -25,9 +24,9 @@ class MW_WP_Form_Field_Hidden extends MW_WP_Form_Abstract_Form_Field {
|
|
25 |
}
|
26 |
|
27 |
/**
|
28 |
-
* Set default attributes
|
29 |
*
|
30 |
-
* @return array
|
31 |
*/
|
32 |
protected function set_defaults() {
|
33 |
return array(
|
@@ -38,11 +37,9 @@ class MW_WP_Form_Field_Hidden extends MW_WP_Form_Abstract_Form_Field {
|
|
38 |
}
|
39 |
|
40 |
/**
|
41 |
-
* Callback of add shortcode for input page
|
42 |
*
|
43 |
-
* @
|
44 |
-
* @param string $element_content
|
45 |
-
* @return string HTML
|
46 |
*/
|
47 |
protected function input_page() {
|
48 |
$value = $this->Data->get_raw( $this->atts['name'] );
|
@@ -58,15 +55,13 @@ class MW_WP_Form_Field_Hidden extends MW_WP_Form_Abstract_Form_Field {
|
|
58 |
}
|
59 |
|
60 |
/**
|
61 |
-
* Callback of add shortcode for confirm page
|
62 |
*
|
63 |
-
* @
|
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 |
}
|
@@ -74,11 +69,10 @@ class MW_WP_Form_Field_Hidden extends MW_WP_Form_Abstract_Form_Field {
|
|
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 |
?>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Field_Hidden
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Field_Hidden extends MW_WP_Form_Abstract_Form_Field {
|
12 |
|
13 |
/**
|
14 |
+
* Set shortcode_name and display_name.
|
15 |
+
* Overwrite required for each child class.
|
16 |
*
|
17 |
+
* @return array
|
18 |
*/
|
19 |
protected function set_names() {
|
20 |
return array(
|
24 |
}
|
25 |
|
26 |
/**
|
27 |
+
* Set default attributes.
|
28 |
*
|
29 |
+
* @return array
|
30 |
*/
|
31 |
protected function set_defaults() {
|
32 |
return array(
|
37 |
}
|
38 |
|
39 |
/**
|
40 |
+
* Callback of add shortcode for input page.
|
41 |
*
|
42 |
+
* @return string
|
|
|
|
|
43 |
*/
|
44 |
protected function input_page() {
|
45 |
$value = $this->Data->get_raw( $this->atts['name'] );
|
55 |
}
|
56 |
|
57 |
/**
|
58 |
+
* Callback of add shortcode for confirm page.
|
59 |
*
|
60 |
+
* @return string
|
|
|
|
|
61 |
*/
|
62 |
protected function confirm_page() {
|
63 |
$value = $this->Data->get_raw( $this->atts['name'] );
|
64 |
+
$echo = '';
|
65 |
if ( 'true' === $this->atts['echo'] ) {
|
66 |
$echo = $value;
|
67 |
}
|
69 |
}
|
70 |
|
71 |
/**
|
72 |
+
* Display tag generator dialog.
|
73 |
+
* Overwrite required for each child class.
|
74 |
*
|
75 |
+
* @param array $options Options.
|
|
|
76 |
*/
|
77 |
public function mwform_tag_generator_dialog( array $options = array() ) {
|
78 |
?>
|
classes/form-fields/class.image.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
@@ -32,35 +32,40 @@ class MW_WP_Form_Field_Image extends MW_WP_Form_Abstract_Form_Field {
|
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
-
* Set default attributes
|
36 |
*
|
37 |
-
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
41 |
-
'name'
|
42 |
-
'id'
|
43 |
-
'class'
|
44 |
'show_error' => 'true',
|
45 |
);
|
46 |
}
|
47 |
|
48 |
/**
|
49 |
-
* Callback of add shortcode for input page
|
50 |
*
|
51 |
-
* @
|
52 |
-
* @param string $element_content
|
53 |
-
* @return string HTML
|
54 |
*/
|
55 |
protected function input_page() {
|
56 |
-
$_ret
|
57 |
-
|
58 |
-
|
59 |
-
|
|
|
|
|
|
|
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 (
|
|
|
|
|
|
|
|
|
64 |
$filepath = MWF_Functions::fileurl_to_path( $value );
|
65 |
if ( file_exists( $filepath ) ) {
|
66 |
$_ret .= sprintf(
|
@@ -81,11 +86,9 @@ class MW_WP_Form_Field_Image extends MW_WP_Form_Abstract_Form_Field {
|
|
81 |
}
|
82 |
|
83 |
/**
|
84 |
-
* Callback of add shortcode for confirm page
|
85 |
*
|
86 |
-
* @
|
87 |
-
* @param string $element_content
|
88 |
-
* @return string HTML
|
89 |
*/
|
90 |
protected function confirm_page() {
|
91 |
$value = $this->Data->get_raw( $this->atts['name'] );
|
@@ -106,11 +109,10 @@ class MW_WP_Form_Field_Image extends MW_WP_Form_Abstract_Form_Field {
|
|
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 |
?>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Field_Image
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Field_Image extends MW_WP_Form_Abstract_Form_Field {
|
12 |
|
13 |
/**
|
14 |
* Types of form type.
|
15 |
+
* input|select|button|input_button|error|other.
|
16 |
+
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* Set default attributes.
|
36 |
*
|
37 |
+
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
41 |
+
'name' => '',
|
42 |
+
'id' => null,
|
43 |
+
'class' => null,
|
44 |
'show_error' => 'true',
|
45 |
);
|
46 |
}
|
47 |
|
48 |
/**
|
49 |
+
* Callback of add shortcode for input page.
|
50 |
*
|
51 |
+
* @return string
|
|
|
|
|
52 |
*/
|
53 |
protected function input_page() {
|
54 |
+
$_ret = $this->Form->file(
|
55 |
+
$this->atts['name'],
|
56 |
+
array(
|
57 |
+
'id' => $this->atts['id'],
|
58 |
+
'class' => $this->atts['class'],
|
59 |
+
)
|
60 |
+
);
|
61 |
$value = $this->Data->get_raw( $this->atts['name'] );
|
62 |
|
63 |
$upload_file_keys = $this->Data->get_post_value_by_key( MWF_Config::UPLOAD_FILE_KEYS );
|
64 |
+
if (
|
65 |
+
! empty( $value )
|
66 |
+
&& is_array( $upload_file_keys )
|
67 |
+
&& in_array( $this->atts['name'], $upload_file_keys, true )
|
68 |
+
) {
|
69 |
$filepath = MWF_Functions::fileurl_to_path( $value );
|
70 |
if ( file_exists( $filepath ) ) {
|
71 |
$_ret .= sprintf(
|
86 |
}
|
87 |
|
88 |
/**
|
89 |
+
* Callback of add shortcode for confirm page.
|
90 |
*
|
91 |
+
* @return string
|
|
|
|
|
92 |
*/
|
93 |
protected function confirm_page() {
|
94 |
$value = $this->Data->get_raw( $this->atts['name'] );
|
109 |
}
|
110 |
|
111 |
/**
|
112 |
+
* Display tag generator dialog.
|
113 |
+
* Overwrite required for each child class.
|
114 |
*
|
115 |
+
* @param array $options Options.
|
|
|
116 |
*/
|
117 |
public function mwform_tag_generator_dialog( array $options = array() ) {
|
118 |
?>
|
classes/form-fields/class.monthpicker.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
@@ -32,9 +32,9 @@ class MW_WP_Form_Field_Monthpicker extends MW_WP_Form_Abstract_Form_Field {
|
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
-
* Set default attributes
|
36 |
*
|
37 |
-
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
@@ -50,17 +50,16 @@ class MW_WP_Form_Field_Monthpicker extends MW_WP_Form_Abstract_Form_Field {
|
|
50 |
}
|
51 |
|
52 |
/**
|
53 |
-
* Callback of add shortcode for input page
|
54 |
*
|
55 |
-
* @
|
56 |
-
* @param string $element_content
|
57 |
-
* @return string HTML
|
58 |
*/
|
59 |
protected function input_page() {
|
60 |
global $wp_scripts;
|
61 |
$ui = $wp_scripts->query( 'jquery-ui-core' );
|
62 |
wp_enqueue_style(
|
63 |
-
'jquery.ui',
|
|
|
64 |
array(),
|
65 |
$ui->ver
|
66 |
);
|
@@ -80,23 +79,29 @@ class MW_WP_Form_Field_Monthpicker extends MW_WP_Form_Abstract_Form_Field {
|
|
80 |
true
|
81 |
);
|
82 |
|
83 |
-
$Json_Parser
|
84 |
$this->atts['js'] = $Json_Parser->create_json();
|
85 |
-
$js
|
86 |
|
87 |
-
$js = array_merge(
|
88 |
-
|
89 |
-
|
|
|
|
|
|
|
90 |
|
91 |
$translate_monthpicker = apply_filters( 'mwform_translate_monthpicker_' . $this->form_key, true );
|
92 |
-
if ( 'ja' ===
|
93 |
-
$js = array_merge(
|
94 |
-
|
95 |
-
'
|
96 |
-
|
|
|
|
|
|
|
97 |
),
|
98 |
-
|
99 |
-
)
|
100 |
}
|
101 |
|
102 |
$this->atts['js'] = json_encode( $js );
|
@@ -107,14 +112,17 @@ class MW_WP_Form_Field_Monthpicker extends MW_WP_Form_Abstract_Form_Field {
|
|
107 |
}
|
108 |
|
109 |
$_ret = '';
|
110 |
-
$_ret .= $this->Form->monthpicker(
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
|
|
|
|
|
|
118 |
if ( 'false' !== $this->atts['show_error'] ) {
|
119 |
$_ret .= $this->get_error( $this->atts['name'] );
|
120 |
}
|
@@ -122,11 +130,9 @@ class MW_WP_Form_Field_Monthpicker extends MW_WP_Form_Abstract_Form_Field {
|
|
122 |
}
|
123 |
|
124 |
/**
|
125 |
-
* Callback of add shortcode for confirm page
|
126 |
*
|
127 |
-
* @
|
128 |
-
* @param string $element_content
|
129 |
-
* @return string HTML
|
130 |
*/
|
131 |
protected function confirm_page() {
|
132 |
$value = $this->Data->get_raw( $this->atts['name'] );
|
@@ -136,11 +142,10 @@ class MW_WP_Form_Field_Monthpicker extends MW_WP_Form_Abstract_Form_Field {
|
|
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 |
?>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Field_Monthpicker
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Field_Monthpicker extends MW_WP_Form_Abstract_Form_Field {
|
12 |
|
13 |
/**
|
14 |
* Types of form type.
|
15 |
+
* input|select|button|input_button|error|other.
|
16 |
+
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* Set default attributes.
|
36 |
*
|
37 |
+
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
50 |
}
|
51 |
|
52 |
/**
|
53 |
+
* Callback of add shortcode for input page.
|
54 |
*
|
55 |
+
* @return string
|
|
|
|
|
56 |
*/
|
57 |
protected function input_page() {
|
58 |
global $wp_scripts;
|
59 |
$ui = $wp_scripts->query( 'jquery-ui-core' );
|
60 |
wp_enqueue_style(
|
61 |
+
'jquery.ui',
|
62 |
+
'//ajax.googleapis.com/ajax/libs/jqueryui/' . $ui->ver . '/themes/smoothness/jquery-ui.min.css',
|
63 |
array(),
|
64 |
$ui->ver
|
65 |
);
|
79 |
true
|
80 |
);
|
81 |
|
82 |
+
$Json_Parser = new MW_WP_Form_Json_Parser( $this->atts['js'] );
|
83 |
$this->atts['js'] = $Json_Parser->create_json();
|
84 |
+
$js = json_decode( $this->atts['js'], true );
|
85 |
|
86 |
+
$js = array_merge(
|
87 |
+
$js,
|
88 |
+
array(
|
89 |
+
'Button' => 'false',
|
90 |
+
)
|
91 |
+
);
|
92 |
|
93 |
$translate_monthpicker = apply_filters( 'mwform_translate_monthpicker_' . $this->form_key, true );
|
94 |
+
if ( $translate_monthpicker && 'ja' === get_locale() ) {
|
95 |
+
$js = array_merge(
|
96 |
+
array(
|
97 |
+
'i18n' => array(
|
98 |
+
'year' => '',
|
99 |
+
'months' => array( '1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月' ),
|
100 |
+
),
|
101 |
+
'MonthFormat' => 'yy年mm月',
|
102 |
),
|
103 |
+
$js
|
104 |
+
);
|
105 |
}
|
106 |
|
107 |
$this->atts['js'] = json_encode( $js );
|
112 |
}
|
113 |
|
114 |
$_ret = '';
|
115 |
+
$_ret .= $this->Form->monthpicker(
|
116 |
+
$this->atts['name'],
|
117 |
+
array(
|
118 |
+
'id' => $this->atts['id'],
|
119 |
+
'class' => $this->atts['class'],
|
120 |
+
'size' => $this->atts['size'],
|
121 |
+
'js' => $this->atts['js'],
|
122 |
+
'value' => $value,
|
123 |
+
'placeholder' => $this->atts['placeholder'],
|
124 |
+
)
|
125 |
+
);
|
126 |
if ( 'false' !== $this->atts['show_error'] ) {
|
127 |
$_ret .= $this->get_error( $this->atts['name'] );
|
128 |
}
|
130 |
}
|
131 |
|
132 |
/**
|
133 |
+
* Callback of add shortcode for confirm page.
|
134 |
*
|
135 |
+
* @return string
|
|
|
|
|
136 |
*/
|
137 |
protected function confirm_page() {
|
138 |
$value = $this->Data->get_raw( $this->atts['name'] );
|
142 |
}
|
143 |
|
144 |
/**
|
145 |
+
* Display tag generator dialog.
|
146 |
+
* Overwrite required for each child class.
|
147 |
*
|
148 |
+
* @param array $options Options.
|
|
|
149 |
*/
|
150 |
public function mwform_tag_generator_dialog( array $options = array() ) {
|
151 |
?>
|
classes/form-fields/class.number.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
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 default attributes
|
36 |
*
|
37 |
-
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
@@ -51,11 +51,9 @@ class MW_WP_Form_Field_Number extends MW_WP_Form_Abstract_Form_Field {
|
|
51 |
}
|
52 |
|
53 |
/**
|
54 |
-
* Callback of add shortcode for input page
|
55 |
*
|
56 |
-
* @
|
57 |
-
* @param string $element_content
|
58 |
-
* @return string HTML
|
59 |
*/
|
60 |
protected function input_page() {
|
61 |
$value = $this->Data->get_raw( $this->atts['name'] );
|
@@ -63,15 +61,18 @@ class MW_WP_Form_Field_Number extends MW_WP_Form_Abstract_Form_Field {
|
|
63 |
$value = $this->atts['value'];
|
64 |
}
|
65 |
|
66 |
-
$_ret = $this->Form->number(
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
|
|
|
|
|
|
75 |
if ( 'false' !== $this->atts['show_error'] ) {
|
76 |
$_ret .= $this->get_error( $this->atts['name'] );
|
77 |
}
|
@@ -79,11 +80,9 @@ class MW_WP_Form_Field_Number extends MW_WP_Form_Abstract_Form_Field {
|
|
79 |
}
|
80 |
|
81 |
/**
|
82 |
-
* Callback of add shortcode for confirm page
|
83 |
*
|
84 |
-
* @
|
85 |
-
* @param string $element_content
|
86 |
-
* @return string HTML
|
87 |
*/
|
88 |
protected function confirm_page() {
|
89 |
$value = $this->Data->get_raw( $this->atts['name'] );
|
@@ -93,11 +92,10 @@ class MW_WP_Form_Field_Number extends MW_WP_Form_Abstract_Form_Field {
|
|
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 |
?>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Field_Number
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Field_Number extends MW_WP_Form_Abstract_Form_Field {
|
12 |
|
13 |
/**
|
14 |
* Types of form type.
|
15 |
+
* input|select|button|input_button|error|other.
|
16 |
+
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* Set default attributes.
|
36 |
*
|
37 |
+
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
51 |
}
|
52 |
|
53 |
/**
|
54 |
+
* Callback of add shortcode for input page.
|
55 |
*
|
56 |
+
* @return string
|
|
|
|
|
57 |
*/
|
58 |
protected function input_page() {
|
59 |
$value = $this->Data->get_raw( $this->atts['name'] );
|
61 |
$value = $this->atts['value'];
|
62 |
}
|
63 |
|
64 |
+
$_ret = $this->Form->number(
|
65 |
+
$this->atts['name'],
|
66 |
+
array(
|
67 |
+
'id' => $this->atts['id'],
|
68 |
+
'class' => $this->atts['class'],
|
69 |
+
'value' => $value,
|
70 |
+
'min' => $this->atts['min'],
|
71 |
+
'max' => $this->atts['max'],
|
72 |
+
'step' => $this->atts['step'],
|
73 |
+
'placeholder' => $this->atts['placeholder'],
|
74 |
+
)
|
75 |
+
);
|
76 |
if ( 'false' !== $this->atts['show_error'] ) {
|
77 |
$_ret .= $this->get_error( $this->atts['name'] );
|
78 |
}
|
80 |
}
|
81 |
|
82 |
/**
|
83 |
+
* Callback of add shortcode for confirm page.
|
84 |
*
|
85 |
+
* @return string
|
|
|
|
|
86 |
*/
|
87 |
protected function confirm_page() {
|
88 |
$value = $this->Data->get_raw( $this->atts['name'] );
|
92 |
}
|
93 |
|
94 |
/**
|
95 |
+
* Display tag generator dialog.
|
96 |
+
* Overwrite required for each child class.
|
97 |
*
|
98 |
+
* @param array $options Options.
|
|
|
99 |
*/
|
100 |
public function mwform_tag_generator_dialog( array $options = array() ) {
|
101 |
?>
|
classes/form-fields/class.password.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
@@ -32,9 +32,9 @@ class MW_WP_Form_Field_Password extends MW_WP_Form_Abstract_Form_Field {
|
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
-
* Set default attributes
|
36 |
*
|
37 |
-
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
@@ -50,11 +50,9 @@ class MW_WP_Form_Field_Password extends MW_WP_Form_Abstract_Form_Field {
|
|
50 |
}
|
51 |
|
52 |
/**
|
53 |
-
* Callback of add shortcode for input page
|
54 |
*
|
55 |
-
* @
|
56 |
-
* @param string $element_content
|
57 |
-
* @return string HTML
|
58 |
*/
|
59 |
protected function input_page() {
|
60 |
$value = $this->Data->get_raw( $this->atts['name'] );
|
@@ -62,14 +60,17 @@ class MW_WP_Form_Field_Password extends MW_WP_Form_Abstract_Form_Field {
|
|
62 |
$value = $this->atts['value'];
|
63 |
}
|
64 |
|
65 |
-
$_ret = $this->Form->password(
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
|
|
|
|
|
|
73 |
if ( 'false' !== $this->atts['show_error'] ) {
|
74 |
$_ret .= $this->get_error( $this->atts['name'] );
|
75 |
}
|
@@ -77,11 +78,9 @@ class MW_WP_Form_Field_Password extends MW_WP_Form_Abstract_Form_Field {
|
|
77 |
}
|
78 |
|
79 |
/**
|
80 |
-
* Callback of add shortcode for confirm page
|
81 |
*
|
82 |
-
* @
|
83 |
-
* @param string $element_content
|
84 |
-
* @return string HTML
|
85 |
*/
|
86 |
protected function confirm_page() {
|
87 |
$value = $this->Data->get_raw( $this->atts['name'] );
|
@@ -89,11 +88,10 @@ class MW_WP_Form_Field_Password extends MW_WP_Form_Abstract_Form_Field {
|
|
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 |
?>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Field_Password
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Field_Password extends MW_WP_Form_Abstract_Form_Field {
|
12 |
|
13 |
/**
|
14 |
* Types of form type.
|
15 |
+
* input|select|button|input_button|error|other.
|
16 |
+
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* Set default attributes.
|
36 |
*
|
37 |
+
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
50 |
}
|
51 |
|
52 |
/**
|
53 |
+
* Callback of add shortcode for input page.
|
54 |
*
|
55 |
+
* @return string
|
|
|
|
|
56 |
*/
|
57 |
protected function input_page() {
|
58 |
$value = $this->Data->get_raw( $this->atts['name'] );
|
60 |
$value = $this->atts['value'];
|
61 |
}
|
62 |
|
63 |
+
$_ret = $this->Form->password(
|
64 |
+
$this->atts['name'],
|
65 |
+
array(
|
66 |
+
'id' => $this->atts['id'],
|
67 |
+
'class' => $this->atts['class'],
|
68 |
+
'size' => $this->atts['size'],
|
69 |
+
'maxlength' => $this->atts['maxlength'],
|
70 |
+
'value' => $value,
|
71 |
+
'placeholder' => $this->atts['placeholder'],
|
72 |
+
)
|
73 |
+
);
|
74 |
if ( 'false' !== $this->atts['show_error'] ) {
|
75 |
$_ret .= $this->get_error( $this->atts['name'] );
|
76 |
}
|
78 |
}
|
79 |
|
80 |
/**
|
81 |
+
* Callback of add shortcode for confirm page.
|
82 |
*
|
83 |
+
* @return string
|
|
|
|
|
84 |
*/
|
85 |
protected function confirm_page() {
|
86 |
$value = $this->Data->get_raw( $this->atts['name'] );
|
88 |
}
|
89 |
|
90 |
/**
|
91 |
+
* Display tag generator dialog.
|
92 |
+
* Overwrite required for each child class.
|
93 |
*
|
94 |
+
* @param array $options Options.
|
|
|
95 |
*/
|
96 |
public function mwform_tag_generator_dialog( array $options = array() ) {
|
97 |
?>
|
classes/form-fields/class.radio.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
@@ -32,9 +32,9 @@ class MW_WP_Form_Field_Radio extends MW_WP_Form_Abstract_Form_Field {
|
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
-
* Set default attributes
|
36 |
*
|
37 |
-
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
@@ -50,11 +50,9 @@ class MW_WP_Form_Field_Radio extends MW_WP_Form_Abstract_Form_Field {
|
|
50 |
}
|
51 |
|
52 |
/**
|
53 |
-
* Callback of add shortcode for input page
|
54 |
*
|
55 |
-
* @
|
56 |
-
* @param string $element_content
|
57 |
-
* @return string HTML
|
58 |
*/
|
59 |
protected function input_page() {
|
60 |
$value = $this->Data->get_raw( $this->atts['name'] );
|
@@ -63,12 +61,16 @@ class MW_WP_Form_Field_Radio extends MW_WP_Form_Abstract_Form_Field {
|
|
63 |
}
|
64 |
$children = $this->get_children( $this->atts['children'] );
|
65 |
|
66 |
-
$_ret = $this->Form->radio(
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
|
|
|
|
|
|
|
|
72 |
if ( 'false' === $this->atts['post_raw'] ) {
|
73 |
$_ret .= $this->Form->children( $this->atts['name'], $children );
|
74 |
}
|
@@ -79,11 +81,9 @@ class MW_WP_Form_Field_Radio extends MW_WP_Form_Abstract_Form_Field {
|
|
79 |
}
|
80 |
|
81 |
/**
|
82 |
-
* Callback of add shortcode for confirm page
|
83 |
*
|
84 |
-
* @
|
85 |
-
* @param string $element_content
|
86 |
-
* @return string HTML
|
87 |
*/
|
88 |
protected function confirm_page() {
|
89 |
$children = $this->get_children( $this->atts['children'] );
|
@@ -100,11 +100,10 @@ class MW_WP_Form_Field_Radio extends MW_WP_Form_Abstract_Form_Field {
|
|
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 |
?>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Field_Radio
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Field_Radio extends MW_WP_Form_Abstract_Form_Field {
|
12 |
|
13 |
/**
|
14 |
* Types of form type.
|
15 |
+
* input|select|button|input_button|error|other.
|
16 |
+
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* Set default attributes.
|
36 |
*
|
37 |
+
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
50 |
}
|
51 |
|
52 |
/**
|
53 |
+
* Callback of add shortcode for input page.
|
54 |
*
|
55 |
+
* @return string
|
|
|
|
|
56 |
*/
|
57 |
protected function input_page() {
|
58 |
$value = $this->Data->get_raw( $this->atts['name'] );
|
61 |
}
|
62 |
$children = $this->get_children( $this->atts['children'] );
|
63 |
|
64 |
+
$_ret = $this->Form->radio(
|
65 |
+
$this->atts['name'],
|
66 |
+
$children,
|
67 |
+
array(
|
68 |
+
'id' => $this->atts['id'],
|
69 |
+
'class' => $this->atts['class'],
|
70 |
+
'value' => $value,
|
71 |
+
'vertically' => $this->atts['vertically'],
|
72 |
+
)
|
73 |
+
);
|
74 |
if ( 'false' === $this->atts['post_raw'] ) {
|
75 |
$_ret .= $this->Form->children( $this->atts['name'], $children );
|
76 |
}
|
81 |
}
|
82 |
|
83 |
/**
|
84 |
+
* Callback of add shortcode for confirm page.
|
85 |
*
|
86 |
+
* @return string
|
|
|
|
|
87 |
*/
|
88 |
protected function confirm_page() {
|
89 |
$children = $this->get_children( $this->atts['children'] );
|
100 |
}
|
101 |
|
102 |
/**
|
103 |
+
* Display tag generator dialog.
|
104 |
+
* Overwrite required for each child class.
|
105 |
*
|
106 |
+
* @param array $options Options.
|
|
|
107 |
*/
|
108 |
public function mwform_tag_generator_dialog( array $options = array() ) {
|
109 |
?>
|
classes/form-fields/class.range.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
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 default attributes
|
36 |
*
|
37 |
-
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
@@ -50,11 +50,9 @@ class MW_WP_Form_Field_Range extends MW_WP_Form_Abstract_Form_Field {
|
|
50 |
}
|
51 |
|
52 |
/**
|
53 |
-
* Callback of add shortcode for input page
|
54 |
*
|
55 |
-
* @
|
56 |
-
* @param string $element_content
|
57 |
-
* @return string HTML
|
58 |
*/
|
59 |
protected function input_page() {
|
60 |
$value = $this->Data->get_raw( $this->atts['name'] );
|
@@ -62,14 +60,17 @@ class MW_WP_Form_Field_Range extends MW_WP_Form_Abstract_Form_Field {
|
|
62 |
$value = $this->atts['value'];
|
63 |
}
|
64 |
|
65 |
-
$_ret = $this->Form->range(
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
|
|
|
|
|
|
73 |
if ( 'false' !== $this->atts['show_error'] ) {
|
74 |
$_ret .= $this->get_error( $this->atts['name'] );
|
75 |
}
|
@@ -77,11 +78,9 @@ class MW_WP_Form_Field_Range extends MW_WP_Form_Abstract_Form_Field {
|
|
77 |
}
|
78 |
|
79 |
/**
|
80 |
-
* Callback of add shortcode for confirm page
|
81 |
*
|
82 |
-
* @
|
83 |
-
* @param string $element_content
|
84 |
-
* @return string HTML
|
85 |
*/
|
86 |
protected function confirm_page() {
|
87 |
$value = $this->Data->get_raw( $this->atts['name'] );
|
@@ -91,11 +90,10 @@ class MW_WP_Form_Field_Range extends MW_WP_Form_Abstract_Form_Field {
|
|
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 |
?>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Field_Range
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Field_Range extends MW_WP_Form_Abstract_Form_Field {
|
12 |
|
13 |
/**
|
14 |
* Types of form type.
|
15 |
+
* input|select|button|input_button|error|other.
|
16 |
+
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* Set default attributes.
|
36 |
*
|
37 |
+
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
50 |
}
|
51 |
|
52 |
/**
|
53 |
+
* Callback of add shortcode for input page.
|
54 |
*
|
55 |
+
* @return string
|
|
|
|
|
56 |
*/
|
57 |
protected function input_page() {
|
58 |
$value = $this->Data->get_raw( $this->atts['name'] );
|
60 |
$value = $this->atts['value'];
|
61 |
}
|
62 |
|
63 |
+
$_ret = $this->Form->range(
|
64 |
+
$this->atts['name'],
|
65 |
+
array(
|
66 |
+
'id' => $this->atts['id'],
|
67 |
+
'class' => $this->atts['class'],
|
68 |
+
'value' => $value,
|
69 |
+
'min' => $this->atts['min'],
|
70 |
+
'max' => $this->atts['max'],
|
71 |
+
'step' => $this->atts['step'],
|
72 |
+
)
|
73 |
+
);
|
74 |
if ( 'false' !== $this->atts['show_error'] ) {
|
75 |
$_ret .= $this->get_error( $this->atts['name'] );
|
76 |
}
|
78 |
}
|
79 |
|
80 |
/**
|
81 |
+
* Callback of add shortcode for confirm page.
|
82 |
*
|
83 |
+
* @return string
|
|
|
|
|
84 |
*/
|
85 |
protected function confirm_page() {
|
86 |
$value = $this->Data->get_raw( $this->atts['name'] );
|
90 |
}
|
91 |
|
92 |
/**
|
93 |
+
* Display tag generator dialog.
|
94 |
+
* Overwrite required for each child class.
|
95 |
*
|
96 |
+
* @param array $options Options.
|
|
|
97 |
*/
|
98 |
public function mwform_tag_generator_dialog( array $options = array() ) {
|
99 |
?>
|
classes/form-fields/class.select.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
@@ -32,9 +32,9 @@ class MW_WP_Form_Field_Select extends MW_WP_Form_Abstract_Form_Field {
|
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
-
* Set default attributes
|
36 |
*
|
37 |
-
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
@@ -49,11 +49,9 @@ class MW_WP_Form_Field_Select extends MW_WP_Form_Abstract_Form_Field {
|
|
49 |
}
|
50 |
|
51 |
/**
|
52 |
-
* Callback of add shortcode for input page
|
53 |
*
|
54 |
-
* @
|
55 |
-
* @param string $element_content
|
56 |
-
* @return string HTML
|
57 |
*/
|
58 |
protected function input_page() {
|
59 |
$value = $this->Data->get_raw( $this->atts['name'] );
|
@@ -62,11 +60,15 @@ class MW_WP_Form_Field_Select extends MW_WP_Form_Abstract_Form_Field {
|
|
62 |
}
|
63 |
$children = $this->get_children( $this->atts['children'] );
|
64 |
|
65 |
-
$_ret = $this->Form->select(
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
|
|
|
|
|
|
|
|
70 |
if ( 'false' === $this->atts['post_raw'] ) {
|
71 |
$_ret .= $this->Form->children( $this->atts['name'], $children );
|
72 |
}
|
@@ -77,11 +79,9 @@ class MW_WP_Form_Field_Select extends MW_WP_Form_Abstract_Form_Field {
|
|
77 |
}
|
78 |
|
79 |
/**
|
80 |
-
* Callback of add shortcode for confirm page
|
81 |
*
|
82 |
-
* @
|
83 |
-
* @param string $element_content
|
84 |
-
* @return string HTML
|
85 |
*/
|
86 |
protected function confirm_page() {
|
87 |
$children = $this->get_children( $this->atts['children'] );
|
@@ -96,11 +96,10 @@ class MW_WP_Form_Field_Select extends MW_WP_Form_Abstract_Form_Field {
|
|
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 |
?>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Field_Select
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Field_Select extends MW_WP_Form_Abstract_Form_Field {
|
12 |
|
13 |
/**
|
14 |
* Types of form type.
|
15 |
+
* input|select|button|input_button|error|other.
|
16 |
+
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* Set default attributes.
|
36 |
*
|
37 |
+
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
49 |
}
|
50 |
|
51 |
/**
|
52 |
+
* Callback of add shortcode for input page.
|
53 |
*
|
54 |
+
* @return string
|
|
|
|
|
55 |
*/
|
56 |
protected function input_page() {
|
57 |
$value = $this->Data->get_raw( $this->atts['name'] );
|
60 |
}
|
61 |
$children = $this->get_children( $this->atts['children'] );
|
62 |
|
63 |
+
$_ret = $this->Form->select(
|
64 |
+
$this->atts['name'],
|
65 |
+
$children,
|
66 |
+
array(
|
67 |
+
'id' => $this->atts['id'],
|
68 |
+
'class' => $this->atts['class'],
|
69 |
+
'value' => $value,
|
70 |
+
)
|
71 |
+
);
|
72 |
if ( 'false' === $this->atts['post_raw'] ) {
|
73 |
$_ret .= $this->Form->children( $this->atts['name'], $children );
|
74 |
}
|
79 |
}
|
80 |
|
81 |
/**
|
82 |
+
* Callback of add shortcode for confirm page.
|
83 |
*
|
84 |
+
* @return string
|
|
|
|
|
85 |
*/
|
86 |
protected function confirm_page() {
|
87 |
$children = $this->get_children( $this->atts['children'] );
|
96 |
}
|
97 |
|
98 |
/**
|
99 |
+
* Display tag generator dialog.
|
100 |
+
* Overwrite required for each child class.
|
101 |
*
|
102 |
+
* @param array $options Options.
|
|
|
103 |
*/
|
104 |
public function mwform_tag_generator_dialog( array $options = array() ) {
|
105 |
?>
|
classes/form-fields/class.submit-button.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
@@ -32,56 +32,63 @@ class MW_WP_Form_Field_Submit_Button extends MW_WP_Form_Abstract_Form_Field {
|
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
-
* Set default attributes
|
36 |
*
|
37 |
-
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
41 |
-
'name'
|
42 |
-
'class'
|
43 |
'confirm_value' => __( 'Confirm', 'mw-wp-form' ),
|
44 |
'submit_value' => __( 'Send', 'mw-wp-form' ),
|
45 |
);
|
46 |
}
|
47 |
|
48 |
/**
|
49 |
-
* Callback of add shortcode for input page
|
50 |
*
|
51 |
-
* @
|
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(
|
58 |
-
|
59 |
-
|
|
|
|
|
|
|
|
|
60 |
}
|
61 |
-
return $this->Form->submit(
|
62 |
-
|
63 |
-
|
|
|
|
|
|
|
|
|
64 |
}
|
65 |
|
66 |
/**
|
67 |
-
* Callback of add shortcode for confirm page
|
68 |
*
|
69 |
-
* @
|
70 |
-
* @param string $element_content
|
71 |
-
* @return string HTML
|
72 |
*/
|
73 |
protected function confirm_page() {
|
74 |
-
return $this->Form->submit(
|
75 |
-
|
76 |
-
|
|
|
|
|
|
|
|
|
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 |
?>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Field_Submit_Button
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Field_Submit_Button extends MW_WP_Form_Abstract_Form_Field {
|
12 |
|
13 |
/**
|
14 |
* Types of form type.
|
15 |
+
* input|select|button|input_button|error|other.
|
16 |
+
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* Set default attributes.
|
36 |
*
|
37 |
+
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
41 |
+
'name' => '',
|
42 |
+
'class' => null,
|
43 |
'confirm_value' => __( 'Confirm', 'mw-wp-form' ),
|
44 |
'submit_value' => __( 'Send', 'mw-wp-form' ),
|
45 |
);
|
46 |
}
|
47 |
|
48 |
/**
|
49 |
+
* Callback of add shortcode for input page.
|
50 |
*
|
51 |
+
* @return string
|
|
|
|
|
52 |
*/
|
53 |
protected function input_page() {
|
54 |
if ( ! empty( $this->atts['confirm_value'] ) ) {
|
55 |
+
return $this->Form->submit(
|
56 |
+
MWF_Config::CONFIRM_BUTTON,
|
57 |
+
$this->atts['confirm_value'],
|
58 |
+
array(
|
59 |
+
'class' => $this->atts['class'],
|
60 |
+
)
|
61 |
+
);
|
62 |
}
|
63 |
+
return $this->Form->submit(
|
64 |
+
$this->atts['name'],
|
65 |
+
$this->atts['submit_value'],
|
66 |
+
array(
|
67 |
+
'class' => $this->atts['class'],
|
68 |
+
)
|
69 |
+
);
|
70 |
}
|
71 |
|
72 |
/**
|
73 |
+
* Callback of add shortcode for confirm page.
|
74 |
*
|
75 |
+
* @return string
|
|
|
|
|
76 |
*/
|
77 |
protected function confirm_page() {
|
78 |
+
return $this->Form->submit(
|
79 |
+
$this->atts['name'],
|
80 |
+
$this->atts['submit_value'],
|
81 |
+
array(
|
82 |
+
'class' => $this->atts['class'],
|
83 |
+
)
|
84 |
+
);
|
85 |
}
|
86 |
|
87 |
/**
|
88 |
+
* Display tag generator dialog.
|
89 |
+
* Overwrite required for each child class.
|
90 |
*
|
91 |
+
* @param array $options Options.
|
|
|
92 |
*/
|
93 |
public function mwform_tag_generator_dialog( array $options = array() ) {
|
94 |
?>
|
classes/form-fields/class.submit.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
@@ -32,9 +32,9 @@ class MW_WP_Form_Field_Submit extends MW_WP_Form_Abstract_Form_Field {
|
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
-
* Set default attributes
|
36 |
*
|
37 |
-
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
@@ -45,34 +45,34 @@ class MW_WP_Form_Field_Submit extends MW_WP_Form_Abstract_Form_Field {
|
|
45 |
}
|
46 |
|
47 |
/**
|
48 |
-
* Callback of add shortcode for input page
|
49 |
*
|
50 |
-
* @
|
51 |
-
* @param string $element_content
|
52 |
-
* @return string HTML
|
53 |
*/
|
54 |
protected function input_page() {
|
55 |
-
return $this->Form->submit(
|
56 |
-
|
57 |
-
|
|
|
|
|
|
|
|
|
58 |
}
|
59 |
|
60 |
/**
|
61 |
-
* Callback of add shortcode for confirm page
|
62 |
*
|
63 |
-
* @
|
64 |
-
* @param string $element_content
|
65 |
-
* @return string HTML
|
66 |
*/
|
67 |
protected function confirm_page() {
|
68 |
return $this->input_page( $this->atts );
|
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() ) {
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Field_Submit
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Field_Submit extends MW_WP_Form_Abstract_Form_Field {
|
12 |
|
13 |
/**
|
14 |
* Types of form type.
|
15 |
+
* input|select|button|input_button|error|other.
|
16 |
+
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* Set default attributes.
|
36 |
*
|
37 |
+
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
45 |
}
|
46 |
|
47 |
/**
|
48 |
+
* Callback of add shortcode for input page.
|
49 |
*
|
50 |
+
* @return string
|
|
|
|
|
51 |
*/
|
52 |
protected function input_page() {
|
53 |
+
return $this->Form->submit(
|
54 |
+
$this->atts['name'],
|
55 |
+
$this->atts['value'],
|
56 |
+
array(
|
57 |
+
'class' => $this->atts['class'],
|
58 |
+
)
|
59 |
+
);
|
60 |
}
|
61 |
|
62 |
/**
|
63 |
+
* Callback of add shortcode for confirm page.
|
64 |
*
|
65 |
+
* @return string
|
|
|
|
|
66 |
*/
|
67 |
protected function confirm_page() {
|
68 |
return $this->input_page( $this->atts );
|
69 |
}
|
70 |
|
71 |
/**
|
72 |
+
* Display tag generator dialog.
|
73 |
+
* Overwrite required for each child class.
|
74 |
*
|
75 |
+
* @param array $options Options.
|
76 |
* @return void
|
77 |
*/
|
78 |
public function mwform_tag_generator_dialog( array $options = array() ) {
|
classes/form-fields/class.tel.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
@@ -32,26 +32,24 @@ class MW_WP_Form_Field_Tel extends MW_WP_Form_Abstract_Form_Field {
|
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
-
* Set default attributes
|
36 |
*
|
37 |
-
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
41 |
-
'name'
|
42 |
-
'class'
|
43 |
-
'value'
|
44 |
-
'show_error'
|
45 |
'conv_half_alphanumeric' => 'true',
|
46 |
);
|
47 |
}
|
48 |
|
49 |
/**
|
50 |
-
* Callback of add shortcode for input page
|
51 |
*
|
52 |
-
* @
|
53 |
-
* @param string $element_content
|
54 |
-
* @return string HTML
|
55 |
*/
|
56 |
protected function input_page() {
|
57 |
$value = $this->Data->get_raw( $this->atts['name'] );
|
@@ -66,11 +64,14 @@ class MW_WP_Form_Field_Tel extends MW_WP_Form_Abstract_Form_Field {
|
|
66 |
$conv_half_alphanumeric = null;
|
67 |
}
|
68 |
|
69 |
-
$_ret = $this->Form->tel(
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
|
|
|
|
|
|
74 |
if ( 'false' !== $this->atts['show_error'] ) {
|
75 |
$_ret .= $this->get_error( $this->atts['name'] );
|
76 |
}
|
@@ -78,27 +79,24 @@ class MW_WP_Form_Field_Tel extends MW_WP_Form_Abstract_Form_Field {
|
|
78 |
}
|
79 |
|
80 |
/**
|
81 |
-
* Callback of add shortcode for confirm page
|
82 |
*
|
83 |
-
* @
|
84 |
-
* @param string $element_content
|
85 |
-
* @return string HTML
|
86 |
*/
|
87 |
protected function confirm_page() {
|
88 |
$value = $this->Data->get( $this->atts['name'] );
|
89 |
$separator = $this->Data->get_separator_value( $this->atts['name'] );
|
90 |
-
$_ret
|
91 |
-
$_ret
|
92 |
-
$_ret
|
93 |
return $_ret;
|
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 |
?>
|
@@ -126,10 +124,10 @@ class MW_WP_Form_Field_Tel extends MW_WP_Form_Abstract_Form_Field {
|
|
126 |
}
|
127 |
|
128 |
/**
|
129 |
-
* This form field is for Japanese environments only
|
130 |
*
|
131 |
-
* @param array $
|
132 |
-
* @return array
|
133 |
*/
|
134 |
public function _mwform_form_fields( array $form_fields ) {
|
135 |
$form_fields = parent::_mwform_form_fields( $form_fields );
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Field_Tel
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Field_Tel extends MW_WP_Form_Abstract_Form_Field {
|
12 |
|
13 |
/**
|
14 |
* Types of form type.
|
15 |
+
* input|select|button|input_button|error|other.
|
16 |
+
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* Set default attributes.
|
36 |
*
|
37 |
+
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
41 |
+
'name' => '',
|
42 |
+
'class' => null,
|
43 |
+
'value' => '',
|
44 |
+
'show_error' => 'true',
|
45 |
'conv_half_alphanumeric' => 'true',
|
46 |
);
|
47 |
}
|
48 |
|
49 |
/**
|
50 |
+
* Callback of add shortcode for input page.
|
51 |
*
|
52 |
+
* @return string
|
|
|
|
|
53 |
*/
|
54 |
protected function input_page() {
|
55 |
$value = $this->Data->get_raw( $this->atts['name'] );
|
64 |
$conv_half_alphanumeric = null;
|
65 |
}
|
66 |
|
67 |
+
$_ret = $this->Form->tel(
|
68 |
+
$this->atts['name'],
|
69 |
+
array(
|
70 |
+
'class' => $this->atts['class'],
|
71 |
+
'conv-half-alphanumeric' => $conv_half_alphanumeric,
|
72 |
+
'value' => $value,
|
73 |
+
)
|
74 |
+
);
|
75 |
if ( 'false' !== $this->atts['show_error'] ) {
|
76 |
$_ret .= $this->get_error( $this->atts['name'] );
|
77 |
}
|
79 |
}
|
80 |
|
81 |
/**
|
82 |
+
* Callback of add shortcode for confirm page.
|
83 |
*
|
84 |
+
* @return string
|
|
|
|
|
85 |
*/
|
86 |
protected function confirm_page() {
|
87 |
$value = $this->Data->get( $this->atts['name'] );
|
88 |
$separator = $this->Data->get_separator_value( $this->atts['name'] );
|
89 |
+
$_ret = esc_html( $value );
|
90 |
+
$_ret .= $this->Form->hidden( $this->atts['name'] . '[data]', $value );
|
91 |
+
$_ret .= $this->Form->separator( $this->atts['name'], $separator );
|
92 |
return $_ret;
|
93 |
}
|
94 |
|
95 |
/**
|
96 |
+
* Display tag generator dialog.
|
97 |
+
* Overwrite required for each child class.
|
98 |
*
|
99 |
+
* @param array $options Options.
|
|
|
100 |
*/
|
101 |
public function mwform_tag_generator_dialog( array $options = array() ) {
|
102 |
?>
|
124 |
}
|
125 |
|
126 |
/**
|
127 |
+
* This form field is for Japanese environments only.
|
128 |
*
|
129 |
+
* @param array $form_fields Array of MW_WP_Form_Abstract_Form_Field.
|
130 |
+
* @return array
|
131 |
*/
|
132 |
public function _mwform_form_fields( array $form_fields ) {
|
133 |
$form_fields = parent::_mwform_form_fields( $form_fields );
|
classes/form-fields/class.text.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
@@ -32,30 +32,28 @@ class MW_WP_Form_Field_Text extends MW_WP_Form_Abstract_Form_Field {
|
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
-
* Set default attributes
|
36 |
*
|
37 |
-
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
41 |
-
'name'
|
42 |
-
'id'
|
43 |
-
'class'
|
44 |
-
'size'
|
45 |
-
'maxlength'
|
46 |
-
'value'
|
47 |
-
'placeholder'
|
48 |
-
'show_error'
|
49 |
'conv_half_alphanumeric' => null,
|
50 |
);
|
51 |
}
|
52 |
|
53 |
/**
|
54 |
-
* Callback of add shortcode for input page
|
55 |
*
|
56 |
-
* @
|
57 |
-
* @param string $element_content
|
58 |
-
* @return string HTML
|
59 |
*/
|
60 |
protected function input_page() {
|
61 |
$conv_half_alphanumeric = 'true';
|
@@ -67,15 +65,18 @@ class MW_WP_Form_Field_Text extends MW_WP_Form_Abstract_Form_Field {
|
|
67 |
$value = $this->atts['value'];
|
68 |
}
|
69 |
|
70 |
-
$_ret = $this->Form->text(
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
|
|
|
|
|
|
79 |
if ( 'false' !== $this->atts['show_error'] ) {
|
80 |
$_ret .= $this->get_error( $this->atts['name'] );
|
81 |
}
|
@@ -83,11 +84,9 @@ class MW_WP_Form_Field_Text extends MW_WP_Form_Abstract_Form_Field {
|
|
83 |
}
|
84 |
|
85 |
/**
|
86 |
-
* Callback of add shortcode for confirm page
|
87 |
*
|
88 |
-
* @
|
89 |
-
* @param string $element_content
|
90 |
-
* @return string HTML
|
91 |
*/
|
92 |
protected function confirm_page() {
|
93 |
$value = $this->Data->get_raw( $this->atts['name'] );
|
@@ -97,11 +96,10 @@ class MW_WP_Form_Field_Text extends MW_WP_Form_Abstract_Form_Field {
|
|
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 |
?>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Field_Text
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Field_Text extends MW_WP_Form_Abstract_Form_Field {
|
12 |
|
13 |
/**
|
14 |
* Types of form type.
|
15 |
+
* input|select|button|input_button|error|other.
|
16 |
+
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* Set default attributes.
|
36 |
*
|
37 |
+
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
41 |
+
'name' => '',
|
42 |
+
'id' => null,
|
43 |
+
'class' => null,
|
44 |
+
'size' => 60,
|
45 |
+
'maxlength' => null,
|
46 |
+
'value' => '',
|
47 |
+
'placeholder' => null,
|
48 |
+
'show_error' => 'true',
|
49 |
'conv_half_alphanumeric' => null,
|
50 |
);
|
51 |
}
|
52 |
|
53 |
/**
|
54 |
+
* Callback of add shortcode for input page.
|
55 |
*
|
56 |
+
* @return string
|
|
|
|
|
57 |
*/
|
58 |
protected function input_page() {
|
59 |
$conv_half_alphanumeric = 'true';
|
65 |
$value = $this->atts['value'];
|
66 |
}
|
67 |
|
68 |
+
$_ret = $this->Form->text(
|
69 |
+
$this->atts['name'],
|
70 |
+
array(
|
71 |
+
'id' => $this->atts['id'],
|
72 |
+
'class' => $this->atts['class'],
|
73 |
+
'size' => $this->atts['size'],
|
74 |
+
'maxlength' => $this->atts['maxlength'],
|
75 |
+
'value' => $value,
|
76 |
+
'placeholder' => $this->atts['placeholder'],
|
77 |
+
'conv-half-alphanumeric' => $conv_half_alphanumeric,
|
78 |
+
)
|
79 |
+
);
|
80 |
if ( 'false' !== $this->atts['show_error'] ) {
|
81 |
$_ret .= $this->get_error( $this->atts['name'] );
|
82 |
}
|
84 |
}
|
85 |
|
86 |
/**
|
87 |
+
* Callback of add shortcode for confirm page.
|
88 |
*
|
89 |
+
* @return string
|
|
|
|
|
90 |
*/
|
91 |
protected function confirm_page() {
|
92 |
$value = $this->Data->get_raw( $this->atts['name'] );
|
96 |
}
|
97 |
|
98 |
/**
|
99 |
+
* Display tag generator dialog.
|
100 |
+
* Overwrite required for each child class.
|
101 |
*
|
102 |
+
* @param array $options Options.
|
|
|
103 |
*/
|
104 |
public function mwform_tag_generator_dialog( array $options = array() ) {
|
105 |
?>
|
classes/form-fields/class.textarea.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
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 default attributes
|
36 |
*
|
37 |
-
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
@@ -50,11 +50,9 @@ class MW_WP_Form_Field_Textarea extends MW_WP_Form_Abstract_Form_Field {
|
|
50 |
}
|
51 |
|
52 |
/**
|
53 |
-
* Callback of add shortcode for input page
|
54 |
*
|
55 |
-
* @
|
56 |
-
* @param string $element_content
|
57 |
-
* @return string HTML
|
58 |
*/
|
59 |
protected function input_page() {
|
60 |
$value = $this->Data->get_raw( $this->atts['name'] );
|
@@ -62,14 +60,17 @@ class MW_WP_Form_Field_Textarea extends MW_WP_Form_Abstract_Form_Field {
|
|
62 |
$value = $this->atts['value'];
|
63 |
}
|
64 |
|
65 |
-
$_ret = $this->Form->textarea(
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
|
|
|
|
|
|
73 |
if ( 'false' !== $this->atts['show_error'] ) {
|
74 |
$_ret .= $this->get_error( $this->atts['name'] );
|
75 |
}
|
@@ -77,11 +78,9 @@ class MW_WP_Form_Field_Textarea extends MW_WP_Form_Abstract_Form_Field {
|
|
77 |
}
|
78 |
|
79 |
/**
|
80 |
-
* Callback of add shortcode for confirm page
|
81 |
*
|
82 |
-
* @
|
83 |
-
* @param string $element_content
|
84 |
-
* @return string HTML
|
85 |
*/
|
86 |
protected function confirm_page() {
|
87 |
$value = $this->Data->get_raw( $this->atts['name'] );
|
@@ -91,11 +90,10 @@ class MW_WP_Form_Field_Textarea extends MW_WP_Form_Abstract_Form_Field {
|
|
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 |
?>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Field_Textarea
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Field_Textarea extends MW_WP_Form_Abstract_Form_Field {
|
12 |
|
13 |
/**
|
14 |
* Types of form type.
|
15 |
+
* input|select|button|input_button|error|other.
|
16 |
+
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* Set default attributes.
|
36 |
*
|
37 |
+
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
50 |
}
|
51 |
|
52 |
/**
|
53 |
+
* Callback of add shortcode for input page.
|
54 |
*
|
55 |
+
* @return string
|
|
|
|
|
56 |
*/
|
57 |
protected function input_page() {
|
58 |
$value = $this->Data->get_raw( $this->atts['name'] );
|
60 |
$value = $this->atts['value'];
|
61 |
}
|
62 |
|
63 |
+
$_ret = $this->Form->textarea(
|
64 |
+
$this->atts['name'],
|
65 |
+
array(
|
66 |
+
'id' => $this->atts['id'],
|
67 |
+
'class' => $this->atts['class'],
|
68 |
+
'cols' => $this->atts['cols'],
|
69 |
+
'rows' => $this->atts['rows'],
|
70 |
+
'value' => $value,
|
71 |
+
'placeholder' => $this->atts['placeholder'],
|
72 |
+
)
|
73 |
+
);
|
74 |
if ( 'false' !== $this->atts['show_error'] ) {
|
75 |
$_ret .= $this->get_error( $this->atts['name'] );
|
76 |
}
|
78 |
}
|
79 |
|
80 |
/**
|
81 |
+
* Callback of add shortcode for confirm page.
|
82 |
*
|
83 |
+
* @return string
|
|
|
|
|
84 |
*/
|
85 |
protected function confirm_page() {
|
86 |
$value = $this->Data->get_raw( $this->atts['name'] );
|
90 |
}
|
91 |
|
92 |
/**
|
93 |
+
* Display tag generator dialog.
|
94 |
+
* Overwrite required for each child class.
|
95 |
*
|
96 |
+
* @param array $options Options.
|
|
|
97 |
*/
|
98 |
public function mwform_tag_generator_dialog( array $options = array() ) {
|
99 |
?>
|
classes/form-fields/class.url.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
@@ -32,30 +32,28 @@ class MW_WP_Form_Field_Url extends MW_WP_Form_Abstract_Form_Field {
|
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
-
* Set default attributes
|
36 |
*
|
37 |
-
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
41 |
-
'name'
|
42 |
-
'id'
|
43 |
-
'class'
|
44 |
-
'size'
|
45 |
-
'maxlength'
|
46 |
-
'value'
|
47 |
-
'placeholder'
|
48 |
-
'show_error'
|
49 |
'conv_half_alphanumeric' => 'true',
|
50 |
);
|
51 |
}
|
52 |
|
53 |
/**
|
54 |
-
* Callback of add shortcode for input page
|
55 |
*
|
56 |
-
* @
|
57 |
-
* @param string $element_content
|
58 |
-
* @return string HTML
|
59 |
*/
|
60 |
protected function input_page() {
|
61 |
$conv_half_alphanumeric = 'true';
|
@@ -67,15 +65,18 @@ class MW_WP_Form_Field_Url extends MW_WP_Form_Abstract_Form_Field {
|
|
67 |
$value = $this->atts['value'];
|
68 |
}
|
69 |
|
70 |
-
$_ret = $this->Form->url(
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
|
|
|
|
|
|
79 |
if ( 'false' !== $this->atts['show_error'] ) {
|
80 |
$_ret .= $this->get_error( $this->atts['name'] );
|
81 |
}
|
@@ -83,11 +84,9 @@ class MW_WP_Form_Field_Url extends MW_WP_Form_Abstract_Form_Field {
|
|
83 |
}
|
84 |
|
85 |
/**
|
86 |
-
* Callback of add shortcode for confirm page
|
87 |
*
|
88 |
-
* @
|
89 |
-
* @param string $element_content
|
90 |
-
* @return string HTML
|
91 |
*/
|
92 |
protected function confirm_page() {
|
93 |
$value = $this->Data->get_raw( $this->atts['name'] );
|
@@ -97,11 +96,10 @@ class MW_WP_Form_Field_Url extends MW_WP_Form_Abstract_Form_Field {
|
|
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 |
?>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Field_Url
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Field_Url extends MW_WP_Form_Abstract_Form_Field {
|
12 |
|
13 |
/**
|
14 |
* Types of form type.
|
15 |
+
* input|select|button|input_button|error|other.
|
16 |
+
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* Set default attributes.
|
36 |
*
|
37 |
+
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
41 |
+
'name' => '',
|
42 |
+
'id' => null,
|
43 |
+
'class' => null,
|
44 |
+
'size' => 60,
|
45 |
+
'maxlength' => null,
|
46 |
+
'value' => '',
|
47 |
+
'placeholder' => null,
|
48 |
+
'show_error' => 'true',
|
49 |
'conv_half_alphanumeric' => 'true',
|
50 |
);
|
51 |
}
|
52 |
|
53 |
/**
|
54 |
+
* Callback of add shortcode for input page.
|
55 |
*
|
56 |
+
* @return string
|
|
|
|
|
57 |
*/
|
58 |
protected function input_page() {
|
59 |
$conv_half_alphanumeric = 'true';
|
65 |
$value = $this->atts['value'];
|
66 |
}
|
67 |
|
68 |
+
$_ret = $this->Form->url(
|
69 |
+
$this->atts['name'],
|
70 |
+
array(
|
71 |
+
'id' => $this->atts['id'],
|
72 |
+
'class' => $this->atts['class'],
|
73 |
+
'size' => $this->atts['size'],
|
74 |
+
'maxlength' => $this->atts['maxlength'],
|
75 |
+
'value' => $value,
|
76 |
+
'placeholder' => $this->atts['placeholder'],
|
77 |
+
'conv-half-alphanumeric' => $conv_half_alphanumeric,
|
78 |
+
)
|
79 |
+
);
|
80 |
if ( 'false' !== $this->atts['show_error'] ) {
|
81 |
$_ret .= $this->get_error( $this->atts['name'] );
|
82 |
}
|
84 |
}
|
85 |
|
86 |
/**
|
87 |
+
* Callback of add shortcode for confirm page.
|
88 |
*
|
89 |
+
* @return string
|
|
|
|
|
90 |
*/
|
91 |
protected function confirm_page() {
|
92 |
$value = $this->Data->get_raw( $this->atts['name'] );
|
96 |
}
|
97 |
|
98 |
/**
|
99 |
+
* Display tag generator dialog.
|
100 |
+
* Overwrite required for each child class.
|
101 |
*
|
102 |
+
* @param array $options Options.
|
|
|
103 |
*/
|
104 |
public function mwform_tag_generator_dialog( array $options = array() ) {
|
105 |
?>
|
classes/form-fields/class.zip.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
@@ -32,26 +32,24 @@ class MW_WP_Form_Field_Zip extends MW_WP_Form_Abstract_Form_Field {
|
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
-
* Set default attributes
|
36 |
*
|
37 |
-
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
41 |
-
'name'
|
42 |
-
'class'
|
43 |
-
'value'
|
44 |
-
'show_error'
|
45 |
'conv_half_alphanumeric' => 'true',
|
46 |
);
|
47 |
}
|
48 |
|
49 |
/**
|
50 |
-
* Callback of add shortcode for input page
|
51 |
*
|
52 |
-
* @
|
53 |
-
* @param string $element_content
|
54 |
-
* @return string HTML
|
55 |
*/
|
56 |
protected function input_page() {
|
57 |
$value = $this->Data->get_raw( $this->atts['name'] );
|
@@ -65,11 +63,14 @@ class MW_WP_Form_Field_Zip extends MW_WP_Form_Abstract_Form_Field {
|
|
65 |
if ( 'true' !== $this->atts['conv_half_alphanumeric'] ) {
|
66 |
$conv_half_alphanumeric = null;
|
67 |
}
|
68 |
-
$_ret = $this->Form->zip(
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
|
|
|
|
|
|
73 |
if ( 'false' !== $this->atts['show_error'] ) {
|
74 |
$_ret .= $this->get_error( $this->atts['name'] );
|
75 |
}
|
@@ -77,27 +78,24 @@ class MW_WP_Form_Field_Zip extends MW_WP_Form_Abstract_Form_Field {
|
|
77 |
}
|
78 |
|
79 |
/**
|
80 |
-
* Callback of add shortcode for confirm page
|
81 |
*
|
82 |
-
* @
|
83 |
-
* @param string $element_content
|
84 |
-
* @return string HTML
|
85 |
*/
|
86 |
protected function confirm_page() {
|
87 |
$value = $this->Data->get( $this->atts['name'] );
|
88 |
$separator = $this->Data->get_separator_value( $this->atts['name'] );
|
89 |
-
$_ret
|
90 |
-
$_ret
|
91 |
-
$_ret
|
92 |
return $_ret;
|
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 |
?>
|
@@ -125,10 +123,10 @@ class MW_WP_Form_Field_Zip extends MW_WP_Form_Abstract_Form_Field {
|
|
125 |
}
|
126 |
|
127 |
/**
|
128 |
-
* This form field is for Japanese environments only
|
129 |
*
|
130 |
-
* @param array $
|
131 |
-
* @return array
|
132 |
*/
|
133 |
public function _mwform_form_fields( array $form_fields ) {
|
134 |
$form_fields = parent::_mwform_form_fields( $form_fields );
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Field_Zip
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Field_Zip extends MW_WP_Form_Abstract_Form_Field {
|
12 |
|
13 |
/**
|
14 |
* Types of form type.
|
15 |
+
* input|select|button|input_button|error|other.
|
16 |
+
*
|
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
|
26 |
*/
|
27 |
protected function set_names() {
|
28 |
return array(
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* Set default attributes.
|
36 |
*
|
37 |
+
* @return array
|
38 |
*/
|
39 |
protected function set_defaults() {
|
40 |
return array(
|
41 |
+
'name' => '',
|
42 |
+
'class' => null,
|
43 |
+
'value' => '',
|
44 |
+
'show_error' => 'true',
|
45 |
'conv_half_alphanumeric' => 'true',
|
46 |
);
|
47 |
}
|
48 |
|
49 |
/**
|
50 |
+
* Callback of add shortcode for input page.
|
51 |
*
|
52 |
+
* @return string
|
|
|
|
|
53 |
*/
|
54 |
protected function input_page() {
|
55 |
$value = $this->Data->get_raw( $this->atts['name'] );
|
63 |
if ( 'true' !== $this->atts['conv_half_alphanumeric'] ) {
|
64 |
$conv_half_alphanumeric = null;
|
65 |
}
|
66 |
+
$_ret = $this->Form->zip(
|
67 |
+
$this->atts['name'],
|
68 |
+
array(
|
69 |
+
'class' => $this->atts['class'],
|
70 |
+
'conv-half-alphanumeric' => $conv_half_alphanumeric,
|
71 |
+
'value' => $value,
|
72 |
+
)
|
73 |
+
);
|
74 |
if ( 'false' !== $this->atts['show_error'] ) {
|
75 |
$_ret .= $this->get_error( $this->atts['name'] );
|
76 |
}
|
78 |
}
|
79 |
|
80 |
/**
|
81 |
+
* Callback of add shortcode for confirm page.
|
82 |
*
|
83 |
+
* @return string
|
|
|
|
|
84 |
*/
|
85 |
protected function confirm_page() {
|
86 |
$value = $this->Data->get( $this->atts['name'] );
|
87 |
$separator = $this->Data->get_separator_value( $this->atts['name'] );
|
88 |
+
$_ret = esc_html( $value );
|
89 |
+
$_ret .= $this->Form->hidden( $this->atts['name'] . '[data]', $value );
|
90 |
+
$_ret .= $this->Form->separator( $this->atts['name'], $separator );
|
91 |
return $_ret;
|
92 |
}
|
93 |
|
94 |
/**
|
95 |
+
* Display tag generator dialog.
|
96 |
+
* Overwrite required for each child class.
|
97 |
*
|
98 |
+
* @param array $options Options.
|
|
|
99 |
*/
|
100 |
public function mwform_tag_generator_dialog( array $options = array() ) {
|
101 |
?>
|
123 |
}
|
124 |
|
125 |
/**
|
126 |
+
* This form field is for Japanese environments only.
|
127 |
*
|
128 |
+
* @param array $form_fields Array of MW_WP_Form_Abstract_Form_Field.
|
129 |
+
* @return array
|
130 |
*/
|
131 |
public function _mwform_form_fields( array $form_fields ) {
|
132 |
$form_fields = parent::_mwform_form_fields( $form_fields );
|
classes/functions.php
CHANGED
@@ -1,20 +1,19 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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 ) {
|
@@ -22,9 +21,9 @@ class MWF_Functions {
|
|
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 ) {
|
@@ -32,19 +31,19 @@ class MWF_Functions {
|
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
-
* If the value is empty (0 is permitted)
|
36 |
*
|
37 |
-
* @param mixed
|
38 |
-
* @return
|
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 ) {
|
@@ -53,9 +52,9 @@ class MWF_Functions {
|
|
53 |
}
|
54 |
|
55 |
$wp_upload_dir = wp_upload_dir();
|
56 |
-
$baseurl
|
57 |
-
$fileurl
|
58 |
-
$filepath
|
59 |
$baseurl,
|
60 |
$wp_upload_dir['basedir'],
|
61 |
$fileurl
|
@@ -65,9 +64,9 @@ class MWF_Functions {
|
|
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 ) {
|
@@ -76,7 +75,7 @@ class MWF_Functions {
|
|
76 |
}
|
77 |
|
78 |
$wp_upload_dir = wp_upload_dir();
|
79 |
-
$fileurl
|
80 |
$wp_upload_dir['basedir'],
|
81 |
$wp_upload_dir['baseurl'],
|
82 |
$filepath
|
@@ -89,20 +88,20 @@ class MWF_Functions {
|
|
89 |
}
|
90 |
|
91 |
/**
|
92 |
-
* Unify line feed code to \n
|
93 |
*
|
94 |
-
* @param sring $string
|
95 |
-
* @return string
|
96 |
*/
|
97 |
public static function convert_eol( $string ) {
|
98 |
return preg_replace( "/\r\n|\r|\n/", "\n", $string );
|
99 |
}
|
100 |
|
101 |
/**
|
102 |
-
* Display deprecated error message
|
103 |
*
|
104 |
-
* @param string $function_name
|
105 |
-
* @param string $
|
106 |
*/
|
107 |
public static function deprecated_message( $function_name, $new_function = '' ) {
|
108 |
if ( ! defined( 'WP_DEBUG' ) || true !== WP_DEBUG || ! current_user_can( 'manage_options' ) ) {
|
@@ -118,7 +117,11 @@ class MWF_Functions {
|
|
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'] ) ) {
|
@@ -142,12 +145,22 @@ class MWF_Functions {
|
|
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 |
public static function _return_deprecated_message( $content = '' ) {
|
152 |
global $mwform_deprecated_message;
|
153 |
$content = $mwform_deprecated_message . $content;
|
@@ -156,12 +169,12 @@ class MWF_Functions {
|
|
156 |
}
|
157 |
|
158 |
/**
|
159 |
-
* Move files from Temp directory to upload directory
|
160 |
*
|
161 |
-
* @param string $filepath
|
162 |
-
* @param string $upload_dir Directory path of new file
|
163 |
-
* @param string $filename
|
164 |
-
* @return string
|
165 |
*/
|
166 |
public static function move_temp_file_to_upload_dir( $filepath, $upload_dir = '', $filename = '' ) {
|
167 |
$wp_upload_dir = wp_upload_dir();
|
@@ -170,7 +183,7 @@ class MWF_Functions {
|
|
170 |
$upload_dir = $wp_upload_dir['path'];
|
171 |
} else {
|
172 |
$upload_dir = trailingslashit( $wp_upload_dir['basedir'] ) . ltrim( $upload_dir, '/\\' );
|
173 |
-
|
174 |
}
|
175 |
|
176 |
if ( ! $filename ) {
|
@@ -179,14 +192,14 @@ class MWF_Functions {
|
|
179 |
|
180 |
if ( ! preg_match( '/(\..+?)$/', $filename ) ) {
|
181 |
$extension = pathinfo( $filepath, PATHINFO_EXTENSION );
|
182 |
-
$filename
|
183 |
}
|
184 |
$filename = sanitize_file_name( $filename );
|
185 |
$filename = wp_unique_filename( $upload_dir, $filename );
|
186 |
|
187 |
$new_filepath = trailingslashit( $upload_dir ) . $filename;
|
188 |
|
189 |
-
if ( $filepath
|
190 |
return $filepath;
|
191 |
}
|
192 |
|
@@ -203,11 +216,11 @@ class MWF_Functions {
|
|
203 |
}
|
204 |
|
205 |
/**
|
206 |
-
* Save attached file on media, save attachment key (array) in posting data
|
207 |
*
|
208 |
-
* @param int
|
209 |
-
* @param array $attachments
|
210 |
-
* @param int
|
211 |
* @return void
|
212 |
*/
|
213 |
public static function save_attachments_in_media( $saved_mail_id, $attachments, $form_id ) {
|
@@ -220,8 +233,7 @@ class MWF_Functions {
|
|
220 |
}
|
221 |
|
222 |
$wp_check_filetype = wp_check_filetype( $filepath );
|
223 |
-
|
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;
|
227 |
}
|
@@ -231,9 +243,7 @@ class MWF_Functions {
|
|
231 |
'post_status' => 'inherit',
|
232 |
'post_content' => __( 'Uploaded from ', 'mw-wp-form' ) . $post_type->label,
|
233 |
);
|
234 |
-
$attach_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 );
|
@@ -247,10 +257,10 @@ class MWF_Functions {
|
|
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 = '' ) {
|
@@ -276,7 +286,7 @@ class MWF_Functions {
|
|
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',
|
@@ -284,7 +294,7 @@ class MWF_Functions {
|
|
284 |
'video/x-msvideo',
|
285 |
);
|
286 |
break;
|
287 |
-
case 'mp3'
|
288 |
$wp_check_filetype['type'] = array(
|
289 |
'audio/mpeg3',
|
290 |
'audio/x-mpeg3',
|
@@ -293,20 +303,20 @@ class MWF_Functions {
|
|
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',
|
@@ -315,7 +325,7 @@ class MWF_Functions {
|
|
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',
|
@@ -328,7 +338,7 @@ class MWF_Functions {
|
|
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 {
|
@@ -342,14 +352,14 @@ class MWF_Functions {
|
|
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 ) {
|
351 |
$tracking_number_title = esc_html__( 'Tracking Number', 'mw-wp-form' );
|
352 |
-
$form_key
|
353 |
if ( $form_key ) {
|
354 |
$tracking_number_title = apply_filters(
|
355 |
'mwform_tracking_number_title_' . $form_key,
|
@@ -360,10 +370,10 @@ class MWF_Functions {
|
|
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
|
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,10 +385,10 @@ class MWF_Functions {
|
|
375 |
}
|
376 |
|
377 |
/**
|
378 |
-
* Return form key from form ID
|
379 |
*
|
380 |
-
* @param int $form_id
|
381 |
-
* @return string
|
382 |
*/
|
383 |
public static function get_form_key_from_form_id( $form_id ) {
|
384 |
if ( MWF_Functions::is_numeric( $form_id ) ) {
|
@@ -387,10 +397,10 @@ class MWF_Functions {
|
|
387 |
}
|
388 |
|
389 |
/**
|
390 |
-
* Return form ID from form key
|
391 |
*
|
392 |
-
* @param string $form_key
|
393 |
-
* @return int
|
394 |
*/
|
395 |
public static function get_form_id_from_form_key( $form_key ) {
|
396 |
if ( preg_match( '/^' . MWF_Config::NAME . '-(\d+)$/', $form_key, $reg ) ) {
|
@@ -399,10 +409,10 @@ class MWF_Functions {
|
|
399 |
}
|
400 |
|
401 |
/**
|
402 |
-
|
403 |
*
|
404 |
-
* @param int $form_id
|
405 |
-
* @return string
|
406 |
*/
|
407 |
public static function get_contact_data_post_type_from_form_id( $form_id ) {
|
408 |
if ( MWF_Functions::is_numeric( $form_id ) ) {
|
@@ -412,26 +422,26 @@ class MWF_Functions {
|
|
412 |
}
|
413 |
|
414 |
/**
|
415 |
-
* Whether the inquiry data post type
|
416 |
*
|
417 |
-
* @param string $post_type
|
418 |
-
* @return
|
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
|
429 |
*/
|
430 |
public static function get_multimedia_data( $value ) {
|
431 |
$mimetype = get_post_mime_type( $value );
|
432 |
if ( $mimetype ) {
|
433 |
-
|
434 |
-
|
435 |
$src_thumbnail = wp_get_attachment_image_src( $value, 'thumbnail' );
|
436 |
$src_full = wp_get_attachment_image_src( $value, 'full' );
|
437 |
return sprintf(
|
@@ -439,9 +449,8 @@ class MWF_Functions {
|
|
439 |
esc_url( $src_full[0] ),
|
440 |
esc_url( $src_thumbnail[0] )
|
441 |
);
|
442 |
-
}
|
443 |
-
|
444 |
-
else {
|
445 |
$src = wp_mime_type_icon( $mimetype );
|
446 |
return sprintf(
|
447 |
'<a href="%s" target="_blank"><img src="%s" alt="" style="height:32px" /></a>',
|
@@ -449,35 +458,36 @@ class MWF_Functions {
|
|
449 |
esc_url( $src )
|
450 |
);
|
451 |
}
|
452 |
-
}
|
453 |
-
|
454 |
-
else {
|
455 |
return esc_html( $value );
|
456 |
}
|
457 |
}
|
458 |
|
459 |
/**
|
460 |
-
* Return attachment file ID
|
461 |
-
*
|
462 |
*
|
463 |
-
* @param WP_Post $post
|
464 |
-
* @param int
|
465 |
* @return int
|
466 |
*/
|
467 |
public static function get_multimedia_id__fallback( $post, $meta_key ) {
|
468 |
-
$
|
469 |
-
$index
|
470 |
|
471 |
if ( false === $index ) {
|
472 |
return;
|
473 |
}
|
474 |
|
475 |
-
$attachments = get_posts(
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
|
|
|
|
481 |
|
482 |
if ( isset( $attachments[0] ) ) {
|
483 |
return $attachments[0]->ID;
|
@@ -485,9 +495,9 @@ class MWF_Functions {
|
|
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 ) {
|
@@ -508,10 +518,10 @@ class MWF_Functions {
|
|
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 ) {
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MWF_Functions
|
|
|
10 |
*/
|
11 |
class MWF_Functions {
|
12 |
|
13 |
/**
|
14 |
+
* Return true when the variable passed as an argument exists and the numeric value.
|
15 |
*
|
16 |
+
* @param variable $value Pass by reference.
|
17 |
* @return bool
|
18 |
*/
|
19 |
public static function is_numeric( &$value ) {
|
21 |
}
|
22 |
|
23 |
/**
|
24 |
+
* Delete empty element of array.
|
25 |
*
|
26 |
+
* @param array $array Array.
|
27 |
* @return array
|
28 |
*/
|
29 |
public static function array_clean( $array ) {
|
31 |
}
|
32 |
|
33 |
/**
|
34 |
+
* If the value is empty (0 is permitted).
|
35 |
*
|
36 |
+
* @param mixed $value Value.
|
37 |
+
* @return boolean
|
38 |
*/
|
39 |
public static function is_empty( $value ) {
|
40 |
return ( array() === $value || '' === $value || is_null( $value ) || false === $value );
|
41 |
}
|
42 |
|
43 |
/**
|
44 |
+
* Convert file URL to file path.
|
45 |
*
|
46 |
+
* @param string $fileurl File URL.
|
47 |
* @return string
|
48 |
*/
|
49 |
public static function fileurl_to_path( $fileurl ) {
|
52 |
}
|
53 |
|
54 |
$wp_upload_dir = wp_upload_dir();
|
55 |
+
$baseurl = preg_replace( '/^https?:\/\/(.+)$/', '$1', $wp_upload_dir['baseurl'] );
|
56 |
+
$fileurl = preg_replace( '/^https?:\/\/(.+)$/', '$1', $fileurl );
|
57 |
+
$filepath = str_replace(
|
58 |
$baseurl,
|
59 |
$wp_upload_dir['basedir'],
|
60 |
$fileurl
|
64 |
}
|
65 |
|
66 |
/**
|
67 |
+
* Convert file path to file URL.
|
68 |
*
|
69 |
+
* @param string $filepath File path.
|
70 |
* @return string
|
71 |
*/
|
72 |
public static function filepath_to_url( $filepath ) {
|
75 |
}
|
76 |
|
77 |
$wp_upload_dir = wp_upload_dir();
|
78 |
+
$fileurl = str_replace(
|
79 |
$wp_upload_dir['basedir'],
|
80 |
$wp_upload_dir['baseurl'],
|
81 |
$filepath
|
88 |
}
|
89 |
|
90 |
/**
|
91 |
+
* Unify line feed code to \n.
|
92 |
*
|
93 |
+
* @param sring $string String.
|
94 |
+
* @return string
|
95 |
*/
|
96 |
public static function convert_eol( $string ) {
|
97 |
return preg_replace( "/\r\n|\r|\n/", "\n", $string );
|
98 |
}
|
99 |
|
100 |
/**
|
101 |
+
* Display deprecated error message.
|
102 |
*
|
103 |
+
* @param string $function_name Function name.
|
104 |
+
* @param string $new_function New function name.
|
105 |
*/
|
106 |
public static function deprecated_message( $function_name, $new_function = '' ) {
|
107 |
if ( ! defined( 'WP_DEBUG' ) || true !== WP_DEBUG || ! current_user_can( 'manage_options' ) ) {
|
117 |
if ( $new_function ) {
|
118 |
$mwform_deprecated_message .= sprintf( 'You should use "<b>%s</b>". ', $new_function );
|
119 |
}
|
120 |
+
|
121 |
+
// phpcs:disable PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue.NeedsInspection
|
122 |
$debug_backtrace = debug_backtrace();
|
123 |
+
// phpcs:enable
|
124 |
+
|
125 |
array_shift( $debug_backtrace );
|
126 |
foreach ( $debug_backtrace as $value ) {
|
127 |
if ( isset( $value['file'], $value['line'] ) ) {
|
145 |
}
|
146 |
}
|
147 |
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
* Display deprecated message.
|
151 |
+
*/
|
152 |
protected static function _display_deprecated_message() {
|
153 |
global $mwform_deprecated_message;
|
154 |
$content = $mwform_deprecated_message;
|
155 |
unset( $mwform_deprecated_message );
|
156 |
echo $content;
|
157 |
}
|
158 |
+
|
159 |
+
/**
|
160 |
+
* Return deprecated message.
|
161 |
+
*
|
162 |
+
* @param string $content Content.
|
163 |
+
*/
|
164 |
public static function _return_deprecated_message( $content = '' ) {
|
165 |
global $mwform_deprecated_message;
|
166 |
$content = $mwform_deprecated_message . $content;
|
169 |
}
|
170 |
|
171 |
/**
|
172 |
+
* Move files from Temp directory to upload directory.
|
173 |
*
|
174 |
+
* @param string $filepath Path of temp file.
|
175 |
+
* @param string $upload_dir Directory path of new file.
|
176 |
+
* @param string $filename New fine name.
|
177 |
+
* @return string
|
178 |
*/
|
179 |
public static function move_temp_file_to_upload_dir( $filepath, $upload_dir = '', $filename = '' ) {
|
180 |
$wp_upload_dir = wp_upload_dir();
|
183 |
$upload_dir = $wp_upload_dir['path'];
|
184 |
} else {
|
185 |
$upload_dir = trailingslashit( $wp_upload_dir['basedir'] ) . ltrim( $upload_dir, '/\\' );
|
186 |
+
wp_mkdir_p( $upload_dir );
|
187 |
}
|
188 |
|
189 |
if ( ! $filename ) {
|
192 |
|
193 |
if ( ! preg_match( '/(\..+?)$/', $filename ) ) {
|
194 |
$extension = pathinfo( $filepath, PATHINFO_EXTENSION );
|
195 |
+
$filename = $filename . '.' . $extension;
|
196 |
}
|
197 |
$filename = sanitize_file_name( $filename );
|
198 |
$filename = wp_unique_filename( $upload_dir, $filename );
|
199 |
|
200 |
$new_filepath = trailingslashit( $upload_dir ) . $filename;
|
201 |
|
202 |
+
if ( $filepath === $new_filepath ) {
|
203 |
return $filepath;
|
204 |
}
|
205 |
|
216 |
}
|
217 |
|
218 |
/**
|
219 |
+
* Save attached file on media, save attachment key (array) in posting data.
|
220 |
*
|
221 |
+
* @param int $saved_mail_id Saved mail ID.
|
222 |
+
* @param array $attachments Attachments.
|
223 |
+
* @param int $form_id Form ID.
|
224 |
* @return void
|
225 |
*/
|
226 |
public static function save_attachments_in_media( $saved_mail_id, $attachments, $form_id ) {
|
233 |
}
|
234 |
|
235 |
$wp_check_filetype = wp_check_filetype( $filepath );
|
236 |
+
$post_type = get_post_type_object( self::get_contact_data_post_type_from_form_id( $form_id ) );
|
|
|
237 |
if ( empty( $post_type->label ) ) {
|
238 |
continue;
|
239 |
}
|
243 |
'post_status' => 'inherit',
|
244 |
'post_content' => __( 'Uploaded from ', 'mw-wp-form' ) . $post_type->label,
|
245 |
);
|
246 |
+
$attach_id = wp_insert_attachment( $attachment, $filepath, $saved_mail_id );
|
|
|
|
|
247 |
if ( $attach_id ) {
|
248 |
// 代わりにここで attachment_id を保存
|
249 |
update_post_meta( $saved_mail_id, $key, $attach_id );
|
257 |
}
|
258 |
|
259 |
/**
|
260 |
+
* Return true when correct file type.
|
261 |
*
|
262 |
+
* @param string $filepath Uploaded file path.
|
263 |
+
* @param string $filename File name.
|
264 |
* @return bool
|
265 |
*/
|
266 |
public static function check_file_type( $filepath, $filename = '' ) {
|
286 |
|
287 |
// For files have multi mime types
|
288 |
switch ( $wp_check_filetype['ext'] ) {
|
289 |
+
case 'avi':
|
290 |
$wp_check_filetype['type'] = array(
|
291 |
'application/x-troff-msvideo',
|
292 |
'video/avi',
|
294 |
'video/x-msvideo',
|
295 |
);
|
296 |
break;
|
297 |
+
case 'mp3':
|
298 |
$wp_check_filetype['type'] = array(
|
299 |
'audio/mpeg3',
|
300 |
'audio/x-mpeg3',
|
303 |
'audio/mpeg',
|
304 |
);
|
305 |
break;
|
306 |
+
case 'mpg':
|
307 |
$wp_check_filetype['type'] = array(
|
308 |
'audio/mpeg',
|
309 |
'video/mpeg',
|
310 |
);
|
311 |
break;
|
312 |
+
case 'docx':
|
313 |
$wp_check_filetype['type'] = array(
|
314 |
$wp_check_filetype['type'],
|
315 |
'application/zip',
|
316 |
'application/msword',
|
317 |
);
|
318 |
break;
|
319 |
+
case 'xlsx':
|
320 |
$wp_check_filetype['type'] = array(
|
321 |
$wp_check_filetype['type'],
|
322 |
'application/zip',
|
325 |
'application/vnd.ms-excel',
|
326 |
);
|
327 |
break;
|
328 |
+
case 'pptx':
|
329 |
$wp_check_filetype['type'] = array(
|
330 |
$wp_check_filetype['type'],
|
331 |
'application/zip',
|
338 |
|
339 |
$type = $finfo->file( $filepath );
|
340 |
if ( is_array( $wp_check_filetype['type'] ) ) {
|
341 |
+
if ( ! in_array( $type, $wp_check_filetype['type'], true ) ) {
|
342 |
return false;
|
343 |
}
|
344 |
} else {
|
352 |
}
|
353 |
|
354 |
/**
|
355 |
+
* Return display name of the tracking number.
|
356 |
*
|
357 |
+
* @param string $post_type Post type of inquiry data.
|
358 |
* @return string
|
359 |
*/
|
360 |
public static function get_tracking_number_title( $post_type ) {
|
361 |
$tracking_number_title = esc_html__( 'Tracking Number', 'mw-wp-form' );
|
362 |
+
$form_key = self::contact_data_post_type_to_form_key( $post_type );
|
363 |
if ( $form_key ) {
|
364 |
$tracking_number_title = apply_filters(
|
365 |
'mwform_tracking_number_title_' . $form_key,
|
370 |
}
|
371 |
|
372 |
/**
|
373 |
+
* Return form key from inquiry data post type.
|
374 |
*
|
375 |
+
* @param string $post_type Post type of inquiry data.
|
376 |
+
* @return string|null
|
377 |
*/
|
378 |
public static function contact_data_post_type_to_form_key( $post_type ) {
|
379 |
if ( self::is_contact_data_post_type( $post_type ) ) {
|
385 |
}
|
386 |
|
387 |
/**
|
388 |
+
* Return form key from form ID.
|
389 |
*
|
390 |
+
* @param int $form_id Form ID.
|
391 |
+
* @return string
|
392 |
*/
|
393 |
public static function get_form_key_from_form_id( $form_id ) {
|
394 |
if ( MWF_Functions::is_numeric( $form_id ) ) {
|
397 |
}
|
398 |
|
399 |
/**
|
400 |
+
* Return form ID from form key.
|
401 |
*
|
402 |
+
* @param string $form_key Form key.
|
403 |
+
* @return int
|
404 |
*/
|
405 |
public static function get_form_id_from_form_key( $form_key ) {
|
406 |
if ( preg_match( '/^' . MWF_Config::NAME . '-(\d+)$/', $form_key, $reg ) ) {
|
409 |
}
|
410 |
|
411 |
/**
|
412 |
+
* Return inquiry data post type from form ID.
|
413 |
*
|
414 |
+
* @param int $form_id Form ID.
|
415 |
+
* @return string
|
416 |
*/
|
417 |
public static function get_contact_data_post_type_from_form_id( $form_id ) {
|
418 |
if ( MWF_Functions::is_numeric( $form_id ) ) {
|
422 |
}
|
423 |
|
424 |
/**
|
425 |
+
* Whether the inquiry data post type.
|
426 |
*
|
427 |
+
* @param string $post_type Post type name.
|
428 |
+
* @return boolean
|
429 |
*/
|
430 |
public static function is_contact_data_post_type( $post_type ) {
|
431 |
return (bool) ( preg_match( '/^' . MWF_Config::DBDATA . '\d+$/', $post_type ) );
|
432 |
}
|
433 |
|
434 |
/**
|
435 |
+
* Return converting attached data to appropriate HTML.
|
436 |
*
|
437 |
+
* @param string $value Post ID or not.
|
438 |
* @return string
|
439 |
*/
|
440 |
public static function get_multimedia_data( $value ) {
|
441 |
$mimetype = get_post_mime_type( $value );
|
442 |
if ( $mimetype ) {
|
443 |
+
if ( in_array( $mimetype, array( 'image/jpeg', 'image/gif', 'image/png', 'image/bmp' ), true ) ) {
|
444 |
+
// Image
|
445 |
$src_thumbnail = wp_get_attachment_image_src( $value, 'thumbnail' );
|
446 |
$src_full = wp_get_attachment_image_src( $value, 'full' );
|
447 |
return sprintf(
|
449 |
esc_url( $src_full[0] ),
|
450 |
esc_url( $src_thumbnail[0] )
|
451 |
);
|
452 |
+
} else {
|
453 |
+
// Other
|
|
|
454 |
$src = wp_mime_type_icon( $mimetype );
|
455 |
return sprintf(
|
456 |
'<a href="%s" target="_blank"><img src="%s" alt="" style="height:32px" /></a>',
|
458 |
esc_url( $src )
|
459 |
);
|
460 |
}
|
461 |
+
} else {
|
462 |
+
// Attached, but $value is not file ID because changed meta data by hook
|
|
|
463 |
return esc_html( $value );
|
464 |
}
|
465 |
}
|
466 |
|
467 |
/**
|
468 |
+
* Return attachment file ID.
|
469 |
+
* 過去バージョンでの不具合でアップロードファイルを示すメタデータが空になっていることがあるのでその場合の代替処理.
|
470 |
*
|
471 |
+
* @param WP_Post $post WP_Post object.
|
472 |
+
* @param int $meta_key Meta data name.
|
473 |
* @return int
|
474 |
*/
|
475 |
public static function get_multimedia_id__fallback( $post, $meta_key ) {
|
476 |
+
$contact_data_setting = new MW_WP_Form_Contact_Data_Setting( $post->ID );
|
477 |
+
$index = $contact_data_setting->get_index_of_key_in_upload_file_keys( $meta_key );
|
478 |
|
479 |
if ( false === $index ) {
|
480 |
return;
|
481 |
}
|
482 |
|
483 |
+
$attachments = get_posts(
|
484 |
+
array(
|
485 |
+
'post_type' => 'attachment',
|
486 |
+
'post_parent' => $post->ID,
|
487 |
+
'posts_per_page' => 1,
|
488 |
+
'offset' => $index,
|
489 |
+
)
|
490 |
+
);
|
491 |
|
492 |
if ( isset( $attachments[0] ) ) {
|
493 |
return $attachments[0]->ID;
|
495 |
}
|
496 |
|
497 |
/**
|
498 |
+
* Enqueue MW WP Form assets.
|
499 |
*
|
500 |
+
* @param int $form_id Form ID.
|
501 |
* @return void
|
502 |
*/
|
503 |
public static function mwform_enqueue_scripts( $form_id ) {
|
518 |
}
|
519 |
|
520 |
/**
|
521 |
+
* Generate input field's attribute and attribute value pair.
|
522 |
*
|
523 |
+
* @param string $attribute_name Attribute name.
|
524 |
+
* @param string $attribute_value Attribute value.
|
525 |
* @return string
|
526 |
*/
|
527 |
public static function generate_input_attribute( $attribute_name, $attribute_value ) {
|
classes/models/class.admin.php
CHANGED
@@ -1,36 +1,37 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
18 |
*/
|
19 |
public function get_forms() {
|
20 |
-
return get_posts(
|
21 |
-
|
22 |
-
|
23 |
-
|
|
|
|
|
24 |
}
|
25 |
|
26 |
/**
|
27 |
-
* Return forms that using database
|
28 |
*
|
29 |
-
* @return array
|
30 |
*/
|
31 |
public function get_forms_using_database() {
|
32 |
$forms_using_database = array();
|
33 |
-
$forms
|
34 |
foreach ( $forms as $form ) {
|
35 |
$Setting = new MW_WP_Form_Setting( $form->ID );
|
36 |
if ( ! $Setting->get( 'usedb' ) ) {
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Admin
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Admin {
|
12 |
|
13 |
/**
|
14 |
+
* Return all forms.
|
15 |
*
|
16 |
+
* @return array
|
17 |
*/
|
18 |
public function get_forms() {
|
19 |
+
return get_posts(
|
20 |
+
array(
|
21 |
+
'post_type' => MWF_Config::NAME,
|
22 |
+
'posts_per_page' => -1,
|
23 |
+
)
|
24 |
+
);
|
25 |
}
|
26 |
|
27 |
/**
|
28 |
+
* Return forms that using database.
|
29 |
*
|
30 |
+
* @return array
|
31 |
*/
|
32 |
public function get_forms_using_database() {
|
33 |
$forms_using_database = array();
|
34 |
+
$forms = $this->get_forms();
|
35 |
foreach ( $forms as $form ) {
|
36 |
$Setting = new MW_WP_Form_Setting( $form->ID );
|
37 |
if ( ! $Setting->get( 'usedb' ) ) {
|
classes/models/class.akismet.php
CHANGED
@@ -1,13 +1,12 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
10 |
-
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
*/
|
12 |
class MW_WP_Form_Akismet {
|
13 |
|
@@ -29,12 +28,12 @@ class MW_WP_Form_Akismet {
|
|
29 |
}
|
30 |
|
31 |
/**
|
32 |
-
* Return true when through akismet check
|
33 |
*
|
34 |
-
* @param string
|
35 |
-
* @param string
|
36 |
-
* @param string
|
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 ) {
|
@@ -48,20 +47,20 @@ class MW_WP_Form_Akismet {
|
|
48 |
|
49 |
$author = '';
|
50 |
if ( $Data->get_post_value_by_key( $akismet_author ) ) {
|
51 |
-
$author
|
52 |
$doAkismet = true;
|
53 |
}
|
54 |
|
55 |
$author_email = '';
|
56 |
if ( $Data->get_post_value_by_key( $akismet_author_email ) ) {
|
57 |
$author_email = $Data->get_post_value_by_key( $akismet_author_email );
|
58 |
-
$doAkismet
|
59 |
}
|
60 |
|
61 |
$author_url = '';
|
62 |
if ( $Data->get_post_value_by_key( $akismet_author_url ) ) {
|
63 |
$author_url = $Data->get_post_value_by_key( $akismet_author_url );
|
64 |
-
$doAkismet
|
65 |
}
|
66 |
|
67 |
if ( ! $doAkismet ) {
|
@@ -85,14 +84,24 @@ class MW_WP_Form_Akismet {
|
|
85 |
$akismet['referrer'] = $_SERVER['HTTP_REFERER'];
|
86 |
$akismet['comment_type'] = MWF_Config::NAME;
|
87 |
|
88 |
-
if ( $permalink )
|
89 |
-
|
90 |
-
|
91 |
-
if ( $
|
92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
@@ -104,7 +113,8 @@ class MW_WP_Form_Akismet {
|
|
104 |
} else {
|
105 |
$response = akismet_http_post(
|
106 |
$query_string,
|
107 |
-
$akismet_api_host,
|
|
|
108 |
$akismet_api_port
|
109 |
);
|
110 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Akismet
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Akismet {
|
12 |
|
28 |
}
|
29 |
|
30 |
/**
|
31 |
+
* Return true when through akismet check.
|
32 |
*
|
33 |
+
* @param string $akismet_author Akismet author.
|
34 |
+
* @param string $akismet_author_email Akismet author e-mail.
|
35 |
+
* @param string $akismet_author_url Akismet author url.
|
36 |
+
* @param MW_WP_Form_Data $Data MW_WP_Form_Data object.
|
37 |
* @return bool
|
38 |
*/
|
39 |
public function is_valid( $akismet_author, $akismet_author_email, $akismet_author_url, $Data ) {
|
47 |
|
48 |
$author = '';
|
49 |
if ( $Data->get_post_value_by_key( $akismet_author ) ) {
|
50 |
+
$author = $Data->get_post_value_by_key( $akismet_author );
|
51 |
$doAkismet = true;
|
52 |
}
|
53 |
|
54 |
$author_email = '';
|
55 |
if ( $Data->get_post_value_by_key( $akismet_author_email ) ) {
|
56 |
$author_email = $Data->get_post_value_by_key( $akismet_author_email );
|
57 |
+
$doAkismet = true;
|
58 |
}
|
59 |
|
60 |
$author_url = '';
|
61 |
if ( $Data->get_post_value_by_key( $akismet_author_url ) ) {
|
62 |
$author_url = $Data->get_post_value_by_key( $akismet_author_url );
|
63 |
+
$doAkismet = true;
|
64 |
}
|
65 |
|
66 |
if ( ! $doAkismet ) {
|
84 |
$akismet['referrer'] = $_SERVER['HTTP_REFERER'];
|
85 |
$akismet['comment_type'] = MWF_Config::NAME;
|
86 |
|
87 |
+
if ( $permalink ) {
|
88 |
+
$akismet['permalink'] = $permalink;
|
89 |
+
}
|
90 |
+
if ( $author ) {
|
91 |
+
$akismet['comment_author'] = $author;
|
92 |
+
}
|
93 |
+
if ( $author_email ) {
|
94 |
+
$akismet['comment_author_email'] = $author_email;
|
95 |
+
}
|
96 |
+
if ( $author_url ) {
|
97 |
+
$akismet['comment_author_url'] = $author_url;
|
98 |
+
}
|
99 |
+
if ( $content ) {
|
100 |
+
$akismet['comment_content'] = $content;
|
101 |
+
}
|
102 |
|
103 |
foreach ( $_SERVER as $key => $value ) {
|
104 |
+
if ( in_array( $key, array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' ), true ) ) {
|
105 |
continue;
|
106 |
}
|
107 |
$akismet[ $key ] = $value;
|
113 |
} else {
|
114 |
$response = akismet_http_post(
|
115 |
$query_string,
|
116 |
+
$akismet_api_host,
|
117 |
+
'/1.1/comment-check',
|
118 |
$akismet_api_port
|
119 |
);
|
120 |
}
|
classes/models/class.contact-data-setting.php
CHANGED
@@ -1,48 +1,54 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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 |
-
* Sended mail to
|
|
|
34 |
* @var string
|
35 |
*/
|
36 |
protected $admin_mail_to;
|
37 |
|
38 |
/**
|
39 |
-
* Memo
|
|
|
40 |
* @var string
|
41 |
*/
|
42 |
protected $memo = '';
|
43 |
|
44 |
/**
|
45 |
-
*
|
|
|
|
|
46 |
*/
|
47 |
public function __construct( $post_id ) {
|
48 |
if ( ! MWF_Functions::is_contact_data_post_type( get_post_type( $post_id ) ) ) {
|
@@ -72,7 +78,7 @@ class MW_WP_Form_Contact_Data_Setting {
|
|
72 |
}
|
73 |
|
74 |
/**
|
75 |
-
* Return statuses
|
76 |
*
|
77 |
* @return array
|
78 |
*/
|
@@ -89,24 +95,24 @@ class MW_WP_Form_Contact_Data_Setting {
|
|
89 |
}
|
90 |
|
91 |
/**
|
92 |
-
* Return updatable keys
|
93 |
*
|
94 |
* @return array
|
95 |
*/
|
96 |
public function get_permit_keys() {
|
97 |
$vars = get_object_vars( $this );
|
98 |
-
unset( $vars[
|
99 |
-
unset( $vars[
|
100 |
return array_keys( $vars );
|
101 |
}
|
102 |
|
103 |
/**
|
104 |
-
* Return all data
|
105 |
*
|
106 |
* @return array
|
107 |
*/
|
108 |
public function gets() {
|
109 |
-
$options
|
110 |
$permit_keys = $this->get_permit_keys();
|
111 |
foreach ( $permit_keys as $permit_key ) {
|
112 |
$options[ $permit_key ] = $this->$permit_key;
|
@@ -115,9 +121,9 @@ class MW_WP_Form_Contact_Data_Setting {
|
|
115 |
}
|
116 |
|
117 |
/**
|
118 |
-
* Return specify data
|
119 |
*
|
120 |
-
* @param string $key
|
121 |
* @return mixed|null
|
122 |
*/
|
123 |
public function get( $key ) {
|
@@ -125,7 +131,7 @@ class MW_WP_Form_Contact_Data_Setting {
|
|
125 |
unset( $vars['options'] );
|
126 |
$attributes = array_keys( $vars );
|
127 |
|
128 |
-
if ( in_array( $key, $attributes ) ) {
|
129 |
if ( 'response_status' === $key ) {
|
130 |
$response_statuses = $this->get_response_statuses();
|
131 |
if ( isset( $response_statuses[ $this->response_status ] ) ) {
|
@@ -141,15 +147,14 @@ class MW_WP_Form_Contact_Data_Setting {
|
|
141 |
}
|
142 |
|
143 |
/**
|
144 |
-
* Set a option
|
145 |
*
|
146 |
-
* @param string $key
|
147 |
-
* @param mixed
|
148 |
-
* @return void
|
149 |
*/
|
150 |
public function set( $key, $value ) {
|
151 |
$permit_keys = $this->get_permit_keys();
|
152 |
-
if ( ! in_array( $key, $permit_keys ) ) {
|
153 |
$this->options[ $key ] = $value;
|
154 |
return;
|
155 |
}
|
@@ -167,10 +172,9 @@ class MW_WP_Form_Contact_Data_Setting {
|
|
167 |
}
|
168 |
|
169 |
/**
|
170 |
-
* Set options
|
171 |
*
|
172 |
-
* @param array $values
|
173 |
-
* @return void
|
174 |
*/
|
175 |
public function sets( array $values ) {
|
176 |
foreach ( $values as $key => $value ) {
|
@@ -179,9 +183,7 @@ class MW_WP_Form_Contact_Data_Setting {
|
|
179 |
}
|
180 |
|
181 |
/**
|
182 |
-
* Save values of permit keys and options
|
183 |
-
*
|
184 |
-
* @return void
|
185 |
*/
|
186 |
public function save() {
|
187 |
$permit_keys = $this->get_permit_keys();
|
@@ -203,21 +205,21 @@ class MW_WP_Form_Contact_Data_Setting {
|
|
203 |
}
|
204 |
|
205 |
/**
|
206 |
-
* Return post types of inquiry data
|
207 |
*
|
208 |
* @return array
|
209 |
*/
|
210 |
public static function get_form_post_types() {
|
211 |
$contact_data_post_types = array();
|
212 |
-
$Admin
|
213 |
-
$forms
|
214 |
foreach ( $forms as $form ) {
|
215 |
-
$post_type
|
216 |
$contact_data_post_types[] = $post_type;
|
217 |
}
|
218 |
|
219 |
-
$raw_post_types
|
220 |
-
$new_post_types
|
221 |
$contact_data_post_types = apply_filters(
|
222 |
'mwform_contact_data_post_types',
|
223 |
$contact_data_post_types
|
@@ -225,7 +227,7 @@ class MW_WP_Form_Contact_Data_Setting {
|
|
225 |
|
226 |
// もともとの配列に含まれていない値は削除する
|
227 |
foreach ( $contact_data_post_types as $post_type ) {
|
228 |
-
if ( in_array( $post_type, $raw_post_types ) ) {
|
229 |
$new_post_types[] = $post_type;
|
230 |
}
|
231 |
}
|
@@ -233,6 +235,13 @@ class MW_WP_Form_Contact_Data_Setting {
|
|
233 |
return $new_post_types;
|
234 |
}
|
235 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
236 |
public static function get_posts() {
|
237 |
MWF_Functions::deprecated_message(
|
238 |
'MW_WP_Form_Contact_Data_Setting::get_posts()',
|
@@ -243,34 +252,34 @@ class MW_WP_Form_Contact_Data_Setting {
|
|
243 |
}
|
244 |
|
245 |
/**
|
246 |
-
* Return true if $meta_key is upload_file_key
|
247 |
*
|
248 |
-
* @param string $meta_key
|
249 |
* @return bool
|
250 |
*/
|
251 |
public function is_upload_file_key( $meta_key ) {
|
252 |
$upload_file_keys = $this->_get_upload_file_keys();
|
253 |
-
return ( is_array( $upload_file_keys ) && in_array( $meta_key, $upload_file_keys ) );
|
254 |
}
|
255 |
|
256 |
/**
|
257 |
-
* Return index when $meta_key is included in upload_file_key
|
258 |
*
|
259 |
-
* @param string $meta_key
|
260 |
* @return int|false
|
261 |
*/
|
262 |
public function get_index_of_key_in_upload_file_keys( $meta_key ) {
|
263 |
$upload_file_keys = $this->_get_upload_file_keys();
|
264 |
if ( is_array( $upload_file_keys ) ) {
|
265 |
-
return array_search( $meta_key, $upload_file_keys );
|
266 |
}
|
267 |
return false;
|
268 |
}
|
269 |
|
270 |
/**
|
271 |
-
* Return the upload_file_key that the post has
|
272 |
*
|
273 |
-
* @return array
|
274 |
*/
|
275 |
protected function _get_upload_file_keys() {
|
276 |
// 前のバージョンでは MWF_Config::UPLOAD_FILE_KEYS を配列で保持していなかったので分岐させる
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Contact_Data_Setting
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Contact_Data_Setting {
|
12 |
|
13 |
/**
|
14 |
+
* Inquiry data ID.
|
15 |
+
*
|
16 |
* @var int
|
17 |
*/
|
18 |
protected $post_id;
|
19 |
|
20 |
/**
|
21 |
+
* Array of posted data.
|
22 |
+
*
|
23 |
* @var array
|
24 |
*/
|
25 |
protected $options = array();
|
26 |
|
27 |
/**
|
28 |
+
* Status of inquiry data.
|
29 |
+
*
|
30 |
* @var string not-supported|reservation|supported
|
31 |
*/
|
32 |
protected $response_status = 'not-supported';
|
33 |
|
34 |
/**
|
35 |
+
* Sended mail to.
|
36 |
+
*
|
37 |
* @var string
|
38 |
*/
|
39 |
protected $admin_mail_to;
|
40 |
|
41 |
/**
|
42 |
+
* Memo.
|
43 |
+
*
|
44 |
* @var string
|
45 |
*/
|
46 |
protected $memo = '';
|
47 |
|
48 |
/**
|
49 |
+
* Constructor.
|
50 |
+
*
|
51 |
+
* @param int $post_id Post ID.
|
52 |
*/
|
53 |
public function __construct( $post_id ) {
|
54 |
if ( ! MWF_Functions::is_contact_data_post_type( get_post_type( $post_id ) ) ) {
|
78 |
}
|
79 |
|
80 |
/**
|
81 |
+
* Return statuses.
|
82 |
*
|
83 |
* @return array
|
84 |
*/
|
95 |
}
|
96 |
|
97 |
/**
|
98 |
+
* Return updatable keys.
|
99 |
*
|
100 |
* @return array
|
101 |
*/
|
102 |
public function get_permit_keys() {
|
103 |
$vars = get_object_vars( $this );
|
104 |
+
unset( $vars['post_id'] );
|
105 |
+
unset( $vars['options'] );
|
106 |
return array_keys( $vars );
|
107 |
}
|
108 |
|
109 |
/**
|
110 |
+
* Return all data.
|
111 |
*
|
112 |
* @return array
|
113 |
*/
|
114 |
public function gets() {
|
115 |
+
$options = $this->options;
|
116 |
$permit_keys = $this->get_permit_keys();
|
117 |
foreach ( $permit_keys as $permit_key ) {
|
118 |
$options[ $permit_key ] = $this->$permit_key;
|
121 |
}
|
122 |
|
123 |
/**
|
124 |
+
* Return specify data.
|
125 |
*
|
126 |
+
* @param string $key Meta data name.
|
127 |
* @return mixed|null
|
128 |
*/
|
129 |
public function get( $key ) {
|
131 |
unset( $vars['options'] );
|
132 |
$attributes = array_keys( $vars );
|
133 |
|
134 |
+
if ( in_array( $key, $attributes, true ) ) {
|
135 |
if ( 'response_status' === $key ) {
|
136 |
$response_statuses = $this->get_response_statuses();
|
137 |
if ( isset( $response_statuses[ $this->response_status ] ) ) {
|
147 |
}
|
148 |
|
149 |
/**
|
150 |
+
* Set a option.
|
151 |
*
|
152 |
+
* @param string $key Meta data name.
|
153 |
+
* @param mixed $value Value.
|
|
|
154 |
*/
|
155 |
public function set( $key, $value ) {
|
156 |
$permit_keys = $this->get_permit_keys();
|
157 |
+
if ( ! in_array( $key, $permit_keys, true ) ) {
|
158 |
$this->options[ $key ] = $value;
|
159 |
return;
|
160 |
}
|
172 |
}
|
173 |
|
174 |
/**
|
175 |
+
* Set options.
|
176 |
*
|
177 |
+
* @param array $values Values.
|
|
|
178 |
*/
|
179 |
public function sets( array $values ) {
|
180 |
foreach ( $values as $key => $value ) {
|
183 |
}
|
184 |
|
185 |
/**
|
186 |
+
* Save values of permit keys and options.
|
|
|
|
|
187 |
*/
|
188 |
public function save() {
|
189 |
$permit_keys = $this->get_permit_keys();
|
205 |
}
|
206 |
|
207 |
/**
|
208 |
+
* Return post types of inquiry data.
|
209 |
*
|
210 |
* @return array
|
211 |
*/
|
212 |
public static function get_form_post_types() {
|
213 |
$contact_data_post_types = array();
|
214 |
+
$Admin = new MW_WP_Form_Admin();
|
215 |
+
$forms = $Admin->get_forms_using_database();
|
216 |
foreach ( $forms as $form ) {
|
217 |
+
$post_type = MWF_Functions::get_contact_data_post_type_from_form_id( $form->ID );
|
218 |
$contact_data_post_types[] = $post_type;
|
219 |
}
|
220 |
|
221 |
+
$raw_post_types = $contact_data_post_types;
|
222 |
+
$new_post_types = array();
|
223 |
$contact_data_post_types = apply_filters(
|
224 |
'mwform_contact_data_post_types',
|
225 |
$contact_data_post_types
|
227 |
|
228 |
// もともとの配列に含まれていない値は削除する
|
229 |
foreach ( $contact_data_post_types as $post_type ) {
|
230 |
+
if ( in_array( $post_type, $raw_post_types, true ) ) {
|
231 |
$new_post_types[] = $post_type;
|
232 |
}
|
233 |
}
|
235 |
return $new_post_types;
|
236 |
}
|
237 |
|
238 |
+
/**
|
239 |
+
* Return post types of inquiry data.
|
240 |
+
*
|
241 |
+
* @deprecated
|
242 |
+
*
|
243 |
+
* @return array
|
244 |
+
*/
|
245 |
public static function get_posts() {
|
246 |
MWF_Functions::deprecated_message(
|
247 |
'MW_WP_Form_Contact_Data_Setting::get_posts()',
|
252 |
}
|
253 |
|
254 |
/**
|
255 |
+
* Return true if $meta_key is upload_file_key.
|
256 |
*
|
257 |
+
* @param string $meta_key Meta data name.
|
258 |
* @return bool
|
259 |
*/
|
260 |
public function is_upload_file_key( $meta_key ) {
|
261 |
$upload_file_keys = $this->_get_upload_file_keys();
|
262 |
+
return ( is_array( $upload_file_keys ) && in_array( $meta_key, $upload_file_keys, true ) );
|
263 |
}
|
264 |
|
265 |
/**
|
266 |
+
* Return index when $meta_key is included in upload_file_key.
|
267 |
*
|
268 |
+
* @param string $meta_key Meta data name.
|
269 |
* @return int|false
|
270 |
*/
|
271 |
public function get_index_of_key_in_upload_file_keys( $meta_key ) {
|
272 |
$upload_file_keys = $this->_get_upload_file_keys();
|
273 |
if ( is_array( $upload_file_keys ) ) {
|
274 |
+
return array_search( $meta_key, $upload_file_keys, true );
|
275 |
}
|
276 |
return false;
|
277 |
}
|
278 |
|
279 |
/**
|
280 |
+
* Return the upload_file_key that the post has.
|
281 |
*
|
282 |
+
* @return array
|
283 |
*/
|
284 |
protected function _get_upload_file_keys() {
|
285 |
// 前のバージョンでは MWF_Config::UPLOAD_FILE_KEYS を配列で保持していなかったので分岐させる
|
classes/models/class.csv.php
CHANGED
@@ -1,13 +1,12 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
10 |
-
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
*/
|
12 |
class MW_WP_Form_CSV {
|
13 |
|
@@ -16,14 +15,17 @@ class MW_WP_Form_CSV {
|
|
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';
|
@@ -34,7 +36,7 @@ class MW_WP_Form_CSV {
|
|
34 |
|
35 |
$csv = $this->_generate_csv();
|
36 |
|
37 |
-
$file_name = 'mw_wp_form_' .
|
38 |
header( 'Content-Type: application/octet-stream' );
|
39 |
header( 'Content-Disposition: attachment; filename=' . $file_name );
|
40 |
echo $csv;
|
@@ -42,9 +44,9 @@ class MW_WP_Form_CSV {
|
|
42 |
}
|
43 |
|
44 |
/**
|
45 |
-
* Generate CSV
|
46 |
*
|
47 |
-
* @return string
|
48 |
*/
|
49 |
protected function _generate_csv() {
|
50 |
$posts_per_page = $this->_get_posts_per_page();
|
@@ -54,12 +56,15 @@ class MW_WP_Form_CSV {
|
|
54 |
if ( empty( $args ) || ! is_array( $args ) ) {
|
55 |
$args = array();
|
56 |
}
|
57 |
-
$args = array_merge(
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
|
|
|
|
|
|
63 |
|
64 |
$posts_mwf = get_posts( $args );
|
65 |
|
@@ -67,13 +72,14 @@ class MW_WP_Form_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 $
|
77 |
foreach ( $row as $column_name => $column ) {
|
78 |
$row[ $column_name ] = $this->_escape_double_quote( $column );
|
79 |
}
|
@@ -85,7 +91,7 @@ class MW_WP_Form_CSV {
|
|
85 |
}
|
86 |
|
87 |
/**
|
88 |
-
* Return number of CSV output
|
89 |
*
|
90 |
* @return int
|
91 |
*/
|
@@ -104,7 +110,7 @@ class MW_WP_Form_CSV {
|
|
104 |
}
|
105 |
|
106 |
/**
|
107 |
-
* Return page number of CSV output
|
108 |
*
|
109 |
* @return int
|
110 |
*/
|
@@ -119,13 +125,13 @@ class MW_WP_Form_CSV {
|
|
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
|
129 |
'ID' => 'ID',
|
130 |
'admin_mail_to' => __( 'Admin Email To', 'mw-wp-form' ),
|
131 |
'response_status' => __( 'Response Status', 'mw-wp-form' ),
|
@@ -156,17 +162,17 @@ class MW_WP_Form_CSV {
|
|
156 |
|
157 |
ksort( $_columns );
|
158 |
$_columns = apply_filters( 'mwform_inquiry_data_columns-' . $this->post_type, $_columns );
|
159 |
-
$columns
|
160 |
-
$columns
|
161 |
-
$columns
|
162 |
return $columns;
|
163 |
}
|
164 |
|
165 |
/**
|
166 |
-
* Generate rows of CSV
|
167 |
*
|
168 |
-
* @param array $posts
|
169 |
-
* @param array $headings
|
170 |
* @return array
|
171 |
*/
|
172 |
protected function _get_rows( array $posts, array $headings ) {
|
@@ -177,30 +183,30 @@ class MW_WP_Form_CSV {
|
|
177 |
setup_postdata( $post );
|
178 |
$columns = array();
|
179 |
foreach ( $headings as $key => $value ) {
|
180 |
-
$
|
181 |
-
$response_statuses = $
|
182 |
-
$column
|
183 |
|
184 |
if ( 'response_status' === $key ) {
|
185 |
-
$response_status = $
|
186 |
-
$column
|
187 |
} elseif ( 'admin_mail_to' === $key ) {
|
188 |
-
$column = $
|
189 |
} elseif ( 'memo' === $key ) {
|
190 |
-
$column = $
|
191 |
-
} elseif ( MWF_Config::TRACKINGNUMBER === $key) {
|
192 |
$column = get_post_meta( get_the_ID(), MWF_Config::TRACKINGNUMBER, true );
|
193 |
} elseif ( isset( $post->$key ) ) {
|
194 |
$post_meta = $post->$key;
|
195 |
|
196 |
-
if ( $
|
197 |
// 過去バージョンでの不具合でメタデータが空になっていることがあるのでその場合は代替処理
|
198 |
if ( '' === $post_meta ) {
|
199 |
$post_meta = MWF_Functions::get_multimedia_id__fallback( $post, $key );
|
200 |
}
|
201 |
$column = wp_get_attachment_url( $post_meta );
|
202 |
} else {
|
203 |
-
$column = ( '' === $post_meta || null === $post_meta || false === $post_meta ) ?
|
204 |
}
|
205 |
}
|
206 |
$columns[ $key ] = $column;
|
@@ -212,9 +218,9 @@ class MW_WP_Form_CSV {
|
|
212 |
}
|
213 |
|
214 |
/**
|
215 |
-
* Escape double quotes
|
216 |
*
|
217 |
-
* @param string $value
|
218 |
* @return string
|
219 |
*/
|
220 |
protected function _escape_double_quote( $value ) {
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_CSV
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_CSV {
|
12 |
|
15 |
*/
|
16 |
protected $post_type;
|
17 |
|
18 |
+
/**
|
19 |
+
* Constructor.
|
20 |
+
*
|
21 |
+
* @param string $post_type Post type name.
|
22 |
+
*/
|
23 |
public function __construct( $post_type ) {
|
24 |
$this->post_type = $post_type;
|
25 |
}
|
26 |
|
27 |
/**
|
28 |
+
* Download CSV.
|
|
|
|
|
29 |
*/
|
30 |
public function download() {
|
31 |
$key_of_csv_download = MWF_Config::NAME . '-csv-download';
|
36 |
|
37 |
$csv = $this->_generate_csv();
|
38 |
|
39 |
+
$file_name = 'mw_wp_form_' . date_i18n( 'YmdHis' ) . '.csv';
|
40 |
header( 'Content-Type: application/octet-stream' );
|
41 |
header( 'Content-Disposition: attachment; filename=' . $file_name );
|
42 |
echo $csv;
|
44 |
}
|
45 |
|
46 |
/**
|
47 |
+
* Generate CSV.
|
48 |
*
|
49 |
+
* @return string
|
50 |
*/
|
51 |
protected function _generate_csv() {
|
52 |
$posts_per_page = $this->_get_posts_per_page();
|
56 |
if ( empty( $args ) || ! is_array( $args ) ) {
|
57 |
$args = array();
|
58 |
}
|
59 |
+
$args = array_merge(
|
60 |
+
$args,
|
61 |
+
array(
|
62 |
+
'post_type' => $this->post_type,
|
63 |
+
'posts_per_page' => $posts_per_page,
|
64 |
+
'paged' => $paged,
|
65 |
+
'post_status' => 'any',
|
66 |
+
)
|
67 |
+
);
|
68 |
|
69 |
$posts_mwf = get_posts( $args );
|
70 |
|
72 |
$csv = '';
|
73 |
|
74 |
// 見出しを追加
|
75 |
+
$rows = array();
|
76 |
$rows[0] = $this->_get_csv_headings( $posts_mwf );
|
77 |
|
78 |
// 各データを追加
|
79 |
$rows = array_merge( $rows, $this->_get_rows( $posts_mwf, $rows[0] ) );
|
80 |
|
81 |
// エンコード
|
82 |
+
foreach ( $rows as $row ) {
|
83 |
foreach ( $row as $column_name => $column ) {
|
84 |
$row[ $column_name ] = $this->_escape_double_quote( $column );
|
85 |
}
|
91 |
}
|
92 |
|
93 |
/**
|
94 |
+
* Return number of CSV output.
|
95 |
*
|
96 |
* @return int
|
97 |
*/
|
110 |
}
|
111 |
|
112 |
/**
|
113 |
+
* Return page number of CSV output.
|
114 |
*
|
115 |
* @return int
|
116 |
*/
|
125 |
}
|
126 |
|
127 |
/**
|
128 |
+
* Genrate headings of CSV.
|
129 |
*
|
130 |
+
* @param array $posts Array of WP_Post.
|
131 |
* @return array
|
132 |
*/
|
133 |
protected function _get_csv_headings( array $posts ) {
|
134 |
+
$columns = array(
|
135 |
'ID' => 'ID',
|
136 |
'admin_mail_to' => __( 'Admin Email To', 'mw-wp-form' ),
|
137 |
'response_status' => __( 'Response Status', 'mw-wp-form' ),
|
162 |
|
163 |
ksort( $_columns );
|
164 |
$_columns = apply_filters( 'mwform_inquiry_data_columns-' . $this->post_type, $_columns );
|
165 |
+
$columns = array_merge( $columns, $_columns );
|
166 |
+
$columns = array_merge( $columns, array( 'memo' => __( 'Memo', 'mw-wp-form' ) ) );
|
167 |
+
$columns = apply_filters( 'mwform_csv_columns-' . $this->post_type, $columns );
|
168 |
return $columns;
|
169 |
}
|
170 |
|
171 |
/**
|
172 |
+
* Generate rows of CSV.
|
173 |
*
|
174 |
+
* @param array $posts Array of WP_Post.
|
175 |
+
* @param array $headings Headings of CSV.
|
176 |
* @return array
|
177 |
*/
|
178 |
protected function _get_rows( array $posts, array $headings ) {
|
183 |
setup_postdata( $post );
|
184 |
$columns = array();
|
185 |
foreach ( $headings as $key => $value ) {
|
186 |
+
$contact_data_setting = new MW_WP_Form_Contact_Data_Setting( $post->ID );
|
187 |
+
$response_statuses = $contact_data_setting->get_response_statuses();
|
188 |
+
$column = '';
|
189 |
|
190 |
if ( 'response_status' === $key ) {
|
191 |
+
$response_status = $contact_data_setting->get( 'response_status' );
|
192 |
+
$column = $response_statuses[ $response_status ];
|
193 |
} elseif ( 'admin_mail_to' === $key ) {
|
194 |
+
$column = $contact_data_setting->get( 'admin_mail_to' );
|
195 |
} elseif ( 'memo' === $key ) {
|
196 |
+
$column = $contact_data_setting->get( 'memo' );
|
197 |
+
} elseif ( MWF_Config::TRACKINGNUMBER === $key ) {
|
198 |
$column = get_post_meta( get_the_ID(), MWF_Config::TRACKINGNUMBER, true );
|
199 |
} elseif ( isset( $post->$key ) ) {
|
200 |
$post_meta = $post->$key;
|
201 |
|
202 |
+
if ( $contact_data_setting->is_upload_file_key( $key ) ) {
|
203 |
// 過去バージョンでの不具合でメタデータが空になっていることがあるのでその場合は代替処理
|
204 |
if ( '' === $post_meta ) {
|
205 |
$post_meta = MWF_Functions::get_multimedia_id__fallback( $post, $key );
|
206 |
}
|
207 |
$column = wp_get_attachment_url( $post_meta );
|
208 |
} else {
|
209 |
+
$column = ( '' === $post_meta || null === $post_meta || false === $post_meta ) ? '' : $post_meta;
|
210 |
}
|
211 |
}
|
212 |
$columns[ $key ] = $column;
|
218 |
}
|
219 |
|
220 |
/**
|
221 |
+
* Escape double quotes.
|
222 |
*
|
223 |
+
* @param string $value Value.
|
224 |
* @return string
|
225 |
*/
|
226 |
protected function _escape_double_quote( $value ) {
|
classes/models/class.data.php
CHANGED
@@ -1,13 +1,12 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
10 |
-
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
*/
|
12 |
class MW_WP_Form_Data {
|
13 |
|
@@ -20,7 +19,15 @@ class MW_WP_Form_Data {
|
|
20 |
* @var MW_WP_Form_Sesion
|
21 |
*/
|
22 |
protected $Session;
|
|
|
|
|
|
|
|
|
23 |
protected $Session_meta;
|
|
|
|
|
|
|
|
|
24 |
protected $Session_validation_error;
|
25 |
|
26 |
/**
|
@@ -36,14 +43,24 @@ class MW_WP_Form_Data {
|
|
36 |
/**
|
37 |
* @var array
|
38 |
*/
|
39 |
-
protected $variables
|
40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
protected $validation_errors = array();
|
42 |
|
43 |
/**
|
44 |
-
*
|
45 |
-
*
|
46 |
-
* @param
|
|
|
|
|
47 |
*/
|
48 |
private function __construct( $form_key, array $POST = array(), array $FILES = array() ) {
|
49 |
$this->Session = new MW_WP_Form_Session( $form_key );
|
@@ -75,8 +92,6 @@ class MW_WP_Form_Data {
|
|
75 |
|
76 |
/**
|
77 |
* Save posted data to session
|
78 |
-
*
|
79 |
-
* @return void
|
80 |
*/
|
81 |
public function _save_to_session() {
|
82 |
$this->Session->clear_values();
|
@@ -90,11 +105,11 @@ class MW_WP_Form_Data {
|
|
90 |
}
|
91 |
|
92 |
/**
|
93 |
-
* Instantiation MW_WP_Form_Data
|
94 |
*
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
* @return MW_WP_Form_Data
|
99 |
*/
|
100 |
public static function connect( $form_key, $POST = null, $FILES = null ) {
|
@@ -114,6 +129,13 @@ class MW_WP_Form_Data {
|
|
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()',
|
@@ -130,7 +152,7 @@ class MW_WP_Form_Data {
|
|
130 |
}
|
131 |
|
132 |
/**
|
133 |
-
* Return form key
|
134 |
*
|
135 |
* @return string
|
136 |
*/
|
@@ -141,19 +163,16 @@ class MW_WP_Form_Data {
|
|
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 ) ) {
|
@@ -162,15 +181,13 @@ class MW_WP_Form_Data {
|
|
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']
|
174 |
$this->set( $name, $file['name'] );
|
175 |
} else {
|
176 |
$this->set( $name, '' );
|
@@ -189,9 +206,9 @@ class MW_WP_Form_Data {
|
|
189 |
}
|
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 |
*/
|
@@ -211,7 +228,7 @@ class MW_WP_Form_Data {
|
|
211 |
}
|
212 |
|
213 |
/**
|
214 |
-
* Get values
|
215 |
*
|
216 |
* @return array
|
217 |
*/
|
@@ -220,21 +237,20 @@ class MW_WP_Form_Data {
|
|
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 ) {
|
@@ -243,10 +259,9 @@ class MW_WP_Form_Data {
|
|
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 ] ) ) {
|
@@ -255,9 +270,7 @@ class MW_WP_Form_Data {
|
|
255 |
}
|
256 |
|
257 |
/**
|
258 |
-
* Clear all values
|
259 |
-
*
|
260 |
-
* @return void
|
261 |
*/
|
262 |
public function clear_values() {
|
263 |
$this->variables = array();
|
@@ -266,10 +279,10 @@ class MW_WP_Form_Data {
|
|
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 ) {
|
@@ -279,17 +292,17 @@ class MW_WP_Form_Data {
|
|
279 |
if ( is_array( $this->variables[ $name ] ) ) {
|
280 |
$this->variables[ $name ][] = $value;
|
281 |
} else {
|
282 |
-
$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
|
293 |
* @return string|null
|
294 |
*/
|
295 |
public function get( $name, array $children = array() ) {
|
@@ -337,9 +350,9 @@ class MW_WP_Form_Data {
|
|
337 |
}
|
338 |
|
339 |
/**
|
340 |
-
* Get the raw value
|
341 |
*
|
342 |
-
* @param string $name
|
343 |
* @return string|null
|
344 |
*/
|
345 |
public function get_raw( $name ) {
|
@@ -388,9 +401,9 @@ class MW_WP_Form_Data {
|
|
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 ) {
|
@@ -400,10 +413,10 @@ class MW_WP_Form_Data {
|
|
400 |
}
|
401 |
|
402 |
/**
|
403 |
-
* Return value when only in $children
|
404 |
*
|
405 |
-
* @param string $name
|
406 |
-
* @param array
|
407 |
* @return string
|
408 |
*/
|
409 |
public function get_in_children( $name, array $children ) {
|
@@ -420,10 +433,10 @@ class MW_WP_Form_Data {
|
|
420 |
}
|
421 |
|
422 |
/**
|
423 |
-
* Return raw value when only in $children
|
424 |
*
|
425 |
-
* @param string $name
|
426 |
-
* @param array
|
427 |
* @return string
|
428 |
*/
|
429 |
public function get_raw_in_children( $name, array $children ) {
|
@@ -440,9 +453,9 @@ class MW_WP_Form_Data {
|
|
440 |
}
|
441 |
|
442 |
/**
|
443 |
-
* Return posted separator value
|
444 |
*
|
445 |
-
* @param string $name
|
446 |
* @return string
|
447 |
*/
|
448 |
public function get_separator_value( $name ) {
|
@@ -453,10 +466,10 @@ class MW_WP_Form_Data {
|
|
453 |
}
|
454 |
|
455 |
/**
|
456 |
-
* Return formatted label from array. If doesn't have separator, return null
|
457 |
*
|
458 |
-
* @param string $name
|
459 |
-
* @param array
|
460 |
* @return string|null
|
461 |
*/
|
462 |
public function get_separated_value( $name, array $children ) {
|
@@ -486,7 +499,7 @@ class MW_WP_Form_Data {
|
|
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 |
}
|
@@ -495,10 +508,10 @@ class MW_WP_Form_Data {
|
|
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
|
502 |
* @return string|null
|
503 |
*/
|
504 |
public function get_separated_raw_value( $name, array $children ) {
|
@@ -528,7 +541,7 @@ class MW_WP_Form_Data {
|
|
528 |
|
529 |
$rightData = array();
|
530 |
foreach ( $value['data'] as $child ) {
|
531 |
-
if ( isset( $children[ $child ] ) && !in_array( $child, $rightData ) ) {
|
532 |
$rightData[] = $child;
|
533 |
}
|
534 |
}
|
@@ -536,11 +549,10 @@ class MW_WP_Form_Data {
|
|
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 ) {
|
@@ -573,9 +585,7 @@ class MW_WP_Form_Data {
|
|
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 );
|
@@ -593,10 +603,9 @@ class MW_WP_Form_Data {
|
|
593 |
}
|
594 |
$upload_file_keys = array_values( array_unique( $upload_file_keys ) );
|
595 |
|
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
|
600 |
if ( ! $upload_file_url || ! file_exists( $filepath ) ) {
|
601 |
unset( $upload_file_keys[ $key ] );
|
602 |
}
|
@@ -606,9 +615,9 @@ class MW_WP_Form_Data {
|
|
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 );
|
@@ -619,24 +628,23 @@ class MW_WP_Form_Data {
|
|
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 |
*/
|
@@ -647,17 +655,16 @@ class MW_WP_Form_Data {
|
|
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 |
*/
|
@@ -668,16 +675,14 @@ class MW_WP_Form_Data {
|
|
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 |
*/
|
@@ -688,37 +693,36 @@ class MW_WP_Form_Data {
|
|
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
|
714 |
-
$errors[ $rule ]
|
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 ) {
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Data
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Data {
|
12 |
|
19 |
* @var MW_WP_Form_Sesion
|
20 |
*/
|
21 |
protected $Session;
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @var MW_WP_Form_Sesion
|
25 |
+
*/
|
26 |
protected $Session_meta;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @var MW_WP_Form_Sesion
|
30 |
+
*/
|
31 |
protected $Session_validation_error;
|
32 |
|
33 |
/**
|
43 |
/**
|
44 |
* @var array
|
45 |
*/
|
46 |
+
protected $variables = array();
|
47 |
+
|
48 |
+
/**
|
49 |
+
* @var array
|
50 |
+
*/
|
51 |
+
protected $meta = array();
|
52 |
+
|
53 |
+
/**
|
54 |
+
* @var array
|
55 |
+
*/
|
56 |
protected $validation_errors = array();
|
57 |
|
58 |
/**
|
59 |
+
* Constructor.
|
60 |
+
*
|
61 |
+
* @param string $form_key Form key.
|
62 |
+
* @param array $POST $_POST.
|
63 |
+
* @param array $FILES $_FILES.
|
64 |
*/
|
65 |
private function __construct( $form_key, array $POST = array(), array $FILES = array() ) {
|
66 |
$this->Session = new MW_WP_Form_Session( $form_key );
|
92 |
|
93 |
/**
|
94 |
* Save posted data to session
|
|
|
|
|
95 |
*/
|
96 |
public function _save_to_session() {
|
97 |
$this->Session->clear_values();
|
105 |
}
|
106 |
|
107 |
/**
|
108 |
+
* Instantiation MW_WP_Form_Data.
|
109 |
*
|
110 |
+
* @param string $form_key Form key.
|
111 |
+
* @param array $POST $_POST.
|
112 |
+
* @param array $FILES $_FILES.
|
113 |
* @return MW_WP_Form_Data
|
114 |
*/
|
115 |
public static function connect( $form_key, $POST = null, $FILES = null ) {
|
129 |
return self::$Instances[ $form_key ];
|
130 |
}
|
131 |
|
132 |
+
/**
|
133 |
+
* Get instance.
|
134 |
+
*
|
135 |
+
* @param string $form_key Form key.
|
136 |
+
* @param array $POST $_POST.
|
137 |
+
* @param array $FILES $_FILES.
|
138 |
+
*/
|
139 |
public static function getInstance( $form_key = null, $POST = null, $FILES = null ) {
|
140 |
MWF_Functions::deprecated_message(
|
141 |
'MW_WP_Form_Data::getInstance()',
|
152 |
}
|
153 |
|
154 |
/**
|
155 |
+
* Return form key.
|
156 |
*
|
157 |
* @return string
|
158 |
*/
|
163 |
}
|
164 |
|
165 |
/**
|
166 |
+
* Set form key.
|
167 |
*
|
168 |
+
* @param string $form_key Form key.
|
|
|
169 |
*/
|
170 |
protected function _set_form_key( $form_key ) {
|
171 |
$this->meta['form_key'] = $form_key;
|
172 |
}
|
173 |
|
174 |
/**
|
175 |
+
* Set $_POST variables.
|
|
|
|
|
176 |
*/
|
177 |
protected function _set_request_valiables() {
|
178 |
if ( ! empty( $this->POST ) ) {
|
181 |
}
|
182 |
|
183 |
/**
|
184 |
+
* Set $_FILES variables.
|
|
|
|
|
185 |
*/
|
186 |
protected function _set_files_valiables() {
|
187 |
$files = array();
|
188 |
foreach ( $this->FILES as $name => $file ) {
|
189 |
if ( ! isset( $this->POST[ $name ] ) || ! empty( $file['name'] ) ) {
|
190 |
+
if ( UPLOAD_ERR_OK === $file['error'] && is_uploaded_file( $file['tmp_name'] ) ) {
|
191 |
$this->set( $name, $file['name'] );
|
192 |
} else {
|
193 |
$this->set( $name, '' );
|
206 |
}
|
207 |
|
208 |
/**
|
209 |
+
* 送信データからどのページを表示すべきかの状態を判定して返す.
|
210 |
+
* Return post condition based on posted data.
|
211 |
+
* But this post condition is not the page to actually display (e.g. validation error).
|
212 |
*
|
213 |
* @return string back|confirm|complete|input
|
214 |
*/
|
228 |
}
|
229 |
|
230 |
/**
|
231 |
+
* Get values.
|
232 |
*
|
233 |
* @return array
|
234 |
*/
|
237 |
}
|
238 |
|
239 |
/**
|
240 |
+
* Set the value.
|
241 |
*
|
242 |
+
* @param string $name Field name.
|
243 |
+
* @param string $value Posted value.
|
244 |
* @return void
|
245 |
*/
|
246 |
+
public function set( $name, $value ) {
|
247 |
$this->variables[ $name ] = $value;
|
248 |
}
|
249 |
|
250 |
/**
|
251 |
+
* Set values.
|
252 |
*
|
253 |
+
* @param array $array Posted data.
|
|
|
254 |
*/
|
255 |
public function sets( array $array ) {
|
256 |
foreach ( $array as $name => $value ) {
|
259 |
}
|
260 |
|
261 |
/**
|
262 |
+
* Clear the value.
|
263 |
*
|
264 |
+
* @param string $name Field name.
|
|
|
265 |
*/
|
266 |
public function clear_value( $name ) {
|
267 |
if ( isset( $this->variables[ $name ] ) ) {
|
270 |
}
|
271 |
|
272 |
/**
|
273 |
+
* Clear all values.
|
|
|
|
|
274 |
*/
|
275 |
public function clear_values() {
|
276 |
$this->variables = array();
|
279 |
}
|
280 |
|
281 |
/**
|
282 |
+
* Push the value.
|
283 |
*
|
284 |
+
* @param string $name Field name.
|
285 |
+
* @param string $value Posted value.
|
286 |
* @return void
|
287 |
*/
|
288 |
public function push( $name, $value ) {
|
292 |
if ( is_array( $this->variables[ $name ] ) ) {
|
293 |
$this->variables[ $name ][] = $value;
|
294 |
} else {
|
295 |
+
$this->variables[ $name ] = array( $this->variables[ $name ] );
|
296 |
$this->variables[ $name ][] = $value;
|
297 |
}
|
298 |
}
|
299 |
}
|
300 |
|
301 |
/**
|
302 |
+
* Return Formatted (transmittable) data. Auto discrimination name value or label.
|
303 |
*
|
304 |
+
* @param string $name Field name.
|
305 |
+
* @param array $children Children.
|
306 |
* @return string|null
|
307 |
*/
|
308 |
public function get( $name, array $children = array() ) {
|
350 |
}
|
351 |
|
352 |
/**
|
353 |
+
* Get the raw value.
|
354 |
*
|
355 |
+
* @param string $name Field name.
|
356 |
* @return string|null
|
357 |
*/
|
358 |
public function get_raw( $name ) {
|
401 |
}
|
402 |
|
403 |
/**
|
404 |
+
* Return posted data specify the name (In addition to value, separator and data etc are linked).
|
405 |
*
|
406 |
+
* @param string $name Field name.
|
407 |
* @return mixed
|
408 |
*/
|
409 |
public function get_post_value_by_key( $name ) {
|
413 |
}
|
414 |
|
415 |
/**
|
416 |
+
* Return value when only in $children.
|
417 |
*
|
418 |
+
* @param string $name Field name.
|
419 |
+
* @param array $children Children.
|
420 |
* @return string
|
421 |
*/
|
422 |
public function get_in_children( $name, array $children ) {
|
433 |
}
|
434 |
|
435 |
/**
|
436 |
+
* Return raw value when only in $children.
|
437 |
*
|
438 |
+
* @param string $name Field name.
|
439 |
+
* @param array $children Children.
|
440 |
* @return string
|
441 |
*/
|
442 |
public function get_raw_in_children( $name, array $children ) {
|
453 |
}
|
454 |
|
455 |
/**
|
456 |
+
* Return posted separator value.
|
457 |
*
|
458 |
+
* @param string $name Field name.
|
459 |
* @return string
|
460 |
*/
|
461 |
public function get_separator_value( $name ) {
|
466 |
}
|
467 |
|
468 |
/**
|
469 |
+
* Return formatted label from array. If doesn't have separator, return null.
|
470 |
*
|
471 |
+
* @param string $name Field name.
|
472 |
+
* @param array $children Children.
|
473 |
* @return string|null
|
474 |
*/
|
475 |
public function get_separated_value( $name, array $children ) {
|
499 |
|
500 |
$rightData = array();
|
501 |
foreach ( $value['data'] as $child ) {
|
502 |
+
if ( isset( $children[ $child ] ) && ! in_array( $children[ $child ], $rightData, true ) ) {
|
503 |
$rightData[] = $children[ $child ];
|
504 |
}
|
505 |
}
|
508 |
}
|
509 |
|
510 |
/**
|
511 |
+
* Return formatted name value from array. If doesn't have separator, return null.
|
512 |
*
|
513 |
+
* @param string $name Field name.
|
514 |
+
* @param array $children Children.
|
515 |
* @return string|null
|
516 |
*/
|
517 |
public function get_separated_raw_value( $name, array $children ) {
|
541 |
|
542 |
$rightData = array();
|
543 |
foreach ( $value['data'] as $child ) {
|
544 |
+
if ( isset( $children[ $child ] ) && ! in_array( $child, $rightData, true ) ) {
|
545 |
$rightData[] = $child;
|
546 |
}
|
547 |
}
|
549 |
}
|
550 |
|
551 |
/**
|
552 |
+
* Return formatted label from array. If doesn't have separator, return null.
|
553 |
+
* If it is all empty don't implode, even if there is even one value return.
|
554 |
*
|
555 |
+
* @param string $name Field name.
|
|
|
556 |
* @return string|null
|
557 |
*/
|
558 |
protected function get_separated_value_not_children_set( $name ) {
|
585 |
}
|
586 |
|
587 |
/**
|
588 |
+
* Delete name of upload failed file or name of deleted file from UPLOAD_FILE_KEYS.
|
|
|
|
|
589 |
*/
|
590 |
public function regenerate_upload_file_keys() {
|
591 |
$upload_file_keys = $this->get_post_value_by_key( MWF_Config::UPLOAD_FILE_KEYS );
|
603 |
}
|
604 |
$upload_file_keys = array_values( array_unique( $upload_file_keys ) );
|
605 |
|
|
|
606 |
foreach ( $upload_file_keys as $key => $upload_file_key ) {
|
607 |
$upload_file_url = $this->get_post_value_by_key( $upload_file_key );
|
608 |
+
$filepath = MWF_Functions::fileurl_to_path( $upload_file_url );
|
609 |
if ( ! $upload_file_url || ! file_exists( $filepath ) ) {
|
610 |
unset( $upload_file_keys[ $key ] );
|
611 |
}
|
615 |
}
|
616 |
|
617 |
/**
|
618 |
+
* Store uploaded files in UPLOAD_FILE_KEYS.
|
619 |
*
|
620 |
+
* @param array $uploaded_files Array of uploaded file url.
|
621 |
*/
|
622 |
public function push_uploaded_file_keys( array $uploaded_files = array() ) {
|
623 |
$upload_file_keys = $this->get_post_value_by_key( MWF_Config::UPLOAD_FILE_KEYS );
|
628 |
|
629 |
foreach ( $uploaded_files as $key => $upload_file ) {
|
630 |
$this->set( $key, $upload_file );
|
631 |
+
if ( is_array( $upload_file_keys ) && ! in_array( $key, $upload_file_keys, true ) ) {
|
632 |
$this->push( MWF_Config::UPLOAD_FILE_KEYS, $key );
|
633 |
}
|
634 |
}
|
635 |
}
|
636 |
|
637 |
/**
|
638 |
+
* Set view flg that is shows the screen to be displayed.
|
639 |
*
|
640 |
+
* @param string $view_flg null|input|confirm|complete.
|
|
|
641 |
*/
|
642 |
public function set_view_flg( $view_flg ) {
|
643 |
$this->meta['view_flg'] = $view_flg;
|
644 |
}
|
645 |
|
646 |
/**
|
647 |
+
* Return view flg that is shows the screen to be displayed.
|
648 |
*
|
649 |
* @return string null|input|confirm|complete
|
650 |
*/
|
655 |
}
|
656 |
|
657 |
/**
|
658 |
+
* Set saved mail id.
|
659 |
*
|
660 |
+
* @param int $saved_mail_id Saved mail ID.
|
|
|
661 |
*/
|
662 |
public function set_saved_mail_id( $saved_mail_id ) {
|
663 |
$this->meta['saved_mail_id'] = $saved_mail_id;
|
664 |
}
|
665 |
|
666 |
/**
|
667 |
+
* Return saved mail id.
|
668 |
*
|
669 |
* @return int|null
|
670 |
*/
|
675 |
}
|
676 |
|
677 |
/**
|
678 |
+
* Set send error flg.
|
|
|
|
|
679 |
*/
|
680 |
public function set_send_error() {
|
681 |
$this->meta[ MWF_Config::SEND_ERROR ] = true;
|
682 |
}
|
683 |
|
684 |
/**
|
685 |
+
* Return send error flg.
|
686 |
*
|
687 |
* @return boolean
|
688 |
*/
|
693 |
}
|
694 |
|
695 |
/**
|
696 |
+
* Nonce check.
|
697 |
*
|
698 |
* @return bool
|
699 |
*/
|
700 |
protected function _is_valid_token() {
|
701 |
$request_token = $this->get_post_value_by_key( MWF_Config::TOKEN_NAME );
|
|
|
702 |
$form_key = $this->get_form_key();
|
703 |
return ( isset( $request_token ) && wp_verify_nonce( $request_token, $form_key ) );
|
704 |
}
|
705 |
|
706 |
/**
|
707 |
+
* Set the error message.
|
708 |
*
|
709 |
+
* @param string $name Field name.
|
710 |
+
* @param string $rule Validation name.
|
711 |
+
* @param string $message Validation error message.
|
712 |
*/
|
713 |
public function set_validation_error( $name, $rule, $message ) {
|
714 |
if ( ! is_string( $message ) ) {
|
715 |
exit( 'The Validate error message must be string!' );
|
716 |
}
|
717 |
+
$errors = $this->get_validation_error( $name );
|
718 |
+
$errors[ $rule ] = $message;
|
719 |
$this->validation_errors[ $name ] = $errors;
|
720 |
}
|
721 |
|
722 |
/**
|
723 |
+
* Return error messages the one form field.
|
724 |
*
|
725 |
+
* @param string $name Field name.
|
726 |
* @return array
|
727 |
*/
|
728 |
public function get_validation_error( $name ) {
|
classes/models/class.file.php
CHANGED
@@ -1,24 +1,26 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
22 |
*/
|
23 |
public function _upload_mimes( $t ) {
|
24 |
$t['psd'] = 'image/vnd.adobe.photoshop';
|
@@ -28,10 +30,10 @@ class MW_WP_Form_File {
|
|
28 |
}
|
29 |
|
30 |
/**
|
31 |
-
* Upload all files
|
32 |
*
|
33 |
-
* @param array $files
|
34 |
-
* @return array
|
35 |
*/
|
36 |
public function upload( array $files = array() ) {
|
37 |
$this->_clean_temp_dir();
|
@@ -49,10 +51,10 @@ class MW_WP_Form_File {
|
|
49 |
}
|
50 |
|
51 |
/**
|
52 |
-
*
|
53 |
*
|
54 |
-
* @param string $name
|
55 |
-
* @return string
|
56 |
*/
|
57 |
protected function _single_file_upload( $name ) {
|
58 |
$this->create_temp_dir();
|
@@ -66,20 +68,21 @@ class MW_WP_Form_File {
|
|
66 |
}
|
67 |
|
68 |
/**
|
69 |
-
* Upload process
|
70 |
*
|
71 |
-
* @param arary $file $_FILES['name']
|
72 |
-
* @return string
|
73 |
*/
|
74 |
protected function _file_upload( $file ) {
|
75 |
if ( empty( $file['tmp_name'] ) ) {
|
76 |
return false;
|
77 |
}
|
78 |
|
79 |
-
if (
|
80 |
-
|
81 |
-
|
82 |
-
|
|
|
83 |
return false;
|
84 |
}
|
85 |
|
@@ -94,14 +97,13 @@ class MW_WP_Form_File {
|
|
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
|
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'];
|
@@ -113,7 +115,8 @@ class MW_WP_Form_File {
|
|
113 |
$upload_url = $wp_upload_dir['url'];
|
114 |
}
|
115 |
|
116 |
-
$filename
|
|
|
117 |
$uploadfile['file'] = trailingslashit( $upload_dir ) . $filename;
|
118 |
$uploadfile['url'] = trailingslashit( $upload_url ) . $filename;
|
119 |
|
@@ -121,20 +124,21 @@ class MW_WP_Form_File {
|
|
121 |
}
|
122 |
|
123 |
/**
|
124 |
-
* Return array of temp directory. Return directory even if it does not exist
|
125 |
*
|
126 |
-
* @return array
|
127 |
*/
|
128 |
public function get_temp_dir() {
|
129 |
-
$wp_upload_dir
|
130 |
-
$temp_dir_name
|
|
|
131 |
$temp_dir['dir'] = $wp_upload_dir['basedir'] . $temp_dir_name;
|
132 |
$temp_dir['url'] = $wp_upload_dir['baseurl'] . $temp_dir_name;
|
133 |
return $temp_dir;
|
134 |
}
|
135 |
|
136 |
/**
|
137 |
-
* Create temp directory
|
138 |
*
|
139 |
* @return bool
|
140 |
*/
|
@@ -153,9 +157,9 @@ class MW_WP_Form_File {
|
|
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();
|
@@ -173,7 +177,9 @@ class MW_WP_Form_File {
|
|
173 |
return;
|
174 |
}
|
175 |
|
|
|
176 |
while ( false !== ( $file = readdir( $handle ) ) ) {
|
|
|
177 |
if ( '.' === $file || '..' === $file ) {
|
178 |
continue;
|
179 |
}
|
@@ -190,9 +196,7 @@ class MW_WP_Form_File {
|
|
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();
|
@@ -207,7 +211,9 @@ class MW_WP_Form_File {
|
|
207 |
return;
|
208 |
}
|
209 |
|
|
|
210 |
while ( false !== ( $filename = readdir( $handle ) ) ) {
|
|
|
211 |
if ( '.' === $filename && '..' === $filename || is_dir( trailingslashit( $temp_dir ) . $filename ) ) {
|
212 |
continue;
|
213 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_File
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_File {
|
12 |
|
13 |
+
/**
|
14 |
+
* Constructor.
|
15 |
+
*/
|
16 |
public function __construct() {
|
17 |
add_filter( 'upload_mimes', array( $this, '_upload_mimes' ) );
|
18 |
}
|
19 |
|
20 |
/**
|
21 |
+
* Add mimes.
|
22 |
*
|
23 |
+
* @param array $t Array of MIME types.
|
24 |
*/
|
25 |
public function _upload_mimes( $t ) {
|
26 |
$t['psd'] = 'image/vnd.adobe.photoshop';
|
30 |
}
|
31 |
|
32 |
/**
|
33 |
+
* Upload all files.
|
34 |
*
|
35 |
+
* @param array $files Array of upload files.
|
36 |
+
* @return array
|
37 |
*/
|
38 |
public function upload( array $files = array() ) {
|
39 |
$this->_clean_temp_dir();
|
51 |
}
|
52 |
|
53 |
/**
|
54 |
+
* 指定したファイルをアップロード.
|
55 |
*
|
56 |
+
* @param string $name Field name.
|
57 |
+
* @return string
|
58 |
*/
|
59 |
protected function _single_file_upload( $name ) {
|
60 |
$this->create_temp_dir();
|
68 |
}
|
69 |
|
70 |
/**
|
71 |
+
* Upload process.
|
72 |
*
|
73 |
+
* @param arary $file $_FILES['name'].
|
74 |
+
* @return string
|
75 |
*/
|
76 |
protected function _file_upload( $file ) {
|
77 |
if ( empty( $file['tmp_name'] ) ) {
|
78 |
return false;
|
79 |
}
|
80 |
|
81 |
+
if (
|
82 |
+
! MWF_Functions::check_file_type( $file['tmp_name'], $file['name'] )
|
83 |
+
|| ! UPLOAD_ERR_OK === $file['error']
|
84 |
+
|| ! is_uploaded_file( $file['tmp_name'] )
|
85 |
+
) {
|
86 |
return false;
|
87 |
}
|
88 |
|
97 |
}
|
98 |
|
99 |
/**
|
100 |
+
* Generate temp file name.
|
101 |
+
* If doesn't generate temp directory, using upload directory.
|
102 |
*
|
103 |
+
* @param string $extension ext.
|
104 |
+
* @return array
|
105 |
*/
|
106 |
protected function _set_upload_file_name( $extension ) {
|
|
|
107 |
$basename = uniqid( rand() );
|
108 |
$temp_dir = $this->get_temp_dir();
|
109 |
$upload_dir = $temp_dir['dir'];
|
115 |
$upload_url = $wp_upload_dir['url'];
|
116 |
}
|
117 |
|
118 |
+
$filename = wp_unique_filename( trailingslashit( $upload_dir ), $basename . '.' . $extension );
|
119 |
+
$uploadfile = array();
|
120 |
$uploadfile['file'] = trailingslashit( $upload_dir ) . $filename;
|
121 |
$uploadfile['url'] = trailingslashit( $upload_url ) . $filename;
|
122 |
|
124 |
}
|
125 |
|
126 |
/**
|
127 |
+
* Return array of temp directory. Return directory even if it does not exist.
|
128 |
*
|
129 |
+
* @return array
|
130 |
*/
|
131 |
public function get_temp_dir() {
|
132 |
+
$wp_upload_dir = wp_upload_dir();
|
133 |
+
$temp_dir_name = '/' . MWF_Config::NAME . '_uploads';
|
134 |
+
$temp_dir = array();
|
135 |
$temp_dir['dir'] = $wp_upload_dir['basedir'] . $temp_dir_name;
|
136 |
$temp_dir['url'] = $wp_upload_dir['baseurl'] . $temp_dir_name;
|
137 |
return $temp_dir;
|
138 |
}
|
139 |
|
140 |
/**
|
141 |
+
* Create temp directory.
|
142 |
*
|
143 |
* @return bool
|
144 |
*/
|
157 |
}
|
158 |
|
159 |
/**
|
160 |
+
* Delete temp directory.
|
161 |
*
|
162 |
+
* @param string $sub_dir Sub directory path.
|
163 |
*/
|
164 |
public function remove_temp_dir( $sub_dir = '' ) {
|
165 |
$temp_dir = $this->get_temp_dir();
|
177 |
return;
|
178 |
}
|
179 |
|
180 |
+
// phpcs:disable WordPress.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition
|
181 |
while ( false !== ( $file = readdir( $handle ) ) ) {
|
182 |
+
// phpcs:enable
|
183 |
if ( '.' === $file || '..' === $file ) {
|
184 |
continue;
|
185 |
}
|
196 |
}
|
197 |
|
198 |
/**
|
199 |
+
* Delete files in temp directory.
|
|
|
|
|
200 |
*/
|
201 |
protected function _clean_temp_dir() {
|
202 |
$temp_dir = $this->get_temp_dir();
|
211 |
return;
|
212 |
}
|
213 |
|
214 |
+
// phpcs:disable WordPress.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition
|
215 |
while ( false !== ( $filename = readdir( $handle ) ) ) {
|
216 |
+
// phpcs:enable
|
217 |
if ( '.' === $filename && '..' === $filename || is_dir( trailingslashit( $temp_dir ) . $filename ) ) {
|
218 |
continue;
|
219 |
}
|
classes/models/class.form-fields.php
CHANGED
@@ -1,13 +1,12 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
10 |
-
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
*/
|
12 |
class MW_WP_Form_Form_Fields {
|
13 |
|
@@ -21,6 +20,9 @@ class MW_WP_Form_Form_Fields {
|
|
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 );
|
@@ -34,6 +36,11 @@ class MW_WP_Form_Form_Fields {
|
|
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 ];
|
@@ -44,7 +51,7 @@ class MW_WP_Form_Form_Fields {
|
|
44 |
}
|
45 |
|
46 |
/**
|
47 |
-
* Return all form fields
|
48 |
*
|
49 |
* @return array
|
50 |
*/
|
@@ -53,9 +60,9 @@ class MW_WP_Form_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 ) {
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Form_Fields
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Form_Fields {
|
12 |
|
20 |
*/
|
21 |
protected static $form_fields = array();
|
22 |
|
23 |
+
/**
|
24 |
+
* Constructor.
|
25 |
+
*/
|
26 |
private function __construct() {
|
27 |
foreach ( glob( plugin_dir_path( __FILE__ ) . '../form-fields/*.php' ) as $filename ) {
|
28 |
$class_name = self::_get_class_name_from_form_field_filename( $filename );
|
36 |
self::$form_fields = apply_filters( 'mwform_form_fields', self::$form_fields );
|
37 |
}
|
38 |
|
39 |
+
/**
|
40 |
+
* instantiation.
|
41 |
+
*
|
42 |
+
* @param string $form_key Form key.
|
43 |
+
*/
|
44 |
public static function instantiation( $form_key ) {
|
45 |
if ( isset( self::$Instances[ $form_key ] ) ) {
|
46 |
return self::$Instances[ $form_key ];
|
51 |
}
|
52 |
|
53 |
/**
|
54 |
+
* Return all form fields.
|
55 |
*
|
56 |
* @return array
|
57 |
*/
|
60 |
}
|
61 |
|
62 |
/**
|
63 |
+
* Return class name from filename of input form field.
|
64 |
*
|
65 |
+
* @param string $filename File name.
|
66 |
* @return string
|
67 |
*/
|
68 |
protected static function _get_class_name_from_form_field_filename( $filename ) {
|
classes/models/class.form.php
CHANGED
@@ -1,23 +1,26 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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(
|
|
|
|
|
|
|
|
|
21 |
MWF_Functions::deprecated_message(
|
22 |
'MW_WP_Form_Form::get_raw()',
|
23 |
'MW_WP_Form_Data::get_raw()'
|
@@ -25,13 +28,17 @@ class MW_WP_Form_Form {
|
|
25 |
}
|
26 |
|
27 |
/**
|
28 |
-
* Return raw value if it is in $children
|
29 |
*
|
30 |
-
* @param string $name
|
31 |
-
* @param array
|
32 |
-
* @return string
|
33 |
*/
|
34 |
-
public function get_raw_in_children(
|
|
|
|
|
|
|
|
|
|
|
35 |
MWF_Functions::deprecated_message(
|
36 |
'MW_WP_Form_Form::get_raw_in_children()',
|
37 |
'MW_WP_Form_Data::get_raw_in_children()'
|
@@ -39,12 +46,15 @@ class MW_WP_Form_Form {
|
|
39 |
}
|
40 |
|
41 |
/**
|
42 |
-
* Return value for zip
|
43 |
*
|
44 |
-
* @param string $name
|
45 |
-
* @return string
|
46 |
*/
|
47 |
-
public function get_zip_value(
|
|
|
|
|
|
|
|
|
48 |
MWF_Functions::deprecated_message(
|
49 |
'MW_WP_Form_Form::get_zip_value()',
|
50 |
'MW_WP_Form_Data::get_separated_value()'
|
@@ -52,12 +62,15 @@ class MW_WP_Form_Form {
|
|
52 |
}
|
53 |
|
54 |
/**
|
55 |
-
* Return value for tel
|
56 |
*
|
57 |
-
* @param string $name
|
58 |
-
* @return string
|
59 |
*/
|
60 |
-
public function get_tel_value(
|
|
|
|
|
|
|
|
|
61 |
MWF_Functions::deprecated_message(
|
62 |
'MW_WP_Form_Form::get_tel_value()',
|
63 |
'MW_WP_Form_Data::get_separated_value()'
|
@@ -65,13 +78,17 @@ class MW_WP_Form_Form {
|
|
65 |
}
|
66 |
|
67 |
/**
|
68 |
-
* Return value for checkbox
|
69 |
*
|
70 |
-
* @param string $name
|
71 |
-
* @param array
|
72 |
-
* @return string
|
73 |
*/
|
74 |
-
public function get_checked_value(
|
|
|
|
|
|
|
|
|
|
|
75 |
MWF_Functions::deprecated_message(
|
76 |
'MW_WP_Form_Form::get_checked_value()',
|
77 |
'MW_WP_Form_Data::get_separated_value()'
|
@@ -79,13 +96,17 @@ class MW_WP_Form_Form {
|
|
79 |
}
|
80 |
|
81 |
/**
|
82 |
-
* Return value for radio
|
83 |
*
|
84 |
-
* @param string $name
|
85 |
-
* @param array
|
86 |
-
* @return string
|
87 |
*/
|
88 |
-
public function get_radio_value(
|
|
|
|
|
|
|
|
|
|
|
89 |
MWF_Functions::deprecated_message(
|
90 |
'MW_WP_Form_Form::get_radio_value()',
|
91 |
'MW_WP_Form_Data::get_in_children()'
|
@@ -93,13 +114,17 @@ class MW_WP_Form_Form {
|
|
93 |
}
|
94 |
|
95 |
/**
|
96 |
-
|
97 |
*
|
98 |
-
* @param string $name
|
99 |
-
* @param array
|
100 |
-
* @return string
|
101 |
*/
|
102 |
-
public function get_selected_value(
|
|
|
|
|
|
|
|
|
|
|
103 |
MWF_Functions::deprecated_message(
|
104 |
'MW_WP_Form_Form::get_selected_value()',
|
105 |
'MW_WP_Form_Data::get_in_children()'
|
@@ -107,13 +132,17 @@ class MW_WP_Form_Form {
|
|
107 |
}
|
108 |
|
109 |
/**
|
110 |
-
* Return formatted raw value (e.g. for checkbox)
|
111 |
*
|
112 |
-
* @param string $name
|
113 |
-
* @param array
|
114 |
-
* @return string
|
115 |
*/
|
116 |
-
public function get_separated_raw_value(
|
|
|
|
|
|
|
|
|
|
|
117 |
MWF_Functions::deprecated_message(
|
118 |
'MW_WP_Form_Form::get_separated_raw_value()',
|
119 |
'MW_WP_Form_Data::get_separated_raw_value()'
|
@@ -121,10 +150,10 @@ class MW_WP_Form_Form {
|
|
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 ) {
|
@@ -134,12 +163,15 @@ class MW_WP_Form_Form {
|
|
134 |
}
|
135 |
|
136 |
/**
|
137 |
-
* Return separator value
|
138 |
*
|
139 |
-
* @param string $name
|
140 |
-
* @return string
|
141 |
*/
|
142 |
-
public function get_separator_value(
|
|
|
|
|
|
|
|
|
143 |
MWF_Functions::deprecated_message(
|
144 |
'MW_WP_Form_Form::get_separator_value()',
|
145 |
'MW_WP_Form_Data::get_separator_value()'
|
@@ -147,10 +179,10 @@ class MW_WP_Form_Form {
|
|
147 |
}
|
148 |
|
149 |
/**
|
150 |
-
* Return hidden field for setting children
|
151 |
*
|
152 |
-
* @param string $name
|
153 |
-
* @param array
|
154 |
* @return string
|
155 |
*/
|
156 |
public function children( $name, array $children ) {
|
@@ -159,42 +191,49 @@ class MW_WP_Form_Form {
|
|
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
|
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(
|
195 |
-
|
196 |
-
|
197 |
-
|
|
|
|
|
|
|
198 |
|
199 |
return sprintf(
|
200 |
'<form method="post" action="%s" enctype="%s">',
|
@@ -204,39 +243,42 @@ class MW_WP_Form_Form {
|
|
204 |
}
|
205 |
|
206 |
/**
|
207 |
-
* Return form ending tag
|
208 |
*
|
209 |
* @return string
|
210 |
*/
|
211 |
public function end() {
|
212 |
-
$html
|
213 |
-
$html
|
214 |
$html .= '</form>';
|
215 |
return $html;
|
216 |
}
|
217 |
|
218 |
/**
|
219 |
-
* Return input[type=text]
|
220 |
*
|
221 |
-
* @param string $name
|
222 |
-
* @param array
|
223 |
* @return string
|
224 |
*/
|
225 |
public function text( $name, $options = array() ) {
|
226 |
$defaults = array(
|
227 |
-
'id'
|
228 |
-
'class'
|
229 |
-
'size'
|
230 |
-
'maxlength'
|
231 |
-
'value'
|
232 |
-
'placeholder'
|
233 |
'conv-half-alphanumeric' => null,
|
234 |
);
|
235 |
|
236 |
$options = shortcode_atts( $defaults, $options );
|
237 |
-
$options = array_merge(
|
238 |
-
|
239 |
-
|
|
|
|
|
|
|
240 |
|
241 |
return $this->remove_newline_space(
|
242 |
$this->_render( 'text', $options )
|
@@ -244,26 +286,29 @@ class MW_WP_Form_Form {
|
|
244 |
}
|
245 |
|
246 |
/**
|
247 |
-
* Return input[type=email]
|
248 |
*
|
249 |
-
* @param string $name
|
250 |
-
* @param array
|
251 |
* @return string
|
252 |
*/
|
253 |
public function email( $name, $options = array() ) {
|
254 |
$defaults = array(
|
255 |
-
'id'
|
256 |
-
'class'
|
257 |
-
'size'
|
258 |
-
'maxlength'
|
259 |
-
'value'
|
260 |
-
'placeholder'
|
261 |
'conv-half-alphanumeric' => null,
|
262 |
);
|
263 |
-
$options
|
264 |
-
$options
|
265 |
-
|
266 |
-
|
|
|
|
|
|
|
267 |
|
268 |
return $this->remove_newline_space(
|
269 |
$this->_render( 'email', $options )
|
@@ -271,26 +316,29 @@ class MW_WP_Form_Form {
|
|
271 |
}
|
272 |
|
273 |
/**
|
274 |
-
* Return input[type=url]
|
275 |
*
|
276 |
-
* @param string $name
|
277 |
-
* @param array
|
278 |
* @return string
|
279 |
*/
|
280 |
public function url( $name, $options = array() ) {
|
281 |
$defaults = array(
|
282 |
-
'id'
|
283 |
-
'class'
|
284 |
-
'size'
|
285 |
-
'maxlength'
|
286 |
-
'value'
|
287 |
-
'placeholder'
|
288 |
'conv-half-alphanumeric' => null,
|
289 |
);
|
290 |
-
$options
|
291 |
-
$options
|
292 |
-
|
293 |
-
|
|
|
|
|
|
|
294 |
|
295 |
return $this->remove_newline_space(
|
296 |
$this->_render( 'url', $options )
|
@@ -298,10 +346,10 @@ class MW_WP_Form_Form {
|
|
298 |
}
|
299 |
|
300 |
/**
|
301 |
-
* Return input[type=range]
|
302 |
*
|
303 |
-
* @param string $name
|
304 |
-
* @param array
|
305 |
* @return string
|
306 |
*/
|
307 |
public function range( $name, $options = array() ) {
|
@@ -313,10 +361,13 @@ class MW_WP_Form_Form {
|
|
313 |
'max' => 100,
|
314 |
'step' => 1,
|
315 |
);
|
316 |
-
$options
|
317 |
-
$options
|
318 |
-
|
319 |
-
|
|
|
|
|
|
|
320 |
|
321 |
return $this->remove_newline_space(
|
322 |
$this->_render( 'range', $options )
|
@@ -324,10 +375,10 @@ class MW_WP_Form_Form {
|
|
324 |
}
|
325 |
|
326 |
/**
|
327 |
-
* Return input[type=number]
|
328 |
*
|
329 |
-
* @param string $name
|
330 |
-
* @param array
|
331 |
* @return string
|
332 |
*/
|
333 |
public function number( $name, $options = array() ) {
|
@@ -340,10 +391,13 @@ class MW_WP_Form_Form {
|
|
340 |
'step' => 1,
|
341 |
'placeholder' => null,
|
342 |
);
|
343 |
-
$options
|
344 |
-
$options
|
345 |
-
|
346 |
-
|
|
|
|
|
|
|
347 |
|
348 |
return $this->remove_newline_space(
|
349 |
$this->_render( 'number', $options )
|
@@ -351,24 +405,27 @@ class MW_WP_Form_Form {
|
|
351 |
}
|
352 |
|
353 |
/**
|
354 |
-
* Return input[type=hidden]
|
355 |
*
|
356 |
-
* @param string $name
|
357 |
-
* @param
|
358 |
* @return string
|
359 |
*/
|
360 |
public function hidden( $name, $value ) {
|
361 |
-
return $this->_render(
|
362 |
-
'
|
363 |
-
|
364 |
-
|
|
|
|
|
|
|
365 |
}
|
366 |
|
367 |
/**
|
368 |
-
* Return input[type=password]
|
369 |
*
|
370 |
-
* @param string $name
|
371 |
-
* @param array
|
372 |
* @return string
|
373 |
*/
|
374 |
public function password( $name, $options = array() ) {
|
@@ -380,10 +437,13 @@ class MW_WP_Form_Form {
|
|
380 |
'value' => '',
|
381 |
'placeholder' => null,
|
382 |
);
|
383 |
-
$options
|
384 |
-
$options
|
385 |
-
|
386 |
-
|
|
|
|
|
|
|
387 |
|
388 |
return $this->remove_newline_space(
|
389 |
$this->_render( 'password', $options )
|
@@ -391,19 +451,19 @@ class MW_WP_Form_Form {
|
|
391 |
}
|
392 |
|
393 |
/**
|
394 |
-
* Return zip field
|
395 |
*
|
396 |
-
* @param string $name
|
397 |
-
* @param array
|
398 |
* @return string
|
399 |
*/
|
400 |
public function zip( $name, $options = array() ) {
|
401 |
$defaults = array(
|
402 |
-
'class'
|
403 |
'conv-half-alphanumeric' => null,
|
404 |
-
'value'
|
405 |
);
|
406 |
-
$options
|
407 |
|
408 |
$children = array();
|
409 |
$separator = '-';
|
@@ -422,45 +482,48 @@ class MW_WP_Form_Form {
|
|
422 |
}
|
423 |
|
424 |
return $this->remove_newline_space(
|
425 |
-
$this->_render(
|
426 |
-
'
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
|
|
|
|
|
|
443 |
),
|
444 |
-
)
|
445 |
-
)
|
446 |
. $this->separator( $name, $separator )
|
447 |
);
|
448 |
}
|
449 |
|
450 |
/**
|
451 |
-
* Return tel field
|
452 |
*
|
453 |
-
* @param string $name
|
454 |
-
* @param array
|
455 |
* @return string
|
456 |
*/
|
457 |
public function tel( $name, $options = array() ) {
|
458 |
$defaults = array(
|
459 |
-
'class'
|
460 |
'conv-half-alphanumeric' => null,
|
461 |
-
'value'
|
462 |
);
|
463 |
-
$options
|
464 |
|
465 |
$children = array();
|
466 |
$separator = '-';
|
@@ -473,50 +536,53 @@ class MW_WP_Form_Form {
|
|
473 |
|
474 |
$values = array( '', '', '' );
|
475 |
foreach ( $children as $key => $val ) {
|
476 |
-
if (
|
477 |
$values[ $key ] = $val;
|
478 |
}
|
479 |
}
|
480 |
|
481 |
return $this->remove_newline_space(
|
482 |
-
$this->_render(
|
483 |
-
'
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
492 |
),
|
493 |
-
|
494 |
-
|
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
|
520 |
* @return string
|
521 |
*/
|
522 |
public function textarea( $name, $options = array() ) {
|
@@ -528,10 +594,13 @@ class MW_WP_Form_Form {
|
|
528 |
'value' => '',
|
529 |
'placeholder' => null,
|
530 |
);
|
531 |
-
$options
|
532 |
-
$options
|
533 |
-
|
534 |
-
|
|
|
|
|
|
|
535 |
|
536 |
return $this->remove_newline_space(
|
537 |
$this->_render( 'textarea', $options )
|
@@ -539,11 +608,11 @@ class MW_WP_Form_Form {
|
|
539 |
}
|
540 |
|
541 |
/**
|
542 |
-
* Return selectbox
|
543 |
*
|
544 |
-
* @param string $name
|
545 |
-
* @param array
|
546 |
-
* @param array
|
547 |
* @return string
|
548 |
*/
|
549 |
public function select( $name, $children = array(), $options = array() ) {
|
@@ -552,11 +621,14 @@ class MW_WP_Form_Form {
|
|
552 |
'id' => null,
|
553 |
'value' => '',
|
554 |
);
|
555 |
-
$options
|
556 |
-
$options
|
557 |
-
|
558 |
-
|
559 |
-
|
|
|
|
|
|
|
560 |
|
561 |
return $this->remove_newline_space(
|
562 |
$this->_render( 'select', $options )
|
@@ -564,11 +636,11 @@ class MW_WP_Form_Form {
|
|
564 |
}
|
565 |
|
566 |
/**
|
567 |
-
* Return input[type=radio]
|
568 |
*
|
569 |
-
* @param string $name
|
570 |
-
* @param array
|
571 |
-
* @param array
|
572 |
* @return string
|
573 |
*/
|
574 |
public function radio( $name, $children = array(), $options = array() ) {
|
@@ -578,9 +650,9 @@ class MW_WP_Form_Form {
|
|
578 |
'value' => '',
|
579 |
'vertically' => null,
|
580 |
);
|
581 |
-
$options
|
582 |
|
583 |
-
$i
|
584 |
$fields = array();
|
585 |
foreach ( $children as $key => $label ) {
|
586 |
$i ++;
|
@@ -592,9 +664,12 @@ class MW_WP_Form_Form {
|
|
592 |
);
|
593 |
}
|
594 |
|
595 |
-
$options = array_merge(
|
596 |
-
|
597 |
-
|
|
|
|
|
|
|
598 |
|
599 |
return $this->remove_newline_space(
|
600 |
$this->_render( 'radio', $options )
|
@@ -602,12 +677,12 @@ class MW_WP_Form_Form {
|
|
602 |
}
|
603 |
|
604 |
/**
|
605 |
-
* Return input[checkbox]
|
606 |
*
|
607 |
-
* @param string $name
|
608 |
-
* @param array
|
609 |
-
* @param array
|
610 |
-
* @param string $separator
|
611 |
* @return string
|
612 |
*/
|
613 |
public function checkbox( $name, $children = array(), $options = array(), $separator = ',' ) {
|
@@ -617,7 +692,7 @@ class MW_WP_Form_Form {
|
|
617 |
'value' => '',
|
618 |
'vertically' => null,
|
619 |
);
|
620 |
-
$options
|
621 |
|
622 |
if ( ! is_array( $options['value'] ) ) {
|
623 |
if ( MWF_Functions::is_empty( $options['value'] ) ) {
|
@@ -627,7 +702,7 @@ class MW_WP_Form_Form {
|
|
627 |
}
|
628 |
}
|
629 |
|
630 |
-
$i
|
631 |
$fields = array();
|
632 |
foreach ( $children as $key => $label ) {
|
633 |
$i ++;
|
@@ -639,9 +714,12 @@ class MW_WP_Form_Form {
|
|
639 |
);
|
640 |
}
|
641 |
|
642 |
-
$options = array_merge(
|
643 |
-
|
644 |
-
|
|
|
|
|
|
|
645 |
|
646 |
return $this->remove_newline_space(
|
647 |
$this->_render( 'checkbox', $options ) . $this->separator( $name, $separator )
|
@@ -649,22 +727,25 @@ class MW_WP_Form_Form {
|
|
649 |
}
|
650 |
|
651 |
/**
|
652 |
-
* Return input[type=submit]
|
653 |
*
|
654 |
-
* @param string $name
|
655 |
-
* @param string $value
|
656 |
-
* @param array
|
657 |
* @return string
|
658 |
*/
|
659 |
public function submit( $name, $value, $options = array() ) {
|
660 |
$defaults = array(
|
661 |
'class' => null,
|
662 |
);
|
663 |
-
$options
|
664 |
-
$options
|
665 |
-
|
666 |
-
|
667 |
-
|
|
|
|
|
|
|
668 |
|
669 |
return $this->remove_newline_space(
|
670 |
$this->_render( 'submit', $options )
|
@@ -672,24 +753,27 @@ class MW_WP_Form_Form {
|
|
672 |
}
|
673 |
|
674 |
/**
|
675 |
-
* Return button[type=submit]
|
676 |
*
|
677 |
-
* @param string $name
|
678 |
-
* @param string $value
|
679 |
-
* @param array
|
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
|
688 |
-
$options
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
|
|
|
|
|
|
693 |
|
694 |
return $this->remove_newline_space(
|
695 |
$this->_render( 'button_submit', $options )
|
@@ -697,22 +781,25 @@ class MW_WP_Form_Form {
|
|
697 |
}
|
698 |
|
699 |
/**
|
700 |
-
* Return input[type=button]
|
701 |
*
|
702 |
-
* @param string $name
|
703 |
-
* @param string $value
|
704 |
-
* @param array
|
705 |
* @return string
|
706 |
*/
|
707 |
public function button( $name, $value, $options = array() ) {
|
708 |
$defaults = array(
|
709 |
'class' => null,
|
710 |
);
|
711 |
-
$options
|
712 |
-
$options
|
713 |
-
|
714 |
-
|
715 |
-
|
|
|
|
|
|
|
716 |
|
717 |
return $this->remove_newline_space(
|
718 |
$this->_render( 'button', $options )
|
@@ -720,24 +807,27 @@ class MW_WP_Form_Form {
|
|
720 |
}
|
721 |
|
722 |
/**
|
723 |
-
* Return button
|
724 |
*
|
725 |
-
* @param string $name
|
726 |
-
* @param string $value
|
727 |
-
* @param array
|
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
|
736 |
-
$options
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
|
|
|
|
|
|
741 |
|
742 |
return $this->remove_newline_space(
|
743 |
$this->_render( 'button_button', $options )
|
@@ -745,10 +835,10 @@ class MW_WP_Form_Form {
|
|
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() ) {
|
@@ -760,10 +850,13 @@ class MW_WP_Form_Form {
|
|
760 |
'value' => '',
|
761 |
'placeholder' => null,
|
762 |
);
|
763 |
-
$options
|
764 |
-
$options
|
765 |
-
|
766 |
-
|
|
|
|
|
|
|
767 |
|
768 |
return $this->remove_newline_space(
|
769 |
$this->_render( 'datepicker', $options )
|
@@ -771,10 +864,10 @@ class MW_WP_Form_Form {
|
|
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() ) {
|
@@ -786,10 +879,13 @@ class MW_WP_Form_Form {
|
|
786 |
'value' => '',
|
787 |
'placeholder' => null,
|
788 |
);
|
789 |
-
$options
|
790 |
-
$options
|
791 |
-
|
792 |
-
|
|
|
|
|
|
|
793 |
|
794 |
return $this->remove_newline_space(
|
795 |
$this->_render( 'monthpicker', $options )
|
@@ -797,10 +893,10 @@ class MW_WP_Form_Form {
|
|
797 |
}
|
798 |
|
799 |
/**
|
800 |
-
* Return input[type=file]
|
801 |
*
|
802 |
-
* @param string $name
|
803 |
-
* @param
|
804 |
* @return string
|
805 |
*/
|
806 |
public function file( $name, $options = array() ) {
|
@@ -808,10 +904,13 @@ class MW_WP_Form_Form {
|
|
808 |
'id' => null,
|
809 |
'class' => null,
|
810 |
);
|
811 |
-
$options
|
812 |
-
$options
|
813 |
-
|
814 |
-
|
|
|
|
|
|
|
815 |
|
816 |
return $this->remove_newline_space(
|
817 |
$this->_render( 'file', $options )
|
@@ -819,10 +918,11 @@ class MW_WP_Form_Form {
|
|
819 |
}
|
820 |
|
821 |
/**
|
822 |
-
*
|
823 |
*
|
824 |
* @deprecated
|
825 |
-
*
|
|
|
826 |
*/
|
827 |
public function generate_attributes( array $_attributes ) {
|
828 |
$attributes = array();
|
@@ -842,10 +942,10 @@ class MW_WP_Form_Form {
|
|
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 = '' ) {
|
@@ -860,19 +960,37 @@ class MW_WP_Form_Form {
|
|
860 |
}
|
861 |
|
862 |
/**
|
863 |
-
* Removed linefeed codes, tabs and spaces
|
864 |
*
|
865 |
-
* @param string $string
|
866 |
* @return string
|
867 |
*/
|
868 |
public function remove_newline_space( $string ) {
|
869 |
-
return preg_replace_callback(
|
|
|
|
|
|
|
|
|
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()',
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Form
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Form {
|
12 |
|
13 |
/**
|
14 |
+
* Return raw value.
|
15 |
*
|
16 |
+
* @param string $name Field name.
|
17 |
* @return mixed
|
18 |
*/
|
19 |
+
public function get_raw(
|
20 |
+
// phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
|
21 |
+
$name
|
22 |
+
// phpcs:enable
|
23 |
+
) {
|
24 |
MWF_Functions::deprecated_message(
|
25 |
'MW_WP_Form_Form::get_raw()',
|
26 |
'MW_WP_Form_Data::get_raw()'
|
28 |
}
|
29 |
|
30 |
/**
|
31 |
+
* Return raw value if it is in $children.
|
32 |
*
|
33 |
+
* @param string $name Field name.
|
34 |
+
* @param array $children Children.
|
|
|
35 |
*/
|
36 |
+
public function get_raw_in_children(
|
37 |
+
// phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
|
38 |
+
$name,
|
39 |
+
array $children
|
40 |
+
// phpcs:enable
|
41 |
+
) {
|
42 |
MWF_Functions::deprecated_message(
|
43 |
'MW_WP_Form_Form::get_raw_in_children()',
|
44 |
'MW_WP_Form_Data::get_raw_in_children()'
|
46 |
}
|
47 |
|
48 |
/**
|
49 |
+
* Return value for zip.
|
50 |
*
|
51 |
+
* @param string $name Field name.
|
|
|
52 |
*/
|
53 |
+
public function get_zip_value(
|
54 |
+
// phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
|
55 |
+
$name
|
56 |
+
// phpcs:enable
|
57 |
+
) {
|
58 |
MWF_Functions::deprecated_message(
|
59 |
'MW_WP_Form_Form::get_zip_value()',
|
60 |
'MW_WP_Form_Data::get_separated_value()'
|
62 |
}
|
63 |
|
64 |
/**
|
65 |
+
* Return value for tel.
|
66 |
*
|
67 |
+
* @param string $name Field name.
|
|
|
68 |
*/
|
69 |
+
public function get_tel_value(
|
70 |
+
// phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
|
71 |
+
$name
|
72 |
+
// phpcs:enable
|
73 |
+
) {
|
74 |
MWF_Functions::deprecated_message(
|
75 |
'MW_WP_Form_Form::get_tel_value()',
|
76 |
'MW_WP_Form_Data::get_separated_value()'
|
78 |
}
|
79 |
|
80 |
/**
|
81 |
+
* Return value for checkbox.
|
82 |
*
|
83 |
+
* @param string $name Field name.
|
84 |
+
* @param array $data Posted value.
|
|
|
85 |
*/
|
86 |
+
public function get_checked_value(
|
87 |
+
// phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
|
88 |
+
$name,
|
89 |
+
array $data
|
90 |
+
// phpcs:enable
|
91 |
+
) {
|
92 |
MWF_Functions::deprecated_message(
|
93 |
'MW_WP_Form_Form::get_checked_value()',
|
94 |
'MW_WP_Form_Data::get_separated_value()'
|
96 |
}
|
97 |
|
98 |
/**
|
99 |
+
* Return value for radio.
|
100 |
*
|
101 |
+
* @param string $name Field name.
|
102 |
+
* @param array $data Posted value.
|
|
|
103 |
*/
|
104 |
+
public function get_radio_value(
|
105 |
+
// phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
|
106 |
+
$name,
|
107 |
+
array $data
|
108 |
+
// phpcs:enable
|
109 |
+
) {
|
110 |
MWF_Functions::deprecated_message(
|
111 |
'MW_WP_Form_Form::get_radio_value()',
|
112 |
'MW_WP_Form_Data::get_in_children()'
|
114 |
}
|
115 |
|
116 |
/**
|
117 |
+
* Return value for selectbox.
|
118 |
*
|
119 |
+
* @param string $name Field name.
|
120 |
+
* @param array $data Posted value.
|
|
|
121 |
*/
|
122 |
+
public function get_selected_value(
|
123 |
+
// phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
|
124 |
+
$name,
|
125 |
+
array $data
|
126 |
+
// phpcs:enable
|
127 |
+
) {
|
128 |
MWF_Functions::deprecated_message(
|
129 |
'MW_WP_Form_Form::get_selected_value()',
|
130 |
'MW_WP_Form_Data::get_in_children()'
|
132 |
}
|
133 |
|
134 |
/**
|
135 |
+
* Return formatted raw value (e.g. for checkbox).
|
136 |
*
|
137 |
+
* @param string $name Field name.
|
138 |
+
* @param array $children Children.
|
|
|
139 |
*/
|
140 |
+
public function get_separated_raw_value(
|
141 |
+
// phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
|
142 |
+
$name,
|
143 |
+
array $children = array()
|
144 |
+
// phpcs:enable
|
145 |
+
) {
|
146 |
MWF_Functions::deprecated_message(
|
147 |
'MW_WP_Form_Form::get_separated_raw_value()',
|
148 |
'MW_WP_Form_Data::get_separated_raw_value()'
|
150 |
}
|
151 |
|
152 |
/**
|
153 |
+
* Return hidden field for separator.
|
154 |
*
|
155 |
+
* @param string $name Field name.
|
156 |
+
* @param string $separator Separator.
|
157 |
* @return string
|
158 |
*/
|
159 |
public function separator( $name, $separator ) {
|
163 |
}
|
164 |
|
165 |
/**
|
166 |
+
* Return separator value.
|
167 |
*
|
168 |
+
* @param string $name Field name.
|
|
|
169 |
*/
|
170 |
+
public function get_separator_value(
|
171 |
+
// phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
|
172 |
+
$name
|
173 |
+
// phpcs:enable
|
174 |
+
) {
|
175 |
MWF_Functions::deprecated_message(
|
176 |
'MW_WP_Form_Form::get_separator_value()',
|
177 |
'MW_WP_Form_Data::get_separator_value()'
|
179 |
}
|
180 |
|
181 |
/**
|
182 |
+
* Return hidden field for setting children.
|
183 |
*
|
184 |
+
* @param string $name Field name.
|
185 |
+
* @param array $children Children.
|
186 |
* @return string
|
187 |
*/
|
188 |
public function children( $name, array $children ) {
|
191 |
}
|
192 |
|
193 |
/**
|
194 |
+
* Render template.
|
195 |
*
|
196 |
+
* @param string $template directory/filename (no extension).
|
197 |
+
* @param array $args Argments.
|
198 |
* @return string
|
199 |
*/
|
200 |
protected function _render( $template, array $args = array() ) {
|
201 |
$template_path = locate_template( 'mw-wp-form/form-fields/' . $template . '.php' );
|
202 |
if ( ! $template_path ) {
|
203 |
+
$template_path = plugin_dir_path( __FILE__ ) . '../../templates/form-fields/' . $template . '.php';
|
204 |
if ( ! file_exists( $template_path ) ) {
|
205 |
return;
|
206 |
}
|
207 |
}
|
208 |
|
209 |
+
foreach ( $args as $key => $val ) {
|
210 |
unset( $args[ $key ] );
|
211 |
$args[ str_replace( '-', '_', $key ) ] = $val;
|
212 |
}
|
213 |
|
214 |
+
// phpcs:disable WordPress.PHP.DontExtract.extract_extract
|
215 |
extract( $args );
|
216 |
+
// phpcs:enable
|
217 |
+
|
218 |
ob_start();
|
219 |
include( $template_path );
|
220 |
return ob_get_clean();
|
221 |
}
|
222 |
|
223 |
/**
|
224 |
+
* Return form staring tag.
|
225 |
*
|
226 |
+
* @param array $options Start tag attributes.
|
227 |
* @return string
|
228 |
*/
|
229 |
public function start( $options = array() ) {
|
230 |
+
$options = array_merge(
|
231 |
+
array(
|
232 |
+
'action' => '',
|
233 |
+
'enctype' => 'multipart/form-data',
|
234 |
+
),
|
235 |
+
$options
|
236 |
+
);
|
237 |
|
238 |
return sprintf(
|
239 |
'<form method="post" action="%s" enctype="%s">',
|
243 |
}
|
244 |
|
245 |
/**
|
246 |
+
* Return form ending tag.
|
247 |
*
|
248 |
* @return string
|
249 |
*/
|
250 |
public function end() {
|
251 |
+
$html = '';
|
252 |
+
$html = apply_filters( 'mwform_form_end_html', $html );
|
253 |
$html .= '</form>';
|
254 |
return $html;
|
255 |
}
|
256 |
|
257 |
/**
|
258 |
+
* Return input[type=text].
|
259 |
*
|
260 |
+
* @param string $name Field name.
|
261 |
+
* @param array $options Options.
|
262 |
* @return string
|
263 |
*/
|
264 |
public function text( $name, $options = array() ) {
|
265 |
$defaults = array(
|
266 |
+
'id' => null,
|
267 |
+
'class' => null,
|
268 |
+
'size' => 60,
|
269 |
+
'maxlength' => null,
|
270 |
+
'value' => '',
|
271 |
+
'placeholder' => null,
|
272 |
'conv-half-alphanumeric' => null,
|
273 |
);
|
274 |
|
275 |
$options = shortcode_atts( $defaults, $options );
|
276 |
+
$options = array_merge(
|
277 |
+
$options,
|
278 |
+
array(
|
279 |
+
'name' => $name,
|
280 |
+
)
|
281 |
+
);
|
282 |
|
283 |
return $this->remove_newline_space(
|
284 |
$this->_render( 'text', $options )
|
286 |
}
|
287 |
|
288 |
/**
|
289 |
+
* Return input[type=email].
|
290 |
*
|
291 |
+
* @param string $name Field name.
|
292 |
+
* @param array $options Options.
|
293 |
* @return string
|
294 |
*/
|
295 |
public function email( $name, $options = array() ) {
|
296 |
$defaults = array(
|
297 |
+
'id' => null,
|
298 |
+
'class' => null,
|
299 |
+
'size' => 60,
|
300 |
+
'maxlength' => null,
|
301 |
+
'value' => '',
|
302 |
+
'placeholder' => null,
|
303 |
'conv-half-alphanumeric' => null,
|
304 |
);
|
305 |
+
$options = shortcode_atts( $defaults, $options );
|
306 |
+
$options = array_merge(
|
307 |
+
$options,
|
308 |
+
array(
|
309 |
+
'name' => $name,
|
310 |
+
)
|
311 |
+
);
|
312 |
|
313 |
return $this->remove_newline_space(
|
314 |
$this->_render( 'email', $options )
|
316 |
}
|
317 |
|
318 |
/**
|
319 |
+
* Return input[type=url].
|
320 |
*
|
321 |
+
* @param string $name Field name.
|
322 |
+
* @param array $options Options.
|
323 |
* @return string
|
324 |
*/
|
325 |
public function url( $name, $options = array() ) {
|
326 |
$defaults = array(
|
327 |
+
'id' => null,
|
328 |
+
'class' => null,
|
329 |
+
'size' => 60,
|
330 |
+
'maxlength' => null,
|
331 |
+
'value' => '',
|
332 |
+
'placeholder' => null,
|
333 |
'conv-half-alphanumeric' => null,
|
334 |
);
|
335 |
+
$options = shortcode_atts( $defaults, $options );
|
336 |
+
$options = array_merge(
|
337 |
+
$options,
|
338 |
+
array(
|
339 |
+
'name' => $name,
|
340 |
+
)
|
341 |
+
);
|
342 |
|
343 |
return $this->remove_newline_space(
|
344 |
$this->_render( 'url', $options )
|
346 |
}
|
347 |
|
348 |
/**
|
349 |
+
* Return input[type=range].
|
350 |
*
|
351 |
+
* @param string $name Field name.
|
352 |
+
* @param array $options Options.
|
353 |
* @return string
|
354 |
*/
|
355 |
public function range( $name, $options = array() ) {
|
361 |
'max' => 100,
|
362 |
'step' => 1,
|
363 |
);
|
364 |
+
$options = shortcode_atts( $defaults, $options );
|
365 |
+
$options = array_merge(
|
366 |
+
$options,
|
367 |
+
array(
|
368 |
+
'name' => $name,
|
369 |
+
)
|
370 |
+
);
|
371 |
|
372 |
return $this->remove_newline_space(
|
373 |
$this->_render( 'range', $options )
|
375 |
}
|
376 |
|
377 |
/**
|
378 |
+
* Return input[type=number].
|
379 |
*
|
380 |
+
* @param string $name Field name.
|
381 |
+
* @param array $options Options.
|
382 |
* @return string
|
383 |
*/
|
384 |
public function number( $name, $options = array() ) {
|
391 |
'step' => 1,
|
392 |
'placeholder' => null,
|
393 |
);
|
394 |
+
$options = shortcode_atts( $defaults, $options );
|
395 |
+
$options = array_merge(
|
396 |
+
$options,
|
397 |
+
array(
|
398 |
+
'name' => $name,
|
399 |
+
)
|
400 |
+
);
|
401 |
|
402 |
return $this->remove_newline_space(
|
403 |
$this->_render( 'number', $options )
|
405 |
}
|
406 |
|
407 |
/**
|
408 |
+
* Return input[type=hidden].
|
409 |
*
|
410 |
+
* @param string $name Field name.
|
411 |
+
* @param array $value Field value.
|
412 |
* @return string
|
413 |
*/
|
414 |
public function hidden( $name, $value ) {
|
415 |
+
return $this->_render(
|
416 |
+
'hidden',
|
417 |
+
array(
|
418 |
+
'name' => $name,
|
419 |
+
'value' => $value,
|
420 |
+
)
|
421 |
+
);
|
422 |
}
|
423 |
|
424 |
/**
|
425 |
+
* Return input[type=password].
|
426 |
*
|
427 |
+
* @param string $name Field name.
|
428 |
+
* @param array $options Options.
|
429 |
* @return string
|
430 |
*/
|
431 |
public function password( $name, $options = array() ) {
|
437 |
'value' => '',
|
438 |
'placeholder' => null,
|
439 |
);
|
440 |
+
$options = shortcode_atts( $defaults, $options );
|
441 |
+
$options = array_merge(
|
442 |
+
$options,
|
443 |
+
array(
|
444 |
+
'name' => $name,
|
445 |
+
)
|
446 |
+
);
|
447 |
|
448 |
return $this->remove_newline_space(
|
449 |
$this->_render( 'password', $options )
|
451 |
}
|
452 |
|
453 |
/**
|
454 |
+
* Return zip field.
|
455 |
*
|
456 |
+
* @param string $name Field name.
|
457 |
+
* @param array $options Options.
|
458 |
* @return string
|
459 |
*/
|
460 |
public function zip( $name, $options = array() ) {
|
461 |
$defaults = array(
|
462 |
+
'class' => null,
|
463 |
'conv-half-alphanumeric' => null,
|
464 |
+
'value' => '',
|
465 |
);
|
466 |
+
$options = shortcode_atts( $defaults, $options );
|
467 |
|
468 |
$children = array();
|
469 |
$separator = '-';
|
482 |
}
|
483 |
|
484 |
return $this->remove_newline_space(
|
485 |
+
$this->_render(
|
486 |
+
'zip',
|
487 |
+
array(
|
488 |
+
'separator' => $separator,
|
489 |
+
'fields' => array(
|
490 |
+
array(
|
491 |
+
'name' => $name . '[data][0]',
|
492 |
+
'class' => $options['class'],
|
493 |
+
'size' => 4,
|
494 |
+
'maxlength' => 3,
|
495 |
+
'value' => $values[0],
|
496 |
+
'conv-half-alphanumeric' => $options['conv-half-alphanumeric'],
|
497 |
+
),
|
498 |
+
array(
|
499 |
+
'name' => $name . '[data][1]',
|
500 |
+
'class' => $options['class'],
|
501 |
+
'size' => 5,
|
502 |
+
'maxlength' => 4,
|
503 |
+
'value' => $values[1],
|
504 |
+
'conv-half-alphanumeric' => $options['conv-half-alphanumeric'],
|
505 |
+
),
|
506 |
),
|
507 |
+
)
|
508 |
+
)
|
509 |
. $this->separator( $name, $separator )
|
510 |
);
|
511 |
}
|
512 |
|
513 |
/**
|
514 |
+
* Return tel field.
|
515 |
*
|
516 |
+
* @param string $name Field name.
|
517 |
+
* @param array $options Options.
|
518 |
* @return string
|
519 |
*/
|
520 |
public function tel( $name, $options = array() ) {
|
521 |
$defaults = array(
|
522 |
+
'class' => null,
|
523 |
'conv-half-alphanumeric' => null,
|
524 |
+
'value' => '',
|
525 |
);
|
526 |
+
$options = shortcode_atts( $defaults, $options );
|
527 |
|
528 |
$children = array();
|
529 |
$separator = '-';
|
536 |
|
537 |
$values = array( '', '', '' );
|
538 |
foreach ( $children as $key => $val ) {
|
539 |
+
if ( 0 === $key || 1 === $key || 2 === $key ) {
|
540 |
$values[ $key ] = $val;
|
541 |
}
|
542 |
}
|
543 |
|
544 |
return $this->remove_newline_space(
|
545 |
+
$this->_render(
|
546 |
+
'tel',
|
547 |
+
array(
|
548 |
+
'separator' => $separator,
|
549 |
+
'fields' => array(
|
550 |
+
array(
|
551 |
+
'name' => $name . '[data][0]',
|
552 |
+
'class' => $options['class'],
|
553 |
+
'size' => 6,
|
554 |
+
'maxlength' => 5,
|
555 |
+
'value' => $values[0],
|
556 |
+
'conv-half-alphanumeric' => $options['conv-half-alphanumeric'],
|
557 |
+
),
|
558 |
+
array(
|
559 |
+
'name' => $name . '[data][1]',
|
560 |
+
'class' => $options['class'],
|
561 |
+
'size' => 5,
|
562 |
+
'maxlength' => 4,
|
563 |
+
'value' => $values[1],
|
564 |
+
'conv-half-alphanumeric' => $options['conv-half-alphanumeric'],
|
565 |
+
),
|
566 |
+
array(
|
567 |
+
'name' => $name . '[data][2]',
|
568 |
+
'class' => $options['class'],
|
569 |
+
'size' => 5,
|
570 |
+
'maxlength' => 4,
|
571 |
+
'value' => $values[2],
|
572 |
+
'conv-half-alphanumeric' => $options['conv-half-alphanumeric'],
|
573 |
+
),
|
574 |
),
|
575 |
+
)
|
576 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
577 |
. $this->separator( $name, $separator )
|
578 |
);
|
579 |
}
|
580 |
|
581 |
/**
|
582 |
+
* Return textarea.
|
583 |
*
|
584 |
+
* @param string $name Field name.
|
585 |
+
* @param array $options Options.
|
586 |
* @return string
|
587 |
*/
|
588 |
public function textarea( $name, $options = array() ) {
|
594 |
'value' => '',
|
595 |
'placeholder' => null,
|
596 |
);
|
597 |
+
$options = shortcode_atts( $defaults, $options );
|
598 |
+
$options = array_merge(
|
599 |
+
$options,
|
600 |
+
array(
|
601 |
+
'name' => $name,
|
602 |
+
)
|
603 |
+
);
|
604 |
|
605 |
return $this->remove_newline_space(
|
606 |
$this->_render( 'textarea', $options )
|
608 |
}
|
609 |
|
610 |
/**
|
611 |
+
* Return selectbox.
|
612 |
*
|
613 |
+
* @param string $name Field name.
|
614 |
+
* @param array $children Children.
|
615 |
+
* @param array $options Options.
|
616 |
* @return string
|
617 |
*/
|
618 |
public function select( $name, $children = array(), $options = array() ) {
|
621 |
'id' => null,
|
622 |
'value' => '',
|
623 |
);
|
624 |
+
$options = shortcode_atts( $defaults, $options );
|
625 |
+
$options = array_merge(
|
626 |
+
$options,
|
627 |
+
array(
|
628 |
+
'name' => $name,
|
629 |
+
'children' => $children,
|
630 |
+
)
|
631 |
+
);
|
632 |
|
633 |
return $this->remove_newline_space(
|
634 |
$this->_render( 'select', $options )
|
636 |
}
|
637 |
|
638 |
/**
|
639 |
+
* Return input[type=radio].
|
640 |
*
|
641 |
+
* @param string $name Field name.
|
642 |
+
* @param array $children Children.
|
643 |
+
* @param array $options Options.
|
644 |
* @return string
|
645 |
*/
|
646 |
public function radio( $name, $children = array(), $options = array() ) {
|
650 |
'value' => '',
|
651 |
'vertically' => null,
|
652 |
);
|
653 |
+
$options = shortcode_atts( $defaults, $options );
|
654 |
|
655 |
+
$i = 0;
|
656 |
$fields = array();
|
657 |
foreach ( $children as $key => $label ) {
|
658 |
$i ++;
|
664 |
);
|
665 |
}
|
666 |
|
667 |
+
$options = array_merge(
|
668 |
+
$options,
|
669 |
+
array(
|
670 |
+
'fields' => $fields,
|
671 |
+
)
|
672 |
+
);
|
673 |
|
674 |
return $this->remove_newline_space(
|
675 |
$this->_render( 'radio', $options )
|
677 |
}
|
678 |
|
679 |
/**
|
680 |
+
* Return input[checkbox].
|
681 |
*
|
682 |
+
* @param string $name Field name.
|
683 |
+
* @param array $children Children.
|
684 |
+
* @param array $options Options.
|
685 |
+
* @param string $separator Separator.
|
686 |
* @return string
|
687 |
*/
|
688 |
public function checkbox( $name, $children = array(), $options = array(), $separator = ',' ) {
|
692 |
'value' => '',
|
693 |
'vertically' => null,
|
694 |
);
|
695 |
+
$options = shortcode_atts( $defaults, $options );
|
696 |
|
697 |
if ( ! is_array( $options['value'] ) ) {
|
698 |
if ( MWF_Functions::is_empty( $options['value'] ) ) {
|
702 |
}
|
703 |
}
|
704 |
|
705 |
+
$i = 0;
|
706 |
$fields = array();
|
707 |
foreach ( $children as $key => $label ) {
|
708 |
$i ++;
|
714 |
);
|
715 |
}
|
716 |
|
717 |
+
$options = array_merge(
|
718 |
+
$options,
|
719 |
+
array(
|
720 |
+
'fields' => $fields,
|
721 |
+
)
|
722 |
+
);
|
723 |
|
724 |
return $this->remove_newline_space(
|
725 |
$this->_render( 'checkbox', $options ) . $this->separator( $name, $separator )
|
727 |
}
|
728 |
|
729 |
/**
|
730 |
+
* Return input[type=submit].
|
731 |
*
|
732 |
+
* @param string $name Field name.
|
733 |
+
* @param string $value Field value.
|
734 |
+
* @param array $options Options.
|
735 |
* @return string
|
736 |
*/
|
737 |
public function submit( $name, $value, $options = array() ) {
|
738 |
$defaults = array(
|
739 |
'class' => null,
|
740 |
);
|
741 |
+
$options = shortcode_atts( $defaults, $options );
|
742 |
+
$options = array_merge(
|
743 |
+
$options,
|
744 |
+
array(
|
745 |
+
'name' => $name,
|
746 |
+
'value' => $value,
|
747 |
+
)
|
748 |
+
);
|
749 |
|
750 |
return $this->remove_newline_space(
|
751 |
$this->_render( 'submit', $options )
|
753 |
}
|
754 |
|
755 |
/**
|
756 |
+
* Return button[type=submit].
|
757 |
*
|
758 |
+
* @param string $name Field name.
|
759 |
+
* @param string $value Field value.
|
760 |
+
* @param array $options Options.
|
761 |
+
* @param string $element_content Field content.
|
762 |
* @return string
|
763 |
*/
|
764 |
public function button_submit( $name, $value, $options = array(), $element_content = '' ) {
|
765 |
$defaults = array(
|
766 |
'class' => null,
|
767 |
);
|
768 |
+
$options = shortcode_atts( $defaults, $options );
|
769 |
+
$options = array_merge(
|
770 |
+
$options,
|
771 |
+
array(
|
772 |
+
'name' => $name,
|
773 |
+
'value' => $value,
|
774 |
+
'element_content' => $element_content,
|
775 |
+
)
|
776 |
+
);
|
777 |
|
778 |
return $this->remove_newline_space(
|
779 |
$this->_render( 'button_submit', $options )
|
781 |
}
|
782 |
|
783 |
/**
|
784 |
+
* Return input[type=button].
|
785 |
*
|
786 |
+
* @param string $name Field name.
|
787 |
+
* @param string $value Field value.
|
788 |
+
* @param array $options Options.
|
789 |
* @return string
|
790 |
*/
|
791 |
public function button( $name, $value, $options = array() ) {
|
792 |
$defaults = array(
|
793 |
'class' => null,
|
794 |
);
|
795 |
+
$options = shortcode_atts( $defaults, $options );
|
796 |
+
$options = array_merge(
|
797 |
+
$options,
|
798 |
+
array(
|
799 |
+
'name' => $name,
|
800 |
+
'value' => $value,
|
801 |
+
)
|
802 |
+
);
|
803 |
|
804 |
return $this->remove_newline_space(
|
805 |
$this->_render( 'button', $options )
|
807 |
}
|
808 |
|
809 |
/**
|
810 |
+
* Return button.
|
811 |
*
|
812 |
+
* @param string $name Field name.
|
813 |
+
* @param string $value Field value.
|
814 |
+
* @param array $options Options.
|
815 |
+
* @param string $element_content Field content.
|
816 |
* @return string
|
817 |
*/
|
818 |
public function button_button( $name, $value, $options = array(), $element_content = '' ) {
|
819 |
$defaults = array(
|
820 |
'class' => null,
|
821 |
);
|
822 |
+
$options = shortcode_atts( $defaults, $options );
|
823 |
+
$options = array_merge(
|
824 |
+
$options,
|
825 |
+
array(
|
826 |
+
'name' => $name,
|
827 |
+
'value' => $value,
|
828 |
+
'element_content' => $element_content,
|
829 |
+
)
|
830 |
+
);
|
831 |
|
832 |
return $this->remove_newline_space(
|
833 |
$this->_render( 'button_button', $options )
|
835 |
}
|
836 |
|
837 |
/**
|
838 |
+
* Return datepicker.
|
839 |
*
|
840 |
+
* @param string $name Field name.
|
841 |
+
* @param string $options Options.
|
842 |
* @return string
|
843 |
*/
|
844 |
public function datepicker( $name, $options = array() ) {
|
850 |
'value' => '',
|
851 |
'placeholder' => null,
|
852 |
);
|
853 |
+
$options = shortcode_atts( $defaults, $options );
|
854 |
+
$options = array_merge(
|
855 |
+
$options,
|
856 |
+
array(
|
857 |
+
'name' => $name,
|
858 |
+
)
|
859 |
+
);
|
860 |
|
861 |
return $this->remove_newline_space(
|
862 |
$this->_render( 'datepicker', $options )
|
864 |
}
|
865 |
|
866 |
/**
|
867 |
+
* Return monthpicker.
|
868 |
*
|
869 |
+
* @param string $name Field name.
|
870 |
+
* @param string $options Options.
|
871 |
* @return string
|
872 |
*/
|
873 |
public function monthpicker( $name, $options = array() ) {
|
879 |
'value' => '',
|
880 |
'placeholder' => null,
|
881 |
);
|
882 |
+
$options = shortcode_atts( $defaults, $options );
|
883 |
+
$options = array_merge(
|
884 |
+
$options,
|
885 |
+
array(
|
886 |
+
'name' => $name,
|
887 |
+
)
|
888 |
+
);
|
889 |
|
890 |
return $this->remove_newline_space(
|
891 |
$this->_render( 'monthpicker', $options )
|
893 |
}
|
894 |
|
895 |
/**
|
896 |
+
* Return input[type=file].
|
897 |
*
|
898 |
+
* @param string $name Field name.
|
899 |
+
* @param string $options Options.
|
900 |
* @return string
|
901 |
*/
|
902 |
public function file( $name, $options = array() ) {
|
904 |
'id' => null,
|
905 |
'class' => null,
|
906 |
);
|
907 |
+
$options = shortcode_atts( $defaults, $options );
|
908 |
+
$options = array_merge(
|
909 |
+
$options,
|
910 |
+
array(
|
911 |
+
'name' => $name,
|
912 |
+
)
|
913 |
+
);
|
914 |
|
915 |
return $this->remove_newline_space(
|
916 |
$this->_render( 'file', $options )
|
918 |
}
|
919 |
|
920 |
/**
|
921 |
+
* タグの属性を最適化して生成する.
|
922 |
*
|
923 |
* @deprecated
|
924 |
+
*
|
925 |
+
* @param array $_attributes キーが属性名、要素が属性値の配列。要素が null のときは無視する.
|
926 |
*/
|
927 |
public function generate_attributes( array $_attributes ) {
|
928 |
$attributes = array();
|
942 |
}
|
943 |
|
944 |
/**
|
945 |
+
* Return ID attribute.
|
946 |
*
|
947 |
+
* @param string $id The id attribute.
|
948 |
+
* @param string $suffix Suffix.
|
949 |
* @return string
|
950 |
*/
|
951 |
protected function _get_attr_id( $id, $suffix = '' ) {
|
960 |
}
|
961 |
|
962 |
/**
|
963 |
+
* Removed linefeed codes, tabs and spaces.
|
964 |
*
|
965 |
+
* @param string $string Target string.
|
966 |
* @return string
|
967 |
*/
|
968 |
public function remove_newline_space( $string ) {
|
969 |
+
return preg_replace_callback(
|
970 |
+
'/<([^<>]+?)>/',
|
971 |
+
array( $this, '_remove_newline_space_callback' ),
|
972 |
+
$string
|
973 |
+
);
|
974 |
}
|
975 |
+
|
976 |
+
/**
|
977 |
+
* Callback for remove_newline_space.
|
978 |
+
*
|
979 |
+
* @param array $matches $matches of remove_newline_space.
|
980 |
+
* @return string
|
981 |
+
*/
|
982 |
protected function _remove_newline_space_callback( $matches ) {
|
983 |
$matches[0] = str_replace( array( "\r\n", "\r", "\n", "\t" ), ' ', $matches[0] );
|
984 |
$matches[0] = preg_replace( '/[\t ]+/', ' ', $matches[0] );
|
985 |
return $matches[0];
|
986 |
}
|
987 |
+
|
988 |
+
/**
|
989 |
+
* Removed linefeed codes, tabs and spaces.
|
990 |
+
*
|
991 |
+
* @param string $string Target string.
|
992 |
+
* @return string
|
993 |
+
*/
|
994 |
public static function remove_linefeed_space( $string ) {
|
995 |
MWF_Functions::deprecated_message(
|
996 |
'MW_WP_Form_Form::remove_linefeed_space()',
|
classes/models/class.json-parser.php
CHANGED
@@ -1,60 +1,68 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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 |
-
*
|
|
|
|
|
58 |
*/
|
59 |
public function __construct( $maybe_json ) {
|
60 |
$this->maybe_json = $maybe_json;
|
@@ -62,9 +70,7 @@ class MW_WP_Form_Json_Parser {
|
|
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,10 +82,9 @@ class MW_WP_Form_Json_Parser {
|
|
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 ] ) ) {
|
@@ -89,9 +94,7 @@ class MW_WP_Form_Json_Parser {
|
|
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 ) {
|
@@ -106,9 +109,7 @@ class MW_WP_Form_Json_Parser {
|
|
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 ) {
|
@@ -123,36 +124,32 @@ class MW_WP_Form_Json_Parser {
|
|
123 |
}
|
124 |
|
125 |
/**
|
126 |
-
|
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
|
135 |
} else {
|
136 |
$this->push_character( ':' );
|
137 |
}
|
138 |
}
|
139 |
|
140 |
/**
|
141 |
-
* Proccess for colon
|
142 |
-
*
|
143 |
-
* @return void
|
144 |
*/
|
145 |
protected function proccess_colon() {
|
146 |
if ( $this->colon_stay ) {
|
147 |
$this->colon_stay = false;
|
148 |
-
$this->key
|
149 |
} else {
|
150 |
$this->push_character( ':' );
|
151 |
}
|
152 |
}
|
153 |
|
154 |
/**
|
155 |
-
* Return json based on the array for generating json
|
156 |
*
|
157 |
* @return json
|
158 |
*/
|
@@ -170,11 +167,11 @@ class MW_WP_Form_Json_Parser {
|
|
170 |
$value = trim( $value );
|
171 |
if ( preg_match( '/^[\-\+]?[\d]+$/', $value ) ) {
|
172 |
$value = (int) $value;
|
173 |
-
} elseif (
|
174 |
$value = true;
|
175 |
-
} elseif (
|
176 |
$value = false;
|
177 |
-
} elseif (
|
178 |
$value = null;
|
179 |
}
|
180 |
$js[ trim( $key ) ] = $value;
|
@@ -183,33 +180,29 @@ class MW_WP_Form_Json_Parser {
|
|
183 |
}
|
184 |
|
185 |
/**
|
186 |
-
* Return json based on the array for generating json
|
187 |
*
|
188 |
* @return json
|
189 |
*/
|
190 |
public function create_json() {
|
191 |
$_js = trim( $this->maybe_json, '{}' );
|
192 |
-
$_js = preg_split(
|
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 |
-
|
212 |
-
else {
|
213 |
$this->push_character( $character );
|
214 |
}
|
215 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Json_Parser
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Json_Parser {
|
12 |
|
13 |
/**
|
14 |
* Json from shortcode
|
15 |
+
*
|
16 |
* @var string
|
17 |
*/
|
18 |
protected $maybe_json;
|
19 |
|
20 |
/**
|
21 |
* Waiting for single quotation
|
22 |
+
*
|
23 |
* @var bool
|
24 |
*/
|
25 |
protected $s_quote_stay = false;
|
26 |
|
27 |
/**
|
28 |
* Waiting for double quotation
|
29 |
+
*
|
30 |
* @var bool
|
31 |
*/
|
32 |
protected $d_quote_stay = false;
|
33 |
|
34 |
/**
|
35 |
* Waiting for colon
|
36 |
+
*
|
37 |
* @var bool
|
38 |
*/
|
39 |
protected $colon_stay = true;
|
40 |
|
41 |
/**
|
42 |
* Array index to generate correct json
|
43 |
+
*
|
44 |
* @var int
|
45 |
*/
|
46 |
protected $index = 0;
|
47 |
|
48 |
/**
|
49 |
* A flag that identifies whether the character to be set is key or value
|
50 |
+
*
|
51 |
* @var string key|value
|
52 |
*/
|
53 |
protected $key = 'key';
|
54 |
|
55 |
/**
|
56 |
* Array of generating json
|
57 |
+
*
|
58 |
* @var array
|
59 |
*/
|
60 |
protected $temp = array();
|
61 |
|
62 |
/**
|
63 |
+
* Constructor.
|
64 |
+
|
65 |
+
* @param string $maybe_json json.
|
66 |
*/
|
67 |
public function __construct( $maybe_json ) {
|
68 |
$this->maybe_json = $maybe_json;
|
70 |
}
|
71 |
|
72 |
/**
|
73 |
+
* Set initial value of each property.
|
|
|
|
|
74 |
*/
|
75 |
protected function set_default_params() {
|
76 |
$this->s_quote_stay = false;
|
82 |
}
|
83 |
|
84 |
/**
|
85 |
+
* Add a character to an array for generating json.
|
86 |
*
|
87 |
+
* @param string $character Character.
|
|
|
88 |
*/
|
89 |
public function push_character( $character ) {
|
90 |
if ( ! isset( $this->temp[ $this->index ][ $this->key ] ) ) {
|
94 |
}
|
95 |
|
96 |
/**
|
97 |
+
* Proccess for single quotation.
|
|
|
|
|
98 |
*/
|
99 |
protected function proccess_single_quote() {
|
100 |
if ( ! $this->d_quote_stay ) {
|
109 |
}
|
110 |
|
111 |
/**
|
112 |
+
* Proccess for double quotation.
|
|
|
|
|
113 |
*/
|
114 |
protected function proccess_double_quote() {
|
115 |
if ( ! $this->s_quote_stay ) {
|
124 |
}
|
125 |
|
126 |
/**
|
127 |
+
* Proccess for connma.
|
|
|
|
|
128 |
*/
|
129 |
protected function proccess_comma() {
|
130 |
if ( ! $this->s_quote_stay || ! $this->d_quote_stay ) {
|
131 |
$this->index ++;
|
132 |
$this->colon_stay = true;
|
133 |
+
$this->key = 'key';
|
134 |
} else {
|
135 |
$this->push_character( ':' );
|
136 |
}
|
137 |
}
|
138 |
|
139 |
/**
|
140 |
+
* Proccess for colon.
|
|
|
|
|
141 |
*/
|
142 |
protected function proccess_colon() {
|
143 |
if ( $this->colon_stay ) {
|
144 |
$this->colon_stay = false;
|
145 |
+
$this->key = 'value';
|
146 |
} else {
|
147 |
$this->push_character( ':' );
|
148 |
}
|
149 |
}
|
150 |
|
151 |
/**
|
152 |
+
* Return json based on the array for generating json.
|
153 |
*
|
154 |
* @return json
|
155 |
*/
|
167 |
$value = trim( $value );
|
168 |
if ( preg_match( '/^[\-\+]?[\d]+$/', $value ) ) {
|
169 |
$value = (int) $value;
|
170 |
+
} elseif ( mb_strtolower( 'true' ) === $value ) {
|
171 |
$value = true;
|
172 |
+
} elseif ( mb_strtolower( 'false' ) === $value ) {
|
173 |
$value = false;
|
174 |
+
} elseif ( mb_strtolower( 'null' ) === $value ) {
|
175 |
$value = null;
|
176 |
}
|
177 |
$js[ trim( $key ) ] = $value;
|
180 |
}
|
181 |
|
182 |
/**
|
183 |
+
* Return json based on the array for generating json.
|
184 |
*
|
185 |
* @return json
|
186 |
*/
|
187 |
public function create_json() {
|
188 |
$_js = trim( $this->maybe_json, '{}' );
|
189 |
+
$_js = preg_split( '//u', $_js, -1, PREG_SPLIT_NO_EMPTY );
|
190 |
|
191 |
foreach ( $_js as $character ) {
|
|
|
192 |
if ( "'" === $character ) {
|
193 |
+
// シングルクォーテーション
|
194 |
$this->proccess_single_quote();
|
195 |
+
} elseif ( '"' === $character ) {
|
196 |
+
// ダブルクォーテーション
|
|
|
197 |
$this->proccess_double_quote();
|
198 |
+
} elseif ( ',' === $character ) {
|
199 |
+
// カンマ
|
|
|
200 |
$this->proccess_comma();
|
201 |
+
} elseif ( ':' === $character ) {
|
202 |
+
// コロン
|
|
|
203 |
$this->proccess_colon();
|
204 |
+
} else {
|
205 |
+
// その他の文字
|
|
|
206 |
$this->push_character( $character );
|
207 |
}
|
208 |
}
|
classes/models/class.mail.php
CHANGED
@@ -1,13 +1,12 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
10 |
-
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
*/
|
12 |
class MW_WP_Form_Mail {
|
13 |
|
@@ -67,7 +66,7 @@ class MW_WP_Form_Mail {
|
|
67 |
protected $Mail_Parser;
|
68 |
|
69 |
/**
|
70 |
-
* Send mail
|
71 |
*
|
72 |
* @return boolean
|
73 |
*/
|
@@ -81,8 +80,8 @@ class MW_WP_Form_Mail {
|
|
81 |
return apply_filters( 'mwform_is_mail_sended', false );
|
82 |
}
|
83 |
|
84 |
-
add_action( 'phpmailer_init'
|
85 |
-
add_filter( 'wp_mail_from'
|
86 |
add_filter( 'wp_mail_from_name', array( $this, '_set_mail_from_name' ) );
|
87 |
|
88 |
$headers = array();
|
@@ -110,17 +109,17 @@ class MW_WP_Form_Mail {
|
|
110 |
$is_mail_sended = wp_mail( $this->to, $this->subject, $this->body, $headers, $this->attachments );
|
111 |
}
|
112 |
|
113 |
-
remove_action( 'phpmailer_init'
|
114 |
-
remove_filter( 'wp_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 ) {
|
@@ -132,9 +131,9 @@ class MW_WP_Form_Mail {
|
|
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 ) {
|
@@ -146,10 +145,9 @@ class MW_WP_Form_Mail {
|
|
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 ) {
|
@@ -160,26 +158,27 @@ class MW_WP_Form_Mail {
|
|
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
|
171 |
$defaults = array(
|
172 |
-
'exclude' => array()
|
173 |
);
|
174 |
-
$options
|
175 |
-
foreach( $array as $key => $value ) {
|
176 |
-
if ( in_array( $key, $options['exclude'] ) )
|
177 |
continue;
|
|
|
178 |
if ( is_array( $value ) && isset( $value['separator'], $value['data'] ) ) {
|
179 |
$_value = '';
|
180 |
if ( is_array( $value['data'] ) ) {
|
181 |
foreach ( $value['data'] as $_val ) {
|
182 |
-
if ( '' !== $_val && ! is_null
|
183 |
$_value = implode( $value['separator'], $value['data'] );
|
184 |
break;
|
185 |
}
|
@@ -197,10 +196,9 @@ class MW_WP_Form_Mail {
|
|
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' );
|
@@ -215,10 +213,9 @@ class MW_WP_Form_Mail {
|
|
215 |
}
|
216 |
|
217 |
/**
|
218 |
-
|
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,16 +223,16 @@ class MW_WP_Form_Mail {
|
|
226 |
$this->bcc = '';
|
227 |
$this->attachments = array();
|
228 |
|
229 |
-
$form_id
|
230 |
-
$form_key
|
231 |
-
$Data
|
232 |
$automatic_reply_email = $Setting->get( 'automatic_reply_email' );
|
233 |
|
234 |
if ( ! $form_id ) {
|
235 |
return;
|
236 |
}
|
237 |
|
238 |
-
$Validation
|
239 |
$is_invalid_mail_address = $Validation->rule(
|
240 |
$automatic_reply_email
|
241 |
);
|
@@ -253,23 +250,22 @@ class MW_WP_Form_Mail {
|
|
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 );
|
263 |
-
$Mail
|
264 |
foreach ( get_object_vars( $Mail ) as $key => $value ) {
|
265 |
$this->$key = $value;
|
266 |
}
|
267 |
}
|
268 |
|
269 |
/**
|
270 |
-
* Save to database
|
271 |
*
|
272 |
-
* @param MW_WP_Form_Setting $Setting
|
273 |
* @return int
|
274 |
*/
|
275 |
public function save( $Setting ) {
|
@@ -279,19 +275,20 @@ class MW_WP_Form_Mail {
|
|
279 |
}
|
280 |
|
281 |
/**
|
282 |
-
* Return saved mail ID
|
283 |
*
|
284 |
* @return int
|
285 |
*/
|
286 |
-
public function get_saved_mail_id(){
|
287 |
if ( $this->Mail_Parser ) {
|
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 ) {
|
@@ -305,7 +302,7 @@ class MW_WP_Form_Mail {
|
|
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";
|
@@ -336,7 +333,7 @@ class MW_WP_Form_Mail {
|
|
336 |
|
337 |
$contents = sprintf(
|
338 |
$contents,
|
339 |
-
|
340 |
$this->to,
|
341 |
$this->sender,
|
342 |
$this->reply_to,
|
@@ -350,7 +347,7 @@ class MW_WP_Form_Mail {
|
|
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 |
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Mail
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Mail {
|
12 |
|
66 |
protected $Mail_Parser;
|
67 |
|
68 |
/**
|
69 |
+
* Send mail.
|
70 |
*
|
71 |
* @return boolean
|
72 |
*/
|
80 |
return apply_filters( 'mwform_is_mail_sended', false );
|
81 |
}
|
82 |
|
83 |
+
add_action( 'phpmailer_init', array( $this, '_set_return_path' ) );
|
84 |
+
add_filter( 'wp_mail_from', array( $this, '_set_mail_from' ) );
|
85 |
add_filter( 'wp_mail_from_name', array( $this, '_set_mail_from_name' ) );
|
86 |
|
87 |
$headers = array();
|
109 |
$is_mail_sended = wp_mail( $this->to, $this->subject, $this->body, $headers, $this->attachments );
|
110 |
}
|
111 |
|
112 |
+
remove_action( 'phpmailer_init', array( $this, '_set_return_path' ) );
|
113 |
+
remove_filter( 'wp_mail_from', array( $this, '_set_mail_from' ) );
|
114 |
remove_filter( 'wp_mail_from_name', array( $this, '_set_mail_from_name' ) );
|
115 |
|
116 |
return apply_filters( 'mwform_is_mail_sended', $is_mail_sended );
|
117 |
}
|
118 |
|
119 |
/**
|
120 |
+
* Set mail from.
|
121 |
*
|
122 |
+
* @param string $email E-mail.
|
123 |
* @return string
|
124 |
*/
|
125 |
public function _set_mail_from( $email ) {
|
131 |
}
|
132 |
|
133 |
/**
|
134 |
+
* Set sender (from name).
|
135 |
*
|
136 |
+
* @param string $sender Sender.
|
137 |
* @return string
|
138 |
*/
|
139 |
public function _set_mail_from_name( $sender ) {
|
145 |
}
|
146 |
|
147 |
/**
|
148 |
+
* Set Return-Path.
|
149 |
*
|
150 |
+
* @param phpmailer $phpmailer phpmailer object.
|
|
|
151 |
*/
|
152 |
public function _set_return_path( $phpmailer ) {
|
153 |
if ( $this->return_path ) {
|
158 |
}
|
159 |
|
160 |
/**
|
161 |
+
* Create mail content from array.
|
162 |
*
|
163 |
+
* @param array $array Posted key and value.
|
164 |
+
* @param array $options Options.
|
165 |
* @return string
|
166 |
*/
|
167 |
public function createBody( array $array, array $options = array() ) {
|
168 |
+
$_ret = '';
|
169 |
$defaults = array(
|
170 |
+
'exclude' => array(),
|
171 |
);
|
172 |
+
$options = array_merge( $defaults, $options );
|
173 |
+
foreach ( $array as $key => $value ) {
|
174 |
+
if ( in_array( $key, $options['exclude'], true ) ) {
|
175 |
continue;
|
176 |
+
}
|
177 |
if ( is_array( $value ) && isset( $value['separator'], $value['data'] ) ) {
|
178 |
$_value = '';
|
179 |
if ( is_array( $value['data'] ) ) {
|
180 |
foreach ( $value['data'] as $_val ) {
|
181 |
+
if ( '' !== $_val && ! is_null( $_val ) ) {
|
182 |
$_value = implode( $value['separator'], $value['data'] );
|
183 |
break;
|
184 |
}
|
196 |
}
|
197 |
|
198 |
/**
|
199 |
+
* Set defaults setting for admin mail.
|
200 |
*
|
201 |
+
* @param MW_WP_Form_Setting $Setting MW_WP_Form_Setting object.
|
|
|
202 |
*/
|
203 |
public function set_admin_mail_raw_params( MW_WP_Form_Setting $Setting ) {
|
204 |
$this->subject = $Setting->get( 'admin_mail_subject' );
|
213 |
}
|
214 |
|
215 |
/**
|
216 |
+
* Set defaults setting for reply mail.
|
217 |
*
|
218 |
+
* @param MW_WP_Form_Setting $Setting MW_WP_Form_Setting object.
|
|
|
219 |
*/
|
220 |
public function set_reply_mail_raw_params( MW_WP_Form_Setting $Setting ) {
|
221 |
$this->to = '';
|
223 |
$this->bcc = '';
|
224 |
$this->attachments = array();
|
225 |
|
226 |
+
$form_id = $Setting->get( 'post_id' );
|
227 |
+
$form_key = MWF_Functions::get_form_key_from_form_id( $form_id );
|
228 |
+
$Data = MW_WP_Form_Data::connect( $form_key );
|
229 |
$automatic_reply_email = $Setting->get( 'automatic_reply_email' );
|
230 |
|
231 |
if ( ! $form_id ) {
|
232 |
return;
|
233 |
}
|
234 |
|
235 |
+
$Validation = new MW_WP_Form_Validation_Rule_Mail( $Data );
|
236 |
$is_invalid_mail_address = $Validation->rule(
|
237 |
$automatic_reply_email
|
238 |
);
|
250 |
}
|
251 |
|
252 |
/**
|
253 |
+
* Replace {name} to content in mail content.
|
254 |
*
|
255 |
+
* @param MW_WP_Form_Setting $Setting MW_WP_Form_Setting object.
|
|
|
256 |
*/
|
257 |
public function parse( $Setting ) {
|
258 |
$this->Mail_Parser = new MW_WP_Form_Mail_Parser( $this, $Setting );
|
259 |
+
$Mail = $this->Mail_Parser->get_parsed_mail_object();
|
260 |
foreach ( get_object_vars( $Mail ) as $key => $value ) {
|
261 |
$this->$key = $value;
|
262 |
}
|
263 |
}
|
264 |
|
265 |
/**
|
266 |
+
* Save to database.
|
267 |
*
|
268 |
+
* @param MW_WP_Form_Setting $Setting MW_WP_Form_Setting object.
|
269 |
* @return int
|
270 |
*/
|
271 |
public function save( $Setting ) {
|
275 |
}
|
276 |
|
277 |
/**
|
278 |
+
* Return saved mail ID.
|
279 |
*
|
280 |
* @return int
|
281 |
*/
|
282 |
+
public function get_saved_mail_id() {
|
283 |
if ( $this->Mail_Parser ) {
|
284 |
return $this->Mail_Parser->get_saved_mail_id();
|
285 |
}
|
286 |
}
|
287 |
|
288 |
/**
|
289 |
+
* Logging that MW WP Form sending mail.
|
290 |
*
|
291 |
+
* @param string $headers Mail headers.
|
292 |
* @return bool
|
293 |
*/
|
294 |
protected function _put_mail_log( $headers ) {
|
302 |
$temp_dir = trailingslashit( $temp_dir['dir'] );
|
303 |
$temp_dir = apply_filters( 'mwform_log_directory', $temp_dir );
|
304 |
|
305 |
+
$contents = '====================';
|
306 |
$contents .= "\n\n";
|
307 |
$contents .= 'Send Date: %1$s';
|
308 |
$contents .= "\n";
|
333 |
|
334 |
$contents = sprintf(
|
335 |
$contents,
|
336 |
+
date_i18n( 'M j Y, H:i:s' ),
|
337 |
$this->to,
|
338 |
$this->sender,
|
339 |
$this->reply_to,
|
347 |
|
348 |
$is_mail_sended = file_put_contents( $temp_dir . '/mw-wp-form-debug.log', $contents, FILE_APPEND );
|
349 |
|
350 |
+
if ( false === $is_mail_sended ) {
|
351 |
return false;
|
352 |
}
|
353 |
|
classes/models/class.parser.php
CHANGED
@@ -1,13 +1,12 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
10 |
-
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
*/
|
12 |
class MW_WP_Form_Parser {
|
13 |
|
@@ -32,7 +31,9 @@ class MW_WP_Form_Parser {
|
|
32 |
protected static $pattern = '/{(.+?)}/';
|
33 |
|
34 |
/**
|
35 |
-
*
|
|
|
|
|
36 |
*/
|
37 |
public function __construct( $Setting ) {
|
38 |
$this->Setting = $Setting;
|
@@ -42,14 +43,21 @@ class MW_WP_Form_Parser {
|
|
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 );
|
@@ -62,23 +70,30 @@ class MW_WP_Form_Parser {
|
|
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 ) {
|
@@ -88,9 +103,9 @@ class MW_WP_Form_Parser {
|
|
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 ) {
|
@@ -104,9 +119,9 @@ class MW_WP_Form_Parser {
|
|
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 ) {
|
@@ -123,14 +138,13 @@ class MW_WP_Form_Parser {
|
|
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;
|
@@ -144,10 +158,10 @@ class MW_WP_Form_Parser {
|
|
144 |
}
|
145 |
|
146 |
/**
|
147 |
-
* Get WP_Post property
|
148 |
*
|
149 |
-
* @param WP_Post|null $post
|
150 |
-
* @param string
|
151 |
* @return string|null
|
152 |
*/
|
153 |
protected function _get_post_property( $post, $meta_key ) {
|
@@ -168,9 +182,9 @@ class MW_WP_Form_Parser {
|
|
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 ) {
|
@@ -185,14 +199,18 @@ class MW_WP_Form_Parser {
|
|
185 |
);
|
186 |
|
187 |
if ( ! empty( $user ) ) {
|
188 |
-
$content = str_replace(
|
189 |
-
$
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
|
|
|
|
|
|
|
|
196 |
} else {
|
197 |
$content = str_replace( $search, '', $content );
|
198 |
}
|
@@ -201,10 +219,10 @@ class MW_WP_Form_Parser {
|
|
201 |
}
|
202 |
|
203 |
/**
|
204 |
-
* Search {$name}
|
205 |
*
|
206 |
-
* @param string $value
|
207 |
-
* @return array
|
208 |
*/
|
209 |
public static function search( $value ) {
|
210 |
preg_match_all(
|
@@ -217,9 +235,9 @@ class MW_WP_Form_Parser {
|
|
217 |
}
|
218 |
|
219 |
/**
|
220 |
-
*
|
221 |
*
|
222 |
-
* @param string $name
|
223 |
* @return string
|
224 |
*/
|
225 |
public function parse( $name ) {
|
@@ -250,12 +268,12 @@ class MW_WP_Form_Parser {
|
|
250 |
}
|
251 |
|
252 |
/**
|
253 |
-
* Apply mwform_custom_mail_tag filter hook
|
254 |
*
|
255 |
-
* @param string
|
256 |
-
* @param string|null $value
|
257 |
-
* @param string
|
258 |
-
* @param string
|
259 |
* @return string
|
260 |
*/
|
261 |
public static function apply_filters_mwform_custom_mail_tag( $form_key, $value, $name, $saved_mail_id = null ) {
|
@@ -276,9 +294,10 @@ class MW_WP_Form_Parser {
|
|
276 |
}
|
277 |
|
278 |
/**
|
279 |
-
* Replace {name} for mail content
|
280 |
*
|
281 |
-
* @param string
|
|
|
282 |
* @return string
|
283 |
*/
|
284 |
protected static function _replace( $value, $callback ) {
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Parser
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Parser {
|
12 |
|
31 |
protected static $pattern = '/{(.+?)}/';
|
32 |
|
33 |
/**
|
34 |
+
* Constructor.
|
35 |
+
*
|
36 |
+
* @param MW_WP_Form_Setting $Setting MW_WP_Form_Setting object.
|
37 |
*/
|
38 |
public function __construct( $Setting ) {
|
39 |
$this->Setting = $Setting;
|
43 |
}
|
44 |
|
45 |
/**
|
46 |
+
* Replace {name} for mail destination.
|
47 |
*
|
48 |
+
* @param string $value Value.
|
49 |
* @return string
|
50 |
*/
|
51 |
public function replace_for_mail_destination( $value ) {
|
52 |
return $this->_replace( $value, array( $this, '_replace_for_mail_destination_callback' ) );
|
53 |
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Callback for replace_for_mail_destination.
|
57 |
+
*
|
58 |
+
* @param array $matches $matches of preg_replace_callback.
|
59 |
+
* @return string|null
|
60 |
+
*/
|
61 |
protected function _replace_for_mail_destination_callback( $matches ) {
|
62 |
$match = $matches[1];
|
63 |
$value = MW_WP_Form_Parser::apply_filters_mwform_custom_mail_tag( $this->form_key, null, $match );
|
70 |
}
|
71 |
|
72 |
/**
|
73 |
+
* Replace {name} for mail content.
|
74 |
*
|
75 |
+
* @param string $value Value.
|
76 |
* @return string
|
77 |
*/
|
78 |
public function replace_for_mail_content( $value ) {
|
79 |
return $this->_replace( $value, array( $this, '_replace_for_mail_content_callback' ) );
|
80 |
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Callback for replace_for_mail_content.
|
84 |
+
*
|
85 |
+
* @param array $matches $matches of preg_replace_callback.
|
86 |
+
* @return string|null
|
87 |
+
*/
|
88 |
protected function _replace_for_mail_content_callback( $matches ) {
|
89 |
$match = $matches[1];
|
90 |
return $this->parse( $match );
|
91 |
}
|
92 |
|
93 |
/**
|
94 |
+
* Replace {name} for input and confirm page.
|
95 |
*
|
96 |
+
* @param string $value Value.
|
97 |
* @return string
|
98 |
*/
|
99 |
public function replace_for_page( $value ) {
|
103 |
}
|
104 |
|
105 |
/**
|
106 |
+
* Replace {foo} in the form. e.g. $post->foo.
|
107 |
*
|
108 |
+
* @param string $value Value.
|
109 |
* @return string
|
110 |
*/
|
111 |
protected function _replace_post_property( $value ) {
|
119 |
}
|
120 |
|
121 |
/**
|
122 |
+
* Callback from preg_replace_callback when enabled querystring setting.
|
123 |
*
|
124 |
+
* @param array $matches $matches of preg_replace_callback.
|
125 |
* @return string|null
|
126 |
*/
|
127 |
protected function _get_post_property_from_querystring( $matches ) {
|
138 |
}
|
139 |
|
140 |
/**
|
141 |
+
* Callback from preg_replace_callback when disabled querystring setting.
|
142 |
*
|
143 |
+
* @param array $matches $matches of preg_replace_callback.
|
144 |
* @return string|null
|
145 |
*/
|
146 |
protected function _get_post_property_from_this( $matches ) {
|
147 |
global $post;
|
|
|
148 |
|
149 |
if ( ! is_singular() ) {
|
150 |
return;
|
158 |
}
|
159 |
|
160 |
/**
|
161 |
+
* Get WP_Post property.
|
162 |
*
|
163 |
+
* @param WP_Post|null $post WP_Post object.
|
164 |
+
* @param string $meta_key Meta data name.
|
165 |
* @return string|null
|
166 |
*/
|
167 |
protected function _get_post_property( $post, $meta_key ) {
|
182 |
}
|
183 |
|
184 |
/**
|
185 |
+
* Replace {property of user} when logged in.
|
186 |
*
|
187 |
+
* @param string $content Post content.
|
188 |
* @return string
|
189 |
*/
|
190 |
protected function _replace_user_property( $content ) {
|
199 |
);
|
200 |
|
201 |
if ( ! empty( $user ) ) {
|
202 |
+
$content = str_replace(
|
203 |
+
$search,
|
204 |
+
array(
|
205 |
+
$user->get( 'ID' ),
|
206 |
+
$user->get( 'user_login' ),
|
207 |
+
$user->get( 'user_email' ),
|
208 |
+
$user->get( 'user_url' ),
|
209 |
+
$user->get( 'user_registered' ),
|
210 |
+
$user->get( 'display_name' ),
|
211 |
+
),
|
212 |
+
$content
|
213 |
+
);
|
214 |
} else {
|
215 |
$content = str_replace( $search, '', $content );
|
216 |
}
|
219 |
}
|
220 |
|
221 |
/**
|
222 |
+
* Search {$name}.
|
223 |
*
|
224 |
+
* @param string $value Value.
|
225 |
+
* @return array
|
226 |
*/
|
227 |
public static function search( $value ) {
|
228 |
preg_match_all(
|
235 |
}
|
236 |
|
237 |
/**
|
238 |
+
* そのキーについて送信された値を返す.
|
239 |
*
|
240 |
+
* @param string $name Posted field name.
|
241 |
* @return string
|
242 |
*/
|
243 |
public function parse( $name ) {
|
268 |
}
|
269 |
|
270 |
/**
|
271 |
+
* Apply mwform_custom_mail_tag filter hook.
|
272 |
*
|
273 |
+
* @param string $form_key Form key.
|
274 |
+
* @param string|null $value Value.
|
275 |
+
* @param string $name Custom mail tag name.
|
276 |
+
* @param string $saved_mail_id Saved mail ID.
|
277 |
* @return string
|
278 |
*/
|
279 |
public static function apply_filters_mwform_custom_mail_tag( $form_key, $value, $name, $saved_mail_id = null ) {
|
294 |
}
|
295 |
|
296 |
/**
|
297 |
+
* Replace {name} for mail content.
|
298 |
*
|
299 |
+
* @param string $value Value.
|
300 |
+
* @param function $callback Callback of preg_replace_callback.
|
301 |
* @return string
|
302 |
*/
|
303 |
protected static function _replace( $value, $callback ) {
|
classes/models/class.session.php
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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,13 +23,16 @@ class MW_WP_Form_Session {
|
|
23 |
protected $session_id;
|
24 |
|
25 |
/**
|
26 |
-
* Transient's survival time
|
|
|
27 |
* @var int
|
28 |
*/
|
29 |
protected $expiration = 1440;
|
30 |
|
31 |
/**
|
32 |
-
*
|
|
|
|
|
33 |
*/
|
34 |
public function __construct( $name ) {
|
35 |
$this->name = MWF_Config::NAME . '_session_' . $name;
|
@@ -38,25 +41,40 @@ class MW_WP_Form_Session {
|
|
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
|
42 |
try {
|
43 |
set_error_handler( array( 'MW_WP_Form_Session', '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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 );
|
@@ -71,11 +89,10 @@ class MW_WP_Form_Session {
|
|
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 );
|
@@ -88,11 +105,10 @@ class MW_WP_Form_Session {
|
|
88 |
}
|
89 |
|
90 |
/**
|
91 |
-
* Push a value
|
92 |
*
|
93 |
-
* @param string $key
|
94 |
-
* @param mixed
|
95 |
-
* @return void
|
96 |
*/
|
97 |
public function push( $key, $value ) {
|
98 |
$transient_data = get_transient( $this->session_id );
|
@@ -106,7 +122,7 @@ class MW_WP_Form_Session {
|
|
106 |
if ( is_array( $transient_data[ $key ] ) ) {
|
107 |
$transient_data[ $key ][] = $value;
|
108 |
} else {
|
109 |
-
$transient_data[ $key ]
|
110 |
$transient_data[ $key ][] = $value;
|
111 |
}
|
112 |
}
|
@@ -114,9 +130,9 @@ class MW_WP_Form_Session {
|
|
114 |
}
|
115 |
|
116 |
/**
|
117 |
-
* Return a value
|
118 |
*
|
119 |
-
* @param string $key
|
120 |
* @return mixed
|
121 |
*/
|
122 |
public function get( $key ) {
|
@@ -127,7 +143,7 @@ class MW_WP_Form_Session {
|
|
127 |
}
|
128 |
|
129 |
/**
|
130 |
-
* Return all values
|
131 |
*
|
132 |
* @return array
|
133 |
*/
|
@@ -140,10 +156,9 @@ class MW_WP_Form_Session {
|
|
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 );
|
@@ -154,16 +169,14 @@ class MW_WP_Form_Session {
|
|
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 |
*/
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Session
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Session {
|
12 |
|
13 |
/**
|
14 |
+
* Session name.
|
15 |
+
*
|
16 |
* @var string
|
17 |
*/
|
18 |
protected $name;
|
23 |
protected $session_id;
|
24 |
|
25 |
/**
|
26 |
+
* Transient's survival time.
|
27 |
+
*
|
28 |
* @var int
|
29 |
*/
|
30 |
protected $expiration = 1440;
|
31 |
|
32 |
/**
|
33 |
+
* Constructor.
|
34 |
+
*
|
35 |
+
* @param string $name Session name.
|
36 |
*/
|
37 |
public function __construct( $name ) {
|
38 |
$this->name = MWF_Config::NAME . '_session_' . $name;
|
41 |
$session_id = $_COOKIE[ $this->name ];
|
42 |
} else {
|
43 |
$session_id = sha1( wp_create_nonce( $this->name ) . ip2long( $this->get_remote_addr() ) . uniqid() );
|
44 |
+
$secure = apply_filters( 'mwform_secure_cookie', is_ssl() );
|
45 |
try {
|
46 |
set_error_handler( array( 'MW_WP_Form_Session', 'error_handler' ) );
|
47 |
setcookie( $this->name, $session_id, 0, COOKIEPATH, COOKIE_DOMAIN, $secure, true );
|
48 |
} catch ( ErrorException $e ) {
|
49 |
+
// No process...
|
50 |
}
|
51 |
}
|
52 |
|
53 |
$this->session_id = $session_id;
|
54 |
}
|
55 |
|
56 |
+
/**
|
57 |
+
* Error handler.
|
58 |
+
*
|
59 |
+
* @param int $errno Contains the level of the error raised.
|
60 |
+
* @param string $errstr Contains the error message.
|
61 |
+
* @param string $errfile Which contains the filename that the error was raised in.
|
62 |
+
* @param int $errline Which contains the line number the error was raised at.
|
63 |
+
*/
|
64 |
+
public static function error_handler(
|
65 |
+
// phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
|
66 |
+
$errno,
|
67 |
+
$errstr,
|
68 |
+
$errfile,
|
69 |
+
$errline
|
70 |
+
// phpcs:disable
|
71 |
+
) {
|
72 |
}
|
73 |
|
74 |
/**
|
75 |
+
* Save values.
|
76 |
*
|
77 |
+
* @param array $data Saving session data.
|
|
|
78 |
*/
|
79 |
public function save( array $data ) {
|
80 |
$transient_data = get_transient( $this->session_id );
|
89 |
}
|
90 |
|
91 |
/**
|
92 |
+
* Save a value.
|
93 |
*
|
94 |
+
* @param string $key Session value name.
|
95 |
+
* @param mixed $value Session value.
|
|
|
96 |
*/
|
97 |
public function set( $key, $value ) {
|
98 |
$transient_data = get_transient( $this->session_id );
|
105 |
}
|
106 |
|
107 |
/**
|
108 |
+
* Push a value.
|
109 |
*
|
110 |
+
* @param string $key Session value name.
|
111 |
+
* @param mixed $value Session value.
|
|
|
112 |
*/
|
113 |
public function push( $key, $value ) {
|
114 |
$transient_data = get_transient( $this->session_id );
|
122 |
if ( is_array( $transient_data[ $key ] ) ) {
|
123 |
$transient_data[ $key ][] = $value;
|
124 |
} else {
|
125 |
+
$transient_data[ $key ] = array( $transient_data[ $key ] );
|
126 |
$transient_data[ $key ][] = $value;
|
127 |
}
|
128 |
}
|
130 |
}
|
131 |
|
132 |
/**
|
133 |
+
* Return a value.
|
134 |
*
|
135 |
+
* @param string $key Session value name.
|
136 |
* @return mixed
|
137 |
*/
|
138 |
public function get( $key ) {
|
143 |
}
|
144 |
|
145 |
/**
|
146 |
+
* Return all values.
|
147 |
*
|
148 |
* @return array
|
149 |
*/
|
156 |
}
|
157 |
|
158 |
/**
|
159 |
+
* Clear a value.
|
160 |
*
|
161 |
+
* @param string $key Session value name.
|
|
|
162 |
*/
|
163 |
public function clear_value( $key ) {
|
164 |
$transient_data = get_transient( $this->session_id );
|
169 |
}
|
170 |
|
171 |
/**
|
172 |
+
* Clear values.
|
|
|
|
|
173 |
*/
|
174 |
public function clear_values() {
|
175 |
delete_transient( $this->session_id );
|
176 |
}
|
177 |
|
178 |
/**
|
179 |
+
* Return $_SERVER['REMOTE_ADDR'].
|
180 |
*
|
181 |
* @return string
|
182 |
*/
|
classes/models/class.setting.php
CHANGED
@@ -1,192 +1,229 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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 = '';
|
97 |
|
98 |
/**
|
99 |
-
* Return-Path
|
|
|
100 |
* @var string
|
101 |
*/
|
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 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
190 |
*/
|
191 |
public function __construct( $post_id ) {
|
192 |
if ( MWF_Config::NAME !== get_post_type( $post_id ) ) {
|
@@ -194,7 +231,12 @@ class MW_WP_Form_Setting {
|
|
194 |
}
|
195 |
|
196 |
$this->post_id = $post_id;
|
197 |
-
|
|
|
|
|
|
|
|
|
|
|
198 |
if ( ! is_array( $values ) ) {
|
199 |
return;
|
200 |
}
|
@@ -203,9 +245,9 @@ class MW_WP_Form_Setting {
|
|
203 |
}
|
204 |
|
205 |
/**
|
206 |
-
* Return a attribute
|
207 |
*
|
208 |
-
* @param string $key
|
209 |
* @return mixed|null
|
210 |
*/
|
211 |
public function get( $key ) {
|
@@ -215,11 +257,10 @@ class MW_WP_Form_Setting {
|
|
215 |
}
|
216 |
|
217 |
/**
|
218 |
-
* Set a attribute
|
219 |
*
|
220 |
-
* @param string $key
|
221 |
-
* @param mixed
|
222 |
-
* @return void
|
223 |
*/
|
224 |
public function set( $key, $value ) {
|
225 |
if ( isset( $this->$key ) ) {
|
@@ -228,9 +269,9 @@ class MW_WP_Form_Setting {
|
|
228 |
}
|
229 |
|
230 |
/**
|
231 |
-
* Set attributes
|
232 |
*
|
233 |
-
* @param array $values
|
234 |
*/
|
235 |
public function sets( array $values ) {
|
236 |
foreach ( $values as $key => $value ) {
|
@@ -239,15 +280,13 @@ class MW_WP_Form_Setting {
|
|
239 |
}
|
240 |
|
241 |
/**
|
242 |
-
* Update with retained data
|
243 |
-
*
|
244 |
-
* @return void
|
245 |
*/
|
246 |
public function save() {
|
247 |
-
$values
|
248 |
$new_values = array();
|
249 |
foreach ( $values as $key => $value ) {
|
250 |
-
if ( 'post_id'
|
251 |
continue;
|
252 |
}
|
253 |
$new_values[ $key ] = $value;
|
@@ -258,9 +297,9 @@ class MW_WP_Form_Setting {
|
|
258 |
}
|
259 |
|
260 |
/**
|
261 |
-
* Return all forms
|
262 |
*
|
263 |
-
* @return array
|
264 |
*/
|
265 |
public function get_posts() {
|
266 |
$Admin = new MW_WP_Form_Admin();
|
@@ -268,9 +307,9 @@ class MW_WP_Form_Setting {
|
|
268 |
}
|
269 |
|
270 |
/**
|
271 |
-
* Return tracking number
|
272 |
*
|
273 |
-
* @return int
|
274 |
*/
|
275 |
public function get_tracking_number() {
|
276 |
$tracking_number = get_post_meta( $this->post_id, MWF_Config::TRACKINGNUMBER, true );
|
@@ -281,9 +320,9 @@ class MW_WP_Form_Setting {
|
|
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;
|
@@ -299,7 +338,7 @@ class MW_WP_Form_Setting {
|
|
299 |
}
|
300 |
|
301 |
/**
|
302 |
-
* Generate verify token for form posts data correct checking
|
303 |
*
|
304 |
* @return string
|
305 |
*/
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Setting
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Setting {
|
12 |
|
13 |
/**
|
14 |
+
* Form ID.
|
15 |
+
*
|
16 |
* @var int
|
17 |
*/
|
18 |
protected $post_id;
|
19 |
|
20 |
/**
|
21 |
+
* Whether to enable URL querystring.
|
22 |
+
*
|
23 |
* @var false|1
|
24 |
*/
|
25 |
protected $querystring = false;
|
26 |
|
27 |
/**
|
28 |
+
* Whether to use database.
|
29 |
+
*
|
30 |
* @var false|1
|
31 |
*/
|
32 |
protected $usedb = false;
|
33 |
|
34 |
/**
|
35 |
+
* Reply mail subject.
|
36 |
+
*
|
37 |
* @var string
|
38 |
*/
|
39 |
protected $mail_subject = '';
|
40 |
|
41 |
/**
|
42 |
+
* Reply mail from.
|
43 |
+
*
|
44 |
* @var string
|
45 |
*/
|
46 |
protected $mail_from = '';
|
47 |
|
48 |
/**
|
49 |
+
* Reply mail sender.
|
50 |
+
*
|
51 |
* @var string
|
52 |
*/
|
53 |
protected $mail_sender = '';
|
54 |
|
55 |
/**
|
56 |
+
* Reply mail Reply-to.
|
57 |
+
*
|
58 |
* @var string
|
59 |
*/
|
60 |
protected $mail_reply_to = '';
|
61 |
|
62 |
/**
|
63 |
+
* Reply mail content.
|
64 |
+
*
|
65 |
* @var string
|
66 |
*/
|
67 |
protected $mail_content = '';
|
68 |
|
69 |
/**
|
70 |
+
* The name of the form field storing the destination of the automatic reply e-mail.
|
71 |
+
*
|
72 |
* @var string
|
73 |
*/
|
74 |
protected $automatic_reply_email = '';
|
75 |
|
76 |
/**
|
77 |
+
* Admin mail To.
|
78 |
+
*
|
79 |
* @var string
|
80 |
*/
|
81 |
protected $mail_to = '';
|
82 |
|
83 |
/**
|
84 |
+
* Admin mail CC.
|
85 |
+
*
|
86 |
* @var string
|
87 |
*/
|
88 |
protected $mail_cc = '';
|
89 |
|
90 |
/**
|
91 |
+
* Admin mail BCC.
|
92 |
+
*
|
93 |
* @var string
|
94 |
*/
|
95 |
protected $mail_bcc = '';
|
96 |
|
97 |
/**
|
98 |
+
* Admin mail Reply-to.
|
99 |
+
*
|
100 |
* @var string
|
101 |
*/
|
102 |
protected $admin_mail_reply_to = '';
|
103 |
|
104 |
/**
|
105 |
+
* Admin mail subject.
|
106 |
+
*
|
107 |
* @var string
|
108 |
*/
|
109 |
protected $admin_mail_subject = '';
|
110 |
|
111 |
/**
|
112 |
+
* Return-Path.
|
113 |
+
*
|
114 |
* @var string
|
115 |
*/
|
116 |
protected $mail_return_path = '';
|
117 |
|
118 |
/**
|
119 |
+
* Admin mail from.
|
120 |
+
*
|
121 |
* @var string
|
122 |
*/
|
123 |
protected $admin_mail_from = '';
|
124 |
|
125 |
/**
|
126 |
+
* Admin mail sender.
|
127 |
+
*
|
128 |
* @var string
|
129 |
*/
|
130 |
protected $admin_mail_sender = '';
|
131 |
|
132 |
/**
|
133 |
+
* Admin mail content.
|
134 |
+
*
|
135 |
* @var string
|
136 |
*/
|
137 |
protected $admin_mail_content = '';
|
138 |
|
139 |
/**
|
140 |
+
* Input field name that targeted akismet author.
|
141 |
+
*
|
142 |
* @var string
|
143 |
*/
|
144 |
protected $akismet_author = '';
|
145 |
|
146 |
/**
|
147 |
+
* Input field name that targeted akismet e-mail.
|
148 |
+
*
|
149 |
* @var string
|
150 |
*/
|
151 |
protected $akismet_author_email = '';
|
152 |
|
153 |
/**
|
154 |
+
* Input field name that targeted akismet URL.
|
155 |
+
*
|
156 |
* @var string
|
157 |
*/
|
158 |
protected $akismet_author_url = '';
|
159 |
|
160 |
/**
|
161 |
+
* Complete screen message.
|
162 |
+
*
|
163 |
* @var string
|
164 |
*/
|
165 |
protected $complete_message = '';
|
166 |
|
167 |
/**
|
168 |
+
* Input screen URL.
|
169 |
+
*
|
170 |
* @var string
|
171 |
*/
|
172 |
protected $input_url = '';
|
173 |
|
174 |
/**
|
175 |
+
* Confirm screen URL.
|
176 |
+
*
|
177 |
* @var string
|
178 |
*/
|
179 |
protected $confirmation_url = '';
|
180 |
|
181 |
/**
|
182 |
+
* Complete screen URL.
|
183 |
+
*
|
184 |
* @var string
|
185 |
*/
|
186 |
protected $complete_url = '';
|
187 |
|
188 |
/**
|
189 |
+
* Validation error screen url.
|
190 |
+
*
|
191 |
* @var string
|
192 |
*/
|
193 |
protected $validation_error_url = '';
|
194 |
|
195 |
/**
|
196 |
+
* Array of validation rules set in the form.
|
197 |
+
*
|
198 |
* @var array
|
199 |
*/
|
200 |
protected $validation = array();
|
201 |
|
202 |
/**
|
203 |
+
* Style set in the form.
|
204 |
+
*
|
205 |
* @var string
|
206 |
*/
|
207 |
protected $style = '';
|
208 |
|
209 |
/**
|
210 |
+
* Whether to scroll to the position of the form.
|
211 |
+
*
|
212 |
* @var false|1
|
213 |
*/
|
214 |
protected $scroll = false;
|
215 |
|
216 |
/**
|
217 |
+
* Extended properties.
|
218 |
+
*
|
219 |
+
* @var array
|
220 |
+
*/
|
221 |
+
protected $extend = array();
|
222 |
+
|
223 |
+
/**
|
224 |
+
* Constructor.
|
225 |
+
*
|
226 |
+
* @param int $post_id Post ID.
|
227 |
*/
|
228 |
public function __construct( $post_id ) {
|
229 |
if ( MWF_Config::NAME !== get_post_type( $post_id ) ) {
|
231 |
}
|
232 |
|
233 |
$this->post_id = $post_id;
|
234 |
+
|
235 |
+
$form_key = MWF_Functions::get_form_key_from_form_id( $this->post_id );
|
236 |
+
$this->extend = apply_filters( 'mwform_settings_extend_fields', $this->extend );
|
237 |
+
$this->extend = apply_filters( 'mwform_settings_extend_fields_' . $form_key, $this->extend );
|
238 |
+
|
239 |
+
$values = get_post_meta( $this->post_id, MWF_Config::NAME, true );
|
240 |
if ( ! is_array( $values ) ) {
|
241 |
return;
|
242 |
}
|
245 |
}
|
246 |
|
247 |
/**
|
248 |
+
* Return a attribute.
|
249 |
*
|
250 |
+
* @param string $key Setting name.
|
251 |
* @return mixed|null
|
252 |
*/
|
253 |
public function get( $key ) {
|
257 |
}
|
258 |
|
259 |
/**
|
260 |
+
* Set a attribute.
|
261 |
*
|
262 |
+
* @param string $key Setting name.
|
263 |
+
* @param mixed $value Setting value.
|
|
|
264 |
*/
|
265 |
public function set( $key, $value ) {
|
266 |
if ( isset( $this->$key ) ) {
|
269 |
}
|
270 |
|
271 |
/**
|
272 |
+
* Set attributes.
|
273 |
*
|
274 |
+
* @param array $values Setting valuels.
|
275 |
*/
|
276 |
public function sets( array $values ) {
|
277 |
foreach ( $values as $key => $value ) {
|
280 |
}
|
281 |
|
282 |
/**
|
283 |
+
* Update with retained data.
|
|
|
|
|
284 |
*/
|
285 |
public function save() {
|
286 |
+
$values = get_object_vars( $this );
|
287 |
$new_values = array();
|
288 |
foreach ( $values as $key => $value ) {
|
289 |
+
if ( 'post_id' === $key ) {
|
290 |
continue;
|
291 |
}
|
292 |
$new_values[ $key ] = $value;
|
297 |
}
|
298 |
|
299 |
/**
|
300 |
+
* Return all forms.
|
301 |
*
|
302 |
+
* @return array
|
303 |
*/
|
304 |
public function get_posts() {
|
305 |
$Admin = new MW_WP_Form_Admin();
|
307 |
}
|
308 |
|
309 |
/**
|
310 |
+
* Return tracking number.
|
311 |
*
|
312 |
+
* @return int
|
313 |
*/
|
314 |
public function get_tracking_number() {
|
315 |
$tracking_number = get_post_meta( $this->post_id, MWF_Config::TRACKINGNUMBER, true );
|
320 |
}
|
321 |
|
322 |
/**
|
323 |
+
* Update traking number.
|
324 |
*
|
325 |
+
* @param null|int $count Update to it if specified.
|
326 |
*/
|
327 |
public function update_tracking_number( $count = null ) {
|
328 |
$new_tracking_number = null;
|
338 |
}
|
339 |
|
340 |
/**
|
341 |
+
* Generate verify token for form posts data correct checking.
|
342 |
*
|
343 |
* @return string
|
344 |
*/
|
classes/models/class.validation-rules.php
CHANGED
@@ -1,18 +1,17 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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 |
|
@@ -22,7 +21,8 @@ class MW_WP_Form_Validation_Rules {
|
|
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(
|
@@ -51,7 +51,9 @@ class MW_WP_Form_Validation_Rules {
|
|
51 |
);
|
52 |
|
53 |
/**
|
54 |
-
*
|
|
|
|
|
55 |
*/
|
56 |
private function __construct( $form_key ) {
|
57 |
$this->form_key = $form_key;
|
@@ -66,6 +68,12 @@ class MW_WP_Form_Validation_Rules {
|
|
66 |
}
|
67 |
}
|
68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
public static function instantiation( $form_key ) {
|
70 |
if ( isset( self::$Instances[ $form_key ] ) ) {
|
71 |
return self::$Instances[ $form_key ];
|
@@ -78,7 +86,7 @@ class MW_WP_Form_Validation_Rules {
|
|
78 |
/**
|
79 |
* Instantiation of validation rules. Set in the array through the hook.
|
80 |
*
|
81 |
-
* @return
|
82 |
*/
|
83 |
public function get_validation_rules() {
|
84 |
self::$validation_rules = apply_filters(
|
@@ -102,9 +110,9 @@ class MW_WP_Form_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 ) {
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Validation_Rules
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Validation_Rules {
|
12 |
|
13 |
/**
|
14 |
+
* @var array Array of MW_WP_Form_Validation_Rules.
|
15 |
*/
|
16 |
protected static $Instances;
|
17 |
|
21 |
protected $form_key;
|
22 |
|
23 |
/**
|
24 |
+
* Array of validation rules. Definition is necessary to fix the order.
|
25 |
+
*
|
26 |
* @var array
|
27 |
*/
|
28 |
protected static $validation_rules = array(
|
51 |
);
|
52 |
|
53 |
/**
|
54 |
+
* Constructor.
|
55 |
+
*
|
56 |
+
* @param string $form_key Form key.
|
57 |
*/
|
58 |
private function __construct( $form_key ) {
|
59 |
$this->form_key = $form_key;
|
68 |
}
|
69 |
}
|
70 |
|
71 |
+
/**
|
72 |
+
* Instantiation.
|
73 |
+
*
|
74 |
+
* @param string $form_key Form key.
|
75 |
+
* @return MW_WP_Form_Validation_Rules
|
76 |
+
*/
|
77 |
public static function instantiation( $form_key ) {
|
78 |
if ( isset( self::$Instances[ $form_key ] ) ) {
|
79 |
return self::$Instances[ $form_key ];
|
86 |
/**
|
87 |
* Instantiation of validation rules. Set in the array through the hook.
|
88 |
*
|
89 |
+
* @return array
|
90 |
*/
|
91 |
public function get_validation_rules() {
|
92 |
self::$validation_rules = apply_filters(
|
110 |
}
|
111 |
|
112 |
/**
|
113 |
+
* Return class name from filename of validation rule.
|
114 |
*
|
115 |
+
* @param string $filename File name.
|
116 |
* @return string
|
117 |
*/
|
118 |
protected static function _get_class_name_from_validation_rule_filename( $filename ) {
|
classes/models/class.validation.php
CHANGED
@@ -1,13 +1,12 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
10 |
-
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
*/
|
12 |
class MW_WP_Form_Validation {
|
13 |
|
@@ -27,13 +26,16 @@ class MW_WP_Form_Validation {
|
|
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 |
-
*
|
|
|
|
|
37 |
*/
|
38 |
public function __construct( $form_key ) {
|
39 |
$this->form_key = $form_key;
|
@@ -65,7 +67,7 @@ class MW_WP_Form_Validation {
|
|
65 |
}
|
66 |
}
|
67 |
|
68 |
-
$Akismet
|
69 |
$akismet_check = $Akismet->is_valid(
|
70 |
$this->Setting->get( 'akismet_author' ),
|
71 |
$this->Setting->get( 'akismet_author_email' ),
|
@@ -76,7 +78,7 @@ class MW_WP_Form_Validation {
|
|
76 |
$this->set_rule( MWF_Config::AKISMET, 'akismet_check' );
|
77 |
}
|
78 |
|
79 |
-
|
80 |
'mwform_validation_' . $this->form_key,
|
81 |
$this,
|
82 |
$this->Data->gets(),
|
@@ -87,22 +89,24 @@ class MW_WP_Form_Validation {
|
|
87 |
/**
|
88 |
* Set validation rule of the form field.
|
89 |
*
|
90 |
-
* @param string $key
|
91 |
-
* @param string $rule
|
92 |
-
* @param array
|
93 |
* @return MW_WP_Form_Validation
|
94 |
*/
|
95 |
public function set_rule( $key, $rule, array $options = array() ) {
|
96 |
$rules = 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 |
*/
|
@@ -116,7 +120,7 @@ class MW_WP_Form_Validation {
|
|
116 |
return false;
|
117 |
}
|
118 |
|
119 |
-
foreach ( $validate as $
|
120 |
if ( ! is_array( $validation_rule ) ) {
|
121 |
return false;
|
122 |
}
|
@@ -139,9 +143,9 @@ class MW_WP_Form_Validation {
|
|
139 |
}
|
140 |
|
141 |
/**
|
142 |
-
* Validation check form fields
|
143 |
*
|
144 |
-
* @return bool
|
145 |
*/
|
146 |
public function is_valid() {
|
147 |
foreach ( $this->validate as $key => $rules ) {
|
@@ -151,6 +155,11 @@ class MW_WP_Form_Validation {
|
|
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()',
|
@@ -161,10 +170,10 @@ class MW_WP_Form_Validation {
|
|
161 |
}
|
162 |
|
163 |
/**
|
164 |
-
* Validation check the one form field
|
165 |
*
|
166 |
-
* @param string $key
|
167 |
-
* @return bool
|
168 |
*/
|
169 |
public function is_valid_field( $key ) {
|
170 |
if ( isset( $this->validate[ $key ] ) ) {
|
@@ -174,7 +183,17 @@ class MW_WP_Form_Validation {
|
|
174 |
return (bool) ! $this->Data->get_validation_error( $key );
|
175 |
}
|
176 |
|
177 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
MWF_Functions::deprecated_message(
|
179 |
'MW_WP_Form_Validation::single_check()',
|
180 |
'MW_WP_Form_Validation::is_valid_field()'
|
@@ -184,10 +203,10 @@ class MW_WP_Form_Validation {
|
|
184 |
}
|
185 |
|
186 |
/**
|
187 |
-
* Set varidation errors into MW_WP_Form_Data
|
188 |
*
|
189 |
-
* @param string $key
|
190 |
-
* @param array
|
191 |
*/
|
192 |
protected function _is_valid( $key, array $rules ) {
|
193 |
$Validation_Rules = MW_WP_Form_Validation_Rules::instantiation( $this->form_key );
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Validation
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Validation {
|
12 |
|
26 |
protected $Setting;
|
27 |
|
28 |
/**
|
29 |
+
* Array of name of validated and array of validation rules for it pairs.
|
30 |
+
*
|
31 |
* @var array
|
32 |
*/
|
33 |
protected $validate = array();
|
34 |
|
35 |
/**
|
36 |
+
* Constructor.
|
37 |
+
*
|
38 |
+
* @param string $form_key Form key.
|
39 |
*/
|
40 |
public function __construct( $form_key ) {
|
41 |
$this->form_key = $form_key;
|
67 |
}
|
68 |
}
|
69 |
|
70 |
+
$Akismet = new MW_WP_Form_Akismet();
|
71 |
$akismet_check = $Akismet->is_valid(
|
72 |
$this->Setting->get( 'akismet_author' ),
|
73 |
$this->Setting->get( 'akismet_author_email' ),
|
78 |
$this->set_rule( MWF_Config::AKISMET, 'akismet_check' );
|
79 |
}
|
80 |
|
81 |
+
apply_filters(
|
82 |
'mwform_validation_' . $this->form_key,
|
83 |
$this,
|
84 |
$this->Data->gets(),
|
89 |
/**
|
90 |
* Set validation rule of the form field.
|
91 |
*
|
92 |
+
* @param string $key Target field name.
|
93 |
+
* @param string $rule Validation name.
|
94 |
+
* @param array $options Options.
|
95 |
* @return MW_WP_Form_Validation
|
96 |
*/
|
97 |
public function set_rule( $key, $rule, array $options = array() ) {
|
98 |
$rules = array(
|
99 |
'rule' => strtolower( $rule ),
|
100 |
+
'options' => $options,
|
101 |
);
|
102 |
+
|
103 |
$this->validate[ $key ][] = $rules;
|
104 |
+
|
105 |
return $this;
|
106 |
}
|
107 |
|
108 |
/**
|
109 |
+
* for unit tests.
|
110 |
*
|
111 |
* @return bool
|
112 |
*/
|
120 |
return false;
|
121 |
}
|
122 |
|
123 |
+
foreach ( $validate as $validation_rule ) {
|
124 |
if ( ! is_array( $validation_rule ) ) {
|
125 |
return false;
|
126 |
}
|
143 |
}
|
144 |
|
145 |
/**
|
146 |
+
* Validation check form fields.
|
147 |
*
|
148 |
+
* @return bool
|
149 |
*/
|
150 |
public function is_valid() {
|
151 |
foreach ( $this->validate as $key => $rules ) {
|
155 |
return (bool) ! $this->Data->get_validation_errors();
|
156 |
}
|
157 |
|
158 |
+
/**
|
159 |
+
* Return true when valid.
|
160 |
+
*
|
161 |
+
* @return boolean
|
162 |
+
*/
|
163 |
public function check() {
|
164 |
MWF_Functions::deprecated_message(
|
165 |
'MW_WP_Form_Validation::check()',
|
170 |
}
|
171 |
|
172 |
/**
|
173 |
+
* Validation check the one form field.
|
174 |
*
|
175 |
+
* @param string $key Target field name.
|
176 |
+
* @return bool
|
177 |
*/
|
178 |
public function is_valid_field( $key ) {
|
179 |
if ( isset( $this->validate[ $key ] ) ) {
|
183 |
return (bool) ! $this->Data->get_validation_error( $key );
|
184 |
}
|
185 |
|
186 |
+
/**
|
187 |
+
* Return true when valid.
|
188 |
+
*
|
189 |
+
* @param string $key Target field name.
|
190 |
+
* @return boolean
|
191 |
+
*/
|
192 |
+
public function single_check(
|
193 |
+
// phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
|
194 |
+
$key
|
195 |
+
// phpcs:enable
|
196 |
+
) {
|
197 |
MWF_Functions::deprecated_message(
|
198 |
'MW_WP_Form_Validation::single_check()',
|
199 |
'MW_WP_Form_Validation::is_valid_field()'
|
203 |
}
|
204 |
|
205 |
/**
|
206 |
+
* Set varidation errors into MW_WP_Form_Data.
|
207 |
*
|
208 |
+
* @param string $key Target field name.
|
209 |
+
* @param array $rules Rules.
|
210 |
*/
|
211 |
protected function _is_valid( $key, array $rules ) {
|
212 |
$Validation_Rules = MW_WP_Form_Validation_Rules::instantiation( $this->form_key );
|
classes/services/class.exec-shortcode.php
CHANGED
@@ -1,13 +1,12 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
10 |
-
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
*/
|
12 |
class MW_WP_Form_Exec_Shortcode {
|
13 |
|
@@ -22,7 +21,7 @@ class MW_WP_Form_Exec_Shortcode {
|
|
22 |
protected $form_key;
|
23 |
|
24 |
/**
|
25 |
-
* @
|
26 |
*/
|
27 |
protected $Data;
|
28 |
|
@@ -36,8 +35,11 @@ class MW_WP_Form_Exec_Shortcode {
|
|
36 |
*/
|
37 |
protected $Setting;
|
38 |
|
|
|
|
|
|
|
39 |
public function __construct() {
|
40 |
-
add_shortcode( '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' ) );
|
@@ -48,9 +50,10 @@ class MW_WP_Form_Exec_Shortcode {
|
|
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 );
|
@@ -70,8 +73,8 @@ class MW_WP_Form_Exec_Shortcode {
|
|
70 |
|
71 |
add_action( 'wp_footer', array( $this->Data, 'clear_values' ) );
|
72 |
|
73 |
-
$Validation
|
74 |
-
$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() ) {
|
@@ -94,11 +97,14 @@ class MW_WP_Form_Exec_Shortcode {
|
|
94 |
$content = '';
|
95 |
}
|
96 |
|
97 |
-
do_action( 'mwform_after_load_content_' .
|
98 |
|
99 |
// Enqueue scroll to MW WP Form script
|
100 |
if ( $this->Setting->get( 'scroll' ) ) {
|
101 |
-
if (
|
|
|
|
|
|
|
102 |
add_action( 'wp_footer', array( $this, '_enqueue_scroll_script' ) );
|
103 |
}
|
104 |
}
|
@@ -112,15 +118,16 @@ class MW_WP_Form_Exec_Shortcode {
|
|
112 |
}
|
113 |
|
114 |
/**
|
115 |
-
* Add shortcode for [mwform]
|
116 |
*
|
117 |
-
* @param
|
118 |
-
* @
|
|
|
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 );
|
@@ -140,10 +147,11 @@ class MW_WP_Form_Exec_Shortcode {
|
|
140 |
}
|
141 |
|
142 |
/**
|
143 |
-
* Add shortcode for [mwform_complete_message]
|
144 |
*
|
145 |
-
* @param array
|
146 |
-
* @
|
|
|
147 |
*/
|
148 |
public function _mwform_complete_message( $attributes, $content = '' ) {
|
149 |
return sprintf(
|
@@ -157,9 +165,9 @@ class MW_WP_Form_Exec_Shortcode {
|
|
157 |
}
|
158 |
|
159 |
/**
|
160 |
-
* Display input page
|
161 |
*
|
162 |
-
* @return string
|
163 |
*/
|
164 |
protected function _get_input_page_content() {
|
165 |
global $post;
|
@@ -176,21 +184,21 @@ class MW_WP_Form_Exec_Shortcode {
|
|
176 |
}
|
177 |
|
178 |
/**
|
179 |
-
* Display confirm page
|
180 |
*
|
181 |
-
* @return string
|
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
|
191 |
*/
|
192 |
protected function _get_complete_page_content() {
|
193 |
-
$Parser = new MW_WP_Form_Parser(
|
194 |
|
195 |
$content = apply_filters(
|
196 |
'mwform_complete_content_raw_' . $this->form_key,
|
@@ -210,9 +218,9 @@ class MW_WP_Form_Exec_Shortcode {
|
|
210 |
}
|
211 |
|
212 |
/**
|
213 |
-
* Display validation error page
|
214 |
*
|
215 |
-
* @return string
|
216 |
*/
|
217 |
protected function _get_send_error_page_content() {
|
218 |
$content = sprintf(
|
@@ -261,12 +269,12 @@ class MW_WP_Form_Exec_Shortcode {
|
|
261 |
$complete = $this->Setting->get( 'complete_url' );
|
262 |
$error = $this->Setting->get( 'validation_error_url' );
|
263 |
|
264 |
-
|
265 |
return false;
|
266 |
}
|
267 |
|
268 |
-
$Validation
|
269 |
-
$is_valid
|
270 |
|
271 |
$Redirected = new MW_WP_Form_Redirected( $this->form_key, $this->Setting, $is_valid, $this->Data->get_post_condition() );
|
272 |
if ( $Redirected->get_request_uri() === $Redirected->get_url() ) {
|
@@ -277,9 +285,9 @@ class MW_WP_Form_Exec_Shortcode {
|
|
277 |
}
|
278 |
|
279 |
/**
|
280 |
-
* Line breaks content according to wpautop()
|
281 |
*
|
282 |
-
* @param string $content
|
283 |
* @return string
|
284 |
*/
|
285 |
protected function _wpautop( $content ) {
|
@@ -305,9 +313,9 @@ class MW_WP_Form_Exec_Shortcode {
|
|
305 |
}
|
306 |
|
307 |
/**
|
308 |
-
* Replace {key} in the form
|
309 |
*
|
310 |
-
* @param string $content
|
311 |
* @return string
|
312 |
*/
|
313 |
public function _get_the_content( $content ) {
|
@@ -317,9 +325,9 @@ class MW_WP_Form_Exec_Shortcode {
|
|
317 |
}
|
318 |
|
319 |
/**
|
320 |
-
* Hidden field for file upload name attribute
|
321 |
*
|
322 |
-
* @param array|string $upload_file_keys
|
323 |
*/
|
324 |
protected function _get_upload_file_hidden( $upload_file_keys ) {
|
325 |
$Form = new MW_WP_Form_Form();
|
@@ -337,9 +345,9 @@ class MW_WP_Form_Exec_Shortcode {
|
|
337 |
}
|
338 |
|
339 |
/**
|
340 |
-
* Get classes for backward compatibility
|
341 |
*
|
342 |
-
* @return string
|
343 |
*/
|
344 |
protected function _get_old_confirm_class() {
|
345 |
if ( 'confirm' === $this->view_flg ) {
|
@@ -348,7 +356,7 @@ class MW_WP_Form_Exec_Shortcode {
|
|
348 |
}
|
349 |
|
350 |
/**
|
351 |
-
* Get classes for style feature
|
352 |
*
|
353 |
* @return string
|
354 |
*/
|
@@ -360,16 +368,19 @@ class MW_WP_Form_Exec_Shortcode {
|
|
360 |
}
|
361 |
|
362 |
/**
|
363 |
-
* ショートコード mwform_formkey をもとにフォームの ID
|
364 |
*
|
365 |
-
* @param array $attributes
|
366 |
-
* @return string
|
367 |
*/
|
368 |
protected function _get_form_id_by_mwform_formkey( $attributes ) {
|
369 |
-
$attributes = shortcode_atts(
|
370 |
-
|
371 |
-
|
372 |
-
|
|
|
|
|
|
|
373 |
|
374 |
if ( ! empty( $attributes['slug'] ) ) {
|
375 |
$post = get_page_by_path( $attributes['slug'], OBJECT, MWF_Config::NAME );
|
@@ -383,9 +394,9 @@ class MW_WP_Form_Exec_Shortcode {
|
|
383 |
}
|
384 |
|
385 |
/**
|
386 |
-
* Add nonce field and form meta data
|
387 |
*
|
388 |
-
* @param string $html
|
389 |
* @return string
|
390 |
*/
|
391 |
public function _mwform_form_end_html( $html ) {
|
@@ -435,9 +446,13 @@ class MW_WP_Form_Exec_Shortcode {
|
|
435 |
false,
|
436 |
true
|
437 |
);
|
438 |
-
wp_localize_script(
|
439 |
-
|
440 |
-
|
|
|
|
|
|
|
|
|
441 |
wp_enqueue_script( MWF_Config::NAME . '-scroll' );
|
442 |
}
|
443 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Exec_Shortcode
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Exec_Shortcode {
|
12 |
|
21 |
protected $form_key;
|
22 |
|
23 |
/**
|
24 |
+
* @var MW_WP_Form_Data
|
25 |
*/
|
26 |
protected $Data;
|
27 |
|
35 |
*/
|
36 |
protected $Setting;
|
37 |
|
38 |
+
/**
|
39 |
+
* Constructor.
|
40 |
+
*/
|
41 |
public function __construct() {
|
42 |
+
add_shortcode( 'mwform', array( $this, '_mwform' ) );
|
43 |
add_shortcode( 'mwform_complete_message', array( $this, '_mwform_complete_message' ) );
|
44 |
|
45 |
add_filter( 'mwform_form_end_html', array( $this, '_mwform_form_end_html' ) );
|
50 |
/**
|
51 |
* Add shortcode for [mwform_formkey]
|
52 |
*
|
|
|
|
|
53 |
* @example [mwform_formkey key="post_id"]
|
54 |
+
*
|
55 |
+
* @param array $attributes Attributes of [mwform_formkey].
|
56 |
+
* @return string
|
57 |
*/
|
58 |
public function initialize( $attributes ) {
|
59 |
$this->form_id = $this->_get_form_id_by_mwform_formkey( $attributes );
|
73 |
|
74 |
add_action( 'wp_footer', array( $this->Data, 'clear_values' ) );
|
75 |
|
76 |
+
$Validation = new MW_WP_Form_Validation( $this->form_key );
|
77 |
+
$is_valid = $Validation->is_valid();
|
78 |
|
79 |
$Redirected = new MW_WP_Form_Redirected( $this->form_key, $this->Setting, $is_valid, $this->Data->get_post_condition() );
|
80 |
if ( $Redirected->get_request_uri() !== $Redirected->get_url() && $Redirected->get_url() ) {
|
97 |
$content = '';
|
98 |
}
|
99 |
|
100 |
+
do_action( 'mwform_after_load_content_' . $this->form_key );
|
101 |
|
102 |
// Enqueue scroll to MW WP Form script
|
103 |
if ( $this->Setting->get( 'scroll' ) ) {
|
104 |
+
if (
|
105 |
+
'input' !== $this->view_flg
|
106 |
+
|| in_array( $this->Data->get_post_condition(), array( 'back', 'confirm', 'complete' ), true )
|
107 |
+
) {
|
108 |
add_action( 'wp_footer', array( $this, '_enqueue_scroll_script' ) );
|
109 |
}
|
110 |
}
|
118 |
}
|
119 |
|
120 |
/**
|
121 |
+
* Add shortcode for [mwform].
|
122 |
*
|
123 |
+
* @param array $attributes Attributes of [mwform].
|
124 |
+
* @param string $content Content of [mwform].
|
125 |
+
* @return string
|
126 |
*/
|
127 |
public function _mwform( $attributes, $content = '' ) {
|
128 |
$Form = new MW_WP_Form_Form();
|
129 |
|
130 |
+
if ( in_array( $this->view_flg, array( 'input', 'confirm' ), true ) ) {
|
131 |
$content = $this->_get_the_content( $content );
|
132 |
$upload_file_keys = $this->Data->get_post_value_by_key( MWF_Config::UPLOAD_FILE_KEYS );
|
133 |
$upload_file_hidden = $this->_get_upload_file_hidden( $upload_file_keys );
|
147 |
}
|
148 |
|
149 |
/**
|
150 |
+
* Add shortcode for [mwform_complete_message].
|
151 |
*
|
152 |
+
* @param array $attributes Attributes of [mwform_complete_message].
|
153 |
+
* @param string $content Content of [mwform_complete_message].
|
154 |
+
* @return string
|
155 |
*/
|
156 |
public function _mwform_complete_message( $attributes, $content = '' ) {
|
157 |
return sprintf(
|
165 |
}
|
166 |
|
167 |
/**
|
168 |
+
* Display input page.
|
169 |
*
|
170 |
+
* @return string
|
171 |
*/
|
172 |
protected function _get_input_page_content() {
|
173 |
global $post;
|
184 |
}
|
185 |
|
186 |
/**
|
187 |
+
* Display confirm page.
|
188 |
*
|
189 |
+
* @return string
|
190 |
*/
|
191 |
+
protected function _get_confirm_page_content() {
|
192 |
return $this->_get_input_page_content();
|
193 |
}
|
194 |
|
195 |
/**
|
196 |
+
* Display complete page.
|
197 |
*
|
198 |
+
* @return string
|
199 |
*/
|
200 |
protected function _get_complete_page_content() {
|
201 |
+
$Parser = new MW_WP_Form_Parser( $this->Setting );
|
202 |
|
203 |
$content = apply_filters(
|
204 |
'mwform_complete_content_raw_' . $this->form_key,
|
218 |
}
|
219 |
|
220 |
/**
|
221 |
+
* Display validation error page.
|
222 |
*
|
223 |
+
* @return string
|
224 |
*/
|
225 |
protected function _get_send_error_page_content() {
|
226 |
$content = sprintf(
|
269 |
$complete = $this->Setting->get( 'complete_url' );
|
270 |
$error = $this->Setting->get( 'validation_error_url' );
|
271 |
|
272 |
+
if ( ! $confirm && ! $complete && ! $error ) {
|
273 |
return false;
|
274 |
}
|
275 |
|
276 |
+
$Validation = new MW_WP_Form_Validation( $this->form_key );
|
277 |
+
$is_valid = $Validation->is_valid();
|
278 |
|
279 |
$Redirected = new MW_WP_Form_Redirected( $this->form_key, $this->Setting, $is_valid, $this->Data->get_post_condition() );
|
280 |
if ( $Redirected->get_request_uri() === $Redirected->get_url() ) {
|
285 |
}
|
286 |
|
287 |
/**
|
288 |
+
* Line breaks content according to wpautop().
|
289 |
*
|
290 |
+
* @param string $content Post content.
|
291 |
* @return string
|
292 |
*/
|
293 |
protected function _wpautop( $content ) {
|
313 |
}
|
314 |
|
315 |
/**
|
316 |
+
* Replace {key} in the form.
|
317 |
*
|
318 |
+
* @param string $content Post content.
|
319 |
* @return string
|
320 |
*/
|
321 |
public function _get_the_content( $content ) {
|
325 |
}
|
326 |
|
327 |
/**
|
328 |
+
* Hidden field for file upload name attribute.
|
329 |
*
|
330 |
+
* @param array|string $upload_file_keys Upload file keys.
|
331 |
*/
|
332 |
protected function _get_upload_file_hidden( $upload_file_keys ) {
|
333 |
$Form = new MW_WP_Form_Form();
|
345 |
}
|
346 |
|
347 |
/**
|
348 |
+
* Get classes for backward compatibility.
|
349 |
*
|
350 |
+
* @return string
|
351 |
*/
|
352 |
protected function _get_old_confirm_class() {
|
353 |
if ( 'confirm' === $this->view_flg ) {
|
356 |
}
|
357 |
|
358 |
/**
|
359 |
+
* Get classes for style feature.
|
360 |
*
|
361 |
* @return string
|
362 |
*/
|
368 |
}
|
369 |
|
370 |
/**
|
371 |
+
* ショートコード mwform_formkey をもとにフォームの ID を取得.
|
372 |
*
|
373 |
+
* @param array $attributes Attributes of mwform_formkey.
|
374 |
+
* @return string
|
375 |
*/
|
376 |
protected function _get_form_id_by_mwform_formkey( $attributes ) {
|
377 |
+
$attributes = shortcode_atts(
|
378 |
+
array(
|
379 |
+
'key' => '',
|
380 |
+
'slug' => '',
|
381 |
+
),
|
382 |
+
$attributes
|
383 |
+
);
|
384 |
|
385 |
if ( ! empty( $attributes['slug'] ) ) {
|
386 |
$post = get_page_by_path( $attributes['slug'], OBJECT, MWF_Config::NAME );
|
394 |
}
|
395 |
|
396 |
/**
|
397 |
+
* Add nonce field and form meta data.
|
398 |
*
|
399 |
+
* @param string $html HTML.
|
400 |
* @return string
|
401 |
*/
|
402 |
public function _mwform_form_end_html( $html ) {
|
446 |
false,
|
447 |
true
|
448 |
);
|
449 |
+
wp_localize_script(
|
450 |
+
MWF_Config::NAME . '-scroll',
|
451 |
+
'mwform_scroll',
|
452 |
+
array(
|
453 |
+
'offset' => apply_filters( 'mwform_scroll_offset_' . $this->form_key, 0 ),
|
454 |
+
)
|
455 |
+
);
|
456 |
wp_enqueue_script( MWF_Config::NAME . '-scroll' );
|
457 |
}
|
458 |
}
|
classes/services/class.mail-parser.php
CHANGED
@@ -1,13 +1,12 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
10 |
-
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
*/
|
12 |
class MW_WP_Form_Mail_Parser {
|
13 |
|
@@ -27,8 +26,8 @@ class MW_WP_Form_Mail_Parser {
|
|
27 |
protected $Setting;
|
28 |
|
29 |
/**
|
30 |
-
* @param MW_WP_Form_Mail
|
31 |
-
* @param MW_WP_Form_Setting $Setting
|
32 |
*/
|
33 |
public function __construct( MW_WP_Form_Mail $Mail, MW_WP_Form_Setting $Setting ) {
|
34 |
$this->Mail = $Mail;
|
@@ -39,7 +38,7 @@ class MW_WP_Form_Mail_Parser {
|
|
39 |
}
|
40 |
|
41 |
/**
|
42 |
-
* Return parsed Mail object
|
43 |
*
|
44 |
* @return MW_WP_Form_Mail
|
45 |
*/
|
@@ -48,18 +47,18 @@ class MW_WP_Form_Mail_Parser {
|
|
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
|
63 |
*/
|
64 |
protected function _parse_mail_object() {
|
65 |
$parsed_Mail_vars = get_object_vars( $this->Mail );
|
@@ -70,29 +69,31 @@ class MW_WP_Form_Mail_Parser {
|
|
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
|
74 |
$this->Mail->$key = $Parser->replace_for_mail_destination( $value );
|
75 |
continue;
|
76 |
}
|
77 |
|
78 |
-
$Parser
|
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
|
90 |
-
$Parser
|
91 |
-
$saved_mail_id = wp_insert_post(
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
|
|
|
|
96 |
|
97 |
if ( ! empty( $saved_mail_id ) ) {
|
98 |
$this->Data->set_saved_mail_id( $saved_mail_id );
|
@@ -121,11 +122,10 @@ class MW_WP_Form_Mail_Parser {
|
|
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 );
|
@@ -135,15 +135,15 @@ class MW_WP_Form_Mail_Parser {
|
|
135 |
return;
|
136 |
}
|
137 |
|
138 |
-
$form_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
|
145 |
$ignore_keys = apply_filters( 'mwform_no_save_keys_' . $form_key, array() );
|
146 |
-
if ( in_array( $name, $ignore_keys ) ) {
|
147 |
continue;
|
148 |
}
|
149 |
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Mail_Parser
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Mail_Parser {
|
12 |
|
26 |
protected $Setting;
|
27 |
|
28 |
/**
|
29 |
+
* @param MW_WP_Form_Mail $Mail MW_WP_Form_Mail object.
|
30 |
+
* @param MW_WP_Form_Setting $Setting MW_WP_Form_Setting object.
|
31 |
*/
|
32 |
public function __construct( MW_WP_Form_Mail $Mail, MW_WP_Form_Setting $Setting ) {
|
33 |
$this->Mail = $Mail;
|
38 |
}
|
39 |
|
40 |
/**
|
41 |
+
* Return parsed Mail object.
|
42 |
*
|
43 |
* @return MW_WP_Form_Mail
|
44 |
*/
|
47 |
}
|
48 |
|
49 |
/**
|
50 |
+
* Return saved mail ID.
|
51 |
*
|
52 |
* @return int|null
|
53 |
*/
|
54 |
+
public function get_saved_mail_id() {
|
55 |
return $this->Data->get_saved_mail_id();
|
56 |
}
|
57 |
|
58 |
/**
|
59 |
+
* Convert each properties of Mail object.
|
60 |
*
|
61 |
+
* @return MW_WP_Form_Mail
|
62 |
*/
|
63 |
protected function _parse_mail_object() {
|
64 |
$parsed_Mail_vars = get_object_vars( $this->Mail );
|
69 |
|
70 |
// To, CC, BCC, Return-Path can not use {name}. But they can use {custom_mail_tag}
|
71 |
if ( 'to' === $key || 'cc' === $key || 'bcc' === $key || 'return_path' === $key ) {
|
72 |
+
$Parser = new MW_WP_Form_Parser( $this->Setting );
|
73 |
$this->Mail->$key = $Parser->replace_for_mail_destination( $value );
|
74 |
continue;
|
75 |
}
|
76 |
|
77 |
+
$Parser = new MW_WP_Form_Parser( $this->Setting );
|
78 |
$this->Mail->$key = $Parser->replace_for_mail_content( $value );
|
79 |
}
|
80 |
return $this->Mail;
|
81 |
}
|
82 |
|
83 |
/**
|
84 |
+
* Save Mail content and attachment files.
|
85 |
+
* Set property of saved mail ID.
|
86 |
*/
|
87 |
public function save() {
|
88 |
+
$form_id = $this->Setting->get( 'post_id' );
|
89 |
+
$Parser = new MW_WP_Form_Parser( $this->Setting );
|
90 |
+
$saved_mail_id = wp_insert_post(
|
91 |
+
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 |
|
98 |
if ( ! empty( $saved_mail_id ) ) {
|
99 |
$this->Data->set_saved_mail_id( $saved_mail_id );
|
122 |
}
|
123 |
|
124 |
/**
|
125 |
+
* Search {name} and save value to database.
|
126 |
+
* Save value even if it is null (e.g. posting which checkbox isn't check).
|
127 |
*
|
128 |
+
* @param string $value Parsing value.
|
|
|
129 |
*/
|
130 |
protected function _save( $value ) {
|
131 |
$Parser = new MW_WP_Form_Parser( $this->Setting );
|
135 |
return;
|
136 |
}
|
137 |
|
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, true ) ) {
|
147 |
continue;
|
148 |
}
|
149 |
|
classes/services/class.mail.php
CHANGED
@@ -1,13 +1,12 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
10 |
-
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
*/
|
12 |
class MW_WP_Form_Mail_Service {
|
13 |
|
@@ -47,10 +46,10 @@ class MW_WP_Form_Mail_Service {
|
|
47 |
protected $Setting;
|
48 |
|
49 |
/**
|
50 |
-
* @param MW_WP_Form_Mail
|
51 |
-
* @param strign
|
52 |
-
* @param MW_WP_Form_Setting $Setting
|
53 |
-
* @param array
|
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;
|
@@ -75,7 +74,7 @@ class MW_WP_Form_Mail_Service {
|
|
75 |
}
|
76 |
|
77 |
/**
|
78 |
-
* Send admin mail and save to database
|
79 |
*
|
80 |
* @return boolean
|
81 |
*/
|
@@ -85,7 +84,7 @@ class MW_WP_Form_Mail_Service {
|
|
85 |
$Mail_admin = $this->_apply_filters_mwform_admin_mail( $Mail_admin );
|
86 |
|
87 |
if ( $this->Setting->get( 'usedb' ) ) {
|
88 |
-
$Mail_admin_for_save
|
89 |
$Mail_admin_for_save->to = $Mail_admin->to;
|
90 |
}
|
91 |
|
@@ -103,7 +102,7 @@ class MW_WP_Form_Mail_Service {
|
|
103 |
}
|
104 |
|
105 |
if ( isset( $Mail_admin_for_save ) && $is_admin_mail_sended ) {
|
106 |
-
$
|
107 |
}
|
108 |
|
109 |
// If not usedb, remove files after sending admin mail
|
@@ -115,9 +114,9 @@ class MW_WP_Form_Mail_Service {
|
|
115 |
}
|
116 |
|
117 |
/**
|
118 |
-
* Return parsed Mail object and save to database
|
119 |
*
|
120 |
-
* @param MW_WP_Form_Mail $_Mail
|
121 |
* @return MW_WP_Form_Mail
|
122 |
*/
|
123 |
protected function _get_parsed_mail_object( MW_WP_Form_Mail $_Mail ) {
|
@@ -127,9 +126,9 @@ class MW_WP_Form_Mail_Service {
|
|
127 |
}
|
128 |
|
129 |
/**
|
130 |
-
* Save to database and return saved mail ID
|
131 |
*
|
132 |
-
* @param MW_WP_Form_Mail $Mail
|
133 |
* @return int
|
134 |
*/
|
135 |
protected function _save( MW_WP_Form_Mail $Mail ) {
|
@@ -137,7 +136,7 @@ class MW_WP_Form_Mail_Service {
|
|
137 |
}
|
138 |
|
139 |
/**
|
140 |
-
* Send reply mail
|
141 |
*
|
142 |
* @return boolean
|
143 |
*/
|
@@ -154,38 +153,33 @@ class MW_WP_Form_Mail_Service {
|
|
154 |
}
|
155 |
|
156 |
/**
|
157 |
-
* Set attachment files to Mail object
|
158 |
*
|
159 |
-
* @param MW_WP_Form_Mail $Mail
|
160 |
-
* @return void
|
161 |
*/
|
162 |
protected function _set_attachments_to( MW_WP_Form_Mail $Mail ) {
|
163 |
$Mail->attachments = $this->attachments;
|
164 |
}
|
165 |
|
166 |
/**
|
167 |
-
* Set admin mail params
|
168 |
-
*
|
169 |
-
* @return void
|
170 |
*/
|
171 |
protected function _set_admin_mail_raw_params() {
|
172 |
$this->Mail_admin_raw->set_admin_mail_raw_params( $this->Setting );
|
173 |
}
|
174 |
|
175 |
/**
|
176 |
-
* Set reply mail params
|
177 |
-
*
|
178 |
-
* @return void
|
179 |
*/
|
180 |
private function _set_reply_mail_raw_params() {
|
181 |
$this->Mail_auto_raw->set_reply_mail_raw_params( $this->Setting );
|
182 |
}
|
183 |
|
184 |
/**
|
185 |
-
* Apply mwform_admin_mail_raw filter hook
|
186 |
*
|
187 |
-
* @param MW_WP_Form_Mail $Mail
|
188 |
-
* @return MW_WP_Form_Mail
|
189 |
*/
|
190 |
protected function _apply_filters_mwform_admin_mail_raw( MW_WP_Form_Mail $Mail ) {
|
191 |
return apply_filters(
|
@@ -197,10 +191,10 @@ class MW_WP_Form_Mail_Service {
|
|
197 |
}
|
198 |
|
199 |
/**
|
200 |
-
* Apply mwform_mail filter hook
|
201 |
*
|
202 |
-
* @param MW_WP_Form_Mail $Mail
|
203 |
-
* @return MW_WP_Form_Mail
|
204 |
*/
|
205 |
protected function _apply_filters_mwform_mail( MW_WP_Form_Mail $Mail ) {
|
206 |
return apply_filters(
|
@@ -212,10 +206,10 @@ class MW_WP_Form_Mail_Service {
|
|
212 |
}
|
213 |
|
214 |
/**
|
215 |
-
* Apply mwform_admin_mail filter hook
|
216 |
*
|
217 |
-
* @param MW_WP_Form_Mail $Mail
|
218 |
-
* @return MW_WP_Form_Mail
|
219 |
*/
|
220 |
protected function _apply_filters_mwform_admin_mail( MW_WP_Form_Mail $Mail ) {
|
221 |
return apply_filters(
|
@@ -227,10 +221,10 @@ class MW_WP_Form_Mail_Service {
|
|
227 |
}
|
228 |
|
229 |
/**
|
230 |
-
* Apply mwform_auto_mail_raw filter hook
|
231 |
*
|
232 |
-
* @param MW_WP_Form_Mail $Mail
|
233 |
-
* @return MW_WP_Form_Mail
|
234 |
*/
|
235 |
protected function _apply_filters_mwform_auto_mail_raw( MW_WP_Form_Mail $Mail ) {
|
236 |
return apply_filters(
|
@@ -242,10 +236,10 @@ class MW_WP_Form_Mail_Service {
|
|
242 |
}
|
243 |
|
244 |
/**
|
245 |
-
* Apply mwform_auto_mail filter hook
|
246 |
*
|
247 |
-
* @param MW_WP_Form_Mail $Mail
|
248 |
-
* @return MW_WP_Form_Mail
|
249 |
*/
|
250 |
protected function _apply_filters_mwform_auto_mail( MW_WP_Form_Mail $Mail ) {
|
251 |
return apply_filters(
|
@@ -257,9 +251,7 @@ class MW_WP_Form_Mail_Service {
|
|
257 |
}
|
258 |
|
259 |
/**
|
260 |
-
* Delete attachment files
|
261 |
-
*
|
262 |
-
* @return void
|
263 |
*/
|
264 |
protected function _delete_files() {
|
265 |
foreach ( $this->attachments as $file ) {
|
@@ -270,9 +262,7 @@ class MW_WP_Form_Mail_Service {
|
|
270 |
}
|
271 |
|
272 |
/**
|
273 |
-
* Update tracking number
|
274 |
-
*
|
275 |
-
* @return void
|
276 |
*/
|
277 |
public function update_tracking_number() {
|
278 |
if ( preg_match( '{' . MWF_Config::TRACKINGNUMBER . '}', $this->Mail_admin_raw->body ) ) {
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Mail_Service
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Mail_Service {
|
12 |
|
46 |
protected $Setting;
|
47 |
|
48 |
/**
|
49 |
+
* @param MW_WP_Form_Mail $Mail MW_WP_Form_Mail object.
|
50 |
+
* @param strign $form_key Form key.
|
51 |
+
* @param MW_WP_Form_Setting $Setting MW_WP_Form_Setting object.
|
52 |
+
* @param array $attachments Array of attachment.
|
53 |
*/
|
54 |
public function __construct( MW_WP_Form_Mail $Mail, $form_key, MW_WP_Form_Setting $Setting, array $attachments = array() ) {
|
55 |
$this->form_key = $form_key;
|
74 |
}
|
75 |
|
76 |
/**
|
77 |
+
* Send admin mail and save to database.
|
78 |
*
|
79 |
* @return boolean
|
80 |
*/
|
84 |
$Mail_admin = $this->_apply_filters_mwform_admin_mail( $Mail_admin );
|
85 |
|
86 |
if ( $this->Setting->get( 'usedb' ) ) {
|
87 |
+
$Mail_admin_for_save = clone $this->Mail_admin_raw;
|
88 |
$Mail_admin_for_save->to = $Mail_admin->to;
|
89 |
}
|
90 |
|
102 |
}
|
103 |
|
104 |
if ( isset( $Mail_admin_for_save ) && $is_admin_mail_sended ) {
|
105 |
+
$this->_save( $Mail_admin_for_save );
|
106 |
}
|
107 |
|
108 |
// If not usedb, remove files after sending admin mail
|
114 |
}
|
115 |
|
116 |
/**
|
117 |
+
* Return parsed Mail object and save to database.
|
118 |
*
|
119 |
+
* @param MW_WP_Form_Mail $_Mail MW_WP_Form_Mail object.
|
120 |
* @return MW_WP_Form_Mail
|
121 |
*/
|
122 |
protected function _get_parsed_mail_object( MW_WP_Form_Mail $_Mail ) {
|
126 |
}
|
127 |
|
128 |
/**
|
129 |
+
* Save to database and return saved mail ID.
|
130 |
*
|
131 |
+
* @param MW_WP_Form_Mail $Mail MW_WP_Form_Mail object.
|
132 |
* @return int
|
133 |
*/
|
134 |
protected function _save( MW_WP_Form_Mail $Mail ) {
|
136 |
}
|
137 |
|
138 |
/**
|
139 |
+
* Send reply mail.
|
140 |
*
|
141 |
* @return boolean
|
142 |
*/
|
153 |
}
|
154 |
|
155 |
/**
|
156 |
+
* Set attachment files to Mail object.
|
157 |
*
|
158 |
+
* @param MW_WP_Form_Mail $Mail MW_WP_Form_Mail object.
|
|
|
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 |
protected function _set_admin_mail_raw_params() {
|
168 |
$this->Mail_admin_raw->set_admin_mail_raw_params( $this->Setting );
|
169 |
}
|
170 |
|
171 |
/**
|
172 |
+
* Set reply mail params.
|
|
|
|
|
173 |
*/
|
174 |
private function _set_reply_mail_raw_params() {
|
175 |
$this->Mail_auto_raw->set_reply_mail_raw_params( $this->Setting );
|
176 |
}
|
177 |
|
178 |
/**
|
179 |
+
* Apply mwform_admin_mail_raw filter hook.
|
180 |
*
|
181 |
+
* @param MW_WP_Form_Mail $Mail MW_WP_Form_Mail object.
|
182 |
+
* @return MW_WP_Form_Mail
|
183 |
*/
|
184 |
protected function _apply_filters_mwform_admin_mail_raw( MW_WP_Form_Mail $Mail ) {
|
185 |
return apply_filters(
|
191 |
}
|
192 |
|
193 |
/**
|
194 |
+
* Apply mwform_mail filter hook.
|
195 |
*
|
196 |
+
* @param MW_WP_Form_Mail $Mail MW_WP_Form_Mail object.
|
197 |
+
* @return MW_WP_Form_Mail
|
198 |
*/
|
199 |
protected function _apply_filters_mwform_mail( MW_WP_Form_Mail $Mail ) {
|
200 |
return apply_filters(
|
206 |
}
|
207 |
|
208 |
/**
|
209 |
+
* Apply mwform_admin_mail filter hook.
|
210 |
*
|
211 |
+
* @param MW_WP_Form_Mail $Mail MW_WP_Form_Mail object.
|
212 |
+
* @return MW_WP_Form_Mail
|
213 |
*/
|
214 |
protected function _apply_filters_mwform_admin_mail( MW_WP_Form_Mail $Mail ) {
|
215 |
return apply_filters(
|
221 |
}
|
222 |
|
223 |
/**
|
224 |
+
* Apply mwform_auto_mail_raw filter hook.
|
225 |
*
|
226 |
+
* @param MW_WP_Form_Mail $Mail MW_WP_Form_Mail object.
|
227 |
+
* @return MW_WP_Form_Mail
|
228 |
*/
|
229 |
protected function _apply_filters_mwform_auto_mail_raw( MW_WP_Form_Mail $Mail ) {
|
230 |
return apply_filters(
|
236 |
}
|
237 |
|
238 |
/**
|
239 |
+
* Apply mwform_auto_mail filter hook.
|
240 |
*
|
241 |
+
* @param MW_WP_Form_Mail $Mail MW_WP_Form_Mail object.
|
242 |
+
* @return MW_WP_Form_Mail
|
243 |
*/
|
244 |
protected function _apply_filters_mwform_auto_mail( MW_WP_Form_Mail $Mail ) {
|
245 |
return apply_filters(
|
251 |
}
|
252 |
|
253 |
/**
|
254 |
+
* Delete attachment files.
|
|
|
|
|
255 |
*/
|
256 |
protected function _delete_files() {
|
257 |
foreach ( $this->attachments as $file ) {
|
262 |
}
|
263 |
|
264 |
/**
|
265 |
+
* Update tracking number.
|
|
|
|
|
266 |
*/
|
267 |
public function update_tracking_number() {
|
268 |
if ( preg_match( '{' . MWF_Config::TRACKINGNUMBER . '}', $this->Mail_admin_raw->body ) ) {
|
classes/services/class.redirected.php
CHANGED
@@ -1,13 +1,12 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
10 |
-
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
*/
|
12 |
class MW_WP_Form_Redirected {
|
13 |
|
@@ -31,9 +30,17 @@ class MW_WP_Form_Redirected {
|
|
31 |
*/
|
32 |
protected $url;
|
33 |
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
$this->form_key = $form_key;
|
36 |
-
$this->Setting = $
|
37 |
|
38 |
$input = $this->_parse_url( $this->Setting->get( 'input_url' ) );
|
39 |
$confirm = $this->_parse_url( $this->Setting->get( 'confirmation_url' ) );
|
@@ -106,17 +113,17 @@ class MW_WP_Form_Redirected {
|
|
106 |
/**
|
107 |
* Return $_SERVER['REQUEST_URI'] that converted https?://...
|
108 |
*
|
109 |
-
* @return string
|
110 |
*/
|
111 |
public function get_request_uri() {
|
112 |
-
$
|
113 |
|
114 |
-
if ( ! $
|
115 |
return;
|
116 |
}
|
117 |
|
118 |
-
if ( preg_match( '/^https?:\/\//', $
|
119 |
-
return $
|
120 |
}
|
121 |
|
122 |
$parse_url = parse_url( home_url() );
|
@@ -124,18 +131,18 @@ class MW_WP_Form_Redirected {
|
|
124 |
// For WP installed in subdirectory
|
125 |
if ( ! empty( $parse_url['path'] ) ) {
|
126 |
$pettern = preg_quote( $parse_url['path'], '/' );
|
127 |
-
return preg_replace( '/' . $pettern . '$/', $
|
128 |
}
|
129 |
|
130 |
-
return trailingslashit( home_url() ) . ltrim( $
|
131 |
-
return $
|
132 |
}
|
133 |
|
134 |
/**
|
135 |
* Convert URL to https?://...
|
136 |
*
|
137 |
-
* @param string URL
|
138 |
-
* @return string
|
139 |
*/
|
140 |
protected function _parse_url( $url ) {
|
141 |
if ( empty( $url ) ) {
|
@@ -150,7 +157,7 @@ class MW_WP_Form_Redirected {
|
|
150 |
}
|
151 |
if ( ! preg_match( '/^https?:\/\//', $url ) ) {
|
152 |
$home_url = home_url();
|
153 |
-
$url
|
154 |
}
|
155 |
$url = preg_replace( '/([^:])\/+/', '$1/', $url );
|
156 |
|
@@ -171,10 +178,8 @@ class MW_WP_Form_Redirected {
|
|
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();
|
@@ -189,10 +194,8 @@ class MW_WP_Form_Redirected {
|
|
189 |
}
|
190 |
|
191 |
/**
|
192 |
-
* Redirect using JavaScript
|
193 |
-
* Don't redirect if the current URL and the redirect URL are the same
|
194 |
-
*
|
195 |
-
* @return void
|
196 |
*/
|
197 |
public function redirect_js() {
|
198 |
$redirect = $this->_get_real_redirect_url();
|
@@ -209,15 +212,15 @@ class MW_WP_Form_Redirected {
|
|
209 |
}
|
210 |
|
211 |
/**
|
212 |
-
* Return redirect url that sanitize and validate
|
213 |
*
|
214 |
* @return string
|
215 |
*/
|
216 |
protected function _get_real_redirect_url() {
|
217 |
$redirect = ( $this->get_url() ) ? $this->get_url() : $this->get_request_uri();
|
218 |
-
$
|
219 |
|
220 |
-
if ( empty( $_POST ) && $redirect === $
|
221 |
return;
|
222 |
}
|
223 |
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Redirected
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Redirected {
|
12 |
|
30 |
*/
|
31 |
protected $url;
|
32 |
|
33 |
+
/**
|
34 |
+
* Constructor.
|
35 |
+
*
|
36 |
+
* @param string $form_key Form key.
|
37 |
+
* @param MW_WP_Form_Setting $setting MW_WP_Form_Setting object.
|
38 |
+
* @param boolean $is_valid Return true when valid.
|
39 |
+
* @param string $post_condition back|confirm|complete.
|
40 |
+
*/
|
41 |
+
public function __construct( $form_key, $setting, $is_valid, $post_condition ) {
|
42 |
$this->form_key = $form_key;
|
43 |
+
$this->Setting = $setting;
|
44 |
|
45 |
$input = $this->_parse_url( $this->Setting->get( 'input_url' ) );
|
46 |
$confirm = $this->_parse_url( $this->Setting->get( 'confirmation_url' ) );
|
113 |
/**
|
114 |
* Return $_SERVER['REQUEST_URI'] that converted https?://...
|
115 |
*
|
116 |
+
* @return string
|
117 |
*/
|
118 |
public function get_request_uri() {
|
119 |
+
$request_uri = $_SERVER['REQUEST_URI'];
|
120 |
|
121 |
+
if ( ! $request_uri ) {
|
122 |
return;
|
123 |
}
|
124 |
|
125 |
+
if ( preg_match( '/^https?:\/\//', $request_uri ) ) {
|
126 |
+
return $request_uri;
|
127 |
}
|
128 |
|
129 |
$parse_url = parse_url( home_url() );
|
131 |
// For WP installed in subdirectory
|
132 |
if ( ! empty( $parse_url['path'] ) ) {
|
133 |
$pettern = preg_quote( $parse_url['path'], '/' );
|
134 |
+
return preg_replace( '/' . $pettern . '$/', $request_uri, home_url() );
|
135 |
}
|
136 |
|
137 |
+
return trailingslashit( home_url() ) . ltrim( $request_uri, '/' );
|
138 |
+
return $request_uri;
|
139 |
}
|
140 |
|
141 |
/**
|
142 |
* Convert URL to https?://...
|
143 |
*
|
144 |
+
* @param string $url URL.
|
145 |
+
* @return string
|
146 |
*/
|
147 |
protected function _parse_url( $url ) {
|
148 |
if ( empty( $url ) ) {
|
157 |
}
|
158 |
if ( ! preg_match( '/^https?:\/\//', $url ) ) {
|
159 |
$home_url = home_url();
|
160 |
+
$url = $home_url . $url;
|
161 |
}
|
162 |
$url = preg_replace( '/([^:])\/+/', '$1/', $url );
|
163 |
|
178 |
}
|
179 |
|
180 |
/**
|
181 |
+
* Redirect.
|
182 |
+
* Don't redirect if the current URL and the redirect URL are the same.
|
|
|
|
|
183 |
*/
|
184 |
public function redirect() {
|
185 |
$redirect = $this->_get_real_redirect_url();
|
194 |
}
|
195 |
|
196 |
/**
|
197 |
+
* Redirect using JavaScript.
|
198 |
+
* Don't redirect if the current URL and the redirect URL are the same.
|
|
|
|
|
199 |
*/
|
200 |
public function redirect_js() {
|
201 |
$redirect = $this->_get_real_redirect_url();
|
212 |
}
|
213 |
|
214 |
/**
|
215 |
+
* Return redirect url that sanitize and validate.
|
216 |
*
|
217 |
* @return string
|
218 |
*/
|
219 |
protected function _get_real_redirect_url() {
|
220 |
$redirect = ( $this->get_url() ) ? $this->get_url() : $this->get_request_uri();
|
221 |
+
$request_uri = $this->get_request_uri();
|
222 |
|
223 |
+
if ( empty( $_POST ) && $redirect === $request_uri ) {
|
224 |
return;
|
225 |
}
|
226 |
|
classes/validation-rules/class.akismet.php
CHANGED
@@ -1,44 +1,49 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
25 |
-
* @return string
|
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 |
);
|
31 |
-
$options
|
32 |
return $options['message'];
|
33 |
}
|
34 |
|
35 |
/**
|
36 |
-
* Add setting field to validation rule setting panel
|
37 |
*
|
38 |
-
* @param numeric $key ID of validation rule
|
39 |
-
* @param array
|
40 |
* @return void
|
41 |
*/
|
42 |
-
public function admin(
|
|
|
|
|
|
|
|
|
|
|
43 |
}
|
44 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Validation_Rule_Akismet
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Validation_Rule_Akismet extends MW_WP_Form_Abstract_Validation_Rule {
|
12 |
|
13 |
/**
|
14 |
+
* Validation rule name.
|
15 |
+
*
|
16 |
* @var string
|
17 |
*/
|
18 |
protected $name = 'akismet_check';
|
19 |
|
20 |
/**
|
21 |
+
* Validation process.
|
22 |
*
|
23 |
+
* @param string $name Validation name.
|
24 |
+
* @param array $options Validation options.
|
25 |
+
* @return string
|
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 |
);
|
31 |
+
$options = array_merge( $defaults, $options );
|
32 |
return $options['message'];
|
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(
|
43 |
+
// phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
|
44 |
+
$key,
|
45 |
+
$value
|
46 |
+
// phpcs:enable
|
47 |
+
) {
|
48 |
}
|
49 |
}
|
classes/validation-rules/class.alpha.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
25 |
-
* @return string
|
26 |
*/
|
27 |
public function rule( $name, array $options = array() ) {
|
28 |
$value = $this->Data->get( $name );
|
@@ -36,17 +36,17 @@ class MW_WP_Form_Validation_Rule_Alpha extends MW_WP_Form_Abstract_Validation_Ru
|
|
36 |
}
|
37 |
|
38 |
$defaults = array(
|
39 |
-
'message' => __( 'Please enter with a half-width alphabetic character.', 'mw-wp-form' )
|
40 |
);
|
41 |
-
$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
|
50 |
* @return void
|
51 |
*/
|
52 |
public function admin( $key, $value ) {
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Validation_Rule_Alpha
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Validation_Rule_Alpha extends MW_WP_Form_Abstract_Validation_Rule {
|
12 |
|
13 |
/**
|
14 |
+
* Validation rule name.
|
15 |
+
*
|
16 |
* @var string
|
17 |
*/
|
18 |
protected $name = 'alpha';
|
19 |
|
20 |
/**
|
21 |
+
* Validation process.
|
22 |
*
|
23 |
+
* @param string $name Validation name.
|
24 |
+
* @param array $options Validation options.
|
25 |
+
* @return string
|
26 |
*/
|
27 |
public function rule( $name, array $options = array() ) {
|
28 |
$value = $this->Data->get( $name );
|
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 ) {
|
classes/validation-rules/class.alphanumeric.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
25 |
-
* @return string
|
26 |
*/
|
27 |
public function rule( $name, array $options = array() ) {
|
28 |
$value = $this->Data->get( $name );
|
@@ -36,17 +36,17 @@ class MW_WP_Form_Validation_Rule_AlphaNumeric extends MW_WP_Form_Abstract_Valida
|
|
36 |
}
|
37 |
|
38 |
$defaults = array(
|
39 |
-
'message' => __( 'Please enter with a half-width alphanumeric character.', 'mw-wp-form' )
|
40 |
);
|
41 |
-
$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
|
50 |
* @return void
|
51 |
*/
|
52 |
public function admin( $key, $value ) {
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Validation_Rule_AlphaNumeric
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Validation_Rule_AlphaNumeric extends MW_WP_Form_Abstract_Validation_Rule {
|
12 |
|
13 |
/**
|
14 |
+
* Validation rule name.
|
15 |
+
*
|
16 |
* @var string
|
17 |
*/
|
18 |
protected $name = 'alphanumeric';
|
19 |
|
20 |
/**
|
21 |
+
* Validation process.
|
22 |
*
|
23 |
+
* @param string $name Validation name.
|
24 |
+
* @param array $options Validation options.
|
25 |
+
* @return string
|
26 |
*/
|
27 |
public function rule( $name, array $options = array() ) {
|
28 |
$value = $this->Data->get( $name );
|
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 ) {
|
classes/validation-rules/class.between.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
25 |
-
* @return string
|
26 |
*/
|
27 |
public function rule( $name, array $options = array() ) {
|
28 |
$value = $this->Data->get( $name );
|
@@ -35,10 +35,10 @@ class MW_WP_Form_Validation_Rule_Between extends MW_WP_Form_Abstract_Validation_
|
|
35 |
$defaults = array(
|
36 |
'min' => 0,
|
37 |
'max' => 0,
|
38 |
-
'message' => __( 'The number of characters is invalid.', 'mw-wp-form' )
|
39 |
);
|
40 |
-
$options
|
41 |
-
$length
|
42 |
if ( MWF_Functions::is_numeric( $options['min'] ) ) {
|
43 |
if ( MWF_Functions::is_numeric( $options['max'] ) ) {
|
44 |
if ( $options['min'] > $length || $length > $options['max'] ) {
|
@@ -57,10 +57,10 @@ class MW_WP_Form_Validation_Rule_Between extends MW_WP_Form_Abstract_Validation_
|
|
57 |
}
|
58 |
|
59 |
/**
|
60 |
-
* Add setting field to validation rule setting panel
|
61 |
*
|
62 |
-
* @param numeric $key ID of validation rule
|
63 |
-
* @param array
|
64 |
* @return void
|
65 |
*/
|
66 |
public function admin( $key, $value ) {
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Validation_Rule_Between
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Validation_Rule_Between extends MW_WP_Form_Abstract_Validation_Rule {
|
12 |
|
13 |
/**
|
14 |
+
* Validation rule name.
|
15 |
+
*
|
16 |
* @var string
|
17 |
*/
|
18 |
protected $name = 'between';
|
19 |
|
20 |
/**
|
21 |
+
* Validation process.
|
22 |
*
|
23 |
+
* @param string $name Validation name.
|
24 |
+
* @param array $options Validation options.
|
25 |
+
* @return string
|
26 |
*/
|
27 |
public function rule( $name, array $options = array() ) {
|
28 |
$value = $this->Data->get( $name );
|
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'] ) {
|
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 ) {
|
classes/validation-rules/class.date.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
25 |
-
* @return string
|
26 |
*/
|
27 |
public function rule( $name, array $options = array() ) {
|
28 |
$value = $this->Data->get( $name );
|
@@ -32,9 +32,9 @@ class MW_WP_Form_Validation_Rule_Date extends MW_WP_Form_Abstract_Validation_Rul
|
|
32 |
}
|
33 |
|
34 |
$defaults = array(
|
35 |
-
'message' => __( 'This is not the format of a date.', 'mw-wp-form' )
|
36 |
);
|
37 |
-
$options
|
38 |
|
39 |
$timestamp = strtotime( $value );
|
40 |
if ( ! $timestamp ) {
|
@@ -44,9 +44,9 @@ class MW_WP_Form_Validation_Rule_Date extends MW_WP_Form_Abstract_Validation_Rul
|
|
44 |
return $options['message'];
|
45 |
}
|
46 |
|
47 |
-
$year
|
48 |
-
$month
|
49 |
-
$day
|
50 |
$checkdate = checkdate( $month, $day, $year );
|
51 |
|
52 |
if ( ! $timestamp || ! $checkdate || preg_match( '/^[a-zA-Z]$/', $value ) || preg_match( '/^\s+$/', $value ) ) {
|
@@ -55,9 +55,9 @@ class MW_WP_Form_Validation_Rule_Date extends MW_WP_Form_Abstract_Validation_Rul
|
|
55 |
}
|
56 |
|
57 |
/**
|
58 |
-
* Convert Japanese notation date to time stamp
|
59 |
*
|
60 |
-
* @param string $jpdate yyyy年mm月dd
|
61 |
* @return string|false
|
62 |
*/
|
63 |
public function convert_jpdate_to_timestamp( $jpdate ) {
|
@@ -69,10 +69,10 @@ class MW_WP_Form_Validation_Rule_Date extends MW_WP_Form_Abstract_Validation_Rul
|
|
69 |
}
|
70 |
|
71 |
/**
|
72 |
-
* Add setting field to validation rule setting panel
|
73 |
*
|
74 |
-
* @param numeric $key ID of validation rule
|
75 |
-
* @param array
|
76 |
* @return void
|
77 |
*/
|
78 |
public function admin( $key, $value ) {
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Validation_Rule_Date
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Validation_Rule_Date extends MW_WP_Form_Abstract_Validation_Rule {
|
12 |
|
13 |
/**
|
14 |
+
* Validation rule name.
|
15 |
+
*
|
16 |
* @var string
|
17 |
*/
|
18 |
protected $name = 'date';
|
19 |
|
20 |
/**
|
21 |
+
* Validation process.
|
22 |
*
|
23 |
+
* @param string $name Validation name.
|
24 |
+
* @param array $options Validation options.
|
25 |
+
* @return string
|
26 |
*/
|
27 |
public function rule( $name, array $options = array() ) {
|
28 |
$value = $this->Data->get( $name );
|
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 ) {
|
44 |
return $options['message'];
|
45 |
}
|
46 |
|
47 |
+
$year = date_i18n( 'Y', $timestamp );
|
48 |
+
$month = date_i18n( 'm', $timestamp );
|
49 |
+
$day = date_i18n( 'd', $timestamp );
|
50 |
$checkdate = checkdate( $month, $day, $year );
|
51 |
|
52 |
if ( ! $timestamp || ! $checkdate || preg_match( '/^[a-zA-Z]$/', $value ) || preg_match( '/^\s+$/', $value ) ) {
|
55 |
}
|
56 |
|
57 |
/**
|
58 |
+
* Convert Japanese notation date to time stamp.
|
59 |
*
|
60 |
+
* @param string $jpdate yyyy年mm月dd日.
|
61 |
* @return string|false
|
62 |
*/
|
63 |
public function convert_jpdate_to_timestamp( $jpdate ) {
|
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 ) {
|
classes/validation-rules/class.eq.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
25 |
-
* @return string
|
26 |
*/
|
27 |
public function rule( $name, array $options = array() ) {
|
28 |
$value = $this->Data->get( $name );
|
@@ -31,23 +31,23 @@ class MW_WP_Form_Validation_Rule_Eq extends MW_WP_Form_Abstract_Validation_Rule
|
|
31 |
return;
|
32 |
}
|
33 |
|
34 |
-
$defaults
|
35 |
'target' => null,
|
36 |
-
'message' => __( 'This is not in agreement.', 'mw-wp-form' )
|
37 |
);
|
38 |
-
$options
|
39 |
$target_value = $this->Data->get( $options['target'] );
|
40 |
|
41 |
-
if ( (
|
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
|
51 |
* @return void
|
52 |
*/
|
53 |
public function admin( $key, $value ) {
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Validation_Rule_Eq
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Validation_Rule_Eq extends MW_WP_Form_Abstract_Validation_Rule {
|
12 |
|
13 |
/**
|
14 |
+
* Validation rule name.
|
15 |
+
*
|
16 |
* @var string
|
17 |
*/
|
18 |
protected $name = 'eq';
|
19 |
|
20 |
/**
|
21 |
+
* Validation process.
|
22 |
*
|
23 |
+
* @param string $name Validation name.
|
24 |
+
* @param array $options Validation options.
|
25 |
+
* @return string
|
26 |
*/
|
27 |
public function rule( $name, array $options = array() ) {
|
28 |
$value = $this->Data->get( $name );
|
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 ) {
|
classes/validation-rules/class.filesize.php
CHANGED
@@ -1,48 +1,49 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
25 |
-
* @return string
|
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']
|
37 |
return __( 'Failed to upload the file.', 'mw-wp-form' );
|
38 |
}
|
39 |
}
|
40 |
-
|
41 |
} else {
|
42 |
-
|
43 |
$upload_file_keys = $this->Data->get_post_value_by_key( MWF_Config::UPLOAD_FILE_KEYS );
|
44 |
-
$filepath
|
45 |
-
if (
|
|
|
|
|
|
|
|
|
46 |
$error_message = $this->_filesize_validate( filesize( $filepath ), $options );
|
47 |
if ( $error_message ) {
|
48 |
// バリデーションは送信ボタン押下時に発火するため
|
@@ -54,33 +55,32 @@ class MW_WP_Form_Validation_Rule_FileSize extends MW_WP_Form_Abstract_Validation
|
|
54 |
return $error_message;
|
55 |
}
|
56 |
}
|
57 |
-
|
58 |
}
|
59 |
}
|
60 |
|
61 |
/**
|
62 |
-
* Validates the filesize
|
63 |
*
|
64 |
-
* @param int
|
65 |
-
* @param array $options
|
66 |
-
* @return string
|
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' )
|
72 |
);
|
73 |
-
$options
|
74 |
if ( ! ( preg_match( '/^[\d]+$/', $options['bytes'] ) && $options['bytes'] >= $byte ) ) {
|
75 |
return $options['message'];
|
76 |
}
|
77 |
}
|
78 |
|
79 |
/**
|
80 |
-
* Add setting field to validation rule setting panel
|
81 |
*
|
82 |
-
* @param numeric $key ID of validation rule
|
83 |
-
* @param array
|
84 |
* @return void
|
85 |
*/
|
86 |
public function admin( $key, $value ) {
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Validation_Rule_FileSize
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Validation_Rule_FileSize extends MW_WP_Form_Abstract_Validation_Rule {
|
12 |
|
13 |
/**
|
14 |
+
* Validation rule name.
|
15 |
+
*
|
16 |
* @var string
|
17 |
*/
|
18 |
protected $name = 'filesize';
|
19 |
|
20 |
/**
|
21 |
+
* Validation process.
|
22 |
*
|
23 |
+
* @param string $name Validation name.
|
24 |
+
* @param array $options Validation options.
|
25 |
+
* @return string
|
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 |
if ( is_array( $data ) && array_key_exists( $name, $data ) ) {
|
32 |
$file = $data[ $name ];
|
33 |
if ( ! empty( $file['size'] ) ) {
|
34 |
return $this->_filesize_validate( $file['size'], $options );
|
35 |
+
} elseif ( ! empty( $file['error'] ) && 1 === $file['error'] ) {
|
36 |
return __( 'Failed to upload the file.', 'mw-wp-form' );
|
37 |
}
|
38 |
}
|
|
|
39 |
} else {
|
|
|
40 |
$upload_file_keys = $this->Data->get_post_value_by_key( MWF_Config::UPLOAD_FILE_KEYS );
|
41 |
+
$filepath = MWF_Functions::fileurl_to_path( $this->Data->get( $name ) );
|
42 |
+
if (
|
43 |
+
is_array( $upload_file_keys )
|
44 |
+
&& in_array( $name, $upload_file_keys, true )
|
45 |
+
&& file_exists( $filepath )
|
46 |
+
) {
|
47 |
$error_message = $this->_filesize_validate( filesize( $filepath ), $options );
|
48 |
if ( $error_message ) {
|
49 |
// バリデーションは送信ボタン押下時に発火するため
|
55 |
return $error_message;
|
56 |
}
|
57 |
}
|
|
|
58 |
}
|
59 |
}
|
60 |
|
61 |
/**
|
62 |
+
* Validates the filesize.
|
63 |
*
|
64 |
+
* @param int $byte Filesize.
|
65 |
+
* @param array $options Validate options.
|
66 |
+
* @return string
|
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' ),
|
72 |
);
|
73 |
+
$options = array_merge( $defaults, $options );
|
74 |
if ( ! ( preg_match( '/^[\d]+$/', $options['bytes'] ) && $options['bytes'] >= $byte ) ) {
|
75 |
return $options['message'];
|
76 |
}
|
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 ) {
|
classes/validation-rules/class.filetype.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
25 |
-
* @return string
|
26 |
*/
|
27 |
public function rule( $name, array $options = array() ) {
|
28 |
$value = $this->Data->get( $name );
|
@@ -33,14 +33,15 @@ class MW_WP_Form_Validation_Rule_FileType extends MW_WP_Form_Abstract_Validation
|
|
33 |
|
34 |
$defaults = array(
|
35 |
'types' => '',
|
36 |
-
'message' => __( 'This file is invalid.', 'mw-wp-form' )
|
37 |
);
|
38 |
-
$options
|
39 |
-
$_types
|
|
|
40 |
foreach ( $_types as $type ) {
|
41 |
$types[] = preg_quote( trim( $type ), '/' );
|
42 |
}
|
43 |
-
$types
|
44 |
$pattern = '/\.(' . $types . ')$/i';
|
45 |
if ( ! preg_match( $pattern, $value ) ) {
|
46 |
return $options['message'];
|
@@ -48,10 +49,10 @@ class MW_WP_Form_Validation_Rule_FileType extends MW_WP_Form_Abstract_Validation
|
|
48 |
}
|
49 |
|
50 |
/**
|
51 |
-
* Add setting field to validation rule setting panel
|
52 |
*
|
53 |
-
* @param numeric $key ID of validation rule
|
54 |
-
* @param array
|
55 |
* @return void
|
56 |
*/
|
57 |
public function admin( $key, $value ) {
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Validation_Rule_FileType
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Validation_Rule_FileType extends MW_WP_Form_Abstract_Validation_Rule {
|
12 |
|
13 |
/**
|
14 |
+
* Validation rule name.
|
15 |
+
*
|
16 |
* @var string
|
17 |
*/
|
18 |
protected $name = 'filetype';
|
19 |
|
20 |
/**
|
21 |
+
* Validation process.
|
22 |
*
|
23 |
+
* @param string $name Validation name.
|
24 |
+
* @param array $options Validation options.
|
25 |
+
* @return string
|
26 |
*/
|
27 |
public function rule( $name, array $options = array() ) {
|
28 |
$value = $this->Data->get( $name );
|
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 |
+
$types = array();
|
41 |
foreach ( $_types as $type ) {
|
42 |
$types[] = preg_quote( trim( $type ), '/' );
|
43 |
}
|
44 |
+
$types = implode( '|', MWF_Functions::array_clean( $types ) );
|
45 |
$pattern = '/\.(' . $types . ')$/i';
|
46 |
if ( ! preg_match( $pattern, $value ) ) {
|
47 |
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 ) {
|
classes/validation-rules/class.hiragana.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
25 |
-
* @return string
|
26 |
*/
|
27 |
public function rule( $name, array $options = array() ) {
|
28 |
$value = $this->Data->get( $name );
|
@@ -36,17 +36,17 @@ class MW_WP_Form_Validation_Rule_Hiragana extends MW_WP_Form_Abstract_Validation
|
|
36 |
}
|
37 |
|
38 |
$defaults = array(
|
39 |
-
'message' => __( 'Please enter with a Japanese Hiragana.', 'mw-wp-form' )
|
40 |
);
|
41 |
-
$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
|
50 |
* @return void
|
51 |
*/
|
52 |
public function admin( $key, $value ) {
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Validation_Rule_Hiragana
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Validation_Rule_Hiragana extends MW_WP_Form_Abstract_Validation_Rule {
|
12 |
|
13 |
/**
|
14 |
+
* Validation rule name.
|
15 |
+
*
|
16 |
* @var string
|
17 |
*/
|
18 |
protected $name = 'hiragana';
|
19 |
|
20 |
/**
|
21 |
+
* Validation process.
|
22 |
*
|
23 |
+
* @param string $name Validation name.
|
24 |
+
* @param array $options Validation options.
|
25 |
+
* @return string
|
26 |
*/
|
27 |
public function rule( $name, array $options = array() ) {
|
28 |
$value = $this->Data->get( $name );
|
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 ) {
|
classes/validation-rules/class.in.php
CHANGED
@@ -1,32 +1,32 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
25 |
-
* @return string
|
26 |
*/
|
27 |
public function rule( $name, array $options = array() ) {
|
28 |
$value = $this->Data->get( $name );
|
29 |
-
$value = (
|
30 |
|
31 |
if ( MWF_Functions::is_empty( $value ) ) {
|
32 |
return;
|
@@ -34,12 +34,12 @@ class MW_WP_Form_Validation_Rule_In extends MW_WP_Form_Abstract_Validation_Rule
|
|
34 |
|
35 |
$defaults = array(
|
36 |
'options' => array(),
|
37 |
-
'message' => __( 'This value is invalid.', 'mw-wp-form' )
|
38 |
);
|
39 |
-
$options
|
40 |
if ( is_array( $options['options'] ) ) {
|
41 |
foreach ( $options['options'] as $option ) {
|
42 |
-
$option = (
|
43 |
if ( $value === $option ) {
|
44 |
return;
|
45 |
}
|
@@ -50,12 +50,17 @@ class MW_WP_Form_Validation_Rule_In extends MW_WP_Form_Abstract_Validation_Rule
|
|
50 |
}
|
51 |
|
52 |
/**
|
53 |
-
* Add setting field to validation rule setting panel
|
54 |
*
|
55 |
-
* @param numeric $key ID of validation rule
|
56 |
-
* @param array
|
57 |
* @return void
|
58 |
*/
|
59 |
-
public function admin(
|
|
|
|
|
|
|
|
|
|
|
60 |
}
|
61 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Validation_Rule_In
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Validation_Rule_In extends MW_WP_Form_Abstract_Validation_Rule {
|
12 |
|
13 |
/**
|
14 |
+
* Validation rule name.
|
15 |
+
*
|
16 |
* @var string
|
17 |
*/
|
18 |
protected $name = 'in';
|
19 |
|
20 |
/**
|
21 |
+
* Validation process.
|
22 |
*
|
23 |
+
* @param string $name Validation name.
|
24 |
+
* @param array $options Validation options.
|
25 |
+
* @return string
|
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;
|
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 |
}
|
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(
|
60 |
+
// phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
|
61 |
+
$key,
|
62 |
+
$value
|
63 |
+
// phpcs:enable
|
64 |
+
) {
|
65 |
}
|
66 |
}
|
classes/validation-rules/class.kana.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
25 |
-
* @return string
|
26 |
*/
|
27 |
public function rule( $name, array $options = array() ) {
|
28 |
$value = $this->Data->get( $name );
|
@@ -36,17 +36,17 @@ class MW_WP_Form_Validation_Rule_Kana extends MW_WP_Form_Abstract_Validation_Rul
|
|
36 |
}
|
37 |
|
38 |
$defaults = array(
|
39 |
-
'message' => __( 'Please enter with a Japanese Hiragana or Katakana.', 'mw-wp-form' )
|
40 |
);
|
41 |
-
$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
|
50 |
* @return void
|
51 |
*/
|
52 |
public function admin( $key, $value ) {
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Validation_Rule_Kana
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Validation_Rule_Kana extends MW_WP_Form_Abstract_Validation_Rule {
|
12 |
|
13 |
/**
|
14 |
+
* Validation rule name.
|
15 |
+
*
|
16 |
* @var string
|
17 |
*/
|
18 |
protected $name = 'kana';
|
19 |
|
20 |
/**
|
21 |
+
* Validation process.
|
22 |
*
|
23 |
+
* @param string $name Validation name.
|
24 |
+
* @param array $options Validation options.
|
25 |
+
* @return string
|
26 |
*/
|
27 |
public function rule( $name, array $options = array() ) {
|
28 |
$value = $this->Data->get( $name );
|
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 ) {
|
classes/validation-rules/class.katakana.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
25 |
-
* @return string
|
26 |
*/
|
27 |
public function rule( $name, array $options = array() ) {
|
28 |
$value = $this->Data->get( $name );
|
@@ -35,17 +35,17 @@ class MW_WP_Form_Validation_Rule_Katakana extends MW_WP_Form_Abstract_Validation
|
|
35 |
}
|
36 |
|
37 |
$defaults = array(
|
38 |
-
'message' => __( 'Please enter with a Japanese Katakana.', 'mw-wp-form' )
|
39 |
);
|
40 |
-
$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
|
49 |
* @return void
|
50 |
*/
|
51 |
public function admin( $key, $value ) {
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Validation_Rule_Katakana
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Validation_Rule_Katakana extends MW_WP_Form_Abstract_Validation_Rule {
|
12 |
|
13 |
/**
|
14 |
+
* Validation rule name.
|
15 |
+
*
|
16 |
* @var string
|
17 |
*/
|
18 |
protected $name = 'katakana';
|
19 |
|
20 |
/**
|
21 |
+
* Validation process.
|
22 |
*
|
23 |
+
* @param string $name Validation name.
|
24 |
+
* @param array $options Validation options.
|
25 |
+
* @return string
|
26 |
*/
|
27 |
public function rule( $name, array $options = array() ) {
|
28 |
$value = $this->Data->get( $name );
|
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 ) {
|
classes/validation-rules/class.mail.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
25 |
-
* @return string
|
26 |
*/
|
27 |
public function rule( $name, array $options = array() ) {
|
28 |
$value = $this->Data->get( $name );
|
@@ -36,17 +36,17 @@ class MW_WP_Form_Validation_Rule_Mail extends MW_WP_Form_Abstract_Validation_Rul
|
|
36 |
}
|
37 |
|
38 |
$defaults = array(
|
39 |
-
'message' => __( 'This is not the format of a mail address.', 'mw-wp-form' )
|
40 |
);
|
41 |
-
$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
|
50 |
* @return void
|
51 |
*/
|
52 |
public function admin( $key, $value ) {
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Validation_Rule_Mail
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Validation_Rule_Mail extends MW_WP_Form_Abstract_Validation_Rule {
|
12 |
|
13 |
/**
|
14 |
+
* Validation rule name.
|
15 |
+
*
|
16 |
* @var string
|
17 |
*/
|
18 |
protected $name = 'mail';
|
19 |
|
20 |
/**
|
21 |
+
* Validation process.
|
22 |
*
|
23 |
+
* @param string $name Validation name.
|
24 |
+
* @param array $options Validation options.
|
25 |
+
* @return string
|
26 |
*/
|
27 |
public function rule( $name, array $options = array() ) {
|
28 |
$value = $this->Data->get( $name );
|
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 ) {
|
classes/validation-rules/class.maximagesize.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
25 |
-
* @return string
|
26 |
*/
|
27 |
public function rule( $name, array $options = array() ) {
|
28 |
$value = $this->Data->get( $name );
|
@@ -37,7 +37,7 @@ class MW_WP_Form_Validation_Rule_MaxImageSize extends MW_WP_Form_Abstract_Valida
|
|
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
|
41 |
|
42 |
if ( ! is_array( $upload_file_keys ) ) {
|
43 |
$upload_file_keys = array();
|
@@ -47,19 +47,18 @@ class MW_WP_Form_Validation_Rule_MaxImageSize extends MW_WP_Form_Abstract_Valida
|
|
47 |
$upload_files = array();
|
48 |
}
|
49 |
|
50 |
-
|
51 |
-
|
52 |
$file_path = $upload_files[ $name ]['tmp_name'];
|
53 |
-
}
|
54 |
-
|
55 |
-
else {
|
56 |
$file_path = MWF_Functions::fileurl_to_path( $value );
|
57 |
}
|
58 |
|
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 |
}
|
@@ -67,19 +66,19 @@ class MW_WP_Form_Validation_Rule_MaxImageSize extends MW_WP_Form_Abstract_Valida
|
|
67 |
$defaults = array(
|
68 |
'width' => 1,
|
69 |
'height' => 1,
|
70 |
-
'message' => __( 'This image size is too big.', 'mw-wp-form' )
|
71 |
);
|
72 |
-
$options
|
73 |
if ( $is_error || $imagesize[0] > $options['width'] || $imagesize[1] > $options['height'] ) {
|
74 |
return $options['message'];
|
75 |
}
|
76 |
}
|
77 |
|
78 |
/**
|
79 |
-
* Add setting field to validation rule setting panel
|
80 |
*
|
81 |
-
* @param numeric $key ID of validation rule
|
82 |
-
* @param array
|
83 |
* @return void
|
84 |
*/
|
85 |
public function admin( $key, $value ) {
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Validation_Rule_MaxImageSize
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Validation_Rule_MaxImageSize extends MW_WP_Form_Abstract_Validation_Rule {
|
12 |
|
13 |
/**
|
14 |
+
* Validation rule name.
|
15 |
+
*
|
16 |
* @var string
|
17 |
*/
|
18 |
protected $name = 'maxfilesize';
|
19 |
|
20 |
/**
|
21 |
+
* Validation process.
|
22 |
*
|
23 |
+
* @param string $name Validation name.
|
24 |
+
* @param array $options Validation options.
|
25 |
+
* @return string
|
26 |
*/
|
27 |
public function rule( $name, array $options = array() ) {
|
28 |
$value = $this->Data->get( $name );
|
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();
|
47 |
$upload_files = array();
|
48 |
}
|
49 |
|
50 |
+
if ( ! in_array( $name, $upload_file_keys, true ) && array_key_exists( $name, $upload_files ) ) {
|
51 |
+
// Check after upload
|
52 |
$file_path = $upload_files[ $name ]['tmp_name'];
|
53 |
+
} else {
|
54 |
+
// Check if uploaded
|
|
|
55 |
$file_path = MWF_Functions::fileurl_to_path( $value );
|
56 |
}
|
57 |
|
58 |
if ( file_exists( $file_path ) && exif_imagetype( $file_path ) ) {
|
59 |
$imagesize = getimagesize( $file_path );
|
60 |
} else {
|
61 |
+
if ( ! in_array( $name, $upload_file_keys, true ) ) {
|
62 |
$is_error = true;
|
63 |
}
|
64 |
}
|
66 |
$defaults = array(
|
67 |
'width' => 1,
|
68 |
'height' => 1,
|
69 |
+
'message' => __( 'This image size is too big.', 'mw-wp-form' ),
|
70 |
);
|
71 |
+
$options = array_merge( $defaults, $options );
|
72 |
if ( $is_error || $imagesize[0] > $options['width'] || $imagesize[1] > $options['height'] ) {
|
73 |
return $options['message'];
|
74 |
}
|
75 |
}
|
76 |
|
77 |
/**
|
78 |
+
* Add setting field to validation rule setting panel.
|
79 |
*
|
80 |
+
* @param numeric $key ID of validation rule.
|
81 |
+
* @param array $value Content of validation rule.
|
82 |
* @return void
|
83 |
*/
|
84 |
public function admin( $key, $value ) {
|
classes/validation-rules/class.minimagesize.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
25 |
-
* @return string
|
26 |
*/
|
27 |
public function rule( $name, array $options = array() ) {
|
28 |
$value = $this->Data->get( $name );
|
@@ -37,7 +37,7 @@ class MW_WP_Form_Validation_Rule_MinImageSize extends MW_WP_Form_Abstract_Valida
|
|
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
|
41 |
|
42 |
if ( ! is_array( $upload_file_keys ) ) {
|
43 |
$upload_file_keys = array();
|
@@ -47,19 +47,18 @@ class MW_WP_Form_Validation_Rule_MinImageSize extends MW_WP_Form_Abstract_Valida
|
|
47 |
$upload_files = array();
|
48 |
}
|
49 |
|
50 |
-
|
51 |
-
|
52 |
$file_path = $upload_files[ $name ]['tmp_name'];
|
53 |
-
}
|
54 |
-
|
55 |
-
else {
|
56 |
$file_path = MWF_Functions::fileurl_to_path( $value );
|
57 |
}
|
58 |
|
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 |
}
|
@@ -67,19 +66,19 @@ class MW_WP_Form_Validation_Rule_MinImageSize extends MW_WP_Form_Abstract_Valida
|
|
67 |
$defaults = array(
|
68 |
'width' => 1,
|
69 |
'height' => 1,
|
70 |
-
'message' => __( 'This image size is too small.', 'mw-wp-form' )
|
71 |
);
|
72 |
-
$options
|
73 |
if ( $is_error || $imagesize[0] < $options['width'] || $imagesize[1] < $options['height'] ) {
|
74 |
return $options['message'];
|
75 |
}
|
76 |
}
|
77 |
|
78 |
/**
|
79 |
-
* Add setting field to validation rule setting panel
|
80 |
*
|
81 |
-
* @param numeric $key ID of validation rule
|
82 |
-
* @param array
|
83 |
* @return void
|
84 |
*/
|
85 |
public function admin( $key, $value ) {
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Validation_Rule_MinImageSize
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Validation_Rule_MinImageSize extends MW_WP_Form_Abstract_Validation_Rule {
|
12 |
|
13 |
/**
|
14 |
+
* Validation rule name.
|
15 |
+
*
|
16 |
* @var string
|
17 |
*/
|
18 |
protected $name = 'minfilesize';
|
19 |
|
20 |
/**
|
21 |
+
* Validation process.
|
22 |
*
|
23 |
+
* @param string $name Validation name.
|
24 |
+
* @param array $options Validation options.
|
25 |
+
* @return string
|
26 |
*/
|
27 |
public function rule( $name, array $options = array() ) {
|
28 |
$value = $this->Data->get( $name );
|
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();
|
47 |
$upload_files = array();
|
48 |
}
|
49 |
|
50 |
+
if ( ! in_array( $name, $upload_file_keys, true ) && array_key_exists( $name, $upload_files ) ) {
|
51 |
+
// Check after upload
|
52 |
$file_path = $upload_files[ $name ]['tmp_name'];
|
53 |
+
} else {
|
54 |
+
// Check if uploaded
|
|
|
55 |
$file_path = MWF_Functions::fileurl_to_path( $value );
|
56 |
}
|
57 |
|
58 |
if ( file_exists( $file_path ) && exif_imagetype( $file_path ) ) {
|
59 |
$imagesize = getimagesize( $file_path );
|
60 |
} else {
|
61 |
+
if ( ! in_array( $name, $upload_file_keys, true ) ) {
|
62 |
$is_error = true;
|
63 |
}
|
64 |
}
|
66 |
$defaults = array(
|
67 |
'width' => 1,
|
68 |
'height' => 1,
|
69 |
+
'message' => __( 'This image size is too small.', 'mw-wp-form' ),
|
70 |
);
|
71 |
+
$options = array_merge( $defaults, $options );
|
72 |
if ( $is_error || $imagesize[0] < $options['width'] || $imagesize[1] < $options['height'] ) {
|
73 |
return $options['message'];
|
74 |
}
|
75 |
}
|
76 |
|
77 |
/**
|
78 |
+
* Add setting field to validation rule setting panel.
|
79 |
*
|
80 |
+
* @param numeric $key ID of validation rule.
|
81 |
+
* @param array $value Content of validation rule.
|
82 |
* @return void
|
83 |
*/
|
84 |
public function admin( $key, $value ) {
|
classes/validation-rules/class.minlength.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
25 |
-
* @return string
|
26 |
*/
|
27 |
public function rule( $name, array $options = array() ) {
|
28 |
$value = $this->Data->get( $name );
|
@@ -33,21 +33,21 @@ class MW_WP_Form_Validation_Rule_MinLength extends MW_WP_Form_Abstract_Validatio
|
|
33 |
}
|
34 |
|
35 |
$defaults = array(
|
36 |
-
'min'
|
37 |
-
'message' => __( 'The number of characters is a few.', 'mw-wp-form' )
|
38 |
);
|
39 |
-
$options
|
40 |
-
$length
|
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
|
51 |
* @return void
|
52 |
*/
|
53 |
public function admin( $key, $value ) {
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Validation_Rule_MinLength
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Validation_Rule_MinLength extends MW_WP_Form_Abstract_Validation_Rule {
|
12 |
|
13 |
/**
|
14 |
+
* Validation rule name.
|
15 |
+
*
|
16 |
* @var string
|
17 |
*/
|
18 |
protected $name = 'minlength';
|
19 |
|
20 |
/**
|
21 |
+
* Validation process.
|
22 |
*
|
23 |
+
* @param string $name Validation name.
|
24 |
+
* @param array $options Validation options.
|
25 |
+
* @return string
|
26 |
*/
|
27 |
public function rule( $name, array $options = array() ) {
|
28 |
$value = $this->Data->get( $name );
|
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 ) {
|
classes/validation-rules/class.month.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
25 |
-
* @return string
|
26 |
*/
|
27 |
public function rule( $name, array $options = array() ) {
|
28 |
$value = $this->Data->get( $name );
|
@@ -31,10 +31,10 @@ class MW_WP_Form_Validation_Rule_Month extends MW_WP_Form_Abstract_Validation_Ru
|
|
31 |
return;
|
32 |
}
|
33 |
|
34 |
-
$defaults
|
35 |
-
'message' => __( 'This is not the format of a date (Year/Month).', 'mw-wp-form' )
|
36 |
);
|
37 |
-
$options
|
38 |
$timestamp = strtotime( $value );
|
39 |
if ( ! $timestamp ) {
|
40 |
$timestamp = $this->convert_jpdate_to_timestamp( $value );
|
@@ -43,8 +43,8 @@ class MW_WP_Form_Validation_Rule_Month extends MW_WP_Form_Abstract_Validation_Ru
|
|
43 |
return $options['message'];
|
44 |
}
|
45 |
|
46 |
-
$year
|
47 |
-
$month
|
48 |
$checkdate = checkdate( $month, 1, $year );
|
49 |
|
50 |
if ( ! $timestamp || ! $checkdate || preg_match( '/^[a-zA-Z]$/', $value ) || preg_match( '/^\s+$/', $value ) ) {
|
@@ -53,9 +53,9 @@ class MW_WP_Form_Validation_Rule_Month extends MW_WP_Form_Abstract_Validation_Ru
|
|
53 |
}
|
54 |
|
55 |
/**
|
56 |
-
* Convert Japanese notation date to time stamp
|
57 |
*
|
58 |
-
* @param string $jpdate yyyy年mm
|
59 |
* @return string|false
|
60 |
*/
|
61 |
public function convert_jpdate_to_timestamp( $jpdate ) {
|
@@ -67,10 +67,10 @@ class MW_WP_Form_Validation_Rule_Month extends MW_WP_Form_Abstract_Validation_Ru
|
|
67 |
}
|
68 |
|
69 |
/**
|
70 |
-
* Add setting field to validation rule setting panel
|
71 |
*
|
72 |
-
* @param numeric $key ID of validation rule
|
73 |
-
* @param array
|
74 |
* @return void
|
75 |
*/
|
76 |
public function admin( $key, $value ) {
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Validation_Rule_Month
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Validation_Rule_Month extends MW_WP_Form_Abstract_Validation_Rule {
|
12 |
|
13 |
/**
|
14 |
+
* Validation rule name.
|
15 |
+
*
|
16 |
* @var string
|
17 |
*/
|
18 |
protected $name = 'month';
|
19 |
|
20 |
/**
|
21 |
+
* Validation process.
|
22 |
*
|
23 |
+
* @param string $name Validation name.
|
24 |
+
* @param array $options Validation options.
|
25 |
+
* @return string
|
26 |
*/
|
27 |
public function rule( $name, array $options = array() ) {
|
28 |
$value = $this->Data->get( $name );
|
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 );
|
43 |
return $options['message'];
|
44 |
}
|
45 |
|
46 |
+
$year = date_i18n( 'Y', $timestamp );
|
47 |
+
$month = date_i18n( 'm', $timestamp );
|
48 |
$checkdate = checkdate( $month, 1, $year );
|
49 |
|
50 |
if ( ! $timestamp || ! $checkdate || preg_match( '/^[a-zA-Z]$/', $value ) || preg_match( '/^\s+$/', $value ) ) {
|
53 |
}
|
54 |
|
55 |
/**
|
56 |
+
* Convert Japanese notation date to time stamp.
|
57 |
*
|
58 |
+
* @param string $jpdate yyyy年mm月.
|
59 |
* @return string|false
|
60 |
*/
|
61 |
public function convert_jpdate_to_timestamp( $jpdate ) {
|
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 ) {
|
classes/validation-rules/class.noempty.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
25 |
-
* @return string
|
26 |
*/
|
27 |
public function rule( $name, array $options = array() ) {
|
28 |
$value = $this->Data->get( $name );
|
@@ -32,17 +32,17 @@ class MW_WP_Form_Validation_Rule_noEmpty extends MW_WP_Form_Abstract_Validation_
|
|
32 |
}
|
33 |
|
34 |
$defaults = array(
|
35 |
-
'message' => __( 'Please enter.', 'mw-wp-form' )
|
36 |
);
|
37 |
-
$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
|
46 |
* @return void
|
47 |
*/
|
48 |
public function admin( $key, $value ) {
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Validation_Rule_noEmpty
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Validation_Rule_noEmpty extends MW_WP_Form_Abstract_Validation_Rule {
|
12 |
|
13 |
/**
|
14 |
+
* Validation rule name.
|
15 |
+
*
|
16 |
* @var string
|
17 |
*/
|
18 |
protected $name = 'noempty';
|
19 |
|
20 |
/**
|
21 |
+
* Validation process.
|
22 |
*
|
23 |
+
* @param string $name Validation name.
|
24 |
+
* @param array $options Validation options.
|
25 |
+
* @return string
|
26 |
*/
|
27 |
public function rule( $name, array $options = array() ) {
|
28 |
$value = $this->Data->get( $name );
|
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 ) {
|
classes/validation-rules/class.nofalse.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
25 |
-
* @return string
|
26 |
*/
|
27 |
public function rule( $name, array $options = array() ) {
|
28 |
$value = $this->Data->get( $name );
|
@@ -32,19 +32,24 @@ class MW_WP_Form_Validation_Rule_noFalse extends MW_WP_Form_Abstract_Validation_
|
|
32 |
}
|
33 |
|
34 |
$defaults = array(
|
35 |
-
'message' => __( 'Please enter.', 'mw-wp-form' )
|
36 |
);
|
37 |
-
$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
|
46 |
* @return void
|
47 |
*/
|
48 |
-
public function admin(
|
|
|
|
|
|
|
|
|
|
|
49 |
}
|
50 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Validation_Rule_noFalse
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Validation_Rule_noFalse extends MW_WP_Form_Abstract_Validation_Rule {
|
12 |
|
13 |
/**
|
14 |
+
* Validation rule name.
|
15 |
+
*
|
16 |
* @var string
|
17 |
*/
|
18 |
protected $name = 'nofalse';
|
19 |
|
20 |
/**
|
21 |
+
* Validation process.
|
22 |
*
|
23 |
+
* @param string $name Validation name.
|
24 |
+
* @param array $options Validation options.
|
25 |
+
* @return string
|
26 |
*/
|
27 |
public function rule( $name, array $options = array() ) {
|
28 |
$value = $this->Data->get( $name );
|
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(
|
49 |
+
// phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
|
50 |
+
$key,
|
51 |
+
$value
|
52 |
+
// phpcs:enable
|
53 |
+
) {
|
54 |
}
|
55 |
}
|
classes/validation-rules/class.numeric.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
25 |
-
* @return string
|
26 |
*/
|
27 |
public function rule( $name, array $options = array() ) {
|
28 |
$value = $this->Data->get( $name );
|
@@ -36,17 +36,17 @@ class MW_WP_Form_Validation_Rule_Numeric extends MW_WP_Form_Abstract_Validation_
|
|
36 |
}
|
37 |
|
38 |
$defaults = array(
|
39 |
-
'message' => __( 'Please enter with a half-width number.', 'mw-wp-form' )
|
40 |
);
|
41 |
-
$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
|
50 |
* @return void
|
51 |
*/
|
52 |
public function admin( $key, $value ) {
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Validation_Rule_Numeric
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Validation_Rule_Numeric extends MW_WP_Form_Abstract_Validation_Rule {
|
12 |
|
13 |
/**
|
14 |
+
* Validation rule name.
|
15 |
+
*
|
16 |
* @var string
|
17 |
*/
|
18 |
protected $name = 'numeric';
|
19 |
|
20 |
/**
|
21 |
+
* Validation process.
|
22 |
*
|
23 |
+
* @param string $name Validation name.
|
24 |
+
* @param array $options Validation options.
|
25 |
+
* @return string
|
26 |
*/
|
27 |
public function rule( $name, array $options = array() ) {
|
28 |
$value = $this->Data->get( $name );
|
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 ) {
|
classes/validation-rules/class.required.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
25 |
-
* @return string
|
26 |
*/
|
27 |
public function rule( $name, array $options = array() ) {
|
28 |
$value = $this->Data->get( $name );
|
@@ -32,17 +32,17 @@ class MW_WP_Form_Validation_Rule_Required extends MW_WP_Form_Abstract_Validation
|
|
32 |
}
|
33 |
|
34 |
$defaults = array(
|
35 |
-
'message' => __( 'This is required.', 'mw-wp-form' )
|
36 |
);
|
37 |
-
$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
|
46 |
* @return void
|
47 |
*/
|
48 |
public function admin( $key, $value ) {
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Validation_Rule_Required
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Validation_Rule_Required extends MW_WP_Form_Abstract_Validation_Rule {
|
12 |
|
13 |
/**
|
14 |
+
* Validation rule name.
|
15 |
+
*
|
16 |
* @var string
|
17 |
*/
|
18 |
protected $name = 'required';
|
19 |
|
20 |
/**
|
21 |
+
* Validation process.
|
22 |
*
|
23 |
+
* @param string $name Validation name.
|
24 |
+
* @param array $options Validation options.
|
25 |
+
* @return string
|
26 |
*/
|
27 |
public function rule( $name, array $options = array() ) {
|
28 |
$value = $this->Data->get( $name );
|
32 |
}
|
33 |
|
34 |
$defaults = array(
|
35 |
+
'message' => __( 'This is required.', '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 ) {
|
classes/validation-rules/class.tel.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
25 |
-
* @return string
|
26 |
*/
|
27 |
public function rule( $name, array $options = array() ) {
|
28 |
$value = $this->Data->get( $name );
|
@@ -32,9 +32,9 @@ class MW_WP_Form_Validation_Rule_Tel extends MW_WP_Form_Abstract_Validation_Rule
|
|
32 |
}
|
33 |
|
34 |
$defaults = array(
|
35 |
-
'message' => __( 'This is not the format of a tel number.', 'mw-wp-form' )
|
36 |
);
|
37 |
-
$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 )
|
@@ -49,10 +49,10 @@ class MW_WP_Form_Validation_Rule_Tel extends MW_WP_Form_Abstract_Validation_Rule
|
|
49 |
}
|
50 |
|
51 |
/**
|
52 |
-
* Add setting field to validation rule setting panel
|
53 |
*
|
54 |
-
* @param numeric $key ID of validation rule
|
55 |
-
* @param array
|
56 |
* @return void
|
57 |
*/
|
58 |
public function admin( $key, $value ) {
|
@@ -62,10 +62,10 @@ class MW_WP_Form_Validation_Rule_Tel extends MW_WP_Form_Abstract_Validation_Rule
|
|
62 |
}
|
63 |
|
64 |
/**
|
65 |
-
* This validation rule is for Japanese environments only
|
66 |
*
|
67 |
-
* @param array $validation_rules
|
68 |
-
* @return array
|
69 |
*/
|
70 |
public function _mwform_validation_rules( array $validation_rules ) {
|
71 |
$validation_rules = parent::_mwform_validation_rules( $validation_rules );
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Validation_Rule_Tel
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Validation_Rule_Tel extends MW_WP_Form_Abstract_Validation_Rule {
|
12 |
|
13 |
/**
|
14 |
+
* Validation rule name.
|
15 |
+
*
|
16 |
* @var string
|
17 |
*/
|
18 |
protected $name = 'tel';
|
19 |
|
20 |
/**
|
21 |
+
* Validation process.
|
22 |
*
|
23 |
+
* @param string $name Validation name.
|
24 |
+
* @param array $options Validation options.
|
25 |
+
* @return string
|
26 |
*/
|
27 |
public function rule( $name, array $options = array() ) {
|
28 |
$value = $this->Data->get( $name );
|
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 )
|
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 ) {
|
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
|
69 |
*/
|
70 |
public function _mwform_validation_rules( array $validation_rules ) {
|
71 |
$validation_rules = parent::_mwform_validation_rules( $validation_rules );
|
classes/validation-rules/class.url.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
25 |
-
* @return string
|
26 |
*/
|
27 |
public function rule( $name, array $options = array() ) {
|
28 |
$value = $this->Data->get( $name );
|
@@ -36,17 +36,17 @@ class MW_WP_Form_Validation_Rule_Url extends MW_WP_Form_Abstract_Validation_Rule
|
|
36 |
}
|
37 |
|
38 |
$defaults = array(
|
39 |
-
'message' => __( 'This is not the format of a url.', 'mw-wp-form' )
|
40 |
);
|
41 |
-
$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
|
50 |
* @return void
|
51 |
*/
|
52 |
public function admin( $key, $value ) {
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Validation_Rule_Url
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Validation_Rule_Url extends MW_WP_Form_Abstract_Validation_Rule {
|
12 |
|
13 |
/**
|
14 |
+
* Validation rule name.
|
15 |
+
*
|
16 |
* @var string
|
17 |
*/
|
18 |
protected $name = 'url';
|
19 |
|
20 |
/**
|
21 |
+
* Validation process.
|
22 |
*
|
23 |
+
* @param string $name Validation name.
|
24 |
+
* @param array $options Validation options.
|
25 |
+
* @return string
|
26 |
*/
|
27 |
public function rule( $name, array $options = array() ) {
|
28 |
$value = $this->Data->get( $name );
|
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 ) {
|
classes/validation-rules/class.zip.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
*
|
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
|
25 |
-
* @return string
|
26 |
*/
|
27 |
public function rule( $name, array $options = array() ) {
|
28 |
$value = $this->Data->get( $name );
|
@@ -32,9 +32,9 @@ class MW_WP_Form_Validation_Rule_Zip extends MW_WP_Form_Abstract_Validation_Rule
|
|
32 |
}
|
33 |
|
34 |
$defaults = array(
|
35 |
-
'message' => __( 'This is not the format of a zip code.', 'mw-wp-form' )
|
36 |
);
|
37 |
-
$options
|
38 |
if ( preg_match( '/^\d{3}-\d{4}$/', $value )
|
39 |
|| preg_match( '/^\d{7}$/', $value ) ) {
|
40 |
|
@@ -45,11 +45,10 @@ class MW_WP_Form_Validation_Rule_Zip extends MW_WP_Form_Abstract_Validation_Rule
|
|
45 |
}
|
46 |
|
47 |
/**
|
48 |
-
* Add setting field to validation rule setting panel
|
49 |
*
|
50 |
-
* @param numeric $key ID of validation rule
|
51 |
-
* @param array
|
52 |
-
* @return void
|
53 |
*/
|
54 |
public function admin( $key, $value ) {
|
55 |
?>
|
@@ -58,10 +57,10 @@ class MW_WP_Form_Validation_Rule_Zip extends MW_WP_Form_Abstract_Validation_Rule
|
|
58 |
}
|
59 |
|
60 |
/**
|
61 |
-
* This validation rule is for Japanese environments only
|
62 |
*
|
63 |
-
* @param array $validation_rules
|
64 |
-
* @return array
|
65 |
*/
|
66 |
public function _mwform_validation_rules( array $validation_rules ) {
|
67 |
$validation_rules = parent::_mwform_validation_rules( $validation_rules );
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* MW_WP_Form_Validation_Rule_Zip
|
|
|
10 |
*/
|
11 |
class MW_WP_Form_Validation_Rule_Zip extends MW_WP_Form_Abstract_Validation_Rule {
|
12 |
|
13 |
/**
|
14 |
+
* Validation rule name.
|
15 |
+
*
|
16 |
* @var string
|
17 |
*/
|
18 |
protected $name = 'zip';
|
19 |
|
20 |
/**
|
21 |
+
* Validation process.
|
22 |
*
|
23 |
+
* @param string $name Validation name.
|
24 |
+
* @param array $options Validation options.
|
25 |
+
* @return string
|
26 |
*/
|
27 |
public function rule( $name, array $options = array() ) {
|
28 |
$value = $this->Data->get( $name );
|
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 |
|
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 |
*/
|
53 |
public function admin( $key, $value ) {
|
54 |
?>
|
57 |
}
|
58 |
|
59 |
/**
|
60 |
+
* This validation rule is for Japanese environments only.
|
61 |
*
|
62 |
+
* @param array $validation_rules Array of MW_WP_Form_Abstract_Validation_Rule.
|
63 |
+
* @return array
|
64 |
*/
|
65 |
public function _mwform_validation_rules( array $validation_rules ) {
|
66 |
$validation_rules = parent::_mwform_validation_rules( $validation_rules );
|
mw-wp-form.php
CHANGED
@@ -3,14 +3,20 @@
|
|
3 |
* Plugin Name: MW WP Form
|
4 |
* Plugin URI: https://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.
|
7 |
-
* Author:
|
8 |
* Author URI: https://2inc.org
|
9 |
-
* Created : September 25, 2012
|
10 |
-
* Modified: October 25, 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' );
|
@@ -18,27 +24,28 @@ 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__
|
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
|
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 ) {
|
@@ -48,37 +55,31 @@ class MW_WP_Form {
|
|
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'
|
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'
|
71 |
-
add_action( 'admin_menu'
|
72 |
-
add_action( 'current_screen'
|
73 |
} elseif ( ! is_admin() ) {
|
74 |
-
|
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 );
|
@@ -86,9 +87,7 @@ class MW_WP_Form {
|
|
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();
|
@@ -107,9 +106,7 @@ class MW_WP_Form {
|
|
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();
|
@@ -128,36 +125,28 @@ class MW_WP_Form {
|
|
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
|
138 |
-
|
139 |
-
}
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
elseif (
|
144 |
-
|
145 |
-
}
|
146 |
-
|
147 |
-
|
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() ) {
|
@@ -165,60 +154,64 @@ class MW_WP_Form {
|
|
165 |
}
|
166 |
|
167 |
// MW WP Form のフォーム設定を管理する投稿タイプ
|
168 |
-
register_post_type(
|
169 |
-
|
170 |
-
|
171 |
-
'
|
172 |
-
'
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
'public' => false,
|
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 ) {
|
189 |
-
$post_type = MWF_Functions::get_contact_data_post_type_from_form_id( $form->ID );
|
190 |
-
register_post_type( $post_type, array(
|
191 |
-
'label' => $form->post_title,
|
192 |
-
'labels' => array(
|
193 |
-
'name' => $form->post_title,
|
194 |
-
'singular_name' => $form->post_title,
|
195 |
-
'edit_item' => __( 'Edit ', 'mw-wp-form' ) . ':' . $form->post_title,
|
196 |
-
'view_item' => __( 'View', 'mw-wp-form' ) . ':' . $form->post_title,
|
197 |
-
'search_items' => __( 'Search', 'mw-wp-form' ) . ':' . $form->post_title,
|
198 |
-
'not_found' => __( 'No data found', 'mw-wp-form' ),
|
199 |
-
'not_found_in_trash' => __( 'No data found in Trash', 'mw-wp-form' ),
|
200 |
),
|
201 |
'capability_type' => 'page',
|
202 |
'public' => false,
|
203 |
'show_ui' => true,
|
204 |
-
|
205 |
-
|
206 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
207 |
}
|
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 |
-
$
|
221 |
-
$forms = $
|
222 |
|
223 |
$data_post_ids = array();
|
224 |
foreach ( $forms as $form ) {
|
@@ -229,10 +222,12 @@ class MW_WP_Form {
|
|
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(
|
233 |
-
|
234 |
-
|
235 |
-
|
|
|
|
|
236 |
if ( empty( $data_posts ) ) {
|
237 |
continue;
|
238 |
}
|
@@ -242,11 +237,11 @@ class MW_WP_Form {
|
|
242 |
}
|
243 |
}
|
244 |
|
245 |
-
$
|
246 |
-
$
|
247 |
|
248 |
delete_option( MWF_Config::NAME );
|
249 |
}
|
250 |
}
|
251 |
|
252 |
-
$
|
3 |
* Plugin Name: MW WP Form
|
4 |
* Plugin URI: https://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.3.1
|
7 |
+
* Author: inc2734
|
8 |
* Author URI: https://2inc.org
|
|
|
|
|
9 |
* Text Domain: mw-wp-form
|
10 |
* License: GPLv2 or later
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
+
*
|
13 |
+
* @package mw-wp-form
|
14 |
+
* @author inc2734
|
15 |
+
* @license GPL-2.0+
|
16 |
+
*/
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Include files.
|
20 |
*/
|
21 |
include_once( plugin_dir_path( __FILE__ ) . 'classes/functions.php' );
|
22 |
include_once( plugin_dir_path( __FILE__ ) . 'classes/config.php' );
|
24 |
|
25 |
class MW_WP_Form {
|
26 |
|
27 |
+
/**
|
28 |
+
* Constructor.
|
29 |
+
*/
|
30 |
public function __construct() {
|
31 |
add_action( 'plugins_loaded', array( $this, '_load_initialize_files' ), 9 );
|
32 |
add_action( 'plugins_loaded', array( $this, '_initialize' ), 11 );
|
33 |
|
34 |
+
register_uninstall_hook( __FILE__, array( __CLASS__, '_uninstall' ) );
|
35 |
}
|
36 |
|
37 |
/**
|
38 |
+
* Load classes.
|
|
|
|
|
39 |
*/
|
40 |
public function _load_initialize_files() {
|
41 |
$plugin_dir_path = plugin_dir_path( __FILE__ );
|
42 |
+
$includes = array(
|
43 |
'/classes/abstract',
|
44 |
'/classes/controllers',
|
45 |
'/classes/models',
|
46 |
'/classes/services',
|
47 |
'/classes/validation-rules',
|
48 |
+
'/classes/form-fields',
|
49 |
);
|
50 |
foreach ( $includes as $include ) {
|
51 |
foreach ( glob( $plugin_dir_path . $include . '/*.php' ) as $file ) {
|
55 |
}
|
56 |
|
57 |
/**
|
58 |
+
* Load text domain, The starting point of the process.
|
|
|
|
|
59 |
*/
|
60 |
public function _initialize() {
|
61 |
load_plugin_textdomain( 'mw-wp-form' );
|
62 |
|
63 |
add_action( 'after_setup_theme', array( $this, '_after_setup_theme' ), 11 );
|
64 |
+
add_action( 'init', array( $this, '_register_post_type' ) );
|
65 |
}
|
66 |
|
67 |
/**
|
68 |
+
* Initialize each screens.
|
|
|
|
|
69 |
*/
|
70 |
public function _after_setup_theme() {
|
71 |
if ( current_user_can( MWF_Config::CAPABILITY ) && is_admin() ) {
|
72 |
add_action( 'admin_enqueue_scripts', array( $this, '_admin_enqueue_scripts' ) );
|
73 |
+
add_action( 'admin_menu', array( $this, '_admin_menu_for_chart' ) );
|
74 |
+
add_action( 'admin_menu', array( $this, '_admin_menu_for_inquiry_data_list' ) );
|
75 |
+
add_action( 'current_screen', array( $this, '_current_screen' ) );
|
76 |
} elseif ( ! is_admin() ) {
|
77 |
+
new MW_WP_Form_Main_Controller();
|
78 |
}
|
79 |
}
|
80 |
|
81 |
/**
|
82 |
+
* Enqueue assets.
|
|
|
|
|
83 |
*/
|
84 |
public function _admin_enqueue_scripts() {
|
85 |
$url = plugins_url( MWF_Config::NAME );
|
87 |
}
|
88 |
|
89 |
/**
|
90 |
+
* Add admin menu for chart.
|
|
|
|
|
91 |
*/
|
92 |
public function _admin_menu_for_chart() {
|
93 |
$contact_data_post_types = MW_WP_Form_Contact_Data_Setting::get_form_post_types();
|
106 |
}
|
107 |
|
108 |
/**
|
109 |
+
* Add admin menu for saved inquiry data.
|
|
|
|
|
110 |
*/
|
111 |
public function _admin_menu_for_inquiry_data_list() {
|
112 |
$contact_data_post_types = MW_WP_Form_Contact_Data_Setting::get_form_post_types();
|
125 |
}
|
126 |
|
127 |
/**
|
128 |
+
* Front controller.
|
129 |
*
|
130 |
+
* @param WP_Screen $screen WP_Screen object.
|
|
|
131 |
*/
|
132 |
public function _current_screen( $screen ) {
|
133 |
+
if ( MWF_Config::NAME === $screen->id ) {
|
134 |
+
new MW_WP_Form_Admin_Controller();
|
135 |
+
} elseif ( 'edit-' . MWF_Config::NAME === $screen->id ) {
|
136 |
+
new MW_WP_Form_Admin_List_Controller();
|
137 |
+
} elseif ( MWF_Functions::is_contact_data_post_type( $screen->id ) ) {
|
138 |
+
new MW_WP_Form_Contact_Data_Controller();
|
139 |
+
} elseif ( preg_match( '/^edit-' . MWF_Config::DBDATA . '\d+$/', $screen->id ) ) {
|
140 |
+
new MW_WP_Form_Contact_Data_List_Controller();
|
141 |
+
} elseif ( MWF_Config::NAME . '_page_' . MWF_Config::NAME . '-chart' === $screen->id ) {
|
142 |
+
new MW_WP_Form_Chart_Controller();
|
143 |
+
} elseif ( MWF_Config::NAME . '_page_' . MWF_Config::NAME . '-save-data' === $screen->id ) {
|
144 |
+
new MW_WP_Form_Stores_Inquiry_Data_Form_List_Controller();
|
|
|
|
|
|
|
|
|
|
|
145 |
}
|
146 |
}
|
147 |
|
148 |
/**
|
149 |
+
* Register post types for MW WP Form and inquiry data.
|
|
|
|
|
150 |
*/
|
151 |
public function _register_post_type() {
|
152 |
if ( ! current_user_can( MWF_Config::CAPABILITY ) && is_admin() ) {
|
154 |
}
|
155 |
|
156 |
// MW WP Form のフォーム設定を管理する投稿タイプ
|
157 |
+
register_post_type(
|
158 |
+
MWF_Config::NAME,
|
159 |
+
array(
|
160 |
+
'label' => 'MW WP Form',
|
161 |
+
'labels' => array(
|
162 |
+
'name' => 'MW WP Form',
|
163 |
+
'singular_name' => 'MW WP Form',
|
164 |
+
'add_new_item' => __( 'Add New Form', 'mw-wp-form' ),
|
165 |
+
'edit_item' => __( 'Edit Form', 'mw-wp-form' ),
|
166 |
+
'new_item' => __( 'New Form', 'mw-wp-form' ),
|
167 |
+
'view_item' => __( 'View Form', 'mw-wp-form' ),
|
168 |
+
'search_items' => __( 'Search Forms', 'mw-wp-form' ),
|
169 |
+
'not_found' => __( 'No Forms found', 'mw-wp-form' ),
|
170 |
+
'not_found_in_trash' => __( 'No Forms found in Trash', 'mw-wp-form' ),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
171 |
),
|
172 |
'capability_type' => 'page',
|
173 |
'public' => false,
|
174 |
'show_ui' => true,
|
175 |
+
)
|
176 |
+
);
|
177 |
+
|
178 |
+
$admin = new MW_WP_Form_Admin();
|
179 |
+
$forms = $admin->get_forms_using_database();
|
180 |
+
foreach ( $forms as $form ) {
|
181 |
+
$post_type = MWF_Functions::get_contact_data_post_type_from_form_id( $form->ID );
|
182 |
+
register_post_type(
|
183 |
+
$post_type,
|
184 |
+
array(
|
185 |
+
'label' => $form->post_title,
|
186 |
+
'labels' => array(
|
187 |
+
'name' => $form->post_title,
|
188 |
+
'singular_name' => $form->post_title,
|
189 |
+
'edit_item' => __( 'Edit ', 'mw-wp-form' ) . ':' . $form->post_title,
|
190 |
+
'view_item' => __( 'View', 'mw-wp-form' ) . ':' . $form->post_title,
|
191 |
+
'search_items' => __( 'Search', 'mw-wp-form' ) . ':' . $form->post_title,
|
192 |
+
'not_found' => __( 'No data found', 'mw-wp-form' ),
|
193 |
+
'not_found_in_trash' => __( 'No data found in Trash', 'mw-wp-form' ),
|
194 |
+
),
|
195 |
+
'capability_type' => 'page',
|
196 |
+
'public' => false,
|
197 |
+
'show_ui' => true,
|
198 |
+
'show_in_menu' => false,
|
199 |
+
'supports' => array( 'title' ),
|
200 |
+
)
|
201 |
+
);
|
202 |
}
|
203 |
}
|
204 |
|
205 |
/**
|
206 |
+
* Uninstall processes.
|
|
|
|
|
207 |
*/
|
208 |
public static function _uninstall() {
|
209 |
$plugin_dir_path = plugin_dir_path( __FILE__ );
|
210 |
include_once( $plugin_dir_path . 'classes/models/class.admin.php' );
|
211 |
include_once( $plugin_dir_path . 'classes/models/class.file.php' );
|
212 |
|
213 |
+
$admin = new MW_WP_Form_Admin();
|
214 |
+
$forms = $admin->get_forms();
|
215 |
|
216 |
$data_post_ids = array();
|
217 |
foreach ( $forms as $form ) {
|
222 |
foreach ( $data_post_ids as $data_post_id ) {
|
223 |
delete_option( MWF_Config::NAME . '-chart-' . $data_post_id );
|
224 |
|
225 |
+
$data_posts = get_posts(
|
226 |
+
array(
|
227 |
+
'post_type' => MWF_Functions::get_contact_data_post_type_from_form_id( $data_post_id ),
|
228 |
+
'posts_per_page' => -1,
|
229 |
+
)
|
230 |
+
);
|
231 |
if ( empty( $data_posts ) ) {
|
232 |
continue;
|
233 |
}
|
237 |
}
|
238 |
}
|
239 |
|
240 |
+
$file = new MW_WP_Form_File();
|
241 |
+
$file->remove_temp_dir();
|
242 |
|
243 |
delete_option( MWF_Config::NAME );
|
244 |
}
|
245 |
}
|
246 |
|
247 |
+
$mw_wp_form = new MW_WP_Form();
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: inc2734, ryu263, tomothumb, nanniku, mt8.biz, NExt-Season, kuck1u,
|
|
3 |
Donate link: https://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: 5.
|
7 |
-
Stable tag: 4.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -73,6 +73,18 @@ Do you have questions or issues with MW WP Form? Use these support channels appr
|
|
73 |
|
74 |
== Changelog ==
|
75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
= 4.2.0 =
|
77 |
* Fixed a bug that memo is not saved.
|
78 |
* The select element can be used in tag generator dialog box.
|
3 |
Donate link: https://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: 5.5
|
7 |
+
Stable tag: 4.3.1
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
73 |
|
74 |
== Changelog ==
|
75 |
|
76 |
+
= 4.3.1 =
|
77 |
+
* Some fix for `mwform_settings_extend_fields`.
|
78 |
+
* Some fix for `mwform_settings_extend_fields_mw-wp-form-xxx`.
|
79 |
+
|
80 |
+
= 4.3.0 =
|
81 |
+
* Add filter hook `mwform_template_render`.
|
82 |
+
* Add filter hook `mwform_template_render_mw-wp-form-xxx`.
|
83 |
+
* Add filter hook `mwform_settings_extend_fields`.
|
84 |
+
* Add filter hook `mwform_settings_extend_fields_mw-wp-form-xxx`.
|
85 |
+
* Fix monthpicker bug.
|
86 |
+
* Add wp-env.
|
87 |
+
|
88 |
= 4.2.0 =
|
89 |
* Fixed a bug that memo is not saved.
|
90 |
* The select element can be used in tag generator dialog box.
|
templates/admin-list/form-key.php
CHANGED
@@ -1 +1,9 @@
|
|
1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
?>
|
8 |
+
|
9 |
+
<span id="formkey_field">[mwform_formkey key="<?php echo esc_html( $post_id ); ?>"]</span>
|
templates/admin/add-ons.php
CHANGED
@@ -1,3 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<p>
|
2 |
<?php esc_html_e( 'You can use more easy and useful to the MW WP Form in add-on!', 'mw-wp-form' ); ?><br />
|
3 |
<a href="https://plugins.2inc.org/mw-wp-form/add-on/" target="_blank" class="button button-primary"><?php esc_html_e( 'View Add-ons', 'mw-wp-form' ); ?></a>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
?>
|
8 |
+
|
9 |
<p>
|
10 |
<?php esc_html_e( 'You can use more easy and useful to the MW WP Form in add-on!', 'mw-wp-form' ); ?><br />
|
11 |
<a href="https://plugins.2inc.org/mw-wp-form/add-on/" target="_blank" class="button button-primary"><?php esc_html_e( 'View Add-ons', 'mw-wp-form' ); ?></a>
|
templates/admin/admin-mail-options.php
CHANGED
@@ -1,9 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<p>
|
2 |
<?php esc_html_e( '{name of form tag} is converted to posted data.', 'mw-wp-form' ); ?>
|
3 |
-
<?php
|
|
|
|
|
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 />
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
?>
|
8 |
+
|
9 |
<p>
|
10 |
<?php esc_html_e( '{name of form tag} is converted to posted data.', 'mw-wp-form' ); ?>
|
11 |
+
<?php
|
12 |
+
echo sprintf(
|
13 |
+
// translators: %s: Tracking number
|
14 |
esc_html__( 'It is automatically converted to Tracking number when you input {%s}.', 'mw-wp-form' ),
|
15 |
MWF_Config::TRACKINGNUMBER
|
16 |
+
);
|
17 |
+
?>
|
18 |
</p>
|
19 |
<p>
|
20 |
<b><?php esc_html_e( 'To ( E-mail address )', 'mw-wp-form' ); ?></b><br />
|
templates/admin/complete-message.php
CHANGED
@@ -1,4 +1,10 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
wp_editor(
|
3 |
$this->_get_option( 'complete_message' ),
|
4 |
MWF_Config::NAME . '_complete_message',
|
@@ -10,8 +16,11 @@ wp_editor(
|
|
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
|
|
|
|
|
14 |
esc_html__( 'It is automatically converted to Tracking number when you input {%s}.', 'mw-wp-form' ),
|
15 |
MWF_Config::TRACKINGNUMBER
|
16 |
-
);
|
|
|
17 |
</p>
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
wp_editor(
|
9 |
$this->_get_option( 'complete_message' ),
|
10 |
MWF_Config::NAME . '_complete_message',
|
16 |
?>
|
17 |
<p class="mwf_note">
|
18 |
<?php esc_html_e( '{name of form tag} is converted to posted data.', 'mw-wp-form' ); ?>
|
19 |
+
<?php
|
20 |
+
echo sprintf(
|
21 |
+
// translators: %s: Tracking Number
|
22 |
esc_html__( 'It is automatically converted to Tracking number when you input {%s}.', 'mw-wp-form' ),
|
23 |
MWF_Config::TRACKINGNUMBER
|
24 |
+
);
|
25 |
+
?>
|
26 |
</p>
|
templates/admin/form-key.php
CHANGED
@@ -1,7 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<p>
|
2 |
<span id="formkey_field">[mwform_formkey key="<?php echo esc_html( $post_id ); ?>"]</span>
|
3 |
<span class="mwf_note">
|
4 |
<?php esc_html_e( 'Copy and Paste this shortcode.', 'mw-wp-form' ); ?><br />
|
5 |
<?php esc_html_e( 'The key to use with hook is ', 'mw-wp-form' ); ?><?php echo MWF_Config::NAME; ?>-<?php echo esc_html( $post_id ); ?>
|
6 |
</span>
|
7 |
-
</p>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
?>
|
8 |
+
|
9 |
<p>
|
10 |
<span id="formkey_field">[mwform_formkey key="<?php echo esc_html( $post_id ); ?>"]</span>
|
11 |
<span class="mwf_note">
|
12 |
<?php esc_html_e( 'Copy and Paste this shortcode.', 'mw-wp-form' ); ?><br />
|
13 |
<?php esc_html_e( 'The key to use with hook is ', 'mw-wp-form' ); ?><?php echo MWF_Config::NAME; ?>-<?php echo esc_html( $post_id ); ?>
|
14 |
</span>
|
15 |
+
</p>
|
templates/admin/mail-options.php
CHANGED
@@ -1,9 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<p>
|
2 |
<?php esc_html_e( '{name of form tag} is converted to posted data.', 'mw-wp-form' ); ?>
|
3 |
-
<?php
|
|
|
|
|
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( 'Subject', 'mw-wp-form' ); ?></b><br />
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
?>
|
8 |
+
|
9 |
<p>
|
10 |
<?php esc_html_e( '{name of form tag} is converted to posted data.', 'mw-wp-form' ); ?>
|
11 |
+
<?php
|
12 |
+
echo sprintf(
|
13 |
+
// translators: %s: Tracing Number
|
14 |
esc_html__( 'It is automatically converted to Tracking number when you input {%s}.', 'mw-wp-form' ),
|
15 |
MWF_Config::TRACKINGNUMBER
|
16 |
+
);
|
17 |
+
?>
|
18 |
</p>
|
19 |
<p>
|
20 |
<b><?php esc_html_e( 'Subject', 'mw-wp-form' ); ?></b><br />
|
templates/admin/settings.php
CHANGED
@@ -1,3 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<div class="section">
|
2 |
<label>
|
3 |
<input
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
?>
|
8 |
+
|
9 |
<div class="section">
|
10 |
<label>
|
11 |
<input
|
templates/admin/style.php
CHANGED
@@ -1,3 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<p>
|
2 |
<select name="<?php echo MWF_Config::NAME; ?>[style]">
|
3 |
<option value=""><?php esc_html_e( 'Select Style', 'mw-wp-form' ); ?></option>
|
@@ -7,4 +15,4 @@
|
|
7 |
</option>
|
8 |
<?php endforeach; ?>
|
9 |
</select>
|
10 |
-
</p>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
?>
|
8 |
+
|
9 |
<p>
|
10 |
<select name="<?php echo MWF_Config::NAME; ?>[style]">
|
11 |
<option value=""><?php esc_html_e( 'Select Style', 'mw-wp-form' ); ?></option>
|
15 |
</option>
|
16 |
<?php endforeach; ?>
|
17 |
</select>
|
18 |
+
</p>
|
templates/admin/tag-generator.php
CHANGED
@@ -1,4 +1,10 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
do_action( 'mwform_tag_generator_dialog' );
|
3 |
|
4 |
$types = array(
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
do_action( 'mwform_tag_generator_dialog' );
|
9 |
|
10 |
$types = array(
|
templates/admin/url.php
CHANGED
@@ -1,3 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<input type="hidden" name="<?php echo esc_attr( MWF_Config::NAME ); ?>_nonce" value="<?php echo wp_create_nonce( MWF_Config::NAME ); ?>" />
|
2 |
<table border="0" cellpadding="0" cellspacing="4">
|
3 |
<tr>
|
@@ -27,5 +35,11 @@
|
|
27 |
</table>
|
28 |
<p class="description">
|
29 |
<?php esc_html_e( 'This urls are the redirection urls at the time of button press. When URL setting is empty, The page redirect on the same page.', 'mw-wp-form' ); ?><br />
|
30 |
-
<?php
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
?>
|
8 |
+
|
9 |
<input type="hidden" name="<?php echo esc_attr( MWF_Config::NAME ); ?>_nonce" value="<?php echo wp_create_nonce( MWF_Config::NAME ); ?>" />
|
10 |
<table border="0" cellpadding="0" cellspacing="4">
|
11 |
<tr>
|
35 |
</table>
|
36 |
<p class="description">
|
37 |
<?php esc_html_e( 'This urls are the redirection urls at the time of button press. When URL setting is empty, The page redirect on the same page.', 'mw-wp-form' ); ?><br />
|
38 |
+
<?php
|
39 |
+
printf(
|
40 |
+
// translators: $s: home_url()
|
41 |
+
esc_html__( 'When a URL doesn\'t begin http or https, %s is complemented.', 'mw-wp-form' ),
|
42 |
+
'<b>' . home_url() . '</b>'
|
43 |
+
);
|
44 |
+
?>
|
45 |
+
</p>
|
templates/admin/validation-rule.php
CHANGED
@@ -1,7 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<b class="add-btn"><?php esc_html_e( 'Add Validation rule', 'mw-wp-form' ); ?></b>
|
2 |
<div class="repeatable-boxes">
|
3 |
-
<?php
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
<div class="sortable-icon-handle"></div>
|
6 |
<div class="remove-btn"><b>×</b></div>
|
7 |
<div class="open-btn"><span><?php echo esc_attr( $value['target'] ); ?></span><b>▼</b></div>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
?>
|
8 |
+
|
9 |
<b class="add-btn"><?php esc_html_e( 'Add Validation rule', 'mw-wp-form' ); ?></b>
|
10 |
<div class="repeatable-boxes">
|
11 |
+
<?php
|
12 |
+
foreach ( $validation as $key => $value ) :
|
13 |
+
$value = array_merge( $validation_keys, $value );
|
14 |
+
?>
|
15 |
+
<div class="repeatable-box"
|
16 |
+
<?php
|
17 |
+
if ( 0 === $key ) :
|
18 |
+
?>
|
19 |
+
style="display:none"<?php endif; ?>>
|
20 |
<div class="sortable-icon-handle"></div>
|
21 |
<div class="remove-btn"><b>×</b></div>
|
22 |
<div class="open-btn"><span><?php echo esc_attr( $value['target'] ); ?></span><b>▼</b></div>
|
templates/chart/index.php
CHANGED
@@ -1,3 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<div class="wrap">
|
2 |
<?php $post_id = preg_replace( '/^(.+_)(\d+)$/', '$2', $post_type ); ?>
|
3 |
<h2>
|
@@ -13,8 +21,12 @@
|
|
13 |
<div class="inside">
|
14 |
<b class="add-btn"><?php esc_html_e( 'Add Chart', 'mw-wp-form' ); ?></b>
|
15 |
<div class="repeatable-boxes">
|
16 |
-
<?php foreach ( $postdata as $key => $value ) :
|
17 |
-
<div class="repeatable-box"
|
|
|
|
|
|
|
|
|
18 |
<div class="sortable-icon-handle"></div>
|
19 |
<div class="remove-btn"><b>×</b></div>
|
20 |
<div class="open-btn"><span><?php echo esc_html( $value['target'] ); ?></span><b>▼</b></div>
|
@@ -75,11 +87,11 @@
|
|
75 |
|
76 |
$chart_data = array();
|
77 |
foreach ( $postdata as $postdata_key => $chart ) {
|
78 |
-
$data
|
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']
|
83 |
}
|
84 |
if ( is_array( $item ) ) {
|
85 |
foreach ( $item as $_item ) {
|
@@ -111,7 +123,7 @@
|
|
111 |
$value = $raw_data_value;
|
112 |
}
|
113 |
$data[] = array(
|
114 |
-
(
|
115 |
$value,
|
116 |
);
|
117 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
?>
|
8 |
+
|
9 |
<div class="wrap">
|
10 |
<?php $post_id = preg_replace( '/^(.+_)(\d+)$/', '$2', $post_type ); ?>
|
11 |
<h2>
|
21 |
<div class="inside">
|
22 |
<b class="add-btn"><?php esc_html_e( 'Add Chart', 'mw-wp-form' ); ?></b>
|
23 |
<div class="repeatable-boxes">
|
24 |
+
<?php foreach ( $postdata as $key => $value ) : ?>
|
25 |
+
<div class="repeatable-box"
|
26 |
+
<?php
|
27 |
+
if ( 0 === $key ) :
|
28 |
+
?>
|
29 |
+
style="display:none"<?php endif; ?>>
|
30 |
<div class="sortable-icon-handle"></div>
|
31 |
<div class="remove-btn"><b>×</b></div>
|
32 |
<div class="open-btn"><span><?php echo esc_html( $value['target'] ); ?></span><b>▼</b></div>
|
87 |
|
88 |
$chart_data = array();
|
89 |
foreach ( $postdata as $postdata_key => $chart ) {
|
90 |
+
$data = array();
|
91 |
$raw_data = array();
|
92 |
foreach ( $custom_keys[ $chart['target'] ] as $item => $values ) {
|
93 |
if ( $chart['separator'] && strstr( $item, $chart['separator'] ) ) {
|
94 |
+
$item = explode( $chart['separator'], $item );
|
95 |
}
|
96 |
if ( is_array( $item ) ) {
|
97 |
foreach ( $item as $_item ) {
|
123 |
$value = $raw_data_value;
|
124 |
}
|
125 |
$data[] = array(
|
126 |
+
(string) $raw_data_key,
|
127 |
$value,
|
128 |
);
|
129 |
}
|
templates/contact-data-list/admin-print-styles.php
CHANGED
@@ -1,5 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<style type="text/css">
|
2 |
#normal-sortables {
|
3 |
display: none;
|
4 |
}
|
5 |
-
</style>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
?>
|
8 |
+
|
9 |
<style type="text/css">
|
10 |
#normal-sortables {
|
11 |
display: none;
|
12 |
}
|
13 |
+
</style>
|
templates/contact-data-list/column.php
CHANGED
@@ -1 +1,8 @@
|
|
1 |
-
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
+
echo $column;
|
templates/contact-data-list/csv-button.php
CHANGED
@@ -1,3 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<form id="mw-wp-form_csv" method="post" action="<?php echo esc_url( $action ); ?>">
|
2 |
<input type="submit" value="<?php esc_attr_e( 'CSV Download', 'mw-wp-form' ); ?>" class="button-primary" />
|
3 |
|
@@ -5,4 +13,4 @@
|
|
5 |
<label><input type="checkbox" name="download-all" value="true" checked="checked" /> Download All</label>
|
6 |
<input type="hidden" name="<?php echo esc_attr( MWF_Config::NAME . '-csv-download' ); ?>" value="1" />
|
7 |
<?php wp_nonce_field( MWF_Config::NAME ); ?>
|
8 |
-
</form>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
?>
|
8 |
+
|
9 |
<form id="mw-wp-form_csv" method="post" action="<?php echo esc_url( $action ); ?>">
|
10 |
<input type="submit" value="<?php esc_attr_e( 'CSV Download', 'mw-wp-form' ); ?>" class="button-primary" />
|
11 |
|
13 |
<label><input type="checkbox" name="download-all" value="true" checked="checked" /> Download All</label>
|
14 |
<input type="hidden" name="<?php echo esc_attr( MWF_Config::NAME . '-csv-download' ); ?>" value="1" />
|
15 |
<?php wp_nonce_field( MWF_Config::NAME ); ?>
|
16 |
+
</form>
|
templates/contact-data/admin-print-styles.php
CHANGED
@@ -1,5 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<style type="text/css">
|
2 |
h2 a.add-new-h2 {
|
3 |
display: none;
|
4 |
}
|
5 |
-
</style>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
?>
|
8 |
+
|
9 |
<style type="text/css">
|
10 |
h2 a.add-new-h2 {
|
11 |
display: none;
|
12 |
}
|
13 |
+
</style>
|
templates/contact-data/detail.php
CHANGED
@@ -1,29 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<input type="hidden" name="<?php echo esc_attr( MWF_Config::NAME ); ?>_nonce" value="<?php echo wp_create_nonce( MWF_Config::NAME ); ?>" />
|
2 |
<table border="0" cellpadding="0" cellspacing="0">
|
3 |
<?php
|
4 |
$columns = array();
|
5 |
-
$values = $
|
6 |
$_columns = array();
|
7 |
foreach ( $values as $key => $value ) {
|
8 |
-
if (
|
9 |
$columns[ $key ] = MWF_Functions::get_tracking_number_title( $post_type );
|
10 |
continue;
|
11 |
}
|
12 |
-
if ( in_array( $key, $
|
13 |
continue;
|
14 |
}
|
15 |
$_columns[ $key ] = $key;
|
16 |
}
|
17 |
$_columns = apply_filters( 'mwform_inquiry_data_columns-' . $post_type, $_columns );
|
18 |
-
$columns
|
19 |
?>
|
20 |
|
21 |
<?php foreach ( $columns as $key => $label ) : ?>
|
22 |
-
|
23 |
<tr>
|
24 |
<th>
|
25 |
<?php
|
26 |
-
if (
|
27 |
echo MWF_Functions::get_tracking_number_title( $post_type );
|
28 |
} else {
|
29 |
echo esc_html( $label );
|
@@ -32,7 +40,7 @@
|
|
32 |
</th>
|
33 |
<td>
|
34 |
<?php
|
35 |
-
if ( $
|
36 |
// 過去バージョンでの不具合でメタデータが空になっていることがあるのでその場合は代替処理
|
37 |
if ( '' === $values[ $key ] ) {
|
38 |
$values[ $key ] = MWF_Functions::get_multimedia_id__fallback( $post, $key );
|
@@ -49,15 +57,15 @@
|
|
49 |
<tr>
|
50 |
<th><?php esc_html_e( 'Admin Email To', 'mw-wp-form' ); ?></th>
|
51 |
<td>
|
52 |
-
<?php echo esc_html( $
|
53 |
</td>
|
54 |
</tr>
|
55 |
<tr>
|
56 |
<th><?php esc_html_e( 'Response Status', 'mw-wp-form' ); ?></th>
|
57 |
<td>
|
58 |
<select name="<?php echo esc_attr( MWF_Config::INQUIRY_DATA_NAME ); ?>[response_status]">
|
59 |
-
<?php foreach ( $
|
60 |
-
<option value="<?php echo esc_attr( $key ); ?>" <?php selected( $key, $
|
61 |
<?php echo esc_html( $value ); ?>
|
62 |
</option>
|
63 |
<?php endforeach; ?>
|
@@ -66,6 +74,6 @@
|
|
66 |
</tr>
|
67 |
<tr>
|
68 |
<th><?php esc_html_e( 'Memo', 'mw-wp-form' ); ?></th>
|
69 |
-
<td><textarea name="<?php echo esc_attr( MWF_Config::INQUIRY_DATA_NAME ); ?>[memo]" cols="50" rows="5"><?php echo $
|
70 |
</tr>
|
71 |
</table>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
?>
|
8 |
+
|
9 |
<input type="hidden" name="<?php echo esc_attr( MWF_Config::NAME ); ?>_nonce" value="<?php echo wp_create_nonce( MWF_Config::NAME ); ?>" />
|
10 |
<table border="0" cellpadding="0" cellspacing="0">
|
11 |
<?php
|
12 |
$columns = array();
|
13 |
+
$values = $contact_data_setting->gets();
|
14 |
$_columns = array();
|
15 |
foreach ( $values as $key => $value ) {
|
16 |
+
if ( MWF_Config::TRACKINGNUMBER === $key ) {
|
17 |
$columns[ $key ] = MWF_Functions::get_tracking_number_title( $post_type );
|
18 |
continue;
|
19 |
}
|
20 |
+
if ( in_array( $key, $contact_data_setting->get_permit_keys(), true ) ) {
|
21 |
continue;
|
22 |
}
|
23 |
$_columns[ $key ] = $key;
|
24 |
}
|
25 |
$_columns = apply_filters( 'mwform_inquiry_data_columns-' . $post_type, $_columns );
|
26 |
+
$columns = array_merge( $columns, $_columns );
|
27 |
?>
|
28 |
|
29 |
<?php foreach ( $columns as $key => $label ) : ?>
|
30 |
+
<?php if ( isset( $values[ $key ] ) ) : ?>
|
31 |
<tr>
|
32 |
<th>
|
33 |
<?php
|
34 |
+
if ( MWF_Config::TRACKINGNUMBER === $key ) {
|
35 |
echo MWF_Functions::get_tracking_number_title( $post_type );
|
36 |
} else {
|
37 |
echo esc_html( $label );
|
40 |
</th>
|
41 |
<td>
|
42 |
<?php
|
43 |
+
if ( $contact_data_setting->is_upload_file_key( $key ) ) {
|
44 |
// 過去バージョンでの不具合でメタデータが空になっていることがあるのでその場合は代替処理
|
45 |
if ( '' === $values[ $key ] ) {
|
46 |
$values[ $key ] = MWF_Functions::get_multimedia_id__fallback( $post, $key );
|
57 |
<tr>
|
58 |
<th><?php esc_html_e( 'Admin Email To', 'mw-wp-form' ); ?></th>
|
59 |
<td>
|
60 |
+
<?php echo esc_html( $contact_data_setting->get( 'admin_mail_to' ) ); ?>
|
61 |
</td>
|
62 |
</tr>
|
63 |
<tr>
|
64 |
<th><?php esc_html_e( 'Response Status', 'mw-wp-form' ); ?></th>
|
65 |
<td>
|
66 |
<select name="<?php echo esc_attr( MWF_Config::INQUIRY_DATA_NAME ); ?>[response_status]">
|
67 |
+
<?php foreach ( $contact_data_setting->get_response_statuses() as $key => $value ) : ?>
|
68 |
+
<option value="<?php echo esc_attr( $key ); ?>" <?php selected( $key, $contact_data_setting->get( 'response_status' ) ); ?>>
|
69 |
<?php echo esc_html( $value ); ?>
|
70 |
</option>
|
71 |
<?php endforeach; ?>
|
74 |
</tr>
|
75 |
<tr>
|
76 |
<th><?php esc_html_e( 'Memo', 'mw-wp-form' ); ?></th>
|
77 |
+
<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>
|
78 |
</tr>
|
79 |
</table>
|
templates/contact-data/returning-link.php
CHANGED
@@ -1,3 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<p>
|
2 |
<a href="<?php echo $link; ?>"><?php esc_html_e( '« Back to the list', 'mw-wp-form' ); ?></a>
|
3 |
-
</p>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
?>
|
8 |
+
|
9 |
<p>
|
10 |
<a href="<?php echo $link; ?>"><?php esc_html_e( '« Back to the list', 'mw-wp-form' ); ?></a>
|
11 |
+
</p>
|
templates/form-fields/button.php
CHANGED
@@ -1,3 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<input type="button"
|
2 |
name="<?php echo esc_attr( $name ); ?>"
|
3 |
value="<?php echo esc_attr( $value ); ?>"
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
?>
|
8 |
+
|
9 |
<input type="button"
|
10 |
name="<?php echo esc_attr( $name ); ?>"
|
11 |
value="<?php echo esc_attr( $value ); ?>"
|
templates/form-fields/button_button.php
CHANGED
@@ -1,3 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<button type="button"
|
2 |
name="<?php echo esc_attr( $name ); ?>"
|
3 |
value="<?php echo esc_attr( $value ); ?>"
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
?>
|
8 |
+
|
9 |
<button type="button"
|
10 |
name="<?php echo esc_attr( $name ); ?>"
|
11 |
value="<?php echo esc_attr( $value ); ?>"
|
templates/form-fields/button_submit.php
CHANGED
@@ -1,3 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<button type="submit"
|
2 |
name="<?php echo esc_attr( $name ); ?>"
|
3 |
value="<?php echo esc_attr( $value ); ?>"
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
?>
|
8 |
+
|
9 |
<button type="submit"
|
10 |
name="<?php echo esc_attr( $name ); ?>"
|
11 |
value="<?php echo esc_attr( $value ); ?>"
|
templates/form-fields/checkbox.php
CHANGED
@@ -1,9 +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 ); ?>">
|
@@ -11,7 +23,7 @@ if ( 'true' === $vertically ) {
|
|
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 |
/>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
?>
|
8 |
+
|
9 |
<?php
|
10 |
if ( 'true' === $vertically ) {
|
11 |
$vertically_class = 'vertical-item';
|
12 |
} else {
|
13 |
$vertically_class = 'horizontal-item';
|
14 |
}
|
15 |
+
|
16 |
+
foreach ( $value as $_key => $_value ) {
|
17 |
+
$value[ $_key ] = (string) $_value;
|
18 |
+
}
|
19 |
?>
|
20 |
<?php foreach ( $fields as $field_value => $field ) : ?>
|
21 |
<span class="mwform-checkbox-field <?php echo esc_attr( $vertically_class ); ?>">
|
23 |
<input type="checkbox"
|
24 |
name="<?php echo esc_attr( $field['name'] ); ?>"
|
25 |
value="<?php echo esc_attr( $field_value ); ?>"
|
26 |
+
<?php checked( in_array( (string) $field_value, $value, true ), true, true ); ?>
|
27 |
<?php echo MWF_Functions::generate_input_attribute( 'id', $field['id'] ); ?>
|
28 |
<?php echo MWF_Functions::generate_input_attribute( 'class', $field['class'] ); ?>
|
29 |
/>
|
templates/form-fields/datepicker.php
CHANGED
@@ -1,3 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<input type="text"
|
2 |
name="<?php echo esc_attr( $name ); ?>"
|
3 |
<?php echo MWF_Functions::generate_input_attribute( 'id', $id ); ?>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
?>
|
8 |
+
|
9 |
<input type="text"
|
10 |
name="<?php echo esc_attr( $name ); ?>"
|
11 |
<?php echo MWF_Functions::generate_input_attribute( 'id', $id ); ?>
|
templates/form-fields/email.php
CHANGED
@@ -1,3 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<input type="email"
|
2 |
name="<?php echo esc_attr( $name ); ?>"
|
3 |
<?php echo MWF_Functions::generate_input_attribute( 'id', $id ); ?>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
?>
|
8 |
+
|
9 |
<input type="email"
|
10 |
name="<?php echo esc_attr( $name ); ?>"
|
11 |
<?php echo MWF_Functions::generate_input_attribute( 'id', $id ); ?>
|
templates/form-fields/file.php
CHANGED
@@ -1,3 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<input type="file"
|
2 |
name="<?php echo esc_attr( $name ); ?>"
|
3 |
<?php echo MWF_Functions::generate_input_attribute( 'id', $id ); ?>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
?>
|
8 |
+
|
9 |
<input type="file"
|
10 |
name="<?php echo esc_attr( $name ); ?>"
|
11 |
<?php echo MWF_Functions::generate_input_attribute( 'id', $id ); ?>
|
templates/form-fields/hidden.php
CHANGED
@@ -1 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<input type="hidden" name="<?php echo esc_attr( $name ); ?>" value="<?php echo esc_attr( $value ); ?>" />
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
?>
|
8 |
+
|
9 |
<input type="hidden" name="<?php echo esc_attr( $name ); ?>" value="<?php echo esc_attr( $value ); ?>" />
|
templates/form-fields/monthpicker.php
CHANGED
@@ -1,3 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<input type="text"
|
2 |
name="<?php echo esc_attr( $name ); ?>"
|
3 |
<?php echo MWF_Functions::generate_input_attribute( 'id', $id ); ?>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
?>
|
8 |
+
|
9 |
<input type="text"
|
10 |
name="<?php echo esc_attr( $name ); ?>"
|
11 |
<?php echo MWF_Functions::generate_input_attribute( 'id', $id ); ?>
|
templates/form-fields/number.php
CHANGED
@@ -1,3 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<input type="number"
|
2 |
name="<?php echo esc_attr( $name ); ?>"
|
3 |
<?php echo MWF_Functions::generate_input_attribute( 'id', $id ); ?>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
?>
|
8 |
+
|
9 |
<input type="number"
|
10 |
name="<?php echo esc_attr( $name ); ?>"
|
11 |
<?php echo MWF_Functions::generate_input_attribute( 'id', $id ); ?>
|
templates/form-fields/password.php
CHANGED
@@ -1,3 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<input type="password"
|
2 |
name="<?php echo esc_attr( $name ); ?>"
|
3 |
<?php echo MWF_Functions::generate_input_attribute( 'id', $id ); ?>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
?>
|
8 |
+
|
9 |
<input type="password"
|
10 |
name="<?php echo esc_attr( $name ); ?>"
|
11 |
<?php echo MWF_Functions::generate_input_attribute( 'id', $id ); ?>
|
templates/form-fields/radio.php
CHANGED
@@ -1,4 +1,10 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
if ( 'true' === $vertically ) {
|
3 |
$vertically_class = 'vertical-item';
|
4 |
} else {
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
|
8 |
if ( 'true' === $vertically ) {
|
9 |
$vertically_class = 'vertical-item';
|
10 |
} else {
|
templates/form-fields/range.php
CHANGED
@@ -1,3 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<input type="range"
|
2 |
name="<?php echo esc_attr( $name ); ?>"
|
3 |
<?php echo MWF_Functions::generate_input_attribute( 'id', $id ); ?>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
?>
|
8 |
+
|
9 |
<input type="range"
|
10 |
name="<?php echo esc_attr( $name ); ?>"
|
11 |
<?php echo MWF_Functions::generate_input_attribute( 'id', $id ); ?>
|
templates/form-fields/select.php
CHANGED
@@ -1,3 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 ); ?>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
?>
|
8 |
+
|
9 |
<select name="<?php echo esc_attr( $name ); ?>"
|
10 |
<?php echo MWF_Functions::generate_input_attribute( 'id', $id ); ?>
|
11 |
<?php echo MWF_Functions::generate_input_attribute( 'class', $class ); ?>
|
templates/form-fields/submit.php
CHANGED
@@ -1,3 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<input type="submit"
|
2 |
name="<?php echo esc_attr( $name ); ?>"
|
3 |
value="<?php echo esc_attr( $value ); ?>"
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
?>
|
8 |
+
|
9 |
<input type="submit"
|
10 |
name="<?php echo esc_attr( $name ); ?>"
|
11 |
value="<?php echo esc_attr( $value ); ?>"
|
templates/form-fields/tel.php
CHANGED
@@ -1,3 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<span class="mwform-tel-field">
|
2 |
<input type="text"
|
3 |
name="<?php echo esc_attr( $fields[0]['name'] ); ?>"
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
?>
|
8 |
+
|
9 |
<span class="mwform-tel-field">
|
10 |
<input type="text"
|
11 |
name="<?php echo esc_attr( $fields[0]['name'] ); ?>"
|
templates/form-fields/text.php
CHANGED
@@ -1,3 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<input type="text"
|
2 |
name="<?php echo esc_attr( $name ); ?>"
|
3 |
<?php echo MWF_Functions::generate_input_attribute( 'id', $id ); ?>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
?>
|
8 |
+
|
9 |
<input type="text"
|
10 |
name="<?php echo esc_attr( $name ); ?>"
|
11 |
<?php echo MWF_Functions::generate_input_attribute( 'id', $id ); ?>
|
templates/form-fields/textarea.php
CHANGED
@@ -1,3 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<textarea
|
2 |
name="<?php echo esc_attr( $name ); ?>"
|
3 |
<?php echo MWF_Functions::generate_input_attribute( 'id', $id ); ?>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
?>
|
8 |
+
|
9 |
<textarea
|
10 |
name="<?php echo esc_attr( $name ); ?>"
|
11 |
<?php echo MWF_Functions::generate_input_attribute( 'id', $id ); ?>
|
templates/form-fields/url.php
CHANGED
@@ -1,3 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<input type="url"
|
2 |
name="<?php echo esc_attr( $name ); ?>"
|
3 |
<?php echo MWF_Functions::generate_input_attribute( 'id', $id ); ?>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
?>
|
8 |
+
|
9 |
<input type="url"
|
10 |
name="<?php echo esc_attr( $name ); ?>"
|
11 |
<?php echo MWF_Functions::generate_input_attribute( 'id', $id ); ?>
|
templates/form-fields/zip.php
CHANGED
@@ -1,3 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<span class="mwform-zip-field">
|
2 |
〒
|
3 |
<input type="text"
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
?>
|
8 |
+
|
9 |
<span class="mwform-zip-field">
|
10 |
〒
|
11 |
<input type="text"
|
templates/stores-inquiry-data-form-list/index.php
CHANGED
@@ -1,3 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<div class="wrap">
|
2 |
<h2><?php esc_html_e( 'Inquiry data', 'mw-wp-form' ); ?></h2>
|
3 |
<p>
|
@@ -12,11 +20,20 @@
|
|
12 |
<th class="<?php echo MWF_Config::NAME; ?>-table-date"><?php esc_html_e( 'Created date', 'mw-wp-form' ); ?></th>
|
13 |
</thead>
|
14 |
<tbody>
|
15 |
-
<?php
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
<td class="<?php echo MWF_Config::NAME; ?>-table-chart"><a href="<?php echo admin_url( 'edit.php?post_type=' . MWF_Config::NAME . '&page=' . MWF_Config::NAME . '-chart&formkey=' . $post_type ); ?>"><?php esc_html_e( 'Display Chart', 'mw-wp-form' ); ?></td>
|
19 |
-
<td class="<?php echo MWF_Config::NAME; ?>-table-count"><a href="<?php echo admin_url( 'edit.php?post_type=' . $post_type ); ?>"><?php echo esc_html( $values['count'] ) ?> <?php esc_html_e( 'cases', 'mw-wp-form' ); ?></a></td>
|
20 |
<td class="<?php echo MWF_Config::NAME; ?>-table-date"><?php echo esc_html( $values['modified_datetime'] ); ?></td>
|
21 |
<td class="<?php echo MWF_Config::NAME; ?>-table-date"><?php echo esc_html( $values['created_datetime'] ); ?></td>
|
22 |
</tr>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package mw-wp-form
|
4 |
+
* @author inc2734
|
5 |
+
* @license GPL-2.0+
|
6 |
+
*/
|
7 |
+
?>
|
8 |
+
|
9 |
<div class="wrap">
|
10 |
<h2><?php esc_html_e( 'Inquiry data', 'mw-wp-form' ); ?></h2>
|
11 |
<p>
|
20 |
<th class="<?php echo MWF_Config::NAME; ?>-table-date"><?php esc_html_e( 'Created date', 'mw-wp-form' ); ?></th>
|
21 |
</thead>
|
22 |
<tbody>
|
23 |
+
<?php
|
24 |
+
$i = 0;
|
25 |
+
foreach ( $form_list as $post_type => $values ) :
|
26 |
+
$i ++;
|
27 |
+
?>
|
28 |
+
<tr
|
29 |
+
<?php
|
30 |
+
if ( 1 === $i % 2 ) {
|
31 |
+
echo 'class="alternate"';}
|
32 |
+
?>
|
33 |
+
>
|
34 |
+
<td class="<?php echo MWF_Config::NAME; ?>-table-title"><?php echo esc_html( $values['title'] ); ?></td>
|
35 |
<td class="<?php echo MWF_Config::NAME; ?>-table-chart"><a href="<?php echo admin_url( 'edit.php?post_type=' . MWF_Config::NAME . '&page=' . MWF_Config::NAME . '-chart&formkey=' . $post_type ); ?>"><?php esc_html_e( 'Display Chart', 'mw-wp-form' ); ?></td>
|
36 |
+
<td class="<?php echo MWF_Config::NAME; ?>-table-count"><a href="<?php echo admin_url( 'edit.php?post_type=' . $post_type ); ?>"><?php echo esc_html( $values['count'] ); ?> <?php esc_html_e( 'cases', 'mw-wp-form' ); ?></a></td>
|
37 |
<td class="<?php echo MWF_Config::NAME; ?>-table-date"><?php echo esc_html( $values['modified_datetime'] ); ?></td>
|
38 |
<td class="<?php echo MWF_Config::NAME; ?>-table-date"><?php echo esc_html( $values['created_datetime'] ); ?></td>
|
39 |
</tr>
|