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

Version Description

  • 2017-08-16
Download this release

Release Info

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

Code changes from version 2.0.4 to 2.0.5

CHANGELOG.md CHANGED
@@ -1,4 +1,12 @@
1
 
 
 
 
 
 
 
 
 
2
  ### v2.0.4 - 2017-08-14
3
  **Changes:**
4
  * All fields are now optional.
1
 
2
+ ### v2.0.5 - 2017-08-16
3
+ **Changes:**
4
+
5
+ ### v2.0.5 - 2017-08-16
6
+ **Changes:**
7
+ * Fixed compatibility with the pro version for multiple fields.
8
+ * Fixed default consistency between forms.
9
+
10
  ### v2.0.4 - 2017-08-14
11
  **Changes:**
12
  * All fields are now optional.
admin/class-pirateforms-admin.php CHANGED
@@ -74,7 +74,6 @@ class PirateForms_Admin {
74
  }
75
  }
76
 
77
-
78
  /**
79
  * Loads the sidebar
80
  *
74
  }
75
  }
76
 
 
77
  /**
78
  * Loads the sidebar
79
  *
admin/partials/pirateforms-settings-sidebar-subscribe.php CHANGED
@@ -7,6 +7,7 @@ if ( ! defined( 'PIRATEFORMSPRO_BASEFILE' ) ) :
7
  <li>Multiple forms builder</li>
8
  <li>MailChimp integration</li>
9
  <li>Developer friendly</li>
 
10
  <li>12 months Support & Updates</li>
11
  <li>30 days Money Back Guaranteed</li>
12
  </ul>
7
  <li>Multiple forms builder</li>
8
  <li>MailChimp integration</li>
9
  <li>Developer friendly</li>
10
+ <li>Custom fields</li>
11
  <li>12 months Support & Updates</li>
12
  <li>30 days Money Back Guaranteed</li>
13
  </ul>
includes/class-pirateforms-html.php CHANGED
@@ -192,6 +192,30 @@ class PirateForms_HTML {
192
  return $this->get_wrap( $args, $html );
193
  }
194
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
195
  /**
196
  * The input type="hidden" element
197
  *
192
  return $this->get_wrap( $args, $html );
193
  }
194
 
195
+ /**
196
+ * The input type="number" element
197
+ *
198
+ * @since 1.2.6
199
+ */
200
+ private function number( $args ) {
201
+ $html = $this->get_label( $args );
202
+ $html .= '<input type="number" ' . $this->get_common( $args, array( 'value' ) ) . ' min=0>';
203
+
204
+ return $this->get_wrap( $args, $html );
205
+ }
206
+
207
+ /**
208
+ * The input type="tel" element
209
+ *
210
+ * @since 1.2.6
211
+ */
212
+ private function tel( $args ) {
213
+ $html = $this->get_label( $args );
214
+ $html .= '<input type="tel" ' . $this->get_common( $args, array( 'value' ) ) . '>';
215
+
216
+ return $this->get_wrap( $args, $html );
217
+ }
218
+
219
  /**
220
  * The input type="hidden" element
221
  *
includes/class-pirateforms-phpformbuilder.php CHANGED
@@ -7,15 +7,26 @@
7
  */
