Version Description
- Refactoring
- Bug fix : Fixed a mwform_tracking_number_title filter hook bug.
- Bug fix : Fixed a bug that can not set the more than 2 default values of the checkbox.
- Bug fix : Fixed a bug that double quotation of shortcodes are escaped in manual form.
- Changed : Class name changed MW_Form_Field to MW_WP_Form_Abstract_Form_Field.
- Changed : Class name changed MW_Validation_Rule to MW_WP_Form_Abstract_Validation_Rule.
- Changed : Zip or Tel validation can use Japanese only.
- Changed : Zip or Tel field can use Japanese only.
- Added : You can set a different value in the key and display value for children of checkbox, select, radio. For xample, [mwform_checkbox name="hoge" children="key1:value1,key2:value2"]
Download this release
Release Info
Developer | inc2734 |
Plugin | MW WP Form |
Version | 2.2.0 |
Comparing to | |
See all releases |
Code changes from version 2.1.3 to 2.2.0
- system/mwf_config.php → classes/config.php +24 -7
- classes/controllers/class.admin-list.php +58 -0
- classes/controllers/class.admin.php +234 -0
- classes/controllers/class.chart.php +176 -0
- classes/controllers/class.contact-data-list.php +309 -0
- classes/controllers/class.contact-data.php +122 -0
- classes/controllers/class.main.php +316 -0
- classes/form-fields/class.akismet_error.php +65 -0
- form_fields/mw_form_field_back_button.php → classes/form-fields/class.back-button.php +20 -19
- form_fields/mw_form_field_button.php → classes/form-fields/class.button.php +20 -19
- form_fields/mw_form_field_checkbox.php → classes/form-fields/class.checkbox.php +31 -27
- form_fields/mw_form_field_confirm_button.php → classes/form-fields/class.confirm-button.php +20 -19
- form_fields/mw_form_field_datepicker.php → classes/form-fields/class.datepicker.php +27 -24
- form_fields/mw_form_field_error.php → classes/form-fields/class.error.php +20 -19
- form_fields/mw_form_field_file.php → classes/form-fields/class.file.php +26 -24
- form_fields/mw_form_field_hidden.php → classes/form-fields/class.hidden.php +17 -17
- form_fields/mw_form_field_image.php → classes/form-fields/class.image.php +26 -24
- form_fields/mw_form_field_password.php → classes/form-fields/class.password.php +24 -22
- form_fields/mw_form_field_radio.php → classes/form-fields/class.radio.php +29 -26
- form_fields/mw_form_field_select.php → classes/form-fields/class.select.php +28 -25
- form_fields/mw_form_field_submit_button.php → classes/form-fields/class.submit-button.php +20 -19
- form_fields/mw_form_field_submit.php → classes/form-fields/class.submit.php +20 -19
- form_fields/mw_form_field_tel.php → classes/form-fields/class.tel.php +25 -23
- form_fields/mw_form_field_text.php → classes/form-fields/class.text.php +25 -23
- form_fields/mw_form_field_textarea.php → classes/form-fields/class.textarea.php +24 -22
- form_fields/mw_form_field_zip.php → classes/form-fields/class.zip.php +25 -23
- classes/functions.php +311 -0
- system/mw_form_field.php → classes/models/class.abstract-form-field.php +169 -70
- classes/models/class.abstract-validation-rule.php +78 -0
- classes/models/class.admin.php +101 -0
- system/mw_akismet.php → classes/models/class.akismet.php +20 -18
- classes/models/class.contact-data-setting.php +230 -0
- classes/models/class.contact-data.php +46 -0
- classes/models/class.data.php +420 -0
- system/mw_error.php → classes/models/class.error.php +18 -17
- classes/models/class.file.php +222 -0
- system/mw_form.php → classes/models/class.form.php +161 -275
- system/mw_mail.php → classes/models/class.mail.php +56 -17
- system/mw_session.php → classes/models/class.session.php +42 -26
- classes/models/class.setting.php +296 -0
- classes/models/class.validation.php +182 -0
- classes/services/class.exec-shortcode.php +226 -0
- classes/services/class.mail.php +477 -0
- classes/services/class.redirected.php +209 -0
- validation_rules/mw_validation_rule_akismet.php → classes/validation-rules/class.akismet.php +11 -9
- validation_rules/mw_validation_rule_alpha.php → classes/validation-rules/class.alpha.php +10 -8
- validation_rules/mw_validation_rule_alphanumeric.php → classes/validation-rules/class.alphanumeric.php +11 -9
- validation_rules/mw_validation_rule_between.php → classes/validation-rules/class.between.php +12 -10
- validation_rules/mw_validation_rule_date.php → classes/validation-rules/class.date.php +18 -10
- validation_rules/mw_validation_rule_eq.php → classes/validation-rules/class.eq.php +11 -9
- validation_rules/mw_validation_rule_filesize.php → classes/validation-rules/class.filesize.php +14 -12
- validation_rules/mw_validation_rule_filetype.php → classes/validation-rules/class.filetype.php +11 -9
- validation_rules/mw_validation_rule_hiragana.php → classes/validation-rules/class.hiragana.php +10 -8
- validation_rules/mw_validation_rule_in.php → classes/validation-rules/class.in.php +10 -8
- validation_rules/mw_validation_rule_katakana.php → classes/validation-rules/class.katakana.php +10 -8
- validation_rules/mw_validation_rule_mail.php → classes/validation-rules/class.mail.php +10 -8
- validation_rules/mw_validation_rule_minlength.php → classes/validation-rules/class.minlength.php +10 -8
- validation_rules/mw_validation_rule_noempty.php → classes/validation-rules/class.noempty.php +10 -8
- validation_rules/mw_validation_rule_nofalse.php → classes/validation-rules/class.nofalse.php +10 -8
- validation_rules/mw_validation_rule_numeric.php → classes/validation-rules/class.numeric.php +10 -8
- validation_rules/mw_validation_rule_required.php → classes/validation-rules/class.required.php +11 -9
- validation_rules/mw_validation_rule_tel.php → classes/validation-rules/class.tel.php +10 -8
- validation_rules/mw_validation_rule_url.php → classes/validation-rules/class.url.php +11 -9
- validation_rules/mw_validation_rule_zip.php → classes/validation-rules/class.zip.php +10 -8
- classes/views/class.admin-list.php +24 -0
- classes/views/class.admin.php +373 -0
- classes/views/class.chart.php +211 -0
- classes/views/class.contact-data-list.php +103 -0
- classes/views/class.contact-data.php +208 -0
- classes/views/class.main.php +319 -0
- classes/views/class.view.php +39 -0
- css/admin.css +8 -1
- form_fields/mw_form_field_akismet_error.php +0 -64
- languages/mw-wp-form-ja.mo +0 -0
- languages/mw-wp-form-ja.po +469 -446
- languages/mw-wp-form.pot +380 -366
- mw-wp-form.php +225 -1087
- readme.txt +17 -3
- system/mw_validation.php +0 -152
- system/mw_validation_rule.php +0 -58
- system/mw_wp_form_admin_page.php +0 -645
- system/mw_wp_form_chart_page.php +0 -337
- system/mw_wp_form_contact_data_page.php +0 -656
- system/mw_wp_form_data.php +0 -187
- system/mw_wp_form_file.php +0 -328
- system/mwf_functions.php +0 -129
system/mwf_config.php → classes/config.php
RENAMED
@@ -1,13 +1,13 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Name:
|
4 |
* Description: 設定ファイル
|
5 |
-
* Version: 1.
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created
|
9 |
-
* Modified:
|
10 |
-
* License: GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
class MWF_Config {
|
@@ -59,4 +59,21 @@ class MWF_Config {
|
|
59 |
* お問い合せ番号用のキー名
|
60 |
*/
|
61 |
const TRACKINGNUMBER = 'tracking_number';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Name : MWF Config
|
4 |
* Description: 設定ファイル
|
5 |
+
* Version : 1.3.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : May 29, 2013
|
9 |
+
* Modified : January 2, 2015
|
10 |
+
* License : GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
class MWF_Config {
|
59 |
* お問い合せ番号用のキー名
|
60 |
*/
|
61 |
const TRACKINGNUMBER = 'tracking_number';
|
62 |
+
|
63 |
+
/**
|
64 |
+
* CONFIRM_BUTTON
|
65 |
+
* 確認ボタンの名前
|
66 |
+
*/
|
67 |
+
const CONFIRM_BUTTON = 'submitConfirm';
|
68 |
+
|
69 |
+
/**
|
70 |
+
* BACK_BUTTON
|
71 |
+
* 戻るボタンの名前
|
72 |
+
*/
|
73 |
+
const BACK_BUTTON = 'submitBack';
|
74 |
+
|
75 |
+
/**
|
76 |
+
* CONTACT_DATA_NAME
|
77 |
+
*/
|
78 |
+
const CONTACT_DATA_NAME = '_mw-wp-form_data';
|
79 |
}
|
classes/controllers/class.admin-list.php
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Name : MW WP Form Admin List Controller
|
4 |
+
* Version : 1.0.0
|
5 |
+
* Author : Takashi Kitajima
|
6 |
+
* Author URI : http://2inc.org
|
7 |
+
* Created : January 1, 2015
|
8 |
+
* Modified :
|
9 |
+
* License : GPLv2
|
10 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
+
*/
|
12 |
+
class MW_WP_Form_Admin_List_Controller {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* initialize
|
16 |
+
*/
|
17 |
+
public function initialize() {
|
18 |
+
add_action( 'admin_head', array( $this, 'add_columns' ) );
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* add_columns
|
23 |
+
*/
|
24 |
+
public function add_columns() {
|
25 |
+
$post_type = get_post_type();
|
26 |
+
if ( $post_type !== MWF_Config::NAME ) {
|
27 |
+
return;
|
28 |
+
}
|
29 |
+
add_filter( 'manage_posts_columns' , array( $this, 'manage_posts_columns' ) );
|
30 |
+
add_action( 'manage_posts_custom_column', array( $this, 'manage_posts_custom_column' ), 10, 2 );
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* manage_posts_columns
|
35 |
+
* @param array $columns
|
36 |
+
* @return array $columns
|
37 |
+
*/
|
38 |
+
public function manage_posts_columns( $columns ) {
|
39 |
+
$date = $columns['date'];
|
40 |
+
unset( $columns['date'] );
|
41 |
+
$columns['mwform_form_key'] = __( 'Form Key', MWF_Config::DOMAIN );
|
42 |
+
$columns['date'] = $date;
|
43 |
+
return $columns;
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* manage_posts_custom_column
|
48 |
+
* @param string $column_name
|
49 |
+
* @param int $post_id
|
50 |
+
*/
|
51 |
+
public function manage_posts_custom_column( $column_name, $post_id ) {
|
52 |
+
$View = new MW_WP_Form_Admin_List_View();
|
53 |
+
$View->set( 'post_id', get_the_ID() );
|
54 |
+
if ( $column_name === 'mwform_form_key' ) {
|
55 |
+
$View->form_key();
|
56 |
+
}
|
57 |
+
}
|
58 |
+
}
|
classes/controllers/class.admin.php
ADDED
@@ -0,0 +1,234 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Name : MW WP Form Admin Controller
|
4 |
+
* Version : 1.0.0
|
5 |
+
* Author : Takashi Kitajima
|
6 |
+
* Author URI : http://2inc.org
|
7 |
+
* Created : December 31, 2014
|
8 |
+
* Modified :
|
9 |
+
* License : GPLv2
|
10 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
+
*/
|
12 |
+
class MW_WP_Form_Admin_Controller {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* $validation_rules
|
16 |
+
* バリデーションルールの配列
|
17 |
+
* @var array
|
18 |
+
*/
|
19 |
+
protected $validation_rules = array();
|
20 |
+
|
21 |
+
/**
|
22 |
+
* __construct
|
23 |
+
* @param array $validation_rules
|
24 |
+
*/
|
25 |
+
public function __construct( array $validation_rules ) {
|
26 |
+
foreach ( $validation_rules as $validation_name => $instance ) {
|
27 |
+
if ( is_callable( array( $instance, 'admin' ) ) ) {
|
28 |
+
$this->validation_rules[$instance->getName()] = $instance;
|
29 |
+
}
|
30 |
+
}
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* initialize
|
35 |
+
*/
|
36 |
+
public function initialize() {
|
37 |
+
$View = new MW_WP_Form_Admin_View();
|
38 |
+
$Admin = new MW_WP_Form_Admin();
|
39 |
+
add_action( 'add_meta_boxes' , array( $this , 'add_meta_boxes' ) );
|
40 |
+
add_action( 'current_screen' , array( $this , 'current_screen' ) );
|
41 |
+
add_filter( 'default_content' , array( $this , 'default_content' ) );
|
42 |
+
add_action( 'media_buttons' , array( $View , 'tag_generator' ) );
|
43 |
+
add_action( 'admin_enqueue_scripts' , array( $this , 'admin_enqueue_scripts' ) );
|
44 |
+
add_action( 'admin_print_footer_scripts', array( $View , 'quicktag' ) );
|
45 |
+
add_action( 'save_post' , array( $Admin, 'save_post' ) );
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* add_meta_boxes
|
50 |
+
*/
|
51 |
+
public function add_meta_boxes() {
|
52 |
+
$post_type = get_post_type();
|
53 |
+
if ( MWF_Config::NAME !== $post_type ) {
|
54 |
+
return;
|
55 |
+
}
|
56 |
+
|
57 |
+
$View = new MW_WP_Form_Admin_View();
|
58 |
+
|
59 |
+
// 完了画面内容
|
60 |
+
$View->set( 'complete_message', $this->get_option( 'complete_message' ) );
|
61 |
+
add_meta_box(
|
62 |
+
MWF_Config::NAME . '_complete_message_metabox',
|
63 |
+
__( 'Complete Message', MWF_Config::DOMAIN ),
|
64 |
+
array( $View, 'complete_message' ),
|
65 |
+
MWF_Config::NAME, 'normal'
|
66 |
+
);
|
67 |
+
|
68 |
+
// 入力画面URL
|
69 |
+
$View->set( 'input_url' , $this->get_option( 'input_url' ) );
|
70 |
+
$View->set( 'confirmation_url' , $this->get_option( 'confirmation_url' ) );
|
71 |
+
$View->set( 'complete_url' , $this->get_option( 'complete_url' ) );
|
72 |
+
$View->set( 'validation_error_url', $this->get_option( 'validation_error_url' ) );
|
73 |
+
add_meta_box(
|
74 |
+
MWF_Config::NAME . '_url',
|
75 |
+
__( 'URL Options', MWF_Config::DOMAIN ),
|
76 |
+
array( $View, 'url' ),
|
77 |
+
MWF_Config::NAME, 'normal'
|
78 |
+
);
|
79 |
+
|
80 |
+
// バリデーション
|
81 |
+
$View->set( 'validation' , $this->get_option( 'validation' ) );
|
82 |
+
$View->set( 'validation_rules', $this->validation_rules );
|
83 |
+
add_meta_box(
|
84 |
+
MWF_Config::NAME . '_validation',
|
85 |
+
__( 'Validation Rule', MWF_Config::DOMAIN ),
|
86 |
+
array( $View, 'validation_rule' ),
|
87 |
+
MWF_Config::NAME, 'normal'
|
88 |
+
);
|
89 |
+
|
90 |
+
// アドオン
|
91 |
+
add_meta_box(
|
92 |
+
MWF_Config::NAME . '_addon',
|
93 |
+
__( 'Add-ons', MWF_Config::DOMAIN ),
|
94 |
+
array( $View, 'add_ons' ),
|
95 |
+
MWF_Config::NAME, 'side'
|
96 |
+
);
|
97 |
+
|
98 |
+
// フォーム識別子
|
99 |
+
$View->set( 'post_id', get_the_ID() );
|
100 |
+
add_meta_box(
|
101 |
+
MWF_Config::NAME . '_formkey',
|
102 |
+
__( 'Form Key', MWF_Config::DOMAIN ),
|
103 |
+
array( $View, 'form_key' ),
|
104 |
+
MWF_Config::NAME, 'side'
|
105 |
+
);
|
106 |
+
|
107 |
+
// 自動返信メール設定
|
108 |
+
$View->set( 'mail_subject' , $this->get_option( 'mail_subject' ) );
|
109 |
+
$View->set( 'mail_sender' , $this->get_option( 'mail_sender' ) );
|
110 |
+
$View->set( 'mail_from' , $this->get_option( 'mail_from' ) );
|
111 |
+
$View->set( 'mail_content' , $this->get_option( 'mail_content' ) );
|
112 |
+
$View->set( 'automatic_reply_email', $this->get_option( 'automatic_reply_email' ) );
|
113 |
+
add_meta_box(
|
114 |
+
MWF_Config::NAME . '_mail',
|
115 |
+
__( 'Automatic Reply Email Options', MWF_Config::DOMAIN ),
|
116 |
+
array( $View, 'mail_options' ),
|
117 |
+
MWF_Config::NAME, 'side'
|
118 |
+
);
|
119 |
+
|
120 |
+
// 管理者メール設定
|
121 |
+
$View->set( 'mail_to' , $this->get_option( 'mail_to' ) );
|
122 |
+
$View->set( 'mail_cc' , $this->get_option( 'mail_cc' ) );
|
123 |
+
$View->set( 'mail_bcc' , $this->get_option( 'mail_bcc' ) );
|
124 |
+
$View->set( 'admin_mail_subject', $this->get_option( 'admin_mail_subject' ) );
|
125 |
+
$View->set( 'admin_mail_sender' , $this->get_option( 'admin_mail_sender' ) );
|
126 |
+
$View->set( 'admin_mail_from' , $this->get_option( 'admin_mail_from' ) );
|
127 |
+
$View->set( 'admin_mail_content', $this->get_option( 'admin_mail_content' ) );
|
128 |
+
add_meta_box(
|
129 |
+
MWF_Config::NAME . '_admin_mail',
|
130 |
+
__( 'Admin Email Options', MWF_Config::DOMAIN ),
|
131 |
+
array( $View, 'admin_mail_options' ),
|
132 |
+
MWF_Config::NAME, 'side'
|
133 |
+
);
|
134 |
+
|
135 |
+
// 設定
|
136 |
+
$View->set( 'querystring' , $this->get_option( 'querystring' ) );
|
137 |
+
$View->set( 'usedb' , $this->get_option( 'usedb' ) );
|
138 |
+
$View->set( 'scroll' , $this->get_option( 'scroll' ) );
|
139 |
+
$View->set( 'akismet_author' , $this->get_option( 'akismet_author' ) );
|
140 |
+
$View->set( 'akismet_author_email', $this->get_option( 'akismet_author_email' ) );
|
141 |
+
$View->set( 'akismet_author_url' , $this->get_option( 'akismet_author_url' ) );
|
142 |
+
add_meta_box(
|
143 |
+
MWF_Config::NAME . '_settings',
|
144 |
+
__( 'settings', MWF_Config::DOMAIN ),
|
145 |
+
array( $View, 'settings' ),
|
146 |
+
MWF_Config::NAME, 'side'
|
147 |
+
);
|
148 |
+
|
149 |
+
// CSS
|
150 |
+
$styles = apply_filters( 'mwform_styles', array() );
|
151 |
+
if ( $styles ) {
|
152 |
+
$View->set( 'styles', $styles );
|
153 |
+
$View->set( 'style' , $this->get_option( 'style' ) );
|
154 |
+
add_meta_box(
|
155 |
+
MWF_Config::NAME . '_styles',
|
156 |
+
__( 'Style setting', MWF_Config::DOMAIN ),
|
157 |
+
array( $View, 'style' ),
|
158 |
+
MWF_Config::NAME, 'side'
|
159 |
+
);
|
160 |
+
}
|
161 |
+
}
|
162 |
+
|
163 |
+
/**
|
164 |
+
* current_screen
|
165 |
+
* 寄付リンクを表示
|
166 |
+
* @param WP_Screen $screen
|
167 |
+
*/
|
168 |
+
public function current_screen( $screen ) {
|
169 |
+
$View = new MW_WP_Form_Admin_View();
|
170 |
+
if ( $screen->id === 'edit-' . MWF_Config::NAME ) {
|
171 |
+
add_filter( 'views_' . $screen->id, array( $View, 'donate_link' ) );
|
172 |
+
}
|
173 |
+
}
|
174 |
+
|
175 |
+
/**
|
176 |
+
* default_content
|
177 |
+
* 本文の初期値を設定
|
178 |
+
* @param string $content
|
179 |
+
* @return string
|
180 |
+
*/
|
181 |
+
public function default_content( $content ) {
|
182 |
+
global $typenow;
|
183 |
+
if ( $typenow === MWF_Config::NAME ) {
|
184 |
+
return apply_filters( 'mwform_default_content', '' );
|
185 |
+
}
|
186 |
+
}
|
187 |
+
|
188 |
+
/**
|
189 |
+
* get_option
|
190 |
+
* フォームの設定データを返す
|
191 |
+
* @param string $key 設定データのキー
|
192 |
+
* @return mixed 設定データ
|
193 |
+
*/
|
194 |
+
protected function get_option( $key ) {
|
195 |
+
global $post;
|
196 |
+
$Setting = new MW_WP_Form_Setting( $post->ID );
|
197 |
+
$value = $Setting->get( $key );
|
198 |
+
if ( !is_null( $value ) ) {
|
199 |
+
return $value;
|
200 |
+
} else {
|
201 |
+
$date = $post->post_date;
|
202 |
+
$modified = $post->post_modified;
|
203 |
+
if ( $date === $modified ){
|
204 |
+
return apply_filters( 'mwform_default_settings', '', $key );
|
205 |
+
}
|
206 |
+
}
|
207 |
+
}
|
208 |
+
|
209 |
+
/**
|
210 |
+
* admin_enqueue_scripts
|
211 |
+
*/
|
212 |
+
public function admin_enqueue_scripts() {
|
213 |
+
$post_type = get_post_type();
|
214 |
+
$url = plugin_dir_url( __FILE__ );
|
215 |
+
if ( isset( $_GET['post_type'] ) && MWF_Config::NAME === $_GET['post_type'] ||
|
216 |
+
MWF_Config::NAME == $post_type ) {
|
217 |
+
wp_enqueue_style( MWF_Config::NAME . '-admin', $url . '../../css/admin.css' );
|
218 |
+
}
|
219 |
+
if ( MWF_Config::NAME === $post_type ) {
|
220 |
+
wp_enqueue_script( MWF_Config::NAME . '-repeatable', $url . '../../js/mw-wp-form-repeatable.js' );
|
221 |
+
wp_enqueue_script( MWF_Config::NAME . '-admin', $url . '../../js/admin.js' );
|
222 |
+
wp_enqueue_script( 'jquery-ui-dialog' );
|
223 |
+
|
224 |
+
global $wp_scripts;
|
225 |
+
$ui = $wp_scripts->query( 'jquery-ui-core' );
|
226 |
+
wp_enqueue_style(
|
227 |
+
'jquery.ui',
|
228 |
+
'//ajax.googleapis.com/ajax/libs/jqueryui/' . $ui->ver . '/themes/smoothness/jquery-ui.min.css',
|
229 |
+
array(),
|
230 |
+
$ui->ver
|
231 |
+
);
|
232 |
+
}
|
233 |
+
}
|
234 |
+
}
|
classes/controllers/class.chart.php
ADDED
@@ -0,0 +1,176 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Name : MW WP Form Chart Controller
|
4 |
+
* Version : 1.0.0
|
5 |
+
* Author : Takashi Kitajima
|
6 |
+
* Author URI : http://2inc.org
|
7 |
+
* Created : January 1, 2015
|
8 |
+
* Modified :
|
9 |
+
* License : GPLv2
|
10 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
+
*/
|
12 |
+
class MW_WP_Form_Chart_Controller {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* $formkey
|
16 |
+
* URL引数で渡される、そのグラフに使う投稿タイプ名
|
17 |
+
* @var string
|
18 |
+
*/
|
19 |
+
protected $formkey;
|
20 |
+
|
21 |
+
/**
|
22 |
+
* $postdata
|
23 |
+
* フォームの設定データ
|
24 |
+
* @var array
|
25 |
+
*/
|
26 |
+
protected $postdata = array();
|
27 |
+
|
28 |
+
/**
|
29 |
+
* $option_group
|
30 |
+
* Settings API グループ名
|
31 |
+
* @var string
|
32 |
+
*/
|
33 |
+
protected $option_group;
|
34 |
+
|
35 |
+
/**
|
36 |
+
* __construct
|
37 |
+
*/
|
38 |
+
public function __construct() {
|
39 |
+
$this->option_group = MWF_Config::NAME . '-' . 'chart-group';
|
40 |
+
if ( !empty( $_GET['formkey'] ) ) {
|
41 |
+
$this->formkey = $_GET['formkey'];
|
42 |
+
}
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* initialize
|
47 |
+
*/
|
48 |
+
public function initialize() {
|
49 |
+
add_action( 'admin_menu' , array( $this, 'admin_menu' ) );
|
50 |
+
add_action( 'admin_init' , array( $this, 'register_setting' ) );
|
51 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts') );
|
52 |
+
add_action( 'admin_print_styles' , array( $this, 'admin_print_styles' ) );
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* admin_menu
|
57 |
+
*/
|
58 |
+
public function admin_menu() {
|
59 |
+
$View = new MW_WP_Form_Chart_View();
|
60 |
+
$View->set( 'is_chart' , $this->is_chart() );
|
61 |
+
$View->set( 'post_type', $this->formkey );
|
62 |
+
$View->set( 'option_group', $this->option_group );
|
63 |
+
add_submenu_page(
|
64 |
+
'edit.php?post_type=' . MWF_Config::NAME,
|
65 |
+
esc_html__( 'Chart', MWF_Config::DOMAIN ),
|
66 |
+
esc_html__( 'Chart', MWF_Config::DOMAIN ),
|
67 |
+
MWF_Config::CAPABILITY,
|
68 |
+
MWF_Config::NAME . '-chart',
|
69 |
+
array( $View, 'index' )
|
70 |
+
);
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* admin_print_styles
|
75 |
+
*/
|
76 |
+
public function admin_print_styles() {
|
77 |
+
$View = new MW_WP_Form_Chart_View();
|
78 |
+
$View->admin_print_styles();
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* admin_enqueue_scripts
|
83 |
+
*/
|
84 |
+
public function admin_enqueue_scripts() {
|
85 |
+
if ( !$this->is_chart() ) {
|
86 |
+
return;
|
87 |
+
}
|
88 |
+
global $wp_scripts;
|
89 |
+
$ui = $wp_scripts->query( 'jquery-ui-core' );
|
90 |
+
wp_enqueue_style(
|
91 |
+
'jquery.ui',
|
92 |
+
'//ajax.googleapis.com/ajax/libs/jqueryui/' . $ui->ver . '/themes/smoothness/jquery-ui.min.css',
|
93 |
+
array( 'jquery' ),
|
94 |
+
$ui->ver
|
95 |
+
);
|
96 |
+
wp_enqueue_script( 'jquery-ui-sortable' );
|
97 |
+
|
98 |
+
$url = plugin_dir_url( __FILE__ );
|
99 |
+
|
100 |
+
wp_register_script( 'jsapi', 'https://www.google.com/jsapi' );
|
101 |
+
wp_enqueue_script( 'jsapi' );
|
102 |
+
|
103 |
+
wp_register_script(
|
104 |
+
MWF_Config::NAME . '-repeatable',
|
105 |
+
$url . '../../js/mw-wp-form-repeatable.js',
|
106 |
+
array( 'jquery' ),
|
107 |
+
null,
|
108 |
+
true
|
109 |
+
);
|
110 |
+
wp_enqueue_script( MWF_Config::NAME . '-repeatable' );
|
111 |
+
|
112 |
+
wp_register_script(
|
113 |
+
MWF_Config::NAME . '-google-chart',
|
114 |
+
$url . '../../js/mw-wp-form-google-chart.js',
|
115 |
+
array( 'jquery' ),
|
116 |
+
null,
|
117 |
+
true
|
118 |
+
);
|
119 |
+
wp_enqueue_script( MWF_Config::NAME . '-google-chart' );
|
120 |
+
|
121 |
+
wp_register_script(
|
122 |
+
MWF_Config::NAME . '-admin-chart',
|
123 |
+
$url . '../../js/admin-chart.js',
|
124 |
+
array( 'jquery', 'jquery-ui-sortable' ),
|
125 |
+
null,
|
126 |
+
true
|
127 |
+
);
|
128 |
+
wp_enqueue_script( MWF_Config::NAME . '-admin-chart' );
|
129 |
+
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* register_setting
|
133 |
+
*/
|
134 |
+
public function register_setting() {
|
135 |
+
if ( !empty( $this->formkey ) ) {
|
136 |
+
$formkey = $this->formkey;
|
137 |
+
} elseif ( !empty( $_POST[MWF_Config::NAME . '-formkey'] ) ) {
|
138 |
+
$formkey = $_POST[MWF_Config::NAME . '-formkey'];
|
139 |
+
}
|
140 |
+
if ( !empty( $formkey ) ) {
|
141 |
+
register_setting(
|
142 |
+
$this->option_group,
|
143 |
+
MWF_Config::NAME . '-chart-' . $formkey,
|
144 |
+
array( $this, 'sanitize' )
|
145 |
+
);
|
146 |
+
}
|
147 |
+
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
* sanitize
|
151 |
+
* @param array $input フォームから送信されたデータ
|
152 |
+
* @return array
|
153 |
+
*/
|
154 |
+
public function sanitize( $input ) {
|
155 |
+
$new_input = array();
|
156 |
+
if ( is_array( $input ) && isset( $input['chart'] ) && is_array( $input['chart'] ) ) {
|
157 |
+
foreach ( $input['chart'] as $key => $value ) {
|
158 |
+
if ( !empty( $value['target'] ) ) {
|
159 |
+
$new_input['chart'][$key] = $value;
|
160 |
+
}
|
161 |
+
}
|
162 |
+
}
|
163 |
+
return $new_input;
|
164 |
+
}
|
165 |
+
|
166 |
+
/**
|
167 |
+
* is_chart
|
168 |
+
* @return bool
|
169 |
+
*/
|
170 |
+
protected function is_chart() {
|
171 |
+
if ( isset( $_GET['page'] ) && $_GET['page'] === 'mw-wp-form-chart' && $this->formkey ) {
|
172 |
+
return true;
|
173 |
+
}
|
174 |
+
return false;
|
175 |
+
}
|
176 |
+
}
|
classes/controllers/class.contact-data-list.php
ADDED
@@ -0,0 +1,309 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Name : MW WP Form Contact Data List Controller
|
4 |
+
* Version : 1.0.0
|
5 |
+
* Author : Takashi Kitajima
|
6 |
+
* Author URI : http://2inc.org
|
7 |
+
* Created : January 1, 2015
|
8 |
+
* Modified :
|
9 |
+
* License : GPLv2
|
10 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
+
*/
|
12 |
+
class MW_WP_Form_Contact_Data_List_Controller {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* initialize
|
16 |
+
*/
|
17 |
+
public function initialize() {
|
18 |
+
add_action( 'wp_loaded' , array( $this, 'csv_download' ) );
|
19 |
+
add_action( 'admin_head' , array( $this, 'add_columns' ) );
|
20 |
+
add_action( 'admin_print_styles', array( $this, 'admin_print_styles' ) );
|
21 |
+
add_action( 'in_admin_footer' , array( $this, 'add_csv_download_button' ) );
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* admin_print_styles
|
26 |
+
* DB登録データの一覧で新規追加のリンクを消す
|
27 |
+
*/
|
28 |
+
public function admin_print_styles() {
|
29 |
+
if ( !$this->is_contact_data_list() ) {
|
30 |
+
return;
|
31 |
+
}
|
32 |
+
$View = new MW_WP_Form_Contact_Data_List_View();
|
33 |
+
$View->admin_print_styles_for_list();
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* add_csv_download_button
|
38 |
+
* CSVダウンロードボタンを表示
|
39 |
+
*/
|
40 |
+
public function add_csv_download_button() {
|
41 |
+
if ( !$this->is_contact_data_list() ) {
|
42 |
+
return;
|
43 |
+
}
|
44 |
+
$post_type = get_post_type();
|
45 |
+
if ( true !== apply_filters( 'mwform_csv_button_' . $post_type, true ) ) {
|
46 |
+
return;
|
47 |
+
}
|
48 |
+
$page = ( basename( $_SERVER['PHP_SELF'] ) );
|
49 |
+
if ( $page !== 'edit.php' ) {
|
50 |
+
return;
|
51 |
+
}
|
52 |
+
$action = $_SERVER['REQUEST_URI'];
|
53 |
+
$View = new MW_WP_Form_Contact_Data_List_View();
|
54 |
+
$View->set( 'action', $action );
|
55 |
+
$View->csv_button();
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* csv_download
|
60 |
+
* CSVを生成、出力
|
61 |
+
*/
|
62 |
+
public function csv_download() {
|
63 |
+
if ( !$this->is_contact_data_list() ) {
|
64 |
+
return;
|
65 |
+
}
|
66 |
+
if ( !isset( $_GET['post_type'] ) ) {
|
67 |
+
return ;
|
68 |
+
}
|
69 |
+
|
70 |
+
$post_type = $_GET['post_type'];
|
71 |
+
$key_of_csv_download = MWF_Config::NAME . '-csv-download';
|
72 |
+
|
73 |
+
if ( !isset( $_POST[$key_of_csv_download] ) || !check_admin_referer( MWF_Config::NAME ) ) {
|
74 |
+
return;
|
75 |
+
}
|
76 |
+
|
77 |
+
$posts_per_page = $this->get_posts_per_page();
|
78 |
+
$paged = $this->get_paged();
|
79 |
+
|
80 |
+
$posts_mwf = get_posts( array(
|
81 |
+
'post_type' => $post_type,
|
82 |
+
'posts_per_page' => $posts_per_page,
|
83 |
+
'paged' => $paged,
|
84 |
+
'post_status' => 'any',
|
85 |
+
) );
|
86 |
+
|
87 |
+
// CSVの内容を貯める
|
88 |
+
$csv = '';
|
89 |
+
|
90 |
+
// 見出しを追加
|
91 |
+
$rows[0] = $this->get_csv_headings( $posts_mwf );
|
92 |
+
|
93 |
+
// 各データを追加
|
94 |
+
$rows = array_merge( $rows, $this->get_rows( $posts_mwf, $rows[0] ) );
|
95 |
+
|
96 |
+
// エンコード
|
97 |
+
foreach ( $rows as $key => $row ) {
|
98 |
+
foreach ( $row as $column_name => $column ) {
|
99 |
+
$row[$column_name] = $this->escape_double_quote( $column );
|
100 |
+
}
|
101 |
+
$csv .= implode( ',', $row ) . "\r\n";
|
102 |
+
}
|
103 |
+
$csv = mb_convert_encoding( $csv, 'sjis-win', get_option( 'blog_charset' ) );
|
104 |
+
|
105 |
+
$file_name = 'mw_wp_form_' . date( 'YmdHis' ) . '.csv';
|
106 |
+
header( 'Content-Type: application/octet-stream' );
|
107 |
+
header( 'Content-Disposition: attachment; filename=' . $file_name );
|
108 |
+
echo $csv;
|
109 |
+
exit;
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* get_csv_headings
|
114 |
+
* @param array $posts
|
115 |
+
* @return array
|
116 |
+
*/
|
117 |
+
protected function get_csv_headings( array $posts ) {
|
118 |
+
$default_headings = array(
|
119 |
+
'ID',
|
120 |
+
__( 'Response Status', MWF_Config::DOMAIN ),
|
121 |
+
'post_date',
|
122 |
+
'post_modified',
|
123 |
+
'post_title'
|
124 |
+
);
|
125 |
+
$rows[] = $default_headings;
|
126 |
+
$columns = array();
|
127 |
+
foreach ( $posts as $post ) {
|
128 |
+
$post_type = get_post_type( $post->ID );
|
129 |
+
$post_custom_keys = get_post_custom_keys( $post->ID );
|
130 |
+
$columns = array();
|
131 |
+
if ( !is_array( $post_custom_keys ) ) {
|
132 |
+
continue;
|
133 |
+
}
|
134 |
+
foreach ( $post_custom_keys as $key ) {
|
135 |
+
if ( preg_match( '/^_/', $key ) ) {
|
136 |
+
continue;
|
137 |
+
}
|
138 |
+
if ( $key === MWF_Config::TRACKINGNUMBER ) {
|
139 |
+
$column = MWF_Functions::get_tracking_number_title( $post_type );
|
140 |
+
} else {
|
141 |
+
$column = $key;
|
142 |
+
}
|
143 |
+
$columns[$key] = $column;
|
144 |
+
}
|
145 |
+
}
|
146 |
+
$rows[0] = array_merge( $rows[0], $columns );
|
147 |
+
$rows[0] = array_merge( $rows[0], array( __( 'Memo', MWF_Config::DOMAIN ) ) );
|
148 |
+
return $rows[0];
|
149 |
+
}
|
150 |
+
|
151 |
+
/**
|
152 |
+
* get_rows
|
153 |
+
* @param array $posts
|
154 |
+
* @param array $headings
|
155 |
+
* @return array
|
156 |
+
*/
|
157 |
+
protected function get_rows( array $posts, array $headings ) {
|
158 |
+
global $post;
|
159 |
+
$rows = array();
|
160 |
+
foreach ( $posts as $post ) {
|
161 |
+
setup_postdata( $post );
|
162 |
+
$columns = array();
|
163 |
+
foreach ( $headings as $key => $value ) {
|
164 |
+
$Contact_Data_Setting = new MW_WP_Form_Contact_Data_Setting( $post->ID );
|
165 |
+
$response_statuses = $Contact_Data_Setting->get_response_statuses();
|
166 |
+
$column = '';
|
167 |
+
if ( $value === __( 'Response Status', MWF_Config::DOMAIN ) ) {
|
168 |
+
$response_status = $Contact_Data_Setting->get( 'response_status' );
|
169 |
+
$column = $response_statuses[$response_status];
|
170 |
+
} elseif ( $value === __( 'Memo', MWF_Config::DOMAIN ) ) {
|
171 |
+
$column = $Contact_Data_Setting->get( 'memo' );
|
172 |
+
} elseif ( isset( $post->$value ) ) {
|
173 |
+
$post_meta = $post->$value;
|
174 |
+
if ( $Contact_Data_Setting->is_upload_file_key( $post, $value ) ) {
|
175 |
+
$column = wp_get_attachment_url( $post_meta );
|
176 |
+
} else {
|
177 |
+
$column = ( $post_meta ) ? $post_meta : '';
|
178 |
+
}
|
179 |
+
}
|
180 |
+
$columns[$key] = $column;
|
181 |
+
}
|
182 |
+
$rows[] = $columns;
|
183 |
+
}
|
184 |
+
wp_reset_postdata();
|
185 |
+
return $rows;
|
186 |
+
}
|
187 |
+
|
188 |
+
/**
|
189 |
+
* escape_double_quote
|
190 |
+
* @param string $value
|
191 |
+
* @return string
|
192 |
+
*/
|
193 |
+
protected function escape_double_quote( $value ) {
|
194 |
+
$value = str_replace( '"', '""', $value );
|
195 |
+
return '"' . $value . '"';
|
196 |
+
}
|
197 |
+
|
198 |
+
/**
|
199 |
+
* get_posts_per_page
|
200 |
+
* @return int
|
201 |
+
*/
|
202 |
+
protected function get_posts_per_page() {
|
203 |
+
$posts_per_page = -1;
|
204 |
+
if ( ( isset( $_POST['download-all'] ) && $_POST['download-all'] === 'true' ) === false ) {
|
205 |
+
$current_user = wp_get_current_user();
|
206 |
+
$_posts_per_page = get_user_meta( $current_user->ID, 'edit_' . $post_type . '_per_page', true );
|
207 |
+
if ( !empty( $_posts_per_page ) ) {
|
208 |
+
$posts_per_page = $_posts_per_page;
|
209 |
+
}
|
210 |
+
}
|
211 |
+
return $posts_per_page;
|
212 |
+
}
|
213 |
+
|
214 |
+
/**
|
215 |
+
* get_paged
|
216 |
+
* @return int
|
217 |
+
*/
|
218 |
+
protected function get_paged() {
|
219 |
+
$posts_per_page = $this->get_posts_per_page();
|
220 |
+
$paged = 1;
|
221 |
+
if ( isset( $_GET['paged'] ) ) {
|
222 |
+
$_paged = $_GET['paged'];
|
223 |
+
if ( MWF_Functions::is_numeric( $_paged ) && $posts_per_page > 0 ) {
|
224 |
+
$paged = $_paged;
|
225 |
+
}
|
226 |
+
}
|
227 |
+
return $paged;
|
228 |
+
}
|
229 |
+
|
230 |
+
/**
|
231 |
+
* add_columns
|
232 |
+
* DB登録使用時に問い合わせデータ一覧にカラムを追加
|
233 |
+
*/
|
234 |
+
public function add_columns() {
|
235 |
+
if ( !$this->is_contact_data_list() ) {
|
236 |
+
return;
|
237 |
+
}
|
238 |
+
$post_type = get_post_type();
|
239 |
+
add_filter(
|
240 |
+
'manage_' . $post_type . '_posts_columns',
|
241 |
+
array( $this, 'add_form_columns_name' )
|
242 |
+
);
|
243 |
+
add_action(
|
244 |
+
'manage_' . $post_type . '_posts_custom_column',
|
245 |
+
array( $this, 'add_form_columns' ),
|
246 |
+
10,
|
247 |
+
2
|
248 |
+
);
|
249 |
+
}
|
250 |
+
|
251 |
+
/**
|
252 |
+
* add_form_columns_name
|
253 |
+
* @param array $columns
|
254 |
+
* @return array $columns
|
255 |
+
*/
|
256 |
+
public function add_form_columns_name( $columns ) {
|
257 |
+
global $posts;
|
258 |
+
unset( $columns['date'] );
|
259 |
+
$columns['post_date'] = __( 'Registed Date', MWF_Config::DOMAIN );
|
260 |
+
$columns['response_status'] = __( 'Response Status', MWF_Config::DOMAIN );
|
261 |
+
foreach ( $posts as $post ) {
|
262 |
+
$post_custom_keys = get_post_custom_keys( $post->ID );
|
263 |
+
if ( ! empty( $post_custom_keys ) && is_array( $post_custom_keys ) ) {
|
264 |
+
foreach ( $post_custom_keys as $key ) {
|
265 |
+
if ( preg_match( '/^_/', $key ) ) {
|
266 |
+
continue;
|
267 |
+
}
|
268 |
+
if ( $key === MWF_Config::TRACKINGNUMBER ) {
|
269 |
+
$columns[$key] = MWF_Functions::get_tracking_number_title( get_post_type( $post->ID ) );
|
270 |
+
continue;
|
271 |
+
}
|
272 |
+
$columns[$key] = $key;
|
273 |
+
}
|
274 |
+
}
|
275 |
+
}
|
276 |
+
return $columns;
|
277 |
+
}
|
278 |
+
|
279 |
+
/**
|
280 |
+
* add_form_columns_name
|
281 |
+
* @param string $column カラム名
|
282 |
+
* @param int $post_id
|
283 |
+
*/
|
284 |
+
public function add_form_columns( $column, $post_id ) {
|
285 |
+
$post_custom_keys = get_post_custom_keys( $post_id );
|
286 |
+
$Contact_Data_Setting = new MW_WP_Form_Contact_Data_Setting( $post_id );
|
287 |
+
$View = new MW_WP_Form_Contact_Data_List_View();
|
288 |
+
$View->set( 'column', $column );
|
289 |
+
$View->set( 'post_id', $post_id );
|
290 |
+
$View->set( 'post_custom_keys', $post_custom_keys );
|
291 |
+
$View->set( 'Contact_Data_Setting', $Contact_Data_Setting );
|
292 |
+
$View->manage_posts_custom_column();
|
293 |
+
}
|
294 |
+
|
295 |
+
/**
|
296 |
+
* is_contact_data_list
|
297 |
+
* @return bool
|
298 |
+
*/
|
299 |
+
protected function is_contact_data_list() {
|
300 |
+
if ( isset( $_GET['post_type'] ) ) {
|
301 |
+
$post_type = $_GET['post_type'];
|
302 |
+
$contact_data_post_types = MW_WP_Form_Contact_Data_Setting::get_posts();
|
303 |
+
if ( in_array( $post_type, $contact_data_post_types ) ) {
|
304 |
+
return true;
|
305 |
+
}
|
306 |
+
}
|
307 |
+
return false;
|
308 |
+
}
|
309 |
+
}
|
classes/controllers/class.contact-data.php
ADDED
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Name : MW WP Form Contact Data Controller
|
4 |
+
* Version : 1.0.0
|
5 |
+
* Author : Takashi Kitajima
|
6 |
+
* Author URI : http://2inc.org
|
7 |
+
* Created : December 31, 2014
|
8 |
+
* Modified :
|
9 |
+
* License : GPLv2
|
10 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
+
*/
|
12 |
+
class MW_WP_Form_Contact_Data_Controller {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* $contact_data_post_types
|
16 |
+
* @var array
|
17 |
+
*/
|
18 |
+
protected $contact_data_post_types = array();
|
19 |
+
|
20 |
+
/**
|
21 |
+
* initialize
|
22 |
+
*/
|
23 |
+
public function initialize() {
|
24 |
+
$this->contact_data_post_types = MW_WP_Form_Contact_Data_Setting::get_posts();
|
25 |
+
$Contact_Data = new MW_WP_Form_Contact_Data();
|
26 |
+
add_action( 'admin_menu' , array( $this, 'admin_menu' ) );
|
27 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
|
28 |
+
add_action( 'add_meta_boxes' , array( $this, 'add_meta_boxes' ) );
|
29 |
+
add_action( 'admin_print_styles' , array( $this, 'admin_print_styles' ) );
|
30 |
+
add_action( 'edit_form_top' , array( $this, 'edit_form_top' ) );
|
31 |
+
add_action( 'save_post' , array( $Contact_Data, 'save_post' ) );
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* admin_menu
|
36 |
+
* 問い合わせデータ閲覧ページへのメニューを追加
|
37 |
+
*/
|
38 |
+
public function admin_menu() {
|
39 |
+
$View = new MW_WP_Form_Contact_Data_View();
|
40 |
+
$View->set( 'contact_data_post_types', $this->contact_data_post_types );
|
41 |
+
add_submenu_page(
|
42 |
+
'edit.php?post_type=' . MWF_Config::NAME,
|
43 |
+
__( 'Inquiry data', MWF_Config::DOMAIN ), // ページタイトル
|
44 |
+
__( 'Inquiry data', MWF_Config::DOMAIN ), // メニュー名
|
45 |
+
MWF_Config::CAPABILITY, // 権限
|
46 |
+
MWF_Config::NAME . '-save-data', // 画面のパス
|
47 |
+
array( $View, 'index' ) // 表示用の関数
|
48 |
+
);
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* admin_enqueue_scripts
|
53 |
+
* 本当は css, js のロードだけしたいけど、ここからしか post_id がとれないので渋々…
|
54 |
+
*/
|
55 |
+
public function admin_enqueue_scripts() {
|
56 |
+
if ( !$this->is_contact_data_post_type() ) {
|
57 |
+
return;
|
58 |
+
}
|
59 |
+
$url = plugin_dir_url( __FILE__ );
|
60 |
+
wp_enqueue_style( MWF_Config::NAME . '-admin', $url . '../../css/admin.css' );
|
61 |
+
wp_enqueue_script( MWF_Config::NAME . '-admin-data', $url . '../../js/admin-data.js' );
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* admin_print_styles
|
66 |
+
* 詳細画面で新規追加のリンクを消す
|
67 |
+
*/
|
68 |
+
public function admin_print_styles() {
|
69 |
+
if ( !$this->is_contact_data_post_type() ) {
|
70 |
+
return;
|
71 |
+
}
|
72 |
+
$View = new MW_WP_Form_Contact_Data_View();
|
73 |
+
$View->admin_print_styles_for_detail();
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* add_meta_boxes
|
78 |
+
*/
|
79 |
+
public function add_meta_boxes() {
|
80 |
+
if ( !$this->is_contact_data_post_type() ) {
|
81 |
+
return;
|
82 |
+
}
|
83 |
+
$post_type = get_post_type();
|
84 |
+
$View = new MW_WP_Form_Contact_Data_View();
|
85 |
+
$View->set( 'post_type', $post_type );
|
86 |
+
$View->set( 'Contact_Data_Setting', new MW_WP_Form_Contact_Data_Setting( get_the_ID() ) );
|
87 |
+
add_meta_box(
|
88 |
+
substr( MWF_Config::CONTACT_DATA_NAME, 1 ) . '_custom_fields',
|
89 |
+
__( 'Custom Fields', MWF_Config::DOMAIN ),
|
90 |
+
array( $View, 'detail' ),
|
91 |
+
$post_type
|
92 |
+
);
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* edit_form_top
|
97 |
+
* 問い合わせデータ詳細画面で一覧に戻るリンクを表示
|
98 |
+
* @param object $post
|
99 |
+
*/
|
100 |
+
public function edit_form_top( $post ) {
|
101 |
+
if ( !$this->is_contact_data_post_type() ) {
|
102 |
+
return;
|
103 |
+
}
|
104 |
+
$post_type = get_post_type();
|
105 |
+
$link = admin_url( '/edit.php?post_type=' . $post_type );
|
106 |
+
$View = new MW_WP_Form_Contact_Data_View();
|
107 |
+
$View->set( 'link', $link );
|
108 |
+
$View->returning_link();
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* is_contact_data_post_type
|
113 |
+
*/
|
114 |
+
protected function is_contact_data_post_type() {
|
115 |
+
$post_type = get_post_type();
|
116 |
+
if ( is_array( $this->contact_data_post_types ) &&
|
117 |
+
in_array( $post_type, $this->contact_data_post_types ) ) {
|
118 |
+
return true;
|
119 |
+
}
|
120 |
+
return false;
|
121 |
+
}
|
122 |
+
}
|
classes/controllers/class.main.php
ADDED
@@ -0,0 +1,316 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Name : MW WP Form Main Controller
|
4 |
+
* Description: フロントエンドにおいて、適切な画面にリダイレクトさせる
|
5 |
+
* Version : 1.0.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : December 23, 2014
|
9 |
+
* Modified :
|
10 |
+
* License : GPLv2
|
11 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
+
*/
|
13 |
+
class MW_WP_Form_Main_Controller {
|
14 |
+
|
15 |
+
/**
|
16 |
+
* $Data
|
17 |
+
* @var MW_WP_Form_Data
|
18 |
+
*/
|
19 |
+
protected $Data;
|
20 |
+
|
21 |
+
/**
|
22 |
+
* $ExecShortcode
|
23 |
+
* @var MW_WP_Form_Exec_Shortcode
|
24 |
+
*/
|
25 |
+
protected $ExecShortcode;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* $Redirected
|
29 |
+
* @var MW_WP_Form_Redrected
|
30 |
+
*/
|
31 |
+
protected $Redirected;
|
32 |
+
|
33 |
+
/**
|
34 |
+
* $Setting
|
35 |
+
* @var MW_WP_Form_Setting
|
36 |
+
*/
|
37 |
+
protected $Setting;
|
38 |
+
|
39 |
+
/**
|
40 |
+
* $validation_rules
|
41 |
+
* @var array
|
42 |
+
*/
|
43 |
+
protected $validation_rules = array();
|
44 |
+
|
45 |
+
/**
|
46 |
+
* __construct
|
47 |
+
* @param array $validation_rules
|
48 |
+
*/
|
49 |
+
public function __construct( array $validation_rules ) {
|
50 |
+
$this->validation_rules = $validation_rules;
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* initialize
|
55 |
+
*/
|
56 |
+
public function initialize() {
|
57 |
+
add_filter( 'nocache_headers' , array( $this, 'nocache_headers' ) , 1 );
|
58 |
+
add_filter( 'template_include', array( $this, 'template_include' ), 10000 );
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* template_include
|
63 |
+
* 表示画面でのプラグインの処理等
|
64 |
+
* @param string $template
|
65 |
+
* @return string $template
|
66 |
+
*/
|
67 |
+
public function template_include( $template ) {
|
68 |
+
global $post;
|
69 |
+
|
70 |
+
$this->ExecShortcode = new MW_WP_Form_Exec_Shortcode( $post, $template );
|
71 |
+
$form_id = $this->ExecShortcode->get_form_id();
|
72 |
+
$form_key = $this->ExecShortcode->get( 'key' );
|
73 |
+
$this->Setting = new MW_WP_Form_Setting( $form_id );
|
74 |
+
|
75 |
+
$has_shortcode = $this->ExecShortcode->has_shortcode();
|
76 |
+
if ( !$has_shortcode ) {
|
77 |
+
return $template;
|
78 |
+
}
|
79 |
+
|
80 |
+
$this->Data = MW_WP_Form_Data::getInstance( $form_key, $_POST, $_FILES );
|
81 |
+
|
82 |
+
foreach ( $this->validation_rules as $validation_name => $validation_rule ) {
|
83 |
+
if ( is_callable( array( $validation_rule, 'set_Data' ) ) ) {
|
84 |
+
$validation_rule->set_Data( $this->Data );
|
85 |
+
}
|
86 |
+
}
|
87 |
+
|
88 |
+
nocache_headers();
|
89 |
+
|
90 |
+
$Error = new MW_WP_Form_Error();
|
91 |
+
$this->Validation = new MW_WP_Form_Validation( $Error );
|
92 |
+
$this->Validation->set_validation_rules( $this->validation_rules );
|
93 |
+
$this->Validation->set_rules( $this->Setting, $this->Data );
|
94 |
+
$this->Validation = apply_filters(
|
95 |
+
'mwform_validation_' . $form_key,
|
96 |
+
$this->Validation,
|
97 |
+
$this->Data->gets()
|
98 |
+
);
|
99 |
+
|
100 |
+
$post_condition = $this->Data->get_post_condition();
|
101 |
+
$is_valid = $this->Validation->check();
|
102 |
+
$this->Redirected = new MW_WP_Form_Redirected(
|
103 |
+
$this->ExecShortcode->get( 'input_url' ),
|
104 |
+
$this->ExecShortcode->get( 'confirmation_url' ),
|
105 |
+
$this->ExecShortcode->get( 'complete_url' ),
|
106 |
+
$this->ExecShortcode->get( 'validation_error_url' ),
|
107 |
+
$is_valid,
|
108 |
+
$post_condition,
|
109 |
+
$this->Setting->get( 'querystring' )
|
110 |
+
);
|
111 |
+
$url = $this->Redirected->get_url();
|
112 |
+
$view_flg = $this->Redirected->get_view_flg();
|
113 |
+
|
114 |
+
// confirm もしくは complete のとき
|
115 |
+
if ( in_array( $post_condition, array( 'confirm', 'complete' ) ) ) {
|
116 |
+
$this->file_upload();
|
117 |
+
}
|
118 |
+
// complete のとき
|
119 |
+
if ( $view_flg === 'complete' ) {
|
120 |
+
if ( !$this->Data->is_complete_twice() ) {
|
121 |
+
$this->send();
|
122 |
+
}
|
123 |
+
// 手動フォームの場合は完了画面に ExecShortcode が無く footer の clear_values が
|
124 |
+
// 効かないためここで消す
|
125 |
+
if ( !$form_id ) {
|
126 |
+
$this->Data->clear_values();
|
127 |
+
}
|
128 |
+
}
|
129 |
+
$this->redirect( $url );
|
130 |
+
|
131 |
+
// スクロール用スクリプトのロード
|
132 |
+
if ( $this->Setting->get( 'scroll' ) ) {
|
133 |
+
if ( in_array( $view_flg, array( 'confirm', 'complete' ) ) || !$is_valid ) {
|
134 |
+
add_action( 'wp_enqueue_scripts', array( $this, 'scroll_script' ) );
|
135 |
+
}
|
136 |
+
}
|
137 |
+
|
138 |
+
// 画面表示用のショートコードを登録
|
139 |
+
$Form = new MW_WP_Form_Form( $this->Data );
|
140 |
+
$View = new MW_WP_Form_Main_View();
|
141 |
+
$View->set( 'Form', $Form );
|
142 |
+
$View->set( 'Error', $Error );
|
143 |
+
$View->set( 'Setting', $this->Setting );
|
144 |
+
$View->set( 'form_key', $form_key );
|
145 |
+
$View->set( 'view_flg', $view_flg );
|
146 |
+
$View->add_shortcode_that_display_content();
|
147 |
+
|
148 |
+
add_action( 'wp_footer' , array( $this->Data, 'clear_values' ) );
|
149 |
+
add_action( 'wp_enqueue_scripts', array( $this , 'wp_enqueue_scripts' ) );
|
150 |
+
|
151 |
+
return $template;
|
152 |
+
}
|
153 |
+
|
154 |
+
/**
|
155 |
+
* redirect
|
156 |
+
* 現在のURLと引数で渡されたリダイレクトURLが同じであればリダイレクトしない
|
157 |
+
* @param string リダイレクトURL
|
158 |
+
*/
|
159 |
+
private function redirect( $url ) {
|
160 |
+
$redirect = ( empty( $url ) ) ? $this->Redirected->get_request_uri() : $url;
|
161 |
+
$REQUEST_URI = $this->Redirected->get_request_uri();
|
162 |
+
if ( !empty( $_POST ) || $redirect != $REQUEST_URI ) {
|
163 |
+
$redirect = wp_sanitize_redirect( $redirect );
|
164 |
+
$redirect = wp_validate_redirect( $redirect, home_url() );
|
165 |
+
wp_redirect( $redirect );
|
166 |
+
exit();
|
167 |
+
}
|
168 |
+
}
|
169 |
+
|
170 |
+
/**
|
171 |
+
* wp_enqueue_scripts
|
172 |
+
*/
|
173 |
+
public function wp_enqueue_scripts() {
|
174 |
+
global $post;
|
175 |
+
|
176 |
+
$url = plugin_dir_url( __FILE__ );
|
177 |
+
wp_enqueue_style( MWF_Config::NAME, $url . '../../css/style.css' );
|
178 |
+
|
179 |
+
$style = $this->Setting->get( 'style' );
|
180 |
+
$styles = apply_filters( 'mwform_styles', array() );
|
181 |
+
if ( is_array( $styles ) && isset( $styles[$style] ) ) {
|
182 |
+
$css = $styles[$style];
|
183 |
+
wp_enqueue_style( MWF_Config::NAME . '_style', $css );
|
184 |
+
}
|
185 |
+
wp_enqueue_script( MWF_Config::NAME, $url . '../../js/form.js', array( 'jquery' ), false, true );
|
186 |
+
}
|
187 |
+
|
188 |
+
/**
|
189 |
+
* scroll_script
|
190 |
+
*/
|
191 |
+
public function scroll_script() {
|
192 |
+
$url = plugin_dir_url( __FILE__ );
|
193 |
+
wp_register_script(
|
194 |
+
MWF_Config::NAME . '-scroll',
|
195 |
+
$url . '../../js/scroll.js',
|
196 |
+
array( 'jquery' ),
|
197 |
+
false,
|
198 |
+
true
|
199 |
+
);
|
200 |
+
wp_localize_script( MWF_Config::NAME . '-scroll', 'mwform_scroll', array(
|
201 |
+
'offset' => apply_filters( 'mwform_scroll_offset_' . $this->ExecShortcode->get( 'key' ), 0 ),
|
202 |
+
) );
|
203 |
+
wp_enqueue_script( MWF_Config::NAME . '-scroll' );
|
204 |
+
}
|
205 |
+
|
206 |
+
/**
|
207 |
+
* nocache_headers
|
208 |
+
* Nginx Cache Controller用
|
209 |
+
* @param array $headers
|
210 |
+
* @return array $headers
|
211 |
+
*/
|
212 |
+
public function nocache_headers( $headers ) {
|
213 |
+
$headers['X-Accel-Expires'] = 0;
|
214 |
+
return $headers;
|
215 |
+
}
|
216 |
+
|
217 |
+
/**
|
218 |
+
* send
|
219 |
+
* メール送信
|
220 |
+
*/
|
221 |
+
protected function send() {
|
222 |
+
$Mail = new MW_WP_Form_Mail();
|
223 |
+
$form_key = $this->ExecShortcode->get( 'key' );
|
224 |
+
$attachments = $this->get_attachments();
|
225 |
+
$Mail_Service = new MW_WP_Form_Mail_Service( $Mail, $this->Data, $form_key, $this->validation_rules, $this->Setting, $attachments );
|
226 |
+
|
227 |
+
// 管理画面で作成した場合だけ自動で送信
|
228 |
+
if ( $this->ExecShortcode->is_generated_by_formkey() ) {
|
229 |
+
$Mail_admin_raw = $Mail_Service->get_Mail_admin_raw();
|
230 |
+
|
231 |
+
// save_mail_body で登録されないように
|
232 |
+
foreach ( $attachments as $key => $attachment ) {
|
233 |
+
$this->Data->clear_value( $key );
|
234 |
+
}
|
235 |
+
|
236 |
+
// メール送信前にファイルのリネームをしないと、tempファイル名をメールで送信してしまう。
|
237 |
+
if ( $this->Setting->get( 'usedb' ) ) {
|
238 |
+
$Mail_Service->save_contact_data( $Mail_admin_raw, $attachments );
|
239 |
+
}
|
240 |
+
|
241 |
+
$Mail_admin = $Mail_Service->get_Mail_admin();
|
242 |
+
$Mail_admin->send();
|
243 |
+
|
244 |
+
// DB非保存時は管理者メール送信後、ファイルを削除
|
245 |
+
if ( !$this->Setting->get( 'usedb' ) ) {
|
246 |
+
$File = new MW_WP_Form_File();
|
247 |
+
$File->delete_files( $attachments );
|
248 |
+
}
|
249 |
+
|
250 |
+
// 自動返信メールの送信
|
251 |
+
$automatic_reply_email = $this->Setting->get( 'automatic_reply_email' );
|
252 |
+
if ( $automatic_reply_email ) {
|
253 |
+
$automatic_reply_email = $this->Data->get_raw( $automatic_reply_email );
|
254 |
+
$is_invalid_mail_address = $this->validation_rules['mail']->rule(
|
255 |
+
$automatic_reply_email
|
256 |
+
);
|
257 |
+
if ( $automatic_reply_email && !$is_invalid_mail_address ) {
|
258 |
+
$Mail_auto = $Mail_Service->get_Mail_auto();
|
259 |
+
$Mail_auto->send();
|
260 |
+
}
|
261 |
+
}
|
262 |
+
|
263 |
+
// 問い合わせ番号を加算
|
264 |
+
if ( preg_match( '{' . MWF_Config::TRACKINGNUMBER . '}', $Mail_admin_raw->body ) ) {
|
265 |
+
$this->Setting->update_tracking_number();
|
266 |
+
}
|
267 |
+
}
|
268 |
+
}
|
269 |
+
|
270 |
+
/**
|
271 |
+
* get_attachments
|
272 |
+
* @return array $attachments pathの配列
|
273 |
+
*/
|
274 |
+
protected function get_attachments() {
|
275 |
+
$attachments = array();
|
276 |
+
$upload_file_keys = $this->Data->get_raw( MWF_Config::UPLOAD_FILE_KEYS );
|
277 |
+
if ( $upload_file_keys !== null && is_array( $upload_file_keys ) ) {
|
278 |
+
$wp_upload_dir = wp_upload_dir();
|
279 |
+
foreach ( $upload_file_keys as $key ) {
|
280 |
+
$upload_file_url = $this->Data->get_raw( $key );
|
281 |
+
if ( !$upload_file_url ) {
|
282 |
+
continue;
|
283 |
+
}
|
284 |
+
$filepath = MWF_Functions::fileurl_to_path( $upload_file_url );
|
285 |
+
if ( file_exists( $filepath ) ) {
|
286 |
+
$filepath = MWF_Functions::move_temp_file_to_upload_dir( $filepath );
|
287 |
+
$new_upload_file_url = MWF_Functions::filepath_to_url( $filepath );
|
288 |
+
$this->Data->set( $key, $new_upload_file_url );
|
289 |
+
$attachments[$key] = $filepath;
|
290 |
+
}
|
291 |
+
}
|
292 |
+
}
|
293 |
+
return $attachments;
|
294 |
+
}
|
295 |
+
|
296 |
+
/**
|
297 |
+
* file_upload
|
298 |
+
* ファイルアップロード処理。実際のアップロード状況に合わせてフォームデータも再生成する。
|
299 |
+
*/
|
300 |
+
protected function file_upload() {
|
301 |
+
$File = new MW_WP_Form_File();
|
302 |
+
$files = array();
|
303 |
+
$upload_files = $this->Data->get_raw( MWF_Config::UPLOAD_FILES );
|
304 |
+
if ( !is_array( $upload_files ) ) {
|
305 |
+
$upload_files = array();
|
306 |
+
}
|
307 |
+
foreach ( $upload_files as $key => $file ) {
|
308 |
+
if ( $this->Validation->single_check( $key ) ) {
|
309 |
+
$files[$key] = $file;
|
310 |
+
}
|
311 |
+
}
|
312 |
+
$uploaded_files = $File->upload( $files );
|
313 |
+
$this->Data->set_upload_file_keys();
|
314 |
+
$this->Data->push_uploaded_file_keys( $uploaded_files );
|
315 |
+
}
|
316 |
+
}
|
classes/form-fields/class.akismet_error.php
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Name : MW WP Form Field Akismet Error
|
4 |
+
* Description: Akismetのエラーを出力
|
5 |
+
* Version : 1.4.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : June 21, 2013
|
9 |
+
* Modified : January 2, 2015
|
10 |
+
* License : GPLv2
|
11 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
+
*/
|
13 |
+
class MW_WP_Form_Field_Akismet_Error extends MW_WP_Form_Abstract_Form_Field {
|
14 |
+
|
15 |
+
/**
|
16 |
+
* $type
|
17 |
+
* フォームタグの種類 input|select|button|error|other
|
18 |
+
* @var string
|
19 |
+
*/
|
20 |
+
public $type = 'error';
|
21 |
+
|
22 |
+
/**
|
23 |
+
* set_names
|
24 |
+
* shortcode_name、display_nameを定義。各子クラスで上書きする。
|
25 |
+
* @return array shortcode_name, display_name
|
26 |
+
*/
|
27 |
+
protected function set_names() {
|
28 |
+
return array(
|
29 |
+
'shortcode_name' => 'mwform_akismet_error',
|
30 |
+
'display_name' => __( 'Akismet Error', MWF_Config::DOMAIN ),
|
31 |
+
);
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* set_defaults
|
36 |
+
* $this->defaultsを設定し返す
|
37 |
+
* @return array defaults
|
38 |
+
*/
|
39 |
+
protected function set_defaults() {
|
40 |
+
return array();
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* input_page
|
45 |
+
* 入力ページでのフォーム項目を返す
|
46 |
+
* @return string HTML
|
47 |
+
*/
|
48 |
+
protected function input_page() {
|
49 |
+
$error = $this->get_error( MWF_Config::AKISMET );
|
50 |
+
if ( $error ) {
|
51 |
+
return sprintf(
|
52 |
+
'<span class="akismet_error">%s</span>',
|
53 |
+
$this->get_error( MWF_Config::AKISMET )
|
54 |
+
);
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* confirm_page
|
60 |
+
* 確認ページでのフォーム項目を返す
|
61 |
+
* @return string HTML
|
62 |
+
*/
|
63 |
+
protected function confirm_page() {
|
64 |
+
}
|
65 |
+
}
|
form_fields/mw_form_field_back_button.php → classes/form-fields/class.back-button.php
RENAMED
@@ -1,20 +1,21 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Name: MW Form Field Back Button
|
4 |
-
* Description:
|
5 |
-
* Version: 1.
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created
|
9 |
-
* Modified:
|
10 |
-
* License: GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
-
class
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
-
* input
|
|
|
18 |
*/
|
19 |
public $type = 'button';
|
20 |
|
@@ -26,36 +27,36 @@ class MW_Form_Field_Back_Button extends MW_Form_Field {
|
|
26 |
protected function set_names() {
|
27 |
return array(
|
28 |
'shortcode_name' => 'mwform_backButton',
|
29 |
-
'display_name'
|
30 |
);
|
31 |
}
|
32 |
|
33 |
/**
|
34 |
-
*
|
35 |
* $this->defaultsを設定し返す
|
36 |
* @return array defaults
|
37 |
*/
|
38 |
-
protected function
|
39 |
return array(
|
40 |
'value' => __( 'Back', MWF_Config::DOMAIN ),
|
41 |
);
|
42 |
}
|
43 |
|
44 |
/**
|
45 |
-
*
|
46 |
* 入力ページでのフォーム項目を返す
|
47 |
* @return string HTML
|
48 |
*/
|
49 |
-
protected function
|
50 |
}
|
51 |
|
52 |
/**
|
53 |
-
*
|
54 |
* 確認ページでのフォーム項目を返す
|
55 |
* @return string HTML
|
56 |
*/
|
57 |
-
protected function
|
58 |
-
return $this->Form->submit(
|
59 |
}
|
60 |
|
61 |
/**
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Name : MW WP Form Field Back Button
|
4 |
+
* Description: 戻るボタンを出力
|
5 |
+
* Version : 1.5.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : December 14, 2012
|
9 |
+
* Modified : January 2, 2015
|
10 |
+
* License : GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
+
class MW_WP_Form_Field_Back_Button extends MW_WP_Form_Abstract_Form_Field {
|
14 |
|
15 |
/**
|
16 |
+
* $type
|
17 |
+
* フォームタグの種類 input|select|button|error|other
|
18 |
+
* @var string
|
19 |
*/
|
20 |
public $type = 'button';
|
21 |
|
27 |
protected function set_names() {
|
28 |
return array(
|
29 |
'shortcode_name' => 'mwform_backButton',
|
30 |
+
'display_name' => __( 'Back', MWF_Config::DOMAIN ),
|
31 |
);
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* set_defaults
|
36 |
* $this->defaultsを設定し返す
|
37 |
* @return array defaults
|
38 |
*/
|
39 |
+
protected function set_defaults() {
|
40 |
return array(
|
41 |
'value' => __( 'Back', MWF_Config::DOMAIN ),
|
42 |
);
|
43 |
}
|
44 |
|
45 |
/**
|
46 |
+
* input_page
|
47 |
* 入力ページでのフォーム項目を返す
|
48 |
* @return string HTML
|
49 |
*/
|
50 |
+
protected function input_page() {
|
51 |
}
|
52 |
|
53 |
/**
|
54 |
+
* confirm_page
|
55 |
* 確認ページでのフォーム項目を返す
|
56 |
* @return string HTML
|
57 |
*/
|
58 |
+
protected function confirm_page() {
|
59 |
+
return $this->Form->submit( MWF_Config::BACK_BUTTON, $this->atts['value'] );
|
60 |
}
|
61 |
|
62 |
/**
|
form_fields/mw_form_field_button.php → classes/form-fields/class.button.php
RENAMED
@@ -1,20 +1,21 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Name: MW Form Field Button
|
4 |
-
* Description:
|
5 |
-
* Version: 1.
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created
|
9 |
-
* Modified:
|
10 |
-
* License: GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
-
class
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
-
* input
|
|
|
18 |
*/
|
19 |
public $type = 'button';
|
20 |
|
@@ -26,16 +27,16 @@ class MW_Form_Field_Button extends MW_Form_Field {
|
|
26 |
protected function set_names() {
|
27 |
return array(
|
28 |
'shortcode_name' => 'mwform_button',
|
29 |
-
'display_name'
|
30 |
);
|
31 |
}
|
32 |
|
33 |
/**
|
34 |
-
*
|
35 |
* $this->defaultsを設定し返す
|
36 |
* @return array defaults
|
37 |
*/
|
38 |
-
protected function
|
39 |
return array(
|
40 |
'name' => '',
|
41 |
'value' => '',
|
@@ -43,21 +44,21 @@ class MW_Form_Field_Button extends MW_Form_Field {
|
|
43 |
}
|
44 |
|
45 |
/**
|
46 |
-
*
|
47 |
* 入力ページでのフォーム項目を返す
|
48 |
* @return string HTML
|
49 |
*/
|
50 |
-
protected function
|
51 |
return $this->Form->button( $this->atts['name'], $this->atts['value'] );
|
52 |
}
|
53 |
|
54 |
/**
|
55 |
-
*
|
56 |
* 確認ページでのフォーム項目を返す
|
57 |
* @return string HTML
|
58 |
*/
|
59 |
-
protected function
|
60 |
-
return $this->
|
61 |
}
|
62 |
|
63 |
/**
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Name : MW WP Form Field Button
|
4 |
+
* Description: ボタンを出力
|
5 |
+
* Version : 1.5.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : December 14, 2012
|
9 |
+
* Modified : January 2, 2015
|
10 |
+
* License : GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
+
class MW_WP_Form_Field_Button extends MW_WP_Form_Abstract_Form_Field {
|
14 |
|
15 |
/**
|
16 |
+
* $type
|
17 |
+
* フォームタグの種類 input|select|button|error|other
|
18 |
+
* @var string
|
19 |
*/
|
20 |
public $type = 'button';
|
21 |
|
27 |
protected function set_names() {
|
28 |
return array(
|
29 |
'shortcode_name' => 'mwform_button',
|
30 |
+
'display_name' => __( 'Button', MWF_Config::DOMAIN ),
|
31 |
);
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* set_defaults
|
36 |
* $this->defaultsを設定し返す
|
37 |
* @return array defaults
|
38 |
*/
|
39 |
+
protected function set_defaults() {
|
40 |
return array(
|
41 |
'name' => '',
|
42 |
'value' => '',
|
44 |
}
|
45 |
|
46 |
/**
|
47 |
+
* input_page
|
48 |
* 入力ページでのフォーム項目を返す
|
49 |
* @return string HTML
|
50 |
*/
|
51 |
+
protected function input_page() {
|
52 |
return $this->Form->button( $this->atts['name'], $this->atts['value'] );
|
53 |
}
|
54 |
|
55 |
/**
|
56 |
+
* confirm_page
|
57 |
* 確認ページでのフォーム項目を返す
|
58 |
* @return string HTML
|
59 |
*/
|
60 |
+
protected function confirm_page() {
|
61 |
+
return $this->input_page();
|
62 |
}
|
63 |
|
64 |
/**
|
form_fields/mw_form_field_checkbox.php → classes/form-fields/class.checkbox.php
RENAMED
@@ -1,20 +1,21 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Name: MW Form Field Checkbox
|
4 |
-
* Description:
|
5 |
-
* Version: 1.
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created
|
9 |
-
* Modified:
|
10 |
-
* License: GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
-
class
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
-
* input
|
|
|
18 |
*/
|
19 |
public $type = 'select';
|
20 |
|
@@ -26,16 +27,16 @@ class MW_Form_Field_Checkbox extends MW_Form_Field {
|
|
26 |
protected function set_names() {
|
27 |
return array(
|
28 |
'shortcode_name' => 'mwform_checkbox',
|
29 |
-
'display_name'
|
30 |
);
|
31 |
}
|
32 |
|
33 |
/**
|
34 |
-
*
|
35 |
* $this->defaultsを設定し返す
|
36 |
* @return array defaults
|
37 |
*/
|
38 |
-
protected function
|
39 |
return array(
|
40 |
'name' => '',
|
41 |
'id' => '',
|
@@ -48,31 +49,33 @@ class MW_Form_Field_Checkbox extends MW_Form_Field {
|
|
48 |
}
|
49 |
|
50 |
/**
|
51 |
-
*
|
52 |
* 入力ページでのフォーム項目を返す
|
53 |
* @return string HTML
|
54 |
*/
|
55 |
-
protected function
|
56 |
-
$children = $this->
|
|
|
57 |
$separator = ( $this->atts['separator'] ) ? $this->atts['separator'] : $this->defaults['separator'];
|
58 |
$_ret = $this->Form->checkbox( $this->atts['name'], $children, array(
|
59 |
'id' => $this->atts['id'],
|
60 |
-
'value' => $
|
61 |
'vertically' => $this->atts['vertically'],
|
62 |
), $separator );
|
63 |
-
if ( $this->atts['show_error'] !== 'false' )
|
64 |
-
$_ret .= $this->
|
|
|
65 |
return $_ret;
|
66 |
}
|
67 |
|
68 |
/**
|
69 |
-
*
|
70 |
* 確認ページでのフォーム項目を返す
|
71 |
* @return string HTML
|
72 |
*/
|
73 |
-
protected function
|
74 |
-
$children = $this->
|
75 |
-
$value = $this->Form->
|
76 |
$_ret = esc_html( $value );
|
77 |
$_ret .= $this->Form->hidden( $this->atts['name'] . '[data]', $value );
|
78 |
$_ret .= $this->Form->separator( $this->atts['name'] );
|
@@ -100,7 +103,8 @@ class MW_Form_Field_Checkbox extends MW_Form_Field {
|
|
100 |
<?php $children = "\n" . $this->get_value_for_generator( 'children', $options ); ?>
|
101 |
<textarea name="children"><?php echo esc_attr( $children ); ?></textarea>
|
102 |
<span class="mwf_note">
|
103 |
-
<?php esc_html_e( 'Input one line about one item.', MWF_Config::DOMAIN );
|
|
|
104 |
</span>
|
105 |
</p>
|
106 |
<p>
|
@@ -116,12 +120,12 @@ class MW_Form_Field_Checkbox extends MW_Form_Field {
|
|
116 |
<p>
|
117 |
<strong><?php esc_html_e( 'Display method', MWF_Config::DOMAIN ); ?></strong>
|
118 |
<?php $vertically = $this->get_value_for_generator( 'vertically', $options ); ?>
|
119 |
-
<input type="checkbox" name="vertically" value="true" <?php checked( 'true', $vertically ); ?> /> <?php esc_html_e( 'Arranged vertically.', MWF_Config::DOMAIN );
|
120 |
</p>
|
121 |
<p>
|
122 |
<strong><?php esc_html_e( 'Dsiplay error', MWF_Config::DOMAIN ); ?></strong>
|
123 |
<?php $show_error = $this->get_value_for_generator( 'show_error', $options ); ?>
|
124 |
-
<input type="checkbox" name="show_error" value="false" <?php checked( 'false', $show_error ); ?> /> <?php esc_html_e( 'Don\'t display error.', MWF_Config::DOMAIN );
|
125 |
</p>
|
126 |
<?php
|
127 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Name : MW WP Form Field Checkbox
|
4 |
+
* Description: チェックボックスを出力
|
5 |
+
* Version : 1.5.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : December 14, 2012
|
9 |
+
* Modified : January 2, 2015
|
10 |
+
* License : GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
+
class MW_WP_Form_Field_Checkbox extends MW_WP_Form_Abstract_Form_Field {
|
14 |
|
15 |
/**
|
16 |
+
* $type
|
17 |
+
* フォームタグの種類 input|select|button|error|other
|
18 |
+
* @var string
|
19 |
*/
|
20 |
public $type = 'select';
|
21 |
|
27 |
protected function set_names() {
|
28 |
return array(
|
29 |
'shortcode_name' => 'mwform_checkbox',
|
30 |
+
'display_name' => __( 'Checkbox', MWF_Config::DOMAIN ),
|
31 |
);
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* set_defaults
|
36 |
* $this->defaultsを設定し返す
|
37 |
* @return array defaults
|
38 |
*/
|
39 |
+
protected function set_defaults() {
|
40 |
return array(
|
41 |
'name' => '',
|
42 |
'id' => '',
|
49 |
}
|
50 |
|
51 |
/**
|
52 |
+
* input_page
|
53 |
* 入力ページでのフォーム項目を返す
|
54 |
* @return string HTML
|
55 |
*/
|
56 |
+
protected function input_page() {
|
57 |
+
$children = $this->get_children( $this->atts['children'] );
|
58 |
+
$value = $this->get_children( $this->atts['value'] );
|
59 |
$separator = ( $this->atts['separator'] ) ? $this->atts['separator'] : $this->defaults['separator'];
|
60 |
$_ret = $this->Form->checkbox( $this->atts['name'], $children, array(
|
61 |
'id' => $this->atts['id'],
|
62 |
+
'value' => $value,
|
63 |
'vertically' => $this->atts['vertically'],
|
64 |
), $separator );
|
65 |
+
if ( $this->atts['show_error'] !== 'false' ) {
|
66 |
+
$_ret .= $this->get_error( $this->atts['name'] );
|
67 |
+
}
|
68 |
return $_ret;
|
69 |
}
|
70 |
|
71 |
/**
|
72 |
+
* confirm_page
|
73 |
* 確認ページでのフォーム項目を返す
|
74 |
* @return string HTML
|
75 |
*/
|
76 |
+
protected function confirm_page() {
|
77 |
+
$children = $this->get_children( $this->atts['children'] );
|
78 |
+
$value = $this->Form->get_checked_value( $this->atts['name'], $children );
|
79 |
$_ret = esc_html( $value );
|
80 |
$_ret .= $this->Form->hidden( $this->atts['name'] . '[data]', $value );
|
81 |
$_ret .= $this->Form->separator( $this->atts['name'] );
|
103 |
<?php $children = "\n" . $this->get_value_for_generator( 'children', $options ); ?>
|
104 |
<textarea name="children"><?php echo esc_attr( $children ); ?></textarea>
|
105 |
<span class="mwf_note">
|
106 |
+
<?php esc_html_e( 'Input one line about one item.', MWF_Config::DOMAIN ); ?><br />
|
107 |
+
<?php esc_html_e( 'Example: value1↵value2 or key1:value1↵key2:value2', MWF_Config::DOMAIN ); ?>
|
108 |
</span>
|
109 |
</p>
|
110 |
<p>
|
120 |
<p>
|
121 |
<strong><?php esc_html_e( 'Display method', MWF_Config::DOMAIN ); ?></strong>
|
122 |
<?php $vertically = $this->get_value_for_generator( 'vertically', $options ); ?>
|
123 |
+
<label><input type="checkbox" name="vertically" value="true" <?php checked( 'true', $vertically ); ?> /> <?php esc_html_e( 'Arranged vertically.', MWF_Config::DOMAIN ); ?></label>
|
124 |
</p>
|
125 |
<p>
|
126 |
<strong><?php esc_html_e( 'Dsiplay error', MWF_Config::DOMAIN ); ?></strong>
|
127 |
<?php $show_error = $this->get_value_for_generator( 'show_error', $options ); ?>
|
128 |
+
<label><input type="checkbox" name="show_error" value="false" <?php checked( 'false', $show_error ); ?> /> <?php esc_html_e( 'Don\'t display error.', MWF_Config::DOMAIN ); ?></label>
|
129 |
</p>
|
130 |
<?php
|
131 |
}
|
form_fields/mw_form_field_confirm_button.php → classes/form-fields/class.confirm-button.php
RENAMED
@@ -1,20 +1,21 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Name: MW Form Field Confirm Button
|
4 |
-
* Description:
|
5 |
-
* Version: 1.
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created
|
9 |
-
* Modified:
|
10 |
-
* License: GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
-
class
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
-
* input
|
|
|
18 |
*/
|
19 |
public $type = 'button';
|
20 |
|
@@ -26,36 +27,36 @@ class MW_Form_Field_Confirm_Button extends MW_Form_Field {
|
|
26 |
protected function set_names() {
|
27 |
return array(
|
28 |
'shortcode_name' => 'mwform_confirmButton',
|
29 |
-
'display_name'
|
30 |
);
|
31 |
}
|
32 |
|
33 |
/**
|
34 |
-
*
|
35 |
* $this->defaultsを設定し返す
|
36 |
* @return array defaults
|
37 |
*/
|
38 |
-
protected function
|
39 |
return array(
|
40 |
'value' => __( 'Confirm', MWF_Config::DOMAIN ),
|
41 |
);
|
42 |
}
|
43 |
|
44 |
/**
|
45 |
-
*
|
46 |
* 入力ページでのフォーム項目を返す
|
47 |
* @return string HTML
|
48 |
*/
|
49 |
-
protected function
|
50 |
-
return $this->Form->submit(
|
51 |
}
|
52 |
|
53 |
/**
|
54 |
-
*
|
55 |
* 確認ページでのフォーム項目を返す
|
56 |
* @return string HTML
|
57 |
*/
|
58 |
-
protected function
|
59 |
}
|
60 |
|
61 |
/**
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Name : MW WP Form Field Confirm Button
|
4 |
+
* Description: 確認ボタンを出力
|
5 |
+
* Version : 1.5.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : December 14, 2012
|
9 |
+
* Modified : January 2, 2015
|
10 |
+
* License : GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
+
class MW_WP_Form_Field_Confirm_Button extends MW_WP_Form_Abstract_Form_Field {
|
14 |
|
15 |
/**
|
16 |
+
* $type
|
17 |
+
* フォームタグの種類 input|select|button|error|other
|
18 |
+
* @var string
|
19 |
*/
|
20 |
public $type = 'button';
|
21 |
|
27 |
protected function set_names() {
|
28 |
return array(
|
29 |
'shortcode_name' => 'mwform_confirmButton',
|
30 |
+
'display_name' => __( 'Confirm Button', MWF_Config::DOMAIN ),
|
31 |
);
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* set_defaults
|
36 |
* $this->defaultsを設定し返す
|
37 |
* @return array defaults
|
38 |
*/
|
39 |
+
protected function set_defaults() {
|
40 |
return array(
|
41 |
'value' => __( 'Confirm', MWF_Config::DOMAIN ),
|
42 |
);
|
43 |
}
|
44 |
|
45 |
/**
|
46 |
+
* input_page
|
47 |
* 入力ページでのフォーム項目を返す
|
48 |
* @return string HTML
|
49 |
*/
|
50 |
+
protected function input_page() {
|
51 |
+
return $this->Form->submit( MWF_Config::CONFIRM_BUTTON, $this->atts['value'] );
|
52 |
}
|
53 |
|
54 |
/**
|
55 |
+
* confirm_page
|
56 |
* 確認ページでのフォーム項目を返す
|
57 |
* @return string HTML
|
58 |
*/
|
59 |
+
protected function confirm_page() {
|
60 |
}
|
61 |
|
62 |
/**
|
form_fields/mw_form_field_datepicker.php → classes/form-fields/class.datepicker.php
RENAMED
@@ -1,20 +1,21 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Name: MW Form Field Datepicker
|
4 |
-
* Description: datepicker
|
5 |
-
* Version: 1.
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created
|
9 |
-
* Modified:
|
10 |
-
* License: GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
-
class
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
-
* input
|
|
|
18 |
*/
|
19 |
public $type = 'input';
|
20 |
|
@@ -26,16 +27,16 @@ class MW_Form_Field_Datepicker extends MW_Form_Field {
|
|
26 |
protected function set_names() {
|
27 |
return array(
|
28 |
'shortcode_name' => 'mwform_datepicker',
|
29 |
-
'display_name'
|
30 |
);
|
31 |
}
|
32 |
|
33 |
/**
|
34 |
-
*
|
35 |
* $this->defaultsを設定し返す
|
36 |
* @return array defaults
|
37 |
*/
|
38 |
-
protected function
|
39 |
return array(
|
40 |
'name' => '',
|
41 |
'id' => '',
|
@@ -47,11 +48,11 @@ class MW_Form_Field_Datepicker extends MW_Form_Field {
|
|
47 |
}
|
48 |
|
49 |
/**
|
50 |
-
*
|
51 |
* 入力ページでのフォーム項目を返す
|
52 |
* @return string HTML
|
53 |
*/
|
54 |
-
protected function
|
55 |
global $wp_scripts;
|
56 |
$ui = $wp_scripts->query( 'jquery-ui-core' );
|
57 |
wp_enqueue_style( 'jquery.ui', '//ajax.googleapis.com/ajax/libs/jqueryui/' . $ui->ver . '/themes/smoothness/jquery-ui.min.css', array(), $ui->ver );
|
@@ -62,11 +63,12 @@ class MW_Form_Field_Datepicker extends MW_Form_Field {
|
|
62 |
}
|
63 |
// 日本語の場合は日本語表記に変更
|
64 |
if ( get_locale() == 'ja' ) {
|
65 |
-
if ( !empty( $this->atts['js'] ) )
|
66 |
$this->atts['js'] = $this->atts['js'] . ',';
|
|
|
67 |
$this->atts['js'] .= '
|
68 |
yearSuffix: "年",
|
69 |
-
dateFormat: "yy
|
70 |
dayNames: ["日曜日","月曜日","火曜日","水曜日","木曜日","金曜日","土曜日"],
|
71 |
dayNamesMin: ["日","月","火","水","木","金","土"],
|
72 |
dayNamesShort: ["日曜","月曜","火曜","水曜","木曜","金曜","土曜"],
|
@@ -81,18 +83,19 @@ class MW_Form_Field_Datepicker extends MW_Form_Field {
|
|
81 |
'js' => $this->atts['js'],
|
82 |
'value' => $this->atts['value'],
|
83 |
) );
|
84 |
-
if ( $this->atts['show_error'] !== 'false' )
|
85 |
-
$_ret .= $this->
|
|
|
86 |
return $_ret;
|
87 |
}
|
88 |
|
89 |
/**
|
90 |
-
*
|
91 |
* 確認ページでのフォーム項目を返す
|
92 |
* @return string HTML
|
93 |
*/
|
94 |
-
protected function
|
95 |
-
$value = $this->Form->
|
96 |
$_ret = esc_html( $value );
|
97 |
$_ret .= $this->Form->hidden( $this->atts['name'], $value );
|
98 |
return $_ret;
|
@@ -132,7 +135,7 @@ class MW_Form_Field_Datepicker extends MW_Form_Field {
|
|
132 |
<p>
|
133 |
<strong><?php esc_html_e( 'Dsiplay error', MWF_Config::DOMAIN ); ?></strong>
|
134 |
<?php $show_error = $this->get_value_for_generator( 'show_error', $options ); ?>
|
135 |
-
<input type="checkbox" name="show_error" value="false" <?php checked( 'false', $show_error ); ?> /> <?php esc_html_e( 'Don\'t display error.', MWF_Config::DOMAIN );
|
136 |
</p>
|
137 |
<?php
|
138 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Name : MW WP Form Field Datepicker
|
4 |
+
* Description: datepickerを出力
|
5 |
+
* Version : 1.5.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : December 14, 2012
|
9 |
+
* Modified : January 2, 2015
|
10 |
+
* License : GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
+
class MW_WP_Form_Field_Datepicker extends MW_WP_Form_Abstract_Form_Field {
|
14 |
|
15 |
/**
|
16 |
+
* $type
|
17 |
+
* フォームタグの種類 input|select|button|error|other
|
18 |
+
* @var string
|
19 |
*/
|
20 |
public $type = 'input';
|
21 |
|
27 |
protected function set_names() {
|
28 |
return array(
|
29 |
'shortcode_name' => 'mwform_datepicker',
|
30 |
+
'display_name' => __( 'Datepicker', MWF_Config::DOMAIN ),
|
31 |
);
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* set_defaults
|
36 |
* $this->defaultsを設定し返す
|
37 |
* @return array defaults
|
38 |
*/
|
39 |
+
protected function set_defaults() {
|
40 |
return array(
|
41 |
'name' => '',
|
42 |
'id' => '',
|
48 |
}
|
49 |
|
50 |
/**
|
51 |
+
* input_page
|
52 |
* 入力ページでのフォーム項目を返す
|
53 |
* @return string HTML
|
54 |
*/
|
55 |
+
protected function input_page() {
|
56 |
global $wp_scripts;
|
57 |
$ui = $wp_scripts->query( 'jquery-ui-core' );
|
58 |
wp_enqueue_style( 'jquery.ui', '//ajax.googleapis.com/ajax/libs/jqueryui/' . $ui->ver . '/themes/smoothness/jquery-ui.min.css', array(), $ui->ver );
|
63 |
}
|
64 |
// 日本語の場合は日本語表記に変更
|
65 |
if ( get_locale() == 'ja' ) {
|
66 |
+
if ( !empty( $this->atts['js'] ) ) {
|
67 |
$this->atts['js'] = $this->atts['js'] . ',';
|
68 |
+
}
|
69 |
$this->atts['js'] .= '
|
70 |
yearSuffix: "年",
|
71 |
+
dateFormat: "yy年mm月dd日",
|
72 |
dayNames: ["日曜日","月曜日","火曜日","水曜日","木曜日","金曜日","土曜日"],
|
73 |
dayNamesMin: ["日","月","火","水","木","金","土"],
|
74 |
dayNamesShort: ["日曜","月曜","火曜","水曜","木曜","金曜","土曜"],
|
83 |
'js' => $this->atts['js'],
|
84 |
'value' => $this->atts['value'],
|
85 |
) );
|
86 |
+
if ( $this->atts['show_error'] !== 'false' ) {
|
87 |
+
$_ret .= $this->get_error( $this->atts['name'] );
|
88 |
+
}
|
89 |
return $_ret;
|
90 |
}
|
91 |
|
92 |
/**
|
93 |
+
* confirm_page
|
94 |
* 確認ページでのフォーム項目を返す
|
95 |
* @return string HTML
|
96 |
*/
|
97 |
+
protected function confirm_page() {
|
98 |
+
$value = $this->Form->get_raw( $this->atts['name'] );
|
99 |
$_ret = esc_html( $value );
|
100 |
$_ret .= $this->Form->hidden( $this->atts['name'], $value );
|
101 |
return $_ret;
|
135 |
<p>
|
136 |
<strong><?php esc_html_e( 'Dsiplay error', MWF_Config::DOMAIN ); ?></strong>
|
137 |
<?php $show_error = $this->get_value_for_generator( 'show_error', $options ); ?>
|
138 |
+
<label><input type="checkbox" name="show_error" value="false" <?php checked( 'false', $show_error ); ?> /> <?php esc_html_e( 'Don\'t display error.', MWF_Config::DOMAIN ); ?></label>
|
139 |
</p>
|
140 |
<?php
|
141 |
}
|
form_fields/mw_form_field_error.php → classes/form-fields/class.error.php
RENAMED
@@ -1,20 +1,21 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Name: MW Form Field
|
4 |
-
* Description:
|
5 |
-
* Version: 1.
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created
|
9 |
-
* Modified:
|
10 |
-
* License: GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
-
class
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
-
* input
|
|
|
18 |
*/
|
19 |
public $type = 'error';
|
20 |
|
@@ -26,41 +27,41 @@ class MW_Form_Field_Error extends MW_Form_Field {
|
|
26 |
protected function set_names() {
|
27 |
return array(
|
28 |
'shortcode_name' => 'mwform_error',
|
29 |
-
'display_name'
|
30 |
);
|
31 |
}
|
32 |
|
33 |
/**
|
34 |
-
*
|
35 |
* $this->defaultsを設定し返す
|
36 |
* @return array defaults
|
37 |
*/
|
38 |
-
protected function
|
39 |
return array(
|
40 |
'keys' => '',
|
41 |
);
|
42 |
}
|
43 |
|
44 |
/**
|
45 |
-
*
|
46 |
* 入力ページでのフォーム項目を返す
|
47 |
* @return string HTML
|
48 |
*/
|
49 |
-
protected function
|
50 |
$keys = explode( ',', $this->atts['keys'] );
|
51 |
$_ret = '';
|
52 |
foreach ( $keys as $key ) {
|
53 |
-
$_ret .= $this->
|
54 |
}
|
55 |
return $_ret;
|
56 |
}
|
57 |
|
58 |
/**
|
59 |
-
*
|
60 |
* 確認ページでのフォーム項目を返す
|
61 |
* @return string HTML
|
62 |
*/
|
63 |
-
protected function
|
64 |
}
|
65 |
|
66 |
/**
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Name : MW WP Form Field Error
|
4 |
+
* Description: エラーを出力
|
5 |
+
* Version : 1.5.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : December 14, 2012
|
9 |
+
* Modified : January 2, 2015
|
10 |
+
* License : GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
+
class MW_WP_Form_Field_Error extends MW_WP_Form_Abstract_Form_Field {
|
14 |
|
15 |
/**
|
16 |
+
* $type
|
17 |
+
* フォームタグの種類 input|select|button|error|other
|
18 |
+
* @var string
|
19 |
*/
|
20 |
public $type = 'error';
|
21 |
|
27 |
protected function set_names() {
|
28 |
return array(
|
29 |
'shortcode_name' => 'mwform_error',
|
30 |
+
'display_name' => __( 'Error Message', MWF_Config::DOMAIN ),
|
31 |
);
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* set_defaults
|
36 |
* $this->defaultsを設定し返す
|
37 |
* @return array defaults
|
38 |
*/
|
39 |
+
protected function set_defaults() {
|
40 |
return array(
|
41 |
'keys' => '',
|
42 |
);
|
43 |
}
|
44 |
|
45 |
/**
|
46 |
+
* input_page
|
47 |
* 入力ページでのフォーム項目を返す
|
48 |
* @return string HTML
|
49 |
*/
|
50 |
+
protected function input_page() {
|
51 |
$keys = explode( ',', $this->atts['keys'] );
|
52 |
$_ret = '';
|
53 |
foreach ( $keys as $key ) {
|
54 |
+
$_ret .= $this->get_error( trim( $key ) );
|
55 |
}
|
56 |
return $_ret;
|
57 |
}
|
58 |
|
59 |
/**
|
60 |
+
* confirm_page
|
61 |
* 確認ページでのフォーム項目を返す
|
62 |
* @return string HTML
|
63 |
*/
|
64 |
+
protected function confirm_page() {
|
65 |
}
|
66 |
|
67 |
/**
|
form_fields/mw_form_field_file.php → classes/form-fields/class.file.php
RENAMED
@@ -1,20 +1,21 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Name: MW Form Field File
|
4 |
-
* Description:
|
5 |
-
* Version: 1.
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created
|
9 |
-
* Modified:
|
10 |
-
* License: GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
-
class
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
-
* input
|
|
|
18 |
*/
|
19 |
public $type = 'input';
|
20 |
|
@@ -26,16 +27,16 @@ class MW_Form_Field_File extends MW_Form_Field {
|
|
26 |
protected function set_names() {
|
27 |
return array(
|
28 |
'shortcode_name' => 'mwform_file',
|
29 |
-
'display_name'
|
30 |
);
|
31 |
}
|
32 |
|
33 |
/**
|
34 |
-
*
|
35 |
* $this->defaultsを設定し返す
|
36 |
* @return array defaults
|
37 |
*/
|
38 |
-
protected function
|
39 |
return array(
|
40 |
'name' => '',
|
41 |
'id' => '',
|
@@ -44,16 +45,16 @@ class MW_Form_Field_File extends MW_Form_Field {
|
|
44 |
}
|
45 |
|
46 |
/**
|
47 |
-
*
|
48 |
* 入力ページでのフォーム項目を返す
|
49 |
* @return string HTML
|
50 |
*/
|
51 |
-
protected function
|
52 |
$_ret = $this->Form->file( $this->atts['name'], array(
|
53 |
'id' => $this->atts['id'],
|
54 |
) );
|
55 |
-
$value = $this->Form->
|
56 |
-
$upload_file_keys = $this->Form->
|
57 |
if ( !empty( $value ) && is_array( $upload_file_keys ) && in_array( $this->atts['name'], $upload_file_keys ) ) {
|
58 |
$filepath = MWF_Functions::fileurl_to_path( $value );
|
59 |
if ( file_exists( $filepath ) ) {
|
@@ -63,18 +64,19 @@ class MW_Form_Field_File extends MW_Form_Field {
|
|
63 |
$_ret .= '</div>';
|
64 |
}
|
65 |
}
|
66 |
-
if ( $this->atts['show_error'] !== 'false' )
|
67 |
-
$_ret .= $this->
|
|
|
68 |
return $_ret;
|
69 |
}
|
70 |
|
71 |
/**
|
72 |
-
*
|
73 |
* 確認ページでのフォーム項目を返す
|
74 |
* @return string HTML
|
75 |
*/
|
76 |
-
protected function
|
77 |
-
$value = $this->Form->
|
78 |
if ( $value ) {
|
79 |
$filepath = MWF_Functions::fileurl_to_path( $value );
|
80 |
if ( file_exists( $filepath ) ) {
|
@@ -106,7 +108,7 @@ class MW_Form_Field_File extends MW_Form_Field {
|
|
106 |
<p>
|
107 |
<strong><?php esc_html_e( 'Dsiplay error', MWF_Config::DOMAIN ); ?></strong>
|
108 |
<?php $show_error = $this->get_value_for_generator( 'show_error', $options ); ?>
|
109 |
-
<input type="checkbox" name="show_error" value="false" <?php checked( 'false', $show_error ); ?> /> <?php esc_html_e( 'Don\'t display error.', MWF_Config::DOMAIN );
|
110 |
</p>
|
111 |
<?php
|
112 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Name : MW WP Form Field File
|
4 |
+
* Description: 画像アップロードフィールドを出力
|
5 |
+
* Version : 1.5.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : May 17, 2013
|
9 |
+
* Modified : January 2, 2015
|
10 |
+
* License : GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
+
class MW_WP_Form_Field_File extends MW_WP_Form_Abstract_Form_Field {
|
14 |
|
15 |
/**
|
16 |
+
* $type
|
17 |
+
* フォームタグの種類 input|select|button|error|other
|
18 |
+
* @var string
|
19 |
*/
|
20 |
public $type = 'input';
|
21 |
|
27 |
protected function set_names() {
|
28 |
return array(
|
29 |
'shortcode_name' => 'mwform_file',
|
30 |
+
'display_name' => __( 'File', MWF_Config::DOMAIN ),
|
31 |
);
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* set_defaults
|
36 |
* $this->defaultsを設定し返す
|
37 |
* @return array defaults
|
38 |
*/
|
39 |
+
protected function set_defaults() {
|
40 |
return array(
|
41 |
'name' => '',
|
42 |
'id' => '',
|
45 |
}
|
46 |
|
47 |
/**
|
48 |
+
* input_page
|
49 |
* 入力ページでのフォーム項目を返す
|
50 |
* @return string HTML
|
51 |
*/
|
52 |
+
protected function input_page() {
|
53 |
$_ret = $this->Form->file( $this->atts['name'], array(
|
54 |
'id' => $this->atts['id'],
|
55 |
) );
|
56 |
+
$value = $this->Form->get_raw( $this->atts['name'] );
|
57 |
+
$upload_file_keys = $this->Form->get_raw( MWF_Config::UPLOAD_FILE_KEYS );
|
58 |
if ( !empty( $value ) && is_array( $upload_file_keys ) && in_array( $this->atts['name'], $upload_file_keys ) ) {
|
59 |
$filepath = MWF_Functions::fileurl_to_path( $value );
|
60 |
if ( file_exists( $filepath ) ) {
|
64 |
$_ret .= '</div>';
|
65 |
}
|
66 |
}
|
67 |
+
if ( $this->atts['show_error'] !== 'false' ) {
|
68 |
+
$_ret .= $this->get_error( $this->atts['name'] );
|
69 |
+
}
|
70 |
return $_ret;
|
71 |
}
|
72 |
|
73 |
/**
|
74 |
+
* confirm_page
|
75 |
* 確認ページでのフォーム項目を返す
|
76 |
* @return string HTML
|
77 |
*/
|
78 |
+
protected function confirm_page() {
|
79 |
+
$value = $this->Form->get_raw( $this->atts['name'] );
|
80 |
if ( $value ) {
|
81 |
$filepath = MWF_Functions::fileurl_to_path( $value );
|
82 |
if ( file_exists( $filepath ) ) {
|
108 |
<p>
|
109 |
<strong><?php esc_html_e( 'Dsiplay error', MWF_Config::DOMAIN ); ?></strong>
|
110 |
<?php $show_error = $this->get_value_for_generator( 'show_error', $options ); ?>
|
111 |
+
<label><input type="checkbox" name="show_error" value="false" <?php checked( 'false', $show_error ); ?> /> <?php esc_html_e( 'Don\'t display error.', MWF_Config::DOMAIN ); ?></label>
|
112 |
</p>
|
113 |
<?php
|
114 |
}
|
form_fields/mw_form_field_hidden.php → classes/form-fields/class.hidden.php
RENAMED
@@ -1,16 +1,16 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Name: MW Form
|
4 |
-
* Description: hidden
|
5 |
-
* Version: 1.
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created
|
9 |
-
* Modified:
|
10 |
-
* License: GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
-
class
|
14 |
|
15 |
/**
|
16 |
* set_names
|
@@ -20,16 +20,16 @@ class MW_Form_Field_Hidden extends MW_Form_Field {
|
|
20 |
protected function set_names() {
|
21 |
return array(
|
22 |
'shortcode_name' => 'mwform_hidden',
|
23 |
-
'display_name'
|
24 |
);
|
25 |
}
|
26 |
|
27 |
/**
|
28 |
-
*
|
29 |
* $this->defaultsを設定し返す
|
30 |
* @return array defaults
|
31 |
*/
|
32 |
-
protected function
|
33 |
return array(
|
34 |
'name' => '',
|
35 |
'value' => '',
|
@@ -38,11 +38,11 @@ class MW_Form_Field_Hidden extends MW_Form_Field {
|
|
38 |
}
|
39 |
|
40 |
/**
|
41 |
-
*
|
42 |
* 入力ページでのフォーム項目を返す
|
43 |
* @return string HTML
|
44 |
*/
|
45 |
-
protected function
|
46 |
$echo_value = '';
|
47 |
if ( $this->atts['echo'] === 'true' ) {
|
48 |
$echo_value = $this->atts['value'];
|
@@ -51,12 +51,12 @@ class MW_Form_Field_Hidden extends MW_Form_Field {
|
|
51 |
}
|
52 |
|
53 |
/**
|
54 |
-
*
|
55 |
* 確認ページでのフォーム項目を返す
|
56 |
* @return string HTML
|
57 |
*/
|
58 |
-
protected function
|
59 |
-
$value = $this->Form->
|
60 |
$echo_value = '';
|
61 |
if ( $this->atts['echo'] === 'true' ) {
|
62 |
$echo_value = $value;
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Name : MW WP Form Hidden
|
4 |
+
* Description: hiddenフィールドを出力
|
5 |
+
* Version : 1.6.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : December 14, 2012
|
9 |
+
* Modified : January 2, 2015
|
10 |
+
* License : GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
+
class MW_WP_Form_Field_Hidden extends MW_WP_Form_Abstract_Form_Field {
|
14 |
|
15 |
/**
|
16 |
* set_names
|
20 |
protected function set_names() {
|
21 |
return array(
|
22 |
'shortcode_name' => 'mwform_hidden',
|
23 |
+
'display_name' => __( 'Hidden', MWF_Config::DOMAIN ),
|
24 |
);
|
25 |
}
|
26 |
|
27 |
/**
|
28 |
+
* set_defaults
|
29 |
* $this->defaultsを設定し返す
|
30 |
* @return array defaults
|
31 |
*/
|
32 |
+
protected function set_defaults() {
|
33 |
return array(
|
34 |
'name' => '',
|
35 |
'value' => '',
|
38 |
}
|
39 |
|
40 |
/**
|
41 |
+
* input_page
|
42 |
* 入力ページでのフォーム項目を返す
|
43 |
* @return string HTML
|
44 |
*/
|
45 |
+
protected function input_page() {
|
46 |
$echo_value = '';
|
47 |
if ( $this->atts['echo'] === 'true' ) {
|
48 |
$echo_value = $this->atts['value'];
|
51 |
}
|
52 |
|
53 |
/**
|
54 |
+
* confirm_page
|
55 |
* 確認ページでのフォーム項目を返す
|
56 |
* @return string HTML
|
57 |
*/
|
58 |
+
protected function confirm_page() {
|
59 |
+
$value = $this->Form->get_raw( $this->atts['name'] );
|
60 |
$echo_value = '';
|
61 |
if ( $this->atts['echo'] === 'true' ) {
|
62 |
$echo_value = $value;
|
form_fields/mw_form_field_image.php → classes/form-fields/class.image.php
RENAMED
@@ -1,20 +1,21 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Name: MW Form Field Image
|
4 |
-
* Description:
|
5 |
-
* Version: 1.
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created
|
9 |
-
* Modified:
|
10 |
-
* License: GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
-
class
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
-
* input
|
|
|
18 |
*/
|
19 |
public $type = 'input';
|
20 |
|
@@ -26,16 +27,16 @@ class MW_Form_Field_Image extends MW_Form_Field {
|
|
26 |
protected function set_names() {
|
27 |
return array(
|
28 |
'shortcode_name' => 'mwform_image',
|
29 |
-
'display_name'
|
30 |
);
|
31 |
}
|
32 |
|
33 |
/**
|
34 |
-
*
|
35 |
* $this->defaultsを設定し返す
|
36 |
* @return array defaults
|
37 |
*/
|
38 |
-
protected function
|
39 |
return array(
|
40 |
'name' => '',
|
41 |
'id' => '',
|
@@ -44,17 +45,17 @@ class MW_Form_Field_Image extends MW_Form_Field {
|
|
44 |
}
|
45 |
|
46 |
/**
|
47 |
-
*
|
48 |
* 入力ページでのフォーム項目を返す
|
49 |
* @return string HTML
|
50 |
*/
|
51 |
-
protected function
|
52 |
$_ret = $this->Form->file( $this->atts['name'], array(
|
53 |
'id' => $this->atts['id'],
|
54 |
) );
|
55 |
-
$value = $this->Form->
|
56 |
|
57 |
-
$upload_file_keys = $this->Form->
|
58 |
if ( !empty( $value ) && is_array( $upload_file_keys ) && in_array( $this->atts['name'], $upload_file_keys ) ) {
|
59 |
$filepath = MWF_Functions::fileurl_to_path( $value );
|
60 |
if ( file_exists( $filepath ) ) {
|
@@ -64,18 +65,19 @@ class MW_Form_Field_Image extends MW_Form_Field {
|
|
64 |
$_ret .= '</div>';
|
65 |
}
|
66 |
}
|
67 |
-
if ( $this->atts['show_error'] !== 'false' )
|
68 |
-
$_ret .= $this->
|
|
|
69 |
return $_ret;
|
70 |
}
|
71 |
|
72 |
/**
|
73 |
-
*
|
74 |
* 確認ページでのフォーム項目を返す
|
75 |
* @return string HTML
|
76 |
*/
|
77 |
-
protected function
|
78 |
-
$value = $this->Form->
|
79 |
if ( $value ) {
|
80 |
$filepath = MWF_Functions::fileurl_to_path( $value );
|
81 |
if ( file_exists( $filepath ) ) {
|
@@ -107,7 +109,7 @@ class MW_Form_Field_Image extends MW_Form_Field {
|
|
107 |
<p>
|
108 |
<strong><?php esc_html_e( 'Dsiplay error', MWF_Config::DOMAIN ); ?></strong>
|
109 |
<?php $show_error = $this->get_value_for_generator( 'show_error', $options ); ?>
|
110 |
-
<input type="checkbox" name="show_error" value="false" <?php checked( 'false', $show_error ); ?> /> <?php esc_html_e( 'Don\'t display error.', MWF_Config::DOMAIN );
|
111 |
</p>
|
112 |
<?php
|
113 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Name : MW WP Form Field Image
|
4 |
+
* Description: 画像アップロードフィールドを出力
|
5 |
+
* Version : 1.5.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : May 17, 2013
|
9 |
+
* Modified : January 2, 2015
|
10 |
+
* License : GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
+
class MW_WP_Form_Field_Image extends MW_WP_Form_Abstract_Form_Field {
|
14 |
|
15 |
/**
|
16 |
+
* $type
|
17 |
+
* フォームタグの種類 input|select|button|error|other
|
18 |
+
* @var string
|
19 |
*/
|
20 |
public $type = 'input';
|
21 |
|
27 |
protected function set_names() {
|
28 |
return array(
|
29 |
'shortcode_name' => 'mwform_image',
|
30 |
+
'display_name' => __( 'Image', MWF_Config::DOMAIN ),
|
31 |
);
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* set_defaults
|
36 |
* $this->defaultsを設定し返す
|
37 |
* @return array defaults
|
38 |
*/
|
39 |
+
protected function set_defaults() {
|
40 |
return array(
|
41 |
'name' => '',
|
42 |
'id' => '',
|
45 |
}
|
46 |
|
47 |
/**
|
48 |
+
* input_page
|
49 |
* 入力ページでのフォーム項目を返す
|
50 |
* @return string HTML
|
51 |
*/
|
52 |
+
protected function input_page() {
|
53 |
$_ret = $this->Form->file( $this->atts['name'], array(
|
54 |
'id' => $this->atts['id'],
|
55 |
) );
|
56 |
+
$value = $this->Form->get_raw( $this->atts['name'] );
|
57 |
|
58 |
+
$upload_file_keys = $this->Form->get_raw( MWF_Config::UPLOAD_FILE_KEYS );
|
59 |
if ( !empty( $value ) && is_array( $upload_file_keys ) && in_array( $this->atts['name'], $upload_file_keys ) ) {
|
60 |
$filepath = MWF_Functions::fileurl_to_path( $value );
|
61 |
if ( file_exists( $filepath ) ) {
|
65 |
$_ret .= '</div>';
|
66 |
}
|
67 |
}
|
68 |
+
if ( $this->atts['show_error'] !== 'false' ) {
|
69 |
+
$_ret .= $this->get_error( $this->atts['name'] );
|
70 |
+
}
|
71 |
return $_ret;
|
72 |
}
|
73 |
|
74 |
/**
|
75 |
+
* confirm_page
|
76 |
* 確認ページでのフォーム項目を返す
|
77 |
* @return string HTML
|
78 |
*/
|
79 |
+
protected function confirm_page() {
|
80 |
+
$value = $this->Form->get_raw( $this->atts['name'] );
|
81 |
if ( $value ) {
|
82 |
$filepath = MWF_Functions::fileurl_to_path( $value );
|
83 |
if ( file_exists( $filepath ) ) {
|
109 |
<p>
|
110 |
<strong><?php esc_html_e( 'Dsiplay error', MWF_Config::DOMAIN ); ?></strong>
|
111 |
<?php $show_error = $this->get_value_for_generator( 'show_error', $options ); ?>
|
112 |
+
<label><input type="checkbox" name="show_error" value="false" <?php checked( 'false', $show_error ); ?> /> <?php esc_html_e( 'Don\'t display error.', MWF_Config::DOMAIN ); ?></label>
|
113 |
</p>
|
114 |
<?php
|
115 |
}
|
form_fields/mw_form_field_password.php → classes/form-fields/class.password.php
RENAMED
@@ -1,20 +1,21 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Name: MW Form
|
4 |
-
* Description:
|
5 |
-
* Version: 1.
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created
|
9 |
-
* Modified:
|
10 |
-
* License: GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
-
class
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
-
* input
|
|
|
18 |
*/
|
19 |
public $type = 'input';
|
20 |
|
@@ -26,16 +27,16 @@ class MW_Form_Field_Password extends MW_Form_Field {
|
|
26 |
protected function set_names() {
|
27 |
return array(
|
28 |
'shortcode_name' => 'mwform_password',
|
29 |
-
'display_name'
|
30 |
);
|
31 |
}
|
32 |
|
33 |
/**
|
34 |
-
*
|
35 |
* $this->defaultsを設定し返す
|
36 |
* @return array defaults
|
37 |
*/
|
38 |
-
protected function
|
39 |
return array(
|
40 |
'name' => '',
|
41 |
'id' => '',
|
@@ -48,11 +49,11 @@ class MW_Form_Field_Password extends MW_Form_Field {
|
|
48 |
}
|
49 |
|
50 |
/**
|
51 |
-
*
|
52 |
* 入力ページでのフォーム項目を返す
|
53 |
* @return string HTML
|
54 |
*/
|
55 |
-
protected function
|
56 |
$_ret = $this->Form->password( $this->atts['name'], array(
|
57 |
'id' => $this->atts['id'],
|
58 |
'size' => $this->atts['size'],
|
@@ -60,18 +61,19 @@ class MW_Form_Field_Password extends MW_Form_Field {
|
|
60 |
'value' => $this->atts['value'],
|
61 |
'placeholder' => $this->atts['placeholder'],
|
62 |
) );
|
63 |
-
if ( $this->atts['show_error'] !== 'false' )
|
64 |
-
$_ret .= $this->
|
|
|
65 |
return $_ret;
|
66 |
}
|
67 |
|
68 |
/**
|
69 |
-
*
|
70 |
* 確認ページでのフォーム項目を返す
|
71 |
* @return string HTML
|
72 |
*/
|
73 |
-
protected function
|
74 |
-
$value = $this->Form->
|
75 |
return '*****' . $this->Form->hidden( $this->atts['name'], $value );
|
76 |
}
|
77 |
|
@@ -114,7 +116,7 @@ class MW_Form_Field_Password extends MW_Form_Field {
|
|
114 |
<p>
|
115 |
<strong><?php esc_html_e( 'Dsiplay error', MWF_Config::DOMAIN ); ?></strong>
|
116 |
<?php $show_error = $this->get_value_for_generator( 'show_error', $options ); ?>
|
117 |
-
<input type="checkbox" name="show_error" value="false" <?php checked( 'false', $show_error ); ?> /> <?php esc_html_e( 'Don\'t display error.', MWF_Config::DOMAIN );
|
118 |
</p>
|
119 |
<?php
|
120 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Name : MW WP Form Password
|
4 |
+
* Description: パスワードフィールドを出力
|
5 |
+
* Version : 1.5.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : December 14, 2012
|
9 |
+
* Modified : January 2, 2015
|
10 |
+
* License : GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
+
class MW_WP_Form_Field_Password extends MW_WP_Form_Abstract_Form_Field {
|
14 |
|
15 |
/**
|
16 |
+
* $type
|
17 |
+
* フォームタグの種類 input|select|button|error|other
|
18 |
+
* @var string
|
19 |
*/
|
20 |
public $type = 'input';
|
21 |
|
27 |
protected function set_names() {
|
28 |
return array(
|
29 |
'shortcode_name' => 'mwform_password',
|
30 |
+
'display_name' => __( 'Password', MWF_Config::DOMAIN ),
|
31 |
);
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* set_defaults
|
36 |
* $this->defaultsを設定し返す
|
37 |
* @return array defaults
|
38 |
*/
|
39 |
+
protected function set_defaults() {
|
40 |
return array(
|
41 |
'name' => '',
|
42 |
'id' => '',
|
49 |
}
|
50 |
|
51 |
/**
|
52 |
+
* input_page
|
53 |
* 入力ページでのフォーム項目を返す
|
54 |
* @return string HTML
|
55 |
*/
|
56 |
+
protected function input_page() {
|
57 |
$_ret = $this->Form->password( $this->atts['name'], array(
|
58 |
'id' => $this->atts['id'],
|
59 |
'size' => $this->atts['size'],
|
61 |
'value' => $this->atts['value'],
|
62 |
'placeholder' => $this->atts['placeholder'],
|
63 |
) );
|
64 |
+
if ( $this->atts['show_error'] !== 'false' ) {
|
65 |
+
$_ret .= $this->get_error( $this->atts['name'] );
|
66 |
+
}
|
67 |
return $_ret;
|
68 |
}
|
69 |
|
70 |
/**
|
71 |
+
* confirm_page
|
72 |
* 確認ページでのフォーム項目を返す
|
73 |
* @return string HTML
|
74 |
*/
|
75 |
+
protected function confirm_page() {
|
76 |
+
$value = $this->Form->get_raw( $this->atts['name'] );
|
77 |
return '*****' . $this->Form->hidden( $this->atts['name'], $value );
|
78 |
}
|
79 |
|
116 |
<p>
|
117 |
<strong><?php esc_html_e( 'Dsiplay error', MWF_Config::DOMAIN ); ?></strong>
|
118 |
<?php $show_error = $this->get_value_for_generator( 'show_error', $options ); ?>
|
119 |
+
<label><input type="checkbox" name="show_error" value="false" <?php checked( 'false', $show_error ); ?> /> <?php esc_html_e( 'Don\'t display error.', MWF_Config::DOMAIN ); ?></label>
|
120 |
</p>
|
121 |
<?php
|
122 |
}
|
form_fields/mw_form_field_radio.php → classes/form-fields/class.radio.php
RENAMED
@@ -1,20 +1,21 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Name: MW Form Field Radio
|
4 |
-
* Description:
|
5 |
-
* Version: 1.
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created
|
9 |
-
* Modified:
|
10 |
-
* License: GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
-
class
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
-
* input
|
|
|
18 |
*/
|
19 |
public $type = 'select';
|
20 |
|
@@ -26,16 +27,16 @@ class MW_Form_Field_Radio extends MW_Form_Field {
|
|
26 |
protected function set_names() {
|
27 |
return array(
|
28 |
'shortcode_name' => 'mwform_radio',
|
29 |
-
'display_name'
|
30 |
);
|
31 |
}
|
32 |
|
33 |
/**
|
34 |
-
*
|
35 |
* $this->defaultsを設定し返す
|
36 |
* @return array defaults
|
37 |
*/
|
38 |
-
protected function
|
39 |
return array(
|
40 |
'name' => '',
|
41 |
'id' => '',
|
@@ -47,30 +48,31 @@ class MW_Form_Field_Radio extends MW_Form_Field {
|
|
47 |
}
|
48 |
|
49 |
/**
|
50 |
-
*
|
51 |
* 入力ページでのフォーム項目を返す
|
52 |
* @return string html
|
53 |
*/
|
54 |
-
protected function
|
55 |
-
$children = $this->
|
56 |
$_ret = $this->Form->radio( $this->atts['name'], $children, array(
|
57 |
'id' => $this->atts['id'],
|
58 |
'value' => $this->atts['value'],
|
59 |
'vertically' => $this->atts['vertically'],
|
60 |
) );
|
61 |
-
if ( $this->atts['show_error'] !== 'false' )
|
62 |
-
$_ret .= $this->
|
|
|
63 |
return $_ret;
|
64 |
}
|
65 |
|
66 |
/**
|
67 |
-
*
|
68 |
* 確認ページでのフォーム項目を返す
|
69 |
* @return string HTML
|
70 |
*/
|
71 |
-
protected function
|
72 |
-
$children = $this->
|
73 |
-
$value = $this->Form->
|
74 |
$_ret = esc_html( $value );
|
75 |
$_ret .= $this->Form->hidden( $this->atts['name'], $value );
|
76 |
return $_ret;
|
@@ -97,7 +99,8 @@ class MW_Form_Field_Radio extends MW_Form_Field {
|
|
97 |
<?php $children = "\n" . $this->get_value_for_generator( 'children', $options ); ?>
|
98 |
<textarea name="children"><?php echo esc_attr( $children ); ?></textarea>
|
99 |
<span class="mwf_note">
|
100 |
-
<?php esc_html_e( 'Input one line about one item.', MWF_Config::DOMAIN );
|
|
|
101 |
</span>
|
102 |
</p>
|
103 |
<p>
|
@@ -108,12 +111,12 @@ class MW_Form_Field_Radio extends MW_Form_Field {
|
|
108 |
<p>
|
109 |
<strong><?php esc_html_e( 'Display method', MWF_Config::DOMAIN ); ?></strong>
|
110 |
<?php $vertically = $this->get_value_for_generator( 'vertically', $options ); ?>
|
111 |
-
<input type="checkbox" name="vertically" value="true" <?php checked( 'true', $vertically ); ?> /> <?php esc_html_e( 'Arranged vertically.', MWF_Config::DOMAIN );
|
112 |
</p>
|
113 |
<p>
|
114 |
<strong><?php esc_html_e( 'Dsiplay error', MWF_Config::DOMAIN ); ?></strong>
|
115 |
<?php $show_error = $this->get_value_for_generator( 'show_error', $options ); ?>
|
116 |
-
<input type="checkbox" name="show_error" value="false" <?php checked( 'false', $show_error ); ?> /> <?php esc_html_e( 'Don\'t display error.', MWF_Config::DOMAIN );
|
117 |
</p>
|
118 |
<?php
|
119 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Name : MW WP Form Field Radio
|
4 |
+
* Description: ラジオボタンを出力
|
5 |
+
* Version : 1.5.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : December 14, 2012
|
9 |
+
* Modified : January 2, 2015
|
10 |
+
* License : GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
+
class MW_WP_Form_Field_Radio extends MW_WP_Form_Abstract_Form_Field {
|
14 |
|
15 |
/**
|
16 |
+
* $type
|
17 |
+
* フォームタグの種類 input|select|button|error|other
|
18 |
+
* @var string
|
19 |
*/
|
20 |
public $type = 'select';
|
21 |
|
27 |
protected function set_names() {
|
28 |
return array(
|
29 |
'shortcode_name' => 'mwform_radio',
|
30 |
+
'display_name' => __( 'Radio', MWF_Config::DOMAIN ),
|
31 |
);
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* set_defaults
|
36 |
* $this->defaultsを設定し返す
|
37 |
* @return array defaults
|
38 |
*/
|
39 |
+
protected function set_defaults() {
|
40 |
return array(
|
41 |
'name' => '',
|
42 |
'id' => '',
|
48 |
}
|
49 |
|
50 |
/**
|
51 |
+
* input_page
|
52 |
* 入力ページでのフォーム項目を返す
|
53 |
* @return string html
|
54 |
*/
|
55 |
+
protected function input_page() {
|
56 |
+
$children = $this->get_children( $this->atts['children'] );
|
57 |
$_ret = $this->Form->radio( $this->atts['name'], $children, array(
|
58 |
'id' => $this->atts['id'],
|
59 |
'value' => $this->atts['value'],
|
60 |
'vertically' => $this->atts['vertically'],
|
61 |
) );
|
62 |
+
if ( $this->atts['show_error'] !== 'false' ) {
|
63 |
+
$_ret .= $this->get_error( $this->atts['name'] );
|
64 |
+
}
|
65 |
return $_ret;
|
66 |
}
|
67 |
|
68 |
/**
|
69 |
+
* confirm_page
|
70 |
* 確認ページでのフォーム項目を返す
|
71 |
* @return string HTML
|
72 |
*/
|
73 |
+
protected function confirm_page() {
|
74 |
+
$children = $this->get_children( $this->atts['children'] );
|
75 |
+
$value = $this->Form->get_radio_value( $this->atts['name'], $children );
|
76 |
$_ret = esc_html( $value );
|
77 |
$_ret .= $this->Form->hidden( $this->atts['name'], $value );
|
78 |
return $_ret;
|
99 |
<?php $children = "\n" . $this->get_value_for_generator( 'children', $options ); ?>
|
100 |
<textarea name="children"><?php echo esc_attr( $children ); ?></textarea>
|
101 |
<span class="mwf_note">
|
102 |
+
<?php esc_html_e( 'Input one line about one item.', MWF_Config::DOMAIN ); ?><br />
|
103 |
+
<?php esc_html_e( 'Example: value1↵value2 or key1:value1↵key2:value2', MWF_Config::DOMAIN ); ?>
|
104 |
</span>
|
105 |
</p>
|
106 |
<p>
|
111 |
<p>
|
112 |
<strong><?php esc_html_e( 'Display method', MWF_Config::DOMAIN ); ?></strong>
|
113 |
<?php $vertically = $this->get_value_for_generator( 'vertically', $options ); ?>
|
114 |
+
<label><input type="checkbox" name="vertically" value="true" <?php checked( 'true', $vertically ); ?> /> <?php esc_html_e( 'Arranged vertically.', MWF_Config::DOMAIN ); ?></label>
|
115 |
</p>
|
116 |
<p>
|
117 |
<strong><?php esc_html_e( 'Dsiplay error', MWF_Config::DOMAIN ); ?></strong>
|
118 |
<?php $show_error = $this->get_value_for_generator( 'show_error', $options ); ?>
|
119 |
+
<label><input type="checkbox" name="show_error" value="false" <?php checked( 'false', $show_error ); ?> /> <?php esc_html_e( 'Don\'t display error.', MWF_Config::DOMAIN ); ?></label>
|
120 |
</p>
|
121 |
<?php
|
122 |
}
|
form_fields/mw_form_field_select.php → classes/form-fields/class.select.php
RENAMED
@@ -1,20 +1,21 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Name: MW Form Field Select
|
4 |
-
* Description:
|
5 |
-
* Version: 1.
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created
|
9 |
-
* Modified:
|
10 |
-
* License: GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
-
class
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
-
* input
|
|
|
18 |
*/
|
19 |
public $type = 'select';
|
20 |
|
@@ -26,16 +27,16 @@ class MW_Form_Field_Select extends MW_Form_Field {
|
|
26 |
protected function set_names() {
|
27 |
return array(
|
28 |
'shortcode_name' => 'mwform_select',
|
29 |
-
'display_name'
|
30 |
);
|
31 |
}
|
32 |
|
33 |
/**
|
34 |
-
*
|
35 |
* $this->defaultsを設定し返す
|
36 |
* @return array defaults
|
37 |
*/
|
38 |
-
protected function
|
39 |
return array(
|
40 |
'name' => '',
|
41 |
'id' => '',
|
@@ -46,29 +47,30 @@ class MW_Form_Field_Select extends MW_Form_Field {
|
|
46 |
}
|
47 |
|
48 |
/**
|
49 |
-
*
|
50 |
* 入力ページでのフォーム項目を返す
|
51 |
* @return string html
|
52 |
*/
|
53 |
-
protected function
|
54 |
-
$children = $this->
|
55 |
$_ret = $this->Form->select( $this->atts['name'], $children, array(
|
56 |
'id' => $this->atts['id'],
|
57 |
'value' => $this->atts['value'],
|
58 |
) );
|
59 |
-
if ( $this->atts['show_error'] !== 'false' )
|
60 |
-
$_ret .= $this->
|
|
|
61 |
return $_ret;
|
62 |
}
|
63 |
|
64 |
/**
|
65 |
-
*
|
66 |
* 確認ページでのフォーム項目を返す
|
67 |
* @return string HTML
|
68 |
*/
|
69 |
-
protected function
|
70 |
-
$children = $this->
|
71 |
-
$value = $this->Form->
|
72 |
$_ret = esc_html( $value );
|
73 |
$_ret .= $this->Form->hidden( $this->atts['name'], $value );
|
74 |
return $_ret;
|
@@ -95,7 +97,8 @@ class MW_Form_Field_Select extends MW_Form_Field {
|
|
95 |
<?php $children = "\n" . $this->get_value_for_generator( 'children', $options ); ?>
|
96 |
<textarea name="children"><?php echo esc_attr( $children ); ?></textarea>
|
97 |
<span class="mwf_note">
|
98 |
-
<?php esc_html_e( 'Input one line about one item.', MWF_Config::DOMAIN );
|
|
|
99 |
</span>
|
100 |
</p>
|
101 |
<p>
|
@@ -106,7 +109,7 @@ class MW_Form_Field_Select extends MW_Form_Field {
|
|
106 |
<p>
|
107 |
<strong><?php esc_html_e( 'Dsiplay error', MWF_Config::DOMAIN ); ?></strong>
|
108 |
<?php $show_error = $this->get_value_for_generator( 'show_error', $options ); ?>
|
109 |
-
<input type="checkbox" name="show_error" value="false" <?php checked( 'false', $show_error ); ?> /> <?php esc_html_e( 'Don\'t display error.', MWF_Config::DOMAIN );
|
110 |
</p>
|
111 |
<?php
|
112 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Name : MW WP Form Field Select
|
4 |
+
* Description: セレクトボックスを出力
|
5 |
+
* Version : 1.5.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : December 14, 2012
|
9 |
+
* Modified : January 2, 2015
|
10 |
+
* License : GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
+
class MW_WP_Form_Field_Select extends MW_WP_Form_Abstract_Form_Field {
|
14 |
|
15 |
/**
|
16 |
+
* $type
|
17 |
+
* フォームタグの種類 input|select|button|error|other
|
18 |
+
* @var string
|
19 |
*/
|
20 |
public $type = 'select';
|
21 |
|
27 |
protected function set_names() {
|
28 |
return array(
|
29 |
'shortcode_name' => 'mwform_select',
|
30 |
+
'display_name' => __( 'Select', MWF_Config::DOMAIN ),
|
31 |
);
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* set_defaults
|
36 |
* $this->defaultsを設定し返す
|
37 |
* @return array defaults
|
38 |
*/
|
39 |
+
protected function set_defaults() {
|
40 |
return array(
|
41 |
'name' => '',
|
42 |
'id' => '',
|
47 |
}
|
48 |
|
49 |
/**
|
50 |
+
* input_page
|
51 |
* 入力ページでのフォーム項目を返す
|
52 |
* @return string html
|
53 |
*/
|
54 |
+
protected function input_page() {
|
55 |
+
$children = $this->get_children( $this->atts['children'] );
|
56 |
$_ret = $this->Form->select( $this->atts['name'], $children, array(
|
57 |
'id' => $this->atts['id'],
|
58 |
'value' => $this->atts['value'],
|
59 |
) );
|
60 |
+
if ( $this->atts['show_error'] !== 'false' ) {
|
61 |
+
$_ret .= $this->get_error( $this->atts['name'] );
|
62 |
+
}
|
63 |
return $_ret;
|
64 |
}
|
65 |
|
66 |
/**
|
67 |
+
* confirm_page
|
68 |
* 確認ページでのフォーム項目を返す
|
69 |
* @return string HTML
|
70 |
*/
|
71 |
+
protected function confirm_page() {
|
72 |
+
$children = $this->get_children( $this->atts['children'] );
|
73 |
+
$value = $this->Form->get_selected_value( $this->atts['name'], $children );
|
74 |
$_ret = esc_html( $value );
|
75 |
$_ret .= $this->Form->hidden( $this->atts['name'], $value );
|
76 |
return $_ret;
|
97 |
<?php $children = "\n" . $this->get_value_for_generator( 'children', $options ); ?>
|
98 |
<textarea name="children"><?php echo esc_attr( $children ); ?></textarea>
|
99 |
<span class="mwf_note">
|
100 |
+
<?php esc_html_e( 'Input one line about one item.', MWF_Config::DOMAIN ); ?><br />
|
101 |
+
<?php esc_html_e( 'Example: value1↵value2 or key1:value1↵key2:value2', MWF_Config::DOMAIN ); ?>
|
102 |
</span>
|
103 |
</p>
|
104 |
<p>
|
109 |
<p>
|
110 |
<strong><?php esc_html_e( 'Dsiplay error', MWF_Config::DOMAIN ); ?></strong>
|
111 |
<?php $show_error = $this->get_value_for_generator( 'show_error', $options ); ?>
|
112 |
+
<label><input type="checkbox" name="show_error" value="false" <?php checked( 'false', $show_error ); ?> /> <?php esc_html_e( 'Don\'t display error.', MWF_Config::DOMAIN ); ?></label>
|
113 |
</p>
|
114 |
<?php
|
115 |
}
|
form_fields/mw_form_field_submit_button.php → classes/form-fields/class.submit-button.php
RENAMED
@@ -1,20 +1,21 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Name: MW Form Field Submit
|
4 |
-
* Description:
|
5 |
-
* Version: 1.
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created
|
9 |
-
* Modified:
|
10 |
-
* License: GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
-
class
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
-
* input
|
|
|
18 |
*/
|
19 |
public $type = 'button';
|
20 |
|
@@ -26,16 +27,16 @@ class MW_Form_Field_Submit_Button extends MW_Form_Field {
|
|
26 |
protected function set_names() {
|
27 |
return array(
|
28 |
'shortcode_name' => 'mwform_submitButton',
|
29 |
-
'display_name'
|
30 |
);
|
31 |
}
|
32 |
|
33 |
/**
|
34 |
-
*
|
35 |
* $this->defaultsを設定し返す
|
36 |
* @return array defaults
|
37 |
*/
|
38 |
-
protected function
|
39 |
return array(
|
40 |
'name' => '',
|
41 |
'confirm_value' => __( 'Confirm', MWF_Config::DOMAIN ),
|
@@ -44,23 +45,23 @@ class MW_Form_Field_Submit_Button extends MW_Form_Field {
|
|
44 |
}
|
45 |
|
46 |
/**
|
47 |
-
*
|
48 |
* 入力ページでのフォーム項目を返す
|
49 |
* @return string HTML
|
50 |
*/
|
51 |
-
protected function
|
52 |
if ( !empty( $this->atts['confirm_value'] ) ) {
|
53 |
-
return $this->Form->submit(
|
54 |
}
|
55 |
return $this->Form->submit( $this->atts['name'], $this->atts['submit_value'] );
|
56 |
}
|
57 |
|
58 |
/**
|
59 |
-
*
|
60 |
* 確認ページでのフォーム項目を返す
|
61 |
* @return string HTML
|
62 |
*/
|
63 |
-
protected function
|
64 |
return $this->Form->submit( $this->atts['name'], $this->atts['submit_value'] );
|
65 |
}
|
66 |
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Name : MW WP Form Field Submit Button
|
4 |
+
* Description: 確認ボタンと送信ボタンを自動出力
|
5 |
+
* Version : 1.5.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : December 14, 2012
|
9 |
+
* Modified : January 2, 2015
|
10 |
+
* License : GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
+
class MW_WP_Form_Field_Submit_Button extends MW_WP_Form_Abstract_Form_Field {
|
14 |
|
15 |
/**
|
16 |
+
* $type
|
17 |
+
* フォームタグの種類 input|select|button|error|other
|
18 |
+
* @var string
|
19 |
*/
|
20 |
public $type = 'button';
|
21 |
|
27 |
protected function set_names() {
|
28 |
return array(
|
29 |
'shortcode_name' => 'mwform_submitButton',
|
30 |
+
'display_name' => __( 'Confirm & Submit', MWF_Config::DOMAIN ),
|
31 |
);
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* set_defaults
|
36 |
* $this->defaultsを設定し返す
|
37 |
* @return array defaults
|
38 |
*/
|
39 |
+
protected function set_defaults() {
|
40 |
return array(
|
41 |
'name' => '',
|
42 |
'confirm_value' => __( 'Confirm', MWF_Config::DOMAIN ),
|
45 |
}
|
46 |
|
47 |
/**
|
48 |
+
* input_page
|
49 |
* 入力ページでのフォーム項目を返す
|
50 |
* @return string HTML
|
51 |
*/
|
52 |
+
protected function input_page() {
|
53 |
if ( !empty( $this->atts['confirm_value'] ) ) {
|
54 |
+
return $this->Form->submit( MWF_Config::CONFIRM_BUTTON, $this->atts['confirm_value'] );
|
55 |
}
|
56 |
return $this->Form->submit( $this->atts['name'], $this->atts['submit_value'] );
|
57 |
}
|
58 |
|
59 |
/**
|
60 |
+
* confirm_page
|
61 |
* 確認ページでのフォーム項目を返す
|
62 |
* @return string HTML
|
63 |
*/
|
64 |
+
protected function confirm_page() {
|
65 |
return $this->Form->submit( $this->atts['name'], $this->atts['submit_value'] );
|
66 |
}
|
67 |
|
form_fields/mw_form_field_submit.php → classes/form-fields/class.submit.php
RENAMED
@@ -1,20 +1,21 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Name: MW Form Field Submit
|
4 |
-
* Description:
|
5 |
-
* Version: 1.
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created
|
9 |
-
* Modified:
|
10 |
-
* License: GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
-
class
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
-
* input
|
|
|
18 |
*/
|
19 |
public $type = 'button';
|
20 |
|
@@ -26,16 +27,16 @@ class MW_Form_Field_Submit extends MW_Form_Field {
|
|
26 |
protected function set_names() {
|
27 |
return array(
|
28 |
'shortcode_name' => 'mwform_submit',
|
29 |
-
'display_name'
|
30 |
);
|
31 |
}
|
32 |
|
33 |
/**
|
34 |
-
*
|
35 |
* $this->defaultsを設定し返す
|
36 |
* @return array defaults
|
37 |
*/
|
38 |
-
protected function
|
39 |
return array(
|
40 |
'name' => '',
|
41 |
'value' => __( 'Send', MWF_Config::DOMAIN ),
|
@@ -43,21 +44,21 @@ class MW_Form_Field_Submit extends MW_Form_Field {
|
|
43 |
}
|
44 |
|
45 |
/**
|
46 |
-
*
|
47 |
* 入力ページでのフォーム項目を返す
|
48 |
* @return string HTML
|
49 |
*/
|
50 |
-
protected function
|
51 |
return $this->Form->submit( $this->atts['name'], $this->atts['value'] );
|
52 |
}
|
53 |
|
54 |
/**
|
55 |
-
*
|
56 |
* 確認ページでのフォーム項目を返す
|
57 |
* @return string HTML
|
58 |
*/
|
59 |
-
protected function
|
60 |
-
return $this->
|
61 |
}
|
62 |
|
63 |
/**
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Name : MW WP Form Field Submit
|
4 |
+
* Description: 送信ボタンを出力
|
5 |
+
* Version : 1.5.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : December 14, 2012
|
9 |
+
* Modified : January 2, 2015
|
10 |
+
* License : GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
+
class MW_WP_Form_Field_Submit extends MW_WP_Form_Abstract_Form_Field {
|
14 |
|
15 |
/**
|
16 |
+
* $type
|
17 |
+
* フォームタグの種類 input|select|button|error|other
|
18 |
+
* @var string
|
19 |
*/
|
20 |
public $type = 'button';
|
21 |
|
27 |
protected function set_names() {
|
28 |
return array(
|
29 |
'shortcode_name' => 'mwform_submit',
|
30 |
+
'display_name' => __( 'Submit Button', MWF_Config::DOMAIN ),
|
31 |
);
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* set_defaults
|
36 |
* $this->defaultsを設定し返す
|
37 |
* @return array defaults
|
38 |
*/
|
39 |
+
protected function set_defaults() {
|
40 |
return array(
|
41 |
'name' => '',
|
42 |
'value' => __( 'Send', MWF_Config::DOMAIN ),
|
44 |
}
|
45 |
|
46 |
/**
|
47 |
+
* input_page
|
48 |
* 入力ページでのフォーム項目を返す
|
49 |
* @return string HTML
|
50 |
*/
|
51 |
+
protected function input_page() {
|
52 |
return $this->Form->submit( $this->atts['name'], $this->atts['value'] );
|
53 |
}
|
54 |
|
55 |
/**
|
56 |
+
* confirm_page
|
57 |
* 確認ページでのフォーム項目を返す
|
58 |
* @return string HTML
|
59 |
*/
|
60 |
+
protected function confirm_page() {
|
61 |
+
return $this->input_page( $this->atts );
|
62 |
}
|
63 |
|
64 |
/**
|
form_fields/mw_form_field_tel.php → classes/form-fields/class.tel.php
RENAMED
@@ -1,20 +1,21 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Name: MW Form Field Tel
|
4 |
-
* Description:
|
5 |
-
* Version: 1.
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created
|
9 |
-
* Modified:
|
10 |
-
* License: GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
-
class
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
-
* input
|
|
|
18 |
*/
|
19 |
public $type = 'input';
|
20 |
|
@@ -26,16 +27,16 @@ class MW_Form_Field_Tel extends MW_Form_Field {
|
|
26 |
protected function set_names() {
|
27 |
return array(
|
28 |
'shortcode_name' => 'mwform_tel',
|
29 |
-
'display_name'
|
30 |
);
|
31 |
}
|
32 |
|
33 |
/**
|
34 |
-
*
|
35 |
* $this->defaultsを設定し返す
|
36 |
* @return array defaults
|
37 |
*/
|
38 |
-
protected function
|
39 |
return array(
|
40 |
'name' => '',
|
41 |
'show_error' => 'true',
|
@@ -44,28 +45,29 @@ class MW_Form_Field_Tel extends MW_Form_Field {
|
|
44 |
}
|
45 |
|
46 |
/**
|
47 |
-
*
|
48 |
* 入力ページでのフォーム項目を返す
|
49 |
* @return string HTML
|
50 |
*/
|
51 |
-
protected function
|
52 |
$conv_half_alphanumeric = false;
|
53 |
if ( $this->atts['conv_half_alphanumeric'] === 'true' ) {
|
54 |
$conv_half_alphanumeric = true;
|
55 |
}
|
56 |
$_ret = $this->Form->tel( $this->atts['name'], array( 'conv-half-alphanumeric' => $conv_half_alphanumeric ) );
|
57 |
-
if ( $this->atts['show_error'] !== 'false' )
|
58 |
-
$_ret .= $this->
|
|
|
59 |
return $_ret;
|
60 |
}
|
61 |
|
62 |
/**
|
63 |
-
*
|
64 |
* 確認ページでのフォーム項目を返す
|
65 |
* @return string HTML
|
66 |
*/
|
67 |
-
protected function
|
68 |
-
$value = $this->Form->
|
69 |
$_ret = esc_html( $value );
|
70 |
$_ret .= $this->Form->hidden( $this->atts['name'].'[data]', $value );
|
71 |
$_ret .= $this->Form->separator( $this->atts['name'] );
|
@@ -86,12 +88,12 @@ class MW_Form_Field_Tel extends MW_Form_Field {
|
|
86 |
<p>
|
87 |
<strong><?php esc_html_e( 'Dsiplay error', MWF_Config::DOMAIN ); ?></strong>
|
88 |
<?php $show_error = $this->get_value_for_generator( 'show_error', $options ); ?>
|
89 |
-
<input type="checkbox" name="show_error" value="false" <?php checked( 'false', $show_error ); ?> /> <?php esc_html_e( 'Don\'t display error.', MWF_Config::DOMAIN );
|
90 |
</p>
|
91 |
<p>
|
92 |
<strong><?php esc_html_e( 'Convert half alphanumeric', MWF_Config::DOMAIN ); ?></strong>
|
93 |
<?php $conv_half_alphanumeric = $this->get_value_for_generator( 'conv_half_alphanumeric', $options ); ?>
|
94 |
-
<input type="checkbox" name="conv_half_alphanumeric" value="false" <?php checked( 'false', $conv_half_alphanumeric ); ?> /> <?php esc_html_e( 'Don\'t Convert.', MWF_Config::DOMAIN );
|
95 |
</p>
|
96 |
<?php
|
97 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Name : MW WP Form Field Tel
|
4 |
+
* Description: 電話番号フィールドを出力
|
5 |
+
* Version : 1.5.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : December 14, 2012
|
9 |
+
* Modified : January 2, 2015
|
10 |
+
* License : GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
+
class MW_WP_Form_Field_Tel extends MW_WP_Form_Abstract_Form_Field {
|
14 |
|
15 |
/**
|
16 |
+
* $type
|
17 |
+
* フォームタグの種類 input|select|button|error|other
|
18 |
+
* @var string
|
19 |
*/
|
20 |
public $type = 'input';
|
21 |
|
27 |
protected function set_names() {
|
28 |
return array(
|
29 |
'shortcode_name' => 'mwform_tel',
|
30 |
+
'display_name' => __( 'Tel', MWF_Config::DOMAIN ),
|
31 |
);
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* set_defaults
|
36 |
* $this->defaultsを設定し返す
|
37 |
* @return array defaults
|
38 |
*/
|
39 |
+
protected function set_defaults() {
|
40 |
return array(
|
41 |
'name' => '',
|
42 |
'show_error' => 'true',
|
45 |
}
|
46 |
|
47 |
/**
|
48 |
+
* input_page
|
49 |
* 入力ページでのフォーム項目を返す
|
50 |
* @return string HTML
|
51 |
*/
|
52 |
+
protected function input_page() {
|
53 |
$conv_half_alphanumeric = false;
|
54 |
if ( $this->atts['conv_half_alphanumeric'] === 'true' ) {
|
55 |
$conv_half_alphanumeric = true;
|
56 |
}
|
57 |
$_ret = $this->Form->tel( $this->atts['name'], array( 'conv-half-alphanumeric' => $conv_half_alphanumeric ) );
|
58 |
+
if ( $this->atts['show_error'] !== 'false' ) {
|
59 |
+
$_ret .= $this->get_error( $this->atts['name'] );
|
60 |
+
}
|
61 |
return $_ret;
|
62 |
}
|
63 |
|
64 |
/**
|
65 |
+
* confirm_page
|
66 |
* 確認ページでのフォーム項目を返す
|
67 |
* @return string HTML
|
68 |
*/
|
69 |
+
protected function confirm_page() {
|
70 |
+
$value = $this->Form->get_tel_value( $this->atts['name'] );
|
71 |
$_ret = esc_html( $value );
|
72 |
$_ret .= $this->Form->hidden( $this->atts['name'].'[data]', $value );
|
73 |
$_ret .= $this->Form->separator( $this->atts['name'] );
|
88 |
<p>
|
89 |
<strong><?php esc_html_e( 'Dsiplay error', MWF_Config::DOMAIN ); ?></strong>
|
90 |
<?php $show_error = $this->get_value_for_generator( 'show_error', $options ); ?>
|
91 |
+
<label><input type="checkbox" name="show_error" value="false" <?php checked( 'false', $show_error ); ?> /> <?php esc_html_e( 'Don\'t display error.', MWF_Config::DOMAIN ); ?></label>
|
92 |
</p>
|
93 |
<p>
|
94 |
<strong><?php esc_html_e( 'Convert half alphanumeric', MWF_Config::DOMAIN ); ?></strong>
|
95 |
<?php $conv_half_alphanumeric = $this->get_value_for_generator( 'conv_half_alphanumeric', $options ); ?>
|
96 |
+
<label><input type="checkbox" name="conv_half_alphanumeric" value="false" <?php checked( 'false', $conv_half_alphanumeric ); ?> /> <?php esc_html_e( 'Don\'t Convert.', MWF_Config::DOMAIN ); ?></label>
|
97 |
</p>
|
98 |
<?php
|
99 |
}
|
form_fields/mw_form_field_text.php → classes/form-fields/class.text.php
RENAMED
@@ -1,20 +1,21 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Name: MW Form Field Text
|
4 |
-
* Description:
|
5 |
-
* Version: 1.
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created
|
9 |
-
* Modified:
|
10 |
-
* License: GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
-
class
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
-
* input
|
|
|
18 |
*/
|
19 |
public $type = 'input';
|
20 |
|
@@ -26,16 +27,16 @@ class MW_Form_Field_Text extends MW_Form_Field {
|
|
26 |
protected function set_names() {
|
27 |
return array(
|
28 |
'shortcode_name' => 'mwform_text',
|
29 |
-
'display_name'
|
30 |
);
|
31 |
}
|
32 |
|
33 |
/**
|
34 |
-
*
|
35 |
* $this->defaultsを設定し返す
|
36 |
* @return array
|
37 |
*/
|
38 |
-
protected function
|
39 |
return array(
|
40 |
'name' => '',
|
41 |
'id' => '',
|
@@ -49,11 +50,11 @@ class MW_Form_Field_Text extends MW_Form_Field {
|
|
49 |
}
|
50 |
|
51 |
/**
|
52 |
-
*
|
53 |
* 入力ページでのフォーム項目を返す
|
54 |
* @return string html
|
55 |
*/
|
56 |
-
protected function
|
57 |
$conv_half_alphanumeric = false;
|
58 |
if ( $this->atts['conv_half_alphanumeric'] === 'true' ) {
|
59 |
$conv_half_alphanumeric = true;
|
@@ -66,18 +67,19 @@ class MW_Form_Field_Text extends MW_Form_Field {
|
|
66 |
'placeholder' => $this->atts['placeholder'],
|
67 |
'conv-half-alphanumeric' => $conv_half_alphanumeric,
|
68 |
) );
|
69 |
-
if ( $this->atts['show_error'] !== 'false' )
|
70 |
-
$_ret .= $this->
|
|
|
71 |
return $_ret;
|
72 |
}
|
73 |
|
74 |
/**
|
75 |
-
*
|
76 |
* 確認ページでのフォーム項目を返す
|
77 |
* @return string HTML
|
78 |
*/
|
79 |
-
protected function
|
80 |
-
$value = $this->Form->
|
81 |
$_ret = esc_html( $value );
|
82 |
$_ret .= $this->Form->hidden( $this->atts['name'], $value );
|
83 |
return $_ret;
|
@@ -122,12 +124,12 @@ class MW_Form_Field_Text extends MW_Form_Field {
|
|
122 |
<p>
|
123 |
<strong><?php esc_html_e( 'Dsiplay error', MWF_Config::DOMAIN ); ?></strong>
|
124 |
<?php $show_error = $this->get_value_for_generator( 'show_error', $options ); ?>
|
125 |
-
<input type="checkbox" name="show_error" value="false" <?php checked( 'false', $show_error ); ?> /> <?php esc_html_e( 'Don\'t display error.', MWF_Config::DOMAIN );
|
126 |
</p>
|
127 |
<p>
|
128 |
<strong><?php esc_html_e( 'Convert half alphanumeric', MWF_Config::DOMAIN ); ?></strong>
|
129 |
<?php $conv_half_alphanumeric = $this->get_value_for_generator( 'conv_half_alphanumeric', $options ); ?>
|
130 |
-
<input type="checkbox" name="conv_half_alphanumeric" value="true" <?php checked( 'true', $conv_half_alphanumeric ); ?> /> <?php esc_html_e( 'Convert.', MWF_Config::DOMAIN );
|
131 |
</p>
|
132 |
<?php
|
133 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Name : MW WP Form Field Text
|
4 |
+
* Description: テキストフィールドを出力
|
5 |
+
* Version : 1.5.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : December 14, 2012
|
9 |
+
* Modified : January 2, 2015
|
10 |
+
* License : GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
+
class MW_WP_Form_Field_Text extends MW_WP_Form_Abstract_Form_Field {
|
14 |
|
15 |
/**
|
16 |
+
* $type
|
17 |
+
* フォームタグの種類 input|select|button|error|other
|
18 |
+
* @var string
|
19 |
*/
|
20 |
public $type = 'input';
|
21 |
|
27 |
protected function set_names() {
|
28 |
return array(
|
29 |
'shortcode_name' => 'mwform_text',
|
30 |
+
'display_name' => __( 'Text', MWF_Config::DOMAIN ),
|
31 |
);
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* set_defaults
|
36 |
* $this->defaultsを設定し返す
|
37 |
* @return array
|
38 |
*/
|
39 |
+
protected function set_defaults() {
|
40 |
return array(
|
41 |
'name' => '',
|
42 |
'id' => '',
|
50 |
}
|
51 |
|
52 |
/**
|
53 |
+
* input_page
|
54 |
* 入力ページでのフォーム項目を返す
|
55 |
* @return string html
|
56 |
*/
|
57 |
+
protected function input_page() {
|
58 |
$conv_half_alphanumeric = false;
|
59 |
if ( $this->atts['conv_half_alphanumeric'] === 'true' ) {
|
60 |
$conv_half_alphanumeric = true;
|
67 |
'placeholder' => $this->atts['placeholder'],
|
68 |
'conv-half-alphanumeric' => $conv_half_alphanumeric,
|
69 |
) );
|
70 |
+
if ( $this->atts['show_error'] !== 'false' ) {
|
71 |
+
$_ret .= $this->get_error( $this->atts['name'] );
|
72 |
+
}
|
73 |
return $_ret;
|
74 |
}
|
75 |
|
76 |
/**
|
77 |
+
* confirm_page
|
78 |
* 確認ページでのフォーム項目を返す
|
79 |
* @return string HTML
|
80 |
*/
|
81 |
+
protected function confirm_page() {
|
82 |
+
$value = $this->Form->get_raw( $this->atts['name'] );
|
83 |
$_ret = esc_html( $value );
|
84 |
$_ret .= $this->Form->hidden( $this->atts['name'], $value );
|
85 |
return $_ret;
|
124 |
<p>
|
125 |
<strong><?php esc_html_e( 'Dsiplay error', MWF_Config::DOMAIN ); ?></strong>
|
126 |
<?php $show_error = $this->get_value_for_generator( 'show_error', $options ); ?>
|
127 |
+
<label><input type="checkbox" name="show_error" value="false" <?php checked( 'false', $show_error ); ?> /> <?php esc_html_e( 'Don\'t display error.', MWF_Config::DOMAIN ); ?></label>
|
128 |
</p>
|
129 |
<p>
|
130 |
<strong><?php esc_html_e( 'Convert half alphanumeric', MWF_Config::DOMAIN ); ?></strong>
|
131 |
<?php $conv_half_alphanumeric = $this->get_value_for_generator( 'conv_half_alphanumeric', $options ); ?>
|
132 |
+
<label><input type="checkbox" name="conv_half_alphanumeric" value="true" <?php checked( 'true', $conv_half_alphanumeric ); ?> /> <?php esc_html_e( 'Convert.', MWF_Config::DOMAIN ); ?></label>
|
133 |
</p>
|
134 |
<?php
|
135 |
}
|
form_fields/mw_form_field_textarea.php → classes/form-fields/class.textarea.php
RENAMED
@@ -1,20 +1,21 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Name: MW Form Field TextArea
|
4 |
-
* Description:
|
5 |
-
* Version: 1.
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created
|
9 |
-
* Modified:
|
10 |
-
* License: GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
-
class
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
-
* input
|
|
|
18 |
*/
|
19 |
public $type = 'input';
|
20 |
|
@@ -26,16 +27,16 @@ class MW_Form_Field_Textarea extends MW_Form_Field {
|
|
26 |
protected function set_names() {
|
27 |
return array(
|
28 |
'shortcode_name' => 'mwform_textarea',
|
29 |
-
'display_name'
|
30 |
);
|
31 |
}
|
32 |
|
33 |
/**
|
34 |
-
*
|
35 |
* $this->defaultsを設定し返す
|
36 |
* @return array
|
37 |
*/
|
38 |
-
protected function
|
39 |
return array(
|
40 |
'name' => '',
|
41 |
'id' => '',
|
@@ -48,11 +49,11 @@ class MW_Form_Field_Textarea extends MW_Form_Field {
|
|
48 |
}
|
49 |
|
50 |
/**
|
51 |
-
*
|
52 |
* 入力ページでのフォーム項目を返す
|
53 |
* @return string html
|
54 |
*/
|
55 |
-
protected function
|
56 |
$_ret = $this->Form->textarea( $this->atts['name'], array(
|
57 |
'id' => $this->atts['id'],
|
58 |
'cols' => $this->atts['cols'],
|
@@ -60,18 +61,19 @@ class MW_Form_Field_Textarea extends MW_Form_Field {
|
|
60 |
'value' => $this->atts['value'],
|
61 |
'placeholder' => $this->atts['placeholder'],
|
62 |
) );
|
63 |
-
if ( $this->atts['show_error'] !== 'false' )
|
64 |
-
$_ret .= $this->
|
|
|
65 |
return $_ret;
|
66 |
}
|
67 |
|
68 |
/**
|
69 |
-
*
|
70 |
* 確認ページでのフォーム項目を返す
|
71 |
* @return string HTML
|
72 |
*/
|
73 |
-
protected function
|
74 |
-
$value = $this->Form->
|
75 |
$_ret = nl2br( esc_html( $value ) );
|
76 |
$_ret .= $this->Form->hidden( $this->atts['name'], $value );
|
77 |
return $_ret;
|
@@ -116,7 +118,7 @@ class MW_Form_Field_Textarea extends MW_Form_Field {
|
|
116 |
<p>
|
117 |
<strong><?php esc_html_e( 'Dsiplay error', MWF_Config::DOMAIN ); ?></strong>
|
118 |
<?php $show_error = $this->get_value_for_generator( 'show_error', $options ); ?>
|
119 |
-
<input type="checkbox" name="show_error" value="false" <?php checked( 'false', $show_error ); ?> /> <?php esc_html_e( 'Don\'t display error.', MWF_Config::DOMAIN );
|
120 |
</p>
|
121 |
<?php
|
122 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Name : MW WP Form Field TextArea
|
4 |
+
* Description: テキストエリアを出力
|
5 |
+
* Version : 1.5.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : December 14, 2012
|
9 |
+
* Modified : January 2, 2015
|
10 |
+
* License : GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
+
class MW_WP_Form_Field_Textarea extends MW_WP_Form_Abstract_Form_Field {
|
14 |
|
15 |
/**
|
16 |
+
* $type
|
17 |
+
* フォームタグの種類 input|select|button|error|other
|
18 |
+
* @var string
|
19 |
*/
|
20 |
public $type = 'input';
|
21 |
|
27 |
protected function set_names() {
|
28 |
return array(
|
29 |
'shortcode_name' => 'mwform_textarea',
|
30 |
+
'display_name' => __( 'Textarea', MWF_Config::DOMAIN ),
|
31 |
);
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* set_defaults
|
36 |
* $this->defaultsを設定し返す
|
37 |
* @return array
|
38 |
*/
|
39 |
+
protected function set_defaults() {
|
40 |
return array(
|
41 |
'name' => '',
|
42 |
'id' => '',
|
49 |
}
|
50 |
|
51 |
/**
|
52 |
+
* input_page
|
53 |
* 入力ページでのフォーム項目を返す
|
54 |
* @return string html
|
55 |
*/
|
56 |
+
protected function input_page() {
|
57 |
$_ret = $this->Form->textarea( $this->atts['name'], array(
|
58 |
'id' => $this->atts['id'],
|
59 |
'cols' => $this->atts['cols'],
|
61 |
'value' => $this->atts['value'],
|
62 |
'placeholder' => $this->atts['placeholder'],
|
63 |
) );
|
64 |
+
if ( $this->atts['show_error'] !== 'false' ) {
|
65 |
+
$_ret .= $this->get_error( $this->atts['name'] );
|
66 |
+
}
|
67 |
return $_ret;
|
68 |
}
|
69 |
|
70 |
/**
|
71 |
+
* confirm_page
|
72 |
* 確認ページでのフォーム項目を返す
|
73 |
* @return string HTML
|
74 |
*/
|
75 |
+
protected function confirm_page() {
|
76 |
+
$value = $this->Form->get_raw( $this->atts['name'] );
|
77 |
$_ret = nl2br( esc_html( $value ) );
|
78 |
$_ret .= $this->Form->hidden( $this->atts['name'], $value );
|
79 |
return $_ret;
|
118 |
<p>
|
119 |
<strong><?php esc_html_e( 'Dsiplay error', MWF_Config::DOMAIN ); ?></strong>
|
120 |
<?php $show_error = $this->get_value_for_generator( 'show_error', $options ); ?>
|
121 |
+
<label><input type="checkbox" name="show_error" value="false" <?php checked( 'false', $show_error ); ?> /> <?php esc_html_e( 'Don\'t display error.', MWF_Config::DOMAIN ); ?></label>
|
122 |
</p>
|
123 |
<?php
|
124 |
}
|
form_fields/mw_form_field_zip.php → classes/form-fields/class.zip.php
RENAMED
@@ -1,20 +1,21 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Name: MW Form Field Zip
|
4 |
-
* Description:
|
5 |
-
* Version: 1.
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created
|
9 |
-
* Modified:
|
10 |
-
* License: GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
-
class
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
-
* input
|
|
|
18 |
*/
|
19 |
public $type = 'input';
|
20 |
|
@@ -26,16 +27,16 @@ class MW_Form_Field_Zip extends MW_Form_Field {
|
|
26 |
protected function set_names() {
|
27 |
return array(
|
28 |
'shortcode_name' => 'mwform_zip',
|
29 |
-
'display_name'
|
30 |
);
|
31 |
}
|
32 |
|
33 |
/**
|
34 |
-
*
|
35 |
* $this->defaultsを設定し返す
|
36 |
* @return array defaults
|
37 |
*/
|
38 |
-
protected function
|
39 |
return array(
|
40 |
'name' => '',
|
41 |
'show_error' => 'true',
|
@@ -44,28 +45,29 @@ class MW_Form_Field_Zip extends MW_Form_Field {
|
|
44 |
}
|
45 |
|
46 |
/**
|
47 |
-
*
|
48 |
* 入力ページでのフォーム項目を返す
|
49 |
* @return string HTML
|
50 |
*/
|
51 |
-
protected function
|
52 |
$conv_half_alphanumeric = false;
|
53 |
if ( $this->atts['conv_half_alphanumeric'] === 'true' ) {
|
54 |
$conv_half_alphanumeric = true;
|
55 |
}
|
56 |
$_ret = $this->Form->zip( $this->atts['name'], array( 'conv-half-alphanumeric' => $conv_half_alphanumeric ) );
|
57 |
-
if ( $this->atts['show_error'] !== 'false' )
|
58 |
-
$_ret .= $this->
|
|
|
59 |
return $_ret;
|
60 |
}
|
61 |
|
62 |
/**
|
63 |
-
*
|
64 |
* 確認ページでのフォーム項目を返す
|
65 |
* @return string HTML
|
66 |
*/
|
67 |
-
protected function
|
68 |
-
$value = $this->Form->
|
69 |
$_ret = esc_html( $value );
|
70 |
$_ret .= $this->Form->hidden( $this->atts['name'].'[data]', $value );
|
71 |
$_ret .= $this->Form->separator( $this->atts['name'] );
|
@@ -86,12 +88,12 @@ class MW_Form_Field_Zip extends MW_Form_Field {
|
|
86 |
<p>
|
87 |
<strong><?php esc_html_e( 'Dsiplay error', MWF_Config::DOMAIN ); ?></strong>
|
88 |
<?php $show_error = $this->get_value_for_generator( 'show_error', $options ); ?>
|
89 |
-
<input type="checkbox" name="show_error" value="false" <?php checked( 'false', $show_error ); ?> /> <?php esc_html_e( 'Don\'t display error.', MWF_Config::DOMAIN );
|
90 |
</p>
|
91 |
<p>
|
92 |
<strong><?php esc_html_e( 'Convert half alphanumeric', MWF_Config::DOMAIN ); ?></strong>
|
93 |
<?php $conv_half_alphanumeric = $this->get_value_for_generator( 'conv_half_alphanumeric', $options ); ?>
|
94 |
-
<input type="checkbox" name="conv_half_alphanumeric" value="false" <?php checked( 'false', $conv_half_alphanumeric ); ?> /> <?php esc_html_e( 'Don\'t Convert.', MWF_Config::DOMAIN );
|
95 |
</p>
|
96 |
<?php
|
97 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Name : MW WP Form Field Zip
|
4 |
+
* Description: 郵便番号フィールドを出力
|
5 |
+
* Version : 1.5.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : December 14, 2012
|
9 |
+
* Modified : January 2, 2015
|
10 |
+
* License : GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
+
class MW_WP_Form_Field_Zip extends MW_WP_Form_Abstract_Form_Field {
|
14 |
|
15 |
/**
|
16 |
+
* $type
|
17 |
+
* フォームタグの種類 input|select|button|error|other
|
18 |
+
* @var string
|
19 |
*/
|
20 |
public $type = 'input';
|
21 |
|
27 |
protected function set_names() {
|
28 |
return array(
|
29 |
'shortcode_name' => 'mwform_zip',
|
30 |
+
'display_name' => __( 'Zip Code', MWF_Config::DOMAIN ),
|
31 |
);
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* set_defaults
|
36 |
* $this->defaultsを設定し返す
|
37 |
* @return array defaults
|
38 |
*/
|
39 |
+
protected function set_defaults() {
|
40 |
return array(
|
41 |
'name' => '',
|
42 |
'show_error' => 'true',
|
45 |
}
|
46 |
|
47 |
/**
|
48 |
+
* input_page
|
49 |
* 入力ページでのフォーム項目を返す
|
50 |
* @return string HTML
|
51 |
*/
|
52 |
+
protected function input_page() {
|
53 |
$conv_half_alphanumeric = false;
|
54 |
if ( $this->atts['conv_half_alphanumeric'] === 'true' ) {
|
55 |
$conv_half_alphanumeric = true;
|
56 |
}
|
57 |
$_ret = $this->Form->zip( $this->atts['name'], array( 'conv-half-alphanumeric' => $conv_half_alphanumeric ) );
|
58 |
+
if ( $this->atts['show_error'] !== 'false' ) {
|
59 |
+
$_ret .= $this->get_error( $this->atts['name'] );
|
60 |
+
}
|
61 |
return $_ret;
|
62 |
}
|
63 |
|
64 |
/**
|
65 |
+
* confirm_page
|
66 |
* 確認ページでのフォーム項目を返す
|
67 |
* @return string HTML
|
68 |
*/
|
69 |
+
protected function confirm_page() {
|
70 |
+
$value = $this->Form->get_zip_value( $this->atts['name'] );
|
71 |
$_ret = esc_html( $value );
|
72 |
$_ret .= $this->Form->hidden( $this->atts['name'].'[data]', $value );
|
73 |
$_ret .= $this->Form->separator( $this->atts['name'] );
|
88 |
<p>
|
89 |
<strong><?php esc_html_e( 'Dsiplay error', MWF_Config::DOMAIN ); ?></strong>
|
90 |
<?php $show_error = $this->get_value_for_generator( 'show_error', $options ); ?>
|
91 |
+
<label><input type="checkbox" name="show_error" value="false" <?php checked( 'false', $show_error ); ?> /> <?php esc_html_e( 'Don\'t display error.', MWF_Config::DOMAIN ); ?></label>
|
92 |
</p>
|
93 |
<p>
|
94 |
<strong><?php esc_html_e( 'Convert half alphanumeric', MWF_Config::DOMAIN ); ?></strong>
|
95 |
<?php $conv_half_alphanumeric = $this->get_value_for_generator( 'conv_half_alphanumeric', $options ); ?>
|
96 |
+
<label><input type="checkbox" name="conv_half_alphanumeric" value="false" <?php checked( 'false', $conv_half_alphanumeric ); ?> /> <?php esc_html_e( 'Don\'t Convert.', MWF_Config::DOMAIN ); ?></label>
|
97 |
</p>
|
98 |
<?php
|
99 |
}
|
classes/functions.php
ADDED
@@ -0,0 +1,311 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Name : MWF Functions
|
4 |
+
* Description: 関数
|
5 |
+
* Version : 1.3.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : May 29, 2013
|
9 |
+
* Modified : July 24, 2014
|
10 |
+
* License : GPLv2
|
11 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
+
*/
|
13 |
+
class MWF_Functions {
|
14 |
+
|
15 |
+
/**
|
16 |
+
* is_numeric
|
17 |
+
* 引数で渡された変数が存在し、かつ数値であるなら true
|
18 |
+
* @param string $value 参照渡し
|
19 |
+
* @return bool
|
20 |
+
*/
|
21 |
+
public static function is_numeric( &$value ) {
|
22 |
+
if ( isset( $value ) && preg_match( '/^\d+$/', $value ) ) {
|
23 |
+
return true;
|
24 |
+
}
|
25 |
+
return false;
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* array_clean
|
30 |
+
* 配列の空要素を削除
|
31 |
+
* @param array $array
|
32 |
+
* @return array
|
33 |
+
*/
|
34 |
+
public static function array_clean( $array ) {
|
35 |
+
return array_merge( array_diff( $array, array( '' ) ) );
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* is_empty
|
40 |
+
* 値が空(0は許可)
|
41 |
+
* @param mixed
|
42 |
+
* @return bool
|
43 |
+
*/
|
44 |
+
public static function is_empty( $value ) {
|
45 |
+
if ( $value === array() || $value === '' || $value === null ) {
|
46 |
+
return true;
|
47 |
+
} else {
|
48 |
+
return false;
|
49 |
+
}
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* fileurl_to_path
|
54 |
+
* ファイルURLをファイルパスに変換
|
55 |
+
* @param string $fileurl
|
56 |
+
* @return string
|
57 |
+
*/
|
58 |
+
public static function fileurl_to_path( $fileurl ) {
|
59 |
+
$wp_upload_dir = wp_upload_dir();
|
60 |
+
if ( preg_match( '/^https?:\/\//', $fileurl ) ) {
|
61 |
+
$baseurl = preg_replace( '/^https?:\/\/(.+)$/', '$1', $wp_upload_dir['baseurl'] );
|
62 |
+
$fileurl = preg_replace( '/^https?:\/\/(.+)$/', '$1', $fileurl );
|
63 |
+
$filepath = str_replace(
|
64 |
+
$baseurl,
|
65 |
+
realpath( $wp_upload_dir['basedir'] ),
|
66 |
+
$fileurl
|
67 |
+
);
|
68 |
+
return $filepath;
|
69 |
+
}
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* filepath_to_url
|
74 |
+
* ファイルパスをURLに変換
|
75 |
+
* @param string $filepath
|
76 |
+
* @return string
|
77 |
+
*/
|
78 |
+
public static function filepath_to_url( $filepath ) {
|
79 |
+
$wp_upload_dir = wp_upload_dir();
|
80 |
+
$fileurl = str_replace(
|
81 |
+
realpath( $wp_upload_dir['basedir'] ),
|
82 |
+
$wp_upload_dir['baseurl'],
|
83 |
+
$filepath
|
84 |
+
);
|
85 |
+
if ( is_ssl() ) {
|
86 |
+
$fileurl = preg_replace( '/^https?:\/\//', 'https://', $fileurl );
|
87 |
+
}
|
88 |
+
return $fileurl;
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* convert_eol
|
93 |
+
* 改行コードを \n に統一
|
94 |
+
* @param sring $string
|
95 |
+
* @return string $string
|
96 |
+
*/
|
97 |
+
public static function convert_eol( $string ) {
|
98 |
+
return preg_replace( "/\r\n|\r|\n/", "\n", $string );
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* deprecated_message
|
103 |
+
* 古いメソッドを使った場合にエラーを出力
|
104 |
+
* @param string $function_name メソッド名
|
105 |
+
* @param string $new_function 代替のメソッド名
|
106 |
+
*/
|
107 |
+
public static function deprecated_message( $function_name, $new_function = '' ) {
|
108 |
+
global $mwform_deprecated_message;
|
109 |
+
$mwform_deprecated_message .= '<div class="error ' . esc_attr( MWF_Config::NAME ) . '-deprecated-message">';
|
110 |
+
$mwform_deprecated_message .= sprintf(
|
111 |
+
'MW WP Form dosen\'t support "%s" already. This method will be removed in the next version. ',
|
112 |
+
$function_name
|
113 |
+
);
|
114 |
+
if ( $new_function ) {
|
115 |
+
$mwform_deprecated_message .= sprintf( 'You should use "%s". ', $new_function );
|
116 |
+
}
|
117 |
+
$debug_backtrace = debug_backtrace();
|
118 |
+
array_shift( $debug_backtrace );
|
119 |
+
foreach ( $debug_backtrace as $value ) {
|
120 |
+
if ( isset( $value['file'], $value['line'] ) ) {
|
121 |
+
$mwform_deprecated_message .= sprintf( '%s line %d', $value['file'], $value['line'] );
|
122 |
+
}
|
123 |
+
break;
|
124 |
+
}
|
125 |
+
$mwform_deprecated_message .= '</div>';
|
126 |
+
if ( is_admin() ) {
|
127 |
+
if ( current_filter() === 'admin_notices' ) {
|
128 |
+
self::display_deprecated_message();
|
129 |
+
} else {
|
130 |
+
add_action( 'admin_notices', 'MWF_Functions::display_deprecated_message' );
|
131 |
+
}
|
132 |
+
} else {
|
133 |
+
if ( current_filter() === 'the_content' ) {
|
134 |
+
self::display_deprecated_message();
|
135 |
+
} else {
|
136 |
+
add_filter( 'the_content', 'MWF_Functions::return_deprecated_message' );
|
137 |
+
}
|
138 |
+
}
|
139 |
+
}
|
140 |
+
public static function display_deprecated_message() {
|
141 |
+
global $mwform_deprecated_message;
|
142 |
+
$content = $mwform_deprecated_message;
|
143 |
+
unset( $mwform_deprecated_message );
|
144 |
+
echo $content;
|
145 |
+
}
|
146 |
+
public static function return_deprecated_message( $content ) {
|
147 |
+
global $mwform_deprecated_message;
|
148 |
+
$content = $mwform_deprecated_message . $content;
|
149 |
+
unset( $mwform_deprecated_message );
|
150 |
+
return $content;
|
151 |
+
}
|
152 |
+
|
153 |
+
/**
|
154 |
+
* move_temp_file_to_upload_dir
|
155 |
+
* Tempディレクトリからuploadディレクトリにファイルを移動。
|
156 |
+
* @param string ファイルパス
|
157 |
+
* @return bool
|
158 |
+
*/
|
159 |
+
public static function move_temp_file_to_upload_dir( $filepath ) {
|
160 |
+
$tempdir = dirname( $filepath );
|
161 |
+
$filename = basename( $filepath );
|
162 |
+
$wp_upload_dir = wp_upload_dir();
|
163 |
+
$uploaddir = realpath( $wp_upload_dir['path'] );
|
164 |
+
$new_filename = wp_unique_filename( $uploaddir, $filename );
|
165 |
+
|
166 |
+
if ( $tempdir == $uploaddir ) {
|
167 |
+
return $filepath;
|
168 |
+
}
|
169 |
+
if ( rename( $filepath, trailingslashit( $uploaddir ) . $new_filename ) ) {
|
170 |
+
return trailingslashit( $uploaddir ) . $new_filename;
|
171 |
+
}
|
172 |
+
return $filepath;
|
173 |
+
}
|
174 |
+
|
175 |
+
/**
|
176 |
+
* save_attachments_in_media
|
177 |
+
* 添付ファイルをメディアに保存、投稿データに添付ファイルのキー(配列)を保存
|
178 |
+
* $this->settings が確定した後でのみ利用可能
|
179 |
+
* @param int post_id
|
180 |
+
* @param array ( ファイルのname属性値 => ファイルパス, … )
|
181 |
+
* @param int 生成フォーム(usedb)の post_id
|
182 |
+
*/
|
183 |
+
public static function save_attachments_in_media( $post_id, $attachments, $form_key_post_id ) {
|
184 |
+
require_once( ABSPATH . 'wp-admin' . '/includes/media.php' );
|
185 |
+
require_once( ABSPATH . 'wp-admin' . '/includes/image.php' );
|
186 |
+
$save_attached_key = array();
|
187 |
+
foreach ( $attachments as $key => $filepath ) {
|
188 |
+
if ( !self::check_file_type( $filepath ) ) {
|
189 |
+
continue;
|
190 |
+
}
|
191 |
+
|
192 |
+
$wp_check_filetype = wp_check_filetype( $filepath );
|
193 |
+
$post_type = get_post_type_object( MWF_Config::DBDATA . $form_key_post_id );
|
194 |
+
$attachment = array(
|
195 |
+
'post_mime_type' => $wp_check_filetype['type'],
|
196 |
+
'post_title' => $key,
|
197 |
+
'post_status' => 'inherit',
|
198 |
+
'post_content' => __( 'Uploaded from ', MWF_Config::DOMAIN ) . $post_type->label,
|
199 |
+
);
|
200 |
+
$attach_id = wp_insert_attachment( $attachment, $filepath, $post_id );
|
201 |
+
$attach_data = wp_generate_attachment_metadata( $attach_id, $filepath );
|
202 |
+
$update_attachment_flg = wp_update_attachment_metadata( $attach_id, $attach_data );
|
203 |
+
if ( $attach_id ) {
|
204 |
+
// 代わりにここで attachment_id を保存
|
205 |
+
update_post_meta( $post_id, $key, $attach_id );
|
206 |
+
// $key が 添付ファイルのキーであるとわかるように隠し設定を保存
|
207 |
+
$save_attached_key[] = $key;
|
208 |
+
}
|
209 |
+
}
|
210 |
+
if ( $save_attached_key ) {
|
211 |
+
update_post_meta( $post_id, '_' . MWF_Config::UPLOAD_FILE_KEYS, $save_attached_key );
|
212 |
+
}
|
213 |
+
}
|
214 |
+
|
215 |
+
/**
|
216 |
+
* check_file_type
|
217 |
+
* @param string $filepath アップロードされたファイルのパス
|
218 |
+
* @param string $filename ファイル名(未アップロード時の$_FILEの検査の場合、temp_nameは乱数になっているため)
|
219 |
+
* @return bool
|
220 |
+
*/
|
221 |
+
public static function check_file_type( $filepath, $filename = '' ) {
|
222 |
+
// WordPress( get_allowed_mime_types ) で許可されたファイルタイプ限定
|
223 |
+
if ( $filename ) {
|
224 |
+
$wp_check_filetype = wp_check_filetype( $filename );
|
225 |
+
} else {
|
226 |
+
$wp_check_filetype = wp_check_filetype( $filepath );
|
227 |
+
}
|
228 |
+
if ( empty( $wp_check_filetype['type'] ) ) {
|
229 |
+
return false;
|
230 |
+
}
|
231 |
+
|
232 |
+
// 1つの拡張子に対し複数のMIMEタイプを持つファイルの対応
|
233 |
+
switch ( $wp_check_filetype['ext'] ) {
|
234 |
+
case 'avi' :
|
235 |
+
$wp_check_filetype['type'] = array(
|
236 |
+
'application/x-troff-msvideo',
|
237 |
+
'video/avi',
|
238 |
+
'video/msvideo',
|
239 |
+
'video/x-msvideo',
|
240 |
+
);
|
241 |
+
break;
|
242 |
+
case 'mp3' :
|
243 |
+
$wp_check_filetype['type'] = array(
|
244 |
+
'audio/mpeg3',
|
245 |
+
'audio/x-mpeg3',
|
246 |
+
'video/mpeg',
|
247 |
+
'video/x-mpeg',
|
248 |
+
'audio/mpeg',
|
249 |
+
);
|
250 |
+
break;
|
251 |
+
case 'mpg' :
|
252 |
+
$wp_check_filetype['type'] = array(
|
253 |
+
'audio/mpeg',
|
254 |
+
'video/mpeg',
|
255 |
+
);
|
256 |
+
break;
|
257 |
+
case 'docx' :
|
258 |
+
case 'xlsx' :
|
259 |
+
case 'pptx' :
|
260 |
+
$wp_check_filetype['type'] = array(
|
261 |
+
$wp_check_filetype['type'],
|
262 |
+
'application/zip',
|
263 |
+
);
|
264 |
+
break;
|
265 |
+
}
|
266 |
+
|
267 |
+
if ( version_compare( phpversion(), '5.3.0' ) >= 0 ) {
|
268 |
+
$finfo = new finfo( FILEINFO_MIME_TYPE );
|
269 |
+
$type = $finfo->file( $filepath );
|
270 |
+
if ( is_array( $wp_check_filetype['type'] ) ) {
|
271 |
+
if ( !( $finfo !== false && in_array( $type, $wp_check_filetype['type'] ) ) ) {
|
272 |
+
return false;
|
273 |
+
}
|
274 |
+
} else {
|
275 |
+
if ( !( $finfo !== false && $type === $wp_check_filetype['type'] ) ) {
|
276 |
+
return false;
|
277 |
+
}
|
278 |
+
}
|
279 |
+
}
|
280 |
+
return true;
|
281 |
+
}
|
282 |
+
|
283 |
+
/**
|
284 |
+
* get_tracking_number_title
|
285 |
+
* @param string $post_type 問い合わせデータの投稿タイプ名
|
286 |
+
* @return string
|
287 |
+
*/
|
288 |
+
public static function get_tracking_number_title( $post_type ) {
|
289 |
+
$tracking_number_title = esc_html__( 'Tracking Number', MWF_Config::DOMAIN );
|
290 |
+
$form_key = self::contact_data_post_type_to_form_key( $post_type );
|
291 |
+
if ( $form_key ) {
|
292 |
+
$tracking_number_title = apply_filters(
|
293 |
+
'mwform_tracking_number_title_' . $form_key,
|
294 |
+
$tracking_number_title
|
295 |
+
);
|
296 |
+
}
|
297 |
+
return $tracking_number_title;
|
298 |
+
}
|
299 |
+
|
300 |
+
/**
|
301 |
+
* contact_data_post_type_to_form_key
|
302 |
+
* @param string $post_type 問い合わせデータの投稿タイプ名
|
303 |
+
* @return string|null フォーム識別子
|
304 |
+
*/
|
305 |
+
public static function contact_data_post_type_to_form_key( $post_type ) {
|
306 |
+
if ( preg_match( '/^' . MWF_Config::DBDATA . '(\d+)$/', $post_type, $match ) ) {
|
307 |
+
$form_key = MWF_Config::NAME . '-' . $match[1];
|
308 |
+
return $form_key;
|
309 |
+
}
|
310 |
+
}
|
311 |
+
}
|
system/mw_form_field.php → classes/models/class.abstract-form-field.php
RENAMED
@@ -1,77 +1,110 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Name: MW Form Field
|
4 |
* Description: フォームフィールドの抽象クラス
|
5 |
-
* Version: 1.
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created
|
9 |
-
* Modified:
|
10 |
-
* License: GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
|
|
|
|
13 |
abstract class MW_Form_Field {
|
14 |
|
15 |
/**
|
16 |
-
*
|
|
|
17 |
*/
|
18 |
protected $shortcode_name;
|
19 |
|
20 |
/**
|
21 |
-
*
|
|
|
22 |
*/
|
23 |
protected $display_name;
|
24 |
|
25 |
/**
|
26 |
-
*
|
|
|
27 |
*/
|
28 |
protected $Form;
|
29 |
|
30 |
/**
|
31 |
-
*
|
|
|
|
|
32 |
*/
|
33 |
protected $defaults = array();
|
34 |
|
35 |
/**
|
36 |
-
*
|
|
|
|
|
37 |
*/
|
38 |
protected $atts = array();
|
39 |
|
40 |
/**
|
41 |
-
*
|
|
|
|
|
42 |
*/
|
43 |
protected $Error;
|
44 |
|
45 |
/**
|
46 |
-
*
|
|
|
|
|
47 |
*/
|
48 |
-
protected $
|
49 |
|
50 |
/**
|
51 |
-
*
|
52 |
-
* input
|
|
|
53 |
*/
|
54 |
protected $type = 'other';
|
55 |
|
56 |
/**
|
57 |
-
*
|
|
|
|
|
58 |
*/
|
59 |
protected $qtags = array(
|
60 |
-
'id'
|
61 |
'display' => '',
|
62 |
-
'arg1'
|
63 |
-
'arg2'
|
64 |
);
|
65 |
|
66 |
/**
|
67 |
* __construct
|
68 |
*/
|
69 |
public function __construct() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
$this->_set_names();
|
71 |
-
|
72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
$this->_add_mwform_tag_generator();
|
74 |
-
|
|
|
75 |
}
|
76 |
|
77 |
/**
|
@@ -82,13 +115,13 @@ abstract class MW_Form_Field {
|
|
82 |
protected function set_names() {
|
83 |
return array(
|
84 |
'shortcode_name' => $this->shortcode_name,
|
85 |
-
'display_name'
|
86 |
);
|
87 |
}
|
88 |
private function _set_names() {
|
89 |
$args = $this->set_names();
|
90 |
$this->shortcode_name = $args['shortcode_name'];
|
91 |
-
$this->display_name
|
92 |
}
|
93 |
|
94 |
/**
|
@@ -99,125 +132,182 @@ abstract class MW_Form_Field {
|
|
99 |
* @param string $arg2 終了タグ(ショートコード)
|
100 |
*/
|
101 |
protected function set_qtags( $id, $display, $arg1, $arg2 = '' ) {
|
102 |
-
MWF_Functions::deprecated_message(
|
|
|
|
|
|
|
103 |
$this->qtags = array(
|
104 |
-
'id'
|
105 |
'display' => $display,
|
106 |
-
'arg1'
|
107 |
-
'arg2'
|
108 |
);
|
109 |
}
|
110 |
|
111 |
/**
|
112 |
-
*
|
113 |
* @param string $key name属性
|
114 |
* @return string エラーHTML
|
115 |
*/
|
116 |
-
protected function
|
117 |
$_ret = '';
|
118 |
-
if ( is_array( $this->Error->
|
119 |
$start_tag = '<span class="error">';
|
120 |
$end_tag = '</span>';
|
121 |
-
foreach ( $this->Error->
|
122 |
$rule = strtolower( $rule );
|
123 |
-
$error = apply_filters(
|
|
|
|
|
|
|
|
|
|
|
124 |
$error_html = apply_filters( 'mwform_error_message_html',
|
125 |
$start_tag . esc_html( $error ) . $end_tag,
|
126 |
$error,
|
127 |
$start_tag,
|
128 |
$end_tag,
|
129 |
-
$this->
|
130 |
$key,
|
131 |
$rule
|
132 |
);
|
133 |
$_ret .= $error_html;
|
134 |
}
|
135 |
}
|
136 |
-
if ( $_ret )
|
137 |
-
return apply_filters( 'mwform_error_message_wrapper', $_ret, $this->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
}
|
139 |
|
140 |
/**
|
141 |
-
*
|
142 |
* $this->defaultsを設定し返す
|
143 |
* @return array defaults
|
144 |
*/
|
145 |
-
|
|
|
|
|
146 |
|
147 |
/**
|
148 |
-
*
|
149 |
* 入力ページでのフォーム項目を返す
|
150 |
* @param array $atts
|
151 |
* @return string HTML
|
152 |
*/
|
153 |
-
|
154 |
-
|
|
|
|
|
155 |
if ( isset( $this->defaults['value'], $atts['name'] ) && !isset( $atts['value'] ) ) {
|
156 |
-
$atts['value'] = apply_filters(
|
|
|
|
|
|
|
|
|
157 |
}
|
158 |
$this->atts = shortcode_atts( $this->defaults, $atts );
|
159 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
}
|
161 |
|
162 |
/**
|
163 |
-
*
|
164 |
* 確認ページでのフォーム項目を返す
|
165 |
* @param array $atts
|
166 |
* @return string HTML
|
167 |
*/
|
168 |
-
|
169 |
-
|
|
|
|
|
170 |
$this->atts = shortcode_atts( $this->defaults, $atts );
|
171 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
172 |
}
|
173 |
|
174 |
/**
|
175 |
-
*
|
176 |
* フォーム項目を返す
|
177 |
-
* @param
|
178 |
-
* @param string $
|
179 |
-
* @param
|
180 |
-
* @param string $
|
181 |
*/
|
182 |
-
public function add_shortcode(
|
183 |
if ( !empty( $this->shortcode_name ) ) {
|
184 |
-
$this->Form
|
185 |
-
$this->Error
|
186 |
-
$this->
|
187 |
-
switch( $
|
188 |
case 'input' :
|
189 |
-
add_shortcode( $this->shortcode_name, array( $this, '
|
190 |
break;
|
191 |
case 'confirm' :
|
192 |
-
add_shortcode( $this->shortcode_name, array( $this, '
|
|
|
|
|
193 |
break;
|
194 |
default :
|
195 |
-
exit( '$
|
196 |
}
|
197 |
}
|
198 |
}
|
199 |
|
200 |
/**
|
201 |
-
*
|
202 |
-
*
|
203 |
* @param string $_children
|
204 |
* @return array $children
|
205 |
*/
|
206 |
-
|
207 |
$children = array();
|
208 |
if ( !empty( $_children ) && !is_array( $_children ) ) {
|
209 |
$_children = explode( ',', $_children );
|
210 |
}
|
211 |
if ( is_array( $_children ) ) {
|
|
|
212 |
foreach ( $_children as $child ) {
|
213 |
-
$
|
|
|
|
|
|
|
|
|
|
|
214 |
}
|
215 |
}
|
216 |
-
if ( $this->
|
217 |
-
$children = apply_filters( 'mwform_choices_' . $this->
|
218 |
}
|
219 |
return $children;
|
220 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
221 |
|
222 |
/**
|
223 |
* _add_mwform_tag_generator
|
@@ -259,8 +349,9 @@ abstract class MW_Form_Field {
|
|
259 |
*/
|
260 |
public function mwform_tag_generator_option() {
|
261 |
$display_name = $this->qtags['display'];
|
262 |
-
if ( $this->display_name )
|
263 |
$display_name = $this->display_name;
|
|
|
264 |
?>
|
265 |
<option value="<?php echo esc_attr( $this->shortcode_name ); ?>"><?php echo esc_html( $display_name ); ?></option>
|
266 |
<?php
|
@@ -268,7 +359,7 @@ abstract class MW_Form_Field {
|
|
268 |
|
269 |
/**
|
270 |
* mwform_form_fields
|
271 |
-
* @param array $form_fields
|
272 |
* @return array $form_fields
|
273 |
*/
|
274 |
public function mwform_form_fields( array $form_fields ) {
|
@@ -284,6 +375,14 @@ abstract class MW_Form_Field {
|
|
284 |
return $this->display_name;
|
285 |
}
|
286 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
287 |
/**
|
288 |
* get_value_for_generator
|
289 |
* MW WP Fomr Generator 用
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Name : MW WP Form Abstract Form Field
|
4 |
* Description: フォームフィールドの抽象クラス
|
5 |
+
* Version : 1.7.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : December 14, 2012
|
9 |
+
* Modified : January 2, 2015
|
10 |
+
* License : GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
+
abstract class MW_WP_Form_Abstract_Form_Field extends MW_Form_Field {
|
14 |
+
}
|
15 |
abstract class MW_Form_Field {
|
16 |
|
17 |
/**
|
18 |
+
* $shortcode_name
|
19 |
+
* @var string
|
20 |
*/
|
21 |
protected $shortcode_name;
|
22 |
|
23 |
/**
|
24 |
+
* $display_name
|
25 |
+
* @var string
|
26 |
*/
|
27 |
protected $display_name;
|
28 |
|
29 |
/**
|
30 |
+
* $Form
|
31 |
+
* @var MW_WP_Form_Form
|
32 |
*/
|
33 |
protected $Form;
|
34 |
|
35 |
/**
|
36 |
+
* $defaults
|
37 |
+
* 属性値等初期値
|
38 |
+
* @var array
|
39 |
*/
|
40 |
protected $defaults = array();
|
41 |
|
42 |
/**
|
43 |
+
* $atts
|
44 |
+
* 属性値
|
45 |
+
* @var array
|
46 |
*/
|
47 |
protected $atts = array();
|
48 |
|
49 |
/**
|
50 |
+
* $Error
|
51 |
+
* エラーオブジェクト
|
52 |
+
* @var Error
|
53 |
*/
|
54 |
protected $Error;
|
55 |
|
56 |
/**
|
57 |
+
* $form_key
|
58 |
+
* フォーム識別子
|
59 |
+
* @var string
|
60 |
*/
|
61 |
+
protected $form_key;
|
62 |
|
63 |
/**
|
64 |
+
* $type
|
65 |
+
* フォームタグの種類 input|select|button|error|other
|
66 |
+
* @var string
|
67 |
*/
|
68 |
protected $type = 'other';
|
69 |
|
70 |
/**
|
71 |
+
* $qtags
|
72 |
+
* qtagsの引数
|
73 |
+
* @var array
|
74 |
*/
|
75 |
protected $qtags = array(
|
76 |
+
'id' => '',
|
77 |
'display' => '',
|
78 |
+
'arg1' => '',
|
79 |
+
'arg2' => '',
|
80 |
);
|
81 |
|
82 |
/**
|
83 |
* __construct
|
84 |
*/
|
85 |
public function __construct() {
|
86 |
+
$parent_class = get_parent_class( $this );
|
87 |
+
$class = get_class( $this );
|
88 |
+
if ( is_admin() && in_array( 'MW_Form_Field', array( $parent_class, $class ) ) ) {
|
89 |
+
MWF_Functions::deprecated_message(
|
90 |
+
'MW_Form_Field',
|
91 |
+
'MW_WP_Form_Abstract_Form_Field'
|
92 |
+
);
|
93 |
+
}
|
94 |
$this->_set_names();
|
95 |
+
// 後方互換
|
96 |
+
if ( method_exists( $this, 'setDefaults' ) ) {
|
97 |
+
MWF_Functions::deprecated_message(
|
98 |
+
'MW_Form_Field::setDefaults()',
|
99 |
+
'MW_WP_Form_Abstract_Form_Field::set_defaults()'
|
100 |
+
);
|
101 |
+
$this->defaults = $this->setDefaults();
|
102 |
+
} else {
|
103 |
+
$this->defaults = $this->set_defaults();
|
104 |
+
}
|
105 |
$this->_add_mwform_tag_generator();
|
106 |
+
add_action( 'mwform_add_shortcode', array( $this, 'add_shortcode' ), 10, 4 );
|
107 |
+
add_filter( 'mwform_form_fields' , array( $this, 'mwform_form_fields' ) );
|
108 |
}
|
109 |
|
110 |
/**
|
115 |
protected function set_names() {
|
116 |
return array(
|
117 |
'shortcode_name' => $this->shortcode_name,
|
118 |
+
'display_name' => $this->display_name,
|
119 |
);
|
120 |
}
|
121 |
private function _set_names() {
|
122 |
$args = $this->set_names();
|
123 |
$this->shortcode_name = $args['shortcode_name'];
|
124 |
+
$this->display_name = $args['display_name'];
|
125 |
}
|
126 |
|
127 |
/**
|
132 |
* @param string $arg2 終了タグ(ショートコード)
|
133 |
*/
|
134 |
protected function set_qtags( $id, $display, $arg1, $arg2 = '' ) {
|
135 |
+
MWF_Functions::deprecated_message(
|
136 |
+
'MW_Form_Field::set_qtags()',
|
137 |
+
'MW_WP_Form_Abstract_Form_Field::set_names()'
|
138 |
+
);
|
139 |
$this->qtags = array(
|
140 |
+
'id' => $id,
|
141 |
'display' => $display,
|
142 |
+
'arg1' => $arg1,
|
143 |
+
'arg2' => $arg2,
|
144 |
);
|
145 |
}
|
146 |
|
147 |
/**
|
148 |
+
* get_error
|
149 |
* @param string $key name属性
|
150 |
* @return string エラーHTML
|
151 |
*/
|
152 |
+
protected function get_error( $key ) {
|
153 |
$_ret = '';
|
154 |
+
if ( is_array( $this->Error->get_error( $key ) ) ) {
|
155 |
$start_tag = '<span class="error">';
|
156 |
$end_tag = '</span>';
|
157 |
+
foreach ( $this->Error->get_error( $key ) as $rule => $error ) {
|
158 |
$rule = strtolower( $rule );
|
159 |
+
$error = apply_filters(
|
160 |
+
'mwform_error_message_' . $this->form_key,
|
161 |
+
$error,
|
162 |
+
$key,
|
163 |
+
$rule
|
164 |
+
);
|
165 |
$error_html = apply_filters( 'mwform_error_message_html',
|
166 |
$start_tag . esc_html( $error ) . $end_tag,
|
167 |
$error,
|
168 |
$start_tag,
|
169 |
$end_tag,
|
170 |
+
$this->form_key,
|
171 |
$key,
|
172 |
$rule
|
173 |
);
|
174 |
$_ret .= $error_html;
|
175 |
}
|
176 |
}
|
177 |
+
if ( $_ret ) {
|
178 |
+
return apply_filters( 'mwform_error_message_wrapper', $_ret, $this->form_key );
|
179 |
+
}
|
180 |
+
}
|
181 |
+
protected function getError( $key ) {
|
182 |
+
MWF_Functions::deprecated_message(
|
183 |
+
'MW_Form_Field::getError()',
|
184 |
+
'MW_WP_Form_Abstract_Form_Field::get_error()'
|
185 |
+
);
|
186 |
+
return $this->get_error( $key );
|
187 |
}
|
188 |
|
189 |
/**
|
190 |
+
* set_defaults
|
191 |
* $this->defaultsを設定し返す
|
192 |
* @return array defaults
|
193 |
*/
|
194 |
+
protected function set_defaults() {
|
195 |
+
// 本当は abstract。後方互換のためしてない。
|
196 |
+
}
|
197 |
|
198 |
/**
|
199 |
+
* input_page
|
200 |
* 入力ページでのフォーム項目を返す
|
201 |
* @param array $atts
|
202 |
* @return string HTML
|
203 |
*/
|
204 |
+
protected function input_page() {
|
205 |
+
// 本当は abstract。後方互換のためしてない。
|
206 |
+
}
|
207 |
+
public function _input_page( $atts ) {
|
208 |
if ( isset( $this->defaults['value'], $atts['name'] ) && !isset( $atts['value'] ) ) {
|
209 |
+
$atts['value'] = apply_filters(
|
210 |
+
'mwform_value_' . $this->form_key,
|
211 |
+
$this->defaults['value'],
|
212 |
+
$atts['name']
|
213 |
+
);
|
214 |
}
|
215 |
$this->atts = shortcode_atts( $this->defaults, $atts );
|
216 |
+
// 後方互換
|
217 |
+
if ( method_exists( $this, 'inputPage' ) ) {
|
218 |
+
MWF_Functions::deprecated_message(
|
219 |
+
'MW_Form_Field::inputPage()',
|
220 |
+
'MW_WP_Form_Abstract_Form_Field::input_page()'
|
221 |
+
);
|
222 |
+
return $this->inputPage();
|
223 |
+
}
|
224 |
+
return $this->input_page();
|
225 |
}
|
226 |
|
227 |
/**
|
228 |
+
* confirm_page
|
229 |
* 確認ページでのフォーム項目を返す
|
230 |
* @param array $atts
|
231 |
* @return string HTML
|
232 |
*/
|
233 |
+
protected function confirm_page() {
|
234 |
+
// 本当は abstract。後方互換のためしてない。
|
235 |
+
}
|
236 |
+
public function _confirm_page( $atts ) {
|
237 |
$this->atts = shortcode_atts( $this->defaults, $atts );
|
238 |
+
// 後方互換
|
239 |
+
if ( method_exists( $this, 'confirmPage' ) ) {
|
240 |
+
MWF_Functions::deprecated_message(
|
241 |
+
'MW_Form_Field::confirmPage()',
|
242 |
+
'MW_WP_Form_Abstract_Form_Field::confirm_page()'
|
243 |
+
);
|
244 |
+
return $this->confirmPage();
|
245 |
+
}
|
246 |
+
return $this->confirm_page();
|
247 |
}
|
248 |
|
249 |
/**
|
250 |
+
* add_shortcode
|
251 |
* フォーム項目を返す
|
252 |
+
* @param MW_WP_Form_Form $Form
|
253 |
+
* @param string $view_flg
|
254 |
+
* @param MW_WP_Form_Error $Error
|
255 |
+
* @param string $form_key
|
256 |
*/
|
257 |
+
public function add_shortcode( MW_WP_Form_Form $Form, $view_flg, MW_WP_Form_Error $Error, $form_key ) {
|
258 |
if ( !empty( $this->shortcode_name ) ) {
|
259 |
+
$this->Form = $Form;
|
260 |
+
$this->Error = $Error;
|
261 |
+
$this->form_key = $form_key;
|
262 |
+
switch( $view_flg ) {
|
263 |
case 'input' :
|
264 |
+
add_shortcode( $this->shortcode_name, array( $this, '_input_page' ) );
|
265 |
break;
|
266 |
case 'confirm' :
|
267 |
+
add_shortcode( $this->shortcode_name, array( $this, '_confirm_page' ) );
|
268 |
+
break;
|
269 |
+
case 'complete' :
|
270 |
break;
|
271 |
default :
|
272 |
+
exit( '$view_flg is not right value. $view_flg is ' . $view_flg . ' now.' );
|
273 |
}
|
274 |
}
|
275 |
}
|
276 |
|
277 |
/**
|
278 |
+
* get_children
|
279 |
+
* 選択肢の配列を返す(:が含まれている場合は分割して前をキーに、後ろを表示名にする)
|
280 |
* @param string $_children
|
281 |
* @return array $children
|
282 |
*/
|
283 |
+
public function get_children( $_children ) {
|
284 |
$children = array();
|
285 |
if ( !empty( $_children ) && !is_array( $_children ) ) {
|
286 |
$_children = explode( ',', $_children );
|
287 |
}
|
288 |
if ( is_array( $_children ) ) {
|
289 |
+
$_children = array_map( 'trim', $_children );
|
290 |
foreach ( $_children as $child ) {
|
291 |
+
$child = array_map( 'trim', explode( ':', $child, 2 ) );
|
292 |
+
if ( count( $child ) === 1 ) {
|
293 |
+
$children[$child[0]] = $child[0];
|
294 |
+
} else {
|
295 |
+
$children[$child[0]] = $child[1];
|
296 |
+
}
|
297 |
}
|
298 |
}
|
299 |
+
if ( $this->form_key ) {
|
300 |
+
$children = apply_filters( 'mwform_choices_' . $this->form_key, $children, $this->atts );
|
301 |
}
|
302 |
return $children;
|
303 |
}
|
304 |
+
public function getChildren( $_children ) {
|
305 |
+
MWF_Functions::deprecated_message(
|
306 |
+
'MW_Form_Field::getChildren()',
|
307 |
+
'MW_WP_Form_Abstract_Form_Field::get_children()'
|
308 |
+
);
|
309 |
+
return $this->get_children( $_children );
|
310 |
+
}
|
311 |
|
312 |
/**
|
313 |
* _add_mwform_tag_generator
|
349 |
*/
|
350 |
public function mwform_tag_generator_option() {
|
351 |
$display_name = $this->qtags['display'];
|
352 |
+
if ( $this->display_name ) {
|
353 |
$display_name = $this->display_name;
|
354 |
+
}
|
355 |
?>
|
356 |
<option value="<?php echo esc_attr( $this->shortcode_name ); ?>"><?php echo esc_html( $display_name ); ?></option>
|
357 |
<?php
|
359 |
|
360 |
/**
|
361 |
* mwform_form_fields
|
362 |
+
* @param array $form_fields MW_WP_Form_Abstract_Form_Field を継承したオブジェクトの一覧
|
363 |
* @return array $form_fields
|
364 |
*/
|
365 |
public function mwform_form_fields( array $form_fields ) {
|
375 |
return $this->display_name;
|
376 |
}
|
377 |
|
378 |
+
/**
|
379 |
+
* get_shortcode_name
|
380 |
+
* @return string ショートコード名
|
381 |
+
*/
|
382 |
+
public function get_shortcode_name() {
|
383 |
+
return $this->shortcode_name;
|
384 |
+
}
|
385 |
+
|
386 |
/**
|
387 |
* get_value_for_generator
|
388 |
* MW WP Fomr Generator 用
|
classes/models/class.abstract-validation-rule.php
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Name : MW WP Form Abstract Validation Rule
|
4 |
+
* Description: バリデーションルールの抽象クラス
|
5 |
+
* Version : 1.1.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : July 19, 2014
|
9 |
+
* Modified : December 31, 2014
|
10 |
+
* License : GPLv2
|
11 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
+
*/
|
13 |
+
abstract class MW_WP_Form_Abstract_Validation_Rule extends MW_Validation_Rule {
|
14 |
+
}
|
15 |
+
abstract class MW_Validation_Rule {
|
16 |
+
|
17 |
+
/**
|
18 |
+
* $name
|
19 |
+
* バリデーションルール名を指定
|
20 |
+
* @var string
|
21 |
+
*/
|
22 |
+
protected $name;
|
23 |
+
|
24 |
+
/**
|
25 |
+
* $Data
|
26 |
+
* @var MW_WP_Form_Data
|
27 |
+
*/
|
28 |
+
protected $Data;
|
29 |
+
|
30 |
+
/**
|
31 |
+
* __construct
|
32 |
+
*/
|
33 |
+
public function __construct() {
|
34 |
+
$parent_class = get_parent_class( $this );
|
35 |
+
$class = get_class( $this );
|
36 |
+
if ( is_admin() && in_array( 'MW_Validation_Rule', array( $parent_class, $class ) ) ) {
|
37 |
+
MWF_Functions::deprecated_message(
|
38 |
+
'MW_Validation_Rule',
|
39 |
+
'MW_WP_Form_Abstract_Validation_Rule'
|
40 |
+
);
|
41 |
+
}
|
42 |
+
if ( !$this->getName() ) {
|
43 |
+
exit( 'MW_WP_Form_Abstract_Validation_Rule::$name must override.' );
|
44 |
+
}
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* set_Data
|
49 |
+
* @param MW_WP_Form_Data $Data
|
50 |
+
*/
|
51 |
+
public function set_Data( MW_WP_Form_Data $Data ) {
|
52 |
+
$this->Data = $Data;
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* getName
|
57 |
+
* バリデーションルール名を返す
|
58 |
+
* @return string $this->name バリデーションルール名
|
59 |
+
*/
|
60 |
+
public function getName() {
|
61 |
+
return $this->name;
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* rule
|
66 |
+
* @param string $key name属性
|
67 |
+
* @param array $option
|
68 |
+
* @return string エラーメッセージ
|
69 |
+
*/
|
70 |
+
abstract public function rule( $key, array $options = array() );
|
71 |
+
|
72 |
+
/**
|
73 |
+
* admin
|
74 |
+
* @param numeric $key バリデーションルールセットの識別番号
|
75 |
+
* @param array $value バリデーションルールセットの内容
|
76 |
+
*/
|
77 |
+
abstract public function admin( $key, $value );
|
78 |
+
}
|
classes/models/class.admin.php
ADDED
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Name : MW WP Form Admin
|
4 |
+
* Description: 管理画面クラス
|
5 |
+
* Version : 2.0.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : February 21, 2013
|
9 |
+
* Modified : January 1, 2015
|
10 |
+
* License : GPLv2
|
11 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
+
*/
|
13 |
+
class MW_WP_Form_Admin {
|
14 |
+
|
15 |
+
/**
|
16 |
+
* save_post
|
17 |
+
* @param int $post_id
|
18 |
+
*/
|
19 |
+
public function save_post( $post_id ) {
|
20 |
+
if ( !( isset( $_POST['post_type'] ) && $_POST['post_type'] === MWF_Config::NAME ) )
|
21 |
+
return $post_id;
|
22 |
+
if ( !isset( $_POST[MWF_Config::NAME . '_nonce'] ) )
|
23 |
+
return $post_id;
|
24 |
+
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
|
25 |
+
return $post_id;
|
26 |
+
if ( !wp_verify_nonce( $_POST[MWF_Config::NAME . '_nonce'], MWF_Config::NAME ) )
|
27 |
+
return $post_id;
|
28 |
+
if ( !current_user_can( MWF_Config::CAPABILITY ) )
|
29 |
+
return $post_id;
|
30 |
+
|
31 |
+
$data = $_POST[MWF_Config::NAME];
|
32 |
+
if ( !empty( $data['validation'] ) && is_array( $data['validation'] ) ) {
|
33 |
+
$validation = array();
|
34 |
+
foreach ( $data['validation'] as $_validation ) {
|
35 |
+
if ( empty( $_validation['target'] ) ) continue;
|
36 |
+
foreach ( $_validation as $key => $value ) {
|
37 |
+
// between min, max
|
38 |
+
if ( $key == 'between' ) {
|
39 |
+
if ( !MWF_Functions::is_numeric( $value['min'] ) ) {
|
40 |
+
unset( $_validation[$key]['min'] );
|
41 |
+
}
|
42 |
+
if ( !MWF_Functions::is_numeric( $value['max'] ) ) {
|
43 |
+
unset( $_validation[$key]['max'] );
|
44 |
+
}
|
45 |
+
}
|
46 |
+
// minlength min
|
47 |
+
elseif ( $key == 'minlength' && !MWF_Functions::is_numeric( $value['min'] ) ) {
|
48 |
+
unset( $_validation[$key] );
|
49 |
+
}
|
50 |
+
// fileType types
|
51 |
+
elseif ( $key == 'fileType' && isset( $value['types'] ) && !preg_match( '/^[0-9A-Za-z,]+$/', $value['types'] ) ) {
|
52 |
+
unset( $_validation[$key] );
|
53 |
+
}
|
54 |
+
// fileSize bytes
|
55 |
+
elseif ( $key == 'fileSize' && !MWF_Functions::is_numeric( $value['bytes'] ) ) {
|
56 |
+
unset( $_validation[$key] );
|
57 |
+
}
|
58 |
+
|
59 |
+
// 要素が空のときは削除
|
60 |
+
// 単一項目のとき
|
61 |
+
if ( empty( $value ) ) {
|
62 |
+
unset( $_validation[$key] );
|
63 |
+
}
|
64 |
+
// 配列のとき
|
65 |
+
elseif ( is_array( $value ) && !array_diff( $value, array( '' ) ) ) {
|
66 |
+
unset( $_validation[$key] );
|
67 |
+
}
|
68 |
+
}
|
69 |
+
$validation[] = $_validation;
|
70 |
+
}
|
71 |
+
$data['validation'] = $validation;
|
72 |
+
}
|
73 |
+
|
74 |
+
// チェックボックスの項目は、未設定のときはデータが来ないのでここで処理する
|
75 |
+
if ( empty( $data['querystring'] ) ) {
|
76 |
+
$data['querystring'] = false;
|
77 |
+
}
|
78 |
+
if ( empty( $data['usedb'] ) ) {
|
79 |
+
$data['usedb'] = false;
|
80 |
+
}
|
81 |
+
if ( empty( $data['scroll'] ) ) {
|
82 |
+
$data['scroll'] = false;
|
83 |
+
}
|
84 |
+
|
85 |
+
$Setting = new MW_WP_Form_Setting( $post_id );
|
86 |
+
$Setting->sets( $data );
|
87 |
+
$Setting->save();
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* get_forms
|
92 |
+
* @return array フォーム(WP_Post)の配列
|
93 |
+
*/
|
94 |
+
public function get_forms() {
|
95 |
+
$forms = get_posts( array(
|
96 |
+
'post_type' => MWF_Config::NAME,
|
97 |
+
'posts_per_page' => -1,
|
98 |
+
) );
|
99 |
+
return $forms;
|
100 |
+
}
|
101 |
+
}
|
system/mw_akismet.php → classes/models/class.akismet.php
RENAMED
@@ -1,16 +1,16 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Name: MW Akismet
|
4 |
* Description: Akismetクラス
|
5 |
-
* Version: 1.0.1
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created
|
9 |
-
* Modified: July 24, 2014
|
10 |
-
* License: GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
-
class
|
14 |
|
15 |
/**
|
16 |
* is_enable
|
@@ -37,38 +37,39 @@ class MW_Akismet {
|
|
37 |
public function check( $akismet_author, $akismet_author_email, $akismet_author_url, $Data ) {
|
38 |
global $akismet_api_host, $akismet_api_port;
|
39 |
|
40 |
-
if ( !$this->is_enable() )
|
41 |
return false;
|
|
|
42 |
|
43 |
$doAkismet = false;
|
44 |
|
45 |
$author = '';
|
46 |
-
if ( $Data->
|
47 |
-
$author = $Data->
|
48 |
$doAkismet = true;
|
49 |
}
|
50 |
|
51 |
$author_email = '';
|
52 |
-
if ( $Data->
|
53 |
-
$author_email = $Data->
|
54 |
$doAkismet = true;
|
55 |
}
|
56 |
|
57 |
$author_url = '';
|
58 |
-
if ( $Data->
|
59 |
-
$author_url = $Data->
|
60 |
$doAkismet = true;
|
61 |
}
|
62 |
|
63 |
if ( $doAkismet ) {
|
64 |
$content = '';
|
65 |
-
foreach ( $Data->
|
66 |
$value = $Data->get( $key );
|
67 |
$content .= $value . "\n\n";
|
68 |
}
|
69 |
$permalink = get_permalink();
|
70 |
$akismet = array();
|
71 |
-
$akismet['blog'] =
|
72 |
$akismet['blog_lang'] = get_locale();
|
73 |
$akismet['blog_charset'] = get_option( 'blog_charset' );
|
74 |
$akismet['user_ip'] = preg_replace( '/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR'] );
|
@@ -82,8 +83,9 @@ class MW_Akismet {
|
|
82 |
if ( $content ) $akismet['comment_content'] = $content;
|
83 |
|
84 |
foreach ( $_SERVER as $key => $value ) {
|
85 |
-
if ( !in_array( $key, array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' ) ) )
|
86 |
$akismet[$key] = $value;
|
|
|
87 |
}
|
88 |
|
89 |
$query_string = http_build_query( $akismet, null, '&' );
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Name : MW WP Form Akismet
|
4 |
* Description: Akismetクラス
|
5 |
+
* Version : 1.0.1
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : April 30, 2014
|
9 |
+
* Modified : July 24, 2014
|
10 |
+
* License : GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
+
class MW_WP_Form_Akismet {
|
14 |
|
15 |
/**
|
16 |
* is_enable
|
37 |
public function check( $akismet_author, $akismet_author_email, $akismet_author_url, $Data ) {
|
38 |
global $akismet_api_host, $akismet_api_port;
|
39 |
|
40 |
+
if ( !$this->is_enable() ) {
|
41 |
return false;
|
42 |
+
}
|
43 |
|
44 |
$doAkismet = false;
|
45 |
|
46 |
$author = '';
|
47 |
+
if ( $Data->get_raw( $akismet_author ) ) {
|
48 |
+
$author = $Data->get_raw( $akismet_author );
|
49 |
$doAkismet = true;
|
50 |
}
|
51 |
|
52 |
$author_email = '';
|
53 |
+
if ( $Data->get_raw( $akismet_author_email ) ) {
|
54 |
+
$author_email = $Data->get_raw( $akismet_author_email );
|
55 |
$doAkismet = true;
|
56 |
}
|
57 |
|
58 |
$author_url = '';
|
59 |
+
if ( $Data->get_raw( $akismet_author_url ) ) {
|
60 |
+
$author_url = $Data->get_raw( $akismet_author_url );
|
61 |
$doAkismet = true;
|
62 |
}
|
63 |
|
64 |
if ( $doAkismet ) {
|
65 |
$content = '';
|
66 |
+
foreach ( $Data->gets() as $key => $value ) {
|
67 |
$value = $Data->get( $key );
|
68 |
$content .= $value . "\n\n";
|
69 |
}
|
70 |
$permalink = get_permalink();
|
71 |
$akismet = array();
|
72 |
+
$akismet['blog'] = home_url();
|
73 |
$akismet['blog_lang'] = get_locale();
|
74 |
$akismet['blog_charset'] = get_option( 'blog_charset' );
|
75 |
$akismet['user_ip'] = preg_replace( '/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR'] );
|
83 |
if ( $content ) $akismet['comment_content'] = $content;
|
84 |
|
85 |
foreach ( $_SERVER as $key => $value ) {
|
86 |
+
if ( !in_array( $key, array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' ) ) ) {
|
87 |
$akismet[$key] = $value;
|
88 |
+
}
|
89 |
}
|
90 |
|
91 |
$query_string = http_build_query( $akismet, null, '&' );
|
classes/models/class.contact-data-setting.php
ADDED
@@ -0,0 +1,230 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Name : MW WP Form Contact Data Setting
|
4 |
+
* Description: 管理画面クラス
|
5 |
+
* Version : 1.0.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : January 1, 2015
|
9 |
+
* Modified :
|
10 |
+
* License : GPLv2
|
11 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
+
*/
|
13 |
+
class MW_WP_Form_Contact_Data_Setting {
|
14 |
+
|
15 |
+
/**
|
16 |
+
* $post_id
|
17 |
+
* フォームのPost ID
|
18 |
+
* @var int
|
19 |
+
*/
|
20 |
+
protected $post_id;
|
21 |
+
|
22 |
+
/**
|
23 |
+
* $options
|
24 |
+
* 各フォーム項目から送信された値を格納
|
25 |
+
* @var array
|
26 |
+
*/
|
27 |
+
protected $options = array();
|
28 |
+
|
29 |
+
/**
|
30 |
+
* $response_status
|
31 |
+
* @var string not-supported|reservation|supported
|
32 |
+
*/
|
33 |
+
protected $response_status = 'not-supported';
|
34 |
+
|
35 |
+
/**
|
36 |
+
* $memo
|
37 |
+
* @var string
|
38 |
+
*/
|
39 |
+
protected $memo = '';
|
40 |
+
|
41 |
+
/**
|
42 |
+
* $response_statuses
|
43 |
+
* 対応状況種別の一覧
|
44 |
+
* @var array
|
45 |
+
*/
|
46 |
+
protected $response_statuses = array();
|
47 |
+
|
48 |
+
/**
|
49 |
+
* __construct
|
50 |
+
* @param int $post_id
|
51 |
+
*/
|
52 |
+
public function __construct( $post_id ) {
|
53 |
+
if ( preg_match( '/^' . MWF_Config::DBDATA . '/', get_post_type( $post_id ) ) ) {
|
54 |
+
$this->post_id = $post_id;
|
55 |
+
$this->response_statuses = array(
|
56 |
+
'not-supported' => esc_html__( 'Not supported', MWF_Config::DOMAIN ),
|
57 |
+
'reservation' => esc_html__( 'Reservation', MWF_Config::DOMAIN ),
|
58 |
+
'supported' => esc_html__( 'Supported', MWF_Config::DOMAIN ),
|
59 |
+
);
|
60 |
+
|
61 |
+
$post_custom = get_post_custom( $post_id );
|
62 |
+
$post_meta = array();
|
63 |
+
foreach ( $post_custom as $key => $value ) {
|
64 |
+
if ( preg_match( '/^_/', $key ) ) {
|
65 |
+
continue;
|
66 |
+
}
|
67 |
+
$post_meta[$key] = $value[0];
|
68 |
+
}
|
69 |
+
|
70 |
+
$permit_values = get_post_meta( $this->post_id, MWF_config::CONTACT_DATA_NAME, true );
|
71 |
+
if ( !$permit_values ) {
|
72 |
+
$permit_values = array();
|
73 |
+
}
|
74 |
+
|
75 |
+
$values = array_merge( $post_meta, $permit_values );
|
76 |
+
if ( is_array( $values ) ) {
|
77 |
+
$this->sets( $values );
|
78 |
+
}
|
79 |
+
}
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* get_response_statuses
|
84 |
+
* @return array
|
85 |
+
*/
|
86 |
+
public function get_response_statuses() {
|
87 |
+
return $this->response_statuses;
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* get_permit_keys
|
92 |
+
* 更新可能なキーを返す
|
93 |
+
* @return array
|
94 |
+
*/
|
95 |
+
public function get_permit_keys() {
|
96 |
+
return array( 'response_status', 'memo' );
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* gets
|
101 |
+
*/
|
102 |
+
public function gets() {
|
103 |
+
$options = $this->options;
|
104 |
+
$permit_keys = $this->get_permit_keys();
|
105 |
+
foreach ( $permit_keys as $value ) {
|
106 |
+
$options[$value] = $this->$value;
|
107 |
+
}
|
108 |
+
return $options;
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* get
|
113 |
+
* 属性の取得
|
114 |
+
* @param string $key
|
115 |
+
* @return mixed|null
|
116 |
+
*/
|
117 |
+
public function get( $key ) {
|
118 |
+
$permit_keys = $this->get_permit_keys();
|
119 |
+
if ( in_array( $key, $permit_keys ) ) {
|
120 |
+
$value = $this->$key;
|
121 |
+
if ( $key === 'response_status' ) {
|
122 |
+
if ( isset( $this->response_statuses[$value] ) ) {
|
123 |
+
return $value;
|
124 |
+
}
|
125 |
+
return $value;
|
126 |
+
}
|
127 |
+
return $value;
|
128 |
+
} elseif ( isset( $this->options[$key] ) ) {
|
129 |
+
return $this->options[$key];
|
130 |
+
}
|
131 |
+
}
|
132 |
+
|
133 |
+
/**
|
134 |
+
* set
|
135 |
+
* 属性をセット
|
136 |
+
* @param string $key
|
137 |
+
* @param mixed $value
|
138 |
+
*/
|
139 |
+
public function set( $key, $value ) {
|
140 |
+
$permit_keys = $this->get_permit_keys();
|
141 |
+
if ( in_array( $key, $permit_keys ) ) {
|
142 |
+
$this->$key = $value;
|
143 |
+
} else {
|
144 |
+
$this->options[$key] = $value;
|
145 |
+
}
|
146 |
+
}
|
147 |
+
|
148 |
+
/**
|
149 |
+
* sets
|
150 |
+
* 属性をセット
|
151 |
+
* @param array $values
|
152 |
+
*/
|
153 |
+
public function sets( array $values ) {
|
154 |
+
foreach ( $values as $key => $value ) {
|
155 |
+
$this->set( $key, $value );
|
156 |
+
}
|
157 |
+
}
|
158 |
+
|
159 |
+
/**
|
160 |
+
* save
|
161 |
+
* @param bool $non_permit_keys_save_flg permit_keys以外のメタデータも更新する
|
162 |
+
*/
|
163 |
+
public function save( $non_permit_keys_save_flg = false ) {
|
164 |
+
$permit_keys = $this->get_permit_keys();
|
165 |
+
$permit_values = array();
|
166 |
+
foreach ( $permit_keys as $key ) {
|
167 |
+
$permit_values[$key] = $this->$key;
|
168 |
+
}
|
169 |
+
update_post_meta( $this->post_id, MWF_config::CONTACT_DATA_NAME, $permit_values );
|
170 |
+
|
171 |
+
if ( $non_permit_keys_save_flg !== true ) {
|
172 |
+
return;
|
173 |
+
}
|
174 |
+
|
175 |
+
foreach ( $this->options as $key => $value ) {
|
176 |
+
update_post_meta( $this->post_id, $key, $value );
|
177 |
+
}
|
178 |
+
}
|
179 |
+
|
180 |
+
/**
|
181 |
+
* get_posts
|
182 |
+
* @return array
|
183 |
+
*/
|
184 |
+
public static function get_posts() {
|
185 |
+
$contact_data_post_types = array();
|
186 |
+
$Admin = new MW_WP_Form_Admin();
|
187 |
+
$forms = $Admin->get_forms();
|
188 |
+
foreach ( $forms as $form ) {
|
189 |
+
$Setting = new MW_WP_Form_Setting( $form->ID );
|
190 |
+
if ( !$Setting->get( 'usedb' ) ) {
|
191 |
+
continue;
|
192 |
+
}
|
193 |
+
$post_type = MWF_Config::DBDATA . $form->ID;
|
194 |
+
$contact_data_post_types[] = $post_type;
|
195 |
+
}
|
196 |
+
return $contact_data_post_types;
|
197 |
+
}
|
198 |
+
|
199 |
+
/**
|
200 |
+
* is_upload_file_key
|
201 |
+
* $meta_key が $post の upload_file_key かどうか
|
202 |
+
* @param WP_Post $post
|
203 |
+
* @param string $meta_key
|
204 |
+
* @return bool
|
205 |
+
*/
|
206 |
+
public function is_upload_file_key( $post, $meta_key ) {
|
207 |
+
$upload_file_keys = $this->get_upload_file_keys( $post );
|
208 |
+
if ( is_array( $upload_file_keys ) && in_array( $meta_key, $upload_file_keys ) ) {
|
209 |
+
return true;
|
210 |
+
}
|
211 |
+
return false;
|
212 |
+
}
|
213 |
+
|
214 |
+
/**
|
215 |
+
* get_upload_file_keys
|
216 |
+
* その投稿がもつ upload_file_key を取得
|
217 |
+
* @param WP_Post $post
|
218 |
+
* @return array $upload_file_keys
|
219 |
+
*/
|
220 |
+
protected function get_upload_file_keys( $post ) {
|
221 |
+
// 前のバージョンでは MWF_Config::UPLOAD_FILE_KEYS を配列で保持していなかったので分岐させる
|
222 |
+
$_upload_file_keys = get_post_meta( $post->ID, '_' . MWF_Config::UPLOAD_FILE_KEYS, true );
|
223 |
+
if ( is_array( $_upload_file_keys ) ) {
|
224 |
+
$upload_file_keys = $_upload_file_keys;
|
225 |
+
} else {
|
226 |
+
$upload_file_keys = get_post_custom_values( '_' . MWF_Config::UPLOAD_FILE_KEYS, $post->ID );
|
227 |
+
}
|
228 |
+
return $upload_file_keys;
|
229 |
+
}
|
230 |
+
}
|
classes/models/class.contact-data.php
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Name : MW WP Form Contact Data
|
4 |
+
* Version : 1.0.0
|
5 |
+
* Author : Takashi Kitajima
|
6 |
+
* Author URI : http://2inc.org
|
7 |
+
* Created : January 1, 2015
|
8 |
+
* Modified :
|
9 |
+
* License : GPLv2
|
10 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
+
*/
|
12 |
+
class MW_WP_Form_Contact_Data {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* save_post
|
16 |
+
* @param int $post_id
|
17 |
+
*/
|
18 |
+
public function save_post( $post_id ) {
|
19 |
+
$contact_data_post_types = MW_WP_Form_Contact_Data_setting::get_posts();
|
20 |
+
if ( !isset( $_POST['post_type'] ) )
|
21 |
+
return $post_id;
|
22 |
+
if ( !in_array( $_POST['post_type'], $contact_data_post_types ) )
|
23 |
+
return $post_id;
|
24 |
+
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
|
25 |
+
return $post_id;
|
26 |
+
if ( !current_user_can( MWF_Config::CAPABILITY ) )
|
27 |
+
return $post_id;
|
28 |
+
|
29 |
+
$Contact_Data_Setting = new MW_WP_Form_Contact_Data_setting( $post_id );
|
30 |
+
$permit_keys = $Contact_Data_Setting->get_permit_keys();
|
31 |
+
$data = array();
|
32 |
+
foreach ( $permit_keys as $key ) {
|
33 |
+
if ( isset( $_POST[MWF_Config::CONTACT_DATA_NAME][$key] ) ) {
|
34 |
+
$value = $_POST[MWF_Config::CONTACT_DATA_NAME][$key];
|
35 |
+
if ( $key === 'response_status' ) {
|
36 |
+
if ( !array_key_exists( $value, $Contact_Data_Setting->get_response_statuses() ) ) {
|
37 |
+
continue;
|
38 |
+
}
|
39 |
+
}
|
40 |
+
$data[$key] = $value;
|
41 |
+
}
|
42 |
+
}
|
43 |
+
$Contact_Data_Setting->sets( $data );
|
44 |
+
$Contact_Data_Setting->save();
|
45 |
+
}
|
46 |
+
}
|
classes/models/class.data.php
ADDED
@@ -0,0 +1,420 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Name : MW WP Form Data
|
4 |
+
* Description: mw_wp_form のデータ操作用
|
5 |
+
* Version : 1.3.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : October 10, 2013
|
9 |
+
* Modified : December 31, 2014
|
10 |
+
* License : GPLv2
|
11 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
+
*/
|
13 |
+
class MW_WP_Form_Data {
|
14 |
+
|
15 |
+
/**
|
16 |
+
* $Instance
|
17 |
+
* @var MW_WP_Form_Data
|
18 |
+
*/
|
19 |
+
protected static $Instance;
|
20 |
+
|
21 |
+
/**
|
22 |
+
* $form_key
|
23 |
+
* フォーム識別子
|
24 |
+
* @var string
|
25 |
+
*/
|
26 |
+
protected $form_key;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* $data
|
30 |
+
* フォームから送信された内容を保存した配列
|
31 |
+
* @var array
|
32 |
+
*/
|
33 |
+
protected $data = array();
|
34 |
+
|
35 |
+
/**
|
36 |
+
* $Session
|
37 |
+
* @var MW_WP_Form_Sesion
|
38 |
+
*/
|
39 |
+
protected $Session;
|
40 |
+
|
41 |
+
/**
|
42 |
+
* $token_name
|
43 |
+
* @var string
|
44 |
+
*/
|
45 |
+
protected $token_name = 'token';
|
46 |
+
|
47 |
+
/**
|
48 |
+
* $complete_twice
|
49 |
+
* リダイレクトされてからの complete であれば true
|
50 |
+
* @var bool
|
51 |
+
*/
|
52 |
+
protected $complete_twice = false;
|
53 |
+
|
54 |
+
/**
|
55 |
+
* $POST
|
56 |
+
* @var array
|
57 |
+
*/
|
58 |
+
protected $POST = array();
|
59 |
+
|
60 |
+
/**
|
61 |
+
* $FILES
|
62 |
+
* @var array
|
63 |
+
*/
|
64 |
+
protected $FILES = array();
|
65 |
+
|
66 |
+
/**
|
67 |
+
* __construct
|
68 |
+
* @param string $form_key フォーム識別子
|
69 |
+
* @param array $POST $_POSTを想定
|
70 |
+
* @param array $FILES $_FILESを想定
|
71 |
+
*/
|
72 |
+
private function __construct( $form_key, array $POST = array(), array $FILES = array() ) {
|
73 |
+
$this->form_key = $form_key;
|
74 |
+
$this->POST = $POST;
|
75 |
+
$this->FILES = $FILES;
|
76 |
+
$this->Session = new MW_WP_Form_Session( $form_key );
|
77 |
+
$this->data = $this->Session->gets();
|
78 |
+
$this->set_request_valiables( $this->POST );
|
79 |
+
$this->set_files_valiables( $this->POST, $this->FILES );
|
80 |
+
add_filter( 'mwform_form_end_html', array( $this, 'mwform_form_end_html' ) );
|
81 |
+
add_action( 'parse_request' , array( $this, 'remove_query_vars_from_post' ) );
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* getInstance
|
86 |
+
* @param string $form_key フォーム識別子
|
87 |
+
* @param array $POST $_POSTを想定
|
88 |
+
* @param array $FILES $_FILESを想定
|
89 |
+
*/
|
90 |
+
public static function getInstance( $form_key, array $POST = array(), array $FILES = array() ) {
|
91 |
+
if ( is_null( self::$Instance ) ) {
|
92 |
+
self::$Instance = new self( $form_key, $POST, $FILES );
|
93 |
+
}
|
94 |
+
return self::$Instance;
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* set_request_valiables
|
99 |
+
* @param array $POST $_POSTを想定
|
100 |
+
*/
|
101 |
+
protected function set_request_valiables( array $POST ) {
|
102 |
+
if ( !empty( $POST ) ) {
|
103 |
+
$this->sets( stripslashes_deep( $POST ) );
|
104 |
+
}
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* set_files_valiables
|
109 |
+
* @param array $POST $_POSTを想定
|
110 |
+
* @param array $FILES $_FILESを想定
|
111 |
+
*/
|
112 |
+
protected function set_files_valiables( array $POST, array $FILES ) {
|
113 |
+
$files = array();
|
114 |
+
foreach ( $FILES as $key => $file ) {
|
115 |
+
if ( !isset( $POST[$key] ) || !empty( $file['name'] ) ) {
|
116 |
+
if ( $file['error'] == UPLOAD_ERR_OK && is_uploaded_file( $file['tmp_name'] ) ) {
|
117 |
+
$this->set( $key, $file['name'] );
|
118 |
+
} else {
|
119 |
+
$this->set( $key, '' );
|
120 |
+
}
|
121 |
+
if ( !empty( $file['name'] ) ) {
|
122 |
+
$files[$key] = $file;
|
123 |
+
}
|
124 |
+
}
|
125 |
+
}
|
126 |
+
// この条件判定がないと fileSize チェックが正しく動作しない
|
127 |
+
if ( $files ) {
|
128 |
+
$this->set( MWF_Config::UPLOAD_FILES, $files );
|
129 |
+
}
|
130 |
+
}
|
131 |
+
|
132 |
+
/**
|
133 |
+
* mwform_form_end_html
|
134 |
+
* @param string $html
|
135 |
+
* @return string $html
|
136 |
+
*/
|
137 |
+
public function mwform_form_end_html( $html ) {
|
138 |
+
$html .= wp_nonce_field( $this->form_key, $this->token_name, true, false );
|
139 |
+
return $html;
|
140 |
+
}
|
141 |
+
|
142 |
+
/**
|
143 |
+
* check
|
144 |
+
* トークンチェック
|
145 |
+
* @return bool
|
146 |
+
*/
|
147 |
+
protected function token_check() {
|
148 |
+
if ( isset( $_POST[$this->token_name] ) ) {
|
149 |
+
$request_token = $_POST[$this->token_name];
|
150 |
+
}
|
151 |
+
$values = $this->gets();
|
152 |
+
if ( isset( $request_token ) && wp_verify_nonce( $request_token, $this->form_key ) ) {
|
153 |
+
return true;
|
154 |
+
} elseif ( empty( $_POST ) && $values ) {
|
155 |
+
$this->complete_twice = true;
|
156 |
+
return true;
|
157 |
+
}
|
158 |
+
return false;
|
159 |
+
}
|
160 |
+
|
161 |
+
/**
|
162 |
+
* is_complete_twice
|
163 |
+
* リダイレクト後の complete かチェック
|
164 |
+
*/
|
165 |
+
public function is_complete_twice() {
|
166 |
+
if ( $this->complete_twice === true ) {
|
167 |
+
return true;
|
168 |
+
}
|
169 |
+
return false;
|
170 |
+
}
|
171 |
+
|
172 |
+
/**
|
173 |
+
* get_post_condition
|
174 |
+
* 送信データからどのページを表示すべきかの状態を判定して返す
|
175 |
+
* ただし実際に表示するページと同じとは限らない(バリデーション通らないとかあるので)
|
176 |
+
* @return string back|confirm|complete|input
|
177 |
+
*/
|
178 |
+
public function get_post_condition() {
|
179 |
+
$backButton = $this->get_raw( MWF_Config::BACK_BUTTON );
|
180 |
+
$confirmButton = $this->get_raw( MWF_Config::CONFIRM_BUTTON );
|
181 |
+
if ( $backButton ) {
|
182 |
+
return 'back';
|
183 |
+
} elseif ( $confirmButton ) {
|
184 |
+
return 'confirm';
|
185 |
+
} elseif ( !$confirmButton && !$backButton && $this->token_check() ) {
|
186 |
+
return 'complete';
|
187 |
+
}
|
188 |
+
return 'input';
|
189 |
+
}
|
190 |
+
|
191 |
+
/**
|
192 |
+
* get_raw
|
193 |
+
* データを取得
|
194 |
+
* @param string $key データのキー
|
195 |
+
* @return string データ
|
196 |
+
*/
|
197 |
+
public function get_raw( $key ) {
|
198 |
+
if ( isset( $this->data[$key] ) ) {
|
199 |
+
return $this->data[$key];
|
200 |
+
}
|
201 |
+
}
|
202 |
+
public function getValue( $key ) {
|
203 |
+
MWF_Functions::deprecated_message(
|
204 |
+
'MW_WP_Form_Data::getValue()',
|
205 |
+
'MW_WP_Form_Data::get_raw()'
|
206 |
+
);
|
207 |
+
return $this->get_raw( $key );
|
208 |
+
}
|
209 |
+
|
210 |
+
/**
|
211 |
+
* getValues
|
212 |
+
* 全てのデータを取得
|
213 |
+
* @return array データ
|
214 |
+
*/
|
215 |
+
public function gets() {
|
216 |
+
if ( $this->data === null ) {
|
217 |
+
return array();
|
218 |
+
}
|
219 |
+
return $this->data;
|
220 |
+
}
|
221 |
+
public function getValues() {
|
222 |
+
MWF_Functions::deprecated_message(
|
223 |
+
'MW_WP_Form_Data::getValues()',
|
224 |
+
'MW_WP_Form_Data::gets()'
|
225 |
+
);
|
226 |
+
return $this->gets();
|
227 |
+
}
|
228 |
+
|
229 |
+
/**
|
230 |
+
* set
|
231 |
+
* データを追加
|
232 |
+
* @param string $key データのキー
|
233 |
+
* @param string $value 値
|
234 |
+
*/
|
235 |
+
public function set( $key, $value ){
|
236 |
+
$this->data[$key] = $value;
|
237 |
+
$this->Session->set( $key, $value );
|
238 |
+
}
|
239 |
+
|
240 |
+
/**
|
241 |
+
* set
|
242 |
+
* 複数のデータを一括で追加
|
243 |
+
* @param array 値
|
244 |
+
*/
|
245 |
+
public function sets( array $array ) {
|
246 |
+
foreach ( $array as $key => $value ) {
|
247 |
+
$this->data[$key] = $value;
|
248 |
+
$this->Session->set( $key, $value );
|
249 |
+
}
|
250 |
+
}
|
251 |
+
|
252 |
+
/**
|
253 |
+
* clear_value
|
254 |
+
* データを消す
|
255 |
+
* @param string $key データのキー
|
256 |
+
*/
|
257 |
+
public function clear_value( $key ) {
|
258 |
+
unset( $this->data[$key] );
|
259 |
+
$this->Session->clear_value( $key );
|
260 |
+
}
|
261 |
+
|
262 |
+
/**
|
263 |
+
* clear_values
|
264 |
+
* データを消す
|
265 |
+
* @param string $key データのキー
|
266 |
+
*/
|
267 |
+
public function clear_values() {
|
268 |
+
$this->data = array();
|
269 |
+
$this->Session->clear_values();
|
270 |
+
}
|
271 |
+
|
272 |
+
/**
|
273 |
+
* push
|
274 |
+
* 指定した $key をキーと配列にデータを追加
|
275 |
+
* @param string $key データのキー
|
276 |
+
* @param string $value 値
|
277 |
+
*/
|
278 |
+
public function push( $key, $value ) {
|
279 |
+
$this->data[$key][] = $value;
|
280 |
+
$this->Session->push( $key, $value );
|
281 |
+
}
|
282 |
+
|
283 |
+
/**
|
284 |
+
* get
|
285 |
+
* 整形済み(メール送信可能な)データを取得
|
286 |
+
* @param string $key データのキー
|
287 |
+
* @return string データ
|
288 |
+
*/
|
289 |
+
public function get( $key ) {
|
290 |
+
if ( isset( $this->data[$key] ) ) {
|
291 |
+
if ( is_array( $this->data[$key] ) ) {
|
292 |
+
if ( !array_key_exists( 'data', $this->data[$key] ) ) {
|
293 |
+
return;
|
294 |
+
}
|
295 |
+
if ( is_array( $this->data[$key]['data'] ) ) {
|
296 |
+
return $this->get_separated_value( $key );
|
297 |
+
} else {
|
298 |
+
return $this->data[$key]['data'];
|
299 |
+
}
|
300 |
+
} else {
|
301 |
+
return $this->data[$key];
|
302 |
+
}
|
303 |
+
}
|
304 |
+
}
|
305 |
+
|
306 |
+
/**
|
307 |
+
* get_separator_value
|
308 |
+
* 送られてきたseparatorを返す
|
309 |
+
* @param string $key name属性
|
310 |
+
* @return string
|
311 |
+
*/
|
312 |
+
public function get_separator_value( $key ) {
|
313 |
+
$value = $this->get_raw( $key );
|
314 |
+
if ( is_array( $value ) && isset( $value['separator'] ) ) {
|
315 |
+
return $value['separator'];
|
316 |
+
}
|
317 |
+
}
|
318 |
+
public function getSeparatorValue( $key ) {
|
319 |
+
MWF_Functions::deprecated_message(
|
320 |
+
'MW_WP_Form_Data::getSeparatorValue()',
|
321 |
+
'MW_WP_Form_Data::get_separator_value()'
|
322 |
+
);
|
323 |
+
return $this->get_separator_value( $key );
|
324 |
+
}
|
325 |
+
|
326 |
+
/**
|
327 |
+
* get_separated_value
|
328 |
+
* 配列データを整形して返す ( 郵便番号等用 )
|
329 |
+
* @param string $key name属性
|
330 |
+
* @param array $children 選択肢
|
331 |
+
* @return string データ
|
332 |
+
*/
|
333 |
+
public function get_separated_value( $key, array $children = array() ) {
|
334 |
+
$separator = $this->get_separator_value( $key );
|
335 |
+
$value = $this->get_raw( $key );
|
336 |
+
if ( is_array( $value ) && isset( $value['data'] ) && is_array( $value['data'] ) && !empty( $separator ) ) {
|
337 |
+
if ( $children ) {
|
338 |
+
$rightData = array();
|
339 |
+
foreach ( $value['data'] as $child ) {
|
340 |
+
if ( isset( $children[$child] ) && !in_array( $children[$child], $rightData ) ) {
|
341 |
+
$rightData[] = $children[$child];
|
342 |
+
}
|
343 |
+
}
|
344 |
+
return implode( $separator, $rightData );
|
345 |
+
} else {
|
346 |
+
// すべて空のからのときはimplodeしないように(---がいってしまうため)
|
347 |
+
foreach ( $value['data'] as $child ) {
|
348 |
+
if ( $child !== '' && $child !== null ) {
|
349 |
+
return implode( $separator, $value['data'] );
|
350 |
+
}
|
351 |
+
}
|
352 |
+
return '';
|
353 |
+
}
|
354 |
+
}
|
355 |
+
}
|
356 |
+
public function getSeparatedValue( $key ) {
|
357 |
+
MWF_Functions::deprecated_message(
|
358 |
+
'MW_WP_Form_Data::getSeparatedValue()',
|
359 |
+
'MW_WP_Form_Data::get_separated_value()'
|
360 |
+
);
|
361 |
+
return $this->get_separated_value( $key );
|
362 |
+
}
|
363 |
+
|
364 |
+
/**
|
365 |
+
* set_upload_file_keys
|
366 |
+
*/
|
367 |
+
public function set_upload_file_keys() {
|
368 |
+
$upload_file_keys = $this->get_raw( MWF_Config::UPLOAD_FILE_KEYS );
|
369 |
+
if ( !$upload_file_keys ) {
|
370 |
+
$upload_file_keys = array();
|
371 |
+
}
|
372 |
+
|
373 |
+
$wp_upload_dir = wp_upload_dir();
|
374 |
+
foreach ( $upload_file_keys as $upload_file_key ) {
|
375 |
+
$upload_file_url = $this->get_raw( $upload_file_key );
|
376 |
+
if ( $upload_file_url ) {
|
377 |
+
$filepath = MWF_Functions::fileurl_to_path( $upload_file_url );
|
378 |
+
if ( !file_exists( $filepath ) ) {
|
379 |
+
unset( $upload_file_keys[$upload_file_key] );
|
380 |
+
}
|
381 |
+
}
|
382 |
+
}
|
383 |
+
$this->set( MWF_Config::UPLOAD_FILE_KEYS, $upload_file_keys );
|
384 |
+
}
|
385 |
+
|
386 |
+
/**
|
387 |
+
* push_uploaded_file_keys
|
388 |
+
* アップロードに成功したファイルをフォームデータに格納
|
389 |
+
* @param array $uploaded_files アップロード済みファイルのパスの配列
|
390 |
+
*/
|
391 |
+
public function push_uploaded_file_keys( array $uploaded_files = array() ) {
|
392 |
+
$upload_file_keys = $this->get_raw( MWF_Config::UPLOAD_FILE_KEYS );
|
393 |
+
foreach ( $uploaded_files as $key => $upload_file ) {
|
394 |
+
$this->set( $key, $upload_file );
|
395 |
+
if ( !in_array( $key, $upload_file_keys ) ) {
|
396 |
+
$this->push( MWF_Config::UPLOAD_FILE_KEYS, $key );
|
397 |
+
}
|
398 |
+
}
|
399 |
+
}
|
400 |
+
|
401 |
+
/**
|
402 |
+
* remove_query_vars_from_post
|
403 |
+
* WordPressへのリクエストに含まれている、$_POSTの値を削除
|
404 |
+
*/
|
405 |
+
public function remove_query_vars_from_post( $wp_query ) {
|
406 |
+
if ( strtolower( $_SERVER['REQUEST_METHOD'] ) === 'post' && isset( $this->POST['token'] ) ) {
|
407 |
+
foreach ( $this->POST as $key => $value ) {
|
408 |
+
if ( $key == 'token' ) {
|
409 |
+
continue;
|
410 |
+
}
|
411 |
+
if ( isset( $wp_query->query_vars[$key] ) &&
|
412 |
+
$wp_query->query_vars[$key] === $value &&
|
413 |
+
!empty( $value ) ) {
|
414 |
+
|
415 |
+
$wp_query->query_vars[$key] = '';
|
416 |
+
}
|
417 |
+
}
|
418 |
+
}
|
419 |
+
}
|
420 |
+
}
|
system/mw_error.php → classes/models/class.error.php
RENAMED
@@ -1,41 +1,42 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Name: MW Error
|
4 |
-
*
|
5 |
-
*
|
6 |
-
* Author:
|
7 |
-
*
|
8 |
-
*
|
9 |
-
*
|
10 |
-
* License: GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
-
class
|
14 |
|
15 |
/**
|
16 |
-
*
|
|
|
|
|
17 |
*/
|
18 |
-
|
19 |
|
20 |
/**
|
21 |
-
*
|
22 |
* エラーメッセージをセット
|
23 |
* @param string $key name属性
|
24 |
* @param string $rule
|
25 |
* @param string $message
|
26 |
*/
|
27 |
-
public function
|
28 |
if ( !is_string( $message ) ) exit( 'The Validate error message must be string!');
|
29 |
$this->errors[$key][$rule] = $message;
|
30 |
}
|
31 |
|
32 |
/**
|
33 |
-
*
|
34 |
* エラーメッセージを返す
|
35 |
* @param string $key name属性
|
36 |
* @return array
|
37 |
*/
|
38 |
-
public function
|
39 |
if ( isset( $this->errors[$key] ) ) {
|
40 |
return $this->errors[$key];
|
41 |
}
|
@@ -43,11 +44,11 @@ class MW_Error {
|
|
43 |
}
|
44 |
|
45 |
/**
|
46 |
-
*
|
47 |
* 全てのエラーメッセージを返す
|
48 |
* @return array
|
49 |
*/
|
50 |
-
public function
|
51 |
return $this->errors;
|
52 |
}
|
53 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Name : MW WP Form Error
|
4 |
+
* Version : 1.1.0
|
5 |
+
* Author : Takashi Kitajima
|
6 |
+
* Author URI : http://2inc.org
|
7 |
+
* Created : July 17, 2012
|
8 |
+
* Modified : December 31, 2014
|
9 |
+
* License : GPLv2
|
|
|
10 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
*/
|
12 |
+
class MW_WP_Form_Error {
|
13 |
|
14 |
/**
|
15 |
+
* $errors
|
16 |
+
* エラー格納用の配列
|
17 |
+
* @var array [key => rule = message]
|
18 |
*/
|
19 |
+
protected $errors = array();
|
20 |
|
21 |
/**
|
22 |
+
* set_error
|
23 |
* エラーメッセージをセット
|
24 |
* @param string $key name属性
|
25 |
* @param string $rule
|
26 |
* @param string $message
|
27 |
*/
|
28 |
+
public function set_error( $key, $rule, $message ) {
|
29 |
if ( !is_string( $message ) ) exit( 'The Validate error message must be string!');
|
30 |
$this->errors[$key][$rule] = $message;
|
31 |
}
|
32 |
|
33 |
/**
|
34 |
+
* get_error
|
35 |
* エラーメッセージを返す
|
36 |
* @param string $key name属性
|
37 |
* @return array
|
38 |
*/
|
39 |
+
public function get_error( $key ) {
|
40 |
if ( isset( $this->errors[$key] ) ) {
|
41 |
return $this->errors[$key];
|
42 |
}
|
44 |
}
|
45 |
|
46 |
/**
|
47 |
+
* get_errors
|
48 |
* 全てのエラーメッセージを返す
|
49 |
* @return array
|
50 |
*/
|
51 |
+
public function get_errors() {
|
52 |
return $this->errors;
|
53 |
}
|
54 |
}
|
classes/models/class.file.php
ADDED
@@ -0,0 +1,222 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Name : MW WP Form File
|
4 |
+
* Description: Tempディレクトリ、ファイルアップロードの処理を行うクラス
|
5 |
+
* Version : 1.0.7
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : October 10, 2013
|
9 |
+
* Modified : September 1, 2014
|
10 |
+
* License : GPLv2
|
11 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
+
*/
|
13 |
+
class MW_WP_Form_File {
|
14 |
+
|
15 |
+
/**
|
16 |
+
* initialize
|
17 |
+
*/
|
18 |
+
public function initialize() {
|
19 |
+
add_filter( 'upload_mimes', array( $this, 'upload_mimes' ) );
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* upload_mimes
|
24 |
+
* @param array $t MIMEタイプの配列
|
25 |
+
*/
|
26 |
+
public function upload_mimes( $t ) {
|
27 |
+
$t['psd'] = 'image/vnd.adobe.photoshop';
|
28 |
+
$t['eps'] = 'application/octet-stream';
|
29 |
+
$t['ai'] = 'application/pdf';
|
30 |
+
return $t;
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* upload
|
35 |
+
* ファイルアップロード処理。
|
36 |
+
* @param array $files アップロードするファイルの配列
|
37 |
+
* @return array ( name属性値 => アップロードできたファイルのURL, … )
|
38 |
+
*/
|
39 |
+
public function upload( array $files = array() ) {
|
40 |
+
$uploaded_files = array();
|
41 |
+
foreach ( $files as $key => $file ) {
|
42 |
+
$uploaded_file = $this->single_file_upload( $key );
|
43 |
+
if ( $uploaded_file ) {
|
44 |
+
$uploaded_files[$key] = $uploaded_file;
|
45 |
+
}
|
46 |
+
}
|
47 |
+
return $uploaded_files;
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* single_file_upload
|
52 |
+
* ファイルアップロード処理。
|
53 |
+
* @param string $key アップロードしたいファイルの name 属性
|
54 |
+
* @return string アップロードできたファイルのURL
|
55 |
+
*/
|
56 |
+
public function single_file_upload( $key ) {
|
57 |
+
$this->create_temp_dir();
|
58 |
+
$this->clean_temp_dir();
|
59 |
+
|
60 |
+
$file = '';
|
61 |
+
if ( is_array( $_FILES ) && isset( $_FILES[$key] ) ) {
|
62 |
+
$file = $_FILES[$key];
|
63 |
+
return $this->_file_upload( $file );
|
64 |
+
}
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* _file_upload
|
69 |
+
* ファイルアップロードの実処理。
|
70 |
+
* @param arary $file $_FILES['hoge'] の配列
|
71 |
+
* @return string アップロードしたファイルの URL
|
72 |
+
*/
|
73 |
+
protected function _file_upload( $file ) {
|
74 |
+
if ( empty( $file['tmp_name'] ) ) {
|
75 |
+
return;
|
76 |
+
}
|
77 |
+
|
78 |
+
$is_uploaded = false;
|
79 |
+
if ( MWF_Functions::check_file_type( $file['tmp_name'], $file['name'] )
|
80 |
+
&& $file['error'] == UPLOAD_ERR_OK
|
81 |
+
&& is_uploaded_file( $file['tmp_name'] ) ) {
|
82 |
+
|
83 |
+
$extension = pathinfo( $file['name'], PATHINFO_EXTENSION );
|
84 |
+
$uploadfile = $this->set_upload_file_name( $extension );
|
85 |
+
|
86 |
+
$is_uploaded = move_uploaded_file( $file['tmp_name'], $uploadfile['file'] );
|
87 |
+
if ( $is_uploaded ) {
|
88 |
+
return $uploadfile['url'];
|
89 |
+
}
|
90 |
+
}
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* set_upload_file_name
|
95 |
+
* 一時ファイル名を生成。Tempディレクトリの生成に失敗していた場合はUploadディレクトリを使用
|
96 |
+
* @param string 拡張子 ( ex: jpg )
|
97 |
+
* @return array ( file =>, url => )
|
98 |
+
*/
|
99 |
+
protected function set_upload_file_name( $extension ) {
|
100 |
+
$count = 0;
|
101 |
+
$basename = date( 'Ymdhis' );
|
102 |
+
$filename = $basename . '.' . $extension;
|
103 |
+
$temp_dir = $this->get_temp_dir();
|
104 |
+
$upload_dir = $temp_dir['dir'];
|
105 |
+
$upload_url = $temp_dir['url'];
|
106 |
+
if ( !is_writable( $temp_dir['dir'] ) ) {
|
107 |
+
$wp_upload_dir = wp_upload_dir();
|
108 |
+
$upload_dir = realpath( $wp_upload_dir['path'] );
|
109 |
+
$upload_url = $wp_upload_dir['url'];
|
110 |
+
}
|
111 |
+
$uploadfile['file'] = trailingslashit( $upload_dir ) . $filename;
|
112 |
+
$uploadfile['url'] = trailingslashit( $upload_url ) . $filename;
|
113 |
+
while ( file_exists( $uploadfile['file'] ) ) {
|
114 |
+
$count ++;
|
115 |
+
$filename = $basename . '-' . $count . '.' . $extension;
|
116 |
+
$uploadfile['file'] = trailingslashit( $upload_dir ) . $filename;
|
117 |
+
$uploadfile['url'] = trailingslashit( $upload_url ) . $filename;
|
118 |
+
}
|
119 |
+
return $uploadfile;
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* get_temp_dir
|
124 |
+
* Tempディレクトリ名(パス、URL)を返す。ディレクトリの存在可否は関係なし
|
125 |
+
* @return array ( dir => Tempディレクトリのパス, url => Tempディレクトリのurl )
|
126 |
+
*/
|
127 |
+
public function get_temp_dir() {
|
128 |
+
$wp_upload_dir = wp_upload_dir();
|
129 |
+
$temp_dir_name = '/' . MWF_Config::NAME . '_uploads';
|
130 |
+
$temp_dir['dir'] = realpath( $wp_upload_dir['basedir'] ) . $temp_dir_name;
|
131 |
+
$temp_dir['url'] = $wp_upload_dir['baseurl'] . $temp_dir_name;
|
132 |
+
return $temp_dir;
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* create_temp_dir
|
137 |
+
* Tempディレクトリを作成
|
138 |
+
* @return bool
|
139 |
+
*/
|
140 |
+
public function create_temp_dir() {
|
141 |
+
$_ret = false;
|
142 |
+
$temp_dir = $this->get_temp_dir();
|
143 |
+
$temp_dir = $temp_dir['dir'];
|
144 |
+
if ( !file_exists( $temp_dir ) && !is_writable( $temp_dir ) ) {
|
145 |
+
$_ret = wp_mkdir_p( trailingslashit( $temp_dir ) );
|
146 |
+
@chmod( $temp_dir, 0733 );
|
147 |
+
return $_ret;
|
148 |
+
}
|
149 |
+
return $_ret;
|
150 |
+
}
|
151 |
+
|
152 |
+
/**
|
153 |
+
* remove_temp_dir
|
154 |
+
* Tempディレクトリを削除
|
155 |
+
* @param string $sub_dir サブディレクトリ名
|
156 |
+
*/
|
157 |
+
public function remove_temp_dir( $sub_dir = '' ) {
|
158 |
+
$temp_dir = $this->get_temp_dir();
|
159 |
+
$temp_dir = $temp_dir['dir'];
|
160 |
+
if ( $sub_dir ) {
|
161 |
+
$temp_dir = trailingslashit( $temp_dir ) . $sub_dir;
|
162 |
+
}
|
163 |
+
|
164 |
+
if ( !file_exists( $temp_dir ) ) {
|
165 |
+
return;
|
166 |
+
}
|
167 |
+
$handle = opendir( $temp_dir );
|
168 |
+
if ( $handle === false ) {
|
169 |
+
return;
|
170 |
+
}
|
171 |
+
|
172 |
+
while ( false !== ( $file = readdir( $handle ) ) ) {
|
173 |
+
if ( $file !== '.' && $file !== '..' ) {
|
174 |
+
if ( is_dir( trailingslashit( $temp_dir ) . $file ) ) {
|
175 |
+
$this->remove_temp_dir( $file );
|
176 |
+
} else {
|
177 |
+
unlink( trailingslashit( $temp_dir ) . $file );
|
178 |
+
}
|
179 |
+
}
|
180 |
+
}
|
181 |
+
closedir( $handle );
|
182 |
+
rmdir( $temp_dir );
|
183 |
+
}
|
184 |
+
|
185 |
+
/**
|
186 |
+
* clean_temp_dir
|
187 |
+
* Tempディレクトリ内のファイルを削除
|
188 |
+
*/
|
189 |
+
protected function clean_temp_dir() {
|
190 |
+
$temp_dir = $this->get_temp_dir();
|
191 |
+
$temp_dir = $temp_dir['dir'];
|
192 |
+
if ( !file_exists( $temp_dir ) ) {
|
193 |
+
return;
|
194 |
+
}
|
195 |
+
$handle = opendir( $temp_dir );
|
196 |
+
if ( $handle === false ) {
|
197 |
+
return;
|
198 |
+
}
|
199 |
+
while ( false !== ( $filename = readdir( $handle ) ) ) {
|
200 |
+
if ( $filename !== '.' && $filename !== '..' &&
|
201 |
+
!is_dir( trailingslashit( $temp_dir ) . $filename ) ) {
|
202 |
+
$stat = stat( trailingslashit( $temp_dir ) . $filename );
|
203 |
+
if ( $stat['mtime'] + 3600 < time() ) {
|
204 |
+
unlink( trailingslashit( $temp_dir ) . $filename );
|
205 |
+
}
|
206 |
+
}
|
207 |
+
}
|
208 |
+
closedir( $handle );
|
209 |
+
}
|
210 |
+
|
211 |
+
/**
|
212 |
+
* delete_files
|
213 |
+
* @param array $attachments 消去するファイルパスの配列
|
214 |
+
*/
|
215 |
+
public function delete_files( array $files ) {
|
216 |
+
foreach ( $files as $file ) {
|
217 |
+
if ( file_exists( $file ) ) {
|
218 |
+
unlink( $file );
|
219 |
+
}
|
220 |
+
}
|
221 |
+
}
|
222 |
+
}
|
system/mw_form.php → classes/models/class.form.php
RENAMED
@@ -1,252 +1,133 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Name: MW Form
|
4 |
-
* Description:
|
5 |
-
* Version: 1.
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created
|
9 |
-
* Modified:
|
10 |
-
* License: GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
-
class
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
-
|
18 |
-
protected $key = 'form_token';
|
19 |
-
|
20 |
-
/**
|
21 |
-
* トークンタグ用のトークン名
|
22 |
-
*/
|
23 |
-
public $tokenName = 'token';
|
24 |
-
|
25 |
-
/**
|
26 |
-
* トークンの値
|
27 |
-
*/
|
28 |
-
protected $token;
|
29 |
-
|
30 |
-
/**
|
31 |
-
* データ
|
32 |
*/
|
33 |
protected $Data;
|
34 |
|
35 |
-
/**
|
36 |
-
* 確認ボタンの名前
|
37 |
-
*/
|
38 |
-
protected $confirmButton = 'submitConfirm';
|
39 |
-
|
40 |
-
/**
|
41 |
-
* 戻るボタンの名前
|
42 |
-
*/
|
43 |
-
protected $backButton = 'submitBack';
|
44 |
-
|
45 |
-
/**
|
46 |
-
* 現在のモード
|
47 |
-
*/
|
48 |
-
protected $modeCheck = 'input';
|
49 |
-
|
50 |
-
/**
|
51 |
-
* フォームの method
|
52 |
-
*/
|
53 |
-
protected $method = 'post';
|
54 |
-
|
55 |
-
/**
|
56 |
-
* 完了画面の判定用
|
57 |
-
*/
|
58 |
-
const COMPLETE_TWICE = '__complete_twice_flg';
|
59 |
-
|
60 |
/**
|
61 |
* __construct
|
62 |
* 取得データを保存
|
63 |
* @param string $key 識別子
|
64 |
*/
|
65 |
-
public function __construct( $
|
66 |
-
$this->Data =
|
67 |
-
if ( $key ) {
|
68 |
-
$this->key = $key . '_key';
|
69 |
-
}
|
70 |
-
$this->modeCheck = $this->modeCheck();
|
71 |
-
}
|
72 |
-
|
73 |
-
/**
|
74 |
-
* getTokenName
|
75 |
-
* nonce用のキーを返す
|
76 |
-
* @return string
|
77 |
-
*/
|
78 |
-
public function getTokenName() {
|
79 |
-
return $this->tokenName;
|
80 |
-
}
|
81 |
-
|
82 |
-
/**
|
83 |
-
* isComplete
|
84 |
-
* 完了画面かどうか
|
85 |
-
* @return bool
|
86 |
-
*/
|
87 |
-
public function isComplete() {
|
88 |
-
$data = $this->Data->getValues();
|
89 |
-
if ( !empty( $data ) && $this->modeCheck === 'complete' ) {
|
90 |
-
return true;
|
91 |
-
}
|
92 |
-
return false;
|
93 |
}
|
94 |
|
95 |
/**
|
96 |
-
*
|
97 |
-
* 確認画面かどうか
|
98 |
-
* @return bool
|
99 |
-
*/
|
100 |
-
public function isConfirm() {
|
101 |
-
$data = $this->Data->getValues();
|
102 |
-
if ( !empty( $data ) && $this->modeCheck === 'confirm' )
|
103 |
-
return true;
|
104 |
-
return false;
|
105 |
-
}
|
106 |
-
|
107 |
-
/**
|
108 |
-
* isInput
|
109 |
-
* 入力画面かどうか
|
110 |
-
* @return bool
|
111 |
-
*/
|
112 |
-
public function isInput() {
|
113 |
-
if ( $this->modeCheck === 'input' )
|
114 |
-
return true;
|
115 |
-
return false;
|
116 |
-
}
|
117 |
-
|
118 |
-
/**
|
119 |
-
* isBack
|
120 |
-
* 入力画面(戻る)かどうか
|
121 |
-
* @return bool
|
122 |
-
*/
|
123 |
-
public function isBack() {
|
124 |
-
if ( $this->modeCheck === 'back' )
|
125 |
-
return true;
|
126 |
-
return false;
|
127 |
-
}
|
128 |
-
|
129 |
-
/**
|
130 |
-
* modeCheck
|
131 |
-
* 表示画面判定
|
132 |
-
* @return string input || confirm || complete
|
133 |
-
*/
|
134 |
-
protected function modeCheck() {
|
135 |
-
$backButton = $this->getValue( $this->backButton );
|
136 |
-
$confirmButton = $this->getValue( $this->confirmButton );
|
137 |
-
if ( isset( $backButton ) ) {
|
138 |
-
return 'back';
|
139 |
-
} elseif ( isset( $confirmButton ) ) {
|
140 |
-
return 'confirm';
|
141 |
-
} elseif ( !isset( $confirmButton ) && !isset( $backButton ) && $this->check() ) {
|
142 |
-
return 'complete';
|
143 |
-
}
|
144 |
-
return 'input';
|
145 |
-
}
|
146 |
-
|
147 |
-
/**
|
148 |
-
* check
|
149 |
-
* トークンチェック
|
150 |
-
* @return bool
|
151 |
-
*/
|
152 |
-
protected function check() {
|
153 |
-
if ( isset( $_POST[$this->tokenName] ) )
|
154 |
-
$requestToken = $_POST[$this->tokenName];
|
155 |
-
|
156 |
-
$data = $this->Data->getValues();
|
157 |
-
if ( isset( $requestToken ) && wp_verify_nonce( $requestToken, $this->key ) ) {
|
158 |
-
$this->Data->setValue( self::COMPLETE_TWICE, true );
|
159 |
-
return true;
|
160 |
-
} elseif ( empty( $_POST ) && !empty( $data ) && $this->Data->getValue( self::COMPLETE_TWICE ) ) {
|
161 |
-
return true;
|
162 |
-
}
|
163 |
-
return false;
|
164 |
-
}
|
165 |
-
|
166 |
-
/**
|
167 |
-
* getConfirmButtonName
|
168 |
-
* 確認画面への変遷用ボタンのname属性値を返す
|
169 |
-
* @return String name属性値
|
170 |
-
*/
|
171 |
-
public function getConfirmButtonName() {
|
172 |
-
return $this->confirmButton;
|
173 |
-
}
|
174 |
-
|
175 |
-
/**
|
176 |
-
* getBackButtonName
|
177 |
-
* 戻る用ボタンのname属性値を返す
|
178 |
-
* @return String
|
179 |
-
*/
|
180 |
-
public function getBackButtonName() {
|
181 |
-
return $this->backButton;
|
182 |
-
}
|
183 |
-
|
184 |
-
/**
|
185 |
-
* getValue
|
186 |
* データを返す
|
187 |
* @param string $key name属性値
|
188 |
* @return mixed
|
189 |
*/
|
190 |
-
public function
|
191 |
-
return $this->Data->
|
192 |
}
|
193 |
|
194 |
/**
|
195 |
-
*
|
196 |
* データを返す ( 郵便番号用 )
|
197 |
* @param string $key name属性
|
198 |
* @return string データ
|
199 |
*/
|
200 |
-
public function
|
201 |
-
return $this->Data->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
202 |
}
|
203 |
|
204 |
/**
|
205 |
-
*
|
206 |
* データを返す ( 電話番号用 )
|
207 |
* @param string $key name属性
|
208 |
* @return string データ
|
209 |
*/
|
|
|
|
|
|
|
210 |
public function getTelValue( $key ) {
|
211 |
-
|
|
|
|
|
|
|
|
|
212 |
}
|
213 |
|
214 |
/**
|
215 |
-
*
|
216 |
* データを返す( checkbox用 )。$dataに含まれる値のみ返す
|
217 |
* @param string $key name属性
|
218 |
* @param array $data
|
219 |
* @return string データ
|
220 |
*/
|
221 |
-
public function
|
222 |
-
return $this->Data->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
223 |
}
|
224 |
|
225 |
/**
|
226 |
-
*
|
227 |
* データを返す( radio用 )。$dataに含まれる値のみ返す
|
228 |
* @param string name属性値
|
229 |
* @param array $data データ
|
230 |
* @return string
|
231 |
*/
|
232 |
-
public function
|
233 |
-
$value = $this->
|
234 |
if ( !is_null( $value ) && !is_array( $value ) ) {
|
235 |
if ( isset( $data[$value] ) ) {
|
236 |
return $data[$value];
|
237 |
}
|
238 |
}
|
239 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
240 |
|
241 |
/**
|
242 |
-
*
|
243 |
* データを返す( selectbox用 )。$dataに含まれる値のみ返す
|
244 |
* @param string $key name属性
|
245 |
* @param array $data データ
|
246 |
* @return string データ
|
247 |
*/
|
248 |
-
public function
|
249 |
-
return $this->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
250 |
}
|
251 |
|
252 |
/**
|
@@ -257,7 +138,7 @@ class MW_Form {
|
|
257 |
* @return string HTML
|
258 |
*/
|
259 |
public function separator( $key, $separator = '' ) {
|
260 |
-
$post_separator = $this->
|
261 |
if ( !$separator && $post_separator ) {
|
262 |
$separator = $post_separator;
|
263 |
}
|
@@ -267,13 +148,20 @@ class MW_Form {
|
|
267 |
}
|
268 |
|
269 |
/**
|
270 |
-
*
|
271 |
* 送られてきたseparatorを返す
|
272 |
* @param string $key name属性
|
273 |
* @return string
|
274 |
*/
|
275 |
-
public function
|
276 |
-
return $this->Data->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
277 |
}
|
278 |
|
279 |
/**
|
@@ -284,13 +172,15 @@ class MW_Form {
|
|
284 |
*/
|
285 |
public function start( $options = array() ) {
|
286 |
$defaults = array(
|
287 |
-
'action'
|
288 |
-
//'enctype' => 'application/x-www-form-urlencoded',
|
289 |
'enctype' => 'multipart/form-data',
|
290 |
);
|
291 |
$options = array_merge( $defaults, $options );
|
292 |
-
return sprintf(
|
293 |
-
|
|
|
|
|
|
|
294 |
}
|
295 |
|
296 |
/**
|
@@ -300,9 +190,7 @@ class MW_Form {
|
|
300 |
*/
|
301 |
public function end() {
|
302 |
$html = '';
|
303 |
-
|
304 |
-
$html .= wp_nonce_field( $this->key, $this->tokenName, true, false );
|
305 |
-
}
|
306 |
$html .= '</form>';
|
307 |
return $html;
|
308 |
}
|
@@ -316,20 +204,17 @@ class MW_Form {
|
|
316 |
*/
|
317 |
public function text( $name, $options = array() ) {
|
318 |
$defaults = array(
|
319 |
-
'id'
|
320 |
-
'size'
|
321 |
-
'maxlength'
|
322 |
-
'value'
|
323 |
'conv-half-alphanumeric' => false,
|
324 |
'placeholder' => '',
|
325 |
);
|
326 |
$options = array_merge( $defaults, $options );
|
327 |
-
$value = $
|
328 |
-
if (
|
329 |
-
$value = $
|
330 |
-
if ( is_null( $value ) ) {
|
331 |
-
$value = $options['value'];
|
332 |
-
}
|
333 |
}
|
334 |
$placeholder = $this->get_attr_placeholder( $options['placeholder'] );
|
335 |
$dataConvHalfAlphanumeric = null;
|
@@ -356,6 +241,9 @@ class MW_Form {
|
|
356 |
* @return string HTML
|
357 |
*/
|
358 |
public function hidden( $name, $value ) {
|
|
|
|
|
|
|
359 |
if ( is_array( $value ) ) {
|
360 |
$value = $this->getZipValue( $name );
|
361 |
}
|
@@ -371,19 +259,16 @@ class MW_Form {
|
|
371 |
*/
|
372 |
public function password( $name, $options = array() ) {
|
373 |
$defaults = array(
|
374 |
-
'id'
|
375 |
-
'size'
|
376 |
-
'maxlength'
|
377 |
-
'value'
|
378 |
'placeholder' => '',
|
379 |
);
|
380 |
$options = array_merge( $defaults, $options );
|
381 |
-
$value = $
|
382 |
-
if (
|
383 |
-
$value = $
|
384 |
-
if ( is_null( $value ) ) {
|
385 |
-
$value = $options['value'];
|
386 |
-
}
|
387 |
}
|
388 |
$placeholder = $this->get_attr_placeholder( $options['placeholder'] );
|
389 |
$id = $this->get_attr_id( $options['id'] );
|
@@ -412,7 +297,7 @@ class MW_Form {
|
|
412 |
|
413 |
$children = array();
|
414 |
$separator = '-';
|
415 |
-
$value = $this->
|
416 |
if ( !is_null( $value ) && is_array( $value ) && isset( $value['data'] ) ) {
|
417 |
if ( is_array( $value['data'] ) ) {
|
418 |
$children = $value['data'];
|
@@ -431,16 +316,16 @@ class MW_Form {
|
|
431 |
$_ret = '<span class="mwform-zip-field">';
|
432 |
$_ret .= '〒';
|
433 |
$_ret .= $this->text( $name . '[data][0]', array(
|
434 |
-
'size'
|
435 |
'maxlength' => 3,
|
436 |
-
'value'
|
437 |
'conv-half-alphanumeric' => $options['conv-half-alphanumeric'],
|
438 |
) );
|
439 |
$_ret .= ' ' . $separator . ' ';
|
440 |
$_ret .= $this->text( $name . '[data][1]', array(
|
441 |
-
'size'
|
442 |
'maxlength' => 4,
|
443 |
-
'value'
|
444 |
'conv-half-alphanumeric' => $options['conv-half-alphanumeric'],
|
445 |
) );
|
446 |
$_ret .= $this->separator( $name, $separator );
|
@@ -463,7 +348,7 @@ class MW_Form {
|
|
463 |
|
464 |
$children = array();
|
465 |
$separator = '-';
|
466 |
-
$value = $this->
|
467 |
if ( !is_null( $value ) && is_array( $value ) && isset( $value['data'] ) ) {
|
468 |
if ( is_array( $value['data'] ) ) {
|
469 |
$children = $value['data'];
|
@@ -481,23 +366,23 @@ class MW_Form {
|
|
481 |
|
482 |
$_ret = '<span class="mwform-tel-field">';
|
483 |
$_ret .= $this->text( $name . '[data][0]', array(
|
484 |
-
'size'
|
485 |
'maxlength' => 5,
|
486 |
-
'value'
|
487 |
'conv-half-alphanumeric' => $options['conv-half-alphanumeric'],
|
488 |
) );
|
489 |
$_ret .= ' ' . $separator . ' ';
|
490 |
$_ret .= $this->text( $name . '[data][1]', array(
|
491 |
-
'size'
|
492 |
'maxlength' => 4,
|
493 |
-
'value'
|
494 |
'conv-half-alphanumeric' => $options['conv-half-alphanumeric'],
|
495 |
) );
|
496 |
$_ret .= ' ' . $separator . ' ';
|
497 |
$_ret .= $this->text( $name . '[data][2]', array(
|
498 |
-
'size'
|
499 |
'maxlength' => 4,
|
500 |
-
'value'
|
501 |
'conv-half-alphanumeric' => $options['conv-half-alphanumeric'],
|
502 |
) );
|
503 |
$_ret .= $this->separator( $name, $separator );
|
@@ -514,19 +399,16 @@ class MW_Form {
|
|
514 |
*/
|
515 |
public function textarea( $name, $options = array() ) {
|
516 |
$defaults = array(
|
517 |
-
'id'
|
518 |
-
'cols'
|
519 |
-
'rows'
|
520 |
-
'value'
|
521 |
'placeholder' => '',
|
522 |
);
|
523 |
$options = array_merge( $defaults, $options );
|
524 |
-
$value = $
|
525 |
-
if (
|
526 |
-
$value = $
|
527 |
-
if ( is_null( $value ) ) {
|
528 |
-
$value = $options['value'];
|
529 |
-
}
|
530 |
}
|
531 |
$placeholder = $this->get_attr_placeholder( $options['placeholder'] );
|
532 |
$id = $this->get_attr_id( $options['id'] );
|
@@ -550,16 +432,13 @@ class MW_Form {
|
|
550 |
*/
|
551 |
public function select( $name, $children = array(), $options = array() ) {
|
552 |
$defaults = array(
|
553 |
-
'id'
|
554 |
'value' => ''
|
555 |
);
|
556 |
$options = array_merge( $defaults, $options );
|
557 |
-
$value = $
|
558 |
-
if (
|
559 |
-
$value = $
|
560 |
-
if ( is_null( $value ) ) {
|
561 |
-
$value = $options['value'];
|
562 |
-
}
|
563 |
}
|
564 |
$id = $this->get_attr_id( $options['id'] );
|
565 |
$_ret = sprintf( '<select name="%s" %s>', esc_attr( $name ), $id );
|
@@ -588,12 +467,9 @@ class MW_Form {
|
|
588 |
'vertically' => '',
|
589 |
);
|
590 |
$options = array_merge( $defaults, $options );
|
591 |
-
$value = $
|
592 |
-
if (
|
593 |
-
$value = $
|
594 |
-
if ( is_null( $value ) ) {
|
595 |
-
$value = $options['value'];
|
596 |
-
}
|
597 |
}
|
598 |
|
599 |
$i = 0;
|
@@ -604,9 +480,10 @@ class MW_Form {
|
|
604 |
$for = $this->get_attr_for( $options['id'], $i );
|
605 |
$vertically = ( $options['vertically'] === 'true' ) ? 'vertical-item' : '';
|
606 |
$checked = ( $key == $value )? ' checked="checked"' : '';
|
607 |
-
$_ret .= sprintf(
|
608 |
-
|
609 |
$vertically,
|
|
|
610 |
esc_attr( $name ),
|
611 |
esc_attr( $key ),
|
612 |
$checked,
|
@@ -633,30 +510,28 @@ class MW_Form {
|
|
633 |
'vertically' => '',
|
634 |
);
|
635 |
$options = array_merge( $defaults, $options );
|
636 |
-
$value = $
|
637 |
-
if (
|
638 |
-
$value = $
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
if ( !is_array( $value ) ) {
|
645 |
-
$value = explode( $separator, $value );
|
646 |
-
}
|
647 |
}
|
648 |
|
649 |
$i = 0;
|
650 |
$_ret = '';
|
651 |
foreach ( $children as $key => $_value ) {
|
652 |
$i ++;
|
653 |
-
$id
|
654 |
$for = $this->get_attr_for( $options['id'], $i );
|
655 |
$vertically = ( $options['vertically'] === 'true' ) ? 'vertical-item' : '';
|
656 |
$checked = ( is_array( $value ) && in_array( $key, $value ) )? ' checked="checked"' : '';
|
657 |
-
$_ret .= sprintf(
|
658 |
-
|
659 |
$vertically,
|
|
|
660 |
esc_attr( $name.'[data][]' ),
|
661 |
esc_attr( $key ),
|
662 |
$checked,
|
@@ -699,18 +574,15 @@ class MW_Form {
|
|
699 |
*/
|
700 |
public function datepicker( $name, $options = array() ) {
|
701 |
$defaults = array(
|
702 |
-
'id'
|
703 |
-
'size'
|
704 |
-
'js'
|
705 |
'value' => '',
|
706 |
);
|
707 |
$options = array_merge( $defaults, $options );
|
708 |
-
$value = $
|
709 |
-
if (
|
710 |
-
$value = $
|
711 |
-
if ( is_null( $value ) ) {
|
712 |
-
$value = $options['value'];
|
713 |
-
}
|
714 |
}
|
715 |
$id = $this->get_attr_id( $options['id'] );
|
716 |
$_ret = sprintf( '<input type="text" name="%s" value="%s" size="%d" %s />',
|
@@ -787,4 +659,18 @@ class MW_Form {
|
|
787 |
return 'placeholder="' . esc_attr( $placeholder ) . '"';
|
788 |
}
|
789 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
790 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Name : MW WP Form Form
|
4 |
+
* Description: フォームヘルパー
|
5 |
+
* Version : 1.5.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : September 25, 2012
|
9 |
+
* Modified : December 31, 2014
|
10 |
+
* License : GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
+
class MW_WP_Form_Form {
|
14 |
|
15 |
/**
|
16 |
+
* $Data
|
17 |
+
* @var MW_WP_Form_Data
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
*/
|
19 |
protected $Data;
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
/**
|
22 |
* __construct
|
23 |
* 取得データを保存
|
24 |
* @param string $key 識別子
|
25 |
*/
|
26 |
+
public function __construct( MW_WP_Form_Data $Data ) {
|
27 |
+
$this->Data = $Data;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
}
|
29 |
|
30 |
/**
|
31 |
+
* get_raw
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
* データを返す
|
33 |
* @param string $key name属性値
|
34 |
* @return mixed
|
35 |
*/
|
36 |
+
public function get_raw( $key ) {
|
37 |
+
return $this->Data->get_raw( $key );
|
38 |
}
|
39 |
|
40 |
/**
|
41 |
+
* get_zip_value
|
42 |
* データを返す ( 郵便番号用 )
|
43 |
* @param string $key name属性
|
44 |
* @return string データ
|
45 |
*/
|
46 |
+
public function get_zip_value( $key ) {
|
47 |
+
return $this->Data->get_separated_value( $key );
|
48 |
+
}
|
49 |
+
public function getZipValue() {
|
50 |
+
MWF_Functions::deprecated_message(
|
51 |
+
'MW_Form::getZipValue()',
|
52 |
+
'MW_WP_Form_Form::get_zip_value()'
|
53 |
+
);
|
54 |
+
return $this->get_zip_value( $key );
|
55 |
}
|
56 |
|
57 |
/**
|
58 |
+
* get_tel_value
|
59 |
* データを返す ( 電話番号用 )
|
60 |
* @param string $key name属性
|
61 |
* @return string データ
|
62 |
*/
|
63 |
+
public function get_tel_value( $key ) {
|
64 |
+
return $this->get_zip_value( $key );
|
65 |
+
}
|
66 |
public function getTelValue( $key ) {
|
67 |
+
MWF_Functions::deprecated_message(
|
68 |
+
'MW_Form::getTelValue()',
|
69 |
+
'MW_WP_Form_Form::get_tel_value()'
|
70 |
+
);
|
71 |
+
return $this->get_tel_value( $key );
|
72 |
}
|
73 |
|
74 |
/**
|
75 |
+
* get_checked_value
|
76 |
* データを返す( checkbox用 )。$dataに含まれる値のみ返す
|
77 |
* @param string $key name属性
|
78 |
* @param array $data
|
79 |
* @return string データ
|
80 |
*/
|
81 |
+
public function get_checked_value( $key, array $data ) {
|
82 |
+
return $this->Data->get_separated_value( $key, $data );
|
83 |
+
}
|
84 |
+
public function getCheckedValue() {
|
85 |
+
MWF_Functions::deprecated_message(
|
86 |
+
'MW_Form::getCheckedValue()',
|
87 |
+
'MW_WP_Form_Form::get_checked_value()'
|
88 |
+
);
|
89 |
+
return $this->get_checked_value( $key );
|
90 |
}
|
91 |
|
92 |
/**
|
93 |
+
* get_radio_value
|
94 |
* データを返す( radio用 )。$dataに含まれる値のみ返す
|
95 |
* @param string name属性値
|
96 |
* @param array $data データ
|
97 |
* @return string
|
98 |
*/
|
99 |
+
public function get_radio_value( $key, array $data ) {
|
100 |
+
$value = $this->get_raw( $key );
|
101 |
if ( !is_null( $value ) && !is_array( $value ) ) {
|
102 |
if ( isset( $data[$value] ) ) {
|
103 |
return $data[$value];
|
104 |
}
|
105 |
}
|
106 |
}
|
107 |
+
public function getRadioValue( $key, array $data ) {
|
108 |
+
MWF_Functions::deprecated_message(
|
109 |
+
'MW_Form::getRadioValue()',
|
110 |
+
'MW_WP_Form_Form::get_radio_value()'
|
111 |
+
);
|
112 |
+
return $this->get_radio_value( $key, $data );
|
113 |
+
}
|
114 |
|
115 |
/**
|
116 |
+
* get_selected_value
|
117 |
* データを返す( selectbox用 )。$dataに含まれる値のみ返す
|
118 |
* @param string $key name属性
|
119 |
* @param array $data データ
|
120 |
* @return string データ
|
121 |
*/
|
122 |
+
public function get_selected_value( $key, array $data ) {
|
123 |
+
return $this->get_radio_value( $key, $data );
|
124 |
+
}
|
125 |
+
public function getSelectedValue( $key, array $data ) {
|
126 |
+
MWF_Functions::deprecated_message(
|
127 |
+
'MW_Form::getSelectedValue()',
|
128 |
+
'MW_WP_Form_Form::get_selected_value()'
|
129 |
+
);
|
130 |
+
return $this->get_selected_value( $key, $data );
|
131 |
}
|
132 |
|
133 |
/**
|
138 |
* @return string HTML
|
139 |
*/
|
140 |
public function separator( $key, $separator = '' ) {
|
141 |
+
$post_separator = $this->get_separator_value( $key );
|
142 |
if ( !$separator && $post_separator ) {
|
143 |
$separator = $post_separator;
|
144 |
}
|
148 |
}
|
149 |
|
150 |
/**
|
151 |
+
* get_separator_value
|
152 |
* 送られてきたseparatorを返す
|
153 |
* @param string $key name属性
|
154 |
* @return string
|
155 |
*/
|
156 |
+
public function get_separator_value( $key ) {
|
157 |
+
return $this->Data->get_separator_value( $key );
|
158 |
+
}
|
159 |
+
public function getSeparatorValue() {
|
160 |
+
MWF_Functions::deprecated_message(
|
161 |
+
'MW_Form::getSeparatorValue()',
|
162 |
+
'MW_WP_Form_Form::get_separator_value()'
|
163 |
+
);
|
164 |
+
return $this->get_separator_value( $key );
|
165 |
}
|
166 |
|
167 |
/**
|
172 |
*/
|
173 |
public function start( $options = array() ) {
|
174 |
$defaults = array(
|
175 |
+
'action' => '',
|
|
|
176 |
'enctype' => 'multipart/form-data',
|
177 |
);
|
178 |
$options = array_merge( $defaults, $options );
|
179 |
+
return sprintf(
|
180 |
+
'<form method="post" action="%s" enctype="%s">',
|
181 |
+
esc_attr( $options['action'] ),
|
182 |
+
esc_attr( $options['enctype'] )
|
183 |
+
);
|
184 |
}
|
185 |
|
186 |
/**
|
190 |
*/
|
191 |
public function end() {
|
192 |
$html = '';
|
193 |
+
$html = apply_filters( 'mwform_form_end_html', $html );
|
|
|
|
|
194 |
$html .= '</form>';
|
195 |
return $html;
|
196 |
}
|
204 |
*/
|
205 |
public function text( $name, $options = array() ) {
|
206 |
$defaults = array(
|
207 |
+
'id' => '',
|
208 |
+
'size' => 60,
|
209 |
+
'maxlength' => 255,
|
210 |
+
'value' => '',
|
211 |
'conv-half-alphanumeric' => false,
|
212 |
'placeholder' => '',
|
213 |
);
|
214 |
$options = array_merge( $defaults, $options );
|
215 |
+
$value = $this->get_raw( $name );
|
216 |
+
if ( is_null( $value ) ) {
|
217 |
+
$value = $options['value'];
|
|
|
|
|
|
|
218 |
}
|
219 |
$placeholder = $this->get_attr_placeholder( $options['placeholder'] );
|
220 |
$dataConvHalfAlphanumeric = null;
|
241 |
* @return string HTML
|
242 |
*/
|
243 |
public function hidden( $name, $value ) {
|
244 |
+
if ( is_null( $value ) ) {
|
245 |
+
$value = $this->get_raw( $name );
|
246 |
+
}
|
247 |
if ( is_array( $value ) ) {
|
248 |
$value = $this->getZipValue( $name );
|
249 |
}
|
259 |
*/
|
260 |
public function password( $name, $options = array() ) {
|
261 |
$defaults = array(
|
262 |
+
'id' => '',
|
263 |
+
'size' => 60,
|
264 |
+
'maxlength' => 255,
|
265 |
+
'value' => '',
|
266 |
'placeholder' => '',
|
267 |
);
|
268 |
$options = array_merge( $defaults, $options );
|
269 |
+
$value = $this->get_raw( $name );
|
270 |
+
if ( is_null( $value ) ) {
|
271 |
+
$value = $options['value'];
|
|
|
|
|
|
|
272 |
}
|
273 |
$placeholder = $this->get_attr_placeholder( $options['placeholder'] );
|
274 |
$id = $this->get_attr_id( $options['id'] );
|
297 |
|
298 |
$children = array();
|
299 |
$separator = '-';
|
300 |
+
$value = $this->get_raw( $name );
|
301 |
if ( !is_null( $value ) && is_array( $value ) && isset( $value['data'] ) ) {
|
302 |
if ( is_array( $value['data'] ) ) {
|
303 |
$children = $value['data'];
|
316 |
$_ret = '<span class="mwform-zip-field">';
|
317 |
$_ret .= '〒';
|
318 |
$_ret .= $this->text( $name . '[data][0]', array(
|
319 |
+
'size' => 4,
|
320 |
'maxlength' => 3,
|
321 |
+
'value' => $values[0],
|
322 |
'conv-half-alphanumeric' => $options['conv-half-alphanumeric'],
|
323 |
) );
|
324 |
$_ret .= ' ' . $separator . ' ';
|
325 |
$_ret .= $this->text( $name . '[data][1]', array(
|
326 |
+
'size' => 5,
|
327 |
'maxlength' => 4,
|
328 |
+
'value' => $values[1],
|
329 |
'conv-half-alphanumeric' => $options['conv-half-alphanumeric'],
|
330 |
) );
|
331 |
$_ret .= $this->separator( $name, $separator );
|
348 |
|
349 |
$children = array();
|
350 |
$separator = '-';
|
351 |
+
$value = $this->get_raw( $name );
|
352 |
if ( !is_null( $value ) && is_array( $value ) && isset( $value['data'] ) ) {
|
353 |
if ( is_array( $value['data'] ) ) {
|
354 |
$children = $value['data'];
|
366 |
|
367 |
$_ret = '<span class="mwform-tel-field">';
|
368 |
$_ret .= $this->text( $name . '[data][0]', array(
|
369 |
+
'size' => 6,
|
370 |
'maxlength' => 5,
|
371 |
+
'value' => $values[0],
|
372 |
'conv-half-alphanumeric' => $options['conv-half-alphanumeric'],
|
373 |
) );
|
374 |
$_ret .= ' ' . $separator . ' ';
|
375 |
$_ret .= $this->text( $name . '[data][1]', array(
|
376 |
+
'size' => 5,
|
377 |
'maxlength' => 4,
|
378 |
+
'value' => $values[1],
|
379 |
'conv-half-alphanumeric' => $options['conv-half-alphanumeric'],
|
380 |
) );
|
381 |
$_ret .= ' ' . $separator . ' ';
|
382 |
$_ret .= $this->text( $name . '[data][2]', array(
|
383 |
+
'size' => 5,
|
384 |
'maxlength' => 4,
|
385 |
+
'value' => $values[2],
|
386 |
'conv-half-alphanumeric' => $options['conv-half-alphanumeric'],
|
387 |
) );
|
388 |
$_ret .= $this->separator( $name, $separator );
|
399 |
*/
|
400 |
public function textarea( $name, $options = array() ) {
|
401 |
$defaults = array(
|
402 |
+
'id' => '',
|
403 |
+
'cols' => 50,
|
404 |
+
'rows' => 5,
|
405 |
+
'value' => '',
|
406 |
'placeholder' => '',
|
407 |
);
|
408 |
$options = array_merge( $defaults, $options );
|
409 |
+
$value = $this->get_raw( $name );
|
410 |
+
if ( is_null( $value ) ) {
|
411 |
+
$value = $options['value'];
|
|
|
|
|
|
|
412 |
}
|
413 |
$placeholder = $this->get_attr_placeholder( $options['placeholder'] );
|
414 |
$id = $this->get_attr_id( $options['id'] );
|
432 |
*/
|
433 |
public function select( $name, $children = array(), $options = array() ) {
|
434 |
$defaults = array(
|
435 |
+
'id' => '',
|
436 |
'value' => ''
|
437 |
);
|
438 |
$options = array_merge( $defaults, $options );
|
439 |
+
$value = $this->get_raw( $name );
|
440 |
+
if ( is_null( $value ) ) {
|
441 |
+
$value = $options['value'];
|
|
|
|
|
|
|
442 |
}
|
443 |
$id = $this->get_attr_id( $options['id'] );
|
444 |
$_ret = sprintf( '<select name="%s" %s>', esc_attr( $name ), $id );
|
467 |
'vertically' => '',
|
468 |
);
|
469 |
$options = array_merge( $defaults, $options );
|
470 |
+
$value = $this->get_raw( $name );
|
471 |
+
if ( is_null( $value ) ) {
|
472 |
+
$value = $options['value'];
|
|
|
|
|
|
|
473 |
}
|
474 |
|
475 |
$i = 0;
|
480 |
$for = $this->get_attr_for( $options['id'], $i );
|
481 |
$vertically = ( $options['vertically'] === 'true' ) ? 'vertical-item' : '';
|
482 |
$checked = ( $key == $value )? ' checked="checked"' : '';
|
483 |
+
$_ret .= sprintf(
|
484 |
+
'<span class="%s"><label %s><input type="radio" name="%s" value="%s"%s %s />%s</label></span>',
|
485 |
$vertically,
|
486 |
+
$for,
|
487 |
esc_attr( $name ),
|
488 |
esc_attr( $key ),
|
489 |
$checked,
|
510 |
'vertically' => '',
|
511 |
);
|
512 |
$options = array_merge( $defaults, $options );
|
513 |
+
$value = $this->get_raw( $name );
|
514 |
+
if ( is_array( $value ) && isset( $value['data'] ) ) {
|
515 |
+
$value = $value['data'];
|
516 |
+
} else {
|
517 |
+
$value = $options['value'];
|
518 |
+
}
|
519 |
+
if ( !is_array( $value ) ) {
|
520 |
+
$value = explode( $separator, $value );
|
|
|
|
|
|
|
521 |
}
|
522 |
|
523 |
$i = 0;
|
524 |
$_ret = '';
|
525 |
foreach ( $children as $key => $_value ) {
|
526 |
$i ++;
|
527 |
+
$id = $this->get_attr_id( $options['id'], $i );
|
528 |
$for = $this->get_attr_for( $options['id'], $i );
|
529 |
$vertically = ( $options['vertically'] === 'true' ) ? 'vertical-item' : '';
|
530 |
$checked = ( is_array( $value ) && in_array( $key, $value ) )? ' checked="checked"' : '';
|
531 |
+
$_ret .= sprintf(
|
532 |
+
'<span class="%s"><label %s><input type="checkbox" name="%s" value="%s"%s %s />%s</label></span>',
|
533 |
$vertically,
|
534 |
+
$for,
|
535 |
esc_attr( $name.'[data][]' ),
|
536 |
esc_attr( $key ),
|
537 |
$checked,
|
574 |
*/
|
575 |
public function datepicker( $name, $options = array() ) {
|
576 |
$defaults = array(
|
577 |
+
'id' => '',
|
578 |
+
'size' => 30,
|
579 |
+
'js' => '',
|
580 |
'value' => '',
|
581 |
);
|
582 |
$options = array_merge( $defaults, $options );
|
583 |
+
$value = $this->get_raw( $name );
|
584 |
+
if ( is_null( $value ) ) {
|
585 |
+
$value = $options['value'];
|
|
|
|
|
|
|
586 |
}
|
587 |
$id = $this->get_attr_id( $options['id'] );
|
588 |
$_ret = sprintf( '<input type="text" name="%s" value="%s" size="%d" %s />',
|
659 |
return 'placeholder="' . esc_attr( $placeholder ) . '"';
|
660 |
}
|
661 |
}
|
662 |
+
|
663 |
+
/**
|
664 |
+
* getValue
|
665 |
+
* データを返す
|
666 |
+
* @param string $key name属性値
|
667 |
+
* @return mixed
|
668 |
+
*/
|
669 |
+
public function getValue( $key ) {
|
670 |
+
MWF_Functions::deprecated_message(
|
671 |
+
'MW_Form::getValue()',
|
672 |
+
'MW_WP_Form_Form::get_raw()'
|
673 |
+
);
|
674 |
+
return $this->Data->get_raw( $key );
|
675 |
+
}
|
676 |
}
|
system/mw_mail.php → classes/models/class.mail.php
RENAMED
@@ -1,69 +1,89 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Name: MW Mail
|
4 |
* Description: メールクラス
|
5 |
-
* Version: 1.
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created: July 20, 2012
|
9 |
-
* Modified:
|
10 |
-
* License: GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
-
class
|
14 |
|
15 |
/**
|
|
|
16 |
* 宛先
|
|
|
17 |
*/
|
18 |
public $to;
|
19 |
|
20 |
/**
|
|
|
21 |
* CC
|
|
|
22 |
*/
|
23 |
public $cc;
|
24 |
|
25 |
/**
|
|
|
26 |
* BCC
|
|
|
27 |
*/
|
28 |
public $bcc;
|
29 |
|
30 |
/**
|
|
|
31 |
* 送信元
|
|
|
32 |
*/
|
33 |
public $from;
|
34 |
|
35 |
/**
|
|
|
36 |
* 送信者
|
|
|
37 |
*/
|
38 |
public $sender;
|
39 |
|
40 |
/**
|
|
|
41 |
* 件名
|
|
|
42 |
*/
|
43 |
public $subject;
|
44 |
|
45 |
/**
|
|
|
46 |
* 本文
|
|
|
47 |
*/
|
48 |
public $body;
|
49 |
|
50 |
/**
|
|
|
51 |
* 添付
|
|
|
52 |
*/
|
53 |
-
public $attachments;
|
54 |
|
55 |
/**
|
56 |
* send
|
57 |
* メール送信
|
58 |
*/
|
59 |
public function send() {
|
60 |
-
if ( !$this->to )
|
|
|
|
|
|
|
61 |
$subject = $this->subject;
|
62 |
-
$body
|
63 |
|
64 |
-
add_action( 'phpmailer_init', array( $this, 'set_return_path' ) );
|
65 |
-
add_filter( 'wp_mail_from', array( $this, 'set_mail_from' ) );
|
66 |
add_filter( 'wp_mail_from_name', array( $this, 'set_mail_from_name' ) );
|
|
|
67 |
$tos = explode( ',', $this->to );
|
68 |
foreach ( $tos as $to ) {
|
69 |
$headers = array();
|
@@ -76,16 +96,34 @@ class MW_Mail {
|
|
76 |
$to = trim( $to );
|
77 |
wp_mail( $to, $subject, $body, $headers, $this->attachments );
|
78 |
}
|
79 |
-
|
80 |
-
|
|
|
81 |
remove_filter( 'wp_mail_from_name', array( $this, 'set_mail_from_name' ) );
|
82 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
public function set_mail_from( $email ) {
|
84 |
return $this->from;
|
85 |
}
|
86 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
return $this->sender;
|
88 |
}
|
|
|
|
|
|
|
|
|
|
|
89 |
public function set_return_path( $phpmailer ) {
|
90 |
$phpmailer->Sender = $this->from;
|
91 |
}
|
@@ -120,8 +158,9 @@ class MW_Mail {
|
|
120 |
}
|
121 |
$value = $_value;
|
122 |
}
|
123 |
-
if ( $value )
|
124 |
$_ret .= sprintf( "▼%s\n%s\n\n", esc_html( $key ), esc_html( $value ) );
|
|
|
125 |
}
|
126 |
return $_ret;
|
127 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Name : MW WP Form Mail
|
4 |
* Description: メールクラス
|
5 |
+
* Version : 1.5.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : July 20, 2012
|
9 |
+
* Modified : January 1, 2015
|
10 |
+
* License : GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
+
class MW_WP_Form_Mail {
|
14 |
|
15 |
/**
|
16 |
+
* $to
|
17 |
* 宛先
|
18 |
+
* @var string
|
19 |
*/
|
20 |
public $to;
|
21 |
|
22 |
/**
|
23 |
+
* $cc
|
24 |
* CC
|
25 |
+
* @var string
|
26 |
*/
|
27 |
public $cc;
|
28 |
|
29 |
/**
|
30 |
+
* $bcc
|
31 |
* BCC
|
32 |
+
* @var string
|
33 |
*/
|
34 |
public $bcc;
|
35 |
|
36 |
/**
|
37 |
+
* $from
|
38 |
* 送信元
|
39 |
+
* @var string
|
40 |
*/
|
41 |
public $from;
|
42 |
|
43 |
/**
|
44 |
+
* $sender
|
45 |
* 送信者
|
46 |
+
* @var string
|
47 |
*/
|
48 |
public $sender;
|
49 |
|
50 |
/**
|
51 |
+
* $subject
|
52 |
* 件名
|
53 |
+
* @var string
|
54 |
*/
|
55 |
public $subject;
|
56 |
|
57 |
/**
|
58 |
+
* $body
|
59 |
* 本文
|
60 |
+
* @var string
|
61 |
*/
|
62 |
public $body;
|
63 |
|
64 |
/**
|
65 |
+
* $attachments
|
66 |
* 添付
|
67 |
+
* @var array
|
68 |
*/
|
69 |
+
public $attachments = array();
|
70 |
|
71 |
/**
|
72 |
* send
|
73 |
* メール送信
|
74 |
*/
|
75 |
public function send() {
|
76 |
+
if ( !$this->to ) {
|
77 |
+
return;
|
78 |
+
}
|
79 |
+
|
80 |
$subject = $this->subject;
|
81 |
+
$body = $this->body;
|
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 |
$tos = explode( ',', $this->to );
|
88 |
foreach ( $tos as $to ) {
|
89 |
$headers = array();
|
96 |
$to = trim( $to );
|
97 |
wp_mail( $to, $subject, $body, $headers, $this->attachments );
|
98 |
}
|
99 |
+
|
100 |
+
remove_action( 'phpmailer_init' , array( $this, 'set_return_path' ) );
|
101 |
+
remove_filter( 'wp_mail_from' , array( $this, 'set_mail_from' ) );
|
102 |
remove_filter( 'wp_mail_from_name', array( $this, 'set_mail_from_name' ) );
|
103 |
}
|
104 |
+
|
105 |
+
/**
|
106 |
+
* set_mail_from
|
107 |
+
* @param string $email fromメールアドレス
|
108 |
+
* @return string
|
109 |
+
*/
|
110 |
public function set_mail_from( $email ) {
|
111 |
return $this->from;
|
112 |
}
|
113 |
+
|
114 |
+
/**
|
115 |
+
* set_mail_from_name
|
116 |
+
* @param string $sender 送信者名
|
117 |
+
* @return string
|
118 |
+
*/
|
119 |
+
public function set_mail_from_name( $sender ) {
|
120 |
return $this->sender;
|
121 |
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* set_return_path
|
125 |
+
* @param phpmailer $phpmailer
|
126 |
+
*/
|
127 |
public function set_return_path( $phpmailer ) {
|
128 |
$phpmailer->Sender = $this->from;
|
129 |
}
|
158 |
}
|
159 |
$value = $_value;
|
160 |
}
|
161 |
+
if ( $value ) {
|
162 |
$_ret .= sprintf( "▼%s\n%s\n\n", esc_html( $key ), esc_html( $value ) );
|
163 |
+
}
|
164 |
}
|
165 |
return $_ret;
|
166 |
}
|
system/mw_session.php → classes/models/class.session.php
RENAMED
@@ -1,31 +1,37 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Name: MW Session
|
4 |
-
* Description:
|
5 |
-
* Version: 2.0
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created
|
9 |
-
* Modified:
|
10 |
-
* License: GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
-
class
|
14 |
|
15 |
/**
|
|
|
16 |
* セッション名
|
|
|
17 |
*/
|
18 |
-
|
19 |
|
20 |
/**
|
|
|
21 |
* セッションID
|
|
|
22 |
*/
|
23 |
-
|
24 |
|
25 |
/**
|
|
|
26 |
* Transient の生存時間
|
|
|
27 |
*/
|
28 |
-
|
29 |
|
30 |
/**
|
31 |
* __construct
|
@@ -36,9 +42,9 @@ class MW_Session {
|
|
36 |
if ( isset( $_COOKIE[$this->name] ) ) {
|
37 |
$session_id = $_COOKIE[$this->name];
|
38 |
} else {
|
39 |
-
$session_id = sha1( wp_create_nonce( $this->name ) . ip2long( $
|
40 |
$secure = apply_filters( 'mwform_secure_cookie', is_ssl() );
|
41 |
-
setcookie( $this->name, $session_id, 0, COOKIEPATH, COOKIE_DOMAIN, $secure, true );
|
42 |
}
|
43 |
$this->session_id = $session_id;
|
44 |
}
|
@@ -48,7 +54,7 @@ class MW_Session {
|
|
48 |
* セッション変数にセット
|
49 |
* @param array $data
|
50 |
*/
|
51 |
-
public function save(
|
52 |
$transient_data = get_transient( $this->session_id );
|
53 |
if ( is_array( $transient_data ) ) {
|
54 |
foreach ( $data as $key => $value ) {
|
@@ -61,12 +67,12 @@ class MW_Session {
|
|
61 |
}
|
62 |
|
63 |
/**
|
64 |
-
*
|
65 |
* セッション変数にセット
|
66 |
* @param string $key キー
|
67 |
* @param mixed $value 値
|
68 |
*/
|
69 |
-
public function
|
70 |
$transient_data = get_transient( $this->session_id );
|
71 |
if ( is_array( $transient_data ) ) {
|
72 |
$transient_data[$key] = $value;
|
@@ -77,12 +83,12 @@ class MW_Session {
|
|
77 |
}
|
78 |
|
79 |
/**
|
80 |
-
*
|
81 |
* セッション変数にセット
|
82 |
* @param string $key キー
|
83 |
* @param mixed $value 値
|
84 |
*/
|
85 |
-
public function
|
86 |
$transient_data = get_transient( $this->session_id );
|
87 |
if ( is_array( $transient_data ) ) {
|
88 |
$transient_data[$key][] = $value;
|
@@ -93,12 +99,12 @@ class MW_Session {
|
|
93 |
}
|
94 |
|
95 |
/**
|
96 |
-
*
|
97 |
* セッション変数から取得
|
98 |
* @param string $key キー
|
99 |
* @return mixed セッション値
|
100 |
*/
|
101 |
-
public function
|
102 |
$transient_data = get_transient( $this->session_id );
|
103 |
if ( is_array( $transient_data ) && isset( $transient_data[$key] ) ) {
|
104 |
return $transient_data[$key];
|
@@ -111,7 +117,7 @@ class MW_Session {
|
|
111 |
* セッション変数から取得
|
112 |
* @return array セッション値
|
113 |
*/
|
114 |
-
public function
|
115 |
$transient_data = get_transient( $this->session_id );
|
116 |
if ( is_array( $transient_data ) ) {
|
117 |
return $transient_data;
|
@@ -120,11 +126,11 @@ class MW_Session {
|
|
120 |
}
|
121 |
|
122 |
/**
|
123 |
-
*
|
124 |
* セッション変数を空に
|
125 |
* @param string $key キー
|
126 |
*/
|
127 |
-
public function
|
128 |
$transient_data = get_transient( $this->session_id );
|
129 |
if ( is_array( $transient_data ) && isset( $transient_data[$key] ) ) {
|
130 |
unset( $transient_data[$key] );
|
@@ -133,10 +139,20 @@ class MW_Session {
|
|
133 |
}
|
134 |
|
135 |
/**
|
136 |
-
*
|
137 |
* セッション変数を空に
|
138 |
*/
|
139 |
-
public function
|
140 |
delete_transient( $this->session_id );
|
141 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Name : MW WP Form Session
|
4 |
+
* Description: 永続的にデータを保存するためのクラス。Transient API を使用
|
5 |
+
* Version : 2.1.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : July 17, 2012
|
9 |
+
* Modified : December 31, 2014
|
10 |
+
* License : GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
+
class MW_WP_Form_Session {
|
14 |
|
15 |
/**
|
16 |
+
* $name
|
17 |
* セッション名
|
18 |
+
* @var string
|
19 |
*/
|
20 |
+
protected $name;
|
21 |
|
22 |
/**
|
23 |
+
* $session_id
|
24 |
* セッションID
|
25 |
+
* @var string
|
26 |
*/
|
27 |
+
protected $session_id;
|
28 |
|
29 |
/**
|
30 |
+
* $expiration
|
31 |
* Transient の生存時間
|
32 |
+
* @var int
|
33 |
*/
|
34 |
+
protected $expiration = 1440;
|
35 |
|
36 |
/**
|
37 |
* __construct
|
42 |
if ( isset( $_COOKIE[$this->name] ) ) {
|
43 |
$session_id = $_COOKIE[$this->name];
|
44 |
} else {
|
45 |
+
$session_id = sha1( wp_create_nonce( $this->name ) . ip2long( $this->get_remote_addr() ) . uniqid() );
|
46 |
$secure = apply_filters( 'mwform_secure_cookie', is_ssl() );
|
47 |
+
@setcookie( $this->name, $session_id, 0, COOKIEPATH, COOKIE_DOMAIN, $secure, true );
|
48 |
}
|
49 |
$this->session_id = $session_id;
|
50 |
}
|
54 |
* セッション変数にセット
|
55 |
* @param array $data
|
56 |
*/
|
57 |
+
public function save( array $data ) {
|
58 |
$transient_data = get_transient( $this->session_id );
|
59 |
if ( is_array( $transient_data ) ) {
|
60 |
foreach ( $data as $key => $value ) {
|
67 |
}
|
68 |
|
69 |
/**
|
70 |
+
* set
|
71 |
* セッション変数にセット
|
72 |
* @param string $key キー
|
73 |
* @param mixed $value 値
|
74 |
*/
|
75 |
+
public function set( $key, $value ) {
|
76 |
$transient_data = get_transient( $this->session_id );
|
77 |
if ( is_array( $transient_data ) ) {
|
78 |
$transient_data[$key] = $value;
|
83 |
}
|
84 |
|
85 |
/**
|
86 |
+
* push
|
87 |
* セッション変数にセット
|
88 |
* @param string $key キー
|
89 |
* @param mixed $value 値
|
90 |
*/
|
91 |
+
public function push( $key, $value ) {
|
92 |
$transient_data = get_transient( $this->session_id );
|
93 |
if ( is_array( $transient_data ) ) {
|
94 |
$transient_data[$key][] = $value;
|
99 |
}
|
100 |
|
101 |
/**
|
102 |
+
* get
|
103 |
* セッション変数から取得
|
104 |
* @param string $key キー
|
105 |
* @return mixed セッション値
|
106 |
*/
|
107 |
+
public function get( $key ) {
|
108 |
$transient_data = get_transient( $this->session_id );
|
109 |
if ( is_array( $transient_data ) && isset( $transient_data[$key] ) ) {
|
110 |
return $transient_data[$key];
|
117 |
* セッション変数から取得
|
118 |
* @return array セッション値
|
119 |
*/
|
120 |
+
public function gets() {
|
121 |
$transient_data = get_transient( $this->session_id );
|
122 |
if ( is_array( $transient_data ) ) {
|
123 |
return $transient_data;
|
126 |
}
|
127 |
|
128 |
/**
|
129 |
+
* clear_value
|
130 |
* セッション変数を空に
|
131 |
* @param string $key キー
|
132 |
*/
|
133 |
+
public function clear_value( $key ) {
|
134 |
$transient_data = get_transient( $this->session_id );
|
135 |
if ( is_array( $transient_data ) && isset( $transient_data[$key] ) ) {
|
136 |
unset( $transient_data[$key] );
|
139 |
}
|
140 |
|
141 |
/**
|
142 |
+
* clear_values
|
143 |
* セッション変数を空に
|
144 |
*/
|
145 |
+
public function clear_values() {
|
146 |
delete_transient( $this->session_id );
|
147 |
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
* get_remote_addr
|
151 |
+
*/
|
152 |
+
protected function get_remote_addr() {
|
153 |
+
if ( isset( $_SERVER['REMOTE_ADDR'] ) ) {
|
154 |
+
return $_SERVER['REMOTE_ADDR'];
|
155 |
+
}
|
156 |
+
return '127.0.0.1';
|
157 |
+
}
|
158 |
}
|
classes/models/class.setting.php
ADDED
@@ -0,0 +1,296 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Name : MW WP Form Setting
|
4 |
+
* Version : 1.0.0
|
5 |
+
* Author : Takashi Kitajima
|
6 |
+
* Author URI : http://2inc.org
|
7 |
+
* Created : December 31, 2014
|
8 |
+
* Modified :
|
9 |
+
* License : GPLv2
|
10 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
+
*/
|
12 |
+
class MW_WP_Form_Setting {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* $post_id
|
16 |
+
* フォームの Post ID
|
17 |
+
* @var int
|
18 |
+
*/
|
19 |
+
protected $post_id;
|
20 |
+
|
21 |
+
/**
|
22 |
+
* $mail_subject
|
23 |
+
* 自動返信メールの題名
|
24 |
+
* @var string
|
25 |
+
*/
|
26 |
+
protected $mail_subject = '';
|
27 |
+
|
28 |
+
/**
|
29 |
+
* $mail_from
|
30 |
+
* 自動返信メールの送信元
|
31 |
+
* @var string
|
32 |
+
*/
|
33 |
+
protected $mail_from = '';
|
34 |
+
|
35 |
+
/**
|
36 |
+
* $mail_sender
|
37 |
+
* 自動返信メールの送信者
|
38 |
+
* @var string
|
39 |
+
*/
|
40 |
+
protected $mail_sender = '';
|
41 |
+
|
42 |
+
/**
|
43 |
+
* $mail_content
|
44 |
+
* 自動返信メールの本文
|
45 |
+
* @var string
|
46 |
+
*/
|
47 |
+
protected $mail_content = '';
|
48 |
+
|
49 |
+
/**
|
50 |
+
* $automatic_reply_email
|
51 |
+
* 自動返信メールの送信先を格納したフォームフィールドのname属性
|
52 |
+
* @var string
|
53 |
+
*/
|
54 |
+
protected $automatic_reply_email = '';
|
55 |
+
|
56 |
+
/**
|
57 |
+
* $mail_to
|
58 |
+
* 管理者メールの送信先
|
59 |
+
* @var string
|
60 |
+
*/
|
61 |
+
protected $mail_to = '';
|
62 |
+
|
63 |
+
/**
|
64 |
+
* $mail_cc
|
65 |
+
* 管理者メールのCC
|
66 |
+
* @var string
|
67 |
+
*/
|
68 |
+
protected $mail_cc = '';
|
69 |
+
|
70 |
+
/**
|
71 |
+
* $mail_bcc
|
72 |
+
* 管理者メールのBCC
|
73 |
+
* @var string
|
74 |
+
*/
|
75 |
+
protected $mail_bcc = '';
|
76 |
+
|
77 |
+
/**
|
78 |
+
* $admin_mail_subject
|
79 |
+
* 管理者メールの題名
|
80 |
+
* @var string
|
81 |
+
*/
|
82 |
+
protected $admin_mail_subject = '';
|
83 |
+
|
84 |
+
/**
|
85 |
+
* $admin_mail_from
|
86 |
+
* 管理者メールの送信元
|
87 |
+
* @var string
|
88 |
+
*/
|
89 |
+
protected $admin_mail_from = '';
|
90 |
+
|
91 |
+
/**
|
92 |
+
* $admin_mail_sender
|
93 |
+
* 管理者メールの送信者
|
94 |
+
* @var string
|
95 |
+
*/
|
96 |
+
protected $admin_mail_sender = '';
|
97 |
+
|
98 |
+
/**
|
99 |
+
* $admin_mail_content
|
100 |
+
* 管理者メールの本文
|
101 |
+
* @var string
|
102 |
+
*/
|
103 |
+
protected $admin_mail_content = '';
|
104 |
+
|
105 |
+
/**
|
106 |
+
* $querystring
|
107 |
+
* URL引数を有効にするかどうか
|
108 |
+
* @var false|1
|
109 |
+
*/
|
110 |
+
protected $querystring = false;
|
111 |
+
|
112 |
+
/**
|
113 |
+
* $usedb
|
114 |
+
* 問い合わせデータを保存するかどうか
|
115 |
+
* @var false|1
|
116 |
+
*/
|
117 |
+
protected $usedb = false;
|
118 |
+
|
119 |
+
/**
|
120 |
+
* $akismet_author
|
121 |
+
* akismet送信者の対象とするフォームフィールドのname属性
|
122 |
+
* @var string
|
123 |
+
*/
|
124 |
+
protected $akismet_author = '';
|
125 |
+
|
126 |
+
/**
|
127 |
+
* $akismet_author_email
|
128 |
+
* akismetメールアドレスの対象とするフォームフィールドのname属性
|
129 |
+
* @var string
|
130 |
+
*/
|
131 |
+
protected $akismet_author_email = '';
|
132 |
+
|
133 |
+
/**
|
134 |
+
* $akismet_author_url
|
135 |
+
* akismet url の対象とするフォームフィールドのname属性
|
136 |
+
* @var string
|
137 |
+
*/
|
138 |
+
protected $akismet_author_url = '';
|
139 |
+
|
140 |
+
/**
|
141 |
+
* $complete_message
|
142 |
+
* 完了画面メッセージ
|
143 |
+
* @var string
|
144 |
+
*/
|
145 |
+
protected $complete_message = '';
|
146 |
+
|
147 |
+
/**
|
148 |
+
* $input_url
|
149 |
+
* 入力画面URL
|
150 |
+
* @var string
|
151 |
+
*/
|
152 |
+
protected $input_url = '';
|
153 |
+
|
154 |
+
/**
|
155 |
+
* $confirmation_url
|
156 |
+
* 確認画面URL
|
157 |
+
* @var string
|
158 |
+
*/
|
159 |
+
protected $confirmation_url = '';
|
160 |
+
|
161 |
+
/**
|
162 |
+
* $complete_url
|
163 |
+
* 完了画面URL
|
164 |
+
* @var string
|
165 |
+
*/
|
166 |
+
protected $complete_url = '';
|
167 |
+
|
168 |
+
/**
|
169 |
+
* $validation_error_url
|
170 |
+
* バリデーションエラー画面URL
|
171 |
+
* @var string
|
172 |
+
*/
|
173 |
+
protected $validation_error_url = '';
|
174 |
+
|
175 |
+
/**
|
176 |
+
* $validation
|
177 |
+
* フォームに設定されたバリデーションルールの配列
|
178 |
+
* @var array
|
179 |
+
*/
|
180 |
+
protected $validation = array();
|
181 |
+
|
182 |
+
/**
|
183 |
+
* $style
|
184 |
+
* フォームに設定されたスタイル
|
185 |
+
* @var string
|
186 |
+
*/
|
187 |
+
protected $style = '';
|
188 |
+
|
189 |
+
/**
|
190 |
+
* $scroll
|
191 |
+
* 入力画面以外を表示したときにフォームの位置までスクロールするかどうか
|
192 |
+
* @var false|1
|
193 |
+
*/
|
194 |
+
protected $scroll = false;
|
195 |
+
|
196 |
+
/**
|
197 |
+
* __construct
|
198 |
+
* @param int $post_id
|
199 |
+
*/
|
200 |
+
public function __construct( $post_id ) {
|
201 |
+
if ( get_post_type( $post_id ) === MWF_Config::NAME ) {
|
202 |
+
$this->post_id = $post_id;
|
203 |
+
$values = get_post_meta( $post_id, MWF_Config::NAME, true );
|
204 |
+
if ( is_array( $values ) ) {
|
205 |
+
$this->sets( $values );
|
206 |
+
}
|
207 |
+
}
|
208 |
+
}
|
209 |
+
|
210 |
+
/**
|
211 |
+
* get
|
212 |
+
* 属性の取得
|
213 |
+
* @param string $key
|
214 |
+
* @return mixed|null
|
215 |
+
*/
|
216 |
+
public function get( $key ) {
|
217 |
+
if ( isset( $this->$key ) ) {
|
218 |
+
return $this->$key;
|
219 |
+
}
|
220 |
+
}
|
221 |
+
|
222 |
+
/**
|
223 |
+
* set
|
224 |
+
* 属性をセット
|
225 |
+
* @param string $key
|
226 |
+
* @param mixed $value
|
227 |
+
*/
|
228 |
+
public function set( $key, $value ) {
|
229 |
+
if ( isset( $this->$key ) ) {
|
230 |
+
$this->$key = $value;
|
231 |
+
}
|
232 |
+
}
|
233 |
+
|
234 |
+
/**
|
235 |
+
* sets
|
236 |
+
* 属性をセット
|
237 |
+
* @param array $values
|
238 |
+
*/
|
239 |
+
public function sets( array $values ) {
|
240 |
+
foreach ( $values as $key => $value ) {
|
241 |
+
$this->set( $key, $value );
|
242 |
+
}
|
243 |
+
}
|
244 |
+
|
245 |
+
/**
|
246 |
+
* save
|
247 |
+
* 保持しているデータでアップデート
|
248 |
+
*/
|
249 |
+
public function save() {
|
250 |
+
$values = get_object_vars( $this );
|
251 |
+
$new_values = array();
|
252 |
+
foreach ( $values as $key => $value ) {
|
253 |
+
if ( $key === 'post_id' ) {
|
254 |
+
continue;
|
255 |
+
}
|
256 |
+
$new_values[$key] = $value;
|
257 |
+
}
|
258 |
+
update_post_meta( $this->post_id, MWF_Config::NAME, $new_values );
|
259 |
+
}
|
260 |
+
|
261 |
+
/**
|
262 |
+
* get_posts
|
263 |
+
* @return array フォーム(WP_Post)の配列
|
264 |
+
*/
|
265 |
+
public function get_posts() {
|
266 |
+
$forms = get_posts( array(
|
267 |
+
'post_type' => MWF_Config::NAME,
|
268 |
+
'posts_per_page' => -1,
|
269 |
+
) );
|
270 |
+
if ( !is_array( $forms ) ) {
|
271 |
+
return array();
|
272 |
+
}
|
273 |
+
return $forms;
|
274 |
+
}
|
275 |
+
|
276 |
+
/**
|
277 |
+
* get_tracking_number
|
278 |
+
* @return int $tracking_number
|
279 |
+
*/
|
280 |
+
public function get_tracking_number() {
|
281 |
+
$tracking_number = get_post_meta( $this->post_id, MWF_Config::TRACKINGNUMBER, true );
|
282 |
+
if ( empty( $tracking_number ) ) {
|
283 |
+
$tracking_number = 1;
|
284 |
+
}
|
285 |
+
return intval( $tracking_number );
|
286 |
+
}
|
287 |
+
|
288 |
+
/**
|
289 |
+
* update_tracking_number
|
290 |
+
*/
|
291 |
+
public function update_tracking_number() {
|
292 |
+
$tracking_number = $this->get_tracking_number();
|
293 |
+
$new_tracking_number = $tracking_number + 1;
|
294 |
+
update_post_meta( $this->post_id, MWF_Config::TRACKINGNUMBER, $new_tracking_number );
|
295 |
+
}
|
296 |
+
}
|
classes/models/class.validation.php
ADDED
@@ -0,0 +1,182 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Name : MW WP Form Validation
|
4 |
+
* Description: 与えられたデータに対してバリデーションエラーがあるかチェックする
|
5 |
+
* Version : 1.8.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : July 20, 2012
|
9 |
+
* Modified : December 31, 2014
|
10 |
+
* License : GPLv2
|
11 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
+
*/
|
13 |
+
class MW_WP_Form_Validation {
|
14 |
+
|
15 |
+
/**
|
16 |
+
* $Error
|
17 |
+
* @var MW_WP_Form_Error
|
18 |
+
*/
|
19 |
+
protected $Error;
|
20 |
+
|
21 |
+
/**
|
22 |
+
* $validate
|
23 |
+
* バリデートをかける項目(name属性)と、それにかけるバリデーションの配列
|
24 |
+
* @var array
|
25 |
+
*/
|
26 |
+
public $validate = array();
|
27 |
+
|
28 |
+
/**
|
29 |
+
* $validation_rules
|
30 |
+
* バリデーションルールの配列
|
31 |
+
* @var array
|
32 |
+
*/
|
33 |
+
protected $validation_rules = array();
|
34 |
+
|
35 |
+
/**
|
36 |
+
* __construct
|
37 |
+
* @param MW_WP_Form_Error $Error
|
38 |
+
*/
|
39 |
+
public function __construct( MW_WP_Form_Error $Error ) {
|
40 |
+
$this->Error = $Error;
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* set_validation_rules
|
45 |
+
* 各バリデーションルールクラスのインスタンスをセット
|
46 |
+
* @param array $validation_rules
|
47 |
+
*/
|
48 |
+
public function set_validation_rules( array $validation_rules ) {
|
49 |
+
foreach ( $validation_rules as $validation_name => $instance ) {
|
50 |
+
if ( is_callable( array( $instance, 'rule' ) ) ) {
|
51 |
+
$this->validation_rules[$instance->getName()] = $instance;
|
52 |
+
}
|
53 |
+
}
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* is_valid
|
58 |
+
* バリデートが通っているかチェック
|
59 |
+
* @return bool
|
60 |
+
*/
|
61 |
+
protected function is_valid() {
|
62 |
+
$errors = $this->Error->get_errors();
|
63 |
+
if ( empty( $errors ) ) {
|
64 |
+
return true;
|
65 |
+
} else {
|
66 |
+
return false;
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* set_rules
|
72 |
+
* @param MW_WP_Form_Setting $Setting
|
73 |
+
* @param MW_WP_Form_Data $Data
|
74 |
+
* @return array $rules
|
75 |
+
*/
|
76 |
+
public function set_rules( MW_WP_Form_Setting $Setting, MW_WP_Form_Data $Data ) {
|
77 |
+
$rules = array();
|
78 |
+
$validations = $Setting->get('validation' );
|
79 |
+
if ( $validations ) {
|
80 |
+
foreach ( $validations as $validation ) {
|
81 |
+
foreach ( $validation as $rule => $options ) {
|
82 |
+
if ( $rule == 'target' ) {
|
83 |
+
continue;
|
84 |
+
}
|
85 |
+
if ( !is_array( $options ) ) {
|
86 |
+
$options = array();
|
87 |
+
}
|
88 |
+
$this->set_rule( $validation['target'], $rule, $options );
|
89 |
+
}
|
90 |
+
}
|
91 |
+
}
|
92 |
+
$Akismet = new MW_WP_Form_Akismet();
|
93 |
+
$akismet_check = $Akismet->check(
|
94 |
+
$Setting->get( 'akismet_author' ),
|
95 |
+
$Setting->get( 'akismet_author_email' ),
|
96 |
+
$Setting->get( 'akismet_author_url' ),
|
97 |
+
$Data->gets()
|
98 |
+
);
|
99 |
+
if ( $akismet_check ) {
|
100 |
+
$this->set_rule( MWF_Config::AKISMET, 'akismet_check' );
|
101 |
+
}
|
102 |
+
}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* set_rule
|
106 |
+
* @param string ターゲットのname属性
|
107 |
+
* @param string バリデーションルール名
|
108 |
+
* @param array オプション
|
109 |
+
* @return bool
|
110 |
+
*/
|
111 |
+
public function set_rule( $key, $rule, array $options = array() ) {
|
112 |
+
$rules = array(
|
113 |
+
'rule' => strtolower( $rule ),
|
114 |
+
'options' => $options
|
115 |
+
);
|
116 |
+
$this->validate[$key][] = $rules;
|
117 |
+
return $this;
|
118 |
+
}
|
119 |
+
public function setRule( $key, $rule, array $options = array() ) {
|
120 |
+
MWF_Functions::deprecated_message(
|
121 |
+
'MW_Validations::setRule()',
|
122 |
+
'MW_WP_Form_Validation::set_rule()'
|
123 |
+
);
|
124 |
+
return $this->set_rule( $key, $rule, $options );
|
125 |
+
}
|
126 |
+
|
127 |
+
/**
|
128 |
+
* check
|
129 |
+
* validate実行
|
130 |
+
* @return bool エラーがなければ true
|
131 |
+
*/
|
132 |
+
public function check() {
|
133 |
+
foreach ( $this->validate as $key => $rules ) {
|
134 |
+
$this->_check( $key, $rules );
|
135 |
+
}
|
136 |
+
return $this->is_valid();
|
137 |
+
}
|
138 |
+
|
139 |
+
/**
|
140 |
+
* single_check
|
141 |
+
* 特定の項目のvalidate実行
|
142 |
+
* @param string $key
|
143 |
+
* @return bool エラーがなければ true
|
144 |
+
*/
|
145 |
+
public function single_check( $key ) {
|
146 |
+
$rules = array();
|
147 |
+
if ( is_array( $this->validate ) && isset( $this->validate[$key] ) ) {
|
148 |
+
$rules = $this->validate[$key];
|
149 |
+
$this->_check( $key, $rules );
|
150 |
+
}
|
151 |
+
return $this->is_valid();
|
152 |
+
}
|
153 |
+
|
154 |
+
/**
|
155 |
+
* _check
|
156 |
+
* validate実行の実体
|
157 |
+
* @param string $key
|
158 |
+
* @param array $rules
|
159 |
+
*/
|
160 |
+
protected function _check( $key, array $rules ) {
|
161 |
+
foreach ( $rules as $rule_set ) {
|
162 |
+
if ( !isset( $rule_set['rule'] ) ) {
|
163 |
+
continue;
|
164 |
+
}
|
165 |
+
$rule = $rule_set['rule'];
|
166 |
+
if ( !isset( $this->validation_rules[$rule] ) ) {
|
167 |
+
continue;
|
168 |
+
}
|
169 |
+
$options = array();
|
170 |
+
if ( isset( $rule_set['options'] ) ) {
|
171 |
+
$options = $rule_set['options'];
|
172 |
+
}
|
173 |
+
$validation_rule = $this->validation_rules[$rule];
|
174 |
+
if ( is_callable( array( $validation_rule, 'rule' ) ) ) {
|
175 |
+
$message = $validation_rule->rule( $key, $options );
|
176 |
+
if ( !empty( $message ) ) {
|
177 |
+
$this->Error->set_error( $key, $rule, $message );
|
178 |
+
}
|
179 |
+
}
|
180 |
+
}
|
181 |
+
}
|
182 |
+
}
|
classes/services/class.exec-shortcode.php
ADDED
@@ -0,0 +1,226 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Name : MW WP Form Exec Shortcode
|
4 |
+
* Version : 1.0.0
|
5 |
+
* Description: ExecShortcode(mwform、mwform_formkey)の存在有無のチェックとそれらの抽象化レイヤー
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : December 31, 2014
|
9 |
+
* Modified :
|
10 |
+
* License : GPLv2
|
11 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
+
*/
|
13 |
+
class MW_WP_Form_Exec_Shortcode {
|
14 |
+
|
15 |
+
/**
|
16 |
+
* $post_id
|
17 |
+
* フォームの Post ID
|
18 |
+
* @var int
|
19 |
+
*/
|
20 |
+
protected $post_id;
|
21 |
+
|
22 |
+
/**
|
23 |
+
* $post
|
24 |
+
* ショートコードが埋め込まれた投稿のオブジェクト
|
25 |
+
* @var WP_Post
|
26 |
+
*/
|
27 |
+
protected $post;
|
28 |
+
|
29 |
+
/**
|
30 |
+
* $template
|
31 |
+
* @var string 表示中のテンプレート
|
32 |
+
*/
|
33 |
+
protected $template;
|
34 |
+
|
35 |
+
/**
|
36 |
+
* $settings
|
37 |
+
* @var array
|
38 |
+
*/
|
39 |
+
protected $settings = array(
|
40 |
+
'input_url' => '',
|
41 |
+
'confirmation_url' => '',
|
42 |
+
'complete_url' => '',
|
43 |
+
'validation_error_url' => '',
|
44 |
+
'key' => null,
|
45 |
+
);
|
46 |
+
|
47 |
+
/**
|
48 |
+
* __construct
|
49 |
+
* @param WP_Post $post
|
50 |
+
* @param string $template 使用テンプレートのパス
|
51 |
+
*/
|
52 |
+
public function __construct( WP_Post $post, $template ) {
|
53 |
+
$this->post = $post;
|
54 |
+
$this->template = $template;
|
55 |
+
|
56 |
+
add_shortcode( 'mwform' , array( $this, 'set_settings_by_mwform' ) );
|
57 |
+
add_shortcode( 'mwform_formkey', array( $this, 'set_settings_by_mwform_formkey' ) );
|
58 |
+
do_shortcode( $this->post->post_content );
|
59 |
+
|
60 |
+
$exec_shortcode = $this->get_exec_shortcode();
|
61 |
+
if ( $exec_shortcode ) {
|
62 |
+
// ここで set_settings_by_mwform(), set_settings_by_mwform_formkey() が実行される
|
63 |
+
do_shortcode( $exec_shortcode );
|
64 |
+
}
|
65 |
+
|
66 |
+
remove_shortcode( 'mwform' );
|
67 |
+
remove_shortcode( 'mwform_formkey' );
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* has_shortcode
|
72 |
+
* 必要な設定が完了していたらtrue
|
73 |
+
* @return bool
|
74 |
+
*/
|
75 |
+
public function has_shortcode() {
|
76 |
+
if ( is_null( $this->settings['key'] ) ) {
|
77 |
+
return false;
|
78 |
+
}
|
79 |
+
return true;
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* get
|
84 |
+
*/
|
85 |
+
public function get( $key ) {
|
86 |
+
if ( isset( $this->settings[$key] ) ) {
|
87 |
+
return $this->settings[$key];
|
88 |
+
}
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* get_exec_shortcode
|
93 |
+
* ExecShortcode が含まれていればそのショートコードを返す
|
94 |
+
* @return string [hoge xxx="xxx"]
|
95 |
+
*/
|
96 |
+
protected function get_exec_shortcode() {
|
97 |
+
$exec_shortcode = '';
|
98 |
+
if ( is_singular() && !empty( $this->post->ID ) ) {
|
99 |
+
$exec_shortcode = $this->get_in_content( $this->post->post_content );
|
100 |
+
}
|
101 |
+
if ( empty( $exec_shortcode ) &&
|
102 |
+
!( defined( 'MWFORM_NOT_USE_TEMPLATE' ) && MWFORM_NOT_USE_TEMPLATE === true ) ) {
|
103 |
+
$response = wp_remote_get( $this->template );
|
104 |
+
if ( !is_wp_error( $response ) && $response['response']['code'] === 200 ) {
|
105 |
+
$template_data = $response['body'];
|
106 |
+
$exec_shortcode = $this->get_in_content( $template_data );
|
107 |
+
}
|
108 |
+
}
|
109 |
+
return $exec_shortcode;
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* get_in_content
|
114 |
+
* ExecShortcode が含まれていればそのショートコードを返す
|
115 |
+
* @param string $content
|
116 |
+
* @return string [hoge xxx="xxx"]
|
117 |
+
*/
|
118 |
+
protected function get_in_content( $content ) {
|
119 |
+
preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER );
|
120 |
+
if ( $matches ) {
|
121 |
+
foreach ( $matches as $shortcode ) {
|
122 |
+
if ( in_array( $shortcode[2], array( 'mwform', 'mwform_formkey' ) ) ) {
|
123 |
+
return $shortcode[0];
|
124 |
+
} else {
|
125 |
+
$shortcode = $this->get_in_content( $shortcode[5] );
|
126 |
+
if ( is_array( $shortcode ) && !empty( $shortcode[0] ) ) {
|
127 |
+
return $shortcode[0];
|
128 |
+
}
|
129 |
+
}
|
130 |
+
}
|
131 |
+
}
|
132 |
+
}
|
133 |
+
|
134 |
+
/**
|
135 |
+
* set_settings_by_mwform
|
136 |
+
* @param array|'' $attributes
|
137 |
+
*/
|
138 |
+
public function set_settings_by_mwform( $attributes ) {
|
139 |
+
$attributes = shortcode_atts( array(
|
140 |
+
'key' => 'mwform',
|
141 |
+
'input' => '',
|
142 |
+
'confirm' => '',
|
143 |
+
'complete' => '',
|
144 |
+
'validation_error' => '',
|
145 |
+
), $attributes );
|
146 |
+
$this->set_settings( $attributes );
|
147 |
+
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
* set_settings_by_mwform_formkey
|
151 |
+
* @param array $attributes|''
|
152 |
+
*/
|
153 |
+
public function set_settings_by_mwform_formkey( $attributes ) {
|
154 |
+
$post_id = $this->get_form_id_by_mwform_formkey( $attributes );
|
155 |
+
$this->post_id = $post_id;
|
156 |
+
$settings = array();
|
157 |
+
if ( !empty( $post_id ) ) {
|
158 |
+
$Setting = new MW_WP_Form_Setting( $post_id );
|
159 |
+
foreach ( $this->settings as $key => $value ) {
|
160 |
+
$settings[$key] = $Setting->get( $key );
|
161 |
+
}
|
162 |
+
$settings['key'] = MWF_Config::NAME . '-' . $post_id;
|
163 |
+
}
|
164 |
+
$this->set_settings( $settings );
|
165 |
+
}
|
166 |
+
|
167 |
+
/**
|
168 |
+
* get_form_id_by_mwform_formkey
|
169 |
+
* @param array|'' $attributes
|
170 |
+
* @return string|null Post ID
|
171 |
+
*/
|
172 |
+
protected function get_form_id_by_mwform_formkey( $attributes ) {
|
173 |
+
$attributes = shortcode_atts( array(
|
174 |
+
'key' => '',
|
175 |
+
), $attributes );
|
176 |
+
$post = get_post( $attributes['key'] );
|
177 |
+
if ( isset( $post->ID ) ) {
|
178 |
+
return $post->ID;
|
179 |
+
}
|
180 |
+
}
|
181 |
+
|
182 |
+
/**
|
183 |
+
* set_settings
|
184 |
+
* @param array $attributes
|
185 |
+
*/
|
186 |
+
protected function set_settings( array $attributes ) {
|
187 |
+
foreach ( $attributes as $key => $value ) {
|
188 |
+
if ( $key === 'key' ) {
|
189 |
+
$this->settings['key'] = $value;
|
190 |
+
}
|
191 |
+
if ( $key === 'input_url' || $key === 'input' ) {
|
192 |
+
$this->settings['input_url'] = $value;
|
193 |
+
}
|
194 |
+
if ( $key === 'confirmation_url' || $key === 'confirm' ) {
|
195 |
+
$this->settings['confirmation_url'] = $value;
|
196 |
+
}
|
197 |
+
if ( $key === 'complete_url' || $key === 'complete' ) {
|
198 |
+
$this->settings['complete_url'] = $value;
|
199 |
+
}
|
200 |
+
if ( $key === 'validation_error_url' || $key === 'validation_error' ) {
|
201 |
+
$this->settings['validation_error_url'] = $value;
|
202 |
+
}
|
203 |
+
}
|
204 |
+
}
|
205 |
+
|
206 |
+
/**
|
207 |
+
* is_generated_by_formkey
|
208 |
+
* 管理画面で作成されたフォームであればtrue
|
209 |
+
* @return bool
|
210 |
+
*/
|
211 |
+
public function is_generated_by_formkey() {
|
212 |
+
if ( $this->post_id ) {
|
213 |
+
return true;
|
214 |
+
}
|
215 |
+
return false;
|
216 |
+
}
|
217 |
+
|
218 |
+
/**
|
219 |
+
* get_form_id
|
220 |
+
*/
|
221 |
+
public function get_form_id() {
|
222 |
+
if ( $this->post_id ) {
|
223 |
+
return $this->post_id;
|
224 |
+
}
|
225 |
+
}
|
226 |
+
}
|
classes/services/class.mail.php
ADDED
@@ -0,0 +1,477 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Name : MW WP Form Mail Service
|
4 |
+
* Version : 1.0.0
|
5 |
+
* Author : Takashi Kitajima
|
6 |
+
* Author URI : http://2inc.org
|
7 |
+
* Created : January 1, 2015
|
8 |
+
* Modified :
|
9 |
+
* License : GPLv2
|
10 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
+
*/
|
12 |
+
class MW_WP_Form_Mail_Service {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* $insert_contact_data_id
|
16 |
+
* 保存した問い合わせデータの Post ID
|
17 |
+
* @var int
|
18 |
+
*/
|
19 |
+
protected $insert_contact_data_id;
|
20 |
+
|
21 |
+
/**
|
22 |
+
* $Mail_raw
|
23 |
+
* @var MW_WP_Form_Mail
|
24 |
+
*/
|
25 |
+
protected $Mail_raw;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* $Mail_admin_raw
|
29 |
+
* @var MW_WP_Form_Mail
|
30 |
+
*/
|
31 |
+
protected $Mail_admin_raw;
|
32 |
+
|
33 |
+
/**
|
34 |
+
* $Mail_auto_raw
|
35 |
+
* @var MW_WP_Form_Mail
|
36 |
+
*/
|
37 |
+
protected $Mail_auto_raw;
|
38 |
+
|
39 |
+
/**
|
40 |
+
* $Mail_admin
|
41 |
+
* @var MW_WP_Form_Mail
|
42 |
+
*/
|
43 |
+
protected $Mail_admin;
|
44 |
+
|
45 |
+
/**
|
46 |
+
* $Mail_auto
|
47 |
+
* @var MW_WP_Form_Mail
|
48 |
+
*/
|
49 |
+
protected $Mail_auto;
|
50 |
+
|
51 |
+
/**
|
52 |
+
* $Data
|
53 |
+
* @var MW_WP_Form_Data
|
54 |
+
*/
|
55 |
+
protected $Data;
|
56 |
+
|
57 |
+
/**
|
58 |
+
* $form_key
|
59 |
+
* フォーム識別子
|
60 |
+
* @var string
|
61 |
+
*/
|
62 |
+
protected $form_key;
|
63 |
+
|
64 |
+
/**
|
65 |
+
* $validation_rules
|
66 |
+
* @var array
|
67 |
+
*/
|
68 |
+
protected $validation_rules = array();
|
69 |
+
|
70 |
+
/**
|
71 |
+
* $attachments
|
72 |
+
* @var array
|
73 |
+
*/
|
74 |
+
protected $attachments = array();
|
75 |
+
|
76 |
+
/**
|
77 |
+
* $Setting
|
78 |
+
* @var MW_WP_Form_Setting
|
79 |
+
*/
|
80 |
+
protected $Setting;
|
81 |
+
|
82 |
+
/**
|
83 |
+
* __construct
|
84 |
+
* @param MW_WP_Form_Mail $Mail
|
85 |
+
* @param MW_WP_Form_Data $Data
|
86 |
+
* @param strign $form_key
|
87 |
+
* @param array $validation_rules
|
88 |
+
* @param MW_WP_Form_Setting $Setting
|
89 |
+
* @param array $attachments
|
90 |
+
*/
|
91 |
+
public function __construct( MW_WP_Form_Mail $Mail, MW_WP_Form_Data $Data, $form_key, array $validation_rules, MW_WP_Form_Setting $Setting, array $attachments = array() ) {
|
92 |
+
$this->form_key = $form_key;
|
93 |
+
$this->Data = $Data;
|
94 |
+
$this->validation_rules = $validation_rules;
|
95 |
+
$this->Mail_raw = $Mail;
|
96 |
+
$this->Mail_admin_raw = clone $Mail;
|
97 |
+
$this->Mail_auto_raw = clone $Mail;
|
98 |
+
$this->attachments = $attachments;
|
99 |
+
$this->Setting = $Setting;
|
100 |
+
|
101 |
+
if ( $this->Setting->get( 'post_id' ) ) {
|
102 |
+
$this->set_admin_mail_raw_params();
|
103 |
+
$this->set_attachments( $this->Mail_admin_raw );
|
104 |
+
$this->Mail_admin_raw = $this->apply_filters_mwform_admin_mail_raw( $this->Mail_admin_raw );
|
105 |
+
$this->Mail_admin = $this->parse_mail_object( $this->Mail_admin_raw );
|
106 |
+
$this->Mail_admin = $this->set_admin_mail_reaquire_params( $this->Mail_admin );
|
107 |
+
$this->Mail_admin = $this->apply_filters_mwform_mail( $this->Mail_admin );
|
108 |
+
$this->Mail_admin = $this->apply_filters_mwform_admin_mail( $this->Mail_admin );
|
109 |
+
|
110 |
+
$this->set_reply_mail_raw_params();
|
111 |
+
$this->Mail_auto_raw = $this->apply_filters_mwform_auto_mail_raw( $this->Mail_auto_raw );
|
112 |
+
$this->Mail_auto = $this->parse_mail_object( $this->Mail_auto_raw );
|
113 |
+
$this->Mail_auto = $this->set_reply_mail_reaquire_params( $this->Mail_auto );
|
114 |
+
$this->Mail_auto = $this->apply_filters_mwform_auto_mail( $this->Mail_auto );
|
115 |
+
} else {
|
116 |
+
$Mail = $this->apply_filters_mwform_mail( $Mail );
|
117 |
+
}
|
118 |
+
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* get_Mail_raw
|
122 |
+
* @return MW_WP_Form_Mail
|
123 |
+
*/
|
124 |
+
public function get_Mail_raw() {
|
125 |
+
return $this->Mail_raw;
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* get_Mail_admin_raw
|
130 |
+
* @return MW_WP_Form_Mail
|
131 |
+
*/
|
132 |
+
public function get_Mail_admin_raw() {
|
133 |
+
return $this->Mail_admin_raw;
|
134 |
+
}
|
135 |
+
|
136 |
+
/**
|
137 |
+
* get_Mail_admin
|
138 |
+
* @return MW_WP_Form_Mail
|
139 |
+
*/
|
140 |
+
public function get_Mail_admin() {
|
141 |
+
return $this->Mail_admin;
|
142 |
+
}
|
143 |
+
|
144 |
+
/**
|
145 |
+
* get_Mail_auto_raw
|
146 |
+
* @return MW_WP_Form_Mail
|
147 |
+
*/
|
148 |
+
public function get_Mail_auto_raw() {
|
149 |
+
return $this->Mail_auto_raw;
|
150 |
+
}
|
151 |
+
|
152 |
+
/**
|
153 |
+
* get_Mail_auto
|
154 |
+
* @return MW_WP_Form_Mail
|
155 |
+
*/
|
156 |
+
public function get_Mail_auto() {
|
157 |
+
return $this->Mail_auto;
|
158 |
+
}
|
159 |
+
|
160 |
+
/**
|
161 |
+
* set_attachments
|
162 |
+
* @param MW_WP_Form_Mail $Mail
|
163 |
+
*/
|
164 |
+
protected function set_attachments( MW_WP_Form_Mail $Mail ) {
|
165 |
+
$Mail->attachments = $this->attachments;
|
166 |
+
}
|
167 |
+
|
168 |
+
/**
|
169 |
+
* set_admin_mail_raw_params
|
170 |
+
* 管理者メールに項目を設定
|
171 |
+
*/
|
172 |
+
protected function set_admin_mail_raw_params() {
|
173 |
+
// タイトルを指定
|
174 |
+
$admin_mail_subject = $this->Setting->get( 'mail_subject' );
|
175 |
+
if ( $this->Setting->get( 'admin_mail_subject' ) ) {
|
176 |
+
$admin_mail_subject = $this->Setting->get( 'admin_mail_subject' );
|
177 |
+
}
|
178 |
+
$this->Mail_admin_raw->subject = $admin_mail_subject;
|
179 |
+
|
180 |
+
// 本文を指定
|
181 |
+
$admin_mail_content = $this->Setting->get( 'mail_content' );
|
182 |
+
if ( $this->Setting->get( 'admin_mail_content' ) ) {
|
183 |
+
$admin_mail_content = $this->Setting->get( 'admin_mail_content' );
|
184 |
+
}
|
185 |
+
$this->Mail_admin_raw->body = $admin_mail_content;
|
186 |
+
|
187 |
+
// 送信先を指定
|
188 |
+
$admin_mail_to = get_bloginfo( 'admin_email' );
|
189 |
+
if ( $this->Setting->get( 'mail_to' ) ) {
|
190 |
+
$admin_mail_to = $this->Setting->get( 'mail_to' );
|
191 |
+
}
|
192 |
+
$this->Mail_admin_raw->to = $admin_mail_to;
|
193 |
+
|
194 |
+
// CCを指定
|
195 |
+
$admin_mail_cc = '';
|
196 |
+
if ( $this->Setting->get( 'mail_cc' ) ) {
|
197 |
+
$admin_mail_cc = $this->Setting->get( 'mail_cc' );
|
198 |
+
}
|
199 |
+
$this->Mail_admin_raw->cc = $admin_mail_cc;
|
200 |
+
|
201 |
+
// BCCを指定
|
202 |
+
$admin_mail_bcc = '';
|
203 |
+
if ( $this->Setting->get( 'mail_bcc' ) ) {
|
204 |
+
$admin_mail_bcc = $this->Setting->get( 'mail_bcc' );
|
205 |
+
}
|
206 |
+
$this->Mail_admin_raw->bcc = $admin_mail_bcc;
|
207 |
+
|
208 |
+
// 送信元を指定
|
209 |
+
$admin_mail_from = get_bloginfo( 'admin_email' );
|
210 |
+
if ( $this->Setting->get( 'admin_mail_from' ) ) {
|
211 |
+
$admin_mail_from = $this->Setting->get( 'admin_mail_from' );
|
212 |
+
}
|
213 |
+
$this->Mail_admin_raw->from = $admin_mail_from;
|
214 |
+
|
215 |
+
// 送信者を指定
|
216 |
+
$admin_mail_sender = get_bloginfo( 'name' );
|
217 |
+
if ( $this->Setting->get( 'admin_mail_sender' ) ) {
|
218 |
+
$admin_mail_sender = $this->Setting->get( 'admin_mail_sender' );
|
219 |
+
}
|
220 |
+
$this->Mail_admin_raw->sender = $admin_mail_sender;
|
221 |
+
}
|
222 |
+
|
223 |
+
/**
|
224 |
+
* set_reply_mail_raw_params
|
225 |
+
* 自動返信メールに項目を設定
|
226 |
+
*/
|
227 |
+
private function set_reply_mail_raw_params() {
|
228 |
+
$this->Mail_auto_raw->to = '';
|
229 |
+
$this->Mail_auto_raw->cc = '';
|
230 |
+
$this->Mail_auto_raw->bcc = '';
|
231 |
+
// 自動返信メールからは添付ファイルを削除
|
232 |
+
$this->Mail_auto_raw->attachments = array();
|
233 |
+
$form_id = $this->Setting->get( 'post_id' );
|
234 |
+
if ( $form_id ) {
|
235 |
+
$automatic_reply_email = $this->Setting->get( 'automatic_reply_email' );
|
236 |
+
$automatic_reply_email = $this->Data->get_raw( $automatic_reply_email );
|
237 |
+
$is_invalid_mail_address = $this->validation_rules['mail']->rule(
|
238 |
+
$automatic_reply_email
|
239 |
+
);
|
240 |
+
|
241 |
+
// 送信先を指定
|
242 |
+
if ( $automatic_reply_email && !$is_invalid_mail_address ) {
|
243 |
+
$this->Mail_auto_raw->to = $automatic_reply_email;
|
244 |
+
}
|
245 |
+
|
246 |
+
// 送信元を指定
|
247 |
+
$reply_mail_from = get_bloginfo( 'admin_email' );
|
248 |
+
if ( $this->Setting->get( 'mail_from' ) ) {
|
249 |
+
$reply_mail_from = $this->Setting->get( 'mail_from' );
|
250 |
+
}
|
251 |
+
$this->Mail_auto_raw->from = $reply_mail_from;
|
252 |
+
|
253 |
+
// 送信者を指定
|
254 |
+
$reply_mail_sender = get_bloginfo( 'name' );
|
255 |
+
if ( $this->Setting->get( 'mail_sender' ) ) {
|
256 |
+
$reply_mail_sender = $this->Setting->get( 'mail_sender' );
|
257 |
+
}
|
258 |
+
$this->Mail_auto_raw->sender = $reply_mail_sender;
|
259 |
+
|
260 |
+
// タイトルを指定
|
261 |
+
$this->Mail_auto_raw->subject = $this->Setting->get( 'mail_subject' );
|
262 |
+
|
263 |
+
// 本文を指定
|
264 |
+
$this->Mail_auto_raw->body = $this->Setting->get( 'mail_content' );
|
265 |
+
}
|
266 |
+
}
|
267 |
+
|
268 |
+
/**
|
269 |
+
* set_admin_mail_reaquire_params
|
270 |
+
* 管理者メールに必須の項目を設定
|
271 |
+
* @param MW_WP_Form_Mail $Mail
|
272 |
+
* @return MW_WP_Form_Mail $Mail
|
273 |
+
*/
|
274 |
+
private function set_admin_mail_reaquire_params( MW_WP_Form_Mail $Mail ) {
|
275 |
+
$admin_mail_to = get_bloginfo( 'admin_email' );
|
276 |
+
$admin_mail_from = get_bloginfo( 'admin_email' );
|
277 |
+
$admin_mail_sender = get_bloginfo( 'name' );
|
278 |
+
|
279 |
+
if ( !$Mail->to ) {
|
280 |
+
$Mail->to = $admin_mail_to;
|
281 |
+
}
|
282 |
+
if ( !$Mail->from ) {
|
283 |
+
$Mail->from = $admin_mail_from;;
|
284 |
+
}
|
285 |
+
if ( !$Mail->sender ) {
|
286 |
+
$Mail->sender = $admin_mail_sender;;
|
287 |
+
}
|
288 |
+
return $Mail;
|
289 |
+
}
|
290 |
+
|
291 |
+
/**
|
292 |
+
* set_reply_mail_reaquire_params
|
293 |
+
* 自動返信メールに必須の項目を設定
|
294 |
+
* @param MW_WP_Form_Mail $Mail
|
295 |
+
* @return MW_WP_Form_Mail $Mail
|
296 |
+
*/
|
297 |
+
private function set_reply_mail_reaquire_params( MW_WP_Form_Mail $Mail ) {
|
298 |
+
$reply_mail_from = get_bloginfo( 'admin_email' );
|
299 |
+
$reply_mail_sender = get_bloginfo( 'name' );
|
300 |
+
|
301 |
+
if ( !$Mail->from ) {
|
302 |
+
$Mail->from = $reply_mail_from;;
|
303 |
+
}
|
304 |
+
if ( !$Mail->sender ) {
|
305 |
+
$Mail->sender = $reply_mail_sender;;
|
306 |
+
}
|
307 |
+
return $Mail;
|
308 |
+
}
|
309 |
+
|
310 |
+
/**
|
311 |
+
* apply_filters_mwform_admin_mail_raw
|
312 |
+
* @param MW_WP_Form_Mail $Mail
|
313 |
+
* @return MW_WP_Form_Mail $Mail
|
314 |
+
*/
|
315 |
+
protected function apply_filters_mwform_admin_mail_raw( MW_WP_Form_Mail $Mail ) {
|
316 |
+
return apply_filters(
|
317 |
+
'mwform_admin_mail_raw_' . $this->form_key,
|
318 |
+
$Mail,
|
319 |
+
$this->Data->gets()
|
320 |
+
);
|
321 |
+
}
|
322 |
+
|
323 |
+
/**
|
324 |
+
* apply_filters_mwform_mail
|
325 |
+
* @param MW_WP_Form_Mail $Mail
|
326 |
+
* @return MW_WP_Form_Mail $Mail
|
327 |
+
*/
|
328 |
+
protected function apply_filters_mwform_mail( MW_WP_Form_Mail $Mail ) {
|
329 |
+
return apply_filters(
|
330 |
+
'mwform_mail_' . $this->form_key,
|
331 |
+
$Mail,
|
332 |
+
$this->Data->gets()
|
333 |
+
);
|
334 |
+
}
|
335 |
+
|
336 |
+
/**
|
337 |
+
* apply_filters_mwform_admin_mail
|
338 |
+
* @param MW_WP_Form_Mail $Mail
|
339 |
+
* @return MW_WP_Form_Mail $Mail
|
340 |
+
*/
|
341 |
+
protected function apply_filters_mwform_admin_mail( MW_WP_Form_Mail $Mail ) {
|
342 |
+
return apply_filters(
|
343 |
+
'mwform_admin_mail_' . $this->form_key,
|
344 |
+
$Mail,
|
345 |
+
$this->Data->gets()
|
346 |
+
);
|
347 |
+
}
|
348 |
+
|
349 |
+
/**
|
350 |
+
* apply_filters_mwform_auto_mail_raw
|
351 |
+
* @param MW_WP_Form_Mail $Mail
|
352 |
+
* @return MW_WP_Form_Mail $Mail
|
353 |
+
*/
|
354 |
+
protected function apply_filters_mwform_auto_mail_raw( MW_WP_Form_Mail $Mail ) {
|
355 |
+
return apply_filters(
|
356 |
+
'mwform_auto_mail_raw_' . $this->form_key,
|
357 |
+
$Mail,
|
358 |
+
$this->Data->gets()
|
359 |
+
);
|
360 |
+
}
|
361 |
+
|
362 |
+
/**
|
363 |
+
* apply_filters_mwform_auto_mail
|
364 |
+
* @param MW_WP_Form_Mail $Mail
|
365 |
+
* @return MW_WP_Form_Mail $Mail
|
366 |
+
*/
|
367 |
+
protected function apply_filters_mwform_auto_mail( MW_WP_Form_Mail $Mail ) {
|
368 |
+
return apply_filters(
|
369 |
+
'mwform_auto_mail_' . $this->form_key,
|
370 |
+
$Mail,
|
371 |
+
$this->Data->gets()
|
372 |
+
);
|
373 |
+
}
|
374 |
+
|
375 |
+
/**
|
376 |
+
* parse_mail_object
|
377 |
+
* @param MW_WP_Form_Mail $_Mail
|
378 |
+
* @return MW_WP_Form_Mail $Mail
|
379 |
+
*/
|
380 |
+
protected function parse_mail_object( MW_WP_Form_Mail $_Mail ) {
|
381 |
+
$Mail = clone $_Mail;
|
382 |
+
$parsed_Mail_vars = get_object_vars( $Mail );
|
383 |
+
foreach ( $parsed_Mail_vars as $key => $value ) {
|
384 |
+
if ( is_array( $value ) || $key == 'to' || $key == 'cc' || $key == 'bcc' ) {
|
385 |
+
continue;
|
386 |
+
}
|
387 |
+
$value = $this->parse_mail_content( $value );
|
388 |
+
$Mail->$key = $value;
|
389 |
+
}
|
390 |
+
return $Mail;
|
391 |
+
}
|
392 |
+
|
393 |
+
/**
|
394 |
+
* parse_mail_content
|
395 |
+
* メール本文用に {name属性} を置換
|
396 |
+
* @param string $value
|
397 |
+
* @return string
|
398 |
+
*/
|
399 |
+
protected function parse_mail_content( $value ) {
|
400 |
+
return preg_replace_callback(
|
401 |
+
'/{(.+?)}/',
|
402 |
+
array( $this, '_parse_mail_content' ),
|
403 |
+
$value
|
404 |
+
);
|
405 |
+
}
|
406 |
+
protected function _parse_mail_content( $matches ) {
|
407 |
+
return $this->parse_mail_body( $matches, false );
|
408 |
+
}
|
409 |
+
|
410 |
+
/**
|
411 |
+
* save_mail_body
|
412 |
+
* DB保存用に {name属性} を置換、保存
|
413 |
+
*/
|
414 |
+
protected function save_mail_body( $value ) {
|
415 |
+
return preg_replace_callback(
|
416 |
+
'/{(.+?)}/',
|
417 |
+
array( $this, '_save_mail_body' ),
|
418 |
+
$value
|
419 |
+
);
|
420 |
+
}
|
421 |
+
protected function _save_mail_body( $matches ) {
|
422 |
+
return $this->parse_mail_body( $matches, true );
|
423 |
+
}
|
424 |
+
|
425 |
+
/**
|
426 |
+
* save_contact_data
|
427 |
+
* @param int $form_id
|
428 |
+
* @param MW_WP_Form_Mail $Mail
|
429 |
+
* @param array $files 保存するファイルパスの配列
|
430 |
+
*/
|
431 |
+
public function save_contact_data( MW_WP_Form_Mail $Mail, array $files = array() ) {
|
432 |
+
$form_id = $this->Setting->get( 'post_id' );
|
433 |
+
$insert_contact_data_id = wp_insert_post( array(
|
434 |
+
'post_title' => $Mail->subject,
|
435 |
+
'post_status' => 'publish',
|
436 |
+
'post_type' => MWF_Config::DBDATA . $form_id,
|
437 |
+
) );
|
438 |
+
$this->insert_contact_data_id = $insert_contact_data_id;
|
439 |
+
|
440 |
+
// メタデータを保存
|
441 |
+
$this->save_mail_body( $Mail->body );
|
442 |
+
|
443 |
+
// 添付ファイルをメディアに保存
|
444 |
+
if ( !empty( $insert_contact_data_id ) ) {
|
445 |
+
MWF_Functions::save_attachments_in_media(
|
446 |
+
$insert_contact_data_id,
|
447 |
+
$files,
|
448 |
+
$form_id
|
449 |
+
);
|
450 |
+
}
|
451 |
+
}
|
452 |
+
|
453 |
+
/**
|
454 |
+
* parse_mail_body
|
455 |
+
* $this->create_mail_body(), $this->save_mail_body の本体
|
456 |
+
* 第2引数でDB保存するか判定
|
457 |
+
* @param array $matches
|
458 |
+
* @param bool $doUpdate
|
459 |
+
* @return string $value
|
460 |
+
*/
|
461 |
+
protected function parse_mail_body( $matches, $doUpdate = false ) {
|
462 |
+
$match = $matches[1];
|
463 |
+
// MWF_Config::TRACKINGNUMBER のときはお問い合せ番号を参照する
|
464 |
+
if ( $match === MWF_Config::TRACKINGNUMBER ) {
|
465 |
+
$form_id = $this->Setting->get( 'post_id' );
|
466 |
+
if ( $form_id ) {
|
467 |
+
$value = $this->Setting->get_tracking_number( $form_id );
|
468 |
+
}
|
469 |
+
} else {
|
470 |
+
$value = $this->Data->get( $match );
|
471 |
+
}
|
472 |
+
if ( $value !== null && $doUpdate ) {
|
473 |
+
update_post_meta( $this->insert_contact_data_id, $match, $value );
|
474 |
+
}
|
475 |
+
return $value;
|
476 |
+
}
|
477 |
+
}
|
classes/services/class.redirected.php
ADDED
@@ -0,0 +1,209 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Name : MW WP Form Redirected
|
4 |
+
* Version : 1.0.0
|
5 |
+
* Author : Takashi Kitajima
|
6 |
+
* Author URI : http://2inc.org
|
7 |
+
* Created : December 31, 2014
|
8 |
+
* Modified :
|
9 |
+
* License : GPLv2
|
10 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
+
*/
|
12 |
+
class MW_WP_Form_Redirected {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* $mode_check
|
16 |
+
* 現在のモード
|
17 |
+
* @var string input|confirm|complete|back
|
18 |
+
*/
|
19 |
+
protected $mode_check = 'input';
|
20 |
+
|
21 |
+
/**
|
22 |
+
* $view_flg
|
23 |
+
* @var string input|confirm|complete
|
24 |
+
*/
|
25 |
+
protected $view_flg = 'input';
|
26 |
+
|
27 |
+
/**
|
28 |
+
* $url
|
29 |
+
* @var string
|
30 |
+
*/
|
31 |
+
protected $url;
|
32 |
+
|
33 |
+
/**
|
34 |
+
* $querystring
|
35 |
+
* @var bool
|
36 |
+
*/
|
37 |
+
protected $querystring;
|
38 |
+
|
39 |
+
/**
|
40 |
+
* __construct
|
41 |
+
* @param string $input
|
42 |
+
* @param string $confirm
|
43 |
+
* @param string $complete
|
44 |
+
* @param string $valdation_error
|
45 |
+
* @param bool $is_valid
|
46 |
+
* @param bool $post_condition
|
47 |
+
* @param bool $querystring
|
48 |
+
*/
|
49 |
+
public function __construct( $input, $confirm, $complete, $valdation_error, $is_valid, $post_condition, $querystring ) {
|
50 |
+
$this->querystring = $querystring; // parse_url
|
51 |
+
|
52 |
+
$this->initialize( $input, $confirm, $complete, $valdation_error, $is_valid, $post_condition );
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* __construct
|
57 |
+
* @param string $input
|
58 |
+
* @param string $confirm
|
59 |
+
* @param string $complete
|
60 |
+
* @param string $valdation_error
|
61 |
+
* @param bool $is_valid
|
62 |
+
* @param bool $post_condition
|
63 |
+
*/
|
64 |
+
protected function initialize( $input, $confirm, $complete, $valdation_error, $is_valid, $post_condition ) {
|
65 |
+
$input = $this->parse_url( $input );
|
66 |
+
$confirm = $this->parse_url( $confirm );
|
67 |
+
$complete = $this->parse_url( $complete );
|
68 |
+
$validation_error = $this->parse_url( $valdation_error );
|
69 |
+
$REQUEST_URI = $this->parse_url( $this->get_request_uri() );
|
70 |
+
|
71 |
+
// 入力画面(戻る)のとき
|
72 |
+
if ( $post_condition === 'back' ) {
|
73 |
+
$this->url = $input;
|
74 |
+
return;
|
75 |
+
}
|
76 |
+
// 確認画面のとき
|
77 |
+
elseif ( $post_condition === 'confirm' ) {
|
78 |
+
if ( $is_valid ) {
|
79 |
+
$this->view_flg = 'confirm';
|
80 |
+
$this->url = $confirm;
|
81 |
+
return;
|
82 |
+
} else {
|
83 |
+
if ( $validation_error ) {
|
84 |
+
$this->url = $validation_error;
|
85 |
+
return;
|
86 |
+
} else {
|
87 |
+
$this->url = $input;
|
88 |
+
return;
|
89 |
+
}
|
90 |
+
}
|
91 |
+
}
|
92 |
+
// 完了画面のとき
|
93 |
+
elseif ( $post_condition === 'complete' ) {
|
94 |
+
if ( $is_valid ) {
|
95 |
+
$this->view_flg = 'complete';
|
96 |
+
$this->url = $complete;
|
97 |
+
return;
|
98 |
+
} else {
|
99 |
+
if ( $validation_error ) {
|
100 |
+
$this->url = $validation_error;
|
101 |
+
return;
|
102 |
+
} else {
|
103 |
+
$this->url = $input;
|
104 |
+
return;
|
105 |
+
}
|
106 |
+
}
|
107 |
+
}
|
108 |
+
// 完了 or 確認画面 or エラーURLが設定済みで
|
109 |
+
// 完了 or 確認画面 or エラーに直接アクセスした場合、
|
110 |
+
// 入力画面に戻れれば戻る。戻れない場合はトップに戻す
|
111 |
+
else {
|
112 |
+
$check_urls = array(
|
113 |
+
$confirm, $complete,
|
114 |
+
);
|
115 |
+
$back_url = ( $input ) ? $input : home_url();
|
116 |
+
foreach ( $check_urls as $check_url ) {
|
117 |
+
if ( $REQUEST_URI === $check_url ) {
|
118 |
+
$this->url = $back_url;
|
119 |
+
return;
|
120 |
+
}
|
121 |
+
}
|
122 |
+
$this->url = $input;
|
123 |
+
return;
|
124 |
+
|
125 |
+
if ( $is_valid && $REQUEST_URI == $validation_error ) {
|
126 |
+
$this->url = $back_url;
|
127 |
+
return;
|
128 |
+
}
|
129 |
+
}
|
130 |
+
}
|
131 |
+
|
132 |
+
/**
|
133 |
+
* get_url
|
134 |
+
* リダイレクト先の URL を返す
|
135 |
+
*/
|
136 |
+
public function get_url() {
|
137 |
+
return $this->url;
|
138 |
+
}
|
139 |
+
|
140 |
+
/**
|
141 |
+
* get_view_flg
|
142 |
+
* 表示すべき画面を示すフラグを返す
|
143 |
+
* @return string $this->view_flg
|
144 |
+
*/
|
145 |
+
public function get_view_flg() {
|
146 |
+
return $this->view_flg;
|
147 |
+
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
* get_request_uri
|
151 |
+
* $_SERVER['REQUEST_URI'] を http:// からはじまるURLに変換する
|
152 |
+
* @return string URL
|
153 |
+
*/
|
154 |
+
public function get_request_uri() {
|
155 |
+
$_REQUEST_URI = $_SERVER['REQUEST_URI'];
|
156 |
+
if ( !preg_match( '/^https?:\/\//', $_REQUEST_URI ) ) {
|
157 |
+
$REQUEST_URI = home_url() . $_REQUEST_URI;
|
158 |
+
$parse_url = parse_url( home_url() );
|
159 |
+
// サブディレクトリ型の場合
|
160 |
+
if ( !empty( $parse_url['path'] ) ) {
|
161 |
+
$pettern = preg_quote( $parse_url['path'], '/' );
|
162 |
+
if ( preg_match( '/^' . $pettern . '/', $_REQUEST_URI ) ) {
|
163 |
+
$REQUEST_URI = preg_replace( '/' . $pettern . '$/', $_REQUEST_URI, home_url() );
|
164 |
+
}
|
165 |
+
}
|
166 |
+
} else {
|
167 |
+
$REQUEST_URI = $_REQUEST_URI;
|
168 |
+
}
|
169 |
+
return $REQUEST_URI;
|
170 |
+
}
|
171 |
+
|
172 |
+
/**
|
173 |
+
* parse_url
|
174 |
+
* http:// からはじまるURLに変換する
|
175 |
+
* @param string URL
|
176 |
+
* @return string URL
|
177 |
+
*/
|
178 |
+
protected function parse_url( $url ) {
|
179 |
+
if ( empty( $url ) ) {
|
180 |
+
return '';
|
181 |
+
}
|
182 |
+
|
183 |
+
$query_string = array();
|
184 |
+
preg_match( '/\?(.*)$/', $url, $reg );
|
185 |
+
if ( !empty( $reg[1] ) ) {
|
186 |
+
$url = str_replace( '?' . $reg[1], '', $url );
|
187 |
+
parse_str( $reg[1], $query_string );
|
188 |
+
}
|
189 |
+
if ( !preg_match( '/^https?:\/\//', $url ) ) {
|
190 |
+
$home_url = home_url();
|
191 |
+
$url = $home_url . $url;
|
192 |
+
}
|
193 |
+
$url = preg_replace( '/([^:])\/+/', '$1/', $url );
|
194 |
+
|
195 |
+
// URL設定でURL引数が使用されている場合はそれを使う。
|
196 |
+
// 「URL引数を有効にする」が有効の場合は $_GET を利用する(重複するURL引数はURL設定のものが優先される ※post_id除く)
|
197 |
+
if ( $this->querystring ) {
|
198 |
+
$query_string = array_merge( $_GET, $query_string );
|
199 |
+
if ( isset( $_GET['post_id'] ) && MWF_Functions::is_numeric( $_GET['post_id'] ) ) {
|
200 |
+
$query_string['post_id'] = $_GET['post_id'];
|
201 |
+
}
|
202 |
+
}
|
203 |
+
|
204 |
+
if ( !empty( $query_string ) ) {
|
205 |
+
$url = $url . '?' . http_build_query( $query_string, null, '&' );
|
206 |
+
}
|
207 |
+
return $url;
|
208 |
+
}
|
209 |
+
}
|
validation_rules/mw_validation_rule_akismet.php → classes/validation-rules/class.akismet.php
RENAMED
@@ -1,19 +1,21 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Name: MW Validation Rule Akismet
|
4 |
-
* Description: Akismetのエラー。常にtrue
|
5 |
-
* Version: 1.0
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created
|
9 |
-
* Modified:
|
10 |
-
* License: GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
-
class
|
14 |
|
15 |
/**
|
|
|
16 |
* バリデーションルール名を指定
|
|
|
17 |
*/
|
18 |
protected $name = 'akismet_check';
|
19 |
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Name : MW WP Form Validation Rule Akismet
|
4 |
+
* Description: Akismetのエラー。常にtrue
|
5 |
+
* Version : 1.1.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : July 21, 2014
|
9 |
+
* Modified : December 31, 2014
|
10 |
+
* License : GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
+
class MW_WP_Form_Validation_Rule_Akismet extends MW_WP_Form_Abstract_Validation_Rule {
|
14 |
|
15 |
/**
|
16 |
+
* $name
|
17 |
* バリデーションルール名を指定
|
18 |
+
* @var string
|
19 |
*/
|
20 |
protected $name = 'akismet_check';
|
21 |
|
validation_rules/mw_validation_rule_alpha.php → classes/validation-rules/class.alpha.php
RENAMED
@@ -1,19 +1,21 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Name: MW Validation Rule Alpha
|
4 |
* Description: 値がアルファベット
|
5 |
-
* Version: 1.0
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created
|
9 |
-
* Modified:
|
10 |
-
* License: GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
-
class
|
14 |
|
15 |
/**
|
|
|
16 |
* バリデーションルール名を指定
|
|
|
17 |
*/
|
18 |
protected $name = 'alpha';
|
19 |
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Name : MW WP Form Validation Rule Alpha
|
4 |
* Description: 値がアルファベット
|
5 |
+
* Version : 1.1.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : July 21, 2014
|
9 |
+
* Modified : December 31, 2014
|
10 |
+
* License : GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
+
class MW_WP_Form_Validation_Rule_Alpha extends MW_WP_Form_Abstract_Validation_Rule {
|
14 |
|
15 |
/**
|
16 |
+
* $name
|
17 |
* バリデーションルール名を指定
|
18 |
+
* @var string
|
19 |
*/
|
20 |
protected $name = 'alpha';
|
21 |
|
validation_rules/mw_validation_rule_alphanumeric.php → classes/validation-rules/class.alphanumeric.php
RENAMED
@@ -1,19 +1,21 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Name: MW Validation Rule AlphaNumeric
|
4 |
-
* Description:
|
5 |
-
* Version: 1.0
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created
|
9 |
-
* Modified:
|
10 |
-
* License: GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
-
class
|
14 |
|
15 |
/**
|
|
|
16 |
* バリデーションルール名を指定
|
|
|
17 |
*/
|
18 |
protected $name = 'alphanumeric';
|
19 |
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Name : MW WP Form Validation Rule AlphaNumeric
|
4 |
+
* Description: 値が英数字
|
5 |
+
* Version : 1.1.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : July 21, 2014
|
9 |
+
* Modified : December 31, 2014
|
10 |
+
* License : GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
+
class MW_WP_Form_Validation_Rule_AlphaNumeric extends MW_WP_Form_Abstract_Validation_Rule {
|
14 |
|
15 |
/**
|
16 |
+
* $name
|
17 |
* バリデーションルール名を指定
|
18 |
+
* @var string
|
19 |
*/
|
20 |
protected $name = 'alphanumeric';
|
21 |
|
validation_rules/mw_validation_rule_between.php → classes/validation-rules/class.between.php
RENAMED
@@ -1,19 +1,21 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Name: MW Validation Rule Between
|
4 |
* Description: 値の文字数が範囲内
|
5 |
-
* Version: 1.0
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created
|
9 |
-
* Modified: December
|
10 |
-
* License: GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
-
class
|
14 |
|
15 |
/**
|
|
|
16 |
* バリデーションルール名を指定
|
|
|
17 |
*/
|
18 |
protected $name = 'between';
|
19 |
|
@@ -28,8 +30,8 @@ class MW_Validation_Rule_Between extends MW_Validation_Rule {
|
|
28 |
$value = MWF_Functions::convert_eol( $value );
|
29 |
if ( !is_null( $value ) && !MWF_Functions::is_empty( $value ) ) {
|
30 |
$defaults = array(
|
31 |
-
'min'
|
32 |
-
'max'
|
33 |
'message' => __( 'The number of characters is invalid.', MWF_Config::DOMAIN )
|
34 |
);
|
35 |
$options = array_merge( $defaults, $options );
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Name : MW WP Form Validation Rule Between
|
4 |
* Description: 値の文字数が範囲内
|
5 |
+
* Version : 1.1.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : July 21, 2014
|
9 |
+
* Modified : December 31, 2014
|
10 |
+
* License : GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
+
class MW_WP_Form_Validation_Rule_Between extends MW_WP_Form_Abstract_Validation_Rule {
|
14 |
|
15 |
/**
|
16 |
+
* $name
|
17 |
* バリデーションルール名を指定
|
18 |
+
* @var string
|
19 |
*/
|
20 |
protected $name = 'between';
|
21 |
|
30 |
$value = MWF_Functions::convert_eol( $value );
|
31 |
if ( !is_null( $value ) && !MWF_Functions::is_empty( $value ) ) {
|
32 |
$defaults = array(
|
33 |
+
'min' => 0,
|
34 |
+
'max' => 0,
|
35 |
'message' => __( 'The number of characters is invalid.', MWF_Config::DOMAIN )
|
36 |
);
|
37 |
$options = array_merge( $defaults, $options );
|
validation_rules/mw_validation_rule_date.php → classes/validation-rules/class.date.php
RENAMED
@@ -1,19 +1,21 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Name: MW Validation Rule Date
|
4 |
* Description: 日付が正しいかどうか
|
5 |
-
* Version: 1.0
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created
|
9 |
-
* Modified:
|
10 |
-
* License: GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
-
class
|
14 |
|
15 |
/**
|
|
|
16 |
* バリデーションルール名を指定
|
|
|
17 |
*/
|
18 |
protected $name = 'date';
|
19 |
|
@@ -31,9 +33,15 @@ class MW_Validation_Rule_Date extends MW_Validation_Rule {
|
|
31 |
);
|
32 |
$options = array_merge( $defaults, $options );
|
33 |
$timestamp = strtotime( $value );
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
$month = date( 'm', $timestamp );
|
36 |
-
$day
|
37 |
$checkdate = checkdate( $month, $day, $year );
|
38 |
if ( !$timestamp || !$checkdate || preg_match( '/^[a-zA-Z]$/', $value ) || preg_match( '/^\s+$/', $value ) ) {
|
39 |
return $options['message'];
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Name : MW WP Form Validation Rule Date
|
4 |
* Description: 日付が正しいかどうか
|
5 |
+
* Version : 1.1.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : July 21, 2014
|
9 |
+
* Modified : December 31, 2014
|
10 |
+
* License : GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
+
class MW_WP_Form_Validation_Rule_Date extends MW_WP_Form_Abstract_Validation_Rule {
|
14 |
|
15 |
/**
|
16 |
+
* $name
|
17 |
* バリデーションルール名を指定
|
18 |
+
* @var string
|
19 |
*/
|
20 |
protected $name = 'date';
|
21 |
|
33 |
);
|
34 |
$options = array_merge( $defaults, $options );
|
35 |
$timestamp = strtotime( $value );
|
36 |
+
if ( !$timestamp ) {
|
37 |
+
if ( preg_match( '/^(\d+)年(\d{1,2})月(\d{1,2})日$/', $value ) ) {
|
38 |
+
$value = sprintf( '%d-%d-%d', $value[1], $value[2], $value[3] );
|
39 |
+
$timestamp = strtotime( $value );
|
40 |
+
}
|
41 |
+
}
|
42 |
+
$year = date( 'Y', $timestamp );
|
43 |
$month = date( 'm', $timestamp );
|
44 |
+
$day = date( 'd', $timestamp );
|
45 |
$checkdate = checkdate( $month, $day, $year );
|
46 |
if ( !$timestamp || !$checkdate || preg_match( '/^[a-zA-Z]$/', $value ) || preg_match( '/^\s+$/', $value ) ) {
|
47 |
return $options['message'];
|
validation_rules/mw_validation_rule_eq.php → classes/validation-rules/class.eq.php
RENAMED
@@ -1,19 +1,21 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Name: MW Validation Rule Eq
|
4 |
* Description: 値が一致している
|
5 |
-
* Version: 1.0
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created
|
9 |
-
* Modified:
|
10 |
-
* License: GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
-
class
|
14 |
|
15 |
/**
|
|
|
16 |
* バリデーションルール名を指定
|
|
|
17 |
*/
|
18 |
protected $name = 'eq';
|
19 |
|
@@ -27,7 +29,7 @@ class MW_Validation_Rule_Eq extends MW_Validation_Rule {
|
|
27 |
$value = $this->Data->get( $key );
|
28 |
if ( !is_null( $value ) ) {
|
29 |
$defaults = array(
|
30 |
-
'target'
|
31 |
'message' => __( 'This is not in agreement.', MWF_Config::DOMAIN )
|
32 |
);
|
33 |
$options = array_merge( $defaults, $options );
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Name : MW WP Form Validation Rule Eq
|
4 |
* Description: 値が一致している
|
5 |
+
* Version : 1.1.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : July 21, 2014
|
9 |
+
* Modified : December 31, 2014
|
10 |
+
* License : GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
+
class MW_WP_Form_Validation_Rule_Eq extends MW_WP_Form_Abstract_Validation_Rule {
|
14 |
|
15 |
/**
|
16 |
+
* $name
|
17 |
* バリデーションルール名を指定
|
18 |
+
* @var string
|
19 |
*/
|
20 |
protected $name = 'eq';
|
21 |
|
29 |
$value = $this->Data->get( $key );
|
30 |
if ( !is_null( $value ) ) {
|
31 |
$defaults = array(
|
32 |
+
'target' => null,
|
33 |
'message' => __( 'This is not in agreement.', MWF_Config::DOMAIN )
|
34 |
);
|
35 |
$options = array_merge( $defaults, $options );
|
validation_rules/mw_validation_rule_filesize.php → classes/validation-rules/class.filesize.php
RENAMED
@@ -1,19 +1,21 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Name: MW Validation Rule
|
4 |
-
* Description:
|
5 |
-
* Version: 1.0
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created
|
9 |
-
* Modified:
|
10 |
-
* License: GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
-
class
|
14 |
|
15 |
/**
|
|
|
16 |
* バリデーションルール名を指定
|
|
|
17 |
*/
|
18 |
protected $name = 'filesize';
|
19 |
|
@@ -24,16 +26,16 @@ class MW_Validation_Rule_FileSize extends MW_Validation_Rule {
|
|
24 |
* @return string エラーメッセージ
|
25 |
*/
|
26 |
public function rule( $key, array $options = array() ) {
|
27 |
-
$data = $this->Data->
|
28 |
if ( !is_null( $data ) && is_array( $data ) && array_key_exists( $key, $data ) ) {
|
29 |
$file = $data[$key];
|
30 |
if ( !empty( $file['size'] ) ) {
|
31 |
$defaults = array(
|
32 |
-
'bytes'
|
33 |
'message' => __( 'This file size is too big.', MWF_Config::DOMAIN )
|
34 |
);
|
35 |
$options = array_merge( $defaults, $options );
|
36 |
-
if ( !( preg_match( '/^[\d]+$/', $options['bytes'] ) && $options['bytes']
|
37 |
return $options['message'];
|
38 |
}
|
39 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Name : MW WP Form Validation Rule FileSize
|
4 |
+
* Description: ファイルサイズが指定したサイズ以内
|
5 |
+
* Version : 1.1.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : July 21, 2014
|
9 |
+
* Modified : December 31, 2014
|
10 |
+
* License : GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
+
class MW_WP_Form_Validation_Rule_FileSize extends MW_WP_Form_Abstract_Validation_Rule {
|
14 |
|
15 |
/**
|
16 |
+
* $name
|
17 |
* バリデーションルール名を指定
|
18 |
+
* @var string
|
19 |
*/
|
20 |
protected $name = 'filesize';
|
21 |
|
26 |
* @return string エラーメッセージ
|
27 |
*/
|
28 |
public function rule( $key, array $options = array() ) {
|
29 |
+
$data = $this->Data->get_raw( MWF_Config::UPLOAD_FILES );
|
30 |
if ( !is_null( $data ) && is_array( $data ) && array_key_exists( $key, $data ) ) {
|
31 |
$file = $data[$key];
|
32 |
if ( !empty( $file['size'] ) ) {
|
33 |
$defaults = array(
|
34 |
+
'bytes' => '0',
|
35 |
'message' => __( 'This file size is too big.', MWF_Config::DOMAIN )
|
36 |
);
|
37 |
$options = array_merge( $defaults, $options );
|
38 |
+
if ( !( preg_match( '/^[\d]+$/', $options['bytes'] ) && $options['bytes'] >= $file['size'] ) ) {
|
39 |
return $options['message'];
|
40 |
}
|
41 |
}
|
validation_rules/mw_validation_rule_filetype.php → classes/validation-rules/class.filetype.php
RENAMED
@@ -1,19 +1,21 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Name: MW Validation Rule FileType
|
4 |
* Description: ファイル名が指定した拡張子を含む。types は , 区切り
|
5 |
-
* Version: 1.0
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created
|
9 |
-
* Modified: December
|
10 |
-
* License: GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
-
class
|
14 |
|
15 |
/**
|
|
|
16 |
* バリデーションルール名を指定
|
|
|
17 |
*/
|
18 |
protected $name = 'filetype';
|
19 |
|
@@ -27,7 +29,7 @@ class MW_Validation_Rule_FileType extends MW_Validation_Rule {
|
|
27 |
$value = $this->Data->get( $key );
|
28 |
if ( !is_null( $value ) && !MWF_Functions::is_empty( $value ) ) {
|
29 |
$defaults = array(
|
30 |
-
'types'
|
31 |
'message' => __( 'This file is invalid.', MWF_Config::DOMAIN )
|
32 |
);
|
33 |
$options = array_merge( $defaults, $options );
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Name : MW WP Form Validation Rule FileType
|
4 |
* Description: ファイル名が指定した拡張子を含む。types は , 区切り
|
5 |
+
* Version : 1.1.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : July 21, 2014
|
9 |
+
* Modified : December 31, 2014
|
10 |
+
* License : GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
+
class MW_WP_Form_Validation_Rule_FileType extends MW_WP_Form_Abstract_Validation_Rule {
|
14 |
|
15 |
/**
|
16 |
+
* $name
|
17 |
* バリデーションルール名を指定
|
18 |
+
* @var string
|
19 |
*/
|
20 |
protected $name = 'filetype';
|
21 |
|
29 |
$value = $this->Data->get( $key );
|
30 |
if ( !is_null( $value ) && !MWF_Functions::is_empty( $value ) ) {
|
31 |
$defaults = array(
|
32 |
+
'types' => '',
|
33 |
'message' => __( 'This file is invalid.', MWF_Config::DOMAIN )
|
34 |
);
|
35 |
$options = array_merge( $defaults, $options );
|
validation_rules/mw_validation_rule_hiragana.php → classes/validation-rules/class.hiragana.php
RENAMED
@@ -1,19 +1,21 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Name: MW Validation Rule Hiragana
|
4 |
* Description: 値がひらがな
|
5 |
-
* Version: 1.0
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created
|
9 |
-
* Modified:
|
10 |
-
* License: GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
-
class
|
14 |
|
15 |
/**
|
|
|
16 |
* バリデーションルール名を指定
|
|
|
17 |
*/
|
18 |
protected $name = 'hiragana';
|
19 |
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Name : MW WP Form Validation Rule Hiragana
|
4 |
* Description: 値がひらがな
|
5 |
+
* Version : 1.1.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : July 21, 2014
|
9 |
+
* Modified : December 31, 2014
|
10 |
+
* License : GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
+
class MW_WP_Form_Validation_Rule_Hiragana extends MW_WP_Form_Abstract_Validation_Rule {
|
14 |
|
15 |
/**
|
16 |
+
* $name
|
17 |
* バリデーションルール名を指定
|
18 |
+
* @var string
|
19 |
*/
|
20 |
protected $name = 'hiragana';
|
21 |
|
validation_rules/mw_validation_rule_in.php → classes/validation-rules/class.in.php
RENAMED
@@ -1,19 +1,21 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Name: MW Validation Rule In
|
4 |
* Description: 値が、配列で指定された中に含まれている
|
5 |
-
* Version: 1.0
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created
|
9 |
-
* Modified:
|
10 |
-
* License: GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
-
class
|
14 |
|
15 |
/**
|
|
|
16 |
* バリデーションルール名を指定
|
|
|
17 |
*/
|
18 |
protected $name = 'in';
|
19 |
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Name : MW WP Form Validation Rule In
|
4 |
* Description: 値が、配列で指定された中に含まれている
|
5 |
+
* Version : 1.1.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : July 21, 2014
|
9 |
+
* Modified : December 31, 2014
|
10 |
+
* License : GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
+
class MW_WP_Form_Validation_Rule_In extends MW_WP_Form_Abstract_Validation_Rule {
|
14 |
|
15 |
/**
|
16 |
+
* $name
|
17 |
* バリデーションルール名を指定
|
18 |
+
* @var string
|
19 |
*/
|
20 |
protected $name = 'in';
|
21 |
|
validation_rules/mw_validation_rule_katakana.php → classes/validation-rules/class.katakana.php
RENAMED
@@ -1,19 +1,21 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Name: MW Validation Rule Katakana
|
4 |
* Description: 値がカタカナ
|
5 |
-
* Version: 1.0
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created
|
9 |
-
* Modified:
|
10 |
-
* License: GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
-
class
|
14 |
|
15 |
/**
|
|
|
16 |
* バリデーションルール名を指定
|
|
|
17 |
*/
|
18 |
protected $name = 'katakana';
|
19 |
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Name : MW WP Form Validation Rule Katakana
|
4 |
* Description: 値がカタカナ
|
5 |
+
* Version : 1.1.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : July 21, 2014
|
9 |
+
* Modified : December 31, 2014
|
10 |
+
* License : GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
+
class MW_WP_Form_Validation_Rule_Katakana extends MW_WP_Form_Abstract_Validation_Rule {
|
14 |
|
15 |
/**
|
16 |
+
* $name
|
17 |
* バリデーションルール名を指定
|
18 |
+
* @var string
|
19 |
*/
|
20 |
protected $name = 'katakana';
|
21 |
|
validation_rules/mw_validation_rule_mail.php → classes/validation-rules/class.mail.php
RENAMED
@@ -1,19 +1,21 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Name: MW Validation Rule Mail
|
4 |
* Description: 値がメールアドレス
|
5 |
-
* Version: 1.0
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created
|
9 |
-
* Modified:
|
10 |
-
* License: GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
-
class
|
14 |
|
15 |
/**
|
|
|
16 |
* バリデーションルール名を指定
|
|
|
17 |
*/
|
18 |
protected $name = 'mail';
|
19 |
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Name : MW WP Form Validation Rule Mail
|
4 |
* Description: 値がメールアドレス
|
5 |
+
* Version : 1.1.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : July 21, 2014
|
9 |
+
* Modified : December 31, 2014
|
10 |
+
* License : GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
+
class MW_WP_Form_Validation_Rule_Mail extends MW_WP_Form_Abstract_Validation_Rule {
|
14 |
|
15 |
/**
|
16 |
+
* $name
|
17 |
* バリデーションルール名を指定
|
18 |
+
* @var string
|
19 |
*/
|
20 |
protected $name = 'mail';
|
21 |
|
validation_rules/mw_validation_rule_minlength.php → classes/validation-rules/class.minlength.php
RENAMED
@@ -1,19 +1,21 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Name: MW Validation Rule MinLength
|
4 |
* Description: 値の文字数が範囲内
|
5 |
-
* Version: 1.0
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created
|
9 |
-
* Modified: December
|
10 |
-
* License: GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
-
class
|
14 |
|
15 |
/**
|
|
|
16 |
* バリデーションルール名を指定
|
|
|
17 |
*/
|
18 |
protected $name = 'minlength';
|
19 |
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Name : MW WP Form Validation Rule MinLength
|
4 |
* Description: 値の文字数が範囲内
|
5 |
+
* Version : 1.1.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : July 21, 2014
|
9 |
+
* Modified : December 31, 2014
|
10 |
+
* License : GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
+
class MW_WP_Form_Validation_Rule_MinLength extends MW_WP_Form_Abstract_Validation_Rule {
|
14 |
|
15 |
/**
|
16 |
+
* $name
|
17 |
* バリデーションルール名を指定
|
18 |
+
* @var string
|
19 |
*/
|
20 |
protected $name = 'minlength';
|
21 |
|
validation_rules/mw_validation_rule_noempty.php → classes/validation-rules/class.noempty.php
RENAMED
@@ -1,19 +1,21 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Name: MW Validation Rule noEmpty
|
4 |
* Description: 値が空ではない(0は許可)
|
5 |
-
* Version: 1.0
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created
|
9 |
-
* Modified:
|
10 |
-
* License: GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
-
class
|
14 |
|
15 |
/**
|
|
|
16 |
* バリデーションルール名を指定
|
|
|
17 |
*/
|
18 |
protected $name = 'noempty';
|
19 |
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Name : MW WP Form Validation Rule noEmpty
|
4 |
* Description: 値が空ではない(0は許可)
|
5 |
+
* Version : 1.1.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : July 21, 2014
|
9 |
+
* Modified : December 31, 2014
|
10 |
+
* License : GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
+
class MW_WP_Form_Validation_Rule_noEmpty extends MW_WP_Form_Abstract_Validation_Rule {
|
14 |
|
15 |
/**
|
16 |
+
* $name
|
17 |
* バリデーションルール名を指定
|
18 |
+
* @var string
|
19 |
*/
|
20 |
protected $name = 'noempty';
|
21 |
|
validation_rules/mw_validation_rule_nofalse.php → classes/validation-rules/class.nofalse.php
RENAMED
@@ -1,19 +1,21 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Name: MW Validation Rule noFalse
|
4 |
* Description: 値が空ではない(0も不可)
|
5 |
-
* Version: 1.0
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created
|
9 |
-
* Modified:
|
10 |
-
* License: GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
-
class
|
14 |
|
15 |
/**
|
|
|
16 |
* バリデーションルール名を指定
|
|
|
17 |
*/
|
18 |
protected $name = 'nofalse';
|
19 |
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Name : MW WP Form Validation Rule noFalse
|
4 |
* Description: 値が空ではない(0も不可)
|
5 |
+
* Version : 1.1.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : July 21, 2014
|
9 |
+
* Modified : December 31, 2014
|
10 |
+
* License : GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
+
class MW_WP_Form_Validation_Rule_noFalse extends MW_WP_Form_Abstract_Validation_Rule {
|
14 |
|
15 |
/**
|
16 |
+
* $name
|
17 |
* バリデーションルール名を指定
|
18 |
+
* @var string
|
19 |
*/
|
20 |
protected $name = 'nofalse';
|
21 |
|
validation_rules/mw_validation_rule_numeric.php → classes/validation-rules/class.numeric.php
RENAMED
@@ -1,19 +1,21 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Name: MW Validation Rule Numeric
|
4 |
* Description: 値が数値
|
5 |
-
* Version: 1.0
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created
|
9 |
-
* Modified:
|
10 |
-
* License: GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
-
class
|
14 |
|
15 |
/**
|
|
|
16 |
* バリデーションルール名を指定
|
|
|
17 |
*/
|
18 |
protected $name = 'numeric';
|
19 |
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Name : MW WP Form Validation Rule Numeric
|
4 |
* Description: 値が数値
|
5 |
+
* Version : 1.1.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : July 21, 2014
|
9 |
+
* Modified : December 31, 2014
|
10 |
+
* License : GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
+
class MW_WP_Form_Validation_Rule_Numeric extends MW_WP_Form_Abstract_Validation_Rule {
|
14 |
|
15 |
/**
|
16 |
+
* $name
|
17 |
* バリデーションルール名を指定
|
18 |
+
* @var string
|
19 |
*/
|
20 |
protected $name = 'numeric';
|
21 |
|
validation_rules/mw_validation_rule_required.php → classes/validation-rules/class.required.php
RENAMED
@@ -1,19 +1,21 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Name: MW Validation Rule Required
|
4 |
* Description: 値が存在する
|
5 |
-
* Version: 1.0
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created
|
9 |
-
* Modified:
|
10 |
-
* License: GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
-
class
|
14 |
|
15 |
/**
|
|
|
16 |
* バリデーションルール名を指定
|
|
|
17 |
*/
|
18 |
protected $name = 'required';
|
19 |
|
@@ -26,7 +28,7 @@ class MW_Validation_Rule_Required extends MW_Validation_Rule {
|
|
26 |
public function rule( $key, array $options = array() ) {
|
27 |
$value = $this->Data->get( $key );
|
28 |
// 値が存在するとき、もしくは存在しないけど他のデータもない(=フォーム送信自体されていない)ときはエラーではない
|
29 |
-
if ( !is_null( $value ) || is_null( $value ) && !$this->Data->
|
30 |
return;
|
31 |
}
|
32 |
$defaults = array(
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Name : MW WP Form Validation Rule Required
|
4 |
* Description: 値が存在する
|
5 |
+
* Version : 1.1.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : July 21, 2014
|
9 |
+
* Modified : December 31, 2014
|
10 |
+
* License : GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
+
class MW_WP_Form_Validation_Rule_Required extends MW_WP_Form_Abstract_Validation_Rule {
|
14 |
|
15 |
/**
|
16 |
+
* $name
|
17 |
* バリデーションルール名を指定
|
18 |
+
* @var string
|
19 |
*/
|
20 |
protected $name = 'required';
|
21 |
|
28 |
public function rule( $key, array $options = array() ) {
|
29 |
$value = $this->Data->get( $key );
|
30 |
// 値が存在するとき、もしくは存在しないけど他のデータもない(=フォーム送信自体されていない)ときはエラーではない
|
31 |
+
if ( !is_null( $value ) || is_null( $value ) && !$this->Data->gets() ) {
|
32 |
return;
|
33 |
}
|
34 |
$defaults = array(
|
validation_rules/mw_validation_rule_tel.php → classes/validation-rules/class.tel.php
RENAMED
@@ -1,19 +1,21 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Name: MW Validation Rule Tel
|
4 |
* Description: 値が電話番号
|
5 |
-
* Version: 1.0
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created
|
9 |
-
* Modified:
|
10 |
-
* License: GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
-
class
|
14 |
|
15 |
/**
|
|
|
16 |
* バリデーションルール名を指定
|
|
|
17 |
*/
|
18 |
protected $name = 'tel';
|
19 |
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Name : MW WP Form Validation Rule Tel
|
4 |
* Description: 値が電話番号
|
5 |
+
* Version : 1.1.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : July 21, 2014
|
9 |
+
* Modified : December 31, 2014
|
10 |
+
* License : GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
+
class MW_WP_Form_Validation_Rule_Tel extends MW_WP_Form_Abstract_Validation_Rule {
|
14 |
|
15 |
/**
|
16 |
+
* $name
|
17 |
* バリデーションルール名を指定
|
18 |
+
* @var string
|
19 |
*/
|
20 |
protected $name = 'tel';
|
21 |
|
validation_rules/mw_validation_rule_url.php → classes/validation-rules/class.url.php
RENAMED
@@ -1,19 +1,21 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Name: MW Validation Rule Url
|
4 |
* Description: 値がURL
|
5 |
-
* Version: 1.0
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created
|
9 |
-
* Modified:
|
10 |
-
* License: GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
-
class
|
14 |
|
15 |
/**
|
|
|
16 |
* バリデーションルール名を指定
|
|
|
17 |
*/
|
18 |
protected $name = 'url';
|
19 |
|
@@ -26,7 +28,7 @@ class MW_Validation_Rule_Url extends MW_Validation_Rule {
|
|
26 |
public function rule( $key, array $options = array() ) {
|
27 |
$value = $this->Data->get( $key );
|
28 |
if ( !is_null( $value ) && !MWF_Functions::is_empty( $value ) ) {
|
29 |
-
if ( !preg_match( '/^https{0,1}:\/\/[^\/]
|
30 |
$defaults = array(
|
31 |
'message' => __( 'This is not the format of a url.', MWF_Config::DOMAIN )
|
32 |
);
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Name : MW WP Form Validation Rule Url
|
4 |
* Description: 値がURL
|
5 |
+
* Version : 1.1.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : July 21, 2014
|
9 |
+
* Modified : December 31, 2014
|
10 |
+
* License : GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
+
class MW_WP_Form_Validation_Rule_Url extends MW_WP_Form_Abstract_Validation_Rule {
|
14 |
|
15 |
/**
|
16 |
+
* $name
|
17 |
* バリデーションルール名を指定
|
18 |
+
* @var string
|
19 |
*/
|
20 |
protected $name = 'url';
|
21 |
|
28 |
public function rule( $key, array $options = array() ) {
|
29 |
$value = $this->Data->get( $key );
|
30 |
if ( !is_null( $value ) && !MWF_Functions::is_empty( $value ) ) {
|
31 |
+
if ( !preg_match( '/^https{0,1}:\/\/[^\/]+\..?/', $value ) ) {
|
32 |
$defaults = array(
|
33 |
'message' => __( 'This is not the format of a url.', MWF_Config::DOMAIN )
|
34 |
);
|
validation_rules/mw_validation_rule_zip.php → classes/validation-rules/class.zip.php
RENAMED
@@ -1,19 +1,21 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Name: MW Validation Rule Zip
|
4 |
* Description: 値が郵便番号
|
5 |
-
* Version: 1.0
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created
|
9 |
-
* Modified:
|
10 |
-
* License: GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
-
class
|
14 |
|
15 |
/**
|
|
|
16 |
* バリデーションルール名を指定
|
|
|
17 |
*/
|
18 |
protected $name = 'zip';
|
19 |
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Name : MW WP Form Validation Rule Zip
|
4 |
* Description: 値が郵便番号
|
5 |
+
* Version : 1.1.0
|
6 |
+
* Author : Takashi Kitajima
|
7 |
+
* Author URI : http://2inc.org
|
8 |
+
* Created : July 21, 2014
|
9 |
+
* Modified : December 31, 2014
|
10 |
+
* License : GPLv2
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
+
class MW_WP_Form_Validation_Rule_Zip extends MW_WP_Form_Abstract_Validation_Rule {
|
14 |
|
15 |
/**
|
16 |
+
* $name
|
17 |
* バリデーションルール名を指定
|
18 |
+
* @var string
|
19 |
*/
|
20 |
protected $name = 'zip';
|
21 |
|
classes/views/class.admin-list.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Name : MW WP Form Admin List View
|
4 |
+
* Version : 1.0.0
|
5 |
+
* Author : Takashi Kitajima
|
6 |
+
* Author URI : http://2inc.org
|
7 |
+
* Created : January 2, 2015
|
8 |
+
* Modified :
|
9 |
+
* License : GPLv2
|
10 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
+
*/
|
12 |
+
class MW_WP_Form_Admin_List_View extends MW_WP_Form_View {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* form_key
|
16 |
+
*/
|
17 |
+
public function form_key() {
|
18 |
+
$post_id = $this->get( 'post_id' );
|
19 |
+
printf(
|
20 |
+
'<span id="formkey_field">[mwform_formkey key="%d"]</span>',
|
21 |
+
$post_id
|
22 |
+
);
|
23 |
+
}
|
24 |
+
}
|
classes/views/class.admin.php
ADDED
@@ -0,0 +1,373 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Name : MW WP Form Admin View
|
4 |
+
* Version : 1.0.0
|
5 |
+
* Author : Takashi Kitajima
|
6 |
+
* Author URI : http://2inc.org
|
7 |
+
* Created : January 2, 2015
|
8 |
+
* Modified :
|
9 |
+
* License : GPLv2
|
10 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
+
*/
|
12 |
+
class MW_WP_Form_Admin_View extends MW_WP_Form_View {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* complete_message
|
16 |
+
* 完了画面内容の入力画面を表示
|
17 |
+
*/
|
18 |
+
public function complete_message() {
|
19 |
+
$complete_message = $this->get( 'complete_message' );
|
20 |
+
wp_editor( $complete_message, MWF_Config::NAME . '_complete_message', array(
|
21 |
+
'textarea_name' => MWF_Config::NAME . '[complete_message]',
|
22 |
+
'textarea_rows' => 7,
|
23 |
+
) );
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* url
|
28 |
+
* URL設定フォームを表示
|
29 |
+
*/
|
30 |
+
public function url() {
|
31 |
+
$input_url = $this->get( 'input_url' );
|
32 |
+
$confirmation_url = $this->get( 'confirmation_url' );
|
33 |
+
$complete_url = $this->get( 'complete_url' );
|
34 |
+
$validation_error_url = $this->get( 'validation_error_url' );
|
35 |
+
?>
|
36 |
+
<input type="hidden" name="<?php echo esc_attr( MWF_Config::NAME ); ?>_nonce" value="<?php echo wp_create_nonce( MWF_Config::NAME ); ?>" />
|
37 |
+
<table border="0" cellpadding="0" cellspacing="4">
|
38 |
+
<tr>
|
39 |
+
<th><?php esc_html_e( 'Input Page URL', MWF_Config::DOMAIN ); ?></th>
|
40 |
+
<td>
|
41 |
+
<input type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[input_url]" value="<?php echo esc_attr( $input_url ); ?>" />
|
42 |
+
</td>
|
43 |
+
</tr>
|
44 |
+
<tr>
|
45 |
+
<th><?php esc_html_e( 'Confirmation Page URL', MWF_Config::DOMAIN ); ?></th>
|
46 |
+
<td>
|
47 |
+
<input type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[confirmation_url]" value="<?php echo esc_attr( $confirmation_url ); ?>" />
|
48 |
+
</td>
|
49 |
+
</tr>
|
50 |
+
<tr>
|
51 |
+
<th><?php esc_html_e( 'Complete Page URL', MWF_Config::DOMAIN ); ?></th>
|
52 |
+
<td>
|
53 |
+
<input type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[complete_url]" value="<?php echo esc_attr( $complete_url ); ?>" />
|
54 |
+
</td>
|
55 |
+
</tr>
|
56 |
+
<tr>
|
57 |
+
<th><?php esc_html_e( 'Validation Error Page URL', MWF_Config::DOMAIN ); ?></th>
|
58 |
+
<td>
|
59 |
+
<input type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[validation_error_url]" value="<?php echo esc_attr( $validation_error_url ); ?>" />
|
60 |
+
</td>
|
61 |
+
</tr>
|
62 |
+
</table>
|
63 |
+
<p class="description">
|
64 |
+
<?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.', MWF_Config::DOMAIN ); ?><br />
|
65 |
+
<?php printf( esc_html__( 'When a URL doesn\'t begin http or https, %s is complemented.', MWF_Config::DOMAIN ), '<b>' . home_url() . '</b>' ); ?>
|
66 |
+
</p>
|
67 |
+
<?php
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* validation_rule
|
72 |
+
* バリデーションルール設定フォームを表示
|
73 |
+
*/
|
74 |
+
public function validation_rule() {
|
75 |
+
$validation = $this->get( 'validation' );
|
76 |
+
$validation_rules = $this->get( 'validation_rules' );
|
77 |
+
|
78 |
+
if ( !$validation ) {
|
79 |
+
$validation = array();
|
80 |
+
}
|
81 |
+
$validation_keys = array(
|
82 |
+
'target' => '',
|
83 |
+
);
|
84 |
+
foreach ( $validation_rules as $validation_rule => $instance ) {
|
85 |
+
$validation_keys[$instance->getName()] = '';
|
86 |
+
}
|
87 |
+
// 空の隠れバリデーションフィールド(コピー元)を挿入
|
88 |
+
array_unshift( $validation, $validation_keys );
|
89 |
+
?>
|
90 |
+
<b class="add-btn"><?php esc_html_e( 'Add Validation rule', MWF_Config::DOMAIN ); ?></b>
|
91 |
+
<div class="repeatable-boxes">
|
92 |
+
<?php foreach ( $validation as $key => $value ) : $value = array_merge( $validation_keys, $value ); ?>
|
93 |
+
<div class="repeatable-box" <?php if ( $key === 0 ) : ?>style="display:none"<?php endif; ?>>
|
94 |
+
<div class="remove-btn"><b>×</b></div>
|
95 |
+
<div class="open-btn"><span><?php echo esc_attr( $value['target'] ); ?></span><b>▼</b></div>
|
96 |
+
<div class="repeatable-box-content">
|
97 |
+
<?php esc_html_e( 'The key which applies validation', MWF_Config::DOMAIN ); ?>:<input type="text" class="targetKey" value="<?php echo esc_attr( $value['target'] ); ?>" name="<?php echo MWF_Config::NAME; ?>[validation][<?php echo esc_attr( $key ); ?>][target]" />
|
98 |
+
<table border="0" cellpadding="0" cellspacing="0">
|
99 |
+
<tr>
|
100 |
+
<td colspan="2">
|
101 |
+
<?php foreach ( $validation_rules as $validation_rule => $instance ) : ?>
|
102 |
+
<?php $instance->admin( $key, $value ); ?>
|
103 |
+
<?php endforeach; ?>
|
104 |
+
</td>
|
105 |
+
</tr>
|
106 |
+
</table>
|
107 |
+
<!-- end .repeatable-box-content --></div>
|
108 |
+
<!-- end .repeatable-box --></div>
|
109 |
+
<?php endforeach; ?>
|
110 |
+
<!-- end .repeatable-boxes --></div>
|
111 |
+
<?php
|
112 |
+
}
|
113 |
+
|
114 |
+
/**
|
115 |
+
* add_ons
|
116 |
+
* アドオン
|
117 |
+
*/
|
118 |
+
public function add_ons() {
|
119 |
+
?>
|
120 |
+
<p>
|
121 |
+
<?php esc_html_e( 'You can use more easy and useful to the MW WP Form in add-on!', MWF_Config::DOMAIN ); ?><br />
|
122 |
+
<a href="http://plugins.2inc.org/mw-wp-form/add-on/" target="_blank" class="button button-primary"><?php esc_html_e( 'View Add-ons', MWF_Config::DOMAIN ); ?></a>
|
123 |
+
</p>
|
124 |
+
<?php
|
125 |
+
}
|
126 |
+
|
127 |
+
/**
|
128 |
+
* form_key
|
129 |
+
* フォーム識別子のテキストフィールドを表示
|
130 |
+
*/
|
131 |
+
public function form_key() {
|
132 |
+
$post_id = $this->get( 'post_id' );
|
133 |
+
?>
|
134 |
+
<p>
|
135 |
+
<span id="formkey_field">[mwform_formkey key="<?php echo esc_html( $post_id ); ?>"]</span>
|
136 |
+
<span class="mwf_note">
|
137 |
+
<?php esc_html_e( 'Copy and Paste this shortcode.', MWF_Config::DOMAIN ); ?><br />
|
138 |
+
<?php esc_html_e( 'The key to use with hook is ', MWF_Config::DOMAIN ); ?><?php echo MWF_Config::NAME; ?>-<?php echo esc_html( $post_id ); ?>
|
139 |
+
</span>
|
140 |
+
</p>
|
141 |
+
<?php
|
142 |
+
}
|
143 |
+
|
144 |
+
/**
|
145 |
+
* mail_options
|
146 |
+
* 自動返信メール設定フォームを表示
|
147 |
+
*/
|
148 |
+
public function mail_options() {
|
149 |
+
$mail_subject = $this->get( 'mail_subject' );
|
150 |
+
$mail_sender = $this->get( 'mail_sender' );
|
151 |
+
$mail_from = $this->get( 'mail_from' );
|
152 |
+
$mail_content = $this->get( 'mail_content' );
|
153 |
+
$automatic_reply_email = $this->get( 'automatic_reply_email' );
|
154 |
+
?>
|
155 |
+
<p>
|
156 |
+
<?php esc_html_e( '{key} is converted form data.', MWF_Config::DOMAIN ); ?>
|
157 |
+
<?php echo sprintf(
|
158 |
+
esc_html__( 'It is automatically converted to Tracking number when you input {%s}.', MWF_Config::DOMAIN ),
|
159 |
+
MWF_Config::TRACKINGNUMBER
|
160 |
+
); ?>
|
161 |
+
</p>
|
162 |
+
<p>
|
163 |
+
<b><?php esc_html_e( 'Subject', MWF_Config::DOMAIN ); ?></b><br />
|
164 |
+
<input type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[mail_subject]" value="<?php echo esc_attr( $mail_subject ); ?>" />
|
165 |
+
</p>
|
166 |
+
<p>
|
167 |
+
<b><?php esc_html_e( 'Sender', MWF_Config::DOMAIN ); ?></b><br />
|
168 |
+
<input type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[mail_sender]" value="<?php echo esc_attr( $mail_sender ); ?>" /><br />
|
169 |
+
<span class="mwf_note"><?php esc_html_e( 'If empty:', MWF_Config::DOMAIN ); ?> <?php bloginfo( 'name' ); ?></span>
|
170 |
+
</p>
|
171 |
+
<p>
|
172 |
+
<b><?php esc_html_e( 'From ( E-mail address )', MWF_Config::DOMAIN ); ?></b><br />
|
173 |
+
<input type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[mail_from]" value="<?php echo esc_attr( $mail_from ); ?>" /><br />
|
174 |
+
<span class="mwf_note"><?php esc_html_e( 'If empty:', MWF_Config::DOMAIN ); ?> <?php bloginfo( 'admin_email' ); ?></span>
|
175 |
+
</p>
|
176 |
+
<p>
|
177 |
+
<b><?php esc_html_e( 'Content', MWF_Config::DOMAIN ); ?></b><br />
|
178 |
+
<textarea name="<?php echo esc_attr( MWF_Config::NAME ); ?>[mail_content]" cols="30" rows="10"><?php echo esc_attr( $mail_content ); ?></textarea>
|
179 |
+
</p>
|
180 |
+
<p>
|
181 |
+
<b><?php esc_html_e( 'Automatic reply email', MWF_Config::DOMAIN ); ?></b><br />
|
182 |
+
<input type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[automatic_reply_email]" value="<?php echo esc_attr( $automatic_reply_email ); ?>" /><br />
|
183 |
+
<span class="mwf_note"><?php esc_html_e( 'Input the key to use as transmission to automatic reply email. {} is unnecessary.', MWF_Config::DOMAIN ); ?></span>
|
184 |
+
</p>
|
185 |
+
<?php
|
186 |
+
}
|
187 |
+
|
188 |
+
/**
|
189 |
+
* admin_mail_options
|
190 |
+
* 管理者宛メール設定フォームを表示
|
191 |
+
*/
|
192 |
+
public function admin_mail_options() {
|
193 |
+
$mail_to = $this->get( 'mail_to' );
|
194 |
+
$mail_cc = $this->get( 'mail_cc' );
|
195 |
+
$mail_bcc = $this->get( 'mail_bcc' );
|
196 |
+
$admin_mail_subject = $this->get( 'admin_mail_subject' );
|
197 |
+
$admin_mail_sender = $this->get( 'admin_mail_sender' );
|
198 |
+
$admin_mail_from = $this->get( 'admin_mail_from' );
|
199 |
+
$admin_mail_content = $this->get( 'admin_mail_content' );
|
200 |
+
?>
|
201 |
+
<p>
|
202 |
+
<?php esc_html_e( '{key} is converted form data.', MWF_Config::DOMAIN ); ?>
|
203 |
+
<?php echo sprintf(
|
204 |
+
esc_html__( 'It is automatically converted to Tracking number when you input {%s}.', MWF_Config::DOMAIN ),
|
205 |
+
MWF_Config::TRACKINGNUMBER
|
206 |
+
); ?>
|
207 |
+
</p>
|
208 |
+
<p>
|
209 |
+
<?php esc_html_e( 'If Admin Email Options is a blank, Automatic Replay Email Options is used as Admin Email Options.', MWF_Config::DOMAIN ); ?>
|
210 |
+
</p>
|
211 |
+
<p>
|
212 |
+
<b><?php esc_html_e( 'To ( E-mail address )', MWF_Config::DOMAIN ); ?></b><br />
|
213 |
+
<input type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[mail_to]" value="<?php echo esc_attr( $mail_to ); ?>" /><br />
|
214 |
+
<span class="mwf_note"><?php esc_html_e( 'If empty:', MWF_Config::DOMAIN ); ?> <?php bloginfo( 'admin_email' ); ?></span>
|
215 |
+
</p>
|
216 |
+
<p>
|
217 |
+
<b><?php esc_html_e( 'CC ( E-mail address )', MWF_Config::DOMAIN ); ?></b><br />
|
218 |
+
<input type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[mail_cc]" value="<?php echo esc_attr( $mail_cc ); ?>" />
|
219 |
+
</p>
|
220 |
+
<p>
|
221 |
+
<b><?php esc_html_e( 'BCC ( E-mail address )', MWF_Config::DOMAIN ); ?></b><br />
|
222 |
+
<input type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[mail_bcc]" value="<?php echo esc_attr( $mail_bcc ); ?>" />
|
223 |
+
</p>
|
224 |
+
<p>
|
225 |
+
<b><?php esc_html_e( 'Subject', MWF_Config::DOMAIN ); ?></b><br />
|
226 |
+
<input type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[admin_mail_subject]" value="<?php echo esc_attr( $admin_mail_subject ); ?>" />
|
227 |
+
</p>
|
228 |
+
<p>
|
229 |
+
<b><?php esc_html_e( 'Sender', MWF_Config::DOMAIN ); ?></b><br />
|
230 |
+
<input type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[admin_mail_sender]" value="<?php echo esc_attr( $admin_mail_sender ); ?>" /><br />
|
231 |
+
<span class="mwf_note"><?php esc_html_e( 'If empty:', MWF_Config::DOMAIN ); ?> <?php bloginfo( 'name' ); ?></span>
|
232 |
+
</p>
|
233 |
+
<p>
|
234 |
+
<b><?php esc_html_e( 'From ( E-mail address )', MWF_Config::DOMAIN ); ?></b><br />
|
235 |
+
<input type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[admin_mail_from]" value="<?php echo esc_attr( $admin_mail_from ); ?>" /><br />
|
236 |
+
<span class="mwf_note"><?php esc_html_e( 'If empty:', MWF_Config::DOMAIN ); ?> <?php bloginfo( 'admin_email' ); ?></span>
|
237 |
+
</p>
|
238 |
+
<p>
|
239 |
+
<b><?php esc_html_e( 'Content', MWF_Config::DOMAIN ); ?></b><br />
|
240 |
+
<textarea name="<?php echo esc_attr( MWF_Config::NAME ); ?>[admin_mail_content]" cols="30" rows="10"><?php echo esc_attr( $admin_mail_content ); ?></textarea>
|
241 |
+
</p>
|
242 |
+
<?php
|
243 |
+
}
|
244 |
+
|
245 |
+
/**
|
246 |
+
* settings
|
247 |
+
* $post を取得するための引数を有効にするフィールドを表示
|
248 |
+
*/
|
249 |
+
public function settings() {
|
250 |
+
$querystring = $this->get( 'querystring' );
|
251 |
+
$usedb = $this->get( 'usedb' );
|
252 |
+
$scroll = $this->get( 'scroll' );
|
253 |
+
$akismet_author = $this->get( 'akismet_author' );
|
254 |
+
$akismet_author_email = $this->get( 'akismet_author_email' );
|
255 |
+
$akismet_author_url = $this->get( 'akismet_author_url' );
|
256 |
+
?>
|
257 |
+
<p>
|
258 |
+
<label><input type="checkbox" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[querystring]" value="1" <?php checked( $querystring, 1 ); ?> /> <?php esc_html_e( 'Activate Query string of post', MWF_Config::DOMAIN ); ?></label><br />
|
259 |
+
<span class="mwf_note"><?php esc_html_e( '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.', MWF_Config::DOMAIN ); ?><br />
|
260 |
+
<?php esc_html_e( 'Example: {ID}, {post_title}, {post_meta} etc...', MWF_Config::DOMAIN ); ?></span>
|
261 |
+
</p>
|
262 |
+
<p>
|
263 |
+
<label><input type="checkbox" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[usedb]" value="1" <?php checked( $usedb, 1 ); ?> /> <?php esc_html_e( 'Saving inquiry data in database', MWF_Config::DOMAIN ); ?></label>
|
264 |
+
</p>
|
265 |
+
<p>
|
266 |
+
<label><input type="checkbox" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[scroll]" value="1" <?php checked( $scroll, 1 ); ?> /> <?php esc_html_e( 'Enable scrolling of screen transition.', MWF_Config::DOMAIN ); ?></label>
|
267 |
+
</p>
|
268 |
+
<table border="0" cellpadding="0" cellspacing="0" class="akismet">
|
269 |
+
<tr>
|
270 |
+
<th colspan="2"><?php esc_html_e( 'Akismet Setting', MWF_Config::DOMAIN ); ?></th>
|
271 |
+
</tr>
|
272 |
+
<tr>
|
273 |
+
<td>author</td>
|
274 |
+
<td><input type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[akismet_author]" value="<?php echo esc_attr( $akismet_author ); ?>" /></td>
|
275 |
+
</tr>
|
276 |
+
<tr>
|
277 |
+
<td>email</td>
|
278 |
+
<td><input type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[akismet_author_email]" value="<?php echo esc_attr( $akismet_author_email ); ?>" /></td>
|
279 |
+
</tr>
|
280 |
+
<tr>
|
281 |
+
<td>url</td>
|
282 |
+
<td><input type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[akismet_author_url]" value="<?php echo esc_attr( $akismet_author_url ); ?>" /></td>
|
283 |
+
</tr>
|
284 |
+
</table>
|
285 |
+
<span class="mwf_note"><?php esc_html_e( 'Input the key to use Akismet.', MWF_Config::DOMAIN ); ?></span>
|
286 |
+
<?php
|
287 |
+
}
|
288 |
+
|
289 |
+
/**
|
290 |
+
* style
|
291 |
+
*/
|
292 |
+
public function style() {
|
293 |
+
$styles = $this->get( 'styles' );
|
294 |
+
$style = $this->get( 'style' );
|
295 |
+
?>
|
296 |
+
<p>
|
297 |
+
<select name="<?php echo MWF_Config::NAME; ?>[style]">
|
298 |
+
<option value=""><?php esc_html_e( 'Select Style', MWF_Config::DOMAIN ); ?></option>
|
299 |
+
<?php foreach ( $styles as $style_key => $css ) : ?>
|
300 |
+
<option value="<?php echo esc_attr( $style_key ); ?>" <?php selected( $style, $style_key ); ?>>
|
301 |
+
<?php echo esc_html( $style_key ); ?>
|
302 |
+
</option>
|
303 |
+
<?php endforeach; ?>
|
304 |
+
</select>
|
305 |
+
</p>
|
306 |
+
<?php
|
307 |
+
}
|
308 |
+
|
309 |
+
/**
|
310 |
+
* donate_link
|
311 |
+
* @param array $views
|
312 |
+
* @return array
|
313 |
+
*/
|
314 |
+
public function donate_link( $views ) {
|
315 |
+
$donation = array( 'donation' => '<div class="donation"><p>' . __( 'Your contribution is needed for making this plugin better.', MWF_Config::DOMAIN ) . ' <a href="http://www.amazon.co.jp/registry/wishlist/39ANKRNSTNW40" class="button">' . __( 'Donate', MWF_Config::DOMAIN ) . '</a></p></div>' );
|
316 |
+
$views = array_merge( $donation, $views );
|
317 |
+
return $views;
|
318 |
+
}
|
319 |
+
|
320 |
+
/**
|
321 |
+
* tag_generator
|
322 |
+
* タグジェネレータを出力
|
323 |
+
* @param string $editor_id
|
324 |
+
*/
|
325 |
+
public function tag_generator( $editor_id ) {
|
326 |
+
$post_type = get_post_type();
|
327 |
+
if ( $post_type !== MWF_Config::NAME ) {
|
328 |
+
return;
|
329 |
+
}
|
330 |
+
if ( $editor_id !== 'content' ) {
|
331 |
+
return;
|
332 |
+
}
|
333 |
+
do_action( 'mwform_tag_generator_dialog' );
|
334 |
+
?>
|
335 |
+
<div class="add-mwform-btn">
|
336 |
+
<select>
|
337 |
+
<option value=""><?php echo esc_html_e( 'Select this.', MWF_Config::DOMAIN ); ?></option>
|
338 |
+
<optgroup label="<?php echo esc_attr_e( 'Input fields', MWF_Config::DOMAIN ); ?>">
|
339 |
+
<?php do_action( 'mwform_tag_generator_input_option' ); ?>
|
340 |
+
</optgroup>
|
341 |
+
<optgroup label="<?php echo esc_attr_e( 'Select fields', MWF_Config::DOMAIN ); ?>">
|
342 |
+
<?php do_action( 'mwform_tag_generator_select_option' ); ?>
|
343 |
+
</optgroup>
|
344 |
+
<optgroup label="<?php echo esc_attr_e( 'Button fields', MWF_Config::DOMAIN ); ?>">
|
345 |
+
<?php do_action( 'mwform_tag_generator_button_option' ); ?>
|
346 |
+
</optgroup>
|
347 |
+
<optgroup label="<?php echo esc_attr_e( 'Error fields', MWF_Config::DOMAIN ); ?>">
|
348 |
+
<?php do_action( 'mwform_tag_generator_error_option' ); ?>
|
349 |
+
</optgroup>
|
350 |
+
<optgroup label="<?php echo esc_attr_e( 'Other fields', MWF_Config::DOMAIN ); ?>">
|
351 |
+
<?php do_action( 'mwform_tag_generator_option' ); ?>
|
352 |
+
</optgroup>
|
353 |
+
</select>
|
354 |
+
<span class="button"><?php esc_html_e( 'Add form tag', MWF_Config::DOMAIN ); ?></span>
|
355 |
+
</div>
|
356 |
+
<?php
|
357 |
+
}
|
358 |
+
|
359 |
+
/**
|
360 |
+
* quicktag
|
361 |
+
* HTMLエディタにクイックタグを追加
|
362 |
+
*/
|
363 |
+
public function quicktag() {
|
364 |
+
if ( MWF_Config::NAME == get_post_type() ) : ?>
|
365 |
+
<script type="text/javascript">
|
366 |
+
if ( typeof( QTags ) !== 'undefined' ) {
|
367 |
+
<?php do_action( 'mwform_add_qtags' ); ?>
|
368 |
+
}
|
369 |
+
</script>
|
370 |
+
<?php
|
371 |
+
endif;
|
372 |
+
}
|
373 |
+
}
|
classes/views/class.chart.php
ADDED
@@ -0,0 +1,211 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Name : MW WP Form Chart View
|
4 |
+
* Version : 1.0.0
|
5 |
+
* Author : Takashi Kitajima
|
6 |
+
* Author URI : http://2inc.org
|
7 |
+
* Created : January 2, 2015
|
8 |
+
* Modified :
|
9 |
+
* License : GPLv2
|
10 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
+
*/
|
12 |
+
class MW_WP_Form_Chart_View extends MW_WP_Form_View {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* admin_print_styles
|
16 |
+
*/
|
17 |
+
public function admin_print_styles() {
|
18 |
+
?>
|
19 |
+
<style>
|
20 |
+
#menu-posts-mw-wp-form .wp-submenu li a[href$="-chart"] {
|
21 |
+
display: none;
|
22 |
+
}
|
23 |
+
</style>
|
24 |
+
<?php
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* index
|
29 |
+
*/
|
30 |
+
public function index() {
|
31 |
+
if ( !$this->get( 'is_chart' ) ) {
|
32 |
+
return;
|
33 |
+
}
|
34 |
+
|
35 |
+
$post_type = $this->get( 'post_type' );
|
36 |
+
$option_group = $this->get( 'option_group' );
|
37 |
+
$form_posts = get_posts( array(
|
38 |
+
'post_type' => $post_type,
|
39 |
+
'posts_per_page' => -1,
|
40 |
+
) );
|
41 |
+
|
42 |
+
$custom_keys = array();
|
43 |
+
foreach ( $form_posts as $post ) {
|
44 |
+
$post_custom_keys = get_post_custom_keys( $post->ID );
|
45 |
+
if ( is_array( $post_custom_keys ) ) {
|
46 |
+
foreach ( $post_custom_keys as $post_custom_key ) {
|
47 |
+
if ( preg_match( '/^_/', $post_custom_key ) ) {
|
48 |
+
continue;
|
49 |
+
}
|
50 |
+
$post_meta = get_post_meta( $post->ID, $post_custom_key, true );
|
51 |
+
$custom_keys[$post_custom_key][$post_meta][] = $post->ID;
|
52 |
+
}
|
53 |
+
}
|
54 |
+
}
|
55 |
+
|
56 |
+
$postdata = array();
|
57 |
+
$option = get_option( MWF_Config::NAME . '-chart-' . $post_type );
|
58 |
+
if ( is_array( $option ) && isset( $option['chart'] ) && is_array( $option['chart'] ) ) {
|
59 |
+
$postdata = $option['chart'];
|
60 |
+
}
|
61 |
+
|
62 |
+
$default_keys = array(
|
63 |
+
'target' => '',
|
64 |
+
'separator' => '',
|
65 |
+
'chart' => '',
|
66 |
+
);
|
67 |
+
// 空の隠れフィールド(コピー元)を挿入
|
68 |
+
array_unshift( $postdata, $default_keys );
|
69 |
+
?>
|
70 |
+
<div class="wrap">
|
71 |
+
<?php $post_id = preg_replace( '/^(.+_)(\d+)$/', '$2', $post_type ); ?>
|
72 |
+
<h2>
|
73 |
+
<?php esc_html_e( 'Chart', MWF_Config::DOMAIN ); ?>
|
74 |
+
:
|
75 |
+
<?php echo esc_html( get_the_title( $post_id ) ); ?>
|
76 |
+
</h2>
|
77 |
+
<form method="post" action="options.php">
|
78 |
+
<?php
|
79 |
+
settings_fields( $option_group );
|
80 |
+
do_settings_sections( $option_group );
|
81 |
+
?>
|
82 |
+
<div id="<?php echo esc_attr( MWF_Config::NAME . '_chart' ); ?>" class="postbox">
|
83 |
+
<div class="inside">
|
84 |
+
<b class="add-btn"><?php esc_html_e( 'Add Chart', MWF_Config::DOMAIN ); ?></b>
|
85 |
+
<div class="repeatable-boxes">
|
86 |
+
<?php foreach ( $postdata as $key => $value ) : ?>
|
87 |
+
<div class="repeatable-box" <?php if ( $key === 0 ) : ?>style="display:none"<?php endif; ?>>
|
88 |
+
<div class="remove-btn"><b>×</b></div>
|
89 |
+
<div class="open-btn"><span><?php echo esc_html( $value['target'] ); ?></span><b>▼</b></div>
|
90 |
+
<div class="repeatable-box-content">
|
91 |
+
<?php esc_html_e( 'Item that create chart', MWF_Config::DOMAIN ); ?>
|
92 |
+
<select class="targetKey" name="<?php echo esc_attr( sprintf( '%s-chart-%s[chart][%s][target]', MWF_Config::NAME, $post_type, $key ) ); ?>">
|
93 |
+
<option value=""><?php esc_html_e( 'Select this.', MWF_Config::DOMAIN ); ?></option>
|
94 |
+
<?php foreach ( $custom_keys as $custom_key_name => $custom_key_value ) : ?>
|
95 |
+
<option value="<?php echo esc_attr( $custom_key_name ); ?>" <?php selected( $value['target'], $custom_key_name ); ?>><?php echo esc_html( $custom_key_name ); ?></option>
|
96 |
+
<?php endforeach; ?>
|
97 |
+
</select>
|
98 |
+
<br />
|
99 |
+
<?php esc_html_e( 'Chart type', MWF_Config::DOMAIN ); ?>
|
100 |
+
<select name="<?php echo esc_attr( sprintf( '%s-chart-%s[chart][%s][chart]', MWF_Config::NAME, $post_type, $key ) ); ?>">
|
101 |
+
<?php
|
102 |
+
$chart_options = array(
|
103 |
+
'pie' => esc_html__( 'Pie chart', MWF_Config::DOMAIN ),
|
104 |
+
'bar' => esc_html__( 'Bar chart', MWF_Config::DOMAIN ),
|
105 |
+
);
|
106 |
+
foreach ( $chart_options as $chart_option_key => $chart_option ) {
|
107 |
+
printf(
|
108 |
+
'<option value="%s" %s>%s</option>',
|
109 |
+
esc_attr( $chart_option_key ),
|
110 |
+
selected( $value['chart'], $chart_option_key, false ),
|
111 |
+
esc_html( $chart_option )
|
112 |
+
);
|
113 |
+
}
|
114 |
+
?>
|
115 |
+
</select>
|
116 |
+
<br />
|
117 |
+
<?php esc_html_e( 'Separator string (If the check box. If the separator attribute is not set to ",")', MWF_Config::DOMAIN ); ?>
|
118 |
+
<input type="text" name="<?php echo esc_attr( sprintf( '%s-chart-%s[chart][%s][separator]', MWF_Config::NAME, $post_type, $key ) ); ?>" value="<?php echo esc_attr( $value['separator'] ); ?>" size="5" />
|
119 |
+
<!-- end .repeatable-box-content --></div>
|
120 |
+
<!-- end .repeatable-box --></div>
|
121 |
+
<?php endforeach; ?>
|
122 |
+
<!-- end .repeatable-boxes --></div>
|
123 |
+
<input type="hidden" name="<?php echo esc_attr( sprintf( '%s-formkey', MWF_Config::NAME ) ); ?>" value="<?php echo esc_attr( $post_type ); ?>" />
|
124 |
+
<?php submit_button(); ?>
|
125 |
+
<!-- end .inside --></div>
|
126 |
+
<!-- end #mw-wp-form_chart --></div>
|
127 |
+
</form>
|
128 |
+
|
129 |
+
<?php
|
130 |
+
foreach ( $postdata as $postdata_key => $chart ) {
|
131 |
+
if ( !isset( $custom_keys[$chart['target']] ) ) {
|
132 |
+
unset( $postdata[$postdata_key] );
|
133 |
+
continue;
|
134 |
+
}
|
135 |
+
printf(
|
136 |
+
'<h3>%s <span style="font-weight:normal;font-size:14px">( %s: %d )</span></h3>
|
137 |
+
<div class="%s" style="width: 100%%; max-width: 800px"></div>',
|
138 |
+
esc_html( $chart['target'] ),
|
139 |
+
esc_html__( 'The number of inquiries', MWF_Config::DOMAIN ),
|
140 |
+
count( $form_posts ),
|
141 |
+
esc_attr( MWF_Config::NAME . '-chart-div-' . $postdata_key )
|
142 |
+
);
|
143 |
+
}
|
144 |
+
|
145 |
+
$chart_data = array();
|
146 |
+
foreach ( $postdata as $postdata_key => $chart ) {
|
147 |
+
$data = array();
|
148 |
+
$raw_data = array();
|
149 |
+
foreach ( $custom_keys[$chart['target']] as $item => $values ) {
|
150 |
+
if ( $chart['separator'] && strstr( $item, $chart['separator'] ) ) {
|
151 |
+
$item = explode( $chart['separator'] , $item );
|
152 |
+
}
|
153 |
+
if ( is_array( $item ) ) {
|
154 |
+
foreach ( $item as $_item ) {
|
155 |
+
if ( $_item === '' ) {
|
156 |
+
$_item = '(Empty)';
|
157 |
+
}
|
158 |
+
if ( empty( $raw_data[$_item] ) ) {
|
159 |
+
$raw_data[$_item] = count( $values );
|
160 |
+
} else {
|
161 |
+
$raw_data[$_item] += count( $values );
|
162 |
+
}
|
163 |
+
}
|
164 |
+
} else {
|
165 |
+
if ( $item === '' ) {
|
166 |
+
$item = '(Empty)';
|
167 |
+
}
|
168 |
+
if ( empty( $raw_data[$item] ) ) {
|
169 |
+
$raw_data[$item] = count( $values );
|
170 |
+
} else {
|
171 |
+
$raw_data[$item] += count( $values );
|
172 |
+
}
|
173 |
+
}
|
174 |
+
}
|
175 |
+
$data[] = array( '', '' );
|
176 |
+
foreach ( $raw_data as $raw_data_key => $raw_data_value ) {
|
177 |
+
if ( $chart['chart'] === 'bar' ) {
|
178 |
+
$value = $raw_data_value / count( $form_posts );
|
179 |
+
} else {
|
180 |
+
$value = $raw_data_value;
|
181 |
+
}
|
182 |
+
$data[] = array(
|
183 |
+
$raw_data_key,
|
184 |
+
$value,
|
185 |
+
);
|
186 |
+
}
|
187 |
+
$chart_data[$postdata_key] = array(
|
188 |
+
'chart' => $chart['chart'],
|
189 |
+
'data' => $data,
|
190 |
+
);
|
191 |
+
}
|
192 |
+
?>
|
193 |
+
<script>
|
194 |
+
google.load( 'visualization', 1, { packages:['corechart'] } );
|
195 |
+
google.setOnLoadCallback( mwformDrawCharts );
|
196 |
+
function mwformDrawCharts() {
|
197 |
+
jQuery( function( $ ) {
|
198 |
+
<?php foreach ( $chart_data as $postdata_key => $chart ) : ?>
|
199 |
+
$( '.<?php echo esc_js( MWF_Config::NAME . '-chart-div-' . $postdata_key ); ?>' )
|
200 |
+
.mw_wp_form_google_chart( {
|
201 |
+
chart: <?php echo json_encode( $chart['chart'] ); ?>,
|
202 |
+
data : <?php echo json_encode( $chart['data'] ); ?>
|
203 |
+
} );
|
204 |
+
<?php endforeach; ?>
|
205 |
+
} );
|
206 |
+
}
|
207 |
+
</script>
|
208 |
+
<!-- end .wrap --></div>
|
209 |
+
<?php
|
210 |
+
}
|
211 |
+
}
|
classes/views/class.contact-data-list.php
ADDED
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Name : MW WP Form Contact Data List View
|
4 |
+
* Version : 1.0.0
|
5 |
+
* Author : Takashi Kitajima
|
6 |
+
* Author URI : http://2inc.org
|
7 |
+
* Created : January 2, 2015
|
8 |
+
* Modified :
|
9 |
+
* License : GPLv2
|
10 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
+
*/
|
12 |
+
class MW_WP_Form_Contact_Data_List_View extends MW_WP_Form_View {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* admin_print_styles_for_list
|
16 |
+
*/
|
17 |
+
public function admin_print_styles_for_list() {
|
18 |
+
?>
|
19 |
+
<style type="text/css">
|
20 |
+
#normal-sortables {
|
21 |
+
display: none;
|
22 |
+
}
|
23 |
+
</style>
|
24 |
+
<?php
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* csv_button
|
29 |
+
*/
|
30 |
+
public function csv_button() {
|
31 |
+
$action = $this->get( 'action' );
|
32 |
+
?>
|
33 |
+
<form id="mw-wp-form_csv" method="post" action="<?php echo esc_url( $action ); ?>">
|
34 |
+
<input type="submit" value="<?php esc_attr_e( 'CSV Download', MWF_Config::DOMAIN ); ?>" class="button-primary" />
|
35 |
+
|
36 |
+
|
37 |
+
<label><input type="checkbox" name="download-all" value="true" checked="checked" /> Download All</label>
|
38 |
+
<input type="hidden" name="<?php echo esc_attr( MWF_Config::NAME . '-csv-download' ); ?>" value="1" />
|
39 |
+
<?php wp_nonce_field( MWF_Config::NAME ); ?>
|
40 |
+
</form>
|
41 |
+
<?php
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* manage_posts_custom_column
|
46 |
+
*/
|
47 |
+
public function manage_posts_custom_column() {
|
48 |
+
$column = $this->get( 'column' );
|
49 |
+
$post_id = $this->get( 'post_id' );
|
50 |
+
$post = get_post( $post_id );
|
51 |
+
$post_custom_keys = $this->get( 'post_custom_keys' );
|
52 |
+
$Contact_Data_Setting = $this->get( 'Contact_Data_Setting' );
|
53 |
+
|
54 |
+
if ( $column === 'post_date' ) {
|
55 |
+
echo esc_html( $post->post_date );
|
56 |
+
}
|
57 |
+
elseif ( $column === 'response_status' ) {
|
58 |
+
$response_statuses = $Contact_Data_Setting->get_response_statuses();
|
59 |
+
$response_status = $Contact_Data_Setting->get( 'response_status' );
|
60 |
+
echo $response_statuses[$response_status];
|
61 |
+
}
|
62 |
+
elseif ( is_array( $post_custom_keys ) && in_array( $column, $post_custom_keys ) ) {
|
63 |
+
$post_meta = get_post_meta( $post_id, $column, true );
|
64 |
+
if ( $Contact_Data_Setting->is_upload_file_key( $post, $column ) ) {
|
65 |
+
echo $this->get_multimedia_data( $post_meta );
|
66 |
+
} elseif ( $post_meta ) {
|
67 |
+
echo esc_html( $post_meta );
|
68 |
+
} else {
|
69 |
+
echo ' ';
|
70 |
+
}
|
71 |
+
} else {
|
72 |
+
echo ' ';
|
73 |
+
}
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* get_multimedia_data
|
78 |
+
* @param string $value
|
79 |
+
* @return string
|
80 |
+
*/
|
81 |
+
protected function get_multimedia_data( $value ) {
|
82 |
+
$mimetype = get_post_mime_type( $value );
|
83 |
+
if ( $mimetype ) {
|
84 |
+
// 画像だったら
|
85 |
+
if ( preg_match( '/^image\/.+?$/', $mimetype ) ) {
|
86 |
+
$src = wp_get_attachment_image_src( $value, 'thumbnail' );
|
87 |
+
return sprintf(
|
88 |
+
'<img src="%s" alt="" style="width:50px;height:50px" />',
|
89 |
+
esc_url( $src[0] )
|
90 |
+
);
|
91 |
+
}
|
92 |
+
// 画像以外
|
93 |
+
else {
|
94 |
+
$src = wp_get_attachment_image_src( $value, 'none', true );
|
95 |
+
return sprintf(
|
96 |
+
'<a href="%s" target="_blank"><img src="%s" alt="" style="height:50px" /></a>',
|
97 |
+
esc_url( wp_get_attachment_url( $value ) ),
|
98 |
+
esc_url( $src[0] )
|
99 |
+
);
|
100 |
+
}
|
101 |
+
}
|
102 |
+
}
|
103 |
+
}
|
classes/views/class.contact-data.php
ADDED
@@ -0,0 +1,208 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Name : MW WP Form Contact Data View
|
4 |
+
* Version : 1.0.0
|
5 |
+
* Author : Takashi Kitajima
|
6 |
+
* Author URI : http://2inc.org
|
7 |
+
* Created : January 2, 2015
|
8 |
+
* Modified :
|
9 |
+
* License : GPLv2
|
10 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
+
*/
|
12 |
+
class MW_WP_Form_Contact_Data_View extends MW_WP_Form_View {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* admin_print_styles_for_detail
|
16 |
+
*/
|
17 |
+
public function admin_print_styles_for_detail() {
|
18 |
+
?>
|
19 |
+
<style type="text/css">
|
20 |
+
h2 a.add-new-h2 {
|
21 |
+
display: none;
|
22 |
+
}
|
23 |
+
</style>
|
24 |
+
<?php
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* index
|
29 |
+
*/
|
30 |
+
public function index() {
|
31 |
+
$contact_data_post_types = $this->get( 'contact_data_post_types' );
|
32 |
+
?>
|
33 |
+
<div class="wrap">
|
34 |
+
<h2><?php esc_html_e( 'Inquiry data', MWF_Config::DOMAIN ); ?></h2>
|
35 |
+
<p>
|
36 |
+
<?php esc_html_e( 'You can see the inquiry data that are saved in the database by clicking on the link below.', MWF_Config::DOMAIN ); ?>
|
37 |
+
</p>
|
38 |
+
<table class="wp-list-table widefat fixed" cellspacing="0">
|
39 |
+
<thead>
|
40 |
+
<th class="<?php echo MWF_Config::NAME; ?>-table-title"><?php esc_html_e( 'Form title', MWF_Config::DOMAIN ); ?></th>
|
41 |
+
<th class="<?php echo MWF_Config::NAME; ?>-table-chart"><?php esc_html_e( 'Display Chart', MWF_Config::DOMAIN ); ?></th>
|
42 |
+
<th class="<?php echo MWF_Config::NAME; ?>-table-count"><?php esc_html_e( 'The number of inquiries', MWF_Config::DOMAIN ); ?></th>
|
43 |
+
<th class="<?php echo MWF_Config::NAME; ?>-table-date"><?php esc_html_e( 'Updated date', MWF_Config::DOMAIN ); ?></th>
|
44 |
+
<th class="<?php echo MWF_Config::NAME; ?>-table-date"><?php esc_html_e( 'Created date', MWF_Config::DOMAIN ); ?></th>
|
45 |
+
</thead>
|
46 |
+
<tbody>
|
47 |
+
<?php $i = 0; foreach ( $contact_data_post_types as $post_type ) : $i ++; ?>
|
48 |
+
<?php $post_type_object = get_post_type_object( $post_type ); ?>
|
49 |
+
<tr <?php if ( $i % 2 == 1 ) echo 'class="alternate"'; ?>>
|
50 |
+
<td class="<?php echo MWF_Config::NAME; ?>-table-title"><?php echo esc_html( $post_type_object->labels->singular_name ) ; ?></td>
|
51 |
+
<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', MWF_Config::DOMAIN ); ?></td>
|
52 |
+
<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( $this->get_count( $post_type ) ) ?> <?php esc_html_e( 'cases', MWF_Config::DOMAIN ); ?></a></td>
|
53 |
+
<td class="<?php echo MWF_Config::NAME; ?>-table-date"><?php echo esc_html( $this->get_modified_datetime( $post_type ) ); ?></td>
|
54 |
+
<td class="<?php echo MWF_Config::NAME; ?>-table-date"><?php echo esc_html( $this->get_created_datetime( $post_type ) ); ?></td>
|
55 |
+
</tr>
|
56 |
+
<?php endforeach; ?>
|
57 |
+
</tbody>
|
58 |
+
</table>
|
59 |
+
<!-- end .wrap --></div>
|
60 |
+
<?php
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* detail
|
65 |
+
*/
|
66 |
+
public function detail() {
|
67 |
+
global $post;
|
68 |
+
$Contact_Data_Setting = $this->get( 'Contact_Data_Setting' );
|
69 |
+
$post_type = $this->get( 'post_type' );
|
70 |
+
?>
|
71 |
+
<table border="0" cellpadding="0" cellspacing="0">
|
72 |
+
<?php
|
73 |
+
$values = $Contact_Data_Setting->gets();
|
74 |
+
foreach ( $values as $key => $value ) :
|
75 |
+
if ( in_array( $key, $Contact_Data_Setting->get_permit_keys() ) ) {
|
76 |
+
continue;
|
77 |
+
}
|
78 |
+
?>
|
79 |
+
<tr>
|
80 |
+
<th>
|
81 |
+
<?php
|
82 |
+
if ( $key === MWF_Config::TRACKINGNUMBER ) {
|
83 |
+
echo MWF_Functions::get_tracking_number_title( $post_type );
|
84 |
+
} else {
|
85 |
+
echo esc_html( $key );
|
86 |
+
}
|
87 |
+
?>
|
88 |
+
</th>
|
89 |
+
<td>
|
90 |
+
<?php
|
91 |
+
if ( $Contact_Data_Setting->is_upload_file_key( $post, $key ) ) {
|
92 |
+
echo $this->get_multimedia_data( $value );
|
93 |
+
} else {
|
94 |
+
echo nl2br( esc_html( $value ) );
|
95 |
+
}
|
96 |
+
?>
|
97 |
+
</td>
|
98 |
+
</tr>
|
99 |
+
<?php endforeach; ?>
|
100 |
+
<tr>
|
101 |
+
<th><?php esc_html_e( 'Response Status', MWF_Config::DOMAIN ); ?></th>
|
102 |
+
<td>
|
103 |
+
<select name="<?php echo esc_attr( MWF_Config::CONTACT_DATA_NAME ); ?>[response_status]">
|
104 |
+
<?php foreach ( $Contact_Data_Setting->get_response_statuses() as $key => $value ) : ?>
|
105 |
+
<option value="<?php echo esc_attr( $key ); ?>" <?php selected( $key, $Contact_Data_Setting->get( 'response_status' ) ); ?>>
|
106 |
+
<?php echo esc_html( $value ); ?>
|
107 |
+
</option>
|
108 |
+
<?php endforeach; ?>
|
109 |
+
</select>
|
110 |
+
</td>
|
111 |
+
</tr>
|
112 |
+
<tr>
|
113 |
+
<th><?php esc_html_e( 'Memo', MWF_Config::DOMAIN ); ?></th>
|
114 |
+
<td><textarea name="<?php echo esc_attr( MWF_Config::CONTACT_DATA_NAME ); ?>[memo]" cols="50" rows="5"><?php echo $Contact_Data_Setting->get( 'memo' ); ?></textarea></td>
|
115 |
+
</tr>
|
116 |
+
</table>
|
117 |
+
<?php
|
118 |
+
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* returning_link
|
122 |
+
*/
|
123 |
+
public function returning_link() {
|
124 |
+
$link = $this->get( 'link' );
|
125 |
+
?>
|
126 |
+
<p>
|
127 |
+
<a href="<?php echo $link; ?>"><?php esc_html_e( '« Back to the list', MWF_Config::DOMAIN ); ?></a>
|
128 |
+
</p>
|
129 |
+
<?php
|
130 |
+
}
|
131 |
+
|
132 |
+
/**
|
133 |
+
* get_multimedia_data
|
134 |
+
* @param string $value
|
135 |
+
* @return string
|
136 |
+
*/
|
137 |
+
protected function get_multimedia_data( $value ) {
|
138 |
+
$mimetype = get_post_mime_type( $value );
|
139 |
+
if ( $mimetype ) {
|
140 |
+
// 画像だったら
|
141 |
+
if ( preg_match( '/^image\/.+?$/', $mimetype ) ) {
|
142 |
+
$src = wp_get_attachment_image_src( $value, 'medium' );
|
143 |
+
return sprintf(
|
144 |
+
'<img src="%s" alt="" />',
|
145 |
+
esc_url( $src[0] )
|
146 |
+
);
|
147 |
+
}
|
148 |
+
// 画像以外
|
149 |
+
else {
|
150 |
+
$src = wp_get_attachment_image_src( $value, 'none', true );
|
151 |
+
return sprintf(
|
152 |
+
'<a href="%s" target="_blank"><img src="%s" alt="" /></a>',
|
153 |
+
esc_url( wp_get_attachment_url( $value ) ),
|
154 |
+
esc_url( $src[0] )
|
155 |
+
);
|
156 |
+
}
|
157 |
+
}
|
158 |
+
}
|
159 |
+
|
160 |
+
/**
|
161 |
+
* get_count
|
162 |
+
* @param string $post_type 投稿タイプ名
|
163 |
+
* @return numeric 投稿数
|
164 |
+
*/
|
165 |
+
protected function get_count( $post_type ) {
|
166 |
+
$query = new WP_Query( array(
|
167 |
+
'post_type' => $post_type,
|
168 |
+
'posts_per_page' => 1,
|
169 |
+
) );
|
170 |
+
return $query->found_posts;
|
171 |
+
}
|
172 |
+
|
173 |
+
/**
|
174 |
+
* get_created_datetime
|
175 |
+
* フォームの作成日時を取得
|
176 |
+
* @param string $post_type 投稿タイプ名
|
177 |
+
* @return string 作成日
|
178 |
+
*/
|
179 |
+
protected function get_created_datetime( $post_type ) {
|
180 |
+
$post_id = preg_replace( '/^mwf_(.+?)$/', '$1', $post_type );
|
181 |
+
$post_date = get_the_date( get_option( 'date_format' ), $post_id );
|
182 |
+
return $post_date;
|
183 |
+
}
|
184 |
+
|
185 |
+
/**
|
186 |
+
* get_modified_datetime
|
187 |
+
* 問い合わせデータの最新保存日を取得
|
188 |
+
* @param string $post_type 投稿タイプ名
|
189 |
+
* @return string 問い合わせデータの最新保存日
|
190 |
+
*/
|
191 |
+
protected function get_modified_datetime( $post_type ) {
|
192 |
+
global $post;
|
193 |
+
$inquiry_posts = get_posts( array(
|
194 |
+
'post_type' => $post_type,
|
195 |
+
'posts_per_page' => 1,
|
196 |
+
'orderby' => 'modified',
|
197 |
+
) );
|
198 |
+
|
199 |
+
$modified_datetime = '';
|
200 |
+
foreach ( $inquiry_posts as $post ) {
|
201 |
+
setup_postdata( $post );
|
202 |
+
$modified_datetime = get_the_modified_date();
|
203 |
+
break;
|
204 |
+
}
|
205 |
+
wp_reset_postdata();
|
206 |
+
return $modified_datetime;
|
207 |
+
}
|
208 |
+
}
|
classes/views/class.main.php
ADDED
@@ -0,0 +1,319 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Name : MW WP Form Main View
|
4 |
+
* Version : 1.0.0
|
5 |
+
* Author : Takashi Kitajima
|
6 |
+
* Author URI : http://2inc.org
|
7 |
+
* Created : December 31, 2014
|
8 |
+
* Modified :
|
9 |
+
* License : GPLv2
|
10 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
+
*/
|
12 |
+
class MW_WP_Form_Main_View extends MW_WP_Form_View {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* add_shortcode_that_display_content
|
16 |
+
*/
|
17 |
+
public function add_shortcode_that_display_content() {
|
18 |
+
add_shortcode( 'mwform_formkey' , array( $this, 'mwform_formkey' ) );
|
19 |
+
add_shortcode( 'mwform' , array( $this, 'mwform' ) );
|
20 |
+
add_shortcode( 'mwform_complete_message', array( $this, 'mwform_complete_message' ) );
|
21 |
+
|
22 |
+
do_action(
|
23 |
+
'mwform_add_shortcode',
|
24 |
+
$this->get( 'Form' ),
|
25 |
+
$this->get( 'view_flg' ),
|
26 |
+
$this->get( 'Error' ),
|
27 |
+
$this->get( 'form_key' )
|
28 |
+
);
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* mwform_formkey
|
33 |
+
* 管理画面で作成したフォームを出力(実際の出力は mwform )
|
34 |
+
* @param array $attributes
|
35 |
+
* @return string html
|
36 |
+
* @example [mwform_formkey key="post_id"]
|
37 |
+
*/
|
38 |
+
public function mwform_formkey( $attributes ) {
|
39 |
+
$view_flg = $this->get( 'view_flg' );
|
40 |
+
$post_id = $attributes['key'];
|
41 |
+
|
42 |
+
// 入力画面
|
43 |
+
if ( $view_flg === 'input' ) {
|
44 |
+
$content = $this->get_input_page_content( $post_id );
|
45 |
+
}
|
46 |
+
// 確認画面
|
47 |
+
elseif ( $view_flg == 'confirm' ) {
|
48 |
+
$content = $this->get_confirm_page_content( $post_id );
|
49 |
+
}
|
50 |
+
// 完了画面
|
51 |
+
elseif ( $view_flg === 'complete' ) {
|
52 |
+
$content = $this->get_complete_page_content();
|
53 |
+
}
|
54 |
+
return do_shortcode( $content );
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* get_input_page_content
|
59 |
+
* @param int $post_id
|
60 |
+
* @return string $content
|
61 |
+
*/
|
62 |
+
protected function get_input_page_content( $post_id ) {
|
63 |
+
global $post;
|
64 |
+
$form_key = $this->get( 'form_key' );
|
65 |
+
$post = get_post( $post_id );
|
66 |
+
setup_postdata( $post );
|
67 |
+
$content = apply_filters( 'mwform_post_content_raw_' . $form_key, get_the_content() );
|
68 |
+
if ( has_filter( 'the_content', 'wpautop' ) ) {
|
69 |
+
$content = wpautop( $content );
|
70 |
+
}
|
71 |
+
$content = sprintf(
|
72 |
+
'[mwform]%s[/mwform]',
|
73 |
+
apply_filters( 'mwform_post_content_' . $form_key, $content )
|
74 |
+
);
|
75 |
+
wp_reset_postdata();
|
76 |
+
return $content;
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* get_confirm_page_content
|
81 |
+
* @param int $post_id
|
82 |
+
* @return string $content
|
83 |
+
*/
|
84 |
+
protected function get_confirm_page_content( $post_id ) {
|
85 |
+
return $this->get_input_page_content( $post_id );
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* get_complete_page_content
|
90 |
+
* @return string $content
|
91 |
+
*/
|
92 |
+
protected function get_complete_page_content() {
|
93 |
+
$Setting = $this->get( 'Setting' );
|
94 |
+
$content = $Setting->get( 'complete_message' );
|
95 |
+
if ( has_filter( 'the_content', 'wpautop' ) ) {
|
96 |
+
$content = wpautop( $content );
|
97 |
+
}
|
98 |
+
$content = sprintf(
|
99 |
+
'[mwform_complete_message]%s[/mwform_complete_message]',
|
100 |
+
$content
|
101 |
+
);
|
102 |
+
return $content;
|
103 |
+
}
|
104 |
+
|
105 |
+
/**
|
106 |
+
* mwform
|
107 |
+
* フォームを出力
|
108 |
+
* @param array $attributes
|
109 |
+
* @return string html
|
110 |
+
*/
|
111 |
+
public function mwform( $attributes, $content = '' ) {
|
112 |
+
$view_flg = $this->get( 'view_flg' );
|
113 |
+
$Form = $this->get( 'Form' );
|
114 |
+
$form_key = $this->get( 'form_key' );
|
115 |
+
|
116 |
+
if ( in_array( $view_flg, array( 'input', 'confirm' ) ) ) {
|
117 |
+
$content = $this->get_the_content( $content );
|
118 |
+
$upload_file_keys = $Form->get_raw( MWF_Config::UPLOAD_FILE_KEYS );
|
119 |
+
$upload_file_hidden = $this->get_upload_file_hidden( $upload_file_keys );
|
120 |
+
$old_confirm_class = $this->get_old_confirm_class( $view_flg );
|
121 |
+
$class_by_style = $this->get_class_by_style();
|
122 |
+
|
123 |
+
return sprintf(
|
124 |
+
'<div id="mw_wp_form_%s" class="mw_wp_form mw_wp_form_%s %s">
|
125 |
+
%s
|
126 |
+
<!-- end .mw_wp_form --></div>',
|
127 |
+
esc_attr( $form_key ),
|
128 |
+
esc_attr( $view_flg . ' ' . $old_confirm_class ),
|
129 |
+
$class_by_style,
|
130 |
+
$Form->start() . do_shortcode( $content ) . $upload_file_hidden . $Form->end()
|
131 |
+
);
|
132 |
+
}
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* mwform_complete_message
|
137 |
+
* 完了後のメッセージ
|
138 |
+
* @param array $attributes
|
139 |
+
* @return string html
|
140 |
+
*/
|
141 |
+
public function mwform_complete_message( $attributes, $content = '' ) {
|
142 |
+
$view_flg = $this->get( 'view_flg' );
|
143 |
+
$form_key = $this->get( 'form_key' );
|
144 |
+
if ( $view_flg === 'complete' ) {
|
145 |
+
return sprintf(
|
146 |
+
'<div id="mw_wp_form_%s" class="mw_wp_form mw_wp_form_%s">
|
147 |
+
%s
|
148 |
+
<!-- end .mw_wp_form --></div>',
|
149 |
+
esc_attr( $form_key ),
|
150 |
+
esc_attr( $view_flg ),
|
151 |
+
$content
|
152 |
+
);
|
153 |
+
}
|
154 |
+
}
|
155 |
+
|
156 |
+
/**
|
157 |
+
* replace_user_property
|
158 |
+
* ユーザーがログイン中の場合、{ユーザー情報のプロパティ}を置換する。
|
159 |
+
* @param string フォーム内容
|
160 |
+
* @return string フォーム内容
|
161 |
+
*/
|
162 |
+
protected function replace_user_property( $content ) {
|
163 |
+
$user = wp_get_current_user();
|
164 |
+
$search = array(
|
165 |
+
'{user_id}',
|
166 |
+
'{user_login}',
|
167 |
+
'{user_email}',
|
168 |
+
'{user_url}',
|
169 |
+
'{user_registered}',
|
170 |
+
'{display_name}',
|
171 |
+
);
|
172 |
+
if ( !empty( $user ) ) {
|
173 |
+
$content = str_replace( $search, array(
|
174 |
+
$user->get( 'ID' ),
|
175 |
+
$user->get( 'user_login' ),
|
176 |
+
$user->get( 'user_email' ),
|
177 |
+
$user->get( 'user_url' ),
|
178 |
+
$user->get( 'user_registered' ),
|
179 |
+
$user->get( 'display_name' ),
|
180 |
+
), $content );
|
181 |
+
} else {
|
182 |
+
$content = str_replace( $search, '', $content );
|
183 |
+
}
|
184 |
+
return $content;
|
185 |
+
}
|
186 |
+
|
187 |
+
/**
|
188 |
+
* replace_post_content
|
189 |
+
* {投稿情報($post->hoge)}を置換する。
|
190 |
+
* @param string フォーム内容
|
191 |
+
* @return string フォーム内容
|
192 |
+
*/
|
193 |
+
protected function replace_post_property( $content ) {
|
194 |
+
$Setting = $this->get( 'Setting' );
|
195 |
+
if ( $Setting->get( 'querystring' ) ) {
|
196 |
+
$content = preg_replace_callback(
|
197 |
+
'/{(.+?)}/',
|
198 |
+
array( $this, 'get_post_property_from_querystring' ),
|
199 |
+
$content
|
200 |
+
);
|
201 |
+
} else {
|
202 |
+
$content = preg_replace_callback(
|
203 |
+
'/{(.+?)}/',
|
204 |
+
array( $this, 'get_post_property_from_this' ),
|
205 |
+
$content
|
206 |
+
);
|
207 |
+
}
|
208 |
+
return $content;
|
209 |
+
}
|
210 |
+
|
211 |
+
/**
|
212 |
+
* get_post_property_from_querystring
|
213 |
+
* 引数 post_id が有効の場合、投稿情報を取得するために preg_replace_callback から呼び出される。
|
214 |
+
* @param array $matches
|
215 |
+
* @return string
|
216 |
+
*/
|
217 |
+
protected function get_post_property_from_querystring( $matches ) {
|
218 |
+
$Setting = $this->get( 'Setting' );
|
219 |
+
if ( $Setting->get( 'querystring' ) &&
|
220 |
+
isset( $_GET['post_id'] ) &&
|
221 |
+
MWF_Functions::is_numeric( $_GET['post_id'] ) ) {
|
222 |
+
|
223 |
+
$post = get_post( $_GET['post_id'] );
|
224 |
+
if ( empty( $post->ID ) ) {
|
225 |
+
return;
|
226 |
+
}
|
227 |
+
if ( isset( $post->$matches[1] ) ) {
|
228 |
+
return $post->$matches[1];
|
229 |
+
} else {
|
230 |
+
// post_meta の処理
|
231 |
+
$pm = get_post_meta( $post->ID, $matches[1], true );
|
232 |
+
if ( !empty( $pm ) ) {
|
233 |
+
return $pm;
|
234 |
+
}
|
235 |
+
}
|
236 |
+
}
|
237 |
+
}
|
238 |
+
|
239 |
+
/**
|
240 |
+
* get_post_property_from_this
|
241 |
+
* 引数 post_id が無効の場合、投稿情報を取得するために preg_replace_callback から呼び出される。
|
242 |
+
* @param array $matches
|
243 |
+
* @return string
|
244 |
+
*/
|
245 |
+
protected function get_post_property_from_this( $matches ) {
|
246 |
+
global $post;
|
247 |
+
if ( !is_singular() ) {
|
248 |
+
return;
|
249 |
+
}
|
250 |
+
if ( isset( $post->ID ) && MWF_Functions::is_numeric( $post->ID ) ) {
|
251 |
+
if ( isset( $post->$matches[1] ) ) {
|
252 |
+
return $post->$matches[1];
|
253 |
+
} else {
|
254 |
+
// post_meta の処理
|
255 |
+
$pm = get_post_meta( $post->ID, $matches[1], true );
|
256 |
+
if ( !empty( $pm ) ) {
|
257 |
+
return $pm;
|
258 |
+
}
|
259 |
+
}
|
260 |
+
}
|
261 |
+
}
|
262 |
+
|
263 |
+
/**
|
264 |
+
* get_the_content
|
265 |
+
* フォームのコンテンツを整形して返す
|
266 |
+
* @param string $content
|
267 |
+
* @return string $content
|
268 |
+
*/
|
269 |
+
protected function get_the_content( $content ) {
|
270 |
+
$content = $this->replace_user_property( $content );
|
271 |
+
$content = $this->replace_post_property( $content );
|
272 |
+
return $content;
|
273 |
+
}
|
274 |
+
|
275 |
+
/**
|
276 |
+
* get_upload_file_hidden
|
277 |
+
* @param array|'' $upload_file_keys
|
278 |
+
*/
|
279 |
+
protected function get_upload_file_hidden( $upload_file_keys ) {
|
280 |
+
$Form = $this->get( 'Form' );
|
281 |
+
$upload_file_hidden = '';
|
282 |
+
if ( !is_array( $upload_file_keys ) ) {
|
283 |
+
return $upload_file_hidden;
|
284 |
+
}
|
285 |
+
foreach ( $upload_file_keys as $value ) {
|
286 |
+
$upload_file_hidden .= $Form->hidden( MWF_Config::UPLOAD_FILE_KEYS . '[]', $value );
|
287 |
+
}
|
288 |
+
return $upload_file_hidden;
|
289 |
+
}
|
290 |
+
|
291 |
+
/**
|
292 |
+
* get_old_confirm_class
|
293 |
+
* 下位互換性のための class を付与
|
294 |
+
* @param string $view_flg
|
295 |
+
* @return string mw_wp_form_preview
|
296 |
+
*/
|
297 |
+
protected function get_old_confirm_class( $view_flg ) {
|
298 |
+
$old_confirm_class = '';
|
299 |
+
if ( $view_flg === 'confirm' ) {
|
300 |
+
$old_confirm_class = 'mw_wp_form_preview';
|
301 |
+
}
|
302 |
+
return $old_confirm_class;
|
303 |
+
}
|
304 |
+
|
305 |
+
/**
|
306 |
+
* get_class_by_style
|
307 |
+
* スタイル機能用の class を付与
|
308 |
+
* @return string
|
309 |
+
*/
|
310 |
+
protected function get_class_by_style() {
|
311 |
+
$Setting = $this->get( 'Setting' );
|
312 |
+
$style = $Setting->get( 'style' );
|
313 |
+
$class_by_style = '';
|
314 |
+
if ( $style ) {
|
315 |
+
$class_by_style = 'mw_wp_form_' . $style;
|
316 |
+
}
|
317 |
+
return $class_by_style;
|
318 |
+
}
|
319 |
+
}
|
classes/views/class.view.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Name : MW WP Form View
|
4 |
+
* Version : 1.0.0
|
5 |
+
* Author : Takashi Kitajima
|
6 |
+
* Author URI : http://2inc.org
|
7 |
+
* Created : January 2, 2015
|
8 |
+
* Modified :
|
9 |
+
* License : GPLv2
|
10 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
+
*/
|
12 |
+
class MW_WP_Form_View {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* $variables
|
16 |
+
* @var array
|
17 |
+
*/
|
18 |
+
protected $variables = array();
|
19 |
+
|
20 |
+
/**
|
21 |
+
* set
|
22 |
+
* @param string $key
|
23 |
+
* @param mixed $value
|
24 |
+
*/
|
25 |
+
public function set( $key, $value ) {
|
26 |
+
$this->variables[$key] = $value;
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* get
|
31 |
+
* @param string $key
|
32 |
+
* @return mixed
|
33 |
+
*/
|
34 |
+
public function get( $key ) {
|
35 |
+
if ( isset( $this->variables[$key] ) ) {
|
36 |
+
return $this->variables[$key];
|
37 |
+
}
|
38 |
+
}
|
39 |
+
}
|
css/admin.css
CHANGED
@@ -54,6 +54,13 @@
|
|
54 |
bottom: 0;
|
55 |
}
|
56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
/**
|
58 |
* フォーム識別子
|
59 |
*/
|
@@ -406,7 +413,7 @@ span#formkey_field {
|
|
406 |
* .column-mwform_form_key
|
407 |
*/
|
408 |
.fixed .column-title {
|
409 |
-
width:
|
410 |
}
|
411 |
.fixed .column-mwform_form_key {
|
412 |
width: 30%;
|
54 |
bottom: 0;
|
55 |
}
|
56 |
|
57 |
+
/**
|
58 |
+
* #mw-wp-form_addon
|
59 |
+
*/
|
60 |
+
#mw-wp-form_addon .button {
|
61 |
+
margin-top: 5px;
|
62 |
+
}
|
63 |
+
|
64 |
/**
|
65 |
* フォーム識別子
|
66 |
*/
|
413 |
* .column-mwform_form_key
|
414 |
*/
|
415 |
.fixed .column-title {
|
416 |
+
width: 30%;
|
417 |
}
|
418 |
.fixed .column-mwform_form_key {
|
419 |
width: 30%;
|
form_fields/mw_form_field_akismet_error.php
DELETED
@@ -1,64 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Name: MW Form Field Akismet Error
|
4 |
-
* Description: Akismetのエラーを出力。
|
5 |
-
* Version: 1.3.4
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created : June 21, 2013
|
9 |
-
* Modified: November 2, 2014
|
10 |
-
* License: GPLv2
|
11 |
-
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
-
*/
|
13 |
-
class MW_Form_Field_Akismet_Error extends MW_Form_Field {
|
14 |
-
|
15 |
-
/**
|
16 |
-
* string $type フォームタグの種類
|
17 |
-
* input, select, button, error, other
|
18 |
-
*/
|
19 |
-
public $type = 'error';
|
20 |
-
|
21 |
-
/**
|
22 |
-
* set_names
|
23 |
-
* shortcode_name、display_nameを定義。各子クラスで上書きする。
|
24 |
-
* @return array shortcode_name, display_name
|
25 |
-
*/
|
26 |
-
protected function set_names() {
|
27 |
-
return array(
|
28 |
-
'shortcode_name' => 'mwform_akismet_error',
|
29 |
-
'display_name' => __( 'Akismet Error', MWF_Config::DOMAIN ),
|
30 |
-
);
|
31 |
-
}
|
32 |
-
|
33 |
-
/**
|
34 |
-
* setDefaults
|
35 |
-
* $this->defaultsを設定し返す
|
36 |
-
* @return array defaults
|
37 |
-
*/
|
38 |
-
protected function setDefaults() {
|
39 |
-
return array();
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* inputPage
|
44 |
-
* 入力ページでのフォーム項目を返す
|
45 |
-
* @return string HTML
|
46 |
-
*/
|
47 |
-
protected function inputPage() {
|
48 |
-
$error = $this->getError( MWF_Config::AKISMET );
|
49 |
-
if ( $error ) {
|
50 |
-
return sprintf(
|
51 |
-
'<span class="akismet_error">%s</span>',
|
52 |
-
$this->getError( MWF_Config::AKISMET )
|
53 |
-
);
|
54 |
-
}
|
55 |
-
}
|
56 |
-
|
57 |
-
/**
|
58 |
-
* confirmPage
|
59 |
-
* 確認ページでのフォーム項目を返す
|
60 |
-
* @return string HTML
|
61 |
-
*/
|
62 |
-
protected function confirmPage() {
|
63 |
-
}
|
64 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 2.
|
6 |
"Report-Msgid-Bugs-To: http://wordpress.org/tag/mw-wp-form\n"
|
7 |
-
"POT-Creation-Date:
|
8 |
-
"PO-Revision-Date:
|
9 |
"Last-Translator: Takashi Kitajima <inc@2inc.org>\n"
|
10 |
"Language-Team: Takashi Kitajima <inc@2inc.org>\n"
|
11 |
"Language: ja\n"
|
@@ -15,365 +15,540 @@ msgstr ""
|
|
15 |
"Plural-Forms: nplurals=1; plural=0;\n"
|
16 |
"X-Poedit-SourceCharset: UTF-8\n"
|
17 |
"X-Poedit-Basepath: .\n"
|
18 |
-
"X-Generator: Poedit 1.
|
19 |
"X-Poedit-KeywordsList: __;_e;_x;esc_html_e;esc_html__\n"
|
20 |
"X-Poedit-SearchPath-0: ..\n"
|
21 |
|
22 |
-
#:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
msgid "Akismet Error"
|
24 |
msgstr "Akismetエラー"
|
25 |
|
26 |
-
#:
|
27 |
-
#:
|
28 |
msgid "Back"
|
29 |
msgstr "戻る"
|
30 |
|
31 |
-
#:
|
32 |
-
#:
|
33 |
-
#:
|
34 |
-
#:
|
35 |
msgid "String on the button"
|
36 |
msgstr "ボタンに表示する文字列"
|
37 |
|
38 |
-
#:
|
39 |
msgid "Button"
|
40 |
msgstr "ボタン"
|
41 |
|
42 |
-
#:
|
43 |
msgid "Checkbox"
|
44 |
msgstr "チェックボックス"
|
45 |
|
46 |
-
#:
|
47 |
-
#:
|
48 |
-
#:
|
49 |
msgid "Choices"
|
50 |
msgstr "選択肢"
|
51 |
|
52 |
-
#:
|
53 |
-
#:
|
54 |
-
#:
|
55 |
-
#:
|
56 |
msgid "Input one line about one item."
|
57 |
msgstr "1項目につき1行で入力してください。"
|
58 |
|
59 |
-
#:
|
60 |
-
#:
|
61 |
-
#:
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
#:
|
66 |
-
#:
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
msgid "Default value"
|
68 |
msgstr "初期値"
|
69 |
|
70 |
-
#:
|
71 |
msgid "Separator string"
|
72 |
msgstr "区切り文字"
|
73 |
|
74 |
-
#:
|
75 |
-
#:
|
76 |
msgid "Display method"
|
77 |
msgstr "表示方法"
|
78 |
|
79 |
-
#:
|
80 |
-
#:
|
81 |
msgid "Arranged vertically."
|
82 |
msgstr "垂直に配置する"
|
83 |
|
84 |
-
#:
|
85 |
-
#:
|
86 |
-
#:
|
87 |
-
#:
|
88 |
-
#:
|
89 |
-
#:
|
90 |
-
#:
|
91 |
-
#:
|
92 |
-
#:
|
93 |
-
#:
|
94 |
msgid "Dsiplay error"
|
95 |
msgstr "エラー表示"
|
96 |
|
97 |
-
#:
|
98 |
-
#:
|
99 |
-
#:
|
100 |
-
#:
|
101 |
-
#:
|
102 |
-
#:
|
103 |
-
#:
|
104 |
-
#:
|
105 |
-
#:
|
106 |
-
#:
|
107 |
msgid "Don't display error."
|
108 |
msgstr "エラーを表示しない"
|
109 |
|
110 |
-
#:
|
111 |
msgid "Confirm Button"
|
112 |
msgstr "確認ボタン"
|
113 |
|
114 |
-
#:
|
115 |
-
#:
|
116 |
msgid "Confirm"
|
117 |
msgstr "確認画面へ"
|
118 |
|
119 |
-
#:
|
120 |
msgid "Datepicker"
|
121 |
msgstr "日付"
|
122 |
|
123 |
-
#:
|
124 |
msgid "Error Message"
|
125 |
msgstr "エラーメッセージ"
|
126 |
|
127 |
-
#:
|
128 |
msgid "name of the element which wants to display error"
|
129 |
msgstr "エラーを表示したい要素のname属性"
|
130 |
|
131 |
-
#:
|
132 |
msgid "File"
|
133 |
msgstr "ファイルフィールド"
|
134 |
|
135 |
-
#:
|
136 |
msgid "Uploaded."
|
137 |
msgstr "アップロードしました。"
|
138 |
|
139 |
-
#:
|
140 |
msgid "Hidden"
|
141 |
msgstr "hiddenフィールド"
|
142 |
|
143 |
-
#:
|
144 |
msgid "Display"
|
145 |
msgstr "表示する"
|
146 |
|
147 |
-
#:
|
148 |
msgid "Display hidden value."
|
149 |
msgstr "hiddenの値を表示"
|
150 |
|
151 |
-
#:
|
152 |
msgid "Image"
|
153 |
msgstr "画像フィールド"
|
154 |
|
155 |
-
#:
|
156 |
msgid "Password"
|
157 |
msgstr "パスワードフィールド"
|
158 |
|
159 |
-
#:
|
160 |
msgid "Radio"
|
161 |
msgstr "ラジオボタン"
|
162 |
|
163 |
-
#:
|
164 |
msgid "Select"
|
165 |
msgstr "セレクトボックス"
|
166 |
|
167 |
-
#:
|
168 |
-
msgid "Submit
|
169 |
-
msgstr "
|
170 |
|
171 |
-
#:
|
172 |
-
#:
|
173 |
msgid "Send"
|
174 |
msgstr "送信する"
|
175 |
|
176 |
-
#:
|
177 |
-
msgid "Confirm & Submit"
|
178 |
-
msgstr "確認・送信"
|
179 |
-
|
180 |
-
#: form_fields/mw_form_field_submit_button.php:79
|
181 |
msgid "String on the confirm button"
|
182 |
msgstr "確認ボタンに表示する文字列"
|
183 |
|
184 |
-
#:
|
185 |
msgid "String on the submit button"
|
186 |
msgstr "送信ボタンに表示する文字列"
|
187 |
|
188 |
-
#:
|
189 |
-
|
|
|
|
|
|
|
|
|
190 |
msgid "Tel"
|
191 |
msgstr "電話番号"
|
192 |
|
193 |
-
#:
|
194 |
-
#:
|
195 |
msgid "Convert half alphanumeric"
|
196 |
msgstr "半角英数字に変換"
|
197 |
|
198 |
-
#:
|
199 |
msgid "Don't Convert."
|
200 |
msgstr "変換しない"
|
201 |
|
202 |
-
#:
|
203 |
msgid "Text"
|
204 |
msgstr "テキストフィールド"
|
205 |
|
206 |
-
#:
|
207 |
msgid "Convert."
|
208 |
msgstr "変換する"
|
209 |
|
210 |
-
#:
|
211 |
msgid "Textarea"
|
212 |
msgstr "テキストエリア"
|
213 |
|
214 |
-
#:
|
215 |
-
#:
|
216 |
msgid "Zip Code"
|
217 |
msgstr "郵便番号"
|
218 |
|
219 |
-
#:
|
220 |
-
msgid "
|
221 |
-
msgstr ""
|
222 |
|
223 |
-
#:
|
224 |
msgid "Tracking Number"
|
225 |
msgstr "問い合わせ番号"
|
226 |
|
227 |
-
#:
|
228 |
-
msgid "
|
229 |
-
msgstr "
|
230 |
|
231 |
-
#:
|
232 |
-
msgid "
|
233 |
-
msgstr "
|
234 |
|
235 |
-
#:
|
236 |
-
msgid "
|
237 |
-
msgstr "
|
238 |
|
239 |
-
#:
|
240 |
-
msgid "
|
241 |
-
msgstr "
|
242 |
|
243 |
-
#:
|
244 |
-
msgid "
|
245 |
-
msgstr "
|
246 |
|
247 |
-
#:
|
248 |
-
msgid "
|
249 |
-
msgstr "
|
250 |
|
251 |
-
#:
|
252 |
-
msgid "
|
253 |
-
msgstr "
|
254 |
|
255 |
-
#:
|
256 |
-
msgid "
|
257 |
-
msgstr "
|
258 |
|
259 |
-
#:
|
260 |
-
msgid "
|
261 |
-
msgstr "
|
262 |
|
263 |
-
#:
|
264 |
-
msgid "
|
265 |
-
msgstr "
|
266 |
|
267 |
-
#:
|
268 |
-
msgid "
|
269 |
-
msgstr "
|
270 |
|
271 |
-
#:
|
272 |
-
msgid "
|
273 |
-
msgstr "
|
274 |
|
275 |
-
#:
|
276 |
-
msgid "
|
277 |
-
msgstr "
|
278 |
|
279 |
-
#:
|
280 |
-
msgid "
|
281 |
-
msgstr "
|
282 |
|
283 |
-
#:
|
284 |
-
msgid "
|
285 |
-
msgstr "
|
286 |
|
287 |
-
#:
|
288 |
-
msgid "
|
289 |
-
msgstr "
|
290 |
|
291 |
-
#:
|
292 |
-
msgid "
|
293 |
-
msgstr "
|
294 |
|
295 |
-
#:
|
296 |
-
msgid "
|
297 |
-
msgstr "
|
298 |
|
299 |
-
#:
|
300 |
-
msgid "
|
301 |
-
msgstr "
|
302 |
|
303 |
-
#:
|
304 |
-
msgid "
|
305 |
-
msgstr "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
306 |
|
307 |
-
#:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
308 |
msgid ""
|
309 |
-
"
|
310 |
-
"
|
311 |
msgstr ""
|
312 |
-
"
|
313 |
-
"
|
314 |
-
"す。"
|
315 |
|
316 |
-
#:
|
317 |
-
msgid "
|
318 |
-
msgstr "
|
319 |
|
320 |
-
#:
|
321 |
-
msgid "
|
322 |
-
msgstr "
|
323 |
|
324 |
-
#:
|
325 |
-
msgid "
|
326 |
-
msgstr "
|
327 |
|
328 |
-
#:
|
329 |
-
msgid "
|
330 |
-
msgstr "
|
331 |
|
332 |
-
#:
|
333 |
-
msgid "
|
334 |
-
msgstr "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
335 |
|
336 |
-
#:
|
337 |
msgid "{key} is converted form data."
|
338 |
msgstr "{キー}でそのフォーム項目に変換されます。"
|
339 |
|
340 |
-
#:
|
341 |
msgid "It is automatically converted to Tracking number when you input {%s}."
|
342 |
msgstr "{%s} と入力すると問い合わせ番号に自動的に変換されます。"
|
343 |
|
344 |
-
#:
|
345 |
msgid "Subject"
|
346 |
msgstr "件名"
|
347 |
|
348 |
-
#:
|
349 |
msgid "Sender"
|
350 |
msgstr "送信者"
|
351 |
|
352 |
-
#:
|
353 |
-
#:
|
354 |
-
#:
|
355 |
msgid "If empty:"
|
356 |
msgstr "未入力の場合:"
|
357 |
|
358 |
-
#:
|
359 |
msgid "From ( E-mail address )"
|
360 |
msgstr "送信元(E-mailアドレス)"
|
361 |
|
362 |
-
#:
|
363 |
msgid "Content"
|
364 |
msgstr "本文"
|
365 |
|
366 |
-
#:
|
367 |
msgid "Automatic reply email"
|
368 |
msgstr "自動返信メール"
|
369 |
|
370 |
-
#:
|
371 |
msgid ""
|
372 |
"Input the key to use as transmission to automatic reply email. {} is "
|
373 |
"unnecessary."
|
374 |
msgstr "自動返信メールに使用する項目のキーを入力してください。{ }は不要です。"
|
375 |
|
376 |
-
#:
|
377 |
msgid ""
|
378 |
"If Admin Email Options is a blank, Automatic Replay Email Options is used as "
|
379 |
"Admin Email Options."
|
@@ -381,187 +556,127 @@ msgstr ""
|
|
381 |
"管理者宛メール設定が空のときは自動返信メール設定に管理者宛メール設定が使用さ"
|
382 |
"れます。"
|
383 |
|
384 |
-
#:
|
385 |
msgid "To ( E-mail address )"
|
386 |
msgstr "送信先(E-mailアドレス)"
|
387 |
|
388 |
-
#:
|
389 |
msgid "CC ( E-mail address )"
|
390 |
msgstr "CC(E-mailアドレス)"
|
391 |
|
392 |
-
#:
|
393 |
msgid "BCC ( E-mail address )"
|
394 |
msgstr "BCC(E-mailアドレス)"
|
395 |
|
396 |
-
#:
|
397 |
-
msgid "
|
398 |
-
msgstr "
|
399 |
-
|
400 |
-
#: system/mw_wp_form_admin_page.php:470
|
401 |
-
msgid "Confirmation Page URL"
|
402 |
-
msgstr "確認画面URL"
|
403 |
-
|
404 |
-
#: system/mw_wp_form_admin_page.php:476
|
405 |
-
msgid "Complete Page URL"
|
406 |
-
msgstr "完了画面URL"
|
407 |
-
|
408 |
-
#: system/mw_wp_form_admin_page.php:482
|
409 |
-
msgid "Validation Error Page URL"
|
410 |
-
msgstr "エラー画面URL"
|
411 |
|
412 |
-
#:
|
413 |
msgid ""
|
414 |
-
"
|
415 |
-
"
|
416 |
msgstr ""
|
417 |
-
"
|
418 |
-
"
|
|
|
419 |
|
420 |
-
#:
|
421 |
-
msgid "
|
422 |
-
msgstr "
|
423 |
|
424 |
-
#:
|
425 |
-
msgid "
|
426 |
-
msgstr "
|
427 |
|
428 |
-
#:
|
429 |
-
msgid "
|
430 |
-
msgstr "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
431 |
|
432 |
-
#:
|
433 |
msgid "Select Style"
|
434 |
msgstr "スタイルを選択"
|
435 |
|
436 |
-
#:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
437 |
msgid "Select this."
|
438 |
msgstr "選択してください"
|
439 |
|
440 |
-
#:
|
441 |
msgid "Input fields"
|
442 |
msgstr "入力項目"
|
443 |
|
444 |
-
#:
|
445 |
msgid "Select fields"
|
446 |
msgstr "選択項目"
|
447 |
|
448 |
-
#:
|
449 |
msgid "Button fields"
|
450 |
msgstr "ボタン項目"
|
451 |
|
452 |
-
#:
|
453 |
msgid "Error fields"
|
454 |
msgstr "エラー項目"
|
455 |
|
456 |
-
#:
|
457 |
msgid "Other fields"
|
458 |
msgstr "その他の項目"
|
459 |
|
460 |
-
#:
|
461 |
msgid "Add form tag"
|
462 |
msgstr "フォームタグを追加"
|
463 |
|
464 |
-
#:
|
465 |
-
#: system/mw_wp_form_chart_page.php:155
|
466 |
-
msgid "Chart"
|
467 |
-
msgstr "グラフ"
|
468 |
-
|
469 |
-
#: system/mw_wp_form_chart_page.php:163
|
470 |
msgid "Add Chart"
|
471 |
msgstr "グラフを追加"
|
472 |
|
473 |
-
#:
|
474 |
msgid "Item that create chart"
|
475 |
msgstr "グラフを作成する項目"
|
476 |
|
477 |
-
#:
|
478 |
msgid "Chart type"
|
479 |
msgstr "グラフの種類"
|
480 |
|
481 |
-
#:
|
482 |
msgid "Pie chart"
|
483 |
msgstr "円グラフ"
|
484 |
|
485 |
-
#:
|
486 |
msgid "Bar chart"
|
487 |
msgstr "棒グラフ"
|
488 |
|
489 |
-
#:
|
490 |
msgid ""
|
491 |
"Separator string (If the check box. If the separator attribute is not set to "
|
492 |
"\",\")"
|
493 |
msgstr ""
|
494 |
"区切り文字(チェックボックスの場合。separator 属性が未設定の場合は「,」)"
|
495 |
|
496 |
-
#:
|
497 |
-
#: system/mw_wp_form_contact_data_page.php:491
|
498 |
msgid "The number of inquiries"
|
499 |
msgstr "問い合わせ件数"
|
500 |
|
501 |
-
#:
|
502 |
-
msgid "Not supported"
|
503 |
-
msgstr "未対応"
|
504 |
-
|
505 |
-
#: system/mw_wp_form_contact_data_page.php:54
|
506 |
-
msgid "Reservation"
|
507 |
-
msgstr "保留"
|
508 |
-
|
509 |
-
#: system/mw_wp_form_contact_data_page.php:55
|
510 |
-
msgid "Supported"
|
511 |
-
msgstr "対応済み"
|
512 |
-
|
513 |
-
#: system/mw_wp_form_contact_data_page.php:117
|
514 |
-
msgid "Edit "
|
515 |
-
msgstr "編集"
|
516 |
-
|
517 |
-
#: system/mw_wp_form_contact_data_page.php:118
|
518 |
-
msgid "View"
|
519 |
-
msgstr "表示"
|
520 |
-
|
521 |
-
#: system/mw_wp_form_contact_data_page.php:119
|
522 |
-
msgid "Search"
|
523 |
-
msgstr "検索"
|
524 |
-
|
525 |
-
#: system/mw_wp_form_contact_data_page.php:120
|
526 |
-
msgid "No data found"
|
527 |
-
msgstr "データがありません"
|
528 |
-
|
529 |
-
#: system/mw_wp_form_contact_data_page.php:121
|
530 |
-
msgid "No data found in Trash"
|
531 |
-
msgstr "ゴミ箱にデータはありません"
|
532 |
-
|
533 |
-
#: system/mw_wp_form_contact_data_page.php:165
|
534 |
msgid "CSV Download"
|
535 |
msgstr "CSVダウンロード"
|
536 |
|
537 |
-
#:
|
538 |
-
#: system/mw_wp_form_contact_data_page.php:230
|
539 |
-
#: system/mw_wp_form_contact_data_page.php:313
|
540 |
-
#: system/mw_wp_form_contact_data_page.php:410
|
541 |
-
msgid "Response Status"
|
542 |
-
msgstr "対応状況"
|
543 |
-
|
544 |
-
#: system/mw_wp_form_contact_data_page.php:221
|
545 |
-
#: system/mw_wp_form_contact_data_page.php:232
|
546 |
-
#: system/mw_wp_form_contact_data_page.php:422
|
547 |
-
msgid "Memo"
|
548 |
-
msgstr "メモ"
|
549 |
-
|
550 |
-
#: system/mw_wp_form_contact_data_page.php:288
|
551 |
-
msgid "Custom Fields"
|
552 |
-
msgstr "カスタムフィールド"
|
553 |
-
|
554 |
-
#: system/mw_wp_form_contact_data_page.php:312
|
555 |
-
msgid "Registed Date"
|
556 |
-
msgstr "登録日時"
|
557 |
-
|
558 |
-
#: system/mw_wp_form_contact_data_page.php:468
|
559 |
-
#: system/mw_wp_form_contact_data_page.php:469
|
560 |
-
#: system/mw_wp_form_contact_data_page.php:483
|
561 |
-
msgid "Inquiry data"
|
562 |
-
msgstr "問い合わせデータ"
|
563 |
-
|
564 |
-
#: system/mw_wp_form_contact_data_page.php:485
|
565 |
msgid ""
|
566 |
"You can see the inquiry data that are saved in the database by clicking on "
|
567 |
"the link below."
|
@@ -569,179 +684,78 @@ msgstr ""
|
|
569 |
"リンクをクリックすることでデータベースに保存された問い合わせデータを見ること"
|
570 |
"ができます。"
|
571 |
|
572 |
-
#:
|
573 |
msgid "Form title"
|
574 |
msgstr "フォーム名"
|
575 |
|
576 |
-
#:
|
577 |
-
#:
|
578 |
msgid "Display Chart"
|
579 |
msgstr "グラフを表示"
|
580 |
|
581 |
-
#:
|
582 |
msgid "Updated date"
|
583 |
msgstr "更新日"
|
584 |
|
585 |
-
#:
|
586 |
msgid "Created date"
|
587 |
msgstr "作成日"
|
588 |
|
589 |
-
#:
|
590 |
msgid "cases"
|
591 |
msgstr "件"
|
592 |
|
593 |
-
#:
|
594 |
msgid "« Back to the list"
|
595 |
msgstr "« 一覧に戻る"
|
596 |
|
597 |
-
#:
|
598 |
-
msgid "
|
599 |
-
msgstr "
|
600 |
-
|
601 |
-
#: validation_rules/mw_validation_rule_akismet.php:28
|
602 |
-
msgid "The contents which you input were judged with spam."
|
603 |
-
msgstr "あなたの入力した内容はスパムと判定されました。"
|
604 |
-
|
605 |
-
#: validation_rules/mw_validation_rule_alpha.php:31
|
606 |
-
msgid "Please enter with a half-width alphabetic character."
|
607 |
-
msgstr "半角英字で入力してください。"
|
608 |
-
|
609 |
-
#: validation_rules/mw_validation_rule_alpha.php:46
|
610 |
-
msgid "Alphabet"
|
611 |
-
msgstr "半角英字"
|
612 |
-
|
613 |
-
#: validation_rules/mw_validation_rule_alphanumeric.php:31
|
614 |
-
msgid "Please enter with a half-width alphanumeric character."
|
615 |
-
msgstr "半角英数字で入力してください。"
|
616 |
-
|
617 |
-
#: validation_rules/mw_validation_rule_alphanumeric.php:46
|
618 |
-
msgid "Alphabet and Numeric"
|
619 |
-
msgstr "半角英数字"
|
620 |
-
|
621 |
-
#: validation_rules/mw_validation_rule_between.php:32
|
622 |
-
msgid "The number of characters is invalid."
|
623 |
-
msgstr "文字数が正しくありません。"
|
624 |
-
|
625 |
-
#: validation_rules/mw_validation_rule_between.php:73
|
626 |
-
msgid "The range of the number of characters"
|
627 |
-
msgstr "文字数の範囲"
|
628 |
-
|
629 |
-
#: validation_rules/mw_validation_rule_date.php:30
|
630 |
-
msgid "This is not the format of a date."
|
631 |
-
msgstr "日付の形式ではありません。"
|
632 |
-
|
633 |
-
#: validation_rules/mw_validation_rule_date.php:51
|
634 |
-
msgid "Date"
|
635 |
-
msgstr "日付"
|
636 |
-
|
637 |
-
#: validation_rules/mw_validation_rule_eq.php:31
|
638 |
-
msgid "This is not in agreement."
|
639 |
-
msgstr "一致しません。"
|
640 |
-
|
641 |
-
#: validation_rules/mw_validation_rule_eq.php:54
|
642 |
-
msgid "The key at same value"
|
643 |
-
msgstr "一致する項目"
|
644 |
-
|
645 |
-
#: validation_rules/mw_validation_rule_filesize.php:33
|
646 |
-
msgid "This file size is too big."
|
647 |
-
msgstr "ファイルサイズが大きすぎます。"
|
648 |
-
|
649 |
-
#: validation_rules/mw_validation_rule_filesize.php:56
|
650 |
-
msgid "Permitted file size"
|
651 |
-
msgstr "サイズ制限"
|
652 |
-
|
653 |
-
#: validation_rules/mw_validation_rule_filesize.php:57
|
654 |
-
msgid "bytes"
|
655 |
-
msgstr "バイト"
|
656 |
-
|
657 |
-
#: validation_rules/mw_validation_rule_filetype.php:31
|
658 |
-
msgid "This file is invalid."
|
659 |
-
msgstr "許可されたファイルではありません。"
|
660 |
-
|
661 |
-
#: validation_rules/mw_validation_rule_filetype.php:59
|
662 |
-
msgid "Permitted Extension"
|
663 |
-
msgstr "拡張子制限"
|
664 |
-
|
665 |
-
#: validation_rules/mw_validation_rule_filetype.php:60
|
666 |
-
msgid "Example:jpg or jpg,txt,…"
|
667 |
-
msgstr "例:jpg もしくは jpg,txt…"
|
668 |
-
|
669 |
-
#: validation_rules/mw_validation_rule_hiragana.php:31
|
670 |
-
msgid "Please enter with a Japanese Hiragana."
|
671 |
-
msgstr "ひらがなで入力してください。"
|
672 |
-
|
673 |
-
#: validation_rules/mw_validation_rule_hiragana.php:46
|
674 |
-
msgid "Japanese Hiragana"
|
675 |
-
msgstr "ひらがな"
|
676 |
-
|
677 |
-
#: validation_rules/mw_validation_rule_in.php:31
|
678 |
-
msgid "This value is invalid."
|
679 |
-
msgstr "値が不正です。"
|
680 |
-
|
681 |
-
#: validation_rules/mw_validation_rule_katakana.php:31
|
682 |
-
msgid "Please enter with a Japanese Katakana."
|
683 |
-
msgstr "カタカナで入力してください。"
|
684 |
-
|
685 |
-
#: validation_rules/mw_validation_rule_katakana.php:46
|
686 |
-
msgid "Japanese Katakana"
|
687 |
-
msgstr "カタカナ"
|
688 |
-
|
689 |
-
#: validation_rules/mw_validation_rule_mail.php:31
|
690 |
-
msgid "This is not the format of a mail address."
|
691 |
-
msgstr "メールアドレスの形式ではありません。"
|
692 |
-
|
693 |
-
#: validation_rules/mw_validation_rule_mail.php:46
|
694 |
-
msgid "E-mail"
|
695 |
-
msgstr "メールアドレス"
|
696 |
-
|
697 |
-
#: validation_rules/mw_validation_rule_minlength.php:31
|
698 |
-
msgid "The number of characters is a few."
|
699 |
-
msgstr "文字数が足りません。"
|
700 |
|
701 |
-
#:
|
702 |
-
msgid "
|
703 |
-
msgstr "
|
704 |
|
705 |
-
#:
|
706 |
-
|
707 |
-
|
708 |
-
msgstr "未入力です。"
|
709 |
|
710 |
-
#:
|
711 |
-
msgid "
|
712 |
-
msgstr "
|
713 |
|
714 |
-
#:
|
715 |
-
msgid "
|
716 |
-
msgstr "
|
717 |
|
718 |
-
#:
|
719 |
-
msgid "
|
720 |
-
msgstr "
|
721 |
|
722 |
-
#:
|
723 |
-
msgid "
|
724 |
-
msgstr "
|
725 |
|
726 |
-
#:
|
727 |
-
msgid "
|
728 |
-
msgstr "
|
729 |
|
730 |
-
#:
|
731 |
-
msgid "
|
732 |
-
msgstr "
|
733 |
|
734 |
-
#:
|
735 |
-
msgid "
|
736 |
-
msgstr "
|
737 |
|
738 |
-
#:
|
739 |
-
msgid "
|
740 |
-
msgstr "
|
741 |
|
742 |
-
#:
|
743 |
-
msgid "
|
744 |
-
msgstr "
|
745 |
|
746 |
#. Plugin Name of the plugin/theme
|
747 |
msgid "MW WP Form"
|
@@ -752,9 +766,14 @@ msgid "http://plugins.2inc.org/mw-wp-form/"
|
|
752 |
msgstr "http://plugins.2inc.org/mw-wp-form/"
|
753 |
|
754 |
#. Description of the plugin/theme
|
755 |
-
msgid "
|
|
|
|
|
|
|
756 |
msgstr ""
|
757 |
-
"MW WP Form
|
|
|
|
|
758 |
|
759 |
#. Author of the plugin/theme
|
760 |
msgid "Takashi Kitajima"
|
@@ -764,6 +783,10 @@ msgstr ""
|
|
764 |
msgid "http://2inc.org"
|
765 |
msgstr ""
|
766 |
|
|
|
|
|
|
|
|
|
767 |
#~ msgid "option"
|
768 |
#~ msgstr "オプション"
|
769 |
|
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 2.2.0\n"
|
6 |
"Report-Msgid-Bugs-To: http://wordpress.org/tag/mw-wp-form\n"
|
7 |
+
"POT-Creation-Date: 2015-01-13 14:16:40+00:00\n"
|
8 |
+
"PO-Revision-Date: 2015-01-13 23:20+0900\n"
|
9 |
"Last-Translator: Takashi Kitajima <inc@2inc.org>\n"
|
10 |
"Language-Team: Takashi Kitajima <inc@2inc.org>\n"
|
11 |
"Language: ja\n"
|
15 |
"Plural-Forms: nplurals=1; plural=0;\n"
|
16 |
"X-Poedit-SourceCharset: UTF-8\n"
|
17 |
"X-Poedit-Basepath: .\n"
|
18 |
+
"X-Generator: Poedit 1.7.3\n"
|
19 |
"X-Poedit-KeywordsList: __;_e;_x;esc_html_e;esc_html__\n"
|
20 |
"X-Poedit-SearchPath-0: ..\n"
|
21 |
|
22 |
+
#: classes/controllers/class.admin-list.php:41
|
23 |
+
#: classes/controllers/class.admin.php:102
|
24 |
+
msgid "Form Key"
|
25 |
+
msgstr "フォーム識別子"
|
26 |
+
|
27 |
+
#: classes/controllers/class.admin.php:63
|
28 |
+
msgid "Complete Message"
|
29 |
+
msgstr "完了画面メッセージ"
|
30 |
+
|
31 |
+
#: classes/controllers/class.admin.php:75
|
32 |
+
msgid "URL Options"
|
33 |
+
msgstr "URL設定"
|
34 |
+
|
35 |
+
#: classes/controllers/class.admin.php:85
|
36 |
+
msgid "Validation Rule"
|
37 |
+
msgstr "バリデーションルール"
|
38 |
+
|
39 |
+
#: classes/controllers/class.admin.php:93
|
40 |
+
msgid "Add-ons"
|
41 |
+
msgstr "アドオン"
|
42 |
+
|
43 |
+
#: classes/controllers/class.admin.php:115
|
44 |
+
msgid "Automatic Reply Email Options"
|
45 |
+
msgstr "自動返信メール設定"
|
46 |
+
|
47 |
+
#: classes/controllers/class.admin.php:130
|
48 |
+
msgid "Admin Email Options"
|
49 |
+
msgstr "管理者宛メール設定"
|
50 |
+
|
51 |
+
#: classes/controllers/class.admin.php:144
|
52 |
+
msgid "settings"
|
53 |
+
msgstr "設定"
|
54 |
+
|
55 |
+
#: classes/controllers/class.admin.php:156
|
56 |
+
msgid "Style setting"
|
57 |
+
msgstr "スタイル設定"
|
58 |
+
|
59 |
+
#: classes/controllers/class.chart.php:65
|
60 |
+
#: classes/controllers/class.chart.php:66 classes/views/class.chart.php:73
|
61 |
+
msgid "Chart"
|
62 |
+
msgstr "グラフ"
|
63 |
+
|
64 |
+
#: classes/controllers/class.contact-data-list.php:120
|
65 |
+
#: classes/controllers/class.contact-data-list.php:167
|
66 |
+
#: classes/controllers/class.contact-data-list.php:260
|
67 |
+
#: classes/views/class.contact-data.php:101
|
68 |
+
msgid "Response Status"
|
69 |
+
msgstr "対応状況"
|
70 |
+
|
71 |
+
#: classes/controllers/class.contact-data-list.php:147
|
72 |
+
#: classes/controllers/class.contact-data-list.php:170
|
73 |
+
#: classes/views/class.contact-data.php:113
|
74 |
+
msgid "Memo"
|
75 |
+
msgstr "メモ"
|
76 |
+
|
77 |
+
#: classes/controllers/class.contact-data-list.php:259
|
78 |
+
msgid "Registed Date"
|
79 |
+
msgstr "登録日時"
|
80 |
+
|
81 |
+
#: classes/controllers/class.contact-data.php:43
|
82 |
+
#: classes/controllers/class.contact-data.php:44
|
83 |
+
#: classes/views/class.contact-data.php:34
|
84 |
+
msgid "Inquiry data"
|
85 |
+
msgstr "問い合わせデータ"
|
86 |
+
|
87 |
+
#: classes/controllers/class.contact-data.php:89
|
88 |
+
msgid "Custom Fields"
|
89 |
+
msgstr "カスタムフィールド"
|
90 |
+
|
91 |
+
#: classes/form-fields/class.akismet_error.php:30
|
92 |
msgid "Akismet Error"
|
93 |
msgstr "Akismetエラー"
|
94 |
|
95 |
+
#: classes/form-fields/class.back-button.php:30
|
96 |
+
#: classes/form-fields/class.back-button.php:41
|
97 |
msgid "Back"
|
98 |
msgstr "戻る"
|
99 |
|
100 |
+
#: classes/form-fields/class.back-button.php:69
|
101 |
+
#: classes/form-fields/class.button.php:76
|
102 |
+
#: classes/form-fields/class.confirm-button.php:69
|
103 |
+
#: classes/form-fields/class.submit.php:76
|
104 |
msgid "String on the button"
|
105 |
msgstr "ボタンに表示する文字列"
|
106 |
|
107 |
+
#: classes/form-fields/class.button.php:30
|
108 |
msgid "Button"
|
109 |
msgstr "ボタン"
|
110 |
|
111 |
+
#: classes/form-fields/class.checkbox.php:30
|
112 |
msgid "Checkbox"
|
113 |
msgstr "チェックボックス"
|
114 |
|
115 |
+
#: classes/form-fields/class.checkbox.php:102
|
116 |
+
#: classes/form-fields/class.radio.php:98
|
117 |
+
#: classes/form-fields/class.select.php:96
|
118 |
msgid "Choices"
|
119 |
msgstr "選択肢"
|
120 |
|
121 |
+
#: classes/form-fields/class.checkbox.php:106
|
122 |
+
#: classes/form-fields/class.error.php:78
|
123 |
+
#: classes/form-fields/class.radio.php:102
|
124 |
+
#: classes/form-fields/class.select.php:100
|
125 |
msgid "Input one line about one item."
|
126 |
msgstr "1項目につき1行で入力してください。"
|
127 |
|
128 |
+
#: classes/form-fields/class.checkbox.php:107
|
129 |
+
#: classes/form-fields/class.radio.php:103
|
130 |
+
#: classes/form-fields/class.select.php:101
|
131 |
+
msgid "Example: value1↵value2 or key1:value1↵key2:value2"
|
132 |
+
msgstr "例:値1↵値2 もしくは キー1:値1↵キー2:値2"
|
133 |
+
|
134 |
+
#: classes/form-fields/class.checkbox.php:111
|
135 |
+
#: classes/form-fields/class.datepicker.php:131
|
136 |
+
#: classes/form-fields/class.hidden.php:79
|
137 |
+
#: classes/form-fields/class.password.php:107
|
138 |
+
#: classes/form-fields/class.radio.php:107
|
139 |
+
#: classes/form-fields/class.select.php:105
|
140 |
+
#: classes/form-fields/class.text.php:115
|
141 |
+
#: classes/form-fields/class.textarea.php:109
|
142 |
msgid "Default value"
|
143 |
msgstr "初期値"
|
144 |
|
145 |
+
#: classes/form-fields/class.checkbox.php:116
|
146 |
msgid "Separator string"
|
147 |
msgstr "区切り文字"
|
148 |
|
149 |
+
#: classes/form-fields/class.checkbox.php:121
|
150 |
+
#: classes/form-fields/class.radio.php:112
|
151 |
msgid "Display method"
|
152 |
msgstr "表示方法"
|
153 |
|
154 |
+
#: classes/form-fields/class.checkbox.php:123
|
155 |
+
#: classes/form-fields/class.radio.php:114
|
156 |
msgid "Arranged vertically."
|
157 |
msgstr "垂直に配置する"
|
158 |
|
159 |
+
#: classes/form-fields/class.checkbox.php:126
|
160 |
+
#: classes/form-fields/class.datepicker.php:136
|
161 |
+
#: classes/form-fields/class.file.php:109
|
162 |
+
#: classes/form-fields/class.image.php:110
|
163 |
+
#: classes/form-fields/class.password.php:117
|
164 |
+
#: classes/form-fields/class.radio.php:117
|
165 |
+
#: classes/form-fields/class.select.php:110
|
166 |
+
#: classes/form-fields/class.tel.php:89 classes/form-fields/class.text.php:125
|
167 |
+
#: classes/form-fields/class.textarea.php:119
|
168 |
+
#: classes/form-fields/class.zip.php:89
|
169 |
msgid "Dsiplay error"
|
170 |
msgstr "エラー表示"
|
171 |
|
172 |
+
#: classes/form-fields/class.checkbox.php:128
|
173 |
+
#: classes/form-fields/class.datepicker.php:138
|
174 |
+
#: classes/form-fields/class.file.php:111
|
175 |
+
#: classes/form-fields/class.image.php:112
|
176 |
+
#: classes/form-fields/class.password.php:119
|
177 |
+
#: classes/form-fields/class.radio.php:119
|
178 |
+
#: classes/form-fields/class.select.php:112
|
179 |
+
#: classes/form-fields/class.tel.php:91 classes/form-fields/class.text.php:127
|
180 |
+
#: classes/form-fields/class.textarea.php:121
|
181 |
+
#: classes/form-fields/class.zip.php:91
|
182 |
msgid "Don't display error."
|
183 |
msgstr "エラーを表示しない"
|
184 |
|
185 |
+
#: classes/form-fields/class.confirm-button.php:30
|
186 |
msgid "Confirm Button"
|
187 |
msgstr "確認ボタン"
|
188 |
|
189 |
+
#: classes/form-fields/class.confirm-button.php:41
|
190 |
+
#: classes/form-fields/class.submit-button.php:42
|
191 |
msgid "Confirm"
|
192 |
msgstr "確認画面へ"
|
193 |
|
194 |
+
#: classes/form-fields/class.datepicker.php:30
|
195 |
msgid "Datepicker"
|
196 |
msgstr "日付"
|
197 |
|
198 |
+
#: classes/form-fields/class.error.php:30
|
199 |
msgid "Error Message"
|
200 |
msgstr "エラーメッセージ"
|
201 |
|
202 |
+
#: classes/form-fields/class.error.php:74
|
203 |
msgid "name of the element which wants to display error"
|
204 |
msgstr "エラーを表示したい要素のname属性"
|
205 |
|
206 |
+
#: classes/form-fields/class.file.php:30
|
207 |
msgid "File"
|
208 |
msgstr "ファイルフィールド"
|
209 |
|
210 |
+
#: classes/form-fields/class.file.php:62 classes/form-fields/class.file.php:84
|
211 |
msgid "Uploaded."
|
212 |
msgstr "アップロードしました。"
|
213 |
|
214 |
+
#: classes/form-fields/class.hidden.php:23
|
215 |
msgid "Hidden"
|
216 |
msgstr "hiddenフィールド"
|
217 |
|
218 |
+
#: classes/form-fields/class.hidden.php:84
|
219 |
msgid "Display"
|
220 |
msgstr "表示する"
|
221 |
|
222 |
+
#: classes/form-fields/class.hidden.php:86
|
223 |
msgid "Display hidden value."
|
224 |
msgstr "hiddenの値を表示"
|
225 |
|
226 |
+
#: classes/form-fields/class.image.php:30
|
227 |
msgid "Image"
|
228 |
msgstr "画像フィールド"
|
229 |
|
230 |
+
#: classes/form-fields/class.password.php:30
|
231 |
msgid "Password"
|
232 |
msgstr "パスワードフィールド"
|
233 |
|
234 |
+
#: classes/form-fields/class.radio.php:30
|
235 |
msgid "Radio"
|
236 |
msgstr "ラジオボタン"
|
237 |
|
238 |
+
#: classes/form-fields/class.select.php:30
|
239 |
msgid "Select"
|
240 |
msgstr "セレクトボックス"
|
241 |
|
242 |
+
#: classes/form-fields/class.submit-button.php:30
|
243 |
+
msgid "Confirm & Submit"
|
244 |
+
msgstr "確認・送信"
|
245 |
|
246 |
+
#: classes/form-fields/class.submit-button.php:43
|
247 |
+
#: classes/form-fields/class.submit.php:42
|
248 |
msgid "Send"
|
249 |
msgstr "送信する"
|
250 |
|
251 |
+
#: classes/form-fields/class.submit-button.php:80
|
|
|
|
|
|
|
|
|
252 |
msgid "String on the confirm button"
|
253 |
msgstr "確認ボタンに表示する文字列"
|
254 |
|
255 |
+
#: classes/form-fields/class.submit-button.php:85
|
256 |
msgid "String on the submit button"
|
257 |
msgstr "送信ボタンに表示する文字列"
|
258 |
|
259 |
+
#: classes/form-fields/class.submit.php:30
|
260 |
+
msgid "Submit Button"
|
261 |
+
msgstr "送信ボタン"
|
262 |
+
|
263 |
+
#: classes/form-fields/class.tel.php:30
|
264 |
+
#: classes/validation-rules/class.tel.php:54
|
265 |
msgid "Tel"
|
266 |
msgstr "電話番号"
|
267 |
|
268 |
+
#: classes/form-fields/class.tel.php:94 classes/form-fields/class.text.php:130
|
269 |
+
#: classes/form-fields/class.zip.php:94
|
270 |
msgid "Convert half alphanumeric"
|
271 |
msgstr "半角英数字に変換"
|
272 |
|
273 |
+
#: classes/form-fields/class.tel.php:96 classes/form-fields/class.zip.php:96
|
274 |
msgid "Don't Convert."
|
275 |
msgstr "変換しない"
|
276 |
|
277 |
+
#: classes/form-fields/class.text.php:30
|
278 |
msgid "Text"
|
279 |
msgstr "テキストフィールド"
|
280 |
|
281 |
+
#: classes/form-fields/class.text.php:132
|
282 |
msgid "Convert."
|
283 |
msgstr "変換する"
|
284 |
|
285 |
+
#: classes/form-fields/class.textarea.php:30
|
286 |
msgid "Textarea"
|
287 |
msgstr "テキストエリア"
|
288 |
|
289 |
+
#: classes/form-fields/class.zip.php:30
|
290 |
+
#: classes/validation-rules/class.zip.php:48
|
291 |
msgid "Zip Code"
|
292 |
msgstr "郵便番号"
|
293 |
|
294 |
+
#: classes/functions.php:198
|
295 |
+
msgid "Uploaded from "
|
296 |
+
msgstr "Uploaded from "
|
297 |
|
298 |
+
#: classes/functions.php:289
|
299 |
msgid "Tracking Number"
|
300 |
msgstr "問い合わせ番号"
|
301 |
|
302 |
+
#: classes/models/class.contact-data-setting.php:56
|
303 |
+
msgid "Not supported"
|
304 |
+
msgstr "未対応"
|
305 |
|
306 |
+
#: classes/models/class.contact-data-setting.php:57
|
307 |
+
msgid "Reservation"
|
308 |
+
msgstr "保留"
|
309 |
|
310 |
+
#: classes/models/class.contact-data-setting.php:58
|
311 |
+
msgid "Supported"
|
312 |
+
msgstr "対応済み"
|
313 |
|
314 |
+
#: classes/validation-rules/class.akismet.php:30
|
315 |
+
msgid "The contents which you input were judged with spam."
|
316 |
+
msgstr "あなたの入力した内容はスパムと判定されました。"
|
317 |
|
318 |
+
#: classes/validation-rules/class.alpha.php:33
|
319 |
+
msgid "Please enter with a half-width alphabetic character."
|
320 |
+
msgstr "半角英字で入力してください。"
|
321 |
|
322 |
+
#: classes/validation-rules/class.alpha.php:48
|
323 |
+
msgid "Alphabet"
|
324 |
+
msgstr "半角英字"
|
325 |
|
326 |
+
#: classes/validation-rules/class.alphanumeric.php:33
|
327 |
+
msgid "Please enter with a half-width alphanumeric character."
|
328 |
+
msgstr "半角英数字で入力してください。"
|
329 |
|
330 |
+
#: classes/validation-rules/class.alphanumeric.php:48
|
331 |
+
msgid "Alphabet and Numeric"
|
332 |
+
msgstr "半角英数字"
|
333 |
|
334 |
+
#: classes/validation-rules/class.between.php:35
|
335 |
+
msgid "The number of characters is invalid."
|
336 |
+
msgstr "文字数が正しくありません。"
|
337 |
|
338 |
+
#: classes/validation-rules/class.between.php:76
|
339 |
+
msgid "The range of the number of characters"
|
340 |
+
msgstr "文字数の範囲"
|
341 |
|
342 |
+
#: classes/validation-rules/class.date.php:32
|
343 |
+
msgid "This is not the format of a date."
|
344 |
+
msgstr "日付の形式ではありません。"
|
345 |
|
346 |
+
#: classes/validation-rules/class.date.php:60
|
347 |
+
msgid "Date"
|
348 |
+
msgstr "日付"
|
349 |
|
350 |
+
#: classes/validation-rules/class.eq.php:33
|
351 |
+
msgid "This is not in agreement."
|
352 |
+
msgstr "一致しません。"
|
353 |
|
354 |
+
#: classes/validation-rules/class.eq.php:56
|
355 |
+
msgid "The key at same value"
|
356 |
+
msgstr "一致する項目"
|
357 |
|
358 |
+
#: classes/validation-rules/class.filesize.php:35
|
359 |
+
msgid "This file size is too big."
|
360 |
+
msgstr "ファイルサイズが大きすぎます。"
|
361 |
|
362 |
+
#: classes/validation-rules/class.filesize.php:58
|
363 |
+
msgid "Permitted file size"
|
364 |
+
msgstr "サイズ制限"
|
365 |
|
366 |
+
#: classes/validation-rules/class.filesize.php:59
|
367 |
+
msgid "bytes"
|
368 |
+
msgstr "バイト"
|
369 |
|
370 |
+
#: classes/validation-rules/class.filetype.php:33
|
371 |
+
msgid "This file is invalid."
|
372 |
+
msgstr "許可されたファイルではありません。"
|
373 |
|
374 |
+
#: classes/validation-rules/class.filetype.php:61
|
375 |
+
msgid "Permitted Extension"
|
376 |
+
msgstr "拡張子制限"
|
377 |
|
378 |
+
#: classes/validation-rules/class.filetype.php:62
|
379 |
+
msgid "Example:jpg or jpg,txt,…"
|
380 |
+
msgstr "例:jpg もしくは jpg,txt…"
|
381 |
+
|
382 |
+
#: classes/validation-rules/class.hiragana.php:33
|
383 |
+
msgid "Please enter with a Japanese Hiragana."
|
384 |
+
msgstr "ひらがなで入力してください。"
|
385 |
+
|
386 |
+
#: classes/validation-rules/class.hiragana.php:48
|
387 |
+
msgid "Japanese Hiragana"
|
388 |
+
msgstr "ひらがな"
|
389 |
+
|
390 |
+
#: classes/validation-rules/class.in.php:33
|
391 |
+
msgid "This value is invalid."
|
392 |
+
msgstr "値が不正です。"
|
393 |
+
|
394 |
+
#: classes/validation-rules/class.katakana.php:33
|
395 |
+
msgid "Please enter with a Japanese Katakana."
|
396 |
+
msgstr "カタカナで入力してください。"
|
397 |
+
|
398 |
+
#: classes/validation-rules/class.katakana.php:48
|
399 |
+
msgid "Japanese Katakana"
|
400 |
+
msgstr "カタカナ"
|
401 |
+
|
402 |
+
#: classes/validation-rules/class.mail.php:33
|
403 |
+
msgid "This is not the format of a mail address."
|
404 |
+
msgstr "メールアドレスの形式ではありません。"
|
405 |
+
|
406 |
+
#: classes/validation-rules/class.mail.php:48
|
407 |
+
msgid "E-mail"
|
408 |
+
msgstr "メールアドレス"
|
409 |
+
|
410 |
+
#: classes/validation-rules/class.minlength.php:34
|
411 |
+
msgid "The number of characters is a few."
|
412 |
+
msgstr "文字数が足りません。"
|
413 |
+
|
414 |
+
#: classes/validation-rules/class.minlength.php:57
|
415 |
+
msgid "The number of the minimum characters"
|
416 |
+
msgstr "最小文字数"
|
417 |
+
|
418 |
+
#: classes/validation-rules/class.noempty.php:32
|
419 |
+
#: classes/validation-rules/class.nofalse.php:32
|
420 |
+
msgid "Please enter."
|
421 |
+
msgstr "未入力です。"
|
422 |
+
|
423 |
+
#: classes/validation-rules/class.noempty.php:46
|
424 |
+
msgid "No empty"
|
425 |
+
msgstr "必須項目"
|
426 |
|
427 |
+
#: classes/validation-rules/class.numeric.php:33
|
428 |
+
msgid "Please enter with a half-width number."
|
429 |
+
msgstr "半角数字で入力してください。"
|
430 |
+
|
431 |
+
#: classes/validation-rules/class.numeric.php:48
|
432 |
+
msgid "Numeric"
|
433 |
+
msgstr "半角数字"
|
434 |
+
|
435 |
+
#: classes/validation-rules/class.required.php:35
|
436 |
+
msgid "This is required."
|
437 |
+
msgstr "必須項目です。"
|
438 |
+
|
439 |
+
#: classes/validation-rules/class.required.php:48
|
440 |
+
msgid "No empty( with checkbox )"
|
441 |
+
msgstr "必須項目(チェックボックス)"
|
442 |
+
|
443 |
+
#: classes/validation-rules/class.tel.php:32
|
444 |
+
msgid "This is not the format of a tel number."
|
445 |
+
msgstr "電話番号の形式ではありません。"
|
446 |
+
|
447 |
+
#: classes/validation-rules/class.url.php:33
|
448 |
+
msgid "This is not the format of a url."
|
449 |
+
msgstr "URLの形式ではありません。"
|
450 |
+
|
451 |
+
#: classes/validation-rules/class.url.php:48
|
452 |
+
msgid "URL"
|
453 |
+
msgstr "URL"
|
454 |
+
|
455 |
+
#: classes/validation-rules/class.zip.php:32
|
456 |
+
msgid "This is not the format of a zip code."
|
457 |
+
msgstr "郵便番号の形式ではありません。"
|
458 |
+
|
459 |
+
#: classes/views/class.admin.php:39
|
460 |
+
msgid "Input Page URL"
|
461 |
+
msgstr "入力画面URL"
|
462 |
+
|
463 |
+
#: classes/views/class.admin.php:45
|
464 |
+
msgid "Confirmation Page URL"
|
465 |
+
msgstr "確認画面URL"
|
466 |
+
|
467 |
+
#: classes/views/class.admin.php:51
|
468 |
+
msgid "Complete Page URL"
|
469 |
+
msgstr "完了画面URL"
|
470 |
+
|
471 |
+
#: classes/views/class.admin.php:57
|
472 |
+
msgid "Validation Error Page URL"
|
473 |
+
msgstr "エラー画面URL"
|
474 |
+
|
475 |
+
#: classes/views/class.admin.php:64
|
476 |
msgid ""
|
477 |
+
"This urls are the redirection urls at the time of button press. When URL "
|
478 |
+
"setting is empty, The page redirect on the same page."
|
479 |
msgstr ""
|
480 |
+
"上記URLはボタン押下時のリダイレクトURLです。URLの設定が空のときは、同一ページ"
|
481 |
+
"上でリダイレクトします。"
|
|
|
482 |
|
483 |
+
#: classes/views/class.admin.php:65
|
484 |
+
msgid "When a URL doesn't begin http or https, %s is complemented."
|
485 |
+
msgstr "URLが http または https で始まっていない場合は %s が補完されます。"
|
486 |
|
487 |
+
#: classes/views/class.admin.php:90
|
488 |
+
msgid "Add Validation rule"
|
489 |
+
msgstr "バリデーションルールを追加"
|
490 |
|
491 |
+
#: classes/views/class.admin.php:97
|
492 |
+
msgid "The key which applies validation"
|
493 |
+
msgstr "バリデーションを適用する項目"
|
494 |
|
495 |
+
#: classes/views/class.admin.php:121
|
496 |
+
msgid "You can use more easy and useful to the MW WP Form in add-on!"
|
497 |
+
msgstr "アドオンで MW WP Form をもっと簡単・便利に使うことができます!"
|
498 |
|
499 |
+
#: classes/views/class.admin.php:122
|
500 |
+
msgid "View Add-ons"
|
501 |
+
msgstr "アドオンを見る"
|
502 |
+
|
503 |
+
#: classes/views/class.admin.php:137
|
504 |
+
msgid "Copy and Paste this shortcode."
|
505 |
+
msgstr "このショートコードをコピー&ペーストしてください。"
|
506 |
+
|
507 |
+
#: classes/views/class.admin.php:138
|
508 |
+
msgid "The key to use with hook is "
|
509 |
+
msgstr "各フックで使用する修飾子は"
|
510 |
|
511 |
+
#: classes/views/class.admin.php:156 classes/views/class.admin.php:202
|
512 |
msgid "{key} is converted form data."
|
513 |
msgstr "{キー}でそのフォーム項目に変換されます。"
|
514 |
|
515 |
+
#: classes/views/class.admin.php:158 classes/views/class.admin.php:204
|
516 |
msgid "It is automatically converted to Tracking number when you input {%s}."
|
517 |
msgstr "{%s} と入力すると問い合わせ番号に自動的に変換されます。"
|
518 |
|
519 |
+
#: classes/views/class.admin.php:163 classes/views/class.admin.php:225
|
520 |
msgid "Subject"
|
521 |
msgstr "件名"
|
522 |
|
523 |
+
#: classes/views/class.admin.php:167 classes/views/class.admin.php:229
|
524 |
msgid "Sender"
|
525 |
msgstr "送信者"
|
526 |
|
527 |
+
#: classes/views/class.admin.php:169 classes/views/class.admin.php:174
|
528 |
+
#: classes/views/class.admin.php:214 classes/views/class.admin.php:231
|
529 |
+
#: classes/views/class.admin.php:236
|
530 |
msgid "If empty:"
|
531 |
msgstr "未入力の場合:"
|
532 |
|
533 |
+
#: classes/views/class.admin.php:172 classes/views/class.admin.php:234
|
534 |
msgid "From ( E-mail address )"
|
535 |
msgstr "送信元(E-mailアドレス)"
|
536 |
|
537 |
+
#: classes/views/class.admin.php:177 classes/views/class.admin.php:239
|
538 |
msgid "Content"
|
539 |
msgstr "本文"
|
540 |
|
541 |
+
#: classes/views/class.admin.php:181
|
542 |
msgid "Automatic reply email"
|
543 |
msgstr "自動返信メール"
|
544 |
|
545 |
+
#: classes/views/class.admin.php:183
|
546 |
msgid ""
|
547 |
"Input the key to use as transmission to automatic reply email. {} is "
|
548 |
"unnecessary."
|
549 |
msgstr "自動返信メールに使用する項目のキーを入力してください。{ }は不要です。"
|
550 |
|
551 |
+
#: classes/views/class.admin.php:209
|
552 |
msgid ""
|
553 |
"If Admin Email Options is a blank, Automatic Replay Email Options is used as "
|
554 |
"Admin Email Options."
|
556 |
"管理者宛メール設定が空のときは自動返信メール設定に管理者宛メール設定が使用さ"
|
557 |
"れます。"
|
558 |
|
559 |
+
#: classes/views/class.admin.php:212
|
560 |
msgid "To ( E-mail address )"
|
561 |
msgstr "送信先(E-mailアドレス)"
|
562 |
|
563 |
+
#: classes/views/class.admin.php:217
|
564 |
msgid "CC ( E-mail address )"
|
565 |
msgstr "CC(E-mailアドレス)"
|
566 |
|
567 |
+
#: classes/views/class.admin.php:221
|
568 |
msgid "BCC ( E-mail address )"
|
569 |
msgstr "BCC(E-mailアドレス)"
|
570 |
|
571 |
+
#: classes/views/class.admin.php:258
|
572 |
+
msgid "Activate Query string of post"
|
573 |
+
msgstr "URL引数を有効にする"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
574 |
|
575 |
+
#: classes/views/class.admin.php:259
|
576 |
msgid ""
|
577 |
+
"If this field is active, MW WP Form get query string. And get post data from "
|
578 |
+
"query string \"post_id\". You can use $post's property in editor."
|
579 |
msgstr ""
|
580 |
+
"有効にした場合、MW WP FormはURL引数を取得します。また、URL引数 ”post_id” をも"
|
581 |
+
"とに投稿を取得します。その投稿($post) のプロパティを使用できるようになりま"
|
582 |
+
"す。"
|
583 |
|
584 |
+
#: classes/views/class.admin.php:260
|
585 |
+
msgid "Example: {ID}, {post_title}, {post_meta} etc..."
|
586 |
+
msgstr "例:{ID}、{post_title}、{post_meta}など…"
|
587 |
|
588 |
+
#: classes/views/class.admin.php:263
|
589 |
+
msgid "Saving inquiry data in database"
|
590 |
+
msgstr "問い合わせデータをデータベースに保存"
|
591 |
|
592 |
+
#: classes/views/class.admin.php:266
|
593 |
+
msgid "Enable scrolling of screen transition."
|
594 |
+
msgstr "画面変遷時のスクロールを有効にする"
|
595 |
+
|
596 |
+
#: classes/views/class.admin.php:270
|
597 |
+
msgid "Akismet Setting"
|
598 |
+
msgstr "Akismet 設定"
|
599 |
+
|
600 |
+
#: classes/views/class.admin.php:285
|
601 |
+
msgid "Input the key to use Akismet."
|
602 |
+
msgstr "Akismetを使用する項目のキーを入力してください。"
|
603 |
|
604 |
+
#: classes/views/class.admin.php:298
|
605 |
msgid "Select Style"
|
606 |
msgstr "スタイルを選択"
|
607 |
|
608 |
+
#: classes/views/class.admin.php:315
|
609 |
+
msgid "Your contribution is needed for making this plugin better."
|
610 |
+
msgstr "あなたの貢献があればこのプラグインをもっと良くすることができます。"
|
611 |
+
|
612 |
+
#: classes/views/class.admin.php:315
|
613 |
+
msgid "Donate"
|
614 |
+
msgstr "寄付する"
|
615 |
+
|
616 |
+
#: classes/views/class.admin.php:337 classes/views/class.chart.php:93
|
617 |
msgid "Select this."
|
618 |
msgstr "選択してください"
|
619 |
|
620 |
+
#: classes/views/class.admin.php:338
|
621 |
msgid "Input fields"
|
622 |
msgstr "入力項目"
|
623 |
|
624 |
+
#: classes/views/class.admin.php:341
|
625 |
msgid "Select fields"
|
626 |
msgstr "選択項目"
|
627 |
|
628 |
+
#: classes/views/class.admin.php:344
|
629 |
msgid "Button fields"
|
630 |
msgstr "ボタン項目"
|
631 |
|
632 |
+
#: classes/views/class.admin.php:347
|
633 |
msgid "Error fields"
|
634 |
msgstr "エラー項目"
|
635 |
|
636 |
+
#: classes/views/class.admin.php:350
|
637 |
msgid "Other fields"
|
638 |
msgstr "その他の項目"
|
639 |
|
640 |
+
#: classes/views/class.admin.php:354
|
641 |
msgid "Add form tag"
|
642 |
msgstr "フォームタグを追加"
|
643 |
|
644 |
+
#: classes/views/class.chart.php:84
|
|
|
|
|
|
|
|
|
|
|
645 |
msgid "Add Chart"
|
646 |
msgstr "グラフを追加"
|
647 |
|
648 |
+
#: classes/views/class.chart.php:91
|
649 |
msgid "Item that create chart"
|
650 |
msgstr "グラフを作成する項目"
|
651 |
|
652 |
+
#: classes/views/class.chart.php:99
|
653 |
msgid "Chart type"
|
654 |
msgstr "グラフの種類"
|
655 |
|
656 |
+
#: classes/views/class.chart.php:103
|
657 |
msgid "Pie chart"
|
658 |
msgstr "円グラフ"
|
659 |
|
660 |
+
#: classes/views/class.chart.php:104
|
661 |
msgid "Bar chart"
|
662 |
msgstr "棒グラフ"
|
663 |
|
664 |
+
#: classes/views/class.chart.php:117
|
665 |
msgid ""
|
666 |
"Separator string (If the check box. If the separator attribute is not set to "
|
667 |
"\",\")"
|
668 |
msgstr ""
|
669 |
"区切り文字(チェックボックスの場合。separator 属性が未設定の場合は「,」)"
|
670 |
|
671 |
+
#: classes/views/class.chart.php:139 classes/views/class.contact-data.php:42
|
|
|
672 |
msgid "The number of inquiries"
|
673 |
msgstr "問い合わせ件数"
|
674 |
|
675 |
+
#: classes/views/class.contact-data-list.php:34
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
676 |
msgid "CSV Download"
|
677 |
msgstr "CSVダウンロード"
|
678 |
|
679 |
+
#: classes/views/class.contact-data.php:36
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
680 |
msgid ""
|
681 |
"You can see the inquiry data that are saved in the database by clicking on "
|
682 |
"the link below."
|
684 |
"リンクをクリックすることでデータベースに保存された問い合わせデータを見ること"
|
685 |
"ができます。"
|
686 |
|
687 |
+
#: classes/views/class.contact-data.php:40
|
688 |
msgid "Form title"
|
689 |
msgstr "フォーム名"
|
690 |
|
691 |
+
#: classes/views/class.contact-data.php:41
|
692 |
+
#: classes/views/class.contact-data.php:51
|
693 |
msgid "Display Chart"
|
694 |
msgstr "グラフを表示"
|
695 |
|
696 |
+
#: classes/views/class.contact-data.php:43
|
697 |
msgid "Updated date"
|
698 |
msgstr "更新日"
|
699 |
|
700 |
+
#: classes/views/class.contact-data.php:44
|
701 |
msgid "Created date"
|
702 |
msgstr "作成日"
|
703 |
|
704 |
+
#: classes/views/class.contact-data.php:52
|
705 |
msgid "cases"
|
706 |
msgstr "件"
|
707 |
|
708 |
+
#: classes/views/class.contact-data.php:127
|
709 |
msgid "« Back to the list"
|
710 |
msgstr "« 一覧に戻る"
|
711 |
|
712 |
+
#: mw-wp-form.php:171
|
713 |
+
msgid "Add New Form"
|
714 |
+
msgstr "フォームを追加"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
715 |
|
716 |
+
#: mw-wp-form.php:172
|
717 |
+
msgid "Edit Form"
|
718 |
+
msgstr "フォームを編集"
|
719 |
|
720 |
+
#: mw-wp-form.php:173
|
721 |
+
msgid "New Form"
|
722 |
+
msgstr "新しいフォーム"
|
|
|
723 |
|
724 |
+
#: mw-wp-form.php:174
|
725 |
+
msgid "View Form"
|
726 |
+
msgstr "フォームを表示"
|
727 |
|
728 |
+
#: mw-wp-form.php:175
|
729 |
+
msgid "Search Forms"
|
730 |
+
msgstr "フォームを検索"
|
731 |
|
732 |
+
#: mw-wp-form.php:176
|
733 |
+
msgid "No Forms found"
|
734 |
+
msgstr "フォームがありません"
|
735 |
|
736 |
+
#: mw-wp-form.php:177
|
737 |
+
msgid "No Forms found in Trash"
|
738 |
+
msgstr "ゴミ箱にフォームはありません"
|
739 |
|
740 |
+
#: mw-wp-form.php:199
|
741 |
+
msgid "Edit "
|
742 |
+
msgstr "編集"
|
743 |
|
744 |
+
#: mw-wp-form.php:200
|
745 |
+
msgid "View"
|
746 |
+
msgstr "表示"
|
747 |
|
748 |
+
#: mw-wp-form.php:201
|
749 |
+
msgid "Search"
|
750 |
+
msgstr "検索"
|
751 |
|
752 |
+
#: mw-wp-form.php:202
|
753 |
+
msgid "No data found"
|
754 |
+
msgstr "データがありません"
|
755 |
|
756 |
+
#: mw-wp-form.php:203
|
757 |
+
msgid "No data found in Trash"
|
758 |
+
msgstr "ゴミ箱にデータはありません"
|
759 |
|
760 |
#. Plugin Name of the plugin/theme
|
761 |
msgid "MW WP Form"
|
766 |
msgstr "http://plugins.2inc.org/mw-wp-form/"
|
767 |
|
768 |
#. Description of the plugin/theme
|
769 |
+
msgid ""
|
770 |
+
"MW WP Form is shortcode base contact form plugin. This plugin have many "
|
771 |
+
"feature. For example you can use many validation rules, contact data saving, "
|
772 |
+
"and chart aggregation using saved contact data."
|
773 |
msgstr ""
|
774 |
+
"MW WP Form はショートコードベースのフォームプラグインです。多くの機能を持って"
|
775 |
+
"おり、例えば、多くのバリデーションルール、問い合わせデータの保存、そしてグラ"
|
776 |
+
"フ機能集計などを使用することができます。"
|
777 |
|
778 |
#. Author of the plugin/theme
|
779 |
msgid "Takashi Kitajima"
|
783 |
msgid "http://2inc.org"
|
784 |
msgstr ""
|
785 |
|
786 |
+
#~ msgid "MW WP Form can create mail form with a confirmation screen."
|
787 |
+
#~ msgstr ""
|
788 |
+
#~ "MW WP Formは確認画面付きのフォームを作成しメールを送信することができます。"
|
789 |
+
|
790 |
#~ msgid "option"
|
791 |
#~ msgstr "オプション"
|
792 |
|
languages/mw-wp-form.pot
CHANGED
@@ -1,723 +1,737 @@
|
|
1 |
-
# Copyright (C)
|
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 2.
|
6 |
"Report-Msgid-Bugs-To: http://wordpress.org/tag/mw-wp-form\n"
|
7 |
-
"POT-Creation-Date:
|
8 |
"MIME-Version: 1.0\n"
|
9 |
"Content-Type: text/plain; charset=UTF-8\n"
|
10 |
"Content-Transfer-Encoding: 8bit\n"
|
11 |
-
"PO-Revision-Date:
|
12 |
"Last-Translator: Takashi Kitajima <inc@2inc.org>\n"
|
13 |
"Language-Team: Takashi Kitajima <inc@2inc.org>\n"
|
14 |
"Plural-Forms: nplurals=1; plural=0;\n"
|
15 |
"X-Poedit-SourceCharset: UTF-8\n"
|
16 |
"X-Poedit-Basepath: .\n"
|
17 |
-
"X-Generator: Poedit 1.
|
18 |
"X-Poedit-KeywordsList: __;_e\n"
|
19 |
"X-Poedit-SearchPath-0: ..\n"
|
20 |
|
21 |
-
#:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
msgid "Akismet Error"
|
23 |
msgstr ""
|
24 |
|
25 |
-
#:
|
26 |
-
#:
|
27 |
msgid "Back"
|
28 |
msgstr ""
|
29 |
|
30 |
-
#:
|
31 |
-
#:
|
32 |
-
#:
|
33 |
-
#:
|
34 |
msgid "String on the button"
|
35 |
msgstr ""
|
36 |
|
37 |
-
#:
|
38 |
msgid "Button"
|
39 |
msgstr ""
|
40 |
|
41 |
-
#:
|
42 |
msgid "Checkbox"
|
43 |
msgstr ""
|
44 |
|
45 |
-
#:
|
46 |
-
#:
|
47 |
-
#:
|
48 |
msgid "Choices"
|
49 |
msgstr ""
|
50 |
|
51 |
-
#:
|
52 |
-
#:
|
53 |
-
#:
|
54 |
-
#:
|
55 |
msgid "Input one line about one item."
|
56 |
msgstr ""
|
57 |
|
58 |
-
#:
|
59 |
-
#:
|
60 |
-
#:
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
#:
|
65 |
-
#:
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
msgid "Default value"
|
67 |
msgstr ""
|
68 |
|
69 |
-
#:
|
70 |
msgid "Separator string"
|
71 |
msgstr ""
|
72 |
|
73 |
-
#:
|
74 |
-
#:
|
75 |
msgid "Display method"
|
76 |
msgstr ""
|
77 |
|
78 |
-
#:
|
79 |
-
#:
|
80 |
msgid "Arranged vertically."
|
81 |
msgstr ""
|
82 |
|
83 |
-
#:
|
84 |
-
#:
|
85 |
-
#:
|
86 |
-
#:
|
87 |
-
#:
|
88 |
-
#:
|
89 |
-
#:
|
90 |
-
#:
|
91 |
-
#:
|
92 |
-
#:
|
93 |
msgid "Dsiplay error"
|
94 |
msgstr ""
|
95 |
|
96 |
-
#:
|
97 |
-
#:
|
98 |
-
#:
|
99 |
-
#:
|
100 |
-
#:
|
101 |
-
#:
|
102 |
-
#:
|
103 |
-
#:
|
104 |
-
#:
|
105 |
-
#:
|
106 |
msgid "Don't display error."
|
107 |
msgstr ""
|
108 |
|
109 |
-
#:
|
110 |
msgid "Confirm Button"
|
111 |
msgstr ""
|
112 |
|
113 |
-
#:
|
114 |
-
#:
|
115 |
msgid "Confirm"
|
116 |
msgstr ""
|
117 |
|
118 |
-
#:
|
119 |
msgid "Datepicker"
|
120 |
msgstr ""
|
121 |
|
122 |
-
#:
|
123 |
msgid "Error Message"
|
124 |
msgstr ""
|
125 |
|
126 |
-
#:
|
127 |
msgid "name of the element which wants to display error"
|
128 |
msgstr ""
|
129 |
|
130 |
-
#:
|
131 |
msgid "File"
|
132 |
msgstr ""
|
133 |
|
134 |
-
#:
|
135 |
msgid "Uploaded."
|
136 |
msgstr ""
|
137 |
|
138 |
-
#:
|
139 |
msgid "Hidden"
|
140 |
msgstr ""
|
141 |
|
142 |
-
#:
|
143 |
msgid "Display"
|
144 |
msgstr ""
|
145 |
|
146 |
-
#:
|
147 |
msgid "Display hidden value."
|
148 |
msgstr ""
|
149 |
|
150 |
-
#:
|
151 |
msgid "Image"
|
152 |
msgstr ""
|
153 |
|
154 |
-
#:
|
155 |
msgid "Password"
|
156 |
msgstr ""
|
157 |
|
158 |
-
#:
|
159 |
msgid "Radio"
|
160 |
msgstr ""
|
161 |
|
162 |
-
#:
|
163 |
msgid "Select"
|
164 |
msgstr ""
|
165 |
|
166 |
-
#:
|
167 |
-
msgid "Submit
|
168 |
msgstr ""
|
169 |
|
170 |
-
#:
|
171 |
-
#:
|
172 |
msgid "Send"
|
173 |
msgstr ""
|
174 |
|
175 |
-
#:
|
176 |
-
msgid "Confirm & Submit"
|
177 |
-
msgstr ""
|
178 |
-
|
179 |
-
#: form_fields/mw_form_field_submit_button.php:79
|
180 |
msgid "String on the confirm button"
|
181 |
msgstr ""
|
182 |
|
183 |
-
#:
|
184 |
msgid "String on the submit button"
|
185 |
msgstr ""
|
186 |
|
187 |
-
#:
|
188 |
-
|
|
|
|
|
|
|
|
|
189 |
msgid "Tel"
|
190 |
msgstr ""
|
191 |
|
192 |
-
#:
|
193 |
-
#:
|
194 |
msgid "Convert half alphanumeric"
|
195 |
msgstr ""
|
196 |
|
197 |
-
#:
|
198 |
msgid "Don't Convert."
|
199 |
msgstr ""
|
200 |
|
201 |
-
#:
|
202 |
msgid "Text"
|
203 |
msgstr ""
|
204 |
|
205 |
-
#:
|
206 |
msgid "Convert."
|
207 |
msgstr ""
|
208 |
|
209 |
-
#:
|
210 |
msgid "Textarea"
|
211 |
msgstr ""
|
212 |
|
213 |
-
#:
|
214 |
-
#:
|
215 |
msgid "Zip Code"
|
216 |
msgstr ""
|
217 |
|
218 |
-
#:
|
219 |
-
msgid "
|
220 |
msgstr ""
|
221 |
|
222 |
-
#:
|
223 |
msgid "Tracking Number"
|
224 |
msgstr ""
|
225 |
|
226 |
-
#:
|
227 |
-
msgid "
|
228 |
msgstr ""
|
229 |
|
230 |
-
#:
|
231 |
-
msgid "
|
232 |
msgstr ""
|
233 |
|
234 |
-
#:
|
235 |
-
msgid "
|
236 |
msgstr ""
|
237 |
|
238 |
-
#:
|
239 |
-
msgid "
|
240 |
msgstr ""
|
241 |
|
242 |
-
#:
|
243 |
-
msgid "
|
244 |
msgstr ""
|
245 |
|
246 |
-
#:
|
247 |
-
msgid "
|
248 |
msgstr ""
|
249 |
|
250 |
-
#:
|
251 |
-
msgid "
|
252 |
msgstr ""
|
253 |
|
254 |
-
#:
|
255 |
-
msgid "
|
256 |
msgstr ""
|
257 |
|
258 |
-
#:
|
259 |
-
msgid "
|
260 |
msgstr ""
|
261 |
|
262 |
-
#:
|
263 |
-
msgid "
|
264 |
msgstr ""
|
265 |
|
266 |
-
#:
|
267 |
-
msgid "
|
268 |
msgstr ""
|
269 |
|
270 |
-
#:
|
271 |
-
msgid "
|
272 |
msgstr ""
|
273 |
|
274 |
-
#:
|
275 |
-
msgid "
|
276 |
msgstr ""
|
277 |
|
278 |
-
#:
|
279 |
-
msgid "
|
280 |
msgstr ""
|
281 |
|
282 |
-
#:
|
283 |
-
msgid "
|
284 |
msgstr ""
|
285 |
|
286 |
-
#:
|
287 |
-
msgid "
|
288 |
msgstr ""
|
289 |
|
290 |
-
#:
|
291 |
-
msgid "
|
292 |
msgstr ""
|
293 |
|
294 |
-
#:
|
295 |
-
msgid "
|
296 |
msgstr ""
|
297 |
|
298 |
-
#:
|
299 |
-
msgid "
|
300 |
msgstr ""
|
301 |
|
302 |
-
#:
|
303 |
-
msgid "
|
304 |
msgstr ""
|
305 |
|
306 |
-
#:
|
307 |
-
msgid "
|
308 |
msgstr ""
|
309 |
|
310 |
-
#:
|
311 |
-
msgid "
|
312 |
msgstr ""
|
313 |
|
314 |
-
#:
|
315 |
-
msgid "
|
316 |
msgstr ""
|
317 |
|
318 |
-
#:
|
319 |
-
msgid "
|
320 |
msgstr ""
|
321 |
|
322 |
-
#:
|
323 |
-
msgid "
|
324 |
msgstr ""
|
325 |
|
326 |
-
#:
|
327 |
-
msgid "
|
328 |
msgstr ""
|
329 |
|
330 |
-
#:
|
331 |
-
msgid "
|
332 |
msgstr ""
|
333 |
|
334 |
-
#:
|
335 |
-
msgid "
|
336 |
msgstr ""
|
337 |
|
338 |
-
#:
|
339 |
-
msgid "
|
340 |
msgstr ""
|
341 |
|
342 |
-
#:
|
343 |
-
|
|
|
344 |
msgstr ""
|
345 |
|
346 |
-
#:
|
347 |
-
|
348 |
-
#: system/mw_wp_form_admin_page.php:445
|
349 |
-
msgid "If empty:"
|
350 |
msgstr ""
|
351 |
|
352 |
-
#:
|
353 |
-
msgid "
|
354 |
msgstr ""
|
355 |
|
356 |
-
#:
|
357 |
-
msgid "
|
358 |
msgstr ""
|
359 |
|
360 |
-
#:
|
361 |
-
msgid "
|
362 |
msgstr ""
|
363 |
|
364 |
-
#:
|
365 |
-
msgid "
|
366 |
msgstr ""
|
367 |
|
368 |
-
#:
|
369 |
-
msgid "
|
370 |
msgstr ""
|
371 |
|
372 |
-
#:
|
373 |
-
msgid "
|
374 |
msgstr ""
|
375 |
|
376 |
-
#:
|
377 |
-
msgid "
|
378 |
msgstr ""
|
379 |
|
380 |
-
#:
|
381 |
-
msgid "
|
382 |
msgstr ""
|
383 |
|
384 |
-
#:
|
385 |
msgid "Input Page URL"
|
386 |
msgstr ""
|
387 |
|
388 |
-
#:
|
389 |
msgid "Confirmation Page URL"
|
390 |
msgstr ""
|
391 |
|
392 |
-
#:
|
393 |
msgid "Complete Page URL"
|
394 |
msgstr ""
|
395 |
|
396 |
-
#:
|
397 |
msgid "Validation Error Page URL"
|
398 |
msgstr ""
|
399 |
|
400 |
-
#:
|
401 |
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."
|
402 |
msgstr ""
|
403 |
|
404 |
-
#:
|
405 |
msgid "When a URL doesn't begin http or https, %s is complemented."
|
406 |
msgstr ""
|
407 |
|
408 |
-
#:
|
409 |
msgid "Add Validation rule"
|
410 |
msgstr ""
|
411 |
|
412 |
-
#:
|
413 |
msgid "The key which applies validation"
|
414 |
msgstr ""
|
415 |
|
416 |
-
#:
|
417 |
-
msgid "
|
418 |
-
msgstr ""
|
419 |
-
|
420 |
-
#: system/mw_wp_form_admin_page.php:589 system/mw_wp_form_chart_page.php:172
|
421 |
-
msgid "Select this."
|
422 |
-
msgstr ""
|
423 |
-
|
424 |
-
#: system/mw_wp_form_admin_page.php:590
|
425 |
-
msgid "Input fields"
|
426 |
-
msgstr ""
|
427 |
-
|
428 |
-
#: system/mw_wp_form_admin_page.php:593
|
429 |
-
msgid "Select fields"
|
430 |
-
msgstr ""
|
431 |
-
|
432 |
-
#: system/mw_wp_form_admin_page.php:596
|
433 |
-
msgid "Button fields"
|
434 |
-
msgstr ""
|
435 |
-
|
436 |
-
#: system/mw_wp_form_admin_page.php:599
|
437 |
-
msgid "Error fields"
|
438 |
-
msgstr ""
|
439 |
-
|
440 |
-
#: system/mw_wp_form_admin_page.php:602
|
441 |
-
msgid "Other fields"
|
442 |
msgstr ""
|
443 |
|
444 |
-
#:
|
445 |
-
msgid "Add
|
446 |
-
msgstr ""
|
447 |
-
|
448 |
-
#: system/mw_wp_form_chart_page.php:62 system/mw_wp_form_chart_page.php:63
|
449 |
-
#: system/mw_wp_form_chart_page.php:155
|
450 |
-
msgid "Chart"
|
451 |
-
msgstr ""
|
452 |
-
|
453 |
-
#: system/mw_wp_form_chart_page.php:163
|
454 |
-
msgid "Add Chart"
|
455 |
-
msgstr ""
|
456 |
-
|
457 |
-
#: system/mw_wp_form_chart_page.php:170
|
458 |
-
msgid "Item that create chart"
|
459 |
-
msgstr ""
|
460 |
-
|
461 |
-
#: system/mw_wp_form_chart_page.php:178
|
462 |
-
msgid "Chart type"
|
463 |
msgstr ""
|
464 |
|
465 |
-
#:
|
466 |
-
msgid "
|
467 |
-
msgstr ""
|
468 |
-
|
469 |
-
#: system/mw_wp_form_chart_page.php:183
|
470 |
-
msgid "Bar chart"
|
471 |
-
msgstr ""
|
472 |
-
|
473 |
-
#: system/mw_wp_form_chart_page.php:196
|
474 |
-
msgid "Separator string (If the check box. If the separator attribute is not set to \",\")"
|
475 |
-
msgstr ""
|
476 |
-
|
477 |
-
#: system/mw_wp_form_chart_page.php:217
|
478 |
-
#: system/mw_wp_form_contact_data_page.php:491
|
479 |
-
msgid "The number of inquiries"
|
480 |
msgstr ""
|
481 |
|
482 |
-
#:
|
483 |
-
msgid "
|
484 |
msgstr ""
|
485 |
|
486 |
-
#:
|
487 |
-
msgid "
|
488 |
msgstr ""
|
489 |
|
490 |
-
#:
|
491 |
-
msgid "
|
492 |
msgstr ""
|
493 |
|
494 |
-
#:
|
495 |
-
msgid "
|
496 |
msgstr ""
|
497 |
|
498 |
-
#:
|
499 |
-
msgid "
|
500 |
msgstr ""
|
501 |
|
502 |
-
#:
|
503 |
-
|
|
|
|
|
504 |
msgstr ""
|
505 |
|
506 |
-
#:
|
507 |
-
msgid "
|
508 |
msgstr ""
|
509 |
|
510 |
-
#:
|
511 |
-
msgid "
|
512 |
msgstr ""
|
513 |
|
514 |
-
#:
|
515 |
-
msgid "
|
516 |
msgstr ""
|
517 |
|
518 |
-
#:
|
519 |
-
|
520 |
-
#: system/mw_wp_form_contact_data_page.php:313
|
521 |
-
#: system/mw_wp_form_contact_data_page.php:410
|
522 |
-
msgid "Response Status"
|
523 |
msgstr ""
|
524 |
|
525 |
-
#:
|
526 |
-
|
527 |
-
#: system/mw_wp_form_contact_data_page.php:422
|
528 |
-
msgid "Memo"
|
529 |
msgstr ""
|
530 |
|
531 |
-
#:
|
532 |
-
msgid "
|
533 |
msgstr ""
|
534 |
|
535 |
-
#:
|
536 |
-
msgid "
|
537 |
msgstr ""
|
538 |
|
539 |
-
#:
|
540 |
-
|
541 |
-
#: system/mw_wp_form_contact_data_page.php:483
|
542 |
-
msgid "Inquiry data"
|
543 |
msgstr ""
|
544 |
|
545 |
-
#:
|
546 |
-
msgid "
|
547 |
msgstr ""
|
548 |
|
549 |
-
#:
|
550 |
-
msgid "Form
|
551 |
msgstr ""
|
552 |
|
553 |
-
#:
|
554 |
-
|
555 |
-
msgid "Display Chart"
|
556 |
msgstr ""
|
557 |
|
558 |
-
#:
|
559 |
-
msgid "
|
560 |
msgstr ""
|
561 |
|
562 |
-
#:
|
563 |
-
msgid "
|
564 |
msgstr ""
|
565 |
|
566 |
-
#:
|
567 |
-
msgid "
|
568 |
msgstr ""
|
569 |
|
570 |
-
#:
|
571 |
-
msgid "
|
572 |
msgstr ""
|
573 |
|
574 |
-
#:
|
575 |
-
msgid "
|
576 |
msgstr ""
|
577 |
|
578 |
-
#:
|
579 |
-
msgid "
|
580 |
msgstr ""
|
581 |
|
582 |
-
#:
|
583 |
-
msgid "
|
584 |
msgstr ""
|
585 |
|
586 |
-
#:
|
587 |
-
msgid "
|
588 |
msgstr ""
|
589 |
|
590 |
-
#:
|
591 |
-
msgid "
|
592 |
msgstr ""
|
593 |
|
594 |
-
#:
|
595 |
-
msgid "
|
596 |
msgstr ""
|
597 |
|
598 |
-
#:
|
599 |
-
msgid "
|
600 |
msgstr ""
|
601 |
|
602 |
-
#:
|
603 |
-
msgid "
|
604 |
msgstr ""
|
605 |
|
606 |
-
#:
|
607 |
-
msgid "
|
608 |
msgstr ""
|
609 |
|
610 |
-
#:
|
611 |
-
msgid "
|
612 |
msgstr ""
|
613 |
|
614 |
-
#:
|
615 |
-
msgid "
|
616 |
msgstr ""
|
617 |
|
618 |
-
#:
|
619 |
-
msgid "
|
620 |
msgstr ""
|
621 |
|
622 |
-
#:
|
623 |
-
msgid "
|
624 |
msgstr ""
|
625 |
|
626 |
-
#:
|
627 |
-
msgid "
|
628 |
msgstr ""
|
629 |
|
630 |
-
#:
|
631 |
-
msgid "
|
632 |
msgstr ""
|
633 |
|
634 |
-
#:
|
635 |
-
msgid "
|
636 |
msgstr ""
|
637 |
|
638 |
-
#:
|
639 |
-
msgid "
|
640 |
msgstr ""
|
641 |
|
642 |
-
#:
|
643 |
-
msgid "
|
644 |
msgstr ""
|
645 |
|
646 |
-
#:
|
647 |
-
msgid "
|
648 |
msgstr ""
|
649 |
|
650 |
-
#:
|
651 |
-
msgid "
|
652 |
msgstr ""
|
653 |
|
654 |
-
#:
|
655 |
-
|
|
|
656 |
msgstr ""
|
657 |
|
658 |
-
#:
|
659 |
-
msgid "
|
660 |
msgstr ""
|
661 |
|
662 |
-
#:
|
663 |
-
msgid "
|
664 |
msgstr ""
|
665 |
|
666 |
-
#:
|
667 |
-
msgid "
|
668 |
msgstr ""
|
669 |
|
670 |
-
#:
|
671 |
-
msgid "
|
672 |
msgstr ""
|
673 |
|
674 |
-
#:
|
675 |
-
msgid "
|
676 |
msgstr ""
|
677 |
|
678 |
-
#:
|
679 |
-
msgid "
|
680 |
msgstr ""
|
681 |
|
682 |
-
#:
|
683 |
-
|
684 |
-
msgid "Please enter."
|
685 |
msgstr ""
|
686 |
|
687 |
-
#:
|
688 |
-
msgid "
|
689 |
msgstr ""
|
690 |
|
691 |
-
#:
|
692 |
-
msgid "
|
693 |
msgstr ""
|
694 |
|
695 |
-
#:
|
696 |
-
msgid "
|
697 |
msgstr ""
|
698 |
|
699 |
-
#:
|
700 |
-
msgid "
|
701 |
msgstr ""
|
702 |
|
703 |
-
#:
|
704 |
-
msgid "
|
705 |
msgstr ""
|
706 |
|
707 |
-
#:
|
708 |
-
msgid "
|
709 |
msgstr ""
|
710 |
|
711 |
-
#:
|
712 |
-
msgid "
|
713 |
msgstr ""
|
714 |
|
715 |
-
#:
|
716 |
-
msgid "
|
717 |
msgstr ""
|
718 |
|
719 |
-
#:
|
720 |
-
msgid "
|
721 |
msgstr ""
|
722 |
#. Plugin Name of the plugin/theme
|
723 |
msgid "MW WP Form"
|
@@ -728,7 +742,7 @@ msgid "http://plugins.2inc.org/mw-wp-form/"
|
|
728 |
msgstr ""
|
729 |
|
730 |
#. Description of the plugin/theme
|
731 |
-
msgid "MW WP Form
|
732 |
msgstr ""
|
733 |
|
734 |
#. Author of the plugin/theme
|
1 |
+
# Copyright (C) 2015 MW WP Form
|
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 2.2.0\n"
|
6 |
"Report-Msgid-Bugs-To: http://wordpress.org/tag/mw-wp-form\n"
|
7 |
+
"POT-Creation-Date: 2015-01-13 14:16:40+00:00\n"
|
8 |
"MIME-Version: 1.0\n"
|
9 |
"Content-Type: text/plain; charset=UTF-8\n"
|
10 |
"Content-Transfer-Encoding: 8bit\n"
|
11 |
+
"PO-Revision-Date: 2015-MO-DA HO:MI+ZONE\n"
|
12 |
"Last-Translator: Takashi Kitajima <inc@2inc.org>\n"
|
13 |
"Language-Team: Takashi Kitajima <inc@2inc.org>\n"
|
14 |
"Plural-Forms: nplurals=1; plural=0;\n"
|
15 |
"X-Poedit-SourceCharset: UTF-8\n"
|
16 |
"X-Poedit-Basepath: .\n"
|
17 |
+
"X-Generator: Poedit 1.7.3\n"
|
18 |
"X-Poedit-KeywordsList: __;_e\n"
|
19 |
"X-Poedit-SearchPath-0: ..\n"
|
20 |
|
21 |
+
#: classes/controllers/class.admin-list.php:41
|
22 |
+
#: classes/controllers/class.admin.php:102
|
23 |
+
msgid "Form Key"
|
24 |
+
msgstr ""
|
25 |
+
|
26 |
+
#: classes/controllers/class.admin.php:63
|
27 |
+
msgid "Complete Message"
|
28 |
+
msgstr ""
|
29 |
+
|
30 |
+
#: classes/controllers/class.admin.php:75
|
31 |
+
msgid "URL Options"
|
32 |
+
msgstr ""
|
33 |
+
|
34 |
+
#: classes/controllers/class.admin.php:85
|
35 |
+
msgid "Validation Rule"
|
36 |
+
msgstr ""
|
37 |
+
|
38 |
+
#: classes/controllers/class.admin.php:93
|
39 |
+
msgid "Add-ons"
|
40 |
+
msgstr ""
|
41 |
+
|
42 |
+
#: classes/controllers/class.admin.php:115
|
43 |
+
msgid "Automatic Reply Email Options"
|
44 |
+
msgstr ""
|
45 |
+
|
46 |
+
#: classes/controllers/class.admin.php:130
|
47 |
+
msgid "Admin Email Options"
|
48 |
+
msgstr ""
|
49 |
+
|
50 |
+
#: classes/controllers/class.admin.php:144
|
51 |
+
msgid "settings"
|
52 |
+
msgstr ""
|
53 |
+
|
54 |
+
#: classes/controllers/class.admin.php:156
|
55 |
+
msgid "Style setting"
|
56 |
+
msgstr ""
|
57 |
+
|
58 |
+
#: classes/controllers/class.chart.php:65
|
59 |
+
#: classes/controllers/class.chart.php:66 classes/views/class.chart.php:73
|
60 |
+
msgid "Chart"
|
61 |
+
msgstr ""
|
62 |
+
|
63 |
+
#: classes/controllers/class.contact-data-list.php:120
|
64 |
+
#: classes/controllers/class.contact-data-list.php:167
|
65 |
+
#: classes/controllers/class.contact-data-list.php:260
|
66 |
+
#: classes/views/class.contact-data.php:101
|
67 |
+
msgid "Response Status"
|
68 |
+
msgstr ""
|
69 |
+
|
70 |
+
#: classes/controllers/class.contact-data-list.php:147
|
71 |
+
#: classes/controllers/class.contact-data-list.php:170
|
72 |
+
#: classes/views/class.contact-data.php:113
|
73 |
+
msgid "Memo"
|
74 |
+
msgstr ""
|
75 |
+
|
76 |
+
#: classes/controllers/class.contact-data-list.php:259
|
77 |
+
msgid "Registed Date"
|
78 |
+
msgstr ""
|
79 |
+
|
80 |
+
#: classes/controllers/class.contact-data.php:43
|
81 |
+
#: classes/controllers/class.contact-data.php:44
|
82 |
+
#: classes/views/class.contact-data.php:34
|
83 |
+
msgid "Inquiry data"
|
84 |
+
msgstr ""
|
85 |
+
|
86 |
+
#: classes/controllers/class.contact-data.php:89
|
87 |
+
msgid "Custom Fields"
|
88 |
+
msgstr ""
|
89 |
+
|
90 |
+
#: classes/form-fields/class.akismet_error.php:30
|
91 |
msgid "Akismet Error"
|
92 |
msgstr ""
|
93 |
|
94 |
+
#: classes/form-fields/class.back-button.php:30
|
95 |
+
#: classes/form-fields/class.back-button.php:41
|
96 |
msgid "Back"
|
97 |
msgstr ""
|
98 |
|
99 |
+
#: classes/form-fields/class.back-button.php:69
|
100 |
+
#: classes/form-fields/class.button.php:76
|
101 |
+
#: classes/form-fields/class.confirm-button.php:69
|
102 |
+
#: classes/form-fields/class.submit.php:76
|
103 |
msgid "String on the button"
|
104 |
msgstr ""
|
105 |
|
106 |
+
#: classes/form-fields/class.button.php:30
|
107 |
msgid "Button"
|
108 |
msgstr ""
|
109 |
|
110 |
+
#: classes/form-fields/class.checkbox.php:30
|
111 |
msgid "Checkbox"
|
112 |
msgstr ""
|
113 |
|
114 |
+
#: classes/form-fields/class.checkbox.php:102
|
115 |
+
#: classes/form-fields/class.radio.php:98
|
116 |
+
#: classes/form-fields/class.select.php:96
|
117 |
msgid "Choices"
|
118 |
msgstr ""
|
119 |
|
120 |
+
#: classes/form-fields/class.checkbox.php:106
|
121 |
+
#: classes/form-fields/class.error.php:78
|
122 |
+
#: classes/form-fields/class.radio.php:102
|
123 |
+
#: classes/form-fields/class.select.php:100
|
124 |
msgid "Input one line about one item."
|
125 |
msgstr ""
|
126 |
|
127 |
+
#: classes/form-fields/class.checkbox.php:107
|
128 |
+
#: classes/form-fields/class.radio.php:103
|
129 |
+
#: classes/form-fields/class.select.php:101
|
130 |
+
msgid "Example: value1↵value2 or key1:value1↵key2:value2"
|
131 |
+
msgstr ""
|
132 |
+
|
133 |
+
#: classes/form-fields/class.checkbox.php:111
|
134 |
+
#: classes/form-fields/class.datepicker.php:131
|
135 |
+
#: classes/form-fields/class.hidden.php:79
|
136 |
+
#: classes/form-fields/class.password.php:107
|
137 |
+
#: classes/form-fields/class.radio.php:107
|
138 |
+
#: classes/form-fields/class.select.php:105
|
139 |
+
#: classes/form-fields/class.text.php:115
|
140 |
+
#: classes/form-fields/class.textarea.php:109
|
141 |
msgid "Default value"
|
142 |
msgstr ""
|
143 |
|
144 |
+
#: classes/form-fields/class.checkbox.php:116
|
145 |
msgid "Separator string"
|
146 |
msgstr ""
|
147 |
|
148 |
+
#: classes/form-fields/class.checkbox.php:121
|
149 |
+
#: classes/form-fields/class.radio.php:112
|
150 |
msgid "Display method"
|
151 |
msgstr ""
|
152 |
|
153 |
+
#: classes/form-fields/class.checkbox.php:123
|
154 |
+
#: classes/form-fields/class.radio.php:114
|
155 |
msgid "Arranged vertically."
|
156 |
msgstr ""
|
157 |
|
158 |
+
#: classes/form-fields/class.checkbox.php:126
|
159 |
+
#: classes/form-fields/class.datepicker.php:136
|
160 |
+
#: classes/form-fields/class.file.php:109
|
161 |
+
#: classes/form-fields/class.image.php:110
|
162 |
+
#: classes/form-fields/class.password.php:117
|
163 |
+
#: classes/form-fields/class.radio.php:117
|
164 |
+
#: classes/form-fields/class.select.php:110
|
165 |
+
#: classes/form-fields/class.tel.php:89 classes/form-fields/class.text.php:125
|
166 |
+
#: classes/form-fields/class.textarea.php:119
|
167 |
+
#: classes/form-fields/class.zip.php:89
|
168 |
msgid "Dsiplay error"
|
169 |
msgstr ""
|
170 |
|
171 |
+
#: classes/form-fields/class.checkbox.php:128
|
172 |
+
#: classes/form-fields/class.datepicker.php:138
|
173 |
+
#: classes/form-fields/class.file.php:111
|
174 |
+
#: classes/form-fields/class.image.php:112
|
175 |
+
#: classes/form-fields/class.password.php:119
|
176 |
+
#: classes/form-fields/class.radio.php:119
|
177 |
+
#: classes/form-fields/class.select.php:112
|
178 |
+
#: classes/form-fields/class.tel.php:91 classes/form-fields/class.text.php:127
|
179 |
+
#: classes/form-fields/class.textarea.php:121
|
180 |
+
#: classes/form-fields/class.zip.php:91
|
181 |
msgid "Don't display error."
|
182 |
msgstr ""
|
183 |
|
184 |
+
#: classes/form-fields/class.confirm-button.php:30
|
185 |
msgid "Confirm Button"
|
186 |
msgstr ""
|
187 |
|
188 |
+
#: classes/form-fields/class.confirm-button.php:41
|
189 |
+
#: classes/form-fields/class.submit-button.php:42
|
190 |
msgid "Confirm"
|
191 |
msgstr ""
|
192 |
|
193 |
+
#: classes/form-fields/class.datepicker.php:30
|
194 |
msgid "Datepicker"
|
195 |
msgstr ""
|
196 |
|
197 |
+
#: classes/form-fields/class.error.php:30
|
198 |
msgid "Error Message"
|
199 |
msgstr ""
|
200 |
|
201 |
+
#: classes/form-fields/class.error.php:74
|
202 |
msgid "name of the element which wants to display error"
|
203 |
msgstr ""
|
204 |
|
205 |
+
#: classes/form-fields/class.file.php:30
|
206 |
msgid "File"
|
207 |
msgstr ""
|
208 |
|
209 |
+
#: classes/form-fields/class.file.php:62 classes/form-fields/class.file.php:84
|
210 |
msgid "Uploaded."
|
211 |
msgstr ""
|
212 |
|
213 |
+
#: classes/form-fields/class.hidden.php:23
|
214 |
msgid "Hidden"
|
215 |
msgstr ""
|
216 |
|
217 |
+
#: classes/form-fields/class.hidden.php:84
|
218 |
msgid "Display"
|
219 |
msgstr ""
|
220 |
|
221 |
+
#: classes/form-fields/class.hidden.php:86
|
222 |
msgid "Display hidden value."
|
223 |
msgstr ""
|
224 |
|
225 |
+
#: classes/form-fields/class.image.php:30
|
226 |
msgid "Image"
|
227 |
msgstr ""
|
228 |
|
229 |
+
#: classes/form-fields/class.password.php:30
|
230 |
msgid "Password"
|
231 |
msgstr ""
|
232 |
|
233 |
+
#: classes/form-fields/class.radio.php:30
|
234 |
msgid "Radio"
|
235 |
msgstr ""
|
236 |
|
237 |
+
#: classes/form-fields/class.select.php:30
|
238 |
msgid "Select"
|
239 |
msgstr ""
|
240 |
|
241 |
+
#: classes/form-fields/class.submit-button.php:30
|
242 |
+
msgid "Confirm & Submit"
|
243 |
msgstr ""
|
244 |
|
245 |
+
#: classes/form-fields/class.submit-button.php:43
|
246 |
+
#: classes/form-fields/class.submit.php:42
|
247 |
msgid "Send"
|
248 |
msgstr ""
|
249 |
|
250 |
+
#: classes/form-fields/class.submit-button.php:80
|
|
|
|
|
|
|
|
|
251 |
msgid "String on the confirm button"
|
252 |
msgstr ""
|
253 |
|
254 |
+
#: classes/form-fields/class.submit-button.php:85
|
255 |
msgid "String on the submit button"
|
256 |
msgstr ""
|
257 |
|
258 |
+
#: classes/form-fields/class.submit.php:30
|
259 |
+
msgid "Submit Button"
|
260 |
+
msgstr ""
|
261 |
+
|
262 |
+
#: classes/form-fields/class.tel.php:30
|
263 |
+
#: classes/validation-rules/class.tel.php:54
|
264 |
msgid "Tel"
|
265 |
msgstr ""
|
266 |
|
267 |
+
#: classes/form-fields/class.tel.php:94 classes/form-fields/class.text.php:130
|
268 |
+
#: classes/form-fields/class.zip.php:94
|
269 |
msgid "Convert half alphanumeric"
|
270 |
msgstr ""
|
271 |
|
272 |
+
#: classes/form-fields/class.tel.php:96 classes/form-fields/class.zip.php:96
|
273 |
msgid "Don't Convert."
|
274 |
msgstr ""
|
275 |
|
276 |
+
#: classes/form-fields/class.text.php:30
|
277 |
msgid "Text"
|
278 |
msgstr ""
|
279 |
|
280 |
+
#: classes/form-fields/class.text.php:132
|
281 |
msgid "Convert."
|
282 |
msgstr ""
|
283 |
|
284 |
+
#: classes/form-fields/class.textarea.php:30
|
285 |
msgid "Textarea"
|
286 |
msgstr ""
|
287 |
|
288 |
+
#: classes/form-fields/class.zip.php:30
|
289 |
+
#: classes/validation-rules/class.zip.php:48
|
290 |
msgid "Zip Code"
|
291 |
msgstr ""
|
292 |
|
293 |
+
#: classes/functions.php:198
|
294 |
+
msgid "Uploaded from "
|
295 |
msgstr ""
|
296 |
|
297 |
+
#: classes/functions.php:289
|
298 |
msgid "Tracking Number"
|
299 |
msgstr ""
|
300 |
|
301 |
+
#: classes/models/class.contact-data-setting.php:56
|
302 |
+
msgid "Not supported"
|
303 |
msgstr ""
|
304 |
|
305 |
+
#: classes/models/class.contact-data-setting.php:57
|
306 |
+
msgid "Reservation"
|
307 |
msgstr ""
|
308 |
|
309 |
+
#: classes/models/class.contact-data-setting.php:58
|
310 |
+
msgid "Supported"
|
311 |
msgstr ""
|
312 |
|
313 |
+
#: classes/validation-rules/class.akismet.php:30
|
314 |
+
msgid "The contents which you input were judged with spam."
|
315 |
msgstr ""
|
316 |
|
317 |
+
#: classes/validation-rules/class.alpha.php:33
|
318 |
+
msgid "Please enter with a half-width alphabetic character."
|
319 |
msgstr ""
|
320 |
|
321 |
+
#: classes/validation-rules/class.alpha.php:48
|
322 |
+
msgid "Alphabet"
|
323 |
msgstr ""
|
324 |
|
325 |
+
#: classes/validation-rules/class.alphanumeric.php:33
|
326 |
+
msgid "Please enter with a half-width alphanumeric character."
|
327 |
msgstr ""
|
328 |
|
329 |
+
#: classes/validation-rules/class.alphanumeric.php:48
|
330 |
+
msgid "Alphabet and Numeric"
|
331 |
msgstr ""
|
332 |
|
333 |
+
#: classes/validation-rules/class.between.php:35
|
334 |
+
msgid "The number of characters is invalid."
|
335 |
msgstr ""
|
336 |
|
337 |
+
#: classes/validation-rules/class.between.php:76
|
338 |
+
msgid "The range of the number of characters"
|
339 |
msgstr ""
|
340 |
|
341 |
+
#: classes/validation-rules/class.date.php:32
|
342 |
+
msgid "This is not the format of a date."
|
343 |
msgstr ""
|
344 |
|
345 |
+
#: classes/validation-rules/class.date.php:60
|
346 |
+
msgid "Date"
|
347 |
msgstr ""
|
348 |
|
349 |
+
#: classes/validation-rules/class.eq.php:33
|
350 |
+
msgid "This is not in agreement."
|
351 |
msgstr ""
|
352 |
|
353 |
+
#: classes/validation-rules/class.eq.php:56
|
354 |
+
msgid "The key at same value"
|
355 |
msgstr ""
|
356 |
|
357 |
+
#: classes/validation-rules/class.filesize.php:35
|
358 |
+
msgid "This file size is too big."
|
359 |
msgstr ""
|
360 |
|
361 |
+
#: classes/validation-rules/class.filesize.php:58
|
362 |
+
msgid "Permitted file size"
|
363 |
msgstr ""
|
364 |
|
365 |
+
#: classes/validation-rules/class.filesize.php:59
|
366 |
+
msgid "bytes"
|
367 |
msgstr ""
|
368 |
|
369 |
+
#: classes/validation-rules/class.filetype.php:33
|
370 |
+
msgid "This file is invalid."
|
371 |
msgstr ""
|
372 |
|
373 |
+
#: classes/validation-rules/class.filetype.php:61
|
374 |
+
msgid "Permitted Extension"
|
375 |
msgstr ""
|
376 |
|
377 |
+
#: classes/validation-rules/class.filetype.php:62
|
378 |
+
msgid "Example:jpg or jpg,txt,…"
|
379 |
msgstr ""
|
380 |
|
381 |
+
#: classes/validation-rules/class.hiragana.php:33
|
382 |
+
msgid "Please enter with a Japanese Hiragana."
|
383 |
msgstr ""
|
384 |
|
385 |
+
#: classes/validation-rules/class.hiragana.php:48
|
386 |
+
msgid "Japanese Hiragana"
|
387 |
msgstr ""
|
388 |
|
389 |
+
#: classes/validation-rules/class.in.php:33
|
390 |
+
msgid "This value is invalid."
|
391 |
msgstr ""
|
392 |
|
393 |
+
#: classes/validation-rules/class.katakana.php:33
|
394 |
+
msgid "Please enter with a Japanese Katakana."
|
395 |
msgstr ""
|
396 |
|
397 |
+
#: classes/validation-rules/class.katakana.php:48
|
398 |
+
msgid "Japanese Katakana"
|
399 |
msgstr ""
|
400 |
|
401 |
+
#: classes/validation-rules/class.mail.php:33
|
402 |
+
msgid "This is not the format of a mail address."
|
403 |
msgstr ""
|
404 |
|
405 |
+
#: classes/validation-rules/class.mail.php:48
|
406 |
+
msgid "E-mail"
|
407 |
msgstr ""
|
408 |
|
409 |
+
#: classes/validation-rules/class.minlength.php:34
|
410 |
+
msgid "The number of characters is a few."
|
411 |
msgstr ""
|
412 |
|
413 |
+
#: classes/validation-rules/class.minlength.php:57
|
414 |
+
msgid "The number of the minimum characters"
|
415 |
msgstr ""
|
416 |
|
417 |
+
#: classes/validation-rules/class.noempty.php:32
|
418 |
+
#: classes/validation-rules/class.nofalse.php:32
|
419 |
+
msgid "Please enter."
|
420 |
msgstr ""
|
421 |
|
422 |
+
#: classes/validation-rules/class.noempty.php:46
|
423 |
+
msgid "No empty"
|
|
|
|
|
424 |
msgstr ""
|
425 |
|
426 |
+
#: classes/validation-rules/class.numeric.php:33
|
427 |
+
msgid "Please enter with a half-width number."
|
428 |
msgstr ""
|
429 |
|
430 |
+
#: classes/validation-rules/class.numeric.php:48
|
431 |
+
msgid "Numeric"
|
432 |
msgstr ""
|
433 |
|
434 |
+
#: classes/validation-rules/class.required.php:35
|
435 |
+
msgid "This is required."
|
436 |
msgstr ""
|
437 |
|
438 |
+
#: classes/validation-rules/class.required.php:48
|
439 |
+
msgid "No empty( with checkbox )"
|
440 |
msgstr ""
|
441 |
|
442 |
+
#: classes/validation-rules/class.tel.php:32
|
443 |
+
msgid "This is not the format of a tel number."
|
444 |
msgstr ""
|
445 |
|
446 |
+
#: classes/validation-rules/class.url.php:33
|
447 |
+
msgid "This is not the format of a url."
|
448 |
msgstr ""
|
449 |
|
450 |
+
#: classes/validation-rules/class.url.php:48
|
451 |
+
msgid "URL"
|
452 |
msgstr ""
|
453 |
|
454 |
+
#: classes/validation-rules/class.zip.php:32
|
455 |
+
msgid "This is not the format of a zip code."
|
456 |
msgstr ""
|
457 |
|
458 |
+
#: classes/views/class.admin.php:39
|
459 |
msgid "Input Page URL"
|
460 |
msgstr ""
|
461 |
|
462 |
+
#: classes/views/class.admin.php:45
|
463 |
msgid "Confirmation Page URL"
|
464 |
msgstr ""
|
465 |
|
466 |
+
#: classes/views/class.admin.php:51
|
467 |
msgid "Complete Page URL"
|
468 |
msgstr ""
|
469 |
|
470 |
+
#: classes/views/class.admin.php:57
|
471 |
msgid "Validation Error Page URL"
|
472 |
msgstr ""
|
473 |
|
474 |
+
#: classes/views/class.admin.php:64
|
475 |
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."
|
476 |
msgstr ""
|
477 |
|
478 |
+
#: classes/views/class.admin.php:65
|
479 |
msgid "When a URL doesn't begin http or https, %s is complemented."
|
480 |
msgstr ""
|
481 |
|
482 |
+
#: classes/views/class.admin.php:90
|
483 |
msgid "Add Validation rule"
|
484 |
msgstr ""
|
485 |
|
486 |
+
#: classes/views/class.admin.php:97
|
487 |
msgid "The key which applies validation"
|
488 |
msgstr ""
|
489 |
|
490 |
+
#: classes/views/class.admin.php:121
|
491 |
+
msgid "You can use more easy and useful to the MW WP Form in add-on!"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
492 |
msgstr ""
|
493 |
|
494 |
+
#: classes/views/class.admin.php:122
|
495 |
+
msgid "View Add-ons"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
496 |
msgstr ""
|
497 |
|
498 |
+
#: classes/views/class.admin.php:137
|
499 |
+
msgid "Copy and Paste this shortcode."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
500 |
msgstr ""
|
501 |
|
502 |
+
#: classes/views/class.admin.php:138
|
503 |
+
msgid "The key to use with hook is "
|
504 |
msgstr ""
|
505 |
|
506 |
+
#: classes/views/class.admin.php:156 classes/views/class.admin.php:202
|
507 |
+
msgid "{key} is converted form data."
|
508 |
msgstr ""
|
509 |
|
510 |
+
#: classes/views/class.admin.php:158 classes/views/class.admin.php:204
|
511 |
+
msgid "It is automatically converted to Tracking number when you input {%s}."
|
512 |
msgstr ""
|
513 |
|
514 |
+
#: classes/views/class.admin.php:163 classes/views/class.admin.php:225
|
515 |
+
msgid "Subject"
|
516 |
msgstr ""
|
517 |
|
518 |
+
#: classes/views/class.admin.php:167 classes/views/class.admin.php:229
|
519 |
+
msgid "Sender"
|
520 |
msgstr ""
|
521 |
|
522 |
+
#: classes/views/class.admin.php:169 classes/views/class.admin.php:174
|
523 |
+
#: classes/views/class.admin.php:214 classes/views/class.admin.php:231
|
524 |
+
#: classes/views/class.admin.php:236
|
525 |
+
msgid "If empty:"
|
526 |
msgstr ""
|
527 |
|
528 |
+
#: classes/views/class.admin.php:172 classes/views/class.admin.php:234
|
529 |
+
msgid "From ( E-mail address )"
|
530 |
msgstr ""
|
531 |
|
532 |
+
#: classes/views/class.admin.php:177 classes/views/class.admin.php:239
|
533 |
+
msgid "Content"
|
534 |
msgstr ""
|
535 |
|
536 |
+
#: classes/views/class.admin.php:181
|
537 |
+
msgid "Automatic reply email"
|
538 |
msgstr ""
|
539 |
|
540 |
+
#: classes/views/class.admin.php:183
|
541 |
+
msgid "Input the key to use as transmission to automatic reply email. {} is unnecessary."
|
|
|
|
|
|
|
542 |
msgstr ""
|
543 |
|
544 |
+
#: classes/views/class.admin.php:209
|
545 |
+
msgid "If Admin Email Options is a blank, Automatic Replay Email Options is used as Admin Email Options."
|
|
|
|
|
546 |
msgstr ""
|
547 |
|
548 |
+
#: classes/views/class.admin.php:212
|
549 |
+
msgid "To ( E-mail address )"
|
550 |
msgstr ""
|
551 |
|
552 |
+
#: classes/views/class.admin.php:217
|
553 |
+
msgid "CC ( E-mail address )"
|
554 |
msgstr ""
|
555 |
|
556 |
+
#: classes/views/class.admin.php:221
|
557 |
+
msgid "BCC ( E-mail address )"
|
|
|
|
|
558 |
msgstr ""
|
559 |
|
560 |
+
#: classes/views/class.admin.php:258
|
561 |
+
msgid "Activate Query string of post"
|
562 |
msgstr ""
|
563 |
|
564 |
+
#: classes/views/class.admin.php:259
|
565 |
+
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."
|
566 |
msgstr ""
|
567 |
|
568 |
+
#: classes/views/class.admin.php:260
|
569 |
+
msgid "Example: {ID}, {post_title}, {post_meta} etc..."
|
|
|
570 |
msgstr ""
|
571 |
|
572 |
+
#: classes/views/class.admin.php:263
|
573 |
+
msgid "Saving inquiry data in database"
|
574 |
msgstr ""
|
575 |
|
576 |
+
#: classes/views/class.admin.php:266
|
577 |
+
msgid "Enable scrolling of screen transition."
|
578 |
msgstr ""
|
579 |
|
580 |
+
#: classes/views/class.admin.php:270
|
581 |
+
msgid "Akismet Setting"
|
582 |
msgstr ""
|
583 |
|
584 |
+
#: classes/views/class.admin.php:285
|
585 |
+
msgid "Input the key to use Akismet."
|
586 |
msgstr ""
|
587 |
|
588 |
+
#: classes/views/class.admin.php:298
|
589 |
+
msgid "Select Style"
|
590 |
msgstr ""
|
591 |
|
592 |
+
#: classes/views/class.admin.php:315
|
593 |
+
msgid "Your contribution is needed for making this plugin better."
|
594 |
msgstr ""
|
595 |
|
596 |
+
#: classes/views/class.admin.php:315
|
597 |
+
msgid "Donate"
|
598 |
msgstr ""
|
599 |
|
600 |
+
#: classes/views/class.admin.php:337 classes/views/class.chart.php:93
|
601 |
+
msgid "Select this."
|
602 |
msgstr ""
|
603 |
|
604 |
+
#: classes/views/class.admin.php:338
|
605 |
+
msgid "Input fields"
|
606 |
msgstr ""
|
607 |
|
608 |
+
#: classes/views/class.admin.php:341
|
609 |
+
msgid "Select fields"
|
610 |
msgstr ""
|
611 |
|
612 |
+
#: classes/views/class.admin.php:344
|
613 |
+
msgid "Button fields"
|
614 |
msgstr ""
|
615 |
|
616 |
+
#: classes/views/class.admin.php:347
|
617 |
+
msgid "Error fields"
|
618 |
msgstr ""
|
619 |
|
620 |
+
#: classes/views/class.admin.php:350
|
621 |
+
msgid "Other fields"
|
622 |
msgstr ""
|
623 |
|
624 |
+
#: classes/views/class.admin.php:354
|
625 |
+
msgid "Add form tag"
|
626 |
msgstr ""
|
627 |
|
628 |
+
#: classes/views/class.chart.php:84
|
629 |
+
msgid "Add Chart"
|
630 |
msgstr ""
|
631 |
|
632 |
+
#: classes/views/class.chart.php:91
|
633 |
+
msgid "Item that create chart"
|
634 |
msgstr ""
|
635 |
|
636 |
+
#: classes/views/class.chart.php:99
|
637 |
+
msgid "Chart type"
|
638 |
msgstr ""
|
639 |
|
640 |
+
#: classes/views/class.chart.php:103
|
641 |
+
msgid "Pie chart"
|
642 |
msgstr ""
|
643 |
|
644 |
+
#: classes/views/class.chart.php:104
|
645 |
+
msgid "Bar chart"
|
646 |
msgstr ""
|
647 |
|
648 |
+
#: classes/views/class.chart.php:117
|
649 |
+
msgid "Separator string (If the check box. If the separator attribute is not set to \",\")"
|
650 |
msgstr ""
|
651 |
|
652 |
+
#: classes/views/class.chart.php:139 classes/views/class.contact-data.php:42
|
653 |
+
msgid "The number of inquiries"
|
654 |
msgstr ""
|
655 |
|
656 |
+
#: classes/views/class.contact-data-list.php:34
|
657 |
+
msgid "CSV Download"
|
658 |
msgstr ""
|
659 |
|
660 |
+
#: classes/views/class.contact-data.php:36
|
661 |
+
msgid "You can see the inquiry data that are saved in the database by clicking on the link below."
|
662 |
msgstr ""
|
663 |
|
664 |
+
#: classes/views/class.contact-data.php:40
|
665 |
+
msgid "Form title"
|
666 |
msgstr ""
|
667 |
|
668 |
+
#: classes/views/class.contact-data.php:41
|
669 |
+
#: classes/views/class.contact-data.php:51
|
670 |
+
msgid "Display Chart"
|
671 |
msgstr ""
|
672 |
|
673 |
+
#: classes/views/class.contact-data.php:43
|
674 |
+
msgid "Updated date"
|
675 |
msgstr ""
|
676 |
|
677 |
+
#: classes/views/class.contact-data.php:44
|
678 |
+
msgid "Created date"
|
679 |
msgstr ""
|
680 |
|
681 |
+
#: classes/views/class.contact-data.php:52
|
682 |
+
msgid "cases"
|
683 |
msgstr ""
|
684 |
|
685 |
+
#: classes/views/class.contact-data.php:127
|
686 |
+
msgid "« Back to the list"
|
687 |
msgstr ""
|
688 |
|
689 |
+
#: mw-wp-form.php:171
|
690 |
+
msgid "Add New Form"
|
691 |
msgstr ""
|
692 |
|
693 |
+
#: mw-wp-form.php:172
|
694 |
+
msgid "Edit Form"
|
695 |
msgstr ""
|
696 |
|
697 |
+
#: mw-wp-form.php:173
|
698 |
+
msgid "New Form"
|
|
|
699 |
msgstr ""
|
700 |
|
701 |
+
#: mw-wp-form.php:174
|
702 |
+
msgid "View Form"
|
703 |
msgstr ""
|
704 |
|
705 |
+
#: mw-wp-form.php:175
|
706 |
+
msgid "Search Forms"
|
707 |
msgstr ""
|
708 |
|
709 |
+
#: mw-wp-form.php:176
|
710 |
+
msgid "No Forms found"
|
711 |
msgstr ""
|
712 |
|
713 |
+
#: mw-wp-form.php:177
|
714 |
+
msgid "No Forms found in Trash"
|
715 |
msgstr ""
|
716 |
|
717 |
+
#: mw-wp-form.php:199
|
718 |
+
msgid "Edit "
|
719 |
msgstr ""
|
720 |
|
721 |
+
#: mw-wp-form.php:200
|
722 |
+
msgid "View"
|
723 |
msgstr ""
|
724 |
|
725 |
+
#: mw-wp-form.php:201
|
726 |
+
msgid "Search"
|
727 |
msgstr ""
|
728 |
|
729 |
+
#: mw-wp-form.php:202
|
730 |
+
msgid "No data found"
|
731 |
msgstr ""
|
732 |
|
733 |
+
#: mw-wp-form.php:203
|
734 |
+
msgid "No data found in Trash"
|
735 |
msgstr ""
|
736 |
#. Plugin Name of the plugin/theme
|
737 |
msgid "MW WP Form"
|
742 |
msgstr ""
|
743 |
|
744 |
#. Description of the plugin/theme
|
745 |
+
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."
|
746 |
msgstr ""
|
747 |
|
748 |
#. Author of the plugin/theme
|
mw-wp-form.php
CHANGED
@@ -2,91 +2,81 @@
|
|
2 |
/**
|
3 |
* Plugin Name: MW WP Form
|
4 |
* Plugin URI: http://plugins.2inc.org/mw-wp-form/
|
5 |
-
* Description: MW WP Form
|
6 |
-
* Version: 2.
|
7 |
* Author: Takashi Kitajima
|
8 |
* Author URI: http://2inc.org
|
9 |
* Created : September 25, 2012
|
10 |
-
* Modified:
|
11 |
* Text Domain: mw-wp-form
|
12 |
* Domain Path: /languages/
|
13 |
* License: GPLv2
|
14 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
15 |
*/
|
16 |
-
include_once( plugin_dir_path( __FILE__ ) . '
|
17 |
-
include_once( plugin_dir_path( __FILE__ ) . '
|
18 |
-
$mw_wp_form = new mw_wp_form();
|
19 |
-
class mw_wp_form {
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
protected $
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
'akismet_check' => '',
|
37 |
-
'noempty'
|
38 |
-
'required'
|
39 |
-
'numeric'
|
40 |
-
'alpha'
|
41 |
-
'alphanumeric'
|
42 |
-
'katakana'
|
43 |
-
'hiragana'
|
44 |
-
'zip'
|
45 |
-
'tel'
|
46 |
-
'mail'
|
47 |
-
'date'
|
48 |
-
'url'
|
49 |
-
'eq'
|
50 |
-
'between'
|
51 |
-
'minlength'
|
52 |
-
'filetype'
|
53 |
-
'filesize'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
);
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
'
|
63 |
-
'
|
64 |
-
'admin_mail_subject' => '',
|
65 |
-
'admin_mail_from' => '',
|
66 |
-
'admin_mail_sender' => '',
|
67 |
-
'admin_mail_content' => '',
|
68 |
-
'querystring' => null,
|
69 |
-
'usedb' => null,
|
70 |
-
'akismet_author' => '',
|
71 |
-
'akismet_author_email' => '',
|
72 |
-
'akismet_author_url' => '',
|
73 |
-
'complete_message' => '',
|
74 |
-
'input_url' => '',
|
75 |
-
'confirmation_url' => '',
|
76 |
-
'complete_url' => '',
|
77 |
-
'validation_error_url' => '',
|
78 |
-
'validation' => array(),
|
79 |
-
'style' => '',
|
80 |
-
'scroll' => null,
|
81 |
);
|
82 |
-
private $form_fields = array();
|
83 |
|
84 |
/**
|
85 |
* __construct
|
86 |
*/
|
87 |
public function __construct() {
|
88 |
-
add_action( 'plugins_loaded', array( $this, '
|
89 |
-
add_action( 'plugins_loaded', array( $this, '
|
90 |
// 有効化した時の処理
|
91 |
register_activation_hook( __FILE__, array( __CLASS__, 'activation' ) );
|
92 |
// アンインストールした時の処理
|
@@ -94,97 +84,130 @@ class mw_wp_form {
|
|
94 |
}
|
95 |
|
96 |
/**
|
97 |
-
*
|
98 |
-
*
|
99 |
-
*/
|
100 |
-
public function
|
101 |
-
|
102 |
-
include_once( plugin_dir_path
|
103 |
-
include_once( plugin_dir_path
|
104 |
-
include_once( plugin_dir_path
|
105 |
-
include_once( plugin_dir_path
|
106 |
-
include_once( plugin_dir_path
|
107 |
-
include_once( plugin_dir_path
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
load_plugin_textdomain( MWF_Config::DOMAIN, false, basename( dirname( __FILE__ ) ) . '/languages' );
|
116 |
|
117 |
-
// 管理画面の実行
|
118 |
-
$this->MW_WP_Form_Admin_Page = new MW_WP_Form_Admin_Page();
|
119 |
-
$MW_WP_Form_Contact_Data_Page = new MW_WP_Form_Contact_Data_Page();
|
120 |
-
$MW_WP_Form_Chart_Page = new MW_WP_Form_Chart_Page();
|
121 |
add_action( 'init', array( $this, 'register_post_type' ) );
|
122 |
|
123 |
// フォームフィールドの読み込み、インスタンス化
|
124 |
-
|
125 |
-
include_once $form_field;
|
126 |
-
$className = basename( $form_field, '.php' );
|
127 |
-
if ( class_exists( $className ) ) {
|
128 |
-
new $className();
|
129 |
-
}
|
130 |
-
}
|
131 |
-
$this->form_fields = apply_filters( 'mwform_form_fields', $this->form_fields );
|
132 |
|
133 |
// バリデーションルールの読み込み、インスタンス化
|
134 |
-
$validation_rules = $this->
|
135 |
-
foreach ( glob( plugin_dir_path( __FILE__ ) . 'validation_rules/*.php' ) as $validation_rule ) {
|
136 |
-
include_once $validation_rule;
|
137 |
-
$className = basename( $validation_rule, '.php' );
|
138 |
-
if ( class_exists( $className ) ) {
|
139 |
-
$instance = new $className( $this->key );
|
140 |
-
$validation_rules[$instance->getName()] = $instance;
|
141 |
-
}
|
142 |
-
}
|
143 |
-
$validation_rules = apply_filters( 'mwform_validation_rules', $validation_rules, $this->key );
|
144 |
-
foreach ( $validation_rules as $validation_name => $instance ) {
|
145 |
-
if ( is_callable( array( $instance, 'admin' ) ) ) {
|
146 |
-
$this->MW_WP_Form_Admin_Page->add_validation_rule( $instance->getName(), $instance );
|
147 |
-
}
|
148 |
-
}
|
149 |
-
$this->validation_rules = $validation_rules;
|
150 |
|
151 |
-
|
|
|
|
|
|
|
152 |
|
153 |
-
|
154 |
-
|
155 |
-
include_once( plugin_dir_path( __FILE__ ) . 'system/mw_form.php' );
|
156 |
-
include_once( plugin_dir_path( __FILE__ ) . 'system/mw_mail.php' );
|
157 |
-
include_once( plugin_dir_path( __FILE__ ) . 'system/mw_validation.php' );
|
158 |
-
include_once( plugin_dir_path( __FILE__ ) . 'system/mw_wp_form_file.php' );
|
159 |
-
add_filter( 'nocache_headers' , array( $this, 'nocache_headers' ) , 1 );
|
160 |
-
add_filter( 'template_include', array( $this, 'main' ), 10000 );
|
161 |
-
add_action( 'parse_request', array( $this, 'remove_query_vars_from_post' ) );
|
162 |
-
}
|
163 |
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
|
|
|
|
|
|
173 |
}
|
174 |
|
175 |
/**
|
176 |
-
*
|
177 |
-
*
|
178 |
*/
|
179 |
-
public function
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
187 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
188 |
}
|
189 |
}
|
190 |
|
@@ -200,10 +223,8 @@ class mw_wp_form {
|
|
200 |
* アンインストールした時の処理
|
201 |
*/
|
202 |
public static function uninstall() {
|
203 |
-
$
|
204 |
-
|
205 |
-
'posts_per_page' => -1,
|
206 |
-
) );
|
207 |
|
208 |
$data_post_ids = array();
|
209 |
foreach ( $forms as $form ) {
|
@@ -214,7 +235,7 @@ class mw_wp_form {
|
|
214 |
foreach ( $data_post_ids as $data_post_id ) {
|
215 |
delete_option( MWF_Config::NAME . '-chart-' . $data_post_id );
|
216 |
$data_posts = get_posts( array(
|
217 |
-
'post_type'
|
218 |
'posts_per_page' => -1,
|
219 |
) );
|
220 |
if ( empty( $data_posts ) ) continue;
|
@@ -223,971 +244,88 @@ class mw_wp_form {
|
|
223 |
}
|
224 |
}
|
225 |
|
226 |
-
include_once( plugin_dir_path( __FILE__ ) . '
|
227 |
$File = new MW_WP_Form_File();
|
228 |
-
$File->
|
229 |
|
230 |
delete_option( MWF_Config::NAME );
|
231 |
}
|
232 |
|
233 |
/**
|
234 |
-
*
|
235 |
-
*
|
236 |
-
*/
|
237 |
-
public function register_post_type() {
|
238 |
-
$this->MW_WP_Form_Admin_Page->register_post_type();
|
239 |
-
}
|
240 |
-
|
241 |
-
/**
|
242 |
-
* original_style
|
243 |
-
* CSS適用
|
244 |
-
*/
|
245 |
-
public function original_style() {
|
246 |
-
$url = plugin_dir_url( __FILE__ );
|
247 |
-
wp_register_style( MWF_Config::NAME, $url . 'css/style.css' );
|
248 |
-
wp_enqueue_style( MWF_Config::NAME );
|
249 |
-
|
250 |
-
$style = $this->options_by_formkey['style'];
|
251 |
-
$styles = apply_filters( 'mwform_styles', array() );
|
252 |
-
if ( is_array( $styles ) && isset( $styles[$style] ) ) {
|
253 |
-
$css = $styles[$style];
|
254 |
-
wp_register_style( MWF_Config::NAME . '_style', $css );
|
255 |
-
wp_enqueue_style( MWF_Config::NAME . '_style' );
|
256 |
-
}
|
257 |
-
}
|
258 |
-
|
259 |
-
/**
|
260 |
-
* original_script
|
261 |
-
* JS適用
|
262 |
-
*/
|
263 |
-
public function original_script() {
|
264 |
-
$url = plugin_dir_url( __FILE__ );
|
265 |
-
wp_register_script( MWF_Config::NAME, $url . 'js/form.js', array( 'jquery' ), false, true );
|
266 |
-
wp_enqueue_script( MWF_Config::NAME );
|
267 |
-
}
|
268 |
-
|
269 |
-
/**
|
270 |
-
* scroll_script
|
271 |
-
*/
|
272 |
-
public function scroll_script() {
|
273 |
-
$url = plugin_dir_url( __FILE__ );
|
274 |
-
wp_register_script( MWF_Config::NAME . '-scroll', $url . 'js/scroll.js', array( 'jquery' ), false, true );
|
275 |
-
wp_localize_script( MWF_Config::NAME . '-scroll', 'mwform_scroll', array(
|
276 |
-
'offset' => apply_filters( 'mwform_scroll_offset_' . $this->key, 0 ),
|
277 |
-
) );
|
278 |
-
wp_enqueue_script( MWF_Config::NAME . '-scroll' );
|
279 |
-
}
|
280 |
-
|
281 |
-
/**
|
282 |
-
* get_shortcode
|
283 |
-
* MW WP Form のショートコードが含まれていればそのショートコードを返す
|
284 |
-
* @param string $content
|
285 |
-
* @return string $_shortcode
|
286 |
*/
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
if ( in_array( $shortcode[2], array( 'mwform', 'mwform_formkey' ) ) ) {
|
292 |
-
return $shortcode;
|
293 |
-
} else {
|
294 |
-
$_shortcode = $this->get_shortcode( $shortcode[5] );
|
295 |
-
if ( $_shortcode ) {
|
296 |
-
return $_shortcode;
|
297 |
-
}
|
298 |
-
}
|
299 |
-
}
|
300 |
-
}
|
301 |
-
}
|
302 |
-
|
303 |
-
/**
|
304 |
-
* main
|
305 |
-
* 表示画面でのプラグインの処理等。
|
306 |
-
* @param string $template
|
307 |
-
* @return string $template
|
308 |
-
*/
|
309 |
-
public function main( $template ) {
|
310 |
-
global $post;
|
311 |
-
|
312 |
-
// URL設定を取得
|
313 |
-
add_shortcode( 'mwform', array( $this, '_meta_mwform' ) );
|
314 |
-
// formkeyでのフォーム生成の場合はそれをもとに設定を取得
|
315 |
-
add_shortcode( 'mwform_formkey', array( $this, '_meta_mwform_formkey' ) );
|
316 |
-
|
317 |
-
if ( is_singular() && !empty( $post->ID ) ) {
|
318 |
-
$shortcode = $this->get_shortcode( $post->post_content );
|
319 |
-
}
|
320 |
-
if ( empty( $shortcode ) && !( defined( 'MWFORM_NOT_USE_TEMPLATE' ) && MWFORM_NOT_USE_TEMPLATE === true ) ) {
|
321 |
-
$template_data = @file_get_contents( $template );
|
322 |
-
$shortcode = $this->get_shortcode( $template_data );
|
323 |
-
}
|
324 |
-
if ( is_array( $shortcode ) && !empty( $shortcode[0] ) ) {
|
325 |
-
do_shortcode( $shortcode[0] );
|
326 |
}
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
is_null( $this->confirm ) ||
|
334 |
-
is_null( $this->complete ) ||
|
335 |
-
is_null( $this->validation_error ) )
|
336 |
-
return $template;
|
337 |
-
|
338 |
-
nocache_headers();
|
339 |
-
|
340 |
-
// セッション初期化
|
341 |
-
$this->Data = MW_WP_Form_Data::getInstance( $this->key );
|
342 |
-
// $_POSTがあるときは$_POST
|
343 |
-
if ( !empty( $_POST ) ) {
|
344 |
-
$this->Data->setValues( stripslashes_deep( $_POST ) );
|
345 |
-
}
|
346 |
-
|
347 |
-
// $_FILESがあるときは$this->dataに統合
|
348 |
-
$files = array();
|
349 |
-
foreach ( $_FILES as $key => $file ) {
|
350 |
-
if ( !isset( $_POST[$key] ) || !empty( $file['name'] ) ) {
|
351 |
-
if ( $file['error'] == UPLOAD_ERR_OK && is_uploaded_file( $file['tmp_name'] ) ) {
|
352 |
-
$this->Data->setValue( $key, $file['name'] );
|
353 |
-
} else {
|
354 |
-
$this->Data->setValue( $key, '' );
|
355 |
-
}
|
356 |
-
if ( !empty( $file['name'] ) ) {
|
357 |
-
$files[$key] = $file;
|
358 |
-
}
|
359 |
-
}
|
360 |
-
}
|
361 |
-
// この条件判定がないと fileSize チェックが正しく動作しない
|
362 |
-
if ( $files ) {
|
363 |
-
$this->Data->setValue( MWF_Config::UPLOAD_FILES, $files );
|
364 |
-
}
|
365 |
-
|
366 |
-
// フォームオブジェクト生成
|
367 |
-
$this->Form = new MW_Form( $this->key );
|
368 |
-
|
369 |
-
// バリデーションオブジェクト生成
|
370 |
-
$this->Validation = new MW_Validation( $this->key );
|
371 |
-
foreach ( $this->validation_rules as $validation_name => $instance ) {
|
372 |
-
if ( is_callable( array( $instance, 'rule' ) ) ) {
|
373 |
-
$this->Validation->add_validation_rule( $instance->getName(), $instance );
|
374 |
-
}
|
375 |
-
}
|
376 |
-
// バリデーション実行(Validation->dataに値がないと$Errorは返さない(true))
|
377 |
-
$this->apply_filters_mwform_validation();
|
378 |
-
|
379 |
-
// ファイル操作オブジェクト生成
|
380 |
-
$this->File = new MW_WP_Form_File();
|
381 |
-
|
382 |
-
// 入力画面(戻る)のとき
|
383 |
-
if ( $this->Form->isBack() ) {
|
384 |
-
$this->redirect( $this->input );
|
385 |
-
}
|
386 |
-
// 確認画面のとき
|
387 |
-
elseif ( $this->Form->isConfirm() ) {
|
388 |
-
$this->fileUpload();
|
389 |
-
if ( $this->Validation->check() ) {
|
390 |
-
$this->viewFlg = 'confirm';
|
391 |
-
$this->redirect( $this->confirm );
|
392 |
-
} else {
|
393 |
-
if ( !empty( $this->validation_error ) ) {
|
394 |
-
$this->redirect( $this->validation_error );
|
395 |
-
} else {
|
396 |
-
$this->redirect( $this->input );
|
397 |
-
}
|
398 |
-
}
|
399 |
-
}
|
400 |
-
// 完了画面のとき
|
401 |
-
elseif ( $this->Form->isComplete() ) {
|
402 |
-
$this->fileUpload();
|
403 |
-
if ( $this->Validation->check() ) {
|
404 |
-
$this->viewFlg = 'complete';
|
405 |
-
|
406 |
-
if ( $this->Data->getValue( $this->Form->getTokenName() ) ) {
|
407 |
-
$this->apply_filters_mwform_mail();
|
408 |
-
$this->Data->clearValue( $this->Form->getTokenName() );
|
409 |
-
|
410 |
-
// 手動フォーム対応
|
411 |
-
$REQUEST_URI = $this->parse_url( $this->get_request_uri() );
|
412 |
-
$input = $this->parse_url( $this->input );
|
413 |
-
$complete = $this->parse_url( $this->complete );
|
414 |
-
if ( !$this->options_by_formkey && $REQUEST_URI !== $complete && $input !== $complete ) {
|
415 |
-
$this->Data->clearValues();
|
416 |
-
}
|
417 |
-
}
|
418 |
-
|
419 |
-
$this->redirect( $this->complete );
|
420 |
-
} else {
|
421 |
-
if ( !empty( $this->validation_error ) ) {
|
422 |
-
$this->redirect( $this->validation_error );
|
423 |
-
} else {
|
424 |
-
$this->redirect( $this->input );
|
425 |
-
}
|
426 |
-
}
|
427 |
-
} else {
|
428 |
-
// 完了 or 確認画面 or エラーURLが設定済みで
|
429 |
-
// 完了 or 確認画面 or エラーに直接アクセスした場合、
|
430 |
-
// 入力画面に戻れれば戻る。戻れない場合はトップに戻す
|
431 |
-
$REQUEST_URI = $this->parse_url( $this->get_request_uri() );
|
432 |
-
$check_urls = array(
|
433 |
-
$this->confirm,
|
434 |
-
$this->complete,
|
435 |
-
);
|
436 |
-
$back_url = ( $this->input ) ? $this->input : home_url();
|
437 |
-
foreach ( $check_urls as $check_url ) {
|
438 |
-
if ( $REQUEST_URI === $check_url ) {
|
439 |
-
$this->Data->clearValues();
|
440 |
-
$this->redirect( $back_url );
|
441 |
-
}
|
442 |
-
}
|
443 |
-
$this->redirect( $this->input );
|
444 |
-
|
445 |
-
if ( $this->Validation->check() && $REQUEST_URI == $this->validation_error ) {
|
446 |
-
$this->Data->clearValues();
|
447 |
-
$this->redirect( $back_url );
|
448 |
-
}
|
449 |
-
}
|
450 |
-
|
451 |
-
// スクロール用スクリプトのロード
|
452 |
-
if ( !empty( $this->options_by_formkey['scroll'] ) ) {
|
453 |
-
if ( $this->Form->isConfirm() || $this->Form->isComplete() || !$this->Validation->check() ) {
|
454 |
-
add_action( 'wp_enqueue_scripts', array( $this, 'scroll_script' ) );
|
455 |
-
}
|
456 |
-
}
|
457 |
-
|
458 |
-
add_shortcode( 'mwform_formkey', array( $this, '_mwform_formkey' ) );
|
459 |
-
add_shortcode( 'mwform', array( $this, '_mwform' ) );
|
460 |
-
add_shortcode( 'mwform_complete_message', array( $this, '_mwform_complete_message' ) );
|
461 |
-
add_action( 'wp_footer', array( $this->Data, 'clearValues' ) );
|
462 |
-
add_action( 'wp_enqueue_scripts', array( $this, 'original_style' ) );
|
463 |
-
add_action( 'wp_enqueue_scripts', array( $this, 'original_script' ) );
|
464 |
-
return $template;
|
465 |
-
}
|
466 |
-
|
467 |
-
/**
|
468 |
-
* _meta_mwform
|
469 |
-
* [mwform〜]を解析し、プロパティを設定
|
470 |
-
* @param array $atts
|
471 |
-
*/
|
472 |
-
public function _meta_mwform( $atts ) {
|
473 |
-
$atts = shortcode_atts( array(
|
474 |
-
'input' => '',
|
475 |
-
'confirm' => '',
|
476 |
-
'complete' => '',
|
477 |
-
'validation_error' => '',
|
478 |
-
'key' => 'mwform'
|
479 |
-
), $atts );
|
480 |
-
$this->key = $atts['key'];
|
481 |
-
$this->input = $this->parse_url( $atts['input'] );
|
482 |
-
if ( $atts['confirm'] ) {
|
483 |
-
$this->confirm = $this->parse_url( $atts['confirm'] );
|
484 |
-
} else {
|
485 |
-
$this->confirm = $this->parse_url( $atts['confirm'] );
|
486 |
-
}
|
487 |
-
$this->complete = $this->parse_url( $atts['complete'] );
|
488 |
-
$this->validation_error = $this->parse_url( $atts['validation_error'] );
|
489 |
-
}
|
490 |
-
|
491 |
-
/**
|
492 |
-
* _meta_mwform_formkey
|
493 |
-
* formkeyをもとにフォームの設定を取得
|
494 |
-
*/
|
495 |
-
public function _meta_mwform_formkey( $atts ) {
|
496 |
-
global $post;
|
497 |
-
$atts = shortcode_atts( array(
|
498 |
-
'key' => ''
|
499 |
-
), $atts );
|
500 |
-
$post = get_post( $atts['key'] );
|
501 |
-
if ( !empty( $post ) ) {
|
502 |
-
setup_postdata( $post );
|
503 |
-
if ( get_post_type() === MWF_Config::NAME ) {
|
504 |
-
$this->options_by_formkey = array_merge(
|
505 |
-
$this->defaults,
|
506 |
-
( array )get_post_meta( $post->ID, MWF_Config::NAME, true )
|
507 |
-
);
|
508 |
-
$this->options_by_formkey['post_id'] = $post->ID;
|
509 |
-
$this->key = MWF_Config::NAME . '-' . $atts['key'];
|
510 |
-
$this->input = $this->parse_url( $this->options_by_formkey['input_url'] );
|
511 |
-
$this->confirm = $this->parse_url( $this->options_by_formkey['confirmation_url'] );
|
512 |
-
$this->complete = $this->parse_url( $this->options_by_formkey['complete_url'] );
|
513 |
-
$this->validation_error = $this->parse_url( $this->options_by_formkey['validation_error_url'] );
|
514 |
-
}
|
515 |
-
}
|
516 |
-
wp_reset_postdata();
|
517 |
-
}
|
518 |
-
|
519 |
-
/**
|
520 |
-
* apply_filters_mwform_validation
|
521 |
-
* バリデーション用フィルタ。フィルタの実行結果としてValidationオブジェクトが返ってこなければエラー
|
522 |
-
* 各バリデーションメソッドの詳細は /system/mw_validation.php を参照
|
523 |
-
*/
|
524 |
-
protected function apply_filters_mwform_validation() {
|
525 |
-
$filterName = 'mwform_validation_' . $this->key;
|
526 |
-
|
527 |
-
if ( $this->options_by_formkey ) {
|
528 |
-
foreach ( $this->options_by_formkey['validation'] as $validation ) {
|
529 |
-
foreach ( $validation as $key => $value ) {
|
530 |
-
if ( $key == 'target' ) continue;
|
531 |
-
if ( is_array( $value ) ) {
|
532 |
-
$this->Validation->setRule( $validation['target'], $key, $value );
|
533 |
-
} else {
|
534 |
-
$this->Validation->setRule( $validation['target'], $key );
|
535 |
-
}
|
536 |
-
}
|
537 |
-
}
|
538 |
-
}
|
539 |
-
|
540 |
-
$Akismet = new MW_Akismet();
|
541 |
-
$akismet_check = $Akismet->check(
|
542 |
-
$this->options_by_formkey['akismet_author'],
|
543 |
-
$this->options_by_formkey['akismet_author_email'],
|
544 |
-
$this->options_by_formkey['akismet_author_url'],
|
545 |
-
$this->Data
|
546 |
-
);
|
547 |
-
if ( $akismet_check ) {
|
548 |
-
$this->Validation->setRule( MWF_Config::AKISMET, 'akismet_check' );
|
549 |
-
}
|
550 |
-
|
551 |
-
$this->Validation = apply_filters( $filterName, $this->Validation, $this->Data->getValues() );
|
552 |
-
if ( !is_a( $this->Validation, 'MW_Validation' ) ) {
|
553 |
-
exit( esc_html__( 'Validation Object is not a MW Validation Class.', MWF_Config::DOMAIN ) );
|
554 |
-
}
|
555 |
-
}
|
556 |
-
|
557 |
-
/**
|
558 |
-
* apply_filters_mwform_mail
|
559 |
-
* メール送信フィルター
|
560 |
-
*/
|
561 |
-
protected function apply_filters_mwform_mail() {
|
562 |
-
$Mail = new MW_Mail();
|
563 |
-
$Mail_raw = clone $Mail;
|
564 |
-
|
565 |
-
if ( $this->options_by_formkey ) {
|
566 |
-
$Mail_raw = $this->set_admin_mail_raw_params( $Mail_raw );
|
567 |
-
|
568 |
-
// 添付ファイルのデータをためた配列を作成
|
569 |
-
$attachments = array();
|
570 |
-
// $Mail->attachments を設定(メールにファイルを添付)
|
571 |
-
$upload_file_keys = $this->Data->getValue( MWF_Config::UPLOAD_FILE_KEYS );
|
572 |
-
if ( $upload_file_keys !== null && is_array( $upload_file_keys ) ) {
|
573 |
-
$wp_upload_dir = wp_upload_dir();
|
574 |
-
foreach ( $upload_file_keys as $key ) {
|
575 |
-
$upload_file_url = $this->Data->getValue( $key );
|
576 |
-
if ( !$upload_file_url )
|
577 |
-
continue;
|
578 |
-
$filepath = MWF_Functions::fileurl_to_path( $upload_file_url );
|
579 |
-
if ( file_exists( $filepath ) ) {
|
580 |
-
$filepath = $this->File->moveTempFileToUploadDir( $filepath );
|
581 |
-
$new_upload_file_url = MWF_Functions::filepath_to_url( $filepath );
|
582 |
-
$attachments[$key] = $filepath;
|
583 |
-
$this->Data->setValue( $key, $new_upload_file_url );
|
584 |
-
}
|
585 |
-
}
|
586 |
-
$Mail_raw->attachments = $attachments;
|
587 |
-
}
|
588 |
-
|
589 |
-
$filter_name = 'mwform_admin_mail_raw_' . $this->key;
|
590 |
-
$Mail_raw = apply_filters( $filter_name, $Mail_raw, $this->Data->getValues() );
|
591 |
-
if ( !is_a( $Mail_raw, 'MW_Mail' ) )
|
592 |
-
return;
|
593 |
-
|
594 |
-
$Mail = $this->parse_mail_object( $Mail_raw );
|
595 |
-
$Mail = $this->set_admin_mail_reaquire_params( $Mail );
|
596 |
-
}
|
597 |
-
|
598 |
-
$filter_name = 'mwform_mail_' . $this->key;
|
599 |
-
$Mail = apply_filters( $filter_name, $Mail, $this->Data->getValues() );
|
600 |
-
|
601 |
-
if ( $this->options_by_formkey && is_a( $Mail, 'MW_Mail' ) && is_a( $Mail_raw, 'MW_Mail' ) ) {
|
602 |
-
|
603 |
-
// メール送信前にファイルのリネームをしないと、tempファイル名をメールで送信してしまう。
|
604 |
-
if ( !empty( $this->options_by_formkey['usedb'] ) ) {
|
605 |
-
// save_mail_body で登録されないように
|
606 |
-
foreach ( $attachments as $key => $filepath ) {
|
607 |
-
$this->Data->clearValue( $key );
|
608 |
-
}
|
609 |
-
|
610 |
-
// $this->insert_id を設定 ( save_mail_body で 使用 )
|
611 |
-
$this->insert_id = wp_insert_post( array(
|
612 |
-
'post_title' => $Mail->subject,
|
613 |
-
'post_status' => 'publish',
|
614 |
-
'post_type' => MWF_Config::DBDATA . $this->options_by_formkey['post_id'],
|
615 |
-
) );
|
616 |
-
// 保存
|
617 |
-
$this->save_mail_body( $Mail_raw->body );
|
618 |
-
|
619 |
-
// 添付ファイルをメディアに保存
|
620 |
-
if ( !empty( $this->insert_id ) ) {
|
621 |
-
$this->File->saveAttachmentsInMedia(
|
622 |
-
$this->insert_id,
|
623 |
-
$attachments,
|
624 |
-
$this->options_by_formkey['post_id']
|
625 |
-
);
|
626 |
-
}
|
627 |
-
}
|
628 |
-
|
629 |
-
$filter_name = 'mwform_admin_mail_' . $this->key;
|
630 |
-
$Mail = apply_filters( $filter_name, $Mail, $this->Data->getValues() );
|
631 |
-
if ( !is_a( $Mail, 'MW_Mail' ) )
|
632 |
-
return;
|
633 |
-
$Mail->send();
|
634 |
-
|
635 |
-
// DB非保存時は管理者メール送信後、ファイルを削除
|
636 |
-
if ( empty( $this->options_by_formkey['usedb'] ) ) {
|
637 |
-
foreach ( $attachments as $filepath ) {
|
638 |
-
if ( file_exists( $filepath ) )
|
639 |
-
unlink( $filepath );
|
640 |
-
}
|
641 |
-
}
|
642 |
-
|
643 |
-
if ( isset( $this->options_by_formkey['automatic_reply_email'] ) ) {
|
644 |
-
$automatic_reply_email = $this->Data->getValue( $this->options_by_formkey['automatic_reply_email'] );
|
645 |
-
if ( $automatic_reply_email && !$this->validation_rules['mail']->rule( $automatic_reply_email ) ) {
|
646 |
-
$Mail_auto_raw = $this->set_reply_mail_raw_params( clone $Mail_raw );
|
647 |
-
|
648 |
-
// 自動返信メールからは添付ファイルを削除
|
649 |
-
$Mail_auto_raw->attachments = array();
|
650 |
-
|
651 |
-
$filter_name = 'mwform_auto_mail_raw_' . $this->key;
|
652 |
-
$Mail_auto_raw = apply_filters( $filter_name, $Mail_auto_raw, $this->Data->getValues() );
|
653 |
-
if ( !is_a( $Mail_auto_raw, 'MW_Mail' ) )
|
654 |
-
return;
|
655 |
-
|
656 |
-
$Mail_auto = $this->parse_mail_object( $Mail_auto_raw );
|
657 |
-
$Mail_auto = $this->set_reply_mail_reaquire_params( $Mail_auto );
|
658 |
-
|
659 |
-
$filter_name = 'mwform_auto_mail_' . $this->key;
|
660 |
-
$Mail_auto = apply_filters( $filter_name, $Mail_auto, $this->Data->getValues() );
|
661 |
-
if ( !is_a( $Mail_auto, 'MW_Mail' ) )
|
662 |
-
return;
|
663 |
-
$Mail_auto->send();
|
664 |
-
}
|
665 |
-
}
|
666 |
-
|
667 |
-
// 問い合わせ番号を加算
|
668 |
-
if ( preg_match( '{' . MWF_Config::TRACKINGNUMBER . '}', $Mail_raw->body, $reg ) ) {
|
669 |
-
$form_id = $this->options_by_formkey['post_id'];
|
670 |
-
$tracking_number = $this->get_tracking_number( $form_id );
|
671 |
-
$new_tracking_number = $tracking_number + 1;
|
672 |
-
update_post_meta( $form_id, MWF_Config::TRACKINGNUMBER, $new_tracking_number );
|
673 |
-
}
|
674 |
-
}
|
675 |
-
}
|
676 |
-
|
677 |
-
/**
|
678 |
-
* parse_mail_object
|
679 |
-
* @param MW_Mail $obj
|
680 |
-
* @return MW_Mail $parsed_obj
|
681 |
-
*/
|
682 |
-
private function parse_mail_object( MW_Mail $obj ) {
|
683 |
-
$parsed_obj = clone $obj;
|
684 |
-
$parsed_obj_vars = get_object_vars( $parsed_obj );
|
685 |
-
foreach ( $parsed_obj_vars as $key => $value ) {
|
686 |
-
if ( is_array( $value ) || $key == 'to' || $key == 'cc' || $key == 'bcc' )
|
687 |
-
continue;
|
688 |
-
$value = $this->parse_mail_content( $value );
|
689 |
-
$parsed_obj->$key = $value;
|
690 |
-
}
|
691 |
-
return $parsed_obj;
|
692 |
-
}
|
693 |
-
|
694 |
-
/**
|
695 |
-
* parse_mail_content
|
696 |
-
* メール本文用に {name属性} を置換
|
697 |
-
* @param string $value
|
698 |
-
* @return string
|
699 |
-
*/
|
700 |
-
public function parse_mail_content( $value ) {
|
701 |
-
return preg_replace_callback(
|
702 |
-
'/{(.+?)}/',
|
703 |
-
array( $this, '_parse_mail_content' ),
|
704 |
-
$value
|
705 |
-
);
|
706 |
-
}
|
707 |
-
public function _parse_mail_content( $matches ) {
|
708 |
-
return $this->parse_mail_body( $matches, false );
|
709 |
-
}
|
710 |
-
|
711 |
-
/**
|
712 |
-
* save_mail_body
|
713 |
-
* DB保存用に {name属性} を置換、保存
|
714 |
-
*/
|
715 |
-
public function save_mail_body( $value ) {
|
716 |
-
return preg_replace_callback(
|
717 |
-
'/{(.+?)}/',
|
718 |
-
array( $this, '_save_mail_body' ),
|
719 |
-
$value
|
720 |
-
);
|
721 |
-
}
|
722 |
-
public function _save_mail_body( $matches ) {
|
723 |
-
return $this->parse_mail_body( $matches, true );
|
724 |
-
}
|
725 |
-
|
726 |
-
/**
|
727 |
-
* parse_mail_body
|
728 |
-
* $this->create_mail_body(), $this->save_mail_body の本体
|
729 |
-
* 第2引数でDB保存するか判定
|
730 |
-
* @param array $matches
|
731 |
-
* @param bool $doUpdate
|
732 |
-
* @return string $value
|
733 |
-
*/
|
734 |
-
protected function parse_mail_body( $matches, $doUpdate = false ) {
|
735 |
-
$match = $matches[1];
|
736 |
-
// MWF_Config::TRACKINGNUMBER のときはお問い合せ番号を参照する
|
737 |
-
if ( $match === MWF_Config::TRACKINGNUMBER ) {
|
738 |
-
if ( !empty( $this->options_by_formkey['post_id'] ) ) {
|
739 |
-
$form_id = $this->options_by_formkey['post_id'];
|
740 |
-
$tracking_number_title = esc_html__( 'Tracking Number', MWF_Config::DOMAIN );
|
741 |
-
$match = apply_filters( 'mwform_tracking_number_title_' . $this->key, $tracking_number_title );
|
742 |
-
$value = $this->get_tracking_number( $form_id );
|
743 |
-
}
|
744 |
-
} else {
|
745 |
-
$value = $this->Data->get( $match );
|
746 |
-
}
|
747 |
-
if ( $value !== null && $doUpdate ) {
|
748 |
-
update_post_meta( $this->insert_id, $match, $value );
|
749 |
-
}
|
750 |
-
return $value;
|
751 |
-
}
|
752 |
-
|
753 |
-
/**
|
754 |
-
* redirect
|
755 |
-
* 現在のURLと引数で渡されたリダイレクトURLが同じであればリダイレクトしない
|
756 |
-
* @param string リダイレクトURL
|
757 |
-
*/
|
758 |
-
private function redirect( $url ) {
|
759 |
-
$redirect = ( empty( $url ) ) ? $this->get_request_uri() : $url;
|
760 |
-
$redirect = $this->parse_url( $redirect );
|
761 |
-
$REQUEST_URI = $this->parse_url( $this->get_request_uri() );
|
762 |
-
if ( !empty( $_POST ) || $redirect != $REQUEST_URI ) {
|
763 |
-
$redirect = wp_sanitize_redirect( $redirect );
|
764 |
-
$redirect = wp_validate_redirect( $redirect, home_url() );
|
765 |
-
wp_redirect( $redirect );
|
766 |
-
exit();
|
767 |
-
}
|
768 |
-
}
|
769 |
-
|
770 |
-
/**
|
771 |
-
* get_request_uri
|
772 |
-
* $_SERVER['REQUEST_URI'] を http:// からはじまるURLに変換する
|
773 |
-
* @return string URL
|
774 |
-
*/
|
775 |
-
protected function get_request_uri() {
|
776 |
-
$_REQUEST_URI = $_SERVER['REQUEST_URI'];
|
777 |
-
if ( !preg_match( '/^https?:\/\//', $_REQUEST_URI ) ) {
|
778 |
-
$REQUEST_URI = home_url() . $_REQUEST_URI;
|
779 |
-
$parse_url = parse_url( home_url() );
|
780 |
-
// サブディレクトリ型の場合
|
781 |
-
if ( !empty( $parse_url['path'] ) ) {
|
782 |
-
$pettern = preg_quote( $parse_url['path'], '/' );
|
783 |
-
if ( preg_match( '/^' . $pettern . '/', $_REQUEST_URI ) ) {
|
784 |
-
$REQUEST_URI = preg_replace( '/' . $pettern . '$/', $_REQUEST_URI, home_url() );
|
785 |
}
|
|
|
786 |
}
|
787 |
-
} else {
|
788 |
-
$REQUEST_URI = $_REQUEST_URI;
|
789 |
}
|
790 |
-
|
791 |
}
|
792 |
|
793 |
/**
|
794 |
-
*
|
795 |
-
*
|
796 |
-
* @
|
797 |
-
* @return string URL
|
798 |
*/
|
799 |
-
protected function
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
$
|
804 |
-
preg_match( '/\?(.*)$/', $url, $reg );
|
805 |
-
if ( !empty( $reg[1] ) ) {
|
806 |
-
$url = str_replace( '?', '', $url );
|
807 |
-
$url = str_replace( $reg[1], '', $url );
|
808 |
-
parse_str( $reg[1], $query_string );
|
809 |
-
}
|
810 |
-
if ( !preg_match( '/^https?:\/\//', $url ) ) {
|
811 |
-
$home_url = home_url();
|
812 |
-
$url = $home_url . $url;
|
813 |
-
}
|
814 |
-
$url = preg_replace( '/([^:])\/+/', '$1/', $url );
|
815 |
-
|
816 |
-
// URL設定でURL引数が使用されている場合はそれを使う。
|
817 |
-
// 「URL引数を有効にする」が有効の場合は $_GET を利用する(重複するURL引数はURL設定のものが優先される ※post_id除く)
|
818 |
-
if ( !empty( $this->options_by_formkey['querystring'] ) ) {
|
819 |
-
$query_string = array_merge( $_GET, $query_string );
|
820 |
-
if ( isset( $_GET['post_id'] ) && MWF_Functions::is_numeric( $_GET['post_id'] ) ) {
|
821 |
-
$query_string['post_id'] = $_GET['post_id'];
|
822 |
-
}
|
823 |
-
}
|
824 |
-
|
825 |
-
if ( !empty( $query_string ) )
|
826 |
-
$url = $url . '?' . http_build_query( $query_string, null, '&' );
|
827 |
-
return $url;
|
828 |
}
|
829 |
|
830 |
/**
|
831 |
-
*
|
832 |
-
*
|
833 |
-
* @
|
834 |
-
*
|
835 |
*/
|
836 |
-
|
837 |
-
|
838 |
-
$
|
839 |
-
|
840 |
-
|
841 |
-
$post = get_post( $atts['key'] );
|
842 |
-
setup_postdata( $post );
|
843 |
-
|
844 |
-
// 入力画面・確認画面
|
845 |
-
if ( $this->viewFlg == 'input' || $this->viewFlg == 'confirm' ) {
|
846 |
-
$content = apply_filters( 'mwform_post_content_raw_' . $this->key, get_the_content() );
|
847 |
-
if ( has_filter( 'the_content', 'wpautop' ) ) {
|
848 |
-
$content = wpautop( $content );
|
849 |
-
}
|
850 |
-
$_ret ='[mwform]' . apply_filters( 'mwform_post_content_' . $this->key, $content ) . '[/mwform]';
|
851 |
-
}
|
852 |
-
// 完了画面
|
853 |
-
elseif( $this->viewFlg == 'complete' ) {
|
854 |
-
$content = $this->options_by_formkey['complete_message'];
|
855 |
-
if ( has_filter( 'the_content', 'wpautop' ) ) {
|
856 |
-
$content = wpautop( $content );
|
857 |
-
}
|
858 |
-
$_ret = '[mwform_complete_message]' . $content . '[/mwform_complete_message]';
|
859 |
}
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
* _mwform
|
867 |
-
* フォームを出力
|
868 |
-
*/
|
869 |
-
public function _mwform( $atts, $content = '' ) {
|
870 |
-
if ( $this->viewFlg == 'input' || $this->viewFlg == 'confirm' ) {
|
871 |
-
$this->Error = $this->Validation->Error();
|
872 |
-
do_action( 'mwform_add_shortcode', $this->Form, $this->viewFlg, $this->Error, $this->key );
|
873 |
-
|
874 |
-
// ユーザー情報取得
|
875 |
-
$content = $this->replace_user_property( $content );
|
876 |
-
|
877 |
-
// 投稿情報取得
|
878 |
-
if ( isset( $this->options_by_formkey['querystring'] ) )
|
879 |
-
$querystring = $this->options_by_formkey['querystring'];
|
880 |
-
if ( !empty( $querystring ) ) {
|
881 |
-
$content = preg_replace_callback( '/{(.+?)}/', array( $this, 'get_post_property_from_querystring' ), $content );
|
882 |
-
} else {
|
883 |
-
$content = preg_replace_callback( '/{(.+?)}/', array( $this, 'get_post_property_from_this' ), $content );
|
884 |
-
}
|
885 |
-
|
886 |
-
$upload_file_keys = $this->Form->getValue( MWF_Config::UPLOAD_FILE_KEYS );
|
887 |
-
$upload_file_hidden = '';
|
888 |
-
if ( is_array( $upload_file_keys ) ) {
|
889 |
-
foreach ( $upload_file_keys as $value ) {
|
890 |
-
$upload_file_hidden .= $this->Form->hidden( MWF_Config::UPLOAD_FILE_KEYS . '[]', $value );
|
891 |
}
|
|
|
|
|
892 |
}
|
893 |
-
$_preview_class = ( $this->viewFlg === 'confirm' ) ? ' mw_wp_form_preview' : '';
|
894 |
-
$style = $this->options_by_formkey['style'];
|
895 |
-
$class_for_style = ( $style ) ? 'mw_wp_form_' . $style : '';
|
896 |
-
return sprintf(
|
897 |
-
'<div id="mw_wp_form_%s" class="mw_wp_form mw_wp_form_%s %s">%s<!-- end .mw_wp_form --></div>',
|
898 |
-
esc_attr( $this->key ),
|
899 |
-
esc_attr( $this->viewFlg . $_preview_class ),
|
900 |
-
$class_for_style,
|
901 |
-
$this->Form->start() . do_shortcode( $content ) . $upload_file_hidden . $this->Form->end()
|
902 |
-
);
|
903 |
}
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
* ユーザーがログイン中の場合、{ユーザー情報のプロパティ}を置換する。
|
909 |
-
* @param string フォーム内容
|
910 |
-
* @return string フォーム内容
|
911 |
-
*/
|
912 |
-
protected function replace_user_property( $content ) {
|
913 |
-
$user = wp_get_current_user();
|
914 |
-
$search = array(
|
915 |
-
'{user_id}',
|
916 |
-
'{user_login}',
|
917 |
-
'{user_email}',
|
918 |
-
'{user_url}',
|
919 |
-
'{user_registered}',
|
920 |
-
'{display_name}',
|
921 |
);
|
922 |
-
|
923 |
-
$content = str_replace( $search, array(
|
924 |
-
$user->get( 'ID' ),
|
925 |
-
$user->get( 'user_login' ),
|
926 |
-
$user->get( 'user_email' ),
|
927 |
-
$user->get( 'user_url' ),
|
928 |
-
$user->get( 'user_registered' ),
|
929 |
-
$user->get( 'display_name' ),
|
930 |
-
), $content );
|
931 |
-
} else {
|
932 |
-
$content = str_replace( $search, '', $content );
|
933 |
-
}
|
934 |
-
return $content;
|
935 |
-
}
|
936 |
-
|
937 |
-
/**
|
938 |
-
* get_post_property_from_querystring
|
939 |
-
* 引数 post_id が有効の場合、投稿情報を取得するために preg_replace_callback から呼び出される。
|
940 |
-
* @param array $matches
|
941 |
-
* @return string
|
942 |
-
*/
|
943 |
-
public function get_post_property_from_querystring( $matches ) {
|
944 |
-
if ( isset( $this->options_by_formkey['querystring'] ) )
|
945 |
-
$querystring = $this->options_by_formkey['querystring'];
|
946 |
-
if ( !empty( $querystring ) && isset( $_GET['post_id'] ) && MWF_Functions::is_numeric( $_GET['post_id'] ) ) {
|
947 |
-
$_post = get_post( $_GET['post_id'] );
|
948 |
-
if ( empty( $_post->ID ) )
|
949 |
-
return;
|
950 |
-
if ( isset( $_post->$matches[1] ) ) {
|
951 |
-
return $_post->$matches[1];
|
952 |
-
} else {
|
953 |
-
// post_meta の処理
|
954 |
-
$pm = get_post_meta( $_post->ID, $matches[1], true );
|
955 |
-
if ( !empty( $pm ) )
|
956 |
-
return $pm;
|
957 |
-
}
|
958 |
-
}
|
959 |
-
return;
|
960 |
-
}
|
961 |
-
|
962 |
-
/**
|
963 |
-
* get_post_property_from_this
|
964 |
-
* 引数 post_id が無効の場合、投稿情報を取得するために preg_replace_callback から呼び出される。
|
965 |
-
* @param array $matches
|
966 |
-
* @return string
|
967 |
-
*/
|
968 |
-
public function get_post_property_from_this( $matches ) {
|
969 |
-
global $post;
|
970 |
-
if ( !is_singular() )
|
971 |
-
return;
|
972 |
-
$post_id = get_the_ID();
|
973 |
-
if ( isset( $post->ID ) && MWF_Functions::is_numeric( $post->ID ) ) {
|
974 |
-
if ( isset( $post->$matches[1] ) ) {
|
975 |
-
return $post->$matches[1];
|
976 |
-
} else {
|
977 |
-
// post_meta の処理
|
978 |
-
$pm = get_post_meta( $post->ID, $matches[1], true );
|
979 |
-
if ( !empty( $pm ) )
|
980 |
-
return $pm;
|
981 |
-
}
|
982 |
-
}
|
983 |
-
return;
|
984 |
-
}
|
985 |
-
|
986 |
-
/**
|
987 |
-
* _mwform_complete_message
|
988 |
-
* 完了後のメッセージ。
|
989 |
-
*/
|
990 |
-
public function _mwform_complete_message( $atts, $content = '' ) {
|
991 |
-
if ( $this->viewFlg == 'complete' ) {
|
992 |
-
return sprintf(
|
993 |
-
'<div id="mw_wp_form_%s" class="mw_wp_form mw_wp_form_%s">%s<!-- end .mw_wp_form --></div>',
|
994 |
-
esc_attr( $this->key ),
|
995 |
-
esc_attr( $this->viewFlg ),
|
996 |
-
$content
|
997 |
-
);
|
998 |
-
}
|
999 |
-
}
|
1000 |
-
|
1001 |
-
/**
|
1002 |
-
* fileupload
|
1003 |
-
* ファイルアップロード処理。実際のアップロード状況に合わせてフォームデータも再生成する。
|
1004 |
-
*/
|
1005 |
-
protected function fileupload() {
|
1006 |
-
$uploadedFiles = array();
|
1007 |
-
$files = $this->Data->getValue( MWF_Config::UPLOAD_FILES );
|
1008 |
-
if ( !is_array( $files ) ) {
|
1009 |
-
$files = array();
|
1010 |
-
}
|
1011 |
-
foreach ( $files as $key => $file ) {
|
1012 |
-
if ( $this->Validation->singleCheck( $key ) ) {
|
1013 |
-
$uploadedFile = $this->File->singleFileupload( $key );
|
1014 |
-
if ( $uploadedFile ) {
|
1015 |
-
$uploadedFiles[$key] = $uploadedFile;
|
1016 |
-
}
|
1017 |
-
}
|
1018 |
-
}
|
1019 |
-
|
1020 |
-
// 時間切れなどで削除されたファイルのキーを削除
|
1021 |
-
$upload_file_keys = $this->Data->getValue( MWF_Config::UPLOAD_FILE_KEYS );
|
1022 |
-
if ( !$upload_file_keys )
|
1023 |
-
$upload_file_keys = array();
|
1024 |
-
|
1025 |
-
$wp_upload_dir = wp_upload_dir();
|
1026 |
-
foreach ( $upload_file_keys as $upload_file_key ) {
|
1027 |
-
$upload_file_url = $this->Data->getValue( $upload_file_key );
|
1028 |
-
if ( $upload_file_url ) {
|
1029 |
-
$filepath = MWF_Functions::fileurl_to_path( $upload_file_url );
|
1030 |
-
if ( !file_exists( $filepath ) ) {
|
1031 |
-
unset( $upload_file_keys[$upload_file_key] );
|
1032 |
-
}
|
1033 |
-
}
|
1034 |
-
}
|
1035 |
-
$this->Data->setValue( MWF_Config::UPLOAD_FILE_KEYS, $upload_file_keys );
|
1036 |
-
|
1037 |
-
// アップロードに成功したファイルをフォームデータに格納
|
1038 |
-
foreach ( $uploadedFiles as $key => $uploadfile ) {
|
1039 |
-
$this->Data->setValue( $key, $uploadfile );
|
1040 |
-
if ( !in_array( $key, $upload_file_keys ) ) {
|
1041 |
-
$this->Data->pushValue( MWF_Config::UPLOAD_FILE_KEYS, $key );
|
1042 |
-
}
|
1043 |
-
}
|
1044 |
-
}
|
1045 |
-
|
1046 |
-
/**
|
1047 |
-
* set_admin_mail_reaquire_params
|
1048 |
-
* 管理者メールに必須の項目を設定
|
1049 |
-
* @param MW_Mail $Mail
|
1050 |
-
* @return MW_Mail $Mail
|
1051 |
-
*/
|
1052 |
-
private function set_admin_mail_reaquire_params( MW_Mail $Mail ) {
|
1053 |
-
$admin_mail_to = get_bloginfo( 'admin_email' );
|
1054 |
-
$admin_mail_from = get_bloginfo( 'admin_email' );
|
1055 |
-
$admin_mail_sender = get_bloginfo( 'name' );
|
1056 |
-
|
1057 |
-
if ( !$Mail->to ) {
|
1058 |
-
$Mail->to = $admin_mail_to;
|
1059 |
-
}
|
1060 |
-
if ( !$Mail->from ) {
|
1061 |
-
$Mail->from = $admin_mail_from;;
|
1062 |
-
}
|
1063 |
-
if ( !$Mail->sender ) {
|
1064 |
-
$Mail->sender = $admin_mail_sender;;
|
1065 |
-
}
|
1066 |
-
return $Mail;
|
1067 |
-
}
|
1068 |
-
|
1069 |
-
/**
|
1070 |
-
* set_reply_mail_reaquire_params
|
1071 |
-
* 自動返信メールに必須の項目を設定
|
1072 |
-
* @param MW_Mail $Mail
|
1073 |
-
* @return MW_Mail $Mail
|
1074 |
-
*/
|
1075 |
-
private function set_reply_mail_reaquire_params( MW_Mail $Mail ) {
|
1076 |
-
$reply_mail_from = get_bloginfo( 'admin_email' );
|
1077 |
-
$reply_mail_sender = get_bloginfo( 'name' );
|
1078 |
-
|
1079 |
-
if ( !$Mail->from ) {
|
1080 |
-
$Mail->from = $reply_mail_from;;
|
1081 |
-
}
|
1082 |
-
if ( !$Mail->sender ) {
|
1083 |
-
$Mail->sender = $reply_mail_sender;;
|
1084 |
-
}
|
1085 |
-
return $Mail;
|
1086 |
-
}
|
1087 |
-
|
1088 |
-
/**
|
1089 |
-
* set_admin_mail_raw_params
|
1090 |
-
* 管理者メールに項目を設定
|
1091 |
-
* @param MW_Mail $Mail
|
1092 |
-
* @return MW_Mail $Mail
|
1093 |
-
*/
|
1094 |
-
private function set_admin_mail_raw_params( MW_Mail $Mail ) {
|
1095 |
-
if ( $this->options_by_formkey ) {
|
1096 |
-
// タイトルを指定
|
1097 |
-
$admin_mail_subject = $this->options_by_formkey['mail_subject'];
|
1098 |
-
if ( !empty( $this->options_by_formkey['admin_mail_subject'] ) )
|
1099 |
-
$admin_mail_subject = $this->options_by_formkey['admin_mail_subject'];
|
1100 |
-
$Mail->subject = $admin_mail_subject;
|
1101 |
-
|
1102 |
-
// 本文を指定
|
1103 |
-
$admin_mail_content = $this->options_by_formkey['mail_content'];
|
1104 |
-
if ( !empty( $this->options_by_formkey['admin_mail_content'] ) )
|
1105 |
-
$admin_mail_content = $this->options_by_formkey['admin_mail_content'];
|
1106 |
-
$Mail->body = $admin_mail_content;
|
1107 |
-
|
1108 |
-
// 送信先を指定
|
1109 |
-
$admin_mail_to = get_bloginfo( 'admin_email' );
|
1110 |
-
if ( !empty( $this->options_by_formkey['mail_to'] ) )
|
1111 |
-
$admin_mail_to = $this->options_by_formkey['mail_to'];
|
1112 |
-
$Mail->to = $admin_mail_to;
|
1113 |
-
|
1114 |
-
// CCを指定
|
1115 |
-
$admin_mail_cc = $this->defaults['mail_cc'];
|
1116 |
-
if ( !empty( $this->options_by_formkey['mail_cc'] ) )
|
1117 |
-
$admin_mail_cc = $this->options_by_formkey['mail_cc'];
|
1118 |
-
$Mail->cc = $admin_mail_cc;
|
1119 |
-
|
1120 |
-
// BCCを指定
|
1121 |
-
$admin_mail_bcc = $this->defaults['mail_bcc'];
|
1122 |
-
if ( !empty( $this->options_by_formkey['mail_bcc'] ) )
|
1123 |
-
$admin_mail_bcc = $this->options_by_formkey['mail_bcc'];
|
1124 |
-
$Mail->bcc = $admin_mail_bcc;
|
1125 |
-
|
1126 |
-
// 送信元を指定
|
1127 |
-
$admin_mail_from = get_bloginfo( 'admin_email' );
|
1128 |
-
if ( !empty( $this->options_by_formkey['admin_mail_from'] ) )
|
1129 |
-
$admin_mail_from = $this->options_by_formkey['admin_mail_from'];
|
1130 |
-
$Mail->from = $admin_mail_from;
|
1131 |
-
|
1132 |
-
// 送信者を指定
|
1133 |
-
$admin_mail_sender = get_bloginfo( 'name' );
|
1134 |
-
if ( !empty( $this->options_by_formkey['admin_mail_sender'] ) )
|
1135 |
-
$admin_mail_sender = $this->options_by_formkey['admin_mail_sender'];
|
1136 |
-
$Mail->sender = $admin_mail_sender;
|
1137 |
-
}
|
1138 |
-
return $Mail;
|
1139 |
}
|
1140 |
|
1141 |
/**
|
1142 |
-
*
|
1143 |
-
*
|
1144 |
-
* @
|
1145 |
-
* @return MW_Mail $Mail
|
1146 |
*/
|
1147 |
-
|
1148 |
-
$
|
1149 |
-
$
|
1150 |
-
$
|
1151 |
-
|
1152 |
-
$automatic_reply_email = $this->Data->getValue( $this->options_by_formkey['automatic_reply_email'] );
|
1153 |
-
if ( $automatic_reply_email && !$this->validation_rules['mail']->rule( $automatic_reply_email ) ) {
|
1154 |
-
// 送信先を指定
|
1155 |
-
$Mail->to = $automatic_reply_email;
|
1156 |
-
|
1157 |
-
// 送信元を指定
|
1158 |
-
$reply_mail_from = get_bloginfo( 'admin_email' );
|
1159 |
-
if ( !empty( $this->options_by_formkey['mail_from'] ) )
|
1160 |
-
$reply_mail_from = $this->options_by_formkey['mail_from'];
|
1161 |
-
$Mail->from = $reply_mail_from;
|
1162 |
-
|
1163 |
-
// 送信者を指定
|
1164 |
-
$reply_mail_sender = get_bloginfo( 'name' );
|
1165 |
-
if ( !empty( $this->options_by_formkey['mail_sender'] ) )
|
1166 |
-
$reply_mail_sender = $this->options_by_formkey['mail_sender'];
|
1167 |
-
$Mail->sender = $reply_mail_sender;
|
1168 |
-
|
1169 |
-
// タイトルを指定
|
1170 |
-
$reply_mail_subject = $this->options_by_formkey['mail_subject'];
|
1171 |
-
$Mail->subject = $reply_mail_subject;
|
1172 |
-
|
1173 |
-
// 本文を指定
|
1174 |
-
$reply_mail_content = $this->options_by_formkey['mail_content'];
|
1175 |
-
$Mail->body = $reply_mail_content;
|
1176 |
-
}
|
1177 |
-
}
|
1178 |
-
return $Mail;
|
1179 |
-
}
|
1180 |
-
|
1181 |
-
/**
|
1182 |
-
* get_tracking_number
|
1183 |
-
* @param int $post_id フォームの Post ID
|
1184 |
-
* @return int $tracking_number
|
1185 |
-
*/
|
1186 |
-
protected function get_tracking_number( $post_id ) {
|
1187 |
-
$tracking_number = get_post_meta( $post_id, MWF_Config::TRACKINGNUMBER, true );
|
1188 |
-
if ( empty( $tracking_number ) ) {
|
1189 |
-
$tracking_number = 1;
|
1190 |
-
}
|
1191 |
-
return intval( $tracking_number );
|
1192 |
}
|
1193 |
}
|
|
2 |
/**
|
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: 2.2.0
|
7 |
* Author: Takashi Kitajima
|
8 |
* Author URI: http://2inc.org
|
9 |
* Created : September 25, 2012
|
10 |
+
* Modified: January 13, 2015
|
11 |
* Text Domain: mw-wp-form
|
12 |
* Domain Path: /languages/
|
13 |
* License: GPLv2
|
14 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
15 |
*/
|
16 |
+
include_once( plugin_dir_path( __FILE__ ) . 'classes/functions.php' );
|
17 |
+
include_once( plugin_dir_path( __FILE__ ) . 'classes/config.php' );
|
|
|
|
|
18 |
|
19 |
+
class MW_WP_Form {
|
20 |
+
|
21 |
+
/**
|
22 |
+
* form_fields
|
23 |
+
* フォームフィールドの配列
|
24 |
+
* @var array
|
25 |
+
*/
|
26 |
+
protected $form_fields = array();
|
27 |
+
|
28 |
+
/**
|
29 |
+
* $validation_rules
|
30 |
+
* バリデーションルールの配列。順番を固定するために定義が必要
|
31 |
+
* @var array
|
32 |
+
*/
|
33 |
+
protected $validation_rules = array(
|
34 |
'akismet_check' => '',
|
35 |
+
'noempty' => '',
|
36 |
+
'required' => '',
|
37 |
+
'numeric' => '',
|
38 |
+
'alpha' => '',
|
39 |
+
'alphanumeric' => '',
|
40 |
+
'katakana' => '',
|
41 |
+
'hiragana' => '',
|
42 |
+
'zip' => '',
|
43 |
+
'tel' => '',
|
44 |
+
'mail' => '',
|
45 |
+
'date' => '',
|
46 |
+
'url' => '',
|
47 |
+
'eq' => '',
|
48 |
+
'between' => '',
|
49 |
+
'minlength' => '',
|
50 |
+
'filetype' => '',
|
51 |
+
'filesize' => '',
|
52 |
+
);
|
53 |
+
|
54 |
+
/**
|
55 |
+
* $validation_rules_only_jp
|
56 |
+
* 日本語の時のみ使用できるバリデーションルール
|
57 |
+
* @var array
|
58 |
+
*/
|
59 |
+
protected $validation_rules_only_jp = array(
|
60 |
+
'MW_WP_Form_Validation_Rule_Zip',
|
61 |
+
'MW_WP_Form_Validation_Rule_Tel',
|
62 |
);
|
63 |
+
|
64 |
+
/**
|
65 |
+
* $form_fields_only_jp
|
66 |
+
* 日本語の時のみ使用できるフォーム項目
|
67 |
+
* @var array
|
68 |
+
*/
|
69 |
+
protected $form_fields_only_jp = array(
|
70 |
+
'MW_WP_Form_Field_Zip',
|
71 |
+
'MW_WP_Form_Field_Tel',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
);
|
|
|
73 |
|
74 |
/**
|
75 |
* __construct
|
76 |
*/
|
77 |
public function __construct() {
|
78 |
+
add_action( 'plugins_loaded', array( $this, 'load_initialize_files' ), 9 );
|
79 |
+
add_action( 'plugins_loaded', array( $this, 'initialize' ), 11 );
|
80 |
// 有効化した時の処理
|
81 |
register_activation_hook( __FILE__, array( __CLASS__, 'activation' ) );
|
82 |
// アンインストールした時の処理
|
84 |
}
|
85 |
|
86 |
/**
|
87 |
+
* load_initialize_files
|
88 |
+
* initialize に必要なファイルをロード
|
89 |
+
*/
|
90 |
+
public function load_initialize_files() {
|
91 |
+
$plugin_dir_path = plugin_dir_path( __FILE__ );
|
92 |
+
include_once( $plugin_dir_path . 'classes/controllers/class.admin.php' );
|
93 |
+
include_once( $plugin_dir_path . 'classes/controllers/class.admin-list.php' );
|
94 |
+
include_once( $plugin_dir_path . 'classes/controllers/class.contact-data.php' );
|
95 |
+
include_once( $plugin_dir_path . 'classes/controllers/class.contact-data-list.php' );
|
96 |
+
include_once( $plugin_dir_path . 'classes/controllers/class.chart.php' );
|
97 |
+
include_once( $plugin_dir_path . 'classes/controllers/class.main.php' );
|
98 |
+
include_once( $plugin_dir_path . 'classes/models/class.abstract-validation-rule.php' );
|
99 |
+
include_once( $plugin_dir_path . 'classes/models/class.admin.php' );
|
100 |
+
include_once( $plugin_dir_path . 'classes/models/class.akismet.php' );
|
101 |
+
include_once( $plugin_dir_path . 'classes/models/class.contact-data.php' );
|
102 |
+
include_once( $plugin_dir_path . 'classes/models/class.contact-data-setting.php' );
|
103 |
+
include_once( $plugin_dir_path . 'classes/models/class.data.php' );
|
104 |
+
include_once( $plugin_dir_path . 'classes/models/class.error.php' );
|
105 |
+
include_once( $plugin_dir_path . 'classes/models/class.file.php' );
|
106 |
+
include_once( $plugin_dir_path . 'classes/models/class.abstract-form-field.php' );
|
107 |
+
include_once( $plugin_dir_path . 'classes/models/class.form.php' );
|
108 |
+
include_once( $plugin_dir_path . 'classes/models/class.mail.php' );
|
109 |
+
include_once( $plugin_dir_path . 'classes/models/class.session.php' );
|
110 |
+
include_once( $plugin_dir_path . 'classes/models/class.setting.php' );
|
111 |
+
include_once( $plugin_dir_path . 'classes/models/class.validation.php' );
|
112 |
+
include_once( $plugin_dir_path . 'classes/services/class.exec-shortcode.php' );
|
113 |
+
include_once( $plugin_dir_path . 'classes/services/class.mail.php' );
|
114 |
+
include_once( $plugin_dir_path . 'classes/services/class.redirected.php' );
|
115 |
+
include_once( $plugin_dir_path . 'classes/views/class.view.php' );
|
116 |
+
include_once( $plugin_dir_path . 'classes/views/class.admin.php' );
|
117 |
+
include_once( $plugin_dir_path . 'classes/views/class.admin-list.php' );
|
118 |
+
include_once( $plugin_dir_path . 'classes/views/class.chart.php' );
|
119 |
+
include_once( $plugin_dir_path . 'classes/views/class.main.php' );
|
120 |
+
include_once( $plugin_dir_path . 'classes/views/class.contact-data.php' );
|
121 |
+
include_once( $plugin_dir_path . 'classes/views/class.contact-data-list.php' );
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* initialize
|
126 |
+
*/
|
127 |
+
public function initialize() {
|
128 |
load_plugin_textdomain( MWF_Config::DOMAIN, false, basename( dirname( __FILE__ ) ) . '/languages' );
|
129 |
|
|
|
|
|
|
|
|
|
130 |
add_action( 'init', array( $this, 'register_post_type' ) );
|
131 |
|
132 |
// フォームフィールドの読み込み、インスタンス化
|
133 |
+
$this->instantiate_form_fields();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
|
135 |
// バリデーションルールの読み込み、インスタンス化
|
136 |
+
$validation_rules = $this->get_validation_rules();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
|
138 |
+
$plugin_dir_path = plugin_dir_path( __FILE__ );
|
139 |
+
if ( is_admin() ) {
|
140 |
+
$Controller = new MW_WP_Form_Admin_Controller( $validation_rules );
|
141 |
+
$Controller->initialize();
|
142 |
|
143 |
+
$Controller = new MW_WP_Form_Admin_List_Controller();
|
144 |
+
$Controller->initialize();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
|
146 |
+
$Controller = new MW_WP_Form_Contact_Data_Controller();
|
147 |
+
$Controller->initialize();
|
148 |
+
|
149 |
+
$Controller = new MW_WP_Form_Contact_Data_List_Controller();
|
150 |
+
$Controller->initialize();
|
151 |
+
|
152 |
+
$Controller = new MW_WP_Form_Chart_Controller();
|
153 |
+
$Controller->initialize();
|
154 |
+
} else {
|
155 |
+
$Controller = new MW_WP_Form_Main_Controller( $validation_rules );
|
156 |
+
$Controller->initialize();
|
157 |
+
}
|
158 |
}
|
159 |
|
160 |
/**
|
161 |
+
* register_post_type
|
162 |
+
* 管理画面(カスタム投稿タイプ)の設定
|
163 |
*/
|
164 |
+
public function register_post_type() {
|
165 |
+
// MW WP Form のフォーム設定を管理する投稿タイプ
|
166 |
+
register_post_type( MWF_Config::NAME, array(
|
167 |
+
'label' => 'MW WP Form',
|
168 |
+
'labels' => array(
|
169 |
+
'name' => 'MW WP Form',
|
170 |
+
'singular_name' => 'MW WP Form',
|
171 |
+
'add_new_item' => __( 'Add New Form', MWF_Config::DOMAIN ),
|
172 |
+
'edit_item' => __( 'Edit Form', MWF_Config::DOMAIN ),
|
173 |
+
'new_item' => __( 'New Form', MWF_Config::DOMAIN ),
|
174 |
+
'view_item' => __( 'View Form', MWF_Config::DOMAIN ),
|
175 |
+
'search_items' => __( 'Search Forms', MWF_Config::DOMAIN ),
|
176 |
+
'not_found' => __( 'No Forms found', MWF_Config::DOMAIN ),
|
177 |
+
'not_found_in_trash' => __( 'No Forms found in Trash', MWF_Config::DOMAIN ),
|
178 |
+
),
|
179 |
+
'capability_type' => 'page',
|
180 |
+
'public' => false,
|
181 |
+
'show_ui' => true,
|
182 |
+
) );
|
183 |
+
|
184 |
+
// MW WP Form のデータベースに保存される問い合わせデータを管理する投稿タイプ
|
185 |
+
$Admin = new MW_WP_Form_Admin();
|
186 |
+
$forms = $Admin->get_forms();
|
187 |
+
foreach ( $forms as $form ) {
|
188 |
+
$Setting = new MW_WP_Form_Setting( $form->ID );
|
189 |
+
if ( !$Setting->get( 'usedb' ) ) {
|
190 |
+
continue;
|
191 |
}
|
192 |
+
|
193 |
+
$post_type = MWF_Config::DBDATA . $form->ID;
|
194 |
+
register_post_type( $post_type, array(
|
195 |
+
'label' => $form->post_title,
|
196 |
+
'labels' => array(
|
197 |
+
'name' => $form->post_title,
|
198 |
+
'singular_name' => $form->post_title,
|
199 |
+
'edit_item' => __( 'Edit ', MWF_Config::DOMAIN ) . ':' . $form->post_title,
|
200 |
+
'view_item' => __( 'View', MWF_Config::DOMAIN ) . ':' . $form->post_title,
|
201 |
+
'search_items' => __( 'Search', MWF_Config::DOMAIN ) . ':' . $form->post_title,
|
202 |
+
'not_found' => __( 'No data found', MWF_Config::DOMAIN ),
|
203 |
+
'not_found_in_trash' => __( 'No data found in Trash', MWF_Config::DOMAIN ),
|
204 |
+
),
|
205 |
+
'capability_type' => 'page',
|
206 |
+
'public' => false,
|
207 |
+
'show_ui' => true,
|
208 |
+
'show_in_menu' => false,
|
209 |
+
'supports' => array( 'title' ),
|
210 |
+
) );
|
211 |
}
|
212 |
}
|
213 |
|
223 |
* アンインストールした時の処理
|
224 |
*/
|
225 |
public static function uninstall() {
|
226 |
+
$Admin = new MW_WP_Form_Admin();
|
227 |
+
$forms = $Admin->get_forms();
|
|
|
|
|
228 |
|
229 |
$data_post_ids = array();
|
230 |
foreach ( $forms as $form ) {
|
235 |
foreach ( $data_post_ids as $data_post_id ) {
|
236 |
delete_option( MWF_Config::NAME . '-chart-' . $data_post_id );
|
237 |
$data_posts = get_posts( array(
|
238 |
+
'post_type' => MWF_Config::DBDATA . $data_post_id,
|
239 |
'posts_per_page' => -1,
|
240 |
) );
|
241 |
if ( empty( $data_posts ) ) continue;
|
244 |
}
|
245 |
}
|
246 |
|
247 |
+
include_once( plugin_dir_path( __FILE__ ) . 'classes/models/class.file.php' );
|
248 |
$File = new MW_WP_Form_File();
|
249 |
+
$File->remove_temp_dir();
|
250 |
|
251 |
delete_option( MWF_Config::NAME );
|
252 |
}
|
253 |
|
254 |
/**
|
255 |
+
* instantiate_form_fields
|
256 |
+
* フォームフィールドのインスタンス化。配列にはフックを通して格納する。
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
257 |
*/
|
258 |
+
protected function instantiate_form_fields() {
|
259 |
+
$plugin_dir_path = plugin_dir_path( __FILE__ );
|
260 |
+
foreach ( $this->form_fields_only_jp as $key => $value ) {
|
261 |
+
$this->form_fields_only_jp[$key] = strtolower( $value );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
262 |
}
|
263 |
+
foreach ( glob( $plugin_dir_path . './classes/form-fields/*.php' ) as $filename ) {
|
264 |
+
include_once $filename;
|
265 |
+
$class_name = $this->get_class_name_from_form_field_filename( $filename );
|
266 |
+
if ( class_exists( $class_name ) ) {
|
267 |
+
if ( get_locale() !== 'ja' && in_array( strtolower( $class_name ), $this->form_fields_only_jp ) ) {
|
268 |
+
continue;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
269 |
}
|
270 |
+
new $class_name();
|
271 |
}
|
|
|
|
|
272 |
}
|
273 |
+
$this->form_fields = apply_filters( 'mwform_form_fields', $this->form_fields );
|
274 |
}
|
275 |
|
276 |
/**
|
277 |
+
* get_class_name_from_form_field_filename
|
278 |
+
* @param string $filename ファイル名
|
279 |
+
* @return string クラス名
|
|
|
280 |
*/
|
281 |
+
protected function get_class_name_from_form_field_filename( $filename ) {
|
282 |
+
$class_name = preg_replace( '/^class\./', '', basename( $filename, '.php' ) );
|
283 |
+
$class_name = str_replace( '-', '_', $class_name );
|
284 |
+
$class_name = 'MW_WP_Form_Field_' . $class_name;
|
285 |
+
return $class_name;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
286 |
}
|
287 |
|
288 |
/**
|
289 |
+
* get_validation_rules
|
290 |
+
* バリデーションルールのインスタンス化。配列にはフックを通して格納する。
|
291 |
+
* @param string $key フォーム識別子
|
292 |
+
* @return $validation_rules バリデーションルールオブジェクトの配列
|
293 |
*/
|
294 |
+
protected function get_validation_rules() {
|
295 |
+
$validation_rules = array();
|
296 |
+
$plugin_dir_path = plugin_dir_path( __FILE__ );
|
297 |
+
foreach ( $this->validation_rules_only_jp as $key => $value ) {
|
298 |
+
$this->validation_rules_only_jp[$key] = strtolower( $value );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
299 |
}
|
300 |
+
foreach ( glob( $plugin_dir_path . './classes/validation-rules/*.php' ) as $filename ) {
|
301 |
+
include_once $filename;
|
302 |
+
$class_name = $this->get_class_name_from_validation_rule_filename( $filename );
|
303 |
+
if ( class_exists( $class_name ) ) {
|
304 |
+
if ( get_locale() !== 'ja' && in_array( strtolower( $class_name ), $this->validation_rules_only_jp ) ) {
|
305 |
+
continue;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
306 |
}
|
307 |
+
$instance = new $class_name();
|
308 |
+
$this->validation_rules[$instance->getName()] = $instance;
|
309 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
310 |
}
|
311 |
+
$this->validation_rules = apply_filters(
|
312 |
+
'mwform_validation_rules',
|
313 |
+
$this->validation_rules,
|
314 |
+
null // 後方互換性のために残してるだけ
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
315 |
);
|
316 |
+
return $this->validation_rules;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
317 |
}
|
318 |
|
319 |
/**
|
320 |
+
* get_class_name_from_validation_rule_filename
|
321 |
+
* @param string $filename ファイル名
|
322 |
+
* @return string クラス名
|
|
|
323 |
*/
|
324 |
+
protected function get_class_name_from_validation_rule_filename( $filename ) {
|
325 |
+
$class_name = preg_replace( '/^class\./', '', basename( $filename, '.php' ) );
|
326 |
+
$class_name = str_replace( '-', '_', $class_name );
|
327 |
+
$class_name = 'MW_WP_Form_Validation_Rule_' . $class_name;
|
328 |
+
return $class_name;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
329 |
}
|
330 |
}
|
331 |
+
$MW_WP_Form = new MW_WP_Form();
|
readme.txt
CHANGED
@@ -3,12 +3,12 @@ Contributors: inc2734, ryu263
|
|
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: 3.7
|
6 |
-
Tested up to: 4.
|
7 |
-
Stable tag: 2.
|
8 |
License: GPLv2
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
11 |
-
MW WP Form
|
12 |
|
13 |
== Description ==
|
14 |
|
@@ -71,6 +71,20 @@ Do you have questions or issues with MW WP Form? Use these support channels appr
|
|
71 |
|
72 |
== Changelog ==
|
73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
= 2.1.3 =
|
75 |
* Bug fix : Fixed a bug that number of newline characters are different by the environment.
|
76 |
* Changed : Modified to ignore uppercase letters of lowercase letters at the file type validation.
|
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: 3.7
|
6 |
+
Tested up to: 4.1
|
7 |
+
Stable tag: 2.2.0
|
8 |
License: GPLv2
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
11 |
+
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.
|
12 |
|
13 |
== Description ==
|
14 |
|
71 |
|
72 |
== Changelog ==
|
73 |
|
74 |
+
= 2.2.0 =
|
75 |
+
* Refactoring
|
76 |
+
* Bug fix : Fixed a mwform_tracking_number_title filter hook bug.
|
77 |
+
* Bug fix : Fixed a bug that can not set the more than 2 default values of the checkbox.
|
78 |
+
* Bug fix : Fixed a bug that double quotation of shortcodes are escaped in manual form.
|
79 |
+
* Changed : Class name changed MW_Form_Field to MW_WP_Form_Abstract_Form_Field.
|
80 |
+
* Changed : Class name changed MW_Validation_Rule to MW_WP_Form_Abstract_Validation_Rule.
|
81 |
+
* Changed : Zip or Tel validation can use Japanese only.
|
82 |
+
* Changed : Zip or Tel field can use Japanese only.
|
83 |
+
* Added : You can set a different value in the key and display value for children of checkbox, select, radio. For xample, [mwform_checkbox name="hoge" children="key1:value1,key2:value2"]
|
84 |
+
|
85 |
+
= 2.1.4 =
|
86 |
+
* Bug fix : Fixed a bug that data lost when there are multiple same name radio buttons and checkboxes.
|
87 |
+
|
88 |
= 2.1.3 =
|
89 |
* Bug fix : Fixed a bug that number of newline characters are different by the environment.
|
90 |
* Changed : Modified to ignore uppercase letters of lowercase letters at the file type validation.
|
system/mw_validation.php
DELETED
@@ -1,152 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Name: MW Validation
|
4 |
-
* Description: バリデーションクラス
|
5 |
-
* Version: 1.7.1
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created : July 20, 2012
|
9 |
-
* Modified: August 26, 2014
|
10 |
-
* License: GPLv2
|
11 |
-
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
-
*/
|
13 |
-
class MW_Validation {
|
14 |
-
|
15 |
-
/**
|
16 |
-
* フォーム識別子
|
17 |
-
*/
|
18 |
-
private $key;
|
19 |
-
|
20 |
-
/**
|
21 |
-
* MW_Error オブジェクト
|
22 |
-
*/
|
23 |
-
protected $Error;
|
24 |
-
|
25 |
-
/**
|
26 |
-
* バリデートをかける項目とかけるバリデーションの種類の一覧
|
27 |
-
*/
|
28 |
-
public $validate = array();
|
29 |
-
|
30 |
-
/**
|
31 |
-
* バリデーションルールの一覧
|
32 |
-
*/
|
33 |
-
private $validation_rules = array();
|
34 |
-
|
35 |
-
/**
|
36 |
-
* __construct
|
37 |
-
* @param string $key 識別子
|
38 |
-
*/
|
39 |
-
public function __construct( $key ) {
|
40 |
-
$this->key = $key;
|
41 |
-
$this->Error = new MW_Error();
|
42 |
-
}
|
43 |
-
|
44 |
-
/**
|
45 |
-
* add_validation_rule
|
46 |
-
* 各バリデーションルールクラスのインスタンスをセット
|
47 |
-
* @param string $rule_name
|
48 |
-
* @param MW_Validation_Rule $instance
|
49 |
-
*/
|
50 |
-
public function add_validation_rule( $rule_name, $instance ) {
|
51 |
-
$this->validation_rules[$rule_name] = $instance;
|
52 |
-
}
|
53 |
-
|
54 |
-
/**
|
55 |
-
* Error
|
56 |
-
* エラーオブジェクトを返す
|
57 |
-
* @return MW_Error エラーオブジェクト
|
58 |
-
*/
|
59 |
-
public function Error() {
|
60 |
-
return $this->Error;
|
61 |
-
}
|
62 |
-
|
63 |
-
/**
|
64 |
-
* isValid
|
65 |
-
* バリデートが通っているかチェック
|
66 |
-
* @return bool
|
67 |
-
*/
|
68 |
-
protected function isValid() {
|
69 |
-
$errors = $this->Error->getErrors();
|
70 |
-
if ( empty( $errors ) ) {
|
71 |
-
return true;
|
72 |
-
} else {
|
73 |
-
return false;
|
74 |
-
}
|
75 |
-
}
|
76 |
-
|
77 |
-
/**
|
78 |
-
* setRule
|
79 |
-
* バリデートが通っているかチェック
|
80 |
-
* @param string キー
|
81 |
-
* @param string バリデーションルール名
|
82 |
-
* @param array オプション
|
83 |
-
* @return bool
|
84 |
-
*/
|
85 |
-
public function setRule( $key, $rule, array $options = array() ) {
|
86 |
-
$rules = array(
|
87 |
-
'rule' => strtolower( $rule ),
|
88 |
-
'options' => $options
|
89 |
-
);
|
90 |
-
$this->validate[$key][] = $rules;
|
91 |
-
return $this;
|
92 |
-
}
|
93 |
-
|
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 |
-
}
|
122 |
-
return true;
|
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_validation_rule.php
DELETED
@@ -1,58 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Name: MW Validation Rule
|
4 |
-
* Description: バリデーションルールの抽象クラス
|
5 |
-
* Version: 1.0.1
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created : July 19, 2014
|
9 |
-
* Modified: August 8, 2014
|
10 |
-
* License: GPLv2
|
11 |
-
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
-
*/
|
13 |
-
abstract class MW_Validation_Rule {
|
14 |
-
|
15 |
-
/**
|
16 |
-
* バリデーションルール名を指定
|
17 |
-
*/
|
18 |
-
protected $name;
|
19 |
-
|
20 |
-
/*
|
21 |
-
* MW_WP_Form_Data オブジェクト
|
22 |
-
*/
|
23 |
-
protected $Data;
|
24 |
-
|
25 |
-
/**
|
26 |
-
* __construct
|
27 |
-
* @param string $key 識別子
|
28 |
-
*/
|
29 |
-
public function __construct( $key ) {
|
30 |
-
if ( !$this->getName() )
|
31 |
-
exit( 'MW_Validation_Rule::$name must override.' );
|
32 |
-
$this->Data = MW_WP_Form_Data::getInstance( $key );
|
33 |
-
}
|
34 |
-
|
35 |
-
/**
|
36 |
-
* getName
|
37 |
-
* バリデーションルール名を返す
|
38 |
-
* @return string $this->name バリデーションルール名
|
39 |
-
*/
|
40 |
-
public function getName() {
|
41 |
-
return $this->name;
|
42 |
-
}
|
43 |
-
|
44 |
-
/**
|
45 |
-
* rule
|
46 |
-
* @param string $key name属性
|
47 |
-
* @param array $option
|
48 |
-
* @return string エラーメッセージ
|
49 |
-
*/
|
50 |
-
abstract public function rule( $key, array $options = array() );
|
51 |
-
|
52 |
-
/**
|
53 |
-
* admin
|
54 |
-
* @param numeric $key バリデーションルールセットの識別番号
|
55 |
-
* @param array $value バリデーションルールセットの内容
|
56 |
-
*/
|
57 |
-
abstract public function admin( $key, $value );
|
58 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
system/mw_wp_form_admin_page.php
DELETED
@@ -1,645 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Name: MW WP Form Admin Page
|
4 |
-
* Description: 管理画面クラス
|
5 |
-
* Version: 1.12.2
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created : February 21, 2013
|
9 |
-
* Modified: November 26, 2014
|
10 |
-
* License: GPLv2
|
11 |
-
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
-
*/
|
13 |
-
class MW_WP_Form_Admin_Page {
|
14 |
-
|
15 |
-
/**
|
16 |
-
* 登録済みのフォームスタイルの一覧
|
17 |
-
*/
|
18 |
-
private $styles = array();
|
19 |
-
|
20 |
-
/**
|
21 |
-
* フォームの設定データ
|
22 |
-
*/
|
23 |
-
private $postdata;
|
24 |
-
|
25 |
-
/**
|
26 |
-
* バリデーションルールの一覧
|
27 |
-
*/
|
28 |
-
private $validation_rules = array();
|
29 |
-
|
30 |
-
/**
|
31 |
-
* __construct
|
32 |
-
*/
|
33 |
-
public function __construct() {
|
34 |
-
add_action( 'admin_enqueue_scripts', array( $this, 'admin_style' ) );
|
35 |
-
add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
|
36 |
-
add_action( 'admin_head', array( $this, 'add_meta_box' ) );
|
37 |
-
add_action( 'save_post', array( $this, 'save_post' ) );
|
38 |
-
add_action( 'admin_print_footer_scripts', array( $this, 'add_quicktag' ) );
|
39 |
-
add_action( 'current_screen', array( $this, 'current_screen' ) );
|
40 |
-
add_filter( 'default_content', array( $this, 'default_content' ) );
|
41 |
-
add_action( 'media_buttons', array( $this, 'add_tag_generator' ) );
|
42 |
-
add_filter( 'manage_posts_columns', array( $this, 'manage_posts_columns' ) );
|
43 |
-
add_action( 'manage_posts_custom_column', array( $this, 'manage_posts_custom_column' ), 10, 2 );
|
44 |
-
}
|
45 |
-
|
46 |
-
/**
|
47 |
-
* current_screen
|
48 |
-
* 寄付リンクを表示
|
49 |
-
* @param WP_Screen $screen
|
50 |
-
*/
|
51 |
-
public function current_screen( $screen ) {
|
52 |
-
if ( $screen->id === 'edit-' . MWF_Config::NAME )
|
53 |
-
add_filter( 'views_' . $screen->id, array( $this, 'display_donate_link' ) );
|
54 |
-
}
|
55 |
-
public function display_donate_link( $views ) {
|
56 |
-
$donation = array( 'donation' => '<div class="donation"><p>' . __( 'Your contribution is needed for making this plugin better.', MWF_Config::DOMAIN ) . ' <a href="http://www.amazon.co.jp/registry/wishlist/39ANKRNSTNW40" class="button">' . __( 'Donate', MWF_Config::DOMAIN ) . '</a></p></div>' );
|
57 |
-
$views = array_merge( $donation, $views );
|
58 |
-
return $views;
|
59 |
-
}
|
60 |
-
|
61 |
-
/**
|
62 |
-
* get_post_data
|
63 |
-
* フォームの設定データを返す
|
64 |
-
* @param string $key 設定データのキー
|
65 |
-
* @return mixed 設定データ
|
66 |
-
*/
|
67 |
-
protected function get_post_data( $key ) {
|
68 |
-
global $post;
|
69 |
-
if ( isset( $this->postdata[$key] ) ) {
|
70 |
-
return $this->postdata[$key];
|
71 |
-
} else {
|
72 |
-
$date = $post->post_date;
|
73 |
-
$modified = $post->post_modified;
|
74 |
-
if ( $date === $modified ){
|
75 |
-
return apply_filters( 'mwform_default_postdata', '', $key );
|
76 |
-
}
|
77 |
-
}
|
78 |
-
}
|
79 |
-
|
80 |
-
/**
|
81 |
-
* default_content
|
82 |
-
* 本文の初期値を設定
|
83 |
-
* @param string $content
|
84 |
-
* @return string
|
85 |
-
*/
|
86 |
-
public function default_content( $content ) {
|
87 |
-
global $typenow;
|
88 |
-
if ( $typenow === MWF_Config::NAME ) {
|
89 |
-
return apply_filters( 'mwform_default_content', '' );
|
90 |
-
}
|
91 |
-
}
|
92 |
-
|
93 |
-
/**
|
94 |
-
* register_post_type
|
95 |
-
*/
|
96 |
-
public function register_post_type() {
|
97 |
-
register_post_type( MWF_Config::NAME, array(
|
98 |
-
'label' => 'MW WP Form',
|
99 |
-
'labels' => array(
|
100 |
-
'name' => 'MW WP Form',
|
101 |
-
'singular_name' => 'MW WP Form',
|
102 |
-
'add_new_item' => __( 'Add New Form', MWF_Config::DOMAIN ),
|
103 |
-
'edit_item' => __( 'Edit Form', MWF_Config::DOMAIN ),
|
104 |
-
'new_item' => __( 'New Form', MWF_Config::DOMAIN ),
|
105 |
-
'view_item' => __( 'View Form', MWF_Config::DOMAIN ),
|
106 |
-
'search_items' => __( 'Search Forms', MWF_Config::DOMAIN ),
|
107 |
-
'not_found' => __( 'No Forms found', MWF_Config::DOMAIN ),
|
108 |
-
'not_found_in_trash' => __( 'No Forms found in Trash', MWF_Config::DOMAIN ),
|
109 |
-
),
|
110 |
-
'capability_type' => 'page',
|
111 |
-
'public' => false,
|
112 |
-
'show_ui' => true,
|
113 |
-
) );
|
114 |
-
}
|
115 |
-
|
116 |
-
/**
|
117 |
-
* add_meta_box
|
118 |
-
*/
|
119 |
-
public function add_meta_box() {
|
120 |
-
$post_type = get_post_type();
|
121 |
-
if ( MWF_Config::NAME == $post_type ) {
|
122 |
-
global $post;
|
123 |
-
// 設定データ取得
|
124 |
-
$this->postdata = get_post_meta( $post->ID, MWF_Config::NAME, true );
|
125 |
-
// 完了画面内容
|
126 |
-
add_meta_box(
|
127 |
-
MWF_Config::NAME . '_complete_message_metabox',
|
128 |
-
__( 'Complete Message', MWF_Config::DOMAIN ),
|
129 |
-
array( $this, 'add_complete_message' ),
|
130 |
-
MWF_Config::NAME, 'normal'
|
131 |
-
);
|
132 |
-
// 入力画面URL
|
133 |
-
add_meta_box(
|
134 |
-
MWF_Config::NAME . '_url',
|
135 |
-
__( 'URL Options', MWF_Config::DOMAIN ),
|
136 |
-
array( $this, 'add_url' ),
|
137 |
-
MWF_Config::NAME, 'normal'
|
138 |
-
);
|
139 |
-
// バリデーション
|
140 |
-
add_meta_box(
|
141 |
-
MWF_Config::NAME . '_validation',
|
142 |
-
__( 'Validation Rule', MWF_Config::DOMAIN ),
|
143 |
-
array( $this, 'display_validation_rule' ),
|
144 |
-
MWF_Config::NAME, 'normal'
|
145 |
-
);
|
146 |
-
// フォーム識別子
|
147 |
-
add_meta_box(
|
148 |
-
MWF_Config::NAME . '_formkey',
|
149 |
-
__( 'Form Key', MWF_Config::DOMAIN ),
|
150 |
-
array( $this, 'display_form_key' ),
|
151 |
-
MWF_Config::NAME, 'side'
|
152 |
-
);
|
153 |
-
// 自動返信メール設定
|
154 |
-
add_meta_box(
|
155 |
-
MWF_Config::NAME . '_mail',
|
156 |
-
__( 'Automatic Reply Email Options', MWF_Config::DOMAIN ),
|
157 |
-
array( $this, 'add_mail_options' ),
|
158 |
-
MWF_Config::NAME, 'side'
|
159 |
-
);
|
160 |
-
// 管理者メール設定
|
161 |
-
add_meta_box(
|
162 |
-
MWF_Config::NAME . '_admin_mail',
|
163 |
-
__( 'Admin Email Options', MWF_Config::DOMAIN ),
|
164 |
-
array( $this, 'add_admin_mail_options' ),
|
165 |
-
MWF_Config::NAME, 'side'
|
166 |
-
);
|
167 |
-
// 設定
|
168 |
-
add_meta_box(
|
169 |
-
MWF_Config::NAME . '_settings',
|
170 |
-
__( 'settings', MWF_Config::DOMAIN ),
|
171 |
-
array( $this, 'settings' ),
|
172 |
-
MWF_Config::NAME, 'side'
|
173 |
-
);
|
174 |
-
// CSS
|
175 |
-
$this->styles = apply_filters( 'mwform_styles', $this->styles );
|
176 |
-
if ( $this->styles ) {
|
177 |
-
add_meta_box(
|
178 |
-
MWF_Config::NAME . '_styles',
|
179 |
-
__( 'Style setting', MWF_Config::DOMAIN ),
|
180 |
-
array( $this, 'add_style_option' ),
|
181 |
-
MWF_Config::NAME, 'side'
|
182 |
-
);
|
183 |
-
}
|
184 |
-
}
|
185 |
-
}
|
186 |
-
|
187 |
-
/**
|
188 |
-
* add_quicktag
|
189 |
-
* HTMLエディタにクイックタグを追加
|
190 |
-
*/
|
191 |
-
public function add_quicktag() {
|
192 |
-
if ( MWF_Config::NAME == get_post_type() ) : ?>
|
193 |
-
<script type="text/javascript">
|
194 |
-
if ( typeof( QTags ) !== 'undefined' ) {
|
195 |
-
<?php do_action( 'mwform_add_qtags' ); ?>
|
196 |
-
}
|
197 |
-
</script>
|
198 |
-
<?php
|
199 |
-
endif;
|
200 |
-
}
|
201 |
-
|
202 |
-
/**
|
203 |
-
* admin_style
|
204 |
-
* CSS適用
|
205 |
-
*/
|
206 |
-
public function admin_style() {
|
207 |
-
$post_type = get_post_type();
|
208 |
-
if ( isset( $_GET['post_type'] ) && MWF_Config::NAME === $_GET['post_type'] || MWF_Config::NAME == $post_type ) {
|
209 |
-
$url = plugin_dir_url( __FILE__ );
|
210 |
-
wp_register_style( MWF_Config::NAME . '-admin', $url . '../css/admin.css' );
|
211 |
-
wp_enqueue_style( MWF_Config::NAME . '-admin' );
|
212 |
-
}
|
213 |
-
}
|
214 |
-
|
215 |
-
/**
|
216 |
-
* admin_scripts
|
217 |
-
* JavaScript適用
|
218 |
-
*/
|
219 |
-
public function admin_scripts() {
|
220 |
-
if ( MWF_Config::NAME == get_post_type() ) {
|
221 |
-
$url = plugin_dir_url( __FILE__ );
|
222 |
-
wp_register_script( MWF_Config::NAME . '-repeatable', $url . '../js/mw-wp-form-repeatable.js' );
|
223 |
-
wp_enqueue_script( MWF_Config::NAME . '-repeatable' );
|
224 |
-
wp_register_script( MWF_Config::NAME . '-admin', $url . '../js/admin.js' );
|
225 |
-
wp_enqueue_script( MWF_Config::NAME . '-admin' );
|
226 |
-
wp_enqueue_script( 'jquery-ui-dialog' );
|
227 |
-
|
228 |
-
global $wp_scripts;
|
229 |
-
$ui = $wp_scripts->query( 'jquery-ui-core' );
|
230 |
-
wp_enqueue_style( 'jquery.ui', '//ajax.googleapis.com/ajax/libs/jqueryui/' . $ui->ver . '/themes/smoothness/jquery-ui.min.css', array(), $ui->ver );
|
231 |
-
}
|
232 |
-
}
|
233 |
-
|
234 |
-
/**
|
235 |
-
* save_post
|
236 |
-
* @param int $post_ID
|
237 |
-
*/
|
238 |
-
public function save_post( $post_ID ) {
|
239 |
-
if ( !( isset( $_POST['post_type'] ) && $_POST['post_type'] === MWF_Config::NAME ) )
|
240 |
-
return $post_ID;
|
241 |
-
if ( !isset( $_POST[MWF_Config::NAME . '_nonce'] ) )
|
242 |
-
return $post_ID;
|
243 |
-
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
|
244 |
-
return $post_ID;
|
245 |
-
if ( !wp_verify_nonce( $_POST[MWF_Config::NAME . '_nonce'], MWF_Config::NAME ) )
|
246 |
-
return $post_ID;
|
247 |
-
if ( !current_user_can( MWF_Config::CAPABILITY ) )
|
248 |
-
return $post_ID;
|
249 |
-
|
250 |
-
$data = $_POST[MWF_Config::NAME];
|
251 |
-
if ( !empty( $data['validation'] ) && is_array( $data['validation'] ) ) {
|
252 |
-
$validation = array();
|
253 |
-
foreach ( $data['validation'] as $_validation ) {
|
254 |
-
if ( empty( $_validation['target'] ) ) continue;
|
255 |
-
foreach ( $_validation as $key => $value ) {
|
256 |
-
// between min, max
|
257 |
-
if ( $key == 'between' ) {
|
258 |
-
if ( !MWF_Functions::is_numeric( $value['min'] ) ) {
|
259 |
-
unset( $_validation[$key]['min'] );
|
260 |
-
}
|
261 |
-
if ( !MWF_Functions::is_numeric( $value['max'] ) ) {
|
262 |
-
unset( $_validation[$key]['max'] );
|
263 |
-
}
|
264 |
-
}
|
265 |
-
// minlength min
|
266 |
-
elseif ( $key == 'minlength' && !MWF_Functions::is_numeric( $value['min'] ) ) {
|
267 |
-
unset( $_validation[$key] );
|
268 |
-
}
|
269 |
-
// fileType types
|
270 |
-
elseif ( $key == 'fileType' && isset( $value['types'] ) && !preg_match( '/^[0-9A-Za-z,]+$/', $value['types'] ) ) {
|
271 |
-
unset( $_validation[$key] );
|
272 |
-
}
|
273 |
-
// fileSize bytes
|
274 |
-
elseif ( $key == 'fileSize' && !MWF_Functions::is_numeric( $value['bytes'] ) ) {
|
275 |
-
unset( $_validation[$key] );
|
276 |
-
}
|
277 |
-
|
278 |
-
// 要素が空のときは削除
|
279 |
-
// 単一項目のとき
|
280 |
-
if ( empty( $value ) ) {
|
281 |
-
unset( $_validation[$key] );
|
282 |
-
}
|
283 |
-
// 配列のとき
|
284 |
-
elseif ( is_array( $value ) && !array_diff( $value, array( '' ) ) ) {
|
285 |
-
unset( $_validation[$key] );
|
286 |
-
}
|
287 |
-
}
|
288 |
-
$validation[] = $_validation;
|
289 |
-
}
|
290 |
-
$data['validation'] = $validation;
|
291 |
-
}
|
292 |
-
//$old_data = get_post_meta( $post_ID, MWF_Config::NAME, true );
|
293 |
-
update_post_meta( $post_ID, MWF_Config::NAME, $data, $this->postdata );
|
294 |
-
}
|
295 |
-
|
296 |
-
/**
|
297 |
-
* display_form_key
|
298 |
-
* formkeyのテキストフィールドを表示
|
299 |
-
*/
|
300 |
-
public function display_form_key() {
|
301 |
-
global $post;
|
302 |
-
?>
|
303 |
-
<p>
|
304 |
-
<span id="formkey_field">[mwform_formkey key="<?php the_ID(); ?>"]</span>
|
305 |
-
<span class="mwf_note">
|
306 |
-
<?php esc_html_e( 'Copy and Paste this shortcode.', MWF_Config::DOMAIN ); ?><br />
|
307 |
-
<?php esc_html_e( 'The key to use with hook is ', MWF_Config::DOMAIN ); ?><?php echo MWF_Config::NAME; ?>-<?php echo $post->ID; ?>
|
308 |
-
</span>
|
309 |
-
</p>
|
310 |
-
<?php
|
311 |
-
}
|
312 |
-
|
313 |
-
/**
|
314 |
-
* settings
|
315 |
-
* $post を取得するための引数を有効にするフィールドを表示
|
316 |
-
*/
|
317 |
-
public function settings() {
|
318 |
-
global $post;
|
319 |
-
?>
|
320 |
-
<p>
|
321 |
-
<label><input type="checkbox" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[querystring]" value="1" <?php checked( $this->get_post_data( 'querystring' ), 1 ); ?> /> <?php esc_html_e( 'Activate Query string of post', MWF_Config::DOMAIN ); ?></label><br />
|
322 |
-
<span class="mwf_note"><?php esc_html_e( '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.', MWF_Config::DOMAIN ); ?><br />
|
323 |
-
<?php esc_html_e( 'Example: {ID}, {post_title}, {post_meta} etc...', MWF_Config::DOMAIN ); ?></span>
|
324 |
-
</p>
|
325 |
-
<p>
|
326 |
-
<label><input type="checkbox" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[usedb]" value="1" <?php checked( $this->get_post_data( 'usedb' ), 1 ); ?> /> <?php esc_html_e( 'Saving inquiry data in database', MWF_Config::DOMAIN ); ?></label>
|
327 |
-
</p>
|
328 |
-
<p>
|
329 |
-
<label><input type="checkbox" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[scroll]" value="1" <?php checked( $this->get_post_data( 'scroll' ), 1 ); ?> /> <?php esc_html_e( 'Enable scrolling of screen transition.', MWF_Config::DOMAIN ); ?></label>
|
330 |
-
</p>
|
331 |
-
<table border="0" cellpadding="0" cellspacing="0" class="akismet">
|
332 |
-
<tr>
|
333 |
-
<th colspan="2"><?php esc_html_e( 'Akismet Setting', MWF_Config::DOMAIN ); ?></th>
|
334 |
-
</tr>
|
335 |
-
<tr>
|
336 |
-
<td>author</td>
|
337 |
-
<td><input type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[akismet_author]" value="<?php echo esc_attr( $this->get_post_data( 'akismet_author' ) ); ?>" /></td>
|
338 |
-
</tr>
|
339 |
-
<tr>
|
340 |
-
<td>email</td>
|
341 |
-
<td><input type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[akismet_author_email]" value="<?php echo esc_attr( $this->get_post_data( 'akismet_author_email' ) ); ?>" /></td>
|
342 |
-
</tr>
|
343 |
-
<tr>
|
344 |
-
<td>url</td>
|
345 |
-
<td><input type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[akismet_author_url]" value="<?php echo esc_attr( $this->get_post_data( 'akismet_author_url' ) ); ?>" /></td>
|
346 |
-
</tr>
|
347 |
-
</table>
|
348 |
-
<span class="mwf_note"><?php esc_html_e( 'Input the key to use Akismet.', MWF_Config::DOMAIN ); ?></span>
|
349 |
-
<?php
|
350 |
-
}
|
351 |
-
|
352 |
-
/**
|
353 |
-
* add_complete_message
|
354 |
-
* 完了画面内容の入力画面を表示
|
355 |
-
*/
|
356 |
-
public function add_complete_message() {
|
357 |
-
global $post;
|
358 |
-
$content = $this->get_post_data( 'complete_message' );
|
359 |
-
wp_editor( $content, MWF_Config::NAME . '_complete_message', array(
|
360 |
-
'textarea_name' => MWF_Config::NAME . '[complete_message]',
|
361 |
-
'textarea_rows' => 7,
|
362 |
-
) );
|
363 |
-
}
|
364 |
-
|
365 |
-
/**
|
366 |
-
* add_mail_options
|
367 |
-
* 自動返信メール設定フォームを表示
|
368 |
-
*/
|
369 |
-
public function add_mail_options() {
|
370 |
-
global $post;
|
371 |
-
?>
|
372 |
-
<p>
|
373 |
-
<?php esc_html_e( '{key} is converted form data.', MWF_Config::DOMAIN ); ?>
|
374 |
-
<?php echo sprintf(
|
375 |
-
esc_html__( 'It is automatically converted to Tracking number when you input {%s}.', MWF_Config::DOMAIN ),
|
376 |
-
MWF_Config::TRACKINGNUMBER
|
377 |
-
); ?>
|
378 |
-
</p>
|
379 |
-
<p>
|
380 |
-
<b><?php esc_html_e( 'Subject', MWF_Config::DOMAIN ); ?></b><br />
|
381 |
-
<input type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[mail_subject]" value="<?php echo esc_attr( $this->get_post_data( 'mail_subject' ) ); ?>" />
|
382 |
-
</p>
|
383 |
-
<p>
|
384 |
-
<b><?php esc_html_e( 'Sender', MWF_Config::DOMAIN ); ?></b><br />
|
385 |
-
<input type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[mail_sender]" value="<?php echo esc_attr( $this->get_post_data( 'mail_sender' ) ); ?>" /><br />
|
386 |
-
<span class="mwf_note"><?php esc_html_e( 'If empty:', MWF_Config::DOMAIN ); ?> <?php bloginfo( 'name' ); ?></span>
|
387 |
-
</p>
|
388 |
-
<p>
|
389 |
-
<b><?php esc_html_e( 'From ( E-mail address )', MWF_Config::DOMAIN ); ?></b><br />
|
390 |
-
<input type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[mail_from]" value="<?php echo esc_attr( $this->get_post_data( 'mail_from' ) ); ?>" /><br />
|
391 |
-
<span class="mwf_note"><?php esc_html_e( 'If empty:', MWF_Config::DOMAIN ); ?> <?php bloginfo( 'admin_email' ); ?></span>
|
392 |
-
</p>
|
393 |
-
<p>
|
394 |
-
<b><?php esc_html_e( 'Content', MWF_Config::DOMAIN ); ?></b><br />
|
395 |
-
<textarea name="<?php echo esc_attr( MWF_Config::NAME ); ?>[mail_content]" cols="30" rows="10"><?php echo esc_attr( $this->get_post_data( 'mail_content' ) ); ?></textarea>
|
396 |
-
</p>
|
397 |
-
<p>
|
398 |
-
<b><?php esc_html_e( 'Automatic reply email', MWF_Config::DOMAIN ); ?></b><br />
|
399 |
-
<input type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[automatic_reply_email]" value="<?php echo esc_attr( $this->get_post_data( 'automatic_reply_email') ); ?>" /><br />
|
400 |
-
<span class="mwf_note"><?php esc_html_e( 'Input the key to use as transmission to automatic reply email. {} is unnecessary.', MWF_Config::DOMAIN ); ?></span>
|
401 |
-
</p>
|
402 |
-
<?php
|
403 |
-
}
|
404 |
-
|
405 |
-
/**
|
406 |
-
* add_admin_mail_options
|
407 |
-
* 管理者宛メール設定フォームを表示
|
408 |
-
*/
|
409 |
-
public function add_admin_mail_options() {
|
410 |
-
global $post;
|
411 |
-
?>
|
412 |
-
<p>
|
413 |
-
<?php esc_html_e( '{key} is converted form data.', MWF_Config::DOMAIN ); ?>
|
414 |
-
<?php echo sprintf(
|
415 |
-
esc_html__( 'It is automatically converted to Tracking number when you input {%s}.', MWF_Config::DOMAIN ),
|
416 |
-
MWF_Config::TRACKINGNUMBER
|
417 |
-
); ?>
|
418 |
-
</p>
|
419 |
-
<p>
|
420 |
-
<?php esc_html_e( 'If Admin Email Options is a blank, Automatic Replay Email Options is used as Admin Email Options.', MWF_Config::DOMAIN ); ?>
|
421 |
-
</p>
|
422 |
-
<p>
|
423 |
-
<b><?php esc_html_e( 'To ( E-mail address )', MWF_Config::DOMAIN ); ?></b><br />
|
424 |
-
<input type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[mail_to]" value="<?php echo esc_attr( $this->get_post_data( 'mail_to' ) ); ?>" /><br />
|
425 |
-
<span class="mwf_note"><?php esc_html_e( 'If empty:', MWF_Config::DOMAIN ); ?> <?php bloginfo( 'admin_email' ); ?></span>
|
426 |
-
</p>
|
427 |
-
<p>
|
428 |
-
<b><?php esc_html_e( 'CC ( E-mail address )', MWF_Config::DOMAIN ); ?></b><br />
|
429 |
-
<input type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[mail_cc]" value="<?php echo esc_attr( $this->get_post_data( 'mail_cc' ) ); ?>" />
|
430 |
-
</p>
|
431 |
-
<p>
|
432 |
-
<b><?php esc_html_e( 'BCC ( E-mail address )', MWF_Config::DOMAIN ); ?></b><br />
|
433 |
-
<input type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[mail_bcc]" value="<?php echo esc_attr( $this->get_post_data( 'mail_bcc' ) ); ?>" />
|
434 |
-
</p>
|
435 |
-
<p>
|
436 |
-
<b><?php esc_html_e( 'Subject', MWF_Config::DOMAIN ); ?></b><br />
|
437 |
-
<input type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[admin_mail_subject]" value="<?php echo esc_attr( $this->get_post_data( 'admin_mail_subject' ) ); ?>" />
|
438 |
-
</p>
|
439 |
-
<p>
|
440 |
-
<b><?php esc_html_e( 'Sender', MWF_Config::DOMAIN ); ?></b><br />
|
441 |
-
<input type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[admin_mail_sender]" value="<?php echo esc_attr( $this->get_post_data( 'admin_mail_sender' ) ); ?>" /><br />
|
442 |
-
<span class="mwf_note"><?php esc_html_e( 'If empty:', MWF_Config::DOMAIN ); ?> <?php bloginfo( 'name' ); ?></span>
|
443 |
-
</p>
|
444 |
-
<p>
|
445 |
-
<b><?php esc_html_e( 'From ( E-mail address )', MWF_Config::DOMAIN ); ?></b><br />
|
446 |
-
<input type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[admin_mail_from]" value="<?php echo esc_attr( $this->get_post_data( 'admin_mail_from' ) ); ?>" /><br />
|
447 |
-
<span class="mwf_note"><?php esc_html_e( 'If empty:', MWF_Config::DOMAIN ); ?> <?php bloginfo( 'admin_email' ); ?></span>
|
448 |
-
</p>
|
449 |
-
<p>
|
450 |
-
<b><?php esc_html_e( 'Content', MWF_Config::DOMAIN ); ?></b><br />
|
451 |
-
<textarea name="<?php echo esc_attr( MWF_Config::NAME ); ?>[admin_mail_content]" cols="30" rows="10"><?php echo esc_attr( $this->get_post_data( 'admin_mail_content' ) ); ?></textarea>
|
452 |
-
</p>
|
453 |
-
<?php
|
454 |
-
}
|
455 |
-
|
456 |
-
/**
|
457 |
-
* add_url
|
458 |
-
* URL設定フォームを表示
|
459 |
-
*/
|
460 |
-
public function add_url() {
|
461 |
-
global $post;
|
462 |
-
?>
|
463 |
-
<input type="hidden" name="<?php echo esc_attr( MWF_Config::NAME ); ?>_nonce" value="<?php echo wp_create_nonce( MWF_Config::NAME ); ?>" />
|
464 |
-
<table border="0" cellpadding="0" cellspacing="4">
|
465 |
-
<tr>
|
466 |
-
<th><?php esc_html_e( 'Input Page URL', MWF_Config::DOMAIN ); ?></th>
|
467 |
-
<td>
|
468 |
-
<input type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[input_url]" value="<?php echo esc_attr( $this->get_post_data( 'input_url' ) ); ?>" />
|
469 |
-
</td>
|
470 |
-
</tr>
|
471 |
-
<tr>
|
472 |
-
<th><?php esc_html_e( 'Confirmation Page URL', MWF_Config::DOMAIN ); ?></th>
|
473 |
-
<td>
|
474 |
-
<input type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[confirmation_url]" value="<?php echo esc_attr( $this->get_post_data( 'confirmation_url' ) ); ?>" />
|
475 |
-
</td>
|
476 |
-
</tr>
|
477 |
-
<tr>
|
478 |
-
<th><?php esc_html_e( 'Complete Page URL', MWF_Config::DOMAIN ); ?></th>
|
479 |
-
<td>
|
480 |
-
<input type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[complete_url]" value="<?php echo esc_attr( $this->get_post_data( 'complete_url' ) ); ?>" />
|
481 |
-
</td>
|
482 |
-
</tr>
|
483 |
-
<tr>
|
484 |
-
<th><?php esc_html_e( 'Validation Error Page URL', MWF_Config::DOMAIN ); ?></th>
|
485 |
-
<td>
|
486 |
-
<input type="text" name="<?php echo esc_attr( MWF_Config::NAME ); ?>[validation_error_url]" value="<?php echo esc_attr( $this->get_post_data( 'validation_error_url' ) ); ?>" />
|
487 |
-
</td>
|
488 |
-
</tr>
|
489 |
-
</table>
|
490 |
-
<p class="description">
|
491 |
-
<?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.', MWF_Config::DOMAIN ); ?><br />
|
492 |
-
<?php printf( esc_html__( 'When a URL doesn\'t begin http or https, %s is complemented.', MWF_Config::DOMAIN ), '<b>' . home_url() . '</b>' ); ?>
|
493 |
-
</p>
|
494 |
-
<?php
|
495 |
-
}
|
496 |
-
|
497 |
-
/**
|
498 |
-
* add_validation_rule
|
499 |
-
* 各バリデーションルールクラスのインスタンスをセット
|
500 |
-
* @param string $rule_name
|
501 |
-
* @param MW_Validation_Rule $instance
|
502 |
-
*/
|
503 |
-
public function add_validation_rule( $rule_name, $instance ) {
|
504 |
-
$this->validation_rules[$rule_name] = $instance;
|
505 |
-
}
|
506 |
-
|
507 |
-
/**
|
508 |
-
* display_validation_rule
|
509 |
-
* バリデーションルール設定フォームを表示
|
510 |
-
*/
|
511 |
-
public function display_validation_rule() {
|
512 |
-
global $post;
|
513 |
-
if ( ! $postdata = $this->get_post_data( 'validation' ) )
|
514 |
-
$postdata = array();
|
515 |
-
$validation_keys = array(
|
516 |
-
'target' => '',
|
517 |
-
);
|
518 |
-
foreach ( $this->validation_rules as $validation_rule => $instance ) {
|
519 |
-
$validation_keys[$instance->getName()] = '';
|
520 |
-
}
|
521 |
-
|
522 |
-
// 空の隠れバリデーションフィールド(コピー元)を挿入
|
523 |
-
array_unshift( $postdata, $validation_keys );
|
524 |
-
?>
|
525 |
-
<b class="add-btn"><?php esc_html_e( 'Add Validation rule', MWF_Config::DOMAIN ); ?></b>
|
526 |
-
<div class="repeatable-boxes">
|
527 |
-
<?php foreach ( $postdata as $key => $value ) : $value = array_merge( $validation_keys, $value ); ?>
|
528 |
-
<div class="repeatable-box"<?php if ( $key === 0 ) : ?> style="display:none"<?php endif; ?>>
|
529 |
-
<div class="remove-btn"><b>×</b></div>
|
530 |
-
<div class="open-btn"><span><?php echo esc_attr( $value['target'] ); ?></span><b>▼</b></div>
|
531 |
-
<div class="repeatable-box-content">
|
532 |
-
<?php esc_html_e( 'The key which applies validation', MWF_Config::DOMAIN ); ?>:<input type="text" class="targetKey" value="<?php echo esc_attr( $value['target'] ); ?>" name="<?php echo MWF_Config::NAME; ?>[validation][<?php echo $key; ?>][target]" />
|
533 |
-
<table border="0" cellpadding="0" cellspacing="0">
|
534 |
-
<tr>
|
535 |
-
<td colspan="2">
|
536 |
-
<?php foreach ( $this->validation_rules as $validation_rule => $instance ) : ?>
|
537 |
-
<?php $instance->admin( $key, $value ); ?>
|
538 |
-
<?php endforeach; ?>
|
539 |
-
</td>
|
540 |
-
</tr>
|
541 |
-
</table>
|
542 |
-
<!-- end .repeatable-box-content --></div>
|
543 |
-
<!-- end .repeatable-box --></div>
|
544 |
-
<?php endforeach; ?>
|
545 |
-
<!-- end .repeatable-boxes --></div>
|
546 |
-
<?php
|
547 |
-
}
|
548 |
-
|
549 |
-
/**
|
550 |
-
* add_style_option
|
551 |
-
*/
|
552 |
-
public function add_style_option() {
|
553 |
-
?>
|
554 |
-
<p>
|
555 |
-
<select name="<?php echo MWF_Config::NAME; ?>[style]">
|
556 |
-
<option value=""><?php esc_html_e( 'Select Style', MWF_Config::DOMAIN ); ?></option>
|
557 |
-
<?php foreach ( $this->styles as $style => $css ) : ?>
|
558 |
-
<option value="<?php echo esc_attr( $style ); ?>" <?php selected( $this->get_post_data( 'style' ), $style ); ?>>
|
559 |
-
<?php echo esc_html( $style ); ?>
|
560 |
-
</option>
|
561 |
-
<?php endforeach; ?>
|
562 |
-
</select>
|
563 |
-
</p>
|
564 |
-
<?php
|
565 |
-
}
|
566 |
-
|
567 |
-
/**
|
568 |
-
* disable_visual_editor
|
569 |
-
* ビジュアルエディタを無効に
|
570 |
-
* @return bool;
|
571 |
-
*/
|
572 |
-
public function disable_visual_editor() {
|
573 |
-
if ( MWF_Config::NAME == get_post_type() ) {
|
574 |
-
return false;
|
575 |
-
}
|
576 |
-
return true;
|
577 |
-
}
|
578 |
-
|
579 |
-
/**
|
580 |
-
* add_tag_generator
|
581 |
-
* タグジェネレータを出力
|
582 |
-
* @param string $editor_id
|
583 |
-
*/
|
584 |
-
public function add_tag_generator( $editor_id ) {
|
585 |
-
$post_type = get_post_type();
|
586 |
-
if ( $post_type !== MWF_Config::NAME )
|
587 |
-
return;
|
588 |
-
if ( $editor_id !== 'content' )
|
589 |
-
return;
|
590 |
-
do_action( 'mwform_tag_generator_dialog' );
|
591 |
-
?>
|
592 |
-
<div class="add-mwform-btn">
|
593 |
-
<select>
|
594 |
-
<option value=""><?php echo esc_html_e( 'Select this.', MWF_Config::DOMAIN ); ?></option>
|
595 |
-
<optgroup label="<?php echo esc_attr_e( 'Input fields', MWF_Config::DOMAIN ); ?>">
|
596 |
-
<?php do_action( 'mwform_tag_generator_input_option' ); ?>
|
597 |
-
</optgroup>
|
598 |
-
<optgroup label="<?php echo esc_attr_e( 'Select fields', MWF_Config::DOMAIN ); ?>">
|
599 |
-
<?php do_action( 'mwform_tag_generator_select_option' ); ?>
|
600 |
-
</optgroup>
|
601 |
-
<optgroup label="<?php echo esc_attr_e( 'Button fields', MWF_Config::DOMAIN ); ?>">
|
602 |
-
<?php do_action( 'mwform_tag_generator_button_option' ); ?>
|
603 |
-
</optgroup>
|
604 |
-
<optgroup label="<?php echo esc_attr_e( 'Error fields', MWF_Config::DOMAIN ); ?>">
|
605 |
-
<?php do_action( 'mwform_tag_generator_error_option' ); ?>
|
606 |
-
</optgroup>
|
607 |
-
<optgroup label="<?php echo esc_attr_e( 'Other fields', MWF_Config::DOMAIN ); ?>">
|
608 |
-
<?php do_action( 'mwform_tag_generator_option' ); ?>
|
609 |
-
</optgroup>
|
610 |
-
</select>
|
611 |
-
<span class="button"><?php esc_html_e( 'Add form tag', MWF_Config::DOMAIN ); ?></span>
|
612 |
-
</div>
|
613 |
-
<?php
|
614 |
-
}
|
615 |
-
|
616 |
-
/**
|
617 |
-
* manage_posts_columns
|
618 |
-
* @param array $columns
|
619 |
-
* @return array $columns
|
620 |
-
*/
|
621 |
-
public function manage_posts_columns( $columns ) {
|
622 |
-
$post_type = get_post_type();
|
623 |
-
if ( $post_type !== MWF_Config::NAME )
|
624 |
-
return $columns;
|
625 |
-
$date = $columns['date'];
|
626 |
-
unset( $columns['date'] );
|
627 |
-
$columns['mwform_form_key'] = __( 'Form Key', MWF_Config::DOMAIN );
|
628 |
-
$columns['date'] = $date;
|
629 |
-
return $columns;
|
630 |
-
}
|
631 |
-
|
632 |
-
/**
|
633 |
-
* manage_posts_custom_column
|
634 |
-
* @param string $column_name
|
635 |
-
* @param int $post_id
|
636 |
-
*/
|
637 |
-
public function manage_posts_custom_column( $column_name, $post_id ) {
|
638 |
-
if ( $column_name === 'mwform_form_key' ) {
|
639 |
-
printf(
|
640 |
-
'<span id="formkey_field">[mwform_formkey key="%d"]</span>',
|
641 |
-
get_the_ID()
|
642 |
-
);
|
643 |
-
}
|
644 |
-
}
|
645 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
system/mw_wp_form_chart_page.php
DELETED
@@ -1,337 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Name: MW WP Form Chart Page
|
4 |
-
* Description: グラフ画面クラス
|
5 |
-
* Version: 1.0.0
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created : August 30, 2014
|
9 |
-
* Modified:
|
10 |
-
* License: GPLv2
|
11 |
-
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
-
*/
|
13 |
-
class MW_WP_Form_Chart_Page {
|
14 |
-
|
15 |
-
/**
|
16 |
-
* formkey
|
17 |
-
*/
|
18 |
-
private $formkey;
|
19 |
-
|
20 |
-
/**
|
21 |
-
* フォームの設定データ
|
22 |
-
*/
|
23 |
-
private $postdata = array();
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Settings API グループ名
|
27 |
-
*/
|
28 |
-
private $option_group;
|
29 |
-
|
30 |
-
/**
|
31 |
-
* __construct
|
32 |
-
*/
|
33 |
-
public function __construct() {
|
34 |
-
add_action( 'admin_menu', array( $this, 'add_menu' ) );
|
35 |
-
add_action( 'admin_init', array( $this, 'register_setting' ) );
|
36 |
-
add_action( 'admin_print_styles', array( $this, 'admin_print_styles' ) );
|
37 |
-
$this->option_group = MWF_Config::NAME . '-' . 'chart-group';
|
38 |
-
if ( !empty( $_GET['formkey'] ) ) {
|
39 |
-
$this->formkey = $_GET['formkey'];
|
40 |
-
}
|
41 |
-
}
|
42 |
-
|
43 |
-
/**
|
44 |
-
* admin_print_styles
|
45 |
-
*/
|
46 |
-
public function admin_print_styles() {
|
47 |
-
?>
|
48 |
-
<style>
|
49 |
-
#menu-posts-mw-wp-form .wp-submenu li:last-child {
|
50 |
-
display: none;
|
51 |
-
}
|
52 |
-
</style>
|
53 |
-
<?php
|
54 |
-
}
|
55 |
-
|
56 |
-
/**
|
57 |
-
* add_menu
|
58 |
-
*/
|
59 |
-
public function add_menu() {
|
60 |
-
$submenu_page = add_submenu_page(
|
61 |
-
'edit.php?post_type=' . MWF_Config::NAME,
|
62 |
-
esc_html__( 'Chart', MWF_Config::DOMAIN ),
|
63 |
-
esc_html__( 'Chart', MWF_Config::DOMAIN ),
|
64 |
-
MWF_Config::CAPABILITY,
|
65 |
-
MWF_Config::NAME . '-chart',
|
66 |
-
array( $this, 'display' )
|
67 |
-
);
|
68 |
-
add_action( 'load-' . $submenu_page, array( $this, 'load' ) );
|
69 |
-
}
|
70 |
-
public function load() {
|
71 |
-
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts') );
|
72 |
-
}
|
73 |
-
|
74 |
-
/**
|
75 |
-
* admin_enqueue_scripts
|
76 |
-
*/
|
77 |
-
public function admin_enqueue_scripts() {
|
78 |
-
global $wp_scripts;
|
79 |
-
$ui = $wp_scripts->query( 'jquery-ui-core' );
|
80 |
-
wp_enqueue_style( 'jquery.ui', '//ajax.googleapis.com/ajax/libs/jqueryui/' . $ui->ver . '/themes/smoothness/jquery-ui.min.css', array( 'jquery' ), $ui->ver );
|
81 |
-
wp_enqueue_script( 'jquery-ui-sortable' );
|
82 |
-
|
83 |
-
$url = plugin_dir_url( __FILE__ );
|
84 |
-
|
85 |
-
wp_register_script( 'jsapi', 'https://www.google.com/jsapi' );
|
86 |
-
wp_enqueue_script( 'jsapi' );
|
87 |
-
|
88 |
-
wp_register_script(
|
89 |
-
MWF_Config::NAME . '-repeatable',
|
90 |
-
$url . '../js/mw-wp-form-repeatable.js',
|
91 |
-
array( 'jquery' ),
|
92 |
-
null,
|
93 |
-
true
|
94 |
-
);
|
95 |
-
wp_enqueue_script( MWF_Config::NAME . '-repeatable' );
|
96 |
-
|
97 |
-
wp_register_script(
|
98 |
-
MWF_Config::NAME . '-google-chart',
|
99 |
-
$url . '../js/mw-wp-form-google-chart.js',
|
100 |
-
array( 'jquery' ),
|
101 |
-
null,
|
102 |
-
true
|
103 |
-
);
|
104 |
-
wp_enqueue_script( MWF_Config::NAME . '-google-chart' );
|
105 |
-
|
106 |
-
wp_register_script(
|
107 |
-
MWF_Config::NAME . '-admin-chart',
|
108 |
-
$url . '../js/admin-chart.js',
|
109 |
-
array( 'jquery', 'jquery-ui-sortable' ),
|
110 |
-
null,
|
111 |
-
true
|
112 |
-
);
|
113 |
-
wp_enqueue_script( MWF_Config::NAME . '-admin-chart' );
|
114 |
-
}
|
115 |
-
|
116 |
-
/**
|
117 |
-
* display
|
118 |
-
*/
|
119 |
-
public function display() {
|
120 |
-
if ( !empty( $this->formkey ) ) {
|
121 |
-
$this->formkey = $_GET['formkey'];
|
122 |
-
$form_posts = get_posts( array(
|
123 |
-
'post_type' => $this->formkey,
|
124 |
-
'posts_per_page' => -1,
|
125 |
-
) );
|
126 |
-
} else {
|
127 |
-
exit;
|
128 |
-
}
|
129 |
-
$custom_keys = array();
|
130 |
-
foreach ( $form_posts as $post ) {
|
131 |
-
setup_postdata( $post );
|
132 |
-
$post_custom_keys = get_post_custom_keys( $post->ID );
|
133 |
-
if ( !empty( $post_custom_keys ) && is_array( $post_custom_keys ) ) {
|
134 |
-
foreach ( $post_custom_keys as $post_custom_key ) {
|
135 |
-
if ( preg_match( '/^_/', $post_custom_key ) )
|
136 |
-
continue;
|
137 |
-
$custom_keys[$post_custom_key][get_post_meta( $post->ID, $post_custom_key, true )][] = $post->ID;
|
138 |
-
}
|
139 |
-
}
|
140 |
-
}
|
141 |
-
wp_reset_postdata();
|
142 |
-
|
143 |
-
if ( ! $postdata = $this->get_option_data( 'chart' ) ) {
|
144 |
-
$postdata = array();
|
145 |
-
}
|
146 |
-
$default_keys = array(
|
147 |
-
'target' => '',
|
148 |
-
'separator' => '',
|
149 |
-
'chart' => '',
|
150 |
-
);
|
151 |
-
// 空の隠れフィールド(コピー元)を挿入
|
152 |
-
array_unshift( $postdata, $default_keys );
|
153 |
-
?>
|
154 |
-
<div class="wrap">
|
155 |
-
<h2><?php esc_html_e( 'Chart', MWF_Config::DOMAIN ); ?> : <?php echo esc_html( get_the_title( preg_replace( '/^(.+_)(\d+)$/', '$2', $this->formkey ) ) ); ?></h2>
|
156 |
-
<form method="post" action="options.php">
|
157 |
-
<?php
|
158 |
-
settings_fields( $this->option_group );
|
159 |
-
do_settings_sections( $this->option_group );
|
160 |
-
?>
|
161 |
-
<div id="<?php echo esc_attr( MWF_Config::NAME . '_chart' ); ?>" class="postbox">
|
162 |
-
<div class="inside">
|
163 |
-
<b class="add-btn"><?php esc_html_e( 'Add Chart', MWF_Config::DOMAIN ); ?></b>
|
164 |
-
<div class="repeatable-boxes">
|
165 |
-
<?php foreach ( $postdata as $key => $value ) : ?>
|
166 |
-
<div class="repeatable-box"<?php if ( $key === 0 ) : ?> style="display:none"<?php endif; ?>>
|
167 |
-
<div class="remove-btn"><b>×</b></div>
|
168 |
-
<div class="open-btn"><span><?php echo esc_attr( $value['target'] ); ?></span><b>▼</b></div>
|
169 |
-
<div class="repeatable-box-content">
|
170 |
-
<?php esc_html_e( 'Item that create chart', MWF_Config::DOMAIN ); ?>
|
171 |
-
<select class="targetKey" name="<?php echo esc_attr( sprintf( '%s-chart-%s[chart][%s][target]', MWF_Config::NAME, $this->formkey, $key ) ); ?>">
|
172 |
-
<option value=""><?php esc_html_e( 'Select this.', MWF_Config::DOMAIN ); ?></option>
|
173 |
-
<?php foreach ( $custom_keys as $custom_key_name => $custom_key_value ) : ?>
|
174 |
-
<option value="<?php echo esc_attr( $custom_key_name ); ?>" <?php selected( $value['target'], $custom_key_name ); ?>><?php echo esc_html( $custom_key_name ); ?></option>
|
175 |
-
<?php endforeach; ?>
|
176 |
-
</select>
|
177 |
-
<br />
|
178 |
-
<?php esc_html_e( 'Chart type', MWF_Config::DOMAIN ); ?>
|
179 |
-
<select name="<?php echo esc_attr( sprintf( '%s-chart-%s[chart][%s][chart]', MWF_Config::NAME, $this->formkey, $key ) ); ?>">
|
180 |
-
<?php
|
181 |
-
$chart_options = array(
|
182 |
-
'pie' => esc_html__( 'Pie chart', MWF_Config::DOMAIN ),
|
183 |
-
'bar' => esc_html__( 'Bar chart', MWF_Config::DOMAIN ),
|
184 |
-
);
|
185 |
-
foreach ( $chart_options as $chart_option_key => $chart_option ) {
|
186 |
-
printf(
|
187 |
-
'<option value="%s" %s>%s</option>',
|
188 |
-
esc_attr( $chart_option_key ),
|
189 |
-
selected( $value['chart'], $chart_option_key, false ),
|
190 |
-
esc_html( $chart_option )
|
191 |
-
);
|
192 |
-
}
|
193 |
-
?>
|
194 |
-
</select>
|
195 |
-
<br />
|
196 |
-
<?php esc_html_e( 'Separator string (If the check box. If the separator attribute is not set to ",")', MWF_Config::DOMAIN ); ?>
|
197 |
-
<input type="text" name="<?php echo esc_attr( sprintf( '%s-chart-%s[chart][%s][separator]', MWF_Config::NAME, $this->formkey, $key ) ); ?>" value="<?php echo esc_attr( $value['separator'] ); ?>" size="5" />
|
198 |
-
<!-- end .repeatable-box-content --></div>
|
199 |
-
<!-- end .repeatable-box --></div>
|
200 |
-
<?php endforeach; ?>
|
201 |
-
<!-- end .repeatable-boxes --></div>
|
202 |
-
<input type="hidden" name="<?php echo esc_attr( sprintf( '%s-formkey', MWF_Config::NAME ) ); ?>" value="<?php echo esc_attr( $this->formkey ); ?>" />
|
203 |
-
<?php submit_button(); ?>
|
204 |
-
<!-- end .inside --></div>
|
205 |
-
<!-- end #mw-wp-form_chart --></div>
|
206 |
-
</form>
|
207 |
-
|
208 |
-
<?php
|
209 |
-
foreach ( $postdata as $postdata_key => $chart ) {
|
210 |
-
if ( !isset( $custom_keys[$chart['target']] ) ) {
|
211 |
-
unset( $postdata[$postdata_key] );
|
212 |
-
continue;
|
213 |
-
}
|
214 |
-
printf(
|
215 |
-
'<h3>%s <span style="font-weight:normal;font-size:14px">( %s: %d )</span></h3><div class="%s" style="width: 100%%; max-width: 800px"></div>',
|
216 |
-
esc_html( $chart['target'] ),
|
217 |
-
esc_html__( 'The number of inquiries', MWF_Config::DOMAIN ),
|
218 |
-
count( $form_posts ),
|
219 |
-
esc_attr( MWF_Config::NAME . '-chart-div-' . $postdata_key )
|
220 |
-
);
|
221 |
-
}
|
222 |
-
|
223 |
-
$chart_data = array();
|
224 |
-
foreach ( $postdata as $postdata_key => $chart ) {
|
225 |
-
$data = array();
|
226 |
-
$raw_data = array();
|
227 |
-
foreach ( $custom_keys[$chart['target']] as $item => $values ) {
|
228 |
-
if ( $chart['separator'] && strstr( $item, $chart['separator'] ) ) {
|
229 |
-
$item = explode( $chart['separator'] , $item );
|
230 |
-
}
|
231 |
-
if ( is_array( $item ) ) {
|
232 |
-
foreach ( $item as $_item ) {
|
233 |
-
if ( $_item === '' ) {
|
234 |
-
$_item = '(Empty)';
|
235 |
-
}
|
236 |
-
if ( empty( $raw_data[$_item] ) ) {
|
237 |
-
$raw_data[$_item] = count( $values );
|
238 |
-
} else {
|
239 |
-
$raw_data[$_item] += count( $values );
|
240 |
-
}
|
241 |
-
}
|
242 |
-
} else {
|
243 |
-
if ( $item === '' ) {
|
244 |
-
$item = '(Empty)';
|
245 |
-
}
|
246 |
-
if ( empty( $raw_data[$item] ) ) {
|
247 |
-
$raw_data[$item] = count( $values );
|
248 |
-
} else {
|
249 |
-
$raw_data[$item] += count( $values );
|
250 |
-
}
|
251 |
-
}
|
252 |
-
}
|
253 |
-
$data[] = array( '', '' );
|
254 |
-
foreach ( $raw_data as $raw_data_key => $raw_data_value ) {
|
255 |
-
if ( $chart['chart'] === 'bar' ) {
|
256 |
-
$value = $raw_data_value / count( $form_posts );
|
257 |
-
} else {
|
258 |
-
$value = $raw_data_value;
|
259 |
-
}
|
260 |
-
$data[] = array(
|
261 |
-
$raw_data_key,
|
262 |
-
$value,
|
263 |
-
);
|
264 |
-
}
|
265 |
-
$chart_data[$postdata_key] = array(
|
266 |
-
'chart' => $chart['chart'],
|
267 |
-
'data' => $data,
|
268 |
-
);
|
269 |
-
}
|
270 |
-
?>
|
271 |
-
<script>
|
272 |
-
google.load( 'visualization', 1, { packages:['corechart'] } );
|
273 |
-
google.setOnLoadCallback( mwformDrawCharts );
|
274 |
-
function mwformDrawCharts() {
|
275 |
-
jQuery( function( $ ) {
|
276 |
-
<?php foreach ( $chart_data as $postdata_key => $chart ) : ?>
|
277 |
-
$( '.<?php echo esc_js( MWF_Config::NAME . '-chart-div-' . $postdata_key ); ?>' )
|
278 |
-
.mw_wp_form_google_chart( {
|
279 |
-
chart: <?php echo json_encode( $chart['chart'] ); ?>,
|
280 |
-
data : <?php echo json_encode( $chart['data'] ); ?>
|
281 |
-
} );
|
282 |
-
<?php endforeach; ?>
|
283 |
-
} );
|
284 |
-
}
|
285 |
-
</script>
|
286 |
-
<!-- end .wrap --></div>
|
287 |
-
<?php
|
288 |
-
}
|
289 |
-
|
290 |
-
/**
|
291 |
-
* register_setting
|
292 |
-
*/
|
293 |
-
public function register_setting() {
|
294 |
-
if ( !empty( $this->formkey ) ) {
|
295 |
-
$formkey = $this->formkey;
|
296 |
-
} elseif ( !empty( $_POST[MWF_Config::NAME . '-formkey'] ) ) {
|
297 |
-
$formkey = $_POST[MWF_Config::NAME . '-formkey'];
|
298 |
-
}
|
299 |
-
if ( !empty( $formkey ) ) {
|
300 |
-
register_setting(
|
301 |
-
$this->option_group,
|
302 |
-
MWF_Config::NAME . '-chart-' . $formkey,
|
303 |
-
array( $this, 'sanitize' )
|
304 |
-
);
|
305 |
-
}
|
306 |
-
}
|
307 |
-
|
308 |
-
/**
|
309 |
-
* sanitize
|
310 |
-
* @param array $input フォームから送信されたデータ
|
311 |
-
* @return array
|
312 |
-
*/
|
313 |
-
public function sanitize( $input ) {
|
314 |
-
$new_input = array();
|
315 |
-
if ( is_array( $input ) && isset( $input['chart'] ) && is_array( $input['chart'] ) ) {
|
316 |
-
foreach ( $input['chart'] as $key => $value ) {
|
317 |
-
if ( !empty( $value['target'] ) ) {
|
318 |
-
$new_input['chart'][$key] = $value;
|
319 |
-
}
|
320 |
-
}
|
321 |
-
}
|
322 |
-
return $new_input;
|
323 |
-
}
|
324 |
-
|
325 |
-
/**
|
326 |
-
* get_option_data
|
327 |
-
* フォームの設定データを返す
|
328 |
-
* @param string $key 設定データのキー
|
329 |
-
* @return mixed 設定データ
|
330 |
-
*/
|
331 |
-
protected function get_option_data( $key ) {
|
332 |
-
$option = get_option( MWF_Config::NAME . '-chart-' . $this->formkey );
|
333 |
-
if ( is_array( $option ) && isset( $option[$key] ) ) {
|
334 |
-
return $option[$key];
|
335 |
-
}
|
336 |
-
}
|
337 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
system/mw_wp_form_contact_data_page.php
DELETED
@@ -1,656 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Name: MW WP Form Contact Data Page
|
4 |
-
* Description: DB保存データを扱うクラス
|
5 |
-
* Version: 1.2.2
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created : October 10, 2013
|
9 |
-
* Modified: November 23, 2014
|
10 |
-
* License: GPLv2
|
11 |
-
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
-
*/
|
13 |
-
class MW_WP_Form_Contact_Data_Page {
|
14 |
-
|
15 |
-
/**
|
16 |
-
* DB保存データ独自の項目(メモとか)の配列のキー
|
17 |
-
*/
|
18 |
-
private $POST_DATA_NAME;
|
19 |
-
|
20 |
-
/**
|
21 |
-
* DB保存データ独自の項目(メモとか)
|
22 |
-
*/
|
23 |
-
private $postdata;
|
24 |
-
|
25 |
-
/**
|
26 |
-
* 対応状況種別の一覧
|
27 |
-
*/
|
28 |
-
private $response_statuses = array();
|
29 |
-
|
30 |
-
/**
|
31 |
-
* DB登録使用時のカスタム投稿タイプ名
|
32 |
-
*/
|
33 |
-
private $form_post_type = array();
|
34 |
-
|
35 |
-
/**
|
36 |
-
* __construct
|
37 |
-
*/
|
38 |
-
public function __construct() {
|
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' ) );
|
46 |
-
add_action( 'save_post', array( $this, 'save_post' ) );
|
47 |
-
add_action( 'in_admin_footer', array( $this, 'add_csv_download_button' ) );
|
48 |
-
add_action( 'wp_loaded', array( $this, 'csv_download' ) );
|
49 |
-
add_action( 'admin_menu', array( $this, 'admin_menu' ) );
|
50 |
-
add_action( 'edit_form_top', array( $this, 'display_returning_link' ) );
|
51 |
-
|
52 |
-
$this->response_statuses = array(
|
53 |
-
'not-supported' => esc_html__( 'Not supported', MWF_Config::DOMAIN ),
|
54 |
-
'reservation' => esc_html__( 'Reservation', MWF_Config::DOMAIN ),
|
55 |
-
'supported' => esc_html__( 'Supported', MWF_Config::DOMAIN ),
|
56 |
-
);
|
57 |
-
}
|
58 |
-
|
59 |
-
/**
|
60 |
-
* get_post_data
|
61 |
-
* フォームの設定データを返す
|
62 |
-
* @param string $key 項目名
|
63 |
-
* @return string
|
64 |
-
*/
|
65 |
-
protected function get_post_data( $key ) {
|
66 |
-
if ( isset( $this->postdata[$key] ) ) {
|
67 |
-
return $this->postdata[$key];
|
68 |
-
}
|
69 |
-
}
|
70 |
-
|
71 |
-
/**
|
72 |
-
* admin_style
|
73 |
-
* CSS適用
|
74 |
-
*/
|
75 |
-
public function admin_style() {
|
76 |
-
$post_type = get_post_type();
|
77 |
-
if ( in_array( $post_type, $this->form_post_type ) ) {
|
78 |
-
$url = plugin_dir_url( __FILE__ );
|
79 |
-
wp_register_style( MWF_Config::NAME . '-admin', $url . '../css/admin.css' );
|
80 |
-
wp_enqueue_style( MWF_Config::NAME . '-admin' );
|
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::NAME . '-admin-data', $url . '../js/admin-data.js' );
|
93 |
-
wp_enqueue_script( MWF_Config::NAME . '-admin-data' );
|
94 |
-
}
|
95 |
-
}
|
96 |
-
|
97 |
-
/**
|
98 |
-
* register_post_type
|
99 |
-
* メインクラスから呼ばれる
|
100 |
-
*/
|
101 |
-
public function register_post_type() {
|
102 |
-
$_posts = get_posts( array(
|
103 |
-
'post_type' => MWF_Config::NAME,
|
104 |
-
'posts_per_page' => -1
|
105 |
-
) );
|
106 |
-
foreach ( $_posts as $_post ) {
|
107 |
-
$post_meta = get_post_meta( $_post->ID, MWF_Config::NAME, true );
|
108 |
-
if ( empty( $post_meta['usedb'] ) )
|
109 |
-
continue;
|
110 |
-
|
111 |
-
$post_type = MWF_Config::DBDATA . $_post->ID;
|
112 |
-
register_post_type( $post_type, array(
|
113 |
-
'label' => $_post->post_title,
|
114 |
-
'labels' => array(
|
115 |
-
'name' => $_post->post_title,
|
116 |
-
'singular_name' => $_post->post_title,
|
117 |
-
'edit_item' => __( 'Edit ', MWF_Config::DOMAIN ) . ':' . $_post->post_title,
|
118 |
-
'view_item' => __( 'View', MWF_Config::DOMAIN ) . ':' . $_post->post_title,
|
119 |
-
'search_items' => __( 'Search', MWF_Config::DOMAIN ) . ':' . $_post->post_title,
|
120 |
-
'not_found' => __( 'No data found', MWF_Config::DOMAIN ),
|
121 |
-
'not_found_in_trash' => __( 'No data found in Trash', MWF_Config::DOMAIN ),
|
122 |
-
),
|
123 |
-
'capability_type' => 'page',
|
124 |
-
'public' => false,
|
125 |
-
'show_ui' => true,
|
126 |
-
'show_in_menu' => false,
|
127 |
-
'supports' => array( 'title' ),
|
128 |
-
) );
|
129 |
-
$this->form_post_type[] = $post_type;
|
130 |
-
}
|
131 |
-
}
|
132 |
-
|
133 |
-
/**
|
134 |
-
* add_style
|
135 |
-
* DB登録データの一覧、詳細画面で新規追加のリンクを消す
|
136 |
-
* 詳細画面でタイトル下の空白を消す
|
137 |
-
*/
|
138 |
-
public function add_style() {
|
139 |
-
if ( in_array( get_post_type(), $this->form_post_type ) ) : ?>
|
140 |
-
<style type="text/css">
|
141 |
-
h2 a.add-new-h2 {
|
142 |
-
display: none;
|
143 |
-
}
|
144 |
-
#normal-sortables {
|
145 |
-
display: none;
|
146 |
-
}
|
147 |
-
</style>
|
148 |
-
<?php
|
149 |
-
endif;
|
150 |
-
}
|
151 |
-
|
152 |
-
/**
|
153 |
-
* add_csv_download_button
|
154 |
-
* CSVダウンロードボタンを表示
|
155 |
-
*/
|
156 |
-
public function add_csv_download_button() {
|
157 |
-
$post_type = get_post_type();
|
158 |
-
if ( true !== apply_filters( 'mwform_csv_button_' . $post_type, true ) )
|
159 |
-
return;
|
160 |
-
$page = ( basename( $_SERVER['PHP_SELF'] ) );
|
161 |
-
if ( in_array( $post_type, $this->form_post_type ) && $page == 'edit.php' ) {
|
162 |
-
$action = $_SERVER['REQUEST_URI'];
|
163 |
-
?>
|
164 |
-
<form id="mw-wp-form_csv" method="post" action="<?php echo esc_url( $action ); ?>">
|
165 |
-
<input type="submit" value="<?php esc_attr_e( 'CSV Download', MWF_Config::DOMAIN ); ?>" class="button-primary" />
|
166 |
-
|
167 |
-
|
168 |
-
<label><input type="checkbox" name="download-all" value="true" checked="checked" /> Download All</label>
|
169 |
-
<input type="hidden" name="<?php echo esc_attr( MWF_Config::NAME . '-csv-download' ); ?>" value="1" />
|
170 |
-
<?php wp_nonce_field( MWF_Config::NAME ); ?>
|
171 |
-
</form>
|
172 |
-
<?php
|
173 |
-
}
|
174 |
-
}
|
175 |
-
|
176 |
-
/**
|
177 |
-
* csv_download
|
178 |
-
* CSVを生成、出力
|
179 |
-
*/
|
180 |
-
public function csv_download() {
|
181 |
-
if ( !isset( $_GET['post_type'] ) )
|
182 |
-
return ;
|
183 |
-
|
184 |
-
$post_type = $_GET['post_type'];
|
185 |
-
|
186 |
-
if ( in_array( $post_type, $this->form_post_type ) &&
|
187 |
-
!empty( $_POST ) &&
|
188 |
-
isset( $_POST[MWF_Config::NAME . '-csv-download'] ) &&
|
189 |
-
check_admin_referer( MWF_Config::NAME ) ) {
|
190 |
-
|
191 |
-
// posts_per_page
|
192 |
-
$posts_per_page = -1;
|
193 |
-
if ( ( isset( $_POST['download-all'] ) && $_POST['download-all'] === 'true' ) === false ) {
|
194 |
-
$current_user = wp_get_current_user();
|
195 |
-
$_posts_per_page = get_user_meta( $current_user->ID, 'edit_' . $post_type . '_per_page', true );
|
196 |
-
if ( !empty( $_posts_per_page ) ) {
|
197 |
-
$posts_per_page = $_posts_per_page;
|
198 |
-
}
|
199 |
-
}
|
200 |
-
|
201 |
-
// paged
|
202 |
-
$paged = 1;
|
203 |
-
$_paged = $_GET['paged'];
|
204 |
-
if ( !empty( $_paged ) && MWF_Functions::is_numeric( $_paged ) && $posts_per_page > 0 ) {
|
205 |
-
$paged = $_paged;
|
206 |
-
}
|
207 |
-
|
208 |
-
$posts_mwf = get_posts( array(
|
209 |
-
'post_type' => $post_type,
|
210 |
-
'posts_per_page' => $posts_per_page,
|
211 |
-
'paged' => $paged,
|
212 |
-
'post_status' => 'any',
|
213 |
-
) );
|
214 |
-
$csv = '';
|
215 |
-
|
216 |
-
// 見出しを追加
|
217 |
-
$default_headings = array(
|
218 |
-
'ID',
|
219 |
-
__( 'Response Status', MWF_Config::DOMAIN ),
|
220 |
-
'post_date',
|
221 |
-
'post_modified',
|
222 |
-
'post_title'
|
223 |
-
);
|
224 |
-
$rows[] = $default_headings;
|
225 |
-
foreach ( $posts_mwf as $post ) {
|
226 |
-
setup_postdata( $post );
|
227 |
-
$columns = array();
|
228 |
-
foreach ( $posts_mwf as $post ) {
|
229 |
-
$post_custom_keys = get_post_custom_keys( $post->ID );
|
230 |
-
if ( ! empty( $post_custom_keys ) && is_array( $post_custom_keys ) ) {
|
231 |
-
foreach ( $post_custom_keys as $key ) {
|
232 |
-
if ( preg_match( '/^_/', $key ) )
|
233 |
-
continue;
|
234 |
-
$columns[$key] = $key;
|
235 |
-
}
|
236 |
-
}
|
237 |
-
}
|
238 |
-
$rows[0] = array_merge( $rows[0], $columns );
|
239 |
-
}
|
240 |
-
wp_reset_postdata();
|
241 |
-
$rows[0] = array_merge( $rows[0], array(
|
242 |
-
__( 'Memo', MWF_Config::DOMAIN )
|
243 |
-
) );
|
244 |
-
|
245 |
-
// 各データを追加
|
246 |
-
foreach ( $posts_mwf as $post ) {
|
247 |
-
setup_postdata( $post );
|
248 |
-
$column = array();
|
249 |
-
foreach ( $rows[0] as $key => $value ) {
|
250 |
-
$_column = '';
|
251 |
-
if ( $value === __( 'Response Status', MWF_Config::DOMAIN ) ) {
|
252 |
-
$_column = $this->get_post_data_value( 'response_status', $post->ID );
|
253 |
-
} elseif ( $value === __( 'Memo', MWF_Config::DOMAIN ) ) {
|
254 |
-
$_column = $this->get_post_data_value( 'memo', $post->ID );
|
255 |
-
} elseif ( isset( $post->$value ) ) {
|
256 |
-
$post_meta = $post->$value;
|
257 |
-
if ( $this->is_upload_file_key( $post, $value ) ) {
|
258 |
-
$_column = wp_get_attachment_url( $post_meta );
|
259 |
-
} else {
|
260 |
-
$_column = ( $post_meta ) ? $post_meta : '';
|
261 |
-
}
|
262 |
-
}
|
263 |
-
$column[$key] = $this->escape_double_quote( $_column );
|
264 |
-
}
|
265 |
-
$rows[] = $column;
|
266 |
-
}
|
267 |
-
// 見出し行をエスケープ
|
268 |
-
foreach ( $rows[0] as $key => $value ) {
|
269 |
-
$rows[0][$key] = $this->escape_double_quote( $value );
|
270 |
-
}
|
271 |
-
wp_reset_postdata();
|
272 |
-
|
273 |
-
// エンコード
|
274 |
-
foreach ( $rows as $key => $row ) {
|
275 |
-
if ( $key === 0 ) {
|
276 |
-
foreach ( $row as $row_key => $column_name ) {
|
277 |
-
if ( in_array( $column_name, array( 'Response Status', 'Memo' ) ) ) {
|
278 |
-
$column_name = esc_html__( $column_name, MWF_Config::DOMAIN );
|
279 |
-
}
|
280 |
-
$row[$row_key] = $column_name;
|
281 |
-
}
|
282 |
-
}
|
283 |
-
$csv .= implode( ',', $row ) . "\r\n";
|
284 |
-
}
|
285 |
-
$csv = mb_convert_encoding( $csv, 'sjis-win', get_option( 'blog_charset' ) );
|
286 |
-
|
287 |
-
$file_name = 'mw_wp_form_' . date( 'YmdHis' ) . '.csv';
|
288 |
-
header( 'Content-Type: application/octet-stream' );
|
289 |
-
header( 'Content-Disposition: attachment; filename=' . $file_name );
|
290 |
-
echo $csv;
|
291 |
-
exit;
|
292 |
-
}
|
293 |
-
}
|
294 |
-
private function escape_double_quote( $value ) {
|
295 |
-
$value = str_replace( '"', '""', $value );
|
296 |
-
return '"' . $value . '"';
|
297 |
-
}
|
298 |
-
|
299 |
-
/**
|
300 |
-
* add_meta_box
|
301 |
-
*/
|
302 |
-
public function add_meta_box() {
|
303 |
-
$post_type = get_post_type();
|
304 |
-
if ( in_array( $post_type, $this->form_post_type ) ) {
|
305 |
-
global $post;
|
306 |
-
$this->postdata = get_post_meta( $post->ID, $this->POST_DATA_NAME, true );
|
307 |
-
add_meta_box(
|
308 |
-
substr( $this->POST_DATA_NAME, 1 ) . '_custom_fields',
|
309 |
-
__( 'Custom Fields', MWF_Config::DOMAIN ),
|
310 |
-
array( $this, 'custom_fields' ),
|
311 |
-
$post_type
|
312 |
-
);
|
313 |
-
}
|
314 |
-
}
|
315 |
-
|
316 |
-
/**
|
317 |
-
* add_form_columns_name
|
318 |
-
* DB登録使用時に問い合わせデータ一覧にカラムを追加
|
319 |
-
*/
|
320 |
-
public function add_forms_columns() {
|
321 |
-
global $wp_query;
|
322 |
-
$post_type = get_post_type();
|
323 |
-
if ( ! is_admin() )
|
324 |
-
return;
|
325 |
-
if ( ! in_array( $post_type, $this->form_post_type ) )
|
326 |
-
return;
|
327 |
-
add_filter( 'manage_' . $post_type . '_posts_columns', array( $this, 'add_form_columns_name' ) );
|
328 |
-
add_action( 'manage_' . $post_type . '_posts_custom_column', array( $this, 'add_form_columns' ), 10, 2 );
|
329 |
-
}
|
330 |
-
public function add_form_columns_name( $columns ) {
|
331 |
-
global $posts;
|
332 |
-
unset( $columns['date'] );
|
333 |
-
$columns['post_date'] = __( 'Registed Date', MWF_Config::DOMAIN );
|
334 |
-
$columns['response_status'] = __( 'Response Status', MWF_Config::DOMAIN );
|
335 |
-
foreach ( $posts as $post ) {
|
336 |
-
$post_custom_keys = get_post_custom_keys( $post->ID );
|
337 |
-
if ( ! empty( $post_custom_keys ) && is_array( $post_custom_keys ) ) {
|
338 |
-
foreach ( $post_custom_keys as $key ) {
|
339 |
-
if ( preg_match( '/^_/', $key ) )
|
340 |
-
continue;
|
341 |
-
$columns[$key] = $key;
|
342 |
-
}
|
343 |
-
}
|
344 |
-
}
|
345 |
-
return $columns;
|
346 |
-
}
|
347 |
-
public function add_form_columns( $column, $post_id ) {
|
348 |
-
global $post;
|
349 |
-
$post_custom_keys = get_post_custom_keys( $post_id );
|
350 |
-
|
351 |
-
if ( $column == 'post_date' ) {
|
352 |
-
$post = get_post( $post_id );
|
353 |
-
echo esc_html( $post->post_date );
|
354 |
-
}
|
355 |
-
elseif ( $column == 'response_status' ) {
|
356 |
-
echo $this->get_post_data_value( 'response_status', $post_id );
|
357 |
-
}
|
358 |
-
elseif ( !empty( $post_custom_keys ) && is_array( $post_custom_keys ) && in_array( $column, $post_custom_keys ) ) {
|
359 |
-
$post_meta = get_post_meta( $post_id, $column, true );
|
360 |
-
if ( $this->is_upload_file_key( $post, $column ) ) {
|
361 |
-
|
362 |
-
$mimetype = get_post_mime_type( $post_meta );
|
363 |
-
if ( $mimetype ) {
|
364 |
-
// 画像だったら
|
365 |
-
if ( preg_match( '/^image\/.+?$/', $mimetype ) ) {
|
366 |
-
$src = wp_get_attachment_image_src( $post_meta, 'thumbnail' );
|
367 |
-
echo '<img src="' . esc_url( $src[0] ) .'" alt="" style="width:50px;height:50px" />';
|
368 |
-
}
|
369 |
-
// 画像以外
|
370 |
-
else {
|
371 |
-
$src = wp_get_attachment_image_src( $post_meta, 'none', true );
|
372 |
-
echo '<a href="' . esc_url( wp_get_attachment_url( $post_meta ) ) .'" target="_blank">';
|
373 |
-
echo '<img src="' . esc_url( $src[0] ) .'" alt="" style="height:50px" />';
|
374 |
-
echo '</a>';
|
375 |
-
}
|
376 |
-
}
|
377 |
-
|
378 |
-
} elseif ( $post_meta ) {
|
379 |
-
echo esc_html( $post_meta );
|
380 |
-
} else {
|
381 |
-
echo ' ';
|
382 |
-
}
|
383 |
-
} else {
|
384 |
-
echo ' ';
|
385 |
-
}
|
386 |
-
}
|
387 |
-
|
388 |
-
/**
|
389 |
-
* custom_fields
|
390 |
-
* DB登録データの詳細画面にカスタムフィールドを表示
|
391 |
-
*/
|
392 |
-
public function custom_fields() {
|
393 |
-
global $post;
|
394 |
-
$post_custom = get_post_custom( $post->ID );
|
395 |
-
|
396 |
-
if ( ! empty( $post_custom ) && is_array( $post_custom ) ) {
|
397 |
-
?>
|
398 |
-
<table border="0" cellpadding="0" cellspacing="0">
|
399 |
-
<?php
|
400 |
-
foreach ( $post_custom as $key => $value ) :
|
401 |
-
if ( preg_match( '/^_/', $key ) ) continue;
|
402 |
-
?>
|
403 |
-
<tr>
|
404 |
-
<th><?php echo esc_html( $key ); ?></th>
|
405 |
-
<td>
|
406 |
-
<?php
|
407 |
-
if ( $this->is_upload_file_key( $post, $key ) ) {
|
408 |
-
$mimetype = get_post_mime_type( $value[0] );
|
409 |
-
if ( $mimetype ) {
|
410 |
-
// 画像だったら
|
411 |
-
if ( preg_match( '/^image\/.+?$/', $mimetype ) ) {
|
412 |
-
$src = wp_get_attachment_image_src( $value[0], 'medium' );
|
413 |
-
echo '<img src="' . esc_url( $src[0] ) .'" alt="" />';
|
414 |
-
}
|
415 |
-
// 画像以外
|
416 |
-
else {
|
417 |
-
$src = wp_get_attachment_image_src( $value[0], 'none', true );
|
418 |
-
echo '<a href="' . esc_url( wp_get_attachment_url( $value[0] ) ) .'" target="_blank">';
|
419 |
-
echo '<img src="' . esc_url( $src[0] ) .'" alt="" />';
|
420 |
-
echo '</a>';
|
421 |
-
}
|
422 |
-
}
|
423 |
-
} else {
|
424 |
-
echo nl2br( esc_html( $value[0] ) );
|
425 |
-
}
|
426 |
-
?>
|
427 |
-
</td>
|
428 |
-
</tr>
|
429 |
-
<?php endforeach; ?>
|
430 |
-
<tr>
|
431 |
-
<th><?php esc_html_e( 'Response Status', MWF_Config::DOMAIN ); ?></th>
|
432 |
-
<td>
|
433 |
-
<select name="<?php echo $this->POST_DATA_NAME; ?>[response_status]">
|
434 |
-
<?php foreach ( $this->response_statuses as $key => $value ) : ?>
|
435 |
-
<option value="<?php echo esc_attr( $key ); ?>" <?php selected( $key, $this->get_post_data( 'response_status' ) ); ?>>
|
436 |
-
<?php echo esc_html( $value ); ?>
|
437 |
-
</option>
|
438 |
-
<?php endforeach; ?>
|
439 |
-
</select>
|
440 |
-
</td>
|
441 |
-
</tr>
|
442 |
-
<tr>
|
443 |
-
<th><?php esc_html_e( 'Memo', MWF_Config::DOMAIN ); ?></th>
|
444 |
-
<td><textarea name="<?php echo $this->POST_DATA_NAME; ?>[memo]" cols="50" rows="5"><?php echo $this->get_post_data( 'memo' ); ?></textarea></td>
|
445 |
-
</tr>
|
446 |
-
</table>
|
447 |
-
<?php
|
448 |
-
}
|
449 |
-
}
|
450 |
-
|
451 |
-
/**
|
452 |
-
* save_post
|
453 |
-
* @param int $post_ID
|
454 |
-
*/
|
455 |
-
public function save_post( $post_ID ) {
|
456 |
-
if ( !( isset( $_POST['post_type'] ) && in_array( $_POST['post_type'], $this->form_post_type ) ) )
|
457 |
-
return $post_ID;
|
458 |
-
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
|
459 |
-
return $post_ID;
|
460 |
-
if ( !current_user_can( MWF_Config::CAPABILITY ) )
|
461 |
-
return $post_ID;
|
462 |
-
|
463 |
-
// 保存可能なキー
|
464 |
-
$permit_keys = array( 'memo', 'response_status' );
|
465 |
-
$data = array();
|
466 |
-
foreach ( $permit_keys as $key ) {
|
467 |
-
if ( isset( $_POST[$this->POST_DATA_NAME][$key] ) ) {
|
468 |
-
$value = $_POST[$this->POST_DATA_NAME][$key];
|
469 |
-
if ( $key === 'response_status' ) {
|
470 |
-
if ( !array_key_exists( $value, $this->response_statuses ) )
|
471 |
-
continue;
|
472 |
-
}
|
473 |
-
$data[$key] = $value;
|
474 |
-
}
|
475 |
-
}
|
476 |
-
update_post_meta( $post_ID, $this->POST_DATA_NAME, $data );
|
477 |
-
}
|
478 |
-
|
479 |
-
/**
|
480 |
-
* admin_menu
|
481 |
-
* 問い合わせデータ閲覧ページへのメニューを追加
|
482 |
-
*/
|
483 |
-
public function admin_menu() {
|
484 |
-
if ( empty( $this->form_post_type ) )
|
485 |
-
return;
|
486 |
-
|
487 |
-
add_submenu_page(
|
488 |
-
'edit.php?post_type=' . MWF_Config::NAME,
|
489 |
-
__( 'Inquiry data', MWF_Config::DOMAIN ), // ページタイトル
|
490 |
-
__( 'Inquiry data', MWF_Config::DOMAIN ), // メニュー名
|
491 |
-
MWF_Config::CAPABILITY, // 権限
|
492 |
-
MWF_Config::NAME . '-save-data', // 画面のパス
|
493 |
-
array( $this, 'inquiry_data_page' ) // 表示用の関数
|
494 |
-
);
|
495 |
-
}
|
496 |
-
|
497 |
-
/**
|
498 |
-
* inquiry_data_page
|
499 |
-
* 問い合わせデータ閲覧ページを表示
|
500 |
-
*/
|
501 |
-
public function inquiry_data_page() {
|
502 |
-
?>
|
503 |
-
<div class="wrap">
|
504 |
-
<h2><?php esc_html_e( 'Inquiry data', MWF_Config::DOMAIN ); ?></h2>
|
505 |
-
<p>
|
506 |
-
<?php esc_html_e( 'You can see the inquiry data that are saved in the database by clicking on the link below.', MWF_Config::DOMAIN ); ?>
|
507 |
-
</p>
|
508 |
-
<table class="wp-list-table widefat fixed" cellspacing="0">
|
509 |
-
<thead>
|
510 |
-
<th class="<?php echo MWF_Config::NAME; ?>-table-title"><?php esc_html_e( 'Form title', MWF_Config::DOMAIN ); ?></th>
|
511 |
-
<th class="<?php echo MWF_Config::NAME; ?>-table-chart"><?php esc_html_e( 'Display Chart', MWF_Config::DOMAIN ); ?></th>
|
512 |
-
<th class="<?php echo MWF_Config::NAME; ?>-table-count"><?php esc_html_e( 'The number of inquiries', MWF_Config::DOMAIN ); ?></th>
|
513 |
-
<th class="<?php echo MWF_Config::NAME; ?>-table-date"><?php esc_html_e( 'Updated date', MWF_Config::DOMAIN ); ?></th>
|
514 |
-
<th class="<?php echo MWF_Config::NAME; ?>-table-date"><?php esc_html_e( 'Created date', MWF_Config::DOMAIN ); ?></th>
|
515 |
-
</thead>
|
516 |
-
<tbody>
|
517 |
-
<?php $i = 0; foreach ( $this->form_post_type as $post_type ) : $i ++; ?>
|
518 |
-
<?php $post_type_object = get_post_type_object( $post_type ); ?>
|
519 |
-
<tr <?php if ( $i % 2 == 1 ) echo 'class="alternate"'; ?>>
|
520 |
-
<td class="<?php echo MWF_Config::NAME; ?>-table-title"><?php echo esc_html( $post_type_object->labels->singular_name ) ; ?></td>
|
521 |
-
<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', MWF_Config::DOMAIN ); ?></td>
|
522 |
-
<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( $this->get_count( $post_type ) ) ?> <?php esc_html_e( 'cases', MWF_Config::DOMAIN ); ?></a></td>
|
523 |
-
<td class="<?php echo MWF_Config::NAME; ?>-table-date"><?php echo esc_html( $this->get_modified_datetime( $post_type ) ); ?></td>
|
524 |
-
<td class="<?php echo MWF_Config::NAME; ?>-table-date"><?php echo esc_html( $this->get_created_datetime( $post_type ) ); ?></td>
|
525 |
-
</tr>
|
526 |
-
<?php endforeach; ?>
|
527 |
-
</tbody>
|
528 |
-
</table>
|
529 |
-
<!-- end .wrap --></div>
|
530 |
-
<?php
|
531 |
-
}
|
532 |
-
|
533 |
-
/**
|
534 |
-
* display_returning_link
|
535 |
-
* 問い合わせデータ詳細画面で一覧に戻るリンクを表示
|
536 |
-
* @param object $post
|
537 |
-
*/
|
538 |
-
public function display_returning_link( $post ) {
|
539 |
-
$post_type = get_post_type();
|
540 |
-
if ( in_array( $post_type, $this->form_post_type ) ) {
|
541 |
-
$link = admin_url( '/edit.php?post_type=' . $post_type );
|
542 |
-
?>
|
543 |
-
<p>
|
544 |
-
<a href="<?php echo $link; ?>"><?php esc_html_e( '« Back to the list', MWF_Config::DOMAIN ); ?></a>
|
545 |
-
</p>
|
546 |
-
<?php
|
547 |
-
}
|
548 |
-
}
|
549 |
-
|
550 |
-
/**
|
551 |
-
* get_count
|
552 |
-
* @param string $post_type 投稿タイプ名
|
553 |
-
* @return numeric 投稿数
|
554 |
-
*/
|
555 |
-
private function get_count( $post_type ) {
|
556 |
-
$query = new WP_Query( array(
|
557 |
-
'post_type' => $post_type,
|
558 |
-
'posts_per_page' => 1,
|
559 |
-
) );
|
560 |
-
return $query->found_posts;
|
561 |
-
}
|
562 |
-
|
563 |
-
/**
|
564 |
-
* get_created_datetime
|
565 |
-
* フォームの作成日時を取得
|
566 |
-
* @param string $post_type 投稿タイプ名
|
567 |
-
* @return string 作成日
|
568 |
-
*/
|
569 |
-
private function get_created_datetime( $post_type ) {
|
570 |
-
global $post;
|
571 |
-
$post_id = preg_replace( '/^mwf_(.+?)$/', '$1', $post_type );
|
572 |
-
$post = get_post( $post_id );
|
573 |
-
$post_date = get_the_date();
|
574 |
-
wp_reset_postdata();
|
575 |
-
return $post_date;
|
576 |
-
}
|
577 |
-
|
578 |
-
/**
|
579 |
-
* get_modified_datetime
|
580 |
-
* 問い合わせデータの最新保存日を取得
|
581 |
-
* @param string $post_type 投稿タイプ名
|
582 |
-
* @return string 問い合わせデータの最新保存日
|
583 |
-
*/
|
584 |
-
private function get_modified_datetime( $post_type ) {
|
585 |
-
global $post;
|
586 |
-
$inquiry_posts = get_posts( array(
|
587 |
-
'post_type' => $post_type,
|
588 |
-
'posts_per_page' => 1,
|
589 |
-
'orderby' => 'modified',
|
590 |
-
) );
|
591 |
-
|
592 |
-
$modified_datetime = '';
|
593 |
-
foreach ( $inquiry_posts as $post ) {
|
594 |
-
setup_postdata( $post );
|
595 |
-
$modified_datetime = get_the_modified_date();
|
596 |
-
break;
|
597 |
-
}
|
598 |
-
wp_reset_postdata();
|
599 |
-
return $modified_datetime;
|
600 |
-
}
|
601 |
-
|
602 |
-
/**
|
603 |
-
* get_upload_file_keys
|
604 |
-
* その投稿がもつ upload_file_key を取得
|
605 |
-
* @param object $post
|
606 |
-
* @return array $upload_file_keys
|
607 |
-
*/
|
608 |
-
private function get_upload_file_keys( $_post ) {
|
609 |
-
// 前のバージョンでは MWF_Config::UPLOAD_FILE_KEYS を配列で保持していなかったので分岐させる
|
610 |
-
$_upload_file_keys = get_post_meta( $_post->ID, '_' . MWF_Config::UPLOAD_FILE_KEYS, true );
|
611 |
-
if ( is_array( $_upload_file_keys ) ) {
|
612 |
-
$upload_file_keys = $_upload_file_keys;
|
613 |
-
} else {
|
614 |
-
$upload_file_keys = get_post_custom_values( '_' . MWF_Config::UPLOAD_FILE_KEYS, $_post->ID );
|
615 |
-
}
|
616 |
-
return $upload_file_keys;
|
617 |
-
}
|
618 |
-
|
619 |
-
/**
|
620 |
-
* is_upload_file_key
|
621 |
-
* $meta_key が $post の upload_file_key かどうか
|
622 |
-
* @param object $post
|
623 |
-
* @param string $meta_key
|
624 |
-
* @return bool
|
625 |
-
*/
|
626 |
-
private function is_upload_file_key( $_post, $meta_key ) {
|
627 |
-
$upload_file_keys = $this->get_upload_file_keys( $_post );
|
628 |
-
if ( is_array( $upload_file_keys ) && in_array( $meta_key, $upload_file_keys ) ) {
|
629 |
-
return true;
|
630 |
-
}
|
631 |
-
return false;
|
632 |
-
}
|
633 |
-
|
634 |
-
/**
|
635 |
-
* get_post_data_value
|
636 |
-
* DB保存データの編集画面で付け足した項目の値を取得(翻訳済み)
|
637 |
-
* @param string $key 項目名
|
638 |
-
* @param numeric $post_id
|
639 |
-
* @return string
|
640 |
-
*/
|
641 |
-
private function get_post_data_value( $key, $post_id ) {
|
642 |
-
$post_data = get_post_meta( $post_id, $this->POST_DATA_NAME, true );
|
643 |
-
|
644 |
-
if ( $key === 'response_status' ) {
|
645 |
-
if ( is_array( $post_data ) && isset( $post_data[$key] ) && array_key_exists( $post_data[$key], $this->response_statuses ) ) {
|
646 |
-
return esc_html__( $this->response_statuses[$post_data[$key]], MWF_Config::DOMAIN );
|
647 |
-
} else {
|
648 |
-
return esc_html__( $this->response_statuses['not-supported'], MWF_Config::DOMAIN );
|
649 |
-
}
|
650 |
-
}
|
651 |
-
|
652 |
-
if ( is_array( $post_data ) && isset( $post_data[$key] ) ) {
|
653 |
-
return $post_data[$key];
|
654 |
-
}
|
655 |
-
}
|
656 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
system/mw_wp_form_data.php
DELETED
@@ -1,187 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Name: MW WP Form Data
|
4 |
-
* Description: mw_wp_form のデータ操作用
|
5 |
-
* Version: 1.2.1
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created : October 10, 2013
|
9 |
-
* Modified: August 8, 2014
|
10 |
-
* License: GPLv2
|
11 |
-
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
-
*/
|
13 |
-
class MW_WP_Form_Data {
|
14 |
-
|
15 |
-
/**
|
16 |
-
* MW_WP_Form_Data オブジェクト
|
17 |
-
*/
|
18 |
-
private static $Instance;
|
19 |
-
|
20 |
-
/**
|
21 |
-
* フォームから送信された内容を保存した配列
|
22 |
-
*/
|
23 |
-
private $data = array();
|
24 |
-
|
25 |
-
/**
|
26 |
-
* MW_Sesion オブジェクト
|
27 |
-
*/
|
28 |
-
private $Session;
|
29 |
-
|
30 |
-
/**
|
31 |
-
* __construct
|
32 |
-
* @param string $key データのキー
|
33 |
-
*/
|
34 |
-
private function __construct( $key ) {
|
35 |
-
$this->Session = new MW_Session( $key );
|
36 |
-
$this->data = $this->Session->getValues();
|
37 |
-
}
|
38 |
-
|
39 |
-
public static function getInstance( $key ) {
|
40 |
-
if ( is_null( self::$Instance ) ) {
|
41 |
-
self::$Instance = new self( $key );
|
42 |
-
}
|
43 |
-
return self::$Instance;
|
44 |
-
}
|
45 |
-
|
46 |
-
/**
|
47 |
-
* getValue
|
48 |
-
* データを取得
|
49 |
-
* @param string $key データのキー
|
50 |
-
* @return string データ
|
51 |
-
*/
|
52 |
-
public function getValue( $key ) {
|
53 |
-
if ( isset( $this->data[$key] ) )
|
54 |
-
return $this->data[$key];
|
55 |
-
}
|
56 |
-
|
57 |
-
/**
|
58 |
-
* getValues
|
59 |
-
* 全てのデータを取得
|
60 |
-
* @return array データ
|
61 |
-
*/
|
62 |
-
public function getValues() {
|
63 |
-
if ( $this->data === null )
|
64 |
-
return array();
|
65 |
-
return $this->data;
|
66 |
-
}
|
67 |
-
|
68 |
-
/**
|
69 |
-
* setValue
|
70 |
-
* データを追加
|
71 |
-
* @param string $key データのキー
|
72 |
-
* @param string $value 値
|
73 |
-
*/
|
74 |
-
public function setValue( $key, $value ){
|
75 |
-
$this->data[$key] = $value;
|
76 |
-
$this->Session->setValue( $key, $value );
|
77 |
-
}
|
78 |
-
|
79 |
-
/**
|
80 |
-
* setValue
|
81 |
-
* 複数のデータを一括で追加
|
82 |
-
* @param array 値
|
83 |
-
*/
|
84 |
-
public function setValues( Array $array ) {
|
85 |
-
foreach ( $array as $key => $value ) {
|
86 |
-
$this->data[$key] = $value;
|
87 |
-
$this->Session->setValue( $key, $value );
|
88 |
-
}
|
89 |
-
}
|
90 |
-
|
91 |
-
/**
|
92 |
-
* clearValue
|
93 |
-
* データを消す
|
94 |
-
* @param string $key データのキー
|
95 |
-
*/
|
96 |
-
public function clearValue( $key ) {
|
97 |
-
unset( $this->data[$key] );
|
98 |
-
$this->Session->clearValue( $key );
|
99 |
-
}
|
100 |
-
|
101 |
-
/**
|
102 |
-
* clearValues
|
103 |
-
* データを消す
|
104 |
-
* @param string $key データのキー
|
105 |
-
*/
|
106 |
-
public function clearValues() {
|
107 |
-
$this->data = array();
|
108 |
-
$this->Session->clearValues();
|
109 |
-
}
|
110 |
-
|
111 |
-
/**
|
112 |
-
* pushValue
|
113 |
-
* 指定した $key をキーと配列にデータを追加
|
114 |
-
* @param string $key データのキー
|
115 |
-
* @param string $value 値
|
116 |
-
*/
|
117 |
-
public function pushValue( $key, $value ) {
|
118 |
-
$this->data[$key][] = $value;
|
119 |
-
$this->Session->pushValue( $key, $value );
|
120 |
-
}
|
121 |
-
|
122 |
-
/**
|
123 |
-
* get
|
124 |
-
* 整形済み(メール送信可能な)データを取得
|
125 |
-
* @param string $key データのキー
|
126 |
-
* @return string データ
|
127 |
-
*/
|
128 |
-
public function get( $key ) {
|
129 |
-
if ( isset( $this->data[$key] ) ) {
|
130 |
-
if ( is_array( $this->data[$key] ) ) {
|
131 |
-
if ( !array_key_exists( 'data', $this->data[$key] ) )
|
132 |
-
return;
|
133 |
-
if ( is_array( $this->data[$key]['data'] ) ) {
|
134 |
-
return $this->getSeparatedValue( $key );
|
135 |
-
} else {
|
136 |
-
return $this->data[$key]['data'];
|
137 |
-
}
|
138 |
-
} else {
|
139 |
-
return $this->data[$key];
|
140 |
-
}
|
141 |
-
}
|
142 |
-
}
|
143 |
-
|
144 |
-
/**
|
145 |
-
* getSeparatorValue
|
146 |
-
* 送られてきたseparatorを返す
|
147 |
-
* @param string $key name属性
|
148 |
-
* @return string
|
149 |
-
*/
|
150 |
-
public function getSeparatorValue( $key ) {
|
151 |
-
$value = $this->getValue( $key );
|
152 |
-
if ( is_array( $value ) && isset( $value['separator'] ) ) {
|
153 |
-
return $value['separator'];
|
154 |
-
}
|
155 |
-
}
|
156 |
-
|
157 |
-
/**
|
158 |
-
* getSeparatedValue
|
159 |
-
* 配列データを整形して返す ( 郵便番号等用 )
|
160 |
-
* @param string $key name属性
|
161 |
-
* @param array $children 選択肢
|
162 |
-
* @return string データ
|
163 |
-
*/
|
164 |
-
public function getSeparatedValue( $key, array $children = array() ) {
|
165 |
-
$separator = $this->getSeparatorValue( $key );
|
166 |
-
$value = $this->getValue( $key );
|
167 |
-
if ( is_array( $value ) && isset( $value['data'] ) && is_array( $value['data'] ) && !empty( $separator ) ) {
|
168 |
-
if ( $children ) {
|
169 |
-
$rightData = array();
|
170 |
-
foreach ( $value['data'] as $child ) {
|
171 |
-
if ( isset( $children[$child] ) && !in_array( $children[$child], $rightData ) ) {
|
172 |
-
$rightData[] = $children[$child];
|
173 |
-
}
|
174 |
-
}
|
175 |
-
return implode( $separator, $rightData );
|
176 |
-
} else {
|
177 |
-
// すべて空のからのときはimplodeしないように(---がいってしまうため)
|
178 |
-
foreach ( $value['data'] as $child ) {
|
179 |
-
if ( $child !== '' && $child !== null ) {
|
180 |
-
return implode( $separator, $value['data'] );
|
181 |
-
}
|
182 |
-
}
|
183 |
-
return '';
|
184 |
-
}
|
185 |
-
}
|
186 |
-
}
|
187 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
system/mw_wp_form_file.php
DELETED
@@ -1,328 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Name: MW WP Form File
|
4 |
-
* Description: Tempディレクトリ、ファイルアップロードの処理を行うクラス
|
5 |
-
* Version: 1.0.7
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created : October 10, 2013
|
9 |
-
* Modified: September 1, 2014
|
10 |
-
* License: GPLv2
|
11 |
-
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
-
*/
|
13 |
-
class MW_WP_Form_File {
|
14 |
-
|
15 |
-
/**
|
16 |
-
* __construct
|
17 |
-
*/
|
18 |
-
public function __construct() {
|
19 |
-
add_filter( 'upload_mimes', array( $this, 'upload_mimes' ) );
|
20 |
-
}
|
21 |
-
|
22 |
-
/**
|
23 |
-
* upload_mimes
|
24 |
-
* @param array $t MIMEタイプの配列
|
25 |
-
*/
|
26 |
-
public function upload_mimes( $t ) {
|
27 |
-
$t['psd'] = 'image/vnd.adobe.photoshop';
|
28 |
-
$t['eps'] = 'application/octet-stream';
|
29 |
-
$t['ai'] = 'application/pdf';
|
30 |
-
return $t;
|
31 |
-
}
|
32 |
-
|
33 |
-
/**
|
34 |
-
* checkFileType
|
35 |
-
* @param string $filepath アップロードされたファイルのパス
|
36 |
-
* @param string $filename ファイル名(未アップロード時の$_FILEの検査の場合、temp_nameは乱数になっているため)
|
37 |
-
* @return bool
|
38 |
-
*/
|
39 |
-
protected function checkFileType( $filepath, $filename = '' ) {
|
40 |
-
// WordPress( get_allowed_mime_types ) で許可されたファイルタイプ限定
|
41 |
-
if ( $filename ) {
|
42 |
-
$wp_check_filetype = wp_check_filetype( $filename );
|
43 |
-
} else {
|
44 |
-
$wp_check_filetype = wp_check_filetype( $filepath );
|
45 |
-
}
|
46 |
-
if ( empty( $wp_check_filetype['type'] ) )
|
47 |
-
return false;
|
48 |
-
|
49 |
-
// 1つの拡張子に対し複数のMIMEタイプを持つファイルの対応
|
50 |
-
switch ( $wp_check_filetype['ext'] ) {
|
51 |
-
case 'avi' :
|
52 |
-
$wp_check_filetype['type'] = array(
|
53 |
-
'application/x-troff-msvideo',
|
54 |
-
'video/avi',
|
55 |
-
'video/msvideo',
|
56 |
-
'video/x-msvideo',
|
57 |
-
);
|
58 |
-
break;
|
59 |
-
case 'mp3' :
|
60 |
-
$wp_check_filetype['type'] = array(
|
61 |
-
'audio/mpeg3',
|
62 |
-
'audio/x-mpeg3',
|
63 |
-
'video/mpeg',
|
64 |
-
'video/x-mpeg',
|
65 |
-
'audio/mpeg',
|
66 |
-
);
|
67 |
-
break;
|
68 |
-
case 'mpg' :
|
69 |
-
$wp_check_filetype['type'] = array(
|
70 |
-
'audio/mpeg',
|
71 |
-
'video/mpeg',
|
72 |
-
);
|
73 |
-
break;
|
74 |
-
case 'docx' :
|
75 |
-
case 'xlsx' :
|
76 |
-
case 'pptx' :
|
77 |
-
$wp_check_filetype['type'] = array(
|
78 |
-
$wp_check_filetype['type'],
|
79 |
-
'application/zip',
|
80 |
-
);
|
81 |
-
break;
|
82 |
-
}
|
83 |
-
|
84 |
-
if ( version_compare( phpversion(), '5.3.0' ) >= 0 ) {
|
85 |
-
$finfo = new finfo( FILEINFO_MIME_TYPE );
|
86 |
-
$type = $finfo->file( $filepath );
|
87 |
-
if ( is_array( $wp_check_filetype['type'] ) ) {
|
88 |
-
if ( !( $finfo !== false && in_array( $type, $wp_check_filetype['type'] ) ) )
|
89 |
-
return false;
|
90 |
-
} else {
|
91 |
-
if ( !( $finfo !== false && $type === $wp_check_filetype['type'] ) )
|
92 |
-
return false;
|
93 |
-
}
|
94 |
-
}
|
95 |
-
return true;
|
96 |
-
}
|
97 |
-
|
98 |
-
/**
|
99 |
-
* fileUpload
|
100 |
-
* ファイルアップロード処理。
|
101 |
-
* @return array ( name属性値 => アップロードできたファイルのURL, … )
|
102 |
-
*/
|
103 |
-
public function fileUpload() {
|
104 |
-
$this->createTempDir();
|
105 |
-
$this->cleanTempDir();
|
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 string アップロードしたファイルの 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 |
-
/**
|
159 |
-
* saveAttachmentsInMedia
|
160 |
-
* 添付ファイルをメディアに保存、投稿データに添付ファイルのキー(配列)を保存
|
161 |
-
* $this->options_by_formkey が確定した後でのみ利用可能
|
162 |
-
* @param int post_id
|
163 |
-
* @param array ( ファイルのname属性値 => ファイルパス, … )
|
164 |
-
* @param int 生成フォーム(usedb)の post_id
|
165 |
-
*/
|
166 |
-
public function saveAttachmentsInMedia( $post_id, $attachments, $form_key_post_id ) {
|
167 |
-
require_once( ABSPATH . 'wp-admin' . '/includes/media.php' );
|
168 |
-
require_once( ABSPATH . 'wp-admin' . '/includes/image.php' );
|
169 |
-
$save_attached_key = array();
|
170 |
-
foreach ( $attachments as $key => $filepath ) {
|
171 |
-
if ( !$this->checkFileType( $filepath ) )
|
172 |
-
continue;
|
173 |
-
|
174 |
-
$wp_check_filetype = wp_check_filetype( $filepath );
|
175 |
-
$post_type = get_post_type_object( MWF_Config::DBDATA . $form_key_post_id );
|
176 |
-
$attachment = array(
|
177 |
-
'post_mime_type' => $wp_check_filetype['type'],
|
178 |
-
'post_title' => $key,
|
179 |
-
'post_status' => 'inherit',
|
180 |
-
'post_content' => __( 'Uploaded from ' ) . $post_type->label,
|
181 |
-
);
|
182 |
-
$attach_id = wp_insert_attachment( $attachment, $filepath, $post_id );
|
183 |
-
$attach_data = wp_generate_attachment_metadata( $attach_id, $filepath );
|
184 |
-
$update_attachment_flg = wp_update_attachment_metadata( $attach_id, $attach_data );
|
185 |
-
if ( $attach_id ) {
|
186 |
-
// 代わりにここで attachment_id を保存
|
187 |
-
update_post_meta( $post_id, $key, $attach_id );
|
188 |
-
// $key が 添付ファイルのキーであるとわかるように隠し設定を保存
|
189 |
-
$save_attached_key[] = $key;
|
190 |
-
}
|
191 |
-
}
|
192 |
-
if ( $save_attached_key )
|
193 |
-
update_post_meta( $post_id, '_' . MWF_Config::UPLOAD_FILE_KEYS, $save_attached_key );
|
194 |
-
}
|
195 |
-
|
196 |
-
/**
|
197 |
-
* setUploadFileName
|
198 |
-
* 一時ファイル名を生成。Tempディレクトリの生成に失敗していた場合はUploadディレクトリを使用
|
199 |
-
* @param string 拡張子 ( ex: jpg )
|
200 |
-
* @return array ( file =>, url => )
|
201 |
-
*/
|
202 |
-
protected function setUploadFileName( $extension ) {
|
203 |
-
$count = 0;
|
204 |
-
$basename = date( 'Ymdhis' );
|
205 |
-
$filename = $basename . '.' . $extension;
|
206 |
-
$temp_dir = $this->getTempDir();
|
207 |
-
$upload_dir = $temp_dir['dir'];
|
208 |
-
$upload_url = $temp_dir['url'];
|
209 |
-
if ( !is_writable( $temp_dir['dir'] ) ) {
|
210 |
-
$wp_upload_dir = wp_upload_dir();
|
211 |
-
$upload_dir = realpath( $wp_upload_dir['path'] );
|
212 |
-
$upload_url = $wp_upload_dir['url'];
|
213 |
-
}
|
214 |
-
$uploadfile['file'] = trailingslashit( $upload_dir ) . $filename;
|
215 |
-
$uploadfile['url'] = trailingslashit( $upload_url ) . $filename;
|
216 |
-
while ( file_exists( $uploadfile['file'] ) ) {
|
217 |
-
$count ++;
|
218 |
-
$filename = $basename . '-' . $count . '.' . $extension;
|
219 |
-
$uploadfile['file'] = trailingslashit( $upload_dir ) . $filename;
|
220 |
-
$uploadfile['url'] = trailingslashit( $upload_url ) . $filename;
|
221 |
-
}
|
222 |
-
return $uploadfile;
|
223 |
-
}
|
224 |
-
|
225 |
-
/**
|
226 |
-
* getTempDir
|
227 |
-
* Tempディレクトリ名(パス、URL)を返す。ディレクトリの存在可否は関係なし
|
228 |
-
* @return array ( dir => Tempディレクトリのパス, url => Tempディレクトリのurl )
|
229 |
-
*/
|
230 |
-
protected function getTempDir() {
|
231 |
-
$wp_upload_dir = wp_upload_dir();
|
232 |
-
$temp_dir_name = '/' . MWF_Config::NAME . '_uploads';
|
233 |
-
$temp_dir['dir'] = realpath( $wp_upload_dir['basedir'] ) . $temp_dir_name;
|
234 |
-
$temp_dir['url'] = $wp_upload_dir['baseurl'] . $temp_dir_name;
|
235 |
-
return $temp_dir;
|
236 |
-
}
|
237 |
-
|
238 |
-
/**
|
239 |
-
* createTempDir
|
240 |
-
* Tempディレクトリを作成
|
241 |
-
* @return bool
|
242 |
-
*/
|
243 |
-
protected function createTempDir() {
|
244 |
-
$_ret = false;
|
245 |
-
$temp_dir = $this->getTempDir();
|
246 |
-
$temp_dir = $temp_dir['dir'];
|
247 |
-
if ( !file_exists( $temp_dir ) && !is_writable( $temp_dir ) ) {
|
248 |
-
$_ret = wp_mkdir_p( trailingslashit( $temp_dir ) );
|
249 |
-
@chmod( $temp_dir, 0733 );
|
250 |
-
return $_ret;
|
251 |
-
}
|
252 |
-
return $_ret;
|
253 |
-
}
|
254 |
-
|
255 |
-
/**
|
256 |
-
* removeTempDir
|
257 |
-
* Tempディレクトリを削除
|
258 |
-
* @param string $sub_dir サブディレクトリ名
|
259 |
-
*/
|
260 |
-
public function removeTempDir( $sub_dir = '' ) {
|
261 |
-
$temp_dir = $this->getTempDir();
|
262 |
-
$temp_dir = $temp_dir['dir'];
|
263 |
-
if ( $sub_dir )
|
264 |
-
$temp_dir = trailingslashit( $temp_dir ) . $sub_dir;
|
265 |
-
|
266 |
-
if ( !file_exists( $temp_dir ) )
|
267 |
-
return;
|
268 |
-
$handle = opendir( $temp_dir );
|
269 |
-
if ( $handle === false )
|
270 |
-
return;
|
271 |
-
|
272 |
-
while ( false !== ( $file = readdir( $handle ) ) ) {
|
273 |
-
if ( $file !== '.' && $file !== '..' ) {
|
274 |
-
if ( is_dir( trailingslashit( $temp_dir ) . $file ) ) {
|
275 |
-
$this->removeTempDir( $file );
|
276 |
-
} else {
|
277 |
-
unlink( trailingslashit( $temp_dir ) . $file );
|
278 |
-
}
|
279 |
-
}
|
280 |
-
}
|
281 |
-
closedir( $handle );
|
282 |
-
rmdir( $temp_dir );
|
283 |
-
}
|
284 |
-
|
285 |
-
/**
|
286 |
-
* cleanTempDir
|
287 |
-
* Tempディレクトリ内のファイルを削除
|
288 |
-
*/
|
289 |
-
protected function cleanTempDir() {
|
290 |
-
$temp_dir = $this->getTempDir();
|
291 |
-
$temp_dir = $temp_dir['dir'];
|
292 |
-
if ( !file_exists( $temp_dir ) )
|
293 |
-
return;
|
294 |
-
$handle = opendir( $temp_dir );
|
295 |
-
if ( $handle === false )
|
296 |
-
return;
|
297 |
-
while ( false !== ( $filename = readdir( $handle ) ) ) {
|
298 |
-
if ( $filename !== '.' && $filename !== '..' && !is_dir( trailingslashit( $temp_dir ) . $filename ) ) {
|
299 |
-
$stat = stat( trailingslashit( $temp_dir ) . $filename );
|
300 |
-
if ( $stat['mtime'] + 3600 < time() )
|
301 |
-
unlink( trailingslashit( $temp_dir ) . $filename );
|
302 |
-
}
|
303 |
-
}
|
304 |
-
closedir( $handle );
|
305 |
-
}
|
306 |
-
|
307 |
-
/**
|
308 |
-
* moveTempFileToUploadDir
|
309 |
-
* Tempディレクトリからuploadディレクトリにファイルを移動。
|
310 |
-
* @param string ファイルパス
|
311 |
-
* @return bool
|
312 |
-
*/
|
313 |
-
public function moveTempFileToUploadDir( $filepath ) {
|
314 |
-
$tempdir = dirname( $filepath );
|
315 |
-
$filename = basename( $filepath );
|
316 |
-
$wp_upload_dir = wp_upload_dir();
|
317 |
-
$uploaddir = realpath( $wp_upload_dir['path'] );
|
318 |
-
$new_filename = wp_unique_filename( $uploaddir, $filename );
|
319 |
-
|
320 |
-
if ( $tempdir == $uploaddir ) {
|
321 |
-
return $filepath;
|
322 |
-
}
|
323 |
-
if ( rename( $filepath, trailingslashit( $uploaddir ) . $new_filename ) ) {
|
324 |
-
return trailingslashit( $uploaddir ) . $new_filename;
|
325 |
-
}
|
326 |
-
return $filepath;
|
327 |
-
}
|
328 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
system/mwf_functions.php
DELETED
@@ -1,129 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Name: MWF Functions
|
4 |
-
* Description: 関数
|
5 |
-
* Version: 1.2.1
|
6 |
-
* Author: Takashi Kitajima
|
7 |
-
* Author URI: http://2inc.org
|
8 |
-
* Created : May 29, 2013
|
9 |
-
* Modified: July 24, 2014
|
10 |
-
* License: GPLv2
|
11 |
-
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
-
*/
|
13 |
-
class MWF_Functions {
|
14 |
-
|
15 |
-
/**
|
16 |
-
* is_numeric
|
17 |
-
* 引数で渡された変数が存在し、かつ数値であるなら true
|
18 |
-
* @param string $value 参照渡し
|
19 |
-
* @return bool
|
20 |
-
*/
|
21 |
-
public static function is_numeric( &$value ) {
|
22 |
-
if ( isset( $value ) && preg_match( '/^\d+$/', $value ) ) {
|
23 |
-
return true;
|
24 |
-
}
|
25 |
-
return false;
|
26 |
-
}
|
27 |
-
|
28 |
-
/**
|
29 |
-
* array_clean
|
30 |
-
* 配列の空要素を削除
|
31 |
-
* @param array $array
|
32 |
-
* @return array
|
33 |
-
*/
|
34 |
-
public static function array_clean( $array ) {
|
35 |
-
return array_merge( array_diff( $array, array( '' ) ) );
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
* is_empty
|
40 |
-
* 値が空(0は許可)
|
41 |
-
* @param mixed
|
42 |
-
* @return bool
|
43 |
-
*/
|
44 |
-
public static function is_empty( $value ) {
|
45 |
-
if ( $value === array() || $value === '' || $value === null ) {
|
46 |
-
return true;
|
47 |
-
} else {
|
48 |
-
return false;
|
49 |
-
}
|
50 |
-
}
|
51 |
-
|
52 |
-
/**
|
53 |
-
* fileurl_to_path
|
54 |
-
* ファイルURLをファイルパスに変換
|
55 |
-
* @param string $fileurl
|
56 |
-
* @return string
|
57 |
-
*/
|
58 |
-
public static function fileurl_to_path( $fileurl ) {
|
59 |
-
$wp_upload_dir = wp_upload_dir();
|
60 |
-
if ( preg_match( '/^https?:\/\//', $fileurl ) ) {
|
61 |
-
$baseurl = preg_replace( '/^https?:\/\/(.+)$/', '$1', $wp_upload_dir['baseurl'] );
|
62 |
-
$fileurl = preg_replace( '/^https?:\/\/(.+)$/', '$1', $fileurl );
|
63 |
-
$filepath = str_replace(
|
64 |
-
$baseurl,
|
65 |
-
realpath( $wp_upload_dir['basedir'] ),
|
66 |
-
$fileurl
|
67 |
-
);
|
68 |
-
return $filepath;
|
69 |
-
}
|
70 |
-
}
|
71 |
-
|
72 |
-
/**
|
73 |
-
* filepath_to_url
|
74 |
-
* ファイルパスをURLに変換
|
75 |
-
* @param string $filepath
|
76 |
-
* @return string
|
77 |
-
*/
|
78 |
-
public static function filepath_to_url( $filepath ) {
|
79 |
-
$wp_upload_dir = wp_upload_dir();
|
80 |
-
$fileurl = str_replace(
|
81 |
-
realpath( $wp_upload_dir['basedir'] ),
|
82 |
-
$wp_upload_dir['baseurl'],
|
83 |
-
$filepath
|
84 |
-
);
|
85 |
-
if ( is_ssl() ) {
|
86 |
-
$fileurl = preg_replace( '/^https?:\/\//', 'https://', $fileurl );
|
87 |
-
}
|
88 |
-
return $fileurl;
|
89 |
-
}
|
90 |
-
|
91 |
-
/**
|
92 |
-
* convert_eol
|
93 |
-
* 改行コードを \n に統一
|
94 |
-
* @param sring $string
|
95 |
-
* @return string $string
|
96 |
-
*/
|
97 |
-
public static function convert_eol( $string ) {
|
98 |
-
return preg_replace( "/\r\n|\r|\n/", "\n", $string );
|
99 |
-
}
|
100 |
-
|
101 |
-
/**
|
102 |
-
* deprecated_message
|
103 |
-
* 古いメソッドを使った場合にエラーを出力
|
104 |
-
* @param string $function_name メソッド名
|
105 |
-
* @param string $new_function 代替のメソッド名
|
106 |
-
*/
|
107 |
-
public static function deprecated_message( $function_name, $new_function = '' ) {
|
108 |
-
global $mwform_deprecated_message;
|
109 |
-
$mwform_deprecated_message .= '<div class="' . esc_attr( MWF_Config::NAME ) . '-deprecated-message">';
|
110 |
-
$mwform_deprecated_message .= sprintf( 'MW WP Form dosen\'t support "%s" already. ', $function_name );
|
111 |
-
if ( $new_function ) {
|
112 |
-
$mwform_deprecated_message .= sprintf( 'You should use "%s". ', $new_function );
|
113 |
-
}
|
114 |
-
$debug_backtrace = debug_backtrace();
|
115 |
-
array_shift( $debug_backtrace );
|
116 |
-
foreach ( $debug_backtrace as $value ) {
|
117 |
-
$mwform_deprecated_message .= sprintf( '%s line %d', @$value['file'], @$value['line'] );
|
118 |
-
break;
|
119 |
-
}
|
120 |
-
$mwform_deprecated_message .= '</div>';
|
121 |
-
add_filter( 'the_content', 'MWF_Functions::_deprecated_message' );
|
122 |
-
}
|
123 |
-
public static function _deprecated_message( $content ) {
|
124 |
-
global $mwform_deprecated_message;
|
125 |
-
$content = $mwform_deprecated_message . $content;
|
126 |
-
unset( $mwform_deprecated_message );
|
127 |
-
return $content;
|
128 |
-
}
|
129 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|