MW WP Form - Version 3.2.0

Version Description

  • Added : Added process of mail sending error. When failed mail sending, displayed mail sending error page.
  • Added : Added filter hook mwform_is_mail_sended
  • Added : Added filter hook mwform_send_error_content_raw_mw-wp-form-xxx
  • Added : Added filter hook mwform_send_error_content_mw-wp-form-xxx
Download this release

Release Info

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

Code changes from version 3.1.0 to 3.2.0

classes/config.php CHANGED
@@ -66,4 +66,9 @@ class MWF_Config {
66
  * CONTACT_DATA_NAME
67
  */
68
  const CONTACT_DATA_NAME = '_mw-wp-form_data';
 
 
 
 
 
69
  }
66
  * CONTACT_DATA_NAME
67
  */
68
  const CONTACT_DATA_NAME = '_mw-wp-form_data';
69
+
70
+ /**
71
+ * 送信エラーかどうかを判定する MW_WP_Form_Data のキー
72
+ */
73
+ const SEND_ERROR = 'mw-wp-form-send-error';
74
  }
classes/controllers/class.main.php CHANGED
@@ -2,11 +2,11 @@
2
  /**
3
  * Name : MW WP Form Main Controller
4
  * Description: フロントエンドにおいて、適切な画面にリダイレクトさせる
5
- * Version : 1.5.0
6
  * Author : Takashi Kitajima
7
  * Author URI : http://2inc.org
8
  * Created : December 23, 2014
9
- * Modified : January 30, 2017
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
@@ -149,12 +149,7 @@ class MW_WP_Form_Main_Controller {
149
  // complete のとき
150
  if ( $view_flg === 'complete' ) {
151
  if ( !$this->is_complete_twice() ) {
152
- $this->send();
153
-
154
- do_action(
155
- 'mwform_after_send_' . $form_key,
156
- $this->Data
157
- );
158
  }
159
  // 手動フォームの場合は完了画面に ExecShortcode が無く footer の clear_values が
160
  // 効かないためここで消す
@@ -163,6 +158,15 @@ class MW_WP_Form_Main_Controller {
163
  }
164
  }
165
 
 
 
 
 
 
 
 
 
 
166
  do_action( 'mwform_before_redirect_' . $form_key );
167
  $url = apply_filters( 'mwform_redirect_url_' . $form_key, $this->Redirected->get_url(), $this->Data );
168
  $this->redirect( $url );
@@ -260,6 +264,8 @@ class MW_WP_Form_Main_Controller {
260
 
261
  /**
262
  * メール送信
 
 
263
  */
264
  protected function send() {
265
  $Mail = new MW_WP_Form_Mail();
@@ -276,7 +282,11 @@ class MW_WP_Form_Main_Controller {
276
  }
277
  }
278
 
279
- $Mail_Service->send_admin_mail();
 
 
 
 
280
 
281
  // 自動返信メールの送信
282
  $automatic_reply_email = $this->Setting->get( 'automatic_reply_email' );
@@ -286,12 +296,14 @@ class MW_WP_Form_Main_Controller {
286
  $automatic_reply_email
287
  );
288
  if ( $automatic_reply_email && !$is_invalid_mail_address ) {
289
- $Mail_Service->send_reply_mail();
290
  }
291
  }
292
 
293
  // 問い合わせ番号を加算
294
  $Mail_Service->update_tracking_number();
 
 
295
  }
296
  }
297
 
2
  /**
3
  * Name : MW WP Form Main Controller
4
  * Description: フロントエンドにおいて、適切な画面にリダイレクトさせる
5
+ * Version : 1.5.1
6
  * Author : Takashi Kitajima
7
  * Author URI : http://2inc.org
8
  * Created : December 23, 2014
9
+ * Modified : April 28, 2017
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
149
  // complete のとき
150
  if ( $view_flg === 'complete' ) {
151
  if ( !$this->is_complete_twice() ) {
152
+ $is_mail_sended = $this->send();
 
 
 
 
 
153
  }
154
  // 手動フォームの場合は完了画面に ExecShortcode が無く footer の clear_values が
155
  // 効かないためここで消す
158
  }
159
  }
160
 
161
+ if ( isset( $is_mail_sended ) && false === $is_mail_sended ) {
162
+ $this->Data->set_send_error();
163
+ } elseif ( isset( $is_mail_sended ) && true === $is_mail_sended ) {
164
+ do_action(
165
+ 'mwform_after_send_' . $form_key,
166
+ $this->Data
167
+ );
168
+ }
169
+
170
  do_action( 'mwform_before_redirect_' . $form_key );
171
  $url = apply_filters( 'mwform_redirect_url_' . $form_key, $this->Redirected->get_url(), $this->Data );
172
  $this->redirect( $url );
264
 
265
  /**
266
  * メール送信
267
+ *
268
+ * @return boolean
269
  */
270
  protected function send() {
271
  $Mail = new MW_WP_Form_Mail();
282
  }
283
  }
284
 
285
+ $is_admin_mail_sended = $Mail_Service->send_admin_mail();
286
+
287
+ if ( ! $is_admin_mail_sended ) {
288
+ return false;
289
+ }
290
 
291
  // 自動返信メールの送信
292
  $automatic_reply_email = $this->Setting->get( 'automatic_reply_email' );
296
  $automatic_reply_email
297
  );
298
  if ( $automatic_reply_email && !$is_invalid_mail_address ) {
299
+ $is_reply_mail_sended = $Mail_Service->send_reply_mail();
300
  }
301
  }
302
 
303
  // 問い合わせ番号を加算
304
  $Mail_Service->update_tracking_number();
305
+
306
+ return true;
307
  }
308
  }
309
 