8
  class PirateForms_PhpFormBuilder {
9
 
 
 
 
 
 
 
 
 
10
  /**
11
  * Build the HTML for the form based on the input queue
12
  *
13
  * @param array $elements The array of HTML elements.
 
 
14
  *
15
  * @return string
16
  */
17
- function build_form( $elements ) {
18
- $pirateformsopt_attachment_field = PirateForms_Util::get_option( 'pirateformsopt_attachment_field' );
 
19
  if ( 'yes' === $pirateformsopt_attachment_field ) {
20
  $pirate_forms_enctype = 'multipart/form-data';
21
  } else {
@@ -23,19 +34,29 @@ class PirateForms_PhpFormBuilder {
23
  }
24
 
25
  $classes = array();
 
26
  $form_start = '<form method="post" enctype="' . $pirate_forms_enctype . '" action="" class="pirate_forms ';
27
 
28
  $html_helper = new PirateForms_HTML();
29
  $form_end = '';
 
30
  foreach ( $elements as $val ) {
31
- $element = $html_helper->add( $val, false );
32
- if ( 'form_honeypot' === $val['id'] || in_array( $val['type'], array( 'hidden', 'div' ) ) ) {
33
- $form_end .= $element;
 
 
 
 
 
 
 
 
34
  }
35
- $this->set_element( $val['id'], $element );
36
- $classes[] = $val['id'] . '-on';
37
  }
38
 
 
 
39
  $form_start .= implode( ' ', $classes ) . '">';
40
  $this->set_element( 'form_start', $form_start );
41
 
7
  */
8
  class PirateForms_PhpFormBuilder {
9
 
10
+ /**
11
+ * The array of options for the form.
12
+ *
13
+ * @access public
14
+ * @var array $pirate_forms_options The array of options for the form.
15
+ */
16
+ public $pirate_forms_options;
17
+
18
  /**
19
  * Build the HTML for the form based on the input queue
20
  *
21
  * @param array $elements The array of HTML elements.
22
+ * @param array $pirate_forms_options The array of options for the form.
23
+ * @param bpol $from_widget Is the form in the widget.
24
  *
25
  * @return string
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 ( 'yes' === $pirateformsopt_attachment_field ) {
31
  $pirate_forms_enctype = 'multipart/form-data';
32
  } else {
34
  }
35
 
36
  $classes = array();
37
+ $classes[] = $from_widget ? 'widget-on' : '';
38
  $form_start = '<form method="post" enctype="' . $pirate_forms_enctype . '" action="" class="pirate_forms ';
39
 
40
  $html_helper = new PirateForms_HTML();
41
  $form_end = '';
42
+ $custom_fields = '';
43
  foreach ( $elements as $val ) {
44
+ if ( isset( $val['is_custom'] ) && $val['is_custom'] ) {
45
+ // we will combine the HTML for all the custom fields and save it under one element name.
46
+ $custom_fields .= $html_helper->add( $val, false );
47
+ $classes[] = $val['id'] . '-on';
48
+ } else {
49
+ $element = $html_helper->add( $val, false );
50
+ if ( 'form_honeypot' === $val['id'] || in_array( $val['type'], array( 'hidden', 'div' ) ) ) {
51
+ $form_end .= $element;
52
+ }
53
+ $this->set_element( $val['id'], $element );
54
+ $classes[] = $val['id'] . '-on';
55
  }
 
 
56
  }
57
 
58
+ $this->set_element( 'custom_fields', $custom_fields );
59
+
60
  $form_start .= implode( ' ', $classes ) . '">';
61
  $this->set_element( 'form_start', $form_start );
62
 
includes/class-pirateforms-util.php CHANGED
@@ -7,6 +7,15 @@
7
  */
8
  class PirateForms_Util {
9
 
 
 
 
 
 
 
 
 
 
10
  /**
11
  * Returns if the domain is localhost
12
  *
7
  */
8
  class PirateForms_Util {
9
 
10
+ /**
11
+ * Return the table row
12
+ *
13
+ * @since 1.0.0
14
+ */
15
+ public static function table_row( $key, $value ) {
16
+ return '<tr><th>' . $key . '</th><td>' . $value . '</td></tr>';
17
+ }
18
+
19
  /**
20
  * Returns if the domain is localhost
21
  *
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.0.4';
73
 
74
  $this->load_dependencies();
75
  $this->set_locale();
@@ -160,6 +160,9 @@ class PirateForms {
160
 
161
  // ONLY FOR UNIT TESTING: we cannot fire template_redirect without errors, that is why we are creating a manual hook for this
162
  $this->loader->add_action( 'pirate_unittesting_template_redirect', $plugin_public, 'template_redirect' );
 
 
 
163
 
164
  $this->loader->add_filter( 'widget_text', $plugin_public, 'widget_text_filter', 9 );
165
  $this->loader->add_filter( 'pirate_forms_public_controls', $plugin_public, 'compatibility_class', 9 );
@@ -215,38 +218,36 @@ class PirateForms {
215
  * @since 1.0.0
216
  */
217
  public function register_content_type() {
218
- if ( PirateForms_Util::get_option( 'pirateformsopt_store' ) === 'yes' ) {
219
- $labels = array(
220
- 'name' => _x( 'Contacts', 'post type general name', 'pirate-forms' ),
221
- 'singular_name' => _x( 'Contact', 'post type singular name', 'pirate-forms' ),
222
- 'menu_name' => _x( 'Contacts', 'admin menu', 'pirate-forms' ),
223
- 'name_admin_bar' => _x( 'Contact', 'add new on admin bar', 'pirate-forms' ),
224
- 'add_new' => _x( 'Add New', 'contact', 'pirate-forms' ),
225
- 'add_new_item' => __( 'Add New Contact', 'pirate-forms' ),
226
- 'new_item' => __( 'New Contact', 'pirate-forms' ),
227
- 'edit_item' => __( 'Edit Contact', 'pirate-forms' ),
228
- 'view_item' => __( 'View Contact', 'pirate-forms' ),
229
- 'all_items' => __( 'All Contacts', 'pirate-forms' ),
230
- 'search_items' => __( 'Search Contacts', 'pirate-forms' ),
231
- 'parent_item_colon' => __( 'Parent Contacts:', 'pirate-forms' ),
232
- 'not_found' => __( 'No contacts found.', 'pirate-forms' ),
233
- 'not_found_in_trash' => __( 'No contacts found in Trash.', 'pirate-forms' ),
234
- );
235
- $args = array(
236
- 'labels' => $labels,
237
- 'description' => __( 'Contacts from Pirate Forms', 'pirate-forms' ),
238
- 'public' => true,
239
- 'publicly_queryable' => true,
240
- 'show_ui' => true,
241
- 'show_in_menu' => 'pirateforms-admin',
242
- 'query_var' => true,
243
- 'capability_type' => 'post',
244
- 'has_archive' => true,
245
- 'hierarchical' => false,
246
- 'menu_position' => null,
247
- 'supports' => array( 'title', 'editor', 'custom-fields' ),
248
- );
249
- register_post_type( 'pf_contact', $args );
250
- }
251
  }
252
  }
69
  public function __construct() {
70
 
71
  $this->plugin_name = 'pirateforms';
72
+ $this->version = '2.0.5';
73
 
74
  $this->load_dependencies();
75
  $this->set_locale();
160
 
161
  // ONLY FOR UNIT TESTING: we cannot fire template_redirect without errors, that is why we are creating a manual hook for this
162
  $this->loader->add_action( 'pirate_unittesting_template_redirect', $plugin_public, 'template_redirect' );
163
+ $this->loader->add_action( 'pirate_forms_render_thankyou', $plugin_public, 'render_thankyou' );
164
+ $this->loader->add_action( 'pirate_forms_render_errors', $plugin_public, 'render_errors' );
165
+ $this->loader->add_action( 'pirate_forms_render_fields', $plugin_public, 'render_fields' );
166
 
167
  $this->loader->add_filter( 'widget_text', $plugin_public, 'widget_text_filter', 9 );
168
  $this->loader->add_filter( 'pirate_forms_public_controls', $plugin_public, 'compatibility_class', 9 );
218
  * @since 1.0.0
219
  */
220
  public function register_content_type() {
221
+ $labels = array(
222
+ 'name' => _x( 'Contacts', 'post type general name', 'pirate-forms' ),
223
+ 'singular_name' => _x( 'Contact', 'post type singular name', 'pirate-forms' ),
224
+ 'menu_name' => _x( 'Contacts', 'admin menu', 'pirate-forms' ),
225
+ 'name_admin_bar' => _x( 'Contact', 'add new on admin bar', 'pirate-forms' ),
226
+ 'add_new' => _x( 'Add New', 'contact', 'pirate-forms' ),
227
+ 'add_new_item' => __( 'Add New Contact', 'pirate-forms' ),
228
+ 'new_item' => __( 'New Contact', 'pirate-forms' ),
229
+ 'edit_item' => __( 'Edit Contact', 'pirate-forms' ),
230
+ 'view_item' => __( 'View Contact', 'pirate-forms' ),
231
+ 'all_items' => __( 'All Contacts', 'pirate-forms' ),
232
+ 'search_items' => __( 'Search Contacts', 'pirate-forms' ),
233
+ 'parent_item_colon' => __( 'Parent Contacts:', 'pirate-forms' ),
234
+ 'not_found' => __( 'No contacts found.', 'pirate-forms' ),
235
+ 'not_found_in_trash' => __( 'No contacts found in Trash.', 'pirate-forms' ),
236
+ );
237
+ $args = array(
238
+ 'labels' => $labels,
239
+ 'description' => __( 'Contacts from Pirate Forms', 'pirate-forms' ),
240
+ 'public' => true,
241
+ 'publicly_queryable' => true,
242
+ 'show_ui' => true,
243
+ 'show_in_menu' => 'pirateforms-admin',
244
+ 'query_var' => true,
245
+ 'capability_type' => 'post',
246
+ 'has_archive' => true,
247
+ 'hierarchical' => false,
248
+ 'menu_position' => null,
249
+ 'supports' => array( 'title', 'editor', 'custom-fields' ),
250
+ );
251
+ register_post_type( 'pf_contact', $args );
 
 
252
  }
253
  }
languages/pirate-forms.pot CHANGED
@@ -2,9 +2,9 @@
2
  # This file is distributed under the GPLv2.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: Free & Simple Contact Form Plugin - Pirateforms 2.0.3\n"
6
  "Report-Msgid-Bugs-To: https://github.com/Codeinwp/pirate-forms/issues\n"
7
- "POT-Creation-Date: 2017-08-14 09:11:43+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
@@ -24,27 +24,27 @@ msgstr ""
24
  "X-Poedit-Bookmarks: \n"
25
  "X-Textdomain-Support: yes\n"
26
 
27
- #: admin/class-pirateforms-admin.php:114 admin/class-pirateforms-admin.php:132
28
  msgid "Settings"
29
  msgstr ""
30
 
31
- #: admin/class-pirateforms-admin.php:190 admin/class-pirateforms-admin.php:194
32
  msgid "Send Message"
33
  msgstr ""
34
 
35
- #: admin/class-pirateforms-admin.php:212
36
  msgid "Form processing options"
37
  msgstr ""
38
 
39
- #: admin/class-pirateforms-admin.php:219
40
  msgid "Contact notification email address"
41
  msgstr ""
42
 
43
- #: admin/class-pirateforms-admin.php:222
44
  msgid "Insert [email] to use the contact form submitter's email."
45
  msgstr ""
46
 
47
- #: admin/class-pirateforms-admin.php:222
48
  msgid ""
49
  "The notification email will be sent from this address both to the "
50
  "recipients below and the contact form submitter (if this is activated below "
@@ -52,38 +52,38 @@ msgid ""
52
  "should match your site's domain)."
53
  msgstr ""
54
 
55
- #: admin/class-pirateforms-admin.php:238
56
  msgid "Contact submission recipients"
57
  msgstr ""
58
 
59
- #: admin/class-pirateforms-admin.php:241
60
  msgid ""
61
  "Email address(es) to receive contact submission notifications. You can "
62
  "separate multiple emails with a comma."
63
  msgstr ""
64
 
65
- #: admin/class-pirateforms-admin.php:257
66
  msgid "Store submissions in the database"
67
  msgstr ""
68
 
69
- #: admin/class-pirateforms-admin.php:260
70
  msgid ""
71
  "Should the submissions be stored in the admin area? If chosen, contact form "
72
  "submissions will be saved in Contacts on the left (appears after this "
73
  "option is activated)."
74
  msgstr ""
75
 
76
- #: admin/class-pirateforms-admin.php:270 admin/class-pirateforms-admin.php:289
77
- #: admin/class-pirateforms-admin.php:443 admin/class-pirateforms-admin.php:664
78
- #: admin/class-pirateforms-admin.php:707
79
  msgid "Yes"
80
  msgstr ""
81
 
82
- #: admin/class-pirateforms-admin.php:276
83
  msgid "Add a nonce to the contact form:"
84
  msgstr ""
85
 
86
- #: admin/class-pirateforms-admin.php:279
87
  msgid ""
88
  "Should the form use a WordPress nonce? This helps reduce spam by ensuring "
89
  "that the form submittor is on the site when submitting the form rather than "
@@ -92,227 +92,227 @@ msgid ""
92
  "forms not being able to be submitted with an error of \"Nonce failed!\""
93
  msgstr ""
94
 
95
- #: admin/class-pirateforms-admin.php:295
96
  msgid "Send email confirmation to form submitter"
97
  msgstr ""
98
 
99
- #: admin/class-pirateforms-admin.php:298
100
  msgid ""
101
  "Adding text here will send an email to the form submitter. The email uses "
102
  "the \"Successful form submission text\" field from the \"Alert Messages\" "
103
  "tab as the subject line. Plain text only here, no HTML."
104
  msgstr ""
105
 
106
- #: admin/class-pirateforms-admin.php:314
107
  msgid "Success Page"
108
  msgstr ""
109
 
110
- #: admin/class-pirateforms-admin.php:317
111
  msgid ""
112
  "Select the page that displays after a successful form submission. The page "
113
  "will be displayed without pausing on the email form, so please be sure to "
114
  "configure a relevant thank you message in this page."
115
  msgstr ""
116
 
117
- #: admin/class-pirateforms-admin.php:332
118
  #: admin/partials/pirateforms-settings-display.php:31
119
  msgid "Fields Settings"
120
  msgstr ""
121
 
122
- #: admin/class-pirateforms-admin.php:340 admin/class-pirateforms-admin.php:490
123
  msgid "Name"
124
  msgstr ""
125
 
 
 
 
 
 
 
126
  #: admin/class-pirateforms-admin.php:349 admin/class-pirateforms-admin.php:368
127
  #: admin/class-pirateforms-admin.php:387 admin/class-pirateforms-admin.php:406
128
  #: admin/class-pirateforms-admin.php:424
129
- msgid "Do not display"
130
  msgstr ""
131
 
132
  #: admin/class-pirateforms-admin.php:350 admin/class-pirateforms-admin.php:369
133
  #: admin/class-pirateforms-admin.php:388 admin/class-pirateforms-admin.php:407
134
  #: admin/class-pirateforms-admin.php:425
135
- msgid "Display but not required"
136
- msgstr ""
137
-
138
- #: admin/class-pirateforms-admin.php:351 admin/class-pirateforms-admin.php:370
139
- #: admin/class-pirateforms-admin.php:389 admin/class-pirateforms-admin.php:408
140
- #: admin/class-pirateforms-admin.php:426
141
  msgid "Required"
142
  msgstr ""
143
 
144
- #: admin/class-pirateforms-admin.php:359
145
  msgid "Email address"
146
  msgstr ""
147
 
148
- #: admin/class-pirateforms-admin.php:378 admin/class-pirateforms-admin.php:516
149
- #: admin/class-pirateforms-admin.php:518
150
  msgid "Subject"
151
  msgstr ""
152
 
153
- #: admin/class-pirateforms-admin.php:397 admin/class-pirateforms-admin.php:529
154
  msgid "Message"
155
  msgstr ""
156
 
157
- #: admin/class-pirateforms-admin.php:416
158
  msgid "Attachment"
159
  msgstr ""
160
 
161
- #: admin/class-pirateforms-admin.php:434
162
  msgid "Add a reCAPTCHA"
163
  msgstr ""
164
 
165
- #: admin/class-pirateforms-admin.php:451
166
  msgid "Site key"
167
  msgstr ""
168
 
169
- #: admin/class-pirateforms-admin.php:454
170
  msgid "Create an account here "
171
  msgstr ""
172
 
173
- #: admin/class-pirateforms-admin.php:454
174
  msgid "to get the Site key and the Secret key for the reCaptcha."
175
  msgstr ""
176
 
177
- #: admin/class-pirateforms-admin.php:470
178
  msgid "Secret key"
179
  msgstr ""
180
 
181
- #: admin/class-pirateforms-admin.php:483
182
  #: admin/partials/pirateforms-settings-display.php:34
183
  msgid "Fields Labels"
184
  msgstr ""
185
 
186
- #: admin/class-pirateforms-admin.php:492
187
  msgid "Your Name"
188
  msgstr ""
189
 
190
- #: admin/class-pirateforms-admin.php:503
191
  msgid "Email"
192
  msgstr ""
193
 
194
- #: admin/class-pirateforms-admin.php:505
195
  msgid "Your Email"
196
  msgstr ""
197
 
198
- #: admin/class-pirateforms-admin.php:531
199
  msgid "Your message"
200
  msgstr ""
201
 
202
- #: admin/class-pirateforms-admin.php:542
203
  msgid "Submit button"
204
  msgstr ""
205
 
206
- #: admin/class-pirateforms-admin.php:555
207
  #: admin/partials/pirateforms-settings-display.php:37
208
  msgid "Alert Messages"
209
  msgstr ""
210
 
211
- #: admin/class-pirateforms-admin.php:562
212
  msgid "Name required and missing"
213
  msgstr ""
214
 
215
- #: admin/class-pirateforms-admin.php:564
216
  msgid "Enter your name"
217
  msgstr ""
218
 
219
- #: admin/class-pirateforms-admin.php:575
220
  msgid "E-mail required and missing"
221
  msgstr ""
222
 
223
- #: admin/class-pirateforms-admin.php:577
224
  msgid "Enter valid email"
225
  msgstr ""
226
 
227
- #: admin/class-pirateforms-admin.php:588
228
  msgid "Subject required and missing"
229
  msgstr ""
230
 
231
- #: admin/class-pirateforms-admin.php:590
232
  msgid "Please enter a subject"
233
  msgstr ""
234
 
235
- #: admin/class-pirateforms-admin.php:601
236
  msgid "Question/comment is missing"
237
  msgstr ""
238
 
239
- #: admin/class-pirateforms-admin.php:603
240
  msgid "Enter your question or comment"
241
  msgstr ""
242
 
243
- #: admin/class-pirateforms-admin.php:614
244
  msgid "Attachment is missing"
245
  msgstr ""
246
 
247
- #: admin/class-pirateforms-admin.php:616
248
  msgid "Please add an attachment"
249
  msgstr ""
250
 
251
- #: admin/class-pirateforms-admin.php:627
252
  msgid "Successful form submission text"
253
  msgstr ""
254
 
255
- #: admin/class-pirateforms-admin.php:630
256
  msgid ""
257
  "This text is used on the page if no Success Page is chosen above. This is "
258
  "also used as the confirmation email title, if one is set to send out."
259
  msgstr ""
260
 
261
- #: admin/class-pirateforms-admin.php:634
262
  msgid "Thanks, your email was sent successfully!"
263
  msgstr ""
264
 
265
- #: admin/class-pirateforms-admin.php:645
266
  msgid "SMTP Options"
267
  msgstr ""
268
 
269
- #: admin/class-pirateforms-admin.php:652
270
  msgid "Use SMTP to send emails?"
271
  msgstr ""
272
 
273
- #: admin/class-pirateforms-admin.php:655
274
  msgid "Instead of PHP mail function"
275
  msgstr ""
276
 
277
- #: admin/class-pirateforms-admin.php:670
278
  msgid "SMTP Host"
279
  msgstr ""
280
 
281
- #: admin/class-pirateforms-admin.php:682
282
  msgid "SMTP Port"
283
  msgstr ""
284
 
285
- #: admin/class-pirateforms-admin.php:694
286
  msgid "Use SMTP Authentication?"
287
  msgstr ""
288
 
289
- #: admin/class-pirateforms-admin.php:697 admin/class-pirateforms-admin.php:716
290
  msgid ""
291
  "If you check this box, make sure the SMTP Username and SMTP Password are "
292
  "completed."
293
  msgstr ""
294
 
295
- #: admin/class-pirateforms-admin.php:713
296
  msgid "Security?"
297
  msgstr ""
298
 
299
- #: admin/class-pirateforms-admin.php:726
300
  msgid "No"
301
  msgstr ""
302
 
303
- #: admin/class-pirateforms-admin.php:727
304
  msgid "SSL"
305
  msgstr ""
306
 
307
- #: admin/class-pirateforms-admin.php:728
308
  msgid "TLS"
309
  msgstr ""
310
 
311
- #: admin/class-pirateforms-admin.php:735
312
  msgid "SMTP Username"
313
  msgstr ""
314
 
315
- #: admin/class-pirateforms-admin.php:747
316
  msgid "SMTP Password"
317
  msgstr ""
318
 
@@ -422,11 +422,11 @@ msgid ""
422
  "newsletter."
423
  msgstr ""
424
 
425
- #: includes/class-pirateforms-util.php:113
426
  msgid "Form submission blocked!"
427
  msgstr ""
428
 
429
- #: includes/class-pirateforms-util.php:129
430
  msgid "None"
431
  msgstr ""
432
 
@@ -446,103 +446,103 @@ msgstr ""
446
  msgid "Subtext:"
447
  msgstr ""
448
 
449
- #: includes/class-pirateforms.php:225
450
  msgid "Add New Contact"
451
  msgstr ""
452
 
453
- #: includes/class-pirateforms.php:226
454
  msgid "New Contact"
455
  msgstr ""
456
 
457
- #: includes/class-pirateforms.php:227
458
  msgid "Edit Contact"
459
  msgstr ""
460
 
461
- #: includes/class-pirateforms.php:228
462
  msgid "View Contact"
463
  msgstr ""
464
 
465
- #: includes/class-pirateforms.php:229
466
  msgid "All Contacts"
467
  msgstr ""
468
 
469
- #: includes/class-pirateforms.php:230
470
  msgid "Search Contacts"
471
  msgstr ""
472
 
473
- #: includes/class-pirateforms.php:231
474
  msgid "Parent Contacts:"
475
  msgstr ""
476
 
477
- #: includes/class-pirateforms.php:232
478
  msgid "No contacts found."
479
  msgstr ""
480
 
481
- #: includes/class-pirateforms.php:233
482
  msgid "No contacts found in Trash."
483
  msgstr ""
484
 
485
- #: includes/class-pirateforms.php:237
486
  msgid "Contacts from Pirate Forms"
487
  msgstr ""
488
 
489
- #: public/class-pirateforms-public.php:121
 
 
 
 
 
 
 
 
490
  msgid "Nonce failed!"
491
  msgstr ""
492
 
493
- #: public/class-pirateforms-public.php:130
494
  msgid "Form submission failed!"
495
  msgstr ""
496
 
497
- #: public/class-pirateforms-public.php:142
498
  msgid "Contact form submission from"
499
  msgstr ""
500
 
501
- #: public/class-pirateforms-public.php:175
502
  msgid "Please enter one or more Contact submission recipients"
503
  msgstr ""
504
 
505
- #: public/class-pirateforms-public.php:190
506
  msgid "IP address: "
507
  msgstr ""
508
 
509
- #: public/class-pirateforms-public.php:191
510
  msgid "IP search:"
511
  msgstr ""
512
 
513
- #: public/class-pirateforms-public.php:196
514
  msgid "Came from: "
515
  msgstr ""
516
 
517
- #: public/class-pirateforms-public.php:200
518
  msgid "Sent from page: "
519
  msgstr ""
520
 
521
- #: public/class-pirateforms-public.php:343
522
- #: public/class-pirateforms-public.php:355
523
  msgid "Wrong reCAPTCHA"
524
  msgstr ""
525
 
526
- #: public/class-pirateforms-public.php:397
527
  msgid "Uploaded file is not allowed for file type"
528
  msgstr ""
529
 
530
- #: public/class-pirateforms-public.php:405
531
  msgid "Uploaded file is too large"
532
  msgstr ""
533
 
534
- #: public/class-pirateforms-public.php:421
535
  msgid "There was an unknown error uploading the file."
536
  msgstr ""
537
 
538
- #: public/class-pirateforms-public.php:803
539
- msgid "Submit"
540
- msgstr ""
541
-
542
- #: public/partials/pirateforms-form.php:29
543
- msgid "Sorry, an error occured."
544
- msgstr ""
545
-
546
  #. Plugin Name of the plugin/theme
547
  msgid "Free & Simple Contact Form Plugin - Pirateforms"
548
  msgstr ""
@@ -563,27 +563,27 @@ msgstr ""
563
  msgid "http://themeisle.com"
564
  msgstr ""
565
 
566
- #: includes/class-pirateforms.php:220
567
  msgctxt "post type general name"
568
  msgid "Contacts"
569
  msgstr ""
570
 
571
- #: includes/class-pirateforms.php:221
572
  msgctxt "post type singular name"
573
  msgid "Contact"
574
  msgstr ""
575
 
576
- #: includes/class-pirateforms.php:222
577
  msgctxt "admin menu"
578
  msgid "Contacts"
579
  msgstr ""
580
 
581
- #: includes/class-pirateforms.php:223
582
  msgctxt "add new on admin bar"
583
  msgid "Contact"
584
  msgstr ""
585
 
586
- #: includes/class-pirateforms.php:224
587
  msgctxt "contact"
588
  msgid "Add New"
589
  msgstr ""
2
  # This file is distributed under the GPLv2.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: Free & Simple Contact Form Plugin - Pirateforms 2.0.4\n"
6
  "Report-Msgid-Bugs-To: https://github.com/Codeinwp/pirate-forms/issues\n"
7
+ "POT-Creation-Date: 2017-08-15 19:26:11+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
24
  "X-Poedit-Bookmarks: \n"
25
  "X-Textdomain-Support: yes\n"
26
 
27
+ #: admin/class-pirateforms-admin.php:113 admin/class-pirateforms-admin.php:131
28
  msgid "Settings"
29
  msgstr ""
30
 
31
+ #: admin/class-pirateforms-admin.php:189 admin/class-pirateforms-admin.php:193
32
  msgid "Send Message"
33
  msgstr ""
34
 
35
+ #: admin/class-pirateforms-admin.php:211
36
  msgid "Form processing options"
37
  msgstr ""
38
 
39
+ #: admin/class-pirateforms-admin.php:218
40
  msgid "Contact notification email address"
41
  msgstr ""
42
 
43
+ #: admin/class-pirateforms-admin.php:221
44
  msgid "Insert [email] to use the contact form submitter's email."
45
  msgstr ""
46
 
47
+ #: admin/class-pirateforms-admin.php:221
48
  msgid ""
49
  "The notification email will be sent from this address both to the "
50
  "recipients below and the contact form submitter (if this is activated below "
52
  "should match your site's domain)."
53
  msgstr ""
54
 
55
+ #: admin/class-pirateforms-admin.php:237
56
  msgid "Contact submission recipients"
57
  msgstr ""
58
 
59
+ #: admin/class-pirateforms-admin.php:240
60
  msgid ""
61
  "Email address(es) to receive contact submission notifications. You can "
62
  "separate multiple emails with a comma."
63
  msgstr ""
64
 
65
+ #: admin/class-pirateforms-admin.php:256
66
  msgid "Store submissions in the database"
67
  msgstr ""
68
 
69
+ #: admin/class-pirateforms-admin.php:259
70
  msgid ""
71
  "Should the submissions be stored in the admin area? If chosen, contact form "
72
  "submissions will be saved in Contacts on the left (appears after this "
73
  "option is activated)."
74
  msgstr ""
75
 
76
+ #: admin/class-pirateforms-admin.php:269 admin/class-pirateforms-admin.php:288
77
+ #: admin/class-pirateforms-admin.php:442 admin/class-pirateforms-admin.php:663
78
+ #: admin/class-pirateforms-admin.php:706
79
  msgid "Yes"
80
  msgstr ""
81
 
82
+ #: admin/class-pirateforms-admin.php:275
83
  msgid "Add a nonce to the contact form:"
84
  msgstr ""
85
 
86
+ #: admin/class-pirateforms-admin.php:278
87
  msgid ""
88
  "Should the form use a WordPress nonce? This helps reduce spam by ensuring "
89
  "that the form submittor is on the site when submitting the form rather than "
92
  "forms not being able to be submitted with an error of \"Nonce failed!\""
93
  msgstr ""
94
 
95
+ #: admin/class-pirateforms-admin.php:294
96
  msgid "Send email confirmation to form submitter"
97
  msgstr ""
98
 
99
+ #: admin/class-pirateforms-admin.php:297
100
  msgid ""
101
  "Adding text here will send an email to the form submitter. The email uses "
102
  "the \"Successful form submission text\" field from the \"Alert Messages\" "
103
  "tab as the subject line. Plain text only here, no HTML."
104
  msgstr ""
105
 
106
+ #: admin/class-pirateforms-admin.php:313
107
  msgid "Success Page"
108
  msgstr ""
109
 
110
+ #: admin/class-pirateforms-admin.php:316
111
  msgid ""
112
  "Select the page that displays after a successful form submission. The page "
113
  "will be displayed without pausing on the email form, so please be sure to "
114
  "configure a relevant thank you message in this page."
115
  msgstr ""
116
 
117
+ #: admin/class-pirateforms-admin.php:331
118
  #: admin/partials/pirateforms-settings-display.php:31
119
  msgid "Fields Settings"
120
  msgstr ""
121
 
122
+ #: admin/class-pirateforms-admin.php:339 admin/class-pirateforms-admin.php:489
123
  msgid "Name"
124
  msgstr ""
125
 
126
+ #: admin/class-pirateforms-admin.php:348 admin/class-pirateforms-admin.php:367
127
+ #: admin/class-pirateforms-admin.php:386 admin/class-pirateforms-admin.php:405
128
+ #: admin/class-pirateforms-admin.php:423
129
+ msgid "Do not display"
130
+ msgstr ""
131
+
132
  #: admin/class-pirateforms-admin.php:349 admin/class-pirateforms-admin.php:368
133
  #: admin/class-pirateforms-admin.php:387 admin/class-pirateforms-admin.php:406
134
  #: admin/class-pirateforms-admin.php:424
135
+ msgid "Display but not required"
136
  msgstr ""
137
 
138
  #: admin/class-pirateforms-admin.php:350 admin/class-pirateforms-admin.php:369
139
  #: admin/class-pirateforms-admin.php:388 admin/class-pirateforms-admin.php:407
140
  #: admin/class-pirateforms-admin.php:425
 
 
 
 
 
 
141
  msgid "Required"
142
  msgstr ""
143
 
144
+ #: admin/class-pirateforms-admin.php:358
145
  msgid "Email address"
146
  msgstr ""
147
 
148
+ #: admin/class-pirateforms-admin.php:377 admin/class-pirateforms-admin.php:515
149
+ #: admin/class-pirateforms-admin.php:517
150
  msgid "Subject"
151
  msgstr ""
152
 
153
+ #: admin/class-pirateforms-admin.php:396 admin/class-pirateforms-admin.php:528
154
  msgid "Message"
155
  msgstr ""
156
 
157
+ #: admin/class-pirateforms-admin.php:415
158
  msgid "Attachment"
159
  msgstr ""
160
 
161
+ #: admin/class-pirateforms-admin.php:433
162
  msgid "Add a reCAPTCHA"
163
  msgstr ""
164
 
165
+ #: admin/class-pirateforms-admin.php:450
166
  msgid "Site key"
167
  msgstr ""
168
 
169
+ #: admin/class-pirateforms-admin.php:453
170
  msgid "Create an account here "
171
  msgstr ""
172
 
173
+ #: admin/class-pirateforms-admin.php:453
174
  msgid "to get the Site key and the Secret key for the reCaptcha."
175
  msgstr ""
176
 
177
+ #: admin/class-pirateforms-admin.php:469
178
  msgid "Secret key"
179
  msgstr ""
180
 
181
+ #: admin/class-pirateforms-admin.php:482
182
  #: admin/partials/pirateforms-settings-display.php:34
183
  msgid "Fields Labels"
184
  msgstr ""
185
 
186
+ #: admin/class-pirateforms-admin.php:491
187
  msgid "Your Name"
188
  msgstr ""
189
 
190
+ #: admin/class-pirateforms-admin.php:502
191
  msgid "Email"
192
  msgstr ""
193
 
194
+ #: admin/class-pirateforms-admin.php:504
195
  msgid "Your Email"
196
  msgstr ""
197
 
198
+ #: admin/class-pirateforms-admin.php:530
199
  msgid "Your message"
200
  msgstr ""
201
 
202
+ #: admin/class-pirateforms-admin.php:541
203
  msgid "Submit button"
204
  msgstr ""
205
 
206
+ #: admin/class-pirateforms-admin.php:554
207
  #: admin/partials/pirateforms-settings-display.php:37
208
  msgid "Alert Messages"
209
  msgstr ""
210
 
211
+ #: admin/class-pirateforms-admin.php:561
212
  msgid "Name required and missing"
213
  msgstr ""
214
 
215
+ #: admin/class-pirateforms-admin.php:563
216
  msgid "Enter your name"
217
  msgstr ""
218
 
219
+ #: admin/class-pirateforms-admin.php:574
220
  msgid "E-mail required and missing"
221
  msgstr ""
222
 
223
+ #: admin/class-pirateforms-admin.php:576
224
  msgid "Enter valid email"
225
  msgstr ""
226
 
227
+ #: admin/class-pirateforms-admin.php:587
228
  msgid "Subject required and missing"
229
  msgstr ""
230
 
231
+ #: admin/class-pirateforms-admin.php:589
232
  msgid "Please enter a subject"
233
  msgstr ""
234
 
235
+ #: admin/class-pirateforms-admin.php:600
236
  msgid "Question/comment is missing"
237
  msgstr ""
238
 
239
+ #: admin/class-pirateforms-admin.php:602
240
  msgid "Enter your question or comment"
241
  msgstr ""
242
 
243
+ #: admin/class-pirateforms-admin.php:613
244
  msgid "Attachment is missing"
245
  msgstr ""
246
 
247
+ #: admin/class-pirateforms-admin.php:615
248
  msgid "Please add an attachment"
249
  msgstr ""
250
 
251
+ #: admin/class-pirateforms-admin.php:626
252
  msgid "Successful form submission text"
253
  msgstr ""
254
 
255
+ #: admin/class-pirateforms-admin.php:629
256
  msgid ""
257
  "This text is used on the page if no Success Page is chosen above. This is "
258
  "also used as the confirmation email title, if one is set to send out."
259
  msgstr ""
260
 
261
+ #: admin/class-pirateforms-admin.php:633
262
  msgid "Thanks, your email was sent successfully!"
263
  msgstr ""
264
 
265
+ #: admin/class-pirateforms-admin.php:644
266
  msgid "SMTP Options"
267
  msgstr ""
268
 
269
+ #: admin/class-pirateforms-admin.php:651
270
  msgid "Use SMTP to send emails?"
271
  msgstr ""
272
 
273
+ #: admin/class-pirateforms-admin.php:654
274
  msgid "Instead of PHP mail function"
275
  msgstr ""
276
 
277
+ #: admin/class-pirateforms-admin.php:669
278
  msgid "SMTP Host"
279
  msgstr ""
280
 
281
+ #: admin/class-pirateforms-admin.php:681
282
  msgid "SMTP Port"
283
  msgstr ""
284
 
285
+ #: admin/class-pirateforms-admin.php:693
286
  msgid "Use SMTP Authentication?"
287
  msgstr ""
288
 
289
+ #: admin/class-pirateforms-admin.php:696 admin/class-pirateforms-admin.php:715
290
  msgid ""
291
  "If you check this box, make sure the SMTP Username and SMTP Password are "
292
  "completed."
293
  msgstr ""
294
 
295
+ #: admin/class-pirateforms-admin.php:712
296
  msgid "Security?"
297
  msgstr ""
298
 
299
+ #: admin/class-pirateforms-admin.php:725
300
  msgid "No"
301
  msgstr ""
302
 
303
+ #: admin/class-pirateforms-admin.php:726
304
  msgid "SSL"
305
  msgstr ""
306
 
307
+ #: admin/class-pirateforms-admin.php:727
308
  msgid "TLS"
309
  msgstr ""
310
 
311
+ #: admin/class-pirateforms-admin.php:734
312
  msgid "SMTP Username"
313
  msgstr ""
314
 
315
+ #: admin/class-pirateforms-admin.php:746
316
  msgid "SMTP Password"
317
  msgstr ""
318
 
422
  "newsletter."
423
  msgstr ""
424
 
425
+ #: includes/class-pirateforms-util.php:122
426
  msgid "Form submission blocked!"
427
  msgstr ""
428
 
429
+ #: includes/class-pirateforms-util.php:138
430
  msgid "None"
431
  msgstr ""
432
 
446
  msgid "Subtext:"
447
  msgstr ""
448
 
449
+ #: includes/class-pirateforms.php:227
450
  msgid "Add New Contact"
451
  msgstr ""
452
 
453
+ #: includes/class-pirateforms.php:228
454
  msgid "New Contact"
455
  msgstr ""
456
 
457
+ #: includes/class-pirateforms.php:229
458
  msgid "Edit Contact"
459
  msgstr ""
460
 
461
+ #: includes/class-pirateforms.php:230
462
  msgid "View Contact"
463
  msgstr ""
464
 
465
+ #: includes/class-pirateforms.php:231
466
  msgid "All Contacts"
467
  msgstr ""
468
 
469
+ #: includes/class-pirateforms.php:232
470
  msgid "Search Contacts"
471
  msgstr ""
472
 
473
+ #: includes/class-pirateforms.php:233
474
  msgid "Parent Contacts:"
475
  msgstr ""
476
 
477
+ #: includes/class-pirateforms.php:234
478
  msgid "No contacts found."
479
  msgstr ""
480
 
481
+ #: includes/class-pirateforms.php:235
482
  msgid "No contacts found in Trash."
483
  msgstr ""
484
 
485
+ #: includes/class-pirateforms.php:239
486
  msgid "Contacts from Pirate Forms"
487
  msgstr ""
488
 
489
+ #: public/class-pirateforms-public.php:330
490
+ msgid "Submit"
491
+ msgstr ""
492
+
493
+ #: public/class-pirateforms-public.php:426
494
+ msgid "Sorry, an error occured."
495
+ msgstr ""
496
+
497
+ #: public/class-pirateforms-public.php:474
498
  msgid "Nonce failed!"
499
  msgstr ""
500
 
501
+ #: public/class-pirateforms-public.php:483
502
  msgid "Form submission failed!"
503
  msgstr ""
504
 
505
+ #: public/class-pirateforms-public.php:495
506
  msgid "Contact form submission from"
507
  msgstr ""
508
 
509
+ #: public/class-pirateforms-public.php:506
510
  msgid "Please enter one or more Contact submission recipients"
511
  msgstr ""
512
 
513
+ #: public/class-pirateforms-public.php:521
514
  msgid "IP address: "
515
  msgstr ""
516
 
517
+ #: public/class-pirateforms-public.php:522
518
  msgid "IP search:"
519
  msgstr ""
520
 
521
+ #: public/class-pirateforms-public.php:527
522
  msgid "Came from: "
523
  msgstr ""
524
 
525
+ #: public/class-pirateforms-public.php:531
526
  msgid "Sent from page: "
527
  msgstr ""
528
 
529
+ #: public/class-pirateforms-public.php:716
530
+ #: public/class-pirateforms-public.php:728
531
  msgid "Wrong reCAPTCHA"
532
  msgstr ""
533
 
534
+ #: public/class-pirateforms-public.php:761
535
  msgid "Uploaded file is not allowed for file type"
536
  msgstr ""
537
 
538
+ #: public/class-pirateforms-public.php:769
539
  msgid "Uploaded file is too large"
540
  msgstr ""
541
 
542
+ #: public/class-pirateforms-public.php:785
543
  msgid "There was an unknown error uploading the file."
544
  msgstr ""
545
 
 
 
 
 
 
 
 
 
546
  #. Plugin Name of the plugin/theme
547
  msgid "Free & Simple Contact Form Plugin - Pirateforms"
548
  msgstr ""
563
  msgid "http://themeisle.com"
564
  msgstr ""
565
 
566
+ #: includes/class-pirateforms.php:222
567
  msgctxt "post type general name"
568
  msgid "Contacts"
569
  msgstr ""
570
 
571
+ #: includes/class-pirateforms.php:223
572
  msgctxt "post type singular name"
573
  msgid "Contact"
574
  msgstr ""
575
 
576
+ #: includes/class-pirateforms.php:224
577
  msgctxt "admin menu"
578
  msgid "Contacts"
579
  msgstr ""
580
 
581
+ #: includes/class-pirateforms.php:225
582
  msgctxt "add new on admin bar"
583
  msgid "Contact"
584
  msgstr ""
585
 
586
+ #: includes/class-pirateforms.php:226
587
  msgctxt "contact"
588
  msgid "Add New"
589
  msgstr ""
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.0.4
20
  * Author: Themeisle
21
  * Author URI: http://themeisle.com
22
  * Text Domain: pirate-forms
@@ -35,7 +35,7 @@ if ( ! defined( 'WPINC' ) ) {
35
 
36
  define( 'PIRATEFORMS_NAME', 'Pirate Forms' );
37
  define( 'PIRATEFORMS_SLUG', 'pirate-forms' );
38
- define( 'PIRATE_FORMS_VERSION', '2.0.4' );
39
  define( 'PIRATEFORMS_DIR', trailingslashit( plugin_dir_path( __FILE__ ) ) );
40
  define( 'PIRATEFORMS_URL', plugin_dir_url( __FILE__ ) );
41
  define( 'PIRATEFORMS_BASENAME', plugin_basename( __FILE__ ) );
16
  * Plugin Name: Free & Simple Contact Form Plugin - Pirateforms
17
  * Plugin URI: http://themeisle.com/plugins/pirate-forms/
18
  * Description: Easily creates a nice looking, simple contact form on your WP site.
19
+ * Version: 2.0.5
20
  * Author: Themeisle
21
  * Author URI: http://themeisle.com
22
  * Text Domain: pirate-forms
35
 
36
  define( 'PIRATEFORMS_NAME', 'Pirate Forms' );
37
  define( 'PIRATEFORMS_SLUG', 'pirate-forms' );
38
+ define( 'PIRATE_FORMS_VERSION', '2.0.5' );
39
  define( 'PIRATEFORMS_DIR', trailingslashit( plugin_dir_path( __FILE__ ) ) );
40
  define( 'PIRATEFORMS_URL', plugin_dir_url( __FILE__ ) );
41
  define( 'PIRATEFORMS_BASENAME', plugin_basename( __FILE__ ) );
public/class-pirateforms-public.php CHANGED
@@ -95,753 +95,841 @@ class PirateForms_Public {
95
  }
96
 
97
  /**
98
- * Process the form after submission
99
  *
100
  * @since 1.0.0
101
- * @throws Exception When file uploading fails.
102
  */
103
- public function template_redirect() {
104
- do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'POST data = %s', print_r( $_POST, true ) ), 'debug', __FILE__, __LINE__ );
 
 
 
 
 
105
 
106
- // If POST and honeypot are not set, beat it
107
- if ( empty( $_POST ) || ! isset( $_POST['honeypot'] ) ) {
108
- return false;
109
- }
110
 
111
- // separate the nonce from a form that is displayed in the widget vs. one that is not
112
- $nonce_append = isset( $_POST['pirate_forms_from_widget'] ) && intval( $_POST['pirate_forms_from_widget'] ) === 1 ? 'yes' : 'no';
 
 
 
 
 
 
 
 
 
113
 
114
- // Session variable for form errors
115
- $error_key = wp_create_nonce( get_bloginfo( 'admin_email' ) . $nonce_append );
116
- $_SESSION[ $error_key ] = array();
 
 
117
 
118
- // If nonce is not valid, beat it
119
- if ( 'yes' === PirateForms_Util::get_option( 'pirateformsopt_nonce' ) ) {
120
- if ( ! wp_verify_nonce( $_POST['wordpress-nonce'], get_bloginfo( 'admin_email' ) . $nonce_append ) ) {
121
- $_SESSION[ $error_key ]['nonce'] = __( 'Nonce failed!', 'pirate-forms' );
122
- do_action( 'themeisle_log_event', PIRATEFORMS_NAME, 'Nonce failed', 'error', __FILE__, __LINE__ );
123
 
124
- return false;
 
 
 
 
 
 
 
 
125
  }
126
  }
127
 
128
- // If the honeypot caught a bear, beat it
129
- if ( ! empty( $_POST['honeypot'] ) ) {
130
- $_SESSION[ $error_key ]['honeypot'] = __( 'Form submission failed!', 'pirate-forms' );
131
-
132
- return false;
133
- }
134
 
135
- $pirate_forms_options = PirateForms_Util::get_form_options( isset( $_POST['pirate_forms_form_id'] ) ? $_POST['pirate_forms_form_id'] : null );
136
 
137
- if ( ! $this->validate_captcha( $error_key, $pirate_forms_options ) ) {
138
- return false;
 
139
  }
140
 
141
- // Start the body of the contact email
142
- $body = '<h2>' . __( 'Contact form submission from', 'pirate-forms' ) . ' ' .
143
- get_bloginfo( 'name' ) . ' (' . site_url() . ') </h2>';
144
-
145
- $body .= '<table>';
146
-
147
- $pirate_forms_contact_email = null;
148
- $pirate_forms_contact_name = null;
149
- $pirate_forms_contact_subject = null;
150
- $fields = array( 'name', 'email', 'subject', 'message' );
151
- foreach ( $fields as $field ) {
152
- $value = isset( $_POST[ 'pirate-forms-contact-' . $field ] ) ? sanitize_text_field( trim( $_POST[ 'pirate-forms-contact-' . $field ] ) ) : '';
153
- if ( $pirate_forms_options[ 'pirateformsopt_' . $field . '_field' ] === 'req' && empty( $value ) ) {
154
- $_SESSION[ $error_key ][ 'pirate-forms-contact-' . $field ] = $pirate_forms_options[ 'pirateformsopt_label_err_' . $field ];
155
- } elseif ( ! empty( $value ) ) {
156
- if ( 'email' === $field && ! filter_var( $value, FILTER_VALIDATE_EMAIL ) ) {
157
- $_SESSION[ $error_key ][ 'pirate-forms-contact-' . $field ] = $pirate_forms_options[ 'pirateformsopt_label_err_' . $field ];
158
- } else {
159
- if ( 'email' === $field ) {
160
- $pirate_forms_contact_email = $value;
161
- } elseif ( 'name' === $field ) {
162
- $pirate_forms_contact_name = $value;
163
- } elseif ( 'subject' === $field ) {
164
- $pirate_forms_contact_subject = $value;
165
- }
166
- $body .= $this->table_row( stripslashes( $pirate_forms_options[ 'pirateformsopt_label_' . $field ] ), $value );
167
- }
168
- }
169
- }
170
 
171
  /**
172
- ******** Validate recipients email */
173
- $site_recipients = sanitize_text_field( $pirate_forms_options['pirateformsopt_email_recipients'] );
174
- if ( empty( $site_recipients ) ) {
175
- $_SESSION[ $error_key ]['pirate-forms-recipients-email'] = __( 'Please enter one or more Contact submission recipients', 'pirate-forms' );
176
- }
177
- /**
178
- ****** Sanitize and validate IP */
179
- $contact_ip = filter_var( $_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP );
180
- /* for the case of a Web server behind a reverse proxy */
181
- if ( array_key_exists( 'HTTP_X_FORWARDED_FOR', $_SERVER ) ) {
182
- $contact_ip_tmp = explode( ',', $_SERVER['HTTP_X_FORWARDED_FOR'] );
183
- if ( ! empty( $contact_ip_tmp ) ) {
184
- $contact_ip = array_pop( $contact_ip_tmp );
185
- }
186
- }
187
-
188
- // If valid and present, create a link to an IP search
189
- if ( ! empty( $contact_ip ) ) {
190
- $body .= $this->table_row( __( 'IP address: ', 'pirate-forms' ), $contact_ip );
191
- $body .= $this->table_row( __( 'IP search:', 'pirate-forms' ), "http://whatismyipaddress.com/ip/$contact_ip" );
192
- }
193
-
194
- // Sanitize and prepare referrer;
195
- if ( ! empty( $_POST['pirate-forms-contact-referrer'] ) ) {
196
- $body .= $this->table_row( __( 'Came from: ', 'pirate-forms' ), sanitize_text_field( $_POST['pirate-forms-contact-referrer'] ) );
197
  }
 
 
 
198
 
199
- // Show the page this contact form was submitted on
200
- $body .= $this->table_row( __( 'Sent from page: ', 'pirate-forms' ), get_permalink( get_the_id() ) );
201
-
202
- // Check the blacklist
203
- $blocked = PirateForms_Util::is_blacklisted( $error_key, $pirate_forms_contact_email, $contact_ip );
204
- if ( $blocked ) {
205
- return false;
206
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
207
 
208
- $body .= '</table>';
 
209
 
210
- // No errors? Go ahead and process the contact
211
- if ( empty( $_SESSION[ $error_key ] ) ) {
212
- $site_email = sanitize_text_field( $pirate_forms_options['pirateformsopt_email'] );
213
- if ( ! empty( $pirate_forms_contact_name ) ) :
214
- $site_name = $pirate_forms_contact_name;
215
- else :
216
- $site_name = htmlspecialchars_decode( get_bloginfo( 'name' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
217
  endif;
218
- // Notification recipients
219
- $site_recipients = sanitize_text_field( $pirate_forms_options['pirateformsopt_email_recipients'] );
220
- $site_recipients = explode( ',', $site_recipients );
221
- $site_recipients = array_map( 'trim', $site_recipients );
222
- $site_recipients = array_map( 'sanitize_email', $site_recipients );
223
- $site_recipients = implode( ',', $site_recipients );
224
- // No name? Use the submitter email address, if one is present
225
- if ( empty( $pirate_forms_contact_name ) ) {
226
- $pirate_forms_contact_name = ! empty( $pirate_forms_contact_email ) ? $pirate_forms_contact_email : '[None given]';
227
- }
228
-
229
- // Need an email address for the email notification
230
- $send_from = '';
231
- if ( '[email]' == $site_email && ! empty( $pirate_forms_contact_email ) ) {
232
- $send_from = $pirate_forms_contact_email;
233
- } elseif ( ! empty( $site_email ) ) {
234
- $send_from = $site_email;
235
- } else {
236
- $send_from = PirateForms_Util::get_from_email();
237
- }
238
- $send_from_name = $site_name;
239
 
240
- // Send an email notification to the correct address
241
- $headers = "From: $send_from_name <$send_from>\r\nReply-To: $pirate_forms_contact_name <$pirate_forms_contact_email>\r\nContent-type: text/html";
242
- add_action( 'phpmailer_init', array( $this, 'phpmailer' ) );
243
 
244
- $attachments = $this->get_attachments( $error_key, $pirate_forms_options );
245
- if ( is_bool( $attachments ) ) {
246
- return false;
247
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
248
 
249
- $subject = 'Contact on ' . htmlspecialchars_decode( get_bloginfo( 'name' ) );
250
- if ( ! empty( $pirate_forms_contact_subject ) ) {
251
- $subject = $pirate_forms_contact_subject;
252
- }
253
 
254
- do_action( 'pirate_forms_before_sending', $pirate_forms_contact_email, $site_recipients, $subject, $body, $headers, $attachments );
255
- do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'before sending email to = %s, subject = %s, body = %s, headers = %s, attachments = %s', $site_recipients, $subject, $body, $headers, print_r( $attachments, true ) ), 'debug', __FILE__, __LINE__ );
256
- $response = wp_mail( $site_recipients, $subject, $body, $headers, $attachments );
257
- if ( ! $response ) {
258
- error_log( 'Email not sent' );
259
- }
260
- do_action( 'pirate_forms_after_sending', $pirate_forms_options, $response, $pirate_forms_contact_email, $site_recipients, $subject, $body, $headers, $attachments );
261
- do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'after sending email, response = %s', $response ), 'debug', __FILE__, __LINE__ );
262
-
263
- // delete the tmp directory
264
- require_once( ABSPATH . 'wp-admin/includes/file.php' );
265
- WP_Filesystem();
266
- global $wp_filesystem;
267
- $wp_filesystem->delete( $this->get_upload_tmp_dir(), true, 'd' );
268
-
269
- // Should a confirm email be sent?
270
- $confirm_body = stripslashes( trim( $pirate_forms_options['pirateformsopt_confirm_email'] ) );
271
- if ( ! empty( $confirm_body ) && ! empty( $pirate_forms_contact_email ) ) {
272
- // Removing entities
273
- $confirm_body = htmlspecialchars_decode( $confirm_body );
274
- $confirm_body = html_entity_decode( $confirm_body );
275
- $confirm_body = str_replace( '&#39;', "'", $confirm_body );
276
- $send_from = PirateForms_Util::get_from_email();
277
- if ( ! empty( $site_email ) && '[email]' !== $site_email ) {
278
- $send_from = $site_email;
279
  }
280
- $site_name = htmlspecialchars_decode( get_bloginfo( 'name' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
281
 
282
- $headers = "From: $site_name <$send_from>\r\nReply-To: $site_name <$send_from>";
283
- $subject = $pirate_forms_options['pirateformsopt_label_submit'] . ' - ' . $site_name;
284
 
285
- do_action( 'pirate_forms_before_sending_confirm', $pirate_forms_contact_email, $pirate_forms_contact_email, $subject, $confirm_body, $headers );
286
- do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'before sending confirm email to = %s, subject = %s, body = %s, headers = %s', $pirate_forms_contact_email, $subject, $confirm_body, $headers ), 'debug', __FILE__, __LINE__ );
287
- $response = wp_mail( $pirate_forms_contact_email, $subject, $confirm_body, $headers );
288
- do_action( 'pirate_forms_after_sending_confirm', $pirate_forms_options, $response, $pirate_forms_contact_email, $pirate_forms_contact_email, $subject, $confirm_body, $headers );
289
- do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'after sending confirm email response = %s', $response ), 'debug', __FILE__, __LINE__ );
290
- if ( ! $response ) {
291
- error_log( 'Confirm email not sent' );
 
292
  }
293
- }
294
-
 
 
 
 
 
 
 
 
 
 
 
295
  /**
296
- *********** Store the entries in the DB */
297
- if ( 'yes' === $pirate_forms_options['pirateformsopt_store'] ) {
298
- $new_post_id = wp_insert_post(
299
- array(
300
- 'post_type' => 'pf_contact',
301
- 'post_title' => date( 'l, M j, Y', time() ) . ' by "' . $pirate_forms_contact_name . '"',
302
- 'post_content' => $body,
303
- 'post_author' => 1,
304
- 'post_status' => 'private',
305
- )
 
 
 
 
306
  );
307
- if ( isset( $pirate_forms_contact_email ) && ! empty( $pirate_forms_contact_email ) ) {
308
- add_post_meta( $new_post_id, 'Contact email', $pirate_forms_contact_email );
309
- }
310
- }
311
- $pirate_forms_current_theme = wp_get_theme();
312
 
313
- /* If a Thank you page is selected, redirect to that page */
314
- if ( $pirate_forms_options['pirateformsopt_thank_you_url'] ) {
315
- $redirect_id = intval( $pirate_forms_options['pirateformsopt_thank_you_url'] );
316
- $redirect = get_permalink( $redirect_id );
317
- wp_safe_redirect( $redirect );
318
- } elseif ( ( 'Zerif Lite' == $pirate_forms_current_theme->name ) || ( 'Zerif Lite' == $pirate_forms_current_theme->parent_theme ) || ( 'Zerif PRO' == $pirate_forms_current_theme->name ) || ( 'Zerif PRO' == $pirate_forms_current_theme->parent_theme ) ) {
319
- $redirect = $_SERVER['HTTP_REFERER'] . ( strpos( $_SERVER['HTTP_REFERER'], '?' ) === false ? '?' : '&' ) . 'pcf=1#contact&done';
320
- wp_safe_redirect( $redirect );
321
- } elseif ( isset( $_SERVER['HTTP_REFERER'] ) ) {
322
- $redirect = $_SERVER['HTTP_REFERER'] . ( strpos( $_SERVER['HTTP_REFERER'], '?' ) === false ? '?' : '&' ) . 'done';
323
- wp_safe_redirect( $redirect );
324
  }
325
- }// End if().
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
326
  }
327
 
328
  /**
329
- * Validate CAPTCHA
330
  *
331
- * @param string $error_key the key for the session object.
332
- * @param array $pirate_forms_options the array of options for this form.
333
  */
334
- function validate_captcha( $error_key, $pirate_forms_options ) {
335
- $pirateformsopt_recaptcha_sitekey = $pirate_forms_options['pirateformsopt_recaptcha_sitekey'];
336
- $pirateformsopt_recaptcha_secretkey = $pirate_forms_options['pirateformsopt_recaptcha_secretkey'];
337
- $pirateformsopt_recaptcha_field = $pirate_forms_options['pirateformsopt_recaptcha_field'];
338
- if ( ! empty( $pirateformsopt_recaptcha_secretkey ) && ! empty( $pirateformsopt_recaptcha_sitekey ) && ! empty( $pirateformsopt_recaptcha_field ) && ( $pirateformsopt_recaptcha_field == 'yes' ) ) :
339
- if ( isset( $_POST['g-recaptcha-response'] ) ) {
340
- $captcha = $_POST['g-recaptcha-response'];
341
- }
342
- if ( ! $captcha ) {
343
- $_SESSION[ $error_key ]['pirate-forms-captcha'] = __( 'Wrong reCAPTCHA', 'pirate-forms' );
344
 
345
- return false;
346
- }
347
- $response = wp_remote_get( 'https://www.google.com/recaptcha/api/siteverify?secret=' . $pirateformsopt_recaptcha_secretkey . '&response=' . $captcha . '&remoteip=' . $_SERVER['REMOTE_ADDR'] );
348
- if ( ! empty( $response ) ) :
349
- $response_body = wp_remote_retrieve_body( $response );
350
- endif;
351
- if ( ! empty( $response_body ) ) :
352
- $result = json_decode( $response_body, true );
353
- endif;
354
- if ( isset( $result['success'] ) && ( $result['success'] == false ) ) {
355
- $_SESSION[ $error_key ]['pirate-forms-captcha'] = __( 'Wrong reCAPTCHA', 'pirate-forms' );
356
 
357
- return false;
358
- }
359
- endif;
360
 
361
- return true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
362
  }
363
 
364
  /**
365
- * Return the table row
366
  *
367
- * @since 1.0.0
368
  */
369
- public function table_row( $key, $value ) {
370
- return '<tr><th>' . $key . '</th><td>' . $value . '</td></tr>';
 
 
 
 
 
 
 
 
 
 
 
 
 
371
  }
372
 
373
  /**
374
- * Get attachments, if any
375
  *
376
- * @param string $error_key the key for the session object.
377
- * @param array $pirate_forms_options the array of options for the form.
 
 
 
 
 
 
 
 
378
  *
 
379
  * @throws Exception When file uploading fails.
380
  */
381
- function get_attachments( $error_key, $pirate_forms_options ) {
382
- $attachments = '';
383
- /**
384
- ******* Validate Attachment */
385
- $use_files = $pirate_forms_options['pirateformsopt_attachment_field'];
386
- if ( ! empty( $use_files ) && ( $use_files == 'yes' ) ) {
387
- $pirate_forms_attach_file = isset( $_FILES['pirate-forms-attachment'] ) ? $_FILES['pirate-forms-attachment'] : '';
388
- if ( ! empty( $pirate_forms_attach_file ) && ! empty( $pirate_forms_attach_file['name'] ) ) {
389
- /* Validate file type */
390
- $file_types_allowed = 'jpg|jpeg|png|gif|pdf|doc|docx|ppt|pptx|odt|avi|ogg|m4a|mov|mp3|mp4|mpg|wav|wmv';
391
- $pirate_forms_file_types_allowed = $file_types_allowed;
392
- $pirate_forms_file_types_allowed = trim( $pirate_forms_file_types_allowed, '|' );
393
- $pirate_forms_file_types_allowed = '(' . $pirate_forms_file_types_allowed . ')';
394
- $pirate_forms_file_types_allowed = '/\.' . $pirate_forms_file_types_allowed . '$/i';
395
- if ( ! preg_match( $pirate_forms_file_types_allowed, $pirate_forms_attach_file['name'] ) ) {
396
- do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'file invalid: expected %s got %s', $file_types_allowed, $pirate_forms_attach_file['name'] ), 'error', __FILE__, __LINE__ );
397
- $_SESSION[ $error_key ]['pirate-forms-upload-failed-type'] = __( 'Uploaded file is not allowed for file type', 'pirate-forms' );
398
 
399
- return false;
400
- }
401
- /* Validate file size */
402
- $pirate_forms_file_size_allowed = 1048576; // default size 1 MB
403
- if ( $pirate_forms_attach_file['size'] > $pirate_forms_file_size_allowed ) {
404
- do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'file too large: expected %d got %d', $pirate_forms_file_size_allowed, $pirate_forms_attach_file['size'] ), 'error', __FILE__, __LINE__ );
405
- $_SESSION[ $error_key ]['pirate-forms-upload-failed-size'] = __( 'Uploaded file is too large', 'pirate-forms' );
406
 
407
- return false;
408
- }
409
- $this->init_uploads();
410
- $uploads_dir = $this->get_upload_tmp_dir();
411
- $uploads_dir = $this->maybe_add_random_dir( $uploads_dir );
412
- $filename = $pirate_forms_attach_file['name'];
413
- $filename = $this->canonicalize( $filename );
414
- $filename = sanitize_file_name( $filename );
415
- $filename = $this->antiscript_file_name( $filename );
416
- $filename = wp_unique_filename( $uploads_dir, $filename );
417
- $new_file = trailingslashit( $uploads_dir ) . $filename;
418
- try {
419
- if ( false === move_uploaded_file( $pirate_forms_attach_file['tmp_name'], $new_file ) ) {
420
- do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'unable to move the uploaded file from %s to %s', $pirate_forms_attach_file['tmp_name'], $new_file ), 'error', __FILE__, __LINE__ );
421
- throw new Exception( __( 'There was an unknown error uploading the file.', 'pirate-forms' ) );
422
- }
423
- } catch ( Exception $ex ) {
424
- do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'unable to move the uploaded file from %s to %s with error %s', $pirate_forms_attach_file['tmp_name'], $new_file, $ex->getMessage() ), 'error', __FILE__, __LINE__ );
425
- $_SESSION[ $error_key ]['pirate-forms-upload-failed-general'] = $ex->getMessage();
426
- }
427
- if ( ! empty( $new_file ) ) {
428
- $attachments = $new_file;
429
- }
430
- }// End if().
431
- }// End if().
432
- return $attachments;
433
- }
434
 
