MW WP Form - Version 1.6.1

Version Description

  • Bug fix : Support Akismet 3.0.0
  • Changed : Support psd, ai, eps file upload.
Download this release

Release Info

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

Code changes from version 1.6.0 to 1.6.1

Files changed (4) hide show
  1. mw-wp-form.php +11 -61
  2. readme.txt +5 -1
  3. system/mw_akismet.php +113 -0
  4. system/mw_wp_form_file.php +13 -2
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 can create mail form with a confirmation screen.
6
- * Version: 1.6.0
7
  * Author: Takashi Kitajima
8
  * Author URI: http://2inc.org
9
  * Created : September 25, 2012
10
- * Modified: April 22, 2014
11
  * Text Domain: mw-wp-form
12
  * Domain Path: /languages/
13
  * License: GPL2
@@ -109,6 +109,7 @@ class mw_wp_form {
109
 
110
  if ( is_admin() ) return;
111
 
 
112
  include_once( plugin_dir_path( __FILE__ ) . 'system/mw_error.php' );
113
  include_once( plugin_dir_path( __FILE__ ) . 'system/mw_form.php' );
114
  include_once( plugin_dir_path( __FILE__ ) . 'system/mw_mail.php' );
@@ -437,7 +438,14 @@ class mw_wp_form {
437
  }
438
  }
439
 
440
- if ( $this->akismet_check() ) {
 
 
 
 
 
 
 
441
  $this->Validation->setRule( MWF_Config::AKISMET, 'akismet_check' );
442
  }
443
 
@@ -447,64 +455,6 @@ class mw_wp_form {
447
  }
448
  }
449
 