classes/models/class.data.php CHANGED
@@ -541,4 +541,20 @@ class MW_WP_Form_Data {
541
  public function get_view_flg() {
542
  return $this->view_flg;
543
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
544
  }
541
  public function get_view_flg() {
542
  return $this->view_flg;
543
  }
544
+
545
+ /**
546
+ * 送信エラーを示すフラグをセット
547
+ */
548
+ public function set_send_error() {
549
+ $this->set( MWF_Config::SEND_ERROR, true );
550
+ }
551
+
552
+ /**
553
+ * 送信エラーを示すフラグを返す
554
+ *
555
+ * @return boolean
556
+ */
557
+ public function get_send_error() {
558
+ return $this->get( MWF_Config::SEND_ERROR );
559
+ }
560
  }
classes/models/class.mail.php CHANGED
@@ -2,11 +2,11 @@
2
  /**
3
  * Name : MW WP Form Mail
4
  * Description: メールクラス
5
- * Version : 2.1.0
6
  * Author : Takashi Kitajima
7
  * Author URI : http://2inc.org
8
  * Created : July 20, 2012
9
- * Modified : January 13, 2017
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
@@ -73,6 +73,8 @@ class MW_WP_Form_Mail {
73
 
74
  /**
75
  * メール送信
 
 
76
  */
77
  public function send() {
78
  if ( !$this->to ) {
@@ -118,14 +120,16 @@ class MW_WP_Form_Mail {
118
  $body,
119
  implode( "\n", $this->attachments )
120
  );
121
- file_put_contents( $temp_dir . '/mw-wp-form-debug.log', $contents, FILE_APPEND );
122
  } else {
123
- @wp_mail( $to, $subject, $body, $headers, $this->attachments );
124
  }
125
 
126
  remove_action( 'phpmailer_init' , array( $this, 'set_return_path' ) );
127
  remove_filter( 'wp_mail_from' , array( $this, 'set_mail_from' ) );
128
  remove_filter( 'wp_mail_from_name', array( $this, 'set_mail_from_name' ) );
 
 
129
  }
130
 
131
  /**
@@ -360,18 +364,27 @@ class MW_WP_Form_Mail {
360
  * メールを送信内容に置換
361
  *
362
  * @param MW_WP_Form_Setting $Setting
363
- * @param bool $do_update
364
  */
365
- public function parse( $Setting, $do_update = false ) {
366
- $Data = MW_WP_Form_Data::getInstance();
367
-
368
  $this->Mail_Parser = new MW_WP_Form_Mail_Parser( $this, $Setting );
369
- $Mail = $this->Mail_Parser->get_parsed_mail_object( $do_update );
370
  foreach ( get_object_vars( $Mail ) as $key => $value ) {
371
  $this->$key = $value;
372
  }
373
  }
374
 
 
 
 
 
 
 
 
 
 
 
 
 
375
  /**
376
  * 保存した問い合わせデータの Post IDを取得する
377
  *
2
  /**
3
  * Name : MW WP Form Mail
4
  * Description: メールクラス
5
+ * Version : 2.2.0
6
  * Author : Takashi Kitajima
7
  * Author URI : http://2inc.org
8
  * Created : July 20, 2012
9
+ * Modified : April 29, 2017
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
73
 
74
  /**
75
  * メール送信
76
+ *
77
+ * @return boolean
78
  */
79
  public function send() {
80
  if ( !$this->to ) {
120
  $body,
121
  implode( "\n", $this->attachments )
122
  );
123
+ $is_mail_sended = file_put_contents( $temp_dir . '/mw-wp-form-debug.log', $contents, FILE_APPEND );
124
  } else {
125
+ $is_mail_sended = wp_mail( $to, $subject, $body, $headers, $this->attachments );
126
  }
127
 
128
  remove_action( 'phpmailer_init' , array( $this, 'set_return_path' ) );
129
  remove_filter( 'wp_mail_from' , array( $this, 'set_mail_from' ) );
130
  remove_filter( 'wp_mail_from_name', array( $this, 'set_mail_from_name' ) );
131
+
132
+ return apply_filters( 'mwform_is_mail_sended', $is_mail_sended );
133
  }
134
 
135
  /**
364
  * メールを送信内容に置換
365
  *
366
  * @param MW_WP_Form_Setting $Setting
 
367
  */
368
+ public function parse( $Setting ) {
 
 
369
  $this->Mail_Parser = new MW_WP_Form_Mail_Parser( $this, $Setting );
370
+ $Mail = $this->Mail_Parser->get_parsed_mail_object();
371
  foreach ( get_object_vars( $Mail ) as $key => $value ) {
372
  $this->$key = $value;
373
  }
374
  }
375
 