435
- /**
436
- * Prepare the uploading process
437
- *
438
- * @since 1.0.0
439
- * @throws Exception When file could not be opened.
440
- */
441
- function init_uploads() {
442
- $dir = $this->get_upload_tmp_dir();
443
- wp_mkdir_p( $dir );
444
- $htaccess_file = trailingslashit( $dir ) . '.htaccess';
445
- if ( file_exists( $htaccess_file ) ) {
446
- return;
447
- }
448
- try {
449
- $handle = fopen( $htaccess_file, 'w' );
450
 
451
- if ( ! $handle ) {
452
- throw new Exception( 'File open failed.' );
453
- } else {
454
- fwrite( $handle, "Deny from all\n" );
455
- fclose( $handle );
 
 
456
  }
457
- } catch ( Exception $e ) {
458
- // nothing
459
  }
460
- }
461
 
462
- /**
463
- * Return the temporary upload dir
464
- *
465
- * @since 1.0.0
466
- */
467
- function get_upload_tmp_dir() {
468
- return $this->get_upload_dir( 'dir' ) . '/pirate_forms_uploads';
469
- }
470
 
471
- /**
472
- * Return the upload dir
473
- *
474
- * @since 1.0.0
475
- */
476
- function get_upload_dir( $type = false ) {
477
- $uploads = wp_upload_dir();
478
- $uploads = apply_filters(
479
- 'pirate_forms_upload_dir', array(
480
- 'dir' => $uploads['basedir'],
481
- 'url' => $uploads['baseurl'],
482
- )
483
- );
484
- if ( 'dir' == $type ) {
485
- return $uploads['dir'];
486
- }
487
- if ( 'url' == $type ) {
488
- return $uploads['url'];
489
  }
490
 
491
- return $uploads;
492
- }
493
 
