MW WP Form - Version 1.8.2

Version Description

  • Bug fix : Fix bug that PHP error is displayed in file type validation.
  • Bug fix : Fix bug that PHP error is displayed in admin page.
  • Changed : Change to upload file even if there is a validation error in other fields.
  • Changed : Change to display by scrolling when width of list of stored data is wide.
Download this release

Release Info

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

Code changes from version 1.8.1 to 1.8.2

css/admin.css CHANGED
@@ -304,3 +304,17 @@ span#formkey_field {
304
  width: 20%;
305
  }
306
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
304
  width: 20%;
305
  }
306
 
307
+ /**
308
+ * .wp-list-table
309
+ */
310
+ .mw-wp-form-wp-list-table {
311
+ overflow: auto;
312
+ }
313
+ .mw-wp-form-wp-list-table .wp-list-table {
314
+ table-layout: auto;
315
+ width: 100%;
316
+ }
317
+ .mw-wp-form-wp-list-table .wp-list-table th {
318
+ white-space: nowrap;
319
+ }
320
+
js/admin-data.js ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ /**
2
+ * list-table
3
+ */
4
+ jQuery( function( $ ) {
5
+ var wp_list_table = $( '.wp-list-table' );
6
+ wp_list_table.wrap( '<div class="mw-wp-form-wp-list-table" />' );
7
+ } );
mw-wp-form.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: MW WP Form
4
  * Plugin URI: http://plugins.2inc.org/mw-wp-form/
5
  * Description: MW WP Form can create mail form with a confirmation screen.
6
- * Version: 1.8.1
7
  * Author: Takashi Kitajima
8
  * Author URI: http://2inc.org
9
  * Created : September 25, 2012