376
+ /**
377
+ * メールをデータベースに保存
378
+ *
379
+ * @param MW_WP_Form_Setting $Setting
380
+ * @return int
381
+ */
382
+ public function save( $Setting ) {
383
+ $this->Mail_Parser = new MW_WP_Form_Mail_Parser( $this, $Setting );
384
+ $this->Mail_Parser->save();
385
+ return $this->get_saved_mail_id();
386
+ }
387
+
388
  /**
389
  * 保存した問い合わせデータの Post IDを取得する
390
  *
classes/services/class.exec-shortcode.php CHANGED
@@ -301,8 +301,12 @@ class MW_WP_Form_Exec_Shortcode {
301
 
302
  do_action( 'mwform_before_load_content_' . $form_key );
303
 
 
 
 
 
304
  // 入力画面
305
- if ( $view_flg === 'input' ) {
306
  $content = $this->get_input_page_content( $form_id );
307
  }
308
  // 確認画面
@@ -333,7 +337,23 @@ class MW_WP_Form_Exec_Shortcode {
333
  $post = get_post( $form_id );
334
  setup_postdata( $post );
335
  $content = apply_filters( 'mwform_post_content_raw_' . $form_key, get_the_content(), $this->Data );
 
 
 
 
 
 
 
 
336
 
 
 
 
 
 
 
 
 
337
  $has_wpautop = false;
338
  if ( has_filter( 'the_content', 'wpautop' ) ) {
339
  $has_wpautop = true;
@@ -348,11 +368,6 @@ class MW_WP_Form_Exec_Shortcode {
348
  $content = wpautop( $content );
349
  }
350
 
351
- $content = sprintf(
352
- '[mwform]%s[/mwform]',
353
- apply_filters( 'mwform_post_content_' . $form_key, $content, $this->Data )
354
- );
355
- wp_reset_postdata();
356
  return $content;
357
  }
358
 
@@ -375,21 +390,7 @@ class MW_WP_Form_Exec_Shortcode {
375
  $form_key = $this->get( 'key' );
376
  $Setting = $this->Setting;
377
  $content = apply_filters( 'mwform_complete_content_raw_' . $form_key, $Setting->get( 'complete_message' ), $this->Data );
378
-
379
- $has_wpautop = false;
380
- if ( has_filter( 'the_content', 'wpautop' ) ) {
381
- $has_wpautop = true;
382
- }
383
- $has_wpautop = apply_filters(
384
- 'mwform_content_wpautop_' . $form_key,
385
- $has_wpautop,
386
- $this->view_flg
387
- );
388
-
389
- if ( $has_wpautop ) {
390
- $content = wpautop( $content );
391
- }
392
-
393
  $content = sprintf(
394
  '[mwform_complete_message]%s[/mwform_complete_message]',
395
  apply_filters( 'mwform_complete_content_' . $form_key, $content, $this->Data )
@@ -397,6 +398,26 @@ class MW_WP_Form_Exec_Shortcode {
397
  return $content;
398
  }
399
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
400
  /**
401
  * フォームを出力
402
  *
301
 
302
  do_action( 'mwform_before_load_content_' . $form_key );
303
 
304
+ // 送信エラー画面
305
+ if ( $this->Data->get_send_error() ) {
306
+ $content = $this->get_send_error_page_content( $form_id );
307
+ }
308
  // 入力画面
309
+ elseif ( $view_flg === 'input' ) {
310
  $content = $this->get_input_page_content( $form_id );
311
  }
312
  // 確認画面
337
  $post = get_post( $form_id );
338
  setup_postdata( $post );
339
  $content = apply_filters( 'mwform_post_content_raw_' . $form_key, get_the_content(), $this->Data );
340
+ $content = $this->wpautop( $content );
341
+ $content = sprintf(
342
+ '[mwform]%s[/mwform]',
343
+ apply_filters( 'mwform_post_content_' . $form_key, $content, $this->Data )
344
+ );
345
+ wp_reset_postdata();
346
+ return $content;
347
+ }
348
 
349
+ /**
350
+ * wpautop の設定に応じてコンテンツを改行する
351
+ *
352
+ * @param string $content
353
+ * @return string
354
+ */
355
+ protected function wpautop( $content ) {
356
+ $form_key = $this->get( 'key' );
357
  $has_wpautop = false;
358
  if ( has_filter( 'the_content', 'wpautop' ) ) {
359
  $has_wpautop = true;
368
  $content = wpautop( $content );
369
  }
370
 
 
 
 
 
 
371
  return $content;
372
  }
373
 
390
  $form_key = $this->get( 'key' );
391
  $Setting = $this->Setting;
392
  $content = apply_filters( 'mwform_complete_content_raw_' . $form_key, $Setting->get( 'complete_message' ), $this->Data );
393
+ $content = $this->wpautop( $content );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
394
  $content = sprintf(
395
  '[mwform_complete_message]%s[/mwform_complete_message]',
396
  apply_filters( 'mwform_complete_content_' . $form_key, $content, $this->Data )
398
  return $content;
399
  }
400
 
401
+ /**
402
+ * 送信エラー画面を表示
403
+ *
404
+ * @return string $content
405
+ */
406
+ public function get_send_error_page_content() {
407
+ $form_key = $this->get( 'key' );
408
+ $content = sprintf(
409
+ '<div id="mw_wp_form_%s" class="mw_wp_form mw_wp_form_send_error">
410
+ %s
411
+ <!-- end .mw_wp_form --></div>',
412
+ esc_attr( $form_key ),
413
+ __( 'There was an error trying to send your message. Please try again later.', 'mw-wp-form' )
414
+ );
415
+ $content = apply_filters( 'mwform_send_error_content_raw_' . $form_key, $content, $this->Data );
416
+ $content = $this->wpautop( $content );
417
+ $content = apply_filters( 'mwform_send_error_content_' . $form_key, $content, $this->Data );
418
+ return $content;
419
+ }
420
+
421
  /**
422
  * フォームを出力
423
  *
classes/services/class.mail-parser.php CHANGED
@@ -2,11 +2,11 @@
2
  /**
3
  * Name : MW WP Form Mail Parser
4
  * Description: メールパーサー
5
- * Version : 1.2.0
6
  * Author : Takashi Kitajima
7
  * Author URI : http://2inc.org
8
  * Created : April 14, 2015
9
- * Modified : December 27, 2016
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
@@ -44,34 +44,12 @@ class MW_WP_Form_Mail_Parser {
44
  }
45
 
46
  /**
47
- * パースした Mail オブジェクトの取得とデータベースへの保存
48
  *
49
- * @param bool $do_update
50
  * @return MW_WP_Form_Mail
51
  */
52
- public function get_parsed_mail_object( $do_update = false ) {
53
- if ( $do_update ) {
54
- $form_id = $this->Setting->get( 'post_id' );
55
- $saved_mail_id = wp_insert_post( array(
56
- 'post_title' => $this->parse_mail_content( $this->Mail->subject ),
57
- 'post_status' => 'publish',
58
- 'post_type' => MWF_Functions::get_contact_data_post_type_from_form_id( $form_id ),
59
- ) );
60
-
61
- // 添付ファイルをメディアに保存
62
- // save_mail_body 内のフックで添付ファイルの情報を使えるように、
63
- // save_mail_body より前にこのブロックを実行する
64
- // ここでポストメタとしてURLではなくファイルのIDを保存
65
- if ( !empty( $saved_mail_id ) ) {
66
- MWF_Functions::save_attachments_in_media(
67
- $saved_mail_id,
68
- $this->Mail->attachments,
69
- $form_id
70
- );
71
- }
72
- $this->saved_mail_id = $saved_mail_id;
73
- }
74
- return $this->parse_mail_object( $do_update );
75
  }