494
- /**
495
- * Add a random directory for uploading
496
- *
497
- * @since 1.0.0
498
- */
499
- function maybe_add_random_dir( $dir ) {
500
- do {
501
- $rand_max = mt_getrandmax();
502
- $rand = zeroise( mt_rand( 0, $rand_max ), strlen( $rand_max ) );
503
- $dir_new = path_join( $dir, $rand );
504
- } while ( file_exists( $dir_new ) );
505
- if ( wp_mkdir_p( $dir_new ) ) {
506
- return $dir_new;
507
  }
508
 
509
- return $dir;
510
- }
 
511
 
512
- /**
513
- * Functions to Process uploaded files
514
- */
515
- function canonicalize( $text ) {
516
- if ( function_exists( 'mb_convert_kana' )
517
- && 'UTF-8' == get_option( 'blog_charset' )
518
- ) {
519
- $text = mb_convert_kana( $text, 'asKV', 'UTF-8' );
520
- }
521
- $text = strtolower( $text );
522
- $text = trim( $text );
523
 
524
- return $text;
525
- }
526
 
527
- /**
528
- * Prevent uploading any script files
529
- *
530
- * @since 1.0.0
531
- */
532
- function antiscript_file_name( $filename ) {
533
- $filename = basename( $filename );
534
- $parts = explode( '.', $filename );
535
- if ( count( $parts ) < 2 ) {
536
- return $filename;
537
  }
538
- $script_pattern = '/^(php|phtml|pl|py|rb|cgi|asp|aspx)\d?$/i';
539
- $filename = array_shift( $parts );
540
- $extension = array_pop( $parts );
541
- foreach ( (array) $parts as $part ) {
542
- if ( preg_match( $script_pattern, $part ) ) {
543
- $filename .= '.' . $part . '_';
544
- } else {
545
- $filename .= '.' . $part;
546
  }
547
  }
548
- if ( preg_match( $script_pattern, $extension ) ) {
549
- $filename .= '.' . $extension . '_.txt';
550
- } else {
551
- $filename .= '.' . $extension;
552
- }
553
 
554
- return $filename;
555
- }
 
 
 
