Contact Form & SMTP Plugin for WordPress by PirateForms - Version 2.4.4

Version Description

  • 2018-07-13
Download this release

Release Info

Developer codeinwp
Plugin Icon 128x128 Contact Form & SMTP Plugin for WordPress by PirateForms
Version 2.4.4
Comparing to
See all releases

Code changes from version 2.4.3 to 2.4.4

CHANGELOG.md CHANGED
@@ -1,4 +1,11 @@
1
 
 
 
 
 
 
 
 
2
  ### v2.4.3 - 2018-06-25
3
  **Changes:**
4
  * New Gutenberg block for the default Pirate Forms form
1
 
2
+ ### v2.4.4 - 2018-07-13
3
+ **Changes:**
4
+ * Fixed compatibility with All in One SEO Pack plugin
5
+ * Fixed problem with form not working with the ajax option
6
+ * Option to save the attachments files
7
+ * Improved recaptcha button layout on mobile devices
8
+
9
  ### v2.4.3 - 2018-06-25
10
  **Changes:**
11
  * New Gutenberg block for the default Pirate Forms form
admin/class-pirateforms-admin.php CHANGED
@@ -396,6 +396,25 @@ class PirateForms_Admin {
396
  ),
397
  'options' => array( 'yes' => __( 'Yes', 'pirate-forms' ) ),
398
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
399
  array(
400
  'id' => 'pirateformsopt_thank_you_url',
401
  'type' => 'select',
@@ -1190,17 +1209,20 @@ class PirateForms_Admin {
1190
  )
1191
  );
1192
 
 
 