@@ -251,7 +251,7 @@ class mw_wp_form {
251
 
252
  /**
253
  * original_script
254
- * CSS適用
255
  */
256
  public function original_script() {
257
  $url = plugin_dir_url( __FILE__ );
@@ -326,13 +326,15 @@ class mw_wp_form {
326
  // $_FILESがあるときは$this->dataに統合
327
  $files = array();
328
  foreach ( $_FILES as $key => $file ) {
329
- if ( !isset( $_POST[$key] ) ) {
330
  if ( $file['error'] == UPLOAD_ERR_OK && is_uploaded_file( $file['tmp_name'] ) ) {
331
  $this->Data->setValue( $key, $file['name'] );
332
  } else {
333
  $this->Data->setValue( $key, '' );
334
  }
335
- $files[$key] = $file;
 
 
336
  }
337
  }
338
  // この条件判定がないと fileSize チェックが正しく動作しない
@@ -362,9 +364,9 @@ class mw_wp_form {
362
  }
363
  // 確認画面のとき
364
  elseif ( $this->Form->isConfirm() ) {
 
365
  if ( $this->Validation->check() ) {
366
  $this->viewFlg = 'confirm';
367
- $this->fileUpload();
368
  $this->redirect( $this->confirm );
369
  } else {
370
  if ( !empty( $this->validation_error ) ) {
@@ -376,9 +378,9 @@ class mw_wp_form {
376
  }
377
  // 完了画面のとき
378
  elseif ( $this->Form->isComplete() ) {
 
379
  if ( $this->Validation->check() ) {
380
  $this->viewFlg = 'complete';
381
- $this->fileUpload();
382
 
383
  if ( $this->Data->getValue( $this->Form->getTokenName() ) ) {
384
  $this->apply_filters_mwform_mail();
@@ -943,35 +945,35 @@ class mw_wp_form {
943
  * ファイルアップロード処理。実際のアップロード状況に合わせてフォームデータも再生成する。
944
  */
945
  protected function fileupload() {
946
- $uploadedFiles = $this->File->fileupload();
947
  $files = $this->Data->getValue( MWF_Config::UPLOAD_FILES );
948
  if ( !is_array( $files ) ) {
949
  $files = array();
950
  }
951
- $excludedFiles = array_diff_key( $files, $uploadedFiles );
 
 
 
 
 
 
 
 
 
952
  $upload_file_keys = $this->Data->getValue( MWF_Config::UPLOAD_FILE_KEYS );
953
  if ( !$upload_file_keys )
954
  $upload_file_keys = array();
955
 
956
- // 確認 => 入力 => 確認のときに空の $_FILES が送られアップ済みのも $excludesFiles に入ってしまうので消す
957
  $wp_upload_dir = wp_upload_dir();
958
  foreach ( $upload_file_keys as $upload_file_key ) {
959
  $upload_file_url = $this->Data->getValue( $upload_file_key );
960
  if ( $upload_file_url ) {
961
  $filepath = MWF_Functions::fileurl_to_path( $upload_file_url );
962
- if ( file_exists( $filepath ) ) {
963
- unset( $excludedFiles[$upload_file_key] );
964
  }
965
  }
966
  }
967
-
968
- // アップロードに失敗したファイルのキーは削除
969
- foreach ( $excludedFiles as $key => $excludedFile ) {
970
- $this->Data->clearValue( $key );
971
- $delete_key = array_search( $key, $upload_file_keys );
972
- if ( $delete_key !== false )
973
- unset( $upload_file_keys[$delete_key] );
974
- }
975
  $this->Data->setValue( MWF_Config::UPLOAD_FILE_KEYS, $upload_file_keys );
976
 
977
  // アップロードに成功したファイルをフォームデータに格納
3
  * Plugin Name: MW WP Form
4
  * Plugin URI: http://plugins.2inc.org/mw-wp-form/
5
  * Description: MW WP Form can create mail form with a confirmation screen.
6
+ * Version: 1.8.2
7
  * Author: Takashi Kitajima
8
  * Author URI: http://2inc.org
9
  * Created : September 25, 2012
251
 
252
  /**
253
  * original_script
254
+ * JS適用
255
  */
256
  public function original_script() {
257
  $url = plugin_dir_url( __FILE__ );
326
  // $_FILESがあるときは$this->dataに統合
327
  $files = array();
328
  foreach ( $_FILES as $key => $file ) {
329
+ if ( !isset( $_POST[$key] ) || !empty( $file['name'] ) ) {
330
  if ( $file['error'] == UPLOAD_ERR_OK && is_uploaded_file( $file['tmp_name'] ) ) {
331
  $this->Data->setValue( $key, $file['name'] );
332
  } else {
333
  $this->Data->setValue( $key, '' );
334
  }
335
+ if ( !empty( $file['name'] ) ) {
336
+ $files[$key] = $file;
337
+ }
338
  }
339
  }
340
  // この条件判定がないと fileSize チェックが正しく動作しない
364
  }
365
  // 確認画面のとき
366
  elseif ( $this->Form->isConfirm() ) {
367
+ $this->fileUpload();
368
  if ( $this->Validation->check() ) {
369
  $this->viewFlg = 'confirm';
 
370
  $this->redirect( $this->confirm );
371
  } else {
372
  if ( !empty( $this->validation_error ) ) {
378
  }
379
  // 完了画面のとき
380
  elseif ( $this->Form->isComplete() ) {
381
+ $this->fileUpload();
382
  if ( $this->Validation->check() ) {
383
  $this->viewFlg = 'complete';
 
384
 
385
  if ( $this->Data->getValue( $this->Form->getTokenName() ) ) {
386
  $this->apply_filters_mwform_mail();
945
  * ファイルアップロード処理。実際のアップロード状況に合わせてフォームデータも再生成する。
946
  */
947
  protected function fileupload() {
948
+ $uploadedFiles = array();
949
  $files = $this->Data->getValue( MWF_Config::UPLOAD_FILES );
950
  if ( !is_array( $files ) ) {
951
  $files = array();
952
  }
953
+ foreach ( $files as $key => $file ) {
954
+ if ( $this->Validation->singleCheck( $key ) ) {
955
+ $uploadedFile = $this->File->singleFileupload( $key );
956
+ if ( $uploadedFile ) {
957
+ $uploadedFiles[$key] = $uploadedFile;
958
+ }
959
+ }
960
+ }
961
+
962
+ // 時間切れなどで削除されたファイルのキーを削除
963
  $upload_file_keys = $this->Data->getValue( MWF_Config::UPLOAD_FILE_KEYS );
964
  if ( !$upload_file_keys )
965
  $upload_file_keys = array();
966
 
 
967
  $wp_upload_dir = wp_upload_dir();
968
  foreach ( $upload_file_keys as $upload_file_key ) {
969
  $upload_file_url = $this->Data->getValue( $upload_file_key );
970
  if ( $upload_file_url ) {
971
  $filepath = MWF_Functions::fileurl_to_path( $upload_file_url );
972
+ if ( !file_exists( $filepath ) ) {
973
+ unset( $upload_file_keys[$upload_file_key] );
974
  }
975
  }
976
  }
 
 
 
 
 
 
 
 
977
  $this->Data->setValue( MWF_Config::UPLOAD_FILE_KEYS, $upload_file_keys );
978
 
979
  // アップロードに成功したファイルをフォームデータに格納
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.amazon.co.jp/registry/wishlist/39ANKRNSTNW40
4
  Tags: plugin, form, confirm, preview, shortcode, mail
5
  Requires at least: 3.7
6
  Tested up to: 3.9.1
7
- Stable tag: 1.8.1
8
  License: GPLv2
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -54,6 +54,12 @@ Do you have questions or issues with MW WP Form? Use these support channels appr
54
 
55
  == Changelog ==
56
 
 
 
 
 
 
 
57
  = 1.8.1 =
58
  * Bug fix : Fix PHP error under PHP 5.3.0
59
  * Bug fix : Fix bug that are not validated of noEmpty in zip and tel field.
4
  Tags: plugin, form, confirm, preview, shortcode, mail
5
  Requires at least: 3.7
6
  Tested up to: 3.9.1
7
+ Stable tag: 1.8.2
8
  License: GPLv2
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
54
 
55
  == Changelog ==
56
 
57
+ = 1.8.2 =
58
+ * Bug fix : Fix bug that PHP error is displayed in file type validation.
59
+ * Bug fix : Fix bug that PHP error is displayed in admin page.
60
+ * Changed : Change to upload file even if there is a validation error in other fields.
61
+ * Changed : Change to display by scrolling when width of list of stored data is wide.
62
+
63
  = 1.8.1 =
64
  * Bug fix : Fix PHP error under PHP 5.3.0
65
  * Bug fix : Fix bug that are not validated of noEmpty in zip and tel field.
system/mw_validation.php CHANGED
@@ -94,29 +94,59 @@ class MW_Validation {
94
  /**
95
  * check
96
  * validate実行
97
- * @return bool
98
  */
99
  public function check() {
100
  $Data = MW_WP_Form_Data::getInstance( $this->key );
101
  foreach ( $this->validate as $key => $rules ) {
102
- foreach ( $rules as $ruleSet ) {
103
- if ( isset( $ruleSet['rule'] ) ) {
104
- $rule = $ruleSet['rule'];
105
- $options = array();
106
- if ( isset( $ruleSet['options'] ) ) {
107
- $options = $ruleSet['options'];
108
- }
109
- if ( isset( $this->validation_rules[$rule] )
110
- && is_callable( array( $this->validation_rules[$rule], 'rule' ) ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
111
 
112
- $message = $this->validation_rules[$rule]->rule( $key, $options );
113
- if ( !empty( $message ) ) {
114
- $this->Error->setError( $key, $rule, $message );
115
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  }
117
  }
118
  }
119
  }
120
- return $this->isValid();
121
  }
122
  }
94
  /**
95
  * check
96
  * validate実行
97
+ * @return bool エラーがなければ true
98
  */
99
  public function check() {
100
  $Data = MW_WP_Form_Data::getInstance( $this->key );
101
  foreach ( $this->validate as $key => $rules ) {
102
+ $this->_check( $key, $rules );
103
+ }
104
+ return $this->isValid();
105
+ }
106
+
107
+ /**
108
+ * singleCheck
109
+ * 特定の項目のvalidate実行
110
+ * @param string $key
111
+ * @return bool エラーがなければ true
112
+ */
113
+ public function singleCheck( $key ) {
114
+ $Data = MW_WP_Form_Data::getInstance( $this->key );
115
+ $rules = array();
116
+ if ( is_array( $this->validate ) && isset( $this->validate[$key] ) ) {
117
+ $rules = $this->validate[$key];
118
+ if ( $this->_check( $key, $rules ) ) {
119
+ return false;
120
+ }
121
+ return true;
122
+ }
123
+ }
124
 
125
+ /**
126
+ * _check
127
+ * validate実行の実態
128
+ * @param string $key
129
+ * @param array $rules
130
+ * @return bool エラーがあれば true
131
+ */
132
+ protected function _check( $key, array $rules ) {
133
+ foreach ( $rules as $ruleSet ) {
134
+ if ( isset( $ruleSet['rule'] ) ) {
135
+ $rule = $ruleSet['rule'];
136
+ $options = array();
137
+ if ( isset( $ruleSet['options'] ) ) {
138
+ $options = $ruleSet['options'];
139
+ }
140
+ if ( isset( $this->validation_rules[$rule] )
141
+ && is_callable( array( $this->validation_rules[$rule], 'rule' ) ) ) {
142
+
143
+ $message = $this->validation_rules[$rule]->rule( $key, $options );
144
+ if ( !empty( $message ) ) {
145
+ $this->Error->setError( $key, $rule, $message );
146
+ return true;
147
  }
148
  }
149
  }
150
  }
 
151
  }
152
  }
system/mw_wp_form_contact_data_page.php CHANGED
@@ -39,6 +39,7 @@ class MW_WP_Form_Contact_Data_Page {
39
  $this->POST_DATA_NAME = '_' . MWF_Config::NAME . '_data';
40
  add_action( 'init', array( $this, 'register_post_type' ) );
41
  add_action( 'admin_enqueue_scripts', array( $this, 'admin_style' ) );
 
42
  add_action( 'admin_head', array( $this, 'add_style' ) );
43
  add_action( 'admin_head', array( $this, 'add_forms_columns' ) );
44
  add_action( 'admin_head', array( $this, 'add_meta_box' ) );
@@ -80,6 +81,19 @@ class MW_WP_Form_Contact_Data_Page {
80
  }
81
  }
82
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  /**
84
  * register_post_type
85
  * メインクラスから呼ばれる
39
  $this->POST_DATA_NAME = '_' . MWF_Config::NAME . '_data';
40
  add_action( 'init', array( $this, 'register_post_type' ) );
41
  add_action( 'admin_enqueue_scripts', array( $this, 'admin_style' ) );
42
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_script' ) );
43
  add_action( 'admin_head', array( $this, 'add_style' ) );
44
  add_action( 'admin_head', array( $this, 'add_forms_columns' ) );
45
  add_action( 'admin_head', array( $this, 'add_meta_box' ) );
81
  }
82
  }
83
 
84
+ /**
85
+ * admin_script
86
+ * JS適用
87
+ */
88
+ public function admin_script() {
89
+ $post_type = get_post_type();
90
+ if ( in_array( $post_type, $this->form_post_type ) ) {
91
+ $url = plugin_dir_url( __FILE__ );
92
+ wp_register_script( MWF_Config::DOMAIN . '-admin-data', $url . '../js/admin-data.js' );
93
+ wp_enqueue_script( MWF_Config::DOMAIN . '-admin-data' );
94
+ }
95
+ }
96
+
97
  /**
98
  * register_post_type
99
  * メインクラスから呼ばれる
system/mw_wp_form_file.php CHANGED
@@ -97,7 +97,7 @@ class MW_WP_Form_File {
97
 
98
  /**
99
  * fileUpload
100
- * ファイルアップロード処理。$this->data[$key] にファイルの URL を入れる
101
  * @return array ( name属性値 => アップロードできたファイルのURL, … )
102
  */
103
  public function fileUpload() {
@@ -106,22 +106,53 @@ class MW_WP_Form_File {
106
 
107
  $uploadedFiles = array();
108
  foreach ( $_FILES as $key => $file ) {
109
- if ( empty( $file['tmp_name'] ) )
110
- continue;
 
 
 
 
111
 
112
- if ( $this->checkFileType( $file['tmp_name'], $file['name'] )
113
- && $file['error'] == UPLOAD_ERR_OK
114
- && is_uploaded_file( $file['tmp_name'] ) ) {
 
 
 
 
 
 
115
 
116
- $extension = pathinfo( $file['name'], PATHINFO_EXTENSION );
117
- $uploadfile = $this->setUploadFileName( $extension );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
 
119
- $is_uploaded = move_uploaded_file( $file['tmp_name'], $uploadfile['file'] );
120
- if ( $is_uploaded )
121
- $uploadedFiles[$key] = $uploadfile['url'];
 
 
 
122
  }
123
  }
124
- return $uploadedFiles;
125
  }
126
 
127
  /**
97
 
98
  /**
99
  * fileUpload
100
+ * ファイルアップロード処理。
101
  * @return array ( name属性値 => アップロードできたファイルのURL, … )
102
  */
103
  public function fileUpload() {
106
 
107
  $uploadedFiles = array();
108
  foreach ( $_FILES as $key => $file ) {
109
+ $upload_file_url = $this->_fileUpload( $file );
110
+ if ( $upload_file_url )
111
+ $uploadedFiles[$key] = $upload_file_url;
112
+ }
113
+ return $uploadedFiles;
114
+ }
115
 
116
+ /**
117
+ * singleFileUpload
118
+ * ファイルアップロード処理。
119
+ * @param string $key アップロードしたいファイルの name 属性
120
+ * @return string アップロードできたファイルのURL
121
+ */
122
+ public function singleFileUpload( $key ) {
123
+ $this->createTempDir();
124
+ $this->cleanTempDir();
125
 
126
+ $file = '';
127
+ if ( is_array( $_FILES ) && isset( $_FILES[$key] ) ) {
128
+ $file = $_FILES[$key];
129
+ return $this->_fileUpload( $file );
130
+ }
131
+ }
132
+
133
+ /**
134
+ * _fileUpload
135
+ * ファイルアップロードの実処理。
136
+ * @param arary $file $_FILES['hoge'] の配列
137
+ * @return アップロードしたファイルの URL
138
+ */
139
+ protected function _fileUpload( $file ) {
140
+ if ( empty( $file['tmp_name'] ) )
141
+ return;
142
+
143
+ $is_uploaded = false;
144
+ if ( $this->checkFileType( $file['tmp_name'], $file['name'] )
145
+ && $file['error'] == UPLOAD_ERR_OK
146
+ && is_uploaded_file( $file['tmp_name'] ) ) {
147
 
148
+ $extension = pathinfo( $file['name'], PATHINFO_EXTENSION );
149
+ $uploadfile = $this->setUploadFileName( $extension );
150
+
151
+ $is_uploaded = move_uploaded_file( $file['tmp_name'], $uploadfile['file'] );
152
+ if ( $is_uploaded ) {
153
+ return $uploadfile['url'];
154
  }
155
  }
 
156
  }
157
 
158
  /**
validation_rules/mw_validation_rule_between.php CHANGED
@@ -2,11 +2,11 @@
2
  /**
3
  * Name: MW Validation Rule Between
4
  * Description: 値の文字数が範囲内
5
- * Version: 1.0.1
6
  * Author: Takashi Kitajima
7
  * Author URI: http://2inc.org
8
  * Created : July 21, 2014
9
- * Modified: August 8, 2014
10
  * License: GPLv2
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
@@ -57,14 +57,24 @@ class MW_Validation_Rule_Between extends MW_Validation_Rule {
57
  * @param array $value バリデーションルールセットの内容
58
  */
59
  public function admin( $key, $value ) {
 
 
 
 
 
 
 
 
 
 
60
  ?>
61
  <table>
62
  <tr>
63
  <td><?php esc_html_e( 'The range of the number of characters', MWF_Config::DOMAIN ); ?></td>
64
  <td>
65
- <input type="text" value="<?php echo esc_attr( @$value[$this->getName()]['min'] ); ?>" size="3" name="<?php echo MWF_Config::NAME; ?>[validation][<?php echo $key; ?>][<?php echo esc_attr( $this->getName() ); ?>][min]" />
66
 
67
- <input type="text" value="<?php echo esc_attr( @$value[$this->getName()]['max'] ); ?>" size="3" name="<?php echo MWF_Config::NAME; ?>[validation][<?php echo $key; ?>][<?php echo esc_attr( $this->getName() ); ?>][max]" />
68
  </td>
69
  </tr>
70
  </table>
2
  /**
3
  * Name: MW Validation Rule Between
4
  * Description: 値の文字数が範囲内
5
+ * Version: 1.0.2
6
  * Author: Takashi Kitajima
7
  * Author URI: http://2inc.org
8
  * Created : July 21, 2014
9
+ * Modified: August 18, 2014
10
  * License: GPLv2
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
57
  * @param array $value バリデーションルールセットの内容
58
  */
59
  public function admin( $key, $value ) {
60
+ $min = '';
61
+ $max = '';
62
+ if ( is_array( $value[$this->getName()] ) ) {
63
+ if ( isset( $value[$this->getName()]['min'] ) ) {
64
+ $min = $value[$this->getName()]['min'];
65
+ }
66
+ if ( isset( $value[$this->getName()]['max'] ) ) {
67
+ $max = $value[$this->getName()]['max'];
68
+ }
69
+ }
70
  ?>
71
  <table>
72
  <tr>
73
  <td><?php esc_html_e( 'The range of the number of characters', MWF_Config::DOMAIN ); ?></td>
74
  <td>
75
+ <input type="text" value="<?php echo esc_attr( $min ); ?>" size="3" name="<?php echo MWF_Config::NAME; ?>[validation][<?php echo $key; ?>][<?php echo esc_attr( $this->getName() ); ?>][min]" />
76
 
77
+ <input type="text" value="<?php echo esc_attr( $max ); ?>" size="3" name="<?php echo MWF_Config::NAME; ?>[validation][<?php echo $key; ?>][<?php echo esc_attr( $this->getName() ); ?>][max]" />
78
  </td>
79
  </tr>
80
  </table>
validation_rules/mw_validation_rule_eq.php CHANGED
@@ -2,11 +2,11 @@
2
  /**
3
  * Name: MW Validation Rule Eq
4
  * Description: 値が一致している
5
- * Version: 1.0.1
6
  * Author: Takashi Kitajima
7
  * Author URI: http://2inc.org
8
  * Created : July 21, 2014
9
- * Modified: August 8, 2014
10
  * License: GPLv2
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
@@ -44,11 +44,15 @@ class MW_Validation_Rule_Eq extends MW_Validation_Rule {
44
  * @param array $value バリデーションルールセットの内容
45
  */
46
  public function admin( $key, $value ) {
 
 
 
 
47
  ?>
48
  <table>
49
  <tr>
50
  <td><?php esc_html_e( 'The key at same value', MWF_Config::DOMAIN ); ?></td>
51
- <td><input type="text" value="<?php echo esc_attr( @$value[$this->getName()]['target'] ); ?>" name="<?php echo MWF_Config::NAME; ?>[validation][<?php echo $key; ?>][<?php echo esc_attr( $this->getName() ); ?>][target]" /></td>
52
  </tr>
53
  </table>
54
  <?php
2
  /**
3
  * Name: MW Validation Rule Eq
4
  * Description: 値が一致している
5
+ * Version: 1.0.2
6
  * Author: Takashi Kitajima
7
  * Author URI: http://2inc.org
8
  * Created : July 21, 2014
9
+ * Modified: August 18, 2014
10
  * License: GPLv2
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
44
  * @param array $value バリデーションルールセットの内容
45
  */
46
  public function admin( $key, $value ) {
47
+ $target = '';
48
+ if ( is_array( $value[$this->getName()] ) && isset( $value[$this->getName()]['target'] ) ) {
49
+ $target = $value[$this->getName()]['target'];
50
+ }
51
  ?>
52
  <table>
53
  <tr>
54
  <td><?php esc_html_e( 'The key at same value', MWF_Config::DOMAIN ); ?></td>
55
+ <td><input type="text" value="<?php echo esc_attr( $target ); ?>" name="<?php echo MWF_Config::NAME; ?>[validation][<?php echo $key; ?>][<?php echo esc_attr( $this->getName() ); ?>][target]" /></td>
56
  </tr>
57
  </table>
58
  <?php
validation_rules/mw_validation_rule_filesize.php CHANGED
@@ -2,11 +2,11 @@
2
  /**
3
  * Name: MW Validation Rule FileType
4
  * Description: ファイル名が指定した拡張子を含む。types は , 区切り
5
- * Version: 1.0.1
6
  * Author: Takashi Kitajima
7
  * Author URI: http://2inc.org
8
  * Created : July 21, 2014
9
- * Modified: August 8, 2014
10
  * License: GPLv2
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
@@ -46,11 +46,15 @@ class MW_Validation_Rule_FileSize extends MW_Validation_Rule {
46
  * @param array $value バリデーションルールセットの内容
47
  */
48
  public function admin( $key, $value ) {
 
 
 
 
49
  ?>
50
  <table>
51
  <tr>
52
  <td><?php esc_html_e( 'Permitted file size', MWF_Config::DOMAIN ); ?></td>
53
- <td><input type="text" value="<?php echo esc_attr( @$value[$this->getName()]['bytes'] ); ?>" name="<?php echo MWF_Config::NAME; ?>[validation][<?php echo $key; ?>][<?php echo esc_attr( $this->getName() ); ?>][bytes]" /> <span class="mwf_note"><?php esc_html_e( 'bytes', MWF_Config::DOMAIN ); ?></span></td>
54
  </tr>
55
  </table>
56
  <?php
2
  /**
3
  * Name: MW Validation Rule FileType
4
  * Description: ファイル名が指定した拡張子を含む。types は , 区切り
5
+ * Version: 1.0.2
6
  * Author: Takashi Kitajima
7
  * Author URI: http://2inc.org
8
  * Created : July 21, 2014
9
+ * Modified: August 18, 2014
10
  * License: GPLv2
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
46
  * @param array $value バリデーションルールセットの内容
47
  */
48
  public function admin( $key, $value ) {
49
+ $bytes = '';
50
+ if ( is_array( $value[$this->getName()] ) && isset( $value[$this->getName()]['bytes'] ) ) {
51
+ $bytes = $value[$this->getName()]['bytes'];
52
+ }
53
  ?>
54
  <table>
55
  <tr>
56
  <td><?php esc_html_e( 'Permitted file size', MWF_Config::DOMAIN ); ?></td>
57
+ <td><input type="text" value="<?php echo esc_attr( $bytes ); ?>" name="<?php echo MWF_Config::NAME; ?>[validation][<?php echo $key; ?>][<?php echo esc_attr( $this->getName() ); ?>][bytes]" /> <span class="mwf_note"><?php esc_html_e( 'bytes', MWF_Config::DOMAIN ); ?></span></td>
58
  </tr>
59
  </table>
60
  <?php
validation_rules/mw_validation_rule_filetype.php CHANGED
@@ -2,11 +2,11 @@
2
  /**
3
  * Name: MW Validation Rule FileType
4
  * Description: ファイル名が指定した拡張子を含む。types は , 区切り
5
- * Version: 1.0.1
6
  * Author: Takashi Kitajima
7
  * Author URI: http://2inc.org
8
  * Created : July 21, 2014
9
- * Modified: August 8, 2014
10
  * License: GPLv2
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
@@ -33,7 +33,7 @@ class MW_Validation_Rule_FileType extends MW_Validation_Rule {
33
  $options = array_merge( $defaults, $options );
34
  $_types = explode( ',', $options['types'] );
35
  foreach ( $_types as $type ) {
36
- $types[] = preg_quote( trim( $type ) );
37
  }
38
  $types = implode( '|', MWF_Functions::array_clean( $types ) );
39
  $pattern = '/\.(' . $types . ')$/';
@@ -49,11 +49,15 @@ class MW_Validation_Rule_FileType extends MW_Validation_Rule {
49
  * @param array $value バリデーションルールセットの内容
50
  */
51
  public function admin( $key, $value ) {
 
 
 
 
52
  ?>
53
  <table>
54
  <tr>
55
  <td><?php esc_html_e( 'Permitted Extension', MWF_Config::DOMAIN ); ?></td>
56
- <td><input type="text" value="<?php echo esc_attr( @$value[$this->getName()]['types'] ); ?>" name="<?php echo MWF_Config::NAME; ?>[validation][<?php echo $key; ?>][<?php echo esc_attr( $this->getName() ); ?>][types]" /> <span class="mwf_note"><?php esc_html_e( 'Example:jpg or jpg,txt,…', MWF_Config::DOMAIN ); ?></span></td>
57
  </tr>
58
  </table>
59
  <?php
2
  /**
3
  * Name: MW Validation Rule FileType
4
  * Description: ファイル名が指定した拡張子を含む。types は , 区切り
5
+ * Version: 1.0.2
6
  * Author: Takashi Kitajima
7
  * Author URI: http://2inc.org
8
  * Created : July 21, 2014
9
+ * Modified: August 18, 2014
10
  * License: GPLv2
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
33
  $options = array_merge( $defaults, $options );
34
  $_types = explode( ',', $options['types'] );
35
  foreach ( $_types as $type ) {
36
+ $types[] = preg_quote( trim( $type ), '/' );
37
  }
38
  $types = implode( '|', MWF_Functions::array_clean( $types ) );
39
  $pattern = '/\.(' . $types . ')$/';
49
  * @param array $value バリデーションルールセットの内容
50
  */
51
  public function admin( $key, $value ) {
52
+ $types = '';
53
+ if ( is_array( $value[$this->getName()] ) && isset( $value[$this->getName()]['types'] ) ) {
54
+ $types = $value[$this->getName()]['types'];
55
+ }
56
  ?>
57
  <table>
58
  <tr>
59
  <td><?php esc_html_e( 'Permitted Extension', MWF_Config::DOMAIN ); ?></td>
60
+ <td><input type="text" value="<?php echo esc_attr( $types ); ?>" name="<?php echo MWF_Config::NAME; ?>[validation][<?php echo $key; ?>][<?php echo esc_attr( $this->getName() ); ?>][types]" /> <span class="mwf_note"><?php esc_html_e( 'Example:jpg or jpg,txt,…', MWF_Config::DOMAIN ); ?></span></td>
61
  </tr>
62
  </table>
63
  <?php
validation_rules/mw_validation_rule_minlength.php CHANGED
@@ -2,11 +2,11 @@
2
  /**
3
  * Name: MW Validation Rule MinLength
4
  * Description: 値の文字数が範囲内
5
- * Version: 1.0.1
6
  * Author: Takashi Kitajima
7
  * Author URI: http://2inc.org
8
  * Created : July 21, 2014
9
- * Modified: August 8, 2014
10
  * License: GPLv2
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
@@ -44,11 +44,15 @@ class MW_Validation_Rule_MinLength extends MW_Validation_Rule {
44
  * @param array $value バリデーションルールセットの内容
45
  */
46
  public function admin( $key, $value ) {
 
 
 
 
47
  ?>
48
  <table>
49
  <tr>
50
  <td><?php esc_html_e( 'The number of the minimum characters', MWF_Config::DOMAIN ); ?></td>
51
- <td><input type="text" value="<?php echo esc_attr( @$value[$this->getName()]['min'] ); ?>" size="3" name="<?php echo MWF_Config::NAME; ?>[validation][<?php echo $key; ?>][<?php echo esc_attr( $this->getName() ); ?>][min]" /></td>
52
  </tr>
53
  </table>
54
  <?php
2
  /**
3
  * Name: MW Validation Rule MinLength
4
  * Description: 値の文字数が範囲内
5
+ * Version: 1.0.2
6
  * Author: Takashi Kitajima
7
  * Author URI: http://2inc.org
8
  * Created : July 21, 2014
9
+ * Modified: August 18, 2014
10
  * License: GPLv2
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
44
  * @param array $value バリデーションルールセットの内容
45
  */
46
  public function admin( $key, $value ) {
47
+ $min = '';
48
+ if ( is_array( $value[$this->getName()] ) && isset( $value[$this->getName()]['min'] ) ) {
49
+ $min = $value[$this->getName()]['min'];
50
+ }
51
  ?>
52
  <table>
53
  <tr>
54
  <td><?php esc_html_e( 'The number of the minimum characters', MWF_Config::DOMAIN ); ?></td>
55
+ <td><input type="text" value="<?php echo esc_attr( $min ); ?>" size="3" name="<?php echo MWF_Config::NAME; ?>[validation][<?php echo $key; ?>][<?php echo esc_attr( $this->getName() ); ?>][min]" /></td>
56
  </tr>
57
  </table>
58
  <?php