556
 
557
- /**
558
- * Change the content of the widget
559
- *
560
- * @since 1.0.0
561
- */
562
- public function widget_text_filter( $content ) {
563
- if ( ! preg_match( '[pirate_forms]', $content ) ) {
564
- return $content;
565
  }
566
- $content = do_shortcode( $content );
567
 
568
- return $content;
569
- }
570
 
571
- /**
572
- * Display the form
573
- *
574
- * @since 1.0.0
575
- */
576
- public function display_form( $atts, $content = null ) {
577
- $atts = shortcode_atts(
578
- array(
579
- 'from' => '',
580
- 'id' => '',
581
- ), $atts
582
- );
583
 
584
- $elements = array();
585
- $pirate_form = new PirateForms_PhpFormBuilder();
586
 
587
- $elements[] = array(
588
- 'type' => 'text',
589
- 'id' => 'form_honeypot',
590
- 'name' => 'honeypot',
591
- 'slug' => 'honeypot',
592
- 'wrap' => array(
593
- 'type' => 'div',
594
- 'class' => 'form_field_wrap hidden',
595
- 'style' => 'display: none',
596
- ),
597
- );
 
 
 
 
 
 
 
598
 
599
- $elements[] = array(
600
- 'type' => 'hidden',
601
- 'id' => 'pirate_forms_from_widget',
602
- 'value' => empty( $atts['from'] ) ? 0 : 1,
603
- );
 
 
 
 
 
604
 
605
- $pirate_forms_options = PirateForms_Util::get_option();
 
 
606
 
607
- if ( isset( $atts['id'] ) && ! empty( $atts['id'] ) ) {
608
- $pirate_forms_options = apply_filters( 'pirateformpro_get_form_attributes', $pirate_forms_options, $atts['id'] );
609
- if ( isset( $pirate_forms_options['id'] ) ) {
610
- // add the form id to the form so that it can be used when we are processing the form
611
- $elements[] = array(
612
- 'type' => 'hidden',
613
- 'id' => 'pirate_forms_form_id',
614
- 'value' => $atts['id'],
615
- );
616
  }
617
- }
618
 
619
- $nonce_append = isset( $_POST['pirate_forms_from_widget'] ) && intval( $_POST['pirate_forms_from_widget'] ) === 1 ? 'yes' : 'no';
 
 
 
620
 
621
- $error_key = wp_create_nonce( get_bloginfo( 'admin_email' ) . ( empty( $atts['from'] ) ? 'no' : 'yes' ) );
 
 
 
 
 
 
 
622
 
623
- $thank_you_message = '';
624
- if ( isset( $_GET['done'] ) ) {
625
- $thank_you_message = sanitize_text_field( $pirate_forms_options['pirateformsopt_label_submit'] );
626
- }
 
627
 
628
- $pirate_form->set_element( 'thank_you_message', $thank_you_message );
 
 
 
 
 
 
 
 
 
 
 
629
 
630
- /**
631
- ******** FormBuilder */
632
- if ( 'yes' === PirateForms_Util::get_option( 'pirateformsopt_nonce' ) ) {
633
- $elements[] = array(
634
- 'type' => 'hidden',
635
- 'id' => 'wordpress-nonce',
636
- 'value' => wp_create_nonce( get_bloginfo( 'admin_email' ) . $nonce_append ),
637
- );
638
- }
639
- if ( ! empty( $pirate_forms_options ) ) :
640
- $field = $pirate_forms_options['pirateformsopt_name_field'];
641
- $label = $pirate_forms_options['pirateformsopt_label_name'];
642
 
643
- /**
644
- ****** Name field */
645
- if ( ! empty( $field ) && ! empty( $label ) ) :
646
- $required = $field === 'req' ? true : false;
647
- $wrap_classes = array(
648
- 'col-sm-6 col-lg-6 contact_name_wrap pirate_forms_three_inputs form_field_wrap',
649
- );
650
- // If this field was submitted with invalid data
651
- if ( isset( $_SESSION[ $error_key ]['contact-name'] ) ) {
652
- $wrap_classes[] = 'error';
653
  }
654
- $elements[] = array(
655
- 'placeholder' => stripslashes( sanitize_text_field( $label ) ),
656
- 'required' => $required,
657
- 'required_msg' => $pirate_forms_options['pirateformsopt_label_err_name'],
658
- 'type' => 'text',
659
- 'id' => 'pirate-forms-contact-name',
660
- 'class' => 'form-control',
661
- 'wrap' => array(
662
- 'type' => 'div',
663
- 'class' => implode( ' ', apply_filters( 'pirateform_wrap_classes_name', $wrap_classes ) ),
664
- ),
665
- 'value' => empty( $thank_you_message ) && isset( $_REQUEST['pirate-forms-contact-name'] ) ? $_REQUEST['pirate-forms-contact-name'] : '',
666
- );
667
- endif;
668
-
669
- $field = $pirate_forms_options['pirateformsopt_email_field'];
670
- $label = $pirate_forms_options['pirateformsopt_label_email'];
671
 
672
  /**
673
- ****** Email field */
674
- if ( ! empty( $field ) && ! empty( $label ) ) :
675
- $required = $field === 'req' ? true : false;
676
- $wrap_classes = array(
677
- 'col-sm-6 col-lg-6 contact_email_wrap pirate_forms_three_inputs form_field_wrap',
 
 
 
 
 
678
  );
679
- // If this field was submitted with invalid data
680
- if ( isset( $_SESSION[ $error_key ]['contact-email'] ) ) {
681
- $wrap_classes[] = 'error';
682
  }
683
- $elements[] = array(
684
- 'placeholder' => stripslashes( sanitize_text_field( $label ) ),
685
- 'required' => $required,
686
- 'required_msg' => $pirate_forms_options['pirateformsopt_label_err_email'],
687
- 'type' => 'email',
688
- 'id' => 'pirate-forms-contact-email',
689
- 'class' => 'form-control',
690
- 'wrap' => array(
691
- 'type' => 'div',
692
- 'class' => implode( ' ', apply_filters( 'pirateform_wrap_classes_email', $wrap_classes ) ),
693
- ),
694
- 'value' => empty( $thank_you_message ) && isset( $_REQUEST['pirate-forms-contact-email'] ) ? $_REQUEST['pirate-forms-contact-email'] : '',
695
- );
696
- endif;
697
 
698
- $field = $pirate_forms_options['pirateformsopt_subject_field'];
699
- $label = $pirate_forms_options['pirateformsopt_label_subject'];
700
 
701
- /**
702
- ****** Subject field */
703
- if ( ! empty( $field ) && ! empty( $label ) ) :
704
- $required = $field === 'req' ? true : false;
705
- $wrap_classes = array(
706
- 'contact_subject_wrap pirate_forms_three_inputs form_field_wrap',
707
- );
708
- // If this field was submitted with invalid data
709
- if ( isset( $_SESSION[ $error_key ]['contact-subject'] ) ) {
710
- $wrap_classes[] = 'error';
711
  }
712
- $elements[] = array(
713
- 'placeholder' => stripslashes( sanitize_text_field( $label ) ),
714
- 'required' => $required,
715
- 'required_msg' => $pirate_forms_options['pirateformsopt_label_err_subject'],
716
- 'type' => 'text',
717
- 'id' => 'pirate-forms-contact-subject',
718
- 'class' => 'form-control',
719
- 'wrap' => array(
720
- 'type' => 'div',
721
- 'class' => implode( ' ', apply_filters( 'pirateform_wrap_classes_subject', $wrap_classes ) ),
722
- ),
723
- 'value' => empty( $thank_you_message ) && isset( $_REQUEST['pirate-forms-contact-subject'] ) ? $_REQUEST['pirate-forms-contact-subject'] : '',
724
- );
725
- endif;
726
-
727
- $field = $pirate_forms_options['pirateformsopt_message_field'];
728
- $label = $pirate_forms_options['pirateformsopt_label_message'];
729
 
730
- /**
731
- ****** Message field */
732
- if ( ! empty( $field ) && ! empty( $label ) ) :
733
- $required = $field === 'req' ? true : false;
734
- $wrap_classes = array( 'col-sm-12 col-lg-12 form_field_wrap contact_message_wrap ' );
735
- // If this field was submitted with invalid data
736
- if ( isset( $_SESSION[ $error_key ]['contact-message'] ) ) {
737
- $wrap_classes[] = 'error';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
738
  }
739
- $elements[] = array(
740
- 'placeholder' => stripslashes( sanitize_text_field( $label ) ),
741
- 'required' => $required,
742
- 'required_msg' => $pirate_forms_options['pirateformsopt_label_err_no_content'],
743
- 'type' => 'textarea',
744
- 'class' => 'form-control',
745
- 'id' => 'pirate-forms-contact-message',
746
- 'wrap' => array(
747
- 'type' => 'div',
748
- 'class' => implode( ' ', apply_filters( 'pirateform_wrap_classes_message', $wrap_classes ) ),
749
- ),
750
- 'value' => empty( $thank_you_message ) && isset( $_REQUEST['pirate-forms-contact-message'] ) ? $_REQUEST['pirate-forms-contact-message'] : '',
751
- );
752
- endif;
753
 
754
- $field = $pirate_forms_options['pirateformsopt_attachment_field'];
755
 
756
- /**
757
- ****** Message field */
758
- if ( ! empty( $field ) && 'no' !== $field ) :
759
- $required = $field === 'req' ? true : false;
760
- $wrap_classes = array( 'col-sm-12 col-lg-12 form_field_wrap contact_attachment_wrap' );
761
- // If this field was submitted with invalid data
762
- if ( isset( $_SESSION[ $error_key ]['contact-attachment'] ) ) {
763
- $wrap_classes[] = 'error';
764
- }
765
- $elements[] = array(
766
- 'placeholder' => stripslashes( sanitize_text_field( $label ) ),
767
- 'required' => $required,
768
- 'required_msg' => $pirate_forms_options['pirateformsopt_label_err_no_attachment'],
769
- 'type' => 'file',
770
- 'class' => 'form-control',
771
- 'id' => 'pirate-forms-attachment',
772
- 'wrap' => array(
773
- 'type' => 'div',
774
- 'class' => implode( ' ', apply_filters( 'pirateform_wrap_classes_attachment', $wrap_classes ) ),
775
- ),
776
- );
 
 
 
 
777
  endif;
778
- /**
779
- ******* ReCaptcha */
780
- if ( ! empty( $pirate_forms_options['pirateformsopt_recaptcha_secretkey'] ) && ! empty( $pirate_forms_options['pirateformsopt_recaptcha_sitekey'] ) && ! empty( $pirate_forms_options['pirateformsopt_recaptcha_field'] ) && ( $pirate_forms_options['pirateformsopt_recaptcha_field'] == 'yes' ) ) :
781
- $pirateformsopt_recaptcha_sitekey = $pirate_forms_options['pirateformsopt_recaptcha_sitekey'];
782
- $pirateformsopt_recaptcha_secretkey = $pirate_forms_options['pirateformsopt_recaptcha_secretkey'];
783
- $elements[] = array(
784
- 'placeholder' => stripslashes( sanitize_text_field( $label ) ),
785
- 'type' => 'div',
786
- 'class' => 'g-recaptcha pirate-forms-g-recaptcha',
787
- 'custom' => array( 'data-sitekey' => $pirateformsopt_recaptcha_sitekey ),
788
- 'id' => 'pirate-forms-captcha',
789
- 'wrap' => array(
790
- 'type' => 'div',
791
- 'class' => implode( ' ', apply_filters( 'pirateform_wrap_classes_captcha', array( 'col-xs-12 col-sm-6 col-lg-6 form_field_wrap form_captcha_wrap' ) ) ),
792
- ),
793
- );
794
  endif;
 
 
795
 
796
- /**
797
- ****** Submit button */
798
- $pirateformsopt_label_submit_btn = '';
799
- if ( ! empty( $pirate_forms_options['pirateformsopt_label_submit_btn'] ) ) {
800
- $pirateformsopt_label_submit_btn = $pirate_forms_options['pirateformsopt_label_submit_btn'];
801
- }
802
- if ( empty( $pirateformsopt_label_submit_btn ) ) {
803
- $pirateformsopt_label_submit_btn = __( 'Submit', 'pirate-forms' );
804
  }
805
- $elements[] = array(
806
- 'type' => 'button',
807
- 'id' => 'pirate-forms-contact-submit',
808
- 'class' => 'pirate-forms-submit-button btn btn-primary',
809
- 'wrap' => array(
810
- 'type' => 'div',
811
- 'class' => implode( ' ', apply_filters( 'pirateform_wrap_classes_submit', array( 'col-xs-12 col-sm-6 col-lg-6 form_field_wrap contact_submit_wrap' ) ) ),
812
- ),
813
- 'value' => $pirateformsopt_label_submit_btn,
814
- );
815
  endif;
816
 
817
- /* Referring site or page, if any */
818
- if ( ! empty( $_SERVER['HTTP_REFERER'] ) ) {
819
- $elements[] = array(
820
- 'type' => 'hidden',
821
- 'id' => 'contact-referrer',
822
- 'value' => $_SERVER['HTTP_REFERER'],
823
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
824
  }
 
 
825
 
826
- /* Referring page, if sent via URL query */
827
- if ( ! empty( $_REQUEST['src'] ) || ! empty( $_REQUEST['ref'] ) ) {
828
- $elements[] = array(
829
- 'type' => 'hidden',
830
- 'id' => 'referring-page',
831
- 'value' => ! empty( $_REQUEST['src'] ) ? $_REQUEST['src'] : $_REQUEST['ref'],
832
- );
 
833
  }
 
834
 
835
- /* Are there any submission errors? */
836
- $errors = '';
837
- if ( ! empty( $_SESSION[ $error_key ] ) ) {
838
- $pirate_form->set_element( 'errors', $_SESSION[ $error_key ] );
839
- unset( $_SESSION[ $error_key ] );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
840
  }
841
 
842
- do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'displaying elements %s', print_r( $elements, true ) ), 'debug', __FILE__, __LINE__ );
 
843
 