1193
  if ( $query->have_posts() ) {
1194
  while ( $query->have_posts() ) {
1195
  $query->the_post();
1196
 
1197
- $data = array(
1198
- array(
1199
- 'name' => __( 'Email content', 'pirate-forms' ),
1200
- 'value' => nl2br( strip_tags( $query->post->post_content ) ),
1201
- ),
1202
  );
1203
 
 
 
1204
  $export_items[] = array(
1205
  'group_id' => 'pf_contact',
1206
  'group_label' => PIRATEFORMS_NAME,
@@ -1248,10 +1270,15 @@ class PirateForms_Admin {
1248
 
1249
  $retained = array();
1250
  $removed = 0;
 
1251
 
1252
  if ( $query->have_posts() ) {
1253
  while ( $query->have_posts() ) {
1254
  $query->the_post();
 
 
 
 
1255
  if ( false !== ( $post_id = wp_delete_post( $query->post, true ) ) ) {
1256
  $removed++;
1257
  } else {
@@ -1263,7 +1290,7 @@ class PirateForms_Admin {
1263
  return array(
1264
  'items_removed' => $removed,
1265
  'items_retained' => ! empty( $retained ) ? count( $retained ) : false,
1266
- 'messages' => ! empty( $retained ) ? array(sprintf( __( 'Unable to delete post(s) %s', 'pirate-forms' ), print_r( $retained, true ) )) : array(),
1267
  'done' => true,
1268
  );
1269
  }
396
  ),
397
  'options' => array( 'yes' => __( 'Yes', 'pirate-forms' ) ),
398
  ),
399
+ array(
400
+ 'id' => 'pirateformsopt_save_attachment',
401
+ 'type' => 'checkbox',
402
+ 'label' => array(
403
+ 'value' => __( 'Save Attachment?', 'pirate-forms' ),
404
+ 'html' => '<span class="dashicons dashicons-editor-help"></span>',
405
+ 'desc' => array(
406
+ 'value' => __( 'Enabling this option will save the attachment(s) otherwise attachments can only be found in the email that is received.', 'pirate-forms' ),
407
+ 'class' => 'pirate_forms_option_description',
408
+ ),
409
+ ),
410
+ 'default' => '',
411
+ 'value' => PirateForms_Util::get_option( 'pirateformsopt_save_attachment' ),
412
+ 'wrap' => array(
413
+ 'type' => 'div',
414
+ 'class' => 'pirate-forms-grouped',
415
+ ),
416
+ 'options' => array( 'yes' => __( 'Yes', 'pirate-forms' ) ),
417
+ ),
418
  array(
419
  'id' => 'pirateformsopt_thank_you_url',
420
  'type' => 'select',
1209
  )
1210
  );
1211
 
1212
+ $pirate_forms_options = PirateForms_Util::get_option();
1213
+
1214
  if ( $query->have_posts() ) {
1215
  while ( $query->have_posts() ) {
1216
  $query->the_post();
1217
 
1218
+ $data = array();
1219
+ $data[] = array(
1220
+ 'name' => __( 'Email content', 'pirate-forms' ),
1221
+ 'value' => nl2br( strip_tags( $query->post->post_content ) ),
 
1222
  );
1223
 
1224
+ $data = apply_filters( 'pirate_forms_private_data_exporter', $data, $query->post->ID, $email_address, $page, $pirate_forms_options );
1225
+
1226
  $export_items[] = array(
1227
  'group_id' => 'pf_contact',
1228
  'group_label' => PIRATEFORMS_NAME,
1270
 
1271
  $retained = array();
1272
  $removed = 0;
1273
+ $pirate_forms_options = PirateForms_Util::get_option();
1274
 
1275
  if ( $query->have_posts() ) {
1276
  while ( $query->have_posts() ) {
1277
  $query->the_post();
1278
+
1279
+ list( $retained, $removed ) = apply_filters( 'pirate_forms_private_data_eraser', array( $retained, $removed ), $query->post, $email_address, $page, $pirate_forms_options );
1280
+
1281
+ // delete the post last so that all dependent operations are complete.
1282
  if ( false !== ( $post_id = wp_delete_post( $query->post, true ) ) ) {
1283
  $removed++;
1284
  } else {
1290
  return array(
1291
  'items_removed' => $removed,
1292
  'items_retained' => ! empty( $retained ) ? count( $retained ) : false,
1293
+ 'messages' => ! empty( $retained ) ? array(sprintf( __( 'Unable to delete %d entries', 'pirate-forms' ), count( $retained ) )) : array(),
1294
  'done' => true,
1295
  );
1296
  }
admin/js/scripts-admin.js CHANGED
@@ -2,167 +2,182 @@
2
  /* global console */
3
  /* global tinyMCE */
4
 
5
- jQuery(document).ready(function() {
6
- initAll();
7
- });
8
-
9
- function initAll(){
10
- jQuery('.pirate-forms-nav-tabs a').click(function (event) {
11
- event.preventDefault();
12
- jQuery(this).parent().addClass('active');
13
- jQuery(this).parent().siblings().removeClass('active');
14
- var tab = jQuery(this).attr('href');
15
- jQuery('.pirate-forms-tab-pane').not(tab).css('display', 'none');
16
- jQuery(tab).fadeIn();
17
- });
18
 
19
- jQuery('.pirate-forms-save-button').click(function (e) {
20
- e.preventDefault();
21
- tinyMCE.triggerSave();
22
- cwpTopUpdateForm();
23
- return false;
24
  });
25
 
26
- jQuery('.pirate-forms-test-button').click(function (e) {
27
- e.preventDefault();
28
- cwpSendTestEmail();
29
- return false;
30
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
 
32
- jQuery('input[name="pirateformsopt_recaptcha_field"]').on('click', function(){
33
- if(jQuery(this).val() === 'yes'){
34
- jQuery('.pirateformsopt_recaptcha').show();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  }else{
36
- jQuery('.pirateformsopt_recaptcha').hide();
 
 
 
 
 
 
 
 
 
 
37
  }
38
- });
39
 
40
- if( jQuery('input[name="pirateformsopt_recaptcha_field"]:checked').val() !== 'yes' ){
41
- jQuery('.pirateformsopt_recaptcha').hide();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  }
43
 
44
  function cwpSendTestEmail() {
45
- jQuery('.pirate-forms-test-message').html('');
46
  startAjaxIntro();
47
- jQuery.ajax({
48
  type: 'POST',
49
- url: cwp_top_ajaxload.ajaxurl,
50
  data: {
51
  action : 'pirate_forms_test',
52
- security : cwp_top_ajaxload.nonce
53
  },
54
  success: function (data) {
55
- jQuery('.pirate-forms-test-message').html(data.data.message);
56
  },
57
  error: function (MLHttpRequest, textStatus, errorThrown) {
58
  console.log('There was an error: ' + errorThrown);
59
- },
60
- complete: function() {
61
- endAjaxIntro();
62
  }
63
  });
 
64
  return false;
65
  }
66
 
67
  function cwpTopUpdateForm() {
68
- if(jQuery('#pirateformsopt_recaptcha_fieldyes').is(':checked') && (jQuery('#pirateformsopt_recaptcha_sitekey').val() === '' || jQuery('#pirateformsopt_recaptcha_secretkey').val() === '')){
69
- window.alert(cwp_top_ajaxload.i10n.recaptcha);
70
  return;
71
  }
72
 
73
  startAjaxIntro();
74
 
75
- var data = jQuery('.pirate_forms_contact_settings').serialize();
76
 
77
- jQuery.ajax({
78
  type: 'POST',
79
- url: cwp_top_ajaxload.ajaxurl,
80
 
81
  data: {
82
  action : 'pirate_forms_save',
83
  dataSent : data,
84
- security : cwp_top_ajaxload.nonce
85
  },
86
  success: function (response) {
87
  console.log(response);
88
  },
89
  error: function (MLHttpRequest, textStatus, errorThrown) {
90
  console.log('There was an error: ' + errorThrown);
91
- },
92
- complete: function(){
93
- endAjaxIntro();
94
  }
95
  });
96
-
 
97
  return false;
98
  }
99
 
100
  // Starting the AJAX intro animation
101
  function startAjaxIntro() {
102
- jQuery('.ajaxAnimation').fadeIn();
103
  }
104
 
105
  // Ending the AJAX intro animation
106
  function endAjaxIntro() {
107
- jQuery('.ajaxAnimation').fadeOut();
108
  }
109
 
110
- /* Recaptcha site key and secret key should appear only when Add a recaptcha is selected */
111
- jQuery('input#pirateformsopt_recaptcha_field').change(function(){
112
- jQuery('.pirate-forms-grouped #pirateformsopt_recaptcha_sitekey').parent().addClass('pirate-forms-hidden');
113
- jQuery('.pirate-forms-grouped #pirateformsopt_recaptcha_secretkey').parent().addClass('pirate-forms-hidden');
114
- if( jQuery(this).is(':checked') ) {
115
- jQuery('.pirate-forms-grouped #pirateformsopt_recaptcha_sitekey').parent().removeClass('pirate-forms-hidden');
116
- jQuery('.pirate-forms-grouped #pirateformsopt_recaptcha_secretkey').parent().removeClass('pirate-forms-hidden');
117
- }
118
- });
119
-
120
- // add visibility toggle to password type fields
121
- jQuery('.pirate-forms-password-toggle').append('<span class="dashicons dashicons-visibility"></span>');
122
- jQuery('.pirate-forms-password-toggle span').on('click', function(){
123
- var span = jQuery(this);
124
- if(span.hasClass('dashicons-visibility')){
125
- span.parent().find('input[type="password"]').attr('type', 'text');
126
- span.removeClass('dashicons-visibility').addClass('dashicons-hidden');
127
- }else{
128
- span.parent().find('input[type="text"]').attr('type', 'password');
129
- span.removeClass('dashicons-hidden').addClass('dashicons-visibility');
130
- }
131
- });
132
-
133
- // tootips in settings.
134
- jQuery(document).tooltip({
135
- items: '.dashicons-editor-help',
136
- hide: 200,
137
- position: {within: '#pirate-forms-main'},
138
-
139
- content: function () {
140
- return jQuery(this).find('div').html();
141
- },
142
- show: null,
143
- close: function (event, ui) {
144
- ui.tooltip.hover(
145
- function () {
146
- jQuery(this).stop(true).fadeTo(400, 1);
147
- },
148
- function () {
149
- jQuery(this).fadeOut('400', function () {
150
- jQuery(this).remove();
151
- });
152
- });
153
- }
154
- });
155
-
156
- jQuery('.pirateforms-notice-gdpr.is-dismissible').on('click', '.notice-dismiss', function(){
157
- jQuery.ajax({
158
- url : cwp_top_ajaxload.ajaxurl,
159
- type : 'POST',
160
- data : {
161
- id : jQuery(this).parent().attr('data-dismissible'),
162
- _action : 'dismiss-notice',
163
- security : cwp_top_ajaxload.nonce,
164
- action : cwp_top_ajaxload.slug
165
- }
166
- });
167
- });
168
- }
2
  /* global console */
3
  /* global tinyMCE */
4
 
5
+ (function($, pf){
 
 
 
 
 
 
 
 
 
 
 
 
6
 
7
+ $(document).ready(function() {
8
+ initAll();
 
 
 
9
  });
10
 
11
+ function initAll(){
12
+ $('.pirate-forms-nav-tabs a').click(function (event) {
13
+ event.preventDefault();
14
+ $(this).parent().addClass('active');
15
+ $(this).parent().siblings().removeClass('active');
16
+ var tab = $(this).attr('href');
17
+ $('.pirate-forms-tab-pane').not(tab).css('display', 'none');
18
+ $(tab).fadeIn();
19
+ });
20
+
21
+ $('.pirate-forms-save-button').click(function (e) {
22
+ e.preventDefault();
23
+ tinyMCE.triggerSave();
24
+ cwpTopUpdateForm();
25
+ return false;
26
+ });
27
+
28
+ $('.pirate-forms-test-button').click(function (e) {
29
+ e.preventDefault();
30
+ cwpSendTestEmail();
31
+ return false;
32
+ });
33
 
34
+
35
+ $('input[name="pirateformsopt_recaptcha_field"]').on('click', function(){
36
+ if($(this).val() === 'yes'){
37
+ $('.pirateformsopt_recaptcha').show();
38
+ }else{
39
+ $('.pirateformsopt_recaptcha').hide();
40
+ }
41
+ });
42
+
43
+ if( $('input[name="pirateformsopt_recaptcha_field"]:checked').val() !== 'yes' ){
44
+ $('.pirateformsopt_recaptcha').hide();
45
+ }
46
+
47
+ if(jQuery.isFunction(jQuery.fn.tooltip)){
48
+ // tootips in settings.
49
+ jQuery(document).tooltip({
50
+ items: '.dashicons-editor-help',
51
+ hide: 200,
52
+ position: {within: '#pirate-forms-main'},
53
+
54
+ content: function () {
55
+ return jQuery(this).find('div').html();
56
+ },
57
+ show: null,
58
+ close: function (event, ui) {
59
+ ui.tooltip.hover(
60
+ function () {
61
+ jQuery(this).stop(true).fadeTo(400, 1);
62
+ },
63
+ function () {
64
+ jQuery(this).fadeOut('400', function () {
65
+ jQuery(this).remove();
66
+ });
67
+ });
68
+ }
69
+ });
70
  }else{
71
+ jQuery('.pirate-forms-grouped').each(function(i, x){
72
+ var desc = jQuery(x).find('.pirate_forms_option_description');
73
+ if(desc.length === 0){
74
+ return;
75
+ }
76
+ var text = desc.html();
77
+ jQuery('<p class="description" style="margin-bottom: ' + jQuery(x).css('margin-bottom') + '"><span class="dashicons dashicons-editor-help"></span>' + text + '</p>').insertAfter(jQuery(x));
78
+ jQuery(x).css('margin-bottom', 0);
79
+ desc.remove();
80
+ jQuery(x).find('span.dashicons-editor-help').remove();
81
+ });
82
  }
 
83
 
84
+ /* Recaptcha site key and secret key should appear only when Add a recaptcha is selected */
85
+ $('input#pirateformsopt_recaptcha_field').change(function(){
86
+ $('.pirate-forms-grouped #pirateformsopt_recaptcha_sitekey').parent().addClass('pirate-forms-hidden');
87
+ $('.pirate-forms-grouped #pirateformsopt_recaptcha_secretkey').parent().addClass('pirate-forms-hidden');
88
+ if( $(this).is(':checked') ) {
89
+ $('.pirate-forms-grouped #pirateformsopt_recaptcha_sitekey').parent().removeClass('pirate-forms-hidden');
90
+ $('.pirate-forms-grouped #pirateformsopt_recaptcha_secretkey').parent().removeClass('pirate-forms-hidden');
91
+ }
92
+ });
93
+
94
+ // add visibility toggle to password type fields
95
+ $('.pirate-forms-password-toggle').append('<span class="dashicons dashicons-visibility"></span>');
96
+ $('.pirate-forms-password-toggle span').on('click', function(){
97
+ var span = $(this);
98
+ if(span.hasClass('dashicons-visibility')){
99
+ span.parent().find('input[type="password"]').attr('type', 'text');
100
+ span.removeClass('dashicons-visibility').addClass('dashicons-hidden');
101
+ }else{
102
+ span.parent().find('input[type="text"]').attr('type', 'password');
103
+ span.removeClass('dashicons-hidden').addClass('dashicons-visibility');
104
+ }
105
+ });
106
+
107
+ $('.pirateforms-notice-gdpr.is-dismissible').on('click', '.notice-dismiss', function(){
108
+ $.ajax({
109
+ url : pf.ajaxurl,
110
+ type : 'POST',
111
+ data : {
112
+ id : $(this).parent().attr('data-dismissible'),
113
+ _action : 'dismiss-notice',
114
+ security : pf.nonce,
115
+ action : pf.slug
116
+ }
117
+ });
118
+ });
119
  }
120
 
121
  function cwpSendTestEmail() {
122
+ $('.pirate-forms-test-message').html('');
123
  startAjaxIntro();
124
+ $.ajax({
125
  type: 'POST',
126
+ url: pf.ajaxurl,
127
  data: {
128
  action : 'pirate_forms_test',
129
+ security : pf.nonce
130
  },
131
  success: function (data) {
132
+ $('.pirate-forms-test-message').html(data.data.message);
133
  },
134
  error: function (MLHttpRequest, textStatus, errorThrown) {
135
  console.log('There was an error: ' + errorThrown);
 
 
 
136
  }
137
  });
138
+ endAjaxIntro();
139
  return false;
140
  }
141
 
142
  function cwpTopUpdateForm() {
143
+ if($('#pirateformsopt_recaptcha_fieldyes').is(':checked') && ($('#pirateformsopt_recaptcha_sitekey').val() === '' || $('#pirateformsopt_recaptcha_secretkey').val() === '')){
144
+ window.alert(pf.i10n.recaptcha);
145
  return;
146
  }
147
 
148
  startAjaxIntro();
149
 
150
+ var data = $('.pirate_forms_contact_settings').serialize();
151
 
152
+ $.ajax({
153
  type: 'POST',
154
+ url: pf.ajaxurl,
155
 
156
  data: {
157
  action : 'pirate_forms_save',
158
  dataSent : data,
159
+ security : pf.nonce
160
  },
161
  success: function (response) {
162
  console.log(response);
163
  },
164
  error: function (MLHttpRequest, textStatus, errorThrown) {
165
  console.log('There was an error: ' + errorThrown);
 
 
 
166
  }
167
  });
168
+
169
+ endAjaxIntro();
170
  return false;
171
  }
172
 
173
  // Starting the AJAX intro animation
174
  function startAjaxIntro() {
175
+ $('.ajaxAnimation').fadeIn();
176
  }
177
 
178
  // Ending the AJAX intro animation
179
  function endAjaxIntro() {
180
+ $('.ajaxAnimation').fadeOut();
181
  }
182
 
183
+ })(jQuery, cwp_top_ajaxload);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/class-pirateforms-util.php CHANGED
@@ -312,6 +312,12 @@ class PirateForms_Util {
312
  $tags[ $k ] = $val;
313
  }
314
 
 
 
 
 
 
 
315
  if ( isset( $pirate_forms_options['pirateformsopt_store_ip'] ) && 'yes' === $pirate_forms_options['pirateformsopt_store_ip'] ) {
316
  $tags += array(
317
  'ip' => __( 'IP address', 'pirate-forms' ),
312
  $tags[ $k ] = $val;
313
  }
314
 
315
+ if ( isset( $pirate_forms_options['pirateformsopt_save_attachment'] ) && 'yes' === $pirate_forms_options['pirateformsopt_save_attachment'] ) {
316
+ $tags += array(
317
+ 'attachments' => __( 'Attachment(s)', 'pirate-forms' ),
318
+ );
319
+ }
320
+
321
  if ( isset( $pirate_forms_options['pirateformsopt_store_ip'] ) && 'yes' === $pirate_forms_options['pirateformsopt_store_ip'] ) {
322
  $tags += array(
323
  'ip' => __( 'IP address', 'pirate-forms' ),
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.3';
73
 
74
  $this->load_dependencies();
75
  $this->set_locale();
69
  public function __construct() {
70
 
71
  $this->plugin_name = 'pirateforms';
72
+ $this->version = '2.4.4';
73
 
74
  $this->load_dependencies();
75
  $this->set_locale();
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.3
20
  * Author: Themeisle
21
  * Author URI: http://themeisle.com
22
  * Text Domain: pirate-forms
@@ -37,7 +37,7 @@ 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.3' );
41
  define( 'PIRATEFORMS_DIR', trailingslashit( plugin_dir_path( __FILE__ ) ) );
42
  define( 'PIRATEFORMS_URL', plugin_dir_url( __FILE__ ) );
43
  define( 'PIRATEFORMS_BASENAME', plugin_basename( __FILE__ ) );
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.4
20
  * Author: Themeisle
21
  * Author URI: http://themeisle.com
22
  * Text Domain: 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.4' );
41
  define( 'PIRATEFORMS_DIR', trailingslashit( plugin_dir_path( __FILE__ ) ) );
42
  define( 'PIRATEFORMS_URL', plugin_dir_url( __FILE__ ) );
43
  define( 'PIRATEFORMS_BASENAME', plugin_basename( __FILE__ ) );
public/class-pirateforms-public.php CHANGED
@@ -185,6 +185,8 @@ class PirateForms_Public {
185
  ), $atts
186
  );
187
 
 
 
188
  $form_id = isset( $atts['id'] ) && ! empty( $atts['id'] ) ? intval( $atts['id'] ) : 0;
189
  $from_widget = ! empty( $atts['from'] );
190
  $elements = array();
@@ -457,6 +459,7 @@ class PirateForms_Public {
457
  'front_end' => true,
458
  'type' => 'button',
459
  'id' => 'pirate-forms-contact-submit',
 
460
  'class' => 'pirate-forms-submit-button btn btn-primary ' . ( $ajax ? 'pirate-forms-submit-button-ajax' : '' ),
461
  'wrap' => array(
462
  'type' => 'div',
@@ -532,7 +535,7 @@ class PirateForms_Public {
532
  $this->_files = $post_files;
533
 
534
  PirateForms_Util::session_start();
535
- do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'POST data = %s', print_r( $post_params, true ) ), 'debug', __FILE__, __LINE__ );
536
 
537
  // If POST and honeypot are not set, beat it
538
  if ( empty( $post_params ) || ! isset( $post_params['honeypot'] ) ) {
@@ -688,7 +691,7 @@ class PirateForms_Public {
688
  $headers = "From: $send_from_name <$send_from>\r\nReply-To: $pirate_forms_contact_name <$pirate_forms_contact_email>\r\nContent-type: text/html";
689
  add_action( 'phpmailer_init', array( $this, 'phpmailer' ) );
690
 
691
- $attachments = $this->get_attachments( $error_key, $pirate_forms_options, $body );
692
  if ( is_bool( $attachments ) ) {
693
  return PirateForms_Util::save_error( $error_key, $new_error_key );
694
  }
@@ -712,11 +715,7 @@ class PirateForms_Public {
712
  do_action( 'pirate_forms_after_sending', $pirate_forms_options, $response, $pirate_forms_contact_email, $site_recipients, $subject, $mail_body, $headers, $attachments );
713
  do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'after sending email, response = %s', $response ), 'debug', __FILE__, __LINE__ );
714
 
715
- // delete the tmp directory
716
- require_once( ABSPATH . 'wp-admin/includes/file.php' );
717
- WP_Filesystem();
718
- global $wp_filesystem;
719
- $wp_filesystem->delete( $this->get_upload_tmp_dir(), true, 'd' );
720
 
721
  // Should a confirm email be sent?
722
  $confirm_body = stripslashes( trim( $pirate_forms_options['pirateformsopt_confirm_email'] ) );
@@ -769,6 +768,7 @@ class PirateForms_Public {
769
  if ( defined( 'PIRATEFORMS_EMAIL_ERROR' ) ) {
770
  add_post_meta( $new_post_id, PIRATEFORMS_SLUG . 'mail-status-reason', PIRATEFORMS_EMAIL_ERROR );
771
  }
 
772
  add_post_meta( $new_post_id, PIRATEFORMS_SLUG . 'confirm-mail-status', $response_confirm ? 'true' : 'false' );
773
  do_action( 'pirate_forms_update_contact', $pirate_forms_options, $new_post_id );
774
  }
@@ -937,6 +937,11 @@ class PirateForms_Public {
937
  foreach ( $fields as $field ) {
938
  $value = isset( $this->_post[ 'pirate-forms-contact-' . $field ] ) ? sanitize_text_field( trim( $this->_post[ 'pirate-forms-contact-' . $field ] ) ) : '';
939
  $body['magic_tags'] += array( $field => $value );
 
 
 
 
 
940
  if ( 'req' === $pirate_forms_options[ 'pirateformsopt_' . $field . '_field' ] && empty( $value ) ) {
941
  $_SESSION[ $error_key ][ 'pirate-forms-contact-' . $field ] = $pirate_forms_options[ 'pirateformsopt_label_err_' . $field ];
942
  } elseif ( ! empty( $value ) ) {
@@ -1022,23 +1027,24 @@ class PirateForms_Public {
1022
  *
1023
  * @param string $error_key the key for the session object.
1024
  * @param array $pirate_forms_options the array of options for the form.
 
1025
  * @param array $body the body of the mail.
1026
  *
1027
  * @throws Exception When file uploading fails.
1028
  */
1029
- private function get_attachments( $error_key, $pirate_forms_options, &$body ) {
1030
  $attachments = array();
1031
  $has_files = $pirate_forms_options['pirateformsopt_attachment_field'];
1032
  if ( ! empty( $has_files ) ) {
1033
- $uploads_dir = $this->get_upload_tmp_dir();
1034
- $uploads_dir = $this->maybe_add_random_dir( $uploads_dir );
1035
-
1036
  $_files = $this->_files;
1037
 
 
 
1038
  foreach ( $_files as $label => $file ) {
1039
  if ( empty( $file['name'] ) ) {
1040
  continue;
1041
  }
 
1042
  /* Validate file type */
1043
  $allowed = implode( '|', apply_filters( 'pirate_forms_allowed_file_types', self::$_file_types_allowed ) );
1044
  $pirate_forms_file_types_allowed = '/\.(' . trim( $allowed, '|' ) . ')$/i';
@@ -1056,47 +1062,97 @@ class PirateForms_Public {
1056
 
1057
  return false;
1058
  }
1059
- $this->init_uploads();
1060
- $filename = $file['name'];
1061
- $filename = $this->canonicalize( $filename );
1062
- $filename = sanitize_file_name( $filename );
1063
- $filename = $this->antiscript_file_name( $filename );
1064
- $filename = wp_unique_filename( $uploads_dir, $filename );
1065
- $new_file = trailingslashit( $uploads_dir ) . $filename;
1066
- try {
1067
- if ( false === move_uploaded_file( $file['tmp_name'], $new_file ) ) {
1068
- do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'unable to move the uploaded file from %s to %s', $file['tmp_name'], $new_file ), 'error', __FILE__, __LINE__ );
1069
- throw new Exception( sprintf( __( 'There was an unknown error uploading the file %s', 'pirate-forms' ), $file['name'] ) );
1070
- }
1071
- } catch ( Exception $ex ) {
1072
- do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'unable to move the uploaded file from %s to %s with error %s', $file['tmp_name'], $new_file, $ex->getMessage() ), 'error', __FILE__, __LINE__ );
1073
- $_SESSION[ $error_key ]['pirate-forms-upload-failed-general'] = $ex->getMessage();
1074
- }
1075
  if ( ! empty( $new_file ) ) {
1076
  $attachments[] = $new_file;
1077
  }
1078
  }
1079
  }
 
1080
  if ( $attachments ) {
1081
- $files = array();
1082
  foreach ( $attachments as $file ) {
1083
- $files[] = basename( $file );
1084
  }
1085
- $body['body'][ __( 'Attachment', 'pirate-forms' ) ] = implode( ',', $files );
1086
- $body['magic_tags'] += array( 'attachments' => implode( ',', $files ) );
1087
  }
1088
  do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'finally attaching attachment(s): %s', print_r( $attachments, true ) ), 'info', __FILE__, __LINE__ );
1089
 
1090
- return $attachments;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1091
  }
1092
 
1093
  /**
1094
- * Return the temporary upload dir
1095
  *
1096
  * @since 1.0.0
1097
  */
1098
- function get_upload_tmp_dir() {
1099
- return $this->get_upload_dir( 'dir' ) . '/pirate_forms_uploads';
1100
  }
1101
 
1102
  /**
@@ -1136,6 +1192,7 @@ class PirateForms_Public {
1136
  if ( wp_mkdir_p( $dir_new ) ) {
1137
  return $dir_new;
1138
  }
 
1139
 
1140
  return $dir;
1141
  }
@@ -1147,8 +1204,11 @@ class PirateForms_Public {
1147
  * @throws Exception When file could not be opened.
1148
  */
1149
  function init_uploads() {
1150
- $dir = $this->get_upload_tmp_dir();
1151
- wp_mkdir_p( $dir );
 
 
 
1152
  $htaccess_file = trailingslashit( $dir ) . '.htaccess';
1153
  if ( file_exists( $htaccess_file ) ) {
1154
  return;
@@ -1282,6 +1342,9 @@ class PirateForms_Public {
1282
 
1283
  if ( $theme ) {
1284
  foreach ( $elements as $k => $element ) {
 
 
 
1285
  $id = str_replace( 'pirate-forms-contact-', '', $element['id'] );
1286
  if ( method_exists( $this, "{$theme}_customization_wrap" ) ) {
1287
  add_filter( "pirateform_wrap_classes_{$id}", array( $this, "{$theme}_customization_wrap" ), 10, 3 );
@@ -1304,24 +1367,22 @@ class PirateForms_Public {
1304
  *
1305
  * @return string The classes to apply.
1306
  */
1307
- public function zerif_customization_field( $classes, $name, $type ) {
1308
- switch ( $type ) {
1309
- case 'text':
1310
- // fall-through.
1311
- case 'tel':
1312
- // fall-through.
1313
- case 'number':
1314
- // fall-through.
1315
- case 'textarea':
1316
- $classes = 'form-control input';
1317
- break;
1318
- case 'button':
1319
- $classes = 'btn btn-primary custom-button red-btn pirate-forms-submit-button';
1320
- break;
1321
- }
1322
-
1323
- switch ( $name ) {
1324
- // empty.
1325
  }
1326
 
1327
  return $classes;
@@ -1336,24 +1397,28 @@ class PirateForms_Public {
1336
  *
1337
  * @return array The classes to apply.
1338
  */
1339
- public function zerif_customization_wrap( $classes, $name, $type ) {
1340
- switch ( $type ) {
1341
- case 'checkbox':
1342
- $classes[] = 'pirate_forms_three_inputs_wrap';
1343
- break;
1344
- }
1345
-
1346
- switch ( $name ) {
1347
- case 'name':
1348
- // fall-through.
1349
- case 'email':
1350
- // fall-through.
1351
- case 'subject':
1352
- $classes = array( 'col-lg-4 col-sm-4 form_field_wrap' );
1353
- break;
1354
- case 'message':
1355
- $classes = array( 'col-lg-12 col-sm-12 form_field_wrap' );
1356
- break;
 
 
 
 
1357
  }
1358
  return $classes;
1359
  }
@@ -1411,4 +1476,33 @@ class PirateForms_Public {
1411
  do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'thankyou message: %s', $message ), 'debug', __FILE__, __LINE__ );
1412
  return new WP_REST_Response( array( 'message' => $message ), 200 );
1413
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1414
  }
185
  ), $atts
186
  );
187
 
188
+ do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'displaying shortcode %s', print_r( $atts, true ) ), 'debug', __FILE__, __LINE__ );
189
+
190
  $form_id = isset( $atts['id'] ) && ! empty( $atts['id'] ) ? intval( $atts['id'] ) : 0;
191
  $from_widget = ! empty( $atts['from'] );
192
  $elements = array();
459
  'front_end' => true,
460
  'type' => 'button',
461
  'id' => 'pirate-forms-contact-submit',
462
+ 'name' => 'pirate-forms-contact-submit',
463
  'class' => 'pirate-forms-submit-button btn btn-primary ' . ( $ajax ? 'pirate-forms-submit-button-ajax' : '' ),
464
  'wrap' => array(
465
  'type' => 'div',
535
  $this->_files = $post_files;
536
 
537
  PirateForms_Util::session_start();
538
+ do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'POST data, FILE data = %s, %s', print_r( $post_params, true ), print_r( $post_files, true ) ), 'debug', __FILE__, __LINE__ );
539
 
540
  // If POST and honeypot are not set, beat it
541
  if ( empty( $post_params ) || ! isset( $post_params['honeypot'] ) ) {
691
  $headers = "From: $send_from_name <$send_from>\r\nReply-To: $pirate_forms_contact_name <$pirate_forms_contact_email>\r\nContent-type: text/html";
692
  add_action( 'phpmailer_init', array( $this, 'phpmailer' ) );
693
 
694
+ list( $attachments, $attachments_relative ) = $this->get_attachments( $error_key, $pirate_forms_options, $form_id, $body );
695
  if ( is_bool( $attachments ) ) {
696
  return PirateForms_Util::save_error( $error_key, $new_error_key );
697
  }
715
  do_action( 'pirate_forms_after_sending', $pirate_forms_options, $response, $pirate_forms_contact_email, $site_recipients, $subject, $mail_body, $headers, $attachments );
716
  do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'after sending email, response = %s', $response ), 'debug', __FILE__, __LINE__ );
717
 
718
+ $this->delete_tmp_dir();
 
 
 
 
719
 
720
  // Should a confirm email be sent?
721
  $confirm_body = stripslashes( trim( $pirate_forms_options['pirateformsopt_confirm_email'] ) );
768
  if ( defined( 'PIRATEFORMS_EMAIL_ERROR' ) ) {
769
  add_post_meta( $new_post_id, PIRATEFORMS_SLUG . 'mail-status-reason', PIRATEFORMS_EMAIL_ERROR );
770
  }
771
+ add_post_meta( $new_post_id, PIRATEFORMS_SLUG . 'attachments', $attachments_relative );
772
  add_post_meta( $new_post_id, PIRATEFORMS_SLUG . 'confirm-mail-status', $response_confirm ? 'true' : 'false' );
773
  do_action( 'pirate_forms_update_contact', $pirate_forms_options, $new_post_id );
774
  }
937
  foreach ( $fields as $field ) {
938
  $value = isset( $this->_post[ 'pirate-forms-contact-' . $field ] ) ? sanitize_text_field( trim( $this->_post[ 'pirate-forms-contact-' . $field ] ) ) : '';
939
  $body['magic_tags'] += array( $field => $value );
940
+
941
+ if ( ! array_key_exists( 'pirateformsopt_' . $field . '_field', $pirate_forms_options ) ) {
942
+ continue;
943
+ }
944
+
945
  if ( 'req' === $pirate_forms_options[ 'pirateformsopt_' . $field . '_field' ] && empty( $value ) ) {
946
  $_SESSION[ $error_key ][ 'pirate-forms-contact-' . $field ] = $pirate_forms_options[ 'pirateformsopt_label_err_' . $field ];
947
  } elseif ( ! empty( $value ) ) {
1027
  *
1028
  * @param string $error_key the key for the session object.
1029
  * @param array $pirate_forms_options the array of options for the form.
1030
+ * @param int $form_id the form id.
1031
  * @param array $body the body of the mail.
1032
  *
1033
  * @throws Exception When file uploading fails.
1034
  */
1035
+ private function get_attachments( $error_key, $pirate_forms_options, $form_id, &$body ) {
1036
  $attachments = array();
1037
  $has_files = $pirate_forms_options['pirateformsopt_attachment_field'];
1038
  if ( ! empty( $has_files ) ) {
 
 
 
1039
  $_files = $this->_files;
1040
 
1041
+ do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'got %d files', count( $_files ) ), 'debug', __FILE__, __LINE__ );
1042
+
1043
  foreach ( $_files as $label => $file ) {
1044
  if ( empty( $file['name'] ) ) {
1045
  continue;
1046
  }
1047
+ do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'processing %s file', $file['name'] ), 'debug', __FILE__, __LINE__ );
1048
  /* Validate file type */
1049
  $allowed = implode( '|', apply_filters( 'pirate_forms_allowed_file_types', self::$_file_types_allowed ) );
1050
  $pirate_forms_file_types_allowed = '/\.(' . trim( $allowed, '|' ) . ')$/i';
1062
 
1063
  return false;
1064
  }
1065
+ $new_file = $this->download_file( $error_key, $pirate_forms_options, $form_id, $file );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1066
  if ( ! empty( $new_file ) ) {
1067
  $attachments[] = $new_file;
1068
  }
1069
  }
1070
  }
1071
+ $attachment_relative = array();
1072
  if ( $attachments ) {
 
1073
  foreach ( $attachments as $file ) {
1074
+ $attachment_relative[] = _wp_relative_upload_path( $file );
1075
  }
1076
+ $body['body'][ __( 'Attachment', 'pirate-forms' ) ] = implode( ',', $attachment_relative );
1077
+ $body['magic_tags'] += array( 'attachments' => $this->get_attachment_links( $attachment_relative ) );
1078
  }
1079
  do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'finally attaching attachment(s): %s', print_r( $attachments, true ) ), 'info', __FILE__, __LINE__ );
1080
 
1081
+ return array( $attachments, $attachment_relative );
1082
+ }
1083
+
1084
+ /**
1085
+ * Show the links to download the attachment.
1086
+ */
1087
+ private function get_attachment_links( $files ) {
1088
+ $urls = array();
1089
+ foreach ( $files as $file ) {
1090
+ $path = $this->get_upload_dir( 'dir' ) . "/$file";
1091
+ $url = $this->get_upload_dir( 'url' ) . "/$file";
1092
+ $urls[] = "<a href='$url'>" . basename( $path ) . '</a>';
1093
+ }
1094
+ return implode( ',', $urls );
1095
+ }
1096
+
1097
+ /**
1098
+ * Download the attachment.
1099
+ *
1100
+ * @throws Exception When file could not be moved.
1101
+ */
1102
+ private function download_file( $error_key, $pirate_forms_options, $form_id, $file ) {
1103
+ $uploads_dir = $this->get_upload_dir_with_folder( 'tmp' );
1104
+ $uploads_dir = $this->maybe_add_random_dir( $uploads_dir );
1105
+ $save_file = array_key_exists( 'pirateformsopt_save_attachment', $pirate_forms_options ) && ! empty( $pirate_forms_options['pirateformsopt_save_attachment'] );
1106
+ do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'saving file = *%s*', $save_file ), 'debug', __FILE__, __LINE__ );
1107
+ if ( $save_file ) {
1108
+ // change uploads directory to /saved instead of /tmp.
1109
+ $dir_new = $this->get_upload_dir_with_folder( "saved/$form_id" );
1110
+ if ( ! wp_mkdir_p( $dir_new ) ) {
1111
+ do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'unable to create directory %s; saving in %s', $dir_new, $uploads_dir ), 'error', __FILE__, __LINE__ );
1112
+ } else {
1113
+ $save_dir = $this->maybe_add_random_dir( $dir_new );
1114
+ $uploads_dir = $save_dir;
1115
+ do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'saving file in %s', $uploads_dir ), 'debug', __FILE__, __LINE__ );
1116
+ }
1117
+ }
1118
+
1119
+ $this->init_uploads();
1120
+ $filename = $file['name'];
1121
+ $filename = $this->canonicalize( $filename );
1122
+ $filename = sanitize_file_name( $filename );
1123
+ $filename = $this->antiscript_file_name( $filename );
1124
+ $filename = wp_unique_filename( $uploads_dir, $filename );
1125
+ $new_file = trailingslashit( $uploads_dir ) . $filename;
1126
+ try {
1127
+ if ( false === move_uploaded_file( $file['tmp_name'], $new_file ) ) {
1128
+ do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'unable to move the uploaded file from %s to %s', $file['tmp_name'], $new_file ), 'error', __FILE__, __LINE__ );
1129
+ throw new Exception( sprintf( __( 'There was an unknown error uploading the file %s', 'pirate-forms' ), $file['name'] ) );
1130
+ }
1131
+ } catch ( Exception $ex ) {
1132
+ do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'unable to move the uploaded file from %s to %s with error %s', $file['tmp_name'], $new_file, $ex->getMessage() ), 'error', __FILE__, __LINE__ );
1133
+ $_SESSION[ $error_key ]['pirate-forms-upload-failed-general'] = $ex->getMessage();
1134
+ }
1135
+ return $new_file;
1136
+ }
1137
+
1138
+ /**
1139
+ * Delete the temporary upload dir
1140
+ */
1141
+ private function delete_tmp_dir() {
1142
+ // delete the tmp directory
1143
+ require_once( ABSPATH . 'wp-admin/includes/file.php' );
1144
+ WP_Filesystem();
1145
+ global $wp_filesystem;
1146
+ $wp_filesystem->delete( $this->get_upload_dir_with_folder( 'tmp' ), true, 'd' );
1147
  }