450
- /**
451
- * akismet_check
452
- * Akismetチェックを実行
453
- * @return Boolean
454
- */
455
- protected function akismet_check() {
456
- global $akismet_api_host, $akismet_api_port;
457
- if ( ! function_exists( 'akismet_get_key' ) || ! akismet_get_key() )
458
- return false;
459
- $doAkismet = false;
460
- $author = '';
461
- $author_email = '';
462
- $author_url = '';
463
- $content = '';
464
- if ( isset( $this->options_by_formkey['akismet_author'] ) ) {
465
- if ( $author = $this->Data->getValue( $this->options_by_formkey['akismet_author'] ) )
466
- $doAkismet = true;
467
- }
468
- if ( isset( $this->options_by_formkey['akismet_author_email'] ) ) {
469
- if ( $author_email = $this->Data->getValue( $this->options_by_formkey['akismet_author_email'] ) )
470
- $doAkismet = true;
471
- }
472
- if ( isset( $this->options_by_formkey['akismet_author_url'] ) ) {
473
- if ( $author_url = $this->Data->getValue( $this->options_by_formkey['akismet_author_url'] ) )
474
- $doAkismet = true;
475
- }
476
- if ( $doAkismet ) {
477
- foreach ( $this->Data->getValues() as $value ) {
478
- $content .= $value . "\n\n";
479
- }
480
- $permalink = get_permalink();
481
- $akismet = array();
482
- $akismet['blog'] = get_option( 'home' );
483
- $akismet['blog_lang'] = get_locale();
484
- $akismet['blog_charset'] = get_option( 'blog_charset' );
485
- $akismet['user_ip'] = preg_replace( '/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR'] );
486
- $akismet['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
487
- $akismet['referrer'] = $_SERVER['HTTP_REFERER'];
488
- $akismet['comment_type'] = MWF_Config::NAME;
489
- if ( $permalink ) $akismet['permalink'] = $permalink;
490
- if ( $author ) $akismet['comment_author'] = $author;
491
- if ( $author_email ) $akismet['comment_author_email'] = $author_email;
492
- if ( $author_url ) $akismet['comment_author_url'] = $author_url;
493
- if ( $content ) $akismet['comment_content'] = $content;
494
-
495
- foreach ( $_SERVER as $key => $value ) {
496
- if ( !in_array( $key, array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' ) ) )
497
- $akismet["$key"] = $value;
498
- }
499
-
500
- $query_string = http_build_query( $akismet, null, '&' );
501
- $response = akismet_http_post( $query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port );
502
- $response = apply_filters( 'mwform_akismet_responce', $response );
503
-
504
- return ( $response[1] == 'true' ) ? true : false;
505
- }
506
- }
507
-
508
  /**
509
  * apply_filters_mwform_mail
510
  * メール送信フィルター
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.6.1
7
  * Author: Takashi Kitajima
8
  * Author URI: http://2inc.org
9
  * Created : September 25, 2012
10
+ * Modified: April 29, 2014
11
  * Text Domain: mw-wp-form
12
  * Domain Path: /languages/
13
  * License: GPL2
109
 
110
  if ( is_admin() ) return;
111
 
112
+ include_once( plugin_dir_path( __FILE__ ) . 'system/mw_akismet.php' );
113
  include_once( plugin_dir_path( __FILE__ ) . 'system/mw_error.php' );
114
  include_once( plugin_dir_path( __FILE__ ) . 'system/mw_form.php' );
115
  include_once( plugin_dir_path( __FILE__ ) . 'system/mw_mail.php' );
438
  }
439
  }
440
 
441
+ $Akismet = new MW_Akismet();
442
+ $akismet_check = $Akismet->check(
443
+ $this->options_by_formkey['akismet_author'],
444
+ $this->options_by_formkey['akismet_author_email'],
445
+ $this->options_by_formkey['akismet_author_url'],
446
+ $this->Data->getValues()
447
+ );
448
+ if ( $akismet_check ) {
449
  $this->Validation->setRule( MWF_Config::AKISMET, 'akismet_check' );
450
  }
451
 
455
  }
456
  }
457
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
458
  /**
459
  * apply_filters_mwform_mail
460
  * メール送信フィルター
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.4
6
  Tested up to: 3.9.0
7
- Stable tag: 1.6.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -54,6 +54,10 @@ Do you have questions or issues with MW WP Form? Use these support channels appr
54
 
55
  == Changelog ==
56
 
 
 
 
 
57
  = 1.6.0 =
58
  * Changed : Changed Redirection flow.
59
  * Changed : If querystring setting is set and doesn't get post from querystring, return empty.
4
  Tags: plugin, form, confirm, preview, shortcode, mail
5
  Requires at least: 3.4
6
  Tested up to: 3.9.0
7
+ Stable tag: 1.6.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
54
 
55
  == Changelog ==
56
 
57
+ = 1.6.1 =
58
+ * Bug fix : Support Akismet 3.0.0
59
+ * Changed : Support psd, ai, eps file upload.
60
+
61
  = 1.6.0 =
62
  * Changed : Changed Redirection flow.
63
  * Changed : If querystring setting is set and doesn't get post from querystring, return empty.
system/mw_akismet.php ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Name: MW Akismet
4
+ * URI: http://2inc.org
5
+ * Description: Akismetクラス
6
+ * Version: 1.0.0
7
+ * Author: Takashi Kitajima
8
+ * Author URI: http://2inc.org
9
+ * Created : April 30, 2014
10
+ * Modified:
11
+ * License: GPL2
12
+ *
13
+ * Copyright 2014 Takashi Kitajima (email : inc@2inc.org)
14
+ *
15
+ * This program is free software; you can redistribute it and/or modify
16
+ * it under the terms of the GNU General Public License, version 2, as
17
+ * published by the Free Software Foundation.
18
+ *
19
+ * This program is distributed in the hope that it will be useful,
20
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
+ * GNU General Public License for more details.
23
+ *
24
+ * You should have received a copy of the GNU General Public License
25
+ * along with this program; if not, write to the Free Software
26
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27
+ */
28
+ class MW_Akismet {
29
+ public function __construct() {
30
+ }
31
+
32
+ private function is_enable() {
33
+ if ( is_callable( array( 'Akismet', 'get_api_key' ) ) ) {
34
+ return Akismet::get_api_key();
35
+ }
36
+ if ( function_exists( 'akismet_get_key' ) ) {
37
+ return akismet_get_key();
38
+ }
39
+ return false;
40
+ }
41
+
42
+ public function check( $akismet_author, $akismet_author_email, $akismet_author_url, $data ) {
43
+ global $akismet_api_host, $akismet_api_port;
44
+
45
+ if ( !$this->is_enable() )
46
+ return false;
47
+
48
+ $doAkismet = false;
49
+
50
+ $author = '';
51
+ if ( !empty( $data[ $akismet_author ] ) ) {
52
+ $author = $data[ $akismet_author ];
53
+ $doAkismet = true;
54
+ }
55
+
56
+ $author_email = '';
57
+ if ( !empty( $data[ $akismet_author_email ] ) ) {
58
+ $author_email = $data[ $akismet_author_email ];
59
+ $doAkismet = true;
60
+ }
61
+
62
+ $author_url = '';
63
+ if ( !empty( $data[ $akismet_author_url ] ) ) {
64
+ $author_url = $data[ $akismet_author_url ];
65
+ $doAkismet = true;
66
+ }
67
+
68
+ if ( $doAkismet ) {
69
+ $content = '';
70
+ foreach ( $data as $value ) {
71
+ if ( is_array( $value ) && isset( $value['data'] ) && is_array( $value['data'] ) ) {
72
+ $value = implode( $value['separator'], $value['data'] );
73
+ }
74
+ if ( !is_array( $value ) ) {
75
+ $content .= $value . "\n\n";
76
+ }
77
+ }
78
+ $permalink = get_permalink();
79
+ $akismet = array();
80
+ $akismet['blog'] = get_option( 'home' );
81
+ $akismet['blog_lang'] = get_locale();
82
+ $akismet['blog_charset'] = get_option( 'blog_charset' );
83
+ $akismet['user_ip'] = preg_replace( '/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR'] );
84
+ $akismet['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
85
+ $akismet['referrer'] = $_SERVER['HTTP_REFERER'];
86
+ $akismet['comment_type'] = MWF_Config::NAME;
87
+ if ( $permalink ) $akismet['permalink'] = $permalink;
88
+ if ( $author ) $akismet['comment_author'] = $author;
89
+ if ( $author_email ) $akismet['comment_author_email'] = $author_email;
90
+ if ( $author_url ) $akismet['comment_author_url'] = $author_url;
91
+ if ( $content ) $akismet['comment_content'] = $content;
92
+
93
+ foreach ( $_SERVER as $key => $value ) {
94
+ if ( !in_array( $key, array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' ) ) )
95
+ $akismet[$key] = $value;
96
+ }
97
+
98
+ $query_string = http_build_query( $akismet, null, '&' );
99
+ if ( is_callable( array( 'Akismet', 'http_post' ) ) ) {
100
+ $response = Akismet::http_post( $query_string, 'comment-check' );
101
+ } else {
102
+ $response = akismet_http_post(
103
+ $query_string,
104
+ $akismet_api_host, '/1.1/comment-check',
105
+ $akismet_api_port
106
+ );
107
+ }
108
+ $response = apply_filters( 'mwform_akismet_responce', $response );
109
+ return ( $response[1] == 'true' ) ? true : false;
110
+ }
111
+ }
112
+ }
113
+ ?>
system/mw_wp_form_file.php CHANGED
@@ -3,11 +3,11 @@
3
  * Name: MW WP Form File
4
  * URI: http://2inc.org
5
  * Description: Tempディレクトリ、ファイルアップロードの処理を行うクラス
6
- * Version: 1.0.4
7
  * Author: Takashi Kitajima
8
  * Author URI: http://2inc.org
9
  * Created : October 10, 2013
10
- * Modified: January 7, 2014
11
  * License: GPL2
12
  *
13
  * Copyright 2014 Takashi Kitajima (email : inc@2inc.org)
@@ -31,6 +31,17 @@ class MW_WP_Form_File {
31
  * __construct
32
  */
33
  public function __construct() {
 
 
 
 
 
 
 
 
 
 
 
34
  }
35
 
36
  /**
3
  * Name: MW WP Form File
4
  * URI: http://2inc.org
5
  * Description: Tempディレクトリ、ファイルアップロードの処理を行うクラス
6
+ * Version: 1.0.5
7
  * Author: Takashi Kitajima
8
  * Author URI: http://2inc.org
9
  * Created : October 10, 2013
10
+ * Modified: April 29, 2014
11
  * License: GPL2
12
  *
13
  * Copyright 2014 Takashi Kitajima (email : inc@2inc.org)
31
  * __construct
32
  */
33
  public function __construct() {
34
+ add_filter( 'upload_mimes', array( $this, 'upload_mimes' ) );
35
+ }
36
+
37
+ /**
38
+ * upload_mimes
39
+ */
40
+ public function upload_mimes( $t ) {
41
+ $t['psd'] = 'image/vnd.adobe.photoshop';
42
+ $t['eps'] = 'application/octet-stream';
43
+ $t['ai'] = 'application/pdf';
44
+ return $t;
45
  }
46
 
47
  /**