MW WP Form - Version 4.0.4

Version Description

  • PHP 5.3, 5.2.4 support
Download this release

Release Info

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

Code changes from version 4.0.3 to 4.0.4

classes/controllers/class.main.php CHANGED
@@ -27,16 +27,12 @@ class MW_WP_Form_Main_Controller {
27
  protected $Validation;
28
 
29
  public function __construct() {
 
 
30
 
31
- nocache_headers();
32
- add_filter( 'nocache_headers' , function($headers) {
33
- $headers['X-Accel-Expires'] = 0;
34
- return $headers;
35
- }, 1 );
36
-
37
- add_action( 'parse_request' , array( $this, '_remove_query_vars_from_post' ) );
38
- add_filter( 'nocache_headers' , array( $this, '_nocache_headers' ) , 1 );
39
- add_filter( 'template_include', array( $this, '_template_include' ), 10000 );
40
  }
41
 
42
  /**
@@ -68,6 +64,38 @@ class MW_WP_Form_Main_Controller {
68
  }
69
  }
70
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  /**
72
  * Customize request header for Nginx Cache Controller
73
  *
@@ -76,26 +104,20 @@ class MW_WP_Form_Main_Controller {
76
  */
77
  public function _nocache_headers( $headers ) {
78
  $headers['X-Accel-Expires'] = 0;
 
79
  return $headers;
80
  }
81
 
82
  /**
83
  * Main process for form displaying
84
- *
85
- * @param string $template
86
- * @return string $template
87
  */
88
- public function _template_include( $template ) {
89
- global $post;
90
-
91
  /**
92
  * - 送信時はバリデーションチェック、トークンチェックを行い、リダイレクト先を決定する
93
  * - 決定したリダイレクト先にリダイレクトする
94
  * - リダイレクト先が現在表示しようとしているページと同じ場合は無視する
95
  */
96
  if ( ! empty( $_POST ) && ! empty( $_POST[ MWF_Config::NAME . '-form-id' ] ) ) {
97
- nocache_headers();
98
-
99
  $form_id = $_POST[ MWF_Config::NAME . '-form-id' ];
100
  if ( MWF_Config::NAME !== get_post_type( $form_id ) ) {
101
  wp_safe_redirect( home_url() );
@@ -144,15 +166,9 @@ class MW_WP_Form_Main_Controller {
144
  );
145
  }
146
 
147
- $this->_set_transient_for_nocache_headers();
148
-
149
  $Redirected->redirect();
150
 
151
  } else {
152
- $transient = $this->_get_transient_for_nocache_headers();
153
- if ( $transient ) {
154
- nocache_headers();
155
- }
156
 
157
  /**
158
  * [mwform], [mwform_formkey] の登録
@@ -169,8 +185,6 @@ class MW_WP_Form_Main_Controller {
169
  $this->_mwform_enqueue_scripts();
170
 
171
  }
172
-
173
- return $template;
174
  }
175
 
176
  /**
@@ -353,13 +367,14 @@ class MW_WP_Form_Main_Controller {
353
  /**
354
  * Set transient for nocache headers
355
  *
 
356
  * @return void
357
  */
358
- protected function _set_transient_for_nocache_headers() {
359
  $transient_name = $this->_get_transient_name_for_nocache_headers();
360
  $transient = get_transient( $transient_name );
361
  if ( ! $transient ) {
362
- $transient = [];
363
  }
364
  $transient[] = $form_key;
365
  set_transient( $transient_name, $transient, 1 );
27
  protected $Validation;
28
 
29
  public function __construct() {
30
+ add_filter( 'nocache_headers', array( $this, '_nocache_headers' ) );
31
+ add_filter( 'nginxchampuru_caching_headers', array( $this, '_nginxchampuru_caching_headers' ) );
32
 
33
+ add_action( 'parse_request' , array( $this, '_remove_query_vars_from_post' ) );
34
+ add_action( 'template_redirect', array( $this, '_send_headers' ), 10000 );
35
+ add_action( 'template_redirect', array( $this, '_template_redirect' ), 10000 );
 
 
 
 
 
 
36
  }
37
 
38
  /**
64
  }
65
  }
66
 
67
+ /**
68
+ * Proxy cache measures
69
+ *
70
+ * @todo NOT WORKING
71
+ */
72
+ public function _send_headers() {
73
+ if ( ! empty( $_POST ) && ! empty( $_POST[ MWF_Config::NAME . '-form-id' ] ) ) {
74
+ nocache_headers();
75
+ $form_id = $_POST[ MWF_Config::NAME . '-form-id' ];
76
+ $form_key = MWF_Functions::get_form_key_from_form_id( $form_id );
77
+ $this->_set_transient_for_nocache_headers( $form_key );
78
+ } else {
79
+ $transient = $this->_get_transient_for_nocache_headers();
80
+ if ( $transient ) {
81
+ nocache_headers();
82
+ }
83
+ }
84
+ }
85
+
86
+ /**
87
+ * Cache control for Nginx Cache Controller plugin
88
+ *
89
+ * @todo NOT WORKING
90
+ */
91
+ public function _nginxchampuru_caching_headers( $headers ) {
92
+ $transient = $this->_get_transient_for_nocache_headers();
93
+ if ( $transient ) {
94
+ $headers = $this->_nocache_headers( $headers );
95
+ }
96
+ return $headers;
97
+ }
98
+
99
  /**
100
  * Customize request header for Nginx Cache Controller
101
  *
104
  */
105
  public function _nocache_headers( $headers ) {
106
  $headers['X-Accel-Expires'] = 0;
107
+ $headers['Cache-Control'] = 'private, no-store, no-cache, must-revalidate';
108
  return $headers;
109
  }
110
 
111
  /**
112
  * Main process for form displaying
 
 
 
113
  */
114
+ public function _template_redirect() {
 
 
115
  /**
116
  * - 送信時はバリデーションチェック、トークンチェックを行い、リダイレクト先を決定する
117
  * - 決定したリダイレクト先にリダイレクトする
118
  * - リダイレクト先が現在表示しようとしているページと同じ場合は無視する
119
  */
120
  if ( ! empty( $_POST ) && ! empty( $_POST[ MWF_Config::NAME . '-form-id' ] ) ) {
 
 
121
  $form_id = $_POST[ MWF_Config::NAME . '-form-id' ];
122
  if ( MWF_Config::NAME !== get_post_type( $form_id ) ) {
123
  wp_safe_redirect( home_url() );
166
  );
167
  }
168
 
 
 
169
  $Redirected->redirect();
170
 
171
  } else {
 
 
 
 
172
 
173
  /**
174
  * [mwform], [mwform_formkey] の登録
185
  $this->_mwform_enqueue_scripts();
186
 
187
  }
 
 
188
  }
189
 
190
  /**
367
  /**
368
  * Set transient for nocache headers
369
  *
370
+ * @param string $form_key
371
  * @return void
372
  */
373
+ protected function _set_transient_for_nocache_headers( $form_key ) {
374
  $transient_name = $this->_get_transient_name_for_nocache_headers();
375
  $transient = get_transient( $transient_name );
376
  if ( ! $transient ) {
377
+ $transient = array();
378
  }
379
  $transient[] = $form_key;
380
  set_transient( $transient_name, $transient, 1 );
classes/services/class.redirected.php CHANGED
@@ -184,7 +184,7 @@ class MW_WP_Form_Redirected {
184
 
185
  do_action( 'mwform_before_redirect_' . $this->form_key );
186
 
187
- wp_safe_redirect( $redirect );
188
  exit();
189
  }
190
 
184
 
185
  do_action( 'mwform_before_redirect_' . $this->form_key );
186
 
187
+ wp_safe_redirect( $redirect, 302 );
188
  exit();
189
  }
190
 
mw-wp-form.php CHANGED
@@ -3,11 +3,11 @@
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.0.3
7
  * Author: Takashi Kitajima
8
  * Author URI: https://2inc.org
9
  * Created : September 25, 2012
10
- * Modified: September 11, 2019
11
  * Text Domain: mw-wp-form
12
  * License: GPLv2 or later
13
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
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.0.4
7
  * Author: Takashi Kitajima
8
  * Author URI: https://2inc.org
9
  * Created : September 25, 2012
10
+ * Modified: September 20, 2019
11
  * Text Domain: mw-wp-form
12
  * License: GPLv2 or later
13
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
readme.txt CHANGED
@@ -4,7 +4,7 @@ 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: 4.9.8
7
- Stable tag: 4.0.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -71,6 +71,9 @@ Do you have questions or issues with MW WP Form? Use these support channels appr
71
 
72
  == Changelog ==
73
 
 
 
 
74
  = 4.0.3 =
75
  * Fix saved contact data list bug.
76
  * Fix nocache headers bug.
@@ -462,7 +465,6 @@ Do you have questions or issues with MW WP Form? Use these support channels appr
462
  * Added : X-Accel-Expires param in header.
463
  * Added : Add CC setting in admin mail setting.
464
  * Added : Add BCC setting in admin mail setting.
465
- * Added : X-Accel-Expires param in header.
466
  * Changed : Data store has been changed to Transient API from PHP SESSION.
467
  * Changed : Nonce check system has been changed to WordPress nonce check system from original.
468
  * Changed : Accept space in katakana validation.
4
  Tags: plugin, form, confirm, preview, shortcode, mail, chart, graph, html, contact form, form creation, form creator, form manager, form builder, custom form
5
  Requires at least: 4.0
6
  Tested up to: 4.9.8
7
+ Stable tag: 4.0.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
71
 
72
  == Changelog ==
73
 
74
+ = 4.0.4 =
75
+ * PHP 5.3, 5.2.4 support
76
+
77
  = 4.0.3 =
78
  * Fix saved contact data list bug.
79
  * Fix nocache headers bug.
465
  * Added : X-Accel-Expires param in header.
466
  * Added : Add CC setting in admin mail setting.
467
  * Added : Add BCC setting in admin mail setting.
 
468
  * Changed : Data store has been changed to Transient API from PHP SESSION.
469
  * Changed : Nonce check system has been changed to WordPress nonce check system from original.
470
  * Changed : Accept space in katakana validation.