1148
 
1149
  /**
1150
+ * Return the temporary/permanent upload dir
1151
  *
1152
  * @since 1.0.0
1153
  */
1154
+ function get_upload_dir_with_folder( $folder ) {
1155
+ return $this->get_upload_dir( 'dir' ) . "/pirate-forms/$folder";
1156
  }
1157
 
1158
  /**
1192
  if ( wp_mkdir_p( $dir_new ) ) {
1193
  return $dir_new;
1194
  }
1195
+ do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'unable to create random tmp directory %s', $dir_new ), 'error', __FILE__, __LINE__ );
1196
 
1197
  return $dir;
1198
  }
1204
  * @throws Exception When file could not be opened.
1205
  */
1206
  function init_uploads() {
1207
+ $dir = $this->get_upload_dir_with_folder( 'tmp' );
1208
+ if ( ! wp_mkdir_p( $dir ) ) {
1209
+ do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'unable to create parent directories of %s', $dir ), 'error', __FILE__, __LINE__ );
1210
+ }
1211
+
1212
  $htaccess_file = trailingslashit( $dir ) . '.htaccess';
1213
  if ( file_exists( $htaccess_file ) ) {
1214
  return;
1342
 
1343
  if ( $theme ) {
1344
  foreach ( $elements as $k => $element ) {
1345
+ if ( 'hidden' === $element['type'] ) {
1346
+ continue;
1347
+ }
1348
  $id = str_replace( 'pirate-forms-contact-', '', $element['id'] );
1349
  if ( method_exists( $this, "{$theme}_customization_wrap" ) ) {
1350
  add_filter( "pirateform_wrap_classes_{$id}", array( $this, "{$theme}_customization_wrap" ), 10, 3 );
1367
  *
1368
  * @return string The classes to apply.
1369
  */
1370
+ public function zerif_customization_field( $classes, $name = null, $type = null ) {
1371
+ if ( $type ) {
1372
+ switch ( $type ) {
1373
+ case 'text':
1374
+ // fall-through.
1375
+ case 'tel':
1376
+ // fall-through.
1377
+ case 'number':
1378
+ // fall-through.
1379
+ case 'textarea':
1380
+ $classes = 'form-control input';
1381
+ break;
1382
+ case 'button':
1383
+ $classes = 'btn btn-primary custom-button red-btn pirate-forms-submit-button';
1384
+ break;
1385
+ }
 
 
1386
  }
1387
 
1388
  return $classes;
1397
  *
1398
  * @return array The classes to apply.
1399
  */
1400
+ public function zerif_customization_wrap( $classes, $name = null, $type = null ) {
1401
+ if ( $type ) {
1402
+ switch ( $type ) {
1403
+ case 'checkbox':
1404
+ $classes[] = 'pirate_forms_three_inputs_wrap';
1405
+ break;
1406
+ }
1407
+ }
1408
+
1409
+ if ( $name ) {
1410
+ switch ( $name ) {
1411
+ case 'name':
1412
+ // fall-through.
1413
+ case 'email':
1414
+ // fall-through.
1415
+ case 'subject':
1416
+ $classes = array( 'col-lg-4 col-sm-4 form_field_wrap' );
1417
+ break;
1418
+ case 'message':
1419
+ $classes = array( 'col-lg-12 col-sm-12 form_field_wrap' );
1420
+ break;
1421
+ }
1422
  }
1423
  return $classes;
1424
  }
1476
  do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'thankyou message: %s', $message ), 'debug', __FILE__, __LINE__ );
1477
  return new WP_REST_Response( array( 'message' => $message ), 200 );
1478
  }
1479
+
1480
+ /**
1481
+ * Displays the thank you message relevant to the form
1482
+ *
1483
+ * @param string $text The message.
1484
+ */
1485
+ private function display_thankyou( $text ) {
1486
+ return apply_filters( 'pirate_forms_thankyou', sprintf( '<div class="col-xs-12 pirate_forms_thankyou_wrap"><p>%s</p></div>', $text ), $text );
1487
+ }
1488
+
1489
+ /**
1490
+ * Displays all the errors relevant to the form
1491
+ *
1492
+ * @param Array $errors The error messages.
1493
+ */
1494
+ private function display_errors( $errors ) {
1495
+ $output = '';
1496
+ if ( ! empty( $errors ) ) {
1497
+ $output .= '<div class="col-xs-12 pirate_forms_error_box">';
1498
+ $output .= '<p>' . __( 'Sorry, an error occured.', 'pirate-forms' ) . '</p>';
1499
+ $output .= '</div>';
1500
+ foreach ( $errors as $err ) {
1501
+ $output .= '<div class="col-xs-12 pirate_forms_error_box">';
1502
+ $output .= "<p>$err</p>";
1503
+ $output .= '</div>';
1504
+ }
1505
+ }
1506
+ return apply_filters( 'pirate_forms_errors', $output, $errors );
1507
+ }
1508
  }
public/css/front.css CHANGED
@@ -1,5 +1,5 @@
1
  /*
2
- Version: 2.4.3
3
  */
4
  .pirate_forms_wrap .form_field_wrap,
5
  .widget .pirate_forms_wrap .form_field_wrap {
@@ -127,4 +127,12 @@ Version: 2.4.3
127
  .pirate_forms_wrap .pirate-forms-footer .form_captcha_wrap {
128
  margin-bottom: 20px;
129
  }
 
 
 
 
 
 
 
 
130
  }
1
  /*
2
+ Version: 2.4.4
3
  */
4
  .pirate_forms_wrap .form_field_wrap,
5
  .widget .pirate_forms_wrap .form_field_wrap {
127
  .pirate_forms_wrap .pirate-forms-footer .form_captcha_wrap {
128
  margin-bottom: 20px;
129
  }
130
+
131
+ .pirate_forms_wrap .form_captcha_wrap {
132
+ padding: 0;
133
+ }
134
+ .pirate_forms_wrap .form_captcha_wrap > div > div {
135
+ transform: scale(0.8);
136
+ overflow: visible;
137
+ }
138
  }
public/partials/fields/button.php CHANGED
@@ -23,5 +23,5 @@ if ( is_null( $wrap_classes ) ) {
23
  ?>
24
 
25
  <div class="<?php echo implode( ' ', apply_filters( "pirateform_wrap_classes_{$name}", $wrap_classes, $name, $args['type'] ) ); ?>">
26
- <button type="submit" class="<?php echo apply_filters( "pirateform_field_classes_{$name}", 'pirate-forms-submit-button btn btn-primary', $name, $args['type'] ); ?>" <?php echo $this->get_common( $args ); ?>><?php echo isset( $args['value'] ) ? $args['value'] : ''; ?></button>
27
  </div>
23
  ?>
24
 
25
  <div class="<?php echo implode( ' ', apply_filters( "pirateform_wrap_classes_{$name}", $wrap_classes, $name, $args['type'] ) ); ?>">
26
+ <button type="submit" class="<?php echo apply_filters( "pirateform_field_classes_{$name}", $args['class'], $name, $args['type'] ); ?>" <?php echo $this->get_common( $args ); ?>><?php echo isset( $args['value'] ) ? $args['value'] : ''; ?></button>
27
  </div>
public/partials/fields/file.php CHANGED
@@ -21,8 +21,8 @@ if ( is_null( $wrap_classes ) ) {
21
 
22
  // since the file field is going to be non-focussable, let's put the required attributes (if available) on the text field
23
  $text_args = array(
24
- 'id' => '',
25
- 'name' => '',
26
  'class' => 'pirate-forms-file-upload-input',
27
  );
28
  if ( isset( $args['required'] ) && $args['required'] && isset( $args['required_msg'] ) ) {
21
 
22
  // since the file field is going to be non-focussable, let's put the required attributes (if available) on the text field
23
  $text_args = array(
24
+ 'id' => $args['id'],
25
+ 'name' => $args['name'],
26
  'class' => 'pirate-forms-file-upload-input',
27
  );
28
  if ( isset( $args['required'] ) && $args['required'] && isset( $args['required_msg'] ) ) {
public/partials/pirateforms-form.php CHANGED
@@ -63,22 +63,22 @@
63
  ?>
64
 
65
  <!-- form -->
66
- <?php
67
- $enctype = 'application/x-www-form-urlencoded';
68
- $pirateformsopt_attachment_field = $this->pirate_forms_options['pirateformsopt_attachment_field'];
69
- if ( ! empty( $pirateformsopt_attachment_field ) ) {
70
- $pirate_forms_enctype = 'multipart/form-data';
71
- }
72
-
73
- $attributes = '';
74
- if ( $this->form_attributes ) {
75
- foreach ( $this->form_attributes as $k => $v ) {
76
- $attributes .= " $k=$v";
77
- }
78
  }
 
79
 
80
- do_action( 'pirate_forms_before_form', $this );
81
- ?>
82
 
83
  <form
84
  method="post"
@@ -133,9 +133,13 @@
133
  echo $this->captcha;
134
  }
135
 
136
- echo $this->contact_submit;
 
 
137
 
138
- echo $this->form_hidden;
 
 
139
  ?>
140
  </form>
141
 
63
  ?>
64
 
65
  <!-- form -->
66
+ <?php
67
+ $enctype = 'application/x-www-form-urlencoded';
68
+ $pirateformsopt_attachment_field = $this->pirate_forms_options['pirateformsopt_attachment_field'];
69
+ if ( ! empty( $pirateformsopt_attachment_field ) ) {
70
+ $enctype = 'multipart/form-data';
71
+ }
72
+
73
+ $attributes = '';
74
+ if ( $this->form_attributes ) {
75
+ foreach ( $this->form_attributes as $k => $v ) {
76
+ $attributes .= " $k=$v";
 
77
  }
78
+ }
79
 
80
+ do_action( 'pirate_forms_before_form', $this );
81
+ ?>
82
 
83
  <form
84
  method="post"
133
  echo $this->captcha;
134
  }
135
 
136
+ if ( isset( $this->contact_submit ) ) {
137
+ echo $this->contact_submit;
138
+ }
139
 
140
+ if ( isset( $this->form_hidden ) ) {
141
+ echo $this->form_hidden;
142
+ }
143
  ?>
144
  </form>
145
 
readme.md CHANGED
@@ -293,6 +293,14 @@ Activating the Pirate Contact Form plugin is just like any other plugin. If you'
293
  4. Screenshot 4. Enabling SMTP
294
 
295
  ## Changelog ##
 
 
 
 
 
 
 
 
296
  ### 2.4.3 - 2018-06-25 ###
297
 
298
  * New Gutenberg block for the default Pirate Forms form
293
  4. Screenshot 4. Enabling SMTP
294
 
295
  ## Changelog ##
296
+ ### 2.4.4 - 2018-07-13 ###
297
+
298
+ * Fixed compatibility with All in One SEO Pack plugin
299
+ * Fixed problem with form not working with the ajax option
300
+ * Option to save the attachments files
301
+ * Improved recaptcha button layout on mobile devices
302
+
303
+
304
  ### 2.4.3 - 2018-06-25 ###
305
 
306
  * New Gutenberg block for the default Pirate Forms form
readme.txt CHANGED
@@ -293,6 +293,14 @@ Activating the Pirate Contact Form plugin is just like any other plugin. If you'
293
  4. Screenshot 4. Enabling SMTP
294
 
295
  == Changelog ==
 
 
 
 
 
 
 
 
296
  = 2.4.3 - 2018-06-25 =
297
 
298
  * New Gutenberg block for the default Pirate Forms form
293
  4. Screenshot 4. Enabling SMTP
294
 
295
  == Changelog ==
296
+ = 2.4.4 - 2018-07-13 =
297
+
298
+ * Fixed compatibility with All in One SEO Pack plugin
299
+ * Fixed problem with form not working with the ajax option
300
+ * Option to save the attachments files
301
+ * Improved recaptcha button layout on mobile devices
302
+
303
+
304
  = 2.4.3 - 2018-06-25 =
305
 
306
  * New Gutenberg block for the default Pirate Forms form
themeisle-hash.json CHANGED
@@ -1 +1 @@
1
- {"index.php":"39ab8276fb0e4bd3fcab3270822c5977","pirate-forms.php":"f8f896d38c607a6743ce06eb22a9aa24","uninstall.php":"9d936442a63521d971a6dbc28df9c0d1","webpack.config.js":"95da658b3e96a29d1f837e36d68a71bf"}
1
+ {"index.php":"39ab8276fb0e4bd3fcab3270822c5977","pirate-forms.php":"7b32706544874dc931999dca3a942c10","uninstall.php":"9d936442a63521d971a6dbc28df9c0d1","webpack.config.js":"95da658b3e96a29d1f837e36d68a71bf"}
vendor/autoload.php CHANGED
@@ -4,4 +4,4 @@
4
 
5
  require_once __DIR__ . '/composer' . '/autoload_real.php';
6
 
7
- return ComposerAutoloaderInit240b6f950288dbf75d1fb8b7a6f2ca07::getLoader();
4
 
5
  require_once __DIR__ . '/composer' . '/autoload_real.php';
6
 
7
+ return ComposerAutoloaderInit4641a8dca4f5ade2af2306ad0b9d4ed1::getLoader();
vendor/autoload_52.php CHANGED
@@ -4,4 +4,4 @@
4
 
5
  require_once dirname(__FILE__) . '/composer'.'/autoload_real_52.php';
6
 
7
- return ComposerAutoloaderInit028d09be7fdf06394e0c906d9652646a::getLoader();
4
 
5
  require_once dirname(__FILE__) . '/composer'.'/autoload_real_52.php';
6
 
7
+ return ComposerAutoloaderInit99c51ebeebaae382b8671d26a57fcbf1::getLoader();
vendor/codeinwp/themeisle-sdk/class-themeisle-sdk-licenser.php CHANGED
@@ -579,6 +579,9 @@ if ( ! class_exists( 'ThemeIsle_SDK_Licenser' ) ) :
579
  set_transient( $this->product_key, $update_data, strtotime( '+12 hours' ) );
580
  }
581
  }
 
 
 
582
  if ( version_compare( $this->product->get_version(), $update_data->new_version, '>=' ) ) {
583
  return false;
584
  }
579
  set_transient( $this->product_key, $update_data, strtotime( '+12 hours' ) );
580
  }
