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

Version Description

  • 2018-06-25
Download this release

Release Info

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

Code changes from version 2.4.2 to 2.4.3

CHANGELOG.md CHANGED
@@ -1,4 +1,11 @@
1
 
 
 
 
 
 
 
 
2
  ### v2.4.2 - 2018-06-07
3
  **Changes:**
4
  * NEW support for submitting Ajax forms with [pirate_forms ajax="yes"]
1
 
2
+ ### v2.4.3 - 2018-06-25
3
+ **Changes:**
4
+ * New Gutenberg block for the default Pirate Forms form
5
+ * Made the checkbox field to store in the database for GDPR compliance
6
+ * New option to disable tracking of the IP for GDPR compliance
7
+ * Replaced subscription form with Sendinblue form
8
+
9
  ### v2.4.2 - 2018-06-07
10
  **Changes:**
11
  * NEW support for submitting Ajax forms with [pirate_forms ajax="yes"]
admin/class-pirateforms-admin.php CHANGED
@@ -319,6 +319,26 @@ class PirateForms_Admin {
319
  'options' => array( 'yes' => __( 'Yes', 'pirate-forms' ) ),
320
  'title' => __( 'According to GDPR, we recommend you to ask for consent in order to store user data.', 'pirate-forms' ),
321
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
322
  array(
323
  'id' => 'pirateformsopt_nonce',
324
  'type' => 'checkbox',
@@ -678,7 +698,7 @@ class PirateForms_Admin {
678
  'type' => 'wysiwyg',
679
  'label' => array(
680
  'value' => __( 'Email content', 'pirate-forms' ),
681
- 'html' => '<br/><br/>' . esc_attr( __( 'You can use the next magic tags:', 'pirate-forms' ) ) . '<br/>' . PirateForms_Util::get_magic_tags(),
682
  ),
683
  'default' => PirateForms_Util::get_default_email_content( true, null, true ),
684
  'value' => PirateForms_Util::get_option( 'pirateformsopt_email_content' ),
319
  'options' => array( 'yes' => __( 'Yes', 'pirate-forms' ) ),
320
  'title' => __( 'According to GDPR, we recommend you to ask for consent in order to store user data.', 'pirate-forms' ),
321
  ),
322
+ array(
323
+ 'id' => 'pirateformsopt_store_ip',
324
+ 'type' => 'checkbox',
325
+ 'label' => array(
326
+ 'value' => __( 'Track and store IP of user', 'pirate-forms' ),
327
+ 'html' => '<span class="dashicons dashicons-editor-help"></span>',
328
+ 'desc' => array(
329
+ 'value' => sprintf( '%s<br>%s<br>%s', __( 'Should the IP of the customer be tracked, stored and displayed in the email content?', 'pirate-forms' ), __( 'According to GDPR we recommend you to ask for consent in order to store user data', 'pirate-forms' ), __( 'If this option is not selected, we may not be able to determine whether this is a spam message.', 'pirate-forms' ) ),
330
+ 'class' => 'pirate_forms_option_description',
331
+ ),
332
+ ),
333
+ 'default' => 'no',
334
+ 'value' => PirateForms_Util::get_option( 'pirateformsopt_store_ip' ),
335
+ 'wrap' => array(
336
+ 'type' => 'div',
337
+ 'class' => 'pirate-forms-grouped',
338
+ ),
339
+ 'options' => array( 'yes' => __( 'Yes', 'pirate-forms' ) ),
340
+ 'title' => __( 'According to GDPR, we recommend you to ask for consent in order to store user data.', 'pirate-forms' ),
341
+ ),
342
  array(
343
  'id' => 'pirateformsopt_nonce',
344
  'type' => 'checkbox',
698
  'type' => 'wysiwyg',
699
  'label' => array(
700
  'value' => __( 'Email content', 'pirate-forms' ),
701
+ 'html' => '<br/><br/>' . esc_attr( __( 'You can use the following magic tags:', 'pirate-forms' ) ) . '<br/>' . PirateForms_Util::get_magic_tags(),
702
  ),
703
  'default' => PirateForms_Util::get_default_email_content( true, null, true ),
704
  'value' => PirateForms_Util::get_option( 'pirateformsopt_email_content' ),
admin/css/wp-admin.css CHANGED
@@ -339,3 +339,6 @@ input#save.pirate-forms-save-button {
339
  color: #fff;
340
  background: #333;
341
  }
 
 
 
339
  color: #fff;
340
  background: #333;
341
  }
342
+ #sib_embed_signup .message_area {
343
+ padding: 8px;
344
+ }
admin/js/scripts-admin.js CHANGED
@@ -56,9 +56,11 @@ function initAll(){
56
  },
57
  error: function (MLHttpRequest, textStatus, errorThrown) {
58
  console.log('There was an error: ' + errorThrown);
 
 
 
59
  }
60
  });
61
- endAjaxIntro();
62
  return false;
63
  }
64
 
@@ -86,10 +88,12 @@ function initAll(){
86
  },
87
  error: function (MLHttpRequest, textStatus, errorThrown) {
88
  console.log('There was an error: ' + errorThrown);
 
 
 
89
  }
90
  });
91
-
92
- endAjaxIntro();
93
  return false;
94
  }
95
 
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
 
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
 
admin/partials/pirateforms-settings-sidebar-subscribe.php CHANGED
@@ -22,37 +22,7 @@ if ( ! defined( 'PIRATEFORMSPRO_BASEFILE' ) ) :
22
  endif;
23
  ?>
24
  <div class="pirate-subscribe postbox card">
25
- <h3 class="title"><?php esc_html_e( 'Get Our Free Email Course', 'pirate-forms' ); ?></h3>
26
- <div class="pirate-forms-subscribe-content">
27
- <?php
28
- if ( ! empty( $_POST['pirate_forms_mail'] ) ) {
29
- if ( ! class_exists( 'Mailin' ) ) {
30
- require_once PIRATEFORMS_DIR . 'vendor/mailin-api/mailin-api-php/V2.0/Mailin.php';
31
- }
32
- $user_info = get_userdata( 1 );
33
- $mailin = new Mailin( 'https://api.sendinblue.com/v2.0', 'cHW5sxZnzE7mhaYb' );
34
- $data = array(
35
- 'email' => $_POST['pirate_forms_mail'],
36
- 'attributes' => array(
37
- 'NAME' => $user_info->first_name,
38
- 'SURNAME' => $user_info->last_name,
39
- ),
40
- 'blacklisted' => 0,
41
- 'listid' => array( 51 ),
42
- 'blacklisted_sms' => 0,
43
- );
44
- $status = $mailin->create_update_user( $data );
45
- if ( $status['code'] == 'success' ) {
46
- update_option( 'pirate_forms_subscribe', true );
47
- }
48
- }
49
- $was_submited = get_option( 'pirate_forms_subscribe', false );
50
- if ( $was_submited == false ) {
51
- echo sprintf( '<p> %s </p><form class="pirate-forms-submit-mail" method="post"><input name="pirate_forms_mail" type="email" value="' . get_option( 'admin_email' ) . '" /><input class="button" type="submit" value="Submit"></form>', esc_html__( 'Ready to learn how to reduce your website loading times by half? Come and join the 1st lesson here!', 'pirate-forms' ) );
52
- } else {
53
- echo sprintf( '<p> %s </p>', esc_html__( 'Thank you for subscribing! You have been added to the mailing list and will receive the next email information in the coming weeks. If you ever wish to unsubscribe, simply use the "Unsubscribe" link included in each newsletter.', 'pirate-forms' ) );
54
- }
55
- ?>
56
  </div>
57
  </div>
58
 
22
  endif;
23
  ?>
24
  <div class="pirate-subscribe postbox card">
25
+ <!-- SendinBlue Signup Form HTML Code --><link rel="stylesheet" href="https://my.sendinblue.com/public/theme/version4/assets/styles/style.css" /> <div id="sib_embed_signup"> <div class="forms-builder-wrapper" style="position:relative;margin-left: auto;margin-right: auto;"> <input type="hidden" id="sib_embed_signup_lang" value="en"> <input type="hidden" id="sib_embed_invalid_email_message" value="That email address is not valid. Please try again."> <input type="hidden" name="primary_type" id="primary_type" value="email"> <div id="sib_loading_gif_area" style="position: absolute;z-index: 9999;display: none;"> <img src="https://my.sendinblue.com/public/theme/version4/assets/images/loader_sblue.gif" style="display: block;margin-left: auto;margin-right: auto;position: relative;top: 40%;"> </div> <form class="description" id="theform" name="theform" action="https://my.sendinblue.com/users/subscribeembed/js_id/1s344/id/3" onsubmit="return false;"> <input type="hidden" name="js_id" id="js_id" value="1s344"><input type="hidden" name="listid" id="listid" value="51"><input type="hidden" name="from_url" id="from_url" value="yes"><input type="hidden" name="hdn_email_txt" id="hdn_email_txt" value=""> <div class="sib-container rounded ui-sortable"> <input type="hidden" name="req_hid" id="req_hid" value="" style="font-size: 13px;"> <div class="header"> <h3 class="title">Get Our Free Email Course</h3> <p>Ready to learn how to reduce your website loading times by half? Come and join the 1st lesson here!</p> <div class="view-messages" style=" margin:5px 0;"> </div> <!-- an email as primary --> <div class="primary-group email-group forms-builder-group ui-sortable" style=""> <div class="row mandatory-email"> <p>Enter your email to subscribe. <span style="color:#ff0000;">*</span></p> <input type="text" name="email" id="email" value="<?php echo get_option( 'admin_email' ); ?>" style="padding: 4px; font-size: 13px; width: 80%; min-width: auto;"><input class="button" type="submit" data-editfield="subscribe" value="Submit"> <div style="clear:both;"></div> <div class="hidden-btns"> <a class="btn move" href="#"><i class="fa fa-arrows"></i></a><br> <!--<a class="btn btn-danger delete" href="#"><i class="fa fa-trash-o fa-inverse"></i></a>--> </div> </div> </div> <div class="captcha forms-builder-group" style="display: none;"><div class="row" style="font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; color: rgb(52, 52, 52); font-size: 10px; padding: 5px;"><div id="gcaptcha" style="transform: scale(0.47); margin-left: -57px;"></div></div></div> <!-- end of primary --><div style="clear:both;"></div> </div> </form> </div> </div> <script type="text/javascript"> var sib_prefix = 'sib'; var sib_dateformat = 'mm-dd-yyyy'; </script> <script type='text/javascript' src='https://my.sendinblue.com/public/theme/version4/assets/js/src/subscribe-validate.js?v=1526904274'></script> <!-- End : SendinBlue Signup Form HTML Code -->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  </div>
27
  </div>
28
 