844
- return $pirate_form->build_form( apply_filters( 'pirate_forms_public_controls', $elements ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
845
  }
846
 
847
  /**
95
  }
96
 
97
  /**
98
+ * Display the form
99
  *
100
  * @since 1.0.0
 
101
  */
102
+ public function display_form( $atts, $content = null ) {
103
+ $atts = shortcode_atts(
104
+ array(
105
+ 'from' => '',
106
+ 'id' => '',
107
+ ), $atts
108
+ );
109
 
110
+ $from_widget = ! empty( $atts['from'] );
111
+ $elements = array();
112
+ $pirate_form = new PirateForms_PhpFormBuilder();
 
113
 
114
+ $elements[] = array(
115
+ 'type' => 'text',
116
+ 'id' => 'form_honeypot',
117
+ 'name' => 'honeypot',
118
+ 'slug' => 'honeypot',
119
+ 'wrap' => array(
120
+ 'type' => 'div',
121
+ 'class' => 'form_field_wrap hidden',
122
+ 'style' => 'display: none',
123
+ ),
124
+ );
125
 
126
+ $elements[] = array(
127
+ 'type' => 'hidden',
128
+ 'id' => 'pirate_forms_from_widget',
129
+ 'value' => $from_widget ? 1 : 0,
130
+ );
131
 
132
+ $pirate_forms_options = PirateForms_Util::get_option();
 
 
 
 
133
 
134
+ if ( isset( $atts['id'] ) && ! empty( $atts['id'] ) ) {
135
+ $pirate_forms_options = apply_filters( 'pirateformpro_get_form_attributes', $pirate_forms_options, $atts['id'] );
136
+ if ( isset( $pirate_forms_options['id'] ) ) {
137
+ // add the form id to the form so that it can be used when we are processing the form
138
+ $elements[] = array(
139
+ 'type' => 'hidden',
140
+ 'id' => 'pirate_forms_form_id',
141
+ 'value' => $atts['id'],
142
+ );
143
  }
144
  }
145
 
146
+ $nonce_append = isset( $_POST['pirate_forms_from_widget'] ) && intval( $_POST['pirate_forms_from_widget'] ) === 1 ? 'yes' : 'no';
 
 
 
 
 
147
 
148
+ $error_key = wp_create_nonce( get_bloginfo( 'admin_email' ) . ( $from_widget ? 'yes' : 'no' ) );
149
 
150
+ $thank_you_message = '';
151
+ if ( isset( $_GET['done'] ) ) {
152
+ $thank_you_message = sanitize_text_field( $pirate_forms_options['pirateformsopt_label_submit'] );
153
  }
154
 
155
+ $pirate_form->set_element( 'thank_you_message', $thank_you_message );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
 
157
  /**
158
+ ******** FormBuilder */
159
+ if ( 'yes' === PirateForms_Util::get_option( 'pirateformsopt_nonce' ) ) {
160
+ $elements[] = array(
161
+ 'type' => 'hidden',
162
+ 'id' => 'wordpress-nonce',
163
+ 'value' => wp_create_nonce( get_bloginfo( 'admin_email' ) . $nonce_append ),
164
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
165
  }
166
+ if ( ! empty( $pirate_forms_options ) ) :
167
+ $field = $pirate_forms_options['pirateformsopt_name_field'];
168
+ $label = $pirate_forms_options['pirateformsopt_label_name'];
169
 
170
+ /**
171
+ ****** Name field */
172
+ if ( ! empty( $field ) && ! empty( $label ) ) :
173
+ $required = $field === 'req' ? true : false;
174
+ $wrap_classes = array(
175
+ 'col-sm-6 col-lg-6 contact_name_wrap pirate_forms_three_inputs form_field_wrap',
176
+ );
177
+ // If this field was submitted with invalid data
178
+ if ( isset( $_SESSION[ $error_key ]['contact-name'] ) ) {
179
+ $wrap_classes[] = 'error';
180
+ }
181
+ $elements[] = array(
182
+ 'placeholder' => stripslashes( sanitize_text_field( $label ) ),
183
+ 'required' => $required,
184
+ 'required_msg' => $pirate_forms_options['pirateformsopt_label_err_name'],
185
+ 'type' => 'text',
186
+ 'id' => 'pirate-forms-contact-name',
187
+ 'class' => 'form-control',
188
+ 'wrap' => array(
189
+ 'type' => 'div',
190
+ 'class' => implode( ' ', apply_filters( 'pirateform_wrap_classes_name', $wrap_classes ) ),
191
+ ),
192
+ 'value' => empty( $thank_you_message ) && isset( $_REQUEST['pirate-forms-contact-name'] ) ? $_REQUEST['pirate-forms-contact-name'] : '',
193
+ );
194
+ endif;
195
 
196
+ $field = $pirate_forms_options['pirateformsopt_email_field'];
197
+ $label = $pirate_forms_options['pirateformsopt_label_email'];
198
 
199
+ /**
200
+ ****** Email field */
201
+ if ( ! empty( $field ) && ! empty( $label ) ) :
202
+ $required = $field === 'req' ? true : false;
203
+ $wrap_classes = array(
204
+ 'col-sm-6 col-lg-6 contact_email_wrap pirate_forms_three_inputs form_field_wrap',
205
+ );
206
+ // If this field was submitted with invalid data
207
+ if ( isset( $_SESSION[ $error_key ]['contact-email'] ) ) {
208
+ $wrap_classes[] = 'error';
209
+ }
210
+ $elements[] = array(
211
+ 'placeholder' => stripslashes( sanitize_text_field( $label ) ),
212
+ 'required' => $required,
213
+ 'required_msg' => $pirate_forms_options['pirateformsopt_label_err_email'],
214
+ 'type' => 'email',
215
+ 'id' => 'pirate-forms-contact-email',
216
+ 'class' => 'form-control',
217
+ 'wrap' => array(
218
+ 'type' => 'div',
219
+ 'class' => implode( ' ', apply_filters( 'pirateform_wrap_classes_email', $wrap_classes ) ),
220
+ ),
221
+ 'value' => empty( $thank_you_message ) && isset( $_REQUEST['pirate-forms-contact-email'] ) ? $_REQUEST['pirate-forms-contact-email'] : '',
222
+ );
223
  endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
224
 
225
+ $field = $pirate_forms_options['pirateformsopt_subject_field'];
226
+ $label = $pirate_forms_options['pirateformsopt_label_subject'];
 
227
 
228
+ /**
229
+ ****** Subject field */
230
+ if ( ! empty( $field ) && ! empty( $label ) ) :
231
+ $required = $field === 'req' ? true : false;
232
+ $wrap_classes = array(
233
+ 'contact_subject_wrap pirate_forms_three_inputs form_field_wrap',
234
+ );
235
+ // If this field was submitted with invalid data
236
+ if ( isset( $_SESSION[ $error_key ]['contact-subject'] ) ) {
237
+ $wrap_classes[] = 'error';
238
+ }
239
+ $elements[] = array(
240
+ 'placeholder' => stripslashes( sanitize_text_field( $label ) ),
241
+ 'required' => $required,
242
+ 'required_msg' => $pirate_forms_options['pirateformsopt_label_err_subject'],
243
+ 'type' => 'text',
244
+ 'id' => 'pirate-forms-contact-subject',
245
+ 'class' => 'form-control',
246
+ 'wrap' => array(
247
+ 'type' => 'div',
248
+ 'class' => implode( ' ', apply_filters( 'pirateform_wrap_classes_subject', $wrap_classes ) ),
249
+ ),
250
+ 'value' => empty( $thank_you_message ) && isset( $_REQUEST['pirate-forms-contact-subject'] ) ? $_REQUEST['pirate-forms-contact-subject'] : '',
251
+ );
252
+ endif;
253
 
254
+ $field = $pirate_forms_options['pirateformsopt_message_field'];
255
+ $label = $pirate_forms_options['pirateformsopt_label_message'];
 
 
256
 
257
+ /**
258
+ ****** Message field */
259
+ if ( ! empty( $field ) && ! empty( $label ) ) :
260
+ $required = $field === 'req' ? true : false;
261
+ $wrap_classes = array( 'col-sm-12 col-lg-12 form_field_wrap contact_message_wrap ' );
262
+ // If this field was submitted with invalid data
263
+ if ( isset( $_SESSION[ $error_key ]['contact-message'] ) ) {
264
+ $wrap_classes[] = 'error';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
265
  }
266
+ $elements[] = array(
267
+ 'placeholder' => stripslashes( sanitize_text_field( $label ) ),
268
+ 'required' => $required,
269
+ 'required_msg' => $pirate_forms_options['pirateformsopt_label_err_no_content'],
270
+ 'type' => 'textarea',
271
+ 'class' => 'form-control',
272
+ 'id' => 'pirate-forms-contact-message',
273
+ 'wrap' => array(
274
+ 'type' => 'div',
275
+ 'class' => implode( ' ', apply_filters( 'pirateform_wrap_classes_message', $wrap_classes ) ),
276
+ ),
277
+ 'value' => empty( $thank_you_message ) && isset( $_REQUEST['pirate-forms-contact-message'] ) ? $_REQUEST['pirate-forms-contact-message'] : '',
278
+ );
279
+ endif;
280
 
281
+ $field = $pirate_forms_options['pirateformsopt_attachment_field'];
 
282
 
283
+ /**
284
+ ****** Message field */
285
+ if ( ! empty( $field ) && 'no' !== $field ) :
286
+ $required = $field === 'req' ? true : false;
287
+ $wrap_classes = array( 'col-sm-12 col-lg-12 form_field_wrap contact_attachment_wrap' );
288
+ // If this field was submitted with invalid data
289
+ if ( isset( $_SESSION[ $error_key ]['contact-attachment'] ) ) {
290
+ $wrap_classes[] = 'error';
291
  }
292
+ $elements[] = array(
293
+ 'placeholder' => stripslashes( sanitize_text_field( $label ) ),
294
+ 'required' => $required,
295
+ 'required_msg' => $pirate_forms_options['pirateformsopt_label_err_no_attachment'],
296
+ 'type' => 'file',
297
+ 'class' => 'form-control',
298
+ 'id' => 'pirate-forms-attachment',
299
+ 'wrap' => array(
300
+ 'type' => 'div',
301
+ 'class' => implode( ' ', apply_filters( 'pirateform_wrap_classes_attachment', $wrap_classes ) ),
302
+ ),
303
+ );
304
+ endif;
305
  /**
306
+ ******* ReCaptcha */
307
+ if ( ! empty( $pirate_forms_options['pirateformsopt_recaptcha_secretkey'] ) && ! empty( $pirate_forms_options['pirateformsopt_recaptcha_sitekey'] ) && ! empty( $pirate_forms_options['pirateformsopt_recaptcha_field'] ) && ( $pirate_forms_options['pirateformsopt_recaptcha_field'] == 'yes' ) ) :
308
+ $pirateformsopt_recaptcha_sitekey = $pirate_forms_options['pirateformsopt_recaptcha_sitekey'];
309
+ $pirateformsopt_recaptcha_secretkey = $pirate_forms_options['pirateformsopt_recaptcha_secretkey'];
310
+ $elements[] = array(
311
+ 'placeholder' => stripslashes( sanitize_text_field( $label ) ),
312
+ 'type' => 'div',
313
+ 'class' => 'g-recaptcha pirate-forms-g-recaptcha',
314
+ 'custom' => array( 'data-sitekey' => $pirateformsopt_recaptcha_sitekey ),
315
+ 'id' => 'pirate-forms-captcha',
316
+ 'wrap' => array(
317
+ 'type' => 'div',
318
+ 'class' => implode( ' ', apply_filters( 'pirateform_wrap_classes_captcha', array( 'col-xs-12 col-sm-6 col-lg-6 form_field_wrap form_captcha_wrap' ) ) ),
319
+ ),
320
  );
321
+ endif;
 
 
 
 
322
 
323
+ /**
324
+ ****** Submit button */
325
+ $pirateformsopt_label_submit_btn = '';
326
+ if ( ! empty( $pirate_forms_options['pirateformsopt_label_submit_btn'] ) ) {
327
+ $pirateformsopt_label_submit_btn = $pirate_forms_options['pirateformsopt_label_submit_btn'];
 
 
 
 
 
 
328
  }
329
+ if ( empty( $pirateformsopt_label_submit_btn ) ) {
330
+ $pirateformsopt_label_submit_btn = __( 'Submit', 'pirate-forms' );
331
+ }
332
+ $elements[] = array(
333
+ 'type' => 'button',
334
+ 'id' => 'pirate-forms-contact-submit',
335
+ 'class' => 'pirate-forms-submit-button btn btn-primary',
336
+ 'wrap' => array(
337
+ 'type' => 'div',
338
+ 'class' => implode( ' ', apply_filters( 'pirateform_wrap_classes_submit', array( 'col-xs-12 col-sm-6 col-lg-6 form_field_wrap contact_submit_wrap' ) ) ),
339
+ ),
340
+ 'value' => $pirateformsopt_label_submit_btn,
341
+ );
342
+ endif;
343
+
344
+ /* Referring site or page, if any */
345
+ if ( ! empty( $_SERVER['HTTP_REFERER'] ) ) {
346
+ $elements[] = array(
347
+ 'type' => 'hidden',
348
+ 'id' => 'contact-referrer',
349
+ 'value' => $_SERVER['HTTP_REFERER'],
350
+ );
351
+ }
352
+
353
+ /* Referring page, if sent via URL query */
354
+ if ( ! empty( $_REQUEST['src'] ) || ! empty( $_REQUEST['ref'] ) ) {
355
+ $elements[] = array(
356
+ 'type' => 'hidden',
357
+ 'id' => 'referring-page',
358
+ 'value' => ! empty( $_REQUEST['src'] ) ? $_REQUEST['src'] : $_REQUEST['ref'],
359
+ );
360
+ }
361
+
362
+ /* Are there any submission errors? */
363
+ $errors = '';
364
+ if ( ! empty( $_SESSION[ $error_key ] ) ) {
365
+ $pirate_form->set_element( 'errors', $_SESSION[ $error_key ] );
366
+ unset( $_SESSION[ $error_key ] );
367
+ }
368
+
369
+ $elements = apply_filters( 'pirate_forms_get_custom_elements', $elements, $pirate_forms_options );
370
+
371
+ do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'displaying elements %s', print_r( $elements, true ) ), 'debug', __FILE__, __LINE__ );
372
+
373
+ return $pirate_form->build_form( apply_filters( 'pirate_forms_public_controls', $elements, $pirate_forms_options, $from_widget ), $pirate_forms_options, $from_widget );
374
  }
375
 
376
  /**
377
+ * Renders all the fields relevant to the form
378
  *
379
+ * @param PirateForms_PhpFormBuilder $form_builder The form builder object.
 
380
  */
381
+ public function render_fields( $form_builder ) {
382
+ echo '<div class="pirate_forms_three_inputs_wrap">';
 
 
 
 
 
 
 
 
383
 
384
+ if ( isset( $form_builder->contact_name ) ) {
385
+ echo $form_builder->contact_name;
386
+ }
 
 
 
 
 
 
 
 
387
 
388
+ if ( isset( $form_builder->contact_email ) ) {
389
+ echo $form_builder->contact_email;
390
+ }
391
 
392
+ if ( isset( $form_builder->contact_subject ) ) {
393
+ echo $form_builder->contact_subject;
394
+ }
395
+
396
+ if ( isset( $form_builder->custom_fields ) ) {
397
+ echo $form_builder->custom_fields;
398
+ }
399
+
400
+ echo '</div>';
401
+
402
+ if ( isset( $form_builder->contact_message ) ) {
403
+ echo $form_builder->contact_message;
404
+ }
405
+
406
+ if ( isset( $form_builder->attachment ) ) {
407
+ echo $form_builder->attachment;
408
+ }
409
+
410
+ if ( isset( $form_builder->captcha ) ) {
411
+ echo $form_builder->captcha;
412
+ }
413
+
414
+ echo $form_builder->contact_submit;
415
  }
416
 
417
  /**
418
+ * Renders all the errors relevant to the form
419
  *
420
+ * @param PirateForms_PhpFormBuilder $form_builder The form builder object.
421
  */
422
+ public function render_errors( $form_builder ) {
423
+ $output = '';
424
+ if ( ! empty( $form_builder->errors ) ) :
425
+ $output .= '<div class="col-sm-12 col-lg-12 pirate_forms_error_box">';
426
+ $output .= '<p>' . __( 'Sorry, an error occured.', 'pirate-forms' ) . '</p>';
427
+ $output .= '</div>';
428
+ foreach ( $form_builder->errors as $err ) :
429
+ $output .= '<div class="col-sm-12 col-lg-12 pirate_forms_error_box">';
430
+ $output .= "<p>$err</p>";
431
+ $output .= '</div>';
432
+ endforeach;
433
+
434
+ endif;
435
+
436
+ echo $output;
437
  }
438
 
439
  /**
440
+ * Renders the thank you message relevant to the form
441
  *
442
+ * @param PirateForms_PhpFormBuilder $form_builder The form builder object.
443
+ */
444
+ public function render_thankyou( $form_builder ) {
445
+ if ( ! empty( $form_builder->thank_you_message ) ) {
446
+ echo '<div class="col-sm-12 col-lg-12 pirate_forms_thankyou_wrap"><p>' . $form_builder->thank_you_message . '</p></div>';
447
+ }
448
+ }
449
+
450
+ /**
451
+ * Process the form after submission
452
  *
453
+ * @since 1.0.0
454
  * @throws Exception When file uploading fails.
455
  */
456
+ public function template_redirect() {
457
+ do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'POST data = %s', print_r( $_POST, true ) ), 'debug', __FILE__, __LINE__ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
458
 
459
+ // If POST and honeypot are not set, beat it
460
+ if ( empty( $_POST ) || ! isset( $_POST['honeypot'] ) ) {
461
+ return false;
462
+ }
 
 
 
463
 
464
+ // separate the nonce from a form that is displayed in the widget vs. one that is not
465
+ $nonce_append = isset( $_POST['pirate_forms_from_widget'] ) && intval( $_POST['pirate_forms_from_widget'] ) === 1 ? 'yes' : 'no';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
466
 
467
+ // Session variable for form errors
468
+ $error_key = wp_create_nonce( get_bloginfo( 'admin_email' ) . $nonce_append );
469
+ $_SESSION[ $error_key ] = array();
 
 
 
 
 
 
 
 
 
 
 
 
470
 
471
+ // If nonce is not valid, beat it
472
+ if ( 'yes' === PirateForms_Util::get_option( 'pirateformsopt_nonce' ) ) {
473
+ if ( ! wp_verify_nonce( $_POST['wordpress-nonce'], get_bloginfo( 'admin_email' ) . $nonce_append ) ) {
474
+ $_SESSION[ $error_key ]['nonce'] = __( 'Nonce failed!', 'pirate-forms' );
475
+ do_action( 'themeisle_log_event', PIRATEFORMS_NAME, 'Nonce failed', 'error', __FILE__, __LINE__ );
476
+
477
+ return false;
478
  }
 
 
479
  }
 
480
 
481
+ // If the honeypot caught a bear, beat it
482
+ if ( ! empty( $_POST['honeypot'] ) ) {
483
+ $_SESSION[ $error_key ]['honeypot'] = __( 'Form submission failed!', 'pirate-forms' );
 
 
 
 
 
484
 
485
+ return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
486
  }
487
 
488
+ $pirate_forms_options = PirateForms_Util::get_form_options( isset( $_POST['pirate_forms_form_id'] ) ? $_POST['pirate_forms_form_id'] : null );
 
489
 
490
+ if ( ! $this->validate_captcha( $error_key, $pirate_forms_options ) ) {
491
+ return false;
 
 
 
 
 
 
 
 
 
 
 
492
  }
493
 
494
+ // Start the body of the contact email
495
+ $body = '<h2>' . __( 'Contact form submission from', 'pirate-forms' ) . ' ' .
496
+ get_bloginfo( 'name' ) . ' (' . site_url() . ') </h2>';
497
 