581
  }
582
+ if ( ! isset( $update_data->new_version ) ) {
583
+ return false;
584
+ }
585
  if ( version_compare( $this->product->get_version(), $update_data->new_version, '>=' ) ) {
586
  return false;
587
  }
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.5';
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.6';
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 ComposerAutoloaderInit240b6f950288dbf75d1fb8b7a6f2ca07
6
  {
7
  private static $loader;
8
 
@@ -19,9 +19,9 @@ class ComposerAutoloaderInit240b6f950288dbf75d1fb8b7a6f2ca07
19
  return self::$loader;
20
  }
21
 
22
- spl_autoload_register(array('ComposerAutoloaderInit240b6f950288dbf75d1fb8b7a6f2ca07', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
- spl_autoload_unregister(array('ComposerAutoloaderInit240b6f950288dbf75d1fb8b7a6f2ca07', 'loadClassLoader'));
25
 
26
  $map = require __DIR__ . '/autoload_namespaces.php';
27
  foreach ($map as $namespace => $path) {
@@ -42,14 +42,14 @@ class ComposerAutoloaderInit240b6f950288dbf75d1fb8b7a6f2ca07
42
 
43
  $includeFiles = require __DIR__ . '/autoload_files.php';
44
  foreach ($includeFiles as $fileIdentifier => $file) {
45
- composerRequire240b6f950288dbf75d1fb8b7a6f2ca07($fileIdentifier, $file);
46
  }
47
 
48
  return $loader;
49
  }
50
  }
51
 
52
- function composerRequire240b6f950288dbf75d1fb8b7a6f2ca07($fileIdentifier, $file)
53
  {
54
  if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
55
  require $file;
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
+ class ComposerAutoloaderInit4641a8dca4f5ade2af2306ad0b9d4ed1
6
  {
7
  private static $loader;
8
 
19
  return self::$loader;
20
  }
21
 
22
+ spl_autoload_register(array('ComposerAutoloaderInit4641a8dca4f5ade2af2306ad0b9d4ed1', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInit4641a8dca4f5ade2af2306ad0b9d4ed1', '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
+ composerRequire4641a8dca4f5ade2af2306ad0b9d4ed1($fileIdentifier, $file);
46
  }
47
 
48
  return $loader;
49
  }
50
  }
51
 
52
+ function composerRequire4641a8dca4f5ade2af2306ad0b9d4ed1($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 ComposerAutoloaderInit028d09be7fdf06394e0c906d9652646a {
6
  private static $loader;
7
 
8
  public static function loadClassLoader($class) {
@@ -19,9 +19,9 @@ class ComposerAutoloaderInit028d09be7fdf06394e0c906d9652646a {
19
  return self::$loader;
20
  }
21
 
22
- spl_autoload_register(array('ComposerAutoloaderInit028d09be7fdf06394e0c906d9652646a', 'loadClassLoader'), true /*, true */);
23
  self::$loader = $loader = new xrstf_Composer52_ClassLoader();
24
- spl_autoload_unregister(array('ComposerAutoloaderInit028d09be7fdf06394e0c906d9652646a', 'loadClassLoader'));
25
 
26
  $vendorDir = dirname(dirname(__FILE__));
27
  $baseDir = dirname($vendorDir);
2
 
3
  // autoload_real_52.php generated by xrstf/composer-php52
4
 
5
+ class ComposerAutoloaderInit99c51ebeebaae382b8671d26a57fcbf1 {
6
  private static $loader;
7
 
8
  public static function loadClassLoader($class) {
19
  return self::$loader;
20
  }
21
 
22
+ spl_autoload_register(array('ComposerAutoloaderInit99c51ebeebaae382b8671d26a57fcbf1', 'loadClassLoader'), true /*, true */);
23
  self::$loader = $loader = new xrstf_Composer52_ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInit99c51ebeebaae382b8671d26a57fcbf1', '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": "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": {
6
  "source": {
7
  "type": "git",
8
  "url": "https://github.com/Codeinwp/themeisle-sdk.git",
9
+ "reference": "56c6a769b08f0559e5085937e40409fb04b7a166"
10
  },
11
  "dist": {
12
  "type": "zip",
13
+ "url": "https://api.github.com/repos/Codeinwp/themeisle-sdk/zipball/56c6a769b08f0559e5085937e40409fb04b7a166",
14
+ "reference": "56c6a769b08f0559e5085937e40409fb04b7a166",
15
  "shasum": ""
16
  },
17
+ "time": "2018-06-28 13:22:23",
18
  "type": "library",
19
  "installation-source": "dist",
20
  "autoload": {