gutenberg/class-pirateforms-gutenberg.php ADDED
@@ -0,0 +1,216 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * The gutenberg functionality of the plugin.
5
+ *
6
+ * @link http://example.com
7
+ * @since 1.0.0
8
+ *
9
+ * @package PirateForms
10
+ * @subpackage PirateForms/gutenberg
11
+ */
12
+
13
+ /**
14
+ * The gutenberg functionality of the plugin.
15
+ *
16
+ * Defines the plugin name, version, and two examples hooks for how to
17
+ * enqueue the admin-specific stylesheet and JavaScript.
18
+ *
19
+ * @package PirateForms
20
+ * @subpackage PirateForms/gutenberg
21
+ * @author Your Name <email@example.com>
22
+ */
23
+ class PirateForms_Gutenberg {
24
+
25
+ /**
26
+ * The ID of this plugin.
27
+ *
28
+ * @since 1.0.0
29
+ * @access private
30
+ * @var string $plugin_name The ID of this plugin.
31
+ */
32
+ private $plugin_name;
33
+
34
+ /**
35
+ * The version of this plugin.
36
+ *
37
+ * @since 1.0.0
38
+ * @access private
39
+ * @var string $version The current version of this plugin.
40
+ */
41
+ private $version;
42
+
43
+ /**
44
+ * Initialize the class and set its properties.
45
+ *
46
+ * @since 1.0.0
47
+ *
48
+ * @param string $plugin_name The name of this plugin.
49
+ * @param string $version The version of this plugin.
50
+ */
51
+ public function __construct( $plugin_name, $version ) {
52
+ $this->plugin_name = $plugin_name;
53
+ $this->version = $version;
54
+
55
+ }
56
+
57
+ /**
58
+ * Load block assets for the editor.
59
+ */
60
+ public function enqueue_block_editor_assets() {
61
+ wp_enqueue_script(
62
+ 'pirate-forms-block',
63
+ PIRATEFORMS_URL . 'gutenberg/js/block.build.js',
64
+ array( 'wp-i18n', 'wp-blocks', 'wp-components' ),
65
+ filemtime( PIRATEFORMS_DIR . '/gutenberg/js/block.build.js' )
66
+ );
67
+
68
+ wp_localize_script(
69
+ 'pirate-forms-block', 'pfjs', array(
70
+ 'url' => PIRATEFORMS_SLUG . '/v' . intval( PIRATEFORMS_API_VERSION ) . '/get_form/#/',
71
+ 'forms' => $this->get_forms( true ),
72
+ 'settings' => array(
73
+ 'default' => admin_url( 'admin.php?page=pirateforms-admin' ),
74
+ 'form' => admin_url( 'post.php?post=#&action=edit' ),
75
+ ),
76
+ 'i10n' => array(
77
+ 'captcha' => __( 'Save and reload the page to see the CAPTCHA', 'pirate-forms' ),
78
+ 'reload' => __( 'Some forms have changed since the last time this post was saved. We have reloaded those forms. You may need to save the post again.', 'pirate-forms' ),
79
+ 'settings' => __( 'Modify Settings', 'pirate-forms' ),
80
+ 'select_form' => __( 'Select Form', 'pirate-forms' ),
81
+ 'select_ajax' => __( 'Use Ajax to submit form', 'pirate-forms' ),
82
+ 'plugin' => PIRATEFORMS_NAME,
83
+ ),
84
+ )
85
+ );
86
+
87
+ wp_enqueue_script( 'pirate-forms-custom-spam', PIRATEFORMS_URL . 'public/js/custom-spam.js', array( 'jquery' ) );
88
+ wp_localize_script(
89
+ 'pirate-forms-custom-spam', 'pf', array(
90
+ 'spam' => array(
91
+ 'label' => apply_filters( 'pirate_forms_custom_spam_label', __( 'I\'m human!', 'pirate-forms' ) ),
92
+ 'value' => wp_create_nonce( PIRATEFORMS_NAME ),
93
+ 'gutenberg' => 1,
94
+ ),
95
+ )
96
+ );
97
+
98
+ $language = get_locale();
99
+ if ( defined( 'POLYLANG_VERSION' ) && function_exists( 'pll_current_language' ) ) {
100
+ $language = pll_current_language();
101
+ }
102
+ wp_enqueue_script( 'recaptcha', "https://www.google.com/recaptcha/api.js?hl=$language" );
103
+
104
+ wp_enqueue_style( 'pirate-forms-front-css', PIRATEFORMS_URL . 'public/css/front.css' );
105
+ wp_enqueue_style( 'pirate-forms-block-css', PIRATEFORMS_URL . 'gutenberg/css/block.css' );
106
+ }
107
+
108
+ /**
109
+ * Register the block.
110
+ */
111
+ public function register_block() {
112
+ register_block_type(
113
+ 'pirate-forms/form', array(
114
+ 'render_callback' => array( $this, 'render_block' ),
115
+ )
116
+ );
117
+ }
118
+
119
+ /**
120
+ * Render the pirate form block.
121
+ */
122
+ function render_block( $atts = null ) {
123
+ $arributes = array();
124
+ if ( is_array( $atts ) && $atts ) {
125
+ if ( array_key_exists( 'form_id', $atts ) ) {
126
+ $attributes['id'] = $atts['form_id'];
127
+ }
128
+ if ( array_key_exists( 'ajax', $atts ) ) {
129
+ $attributes['ajax'] = $atts['ajax'];
130
+ }
131
+ } else {
132
+ $attributes['id'] = $atts;
133
+ }
134
+
135
+ $params = '';
136
+ if ( $attributes ) {
137
+ foreach ( $attributes as $key => $value ) {
138
+ $params .= " $key=$value";
139
+ }
140
+ }
141
+
142
+ return do_shortcode( "[pirate_forms $params]" );
143
+ }
144
+
145
+ /**
146
+ * Register the REST endpoints.
147
+ */
148
+ public function register_endpoints() {
149
+ register_rest_route(
150
+ PIRATEFORMS_SLUG, '/v' . intval( PIRATEFORMS_API_VERSION ) . '/get_form/(?P<id>\d+)/',
151
+ array(
152
+ 'methods' => 'GET',
153
+ 'callback' => array( $this, 'get_form_html' ),
154
+ )
155
+ );
156
+ }
157
+
158
+ /**
159
+ * Get the requested form's HTML content.
160
+ */
161
+ function get_form_html( WP_REST_Request $request ) {
162
+ $return = $this->validate_params( $request, array( 'id' ) );
163
+ if ( is_wp_error( $return ) ) {
164
+ return $return;
165
+ }
166
+
167
+ return new WP_REST_Response( array( 'html' => $this->render_block( $request->get_param( 'id' ) ) ) );
168
+ }
169
+
170
+ /**
171
+ * Validate REST params.
172
+ */
173
+ private function validate_params( WP_REST_Request $request, $params = array() ) {
174
+ $return = array();
175
+ foreach ( $params as $param ) {
176
+ $value = $request->get_param( $param );
177
+ if ( ! is_numeric( $value ) && empty( $value ) ) {
178
+ return new WP_Error( $param . '_invalid', sprintf( __( 'Invalid %s', 'pirate-forms' ), $param ), array( 'status' => 403 ) );
179
+ } else {
180
+ $return[] = $value;
181
+ }
182
+ }
183
+
184
+ return $return;
185
+ }
186
+
187
+ /**
188
+ * Get all the forms.
189
+ */
190
+ private function get_forms( $include_default = false ) {
191
+ $forms = array();
192
+ if ( $include_default ) {
193
+ $forms[] = array( 'label' => __( 'Default', 'pirate-forms' ), 'value' => 0 );
194
+ }
195
+ if ( defined( 'PIRATEFORMSPRO_NAME' ) ) {
196
+ $query = new WP_Query(
197
+ apply_filters(
198
+ 'pirate_forms_get_forms_attributes', array(
199
+ 'post_type' => 'pf_form',
200
+ 'numberposts' => 300,
201
+ 'post_status' => 'publish',
202
+ ), basename( __FILE__ )
203
+ )
204
+ );
205
+
206
+ if ( $query->have_posts() ) {
207
+ while ( $query->have_posts() ) {
208
+ $query->the_post();
209
+ $forms[] = array( 'label' => get_the_title(), 'value' => get_the_ID() );
210
+ }
211
+ }
212
+ }
213
+ return $forms;
214
+ }
215
+
216
+ }
gutenberg/css/block.css ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ .pf-form-spinner {
2
+ display: none;
3
+ }
4
+
5
+ .pf-form-spinner.pf-form-loading {
6
+ display: block;
7
+ }
8
+
9
+ .pirate-forms-maps-custom input {
10
+ display: inline-block !important;
11
+ }
gutenberg/js/block.build.js ADDED
@@ -0,0 +1,265 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /******/ (function(modules) { // webpackBootstrap
2
+ /******/ // The module cache
3
+ /******/ var installedModules = {};
4
+ /******/
5
+ /******/ // The require function
6
+ /******/ function __webpack_require__(moduleId) {
7
+ /******/
8
+ /******/ // Check if module is in cache
9
+ /******/ if(installedModules[moduleId]) {
10
+ /******/ return installedModules[moduleId].exports;
11
+ /******/ }
12
+ /******/ // Create a new module (and put it into the cache)
13
+ /******/ var module = installedModules[moduleId] = {
14
+ /******/ i: moduleId,
15
+ /******/ l: false,
16
+ /******/ exports: {}
17
+ /******/ };
18
+ /******/
19
+ /******/ // Execute the module function
20
+ /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
21
+ /******/
22
+ /******/ // Flag the module as loaded
23
+ /******/ module.l = true;
24
+ /******/
25
+ /******/ // Return the exports of the module
26
+ /******/ return module.exports;
27
+ /******/ }
28
+ /******/
29
+ /******/
30
+ /******/ // expose the modules object (__webpack_modules__)
31
+ /******/ __webpack_require__.m = modules;
32
+ /******/
33
+ /******/ // expose the module cache
34
+ /******/ __webpack_require__.c = installedModules;
35
+ /******/
36
+ /******/ // define getter function for harmony exports
37
+ /******/ __webpack_require__.d = function(exports, name, getter) {
38
+ /******/ if(!__webpack_require__.o(exports, name)) {
39
+ /******/ Object.defineProperty(exports, name, {
40
+ /******/ configurable: false,
41
+ /******/ enumerable: true,
42
+ /******/ get: getter
43
+ /******/ });
44
+ /******/ }
45
+ /******/ };
46
+ /******/
47
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
48
+ /******/ __webpack_require__.n = function(module) {
49
+ /******/ var getter = module && module.__esModule ?
50
+ /******/ function getDefault() { return module['default']; } :
51
+ /******/ function getModuleExports() { return module; };
52
+ /******/ __webpack_require__.d(getter, 'a', getter);
53
+ /******/ return getter;
54
+ /******/ };
55
+ /******/
56
+ /******/ // Object.prototype.hasOwnProperty.call
57
+ /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
58
+ /******/
59
+ /******/ // __webpack_public_path__
60
+ /******/ __webpack_require__.p = "";
61
+ /******/
62
+ /******/ // Load entry module and return exports
63
+ /******/ return __webpack_require__(__webpack_require__.s = 0);
64
+ /******/ })
65
+ /************************************************************************/
66
+ /******/ ([
67
+ /* 0 */
68
+ /***/ (function(module, exports) {
69
+
70
+ var _this = this;
71
+
72
+ var __ = wp.i18n.__;
73
+ var _wp$blocks = wp.blocks,
74
+ registerBlockType = _wp$blocks.registerBlockType,
75
+ Editable = _wp$blocks.Editable;
76
+ var InspectorControls = wp.editor.InspectorControls;
77
+ var _wp$components = wp.components,
78
+ ToggleControl = _wp$components.ToggleControl,
79
+ SelectControl = _wp$components.SelectControl,
80
+ Spinner = _wp$components.Spinner;
81
+
82
+
83
+ var el = wp.element.createElement;
84
+
85
+ registerBlockType('pirate-forms/form', {
86
+ title: pfjs.i10n.plugin,
87
+ icon: 'index-card',
88
+ category: 'common',
89
+ supports: {
90
+ html: false
91
+ },
92
+ attributes: {
93
+ // contains the html of the form.
94
+ html: {
95
+ type: 'string',
96
+ default: ''
97
+ },
98
+ // tracks if html has changed from the saved html.
99
+ html_changed: {
100
+ type: 'number',
101
+ default: 1
102
+ },
103
+ // contains the form id of the form.
104
+ form_id: {
105
+ type: 'number',
106
+ default: -1
107
+ },
108
+ // indicates whether this is an ajax form.
109
+ ajax: {
110
+ type: 'string',
111
+ default: 'no'
112
+ },
113
+ // the label to show in gutenberg.
114
+ label: {
115
+ type: 'string',
116
+ default: __('Loading Form') + '...'
117
+ },
118
+ // the class of the spinner container.
119
+ spinner: {
120
+ type: 'string',
121
+ default: 'pf-form-spinner'
122
+ },
123
+ // link to settings - name of the link.
124
+ link: {
125
+ type: 'string',
126
+ default: ''
127
+ },
128
+ // link to settings.
129
+ url: {
130
+ type: 'string',
131
+ default: ''
132
+ }
133
+ },
134
+ edit: function edit(props) {
135
+ var getFormHTML = function getFormHTML($id) {
136
+ props.setAttributes({ spinner: 'pf-form-spinner pf-form-loading', link: '' });
137
+ wp.apiRequest({ path: pfjs.url.replace('#', $id) }).then(function (data) {
138
+ props.setAttributes({ spinner: 'pf-form-spinner' });
139
+ if (_this.unmounting) {
140
+ return data;
141
+ }
142
+
143
+ // check if the new html is different from what was previously saved.
144
+ if (props.attributes.html === data.html) {
145
+ props.setAttributes({ html_changed: 0 });
146
+ return;
147
+ }
148
+
149
+ if (props.attributes.html !== '') {
150
+ alert(pfjs.i10n.reload);
151
+ }
152
+
153
+ var $url = $id == 0 ? pfjs.settings.default : pfjs.settings.form.replace('#', $id);
154
+
155
+ props.setAttributes({ html: data.html, label: '', spinner: 'pf-form-spinner', url: $url, link: pfjs.i10n.settings, html_changed: 0 });
156
+ jQuery('.pirate-forms-maps-custom').trigger('addCustomSpam');
157
+
158
+ // when the form is just added, captcha will not show.
159
+ jQuery('.pirate-forms-google-recaptcha').each(function () {
160
+ if (jQuery(this).html().length === 0) {
161
+ jQuery(this).html(pfjs.i10n.captcha);
162
+ }
163
+ });
164
+ });
165
+ };
166
+
167
+ var innerHTML = function innerHTML() {
168
+ return { __html: props.attributes.html };
169
+ };
170
+
171
+ var onChangeForm = function onChangeForm(value) {
172
+ props.setAttributes({ form_id: value });
173
+ if (value > -1) {
174
+ getFormHTML(value);
175
+ }
176
+ return null;
177
+ };
178
+
179
+ var onChangeAjax = function onChangeAjax(value) {
180
+ props.setAttributes({ ajax: value === true ? 'yes' : 'no' });
181
+ return null;
182
+ };
183
+
184
+ var getInspectorControls = function getInspectorControls() {
185
+ if (!!props.isSelected) {
186
+ if (pfjs.forms.length > 1) {
187
+ return wp.element.createElement(
188
+ InspectorControls,
189
+ null,
190
+ wp.element.createElement(SelectControl, {
191
+ label: pfjs.i10n.select_form,
192
+ options: pfjs.forms,
193
+ value: props.attributes.form_id,
194
+ onChange: onChangeForm
195
+ }),
196
+ wp.element.createElement(ToggleControl, {
197
+ label: pfjs.i10n.select_ajax,
198
+ checked: props.attributes.ajax == 'yes',
199
+ onChange: onChangeAjax
200
+ }),
201
+ wp.element.createElement(
202
+ 'div',
203
+ null,
204
+ wp.element.createElement(
205
+ 'a',
206
+ { href: props.attributes.url, target: '_new' },
207
+ props.attributes.link
208
+ )
209
+ ),
210
+ wp.element.createElement(
211
+ 'div',
212
+ { className: props.attributes.spinner },
213
+ wp.element.createElement(Spinner, null)
214
+ )
215
+ );
216
+ }
217
+ return wp.element.createElement(
218
+ InspectorControls,
219
+ null,
220
+ wp.element.createElement(ToggleControl, {
221
+ label: pfjs.i10n.select_ajax,
222
+ checked: props.attributes.ajax == 'yes',
223
+ onChange: onChangeAjax
224
+ }),
225
+ wp.element.createElement(
226
+ 'div',
227
+ null,
228
+ wp.element.createElement(
229
+ 'a',
230
+ { href: props.attributes.url, target: '_new' },
231
+ props.attributes.link
232
+ )
233
+ ),
234
+ wp.element.createElement(
235
+ 'div',
236
+ { className: props.attributes.spinner },
237
+ wp.element.createElement(Spinner, null)
238
+ )
239
+ );
240
+ }
241
+ return null;
242
+ };
243
+
244
+ // load default by default.
245
+ if (props.attributes.form_id == -1) {
246
+ onChangeForm(0);
247
+ } else if (props.attributes.html_changed === 1) {
248
+ props.setAttributes({ html_changed: 0 });
249
+ getFormHTML(props.attributes.form_id);
250
+ }
251
+
252
+ return [wp.element.createElement(
253
+ 'div',
254
+ { className: props.className },
255
+ props.attributes.label
256
+ ), getInspectorControls(), wp.element.createElement('div', { className: props.className, dangerouslySetInnerHTML: innerHTML() })];
257
+ },
258
+ save: function save(props) {
259
+ props.attributes.html_changed = 1;
260
+ return null;
261
+ }
262
+ });
263
+
264
+ /***/ })
265
+ /******/ ]);
gutenberg/js/block.js ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const { __ } = wp.i18n;
2
+ const {
3
+ registerBlockType,
4
+ Editable,
5
+ } = wp.blocks;
6
+
7
+ const {
8
+ InspectorControls,
9
+ } = wp.editor;
10
+
11
+ const {
12
+ ToggleControl,
13
+ SelectControl,
14
+ Spinner,
15
+ } = wp.components;
16
+
17
+ var el = wp.element.createElement;
18
+
19
+ registerBlockType( 'pirate-forms/form', {
20
+ title: pfjs.i10n.plugin,
21
+ icon: 'index-card',
22
+ category: 'common',
23
+ supports: {
24
+ html: false,
25
+ },
26
+ attributes: {
27
+ // contains the html of the form.
28
+ html: {
29
+ type: 'string',
30
+ default: '',
31
+ },
32
+ // tracks if html has changed from the saved html.
33
+ html_changed: {
34
+ type: 'number',
35
+ default: 1,
36
+ },
37
+ // contains the form id of the form.
38
+ form_id: {
39
+ type: 'number',
40
+ default: -1,
41
+ },
42
+ // indicates whether this is an ajax form.
43
+ ajax: {
44
+ type: 'string',
45
+ default: 'no',
46
+ },
47
+ // the label to show in gutenberg.
48
+ label: {
49
+ type: 'string',
50
+ default: __( 'Loading Form' ) + '...',
51
+ },
52
+ // the class of the spinner container.
53
+ spinner: {
54
+ type: 'string',
55
+ default: 'pf-form-spinner',
56
+ },
57
+ // link to settings - name of the link.
58
+ link: {
59
+ type: 'string',
60
+ default: '',
61
+ },
62
+ // link to settings.
63
+ url: {
64
+ type: 'string',
65
+ default: '',
66
+ },
67
+ },
68
+ edit: props => {
69
+ const getFormHTML = ($id) => {
70
+ props.setAttributes( { spinner: 'pf-form-spinner pf-form-loading', link: '' } );
71
+ wp.apiRequest( { path: pfjs.url.replace('#', $id)} )
72
+ .then(
73
+ (data) => {
74
+ props.setAttributes( { spinner: 'pf-form-spinner' } );
75
+ if ( this.unmounting ) {
76
+ return data;
77
+ }
78
+
79
+ // check if the new html is different from what was previously saved.
80
+ if(props.attributes.html === data.html){
81
+ props.setAttributes( { html_changed: 0 } );
82
+ return;
83
+ }
84
+
85
+ if(props.attributes.html !== ''){
86
+ alert(pfjs.i10n.reload);
87
+ }
88
+
89
+ var $url = $id == 0 ? pfjs.settings.default : pfjs.settings.form.replace('#', $id);
90
+
91
+ props.setAttributes( { html: data.html, label: '', spinner: 'pf-form-spinner', url: $url, link: pfjs.i10n.settings, html_changed: 0 } );
92
+ jQuery('.pirate-forms-maps-custom').trigger('addCustomSpam');
93
+
94
+ // when the form is just added, captcha will not show.
95
+ jQuery('.pirate-forms-google-recaptcha').each(function(){
96
+ if(jQuery(this).html().length === 0){
97
+ jQuery(this).html(pfjs.i10n.captcha);
98
+ }
99
+ });
100
+ }
101
+ );
102
+ };
103
+
104
+ const innerHTML = () => {
105
+ return {__html: props.attributes.html};
106
+ }
107
+
108
+ const onChangeForm = value => {
109
+ props.setAttributes( { form_id: value } );
110
+ if(value > -1){
111
+ getFormHTML(value);
112
+ }
113
+ return null;
114
+ }
115
+
116
+ const onChangeAjax = value => {
117
+ props.setAttributes( { ajax: ( value === true ? 'yes' : 'no' ) } );
118
+ return null;
119
+ }
120
+
121
+ const getInspectorControls = () => {
122
+ if(!! props.isSelected){
123
+ if(pfjs.forms.length > 1){
124
+ return <InspectorControls>
125
+ <SelectControl
126
+ label={pfjs.i10n.select_form}
127
+ options={pfjs.forms}
128
+ value={props.attributes.form_id}
129
+ onChange={ onChangeForm }
130
+ />
131
+ <ToggleControl
132
+ label={pfjs.i10n.select_ajax}
133
+ checked={props.attributes.ajax == 'yes'}
134
+ onChange={ onChangeAjax }
135
+ />
136
+ <div>
137
+ <a href={props.attributes.url} target="_new">{props.attributes.link}</a>
138
+ </div>
139
+ <div className={props.attributes.spinner}>
140
+ <Spinner />
141
+ </div>
142
+ </InspectorControls>;
143
+ }
144
+ return <InspectorControls>
145
+ <ToggleControl
146
+ label={pfjs.i10n.select_ajax}
147
+ checked={props.attributes.ajax == 'yes'}
148
+ onChange={ onChangeAjax }
149
+ />
150
+ <div>
151
+ <a href={props.attributes.url} target="_new">{props.attributes.link}</a>
152
+ </div>
153
+ <div className={props.attributes.spinner}>
154
+ <Spinner />
155
+ </div>
156
+ </InspectorControls>;
157
+ }
158
+ return null;
159
+ }
160
+
161
+ // load default by default.
162
+ if(props.attributes.form_id == -1){
163
+ onChangeForm(0);
164
+ } else if(props.attributes.html_changed === 1){
165
+ props.setAttributes( { html_changed: 0 } );
166
+ getFormHTML(props.attributes.form_id);
167
+ }
168
+
169
+ return [
170
+ <div className={ props.className }>{props.attributes.label}</div>,
171
+ getInspectorControls(),
172
+ <div className={ props.className } dangerouslySetInnerHTML={innerHTML()}></div>,
173
+ ];
174
+ },
175
+ save: props => {
176
+ props.attributes.html_changed = 1;
177
+ return null;
178
+ },
179
+ } );
includes/class-pirateforms-html.php CHANGED
@@ -14,6 +14,15 @@ class PirateForms_HTML {
14
  * @since 1.2.6
15
  */
16
  public function add( $args, $echo = true ) {
 
 
 
 
 
 
 
 
 
17
  $type = $args['type'];
18
  $html = '';
19
  if ( method_exists( $this, $type ) ) {
@@ -406,13 +415,53 @@ class PirateForms_HTML {
406
  */
407
  private function wysiwyg( $args ) {
408
  $html = $this->get_label( $args );
409
- $content = isset( $args['value'] ) && ! empty( $args['value'] ) ? $args['value'] : $args['default'];
410
  ob_start();
411
  wp_editor( $content, $args['id'], $args['wysiwyg'] );
412
  $html .= ob_get_clean();
413
  return $this->get_wrap( $args, $html );
414
  }
415
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
416
  /**
417
  * The label element.
418
  */
14
  * @since 1.2.6
15
  */
16
  public function add( $args, $echo = true ) {
17
+ if ( isset( $args['front_end'] ) && $args['front_end'] ) {
18
+ $html = $this->front_end( $args );
19
+ if ( ! $echo ) {
20
+ return $html;
21
+ }
22
+ echo $html;
23
+ return;
24
+ }
25
+
26
  $type = $args['type'];
27
  $html = '';
28
  if ( method_exists( $this, $type ) ) {
415
  */
416
  private function wysiwyg( $args ) {
417
  $html = $this->get_label( $args );
418
+ $content = isset( $args['value'] ) && ! empty( $args['value'] ) ? $args['value'] : ( isset( $args['default'] ) ? $args['default'] : '' );
419
  ob_start();
420
  wp_editor( $content, $args['id'], $args['wysiwyg'] );
421
  $html .= ob_get_clean();
422
  return $this->get_wrap( $args, $html );
423
  }
424
 
425
+ /**
426
+ * Elements on the front end.
427
+ *
428
+ * @throws Exception If method is not defined.
429
+ */
430
+ private function front_end( $args ) {
431
+ $type = $args['type'];
432
+
433
+ require_once( ABSPATH . 'wp-admin/includes/file.php' );
434
+ WP_Filesystem();
435
+ global $wp_filesystem;
436
+ $plugin_path = str_replace( ABSPATH, $wp_filesystem->abspath(), PIRATEFORMS_DIR );
437
+ $template = trailingslashit( $plugin_path ) . "/public/partials/fields/{$type}.php";
438
+ if ( ! $wp_filesystem->is_readable( $template ) ) {
439
+ throw new Exception( "Template for $type not defined" );
440
+ }
441
+
442
+ if ( isset( $args['id'] ) && ! isset( $args['name'] ) ) {
443
+ $args['name'] = $args['id'];
444
+ }
445
+
446
+ $name = str_replace( array( 'pirate-forms-contact-', 'pirate-forms-' ), '', $args['name'] );
447
+
448
+ $args = apply_filters( "pirate_forms_front_end_{$type}_args", $args, $name );
449
+
450
+ // themes might have overriden some attributes, so we need to extract them in a backward-compatible way.
451
+ $wrap_classes = null;
452
+ if ( isset( $args['wrap']['class'] ) ) {
453
+ $wrap_classes = array( $args['wrap']['class'] );
454
+ }
455
+ $label = null;
456
+ if ( isset( $args['label'] ) ) {
457
+ $label = $this->get_label( $args );
458
+ }
459
+
460
+ ob_start();
461
+ include $template;
462
+ return ob_get_clean();
463
+ }
464
+
465
  /**
466
  * The label element.
467
  */
includes/class-pirateforms-phpformbuilder.php CHANGED
@@ -26,12 +26,7 @@ class PirateForms_PhpFormBuilder {
26
  */
27
  function build_form( $elements, $pirate_forms_options, $from_widget ) {
28
  $this->pirate_forms_options = $pirate_forms_options;
29
- $pirateformsopt_attachment_field = $pirate_forms_options['pirateformsopt_attachment_field'];
30
- if ( ! empty( $pirateformsopt_attachment_field ) ) {
31
- $pirate_forms_enctype = 'multipart/form-data';
32
- } else {
33
- $pirate_forms_enctype = 'application/x-www-form-urlencoded';
34
- }
35
 
36
  $classes = array();
37
  $classes[] = $from_widget ? 'widget-on' : '';
@@ -44,13 +39,11 @@ class PirateForms_PhpFormBuilder {
44
  'value' => $id,
45
  );
46
 
47
- $form_start = '<form method="post" id="' . $id . '" enctype="' . $pirate_forms_enctype . '" class="pirate_forms ';
48
-
49
  $html_helper = new PirateForms_HTML();
50
- $form_end = '';
51
  $custom_fields = '';
52
  foreach ( $elements as $val ) {
53
- if ( 'form_honeypot' !== $val['id'] && ! in_array( $val['type'], array( 'hidden', 'div' ) ) ) {
54
  $val['class'] = apply_filters( 'pirate_forms_field_class', $val['class'], $val['id'] );
55
  }
56
  if ( isset( $val['is_custom'] ) && $val['is_custom'] ) {
@@ -59,14 +52,21 @@ class PirateForms_PhpFormBuilder {
59
  $classes[] = $val['id'] . '-on';
60
  } else {
61
  $element = $html_helper->add( $val, false );
62
- if ( ( 'form_honeypot' === $val['id'] || in_array( $val['type'], array( 'hidden', 'div' ) ) ) && ! in_array( $val['id'], array( 'pirate-forms-maps-custom', 'pirate-forms-captcha' ) ) ) {
63
- $form_end .= $element;
 
64
  }
65
  if ( $val['id'] === 'pirate-forms-maps-custom' ) {
66
  $this->set_element( 'captcha', $element );
67
  }
68
  $this->set_element( $val['id'], $element );
69
- $classes[] = $val['id'] . '-on';
 
 
 
 
 
 
70
  }
71
  }
72
 
@@ -90,17 +90,9 @@ class PirateForms_PhpFormBuilder {
90
  }
91
  }
92
 
93
- $form_start .= implode( ' ', $classes ) . '"';
94
- if ( $form_attributes ) {
95
- foreach ( $form_attributes as $k => $v ) {
96
- $form_start .= " $k=$v";
97
- }
98
- }
99
- $form_start .= '>';
100
- $this->set_element( 'form_start', $form_start );
101
-
102
- $form_end .= '</form>';
103
- $this->set_element( 'form_end', $form_end );
104
 
105
  $output = $this->load_theme();
106
  return $output;
@@ -113,7 +105,11 @@ class PirateForms_PhpFormBuilder {
113
  */
114
  public function set_element( $element_name, $output ) {
115
  $name = str_replace( array( 'pirate-forms-', '-' ), array( '', '_' ), $element_name );
116
- $this->$name = $output;
 
 
 
 
117
  }
118
 
119
  /**
26
  */
27
  function build_form( $elements, $pirate_forms_options, $from_widget ) {
28
  $this->pirate_forms_options = $pirate_forms_options;
29
+ $this->container_class = apply_filters( 'pirate_forms_container_class', $from_widget ? 'widget-yes' : 'widget-no', $this->pirate_forms_options );
 
 
 
 
 
30
 
31
  $classes = array();
32
  $classes[] = $from_widget ? 'widget-on' : '';
39
  'value' => $id,
40
  );
41
 
 
 
42
  $html_helper = new PirateForms_HTML();
43
+ $hidden = '';
44
  $custom_fields = '';
45
  foreach ( $elements as $val ) {
46
+ if ( 'form_honeypot' !== $val['id'] && ! in_array( $val['type'], array( 'hidden', 'div' ) ) && array_key_exists( 'class', $val ) ) {
47
  $val['class'] = apply_filters( 'pirate_forms_field_class', $val['class'], $val['id'] );
48
  }
49
  if ( isset( $val['is_custom'] ) && $val['is_custom'] ) {
52
  $classes[] = $val['id'] . '-on';
53
  } else {
54
  $element = $html_helper->add( $val, false );
55
+ if ( ( 'form_honeypot' === $val['id'] || in_array( $val['type'], array( 'hidden', 'div' ) ) ) && $val['id'] !== 'pirate-forms-maps-custom'
56
+ ) {
57
+ $hidden .= $element;
58
  }
59
  if ( $val['id'] === 'pirate-forms-maps-custom' ) {
60
  $this->set_element( 'captcha', $element );
61
  }
62
  $this->set_element( $val['id'], $element );
63
+ if ( in_array( $val['type'], array( 'hidden') ) ) {
64
+ if ( ! empty( $val['value'] ) ) {
65
+ $classes[] = $val['id'] . '-on';
66
+ }
67
+ } else {
68
+ $classes[] = $val['id'] . '-on';
69
+ }
70
  }
71
  }
72
 
90
  }
91
  }
92
 
93
+ $this->form_classes = apply_filters( 'pirate_forms_form_classes', $classes, $this );
94
+ $this->form_attributes = $form_attributes;
95
+ $this->form_hidden = $hidden;
 
 
 
 
 
 
 
 
96
 
97
  $output = $this->load_theme();
98
  return $output;
105
  */
106
  public function set_element( $element_name, $output ) {
107
  $name = str_replace( array( 'pirate-forms-', '-' ), array( '', '_' ), $element_name );
108
+ $final = apply_filters( "pirate_forms_before_{$name}", '', $this->pirate_forms_options );
109
+ $final .= $output;
110
+ $final .= apply_filters( "pirate_forms_after_{$name}", '', $this->pirate_forms_options );
111
+
112
+ $this->$name = $final;
113
  }
114
 
115
  /**
includes/class-pirateforms-util.php CHANGED
@@ -10,6 +10,14 @@ class PirateForms_Util {
10
  const MAGIC_TAG_PREFIX = '{';
11
  const MAGIC_TAG_POSTFIX = '}';
12
 
 
 
 
 
 
 
 
 
13
  /**
14
  * Return the table.
15
  *
@@ -241,8 +249,11 @@ class PirateForms_Util {
241
  $body['body'] = array();
242
  $pirate_forms_options = PirateForms_Util::get_form_options( $id );
243
 
244
- $elements = array( 'name', 'email', 'subject', 'message' );
245
  foreach ( $elements as $k ) {
 
 
 
246
  $display = $pirate_forms_options[ 'pirateformsopt_' . $k . '_field' ];
247
  if ( ! $first_time && empty( $display ) ) {
248
  continue;
@@ -253,7 +264,11 @@ class PirateForms_Util {
253
  }
254
  $body['body'][ $val ] = self::MAGIC_TAG_PREFIX . $k . self::MAGIC_TAG_POSTFIX;
255
  }
256
- $body['body'][ __( 'IP address', 'pirate-forms' ) ] = self::MAGIC_TAG_PREFIX . 'ip' . self::MAGIC_TAG_POSTFIX;
 
 
 
 
257
  $body['body'][ __( 'IP search', 'pirate-forms' ) ] = 'http://whatismyipaddress.com/ip/' . self::MAGIC_TAG_PREFIX . 'ip' . self::MAGIC_TAG_POSTFIX;
258
  $body['body'][ __( 'Came from', 'pirate-forms' ) ] = self::MAGIC_TAG_PREFIX . 'referer' . self::MAGIC_TAG_POSTFIX;
259
  $body['body'][ __( 'Sent from page', 'pirate-forms' ) ] = self::MAGIC_TAG_PREFIX . 'permalink' . self::MAGIC_TAG_POSTFIX;
@@ -285,8 +300,11 @@ class PirateForms_Util {
285
  public static function get_magic_tags( $id = null ) {
286
  $pirate_forms_options = PirateForms_Util::get_form_options( $id );
287
 
288
- $elements = array( 'name', 'email', 'subject', 'message' );
289
  foreach ( $elements as $k ) {
 
 
 
290
  $val = $pirate_forms_options[ 'pirateformsopt_label_' . $k ];
291
  if ( empty( $val ) ) {
292
  $val = ucwords( $k );
@@ -294,8 +312,13 @@ class PirateForms_Util {
294
  $tags[ $k ] = $val;
295
  }
296
 
 
 
 
 
 
 
297
  $tags += array(
298
- 'ip' => __( 'IP address', 'pirate-forms' ),
299
  'referer' => __( 'Came from', 'pirate-forms' ),
300
  'permalink' => __( 'Sent from page', 'pirate-forms' ),
301
  );
10
  const MAGIC_TAG_PREFIX = '{';
11
  const MAGIC_TAG_POSTFIX = '}';
12
 
13
+ /**
14
+ * The default fields used by the plugin.
15
+ *
16
+ * @access private
17
+ * @var array $DEFAULT_FIELDS The default fields used by the plugin.
18
+ */
19
+ public static $DEFAULT_FIELDS = array( 'name', 'email', 'subject', 'message', 'checkbox' );
20
+
21
  /**
22
  * Return the table.
23
  *
249
  $body['body'] = array();
250
  $pirate_forms_options = PirateForms_Util::get_form_options( $id );
251
 
252
+ $elements = self::$DEFAULT_FIELDS;
253
  foreach ( $elements as $k ) {
254
+ if ( is_array( $pirate_forms_options ) && ! array_key_exists( 'pirateformsopt_' . $k . '_field', $pirate_forms_options ) ) {
255
+ continue;
256
+ }
257
  $display = $pirate_forms_options[ 'pirateformsopt_' . $k . '_field' ];
258
  if ( ! $first_time && empty( $display ) ) {
259
  continue;
264
  }
265
  $body['body'][ $val ] = self::MAGIC_TAG_PREFIX . $k . self::MAGIC_TAG_POSTFIX;
266
  }
267
+
268
+ if ( isset( $pirate_forms_options['pirateformsopt_store_ip'] ) && 'yes' === $pirate_forms_options['pirateformsopt_store_ip'] ) {
269
+ $body['body'][ __( 'IP address', 'pirate-forms' ) ] = self::MAGIC_TAG_PREFIX . 'ip' . self::MAGIC_TAG_POSTFIX;
270
+ }
271
+
272
  $body['body'][ __( 'IP search', 'pirate-forms' ) ] = 'http://whatismyipaddress.com/ip/' . self::MAGIC_TAG_PREFIX . 'ip' . self::MAGIC_TAG_POSTFIX;
273
  $body['body'][ __( 'Came from', 'pirate-forms' ) ] = self::MAGIC_TAG_PREFIX . 'referer' . self::MAGIC_TAG_POSTFIX;
274
  $body['body'][ __( 'Sent from page', 'pirate-forms' ) ] = self::MAGIC_TAG_PREFIX . 'permalink' . self::MAGIC_TAG_POSTFIX;
300
  public static function get_magic_tags( $id = null ) {
301
  $pirate_forms_options = PirateForms_Util::get_form_options( $id );
302
 
303
+ $elements = self::$DEFAULT_FIELDS;
304
  foreach ( $elements as $k ) {
305
+ if ( is_array( $pirate_forms_options ) && ! array_key_exists( 'pirateformsopt_label_' . $k, $pirate_forms_options ) ) {
306
+ continue;
307
+ }
308
  $val = $pirate_forms_options[ 'pirateformsopt_label_' . $k ];
309
  if ( empty( $val ) ) {
310
  $val = ucwords( $k );
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' ),
318
+ );
319
+ }
320
+
321
  $tags += array(
 
322
  'referer' => __( 'Came from', 'pirate-forms' ),
323
  'permalink' => __( 'Sent from page', 'pirate-forms' ),
324
  );
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.2';
73
 
74
  $this->load_dependencies();
75
  $this->set_locale();
@@ -77,6 +77,22 @@ class PirateForms {
77
  $this->define_admin_hooks();
78
  $this->define_public_hooks();
79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  }
81
 
82
  /**
@@ -186,9 +202,6 @@ class PirateForms {
186
 
187
  // ONLY FOR UNIT TESTING: we cannot fire template_redirect without errors, that is why we are creating a manual hook for this
188
  $this->loader->add_action( 'pirate_unittesting_template_redirect', $plugin_public, 'template_redirect' );
189
- $this->loader->add_action( 'pirate_forms_render_thankyou', $plugin_public, 'render_thankyou' );
190
- $this->loader->add_action( 'pirate_forms_render_errors', $plugin_public, 'render_errors' );
191
- $this->loader->add_action( 'pirate_forms_render_fields', $plugin_public, 'render_fields' );
192
  $this->loader->add_action( 'pirate_forms_send_email', $plugin_public, 'send_email' );
193
 
194
  $this->loader->add_filter( 'widget_text', $plugin_public, 'widget_text_filter', 9 );
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();
77
  $this->define_admin_hooks();
78
  $this->define_public_hooks();
79
 
80
+ if ( function_exists( 'register_block_type' ) ) {
81
+ $this->define_gutenberg_hooks();
82
+ }
83
+ }
84
+
85
+ /**
86
+ * Load the required gutenberg dependencies for this plugin.
87
+ *
88
+ * @access private
89
+ */
90
+ private function define_gutenberg_hooks() {
91
+ $gutenberg = new PirateForms_Gutenberg( $this->get_plugin_name(), $this->get_version() );
92
+
93
+ $this->loader->add_action( 'enqueue_block_editor_assets', $gutenberg, 'enqueue_block_editor_assets' );
94
+ $this->loader->add_action( 'init', $gutenberg, 'register_block' );
95
+ $this->loader->add_action( 'rest_api_init', $gutenberg, 'register_endpoints' );
96
  }
97
 
98
  /**
202
 
203
  // ONLY FOR UNIT TESTING: we cannot fire template_redirect without errors, that is why we are creating a manual hook for this
204
  $this->loader->add_action( 'pirate_unittesting_template_redirect', $plugin_public, 'template_redirect' );
 
 
 
205
  $this->loader->add_action( 'pirate_forms_send_email', $plugin_public, 'send_email' );
206
 
207
  $this->loader->add_filter( 'widget_text', $plugin_public, 'widget_text_filter', 9 );
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.2
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.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__ ) );
@@ -113,6 +113,13 @@ function pirate_forms_autoload( $class ) {
113
 
114
  return true;
115
  }
 
 
 
 
 
 
 
116
  }
117
 
118
  $filename = PIRATEFORMS_DIR . 'includes/class-pirateforms-widget.php';
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
  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__ ) );
113
 
114
  return true;
115
  }
116
+
117
+ $filename = PIRATEFORMS_DIR . 'gutenberg/' . $class1 . '.php';
118
+ if ( is_readable( $filename ) ) {
119
+ require_once $filename;
120
+
121
+ return true;
122
+ }
123
  }
124
 
125
  $filename = PIRATEFORMS_DIR . 'includes/class-pirateforms-widget.php';
public/class-pirateforms-public.php CHANGED
@@ -130,8 +130,8 @@ class PirateForms_Public {
130
 
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();
@@ -141,16 +141,12 @@ class PirateForms_Public {
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/' ),
@@ -159,6 +155,17 @@ class PirateForms_Public {
159
  ),
160
  )
161
  );
 
 
 
 
 
 
 
 
 
 
 
162
  }
163
 
164
  /**
@@ -250,14 +257,14 @@ class PirateForms_Public {
250
  'value' => wp_create_nonce( get_bloginfo( 'admin_email' ) . $nonce_append ),
251
  );
252
  }
253
- if ( ! empty( $pirate_forms_options ) ) :
254
  $field = $pirate_forms_options['pirateformsopt_name_field'];
255
  $label = $pirate_forms_options['pirateformsopt_label_name'];
256
  $subjectField = $pirate_forms_options['pirateformsopt_subject_field'];
257
 
258
  /**
259
  ****** Name field */
260
- if ( ! empty( $field ) && ! empty( $label ) ) :
261
  $required = $field === 'req' ? true : false;
262
  $wrap_classes = array(
263
  ( ! empty( $subjectField ) ? 'col-xs-12 col-sm-6' : 'col-xs-12' ) . ' contact_name_wrap pirate_forms_three_inputs form_field_wrap',
@@ -267,26 +274,23 @@ class PirateForms_Public {
267
  $wrap_classes[] = 'error';
268
  }
269
  $elements[] = array(
 
270
  'placeholder' => stripslashes( sanitize_text_field( $label ) ),
271
- 'required' => $required,
272
  'required_msg' => $pirate_forms_options['pirateformsopt_label_err_name'],
273
  'type' => 'text',
274
  'id' => 'pirate-forms-contact-name',
275
- 'class' => 'form-control',
276
- 'wrap' => array(
277
- 'type' => 'div',
278
- 'class' => implode( ' ', apply_filters( 'pirateform_wrap_classes_name', $wrap_classes ) ),
279
- ),
280
  'value' => empty( $thank_you_message ) && isset( $_REQUEST['pirate-forms-contact-name'] ) ? $_REQUEST['pirate-forms-contact-name'] : '',
 
281
  );
282
- endif;
283
 
284
  $field = $pirate_forms_options['pirateformsopt_email_field'];
285
  $label = $pirate_forms_options['pirateformsopt_label_email'];
286
 
287
  /**
288
  ****** Email field */
289
- if ( ! empty( $field ) && ! empty( $label ) ) :
290
  $required = $field === 'req' ? true : false;
291
  $wrap_classes = array(
292
  ( ! empty( $subjectField ) ? 'col-xs-12 col-sm-6' : 'col-xs-12' ) . ' contact_email_wrap pirate_forms_three_inputs form_field_wrap',
@@ -296,26 +300,23 @@ class PirateForms_Public {
296
  $wrap_classes[] = 'error';
297
  }
298
  $elements[] = array(
 
299
  'placeholder' => stripslashes( sanitize_text_field( $label ) ),
300
- 'required' => $required,
301
  'required_msg' => $pirate_forms_options['pirateformsopt_label_err_email'],
302
  'type' => 'email',
303
  'id' => 'pirate-forms-contact-email',
304
- 'class' => 'form-control',
305
- 'wrap' => array(
306
- 'type' => 'div',
307
- 'class' => implode( ' ', apply_filters( 'pirateform_wrap_classes_email', $wrap_classes ) ),
308
- ),
309
  'value' => empty( $thank_you_message ) && isset( $_REQUEST['pirate-forms-contact-email'] ) ? $_REQUEST['pirate-forms-contact-email'] : '',
 
310
  );
311
- endif;
312
 
313
  $field = $pirate_forms_options['pirateformsopt_subject_field'];
314
  $label = $pirate_forms_options['pirateformsopt_label_subject'];
315
 
316
  /**
317
  ****** Subject field */
318
- if ( ! empty( $field ) && ! empty( $label ) ) :
319
  $required = $field === 'req' ? true : false;
320
  $wrap_classes = array(
321
  'col-xs-12 contact_subject_wrap pirate_forms_three_inputs form_field_wrap',
@@ -325,52 +326,49 @@ class PirateForms_Public {
325
  $wrap_classes[] = 'error';
326
  }
327
  $elements[] = array(
 
328
  'placeholder' => stripslashes( sanitize_text_field( $label ) ),
329
- 'required' => $required,
330
  'required_msg' => $pirate_forms_options['pirateformsopt_label_err_subject'],
331
  'type' => 'text',
332
  'id' => 'pirate-forms-contact-subject',
333
- 'class' => 'form-control',
334
- 'wrap' => array(
335
- 'type' => 'div',
336
- 'class' => implode( ' ', apply_filters( 'pirateform_wrap_classes_subject', $wrap_classes ) ),
337
- ),
338
  'value' => empty( $thank_you_message ) && isset( $_REQUEST['pirate-forms-contact-subject'] ) ? $_REQUEST['pirate-forms-contact-subject'] : '',
 
339
  );
340
- endif;
341
 
342
  $field = $pirate_forms_options['pirateformsopt_message_field'];
343
  $label = $pirate_forms_options['pirateformsopt_label_message'];
344
 
345
  /**
346
  ****** Message field */
347
- if ( ! empty( $field ) && ! empty( $label ) ) :
348
  $required = $field === 'req' ? true : false;
349
- $wrap_classes = array( 'col-xs-12 form_field_wrap contact_message_wrap ' );
 
 
350
  // If this field was submitted with invalid data
351
  if ( isset( $_SESSION[ $error_key ]['contact-message'] ) ) {
352
  $wrap_classes[] = 'error';
353
  }
 
354
  $elements[] = array(
 
355
  'placeholder' => stripslashes( sanitize_text_field( $label ) ),
356
- 'required' => $required,
357
  'required_msg' => $pirate_forms_options['pirateformsopt_label_err_no_content'],
358
  'type' => 'textarea',
359
- 'class' => 'form-control',
360
  'id' => 'pirate-forms-contact-message',
361
- 'wrap' => array(
362
- 'type' => 'div',
363
- 'class' => implode( ' ', apply_filters( 'pirateform_wrap_classes_message', $wrap_classes ) ),
364
- ),
365
  'value' => empty( $thank_you_message ) && isset( $_REQUEST['pirate-forms-contact-message'] ) ? $_REQUEST['pirate-forms-contact-message'] : '',
 
366
  );
367
- endif;
368
 
369
  $field = $pirate_forms_options['pirateformsopt_attachment_field'];
370
 
371
  /**
372
  ****** Attachment field */
373
- if ( ! empty( $field ) && 'no' !== $field ) :
374
  $required = $field === 'req' ? true : false;
375
  $wrap_classes = array( 'col-xs-12 form_field_wrap contact_attachment_wrap' );
376
  // If this field was submitted with invalid data
@@ -378,17 +376,15 @@ class PirateForms_Public {
378
  $wrap_classes[] = 'error';
379
  }
380
  $elements[] = array(
381
- 'required' => $required,
 
382
  'required_msg' => $pirate_forms_options['pirateformsopt_label_err_no_attachment'],
383
  'type' => 'file',
384
- 'class' => 'form-control',
385
  'id' => 'pirate-forms-attachment',
386
- 'wrap' => array(
387
- 'type' => 'div',
388
- 'class' => implode( ' ', apply_filters( 'pirateform_wrap_classes_attachment', $wrap_classes ) ),
389
- ),
390
  );
391
- endif;
392
 
393
  if ( array_key_exists( 'pirateformsopt_checkbox_field', $pirate_forms_options ) ) {
394
  $field = $pirate_forms_options['pirateformsopt_checkbox_field'];
@@ -396,7 +392,7 @@ class PirateForms_Public {
396
 
397
  /**
398
  ****** checkbox field */
399
- if ( ! empty( $field ) && ! empty( $label ) ) :
400
  $required = $field === 'req' ? true : false;
401
  $wrap_classes = array( 'col-xs-12 form_field_wrap contact_checkbox_wrap ' );
402
  // If this field was submitted with invalid data
@@ -404,10 +400,10 @@ class PirateForms_Public {
404
  $wrap_classes[] = 'error';
405
  }
406
  $elements[] = array(
 
407
  'required' => $required,
408
  'required_msg' => $pirate_forms_options['pirateformsopt_label_err_no_checkbox'],
409
  'type' => 'checkbox',
410
- 'class' => 'form-control',
411
  'id' => 'pirate-forms-contact-checkbox',
412
  'wrap' => array(
413
  'type' => 'div',
@@ -418,18 +414,19 @@ class PirateForms_Public {
418
  'yes' => stripslashes( $label ),
419
  ),
420
  );
421
- endif;
422
  }
423
 
424
  /**
425
  ******* ReCaptcha */
426
- 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'] ) ) :
427
  $pirateformsopt_recaptcha_sitekey = $pirate_forms_options['pirateformsopt_recaptcha_sitekey'];
428
  $pirateformsopt_recaptcha_secretkey = $pirate_forms_options['pirateformsopt_recaptcha_secretkey'];
429
  $elements[] = array(
 
 
430
  'placeholder' => stripslashes( sanitize_text_field( $label ) ),
431
- 'type' => 'div',
432
- 'class' => 'g-recaptcha pirate-forms-google-recaptcha',
433
  'custom' => array( 'data-sitekey' => $pirateformsopt_recaptcha_sitekey ),
434
  'id' => 'pirate-forms-captcha',
435
  'wrap' => array(
@@ -437,19 +434,15 @@ class PirateForms_Public {
437
  'class' => implode( ' ', apply_filters( 'pirateform_wrap_classes_captcha', array( 'col-xs-12 ' . ( $pirate_forms_options['pirateformsopt_recaptcha_field'] !== 'yes' ? 'col-sm-6 ' : '' ) . 'form_field_wrap form_captcha_wrap' ) ) ),
438
  ),
439
  );
440
- endif;
441
 
442
- if ( ! empty( $pirate_forms_options['pirateformsopt_recaptcha_field'] ) && ( 'custom' === $pirate_forms_options['pirateformsopt_recaptcha_field'] ) ) :
443
  $elements[] = array(
444
- 'type' => 'div',
445
- 'class' => 'pirate-forms-maps-custom', // spam.reverse() = maps
446
  'id' => 'pirate-forms-maps-custom',
447
- 'wrap' => array(
448
- 'type' => 'div',
449
- 'class' => implode( ' ', apply_filters( 'pirateform_wrap_classes_spam', array( 'col-xs-12 col-sm-6 form_field_wrap pirateform_wrap_classes_spam_wrap' ) ) ),
450
- ),
451
  );
452
- endif;
453
 
454
  /**
455
  ****** Submit button */
@@ -461,6 +454,7 @@ class PirateForms_Public {
461
  $pirateformsopt_label_submit_btn = __( 'Submit', 'pirate-forms' );
462
  }
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' : '' ),
@@ -470,7 +464,7 @@ class PirateForms_Public {
470
  ),
471
  'value' => $pirateformsopt_label_submit_btn,
472
  );
473
- endif;
474
 
475
  /* Referring site or page, if any */
476
  if ( ! empty( $_SERVER['HTTP_REFERER'] ) ) {
@@ -508,104 +502,6 @@ class PirateForms_Public {
508
  return $output;
509
  }
510
 
511
- /**
512
- * Renders all the fields relevant to the form
513
- *
514
- * @param PirateForms_PhpFormBuilder $form_builder The form builder object.
515
- */
516
- public function render_fields( $form_builder ) {
517
- echo '<div class="pirate-forms-fields-container"><div class="pirate_forms_three_inputs_wrap">';
518
-
519
- if ( isset( $form_builder->contact_name ) ) {
520
- echo $form_builder->contact_name;
521
- }
522
-
523
- if ( isset( $form_builder->contact_email ) ) {
524
- echo $form_builder->contact_email;
525
- }
526
-
527
- if ( isset( $form_builder->contact_subject ) ) {
528
- echo $form_builder->contact_subject;
529
- }
530
-
531
- if ( isset( $form_builder->custom_fields ) ) {
532
- echo $form_builder->custom_fields;
533
- }
534
-
535
- echo '</div>';
536
-
537
- if ( isset( $form_builder->contact_message ) ) {
538
- echo $form_builder->contact_message;
539
- }
540
-
541
- if ( isset( $form_builder->attachment ) ) {
542
- echo $form_builder->attachment;
543
- }
544
-
545
- if ( isset( $form_builder->contact_checkbox ) ) {
546
- echo $form_builder->contact_checkbox;
547
- }
548
-
549
- echo '<div class="pirate-forms-footer">';
550
-
551
- if ( isset( $form_builder->captcha ) ) {
552
- echo $form_builder->captcha;
553
- }
554
-
555
- echo $form_builder->contact_submit;
556
-
557
- echo '</div></div>';
558
- }
559
-
560
- /**
561
- * Renders all the errors relevant to the form
562
- *
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
- /**
590
- * Renders the thank you message relevant to the form
591
- *
592
- * @param PirateForms_PhpFormBuilder $form_builder The form builder object.
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
  *
@@ -690,19 +586,19 @@ class PirateForms_Public {
690
  if ( empty( $site_recipients ) ) {
691
  $_SESSION[ $error_key ]['pirate-forms-recipients-email'] = __( 'Please enter one or more Contact submission recipients', 'pirate-forms' );
692
  }
693
- /**
694
- ****** Sanitize and validate IP */
695
- $contact_ip = filter_var( $_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP );
696
- /* for the case of a Web server behind a reverse proxy */
697
- if ( array_key_exists( 'HTTP_X_FORWARDED_FOR', $_SERVER ) ) {
698
- $contact_ip_tmp = explode( ',', $_SERVER['HTTP_X_FORWARDED_FOR'] );
699
- if ( ! empty( $contact_ip_tmp ) ) {
700
- $contact_ip = array_pop( $contact_ip_tmp );
 
 
701
  }
702
- }
703
 
704
- // If valid and present, create a link to an IP search
705
- if ( ! empty( $contact_ip ) ) {
706
  $body['body'][ __( 'IP address', 'pirate-forms' ) ] = $contact_ip;
707
  $body['body'][ __( 'IP search', 'pirate-forms' ) ] = "http://whatismyipaddress.com/ip/$contact_ip";
708
  $body['magic_tags'] += array( 'ip' => $contact_ip );
@@ -771,6 +667,23 @@ class PirateForms_Public {
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' ) );
@@ -786,6 +699,7 @@ class PirateForms_Public {
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 );
@@ -982,12 +896,12 @@ class PirateForms_Public {
982
  return false;
983
  }
984
  $response = wp_remote_get( 'https://www.google.com/recaptcha/api/siteverify?secret=' . $pirateformsopt_recaptcha_secretkey . '&response=' . $captcha . '&remoteip=' . $_SERVER['REMOTE_ADDR'] );
985
- if ( ! empty( $response ) ) :
986
  $response_body = wp_remote_retrieve_body( $response );
987
- endif;
988
- if ( ! empty( $response_body ) ) :
989
  $result = json_decode( $response_body, true );
990
- endif;
991
  if ( isset( $result['success'] ) && ( $result['success'] == false ) ) {
992
  $_SESSION[ $error_key ]['pirate-forms-captcha'] = __( 'Incorrect CAPTCHA', 'pirate-forms' );
993
 
@@ -1018,7 +932,7 @@ class PirateForms_Public {
1018
  $contact_name = null;
1019
  $contact_subject = null;
1020
  $message = null;
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 ] ) ) : '';
@@ -1330,54 +1244,50 @@ class PirateForms_Public {
1330
  $pirateformsopt_smtp_password = $pirate_forms_options['pirateformsopt_smtp_password'];
1331
  $pirateformsopt_use_secure = $pirate_forms_options['pirateformsopt_use_secure'];
1332
  $pirateformsopt_use_smtp_authentication = $pirate_forms_options['pirateformsopt_use_smtp_authentication'];
1333
- if ( ! empty( $pirateformsopt_use_smtp ) && ( $pirateformsopt_use_smtp == 'yes' ) && ! empty( $pirateformsopt_smtp_host ) && ! empty( $pirateformsopt_smtp_port ) ) :
1334
  // @codingStandardsIgnoreStart
1335
  $phpmailer->isSMTP();
1336
  $phpmailer->Host = $pirateformsopt_smtp_host;
1337
- if ( ! empty( $pirateformsopt_use_smtp_authentication ) && ( $pirateformsopt_use_smtp_authentication == 'yes' ) && ! empty( $pirateformsopt_smtp_username ) && ! empty( $pirateformsopt_smtp_password ) ) :
1338
  $phpmailer->SMTPAuth = true; // Force it to use Username and Password to authenticate
1339
  $phpmailer->Port = $pirateformsopt_smtp_port;
1340
  $phpmailer->Username = $pirateformsopt_smtp_username;
1341
  $phpmailer->Password = $pirateformsopt_smtp_password;
1342
- endif;
1343
 
1344
  if ( ! empty( $pirateformsopt_use_secure ) ) {
1345
  $phpmailer->SMTPSecure = $pirateformsopt_use_secure;
1346
  }
1347
  // @codingStandardsIgnoreEnd
1348
- endif;
1349
 
1350
  do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'phpmailer config %s', print_r( $phpmailer, true ) ), 'debug', __FILE__, __LINE__ );
1351
  }
1352
 
1353
  /**
1354
- * Alter classes and wrapper of form elements for compatibility reasons with differen themes.
1355
  *
1356
  * @param array $elements The form elements.
1357
  *
1358
  * @return array The form elements.
1359
  */
1360
  public function compatibility_class( $elements ) {
 
1361
  if ( function_exists( 'zerif_setup' ) ) {
 
 
 
 
 
 
 
1362
  foreach ( $elements as $k => $element ) {
1363
- if ( $element['id'] == 'pirate-forms-contact-submit' ) {
1364
- $elements[ $k ]['class'] = 'btn btn-primary custom-button red-btn pirate-forms-submit-button';
1365
- }
1366
- if ( $element['id'] == 'pirate-forms-contact-name' ) {
1367
- $elements[ $k ]['wrap']['class'] = 'col-lg-4 col-sm-4 form_field_wrap';
1368
- $elements[ $k ]['class'] = 'form-control input';
1369
- }
1370
- if ( $element['id'] == 'pirate-forms-contact-email' ) {
1371
- $elements[ $k ]['wrap']['class'] = 'col-lg-4 col-sm-4 form_field_wrap';
1372
- $elements[ $k ]['class'] = 'form-control input';
1373
- }
1374
- if ( $element['id'] == 'pirate-forms-contact-subject' ) {
1375
- $elements[ $k ]['wrap']['class'] = 'col-lg-4 col-sm-4 form_field_wrap';
1376
- $elements[ $k ]['class'] = 'form-control input';
1377
  }
1378
- if ( $element['id'] == 'pirate-forms-contact-message' ) {
1379
- $elements[ $k ]['wrap']['class'] = 'col-lg-12 col-sm-12 form_field_wrap';
1380
- $elements[ $k ]['class'] = 'form-control input';
1381
  }
1382
  }
1383
  }
@@ -1385,6 +1295,69 @@ class PirateForms_Public {
1385
  return $elements;
1386
  }
1387
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1388
  /**
1389
  * Register REST endpoints.
1390
  */
130
 
131
  /* style for frontpage contact */
132
  wp_register_style( 'pirate_forms_front_styles', PIRATEFORMS_URL . 'public/css/front.css', array(), $this->version );
 
133
 
134
+ /* recaptcha js */
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();
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
+ }
147
  wp_localize_script(
148
  'pirate_forms_scripts', 'pirateFormsObject', array(
149
  'errors' => $pirate_forms_errors,
 
 
 
 
150
  'rest' => array(
151
  'submit' => array(
152
  'url' => get_rest_url( null, PIRATEFORMS_SLUG . '/v' . intval( PIRATEFORMS_API_VERSION ) . '/send_email/' ),
155
  ),
156
  )
157
  );
158
+
159
+ wp_enqueue_script( 'pirate-forms-custom-spam', PIRATEFORMS_URL . 'public/js/custom-spam.js', array( 'jquery' ) );
160
+ wp_localize_script(
161
+ 'pirate-forms-custom-spam', 'pf', array(
162
+ 'spam' => array(
163
+ 'label' => apply_filters( 'pirate_forms_custom_spam_label', __( 'I\'m human!', 'pirate-forms' ) ),
164
+ 'value' => wp_create_nonce( PIRATEFORMS_NAME ),
165
+ ),
166
+ )
167
+ );
168
+
169
  }
170
 
171
  /**
257
  'value' => wp_create_nonce( get_bloginfo( 'admin_email' ) . $nonce_append ),
258
  );
259
  }
260
+ if ( ! empty( $pirate_forms_options ) ) {
261
  $field = $pirate_forms_options['pirateformsopt_name_field'];
262
  $label = $pirate_forms_options['pirateformsopt_label_name'];
263
  $subjectField = $pirate_forms_options['pirateformsopt_subject_field'];
264
 
265
  /**
266
  ****** Name field */
267
+ if ( ! empty( $field ) && ! empty( $label ) ) {
268
  $required = $field === 'req' ? true : false;
269
  $wrap_classes = array(
270
  ( ! empty( $subjectField ) ? 'col-xs-12 col-sm-6' : 'col-xs-12' ) . ' contact_name_wrap pirate_forms_three_inputs form_field_wrap',
274
  $wrap_classes[] = 'error';
275
  }
276
  $elements[] = array(
277
+ 'front_end' => true,
278
  'placeholder' => stripslashes( sanitize_text_field( $label ) ),
279
+ 'required' => $field === 'req' ? true : false,
280
  'required_msg' => $pirate_forms_options['pirateformsopt_label_err_name'],
281
  'type' => 'text',
282
  'id' => 'pirate-forms-contact-name',
 
 
 
 
 
283
  'value' => empty( $thank_you_message ) && isset( $_REQUEST['pirate-forms-contact-name'] ) ? $_REQUEST['pirate-forms-contact-name'] : '',
284
+ 'wrap_class' => implode( ' ', $wrap_classes ),
285
  );
286
+ }
287
 
288
  $field = $pirate_forms_options['pirateformsopt_email_field'];
289
  $label = $pirate_forms_options['pirateformsopt_label_email'];
290
 
291
  /**
292
  ****** Email field */
293
+ if ( ! empty( $field ) && ! empty( $label ) ) {
294
  $required = $field === 'req' ? true : false;
295
  $wrap_classes = array(
296
  ( ! empty( $subjectField ) ? 'col-xs-12 col-sm-6' : 'col-xs-12' ) . ' contact_email_wrap pirate_forms_three_inputs form_field_wrap',
300
  $wrap_classes[] = 'error';
301
  }
302
  $elements[] = array(
303
+ 'front_end' => true,
304
  'placeholder' => stripslashes( sanitize_text_field( $label ) ),
305
+ 'required' => $field === 'req' ? true : false,
306
  'required_msg' => $pirate_forms_options['pirateformsopt_label_err_email'],
307
  'type' => 'email',
308
  'id' => 'pirate-forms-contact-email',
 
 
 
 
 
309
  'value' => empty( $thank_you_message ) && isset( $_REQUEST['pirate-forms-contact-email'] ) ? $_REQUEST['pirate-forms-contact-email'] : '',
310
+ 'wrap_class' => implode( ' ', $wrap_classes ),
311
  );
312
+ }
313
 
314
  $field = $pirate_forms_options['pirateformsopt_subject_field'];
315
  $label = $pirate_forms_options['pirateformsopt_label_subject'];
316
 
317
  /**
318
  ****** Subject field */
319
+ if ( ! empty( $field ) && ! empty( $label ) ) {
320
  $required = $field === 'req' ? true : false;
321
  $wrap_classes = array(
322
  'col-xs-12 contact_subject_wrap pirate_forms_three_inputs form_field_wrap',
326
  $wrap_classes[] = 'error';
327
  }
328
  $elements[] = array(
329
+ 'front_end' => true,
330
  'placeholder' => stripslashes( sanitize_text_field( $label ) ),
331
+ 'required' => $field === 'req' ? true : false,
332
  'required_msg' => $pirate_forms_options['pirateformsopt_label_err_subject'],
333
  'type' => 'text',
334
  'id' => 'pirate-forms-contact-subject',
 
 
 
 
 
335
  'value' => empty( $thank_you_message ) && isset( $_REQUEST['pirate-forms-contact-subject'] ) ? $_REQUEST['pirate-forms-contact-subject'] : '',
336
+ 'wrap_class' => implode( ' ', $wrap_classes ),
337
  );
338
+ }
339
 
340
  $field = $pirate_forms_options['pirateformsopt_message_field'];
341
  $label = $pirate_forms_options['pirateformsopt_label_message'];
342
 
343
  /**
344
  ****** Message field */
345
+ if ( ! empty( $field ) && ! empty( $label ) ) {
346
  $required = $field === 'req' ? true : false;
347
+ $wrap_classes = array(
348
+ 'col-xs-12 contact_message_wrap pirate_forms_three_inputs form_field_wrap',
349
+ );
350
  // If this field was submitted with invalid data
351
  if ( isset( $_SESSION[ $error_key ]['contact-message'] ) ) {
352
  $wrap_classes[] = 'error';
353
  }
354
+
355
  $elements[] = array(
356
+ 'front_end' => true,
357
  'placeholder' => stripslashes( sanitize_text_field( $label ) ),
358
+ 'required' => $field === 'req' ? true : false,
359
  'required_msg' => $pirate_forms_options['pirateformsopt_label_err_no_content'],
360
  'type' => 'textarea',
 
361
  'id' => 'pirate-forms-contact-message',
 
 
 
 
362
  'value' => empty( $thank_you_message ) && isset( $_REQUEST['pirate-forms-contact-message'] ) ? $_REQUEST['pirate-forms-contact-message'] : '',
363
+ 'wrap_class' => implode( ' ', $wrap_classes ),
364
  );
365
+ }
366
 
367
  $field = $pirate_forms_options['pirateformsopt_attachment_field'];
368
 
369
  /**
370
  ****** Attachment field */
371
+ if ( ! empty( $field ) && 'no' !== $field ) {
372
  $required = $field === 'req' ? true : false;
373
  $wrap_classes = array( 'col-xs-12 form_field_wrap contact_attachment_wrap' );
374
  // If this field was submitted with invalid data
376
  $wrap_classes[] = 'error';
377
  }
378
  $elements[] = array(
379
+ 'front_end' => true,
380
+ 'required' => $field === 'req' ? true : false,
381
  'required_msg' => $pirate_forms_options['pirateformsopt_label_err_no_attachment'],
382
  'type' => 'file',
383
+ 'title' => __( 'Upload file', 'pirate-forms' ),
384
  'id' => 'pirate-forms-attachment',
385
+ 'wrap_class' => implode( ' ', $wrap_classes ),
 
 
 
386
  );
387
+ }
388
 
389
  if ( array_key_exists( 'pirateformsopt_checkbox_field', $pirate_forms_options ) ) {
390
  $field = $pirate_forms_options['pirateformsopt_checkbox_field'];
392
 
393
  /**
394
  ****** checkbox field */
395
+ if ( ! empty( $field ) && ! empty( $label ) ) {
396
  $required = $field === 'req' ? true : false;
397
  $wrap_classes = array( 'col-xs-12 form_field_wrap contact_checkbox_wrap ' );
398
  // If this field was submitted with invalid data
400
  $wrap_classes[] = 'error';
401
  }
402
  $elements[] = array(
403
+ 'front_end' => true,
404
  'required' => $required,
405
  'required_msg' => $pirate_forms_options['pirateformsopt_label_err_no_checkbox'],
406
  'type' => 'checkbox',
 
407
  'id' => 'pirate-forms-contact-checkbox',
408
  'wrap' => array(
409
  'type' => 'div',
414
  'yes' => stripslashes( $label ),
415
  ),
416
  );
417
+ }
418
  }
419
 
420
  /**
421
  ******* ReCaptcha */
422
+ 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'] ) {
423
  $pirateformsopt_recaptcha_sitekey = $pirate_forms_options['pirateformsopt_recaptcha_sitekey'];
424
  $pirateformsopt_recaptcha_secretkey = $pirate_forms_options['pirateformsopt_recaptcha_secretkey'];
425
  $elements[] = array(
426
+ 'front_end' => true,
427
+ 'id' => 'pirate-forms-captcha',
428
  'placeholder' => stripslashes( sanitize_text_field( $label ) ),
429
+ 'type' => 'captcha',
 
430
  'custom' => array( 'data-sitekey' => $pirateformsopt_recaptcha_sitekey ),
431
  'id' => 'pirate-forms-captcha',
432
  'wrap' => array(
434
  'class' => implode( ' ', apply_filters( 'pirateform_wrap_classes_captcha', array( 'col-xs-12 ' . ( $pirate_forms_options['pirateformsopt_recaptcha_field'] !== 'yes' ? 'col-sm-6 ' : '' ) . 'form_field_wrap form_captcha_wrap' ) ) ),
435
  ),
436
  );
437
+ }
438
 
439
+ if ( ! empty( $pirate_forms_options['pirateformsopt_recaptcha_field'] ) && 'custom' === $pirate_forms_options['pirateformsopt_recaptcha_field'] ) {
440
  $elements[] = array(
441
+ 'front_end' => true,
442
+ 'type' => 'spam',
443
  'id' => 'pirate-forms-maps-custom',
 
 
 
 
444
  );
445
+ }
446
 
447
  /**
448
  ****** Submit button */
454
  $pirateformsopt_label_submit_btn = __( 'Submit', 'pirate-forms' );
455
  }
456
  $elements[] = array(
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' : '' ),
464
  ),
465
  'value' => $pirateformsopt_label_submit_btn,
466
  );
467
+ }
468
 
469
  /* Referring site or page, if any */
470
  if ( ! empty( $_SERVER['HTTP_REFERER'] ) ) {
502
  return $output;
503
  }
504
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
505
  /**
506
  * Process the form after submission
507
  *
586
  if ( empty( $site_recipients ) ) {
587
  $_SESSION[ $error_key ]['pirate-forms-recipients-email'] = __( 'Please enter one or more Contact submission recipients', 'pirate-forms' );
588
  }
589
+
590
+ $contact_ip = null;
591
+ if ( isset( $pirate_forms_options['pirateformsopt_store_ip'] ) && 'yes' === $pirate_forms_options['pirateformsopt_store_ip'] ) {
592
+ $contact_ip = filter_var( $_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP );
593
+ /* for the case of a Web server behind a reverse proxy */
594
+ if ( array_key_exists( 'HTTP_X_FORWARDED_FOR', $_SERVER ) ) {
595
+ $contact_ip_tmp = explode( ',', $_SERVER['HTTP_X_FORWARDED_FOR'] );
596
+ if ( ! empty( $contact_ip_tmp ) ) {
597
+ $contact_ip = array_pop( $contact_ip_tmp );
598
+ }
599
  }
 
600
 
601
+ // If valid and present, create a link to an IP search
 
602
  $body['body'][ __( 'IP address', 'pirate-forms' ) ] = $contact_ip;
603
  $body['body'][ __( 'IP search', 'pirate-forms' ) ] = "http://whatismyipaddress.com/ip/$contact_ip";
604
  $body['magic_tags'] += array( 'ip' => $contact_ip );
667
  }
668
  $send_from_name = $site_name;
669
 
670
+ $site_email = sanitize_text_field( $pirate_forms_options['pirateformsopt_email'] );
671
+ if ( ! empty( $pirate_forms_contact_name ) ) {
672
+ $site_name = $pirate_forms_contact_name;
673
+ } else {
674
+ $site_name = htmlspecialchars_decode( get_bloginfo( 'name' ) );
675
+ }
676
+
677
+ // Notification recipients
678
+ $site_recipients = sanitize_text_field( $pirate_forms_options['pirateformsopt_email_recipients'] );
679
+ $site_recipients = explode( ',', $site_recipients );
680
+ $site_recipients = array_map( 'trim', $site_recipients );
681
+ $site_recipients = array_map( 'sanitize_email', $site_recipients );
682
+ $site_recipients = implode( ',', $site_recipients );
683
+ // No name? Use the submitter email address, if one is present
684
+ if ( empty( $pirate_forms_contact_name ) ) {
685
+ $pirate_forms_contact_name = ! empty( $pirate_forms_contact_email ) ? $pirate_forms_contact_email : '[None given]';
686
+ }
687
  // Send an email notification to the correct address
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' ) );
699
  }
700
 
701
  $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 );
702
+
703
  $mail_body = PirateForms_Util::replace_magic_tags( $mail_body, $body );
704
 
705
  do_action( 'pirate_forms_before_sending', $pirate_forms_contact_email, $site_recipients, $subject, $mail_body, $headers, $attachments );
896
  return false;
897
  }
898
  $response = wp_remote_get( 'https://www.google.com/recaptcha/api/siteverify?secret=' . $pirateformsopt_recaptcha_secretkey . '&response=' . $captcha . '&remoteip=' . $_SERVER['REMOTE_ADDR'] );
899
+ if ( ! empty( $response ) ) {
900
  $response_body = wp_remote_retrieve_body( $response );
901
+ }
902
+ if ( ! empty( $response_body ) ) {
903
  $result = json_decode( $response_body, true );
904
+ }
905
  if ( isset( $result['success'] ) && ( $result['success'] == false ) ) {
906
  $_SESSION[ $error_key ]['pirate-forms-captcha'] = __( 'Incorrect CAPTCHA', 'pirate-forms' );
907
 
932
  $contact_name = null;
933
  $contact_subject = null;
934
  $message = null;
935
+ $fields = PirateForms_Util::$DEFAULT_FIELDS;
936
 
937
  foreach ( $fields as $field ) {
938
  $value = isset( $this->_post[ 'pirate-forms-contact-' . $field ] ) ? sanitize_text_field( trim( $this->_post[ 'pirate-forms-contact-' . $field ] ) ) : '';
1244
  $pirateformsopt_smtp_password = $pirate_forms_options['pirateformsopt_smtp_password'];
1245
  $pirateformsopt_use_secure = $pirate_forms_options['pirateformsopt_use_secure'];
1246
  $pirateformsopt_use_smtp_authentication = $pirate_forms_options['pirateformsopt_use_smtp_authentication'];
1247
+ if ( ! empty( $pirateformsopt_use_smtp ) && ( $pirateformsopt_use_smtp == 'yes' ) && ! empty( $pirateformsopt_smtp_host ) && ! empty( $pirateformsopt_smtp_port ) ) {
1248
  // @codingStandardsIgnoreStart
1249
  $phpmailer->isSMTP();
1250
  $phpmailer->Host = $pirateformsopt_smtp_host;
1251
+ if ( ! empty( $pirateformsopt_use_smtp_authentication ) && ( $pirateformsopt_use_smtp_authentication == 'yes' ) && ! empty( $pirateformsopt_smtp_username ) && ! empty( $pirateformsopt_smtp_password ) ) {
1252
  $phpmailer->SMTPAuth = true; // Force it to use Username and Password to authenticate
1253
  $phpmailer->Port = $pirateformsopt_smtp_port;
1254
  $phpmailer->Username = $pirateformsopt_smtp_username;
1255
  $phpmailer->Password = $pirateformsopt_smtp_password;
1256
+ }
1257
 
1258
  if ( ! empty( $pirateformsopt_use_secure ) ) {
1259
  $phpmailer->SMTPSecure = $pirateformsopt_use_secure;
1260
  }
1261
  // @codingStandardsIgnoreEnd
1262
+ }
1263
 
1264
  do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'phpmailer config %s', print_r( $phpmailer, true ) ), 'debug', __FILE__, __LINE__ );
1265
  }
1266
 
1267
  /**
1268
+ * Alter classes and wrapper of form elements for compatibility reasons with different themes.
1269
  *
1270
  * @param array $elements The form elements.
1271
  *
1272
  * @return array The form elements.
1273
  */
1274
  public function compatibility_class( $elements ) {
1275
+ $theme = null;
1276
  if ( function_exists( 'zerif_setup' ) ) {
1277
+ $theme = 'zerif';
1278
+ } else {
1279
+ $current_theme = wp_get_theme();
1280
+ $theme = sanitize_key( $current_theme->get( 'Name' ) );
1281
+ }
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 );
 
 
 
 
 
 
 
 
 
 
 
1288
  }