498
+ $body .= '<table>';
 
 
 
 
 
 
 
 
 
 
499
 
500
+ list($pirate_forms_contact_email, $pirate_forms_contact_name, $pirate_forms_contact_subject) = $this->validate_request( $error_key, $pirate_forms_options, $body );
 
501
 
502
+ /**
503
+ ******** Validate recipients email */
504
+ $site_recipients = sanitize_text_field( $pirate_forms_options['pirateformsopt_email_recipients'] );
505
+ if ( empty( $site_recipients ) ) {
506
+ $_SESSION[ $error_key ]['pirate-forms-recipients-email'] = __( 'Please enter one or more Contact submission recipients', 'pirate-forms' );
 
 
 
 
 
507
  }
508
+ /**
509
+ ****** Sanitize and validate IP */
510
+ $contact_ip = filter_var( $_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP );
511
+ /* for the case of a Web server behind a reverse proxy */
512
+ if ( array_key_exists( 'HTTP_X_FORWARDED_FOR', $_SERVER ) ) {
513
+ $contact_ip_tmp = explode( ',', $_SERVER['HTTP_X_FORWARDED_FOR'] );
514
+ if ( ! empty( $contact_ip_tmp ) ) {
515
+ $contact_ip = array_pop( $contact_ip_tmp );
516
  }
517
  }
 
 
 
 
 
518
 
519
+ // If valid and present, create a link to an IP search
520
+ if ( ! empty( $contact_ip ) ) {
521
+ $body .= PirateForms_Util::table_row( __( 'IP address: ', 'pirate-forms' ), $contact_ip );
522
+ $body .= PirateForms_Util::table_row( __( 'IP search:', 'pirate-forms' ), "http://whatismyipaddress.com/ip/$contact_ip" );
523
+ }
524
 
525
+ // Sanitize and prepare referrer;
526
+ if ( ! empty( $_POST['pirate-forms-contact-referrer'] ) ) {
527
+ $body .= PirateForms_Util::table_row( __( 'Came from: ', 'pirate-forms' ), sanitize_text_field( $_POST['pirate-forms-contact-referrer'] ) );
 
 
 
 
 
528
  }
 
529
 
530
+ // Show the page this contact form was submitted on
531
+ $body .= PirateForms_Util::table_row( __( 'Sent from page: ', 'pirate-forms' ), get_permalink( get_the_id() ) );
532
 
533
+ // Check the blacklist
534
+ $blocked = PirateForms_Util::is_blacklisted( $error_key, $pirate_forms_contact_email, $contact_ip );
535
+ if ( $blocked ) {
536
+ return false;
537
+ }
 
 
 
 
 
 
 
538
 
539
+ $body .= '</table>';
 
540
 
541
+ // No errors? Go ahead and process the contact
542
+ if ( empty( $_SESSION[ $error_key ] ) ) {
543
+ $site_email = sanitize_text_field( $pirate_forms_options['pirateformsopt_email'] );
544
+ if ( ! empty( $pirate_forms_contact_name ) ) :
545
+ $site_name = $pirate_forms_contact_name;
546
+ else :
547
+ $site_name = htmlspecialchars_decode( get_bloginfo( 'name' ) );
548
+ endif;
549
+ // Notification recipients
550
+ $site_recipients = sanitize_text_field( $pirate_forms_options['pirateformsopt_email_recipients'] );
551
+ $site_recipients = explode( ',', $site_recipients );
552
+ $site_recipients = array_map( 'trim', $site_recipients );
553
+ $site_recipients = array_map( 'sanitize_email', $site_recipients );
554
+ $site_recipients = implode( ',', $site_recipients );
555
+ // No name? Use the submitter email address, if one is present
556
+ if ( empty( $pirate_forms_contact_name ) ) {
557
+ $pirate_forms_contact_name = ! empty( $pirate_forms_contact_email ) ? $pirate_forms_contact_email : '[None given]';
558
+ }
559
 
560
+ // Need an email address for the email notification
561
+ $send_from = '';
562
+ if ( '[email]' == $site_email && ! empty( $pirate_forms_contact_email ) ) {
563
+ $send_from = $pirate_forms_contact_email;
564
+ } elseif ( ! empty( $site_email ) ) {
565
+ $send_from = $site_email;
566
+ } else {
567
+ $send_from = PirateForms_Util::get_from_email();
568
+ }
569
+ $send_from_name = $site_name;
570
 
571
+ // Send an email notification to the correct address
572
+ $headers = "From: $send_from_name <$send_from>\r\nReply-To: $pirate_forms_contact_name <$pirate_forms_contact_email>\r\nContent-type: text/html";
573
+ add_action( 'phpmailer_init', array( $this, 'phpmailer' ) );
574
 
575
+ $attachments = $this->get_attachments( $error_key, $pirate_forms_options );
576
+ if ( is_bool( $attachments ) ) {
577
+ return false;
 
 
 
 
 
 
578
  }
 
579
 
580
+ $subject = 'Contact on ' . htmlspecialchars_decode( get_bloginfo( 'name' ) );
581
+ if ( ! empty( $pirate_forms_contact_subject ) ) {
582
+ $subject = $pirate_forms_contact_subject;
583
+ }
584
 
585
+ do_action( 'pirate_forms_before_sending', $pirate_forms_contact_email, $site_recipients, $subject, $body, $headers, $attachments );
586
+ do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'before sending email to = %s, subject = %s, body = %s, headers = %s, attachments = %s', $site_recipients, $subject, $body, $headers, print_r( $attachments, true ) ), 'debug', __FILE__, __LINE__ );
587
+ $response = wp_mail( $site_recipients, $subject, $body, $headers, $attachments );
588
+ if ( ! $response ) {
589
+ error_log( 'Email not sent' );
590
+ }
591
+ do_action( 'pirate_forms_after_sending', $pirate_forms_options, $response, $pirate_forms_contact_email, $site_recipients, $subject, $body, $headers, $attachments );
592
+ do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'after sending email, response = %s', $response ), 'debug', __FILE__, __LINE__ );
593
 
594
+ // delete the tmp directory
595
+ require_once( ABSPATH . 'wp-admin/includes/file.php' );
596
+ WP_Filesystem();
597
+ global $wp_filesystem;
598
+ $wp_filesystem->delete( $this->get_upload_tmp_dir(), true, 'd' );
599
 
600
+ // Should a confirm email be sent?
601
+ $confirm_body = stripslashes( trim( $pirate_forms_options['pirateformsopt_confirm_email'] ) );
602
+ if ( ! empty( $confirm_body ) && ! empty( $pirate_forms_contact_email ) ) {
603
+ // Removing entities
604
+ $confirm_body = htmlspecialchars_decode( $confirm_body );
605
+ $confirm_body = html_entity_decode( $confirm_body );
606
+ $confirm_body = str_replace( '&#39;', "'", $confirm_body );
607
+ $send_from = PirateForms_Util::get_from_email();
608
+ if ( ! empty( $site_email ) && '[email]' !== $site_email ) {
609
+ $send_from = $site_email;
610
+ }
611
+ $site_name = htmlspecialchars_decode( get_bloginfo( 'name' ) );
612
 
613
+ $headers = "From: $site_name <$send_from>\r\nReply-To: $site_name <$send_from>";
614
+ $subject = $pirate_forms_options['pirateformsopt_label_submit'] . ' - ' . $site_name;
 
 
 
 
 
 
 
 
 
 
615
 
616
+ do_action( 'pirate_forms_before_sending_confirm', $pirate_forms_contact_email, $pirate_forms_contact_email, $subject, $confirm_body, $headers );
617
+ do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'before sending confirm email to = %s, subject = %s, body = %s, headers = %s', $pirate_forms_contact_email, $subject, $confirm_body, $headers ), 'debug', __FILE__, __LINE__ );
618
+ $response = wp_mail( $pirate_forms_contact_email, $subject, $confirm_body, $headers );
619
+ do_action( 'pirate_forms_after_sending_confirm', $pirate_forms_options, $response, $pirate_forms_contact_email, $pirate_forms_contact_email, $subject, $confirm_body, $headers );
620
+ do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'after sending confirm email response = %s', $response ), 'debug', __FILE__, __LINE__ );
621
+ if ( ! $response ) {
622
+ error_log( 'Confirm email not sent' );
 
 
 
623
  }
624
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
625
 
626
  /**
627
+ *********** Store the entries in the DB */
628
+ if ( 'yes' === $pirate_forms_options['pirateformsopt_store'] ) {
629
+ $new_post_id = wp_insert_post(
630
+ array(
631
+ 'post_type' => 'pf_contact',
632
+ 'post_title' => date( 'l, M j, Y', time() ) . ' by "' . $pirate_forms_contact_name . '"',
633
+ 'post_content' => $body,
634
+ 'post_author' => 1,
635
+ 'post_status' => 'private',
636
+ )
637
  );
638
+ if ( isset( $pirate_forms_contact_email ) && ! empty( $pirate_forms_contact_email ) ) {
639
+ add_post_meta( $new_post_id, 'Contact email', $pirate_forms_contact_email );
 
640
  }
641
+ do_action( 'pirate_forms_update_contact', $pirate_forms_options, $new_post_id );
642
+ }
 
 
 
 
 
 
 
 
 
 
 
 
643
 
644
+ $pirate_forms_current_theme = wp_get_theme();
 
645
 
646
+ /* If a Thank you page is selected, redirect to that page */
647
+ if ( $pirate_forms_options['pirateformsopt_thank_you_url'] ) {
648
+ $redirect_id = intval( $pirate_forms_options['pirateformsopt_thank_you_url'] );
649
+ $redirect = get_permalink( $redirect_id );
650
+ if ( ! empty( $redirect ) ) {
651
+ wp_safe_redirect( $redirect );
 
 
 
 
652
  }
653
+ } elseif ( ( 'Zerif Lite' == $pirate_forms_current_theme->name ) || ( 'Zerif Lite' == $pirate_forms_current_theme->parent_theme ) || ( 'Zerif PRO' == $pirate_forms_current_theme->name ) || ( 'Zerif PRO' == $pirate_forms_current_theme->parent_theme ) ) {
654
+ // the fragment identifier should always be the last argument, otherwise the thank you message will not show.
655
+ $redirect = add_query_arg( array( 'done' => 'done', 'pcf' => '1#contact' ), $_SERVER['HTTP_REFERER'] );
656
+ wp_safe_redirect( $redirect );
657
+ } elseif ( isset( $_SERVER['HTTP_REFERER'] ) ) {
658
+ $redirect = add_query_arg( array( 'done' => 'done' ), $_SERVER['HTTP_REFERER'] );
659
+ wp_safe_redirect( $redirect );
660
+ }
661
+ }
662
+ }
 
 
 
 
 
 
 
663
 
664
+ /**
665
+ * Validate request
666
+ *
667
+ * @param string $error_key the key for the session object.
668
+ * @param array $pirate_forms_options the array of options for this form.
669
+ * @param string $body the body to save as the CPT.
670
+ */
671
+ function validate_request( $error_key, $pirate_forms_options, &$body ) {
672
+ $pirate_forms_contact_email = null;
673
+ $pirate_forms_contact_name = null;
674
+ $pirate_forms_contact_subject = null;
675
+ $fields = array( 'name', 'email', 'subject', 'message' );
676
+ foreach ( $fields as $field ) {
677
+ $value = isset( $_POST[ 'pirate-forms-contact-' . $field ] ) ? sanitize_text_field( trim( $_POST[ 'pirate-forms-contact-' . $field ] ) ) : '';
678
+ if ( 'req' === $pirate_forms_options[ 'pirateformsopt_' . $field . '_field' ] && empty( $value ) ) {
679
+ $_SESSION[ $error_key ][ 'pirate-forms-contact-' . $field ] = $pirate_forms_options[ 'pirateformsopt_label_err_' . $field ];
680
+ } elseif ( ! empty( $value ) ) {
681
+ if ( 'email' === $field && ! filter_var( $value, FILTER_VALIDATE_EMAIL ) ) {
682
+ $_SESSION[ $error_key ][ 'pirate-forms-contact-' . $field ] = $pirate_forms_options[ 'pirateformsopt_label_err_' . $field ];
683
+ } else {
684
+ if ( 'email' === $field ) {
685
+ $pirate_forms_contact_email = $value;
686
+ } elseif ( 'name' === $field ) {
687
+ $pirate_forms_contact_name = $value;
688
+ } elseif ( 'subject' === $field ) {
689
+ $pirate_forms_contact_subject = $value;
690
+ }
691
+ $body .= PirateForms_Util::table_row( stripslashes( $pirate_forms_options[ 'pirateformsopt_label_' . $field ] ), $value );
692
  }
693
+ }
694
+ }
 
 
 
 
 
 
 
 
 
 
 
 
695
 
696
+ $body = apply_filters( 'pirate_forms_validate_request', $body, $error_key, $pirate_forms_options );
697
 
698
+ return array( $pirate_forms_contact_email, $pirate_forms_contact_name, $pirate_forms_contact_subject );
699
+ }
700
+
701
+ /**
702
+ * Validate CAPTCHA
703
+ *
704
+ * @param string $error_key the key for the session object.
705
+ * @param array $pirate_forms_options the array of options for this form.
706
+ */
707
+ function validate_captcha( $error_key, $pirate_forms_options ) {
708
+ $pirateformsopt_recaptcha_sitekey = $pirate_forms_options['pirateformsopt_recaptcha_sitekey'];
709
+ $pirateformsopt_recaptcha_secretkey = $pirate_forms_options['pirateformsopt_recaptcha_secretkey'];
710
+ $pirateformsopt_recaptcha_field = $pirate_forms_options['pirateformsopt_recaptcha_field'];
711
+ if ( ! empty( $pirateformsopt_recaptcha_secretkey ) && ! empty( $pirateformsopt_recaptcha_sitekey ) && ! empty( $pirateformsopt_recaptcha_field ) && ( $pirateformsopt_recaptcha_field == 'yes' ) ) :
712
+ if ( isset( $_POST['g-recaptcha-response'] ) ) {
713
+ $captcha = $_POST['g-recaptcha-response'];
714
+ }
715
+ if ( ! $captcha ) {
716
+ $_SESSION[ $error_key ]['pirate-forms-captcha'] = __( 'Wrong reCAPTCHA', 'pirate-forms' );
717
+
718
+ return false;
719
+ }
720
+ $response = wp_remote_get( 'https://www.google.com/recaptcha/api/siteverify?secret=' . $pirateformsopt_recaptcha_secretkey . '&response=' . $captcha . '&remoteip=' . $_SERVER['REMOTE_ADDR'] );
721
+ if ( ! empty( $response ) ) :
722
+ $response_body = wp_remote_retrieve_body( $response );
723
  endif;
724
+ if ( ! empty( $response_body ) ) :
725
+ $result = json_decode( $response_body, true );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
726
  endif;
727
+ if ( isset( $result['success'] ) && ( $result['success'] == false ) ) {
728
+ $_SESSION[ $error_key ]['pirate-forms-captcha'] = __( 'Wrong reCAPTCHA', 'pirate-forms' );
729
 
730
+ return false;
 
 
 
 
 
 
 
731
  }
 
 
 
 
 
 
 
 
 
 
732
  endif;
733
 
734
+ return true;
735
+ }
736
+
737
+ /**
738
+ * Get attachments, if any
739
+ *
740
+ * @param string $error_key the key for the session object.
741
+ * @param array $pirate_forms_options the array of options for the form.
742
+ *
743
+ * @throws Exception When file uploading fails.
744
+ */
745
+ function get_attachments( $error_key, $pirate_forms_options ) {
746
+ $attachments = '';
747
+ /**
748
+ ******* Validate Attachment */
749
+ $use_files = $pirate_forms_options['pirateformsopt_attachment_field'];
750
+ if ( ! empty( $use_files ) && ( $use_files == 'yes' ) ) {
751
+ $pirate_forms_attach_file = isset( $_FILES['pirate-forms-attachment'] ) ? $_FILES['pirate-forms-attachment'] : '';
752
+ if ( ! empty( $pirate_forms_attach_file ) && ! empty( $pirate_forms_attach_file['name'] ) ) {
753
+ /* Validate file type */
754
+ $file_types_allowed = 'jpg|jpeg|png|gif|pdf|doc|docx|ppt|pptx|odt|avi|ogg|m4a|mov|mp3|mp4|mpg|wav|wmv';
755
+ $pirate_forms_file_types_allowed = $file_types_allowed;
756
+ $pirate_forms_file_types_allowed = trim( $pirate_forms_file_types_allowed, '|' );
757
+ $pirate_forms_file_types_allowed = '(' . $pirate_forms_file_types_allowed . ')';
758
+ $pirate_forms_file_types_allowed = '/\.' . $pirate_forms_file_types_allowed . '$/i';
759
+ if ( ! preg_match( $pirate_forms_file_types_allowed, $pirate_forms_attach_file['name'] ) ) {
760
+ do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'file invalid: expected %s got %s', $file_types_allowed, $pirate_forms_attach_file['name'] ), 'error', __FILE__, __LINE__ );
761
+ $_SESSION[ $error_key ]['pirate-forms-upload-failed-type'] = __( 'Uploaded file is not allowed for file type', 'pirate-forms' );
762
+
763
+ return false;
764
+ }
765
+ /* Validate file size */
766
+ $pirate_forms_file_size_allowed = 1048576; // default size 1 MB
767
+ if ( $pirate_forms_attach_file['size'] > $pirate_forms_file_size_allowed ) {
768
+ do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'file too large: expected %d got %d', $pirate_forms_file_size_allowed, $pirate_forms_attach_file['size'] ), 'error', __FILE__, __LINE__ );
769
+ $_SESSION[ $error_key ]['pirate-forms-upload-failed-size'] = __( 'Uploaded file is too large', 'pirate-forms' );
770
+
771
+ return false;
772
+ }
773
+ $this->init_uploads();
774
+ $uploads_dir = $this->get_upload_tmp_dir();
775
+ $uploads_dir = $this->maybe_add_random_dir( $uploads_dir );
776
+ $filename = $pirate_forms_attach_file['name'];
777
+ $filename = $this->canonicalize( $filename );
778
+ $filename = sanitize_file_name( $filename );
779
+ $filename = $this->antiscript_file_name( $filename );
780
+ $filename = wp_unique_filename( $uploads_dir, $filename );
781
+ $new_file = trailingslashit( $uploads_dir ) . $filename;
782
+ try {
783
+ if ( false === move_uploaded_file( $pirate_forms_attach_file['tmp_name'], $new_file ) ) {
784
+ do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'unable to move the uploaded file from %s to %s', $pirate_forms_attach_file['tmp_name'], $new_file ), 'error', __FILE__, __LINE__ );
785
+ throw new Exception( __( 'There was an unknown error uploading the file.', 'pirate-forms' ) );
786
+ }
787
+ } catch ( Exception $ex ) {
788
+ do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'unable to move the uploaded file from %s to %s with error %s', $pirate_forms_attach_file['tmp_name'], $new_file, $ex->getMessage() ), 'error', __FILE__, __LINE__ );
789
+ $_SESSION[ $error_key ]['pirate-forms-upload-failed-general'] = $ex->getMessage();
790
+ }
791
+ if ( ! empty( $new_file ) ) {
792
+ $attachments = $new_file;
793
+ }
794
+ }// End if().
795
+ }// End if().
796
+ return $attachments;
797
+ }
798
+
799
+ /**
800
+ * Prepare the uploading process
801
+ *
802
+ * @since 1.0.0
803
+ * @throws Exception When file could not be opened.
804
+ */
805
+ function init_uploads() {
806
+ $dir = $this->get_upload_tmp_dir();
807
+ wp_mkdir_p( $dir );
808
+ $htaccess_file = trailingslashit( $dir ) . '.htaccess';
809
+ if ( file_exists( $htaccess_file ) ) {
810
+ return;
811
  }
812
+ try {
813
+ $handle = fopen( $htaccess_file, 'w' );
814
 
815
+ if ( ! $handle ) {
816
+ throw new Exception( 'File open failed.' );
817
+ } else {
818
+ fwrite( $handle, "Deny from all\n" );
819
+ fclose( $handle );
820
+ }
821
+ } catch ( Exception $e ) {
822
+ // nothing
823
  }
824
+ }
825
 
