Version Description
- 2018-06-07
Download this release
Release Info
Developer | codeinwp |
Plugin | Contact Form & SMTP Plugin for WordPress by PirateForms |
Version | 2.4.2 |
Comparing to | |
See all releases |
Code changes from version 2.4.1 to 2.4.2
- CHANGELOG.md +7 -0
- admin/class-pirateforms-admin.php +114 -4
- includes/class-pirateforms-widget.php +10 -0
- includes/class-pirateforms.php +16 -1
- pirate-forms.php +4 -2
- public/class-pirateforms-public.php +318 -202
- public/css/front.css +1 -1
- public/js/scripts-general.js +0 -21
- public/js/scripts.js +123 -30
- readme.md +27 -0
- readme.txt +27 -0
- themeisle-hash.json +1 -1
- vendor/autoload.php +1 -1
- vendor/autoload_52.php +1 -1
- vendor/codeinwp/themeisle-sdk/class-themeisle-sdk-licenser.php +48 -57
- vendor/codeinwp/themeisle-sdk/load.php +1 -1
- vendor/composer/autoload_real.php +5 -5
- vendor/composer/autoload_real_52.php +3 -3
- vendor/composer/installed.json +4 -4
CHANGELOG.md
CHANGED
@@ -1,4 +1,11 @@
|
|
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
### v2.4.1 - 2018-05-07
|
3 |
**Changes:**
|
4 |
* GDPR compliance
|
1 |
|
2 |
+
### v2.4.2 - 2018-06-07
|
3 |
+
**Changes:**
|
4 |
+
* NEW support for submitting Ajax forms with [pirate_forms ajax="yes"]
|
5 |
+
* Added compatibility with WordPress 4.9.6 Export and Erase Personal Data options
|
6 |
+
* Fixed issue with form caused by the reCaptcha
|
7 |
+
* Fixed compatibility issues with the wpDataTables Lite plugin
|
8 |
+
|
9 |
### v2.4.1 - 2018-05-07
|
10 |
**Changes:**
|
11 |
* GDPR compliance
|
admin/class-pirateforms-admin.php
CHANGED
@@ -61,11 +61,13 @@ class PirateForms_Admin {
|
|
61 |
* @since 1.0.0
|
62 |
*/
|
63 |
public function enqueue_styles_and_scripts() {
|
64 |
-
|
65 |
|
66 |
-
|
|
|
|
|
67 |
|
68 |
-
if (
|
69 |
wp_enqueue_style( 'pirateforms_admin_styles', PIRATEFORMS_URL . 'admin/css/wp-admin.css', array(), $this->version );
|
70 |
wp_enqueue_script( 'pirateforms_scripts_admin', PIRATEFORMS_URL . 'admin/js/scripts-admin.js', array( 'jquery', 'jquery-ui-tooltip' ), $this->version );
|
71 |
wp_localize_script(
|
@@ -79,8 +81,8 @@ class PirateForms_Admin {
|
|
79 |
)
|
80 |
);
|
81 |
}
|
82 |
-
if ( isset( $_GET['page'] ) && $_GET['page'] == 'pf_more_features' ) {
|
83 |
|
|
|
84 |
wp_enqueue_style( 'pirateforms_upsell_styles', PIRATEFORMS_URL . 'admin/css/upsell.css', array(), $this->version );
|
85 |
}
|
86 |
}
|
@@ -1137,4 +1139,112 @@ class PirateForms_Admin {
|
|
1137 |
|
1138 |
return $body;
|
1139 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1140 |
}
|
61 |
* @since 1.0.0
|
62 |
*/
|
63 |
public function enqueue_styles_and_scripts() {
|
64 |
+
$current_screen = get_current_screen();
|
65 |
|
66 |
+
if ( ! isset( $current_screen->id ) ) {
|
67 |
+
return;
|
68 |
+
}
|
69 |
|
70 |
+
if ( in_array( $current_screen->id, array( 'edit-pf_contact', 'edit-pf_form', 'pf_form', 'toplevel_page_pirateforms-admin' ) ) ) {
|
71 |
wp_enqueue_style( 'pirateforms_admin_styles', PIRATEFORMS_URL . 'admin/css/wp-admin.css', array(), $this->version );
|
72 |
wp_enqueue_script( 'pirateforms_scripts_admin', PIRATEFORMS_URL . 'admin/js/scripts-admin.js', array( 'jquery', 'jquery-ui-tooltip' ), $this->version );
|
73 |
wp_localize_script(
|
81 |
)
|
82 |
);
|
83 |
}
|
|
|
84 |
|
85 |
+
if ( isset( $_GET['page'] ) && $_GET['page'] == 'pf_more_features' ) {
|
86 |
wp_enqueue_style( 'pirateforms_upsell_styles', PIRATEFORMS_URL . 'admin/css/upsell.css', array(), $this->version );
|
87 |
}
|
88 |
}
|
1139 |
|
1140 |
return $body;
|
1141 |
}
|
1142 |
+
|
1143 |
+
/**
|
1144 |
+
* Register the private data exporter.
|
1145 |
+
*/
|
1146 |
+
public function register_private_data_exporter( $exporters ) {
|
1147 |
+
$exporters[ PIRATEFORMS_SLUG ] = array(
|
1148 |
+
'exporter_friendly_name' => PIRATEFORMS_NAME,
|
1149 |
+
'callback' => array( $this, 'private_data_exporter' ),
|
1150 |
+
);
|
1151 |
+
return $exporters;
|
1152 |
+
}
|
1153 |
+
|
1154 |
+
/**
|
1155 |
+
* Export the private data.
|
1156 |
+
*/
|
1157 |
+
public function private_data_exporter( $email_address, $page = 1 ) {
|
1158 |
+
$export_items = array();
|
1159 |
+
$query = new WP_Query(
|
1160 |
+
array(
|
1161 |
+
'post_type' => 'pf_contact',
|
1162 |
+
'numberposts' => 300,
|
1163 |
+
'post_status' => array( 'publish', 'private' ),
|
1164 |
+
'meta_query' => array(
|
1165 |
+
array(
|
1166 |
+
'key' => 'Contact email',
|
1167 |
+
'value' => $email_address,
|
1168 |
+
),
|
1169 |
+
),
|
1170 |
+
)
|
1171 |
+
);
|
1172 |
+
|
1173 |
+
if ( $query->have_posts() ) {
|
1174 |
+
while ( $query->have_posts() ) {
|
1175 |
+
$query->the_post();
|
1176 |
+
|
1177 |
+
$data = array(
|
1178 |
+
array(
|
1179 |
+
'name' => __( 'Email content', 'pirate-forms' ),
|
1180 |
+
'value' => nl2br( strip_tags( $query->post->post_content ) ),
|
1181 |
+
),
|
1182 |
+
);
|
1183 |
+
|
1184 |
+
$export_items[] = array(
|
1185 |
+
'group_id' => 'pf_contact',
|
1186 |
+
'group_label' => PIRATEFORMS_NAME,
|
1187 |
+
'item_id' => "pf_contact-{$query->post->ID}",
|
1188 |
+
'data' => $data,
|
1189 |
+
);
|
1190 |
+
}
|
1191 |
+
}
|
1192 |
+
|
1193 |
+
return array(
|
1194 |
+
'data' => $export_items,
|
1195 |
+
'done' => true,
|
1196 |
+
);
|
1197 |
+
}
|
1198 |
+
|
1199 |
+
/**
|
1200 |
+
* Register the private data eraser.
|
1201 |
+
*/
|
1202 |
+
public function register_private_data_eraser( $erasers ) {
|
1203 |
+
$erasers[ PIRATEFORMS_SLUG ] = array(
|
1204 |
+
'eraser_friendly_name' => PIRATEFORMS_NAME,
|
1205 |
+
'callback' => array( $this, 'private_data_eraser' ),
|
1206 |
+
);
|
1207 |
+
return $erasers;
|
1208 |
+
}
|
1209 |
+
|
1210 |
+
/**
|
1211 |
+
* Erase the private data.
|
1212 |
+
*/
|
1213 |
+
public function private_data_eraser( $email_address, $page = 1 ) {
|
1214 |
+
$query = new WP_Query(
|
1215 |
+
array(
|
1216 |
+
'post_type' => 'pf_contact',
|
1217 |
+
'numberposts' => 300,
|
1218 |
+
'post_status' => array( 'publish', 'private' ),
|
1219 |
+
'fields' => 'ids',
|
1220 |
+
'meta_query' => array(
|
1221 |
+
array(
|
1222 |
+
'key' => 'Contact email',
|
1223 |
+
'value' => $email_address,
|
1224 |
+
),
|
1225 |
+
),
|
1226 |
+
)
|
1227 |
+
);
|
1228 |
+
|
1229 |
+
$retained = array();
|
1230 |
+
$removed = 0;
|
1231 |
+
|
1232 |
+
if ( $query->have_posts() ) {
|
1233 |
+
while ( $query->have_posts() ) {
|
1234 |
+
$query->the_post();
|
1235 |
+
if ( false !== ( $post_id = wp_delete_post( $query->post, true ) ) ) {
|
1236 |
+
$removed++;
|
1237 |
+
} else {
|
1238 |
+
$retained[] = $query->post;
|
1239 |
+
}
|
1240 |
+
}
|
1241 |
+
}
|
1242 |
+
|
1243 |
+
return array(
|
1244 |
+
'items_removed' => $removed,
|
1245 |
+
'items_retained' => ! empty( $retained ) ? count( $retained ) : false,
|
1246 |
+
'messages' => ! empty( $retained ) ? array(sprintf( __( 'Unable to delete post(s) %s', 'pirate-forms' ), print_r( $retained, true ) )) : array(),
|
1247 |
+
'done' => true,
|
1248 |
+
);
|
1249 |
+
}
|
1250 |
}
|
includes/class-pirateforms-widget.php
CHANGED
@@ -59,6 +59,10 @@ class pirate_forms_contact_widget extends WP_Widget {
|
|
59 |
}
|
60 |
|
61 |
$attributes = array( 'from' => 'widget' );
|
|
|
|
|
|
|
|
|
62 |
$attributes = apply_filters( 'pirate_forms_widget_attributes', $attributes, $instance );
|
63 |
|
64 |
$shortcode = '[pirate_forms';
|
@@ -82,6 +86,7 @@ class pirate_forms_contact_widget extends WP_Widget {
|
|
82 |
// Storing widget title as inputted option or category name
|
83 |
$instance['pirate_forms_widget_title'] = apply_filters( 'widget_title', sanitize_text_field( $new_instance['pirate_forms_widget_title'] ) );
|
84 |
$instance['pirate_forms_widget_subtext'] = $new_instance['pirate_forms_widget_subtext'];
|
|
|
85 |
|
86 |
$instance = apply_filters( 'pirate_forms_widget_update', $instance, $new_instance );
|
87 |
|
@@ -96,6 +101,7 @@ class pirate_forms_contact_widget extends WP_Widget {
|
|
96 |
function form( $instance ) {
|
97 |
$pirate_forms_widget_title = ! empty( $instance['pirate_forms_widget_title'] ) ? $instance['pirate_forms_widget_title'] : __( 'Title', 'pirate-forms' );
|
98 |
$pirate_forms_widget_subtext = ! empty( $instance['pirate_forms_widget_subtext'] ) ? $instance['pirate_forms_widget_subtext'] : __( 'Text above form', 'pirate-forms' );
|
|
|
99 |
?>
|
100 |
<p>
|
101 |
<label for="<?php echo $this->get_field_id( 'pirate_forms_widget_title' ); ?>"><?php _e( 'Title:', 'pirate-forms' ); ?></label>
|
@@ -108,6 +114,10 @@ class pirate_forms_contact_widget extends WP_Widget {
|
|
108 |
<textarea class="widefat" id="<?php echo $this->get_field_id( 'pirate_forms_widget_subtext' ); ?>"
|
109 |
name="<?php echo $this->get_field_name( 'pirate_forms_widget_subtext' ); ?>"><?php echo esc_attr( $pirate_forms_widget_subtext ); ?></textarea>
|
110 |
</p>
|
|
|
|
|
|
|
|
|
111 |
<?php
|
112 |
echo apply_filters( 'pirate_forms_widget_form', sprintf( '<p>%s</p>', sprintf( __( 'Need more forms ? Check our <a href="%s" target="_blank">extended</a> version for more features', 'pirate-forms' ), PIRATEFORMS_USELL_LINK ) ), $instance, $this );
|
113 |
}
|
59 |
}
|
60 |
|
61 |
$attributes = array( 'from' => 'widget' );
|
62 |
+
if ( isset( $instance['pirate_forms_widget_ajax'] ) && $instance['pirate_forms_widget_ajax'] ) {
|
63 |
+
$attributes['ajax'] = 'yes';
|
64 |
+
}
|
65 |
+
|
66 |
$attributes = apply_filters( 'pirate_forms_widget_attributes', $attributes, $instance );
|
67 |
|
68 |
$shortcode = '[pirate_forms';
|
86 |
// Storing widget title as inputted option or category name
|
87 |
$instance['pirate_forms_widget_title'] = apply_filters( 'widget_title', sanitize_text_field( $new_instance['pirate_forms_widget_title'] ) );
|
88 |
$instance['pirate_forms_widget_subtext'] = $new_instance['pirate_forms_widget_subtext'];
|
89 |
+
$instance['pirate_forms_widget_ajax'] = ( isset( $new_instance['pirate_forms_widget_ajax'] ) ) ? (bool) $new_instance['pirate_forms_widget_ajax'] : false;
|
90 |
|
91 |
$instance = apply_filters( 'pirate_forms_widget_update', $instance, $new_instance );
|
92 |
|
101 |
function form( $instance ) {
|
102 |
$pirate_forms_widget_title = ! empty( $instance['pirate_forms_widget_title'] ) ? $instance['pirate_forms_widget_title'] : __( 'Title', 'pirate-forms' );
|
103 |
$pirate_forms_widget_subtext = ! empty( $instance['pirate_forms_widget_subtext'] ) ? $instance['pirate_forms_widget_subtext'] : __( 'Text above form', 'pirate-forms' );
|
104 |
+
$pirate_forms_widget_ajax = ! empty( $instance['pirate_forms_widget_ajax'] ) && intval( $instance['pirate_forms_widget_ajax'] ) === 1 ? 'checked' : '';
|
105 |
?>
|
106 |
<p>
|
107 |
<label for="<?php echo $this->get_field_id( 'pirate_forms_widget_title' ); ?>"><?php _e( 'Title:', 'pirate-forms' ); ?></label>
|
114 |
<textarea class="widefat" id="<?php echo $this->get_field_id( 'pirate_forms_widget_subtext' ); ?>"
|
115 |
name="<?php echo $this->get_field_name( 'pirate_forms_widget_subtext' ); ?>"><?php echo esc_attr( $pirate_forms_widget_subtext ); ?></textarea>
|
116 |
</p>
|
117 |
+
<p>
|
118 |
+
<label for="<?php echo $this->get_field_id( 'pirate_forms_widget_ajax' ); ?>"><?php _e( 'Submit form using Ajax:', 'pirate-forms' ); ?></label>
|
119 |
+
<input type="checkbox" id="<?php echo $this->get_field_id( 'pirate_forms_widget_ajax' ); ?>" name="<?php echo $this->get_field_name( 'pirate_forms_widget_ajax' ); ?>" value="1" <?php echo $pirate_forms_widget_ajax; ?>>
|
120 |
+
</p>
|
121 |
<?php
|
122 |
echo apply_filters( 'pirate_forms_widget_form', sprintf( '<p>%s</p>', sprintf( __( 'Need more forms ? Check our <a href="%s" target="_blank">extended</a> version for more features', 'pirate-forms' ), PIRATEFORMS_USELL_LINK ) ), $instance, $this );
|
123 |
}
|
includes/class-pirateforms.php
CHANGED
@@ -69,7 +69,7 @@ class PirateForms {
|
|
69 |
public function __construct() {
|
70 |
|
71 |
$this->plugin_name = 'pirateforms';
|
72 |
-
$this->version = '2.4.
|
73 |
|
74 |
$this->load_dependencies();
|
75 |
$this->set_locale();
|
@@ -130,6 +130,10 @@ class PirateForms {
|
|
130 |
private function define_common_hooks() {
|
131 |
$this->loader->add_action( 'init', $this, 'register_content_type', 10 );
|
132 |
$this->loader->add_filter( 'pirate_forms_version_supports', $this, 'version_supports' );
|
|
|
|
|
|
|
|
|
133 |
}
|
134 |
|
135 |
/**
|
@@ -160,6 +164,8 @@ class PirateForms {
|
|
160 |
|
161 |
$this->loader->add_filter( 'manage_pf_contact_posts_columns', $plugin_admin, 'manage_contact_posts_columns', PHP_INT_MAX );
|
162 |
$this->loader->add_filter( 'manage_pf_contact_posts_custom_column', $plugin_admin, 'manage_contact_posts_custom_column', 10, 2 );
|
|
|
|
|
163 |
|
164 |
}
|
165 |
|
@@ -188,6 +194,8 @@ class PirateForms {
|
|
188 |
$this->loader->add_filter( 'widget_text', $plugin_public, 'widget_text_filter', 9 );
|
189 |
$this->loader->add_filter( 'pirate_forms_public_controls', $plugin_public, 'compatibility_class', 9 );
|
190 |
|
|
|
|
|
191 |
/**
|
192 |
* SDK tweaks.
|
193 |
*/
|
@@ -286,4 +294,11 @@ class PirateForms {
|
|
286 |
public function version_supports( $null = null ) {
|
287 |
return array( 'wysiwyg' );
|
288 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
289 |
}
|
69 |
public function __construct() {
|
70 |
|
71 |
$this->plugin_name = 'pirateforms';
|
72 |
+
$this->version = '2.4.2';
|
73 |
|
74 |
$this->load_dependencies();
|
75 |
$this->set_locale();
|
130 |
private function define_common_hooks() {
|
131 |
$this->loader->add_action( 'init', $this, 'register_content_type', 10 );
|
132 |
$this->loader->add_filter( 'pirate_forms_version_supports', $this, 'version_supports' );
|
133 |
+
|
134 |
+
if ( PIRATEFORMS_DEBUG ) {
|
135 |
+
$this->loader->add_action( 'themeisle_log_event', $this, 'themeisle_log_event_debug', 10, 5 );
|
136 |
+
}
|
137 |
}
|
138 |
|
139 |
/**
|
164 |
|
165 |
$this->loader->add_filter( 'manage_pf_contact_posts_columns', $plugin_admin, 'manage_contact_posts_columns', PHP_INT_MAX );
|
166 |
$this->loader->add_filter( 'manage_pf_contact_posts_custom_column', $plugin_admin, 'manage_contact_posts_custom_column', 10, 2 );
|
167 |
+
$this->loader->add_filter( 'wp_privacy_personal_data_exporters', $plugin_admin, 'register_private_data_exporter', 10 );
|
168 |
+
$this->loader->add_filter( 'wp_privacy_personal_data_erasers', $plugin_admin, 'register_private_data_eraser', 10 );
|
169 |
|
170 |
}
|
171 |
|
194 |
$this->loader->add_filter( 'widget_text', $plugin_public, 'widget_text_filter', 9 );
|
195 |
$this->loader->add_filter( 'pirate_forms_public_controls', $plugin_public, 'compatibility_class', 9 );
|
196 |
|
197 |
+
$this->loader->add_action( 'rest_api_init', $plugin_public, 'register_endpoint' );
|
198 |
+
|
199 |
/**
|
200 |
* SDK tweaks.
|
201 |
*/
|
294 |
public function version_supports( $null = null ) {
|
295 |
return array( 'wysiwyg' );
|
296 |
}
|
297 |
+
|
298 |
+
/**
|
299 |
+
* For local testing, overrides the 'themeisle_log_event' hook and redirects to error.log.
|
300 |
+
*/
|
301 |
+
final function themeisle_log_event_debug( $name, $message, $type, $file, $line ) {
|
302 |
+
error_log( sprintf( '%s (%s): %s in %s:%s', $name, $type, $message, $file, $line ) );
|
303 |
+
}
|
304 |
}
|
pirate-forms.php
CHANGED
@@ -16,7 +16,7 @@
|
|
16 |
* Plugin Name: Free & Simple Contact Form Plugin - Pirateforms
|
17 |
* Plugin URI: http://themeisle.com/plugins/pirate-forms/
|
18 |
* Description: Easily creates a nice looking, simple contact form on your WP site.
|
19 |
-
* Version: 2.4.
|
20 |
* Author: Themeisle
|
21 |
* Author URI: http://themeisle.com
|
22 |
* Text Domain: pirate-forms
|
@@ -35,13 +35,15 @@ if ( ! defined( 'WPINC' ) ) {
|
|
35 |
|
36 |
define( 'PIRATEFORMS_NAME', 'Pirate Forms' );
|
37 |
define( 'PIRATEFORMS_SLUG', 'pirate-forms' );
|
|
|
38 |
define( 'PIRATEFORMS_USELL_LINK', 'https://themeisle.com/plugins/pirate-forms-extended/' );
|
39 |
-
define( 'PIRATE_FORMS_VERSION', '2.4.
|
40 |
define( 'PIRATEFORMS_DIR', trailingslashit( plugin_dir_path( __FILE__ ) ) );
|
41 |
define( 'PIRATEFORMS_URL', plugin_dir_url( __FILE__ ) );
|
42 |
define( 'PIRATEFORMS_BASENAME', plugin_basename( __FILE__ ) );
|
43 |
define( 'PIRATEFORMS_BASEFILE', __FILE__ );
|
44 |
define( 'PIRATEFORMS_ROOT', trailingslashit( plugins_url( '', __FILE__ ) ) );
|
|
|
45 |
|
46 |
/**
|
47 |
* The code that runs during plugin activation.
|
16 |
* Plugin Name: Free & Simple Contact Form Plugin - Pirateforms
|
17 |
* Plugin URI: http://themeisle.com/plugins/pirate-forms/
|
18 |
* Description: Easily creates a nice looking, simple contact form on your WP site.
|
19 |
+
* Version: 2.4.2
|
20 |
* Author: Themeisle
|
21 |
* Author URI: http://themeisle.com
|
22 |
* Text Domain: pirate-forms
|
35 |
|
36 |
define( 'PIRATEFORMS_NAME', 'Pirate Forms' );
|
37 |
define( 'PIRATEFORMS_SLUG', 'pirate-forms' );
|
38 |
+
define( 'PIRATEFORMS_API_VERSION', '1' );
|
39 |
define( 'PIRATEFORMS_USELL_LINK', 'https://themeisle.com/plugins/pirate-forms-extended/' );
|
40 |
+
define( 'PIRATE_FORMS_VERSION', '2.4.2' );
|
41 |
define( 'PIRATEFORMS_DIR', trailingslashit( plugin_dir_path( __FILE__ ) ) );
|
42 |
define( 'PIRATEFORMS_URL', plugin_dir_url( __FILE__ ) );
|
43 |
define( 'PIRATEFORMS_BASENAME', plugin_basename( __FILE__ ) );
|
44 |
define( 'PIRATEFORMS_BASEFILE', __FILE__ );
|
45 |
define( 'PIRATEFORMS_ROOT', trailingslashit( plugins_url( '', __FILE__ ) ) );
|
46 |
+
define( 'PIRATEFORMS_DEBUG', false );
|
47 |
|
48 |
/**
|
49 |
* The code that runs during plugin activation.
|
public/class-pirateforms-public.php
CHANGED
@@ -40,6 +40,22 @@ class PirateForms_Public {
|
|
40 |
*/
|
41 |
private $version;
|
42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
/**
|
44 |
* The file types allowed to be uploaded. Can take a look at https://en.support.wordpress.com/accepted-filetypes/ for inspiration.
|
45 |
*
|
@@ -115,34 +131,32 @@ class PirateForms_Public {
|
|
115 |
/* style for frontpage contact */
|
116 |
wp_register_style( 'pirate_forms_front_styles', PIRATEFORMS_URL . 'public/css/front.css', array(), $this->version );
|
117 |
/* recaptcha js */
|
118 |
-
$deps = array( 'jquery' );
|
119 |
-
$pirate_forms_options = get_option( 'pirate_forms_settings_array' );
|
120 |
-
if ( ! empty( $pirate_forms_options ) ) :
|
121 |
-
if ( ! empty( $pirate_forms_options['pirateformsopt_recaptcha_secretkey'] ) && ! empty( $pirate_forms_options['pirateformsopt_recaptcha_sitekey'] ) && ! empty( $pirate_forms_options['pirateformsopt_recaptcha_field'] ) && ( 'yes' === $pirate_forms_options['pirateformsopt_recaptcha_field'] ) ) :
|
122 |
-
if ( defined( 'POLYLANG_VERSION' ) && function_exists( 'pll_current_language' ) ) {
|
123 |
-
$pirate_forms_contactus_language = pll_current_language();
|
124 |
-
} else {
|
125 |
-
$pirate_forms_contactus_language = get_locale();
|
126 |
-
}
|
127 |
-
wp_register_script( 'recaptcha', 'https://www.google.com/recaptcha/api.js?hl=' . $pirate_forms_contactus_language . '' );
|
128 |
-
$deps[] = 'recaptcha';
|
129 |
-
endif;
|
130 |
-
endif;
|
131 |
|
132 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
|
134 |
-
wp_register_script( 'pirate_forms_scripts_general', PIRATEFORMS_URL . 'public/js/scripts-general.js', array( 'jquery' ), $this->version );
|
135 |
$pirate_forms_errors = '';
|
136 |
if ( ! empty( $_SESSION['pirate_forms_contact_errors'] ) ) :
|
137 |
$pirate_forms_errors = $_SESSION['pirate_forms_contact_errors'];
|
138 |
endif;
|
139 |
wp_localize_script(
|
140 |
-
'
|
141 |
'errors' => $pirate_forms_errors,
|
142 |
'spam' => array(
|
143 |
'label' => __( 'I\'m human!', 'pirate-forms' ),
|
144 |
'value' => wp_create_nonce( PIRATEFORMS_NAME ),
|
145 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
)
|
147 |
);
|
148 |
}
|
@@ -153,8 +167,6 @@ class PirateForms_Public {
|
|
153 |
* @since 1.0.0
|
154 |
*/
|
155 |
public function display_form( $atts, $content = null ) {
|
156 |
-
wp_enqueue_script( 'pirate_forms_scripts' );
|
157 |
-
wp_enqueue_script( 'pirate_forms_scripts_general' );
|
158 |
wp_enqueue_style( 'pirate_forms_front_styles' );
|
159 |
|
160 |
PirateForms_Util::session_start();
|
@@ -162,6 +174,7 @@ class PirateForms_Public {
|
|
162 |
array(
|
163 |
'from' => '',
|
164 |
'id' => '',
|
|
|
165 |
), $atts
|
166 |
);
|
167 |
|
@@ -170,6 +183,20 @@ class PirateForms_Public {
|
|
170 |
$elements = array();
|
171 |
$pirate_form = new PirateForms_PhpFormBuilder();
|
172 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
$elements[] = array(
|
174 |
'type' => 'text',
|
175 |
'id' => 'form_honeypot',
|
@@ -205,10 +232,11 @@ class PirateForms_Public {
|
|
205 |
$nonce_append = $from_widget ? 'yes' : 'no';
|
206 |
|
207 |
$error_key = wp_create_nonce( get_bloginfo( 'admin_email' ) . ( $from_widget ? 'yes' : 'no' ) );
|
|
|
208 |
|
209 |
$thank_you_message = '';
|
210 |
-
if ( isset( $_GET['done'] ) && ! empty( $_SESSION[ 'success' . $
|
211 |
-
$thank_you_message = $_SESSION[ 'success' . $
|
212 |
}
|
213 |
|
214 |
$pirate_form->set_element( 'thank_you_message', $thank_you_message );
|
@@ -435,7 +463,7 @@ class PirateForms_Public {
|
|
435 |
$elements[] = array(
|
436 |
'type' => 'button',
|
437 |
'id' => 'pirate-forms-contact-submit',
|
438 |
-
'class' => 'pirate-forms-submit-button btn btn-primary',
|
439 |
'wrap' => array(
|
440 |
'type' => 'div',
|
441 |
'class' => implode( ' ', apply_filters( 'pirateform_wrap_classes_submit', array( 'col-xs-12 ' . ( ( ! empty( $pirate_forms_options['pirateformsopt_recaptcha_field'] ) && ( $pirate_forms_options['pirateformsopt_recaptcha_field'] !== 'yes' ) ) ? 'col-sm-6 ' : '' ) . 'form_field_wrap contact_submit_wrap' ) ) ),
|
@@ -463,9 +491,9 @@ class PirateForms_Public {
|
|
463 |
}
|
464 |
|
465 |
/* Are there any submission errors? */
|
466 |
-
if ( ! empty( $_SESSION[ 'error' . $
|
467 |
-
$pirate_form->set_element( 'errors', $_SESSION[ 'error' . $
|
468 |
-
unset( $_SESSION[ 'error' . $
|
469 |
}
|
470 |
|
471 |
$elements = apply_filters( 'pirate_forms_get_custom_elements', $elements, $pirate_forms_options );
|
@@ -474,8 +502,8 @@ class PirateForms_Public {
|
|
474 |
|
475 |
$output = $pirate_form->build_form( apply_filters( 'pirate_forms_public_controls', $elements, $pirate_forms_options, $from_widget ), $pirate_forms_options, $from_widget );
|
476 |
|
477 |
-
unset( $_SESSION[ 'success' . $
|
478 |
-
unset( $_SESSION[ 'error' . $
|
479 |
|
480 |
return $output;
|
481 |
}
|
@@ -535,20 +563,27 @@ class PirateForms_Public {
|
|
535 |
* @param PirateForms_PhpFormBuilder $form_builder The form builder object.
|
536 |
*/
|
537 |
public function render_errors( $form_builder ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
538 |
$output = '';
|
539 |
-
if ( ! empty( $
|
540 |
$output .= '<div class="col-xs-12 pirate_forms_error_box">';
|
541 |
$output .= '<p>' . __( 'Sorry, an error occured.', 'pirate-forms' ) . '</p>';
|
542 |
$output .= '</div>';
|
543 |
-
foreach ( $
|
544 |
$output .= '<div class="col-xs-12 pirate_forms_error_box">';
|
545 |
$output .= "<p>$err</p>";
|
546 |
$output .= '</div>';
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
echo $output;
|
552 |
}
|
553 |
|
554 |
/**
|
@@ -558,11 +593,19 @@ class PirateForms_Public {
|
|
558 |
*/
|
559 |
public function render_thankyou( $form_builder ) {
|
560 |
if ( ! empty( $form_builder->thank_you_message ) ) {
|
561 |
-
echo
|
562 |
-
. '</p></div>';
|
563 |
}
|
564 |
}
|
565 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
566 |
/**
|
567 |
* Process the form after submission
|
568 |
*
|
@@ -581,42 +624,53 @@ class PirateForms_Public {
|
|
581 |
* @since 1.0.0
|
582 |
* @throws Exception When file uploading fails.
|
583 |
*/
|
584 |
-
public function send_email( $test = false ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
585 |
PirateForms_Util::session_start();
|
586 |
-
do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'POST data = %s', print_r( $
|
587 |
|
588 |
// If POST and honeypot are not set, beat it
|
589 |
-
if ( empty( $
|
590 |
return false;
|
591 |
}
|
592 |
|
593 |
// separate the nonce from a form that is displayed in the widget vs. one that is not
|
594 |
-
$nonce_append = isset( $
|
595 |
|
596 |
// Session variable for form errors
|
597 |
$error_key = wp_create_nonce( get_bloginfo( 'admin_email' ) . $nonce_append );
|
598 |
$_SESSION[ $error_key ] = array();
|
|
|
|
|
599 |
|
600 |
-
// If nonce is not valid, beat it
|
601 |
if ( ! $test && 'yes' === PirateForms_Util::get_option( 'pirateformsopt_nonce' ) ) {
|
602 |
-
if ( ! wp_verify_nonce( $
|
603 |
$_SESSION[ $error_key ]['nonce'] = __( 'Nonce failed!', 'pirate-forms' );
|
604 |
do_action( 'themeisle_log_event', PIRATEFORMS_NAME, 'Nonce failed', 'error', __FILE__, __LINE__ );
|
605 |
-
return PirateForms_Util::save_error( $error_key, $
|
606 |
}
|
607 |
}
|
608 |
|
609 |
// If the honeypot caught a bear, beat it
|
610 |
-
if ( ! empty( $
|
611 |
$_SESSION[ $error_key ]['honeypot'] = __( 'Form submission failed!', 'pirate-forms' );
|
612 |
-
return PirateForms_Util::save_error( $error_key, $
|
613 |
}
|
614 |
|
615 |
-
$form_id = isset( $_POST['pirate_forms_form_id'] ) ? $_POST['pirate_forms_form_id'] : 0;
|
616 |
$pirate_forms_options = PirateForms_Util::get_form_options( $form_id );
|
617 |
|
618 |
if ( ! $this->validate_spam( $error_key, $pirate_forms_options ) ) {
|
619 |
-
return PirateForms_Util::save_error( $error_key, $
|
620 |
}
|
621 |
|
622 |
// Start the body of the contact email
|
@@ -658,8 +712,8 @@ class PirateForms_Public {
|
|
658 |
}
|
659 |
|
660 |
// Sanitize and prepare referrer;
|
661 |
-
if ( ! empty( $
|
662 |
-
$page = sanitize_text_field( $
|
663 |
$body['body'][ __( 'Came from', 'pirate-forms' ) ] = $page;
|
664 |
$body['magic_tags'] += array( 'referer' => $page );
|
665 |
|
@@ -676,8 +730,7 @@ class PirateForms_Public {
|
|
676 |
// Check the blacklist
|
677 |
$blocked = PirateForms_Util::is_blacklisted( $error_key, $pirate_forms_contact_email, $contact_ip );
|
678 |
if ( $blocked ) {
|
679 |
-
PirateForms_Util::save_error( $error_key, $
|
680 |
-
return false;
|
681 |
}
|
682 |
|
683 |
if ( $this->is_spam( $pirate_forms_options, $contact_ip, get_permalink( get_the_id() ), $msg ) ) {
|
@@ -685,172 +738,175 @@ class PirateForms_Public {
|
|
685 |
}
|
686 |
|
687 |
if ( ! empty( $_SESSION[ $error_key ] ) ) {
|
688 |
-
PirateForms_Util::save_error( $error_key, $
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
689 |
} else {
|
690 |
-
$
|
|
|
|
|
691 |
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
else :
|
696 |
-
$site_name = htmlspecialchars_decode( get_bloginfo( 'name' ) );
|
697 |
-
endif;
|
698 |
-
// Notification recipients
|
699 |
-
$site_recipients = sanitize_text_field( $pirate_forms_options['pirateformsopt_email_recipients'] );
|
700 |
-
$site_recipients = explode( ',', $site_recipients );
|
701 |
-
$site_recipients = array_map( 'trim', $site_recipients );
|
702 |
-
$site_recipients = array_map( 'sanitize_email', $site_recipients );
|
703 |
-
$site_recipients = implode( ',', $site_recipients );
|
704 |
-
// No name? Use the submitter email address, if one is present
|
705 |
-
if ( empty( $pirate_forms_contact_name ) ) {
|
706 |
-
$pirate_forms_contact_name = ! empty( $pirate_forms_contact_email ) ? $pirate_forms_contact_email : '[None given]';
|
707 |
-
}
|
708 |
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
714 |
$send_from = $site_email;
|
715 |
-
} else {
|
716 |
-
$send_from = PirateForms_Util::get_from_email();
|
717 |
}
|
718 |
-
$
|
719 |
|
720 |
-
|
721 |
-
$
|
722 |
-
add_action( 'phpmailer_init', array( $this, 'phpmailer' ) );
|
723 |
|
724 |
-
|
725 |
-
|
726 |
-
PirateForms_Util::save_error( $error_key, $nonce_append . '.' . $form_id );
|
727 |
-
return false;
|
728 |
}
|
729 |
|
730 |
-
|
731 |
-
|
732 |
-
|
|
|
|
|
|
|
|
|
|
|
733 |
}
|
|
|
734 |
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
|
|
|
|
|
|
|
|
|
|
744 |
}
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
$wp_filesystem->delete( $this->get_upload_tmp_dir(), true, 'd' );
|
753 |
-
|
754 |
-
// Should a confirm email be sent?
|
755 |
-
$confirm_body = stripslashes( trim( $pirate_forms_options['pirateformsopt_confirm_email'] ) );
|
756 |
-
$response_confirm = '';
|
757 |
-
if ( ! empty( $confirm_body ) && ! empty( $pirate_forms_contact_email ) ) {
|
758 |
-
// Removing entities
|
759 |
-
$confirm_body = htmlspecialchars_decode( $confirm_body );
|
760 |
-
$confirm_body = html_entity_decode( $confirm_body );
|
761 |
-
$confirm_body = str_replace( ''', "'", $confirm_body );
|
762 |
-
$send_from = PirateForms_Util::get_from_email();
|
763 |
-
if ( ! empty( $site_email ) && '[email]' !== $site_email ) {
|
764 |
-
$send_from = $site_email;
|
765 |
-
}
|
766 |
-
$site_name = htmlspecialchars_decode( get_bloginfo( 'name' ) );
|
767 |
|
768 |
-
|
769 |
-
$subject = $pirate_forms_options['pirateformsopt_label_submit'] . ' - ' . $site_name;
|
770 |
|
771 |
-
|
772 |
-
|
773 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
774 |
|
775 |
-
|
776 |
-
|
777 |
-
$response_confirm = $this->finally_send_mail( $pirate_forms_contact_email, $subject, $confirm_body, $headers, null, false );
|
778 |
-
do_action( 'pirate_forms_after_sending_confirm', $pirate_forms_options, $response_confirm, $pirate_forms_contact_email, $pirate_forms_contact_email, $subject, $confirm_body, $headers );
|
779 |
-
do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'after sending confirm email response = %s', $response_confirm ), 'debug', __FILE__, __LINE__ );
|
780 |
-
if ( ! $response_confirm ) {
|
781 |
-
do_action( 'themeisle_log_event', PIRATEFORMS_NAME, 'Confirm email not sent', 'debug', __FILE__, __LINE__ );
|
782 |
-
error_log( 'Confirm email not sent' );
|
783 |
-
}
|
784 |
}
|
785 |
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
790 |
array(
|
791 |
-
'
|
792 |
-
'
|
793 |
-
|
794 |
-
'post_author' => 1,
|
795 |
-
'post_status' => 'private',
|
796 |
-
)
|
797 |
);
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
add_post_meta( $new_post_id, PIRATEFORMS_SLUG . 'mail-status', $response ? 'true' : 'false' );
|
802 |
-
if ( defined( 'PIRATEFORMS_EMAIL_ERROR' ) ) {
|
803 |
-
add_post_meta( $new_post_id, PIRATEFORMS_SLUG . 'mail-status-reason', PIRATEFORMS_EMAIL_ERROR );
|
804 |
-
}
|
805 |
-
add_post_meta( $new_post_id, PIRATEFORMS_SLUG . 'confirm-mail-status', $response_confirm ? 'true' : 'false' );
|
806 |
-
do_action( 'pirate_forms_update_contact', $pirate_forms_options, $new_post_id );
|
807 |
-
}
|
808 |
-
|
809 |
-
do_action( 'pirate_forms_after_processing', $response );
|
810 |
-
|
811 |
-
if ( ! $test ) {
|
812 |
-
$pirate_forms_current_theme = wp_get_theme();
|
813 |
-
$is_our_theme = array_intersect(
|
814 |
array(
|
815 |
-
'
|
816 |
-
'
|
817 |
-
|
818 |
-
), array( $pirate_forms_current_theme->name, $pirate_forms_current_theme->parent_theme )
|
819 |
);
|
|
|
820 |
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
/* If a Thank you page is selected, redirect to that page */
|
825 |
-
if ( $pirate_forms_options['pirateformsopt_thank_you_url'] ) {
|
826 |
-
$redirect_id = intval( $pirate_forms_options['pirateformsopt_thank_you_url'] );
|
827 |
-
$redirect = get_permalink( $redirect_id );
|
828 |
-
if ( ! empty( $redirect ) ) {
|
829 |
-
$redirect_to = $redirect;
|
830 |
-
}
|
831 |
-
} elseif ( $is_our_theme ) {
|
832 |
-
// the fragment identifier should always be the last argument, otherwise the thank you message will not show.
|
833 |
-
// the fragment identifier is called pcf here so that the URL can tell us if our theme was recognized.
|
834 |
-
$redirect_to = add_query_arg(
|
835 |
-
array(
|
836 |
-
'done' => 'done',
|
837 |
-
'pcf' => "#$scroll_to",
|
838 |
-
), $_SERVER['HTTP_REFERER']
|
839 |
-
);
|
840 |
-
} elseif ( isset( $_SERVER['HTTP_REFERER'] ) ) {
|
841 |
-
// the fragment identifier is called pf here so that the URL can tell us if this is a not-our theme case.
|
842 |
-
$redirect_to = add_query_arg(
|
843 |
-
array(
|
844 |
-
'done' => 'done',
|
845 |
-
'pf' => "#$scroll_to",
|
846 |
-
), $_SERVER['HTTP_REFERER']
|
847 |
-
);
|
848 |
-
}
|
849 |
-
|
850 |
-
if ( $redirect_to ) {
|
851 |
-
wp_safe_redirect( $redirect_to );
|
852 |
-
exit();
|
853 |
-
}
|
854 |
}
|
855 |
}
|
856 |
}
|
@@ -918,7 +974,7 @@ class PirateForms_Public {
|
|
918 |
$pirateformsopt_recaptcha_sitekey = $pirate_forms_options['pirateformsopt_recaptcha_sitekey'];
|
919 |
$pirateformsopt_recaptcha_secretkey = $pirate_forms_options['pirateformsopt_recaptcha_secretkey'];
|
920 |
if ( ! empty( $pirateformsopt_recaptcha_secretkey ) && ! empty( $pirateformsopt_recaptcha_sitekey ) ) {
|
921 |
-
$captcha = $
|
922 |
}
|
923 |
if ( ! $captcha ) {
|
924 |
$_SESSION[ $error_key ]['pirate-forms-captcha'] = __( 'Invalid CAPTCHA', 'pirate-forms' );
|
@@ -938,7 +994,7 @@ class PirateForms_Public {
|
|
938 |
return false;
|
939 |
}
|
940 |
} elseif ( 'custom' === $pirateformsopt_recaptcha_field ) {
|
941 |
-
if ( isset( $
|
942 |
return true;
|
943 |
}
|
944 |
|
@@ -965,7 +1021,7 @@ class PirateForms_Public {
|
|
965 |
$fields = array( 'name', 'email', 'subject', 'message' );
|
966 |
|
967 |
foreach ( $fields as $field ) {
|
968 |
-
$value = isset( $
|
969 |
$body['magic_tags'] += array( $field => $value );
|
970 |
if ( 'req' === $pirate_forms_options[ 'pirateformsopt_' . $field . '_field' ] && empty( $value ) ) {
|
971 |
$_SESSION[ $error_key ][ 'pirate-forms-contact-' . $field ] = $pirate_forms_options[ 'pirateformsopt_label_err_' . $field ];
|
@@ -991,11 +1047,11 @@ class PirateForms_Public {
|
|
991 |
if ( ! $customize ) {
|
992 |
// new lite, old pro
|
993 |
$temp = '';
|
994 |
-
$temp = apply_filters( 'pirate_forms_validate_request', $temp, $error_key, $pirate_forms_options );
|
995 |
$body['rows'] = $temp;
|
996 |
} else {
|
997 |
// new lite, new pro
|
998 |
-
$body = apply_filters( 'pirate_forms_validate_request', $body, $error_key, $pirate_forms_options );
|
999 |
}
|
1000 |
|
1001 |
return array( $contact_email, $contact_name, $contact_subject, $message );
|
@@ -1056,14 +1112,16 @@ class PirateForms_Public {
|
|
1056 |
*
|
1057 |
* @throws Exception When file uploading fails.
|
1058 |
*/
|
1059 |
-
function get_attachments( $error_key, $pirate_forms_options, &$body ) {
|
1060 |
$attachments = array();
|
1061 |
$has_files = $pirate_forms_options['pirateformsopt_attachment_field'];
|
1062 |
if ( ! empty( $has_files ) ) {
|
1063 |
$uploads_dir = $this->get_upload_tmp_dir();
|
1064 |
$uploads_dir = $this->maybe_add_random_dir( $uploads_dir );
|
1065 |
|
1066 |
-
|
|
|
|
|
1067 |
if ( empty( $file['name'] ) ) {
|
1068 |
continue;
|
1069 |
}
|
@@ -1260,7 +1318,11 @@ class PirateForms_Public {
|
|
1260 |
* @param object $phpmailer PHPMailer object.
|
1261 |
*/
|
1262 |
function phpmailer( $phpmailer ) {
|
1263 |
-
$
|
|
|
|
|
|
|
|
|
1264 |
$pirateformsopt_use_smtp = $pirate_forms_options['pirateformsopt_use_smtp'];
|
1265 |
$pirateformsopt_smtp_host = $pirate_forms_options['pirateformsopt_smtp_host'];
|
1266 |
$pirateformsopt_smtp_port = $pirate_forms_options['pirateformsopt_smtp_port'];
|
@@ -1322,4 +1384,58 @@ class PirateForms_Public {
|
|
1322 |
|
1323 |
return $elements;
|
1324 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1325 |
}
|
40 |
*/
|
41 |
private $version;
|
42 |
|
43 |
+
/**
|
44 |
+
* The post parameters sent in the ajax request.
|
45 |
+
*
|
46 |
+
* @access private
|
47 |
+
* @var array $_post The post parameters sent in the ajax request.
|
48 |
+
*/
|
49 |
+
private $_post;
|
50 |
+
|
51 |
+
/**
|
52 |
+
* The files sent in the ajax request.
|
53 |
+
*
|
54 |
+
* @access private
|
55 |
+
* @var array $_files The files sent in the ajax request.
|
56 |
+
*/
|
57 |
+
private $_files;
|
58 |
+
|
59 |
/**
|
60 |
* The file types allowed to be uploaded. Can take a look at https://en.support.wordpress.com/accepted-filetypes/ for inspiration.
|
61 |
*
|
131 |
/* style for frontpage contact */
|
132 |
wp_register_style( 'pirate_forms_front_styles', PIRATEFORMS_URL . 'public/css/front.css', array(), $this->version );
|
133 |
/* recaptcha js */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
|
135 |
+
$pirate_forms_contactus_language = get_locale();
|
136 |
+
if ( defined( 'POLYLANG_VERSION' ) && function_exists( 'pll_current_language' ) ) {
|
137 |
+
$pirate_forms_contactus_language = pll_current_language();
|
138 |
+
}
|
139 |
+
wp_register_script( 'google-recaptcha', 'https://www.google.com/recaptcha/api.js?hl=' . $pirate_forms_contactus_language . '', array( 'jquery' ) );
|
140 |
+
|
141 |
+
wp_register_script( 'pirate_forms_scripts', PIRATEFORMS_URL . 'public/js/scripts.js', array( 'jquery' ), $this->version );
|
142 |
|
|
|
143 |
$pirate_forms_errors = '';
|
144 |
if ( ! empty( $_SESSION['pirate_forms_contact_errors'] ) ) :
|
145 |
$pirate_forms_errors = $_SESSION['pirate_forms_contact_errors'];
|
146 |
endif;
|
147 |
wp_localize_script(
|
148 |
+
'pirate_forms_scripts', 'pirateFormsObject', array(
|
149 |
'errors' => $pirate_forms_errors,
|
150 |
'spam' => array(
|
151 |
'label' => __( 'I\'m human!', 'pirate-forms' ),
|
152 |
'value' => wp_create_nonce( PIRATEFORMS_NAME ),
|
153 |
),
|
154 |
+
'rest' => array(
|
155 |
+
'submit' => array(
|
156 |
+
'url' => get_rest_url( null, PIRATEFORMS_SLUG . '/v' . intval( PIRATEFORMS_API_VERSION ) . '/send_email/' ),
|
157 |
+
),
|
158 |
+
'nonce' => wp_create_nonce( 'wp_rest' ),
|
159 |
+
),
|
160 |
)
|
161 |
);
|
162 |
}
|
167 |
* @since 1.0.0
|
168 |
*/
|
169 |
public function display_form( $atts, $content = null ) {
|
|
|
|
|
170 |
wp_enqueue_style( 'pirate_forms_front_styles' );
|
171 |
|
172 |
PirateForms_Util::session_start();
|
174 |
array(
|
175 |
'from' => '',
|
176 |
'id' => '',
|
177 |
+
'ajax' => 'no',
|
178 |
), $atts
|
179 |
);
|
180 |
|
183 |
$elements = array();
|
184 |
$pirate_form = new PirateForms_PhpFormBuilder();
|
185 |
|
186 |
+
$pirate_forms_options = PirateForms_Util::get_form_options( $form_id );
|
187 |
+
if ( ! empty( $pirate_forms_options['pirateformsopt_recaptcha_secretkey'] ) && ! empty( $pirate_forms_options['pirateformsopt_recaptcha_sitekey'] ) && ! empty( $pirate_forms_options['pirateformsopt_recaptcha_field'] ) && ( 'yes' === $pirate_forms_options['pirateformsopt_recaptcha_field'] ) ) {
|
188 |
+
wp_enqueue_script( 'google-recaptcha' );
|
189 |
+
}
|
190 |
+
wp_enqueue_script( 'pirate_forms_scripts' );
|
191 |
+
|
192 |
+
$ajax = 'yes' === $atts['ajax'];
|
193 |
+
$elements[] = array(
|
194 |
+
'type' => 'hidden',
|
195 |
+
'id' => 'pirate_forms_ajax',
|
196 |
+
'name' => 'pirate_forms_ajax',
|
197 |
+
'value' => $ajax ? 1 : 0,
|
198 |
+
);
|
199 |
+
|
200 |
$elements[] = array(
|
201 |
'type' => 'text',
|
202 |
'id' => 'form_honeypot',
|
232 |
$nonce_append = $from_widget ? 'yes' : 'no';
|
233 |
|
234 |
$error_key = wp_create_nonce( get_bloginfo( 'admin_email' ) . ( $from_widget ? 'yes' : 'no' ) );
|
235 |
+
$new_error_key = $nonce_append . '.' . $form_id;
|
236 |
|
237 |
$thank_you_message = '';
|
238 |
+
if ( isset( $_GET['done'] ) && ! empty( $_SESSION[ 'success' . $new_error_key ] ) ) {
|
239 |
+
$thank_you_message = $_SESSION[ 'success' . $new_error_key ];
|
240 |
}
|
241 |
|
242 |
$pirate_form->set_element( 'thank_you_message', $thank_you_message );
|
463 |
$elements[] = array(
|
464 |
'type' => 'button',
|
465 |
'id' => 'pirate-forms-contact-submit',
|
466 |
+
'class' => 'pirate-forms-submit-button btn btn-primary ' . ( $ajax ? 'pirate-forms-submit-button-ajax' : '' ),
|
467 |
'wrap' => array(
|
468 |
'type' => 'div',
|
469 |
'class' => implode( ' ', apply_filters( 'pirateform_wrap_classes_submit', array( 'col-xs-12 ' . ( ( ! empty( $pirate_forms_options['pirateformsopt_recaptcha_field'] ) && ( $pirate_forms_options['pirateformsopt_recaptcha_field'] !== 'yes' ) ) ? 'col-sm-6 ' : '' ) . 'form_field_wrap contact_submit_wrap' ) ) ),
|
491 |
}
|
492 |
|
493 |
/* Are there any submission errors? */
|
494 |
+
if ( ! empty( $_SESSION[ 'error' . $new_error_key ] ) ) {
|
495 |
+
$pirate_form->set_element( 'errors', $_SESSION[ 'error' . $new_error_key ] );
|
496 |
+
unset( $_SESSION[ 'error' . $new_error_key ] );
|
497 |
}
|
498 |
|
499 |
$elements = apply_filters( 'pirate_forms_get_custom_elements', $elements, $pirate_forms_options );
|
502 |
|
503 |
$output = $pirate_form->build_form( apply_filters( 'pirate_forms_public_controls', $elements, $pirate_forms_options, $from_widget ), $pirate_forms_options, $from_widget );
|
504 |
|
505 |
+
unset( $_SESSION[ 'success' . $new_error_key ] );
|
506 |
+
unset( $_SESSION[ 'error' . $new_error_key ] );
|
507 |
|
508 |
return $output;
|
509 |
}
|
563 |
* @param PirateForms_PhpFormBuilder $form_builder The form builder object.
|
564 |
*/
|
565 |
public function render_errors( $form_builder ) {
|
566 |
+
echo empty( $form_builder->errors ) ? '' : $this->display_errors( $form_builder->errors );
|
567 |
+
}
|
568 |
+
|
569 |
+
/**
|
570 |
+
* Displays all the errors relevant to the form
|
571 |
+
*
|
572 |
+
* @param Array $errors The error messages.
|
573 |
+
*/
|
574 |
+
private function display_errors( $errors ) {
|
575 |
$output = '';
|
576 |
+
if ( ! empty( $errors ) ) {
|
577 |
$output .= '<div class="col-xs-12 pirate_forms_error_box">';
|
578 |
$output .= '<p>' . __( 'Sorry, an error occured.', 'pirate-forms' ) . '</p>';
|
579 |
$output .= '</div>';
|
580 |
+
foreach ( $errors as $err ) {
|
581 |
$output .= '<div class="col-xs-12 pirate_forms_error_box">';
|
582 |
$output .= "<p>$err</p>";
|
583 |
$output .= '</div>';
|
584 |
+
}
|
585 |
+
}
|
586 |
+
return apply_filters( 'pirate_forms_errors', $output, $errors );
|
|
|
|
|
587 |
}
|
588 |
|
589 |
/**
|
593 |
*/
|
594 |
public function render_thankyou( $form_builder ) {
|
595 |
if ( ! empty( $form_builder->thank_you_message ) ) {
|
596 |
+
echo $this->display_thankyou( $form_builder->thank_you_message );
|
|
|
597 |
}
|
598 |
}
|
599 |
|
600 |
+
/**
|
601 |
+
* Displays the thank you message relevant to the form
|
602 |
+
*
|
603 |
+
* @param string $text The message.
|
604 |
+
*/
|
605 |
+
private function display_thankyou( $text ) {
|
606 |
+
return apply_filters( 'pirate_forms_thankyou', sprintf( '<div class="col-xs-12 pirate_forms_thankyou_wrap"><p>%s</p></div>', $text ), $text );
|
607 |
+
}
|
608 |
+
|
609 |
/**
|
610 |
* Process the form after submission
|
611 |
*
|
624 |
* @since 1.0.0
|
625 |
* @throws Exception When file uploading fails.
|
626 |
*/
|
627 |
+
public function send_email( $test = false, $ajax = false, $_post = null, $_files = null ) {
|
628 |
+
$post_params = $_POST;
|
629 |
+
$post_files = $_FILES;
|
630 |
+
|
631 |
+
if ( $ajax ) {
|
632 |
+
$post_params = $_post;
|
633 |
+
$post_files = $_files;
|
634 |
+
}
|
635 |
+
$this->_post = $post_params;
|
636 |
+
$this->_files = $post_files;
|
637 |
+
|
638 |
PirateForms_Util::session_start();
|
639 |
+
do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'POST data = %s', print_r( $post_params, true ) ), 'debug', __FILE__, __LINE__ );
|
640 |
|
641 |
// If POST and honeypot are not set, beat it
|
642 |
+
if ( empty( $post_params ) || ! isset( $post_params['honeypot'] ) ) {
|
643 |
return false;
|
644 |
}
|
645 |
|
646 |
// separate the nonce from a form that is displayed in the widget vs. one that is not
|
647 |
+
$nonce_append = isset( $post_params['pirate_forms_from_widget'] ) && intval( $post_params['pirate_forms_from_widget'] ) === 1 ? 'yes' : 'no';
|
648 |
|
649 |
// Session variable for form errors
|
650 |
$error_key = wp_create_nonce( get_bloginfo( 'admin_email' ) . $nonce_append );
|
651 |
$_SESSION[ $error_key ] = array();
|
652 |
+
$form_id = isset( $post_params['pirate_forms_form_id'] ) ? $post_params['pirate_forms_form_id'] : 0;
|
653 |
+
$new_error_key = $nonce_append . '.' . $form_id;
|
654 |
|
655 |
+
// If nonce is not valid, beat it.
|
656 |
if ( ! $test && 'yes' === PirateForms_Util::get_option( 'pirateformsopt_nonce' ) ) {
|
657 |
+
if ( ! wp_verify_nonce( $post_params['wordpress-nonce'], get_bloginfo( 'admin_email' ) . $nonce_append ) ) {
|
658 |
$_SESSION[ $error_key ]['nonce'] = __( 'Nonce failed!', 'pirate-forms' );
|
659 |
do_action( 'themeisle_log_event', PIRATEFORMS_NAME, 'Nonce failed', 'error', __FILE__, __LINE__ );
|
660 |
+
return PirateForms_Util::save_error( $error_key, $new_error_key );
|
661 |
}
|
662 |
}
|
663 |
|
664 |
// If the honeypot caught a bear, beat it
|
665 |
+
if ( ! empty( $post_params['honeypot'] ) ) {
|
666 |
$_SESSION[ $error_key ]['honeypot'] = __( 'Form submission failed!', 'pirate-forms' );
|
667 |
+
return PirateForms_Util::save_error( $error_key, $new_error_key );
|
668 |
}
|
669 |
|
|
|
670 |
$pirate_forms_options = PirateForms_Util::get_form_options( $form_id );
|
671 |
|
672 |
if ( ! $this->validate_spam( $error_key, $pirate_forms_options ) ) {
|
673 |
+
return PirateForms_Util::save_error( $error_key, $new_error_key );
|
674 |
}
|
675 |
|
676 |
// Start the body of the contact email
|
712 |
}
|
713 |
|
714 |
// Sanitize and prepare referrer;
|
715 |
+
if ( ! empty( $post_params['pirate-forms-contact-referrer'] ) ) {
|
716 |
+
$page = sanitize_text_field( $post_params['pirate-forms-contact-referrer'] );
|
717 |
$body['body'][ __( 'Came from', 'pirate-forms' ) ] = $page;
|
718 |
$body['magic_tags'] += array( 'referer' => $page );
|
719 |
|
730 |
// Check the blacklist
|
731 |
$blocked = PirateForms_Util::is_blacklisted( $error_key, $pirate_forms_contact_email, $contact_ip );
|
732 |
if ( $blocked ) {
|
733 |
+
return PirateForms_Util::save_error( $error_key, $new_error_key );
|
|
|
734 |
}
|
735 |
|
736 |
if ( $this->is_spam( $pirate_forms_options, $contact_ip, get_permalink( get_the_id() ), $msg ) ) {
|
738 |
}
|
739 |
|
740 |
if ( ! empty( $_SESSION[ $error_key ] ) ) {
|
741 |
+
return PirateForms_Util::save_error( $error_key, $new_error_key );
|
742 |
+
}
|
743 |
+
|
744 |
+
$_SESSION[ 'success' . $new_error_key ] = sanitize_text_field( $pirate_forms_options['pirateformsopt_label_submit'] );
|
745 |
+
|
746 |
+
$site_email = sanitize_text_field( $pirate_forms_options['pirateformsopt_email'] );
|
747 |
+
if ( ! empty( $pirate_forms_contact_name ) ) :
|
748 |
+
$site_name = $pirate_forms_contact_name;
|
749 |
+
else :
|
750 |
+
$site_name = htmlspecialchars_decode( get_bloginfo( 'name' ) );
|
751 |
+
endif;
|
752 |
+
// Notification recipients
|
753 |
+
$site_recipients = sanitize_text_field( $pirate_forms_options['pirateformsopt_email_recipients'] );
|
754 |
+
$site_recipients = explode( ',', $site_recipients );
|
755 |
+
$site_recipients = array_map( 'trim', $site_recipients );
|
756 |
+
$site_recipients = array_map( 'sanitize_email', $site_recipients );
|
757 |
+
$site_recipients = implode( ',', $site_recipients );
|
758 |
+
// No name? Use the submitter email address, if one is present
|
759 |
+
if ( empty( $pirate_forms_contact_name ) ) {
|
760 |
+
$pirate_forms_contact_name = ! empty( $pirate_forms_contact_email ) ? $pirate_forms_contact_email : '[None given]';
|
761 |
+
}
|
762 |
+
|
763 |
+
// Need an email address for the email notification
|
764 |
+
$send_from = '';
|
765 |
+
if ( '[email]' == $site_email && ! empty( $pirate_forms_contact_email ) ) {
|
766 |
+
$send_from = $pirate_forms_contact_email;
|
767 |
+
} elseif ( ! empty( $site_email ) ) {
|
768 |
+
$send_from = $site_email;
|
769 |
} else {
|
770 |
+
$send_from = PirateForms_Util::get_from_email();
|
771 |
+
}
|
772 |
+
$send_from_name = $site_name;
|
773 |
|
774 |
+
// Send an email notification to the correct address
|
775 |
+
$headers = "From: $send_from_name <$send_from>\r\nReply-To: $pirate_forms_contact_name <$pirate_forms_contact_email>\r\nContent-type: text/html";
|
776 |
+
add_action( 'phpmailer_init', array( $this, 'phpmailer' ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
777 |
|
778 |
+
$attachments = $this->get_attachments( $error_key, $pirate_forms_options, $body );
|
779 |
+
if ( is_bool( $attachments ) ) {
|
780 |
+
return PirateForms_Util::save_error( $error_key, $new_error_key );
|
781 |
+
}
|
782 |
+
|
783 |
+
$subject = apply_filters( 'pirate_forms_subject', 'Contact on ' . htmlspecialchars_decode( get_bloginfo( 'name' ) ) );
|
784 |
+
if ( ! empty( $pirate_forms_contact_subject ) ) {
|
785 |
+
$subject = $pirate_forms_contact_subject;
|
786 |
+
}
|
787 |
+
|
788 |
+
$mail_body = ! empty( $pirate_forms_options['pirateformsopt_email_content'] ) ? $pirate_forms_options['pirateformsopt_email_content'] : PirateForms_Util::get_default_email_content( true, $form_id, true );
|
789 |
+
$mail_body = PirateForms_Util::replace_magic_tags( $mail_body, $body );
|
790 |
+
|
791 |
+
do_action( 'pirate_forms_before_sending', $pirate_forms_contact_email, $site_recipients, $subject, $mail_body, $headers, $attachments );
|
792 |
+
do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'before sending email to = %s, subject = %s, body = %s, headers = %s, attachments = %s', $site_recipients, $subject, $mail_body, $headers, print_r( $attachments, true ) ), 'debug', __FILE__, __LINE__ );
|
793 |
+
$response = $this->finally_send_mail( $site_recipients, $subject, $mail_body, $headers, $attachments, true );
|
794 |
+
if ( ! $response ) {
|
795 |
+
do_action( 'themeisle_log_event', PIRATEFORMS_NAME, 'Email not sent', 'debug', __FILE__, __LINE__ );
|
796 |
+
error_log( 'Email not sent' );
|
797 |
+
}
|
798 |
+
do_action( 'pirate_forms_after_sending', $pirate_forms_options, $response, $pirate_forms_contact_email, $site_recipients, $subject, $mail_body, $headers, $attachments );
|
799 |
+
do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'after sending email, response = %s', $response ), 'debug', __FILE__, __LINE__ );
|
800 |
+
|
801 |
+
// delete the tmp directory
|
802 |
+
require_once( ABSPATH . 'wp-admin/includes/file.php' );
|
803 |
+
WP_Filesystem();
|
804 |
+
global $wp_filesystem;
|
805 |
+
$wp_filesystem->delete( $this->get_upload_tmp_dir(), true, 'd' );
|
806 |
+
|
807 |
+
// Should a confirm email be sent?
|
808 |
+
$confirm_body = stripslashes( trim( $pirate_forms_options['pirateformsopt_confirm_email'] ) );
|
809 |
+
$response_confirm = '';
|
810 |
+
if ( ! empty( $confirm_body ) && ! empty( $pirate_forms_contact_email ) ) {
|
811 |
+
// Removing entities
|
812 |
+
$confirm_body = htmlspecialchars_decode( $confirm_body );
|
813 |
+
$confirm_body = html_entity_decode( $confirm_body );
|
814 |
+
$confirm_body = str_replace( ''', "'", $confirm_body );
|
815 |
+
$send_from = PirateForms_Util::get_from_email();
|
816 |
+
if ( ! empty( $site_email ) && '[email]' !== $site_email ) {
|
817 |
$send_from = $site_email;
|
|
|
|
|
818 |
}
|
819 |
+
$site_name = htmlspecialchars_decode( get_bloginfo( 'name' ) );
|
820 |
|
821 |
+
$headers = "From: $site_name <$send_from>\r\nReply-To: $site_name <$send_from>";
|
822 |
+
$subject = $pirate_forms_options['pirateformsopt_label_submit'] . ' - ' . $site_name;
|
|
|
823 |
|
824 |
+
if ( isset( $pirate_forms_options['pirateformsopt_copy_email'] ) && 'yes' === $pirate_forms_options['pirateformsopt_copy_email'] ) {
|
825 |
+
$confirm_body = $this->append_original_email( $confirm_body, $body, $private_fields );
|
|
|
|
|
826 |
}
|
827 |
|
828 |
+
do_action( 'pirate_forms_before_sending_confirm', $pirate_forms_contact_email, $pirate_forms_contact_email, $subject, $confirm_body, $headers );
|
829 |
+
do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'before sending confirm email to = %s, subject = %s, body = %s, headers = %s', $pirate_forms_contact_email, $subject, $confirm_body, $headers ), 'debug', __FILE__, __LINE__ );
|
830 |
+
$response_confirm = $this->finally_send_mail( $pirate_forms_contact_email, $subject, $confirm_body, $headers, null, false );
|
831 |
+
do_action( 'pirate_forms_after_sending_confirm', $pirate_forms_options, $response_confirm, $pirate_forms_contact_email, $pirate_forms_contact_email, $subject, $confirm_body, $headers );
|
832 |
+
do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'after sending confirm email response = %s', $response_confirm ), 'debug', __FILE__, __LINE__ );
|
833 |
+
if ( ! $response_confirm ) {
|
834 |
+
do_action( 'themeisle_log_event', PIRATEFORMS_NAME, 'Confirm email not sent', 'debug', __FILE__, __LINE__ );
|
835 |
+
error_log( 'Confirm email not sent' );
|
836 |
}
|
837 |
+
}
|
838 |
|
839 |
+
/**
|
840 |
+
*********** Store the entries in the DB */
|
841 |
+
if ( 'yes' === $pirate_forms_options['pirateformsopt_store'] ) {
|
842 |
+
$new_post_id = wp_insert_post(
|
843 |
+
array(
|
844 |
+
'post_type' => 'pf_contact',
|
845 |
+
'post_title' => date( 'l, M j, Y', time() ) . ' by "' . $pirate_forms_contact_name . '"',
|
846 |
+
'post_content' => $mail_body,
|
847 |
+
'post_author' => 1,
|
848 |
+
'post_status' => 'private',
|
849 |
+
)
|
850 |
+
);
|
851 |
+
if ( isset( $pirate_forms_contact_email ) && ! empty( $pirate_forms_contact_email ) ) {
|
852 |
+
add_post_meta( $new_post_id, 'Contact email', $pirate_forms_contact_email );
|
853 |
}
|
854 |
+
add_post_meta( $new_post_id, PIRATEFORMS_SLUG . 'mail-status', $response ? 'true' : 'false' );
|
855 |
+
if ( defined( 'PIRATEFORMS_EMAIL_ERROR' ) ) {
|
856 |
+
add_post_meta( $new_post_id, PIRATEFORMS_SLUG . 'mail-status-reason', PIRATEFORMS_EMAIL_ERROR );
|
857 |
+
}
|
858 |
+
add_post_meta( $new_post_id, PIRATEFORMS_SLUG . 'confirm-mail-status', $response_confirm ? 'true' : 'false' );
|
859 |
+
do_action( 'pirate_forms_update_contact', $pirate_forms_options, $new_post_id );
|
860 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
861 |
|
862 |
+
do_action( 'pirate_forms_after_processing', $response );
|
|
|
863 |
|
864 |
+
if ( ! $test ) {
|
865 |
+
$pirate_forms_current_theme = wp_get_theme();
|
866 |
+
$is_our_theme = array_intersect(
|
867 |
+
array(
|
868 |
+
'Zerif Lite',
|
869 |
+
'Zerif PRO',
|
870 |
+
'Hestia Pro',
|
871 |
+
), array( $pirate_forms_current_theme->name, $pirate_forms_current_theme->parent_theme )
|
872 |
+
);
|
873 |
|
874 |
+
if ( $ajax ) {
|
875 |
+
return true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
876 |
}
|
877 |
|
878 |
+
$redirect_to = null;
|
879 |
+
$scroll_to = isset( $post_params['pirate_forms_from_form'] ) ? $post_params['pirate_forms_from_form'] : '';
|
880 |
+
|
881 |
+
/* If a Thank you page is selected, redirect to that page */
|
882 |
+
if ( $pirate_forms_options['pirateformsopt_thank_you_url'] ) {
|
883 |
+
$redirect_id = intval( $pirate_forms_options['pirateformsopt_thank_you_url'] );
|
884 |
+
$redirect = get_permalink( $redirect_id );
|
885 |
+
if ( ! empty( $redirect ) ) {
|
886 |
+
$redirect_to = $redirect;
|
887 |
+
}
|
888 |
+
} elseif ( $is_our_theme ) {
|
889 |
+
// the fragment identifier should always be the last argument, otherwise the thank you message will not show.
|
890 |
+
// the fragment identifier is called pcf here so that the URL can tell us if our theme was recognized.
|
891 |
+
$redirect_to = add_query_arg(
|
892 |
array(
|
893 |
+
'done' => 'done',
|
894 |
+
'pcf' => "#$scroll_to",
|
895 |
+
), $_SERVER['HTTP_REFERER']
|
|
|
|
|
|
|
896 |
);
|
897 |
+
} elseif ( isset( $_SERVER['HTTP_REFERER'] ) ) {
|
898 |
+
// the fragment identifier is called pf here so that the URL can tell us if this is a not-our theme case.
|
899 |
+
$redirect_to = add_query_arg(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
900 |
array(
|
901 |
+
'done' => 'done',
|
902 |
+
'pf' => "#$scroll_to",
|
903 |
+
), $_SERVER['HTTP_REFERER']
|
|
|
904 |
);
|
905 |
+
}
|
906 |
|
907 |
+
if ( $redirect_to ) {
|
908 |
+
wp_safe_redirect( $redirect_to );
|
909 |
+
exit();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
910 |
}
|
911 |
}
|
912 |
}
|
974 |
$pirateformsopt_recaptcha_sitekey = $pirate_forms_options['pirateformsopt_recaptcha_sitekey'];
|
975 |
$pirateformsopt_recaptcha_secretkey = $pirate_forms_options['pirateformsopt_recaptcha_secretkey'];
|
976 |
if ( ! empty( $pirateformsopt_recaptcha_secretkey ) && ! empty( $pirateformsopt_recaptcha_sitekey ) ) {
|
977 |
+
$captcha = $this->_post['g-recaptcha-response'];
|
978 |
}
|
979 |
if ( ! $captcha ) {
|
980 |
$_SESSION[ $error_key ]['pirate-forms-captcha'] = __( 'Invalid CAPTCHA', 'pirate-forms' );
|
994 |
return false;
|
995 |
}
|
996 |
} elseif ( 'custom' === $pirateformsopt_recaptcha_field ) {
|
997 |
+
if ( isset( $this->_post['xobkcehc'] ) && wp_verify_nonce( $this->_post['xobkcehc'], PIRATEFORMS_NAME ) ) {
|
998 |
return true;
|
999 |
}
|
1000 |
|
1021 |
$fields = array( 'name', 'email', 'subject', 'message' );
|
1022 |
|
1023 |
foreach ( $fields as $field ) {
|
1024 |
+
$value = isset( $this->_post[ 'pirate-forms-contact-' . $field ] ) ? sanitize_text_field( trim( $this->_post[ 'pirate-forms-contact-' . $field ] ) ) : '';
|
1025 |
$body['magic_tags'] += array( $field => $value );
|
1026 |
if ( 'req' === $pirate_forms_options[ 'pirateformsopt_' . $field . '_field' ] && empty( $value ) ) {
|
1027 |
$_SESSION[ $error_key ][ 'pirate-forms-contact-' . $field ] = $pirate_forms_options[ 'pirateformsopt_label_err_' . $field ];
|
1047 |
if ( ! $customize ) {
|
1048 |
// new lite, old pro
|
1049 |
$temp = '';
|
1050 |
+
$temp = apply_filters( 'pirate_forms_validate_request', $temp, $error_key, $pirate_forms_options, $this->_post, $this->_files );
|
1051 |
$body['rows'] = $temp;
|
1052 |
} else {
|
1053 |
// new lite, new pro
|
1054 |
+
$body = apply_filters( 'pirate_forms_validate_request', $body, $error_key, $pirate_forms_options, $this->_post, $this->_files );
|
1055 |
}
|
1056 |
|
1057 |
return array( $contact_email, $contact_name, $contact_subject, $message );
|
1112 |
*
|
1113 |
* @throws Exception When file uploading fails.
|
1114 |
*/
|
1115 |
+
private function get_attachments( $error_key, $pirate_forms_options, &$body ) {
|
1116 |
$attachments = array();
|
1117 |
$has_files = $pirate_forms_options['pirateformsopt_attachment_field'];
|
1118 |
if ( ! empty( $has_files ) ) {
|
1119 |
$uploads_dir = $this->get_upload_tmp_dir();
|
1120 |
$uploads_dir = $this->maybe_add_random_dir( $uploads_dir );
|
1121 |
|
1122 |
+
$_files = $this->_files;
|
1123 |
+
|
1124 |
+
foreach ( $_files as $label => $file ) {
|
1125 |
if ( empty( $file['name'] ) ) {
|
1126 |
continue;
|
1127 |
}
|
1318 |
* @param object $phpmailer PHPMailer object.
|
1319 |
*/
|
1320 |
function phpmailer( $phpmailer ) {
|
1321 |
+
$id = null;
|
1322 |
+
if ( isset( $this->_post['pirate_forms_form_id'] ) && ! empty( $this->_post['pirate_forms_form_id'] ) ) {
|
1323 |
+
$id = $this->_post['pirate_forms_form_id'];
|
1324 |
+
}
|
1325 |
+
$pirate_forms_options = PirateForms_Util::get_form_options( $id );
|
1326 |
$pirateformsopt_use_smtp = $pirate_forms_options['pirateformsopt_use_smtp'];
|
1327 |
$pirateformsopt_smtp_host = $pirate_forms_options['pirateformsopt_smtp_host'];
|
1328 |
$pirateformsopt_smtp_port = $pirate_forms_options['pirateformsopt_smtp_port'];
|
1384 |
|
1385 |
return $elements;
|
1386 |
}
|
1387 |
+
|
1388 |
+
/**
|
1389 |
+
* Register REST endpoints.
|
1390 |
+
*/
|
1391 |
+
public function register_endpoint() {
|
1392 |
+
register_rest_route(
|
1393 |
+
PIRATEFORMS_SLUG . '/v' . intval( PIRATEFORMS_API_VERSION ),
|
1394 |
+
'/send_email/',
|
1395 |
+
array(
|
1396 |
+
'methods' => 'POST',
|
1397 |
+
'callback' => array( $this, 'send_email_ajax' ),
|
1398 |
+
)
|
1399 |
+
);
|
1400 |
+
}
|
1401 |
+
|
1402 |
+
/**
|
1403 |
+
* The REST endpoint for sending email.
|
1404 |
+
*/
|
1405 |
+
public function send_email_ajax( WP_REST_Request $request ) {
|
1406 |
+
do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'calling ajax with %s, %s', print_r( $request->get_params(), true ), print_r( $request->get_file_params(), true ) ), 'debug', __FILE__, __LINE__ );
|
1407 |
+
|
1408 |
+
$return = $this->send_email( false, true, $request->get_params(), $request->get_file_params() );
|
1409 |
+
$form_id = intval( $request->get_param( 'pirate_forms_form_id' ) );
|
1410 |
+
|
1411 |
+
// errors?
|
1412 |
+
if ( is_bool( $return ) && ! $return ) {
|
1413 |
+
$nonce_append = intval( $request->get_param( 'pirate_forms_from_widget' ) ) === 1 ? 'yes' : 'no';
|
1414 |
+
$errors = $_SESSION[ 'error' . $nonce_append . '.' . $form_id ];
|
1415 |
+
if ( $errors ) {
|
1416 |
+
$messages = array();
|
1417 |
+
foreach ( $errors as $k => $v ) {
|
1418 |
+
$messages[] = $v;
|
1419 |
+
}
|
1420 |
+
do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'got errors %s', print_r( $messages, true ) ), 'debug', __FILE__, __LINE__ );
|
1421 |
+
return new WP_REST_Response( array( 'error' => $this->display_errors( $messages ) ), 500 );
|
1422 |
+
}
|
1423 |
+
}
|
1424 |
+
|
1425 |
+
// redirect?
|
1426 |
+
$pirate_forms_options = PirateForms_Util::get_form_options( $form_id );
|
1427 |
+
if ( $pirate_forms_options['pirateformsopt_thank_you_url'] ) {
|
1428 |
+
$redirect_id = intval( $pirate_forms_options['pirateformsopt_thank_you_url'] );
|
1429 |
+
$redirect = get_permalink( $redirect_id );
|
1430 |
+
do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'redirecting to %s', $redirect ), 'debug', __FILE__, __LINE__ );
|
1431 |
+
if ( ! empty( $redirect ) ) {
|
1432 |
+
return new WP_REST_Response( array( 'redirect' => $redirect ), 200 );
|
1433 |
+
}
|
1434 |
+
}
|
1435 |
+
|
1436 |
+
// thank you message.
|
1437 |
+
$message = $this->display_thankyou( sanitize_text_field( $pirate_forms_options['pirateformsopt_label_submit'] ) );
|
1438 |
+
do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'thankyou message: %s', $message ), 'debug', __FILE__, __LINE__ );
|
1439 |
+
return new WP_REST_Response( array( 'message' => $message ), 200 );
|
1440 |
+
}
|
1441 |
}
|
public/css/front.css
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
/*
|
2 |
-
Version: 2.4.
|
3 |
*/
|
4 |
.pirate_forms_wrap .form_field_wrap,
|
5 |
.widget .pirate_forms_wrap .form_field_wrap {
|
1 |
/*
|
2 |
+
Version: 2.4.2
|
3 |
*/
|
4 |
.pirate_forms_wrap .form_field_wrap,
|
5 |
.widget .pirate_forms_wrap .form_field_wrap {
|
public/js/scripts-general.js
DELETED
@@ -1,21 +0,0 @@
|
|
1 |
-
/* global pirateFormsObject */
|
2 |
-
/* global jQuery */
|
3 |
-
jQuery(document).ready(function() {
|
4 |
-
|
5 |
-
var session_var = pirateFormsObject.errors;
|
6 |
-
|
7 |
-
if( (typeof session_var !== 'undefined') && (session_var !== '') && (typeof jQuery('#contact') !== 'undefined') && (typeof jQuery('#contact').offset() !== 'undefined') ) {
|
8 |
-
|
9 |
-
jQuery('html, body').animate({
|
10 |
-
scrollTop: jQuery('#contact').offset().top
|
11 |
-
}, 'slow');
|
12 |
-
}
|
13 |
-
|
14 |
-
if(jQuery('.pirate-forms-maps-custom').length > 0){
|
15 |
-
jQuery('.pirate-forms-maps-custom').each(function(i){
|
16 |
-
var $id = 'xobkcehc-' + i;
|
17 |
-
jQuery(this).html(jQuery('<input id="' + $id + '" name="xobkcehc" type="' + 'xobkcehc'.split('').reverse().join('') + '" value="' + pirateFormsObject.spam.value + '"><label for="' + $id + '"><span>' + pirateFormsObject.spam.label + '</span></label>'));
|
18 |
-
});
|
19 |
-
}
|
20 |
-
|
21 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public/js/scripts.js
CHANGED
@@ -1,31 +1,124 @@
|
|
1 |
/* global jQuery */
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
} );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
/* global jQuery */
|
2 |
+
/* global pirateFormsObject */
|
3 |
+
|
4 |
+
(function($, pf){
|
5 |
+
|
6 |
+
$( document ).ready( function () {
|
7 |
+
onDocumentReady();
|
8 |
+
});
|
9 |
+
|
10 |
+
$( window ).load( function () {
|
11 |
+
onWindowLoad();
|
12 |
+
});
|
13 |
+
|
14 |
+
function onDocumentReady() {
|
15 |
+
'use strict';
|
16 |
+
|
17 |
+
// file upload behavior.
|
18 |
+
$( '.pirate-forms-file-upload-button' ).on( 'click', function () {
|
19 |
+
var $button = $( this );
|
20 |
+
$button.parent().find( 'input[type=file]' ).on( 'change', function () {
|
21 |
+
$button.parent().find( 'input[type=text]' ).val( $( this ).val() ).change();
|
22 |
+
} );
|
23 |
+
$button.parent().find( 'input[type=file]' ).focus().click();
|
24 |
+
} );
|
25 |
+
|
26 |
+
$( '.pirate-forms-file-upload-input' ).on( 'click', function () {
|
27 |
+
$( this ).parent().find( '.pirate-forms-file-upload-button' ).trigger( 'click' );
|
28 |
+
} );
|
29 |
+
$( '.pirate-forms-file-upload-input' ).on( 'focus', function () {
|
30 |
+
$( this ).blur();
|
31 |
+
} );
|
32 |
+
|
33 |
+
// show errors.
|
34 |
+
var session_var = pf.errors;
|
35 |
+
if( (typeof session_var !== 'undefined') && (session_var !== '') && (typeof $('#contact') !== 'undefined') && (typeof $('#contact').offset() !== 'undefined') ) {
|
36 |
+
$('html, body').animate({
|
37 |
+
scrollTop: $('#contact').offset().top
|
38 |
+
}, 'slow');
|
39 |
+
}
|
40 |
+
|
41 |
+
// show custom spam trap.
|
42 |
+
if($('.pirate-forms-maps-custom').length > 0){
|
43 |
+
$('.pirate-forms-maps-custom').each(function(i){
|
44 |
+
var $id = 'xobkcehc-' + i;
|
45 |
+
$(this).html($('<input id="' + $id + '" name="xobkcehc" type="' + 'xobkcehc'.split('').reverse().join('') + '" value="' + pf.spam.value + '"><label for="' + $id + '"><span>' + pf.spam.label + '</span></label>'));
|
46 |
+
});
|
47 |
+
}
|
48 |
+
|
49 |
+
// support ajax forms.
|
50 |
+
$('.pirate-forms-submit-button-ajax').closest('form').submit(function(){
|
51 |
+
var form = $(this);
|
52 |
+
var formData = new FormData(form[0]);
|
53 |
+
ajaxStart( form );
|
54 |
+
|
55 |
+
// remove the dynamic containers.
|
56 |
+
$('div.pirate-forms-ajax').remove();
|
57 |
+
|
58 |
+
$.ajax({
|
59 |
+
url: pf.rest.submit.url,
|
60 |
+
data: formData,
|
61 |
+
type: 'POST',
|
62 |
+
dataType: 'json',
|
63 |
+
contentType: false,
|
64 |
+
processData: false,
|
65 |
+
beforeSend: function ( xhr ) {
|
66 |
+
xhr.setRequestHeader( 'X-WP-Nonce', pf.rest.nonce );
|
67 |
+
},
|
68 |
+
success: function(data){
|
69 |
+
//console.log("success");
|
70 |
+
//console.log(data);
|
71 |
+
form.find('input').val('');
|
72 |
+
form.find('select').val('');
|
73 |
+
form.find('input[type="checkbox"]').removeAttr('checked');
|
74 |
+
form.find('input[type="radio"]').removeAttr('checked');
|
75 |
+
var $time = new Date().getTime();
|
76 |
+
|
77 |
+
if(data.message){
|
78 |
+
form.closest('.pirate_forms_wrap').before('<div id="' + $time + '" class="pirate-forms-ajax pirate-forms-ajax-thankyou"></div>');
|
79 |
+
$('#' + $time).append(data.message);
|
80 |
+
}else if(data.redirect){
|
81 |
+
location.href = data.redirect;
|
82 |
+
}
|
83 |
+
},
|
84 |
+
error: function(data){
|
85 |
+
//console.log("no");
|
86 |
+
//console.log(data);
|
87 |
+
if(data.responseJSON){
|
88 |
+
var $time = new Date().getTime();
|
89 |
+
form.closest('.pirate_forms_wrap').prepend('<div id="' + $time + '" class="pirate-forms-ajax pirate-forms-ajax-errors"></div>');
|
90 |
+
$('#' + $time).append(data.responseJSON.error);
|
91 |
+
}
|
92 |
+
},
|
93 |
+
complete: function(){
|
94 |
+
ajaxStop( form );
|
95 |
+
}
|
96 |
+
});
|
97 |
+
|
98 |
+
return false;
|
99 |
+
});
|
100 |
+
|
101 |
+
}
|
102 |
+
|
103 |
+
function onWindowLoad() {
|
104 |
+
'use strict';
|
105 |
+
if ( $( '.pirate_forms_wrap' ).length ) {
|
106 |
+
$( '.pirate_forms_wrap' ).each( function () {
|
107 |
+
var formWidth = $( this ).innerWidth();
|
108 |
+
var footerWidth = $( this ).find( '.pirate-forms-footer' ).innerWidth();
|
109 |
+
if ( footerWidth > formWidth ) {
|
110 |
+
$( this ).find( '.contact_submit_wrap, .form_captcha_wrap, .pirateform_wrap_classes_spam_wrap' ).css( {'text-align' : 'left', 'display' : 'block' } );
|
111 |
+
}
|
112 |
+
} );
|
113 |
+
}
|
114 |
+
}
|
115 |
+
|
116 |
+
function ajaxStart(element) {
|
117 |
+
$(element).fadeTo( 'slow', 0.5 );
|
118 |
+
}
|
119 |
+
|
120 |
+
function ajaxStop(element) {
|
121 |
+
$(element).fadeTo( 'fast', 1 );
|
122 |
+
}
|
123 |
+
|
124 |
+
})(jQuery, pirateFormsObject);
|
readme.md
CHANGED
@@ -50,11 +50,23 @@ You can keep all the contacts in an archive by saving their e-mail addresses. Pi
|
|
50 |
|
51 |
A simple to use contact form plugin for creating a clean contact form using the [pirate_forms] shortcode or the 'Pirate Forms' form widget.
|
52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
- What PirateForms isn't for now
|
54 |
|
55 |
|
56 |
This is not a form maker or drag & drop builder plugin nor "the best contact form plugin", you cannot add new fields or create multiple forms (subscription forms, payment, order, feedback or quote), there are some great alternatives out there for those like : Caldera Forms or Ninja Forms.
|
57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
= See how Pirate Forms can integrate with your website =
|
59 |
|
60 |
* [Default form](https://demo.themeisle.com/pirate-forms/default-form-shortcode/)
|
@@ -90,6 +102,7 @@ This plugin started as a fork of https://wordpress.org/plugins/proper-contact-fo
|
|
90 |
|
91 |
|
92 |
|
|
|
93 |
### How I can get support for this contact form plugin ? ###
|
94 |
|
95 |
You can learn more about PirateForms and ask for help by <a href="https://themeisle.com/contact/" >visiting ThemeIsle website</a>.
|
@@ -246,6 +259,12 @@ You can follow the full documentation [here](http://docs.themeisle.com/article/4
|
|
246 |
= How to send a copy of the sent email to the sender. =
|
247 |
[https://docs.themeisle.com/article/837-how-to-send-a-copy-of-the-sent-email-to-the-sender](https://docs.themeisle.com/article/837-how-to-send-a-copy-of-the-sent-email-to-the-sender)
|
248 |
|
|
|
|
|
|
|
|
|
|
|
|
|
249 |
== Installation ==
|
250 |
|
251 |
Activating the Pirate Contact Form plugin is just like any other plugin. If you've uploaded the plugin package to your server already, skip to step 5 below:
|
@@ -267,6 +286,14 @@ Activating the Pirate Contact Form plugin is just like any other plugin. If you'
|
|
267 |
4. Screenshot 4. Enabling SMTP
|
268 |
|
269 |
## Changelog ##
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
270 |
### 2.4.1 - 2018-05-07 ###
|
271 |
|
272 |
* GDPR compliance
|
50 |
|
51 |
A simple to use contact form plugin for creating a clean contact form using the [pirate_forms] shortcode or the 'Pirate Forms' form widget.
|
52 |
|
53 |
+
- Provides option to allow submitting the form using AJAX
|
54 |
+
|
55 |
+
Standard contact forms work just fine, but you can make them nicer by using AJAX to submit the form data in the background.
|
56 |
+
|
57 |
+
Pirate Forms allows you to take advantage of this great feature using the [pirate_forms ajax="yes"] shortcode or the 'Submit form using Ajax' option in the Pirate Forms widget.
|
58 |
+
|
59 |
- What PirateForms isn't for now
|
60 |
|
61 |
|
62 |
This is not a form maker or drag & drop builder plugin nor "the best contact form plugin", you cannot add new fields or create multiple forms (subscription forms, payment, order, feedback or quote), there are some great alternatives out there for those like : Caldera Forms or Ninja Forms.
|
63 |
|
64 |
+
- Privacy Notices
|
65 |
+
|
66 |
+
If you activate the "Store submissions in the database" feature in the Pirate Forms, the contact form submitter’s personal data, including their IP address, will be stored in the database.
|
67 |
+
|
68 |
+
Thus, confirming the provider’s privacy policy is recommended.
|
69 |
+
|
70 |
= See how Pirate Forms can integrate with your website =
|
71 |
|
72 |
* [Default form](https://demo.themeisle.com/pirate-forms/default-form-shortcode/)
|
102 |
|
103 |
|
104 |
|
105 |
+
|
106 |
### How I can get support for this contact form plugin ? ###
|
107 |
|
108 |
You can learn more about PirateForms and ask for help by <a href="https://themeisle.com/contact/" >visiting ThemeIsle website</a>.
|
259 |
= How to send a copy of the sent email to the sender. =
|
260 |
[https://docs.themeisle.com/article/837-how-to-send-a-copy-of-the-sent-email-to-the-sender](https://docs.themeisle.com/article/837-how-to-send-a-copy-of-the-sent-email-to-the-sender)
|
261 |
|
262 |
+
= How to add a multiple choice field in a form =
|
263 |
+
[https://docs.themeisle.com/article/866-how-to-add-a-multiple-choice-field-in-a-form](https://docs.themeisle.com/article/866-how-to-add-a-multiple-choice-field-in-a-form)
|
264 |
+
|
265 |
+
= How to add a select field in a form =
|
266 |
+
[https://docs.themeisle.com/article/867-how-to-add-a-select-field-in-a-form](https://docs.themeisle.com/article/867-how-to-add-a-select-field-in-a-form)
|
267 |
+
|
268 |
== Installation ==
|
269 |
|
270 |
Activating the Pirate Contact Form plugin is just like any other plugin. If you've uploaded the plugin package to your server already, skip to step 5 below:
|
286 |
4. Screenshot 4. Enabling SMTP
|
287 |
|
288 |
## Changelog ##
|
289 |
+
### 2.4.2 - 2018-06-07 ###
|
290 |
+
|
291 |
+
* NEW support for submitting Ajax forms with [pirate_forms ajax="yes"]
|
292 |
+
* Added compatibility with WordPress 4.9.6 Export and Erase Personal Data options
|
293 |
+
* Fixed issue with form caused by the reCaptcha
|
294 |
+
* Fixed compatibility issues with the wpDataTables Lite plugin
|
295 |
+
|
296 |
+
|
297 |
### 2.4.1 - 2018-05-07 ###
|
298 |
|
299 |
* GDPR compliance
|
readme.txt
CHANGED
@@ -50,11 +50,23 @@ You can keep all the contacts in an archive by saving their e-mail addresses. Pi
|
|
50 |
|
51 |
A simple to use contact form plugin for creating a clean contact form using the [pirate_forms] shortcode or the 'Pirate Forms' form widget.
|
52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
- What PirateForms isn't for now
|
54 |
|
55 |
|
56 |
This is not a form maker or drag & drop builder plugin nor "the best contact form plugin", you cannot add new fields or create multiple forms (subscription forms, payment, order, feedback or quote), there are some great alternatives out there for those like : Caldera Forms or Ninja Forms.
|
57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
= See how Pirate Forms can integrate with your website =
|
59 |
|
60 |
* [Default form](https://demo.themeisle.com/pirate-forms/default-form-shortcode/)
|
@@ -91,6 +103,7 @@ This plugin started as a fork of https://wordpress.org/plugins/proper-contact-fo
|
|
91 |
|
92 |
|
93 |
|
|
|
94 |
= How I can get support for this contact form plugin ? =
|
95 |
|
96 |
You can learn more about PirateForms and ask for help by <a href="https://themeisle.com/contact/" >visiting ThemeIsle website</a>.
|
@@ -253,6 +266,12 @@ You can follow the full documentation [here](http://docs.themeisle.com/article/4
|
|
253 |
= How to add a select field in a form =
|
254 |
[https://docs.themeisle.com/article/867-how-to-add-a-select-field-in-a-form](https://docs.themeisle.com/article/867-how-to-add-a-select-field-in-a-form)
|
255 |
|
|
|
|
|
|
|
|
|
|
|
|
|
256 |
== Installation ==
|
257 |
|
258 |
Activating the Pirate Contact Form plugin is just like any other plugin. If you've uploaded the plugin package to your server already, skip to step 5 below:
|
@@ -274,6 +293,14 @@ Activating the Pirate Contact Form plugin is just like any other plugin. If you'
|
|
274 |
4. Screenshot 4. Enabling SMTP
|
275 |
|
276 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
277 |
= 2.4.1 - 2018-05-07 =
|
278 |
|
279 |
* GDPR compliance
|
50 |
|
51 |
A simple to use contact form plugin for creating a clean contact form using the [pirate_forms] shortcode or the 'Pirate Forms' form widget.
|
52 |
|
53 |
+
- Provides option to allow submitting the form using AJAX
|
54 |
+
|
55 |
+
Standard contact forms work just fine, but you can make them nicer by using AJAX to submit the form data in the background.
|
56 |
+
|
57 |
+
Pirate Forms allows you to take advantage of this great feature using the [pirate_forms ajax="yes"] shortcode or the 'Submit form using Ajax' option in the Pirate Forms widget.
|
58 |
+
|
59 |
- What PirateForms isn't for now
|
60 |
|
61 |
|
62 |
This is not a form maker or drag & drop builder plugin nor "the best contact form plugin", you cannot add new fields or create multiple forms (subscription forms, payment, order, feedback or quote), there are some great alternatives out there for those like : Caldera Forms or Ninja Forms.
|
63 |
|
64 |
+
- Privacy Notices
|
65 |
+
|
66 |
+
If you activate the "Store submissions in the database" feature in the Pirate Forms, the contact form submitter’s personal data, including their IP address, will be stored in the database.
|
67 |
+
|
68 |
+
Thus, confirming the provider’s privacy policy is recommended.
|
69 |
+
|
70 |
= See how Pirate Forms can integrate with your website =
|
71 |
|
72 |
* [Default form](https://demo.themeisle.com/pirate-forms/default-form-shortcode/)
|
103 |
|
104 |
|
105 |
|
106 |
+
|
107 |
= How I can get support for this contact form plugin ? =
|
108 |
|
109 |
You can learn more about PirateForms and ask for help by <a href="https://themeisle.com/contact/" >visiting ThemeIsle website</a>.
|
266 |
= How to add a select field in a form =
|
267 |
[https://docs.themeisle.com/article/867-how-to-add-a-select-field-in-a-form](https://docs.themeisle.com/article/867-how-to-add-a-select-field-in-a-form)
|
268 |
|
269 |
+
= GDPR and Pirate Forms =
|
270 |
+
[https://docs.themeisle.com/article/886-gdpr-and-pirate-forms](https://docs.themeisle.com/article/886-gdpr-and-pirate-forms)
|
271 |
+
|
272 |
+
= How to enable form submission without reloading the page using AJAX =
|
273 |
+
[https://docs.themeisle.com/article/909-how-to-enable-form-submission-without-reloading-the-page-using-ajax](https://docs.themeisle.com/article/909-how-to-enable-form-submission-without-reloading-the-page-using-ajax)
|
274 |
+
|
275 |
== Installation ==
|
276 |
|
277 |
Activating the Pirate Contact Form plugin is just like any other plugin. If you've uploaded the plugin package to your server already, skip to step 5 below:
|
293 |
4. Screenshot 4. Enabling SMTP
|
294 |
|
295 |
== Changelog ==
|
296 |
+
= 2.4.2 - 2018-06-07 =
|
297 |
+
|
298 |
+
* NEW support for submitting Ajax forms with [pirate_forms ajax="yes"]
|
299 |
+
* Added compatibility with WordPress 4.9.6 Export and Erase Personal Data options
|
300 |
+
* Fixed issue with form caused by the reCaptcha
|
301 |
+
* Fixed compatibility issues with the wpDataTables Lite plugin
|
302 |
+
|
303 |
+
|
304 |
= 2.4.1 - 2018-05-07 =
|
305 |
|
306 |
* GDPR compliance
|
themeisle-hash.json
CHANGED
@@ -1 +1 @@
|
|
1 |
-
{"index.php":"39ab8276fb0e4bd3fcab3270822c5977","pirate-forms.php":"
|
1 |
+
{"index.php":"39ab8276fb0e4bd3fcab3270822c5977","pirate-forms.php":"b362d348135cec32a3e5f560a52dfe75","uninstall.php":"9d936442a63521d971a6dbc28df9c0d1"}
|
vendor/autoload.php
CHANGED
@@ -4,4 +4,4 @@
|
|
4 |
|
5 |
require_once __DIR__ . '/composer' . '/autoload_real.php';
|
6 |
|
7 |
-
return
|
4 |
|
5 |
require_once __DIR__ . '/composer' . '/autoload_real.php';
|
6 |
|
7 |
+
return ComposerAutoloaderInit56af298a22d6a897a874f285605e4ce2::getLoader();
|
vendor/autoload_52.php
CHANGED
@@ -4,4 +4,4 @@
|
|
4 |
|
5 |
require_once dirname(__FILE__) . '/composer'.'/autoload_real_52.php';
|
6 |
|
7 |
-
return
|
4 |
|
5 |
require_once dirname(__FILE__) . '/composer'.'/autoload_real_52.php';
|
6 |
|
7 |
+
return ComposerAutoloaderInitf7f3d7f92a70be0a2cc5f0a49cf36402::getLoader();
|
vendor/codeinwp/themeisle-sdk/class-themeisle-sdk-licenser.php
CHANGED
@@ -49,7 +49,8 @@ if ( ! class_exists( 'ThemeIsle_SDK_Licenser' ) ) :
|
|
49 |
* @param ThemeIsle_SDK_Product $product The product object.
|
50 |
*/
|
51 |
public function __construct( $product ) {
|
52 |
-
$this->product
|
|
|
53 |
$this->product_key = $this->product->get_key() . '-update-response';
|
54 |
if ( ! $this->product->requires_license() ) {
|
55 |
$this->license_key = 'free';
|
@@ -517,6 +518,39 @@ if ( ! class_exists( 'ThemeIsle_SDK_Licenser' ) ) :
|
|
517 |
delete_transient( $this->product_key );
|
518 |
}
|
519 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
520 |
/**
|
521 |
* Check for updates
|
522 |
*
|
@@ -525,45 +559,22 @@ if ( ! class_exists( 'ThemeIsle_SDK_Licenser' ) ) :
|
|
525 |
function check_for_update() {
|
526 |
$theme = wp_get_theme( $this->product->get_slug() );
|
527 |
$update_data = get_transient( $this->product_key );
|
|
|
528 |
if ( false === $update_data ) {
|
529 |
$failed = false;
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
$api_params = array(
|
534 |
-
'edd_action' => 'get_version',
|
535 |
-
'version' => $this->product->get_version(),
|
536 |
-
'license' => $this->license_key,
|
537 |
-
'name' => $this->product->get_name(),
|
538 |
-
'slug' => $this->product->get_slug(),
|
539 |
-
'author' => $this->product->get_store_name(),
|
540 |
-
'url' => rawurlencode( home_url() ),
|
541 |
-
);
|
542 |
-
$response = wp_remote_post(
|
543 |
-
$this->product->get_store_url(), array(
|
544 |
-
'timeout' => 15,
|
545 |
-
'sslverify' => false,
|
546 |
-
'body' => $api_params,
|
547 |
-
)
|
548 |
-
);
|
549 |
-
// make sure the response was successful
|
550 |
-
if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) {
|
551 |
-
$failed = true;
|
552 |
-
}
|
553 |
-
$update_data = json_decode( wp_remote_retrieve_body( $response ) );
|
554 |
-
if ( ! is_object( $update_data ) ) {
|
555 |
$failed = true;
|
556 |
}
|
557 |
-
//
|
558 |
if ( $failed ) {
|
559 |
$data = new stdClass;
|
560 |
$data->new_version = $this->product->get_version();
|
561 |
set_transient( $this->product_key, $data, strtotime( '+30 minutes' ) );
|
562 |
|
563 |
return false;
|
564 |
-
}
|
565 |
-
// if the status is 'ok', return the update arguments
|
566 |
-
if ( ! $failed ) {
|
567 |
$update_data->sections = maybe_unserialize( $update_data->sections );
|
568 |
set_transient( $this->product_key, $update_data, strtotime( '+12 hours' ) );
|
569 |
}
|
@@ -618,34 +629,14 @@ if ( ! class_exists( 'ThemeIsle_SDK_Licenser' ) ) :
|
|
618 |
* @return false||object
|
619 |
*/
|
620 |
private function api_request( $_action = '', $_data = '' ) {
|
621 |
-
|
622 |
-
|
623 |
-
}
|
624 |
-
$api_params = array(
|
625 |
-
'edd_action' => 'get_version',
|
626 |
-
'license' => $this->license_key,
|
627 |
-
'name' => rawurlencode( $this->product->get_name() ),
|
628 |
-
'slug' => rawurlencode( $this->product->get_slug() ),
|
629 |
-
'author' => $this->product->get_store_name(),
|
630 |
-
'url' => rawurlencode( home_url() ),
|
631 |
-
);
|
632 |
-
$request = wp_remote_post(
|
633 |
-
$this->product->get_store_url(), array(
|
634 |
-
'timeout' => 15,
|
635 |
-
'sslverify' => false,
|
636 |
-
'body' => $api_params,
|
637 |
-
)
|
638 |
-
);
|
639 |
-
if ( ! is_wp_error( $request ) ) :
|
640 |
-
$request = json_decode( wp_remote_retrieve_body( $request ) );
|
641 |
-
if ( $request && isset( $request->sections ) ) {
|
642 |
-
$request->sections = maybe_unserialize( $request->sections );
|
643 |
-
}
|
644 |
-
|
645 |
-
return $request;
|
646 |
-
else :
|
647 |
return false;
|
648 |
-
|
|
|
|
|
|
|
|
|
649 |
}
|
650 |
|
651 |
/**
|
49 |
* @param ThemeIsle_SDK_Product $product The product object.
|
50 |
*/
|
51 |
public function __construct( $product ) {
|
52 |
+
$this->product = $product;
|
53 |
+
|
54 |
$this->product_key = $this->product->get_key() . '-update-response';
|
55 |
if ( ! $this->product->requires_license() ) {
|
56 |
$this->license_key = 'free';
|
518 |
delete_transient( $this->product_key );
|
519 |
}
|
520 |
|
521 |
+
/**
|
522 |
+
* Check remote api for latest version.
|
523 |
+
*
|
524 |
+
* @return bool|mixed Update api response.
|
525 |
+
*/
|
526 |
+
private function get_version_data() {
|
527 |
+
$api_params = array(
|
528 |
+
'edd_action' => 'get_version',
|
529 |
+
'version' => $this->product->get_version(),
|
530 |
+
'license' => $this->license_key,
|
531 |
+
'name' => $this->product->get_name(),
|
532 |
+
'slug' => $this->product->get_slug(),
|
533 |
+
'author' => $this->product->get_store_name(),
|
534 |
+
'url' => rawurlencode( home_url() ),
|
535 |
+
);
|
536 |
+
$response = wp_remote_post(
|
537 |
+
$this->product->get_store_url(), array(
|
538 |
+
'timeout' => 15,
|
539 |
+
'sslverify' => false,
|
540 |
+
'body' => $api_params,
|
541 |
+
)
|
542 |
+
);
|
543 |
+
if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) {
|
544 |
+
return false;
|
545 |
+
}
|
546 |
+
$update_data = json_decode( wp_remote_retrieve_body( $response ) );
|
547 |
+
if ( ! is_object( $update_data ) ) {
|
548 |
+
return false;
|
549 |
+
}
|
550 |
+
|
551 |
+
return $update_data;
|
552 |
+
}
|
553 |
+
|
554 |
/**
|
555 |
* Check for updates
|
556 |
*
|
559 |
function check_for_update() {
|
560 |
$theme = wp_get_theme( $this->product->get_slug() );
|
561 |
$update_data = get_transient( $this->product_key );
|
562 |
+
|
563 |
if ( false === $update_data ) {
|
564 |
$failed = false;
|
565 |
+
|
566 |
+
$update_data = $this->get_version_data();
|
567 |
+
if ( empty( $update_data ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
568 |
$failed = true;
|
569 |
}
|
570 |
+
// If the response failed, try again in 30 minutes.
|
571 |
if ( $failed ) {
|
572 |
$data = new stdClass;
|
573 |
$data->new_version = $this->product->get_version();
|
574 |
set_transient( $this->product_key, $data, strtotime( '+30 minutes' ) );
|
575 |
|
576 |
return false;
|
577 |
+
} else {
|
|
|
|
|
578 |
$update_data->sections = maybe_unserialize( $update_data->sections );
|
579 |
set_transient( $this->product_key, $update_data, strtotime( '+12 hours' ) );
|
580 |
}
|
629 |
* @return false||object
|
630 |
*/
|
631 |
private function api_request( $_action = '', $_data = '' ) {
|
632 |
+
$update_data = $this->get_version_data();
|
633 |
+
if ( empty( $update_data ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
634 |
return false;
|
635 |
+
}
|
636 |
+
if ( $update_data && isset( $update_data->sections ) ) {
|
637 |
+
$update_data->sections = maybe_unserialize( $update_data->sections );
|
638 |
+
}
|
639 |
+
return $update_data;
|
640 |
}
|
641 |
|
642 |
/**
|
vendor/codeinwp/themeisle-sdk/load.php
CHANGED
@@ -11,7 +11,7 @@
|
|
11 |
*/
|
12 |
|
13 |
// Current SDK version and path.
|
14 |
-
$themeisle_sdk_version = '2.2.
|
15 |
$themeisle_sdk_path = dirname( __FILE__ );
|
16 |
|
17 |
global $themeisle_sdk_max_version;
|
11 |
*/
|
12 |
|
13 |
// Current SDK version and path.
|
14 |
+
$themeisle_sdk_version = '2.2.5';
|
15 |
$themeisle_sdk_path = dirname( __FILE__ );
|
16 |
|
17 |
global $themeisle_sdk_max_version;
|
vendor/composer/autoload_real.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
-
class
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
@@ -19,9 +19,9 @@ class ComposerAutoloaderInita5db61f3dfc499606d73fc8e303bc781
|
|
19 |
return self::$loader;
|
20 |
}
|
21 |
|
22 |
-
spl_autoload_register(array('
|
23 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
24 |
-
spl_autoload_unregister(array('
|
25 |
|
26 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
27 |
foreach ($map as $namespace => $path) {
|
@@ -42,14 +42,14 @@ class ComposerAutoloaderInita5db61f3dfc499606d73fc8e303bc781
|
|
42 |
|
43 |
$includeFiles = require __DIR__ . '/autoload_files.php';
|
44 |
foreach ($includeFiles as $fileIdentifier => $file) {
|
45 |
-
|
46 |
}
|
47 |
|
48 |
return $loader;
|
49 |
}
|
50 |
}
|
51 |
|
52 |
-
function
|
53 |
{
|
54 |
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
55 |
require $file;
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
+
class ComposerAutoloaderInit56af298a22d6a897a874f285605e4ce2
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
19 |
return self::$loader;
|
20 |
}
|
21 |
|
22 |
+
spl_autoload_register(array('ComposerAutoloaderInit56af298a22d6a897a874f285605e4ce2', 'loadClassLoader'), true, true);
|
23 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
24 |
+
spl_autoload_unregister(array('ComposerAutoloaderInit56af298a22d6a897a874f285605e4ce2', 'loadClassLoader'));
|
25 |
|
26 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
27 |
foreach ($map as $namespace => $path) {
|
42 |
|
43 |
$includeFiles = require __DIR__ . '/autoload_files.php';
|
44 |
foreach ($includeFiles as $fileIdentifier => $file) {
|
45 |
+
composerRequire56af298a22d6a897a874f285605e4ce2($fileIdentifier, $file);
|
46 |
}
|
47 |
|
48 |
return $loader;
|
49 |
}
|
50 |
}
|
51 |
|
52 |
+
function composerRequire56af298a22d6a897a874f285605e4ce2($fileIdentifier, $file)
|
53 |
{
|
54 |
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
55 |
require $file;
|
vendor/composer/autoload_real_52.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
// autoload_real_52.php generated by xrstf/composer-php52
|
4 |
|
5 |
-
class
|
6 |
private static $loader;
|
7 |
|
8 |
public static function loadClassLoader($class) {
|
@@ -19,9 +19,9 @@ class ComposerAutoloaderInit48f2620de42f666b4c12b0ca3903f134 {
|
|
19 |
return self::$loader;
|
20 |
}
|
21 |
|
22 |
-
spl_autoload_register(array('
|
23 |
self::$loader = $loader = new xrstf_Composer52_ClassLoader();
|
24 |
-
spl_autoload_unregister(array('
|
25 |
|
26 |
$vendorDir = dirname(dirname(__FILE__));
|
27 |
$baseDir = dirname($vendorDir);
|
2 |
|
3 |
// autoload_real_52.php generated by xrstf/composer-php52
|
4 |
|
5 |
+
class ComposerAutoloaderInitf7f3d7f92a70be0a2cc5f0a49cf36402 {
|
6 |
private static $loader;
|
7 |
|
8 |
public static function loadClassLoader($class) {
|
19 |
return self::$loader;
|
20 |
}
|
21 |
|
22 |
+
spl_autoload_register(array('ComposerAutoloaderInitf7f3d7f92a70be0a2cc5f0a49cf36402', 'loadClassLoader'), true /*, true */);
|
23 |
self::$loader = $loader = new xrstf_Composer52_ClassLoader();
|
24 |
+
spl_autoload_unregister(array('ComposerAutoloaderInitf7f3d7f92a70be0a2cc5f0a49cf36402', 'loadClassLoader'));
|
25 |
|
26 |
$vendorDir = dirname(dirname(__FILE__));
|
27 |
$baseDir = dirname($vendorDir);
|
vendor/composer/installed.json
CHANGED
@@ -6,15 +6,15 @@
|
|
6 |
"source": {
|
7 |
"type": "git",
|
8 |
"url": "https://github.com/Codeinwp/themeisle-sdk.git",
|
9 |
-
"reference": "
|
10 |
},
|
11 |
"dist": {
|
12 |
"type": "zip",
|
13 |
-
"url": "https://api.github.com/repos/Codeinwp/themeisle-sdk/zipball/
|
14 |
-
"reference": "
|
15 |
"shasum": ""
|
16 |
},
|
17 |
-
"time": "2018-
|
18 |
"type": "library",
|
19 |
"installation-source": "dist",
|
20 |
"autoload": {
|
6 |
"source": {
|
7 |
"type": "git",
|
8 |
"url": "https://github.com/Codeinwp/themeisle-sdk.git",
|
9 |
+
"reference": "33d470402379047bc430c39ecab9a8a4a850d0d2"
|
10 |
},
|
11 |
"dist": {
|
12 |
"type": "zip",
|
13 |
+
"url": "https://api.github.com/repos/Codeinwp/themeisle-sdk/zipball/33d470402379047bc430c39ecab9a8a4a850d0d2",
|
14 |
+
"reference": "33d470402379047bc430c39ecab9a8a4a850d0d2",
|
15 |
"shasum": ""
|
16 |
},
|
17 |
+
"time": "2018-06-06 14:49:32",
|
18 |
"type": "library",
|
19 |
"installation-source": "dist",
|
20 |
"autoload": {
|