1289
+ if ( method_exists( $this, "{$theme}_customization_field" ) ) {
1290
+ add_filter( "pirateform_field_classes_{$id}", array( $this, "{$theme}_customization_field" ), 10, 3 );
 
1291
  }
1292
  }
1293
  }
1295
  return $elements;
1296
  }
1297
 
1298
+ /**
1299
+ * Alter classes of form elements for compatibility reasons with Zerif.
1300
+ *
1301
+ * @param string $classes The classes.
1302
+ * @param string $name The name of the element.
1303
+ * @param string $type The type of the element.
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;
1328
+ }
1329
+
1330
+ /**
1331
+ * Alter wrap classes of form elements for compatibility reasons with Zerif.
1332
+ *
1333
+ * @param array $classes The classes.
1334
+ * @param string $name The name of the element.
1335
+ * @param string $type The type of the element.
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
+ }
1360
+
1361
  /**
1362
  * Register REST endpoints.
1363
  */
public/css/front.css CHANGED
@@ -1,5 +1,5 @@
1
  /*
2
- Version: 2.4.2
3
  */
4
  .pirate_forms_wrap .form_field_wrap,
5
  .widget .pirate_forms_wrap .form_field_wrap {
@@ -112,6 +112,10 @@ Version: 2.4.2
112
  margin-left: 5px;
113
  }