826
+ /**
827
+ * Return the temporary upload dir
828
+ *
829
+ * @since 1.0.0
830
+ */
831
+ function get_upload_tmp_dir() {
832
+ return $this->get_upload_dir( 'dir' ) . '/pirate_forms_uploads';
833
+ }
834
+
835
+ /**
836
+ * Return the upload dir
837
+ *
838
+ * @since 1.0.0
839
+ */
840
+ function get_upload_dir( $type = false ) {
841
+ $uploads = wp_upload_dir();
842
+ $uploads = apply_filters(
843
+ 'pirate_forms_upload_dir', array(
844
+ 'dir' => $uploads['basedir'],
845
+ 'url' => $uploads['baseurl'],
846
+ )
847
+ );
848
+ if ( 'dir' == $type ) {
849
+ return $uploads['dir'];
850
+ }
851
+ if ( 'url' == $type ) {
852
+ return $uploads['url'];
853
  }
854
 
855
+ return $uploads;
856
+ }
857
 
858
+ /**
859
+ * Add a random directory for uploading
860
+ *
861
+ * @since 1.0.0
862
+ */
863
+ function maybe_add_random_dir( $dir ) {
864
+ do {
865
+ $rand_max = mt_getrandmax();
866
+ $rand = zeroise( mt_rand( 0, $rand_max ), strlen( $rand_max ) );
867
+ $dir_new = path_join( $dir, $rand );
868
+ } while ( file_exists( $dir_new ) );
869
+ if ( wp_mkdir_p( $dir_new ) ) {
870
+ return $dir_new;
871
+ }
872
+
873
+ return $dir;
874
+ }
875
+
876
+ /**
877
+ * Functions to Process uploaded files
878
+ */
879
+ function canonicalize( $text ) {
880
+ if ( function_exists( 'mb_convert_kana' )
881
+ && 'UTF-8' == get_option( 'blog_charset' )
882
+ ) {
883
+ $text = mb_convert_kana( $text, 'asKV', 'UTF-8' );
884
+ }
885
+ $text = strtolower( $text );
886
+ $text = trim( $text );
887
+
888
+ return $text;
889
+ }
890
+
891
+ /**
892
+ * Prevent uploading any script files
893
+ *
894
+ * @since 1.0.0
895
+ */
896
+ function antiscript_file_name( $filename ) {
897
+ $filename = basename( $filename );
898
+ $parts = explode( '.', $filename );
899
+ if ( count( $parts ) < 2 ) {
900
+ return $filename;
901
+ }
902
+ $script_pattern = '/^(php|phtml|pl|py|rb|cgi|asp|aspx)\d?$/i';
903
+ $filename = array_shift( $parts );
904
+ $extension = array_pop( $parts );
905
+ foreach ( (array) $parts as $part ) {
906
+ if ( preg_match( $script_pattern, $part ) ) {
907
+ $filename .= '.' . $part . '_';
908
+ } else {
909
+ $filename .= '.' . $part;
910
+ }
911
+ }
912
+ if ( preg_match( $script_pattern, $extension ) ) {
913
+ $filename .= '.' . $extension . '_.txt';
914
+ } else {
915
+ $filename .= '.' . $extension;
916
+ }
917
+
918
+ return $filename;
919
+ }
920
+
921
+ /**
922
+ * Change the content of the widget
923
+ *
924
+ * @since 1.0.0
925
+ */
926
+ public function widget_text_filter( $content ) {
927
+ if ( ! preg_match( '[pirate_forms]', $content ) ) {
928
+ return $content;
929
+ }
930
+ $content = do_shortcode( $content );
931
+
932
+ return $content;
933
  }
934
 
935
  /**
public/css/front.css CHANGED
@@ -1,5 +1,5 @@
1
  /*
2
- Version: 2.0.4
3
  */
4
  .pirate_forms_wrap .form_field_wrap {
5
  margin-bottom: 20px;
1
  /*
2
+ Version: 2.0.5
3
  */
4
  .pirate_forms_wrap .form_field_wrap {
5
  margin-bottom: 20px;
public/js/scripts-general.js CHANGED
@@ -11,9 +11,5 @@ jQuery(document).ready(function() {
11
  }, 'slow');
12
  }
13
 
14
- if( typeof jQuery('.pirate_forms_three_inputs').val() !== 'undefined' ) {
15
- jQuery('.pirate_forms ').each(function(){
16
- jQuery(this).find('.pirate_forms_three_inputs').wrapAll('<div class="pirate_forms_three_inputs_wrap">');
17
- });
18
- }
19
  });
11
  }, 'slow');
12
  }
13
 
14
+
 
 
 
 
15
  });
public/partials/pirateforms-form.php CHANGED
@@ -13,62 +13,17 @@
13
  */
14
  ?>
15
 
16
- <?php
17
- if ( ! empty( $this->thank_you_message ) ) :
18
- ?>
19
- <div class="col-sm-12 col-lg-12 pirate_forms_thankyou_wrap">
20
- <p><?php echo $this->thank_you_message; ?></p>
21
- </div>
22
- <?php endif; ?>
23
 
24
  <div class="pirate_forms_wrap">
25
- <?php
26
- $output = '';
27
- if ( ! empty( $this->errors ) ) :
28
- $output .= '<div class="col-sm-12 col-lg-12 pirate_forms_error_box">';
29
- $output .= '<p>' . __( 'Sorry, an error occured.', 'pirate-forms' ) . '</p>';
30
- $output .= '</div>';
31
- foreach ( $this->errors as $err ) :
32
- $output .= '<div class="col-sm-12 col-lg-12 pirate_forms_error_box">';
33
- $output .= "<p>$err</p>";
34
- $output .= '</div>';
35
- endforeach;
36
-
37
- endif;
38
-
39
- echo $output;
40
- ?>
41
 
42
  <?php echo $this->form_start; ?>
43
 
44
- <div class="pirate_forms_three_inputs_wrap">
45
- <?php if ( isset( $this->contact_name ) ) { ?>
46
- <?php echo $this->contact_name; ?>
47
- <?php } ?>
48
-
49
- <?php if ( isset( $this->contact_email ) ) { ?>
50
- <?php echo $this->contact_email; ?>
51
- <?php } ?>
52
-
53
- <?php if ( isset( $this->contact_subject ) ) { ?>
54
- <?php echo $this->contact_subject; ?>
55
- <?php } ?>
56
- </div>
57
-
58
- <?php if ( isset( $this->contact_message ) ) { ?>
59
- <?php echo $this->contact_message; ?>
60
- <?php } ?>
61
-
62
- <?php if ( isset( $this->attachment ) ) { ?>
63
- <?php echo $this->attachment; ?>
64
- <?php } ?>
65
-
66
- <?php if ( isset( $this->captcha ) ) { ?>
67
- <?php echo $this->captcha; ?>
68
- <?php } ?>
69
-
70
- <?php echo $this->contact_submit; ?>
71
 
72
  <?php echo $this->form_end; ?>
73
  <div class="pirate_forms_clearfix"></div>
74
  </div>
 
 
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 ); ?>
readme.txt CHANGED
@@ -18,6 +18,7 @@ This is an easy-to-use WordPress contact form with captcha plugin. To create a c
18
  >
19
  > * Create multiple forms
20
  > * Mailchimp Integration
 
21
  > * Developer friendly
22
  > * 12 months Support & Updates
23
  > * 30 days Money Back Guaranteed
@@ -60,6 +61,9 @@ This is not a form maker or drag & drop builder plugin nor "the best contact for
60
  * [Use multiple forms on same page](https://demo.themeisle.com/pirate-forms/multiple-forms-page/)
61
  * [Minimalistic form](https://demo.themeisle.com/pirate-forms/minimalistic-form/)
62
  * [Form with attachment](https://demo.themeisle.com/pirate-forms/form-with-attachment/)
 
 
 
63
 
64
 
65
 
@@ -130,6 +134,12 @@ Activating the Pirate Contact Form plugin is just like any other plugin. If you'
130
  4. Screenshot 4. Enabling SMTP
131
 
132
  == Changelog ==
 
 
 
 
 
 
133
  = 2.0.4 - 2017-08-14 =
134
 
135
  * All fields are now optional.
18
  >
19
  > * Create multiple forms
20
  > * Mailchimp Integration
21
+ > * Custom fields
22
  > * Developer friendly
23
  > * 12 months Support & Updates
24
  > * 30 days Money Back Guaranteed
61
  * [Use multiple forms on same page](https://demo.themeisle.com/pirate-forms/multiple-forms-page/)
62
  * [Minimalistic form](https://demo.themeisle.com/pirate-forms/minimalistic-form/)
63
  * [Form with attachment](https://demo.themeisle.com/pirate-forms/form-with-attachment/)
64
+ * [Subscription form](https://demo.themeisle.com/pirate-forms/subscription-form/)
65
+ * [Complex support form](https://demo.themeisle.com/pirate-forms/support-form/)
66
+ * [Telephone field form](https://demo.themeisle.com/pirate-forms/phone-number-form/)
67
 
68
 
69
 
134
  4. Screenshot 4. Enabling SMTP
135
 
136
  == Changelog ==
137
+ = 2.0.5 - 2017-08-16 =
138
+
139
+ * Fixed compatibility with the pro version for multiple fields.
140
+ * Fixed default consistency between forms.
141
+
142
+
143
  = 2.0.4 - 2017-08-14 =
144
 
145
  * All fields are now optional.
vendor/autoload.php CHANGED
@@ -4,4 +4,4 @@
4
 
5
  require_once __DIR__ . '/composer' . '/autoload_real.php';
6
 
7
- return ComposerAutoloaderInitc82fb3d4309edfd8ea523799ad4e4047::getLoader();
4
 
5
  require_once __DIR__ . '/composer' . '/autoload_real.php';
6
 
7
+ return ComposerAutoloaderInita335211086c2f06f359bc403030d5102::getLoader();
vendor/autoload_52.php CHANGED
@@ -4,4 +4,4 @@
4
 
5
  require_once dirname(__FILE__) . '/composer'.'/autoload_real_52.php';
6
 
7
- return ComposerAutoloaderInit6e188c71a42c36997d2c289096f78e62::getLoader();
4
 
5
  require_once dirname(__FILE__) . '/composer'.'/autoload_real_52.php';
6
 
7
+ return ComposerAutoloaderInit065b709dff92c3a8af66aa4d36bda067::getLoader();
vendor/composer/autoload_real.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
- class ComposerAutoloaderInitc82fb3d4309edfd8ea523799ad4e4047
6
  {
7
  private static $loader;
8
 
@@ -19,9 +19,9 @@ class ComposerAutoloaderInitc82fb3d4309edfd8ea523799ad4e4047
19
  return self::$loader;
20
  }
21
 
22
- spl_autoload_register(array('ComposerAutoloaderInitc82fb3d4309edfd8ea523799ad4e4047', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
- spl_autoload_unregister(array('ComposerAutoloaderInitc82fb3d4309edfd8ea523799ad4e4047', 'loadClassLoader'));
25
 
26
  $map = require __DIR__ . '/autoload_namespaces.php';
27
  foreach ($map as $namespace => $path) {
@@ -42,14 +42,14 @@ class ComposerAutoloaderInitc82fb3d4309edfd8ea523799ad4e4047
42
 
43
  $includeFiles = require __DIR__ . '/autoload_files.php';
44
  foreach ($includeFiles as $fileIdentifier => $file) {
45
- composerRequirec82fb3d4309edfd8ea523799ad4e4047($fileIdentifier, $file);
46
  }
47
 
48
  return $loader;
49
  }
50
  }
51
 
52
- function composerRequirec82fb3d4309edfd8ea523799ad4e4047($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 ComposerAutoloaderInita335211086c2f06f359bc403030d5102
6
  {
7
  private static $loader;
8
 
19
  return self::$loader;
20
  }
21
 
22
+ spl_autoload_register(array('ComposerAutoloaderInita335211086c2f06f359bc403030d5102', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInita335211086c2f06f359bc403030d5102', '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
+ composerRequirea335211086c2f06f359bc403030d5102($fileIdentifier, $file);
46
  }
47
 
48
  return $loader;
49
  }
50
  }
51
 
52
+ function composerRequirea335211086c2f06f359bc403030d5102($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 ComposerAutoloaderInit6e188c71a42c36997d2c289096f78e62 {
6
  private static $loader;
7
 
8
  public static function loadClassLoader($class) {
@@ -19,9 +19,9 @@ class ComposerAutoloaderInit6e188c71a42c36997d2c289096f78e62 {
19
  return self::$loader;
20
  }
21
 
22
- spl_autoload_register(array('ComposerAutoloaderInit6e188c71a42c36997d2c289096f78e62', 'loadClassLoader'), true /*, true */);
23
  self::$loader = $loader = new xrstf_Composer52_ClassLoader();
24
- spl_autoload_unregister(array('ComposerAutoloaderInit6e188c71a42c36997d2c289096f78e62', '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 ComposerAutoloaderInit065b709dff92c3a8af66aa4d36bda067 {
6
  private static $loader;
7
 
8
  public static function loadClassLoader($class) {
19
  return self::$loader;
20
  }
21
 
22
+ spl_autoload_register(array('ComposerAutoloaderInit065b709dff92c3a8af66aa4d36bda067', 'loadClassLoader'), true /*, true */);
23
  self::$loader = $loader = new xrstf_Composer52_ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInit065b709dff92c3a8af66aa4d36bda067', 'loadClassLoader'));
25
 
26
  $vendorDir = dirname(dirname(__FILE__));
27
  $baseDir = dirname($vendorDir);
vendor/composer/installed.json CHANGED
@@ -38,7 +38,7 @@
38
  "version_normalized": "9999999-dev",
39
  "source": {
40
  "type": "git",
41
- "url": "https://github.com/Codeinwp/themeisle-sdk.git",
42
  "reference": "f05bd8f0fe4d628424484e2bdd6d20ee65f454ee"
43
  },
44
  "dist": {
@@ -71,8 +71,7 @@
71
  "wordpress"
72
  ],
73
  "support": {
74
- "issues": "https://github.com/Codeinwp/themeisle-sdk/issues",
75
- "source": "https://github.com/Codeinwp/themeisle-sdk/tree/master"
76
  }
77
  }
78
  ]
38
  "version_normalized": "9999999-dev",
39
  "source": {
40
  "type": "git",
41
+ "url": "git@github.com:Codeinwp/themeisle-sdk.git",
42
  "reference": "f05bd8f0fe4d628424484e2bdd6d20ee65f454ee"
43
  },
44
  "dist": {
71
  "wordpress"
72
  ],
73
  "support": {
74
+ "issues": "https://github.com/Codeinwp/themeisle-sdk/issues"
 
75
  }
76
  }
77
  ]