76
 
77
  /**
@@ -86,10 +64,9 @@ class MW_WP_Form_Mail_Parser {
86
  /**
87
  * メールオブジェクトの各プロパティを変換
88
  *
89
- * @param bool $do_update
90
  * @return MW_WP_Form_Mail $Mail
91
  */
92
- protected function parse_mail_object( $do_update = false ) {
93
  $parsed_Mail_vars = get_object_vars( $this->Mail );
94
  foreach ( $parsed_Mail_vars as $key => $value ) {
95
  if ( is_array( $value ) ) {
@@ -100,13 +77,7 @@ class MW_WP_Form_Mail_Parser {
100
  $this->Mail->$key = $this->parse_mail_destination( $value );
101
  continue;
102
  }
103
-
104
- if ( $key == 'body' && $do_update ) {
105
- $value = $this->parse_mail_content( $value, true );
106
- } else {
107
- $value = $this->parse_mail_content( $value );
108
- }
109
- $this->Mail->$key = $value;
110
  }
111
  return $this->Mail;
112
  }
@@ -141,61 +112,108 @@ class MW_WP_Form_Mail_Parser {
141
  * メール本文用に {name属性} を置換
142
  *
143
  * @param string $value
144
- * @param bool $do_update
145
  * @return string
146
  */
147
- protected function parse_mail_content( $value, $do_update = false ) {
148
- if ( $do_update ) {
149
- $callback = '_save_mail_content';
150
- } else {
151
- $callback = '_parse_mail_content';
152
- }
153
  return preg_replace_callback(
154
  '/{(.+?)}/',
155
- array( $this, $callback ),
156
  $value
157
  );
158
  }
159
  protected function _parse_mail_content( $matches ) {
160
- return $this->parse( $matches, false );
 
161
  }
162
- protected function _save_mail_content( $matches ) {
163
- return $this->parse( $matches, true );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
  }
165
 
166
  /**
167
- * $this->_parse_mail_content(), $this->_save_mail_content の本体
168
- * 第2引数でDB保存するか判定
169
  *
170
- * @param array $matches
171
- * @param bool $do_update
172
- * @return string $value
173
  */
174
- protected function parse( $matches, $do_update = false ) {
175
- $match = $matches[1];
 
 
 
 
 
 
 
 
 
176
  $form_id = $this->Setting->get( 'post_id' );
177
  $form_key = MWF_Functions::get_form_key_from_form_id( $form_id );
178
- // MWF_Config::TRACKINGNUMBER のときはお問い合せ番号を参照する
179
- if ( $match === MWF_Config::TRACKINGNUMBER ) {
180
- if ( $form_id ) {
181
- $value = $this->Setting->get_tracking_number( $form_id );
182
- }
183
- } else {
184
- $value = $this->Data->get( $match );
185
- $value = $this->apply_filters_mwform_custom_mail_tag( $form_key, $value, $match );
186
- }
187
 
188
- // 値が null でも保存(チェッボックス未チェックで直送信でも保存させるため)
189
- if ( $do_update ) {
 
190
  $ignore_keys = apply_filters( 'mwform_no_save_keys_' . $form_key, array() );
191
- if ( !in_array( $match, $ignore_keys ) ) {
192
  // ファイルは MWF_Functions::save_attachments_in_media() で ID が保存されるため
193
  // ここで送信された値(URL)は保存しない
194
- if ( !array_key_exists( $match, $this->Mail->attachments ) ) {
195
- update_post_meta( $this->saved_mail_id, $match, $value );
196
  }
197
  }
198
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
199
  return $value;
200
  }
201
 
2
  /**
3
  * Name : MW WP Form Mail Parser
4
  * Description: メールパーサー
5
+ * Version : 1.3.0
6
  * Author : Takashi Kitajima
7
  * Author URI : http://2inc.org
8
  * Created : April 14, 2015
9
+ * Modified : April 29, 2017
10
  * License : GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
44
  }
45
 
46
  /**
47
+ * パースした Mail オブジェクトの取得
48
  *
 
49
  * @return MW_WP_Form_Mail
50
  */
51
+ public function get_parsed_mail_object() {
52
+ return $this->parse_mail_object();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  }
54
 
55
  /**
64
  /**
65
  * メールオブジェクトの各プロパティを変換
66
  *
 
67
  * @return MW_WP_Form_Mail $Mail
68
  */
69
+ protected function parse_mail_object() {
70
  $parsed_Mail_vars = get_object_vars( $this->Mail );
71
  foreach ( $parsed_Mail_vars as $key => $value ) {
72
  if ( is_array( $value ) ) {
77
  $this->Mail->$key = $this->parse_mail_destination( $value );
78
  continue;
79
  }
80
+ $this->Mail->$key = $this->parse_mail_content( $value );
 
 
 
 
 
 
81
  }
82
  return $this->Mail;
83
  }
112
  * メール本文用に {name属性} を置換
113
  *
114
  * @param string $value
 
115
  * @return string
116
  */
117
+ protected function parse_mail_content( $value ) {
 
 
 
 
 
118
  return preg_replace_callback(
119
  '/{(.+?)}/',
120
+ array( $this, '_parse_mail_content' ),
121
  $value
122
  );
123
  }
124
  protected function _parse_mail_content( $matches ) {
125
+ $match = $matches[1];
126
+ return $this->_parse( $match );
127
  }
128
+
129
+ /**
130
+ * メール本文・添付ファイルを保存、保存したメール(投稿)の ID をプロパティにセット
131
+ */
132
+ public function save() {
133
+ $form_id = $this->Setting->get( 'post_id' );
134
+ $saved_mail_id = wp_insert_post( array(
135
+ 'post_title' => $this->parse_mail_content( $this->Mail->subject ),
136
+ 'post_status' => 'publish',
137
+ 'post_type' => MWF_Functions::get_contact_data_post_type_from_form_id( $form_id ),
138
+ ) );
139
+
140
+ // 添付ファイルをメディアに保存
141
+ // save_mail_body 内のフックで添付ファイルの情報を使えるように、
142
+ // save_mail_body より前にこのブロックを実行する
143
+ // ここでポストメタとしてURLではなくファイルのIDを保存
144
+ if ( !empty( $saved_mail_id ) ) {
145
+ MWF_Functions::save_attachments_in_media(
146
+ $saved_mail_id,
147
+ $this->Mail->attachments,
148
+ $form_id
149
+ );
150
+ }
151
+
152
+ $this->saved_mail_id = $saved_mail_id;
153
+
154
+ $parsed_Mail_vars = get_object_vars( $this->Mail );
155
+ foreach ( $parsed_Mail_vars as $key => $value ) {
156
+ if ( is_array( $value ) ) {
157
+ continue;
158
+ }
159
+
160
+ if ( $key == 'body' ) {
161
+ $this->_save( $value );
162
+ }
163
+ }
164
  }
165
 
166
  /**
167
+ * {キー}の部分を検索し、その値をデータベースに保存
 
168
  *
169
+ * @param string $value
 
 
170
  */
171
+ protected function _save( $value ) {
172
+ preg_match_all(
173
+ '/{(.+?)}/',
174
+ $value,
175
+ $matches
176
+ );
177
+
178
+ if ( ! isset( $matches[1] ) ) {
179
+ return;
180
+ }
181
+
182
  $form_id = $this->Setting->get( 'post_id' );
183
  $form_key = MWF_Functions::get_form_key_from_form_id( $form_id );
 
 
 
 
 
 
 
 
 
184
 
185
+ foreach ( $matches[1] as $key ) {
186
+ $value = $this->_parse( $key );
187
+ // 値が null でも保存(チェッボックス未チェックで直送信でも保存させるため)
188
  $ignore_keys = apply_filters( 'mwform_no_save_keys_' . $form_key, array() );
189
+ if ( ! in_array( $key, $ignore_keys ) ) {
190
  // ファイルは MWF_Functions::save_attachments_in_media() で ID が保存されるため
191
  // ここで送信された値(URL)は保存しない
192
+ if ( ! array_key_exists( $key, $this->Mail->attachments ) ) {
193
+ update_post_meta( $this->saved_mail_id, $key, $value );
194
  }
195
  }
196
  }
197
+ }
198
+
199
+ /**
200
+ * そのキーについて送信された値を返す
201
+ *
202
+ * @param string $key
203
+ * @return string
204
+ */
205
+ protected function _parse( $key ) {
206
+ $form_id = $this->Setting->get( 'post_id' );
207
+ $form_key = MWF_Functions::get_form_key_from_form_id( $form_id );
208
+ // MWF_Config::TRACKINGNUMBER のときはお問い合せ番号を参照する
209
+ if ( $key === MWF_Config::TRACKINGNUMBER ) {
210
+ if ( $form_id ) {
211
+ $value = $this->Setting->get_tracking_number( $form_id );
212
+ }
213
+ } else {
214
+ $value = $this->Data->get( $key );
215
+ $value = $this->apply_filters_mwform_custom_mail_tag( $form_key, $value, $key );
216
+ }
217
  return $value;
218
  }
219
 
classes/services/class.mail.php CHANGED
@@ -1,11 +1,11 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Mail Service
4
- * Version : 1.3.1
5
  * Author : Takashi Kitajima
6
  * Author URI : http://2inc.org
7
  * Created : January 1, 2015
8
- * Modified : March 18, 2016
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
@@ -79,17 +79,13 @@ class MW_WP_Form_Mail_Service {
79
 
80
  /**
81
  * 管理者メールの送信とデータベースへの保存
 
 
82
  */
83
  public function send_admin_mail() {
 
84
  if ( $this->Setting->get( 'usedb' ) ) {
85
- $Mail_admin = $this->get_parsed_mail_object( $this->Mail_admin_raw, true );
86
-
87
- // 問い合わせデータのメタデータの初期値を保存
88
- $saved_mail_id = $Mail_admin->get_saved_mail_id();
89
- $Contact_Data_Setting = new MW_WP_Form_Contact_Data_Setting( $saved_mail_id );
90
- $Contact_Data_Setting->save();
91
- } else {
92
- $Mail_admin = $this->get_parsed_mail_object( $this->Mail_admin_raw );
93
  }
94
 
95
  $Mail_admin->set_admin_mail_reaquire_params();
@@ -100,30 +96,49 @@ class MW_WP_Form_Mail_Service {
100
  clone $Mail_admin,
101
  clone $this->Data
102
  );
103
- $Mail_admin->send();
 
 
 
 
 
 
104
 
105
  // DB非保存時は管理者メール送信後、ファイルを削除
106
  if ( !$this->Setting->get( 'usedb' ) ) {
107
  $File = new MW_WP_Form_File();
108
  $File->delete_files( $this->attachments );
109
  }
 
 
110
  }
111
 
112
  /**
113
  * パースしたMailオブジェクトの取得とデータベースへの保存
114
  *
115
  * @param MW_WP_Form_Mail $_Mail
116
- * @param bool $do_update
117
  * @return MW_WP_Form_Mail
118
  */
119
- protected function get_parsed_mail_object( MW_WP_Form_Mail $_Mail, $do_update = false ) {
120
  $Mail = clone $_Mail;
121
- $Mail->parse( $this->Setting, $do_update );
122
  return $Mail;
123
  }
124
 
 
 
 
 
 
 
 
 
 
 
125
  /**
126
  * 自動返信メールの送信
 
 
127
  */
128
  public function send_reply_mail() {
129
  $Mail_auto = $this->get_parsed_mail_object( $this->Mail_auto_raw );
@@ -134,7 +149,8 @@ class MW_WP_Form_Mail_Service {
134
  clone $Mail_auto,
135
  clone $this->Data
136
  );
137
- $Mail_auto->send();
 
138
  }
139
 
140
  /**
1
  <?php
2
  /**
3
  * Name : MW WP Form Mail Service
4
+ * Version : 1.4.0
5
  * Author : Takashi Kitajima
6
  * Author URI : http://2inc.org
7
  * Created : January 1, 2015
8
+ * Modified : April 29, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
79
 
80
  /**
81
  * 管理者メールの送信とデータベースへの保存
82
+ *
83
+ * @return boolean
84
  */
85
  public function send_admin_mail() {
86
+ $Mail_admin = $this->get_parsed_mail_object( $this->Mail_admin_raw );
87
  if ( $this->Setting->get( 'usedb' ) ) {
88
+ $Mail_admin_for_save = clone $this->Mail_admin_raw;
 
 
 
 
 
 
 
89
  }
90
 
91
  $Mail_admin->set_admin_mail_reaquire_params();
96
  clone $Mail_admin,
97
  clone $this->Data
98
  );
99
+ $is_admin_mail_sended = $Mail_admin->send();
100
+
101
+ if ( isset( $Mail_admin_for_save ) && $is_admin_mail_sended ) {
102
+ $saved_mail_id = $this->save( $Mail_admin_for_save );
103
+ $Contact_Data_Setting = new MW_WP_Form_Contact_Data_Setting( $saved_mail_id );
104
+ $Contact_Data_Setting->save();
105
+ }
106
 
107
  // DB非保存時は管理者メール送信後、ファイルを削除
108
  if ( !$this->Setting->get( 'usedb' ) ) {
109
  $File = new MW_WP_Form_File();
110
  $File->delete_files( $this->attachments );
111
  }
112
+
113
+ return $is_admin_mail_sended;
114
  }
115
 
116
  /**
117
  * パースしたMailオブジェクトの取得とデータベースへの保存
118
  *
119
  * @param MW_WP_Form_Mail $_Mail
 
120
  * @return MW_WP_Form_Mail
121
  */
122
+ protected function get_parsed_mail_object( MW_WP_Form_Mail $_Mail ) {
123
  $Mail = clone $_Mail;
124
+ $Mail->parse( $this->Setting );
125
  return $Mail;
126
  }
127
 
128
+ /**
129
+ * メールをデータベースに保存し、保存されたメール(投稿)の ID を返す
130
+ *
131
+ * @param MW_WP_Form_Mail $Mail
132
+ * @return int 保存されたメール(投稿)の ID
133
+ */
134
+ protected function save( MW_WP_Form_Mail $Mail ) {
135
+ return $Mail->save( $this->Setting );
136
+ }
137
+
138
  /**
139
  * 自動返信メールの送信
140
+ *
141
+ * @return boolean
142
  */
143
  public function send_reply_mail() {
144
  $Mail_auto = $this->get_parsed_mail_object( $this->Mail_auto_raw );
149
  clone $Mail_auto,
150
  clone $this->Data
151
  );
152
+ $is_reply_mail_sended = $Mail_auto->send();
153
+ return $is_reply_mail_sended;
154
  }
155
 
156
  /**
classes/services/class.redirected.php CHANGED
@@ -1,11 +1,11 @@
1
  <?php
2
  /**
3
  * Name : MW WP Form Redirected
4
- * Version : 1.0.1
5
  * Author : Takashi Kitajima
6
  * Author URI : http://2inc.org
7
  * Created : December 31, 2014
8
- * Modified : April 3, 2015
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
@@ -31,7 +31,7 @@ class MW_WP_Form_Redirected {
31
  * @var bool
32
  */
33
  protected $querystring;
34
-
35
  /**
36
  * __construct
37
  *
@@ -48,7 +48,7 @@ class MW_WP_Form_Redirected {
48
 
49
  $this->initialize( $input, $confirm, $complete, $valdation_error, $is_valid, $post_condition );
50
  }
51
-
52
  /**
53
  * initialize
54
  *
1
  <?php
2
  /**
3
  * Name : MW WP Form Redirected
4
+ * Version : 1.0.2
5
  * Author : Takashi Kitajima
6
  * Author URI : http://2inc.org
7
  * Created : December 31, 2014
8
+ * Modified : April 28, 2017
9
  * License : GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
31
  * @var bool
32
  */
33
  protected $querystring;
34
+
35
  /**
36
  * __construct
37
  *
48
 
49
  $this->initialize( $input, $confirm, $complete, $valdation_error, $is_valid, $post_condition );
50
  }
51
+
52
  /**
53
  * initialize
54
  *
languages/mw-wp-form-ja.mo CHANGED
Binary file
languages/mw-wp-form-ja.po CHANGED
@@ -2,10 +2,10 @@
2
  # This file is distributed under the same license as the MW WP Form package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: MW WP Form 3.1.0\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/mw-wp-form\n"
7
- "POT-Creation-Date: 2017-03-25 21:29+0900\n"
8
- "PO-Revision-Date: 2017-03-25 21:30+0900\n"
9
  "Last-Translator: inc2734 <inc@2inc.org>\n"
10
  "Language-Team: Takashi Kitajima <inc@2inc.org>\n"
11
  "Language: ja\n"
@@ -402,6 +402,10 @@ msgstr "対応済み"
402
  msgid "Memo"
403
  msgstr "メモ"
404
 
 
 
 
 
405
  #: classes/validation-rules/class.akismet.php:30
406
  msgid "The contents which you input were judged with spam."
407
  msgstr "あなたの入力した内容はスパムと判定されました。"
2
  # This file is distributed under the same license as the MW WP Form package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: MW WP Form 3.2.0\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/mw-wp-form\n"
7
+ "POT-Creation-Date: 2017-04-29 22:29+0900\n"
8
+ "PO-Revision-Date: 2017-04-29 22:29+0900\n"
9
  "Last-Translator: inc2734 <inc@2inc.org>\n"
10
  "Language-Team: Takashi Kitajima <inc@2inc.org>\n"
11
  "Language: ja\n"
402
  msgid "Memo"
403
  msgstr "メモ"
404
 
405
+ #: classes/services/class.exec-shortcode.php:413
406
+ msgid "There was an error trying to send your message. Please try again later."
407
+ msgstr "エラーが発生しました、後ほど、もう一度お試しください"
408
+
409
  #: classes/validation-rules/class.akismet.php:30
410
  msgid "The contents which you input were judged with spam."
411
  msgstr "あなたの入力した内容はスパムと判定されました。"
languages/mw-wp-form.pot CHANGED
@@ -2,9 +2,9 @@
2
  # This file is distributed under the same license as the MW WP Form package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: MW WP Form 3.1.0\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/mw-wp-form\n"
7
- "POT-Creation-Date: 2017-03-25 12:29:04+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
@@ -168,7 +168,9 @@ msgstr ""
168
  #: classes/form-fields/class.checkbox.php:130
169
  #: classes/form-fields/class.radio.php:126
170
  #: classes/form-fields/class.select.php:122
171
- msgid "You can split the post value and display value by \":\". But display value is sent in e-mail."
 
 
172
  msgstr ""
173
 
174
  #: classes/form-fields/class.checkbox.php:131
@@ -186,7 +188,9 @@ msgstr ""
186
  #: classes/form-fields/class.checkbox.php:138
187
  #: classes/form-fields/class.radio.php:134
188
  #: classes/form-fields/class.select.php:130
189
- msgid "Send post value when you split the post value and display value by \":\" in choices."
 
 
190
  msgstr ""
191
 
192
  #: classes/form-fields/class.checkbox.php:141
@@ -390,6 +394,10 @@ msgstr ""
390
  msgid "Memo"
391
  msgstr ""
392
 
 
 
 
 
393
  #: classes/validation-rules/class.akismet.php:30
394
  msgid "The contents which you input were judged with spam."
395
  msgstr ""
@@ -646,7 +654,9 @@ msgid "It is automatically converted to Tracking number when you input {%s}."
646
  msgstr ""
647
 
648
  #: templates/admin/admin-mail-options.php:9
649
- msgid "If Admin Email Options is a blank, Automatic Replay Email Options is used as Admin Email Options."
 
 
650
  msgstr ""
651
 
652
  #: templates/admin/admin-mail-options.php:12
@@ -705,7 +715,9 @@ msgid "Automatic reply email"
705
  msgstr ""
706
 
707
  #: templates/admin/mail-options.php:29
708
- msgid "Input the key to use as transmission to automatic reply email. {} is unnecessary."
 
 
709
  msgstr ""
710
 
711
  #: templates/admin/settings.php:9
@@ -713,7 +725,9 @@ msgid "Activate Query string of post"
713
  msgstr ""
714
 
715
  #: templates/admin/settings.php:13
716
- msgid "If this field is active, MW WP Form get query string. And get post data from query string \"post_id\". You can use $post's property in editor."
 
 
717
  msgstr ""
718
 
719
  #: templates/admin/settings.php:15
@@ -797,7 +811,9 @@ msgid "Validation Error Page URL"
797
  msgstr ""
798
 
799
  #: templates/admin/url.php:29
800
- msgid "This urls are the redirection urls at the time of button press. When URL setting is empty, The page redirect on the same page."
 
 
801
  msgstr ""
802
 
803
  #: templates/admin/url.php:30
@@ -833,7 +849,9 @@ msgid "Bar chart"
833
  msgstr ""
834
 
835
  #: templates/chart/index.php:49
836
- msgid "Separator string (If the check box. If the separator attribute is not set to \",\")"
 
 
837
  msgstr ""
838
 
839
  #: templates/chart/index.php:71
@@ -850,7 +868,9 @@ msgid "CSV Download"
850
  msgstr ""
851
 
852
  #: templates/stores-inquiry-data-form-list/index.php:4
853
- msgid "You can see the inquiry data that are saved in the database by clicking on the link below."
 
 
854
  msgstr ""
855
 
856
  #: templates/stores-inquiry-data-form-list/index.php:8
@@ -873,6 +893,7 @@ msgstr ""
873
  #: templates/stores-inquiry-data-form-list/index.php:19
874
  msgid "cases"
875
  msgstr ""
 
876
  #. Plugin Name of the plugin/theme
877
  msgid "MW WP Form"
878
  msgstr ""
@@ -882,7 +903,10 @@ msgid "http://plugins.2inc.org/mw-wp-form/"
882
  msgstr ""
883
 
884
  #. Description of the plugin/theme
885
- msgid "MW WP Form is shortcode base contact form plugin. This plugin have many feature. For example you can use many validation rules, contact data saving, and chart aggregation using saved contact data."
 
 
 
886
  msgstr ""
887
 
888
  #. Author of the plugin/theme
2
  # This file is distributed under the same license as the MW WP Form package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: MW WP Form 3.2.0\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/mw-wp-form\n"
7
+ "POT-Creation-Date: 2017-04-29 13:28:37+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
168
  #: classes/form-fields/class.checkbox.php:130
169
  #: classes/form-fields/class.radio.php:126
170
  #: classes/form-fields/class.select.php:122
171
+ msgid ""
172
+ "You can split the post value and display value by \":\". But display value "
173
+ "is sent in e-mail."
174
  msgstr ""
175
 
176
  #: classes/form-fields/class.checkbox.php:131
188
  #: classes/form-fields/class.checkbox.php:138
189
  #: classes/form-fields/class.radio.php:134
190
  #: classes/form-fields/class.select.php:130
191
+ msgid ""
192
+ "Send post value when you split the post value and display value by \":\" in "
193
+ "choices."
194
  msgstr ""
195
 
196
  #: classes/form-fields/class.checkbox.php:141
394
  msgid "Memo"
395
  msgstr ""
396
 
397
+ #: classes/services/class.exec-shortcode.php:413
398
+ msgid "There was an error trying to send your message. Please try again later."
399
+ msgstr ""
400
+
401
  #: classes/validation-rules/class.akismet.php:30
402
  msgid "The contents which you input were judged with spam."
403
  msgstr ""
654
  msgstr ""
655
 
656
  #: templates/admin/admin-mail-options.php:9
657
+ msgid ""
658
+ "If Admin Email Options is a blank, Automatic Replay Email Options is used as "
659
+ "Admin Email Options."
660
  msgstr ""
661
 
662
  #: templates/admin/admin-mail-options.php:12
715
  msgstr ""
716
 
717
  #: templates/admin/mail-options.php:29
718
+ msgid ""
719
+ "Input the key to use as transmission to automatic reply email. {} is "
720
+ "unnecessary."
721
  msgstr ""
722
 
723
  #: templates/admin/settings.php:9
725
  msgstr ""
726
 
727
  #: templates/admin/settings.php:13
728
+ msgid ""
729
+ "If this field is active, MW WP Form get query string. And get post data from "
730
+ "query string \"post_id\". You can use $post's property in editor."
731
  msgstr ""
732
 
733
  #: templates/admin/settings.php:15
811
  msgstr ""
812
 
813
  #: templates/admin/url.php:29
814
+ msgid ""
815
+ "This urls are the redirection urls at the time of button press. When URL "
816
+ "setting is empty, The page redirect on the same page."
817
  msgstr ""
818
 
819
  #: templates/admin/url.php:30
849
  msgstr ""
850
 
851
  #: templates/chart/index.php:49
852
+ msgid ""
853
+ "Separator string (If the check box. If the separator attribute is not set to "
854
+ "\",\")"
855
  msgstr ""
856
 
857
  #: templates/chart/index.php:71
868
  msgstr ""
869
 
870
  #: templates/stores-inquiry-data-form-list/index.php:4
871
+ msgid ""
872
+ "You can see the inquiry data that are saved in the database by clicking on "
873
+ "the link below."
874
  msgstr ""
875
 
876
  #: templates/stores-inquiry-data-form-list/index.php:8
893
  #: templates/stores-inquiry-data-form-list/index.php:19
894
  msgid "cases"
895
  msgstr ""
896
+
897
  #. Plugin Name of the plugin/theme
898
  msgid "MW WP Form"
899
  msgstr ""
903
  msgstr ""
904
 
905
  #. Description of the plugin/theme
906
+ msgid ""
907
+ "MW WP Form is shortcode base contact form plugin. This plugin have many "
908
+ "feature. For example you can use many validation rules, contact data saving, "
909
+ "and chart aggregation using saved contact data."
910
  msgstr ""
911
 
912
  #. Author of the plugin/theme
mw-wp-form.php CHANGED
@@ -3,11 +3,11 @@
3
  * Plugin Name: MW WP Form
4
  * Plugin URI: http://plugins.2inc.org/mw-wp-form/
5
  * Description: MW WP Form is shortcode base contact form plugin. This plugin have many feature. For example you can use many validation rules, contact data saving, and chart aggregation using saved contact data.
6
- * Version: 3.1.0
7
  * Author: Takashi Kitajima
8
  * Author URI: http://2inc.org
9
  * Created : September 25, 2012
10
- * Modified: March 9, 2017
11
  * Text Domain: mw-wp-form
12
  * Domain Path: /languages/
13
  * License: GPLv2 or later
3
  * Plugin Name: MW WP Form
4
  * Plugin URI: http://plugins.2inc.org/mw-wp-form/
5
  * Description: MW WP Form is shortcode base contact form plugin. This plugin have many feature. For example you can use many validation rules, contact data saving, and chart aggregation using saved contact data.
6
+ * Version: 3.2.0
7
  * Author: Takashi Kitajima
8
  * Author URI: http://2inc.org
9
  * Created : September 25, 2012
10
+ * Modified: April 29, 2017
11
  * Text Domain: mw-wp-form
12
  * Domain Path: /languages/
13
  * License: GPLv2 or later
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: inc2734, ryu263, tomothumb, nanniku, mt8.biz, NExt-Season, kuck1u,
3
  Donate link: http://www.amazon.co.jp/registry/wishlist/39ANKRNSTNW40
4
  Tags: plugin, form, confirm, preview, shortcode, mail, chart, graph, html, contact form, form creation, form creator, form manager, form builder, custom form
5
  Requires at least: 4.0
6
- Tested up to: 4.7.2
7
- Stable tag: 3.1.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -80,6 +80,12 @@ Do you have questions or issues with MW WP Form? Use these support channels appr
80
 
81
  == Changelog ==
82
 
 
 
 
 
 
 
83
  = 3.1.0 =
84
  * Added : Added the month picker field.
85
 
3
  Donate link: http://www.amazon.co.jp/registry/wishlist/39ANKRNSTNW40
4
  Tags: plugin, form, confirm, preview, shortcode, mail, chart, graph, html, contact form, form creation, form creator, form manager, form builder, custom form
5
  Requires at least: 4.0
6
+ Tested up to: 4.7.4
7
+ Stable tag: 3.2.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
80
 
81
  == Changelog ==
82
 
83
+ = 3.2.0 =
84
+ * Added : Added process of mail sending error. When failed mail sending, displayed mail sending error page.
85
+ * Added : Added filter hook mwform_is_mail_sended
86
+ * Added : Added filter hook mwform_send_error_content_raw_mw-wp-form-xxx
87
+ * Added : Added filter hook mwform_send_error_content_mw-wp-form-xxx
88
+
89
  = 3.1.0 =
90
  * Added : Added the month picker field.
91