114
 
 
 
 
 
115
  @media (max-width: 480px) {
116
  .pirate_forms_wrap .pirate-forms-footer .form_field_wrap,
117
  .pirate_forms_wrap .form_field_wrap .pirate-forms-submit-button {
1
  /*
2
+ Version: 2.4.3
3
  */
4
  .pirate_forms_wrap .form_field_wrap,
5
  .widget .pirate_forms_wrap .form_field_wrap {
112
  margin-left: 5px;
113
  }
114
 
115
+ .pirate_forms .contact_checkbox_wrap #pirate-forms-contact-checkbox, .pirate_forms .contact_checkbox_wrap p {
116
+ display: inline-block;
117
+ }
118
+
119
  @media (max-width: 480px) {
120
  .pirate_forms_wrap .pirate-forms-footer .form_field_wrap,
121
  .pirate_forms_wrap .form_field_wrap .pirate-forms-submit-button {
public/js/custom-spam.js ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* global pf */
2
+ /* global jQuery */
3
+ (function($, pf){
4
+
5
+ $(document).ready(function() {
6
+ onDocumentReady();
7
+ });
8
+
9
+ $(window).load(function() {
10
+ onWindowLoad();
11
+ });
12
+
13
+ function onDocumentReady() {
14
+ // fired when a form is changed from the inspector.
15
+ if(pf.spam.gutenberg === 1){
16
+ jQuery('body').delegate('.pirate-forms-maps-custom', 'addCustomSpam', function(){
17
+ var i = 0;
18
+ addCustomSpam(i++, jQuery(this));
19
+ });
20
+ }
21
+
22
+ // for the front end.
23
+ jQuery('.pirate-forms-maps-custom').each(function(i){
24
+ addCustomSpam(i, jQuery(this));
25
+ });
26
+ }
27
+
28
+ function onWindowLoad() {
29
+ // fired when a saved form is loaded in gutenberg.
30
+ if(pf.spam.gutenberg === 1){
31
+ jQuery('.pirate-forms-maps-custom').each(function(i){
32
+ addCustomSpam(i, jQuery(this));
33
+ });
34
+ }
35
+ }
36
+
37
+ function addCustomSpam(i, object){
38
+ var $id = 'xobkcehc-' + i;
39
+ object.empty().html(jQuery('<input id="' + $id + '" name="xobkcehc" type="' + 'xobkcehc'.split('').reverse().join('') + '" value="' + pf.spam.value + '"><label for="' + $id + '"><span>' + pf.spam.label + '</span></label>'));
40
+ }
41
+ })(jQuery, pf);
public/js/scripts.js CHANGED
@@ -38,14 +38,6 @@
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);
38
  }, 'slow');
39
  }
40
 
 
 
 
 
 
 
 
 
41
  // support ajax forms.
42
  $('.pirate-forms-submit-button-ajax').closest('form').submit(function(){
43
  var form = $(this);
public/partials/fields/button.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Provide a public-facing view for the button field.
5
+ *
6
+ * This file provides a public-facing view for the button field.
7
+ *
8
+ * @package PirateForms
9
+ * @subpackage PirateForms/public/partials
10
+ */
11
+ ?>
12
+
13
+ <?php
14
+
15
+ $name = 'submit';
16
+
17
+ if ( is_null( $wrap_classes ) ) {
18
+ $wrap_classes = array(
19
+ 'col-xs-12 col-sm-6 form_field_wrap',
20
+ "contact_{$name}_wrap",
21
+ );
22
+ }
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>
public/partials/fields/captcha.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Provide a public-facing view for the CATPCHA field.
5
+ *
6
+ * This file provides a public-facing view for the CATPCHA field.
7
+ *
8
+ * @package PirateForms
9
+ * @subpackage PirateForms/public/partials
10
+ */
11
+ ?>
12
+
13
+ <?php
14
+ if ( is_null( $wrap_classes ) ) {
15
+ $wrap_classes = array(
16
+ 'col-xs-12 col-sm-6 form_field_wrap',
17
+ "form_{$name}_wrap",
18
+ );
19
+ }
20
+
21
+ $attributes = '';
22
+ if ( isset( $args['custom'] ) ) {
23
+ foreach ( $args['custom'] as $key => $val ) {
24
+ $attributes .= ' ' . $key . '="' . esc_attr( $val ) . '"';
25
+ }
26
+ }
27
+
28
+ ?>
29
+
30
+ <div class="<?php echo implode( ' ', apply_filters( "pirateform_wrap_classes_{$name}", $wrap_classes, $name, $args['type'] ) ); ?>">
31
+ <div id="<?php echo $args['id']; ?>" class="<?php echo apply_filters( "pirateform_field_classes_{$name}", 'g-recaptcha pirate-forms-google-recaptcha', $name, $args['type'] ); ?>" <?php echo $attributes; ?>>
32
+ </div>
33
+ </div>
public/partials/fields/checkbox.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Provide a public-facing view for the input checkbox field.
5
+ *
6
+ * This file provides a public-facing view for the input checkbox field.
7
+ *
8
+ * @package PirateForms
9
+ * @subpackage PirateForms/public/partials
10
+ */
11
+ ?>
12
+
13
+ <?php
14
+ if ( is_null( $wrap_classes ) ) {
15
+ $wrap_classes = array(
16
+ 'col-xs-12',
17
+ 'pirate_forms_three_inputs form_field_wrap',
18
+ "contact_{$name}_wrap",
19
+ isset( $args['wrap_class'] ) ? $args['wrap_class'] : '',
20
+ );
21
+ }
22
+
23
+ $options = apply_filters( 'pirate_forms_checkbox_options', $args['options'], $name );
24
+ if ( count( $options ) > 1 ) {
25
+ $args['name'] = $name . '[]';
26
+ }
27
+
28
+ ?>
29
+
30
+ <div class="<?php echo implode( ' ', apply_filters( "pirateform_wrap_classes_{$name}", $wrap_classes, $name, $args['type'] ) ); ?>">
31
+ <?php
32
+ foreach ( $options as $key => $val ) {
33
+ $extra = isset( $args['value'] ) && $key == $args['value'] ? 'checked' : '';
34
+ ?>
35
+ <input type="checkbox" class="<?php echo apply_filters( "pirateform_field_classes_{$name}", '', $name, $args['type'] ); ?>" <?php echo $extra; ?> <?php echo $this->get_common( $args ); ?> value="<?php echo esc_attr( $key ); ?>">&nbsp;<?php echo $val; ?>
36
+ <?php
37
+ }
38
+ ?>
39
+ </div>
public/partials/fields/email.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Provide a public-facing view for the input text field.
5
+ *
6
+ * This file provides a public-facing view for the input text field.
7
+ *
8
+ * @package PirateForms
9
+ * @subpackage PirateForms/public/partials
10
+ */
11
+ ?>
12
+
13
+ <?php
14
+ if ( is_null( $wrap_classes ) ) {
15
+ $wrap_classes = array(
16
+ 'col-xs-12',
17
+ 'pirate_forms_three_inputs form_field_wrap',
18
+ "contact_{$name}_wrap",
19
+ isset( $args['wrap_class'] ) ? $args['wrap_class'] : '',
20
+ );
21
+ }
22
+ ?>
23
+
24
+ <div class="<?php echo implode( ' ', apply_filters( "pirateform_wrap_classes_{$name}", $wrap_classes, $name, $args['type'] ) ); ?>">
25
+ <?php echo $label; ?>
26
+ <input type="email" class="<?php echo apply_filters( "pirateform_field_classes_{$name}", 'form-control', $name, $args['type'] ); ?>" <?php echo $this->get_common( $args, array( 'value' ) ); ?> >
27
+ </div>
public/partials/fields/file.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Provide a public-facing view for the input file field.
5
+ *
6
+ * This file provides a public-facing view for the input file field.
7
+ *
8
+ * @package PirateForms
9
+ * @subpackage PirateForms/public/partials
10
+ */
11
+ ?>
12
+
13
+ <?php
14
+ if ( is_null( $wrap_classes ) ) {
15
+ $wrap_classes = array(
16
+ 'col-xs-12 form_field_wrap',
17
+ "contact_{$name}_wrap",
18
+ isset( $args['wrap_class'] ) ? $args['wrap_class'] : '',
19
+ );
20
+ }
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'] ) ) {
29
+ $text_args['required'] = $args['required'];
30
+ $text_args['required_msg'] = $args['required_msg'];
31
+ unset( $args['required'] );
32
+ unset( $args['required_msg'] );
33
+ }
34
+
35
+ ?>
36
+
37
+ <div class="<?php echo implode( ' ', apply_filters( "pirateform_wrap_classes_{$name}", $wrap_classes, $name, $args['type'] ) ); ?>">
38
+ <div class="pirate-forms-file-upload-wrapper">
39
+ <div class="pirate-forms-file-upload-wrapper"><input type="file" class="<?php echo apply_filters( "pirateform_field_classes_{$name}", 'form-control', $name, $args['type'] ); ?>" <?php echo $this->get_common( $text_args, array( 'value' ) ); ?> tabindex="-1"></div>
40
+ </div>
41
+ </div>
public/partials/fields/number.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Provide a public-facing view for the input number field.
5
+ *
6
+ * This file provides a public-facing view for the input number field.
7
+ *
8
+ * @package PirateForms
9
+ * @subpackage PirateForms/public/partials
10
+ */
11
+ ?>
12
+
13
+ <?php
14
+ if ( is_null( $wrap_classes ) ) {
15
+ $wrap_classes = array(
16
+ 'col-xs-12',
17
+ 'pirate_forms_three_inputs form_field_wrap',
18
+ "contact_{$name}_wrap",
19
+ isset( $args['wrap_class'] ) ? $args['wrap_class'] : '',
20
+ );
21
+ }
22
+
23
+ $min = isset( $args['min'] ) ? $args['min'] : 0;
24
+ $max = isset( $args['max'] ) ? $args['max'] : PHP_INT_MAX;
25
+
26
+ ?>
27
+
28
+ <div class="<?php echo implode( ' ', apply_filters( "pirateform_wrap_classes_{$name}", $wrap_classes, $name, $args['type'] ) ); ?>">
29
+ <?php echo $label; ?>
30
+ <input type="number" min="<?php echo $min; ?>" max="<?php echo $max; ?>" class="<?php echo apply_filters( "pirateform_field_classes_{$name}", 'form-control', $name, $args['type'] ); ?>" <?php echo $this->get_common( $args, array( 'value' ) ); ?> >
31
+ </div>
public/partials/fields/spam.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Provide a public-facing view for the custom spam field.
5
+ *
6
+ * This file provides a public-facing view for the custom spam field.
7
+ *
8
+ * @package PirateForms
9
+ * @subpackage PirateForms/public/partials
10
+ */
11
+ ?>
12
+
13
+ <?php
14
+ $wrap_classes = array(
15
+ 'col-xs-12 col-sm-6 form_field_wrap pirateform_wrap_classes_spam_wrap',
16
+ );
17
+
18
+ ?>
19
+
20
+ <div class="<?php echo implode( ' ', apply_filters( 'pirateform_wrap_classes_spam', $wrap_classes, $name, $args['type'] ) ); ?>">
21
+ <div id="<?php echo $args['id']; ?>" class="<?php echo apply_filters( 'pirateform_field_classes_spam', 'pirate-forms-maps-custom', $name, $args['type'] ); ?>"></div>
22
+ </div>
public/partials/fields/tel.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Provide a public-facing view for the input phone field.
5
+ *
6
+ * This file provides a public-facing view for the input phone field.
7
+ *
8
+ * @package PirateForms
9
+ * @subpackage PirateForms/public/partials
10
+ */
11
+ ?>
12
+
13
+ <?php
14
+ if ( is_null( $wrap_classes ) ) {
15
+ $wrap_classes = array(
16
+ 'col-xs-12',
17
+ 'pirate_forms_three_inputs form_field_wrap',
18
+ "contact_{$name}_wrap",
19
+ isset( $args['wrap_class'] ) ? $args['wrap_class'] : '',
20
+ );
21
+ }
22
+ ?>
23
+
24
+ <div class="<?php echo implode( ' ', apply_filters( "pirateform_wrap_classes_{$name}", $wrap_classes, $name, $args['type'] ) ); ?>">
25
+ <?php echo $label; ?>
26
+ <input type="tel" class="<?php echo apply_filters( "pirateform_field_classes_{$name}", 'form-control', $name, $args['type'] ); ?>" <?php echo $this->get_common( $args, array( 'value' ) ); ?> >
27
+ </div>
public/partials/fields/text.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Provide a public-facing view for the input email field.
5
+ *
6
+ * This file provides a public-facing view for the input email field.
7
+ *
8
+ * @package PirateForms
9
+ * @subpackage PirateForms/public/partials
10
+ */
11
+ ?>
12
+
13
+ <?php
14
+ if ( is_null( $wrap_classes ) ) {
15
+ $wrap_classes = array(
16
+ 'col-xs-12',
17
+ 'pirate_forms_three_inputs form_field_wrap',
18
+ "contact_{$name}_wrap",
19
+ isset( $args['wrap_class'] ) ? $args['wrap_class'] : '',
20
+ );
21
+ }
22
+ ?>
23
+
24
+ <div class="<?php echo implode( ' ', apply_filters( "pirateform_wrap_classes_{$name}", $wrap_classes, $name, $args['type'] ) ); ?>">
25
+ <?php echo $label; ?>
26
+ <input type="text" class="<?php echo apply_filters( "pirateform_field_classes_{$name}", 'form-control', $name, $args['type'] ); ?>" <?php echo $this->get_common( $args, array( 'value' ) ); ?> >
27
+ </div>
public/partials/fields/textarea.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Provide a public-facing view for the input textarea field.
5
+ *
6
+ * This file provides a public-facing view for the input textarea field.
7
+ *
8
+ * @package PirateForms
9
+ * @subpackage PirateForms/public/partials
10
+ */
11
+ ?>
12
+
13
+ <?php
14
+ if ( is_null( $wrap_classes ) ) {
15
+ $wrap_classes = array(
16
+ 'col-xs-12 form_field_wrap',
17
+ "contact_{$name}_wrap",
18
+ isset( $args['wrap_class'] ) ? $args['wrap_class'] : '',
19
+ );
20
+ }
21
+
22
+ $cols = isset( $args['cols'] ) ? $args['cols'] : 30;
23
+ $rows = isset( $args['rows'] ) ? $args['rows'] : 5;
24
+
25
+ ?>
26
+
27
+ <div class="<?php echo implode( ' ', apply_filters( "pirateform_wrap_classes_{$name}", $wrap_classes, $name, $args['type'] ) ); ?>">
28
+ <?php echo $label; ?>
29
+ <textarea rows="<?php echo $rows; ?>" cols="<?php echo $cols; ?>" class="<?php echo apply_filters( "pirateform_field_classes_{$name}", 'form-control', $name, $args['type'] ); ?>" <?php echo $this->get_common( $args ); ?> ><?php echo isset( $args['value'] ) ? esc_attr( $args['value'] ) : ''; ?></textarea>
30
+ </div>
public/partials/pirateforms-form.php CHANGED
@@ -13,17 +13,140 @@
13
  */
14
  ?>
15
 
16
- <?php do_action( 'pirate_forms_render_thankyou', $this ); ?>
17
-
18
- <div class="pirate_forms_wrap">
19
- <?php do_action( 'pirate_forms_render_errors', $this ); ?>
20
 
21
- <?php echo $this->form_start; ?>
 
 
22
 
23
- <?php do_action( 'pirate_forms_render_fields', $this ); ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
- <?php echo $this->form_end; ?>
26
- <div class="pirate_forms_clearfix"></div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
- <?php do_action( 'pirate_forms_render_footer', $this ); ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  */
14
  ?>
15
 
16
+ <?php
17
+ $form_id = isset( $this->pirate_forms_options['id'] ) ? $this->pirate_forms_options['id'] : 'default';
18
+ ?>
 
19
 
20
+ <div class="pirate_forms_container <?php echo $this->container_class; ?>" id="pirate_forms_container_<?php echo $form_id; ?>">
21
+ <!-- header -->
22
+ <?php do_action( 'pirate_forms_render_header', $this ); ?>
23
 
24
+ <!-- thank you -->
25
+ <?php
26
+ if ( ! empty( $this->thank_you_message ) ) {
27
+ do_action( 'pirate_forms_before_thankyou_message', $this );
28
+ ?>
29
+ <div class="col-xs-12 pirate_forms_thankyou_wrap">
30
+ <p>
31
+ <?php echo apply_filters( 'pirate_forms_thankyou_message', $this->thank_you_message ); ?>
32
+ </p>
33
+ </div>
34
+ <?php
35
+ do_action( 'pirate_forms_after_thankyou_message', $this );
36
+ }
37
+ ?>
38
 
39
+ <div class="pirate_forms_wrap">
40
+ <!-- errors -->
41
+ <?php
42
+ if ( ! empty( $this->errors ) ) {
43
+ do_action( 'pirate_forms_before_errors', $this );
44
+ ?>
45
+ <div class="col-xs-12 pirate_forms_error_box pirate_forms_error_heading">
46
+ <p>
47
+ <?php echo apply_filters( 'pirate_forms_error_message', __( 'Sorry, an error occured.', 'pirate-forms' ), $this->pirate_forms_options ); ?>
48
+ </p>
49
+ </div>
50
+ <?php
51
+ foreach ( $this->errors as $err ) {
52
+ ?>
53
+ <div class="col-xs-12 pirate_forms_error_box">
54
+ <p>
55
+ <?php echo $err; ?>
56
+ </p>
57
  </div>
58
+ <?php
59
+ }
60
+
61
+ do_action( 'pirate_forms_after_errors', $this );
62
+ }
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"
85
+ enctype="<?php echo $enctype; ?>"
86
+ class="pirate_forms <?php echo implode( ' ', $this->form_classes ); ?>"
87
+ <?php echo $attributes; ?>
88
+ >
89
+ <div class="pirate_forms_three_inputs_wrap <?php echo apply_filters( 'pirate_forms_wrap_classes', '', $this->pirate_forms_options ); ?>">
90
+ <?php
91
+ if ( isset( $this->contact_name ) ) {
92
+ echo $this->contact_name;
93
+ }
94
+
95
+ if ( isset( $this->contact_email ) ) {
96
+ echo $this->contact_email;
97
+ }
98
+
99
+ if ( isset( $this->contact_subject ) ) {
100
+ echo $this->contact_subject;
101
+ }
102
+
103
+ if ( isset( $this->custom_fields ) && ! apply_filters( 'pirate_forms_show_custom_fields_last', false ) ) {
104
+ echo $this->custom_fields;
105
+ }
106
+ ?>
107
+ </div>
108
 
109
+ <?php
110
+ if ( isset( $this->contact_message ) ) {
111
+ echo $this->contact_message;
112
+ }
113
+
114
+ if ( isset( $this->attachment ) ) {
115
+ echo $this->attachment;
116
+ }
117
+
118
+ if ( isset( $this->contact_checkbox ) ) {
119
+ echo $this->contact_checkbox;
120
+ }
121
+
122
+ if ( isset( $this->custom_fields ) && apply_filters( 'pirate_forms_show_custom_fields_last', false ) ) {
123
+ ?>
124
+ <div class="pirate_forms_three_inputs_wrap <?php echo apply_filters( 'pirate_forms_wrap_classes', '', $this->pirate_forms_options ); ?>">
125
+ <?php
126
+ echo $this->custom_fields;
127
+ ?>
128
+ </div>
129
+ <?php
130
+ }
131
+
132
+ if ( isset( $this->captcha ) ) {
133
+ echo $this->captcha;
134
+ }
135
+
136
+ echo $this->contact_submit;
137
+
138
+ echo $this->form_hidden;
139
+ ?>
140
+ </form>
141
+
142
+ <?php
143
+ do_action( 'pirate_forms_after_form', $this );
144
+ ?>
145
+
146
+ <div class="pirate_forms_clearfix"></div>
147
+ </div>
148
+
149
+ <!-- footer -->
150
+ <?php do_action( 'pirate_forms_render_footer', $this ); ?>
151
+
152
+ </div>
readme.md CHANGED
@@ -103,6 +103,7 @@ This plugin started as a fork of https://wordpress.org/plugins/proper-contact-fo
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>.
@@ -265,6 +266,12 @@ You can follow the full documentation [here](http://docs.themeisle.com/article/4
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,6 +293,14 @@ Activating the Pirate Contact Form plugin is just like any other plugin. If you'
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"]
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.3 - 2018-06-25 ###
297
+
298
+ * New Gutenberg block for the default Pirate Forms form
299
+ * Made the checkbox field to store in the database for GDPR compliance
300
+ * New option to disable tracking of the IP for GDPR compliance
301
+ * Replaced subscription form with Sendinblue form
302
+
303
+
304
  ### 2.4.2 - 2018-06-07 ###
305
 
306
  * NEW support for submitting Ajax forms with [pirate_forms ajax="yes"]
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.2 - 2018-06-07 =
297
 
298
  * NEW support for submitting Ajax forms with [pirate_forms ajax="yes"]
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
299
+ * Made the checkbox field to store in the database for GDPR compliance
300
+ * New option to disable tracking of the IP for GDPR compliance
301
+ * Replaced subscription form with Sendinblue form
302
+
303
+
304
  = 2.4.2 - 2018-06-07 =
305
 
306
  * NEW support for submitting Ajax forms with [pirate_forms ajax="yes"]
themeisle-hash.json CHANGED
@@ -1 +1 @@
1
- {"index.php":"39ab8276fb0e4bd3fcab3270822c5977","pirate-forms.php":"b362d348135cec32a3e5f560a52dfe75","uninstall.php":"9d936442a63521d971a6dbc28df9c0d1"}
1
+ {"index.php":"39ab8276fb0e4bd3fcab3270822c5977","pirate-forms.php":"f8f896d38c607a6743ce06eb22a9aa24","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 ComposerAutoloaderInit56af298a22d6a897a874f285605e4ce2::getLoader();
4
 
5
  require_once __DIR__ . '/composer' . '/autoload_real.php';
6
 
7
+ return ComposerAutoloaderInit240b6f950288dbf75d1fb8b7a6f2ca07::getLoader();
vendor/autoload_52.php CHANGED
@@ -4,4 +4,4 @@
4
 
5
  require_once dirname(__FILE__) . '/composer'.'/autoload_real_52.php';
6
 
7
- return ComposerAutoloaderInitf7f3d7f92a70be0a2cc5f0a49cf36402::getLoader();
4
 
5
  require_once dirname(__FILE__) . '/composer'.'/autoload_real_52.php';
6
 
7
+ return ComposerAutoloaderInit028d09be7fdf06394e0c906d9652646a::getLoader();
vendor/composer/autoload_real.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
- class ComposerAutoloaderInit56af298a22d6a897a874f285605e4ce2
6
  {
7
  private static $loader;
8
 
@@ -19,9 +19,9 @@ class ComposerAutoloaderInit56af298a22d6a897a874f285605e4ce2
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,14 +42,14 @@ class ComposerAutoloaderInit56af298a22d6a897a874f285605e4ce2
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;
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
+ class ComposerAutoloaderInit240b6f950288dbf75d1fb8b7a6f2ca07
6
  {
7
  private static $loader;
8
 
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
 
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;
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 ComposerAutoloaderInitf7f3d7f92a70be0a2cc5f0a49cf36402 {
6
  private static $loader;
7
 
8
  public static function loadClassLoader($class) {
@@ -19,9 +19,9 @@ class ComposerAutoloaderInitf7f3d7f92a70be0a2cc5f0a49cf36402 {
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);
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
  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);
webpack.config.js ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var webpack = require( 'webpack' ),
2
+ NODE_ENV = process.env.NODE_ENV || 'development',
3
+ webpackConfig = {
4
+ entry: './gutenberg/js/block.js',
5
+ output: {
6
+ path: __dirname,
7
+ filename: './gutenberg/js/block.build.js',
8
+ },
9
+ module: {
10
+ loaders: [
11
+ {
12
+ test: /.js$/,
13
+ loader: 'babel-loader',
14
+ exclude: /node_modules/,
15
+ },
16
+ ],
17
+ },
18
+ plugins: [
19
+ new webpack.DefinePlugin( {
20
+ 'process.env.NODE_ENV': JSON.stringify( NODE_ENV )
21
+ } ),
22
+ ]
23
+ };
24
+
25
+ if ( 'production' === NODE_ENV ) {
26
+ webpackConfig.plugins.push( new webpack.optimize.UglifyJsPlugin() );
27
+ }
28
+
29
+ module.exports = webpackConfig;