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

Version Description

  • Added integration with custom emails plugin
  • Fixed text domains errors
Download this release

Release Info

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

Code changes from version 1.0.18 to 1.1.3

CHANGELOG.md CHANGED
@@ -1,4 +1,26 @@
1
 
 
 
 
2
- Update readme.txt
 
 
 
3
- Sync with wp.org
 
 
 
4
- Added upsell for custom emails plugin
5
- Fixed text domains errors
6
- Added travis and grunt
 
 
 
7
- Update changelog
 
 
 
8
- Escape form fields
9
 
10
 
11
 
12
- Fixed php strict standards error
1
 
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
 
25
 
26
 
 
css/front.css CHANGED
@@ -1,30 +1,49 @@
 
 
 
1
  .pirate_forms_wrap .form_field_wrap {
2
  margin-bottom: 20px;
3
  }
 
4
  .pirate-forms-g-recaptcha {
5
  display: none;
6
  }
 
7
  .pirate_forms_wrap {
8
- float:left;
9
  width: 100%;
10
  }
11
- .sidebar .pirate_forms_wrap, .sidebar-wrap .pirate_forms_wrap, #sidebar-secondary .pirate_forms_wrap {
 
 
 
12
  margin-bottom: 20px;
13
  }
14
- .sidebar .form_field_wrap, .sidebar-wrap .form_field_wrap, #sidebar-secondary .form_field_wrap {
 
 
 
15
  width: 100%;
16
  }
17
- .sidebar .pirate-forms-submit-button, .sidebar-wrap .pirate-forms-submit-button, #sidebar-secondary .pirate-forms-submit-button {
18
- float:left !important;
19
- margin-left: 0px;
20
- width: 100%;
 
 
 
21
  }
22
- .sidebar .pirate_forms_wrap label, .sidebar-wrap .pirate_forms_wrap label, #sidebar-secondary .pirate_forms_wrap label {
 
 
 
23
  display: none;
24
  }
 
25
  .pirate_forms_clearfix {
26
  clear: both;
27
  }
 
28
  .contact_submit_wrap {
29
  text-align: right;
30
  }
1
+ /*
2
+ Version: 1.1.3
3
+ */
4
  .pirate_forms_wrap .form_field_wrap {
5
  margin-bottom: 20px;
6
  }
7
+
8
  .pirate-forms-g-recaptcha {
9
  display: none;
10
  }
11
+
12
  .pirate_forms_wrap {
13
+ float: left;
14
  width: 100%;
15
  }
16
+
17
+ .sidebar .pirate_forms_wrap,
18
+ .sidebar-wrap .pirate_forms_wrap,
19
+ #sidebar-secondary .pirate_forms_wrap {
20
  margin-bottom: 20px;
21
  }
22
+
23
+ .sidebar .form_field_wrap,
24
+ .sidebar-wrap .form_field_wrap,
25
+ #sidebar-secondary .form_field_wrap {
26
  width: 100%;
27
  }
28
+
29
+ .sidebar .pirate-forms-submit-button,
30
+ .sidebar-wrap .pirate-forms-submit-button,
31
+ #sidebar-secondary .pirate-forms-submit-button {
32
+ float: left !important;
33
+ width: 100%;
34
+ margin-left: 0;
35
  }
36
+
37
+ .sidebar .pirate_forms_wrap label,
38
+ .sidebar-wrap .pirate_forms_wrap label,
39
+ #sidebar-secondary .pirate_forms_wrap label {
40
  display: none;
41
  }
42
+
43
  .pirate_forms_clearfix {
44
  clear: both;
45
  }
46
+
47
  .contact_submit_wrap {
48
  text-align: right;
49
  }
css/wp-admin.css CHANGED
@@ -1,169 +1,192 @@
1
  .pirate-forms-nav-tabs a {
2
- box-shadow: none !important;
3
  -webkit-box-shadow: none !important;
 
4
  }
 
5
  .pirate-forms-postbox {
6
  margin-top: 20px;
7
  padding: 10px 20px;
8
  background: #fff;
9
  }
 
10
  .pirate-forms-nav-tabs {
11
  margin-bottom: 0;
12
  }
 
13
  .pirate-forms-nav-tabs:after {
14
- clear: both;
15
  display: table;
 
16
  content: " ";
17
  }
 
18
  .pirate-forms-nav-tabs > li {
 
19
  float: left;
20
  margin-bottom: -1px;
21
- display: block;
22
  }
 
23
  .pirate-forms-nav-tabs > li > a {
24
- border: 1px solid transparent;
25
- border-radius: 4px 4px 0 0;
26
  display: block;
27
  padding: 10px 15px;
 
 
28
  text-decoration: none;
29
  }
30
- .pirate-forms-nav-tabs > li.active > a, .pirate-forms-nav-tabs > li.active > a:focus, .pirate-forms-nav-tabs > li.active > a:hover {
31
- color: #555;
32
- background-color: #fff;
 
33
  border: 1px solid #ddd;
34
  border-bottom-color: transparent;
 
 
35
  font-weight: bold;
36
  }
 
37
  .pirate-forms-nav-tabs > li.zerif-lite-w-red-tab > a {
38
  color: red;
39
  font-weight: bold;
40
  }
 
41
  .pirate-forms-tab-content {
42
- background-color: #fff;
43
- border-bottom: 1px solid #ddd;
44
  border-right: 1px solid #ddd;
 
45
  border-left: 1px solid #ddd;
46
- width: 860px;
47
- float: left;
48
  }
 
49
  .pirate-forms-tab-content > .tab-pane {
50
  display: none;
51
  }
 
52
  .pirate-forms-tab-content > .active {
53
  display: block;
54
  }
55
 
56
  .pirate-forms-tab-pane {
57
- padding: 30px;
58
  display: none;
 
59
  }
60
 
61
  .pirate-forms-tab-pane.active {
62
  display: block;
63
  }
 
64
  .pirate-forms-grouped {
 
 
 
65
  display: flex;
66
- align-items: center;
67
  margin-bottom: 20px;
 
 
 
 
 
68
  }
 
69
  .pirate-forms-grouped label {
70
  display: inline-block;
71
  width: 260px;
72
  margin: 0 1em 0 0;
73
- font-size: 15px;
74
  color: #333;
 
75
  font-weight: bold;
76
  }
 
77
  .pirate-forms-grouped label .pirate_forms_option_description {
78
  font-size: 11px;
79
  font-weight: normal;
80
  }
81
- .pirate-forms-grouped select,.pirate-forms-grouped input[type="text"] {
 
 
82
  display: inline-block;
83
  }
 
84
  .pirate-forms-grouped input[type="text"] {
85
  width: 30%;
86
  }
87
 
88
- .pirate-options{
89
  display: inline-block;
90
  }
91
- .pirate-subscribe.postbox{
 
92
  display: inline-block;
93
- vertical-align: top;
94
- margin: 20px;
95
- margin-right: 0px;
96
- margin-bottom: 0;
97
- margin-top: 51px;
98
- padding: 10px;
99
- width: 250px;
100
  }
101
 
102
- .wrap{
103
  margin-right: 0;
104
  }
105
 
106
  #\31 > form > div > label > span.dashicons {
107
- color: #888;
108
- margin-left: 10px;
109
  }
110
 
111
  #\31 > form > div > label > span.dashicons:after {
112
- display: none;
113
- content: "";
114
- position: absolute;
115
- margin-left: 5px;
116
- border-left: 5px solid transparent;
117
- border-right: 5px solid transparent;
118
- border-bottom: 5px solid black;
119
  }
120
 
121
  #\31 > form > div > label > .pirate_forms_option_description {
122
  display: none;
123
- background: rgba(0,0,0,.8);
124
- border-radius: 5px;
125
- color: #fff;
126
- padding: 15px;
127
- position: absolute;
128
- font-size: 11px;
129
- line-height: 16px;
130
  margin-left: 190px;
131
- margin-top: 4px;
132
- z-index: 999;
133
- width: 200px;
134
- text-align: left;
 
 
 
135
  }
136
 
137
- #\31 > form > div > label > span.dashicons:hover + .pirate_forms_option_description, #\31 > form > div > label > span.dashicons:hover::after {
138
- display:block;
139
-
140
  }
141
 
142
  #\31 > form > div > label {
143
  width: 400px;
144
- font-weight: normal;
145
  }
146
 
147
- .pirate_forms_contact_settings h3.title, .pirate_forms_welcome_text {
 
 
 
 
148
  text-align: center;
149
- font-size: 23px;
150
- color: #555;
151
- margin: 10px 0 30px;
152
  }
153
 
154
  .pirate-forms-tab-pane hr {
155
- margin-bottom: 30px;
156
  }
157
 
158
  .pirate-forms-tab-pane ol {
159
  margin: 20px 0 20px 50px;
160
- list-style: inherit;
161
  }
162
 
163
  .pirate_forms_subheading {
164
- text-align: center;
165
  color: #333;
166
  font-size: 14px;
 
167
  }
168
 
169
  .rate_plugin_invite {
@@ -171,24 +194,87 @@
171
  }
172
 
173
  .rate_plugin_invite .dashicons {
 
174
  color: #0073aa;
175
  font-size: 12px;
176
- width: auto;
177
  }
178
 
179
  .pirate_forms_preview {
180
- margin: 0 auto 10px;
181
  display: inherit;
 
182
  }
183
 
184
- @media( max-width: 1360px){
185
- .pirate-subscribe.postbox{
186
- margin-left: 0;
187
- margin-top: 40px;
188
  display: block;
 
 
189
  }
190
  }
191
 
192
- .ajaxAnimation { background: url("../img/loader.gif") no-repeat center center, rgba(255,255,255,0.8); position: absolute;top: 0; left: 0; right: 0; bottom: 0; display: none;}
 
 
 
 
 
 
 
 
 
 
 
 
193
 
194
- .pirate-forms-hidden { display:none !important; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  .pirate-forms-nav-tabs a {
 
2
  -webkit-box-shadow: none !important;
3
+ box-shadow: none !important;
4
  }
5
+
6
  .pirate-forms-postbox {
7
  margin-top: 20px;
8
  padding: 10px 20px;
9
  background: #fff;
10
  }
11
+
12
  .pirate-forms-nav-tabs {
13
  margin-bottom: 0;
14
  }
15
+
16
  .pirate-forms-nav-tabs:after {
 
17
  display: table;
18
+ clear: both;
19
  content: " ";
20
  }
21
+
22
  .pirate-forms-nav-tabs > li {
23
+ display: block;
24
  float: left;
25
  margin-bottom: -1px;
 
26
  }
27
+
28
  .pirate-forms-nav-tabs > li > a {
 
 
29
  display: block;
30
  padding: 10px 15px;
31
+ border: 1px solid transparent;
32
+ border-radius: 4px 4px 0 0;
33
  text-decoration: none;
34
  }
35
+
36
+ .pirate-forms-nav-tabs > li.active > a,
37
+ .pirate-forms-nav-tabs > li.active > a:focus,
38
+ .pirate-forms-nav-tabs > li.active > a:hover {
39
  border: 1px solid #ddd;
40
  border-bottom-color: transparent;
41
+ color: #555;
42
+ background-color: #fff;
43
  font-weight: bold;
44
  }
45
+
46
  .pirate-forms-nav-tabs > li.zerif-lite-w-red-tab > a {
47
  color: red;
48
  font-weight: bold;
49
  }
50
+
51
  .pirate-forms-tab-content {
52
+ float: left;
53
+ width: 860px;
54
  border-right: 1px solid #ddd;
55
+ border-bottom: 1px solid #ddd;
56
  border-left: 1px solid #ddd;
57
+ background-color: #fff;
 
58
  }
59
+
60
  .pirate-forms-tab-content > .tab-pane {
61
  display: none;
62
  }
63
+
64
  .pirate-forms-tab-content > .active {
65
  display: block;
66
  }
67
 
68
  .pirate-forms-tab-pane {
 
69
  display: none;
70
+ padding: 30px;
71
  }
72
 
73
  .pirate-forms-tab-pane.active {
74
  display: block;
75
  }
76
+
77
  .pirate-forms-grouped {
78
+ display: -webkit-box;
79
+ display: -webkit-flex;
80
+ display: -ms-flexbox;
81
  display: flex;
 
82
  margin-bottom: 20px;
83
+
84
+ -webkit-align-items: center;
85
+ align-items: center;
86
+ -webkit-box-align: center;
87
+ -ms-flex-align: center;
88
  }
89
+
90
  .pirate-forms-grouped label {
91
  display: inline-block;
92
  width: 260px;
93
  margin: 0 1em 0 0;
 
94
  color: #333;
95
+ font-size: 15px;
96
  font-weight: bold;
97
  }
98
+
99
  .pirate-forms-grouped label .pirate_forms_option_description {
100
  font-size: 11px;
101
  font-weight: normal;
102
  }
103
+
104
+ .pirate-forms-grouped select,
105
+ .pirate-forms-grouped input[type="text"] {
106
  display: inline-block;
107
  }
108
+
109
  .pirate-forms-grouped input[type="text"] {
110
  width: 30%;
111
  }
112
 
113
+ .pirate-options {
114
  display: inline-block;
115
  }
116
+
117
+ .pirate-subscribe.postbox {
118
  display: inline-block;
119
+ width: 90%;
120
+ margin: auto;
121
+ vertical-align: top;
 
 
 
 
122
  }
123
 
124
+ .wrap {
125
  margin-right: 0;
126
  }
127
 
128
  #\31 > form > div > label > span.dashicons {
129
+ margin-left: 10px;
130
+ color: #888;
131
  }
132
 
133
  #\31 > form > div > label > span.dashicons:after {
134
+ display: none;
135
+ position: absolute;
136
+ margin-left: 5px;
137
+ border-right: 5px solid transparent;
138
+ border-bottom: 5px solid black;
139
+ border-left: 5px solid transparent;
140
+ content: "";
141
  }
142
 
143
  #\31 > form > div > label > .pirate_forms_option_description {
144
  display: none;
145
+ position: absolute;
146
+ z-index: 999;
147
+ width: 200px;
148
+ margin-top: 4px;
 
 
 
149
  margin-left: 190px;
150
+ padding: 15px;
151
+ border-radius: 5px;
152
+ color: #fff;
153
+ background: rgba(0,0,0,0.8);
154
+ font-size: 11px;
155
+ line-height: 16px;
156
+ text-align: left;
157
  }
158
 
159
+ #\31 > form > div > label > span.dashicons:hover + .pirate_forms_option_description,
160
+ #\31 > form > div > label > span.dashicons:hover::after {
161
+ display: block;
162
  }
163
 
164
  #\31 > form > div > label {
165
  width: 400px;
166
+ font-weight: normal;
167
  }
168
 
169
+ .pirate_forms_contact_settings h3.title,
170
+ .pirate_forms_welcome_text {
171
+ margin: 10px 0 30px;
172
+ color: #555;
173
+ font-size: 23px;
174
  text-align: center;
 
 
 
175
  }
176
 
177
  .pirate-forms-tab-pane hr {
178
+ margin-bottom: 30px;
179
  }
180
 
181
  .pirate-forms-tab-pane ol {
182
  margin: 20px 0 20px 50px;
183
+ list-style: inherit;
184
  }
185
 
186
  .pirate_forms_subheading {
 
187
  color: #333;
188
  font-size: 14px;
189
+ text-align: center;
190
  }
191
 
192
  .rate_plugin_invite {
194
  }
195
 
196
  .rate_plugin_invite .dashicons {
197
+ width: auto;
198
  color: #0073aa;
199
  font-size: 12px;
 
200
  }
201
 
202
  .pirate_forms_preview {
 
203
  display: inherit;
204
+ margin: 0 auto 10px;
205
  }
206
 
207
+ @media( max-width: 1360px) {
208
+ .pirate-subscribe.postbox {
 
 
209
  display: block;
210
+ margin-top: 40px;
211
+ margin-left: 0;
212
  }
213
  }
214
 
215
+ .ajaxAnimation {
216
+ display: none;
217
+ position: absolute;
218
+ top: 0;
219
+ right: 0;
220
+ bottom: 0;
221
+ left: 0;
222
+ background: url("../img/loader.gif") no-repeat center center, rgba(255,255,255,0.8);
223
+ }
224
+
225
+ .pirate-forms-hidden {
226
+ display: none !important;
227
+ }
228
 
229
+ #pirate-forms-main {
230
+ float: left;
231
+ }
232
+
233
+ #pirate-forms-sidebar {
234
+ float: left;
235
+ width: 300px;
236
+ margin-top: 94px;
237
+ margin-left: 50px;
238
+ }
239
+
240
+ .pirate-custom-emails a:hover {
241
+ -webkit-box-shadow: none;
242
+ box-shadow: none;
243
+ -webkit-transform: translateY(4px);
244
+ -moz-transform: translateY(4px);
245
+ -ms-transform: translateY(4px);
246
+ -o-transform: translateY(4px);
247
+ transform: translateY(4px);
248
+ }
249
+
250
+ .pirate-custom-emails a {
251
+ display: inline-block;
252
+ margin-top: 10px;
253
+ padding: 9px;
254
+ border-radius: 3px;
255
+ color: #fff;
256
+ background: #ff7f65;
257
+ -webkit-box-shadow: 0 4px 0 #da6f5a;
258
+ box-shadow: 0 4px 0 #da6f5a;
259
+ font-size: 12px;
260
+ font-weight: 700;
261
+ text-decoration: none;
262
+ text-transform: uppercase;
263
+ cursor: pointer;
264
+ -webkit-transition: ease 0.25s;
265
+ transition: ease 0.25s;
266
+ }
267
+
268
+ .pirate-custom-emails {
269
+ width: 90%;
270
+ margin: auto;
271
+ margin-top: 10px;
272
+ border-color: #fdbda9;
273
+ }
274
+
275
+ @media screen and (max-width: 780px) {
276
+ #pirate-forms-sidebar {
277
+ width: 100%;
278
+ margin: 4px;
279
+ }
280
+ }
inc/PhpFormBuilder.php CHANGED
@@ -1,7 +1,6 @@
1
  <?php
2
 
3
  // v 0.8.6
4
-
5
  class PhpFormBuilder {
6
 
7
  // Stores all form inputs
@@ -23,11 +22,10 @@ class PhpFormBuilder {
23
 
24
  /* if the form has an attachment option change the enctype to multipart/form-data */
25
 
26
- $pirateformsopt_attachment_field = pirate_forms_get_key('pirateformsopt_attachment_field');
27
- if( !empty($pirateformsopt_attachment_field) && ($pirateformsopt_attachment_field == 'yes') ) {
28
  $pirate_forms_enctype = 'multipart/form-data';
29
- }
30
- else {
31
  $pirate_forms_enctype = 'application/x-www-form-urlencoded';
32
  }
33
 
@@ -43,7 +41,7 @@ class PhpFormBuilder {
43
  'add_nonce' => false,
44
  'add_honeypot' => true,
45
  'form_element' => true,
46
- 'add_submit' => true
47
  );
48
 
49
  // Merge with arguments, if present
@@ -171,7 +169,7 @@ class PhpFormBuilder {
171
  'wrap_style' => '',
172
  'before_html' => '',
173
  'after_html' => '',
174
- 'request_populate' => true
175
  );
176
 
177
  // Combined defaults and arguments
@@ -251,7 +249,7 @@ class PhpFormBuilder {
251
  'wrap_class' => array( 'form_field_wrap', 'hidden' ),
252
  'wrap_id' => '',
253
  'wrap_style' => 'display: none',
254
- 'request_populate' => false
255
  ) );
256
  }
257
 
@@ -261,7 +259,7 @@ class PhpFormBuilder {
261
  'value' => wp_create_nonce( $this->form['add_nonce'] ),
262
  'add_label' => false,
263
  'type' => 'hidden',
264
- 'request_populate' => false
265
  ) );
266
  }
267
 
@@ -303,7 +301,7 @@ class PhpFormBuilder {
303
 
304
  case 'textarea':
305
  $element = 'textarea';
306
- $end = ' class="form-control" placeholder="'.$val['placeholder'].'">' . $val['value'] . '</textarea>';
307
  break;
308
 
309
  case 'select':
@@ -323,7 +321,7 @@ class PhpFormBuilder {
323
  ) {
324
  $opt_insert = ' selected';
325
 
326
- // Does the field have a default selected value?
327
  } else if ( $val['selected'] === $key ) {
328
  $opt_insert = ' selected';
329
  }
@@ -333,7 +331,7 @@ class PhpFormBuilder {
333
  break;
334
  case 'captcha':
335
  $element = 'div';
336
- $end = ' class="g-recaptcha pirate-forms-g-recaptcha" data-sitekey="' .$val['value'] . '"></div>';
337
  break;
338
  case 'file':
339
  $element = 'input';
@@ -380,11 +378,10 @@ class PhpFormBuilder {
380
  $element = 'input';
381
 
382
  /* don't add a placeholder attribute for input type=hidden */
383
- if( !empty($val['type']) && ($val['type'] == 'hidden' ) ) {
384
- $end .= ' class="form-control" type="' . $val['type'] . '" value="' . $val['value'] . '"';
385
- }
386
- else {
387
- $end .= ' class="form-control" type="' . $val['type'] . '" value="' . $val['value'] . '" placeholder="' . $val['placeholder'] . '"';
388
  }
389
  $end .= $val['checked'] ? ' checked' : '';
390
  $end .= $this->field_close();
@@ -428,16 +425,14 @@ class PhpFormBuilder {
428
  $field = '
429
  <' . $element . $id . ' name="' . $val['name'] . '"' . $min_max_range . $class . $attr . $end .
430
  $field;
431
- }
432
- elseif ( $val['type'] === 'captcha' ) { /* don't add name attribute to div's holding recaptcha keys */
433
  $field .= '
434
  <' . $element . $id . ' ' . $min_max_range . $class . $attr . $end;
435
- }
436
- else {
437
  $field .= '
438
  <' . $element . $id . ' name="' . $val['name'] . '"' . $min_max_range . $class . $attr . $end;
439
  }
440
- // Not a form element
441
  } else {
442
  $field .= $end;
443
  }
@@ -497,7 +492,6 @@ class PhpFormBuilder {
497
 
498
  // Check $name for correct characters
499
  // "^[a-zA-Z0-9_-]*$"
500
-
501
  return $result;
502
 
503
  }
@@ -523,7 +517,6 @@ class PhpFormBuilder {
523
 
524
  $output = '';
525
 
526
-
527
  if ( is_array( $classes ) && count( $classes ) > 0 ) {
528
  $output .= ' class="';
529
  foreach ( $classes as $class ) {
@@ -536,4 +529,4 @@ class PhpFormBuilder {
536
 
537
  return $output;
538
  }
539
- }
1
  <?php
2
 
3
  // v 0.8.6
 
4
  class PhpFormBuilder {
5
 
6
  // Stores all form inputs
22
 
23
  /* if the form has an attachment option change the enctype to multipart/form-data */
24
 
25
+ $pirateformsopt_attachment_field = pirate_forms_get_key( 'pirateformsopt_attachment_field' );
26
+ if ( ! empty( $pirateformsopt_attachment_field ) && ($pirateformsopt_attachment_field == 'yes') ) {
27
  $pirate_forms_enctype = 'multipart/form-data';
28
+ } else {
 
29
  $pirate_forms_enctype = 'application/x-www-form-urlencoded';
30
  }
31
 
41
  'add_nonce' => false,
42
  'add_honeypot' => true,
43
  'form_element' => true,
44
+ 'add_submit' => true,
45
  );
46
 
47
  // Merge with arguments, if present
169
  'wrap_style' => '',
170
  'before_html' => '',
171
  'after_html' => '',
172
+ 'request_populate' => true,
173
  );
174
 
175
  // Combined defaults and arguments
249
  'wrap_class' => array( 'form_field_wrap', 'hidden' ),
250
  'wrap_id' => '',
251
  'wrap_style' => 'display: none',
252
+ 'request_populate' => false,
253
  ) );
254
  }
255
 
259
  'value' => wp_create_nonce( $this->form['add_nonce'] ),
260
  'add_label' => false,
261
  'type' => 'hidden',
262
+ 'request_populate' => false,
263
  ) );
264
  }
265
 
301
 
302
  case 'textarea':
303
  $element = 'textarea';
304
+ $end = ' class="form-control" placeholder="' . $val['placeholder'] . '">' . esc_attr( $val['value'] ) . '</textarea>';
305
  break;
306
 
307
  case 'select':
321
  ) {
322
  $opt_insert = ' selected';
323
 
324
+ // Does the field have a default selected value?
325
  } else if ( $val['selected'] === $key ) {
326
  $opt_insert = ' selected';
327
  }
331
  break;
332
  case 'captcha':
333
  $element = 'div';
334
+ $end = ' class="g-recaptcha pirate-forms-g-recaptcha" data-sitekey="' . $val['value'] . '"></div>';
335
  break;
336
  case 'file':
337
  $element = 'input';
378
  $element = 'input';
379
 
380
  /* don't add a placeholder attribute for input type=hidden */
381
+ if ( ! empty( $val['type'] ) && ($val['type'] == 'hidden' ) ) {
382
+ $end .= ' class="form-control" type="' . $val['type'] . '" value="' . esc_attr( $val['value'] ) . '"';
383
+ } else {
384
+ $end .= ' class="form-control" type="' . $val['type'] . '" value="' . esc_attr( $val['value'] ) . '" placeholder="' . $val['placeholder'] . '"';
 
385
  }
386
  $end .= $val['checked'] ? ' checked' : '';
387
  $end .= $this->field_close();
425
  $field = '
426
  <' . $element . $id . ' name="' . $val['name'] . '"' . $min_max_range . $class . $attr . $end .
427
  $field;
428
+ } elseif ( $val['type'] === 'captcha' ) { /* don't add name attribute to div's holding recaptcha keys */
 
429
  $field .= '
430
  <' . $element . $id . ' ' . $min_max_range . $class . $attr . $end;
431
+ } else {
 
432
  $field .= '
433
  <' . $element . $id . ' name="' . $val['name'] . '"' . $min_max_range . $class . $attr . $end;
434
  }
435
+ // Not a form element
436
  } else {
437
  $field .= $end;
438
  }
492
 
493
  // Check $name for correct characters
494
  // "^[a-zA-Z0-9_-]*$"
 
495
  return $result;
496
 
497
  }
517
 
518
  $output = '';
519
 
 
520
  if ( is_array( $classes ) && count( $classes ) > 0 ) {
521
  $output .= ' class="';
522
  foreach ( $classes as $class ) {
529
 
530
  return $output;
531
  }
532
+ }
inc/helpers.php CHANGED
@@ -1,8 +1,8 @@
1
  <?php
 
 
 
2
 
3
- /**************************************************/
4
- /**************** Show errors *********************/
5
- /**************************************************/
6
 
7
  if ( ! function_exists( 'pirate_forms_display_errors' ) ) {
8
 
@@ -10,10 +10,10 @@ if ( ! function_exists( 'pirate_forms_display_errors' ) ) {
10
 
11
  $output = '';
12
 
13
- if( !empty($errs) ):
14
 
15
  $output .= '<div class="col-sm-12 col-lg-12 pirate_forms_error_box">';
16
- $output .= '<p>'.__( 'Sorry, an error occured.','pirate-forms' ).'</p>';
17
  $output .= '</div>';
18
  foreach ( $errs as $err ) :
19
  $output .= '<div class="col-sm-12 col-lg-12 pirate_forms_error_box">';
@@ -27,9 +27,10 @@ if ( ! function_exists( 'pirate_forms_display_errors' ) ) {
27
  }
28
  }
29
 
30
- /***************************************************************************/
31
- /******** Get blacklist IPs and emails from the Discussion settings ********/
32
- /***************************************************************************/
 
33
 
34
  if ( ! function_exists( 'pirate_forms_get_blacklist' ) ) {
35
 
@@ -55,4 +56,4 @@ if ( ! function_exists( 'pirate_forms_get_blacklist' ) ) {
55
 
56
  return $final_blocked_arr;
57
  }
58
- }
1
  <?php
2
+ /**
3
+
4
+ * ************* Show errors *********************/
5
 
 
 
 
6
 
7
  if ( ! function_exists( 'pirate_forms_display_errors' ) ) {
8
 
10
 
11
  $output = '';
12
 
13
+ if ( ! empty( $errs ) ) :
14
 
15
  $output .= '<div class="col-sm-12 col-lg-12 pirate_forms_error_box">';
16
+ $output .= '<p>' . __( 'Sorry, an error occured.','pirate-forms' ) . '</p>';
17
  $output .= '</div>';
18
  foreach ( $errs as $err ) :
19
  $output .= '<div class="col-sm-12 col-lg-12 pirate_forms_error_box">';
27
  }
28
  }
29
 
30
+ /**
31
+
32
+ ****** Get blacklist IPs and emails from the Discussion settings */
33
+
34
 
35
  if ( ! function_exists( 'pirate_forms_get_blacklist' ) ) {
36
 
56
 
57
  return $final_blocked_arr;
58
  }
59
+ }
inc/settings.php CHANGED
@@ -1,21 +1,19 @@
1
  <?php
2
  function pirate_forms_is_localhost() {
3
  $server_name = strtolower( $_SERVER['SERVER_NAME'] );
 
4
  return in_array( $server_name, array( 'localhost', '127.0.0.1' ) );
5
  }
6
- function pirate_forms_from_email() {
7
 
 
8
  $admin_email = get_option( 'admin_email' );
9
- $sitename = strtolower( $_SERVER['SERVER_NAME'] );
10
-
11
  if ( pirate_forms_is_localhost() ) {
12
  return $admin_email;
13
  }
14
-
15
  if ( substr( $sitename, 0, 4 ) == 'www.' ) {
16
  $sitename = substr( $sitename, 4 );
17
  }
18
-
19
  if ( strpbrk( $admin_email, '@' ) == '@' . $sitename ) {
20
  return $admin_email;
21
  }
@@ -25,20 +23,16 @@ function pirate_forms_from_email() {
25
 
26
  if ( ! function_exists( 'pirate_forms_get_pages_array' ) ) {
27
  function pirate_forms_get_pages_array( $type = 'page' ) {
28
-
29
  $content = array(
30
- '' => __( 'None', 'pirate_forms' )
31
  );
32
-
33
- $items = get_posts( array(
34
  'post_type' => $type,
35
- 'numberposts' => - 1
36
  ) );
37
-
38
-
39
  if ( ! empty( $items ) ) :
40
  foreach ( $items as $item ) :
41
- $content[$item->ID] = $item->post_title;
42
  endforeach;
43
  endif;
44
 
@@ -46,7 +40,6 @@ if ( ! function_exists( 'pirate_forms_get_pages_array' ) ) {
46
 
47
  }
48
  }
49
-
50
  /*
51
  *
52
  * OPTIONS
@@ -55,304 +48,293 @@ if ( ! function_exists( 'pirate_forms_get_pages_array' ) ) {
55
  *
56
  */
57
  function pirate_forms_plugin_options() {
58
-
59
- /*********************************************************/
60
- /************ Default values from Zerif Lite ************/
61
- /*********************************************************/
62
-
63
- $zerif_contactus_sitekey = get_theme_mod('zerif_contactus_sitekey');
64
-
65
- if( !empty($zerif_contactus_sitekey) ):
66
  $pirate_forms_contactus_sitekey = $zerif_contactus_sitekey;
67
- else:
68
  $pirate_forms_contactus_sitekey = '';
69
  endif;
70
-
71
- $zerif_contactus_secretkey = get_theme_mod('zerif_contactus_secretkey');
72
- if( !empty($zerif_contactus_secretkey) ):
73
  $pirate_forms_contactus_secretkey = $zerif_contactus_secretkey;
74
- else:
75
  $pirate_forms_contactus_secretkey = '';
76
  endif;
77
-
78
- $zerif_contactus_recaptcha_show = get_theme_mod('zerif_contactus_recaptcha_show');
79
-
80
- if( isset($zerif_contactus_recaptcha_show) && ($zerif_contactus_recaptcha_show == '1') ):
81
  $pirate_forms_contactus_recaptcha_show = '';
82
- else:
83
  $pirate_forms_contactus_recaptcha_show = 'yes';
84
  endif;
85
-
86
- $zerif_contactus_button_label = get_theme_mod('zerif_contactus_button_label',__('Send Message','zerif-lite'));
87
- if( !empty($zerif_contactus_button_label) ):
88
  $pirate_forms_contactus_button_label = $zerif_contactus_button_label;
89
- else:
90
- $pirate_forms_contactus_button_label = __( 'Send Message','pirate-forms' );
91
  endif;
92
-
93
- $zerif_contactus_email = get_theme_mod('zerif_contactus_email');
94
- $zerif_email = get_theme_mod('zerif_email');
95
-
96
  $pirate_forms_contactus_email = '';
97
- if( !empty($zerif_contactus_email) ):
98
  $pirate_forms_contactus_email = $zerif_contactus_email;
99
- elseif( !empty($zerif_email) ):
100
  $pirate_forms_contactus_email = $zerif_email;
101
- else:
102
  $pirate_forms_contactus_email = get_bloginfo( 'admin_email' );
103
  endif;
104
 
105
  return array(
106
  'fourth_tab' => array(
107
- 'header_options' => array(
108
- __( 'Form processing options','pirate-forms' ),
109
  '',
110
  'title',
111
  '',
112
  ),
113
- 'pirateformsopt_email' => array(
114
- __( 'Contact notification sender email','pirate-forms' ),
115
- '<strong>'.__( "Insert [email] to use the contact form submitter's email.","pirate-forms" ).'</strong><br>'.__( "Email to use for the sender of the contact form emails both to the recipients below and the contact form submitter (if this is activated below). The domain for this email address should match your site's domain.","pirate-forms" ),
116
  'text',
117
- pirate_forms_from_email()
118
  ),
119
  'pirateformsopt_email_recipients' => array(
120
- __( 'Contact submission recipients','pirate-forms' ),
121
- __( 'Email address(es) to receive contact submission notifications. You can separate multiple emails with a comma.','pirate-forms' ),
122
  'text',
123
- pirate_forms_get_key( 'pirateformsopt_email' ) ? pirate_forms_get_key( 'pirateformsopt_email' ) : $pirate_forms_contactus_email
124
  ),
125
- 'pirateformsopt_store' => array(
126
- __( 'Store submissions in the database','pirate-forms' ),
127
- __( 'Should the submissions be stored in the admin area? If chosen, contact form submissions will be saved in Contacts on the left (appears after this option is activated).','pirate-forms' ),
128
  'checkbox',
129
  'yes',
130
  ),
131
- 'pirateformsopt_nonce' => array(
132
- __( 'Add a nonce to the contact form:','pirate-forms' ),
133
- __( 'Should the form use a WordPress nonce? This helps reduce spam by ensuring that the form submittor is on the site when submitting the form rather than submitting remotely. This could, however, cause problems with sites using a page caching plugin. Turn this off if you are getting complaints about forms not being able to be submitted with an error of "Nonce failed!"','pirate-forms' ),
134
  'checkbox',
135
  'yes',
136
  ),
137
- 'pirateformsopt_confirm_email' => array(
138
- __( 'Send email confirmation to form submitter','pirate-forms' ),
139
- __( 'Adding text here will send an email to the form submitter. The email uses the "Successful form submission text" field from the "Alert Messages" tab as the subject line. Plain text only here, no HTML.','pirate-forms' ),
140
  'textarea',
141
  '',
142
  ),
143
- 'pirateformsopt_thank_you_url' => array(
144
- __( '"Thank You" URL','pirate-forms' ),
145
- __( 'Select the post-submit page for all forms submitted','pirate-forms' ),
146
  'select',
147
  '',
148
- pirate_forms_get_pages_array()
149
- )
150
  ),
151
- 'first_tab' => array(
152
- 'header_fields' => array(
153
- __( 'Fields Settings','pirate-forms' ),
154
  '',
155
  'title',
156
  '',
157
  ),
158
  /* Name */
159
- 'pirateformsopt_name_field' => array(
160
- __( 'Name','pirate-forms' ),
161
- __( 'Do you want the name field to be displayed?','pirate-forms' ),
162
  'select',
163
  'req',
164
  array(
165
- '' => __( 'None','pirate-forms' ),
166
- 'yes' => __( 'Yes but not required','pirate-forms' ),
167
- 'req' => __( 'Required','pirate-forms' ),
168
  ),
169
  ),
170
  /* Email */
171
- 'pirateformsopt_email_field' => array(
172
- __( 'Email address','pirate-forms' ),
173
- __( 'Do you want the email address field be displayed?','pirate-forms' ),
174
  'select',
175
  'req',
176
  array(
177
- '' => __( 'None','pirate-forms' ),
178
- 'yes' => __( 'Yes but not required','pirate-forms' ),
179
- 'req' => __( 'Required','pirate-forms' ),
180
  ),
181
  ),
182
  /* Subject */
183
- 'pirateformsopt_subject_field' => array(
184
- __( 'Subject','pirate-forms' ),
185
- __( 'Do you want the subject field be displayed?','pirate-forms' ),
186
  'select',
187
  'req',
188
  array(
189
- '' => __( 'None','pirate-forms' ),
190
- 'yes' => __( 'Yes but not required','pirate-forms' ),
191
- 'req' => __( 'Required','pirate-forms' ),
192
  ),
193
  ),
194
  /* Message */
195
- 'pirateformsopt_message_field' => array(
196
- __( 'Message','pirate-forms' ),
197
  '',
198
  'select',
199
  'req',
200
  array(
201
- '' => __( 'None','pirate-forms' ),
202
- 'yes' => __( 'Yes but not required','pirate-forms' ),
203
- 'req' => __( 'Required','pirate-forms' ),
204
  ),
205
  ),
206
  /* Recaptcha */
207
- 'pirateformsopt_recaptcha_field' => array(
208
- __( 'Add a reCAPTCHA','pirate-forms' ),
209
  '',
210
  'checkbox',
211
  $pirate_forms_contactus_recaptcha_show,
212
  ),
213
  /* Site key */
214
- 'pirateformsopt_recaptcha_sitekey' => array(
215
- __( 'Site key','pirate-forms' ),
216
- '<a href="https://www.google.com/recaptcha/admin#list" target="_blank">'.__( 'Create an account here ','pirate-forms' ).'</a>'.__( 'to get the Site key and the Secret key for the reCaptcha.','pirate-forms' ),
217
  'text',
218
  $pirate_forms_contactus_sitekey,
219
  ),
220
  /* Secret key */
221
  'pirateformsopt_recaptcha_secretkey' => array(
222
- __( 'Secret key','pirate-forms' ),
223
  '',
224
  'text',
225
  $pirate_forms_contactus_secretkey,
226
  ),
227
  /* Attachment */
228
- 'pirateformsopt_attachment_field' => array(
229
- __( 'Add an attachment field','pirate-forms' ),
230
  '',
231
  'checkbox',
232
  '',
233
  ),
234
-
235
  ),
236
  'second_tab' => array(
237
- 'header_labels' => array(
238
- __( 'Fields Labels','pirate-forms' ),
239
  '',
240
  'title',
241
  '',
242
  ),
243
- 'pirateformsopt_label_name' => array(
244
- __( 'Name','pirate-forms' ),
245
  '',
246
  'text',
247
- __( 'Your Name','pirate-forms' ),
248
  ),
249
- 'pirateformsopt_label_email' => array(
250
- __( 'Email','pirate-forms' ),
251
  '',
252
  'text',
253
- __( 'Your Email','pirate-forms' )
254
  ),
255
- 'pirateformsopt_label_subject' => array(
256
- __( 'Subject','pirate-forms' ),
257
  '',
258
  'text',
259
- __( 'Subject','pirate-forms' )
260
  ),
261
- 'pirateformsopt_label_message' => array(
262
- __( 'Message','pirate-forms' ),
263
  '',
264
  'text',
265
- __( 'Your message','pirate-forms' )
266
  ),
267
  'pirateformsopt_label_submit_btn' => array(
268
- __( 'Submit button','pirate-forms' ),
269
  '',
270
  'text',
271
- $pirate_forms_contactus_button_label
272
- )
273
  ),
274
- 'third_tab' => array(
275
- 'header_messages' => array(
276
- __( 'Alert Messages','pirate-forms' ),
277
  '',
278
  'title',
279
  '',
280
  ),
281
- 'pirateformsopt_label_err_name' => array(
282
- __( 'Name required and missing','pirate-forms' ),
283
  '',
284
  'text',
285
- __( 'Enter your name','pirate-forms' )
286
  ),
287
- 'pirateformsopt_label_err_email' => array(
288
- __( 'E-mail required and missing','pirate-forms' ),
289
  '',
290
  'text',
291
- __( 'Enter a valid email','pirate-forms' )
292
  ),
293
- 'pirateformsopt_label_err_subject' => array(
294
- __( 'Subject required and missing','pirate-forms' ),
295
  '',
296
  'text',
297
- __( 'Please enter a subject','pirate-forms' )
298
  ),
299
  'pirateformsopt_label_err_no_content' => array(
300
- __( 'Question/comment is missing','pirate-forms' ),
301
  '',
302
  'text',
303
- __( 'Enter your question or comment','pirate-forms' )
304
  ),
305
- 'pirateformsopt_label_submit' => array(
306
- __( 'Successful form submission text','pirate-forms' ),
307
- __( 'This text is used on the page if no "Thank You" URL is set above. This is also used as the confirmation email title, if one is set to send out.','pirate-forms' ),
308
  'text',
309
- __( 'Thanks, your email was sent successfully!','pirate-forms' )
310
- )
311
  ),
312
- 'fifth_tab' => array(
313
- 'header_smtp' => array(
314
- __( 'SMTP Options','pirate-forms' ),
315
  '',
316
  'title',
317
  '',
318
  ),
319
- 'pirateformsopt_use_smtp' => array(
320
- __( 'Use SMTP to send emails?','pirate-forms' ),
321
- __( 'Instead of PHP mail function','pirate-forms' ),
322
  'checkbox',
323
  '',
324
  ),
325
- 'pirateformsopt_smtp_host' => array(
326
- __( 'SMTP Host','pirate-forms' ),
327
  '',
328
  'text',
329
  '',
330
  ),
331
- 'pirateformsopt_smtp_port' => array(
332
- __( 'SMTP Port','pirate-forms' ),
333
  '',
334
  'text',
335
  '',
336
  ),
337
  'pirateformsopt_use_smtp_authentication' => array(
338
- __( 'Use SMTP Authentication?','pirate-forms' ),
339
- __( 'If you check this box, make sure the SMTP Username and SMTP Password are completed.','pirate-forms' ),
340
  'checkbox',
341
  'yes',
342
  ),
343
- 'pirateformsopt_smtp_username' => array(
344
- __( 'SMTP Username','pirate-forms' ),
345
  '',
346
  'text',
347
  '',
348
  ),
349
- 'pirateformsopt_smtp_password' => array(
350
- __( 'SMTP Password','pirate-forms' ),
351
  '',
352
  'text',
353
  '',
354
- )
355
- )
356
  );
357
  }
358
 
@@ -362,105 +344,81 @@ function pirate_forms_plugin_options() {
362
  * @since 1.0.0
363
  */
364
  function pirate_forms_add_to_admin() {
365
-
366
  add_submenu_page(
367
  'options-general.php',
368
  __( 'Pirate Forms settings', 'pirate-forms' ),
369
  __( 'Pirate Forms', 'pirate-forms' ),
370
  'manage_options',
371
  'pirate-forms-admin',
372
- 'pirate_forms_admin' );
373
 
374
  }
375
- add_action( 'admin_menu', 'pirate_forms_add_to_admin' );
376
 
 
377
  /*
378
  *
379
  * Save forms via Ajax
380
  * @since 1.0.0
381
  *
382
  */
383
- add_action('wp_ajax_pirate_forms_save', 'pirate_forms_save_callback');
384
- add_action('wp_ajax_nopriv_pirate_forms_save', 'pirate_forms_save_callback');
385
-
386
  function pirate_forms_save_callback() {
387
-
388
- if( isset($_POST['dataSent']) ):
389
  $dataSent = $_POST['dataSent'];
390
-
391
- $params = array();
392
-
393
- if( !empty($dataSent) ):
394
  parse_str( $dataSent, $params );
395
  endif;
396
-
397
- if( !empty($params) ):
398
-
399
- /*****************************************************************/
400
- /******** Important fix for saving inputs of type checkbox *******/
401
- /*****************************************************************/
402
-
403
- if( !isset($params['pirateformsopt_store']) ) {
404
  $params['pirateformsopt_store'] = '';
405
  }
406
- if( !isset($params['pirateformsopt_recaptcha_field']) ) {
407
  $params['pirateformsopt_recaptcha_field'] = '';
408
  }
409
- if( !isset($params['pirateformsopt_nonce']) ) {
410
  $params['pirateformsopt_nonce'] = '';
411
  }
412
- if( !isset($params['pirateformsopt_attachment_field']) ) {
413
  $params['pirateformsopt_attachment_field'] = '';
414
  }
415
- if( !isset($params['pirateformsopt_use_smtp']) ) {
416
  $params['pirateformsopt_use_smtp'] = '';
417
  }
418
- if( !isset($params['pirateformsopt_use_smtp_authentication']) ) {
419
  $params['pirateformsopt_use_smtp_authentication'] = '';
420
  }
421
-
422
  update_option( 'pirate_forms_settings_array', $params );
423
-
424
- $pirate_forms_zerif_lite_mods = get_option('theme_mods_zerif-lite');
425
-
426
- if( empty($pirate_forms_zerif_lite_mods) ):
427
  $pirate_forms_zerif_lite_mods = array();
428
  endif;
429
-
430
- if( isset($params['pirateformsopt_label_submit_btn']) ):
431
- $pirate_forms_zerif_lite_mods['zerif_contactus_button_label'] = $params['pirateformsopt_label_submit_btn'];
432
- endif;
433
-
434
- if( isset($params['pirateformsopt_email']) ):
435
- $pirate_forms_zerif_lite_mods['zerif_contactus_email'] = $params['pirateformsopt_email'];
436
- endif;
437
-
438
- if( isset($params['pirateformsopt_email_recipients']) ):
439
- $pirate_forms_zerif_lite_mods['zerif_contactus_email'] = $params['pirateformsopt_email_recipients'];
440
- endif;
441
-
442
- if( isset($params['pirateformsopt_recaptcha_field']) && ($params['pirateformsopt_recaptcha_field'] == 'yes') ):
443
- $pirate_forms_zerif_lite_mods['zerif_contactus_recaptcha_show'] = 0;
444
- else:
445
- $pirate_forms_zerif_lite_mods['zerif_contactus_recaptcha_show'] = 1;
446
- endif;
447
-
448
- if( isset($params['pirateformsopt_recaptcha_sitekey']) ):
449
- $pirate_forms_zerif_lite_mods['zerif_contactus_sitekey'] = $params['pirateformsopt_recaptcha_sitekey'];
450
- endif;
451
-
452
- if( isset($params['pirateformsopt_recaptcha_secretkey']) ):
453
- $pirate_forms_zerif_lite_mods['zerif_contactus_secretkey'] = $params['pirateformsopt_recaptcha_secretkey'];
454
- endif;
455
-
456
- update_option('theme_mods_zerif-lite', $pirate_forms_zerif_lite_mods);
457
-
458
-
459
-
460
  endif;
461
-
462
  endif;
463
-
464
  die();
465
 
466
  }
@@ -471,130 +429,132 @@ function pirate_forms_save_callback() {
471
  *
472
  */
473
  function pirate_forms_admin() {
474
-
475
  global $current_user;
476
-
477
  $pirate_forms_options = get_option( 'pirate_forms_settings_array' );
478
-
479
- $plugin_options = pirate_forms_plugin_options();
480
  ?>
481
 
482
  <div class="wrap">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
483
 
484
- <h1><?php esc_html_e( 'Pirate Forms','pirate-forms' ); ?></h1>
485
-
486
-
487
- <div class="pirate-options">
488
- <ul class="pirate-forms-nav-tabs" role="tablist">
489
- <li role="presentation" class="active"><a href="#0" aria-controls="how_to_use" role="tab" data-toggle="tab"><?php esc_html_e( 'How to use','pirate-forms'); ?></a></li>
490
- <li role="presentation"><a href="#1" aria-controls="options" role="tab" data-toggle="tab"><?php esc_html_e( 'Options','pirate-forms'); ?></a></li>
491
- <li role="presentation"><a href="#2" aria-controls="fields" role="tab" data-toggle="tab"><?php esc_html_e( 'Fields Settings','pirate-forms'); ?></a></li>
492
- <li role="presentation"><a href="#3" aria-controls="labels" role="tab" data-toggle="tab"><?php esc_html_e( 'Fields Labels','pirate-forms'); ?></a></li>
493
- <li role="presentation"><a href="#4" aria-controls="messages" role="tab" data-toggle="tab"><?php esc_html_e( 'Alert Messages','pirate-forms'); ?></a></li>
494
- <li role="presentation"><a href="#5" aria-controls="smtp" role="tab" data-toggle="tab"><?php esc_html_e( 'SMTP','pirate-forms'); ?></a></li>
495
- </ul>
496
-
497
- <div class="pirate-forms-tab-content">
498
-
499
- <div id="0" class="pirate-forms-tab-pane active">
500
-
501
- <h2 class="pirate_forms_welcome_text"><?php esc_html_e( 'Welcome to Pirate Forms!','pirate-forms' ); ?></h2>
502
- <p class= "pirate_forms_subheading"><?php esc_html_e( 'To get started, just ','pirate-forms'); ?><b><?php esc_html_e( 'configure all the options ','pirate-forms'); ?></b><?php esc_html_e( 'you need, hit save and start using the created form.','pirate-forms' ); ?></p>
503
-
504
- <hr>
505
-
506
- <p><?php esc_html_e( 'There are 3 ways of using the newly created form:','pirate-forms' ); ?></p>
507
- <ol>
508
- <li><?php esc_html_e( 'Add a ','pirate-forms' ); ?><strong><a href="<?php echo admin_url( 'widgets.php' ); ?>"><?php esc_html_e( 'widget','pirate-forms' ); ?></a></strong></li>
509
- <li><?php esc_html_e( 'Use the shortcode ','pirate-forms' ); ?><strong><code>[pirate_forms]</code></strong><?php esc_html_e( ' in any page or post.','pirate-forms' ); ?></li>
510
- <li><?php esc_html_e( 'Use the shortcode ','pirate-forms' ); ?><strong><code>&lt;?php echo do_shortcode( '[pirate_forms]' ) ?&gt;</code></strong><?php esc_html_e( ' in the theme\'s files.','pirate-forms' ); ?></li>
511
- </ol>
512
-
513
- <hr>
514
-
515
- <div class="rate_plugin_invite">
516
-
517
- <h4><?php esc_html_e( 'Are you enjoying Pirate Forms?', 'pirate-forms' ); ?></h4>
518
-
519
- <p class="review-link"><?php echo sprintf( esc_html__( 'Rate our plugin on %sWordPress.org%s. We\'d really appreciate it!', 'pirate-forms' ), '<a href="https://wordpress.org/support/view/plugin-reviews/pirate-forms" target="_blank" rel="nofollow"> ', '</a>' ); ?></p>
520
-
521
- <p><span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span></p>
522
-
523
- <p><small><?php echo sprintf( esc_html__( 'If you want a more complex Contact Form Plugin please check %sthis link%s.', 'pirate-forms' ), '<a href="http://www.codeinwp.com/blog/best-contact-form-plugins-wordpress/" target="_blank" >', '</a>'); ?></small></p>
524
  </div>
525
 
526
-
527
- </div>
528
-
529
- <?php
530
-
531
- $pirate_forms_nr_tabs = 1;
532
-
533
- foreach ( $plugin_options as $plugin_options_tab ) :
534
-
535
- echo '<div id="'.$pirate_forms_nr_tabs.'" class="pirate-forms-tab-pane">';
536
-
537
  ?>
538
  <form method="post" class="pirate_forms_contact_settings">
539
 
540
  <?php
541
- $pirate_forms_nr_tabs++;
542
  foreach ( $plugin_options_tab as $key => $value ) :
543
-
544
  /* Label */
545
- if( !empty($value[0]) ):
546
  $opt_name = $value[0];
547
  endif;
548
-
549
  /* ID */
550
  $opt_id = $key;
551
-
552
  /* Description */
553
- if( !empty($value[1]) ):
554
  $opt_desc = $value[1];
555
- else:
556
  $opt_desc = '';
557
  endif;
558
-
559
  /* Input type */
560
- if( !empty($value[2]) ):
561
  $opt_type = $value[2];
562
- else:
563
  $opt_type = '';
564
  endif;
565
-
566
  /* Default value */
567
- if( !empty($value[3]) ):
568
  $opt_default = $value[3];
569
- else:
570
  $opt_default = '';
571
  endif;
572
-
573
  /* Value */
574
- $opt_val = isset( $pirate_forms_options[$opt_id] ) ? $pirate_forms_options[$opt_id] : $opt_default;
575
-
576
  /* Options if checkbox, select, or radio */
577
  $opt_options = empty( $value[4] ) ? array() : $value[4];
578
-
579
- switch ($opt_type) {
580
- case "title":
581
-
582
- if( !empty($opt_name) ):
583
- echo '<h3 class="title">'.$opt_name.'</h3><hr />';
584
  endif;
585
-
586
  break;
587
-
588
- case "text":
589
-
590
  /* Display recaptcha secret key and site key only if the Add a reCAPTCHA option is checked */
591
-
592
- $pirateformsopt_recaptcha_field = pirate_forms_get_key('pirateformsopt_recaptcha_field');
593
-
594
- if( !empty( $opt_id ) && (( $opt_id != 'pirateformsopt_recaptcha_sitekey' ) && ( $opt_id != 'pirateformsopt_recaptcha_secretkey' )) || (!empty($pirateformsopt_recaptcha_field) && ($pirateformsopt_recaptcha_field == 'yes') && (( $opt_id == 'pirateformsopt_recaptcha_sitekey' ) || ( $opt_id == 'pirateformsopt_recaptcha_secretkey' )) ) ) {
595
  $pirate_forms_is_hidden_class = '';
596
- }
597
- else {
598
  $pirate_forms_is_hidden_class = 'pirate-forms-hidden';
599
  }
600
  ?>
@@ -602,132 +562,115 @@ function pirate_forms_admin() {
602
  <div class="pirate-forms-grouped <?php echo $pirate_forms_is_hidden_class; ?>">
603
 
604
  <label for="<?php echo $opt_id ?>"><?php echo $opt_name;
 
 
 
605
 
606
- if ( ! empty( $opt_desc ) ) {
607
-
608
- if ( ( $opt_id == "pirateformsopt_email" ) || ( $opt_id == "pirateformsopt_email_recipients" ) || ( $opt_id == "pirateformsopt_confirm_email" ) ) {
609
-
610
- echo '<span class="dashicons dashicons-editor-help"></span>';
611
-
612
- }
613
-
614
- echo '<div class="pirate_forms_option_description">' . $opt_desc . '</div>';
615
- } ?>
616
 
617
  </label>
618
 
619
  <input name="<?php echo $opt_id; ?>" id="<?php echo $opt_id ?>"
620
- type="<?php echo $opt_type; ?>"
621
- value="<?php echo stripslashes( $opt_val ); ?>" class="widefat">
622
  </div>
623
 
624
  <?php
625
-
626
  break;
627
-
628
- case "textarea":
629
  ?>
630
 
631
  <div class="pirate-forms-grouped">
632
 
633
  <label for="<?php echo $opt_id ?>"><?php echo $opt_name;
 
 
 
634
 
635
- if(!empty($opt_desc)) {
636
-
637
- if( ($opt_id == "pirateformsopt_confirm_email") ) {
638
-
639
- echo '<span class="dashicons dashicons-editor-help"></span>';
640
-
641
- }
642
-
643
- echo '<div class="pirate_forms_option_description">'.$opt_desc.'</div>'; } ?>
644
 
645
  </label>
646
 
647
- <textarea name="<?php echo $opt_id; ?>" id="<?php echo $opt_id ?>" type="<?php echo $opt_type; ?>" rows="5" cols="30"><?php echo stripslashes( $opt_val ); ?></textarea>
 
 
648
  </div>
649
 
650
  <?php
651
  break;
652
-
653
- case "select":
654
  ?>
655
  <div class="pirate-forms-grouped">
656
 
657
  <label for="<?php echo $opt_id ?>"><?php echo $opt_name;
 
 
 
658
 
659
- if(!empty($opt_desc)) {
660
-
661
- if ( ( $opt_id == "pirateformsopt_thank_you_url" ) ) {
662
-
663
- echo '<span class="dashicons dashicons-editor-help"></span>';
664
-
665
- }
666
-
667
- echo '<div class="pirate_forms_option_description">'.$opt_desc.'</div>';
668
 
669
- } ?>
670
 
671
  </label>
672
 
673
  <select name="<?php echo $opt_id ?>" id="<?php echo $opt_id; ?>">
674
  <?php
675
  foreach ( $opt_options as $key => $val ) :
676
-
677
  $selected = '';
678
- if ( $opt_val == $key )
679
  $selected = 'selected';
 
680
  ?>
681
  <option value="<?php echo $key ?>" <?php echo $selected; ?>><?php echo $val; ?></option>
682
  <?php endforeach; ?>
683
  </select>
684
 
685
-
686
  </div>
687
 
688
- <?php
689
  break;
690
- case "checkbox":
691
-
692
  ?>
693
  <div class="pirate-forms-grouped">
694
 
695
  <label for="<?php echo $opt_id ?>"><?php echo $opt_name;
 
 
 
696
 
697
- if(!empty($opt_desc)) {
698
-
699
- if( ($opt_id == "pirateformsopt_store") || ($opt_id == "pirateformsopt_nonce") ) {
700
-
701
- echo '<span class="dashicons dashicons-editor-help"></span>';
702
-
703
- }
704
-
705
- echo '<div class="pirate_forms_option_description">'.$opt_desc.'</div>'; } ?>
706
 
707
  </label>
708
 
709
  <?php
 
 
 
 
 
710
 
711
- $checked = '';
712
- if( ($opt_val == 'yes') ) {
713
- $checked = 'checked';
714
- }
715
- ?>
716
-
717
- <input type="checkbox" value="yes" name="<?php echo $opt_id; ?>" id="<?php echo $opt_id; ?>" <?php echo $checked; ?>>Yes
718
 
719
  </div>
720
 
721
-
722
- <?php
723
  break;
724
  }
725
-
726
  endforeach;
727
  ?>
728
- <input name="save" type="submit" value="<?php _e( 'Save changes', 'pirate-forms' ) ?>" class="button-primary pirate-forms-save-button">
 
729
  <input type="hidden" name="action" value="save">
730
- <input type="hidden" name="proper_nonce" value="<?php echo wp_create_nonce( $current_user->user_email ) ?>">
 
731
 
732
  </form><!-- .pirate_forms_contact_settings -->
733
  <div class="ajaxAnimation"></div>
@@ -737,57 +680,70 @@ function pirate_forms_admin() {
737
 
738
  </div><!-- .pirate-forms-tab-content -->
739
  </div><!-- .pirate-options -->
740
-
 
741
  <div class="pirate-subscribe postbox card">
742
- <h3 class="title"><?php esc_html_e( 'Get Our Free Email Course', 'islemag' )?></h3>
743
  <div class="pirate-forms-subscribe-content">
744
  <?php
745
- if(!empty($_POST["pirate_forms_mail"])){
746
- require( PIRATE_FORMS_PATH . 'mailin.php' );
747
- $user_info = get_userdata(1);
748
- $mailin = new Mailin("https://api.sendinblue.com/v2.0","cHW5sxZnzE7mhaYb");
749
- $data = array( "email" => $_POST["pirate_forms_mail"],
750
- "attributes" => array("NAME"=>$user_info->first_name, "SURNAME"=>$user_info->last_name),
751
- "blacklisted" => 0,
752
- "listid" => array(51),
753
- "blacklisted_sms" => 0
754
- );
755
- $status = $mailin->create_update_user($data);
756
- if($status['code'] == 'success'){
757
- update_option( 'pirate_forms_subscribe', true);
758
- }
759
- }
760
- $was_submited = get_option( 'pirate_forms_subscribe', false);
761
- if( $was_submited == false ){
762
- echo sprintf( '<p> %s </p><form class="pirate-forms-submit-mail" method="post"><input name="pirate_forms_mail" type="email" value="'.get_option( 'admin_email' ) .'" /><input class="button" type="submit" value="Submit"></form>', esc_html__('Ready to learn how to reduce your website loading times by half? Come and join the 1st lesson here!', 'pirate-forms' ) );
763
- } else {
764
- echo sprintf( '<p> %s </p>', esc_html__( 'Thank you for subscribing! You have been added to the mailing list and will receive the next email information in the coming weeks. If you ever wish to unsubscribe, simply use the "Unsubscribe" link included in each newsletter.', 'pirate-forms' ) );
765
- } ?>
 
 
 
 
766
  </div>
767
  </div>
768
-
769
-
770
-
 
 
 
 
 
 
 
 
 
 
 
 
 
771
  </div><!-- .wrap -->
772
 
773
  <?php
774
  }
775
 
776
- /***********************************************************/
777
- /*********** Save default options if none exist ***********/
778
- /**********************************************************/
779
-
780
  function pirate_forms_settings_init() {
781
-
782
  if ( ! get_option( 'pirate_forms_settings_array' ) ) {
783
-
784
  $new_opt = array();
785
  foreach ( pirate_forms_plugin_options() as $temparr ) {
786
- foreach ($temparr as $key => $opt) {
787
- $new_opt[$key] = $opt[3];
788
  }
789
  }
790
-
791
  update_option( 'pirate_forms_settings_array', $new_opt );
792
 
793
  }
1
  <?php
2
  function pirate_forms_is_localhost() {
3
  $server_name = strtolower( $_SERVER['SERVER_NAME'] );
4
+
5
  return in_array( $server_name, array( 'localhost', '127.0.0.1' ) );
6
  }
 
7
 
8
+ function pirate_forms_from_email() {
9
  $admin_email = get_option( 'admin_email' );
10
+ $sitename = strtolower( $_SERVER['SERVER_NAME'] );
 
11
  if ( pirate_forms_is_localhost() ) {
12
  return $admin_email;
13
  }
 
14
  if ( substr( $sitename, 0, 4 ) == 'www.' ) {
15
  $sitename = substr( $sitename, 4 );
16
  }
 
17
  if ( strpbrk( $admin_email, '@' ) == '@' . $sitename ) {
18
  return $admin_email;
19
  }
23
 
24
  if ( ! function_exists( 'pirate_forms_get_pages_array' ) ) {
25
  function pirate_forms_get_pages_array( $type = 'page' ) {
 
26
  $content = array(
27
+ '' => __( 'None', 'pirate-forms' ),
28
  );
29
+ $items = get_posts( array(
 
30
  'post_type' => $type,
31
+ 'numberposts' => - 1,
32
  ) );
 
 
33
  if ( ! empty( $items ) ) :
34
  foreach ( $items as $item ) :
35
+ $content[ $item->ID ] = $item->post_title;
36
  endforeach;
37
  endif;
38
 
40
 
41
  }
42
  }
 
43
  /*
44
  *
45
  * OPTIONS
48
  *
49
  */
50
  function pirate_forms_plugin_options() {
51
+ /**
52
+ ********** Default values from Zerif Lite */
53
+ $zerif_contactus_sitekey = get_theme_mod( 'zerif_contactus_sitekey' );
54
+ if ( ! empty( $zerif_contactus_sitekey ) ) :
 
 
 
 
55
  $pirate_forms_contactus_sitekey = $zerif_contactus_sitekey;
56
+ else :
57
  $pirate_forms_contactus_sitekey = '';
58
  endif;
59
+ $zerif_contactus_secretkey = get_theme_mod( 'zerif_contactus_secretkey' );
60
+ if ( ! empty( $zerif_contactus_secretkey ) ) :
 
61
  $pirate_forms_contactus_secretkey = $zerif_contactus_secretkey;
62
+ else :
63
  $pirate_forms_contactus_secretkey = '';
64
  endif;
65
+ $zerif_contactus_recaptcha_show = get_theme_mod( 'zerif_contactus_recaptcha_show' );
66
+ if ( isset( $zerif_contactus_recaptcha_show ) && ( $zerif_contactus_recaptcha_show == '1' ) ) :
 
 
67
  $pirate_forms_contactus_recaptcha_show = '';
68
+ else :
69
  $pirate_forms_contactus_recaptcha_show = 'yes';
70
  endif;
71
+ $zerif_contactus_button_label = get_theme_mod( 'zerif_contactus_button_label', __( 'Send Message', 'pirate-forms' ) );
72
+ if ( ! empty( $zerif_contactus_button_label ) ) :
 
73
  $pirate_forms_contactus_button_label = $zerif_contactus_button_label;
74
+ else :
75
+ $pirate_forms_contactus_button_label = __( 'Send Message', 'pirate-forms' );
76
  endif;
77
+ $zerif_contactus_email = get_theme_mod( 'zerif_contactus_email' );
78
+ $zerif_email = get_theme_mod( 'zerif_email' );
 
 
79
  $pirate_forms_contactus_email = '';
80
+ if ( ! empty( $zerif_contactus_email ) ) :
81
  $pirate_forms_contactus_email = $zerif_contactus_email;
82
+ elseif ( ! empty( $zerif_email ) ) :
83
  $pirate_forms_contactus_email = $zerif_email;
84
+ else :
85
  $pirate_forms_contactus_email = get_bloginfo( 'admin_email' );
86
  endif;
87
 
88
  return array(
89
  'fourth_tab' => array(
90
+ 'header_options' => array(
91
+ __( 'Form processing options', 'pirate-forms' ),
92
  '',
93
  'title',
94
  '',
95
  ),
96
+ 'pirateformsopt_email' => array(
97
+ __( 'Contact notification sender email', 'pirate-forms' ),
98
+ '<strong>' . __( "Insert [email] to use the contact form submitter's email.", 'pirate-forms' ) . '</strong><br>' . __( "Email to use for the sender of the contact form emails both to the recipients below and the contact form submitter (if this is activated below). The domain for this email address should match your site's domain.", 'pirate-forms' ),
99
  'text',
100
+ pirate_forms_from_email(),
101
  ),
102
  'pirateformsopt_email_recipients' => array(
103
+ __( 'Contact submission recipients', 'pirate-forms' ),
104
+ __( 'Email address(es) to receive contact submission notifications. You can separate multiple emails with a comma.', 'pirate-forms' ),
105
  'text',
106
+ pirate_forms_get_key( 'pirateformsopt_email' ) ? pirate_forms_get_key( 'pirateformsopt_email' ) : $pirate_forms_contactus_email,
107
  ),
108
+ 'pirateformsopt_store' => array(
109
+ __( 'Store submissions in the database', 'pirate-forms' ),
110
+ __( 'Should the submissions be stored in the admin area? If chosen, contact form submissions will be saved in Contacts on the left (appears after this option is activated).', 'pirate-forms' ),
111
  'checkbox',
112
  'yes',
113
  ),
114
+ 'pirateformsopt_nonce' => array(
115
+ __( 'Add a nonce to the contact form:', 'pirate-forms' ),
116
+ __( 'Should the form use a WordPress nonce? This helps reduce spam by ensuring that the form submittor is on the site when submitting the form rather than submitting remotely. This could, however, cause problems with sites using a page caching plugin. Turn this off if you are getting complaints about forms not being able to be submitted with an error of "Nonce failed!"', 'pirate-forms' ),
117
  'checkbox',
118
  'yes',
119
  ),
120
+ 'pirateformsopt_confirm_email' => array(
121
+ __( 'Send email confirmation to form submitter', 'pirate-forms' ),
122
+ __( 'Adding text here will send an email to the form submitter. The email uses the "Successful form submission text" field from the "Alert Messages" tab as the subject line. Plain text only here, no HTML.', 'pirate-forms' ),
123
  'textarea',
124
  '',
125
  ),
126
+ 'pirateformsopt_thank_you_url' => array(
127
+ __( '"Thank You" URL', 'pirate-forms' ),
128
+ __( 'Select the post-submit page for all forms submitted', 'pirate-forms' ),
129
  'select',
130
  '',
131
+ pirate_forms_get_pages_array(),
132
+ ),
133
  ),
134
+ 'first_tab' => array(
135
+ 'header_fields' => array(
136
+ __( 'Fields Settings', 'pirate-forms' ),
137
  '',
138
  'title',
139
  '',
140
  ),
141
  /* Name */
142
+ 'pirateformsopt_name_field' => array(
143
+ __( 'Name', 'pirate-forms' ),
144
+ __( 'Do you want the name field to be displayed?', 'pirate-forms' ),
145
  'select',
146
  'req',
147
  array(
148
+ '' => __( 'None', 'pirate-forms' ),
149
+ 'yes' => __( 'Yes but not required', 'pirate-forms' ),
150
+ 'req' => __( 'Required', 'pirate-forms' ),
151
  ),
152
  ),
153
  /* Email */
154
+ 'pirateformsopt_email_field' => array(
155
+ __( 'Email address', 'pirate-forms' ),
156
+ __( 'Do you want the email address field be displayed?', 'pirate-forms' ),
157
  'select',
158
  'req',
159
  array(
160
+ '' => __( 'None', 'pirate-forms' ),
161
+ 'yes' => __( 'Yes but not required', 'pirate-forms' ),
162
+ 'req' => __( 'Required', 'pirate-forms' ),
163
  ),
164
  ),
165
  /* Subject */
166
+ 'pirateformsopt_subject_field' => array(
167
+ __( 'Subject', 'pirate-forms' ),
168
+ __( 'Do you want the subject field be displayed?', 'pirate-forms' ),
169
  'select',
170
  'req',
171
  array(
172
+ '' => __( 'None', 'pirate-forms' ),
173
+ 'yes' => __( 'Yes but not required', 'pirate-forms' ),
174
+ 'req' => __( 'Required', 'pirate-forms' ),
175
  ),
176
  ),
177
  /* Message */
178
+ 'pirateformsopt_message_field' => array(
179
+ __( 'Message', 'pirate-forms' ),
180
  '',
181
  'select',
182
  'req',
183
  array(
184
+ '' => __( 'None', 'pirate-forms' ),
185
+ 'yes' => __( 'Yes but not required', 'pirate-forms' ),
186
+ 'req' => __( 'Required', 'pirate-forms' ),
187
  ),
188
  ),
189
  /* Recaptcha */
190
+ 'pirateformsopt_recaptcha_field' => array(
191
+ __( 'Add a reCAPTCHA', 'pirate-forms' ),
192
  '',
193
  'checkbox',
194
  $pirate_forms_contactus_recaptcha_show,
195
  ),
196
  /* Site key */
197
+ 'pirateformsopt_recaptcha_sitekey' => array(
198
+ __( 'Site key', 'pirate-forms' ),
199
+ '<a href="https://www.google.com/recaptcha/admin#list" target="_blank">' . __( 'Create an account here ', 'pirate-forms' ) . '</a>' . __( 'to get the Site key and the Secret key for the reCaptcha.', 'pirate-forms' ),
200
  'text',
201
  $pirate_forms_contactus_sitekey,
202
  ),
203
  /* Secret key */
204
  'pirateformsopt_recaptcha_secretkey' => array(
205
+ __( 'Secret key', 'pirate-forms' ),
206
  '',
207
  'text',
208
  $pirate_forms_contactus_secretkey,
209
  ),
210
  /* Attachment */
211
+ 'pirateformsopt_attachment_field' => array(
212
+ __( 'Add an attachment field', 'pirate-forms' ),
213
  '',
214
  'checkbox',
215
  '',
216
  ),
 
217
  ),
218
  'second_tab' => array(
219
+ 'header_labels' => array(
220
+ __( 'Fields Labels', 'pirate-forms' ),
221
  '',
222
  'title',
223
  '',
224
  ),
225
+ 'pirateformsopt_label_name' => array(
226
+ __( 'Name', 'pirate-forms' ),
227
  '',
228
  'text',
229
+ __( 'Your Name', 'pirate-forms' ),
230
  ),
231
+ 'pirateformsopt_label_email' => array(
232
+ __( 'Email', 'pirate-forms' ),
233
  '',
234
  'text',
235
+ __( 'Your Email', 'pirate-forms' ),
236
  ),
237
+ 'pirateformsopt_label_subject' => array(
238
+ __( 'Subject', 'pirate-forms' ),
239
  '',
240
  'text',
241
+ __( 'Subject', 'pirate-forms' ),
242
  ),
243
+ 'pirateformsopt_label_message' => array(
244
+ __( 'Message', 'pirate-forms' ),
245
  '',
246
  'text',
247
+ __( 'Your message', 'pirate-forms' ),
248
  ),
249
  'pirateformsopt_label_submit_btn' => array(
250
+ __( 'Submit button', 'pirate-forms' ),
251
  '',
252
  'text',
253
+ $pirate_forms_contactus_button_label,
254
+ ),
255
  ),
256
+ 'third_tab' => array(
257
+ 'header_messages' => array(
258
+ __( 'Alert Messages', 'pirate-forms' ),
259
  '',
260
  'title',
261
  '',
262
  ),
263
+ 'pirateformsopt_label_err_name' => array(
264
+ __( 'Name required and missing', 'pirate-forms' ),
265
  '',
266
  'text',
267
+ __( 'Enter your name', 'pirate-forms' ),
268
  ),
269
+ 'pirateformsopt_label_err_email' => array(
270
+ __( 'E-mail required and missing', 'pirate-forms' ),
271
  '',
272
  'text',
273
+ __( 'Enter a valid email', 'pirate-forms' ),
274
  ),
275
+ 'pirateformsopt_label_err_subject' => array(
276
+ __( 'Subject required and missing', 'pirate-forms' ),
277
  '',
278
  'text',
279
+ __( 'Please enter a subject', 'pirate-forms' ),
280
  ),
281
  'pirateformsopt_label_err_no_content' => array(
282
+ __( 'Question/comment is missing', 'pirate-forms' ),
283
  '',
284
  'text',
285
+ __( 'Enter your question or comment', 'pirate-forms' ),
286
  ),
287
+ 'pirateformsopt_label_submit' => array(
288
+ __( 'Successful form submission text', 'pirate-forms' ),
289
+ __( 'This text is used on the page if no "Thank You" URL is set above. This is also used as the confirmation email title, if one is set to send out.', 'pirate-forms' ),
290
  'text',
291
+ __( 'Thanks, your email was sent successfully!', 'pirate-forms' ),
292
+ ),
293
  ),
294
+ 'fifth_tab' => array(
295
+ 'header_smtp' => array(
296
+ __( 'SMTP Options', 'pirate-forms' ),
297
  '',
298
  'title',
299
  '',
300
  ),
301
+ 'pirateformsopt_use_smtp' => array(
302
+ __( 'Use SMTP to send emails?', 'pirate-forms' ),
303
+ __( 'Instead of PHP mail function', 'pirate-forms' ),
304
  'checkbox',
305
  '',
306
  ),
307
+ 'pirateformsopt_smtp_host' => array(
308
+ __( 'SMTP Host', 'pirate-forms' ),
309
  '',
310
  'text',
311
  '',
312
  ),
313
+ 'pirateformsopt_smtp_port' => array(
314
+ __( 'SMTP Port', 'pirate-forms' ),
315
  '',
316
  'text',
317
  '',
318
  ),
319
  'pirateformsopt_use_smtp_authentication' => array(
320
+ __( 'Use SMTP Authentication?', 'pirate-forms' ),
321
+ __( 'If you check this box, make sure the SMTP Username and SMTP Password are completed.', 'pirate-forms' ),
322
  'checkbox',
323
  'yes',
324
  ),
325
+ 'pirateformsopt_smtp_username' => array(
326
+ __( 'SMTP Username', 'pirate-forms' ),
327
  '',
328
  'text',
329
  '',
330
  ),
331
+ 'pirateformsopt_smtp_password' => array(
332
+ __( 'SMTP Password', 'pirate-forms' ),
333
  '',
334
  'text',
335
  '',
336
+ ),
337
+ ),
338
  );
339
  }
340
 
344
  * @since 1.0.0
345
  */
346
  function pirate_forms_add_to_admin() {
 
347
  add_submenu_page(
348
  'options-general.php',
349
  __( 'Pirate Forms settings', 'pirate-forms' ),
350
  __( 'Pirate Forms', 'pirate-forms' ),
351
  'manage_options',
352
  'pirate-forms-admin',
353
+ 'pirate_forms_admin' );
354
 
355
  }
 
356
 
357
+ add_action( 'admin_menu', 'pirate_forms_add_to_admin' );
358
  /*
359
  *
360
  * Save forms via Ajax
361
  * @since 1.0.0
362
  *
363
  */
364
+ add_action( 'wp_ajax_pirate_forms_save', 'pirate_forms_save_callback' );
365
+ add_action( 'wp_ajax_nopriv_pirate_forms_save', 'pirate_forms_save_callback' );
 
366
  function pirate_forms_save_callback() {
367
+ if ( isset( $_POST['dataSent'] ) ) :
 
368
  $dataSent = $_POST['dataSent'];
369
+ $params = array();
370
+ if ( ! empty( $dataSent ) ) :
 
 
371
  parse_str( $dataSent, $params );
372
  endif;
373
+ if ( ! empty( $params ) ) :
374
+ /**
375
+ ****** Important fix for saving inputs of type checkbox */
376
+ if ( ! isset( $params['pirateformsopt_store'] ) ) {
 
 
 
 
377
  $params['pirateformsopt_store'] = '';
378
  }
379
+ if ( ! isset( $params['pirateformsopt_recaptcha_field'] ) ) {
380
  $params['pirateformsopt_recaptcha_field'] = '';
381
  }
382
+ if ( ! isset( $params['pirateformsopt_nonce'] ) ) {
383
  $params['pirateformsopt_nonce'] = '';
384
  }
385
+ if ( ! isset( $params['pirateformsopt_attachment_field'] ) ) {
386
  $params['pirateformsopt_attachment_field'] = '';
387
  }
388
+ if ( ! isset( $params['pirateformsopt_use_smtp'] ) ) {
389
  $params['pirateformsopt_use_smtp'] = '';
390
  }
391
+ if ( ! isset( $params['pirateformsopt_use_smtp_authentication'] ) ) {
392
  $params['pirateformsopt_use_smtp_authentication'] = '';
393
  }
 
394
  update_option( 'pirate_forms_settings_array', $params );
395
+ $pirate_forms_zerif_lite_mods = get_option( 'theme_mods_zerif-lite' );
396
+ if ( empty( $pirate_forms_zerif_lite_mods ) ) :
 
 
397
  $pirate_forms_zerif_lite_mods = array();
398
  endif;
399
+ if ( isset( $params['pirateformsopt_label_submit_btn'] ) ) :
400
+ $pirate_forms_zerif_lite_mods['zerif_contactus_button_label'] = $params['pirateformsopt_label_submit_btn'];
401
+ endif;
402
+ if ( isset( $params['pirateformsopt_email'] ) ) :
403
+ $pirate_forms_zerif_lite_mods['zerif_contactus_email'] = $params['pirateformsopt_email'];
404
+ endif;
405
+ if ( isset( $params['pirateformsopt_email_recipients'] ) ) :
406
+ $pirate_forms_zerif_lite_mods['zerif_contactus_email'] = $params['pirateformsopt_email_recipients'];
407
+ endif;
408
+ if ( isset( $params['pirateformsopt_recaptcha_field'] ) && ( $params['pirateformsopt_recaptcha_field'] == 'yes' ) ) :
409
+ $pirate_forms_zerif_lite_mods['zerif_contactus_recaptcha_show'] = 0;
410
+ else :
411
+ $pirate_forms_zerif_lite_mods['zerif_contactus_recaptcha_show'] = 1;
412
+ endif;
413
+ if ( isset( $params['pirateformsopt_recaptcha_sitekey'] ) ) :
414
+ $pirate_forms_zerif_lite_mods['zerif_contactus_sitekey'] = $params['pirateformsopt_recaptcha_sitekey'];
415
+ endif;
416
+ if ( isset( $params['pirateformsopt_recaptcha_secretkey'] ) ) :
417
+ $pirate_forms_zerif_lite_mods['zerif_contactus_secretkey'] = $params['pirateformsopt_recaptcha_secretkey'];
418
+ endif;
419
+ update_option( 'theme_mods_zerif-lite', $pirate_forms_zerif_lite_mods );
 
 
 
 
 
 
 
 
 
 
420
  endif;
 
421
  endif;
 
422
  die();
423
 
424
  }
429
  *
430
  */
431
  function pirate_forms_admin() {
 
432
  global $current_user;
 
433
  $pirate_forms_options = get_option( 'pirate_forms_settings_array' );
434
+ $plugin_options = pirate_forms_plugin_options();
 
435
  ?>
436
 
437
  <div class="wrap">
438
+ <div id="pirate-forms-main">
439
+ <h1><?php esc_html_e( 'Pirate Forms', 'pirate-forms' ); ?></h1>
440
+
441
+ <div class="pirate-options">
442
+ <ul class="pirate-forms-nav-tabs" role="tablist">
443
+ <li role="presentation" class="active"><a href="#0" aria-controls="how_to_use" role="tab"
444
+ data-toggle="tab"><?php esc_html_e( 'How to use', 'pirate-forms' ); ?></a>
445
+ </li>
446
+ <li role="presentation"><a href="#1" aria-controls="options" role="tab"
447
+ data-toggle="tab"><?php esc_html_e( 'Options', 'pirate-forms' ); ?></a>
448
+ </li>
449
+ <li role="presentation"><a href="#2" aria-controls="fields" role="tab"
450
+ data-toggle="tab"><?php esc_html_e( 'Fields Settings', 'pirate-forms' ); ?></a>
451
+ </li>
452
+ <li role="presentation"><a href="#3" aria-controls="labels" role="tab"
453
+ data-toggle="tab"><?php esc_html_e( 'Fields Labels', 'pirate-forms' ); ?></a>
454
+ </li>
455
+ <li role="presentation"><a href="#4" aria-controls="messages" role="tab"
456
+ data-toggle="tab"><?php esc_html_e( 'Alert Messages', 'pirate-forms' ); ?></a>
457
+ </li>
458
+ <li role="presentation"><a href="#5" aria-controls="smtp" role="tab"
459
+ data-toggle="tab"><?php esc_html_e( 'SMTP', 'pirate-forms' ); ?></a></li>
460
+ </ul>
461
+
462
+ <div class="pirate-forms-tab-content">
463
+
464
+ <div id="0" class="pirate-forms-tab-pane active">
465
+
466
+ <h2 class="pirate_forms_welcome_text"><?php esc_html_e( 'Welcome to Pirate Forms!', 'pirate-forms' ); ?></h2>
467
+ <p class="pirate_forms_subheading"><?php esc_html_e( 'To get started, just ', 'pirate-forms' ); ?>
468
+ <b><?php esc_html_e( 'configure all the options ', 'pirate-forms' ); ?></b><?php esc_html_e( 'you need, hit save and start using the created form.', 'pirate-forms' ); ?>
469
+ </p>
470
+
471
+ <hr>
472
+
473
+ <p><?php esc_html_e( 'There are 3 ways of using the newly created form:', 'pirate-forms' ); ?></p>
474
+ <ol>
475
+ <li><?php esc_html_e( 'Add a ', 'pirate-forms' ); ?><strong><a
476
+ href="<?php echo admin_url( 'widgets.php' ); ?>"><?php esc_html_e( 'widget', 'pirate-forms' ); ?></a></strong>
477
+ </li>
478
+ <li><?php esc_html_e( 'Use the shortcode ', 'pirate-forms' ); ?>
479
+ <strong><code>[pirate_forms]</code></strong><?php esc_html_e( ' in any page or post.', 'pirate-forms' ); ?>
480
+ </li>
481
+ <li><?php esc_html_e( 'Use the shortcode ', 'pirate-forms' ); ?><strong><code>&lt;?php echo
482
+ do_shortcode( '[pirate_forms]' )
483
+ ?&gt;</code></strong><?php esc_html_e( ' in the theme\'s files.', 'pirate-forms' ); ?>
484
+ </li>
485
+ </ol>
486
+
487
+ <hr>
488
+
489
+ <div class="rate_plugin_invite">
490
+
491
+ <h4><?php esc_html_e( 'Are you enjoying Pirate Forms?', 'pirate-forms' ); ?></h4>
492
+
493
+ <p class="review-link"><?php echo sprintf( esc_html__( 'Rate our plugin on %1$s WordPress.org %2$s. We\'d really appreciate it!', 'pirate-forms' ), '<a href="https://wordpress.org/support/view/plugin-reviews/pirate-forms" target="_blank" rel="nofollow"> ', '</a>' ); ?></p>
494
+
495
+ <p><span class="dashicons dashicons-star-filled"></span><span
496
+ class="dashicons dashicons-star-filled"></span><span
497
+ class="dashicons dashicons-star-filled"></span><span
498
+ class="dashicons dashicons-star-filled"></span><span
499
+ class="dashicons dashicons-star-filled"></span></p>
500
+
501
+ <p>
502
+ <small><?php echo sprintf( esc_html__( 'If you want a more complex Contact Form Plugin please check %1$s this link %2$s.', 'pirate-forms' ), '<a href="http://www.codeinwp.com/blog/best-contact-form-plugins-wordpress/" target="_blank" >', '</a>' ); ?></small>
503
+ </p>
504
+ </div>
505
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
506
  </div>
507
 
508
+ <?php
509
+ $pirate_forms_nr_tabs = 1;
510
+ foreach ( $plugin_options as $plugin_options_tab ) :
511
+ echo '<div id="' . $pirate_forms_nr_tabs . '" class="pirate-forms-tab-pane">';
 
 
 
 
 
 
 
512
  ?>
513
  <form method="post" class="pirate_forms_contact_settings">
514
 
515
  <?php
516
+ $pirate_forms_nr_tabs ++;
517
  foreach ( $plugin_options_tab as $key => $value ) :
 
518
  /* Label */
519
+ if ( ! empty( $value[0] ) ) :
520
  $opt_name = $value[0];
521
  endif;
 
522
  /* ID */
523
  $opt_id = $key;
 
524
  /* Description */
525
+ if ( ! empty( $value[1] ) ) :
526
  $opt_desc = $value[1];
527
+ else :
528
  $opt_desc = '';
529
  endif;
 
530
  /* Input type */
531
+ if ( ! empty( $value[2] ) ) :
532
  $opt_type = $value[2];
533
+ else :
534
  $opt_type = '';
535
  endif;
 
536
  /* Default value */
537
+ if ( ! empty( $value[3] ) ) :
538
  $opt_default = $value[3];
539
+ else :
540
  $opt_default = '';
541
  endif;
 
542
  /* Value */
543
+ $opt_val = isset( $pirate_forms_options[ $opt_id ] ) ? $pirate_forms_options[ $opt_id ] : $opt_default;
 
544
  /* Options if checkbox, select, or radio */
545
  $opt_options = empty( $value[4] ) ? array() : $value[4];
546
+ switch ( $opt_type ) {
547
+ case 'title':
548
+ if ( ! empty( $opt_name ) ) :
549
+ echo '<h3 class="title">' . $opt_name . '</h3><hr />';
 
 
550
  endif;
 
551
  break;
552
+ case 'text':
 
 
553
  /* Display recaptcha secret key and site key only if the Add a reCAPTCHA option is checked */
554
+ $pirateformsopt_recaptcha_field = pirate_forms_get_key( 'pirateformsopt_recaptcha_field' );
555
+ if ( ! empty( $opt_id ) && ( ( $opt_id != 'pirateformsopt_recaptcha_sitekey' ) && ( $opt_id != 'pirateformsopt_recaptcha_secretkey' ) ) || ( ! empty( $pirateformsopt_recaptcha_field ) && ( $pirateformsopt_recaptcha_field == 'yes' ) && ( ( $opt_id == 'pirateformsopt_recaptcha_sitekey' ) || ( $opt_id == 'pirateformsopt_recaptcha_secretkey' ) ) ) ) {
 
 
556
  $pirate_forms_is_hidden_class = '';
557
+ } else {
 
558
  $pirate_forms_is_hidden_class = 'pirate-forms-hidden';
559
  }
560
  ?>
562
  <div class="pirate-forms-grouped <?php echo $pirate_forms_is_hidden_class; ?>">
563
 
564
  <label for="<?php echo $opt_id ?>"><?php echo $opt_name;
565
+ if ( ! empty( $opt_desc ) ) {
566
+ if ( ( $opt_id == 'pirateformsopt_email' ) || ( $opt_id == 'pirateformsopt_email_recipients' ) || ( $opt_id == 'pirateformsopt_confirm_email' ) ) {
567
+ echo '<span class="dashicons dashicons-editor-help"></span>';
568
 
569
+ }
570
+ echo '<div class="pirate_forms_option_description">' . $opt_desc . '</div>';
571
+ } ?>
 
 
 
 
 
 
 
572
 
573
  </label>
574
 
575
  <input name="<?php echo $opt_id; ?>" id="<?php echo $opt_id ?>"
576
+ type="<?php echo $opt_type; ?>"
577
+ value="<?php echo stripslashes( $opt_val ); ?>" class="widefat">
578
  </div>
579
 
580
  <?php
 
581
  break;
582
+ case 'textarea':
 
583
  ?>
584
 
585
  <div class="pirate-forms-grouped">
586
 
587
  <label for="<?php echo $opt_id ?>"><?php echo $opt_name;
588
+ if ( ! empty( $opt_desc ) ) {
589
+ if ( ( $opt_id == 'pirateformsopt_confirm_email' ) ) {
590
+ echo '<span class="dashicons dashicons-editor-help"></span>';
591
 
592
+ }
593
+ echo '<div class="pirate_forms_option_description">' . $opt_desc . '</div>';
594
+ } ?>
 
 
 
 
 
 
595
 
596
  </label>
597
 
598
+ <textarea name="<?php echo $opt_id; ?>" id="<?php echo $opt_id ?>"
599
+ type="<?php echo $opt_type; ?>" rows="5"
600
+ cols="30"><?php echo stripslashes( $opt_val ); ?></textarea>
601
  </div>
602
 
603
  <?php
604
  break;
605
+ case 'select':
 
606
  ?>
607
  <div class="pirate-forms-grouped">
608
 
609
  <label for="<?php echo $opt_id ?>"><?php echo $opt_name;
610
+ if ( ! empty( $opt_desc ) ) {
611
+ if ( ( $opt_id == 'pirateformsopt_thank_you_url' ) ) {
612
+ echo '<span class="dashicons dashicons-editor-help"></span>';
613
 
614
+ }
615
+ echo '<div class="pirate_forms_option_description">' . $opt_desc . '</div>';
 
 
 
 
 
 
 
616
 
617
+ } ?>
618
 
619
  </label>
620
 
621
  <select name="<?php echo $opt_id ?>" id="<?php echo $opt_id; ?>">
622
  <?php
623
  foreach ( $opt_options as $key => $val ) :
 
624
  $selected = '';
625
+ if ( $opt_val == $key ) {
626
  $selected = 'selected';
627
+ }
628
  ?>
629
  <option value="<?php echo $key ?>" <?php echo $selected; ?>><?php echo $val; ?></option>
630
  <?php endforeach; ?>
631
  </select>
632
 
 
633
  </div>
634
 
635
+ <?php
636
  break;
637
+ case 'checkbox':
 
638
  ?>
639
  <div class="pirate-forms-grouped">
640
 
641
  <label for="<?php echo $opt_id ?>"><?php echo $opt_name;
642
+ if ( ! empty( $opt_desc ) ) {
643
+ if ( ( $opt_id == 'pirateformsopt_store' ) || ( $opt_id == 'pirateformsopt_nonce' ) ) {
644
+ echo '<span class="dashicons dashicons-editor-help"></span>';
645
 
646
+ }
647
+ echo '<div class="pirate_forms_option_description">' . $opt_desc . '</div>';
648
+ } ?>
 
 
 
 
 
 
649
 
650
  </label>
651
 
652
  <?php
653
+ $checked = '';
654
+ if ( ( $opt_val == 'yes' ) ) {
655
+ $checked = 'checked';
656
+ }
657
+ ?>
658
 
659
+ <input type="checkbox" value="yes" name="<?php echo $opt_id; ?>"
660
+ id="<?php echo $opt_id; ?>" <?php echo $checked; ?>>Yes
 
 
 
 
 
661
 
662
  </div>
663
 
664
+ <?php
 
665
  break;
666
  }
 
667
  endforeach;
668
  ?>
669
+ <input name="save" type="submit" value="<?php _e( 'Save changes', 'pirate-forms' ) ?>"
670
+ class="button-primary pirate-forms-save-button">
671
  <input type="hidden" name="action" value="save">
672
+ <input type="hidden" name="proper_nonce"
673
+ value="<?php echo wp_create_nonce( $current_user->user_email ) ?>">
674
 
675
  </form><!-- .pirate_forms_contact_settings -->
676
  <div class="ajaxAnimation"></div>
680
 
681
  </div><!-- .pirate-forms-tab-content -->
682
  </div><!-- .pirate-options -->
683
+ </div><!-- .pirate-options -->
684
+ <div id="pirate-forms-sidebar">
685
  <div class="pirate-subscribe postbox card">
686
+ <h3 class="title"><?php esc_html_e( 'Get Our Free Email Course', 'pirate-forms' ) ?></h3>
687
  <div class="pirate-forms-subscribe-content">
688
  <?php
689
+ if ( ! empty( $_POST['pirate_forms_mail'] ) ) {
690
+ require( PIRATE_FORMS_PATH . 'mailin.php' );
691
+ $user_info = get_userdata( 1 );
692
+ $mailin = new Mailin( 'https://api.sendinblue.com/v2.0', 'cHW5sxZnzE7mhaYb' );
693
+ $data = array(
694
+ 'email' => $_POST['pirate_forms_mail'],
695
+ 'attributes' => array(
696
+ 'NAME' => $user_info->first_name,
697
+ 'SURNAME' => $user_info->last_name,
698
+ ),
699
+ 'blacklisted' => 0,
700
+ 'listid' => array( 51 ),
701
+ 'blacklisted_sms' => 0,
702
+ );
703
+ $status = $mailin->create_update_user( $data );
704
+ if ( $status['code'] == 'success' ) {
705
+ update_option( 'pirate_forms_subscribe', true );
706
+ }
707
+ }
708
+ $was_submited = get_option( 'pirate_forms_subscribe', false );
709
+ if ( $was_submited == false ) {
710
+ echo sprintf( '<p> %s </p><form class="pirate-forms-submit-mail" method="post"><input name="pirate_forms_mail" type="email" value="' . get_option( 'admin_email' ) . '" /><input class="button" type="submit" value="Submit"></form>', esc_html__( 'Ready to learn how to reduce your website loading times by half? Come and join the 1st lesson here!', 'pirate-forms' ) );
711
+ } else {
712
+ echo sprintf( '<p> %s </p>', esc_html__( 'Thank you for subscribing! You have been added to the mailing list and will receive the next email information in the coming weeks. If you ever wish to unsubscribe, simply use the "Unsubscribe" link included in each newsletter.', 'pirate-forms' ) );
713
+ } ?>
714
  </div>
715
  </div>
716
+ <?php
717
+ if ( ! class_exists( 'Dev7CustomEmails' ) ) {
718
+ ?>
719
+ <div class="pirate-custom-emails postbox card">
720
+ <h3 class="title"><?php esc_html_e( 'Control Emails in WordPress', 'pirate-forms' ) ?></h3>
721
+ <div class="pirate-forms-custom-emails-content">
722
+ Change default WordPress email templates using <strong>Custom Emails</strong> plugin
723
+ <a href="https://themeisle.com/plugins/custom-emails-wordpress-plugin/" target="_blank">View more
724
+ details</a>
725
+ </div>
726
+ </div>
727
+ <?php
728
+ }
729
+ ?>
730
+ </div>
731
+ <div class="clear"></div>
732
  </div><!-- .wrap -->
733
 
734
  <?php
735
  }
736
 
737
+ /**
738
+ * ******** Save default options if none exist ***********/
 
 
739
  function pirate_forms_settings_init() {
 
740
  if ( ! get_option( 'pirate_forms_settings_array' ) ) {
 
741
  $new_opt = array();
742
  foreach ( pirate_forms_plugin_options() as $temparr ) {
743
+ foreach ( $temparr as $key => $opt ) {
744
+ $new_opt[ $key ] = $opt[3];
745
  }
746
  }
 
747
  update_option( 'pirate_forms_settings_array', $new_opt );
748
 
749
  }
inc/widget.php CHANGED
@@ -1,10 +1,13 @@
1
  <?php
 
2
  /**
3
  * Template for new WordPress widget
4
  *
5
  * @see WP_Widget::widget()
6
  */
 
7
  class pirate_forms_contact_widget extends WP_Widget {
 
8
 
9
  /**
10
  * Widget constructor
@@ -13,7 +16,7 @@ class pirate_forms_contact_widget extends WP_Widget {
13
  parent::__construct(
14
  'pirate_forms_contact_widget',
15
  __( 'Pirate Forms', 'pirate-forms' ),
16
- array( 'classname' => __FUNCTION__, 'description' => __( 'Pirate Forms','pirate-forms') )
17
  );
18
  }
19
 
@@ -24,25 +27,28 @@ class pirate_forms_contact_widget extends WP_Widget {
24
  * @param array $instance
25
  */
26
  function widget( $args, $instance ) {
27
-
28
  // Pulling out all settings
29
- extract( $args );
30
- extract( $instance );
31
-
 
 
 
 
 
 
 
32
  // Output all wrappers
33
- echo $before_widget . '<div class="pirate-forms-contact-widget">';
34
-
35
- if ( ! empty( $pirate_forms_widget_title ) )
36
- echo $before_title . $pirate_forms_widget_title . $after_title;
37
-
38
- if ( ! empty( $pirate_forms_widget_subtext ) )
39
- echo wpautop( stripslashes( $pirate_forms_widget_subtext ) );
40
-
41
- echo do_shortcode('[pirate_forms]');
42
-
43
- echo '<div class="pirate_forms_clearfix"></div>';
44
-
45
- echo '</div>' . $after_widget;
46
 
47
  }
48
 
@@ -56,10 +62,8 @@ class pirate_forms_contact_widget extends WP_Widget {
56
  */
57
  function update( $new_instance, $old_instance ) {
58
  $instance = $old_instance;
59
-
60
  // Storing widget title as inputted option or category name
61
- $instance['pirate_forms_widget_title'] = apply_filters( 'widget_title', sanitize_text_field( $new_instance['pirate_forms_widget_title'] ) );
62
-
63
  $instance['pirate_forms_widget_subtext'] = $new_instance['pirate_forms_widget_subtext'];
64
 
65
  return $instance;
@@ -73,21 +77,23 @@ class pirate_forms_contact_widget extends WP_Widget {
73
  * @return string|void
74
  */
75
  function form( $instance ) {
76
-
77
- $pirate_forms_widget_title = ! empty( $instance['pirate_forms_widget_title'] ) ? $instance['pirate_forms_widget_title'] : __( 'Title','pirate-forms' );
78
- $pirate_forms_widget_subtext = ! empty( $instance['pirate_forms_widget_subtext'] ) ? $instance['pirate_forms_widget_subtext'] : __( 'Text above form','pirate-forms' );
79
  ?>
80
  <p>
81
- <label for="<?php echo $this->get_field_id( 'pirate_forms_widget_title' ); ?>"><?php _e( 'Title:' ); ?></label>
82
- <input class="widefat" id="<?php echo $this->get_field_id( 'pirate_forms_widget_title' ); ?>" name="<?php echo $this->get_field_name( 'pirate_forms_widget_title' ); ?>" type="text" value="<?php echo esc_attr( $pirate_forms_widget_title ); ?>">
 
 
83
  </p>
84
  <p>
85
- <label for="<?php echo $this->get_field_id( 'pirate_forms_widget_subtext' ); ?>"><?php _e( 'Subtext:' ); ?></label>
86
- <textarea class="widefat" id="<?php echo $this->get_field_id( 'pirate_forms_widget_subtext' ); ?>" name="<?php echo $this->get_field_name( 'pirate_forms_widget_subtext' ); ?>"><?php echo esc_attr( $pirate_forms_widget_subtext ); ?></textarea>
 
87
  </p>
88
  <?php
89
 
90
  }
91
  }
92
 
93
- add_action( 'widgets_init', create_function( '', 'return register_widget("pirate_forms_contact_widget");' ) );
1
  <?php
2
+
3
  /**
4
  * Template for new WordPress widget
5
  *
6
  * @see WP_Widget::widget()
7
  */
8
+ // @codingStandardsIgnoreStart
9
  class pirate_forms_contact_widget extends WP_Widget {
10
+ // @codingStandardsIgnoreEnd
11
 
12
  /**
13
  * Widget constructor
16
  parent::__construct(
17
  'pirate_forms_contact_widget',
18
  __( 'Pirate Forms', 'pirate-forms' ),
19
+ array( 'classname' => __FUNCTION__, 'description' => __( 'Pirate Forms', 'pirate-forms' ) )
20
  );
21
  }
22
 
27
  * @param array $instance
28
  */
29
  function widget( $args, $instance ) {
 
30
  // Pulling out all settings
31
+ $args = wp_parse_args( $args, array(
32
+ 'before_widget' => '',
33
+ 'after_widget' => '',
34
+ 'before_title' => '',
35
+ 'after_title' => '',
36
+ ) );
37
+ $instance = wp_parse_args( $instance, array(
38
+ 'pirate_forms_widget_title' => 'Pirate Forms',
39
+ 'pirate_forms_widget_subtext' => 'Pirate Forms',
40
+ ) );
41
  // Output all wrappers
42
+ echo $args['before_widget'] . '<div class="pirate-forms-contact-widget">';
43
+ if ( ! empty( $instance['pirate_forms_widget_title'] ) ) {
44
+ echo $args['before_title'] . $instance['pirate_forms_widget_title'] . $args['after_title'];
45
+ }
46
+ if ( ! empty( $instance['pirate_forms_widget_subtext'] ) ) {
47
+ echo wpautop( stripslashes( $instance['pirate_forms_widget_subtext'] ) );
48
+ }
49
+ echo do_shortcode( '[pirate_forms]' );
50
+ echo '<div class="pirate_forms_clearfix"></div>';
51
+ echo '</div>' . $args['after_widget'];
 
 
 
52
 
53
  }
54
 
62
  */
63
  function update( $new_instance, $old_instance ) {
64
  $instance = $old_instance;
 
65
  // Storing widget title as inputted option or category name
66
+ $instance['pirate_forms_widget_title'] = apply_filters( 'widget_title', sanitize_text_field( $new_instance['pirate_forms_widget_title'] ) );
 
67
  $instance['pirate_forms_widget_subtext'] = $new_instance['pirate_forms_widget_subtext'];
68
 
69
  return $instance;
77
  * @return string|void
78
  */
79
  function form( $instance ) {
80
+ $pirate_forms_widget_title = ! empty( $instance['pirate_forms_widget_title'] ) ? $instance['pirate_forms_widget_title'] : __( 'Title', 'pirate-forms' );
81
+ $pirate_forms_widget_subtext = ! empty( $instance['pirate_forms_widget_subtext'] ) ? $instance['pirate_forms_widget_subtext'] : __( 'Text above form', 'pirate-forms' );
 
82
  ?>
83
  <p>
84
+ <label for="<?php echo $this->get_field_id( 'pirate_forms_widget_title' ); ?>"><?php _e( 'Title:','pirate-forms' ); ?></label>
85
+ <input class="widefat" id="<?php echo $this->get_field_id( 'pirate_forms_widget_title' ); ?>"
86
+ name="<?php echo $this->get_field_name( 'pirate_forms_widget_title' ); ?>" type="text"
87
+ value="<?php echo esc_attr( $pirate_forms_widget_title ); ?>">
88
  </p>
89
  <p>
90
+ <label for="<?php echo $this->get_field_id( 'pirate_forms_widget_subtext' ); ?>"><?php _e( 'Subtext:','pirate-forms' ); ?></label>
91
+ <textarea class="widefat" id="<?php echo $this->get_field_id( 'pirate_forms_widget_subtext' ); ?>"
92
+ name="<?php echo $this->get_field_name( 'pirate_forms_widget_subtext' ); ?>"><?php echo esc_attr( $pirate_forms_widget_subtext ); ?></textarea>
93
  </p>
94
  <?php
95
 
96
  }
97
  }
98
 
99
+ add_action( 'widgets_init', create_function( '', 'return register_widget("pirate_forms_contact_widget");' ) );
js/scripts-admin.js CHANGED
@@ -1,14 +1,17 @@
 
 
 
1
  jQuery(document).ready(function() {
2
- jQuery(".pirate-forms-nav-tabs a").click(function (event) {
3
  event.preventDefault();
4
- jQuery(this).parent().addClass("active");
5
- jQuery(this).parent().siblings().removeClass("active");
6
- var tab = jQuery(this).attr("href");
7
- jQuery(".pirate-forms-tab-pane").not(tab).css("display", "none");
8
  jQuery(tab).fadeIn();
9
  });
10
 
11
- jQuery(".pirate-forms-save-button").click(function (e) {
12
  e.preventDefault();
13
  cwpTopUpdateForm();
14
  return false;
@@ -17,21 +20,21 @@ jQuery(document).ready(function() {
17
 
18
  startAjaxIntro();
19
 
20
- var data = jQuery(".pirate_forms_contact_settings").serialize();
21
 
22
  jQuery.ajax({
23
- type: "POST",
24
  url: cwp_top_ajaxload.ajaxurl,
25
 
26
  data: {
27
- action: "pirate_forms_save",
28
  dataSent: data
29
  },
30
  success: function (response) {
31
  console.log(response);
32
  },
33
  error: function (MLHttpRequest, textStatus, errorThrown) {
34
- console.log("There was an error: " + errorThrown);
35
  }
36
  });
37
 
@@ -41,12 +44,12 @@ jQuery(document).ready(function() {
41
 
42
  // Starting the AJAX intro animation
43
  function startAjaxIntro() {
44
- jQuery(".ajaxAnimation").fadeIn();
45
  }
46
 
47
  // Ending the AJAX intro animation
48
  function endAjaxIntro() {
49
- jQuery(".ajaxAnimation").fadeOut();
50
  }
51
 
52
  /* Recaptcha site key and secret key should appear only when Add a recaptcha is selected */
1
+ /* global cwp_top_ajaxload */
2
+ /* global console */
3
+
4
  jQuery(document).ready(function() {
5
+ jQuery('.pirate-forms-nav-tabs a').click(function (event) {
6
  event.preventDefault();
7
+ jQuery(this).parent().addClass('active');
8
+ jQuery(this).parent().siblings().removeClass('active');
9
+ var tab = jQuery(this).attr('href');
10
+ jQuery('.pirate-forms-tab-pane').not(tab).css('display', 'none');
11
  jQuery(tab).fadeIn();
12
  });
13
 
14
+ jQuery('.pirate-forms-save-button').click(function (e) {
15
  e.preventDefault();
16
  cwpTopUpdateForm();
17
  return false;
20
 
21
  startAjaxIntro();
22
 
23
+ var data = jQuery('.pirate_forms_contact_settings').serialize();
24
 
25
  jQuery.ajax({
26
+ type: 'POST',
27
  url: cwp_top_ajaxload.ajaxurl,
28
 
29
  data: {
30
+ action: 'pirate_forms_save',
31
  dataSent: data
32
  },
33
  success: function (response) {
34
  console.log(response);
35
  },
36
  error: function (MLHttpRequest, textStatus, errorThrown) {
37
+ console.log('There was an error: ' + errorThrown);
38
  }
39
  });
40
 
44
 
45
  // Starting the AJAX intro animation
46
  function startAjaxIntro() {
47
+ jQuery('.ajaxAnimation').fadeIn();
48
  }
49
 
50
  // Ending the AJAX intro animation
51
  function endAjaxIntro() {
52
+ jQuery('.ajaxAnimation').fadeOut();
53
  }
54
 
55
  /* Recaptcha site key and secret key should appear only when Add a recaptcha is selected */
js/scripts-general.js CHANGED
@@ -1,17 +1,18 @@
 
1
  jQuery(document).ready(function() {
2
 
3
  var session_var = pirateFormsObject.errors;
4
 
5
- if( (typeof session_var != 'undefined') && (session_var != '') && (typeof jQuery('#contact') != 'undefined') && (typeof jQuery('#contact').offset() != 'undefined') ) {
6
 
7
  jQuery('html, body').animate({
8
  scrollTop: jQuery('#contact').offset().top
9
  }, 'slow');
10
  }
11
 
12
- if( typeof jQuery('.pirate_forms_three_inputs').val() != 'undefined' ) {
13
  jQuery('.pirate_forms ').each(function(){
14
  jQuery(this).find('.pirate_forms_three_inputs').wrapAll('<div class="pirate_forms_three_inputs_wrap">');
15
- })
16
  }
17
  });
1
+ /* global pirateFormsObject */
2
  jQuery(document).ready(function() {
3
 
4
  var session_var = pirateFormsObject.errors;
5
 
6
+ if( (typeof session_var !== 'undefined') && (session_var !== '') && (typeof jQuery('#contact') !== 'undefined') && (typeof jQuery('#contact').offset() !== 'undefined') ) {
7
 
8
  jQuery('html, body').animate({
9
  scrollTop: jQuery('#contact').offset().top
10
  }, 'slow');
11
  }
12
 
13
+ if( typeof jQuery('.pirate_forms_three_inputs').val() !== 'undefined' ) {
14
  jQuery('.pirate_forms ').each(function(){
15
  jQuery(this).find('.pirate_forms_three_inputs').wrapAll('<div class="pirate_forms_three_inputs_wrap">');
16
+ });
17
  }
18
  });
js/scripts.js CHANGED
@@ -10,7 +10,7 @@ jQuery(document).ready(function() {
10
  return false;
11
  }
12
  });
13
- if ( thisOpen == false && (typeof jQuery('.pirate_forms textarea').val() != 'undefined') && (jQuery('.pirate_forms textarea').val().length > 0) ) {
14
  thisOpen = true;
15
  jQuery('.pirate-forms-g-recaptcha').css('display','block').delay(1000).css('opacity','1');
16
  }
10
  return false;
11
  }
12
  });
13
+ if ( thisOpen === false && (typeof jQuery('.pirate_forms textarea').val() !== 'undefined') && (jQuery('.pirate_forms textarea').val().length > 0) ) {
14
  thisOpen = true;
15
  jQuery('.pirate-forms-g-recaptcha').css('display','block').delay(1000).css('opacity','1');
16
  }
languages/pirate-forms.pot CHANGED
@@ -1,453 +1,554 @@
 
 
1
  msgid ""
2
  msgstr ""
3
- "Project-Id-Version: Pirate Forms\n"
4
- "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2016-03-09 18:51+0200\n"
6
- "PO-Revision-Date: 2016-03-09 18:51+0200\n"
7
- "Last-Translator: \n"
8
- "Language-Team: Themeisle <friends@themeisle.com>\n"
9
  "MIME-Version: 1.0\n"
10
- "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
- "X-Poedit-KeywordsList: _;gettext;gettext_noop;__;_e;esc_html__;esc_html_e\n"
 
 
 
 
 
 
 
 
 
 
13
  "X-Poedit-Basepath: ../\n"
14
  "X-Poedit-SearchPath-0: .\n"
15
- "X-Poedit-SearchPath-1: inc\n"
16
-
17
- #: pirate-forms.php:295
18
- msgid "Contact Referrer"
19
- msgstr ""
20
-
21
- #: pirate-forms.php:306
22
- msgid "Referring page"
23
- msgstr ""
24
-
25
- #: pirate-forms.php:346
26
- msgid "Nonce failed!"
27
- msgstr ""
28
-
29
- #: pirate-forms.php:352
30
- msgid "Form submission failed!"
31
- msgstr ""
32
-
33
- #: pirate-forms.php:357
34
- msgid "Contact form submission on"
35
- msgstr ""
36
-
37
- #: pirate-forms.php:438
38
- #: pirate-forms.php:451
39
- msgid "Wrong reCAPTCHA"
40
- msgstr ""
41
-
42
- #: pirate-forms.php:462
43
- msgid "Please enter one or more Contact submission recipients"
44
- msgstr ""
45
-
46
- #: pirate-forms.php:473
47
- msgid "IP address: "
48
- msgstr ""
49
-
50
- #: pirate-forms.php:473
51
- msgid "IP search:"
52
- msgstr ""
53
-
54
- #: pirate-forms.php:478
55
- msgid "Came from: "
56
- msgstr ""
57
-
58
- #: pirate-forms.php:482
59
- msgid "Sent from page: "
60
- msgstr ""
61
-
62
- #: pirate-forms.php:491
63
- msgid "Form submission blocked!"
64
- msgstr ""
65
-
66
- #: pirate-forms.php:705
67
- msgid "Add New Contact"
68
- msgstr ""
69
-
70
- #: pirate-forms.php:706
71
- msgid "New Contact"
72
- msgstr ""
73
-
74
- #: pirate-forms.php:707
75
- msgid "Edit Contact"
76
- msgstr ""
77
-
78
- #: pirate-forms.php:708
79
- msgid "View Contact"
80
- msgstr ""
81
-
82
- #: pirate-forms.php:709
83
- msgid "All Contacts"
84
- msgstr ""
85
-
86
- #: pirate-forms.php:710
87
- msgid "Search Contacts"
88
- msgstr ""
89
-
90
- #: pirate-forms.php:711
91
- msgid "Parent Contacts:"
92
- msgstr ""
93
-
94
- #: pirate-forms.php:712
95
- msgid "No contacts found."
96
- msgstr ""
97
-
98
- #: pirate-forms.php:713
99
- msgid "No contacts found in Trash."
100
- msgstr ""
101
-
102
- #: pirate-forms.php:717
103
- msgid "Contacts from Pirate Forms"
104
- msgstr ""
105
-
106
- #: pirate-forms.php:739
107
- msgid "Settings"
108
- msgstr ""
109
 
110
  #: inc/helpers.php:16
111
  msgid "Sorry, an error occured."
112
  msgstr ""
113
 
114
- #: inc/settings.php:62
115
- #: inc/settings.php:66
 
 
 
 
116
  msgid "Send Message"
117
  msgstr ""
118
 
119
- #: inc/settings.php:84
120
  msgid "Form processing options"
121
  msgstr ""
122
 
123
- #: inc/settings.php:90
124
  msgid "Contact notification sender email"
125
  msgstr ""
126
 
127
- #: inc/settings.php:91
128
  msgid "Insert [email] to use the contact form submitter's email."
129
  msgstr ""
130
 
131
- #: inc/settings.php:91
132
- msgid "Email to use for the sender of the contact form emails both to the recipients below and the contact form submitter (if this is activated below). The domain for this email address should match your site's domain."
 
 
 
133
  msgstr ""
134
 
135
- #: inc/settings.php:96
136
  msgid "Contact submission recipients"
137
  msgstr ""
138
 
139
- #: inc/settings.php:97
140
- msgid "Email address(es) to receive contact submission notifications. You can separate multiple emails with a comma."
 
 
141
  msgstr ""
142
 
143
- #: inc/settings.php:102
144
  msgid "Store submissions in the database"
145
  msgstr ""
146
 
147
- #: inc/settings.php:103
148
- msgid "Should the submissions be stored in the admin area? If chosen, contact form submissions will be saved in Contacts on the left (appears after this option is activated)."
 
 
 
149
  msgstr ""
150
 
151
- #: inc/settings.php:108
152
- msgid "Use the comments blacklist to restrict submissions"
153
  msgstr ""
154
 
155
- #: inc/settings.php:109
156
- msgid "Should form submission IP and email addresses be compared against the Comment Blacklist, found in"
 
 
 
 
 
157
  msgstr ""
158
 
159
- #: inc/settings.php:109
160
- msgid "wp-admin > Settings > Discussion > Comment Blacklist?"
161
  msgstr ""
162
 
163
- #: inc/settings.php:114
164
- msgid "Send email confirmation to form submitter"
 
 
 
165
  msgstr ""
166
 
167
- #: inc/settings.php:115
168
- msgid "Adding text here will send an email to the form submitter. The email uses the \"Text to show when form is submitted...\" field below as the subject line. Plain text only here, no HTML."
169
  msgstr ""
170
 
171
- #: inc/settings.php:122
172
- #: inc/settings.php:424
173
- msgid "Fields"
174
  msgstr ""
175
 
176
- #: inc/settings.php:129
177
- #: inc/settings.php:206
178
- msgid "Name"
179
  msgstr ""
180
 
181
- #: inc/settings.php:130
182
- msgid "Do you want the name field to be displayed?"
183
  msgstr ""
184
 
185
- #: inc/settings.php:134
186
- #: inc/settings.php:146
187
- #: inc/settings.php:158
188
- #: inc/settings.php:170
189
- msgid "None"
190
  msgstr ""
191
 
192
- #: inc/settings.php:135
193
- #: inc/settings.php:147
194
- #: inc/settings.php:159
195
- #: inc/settings.php:171
196
  msgid "Yes but not required"
197
  msgstr ""
198
 
199
- #: inc/settings.php:136
200
- #: inc/settings.php:148
201
- #: inc/settings.php:160
202
- #: inc/settings.php:172
203
  msgid "Required"
204
  msgstr ""
205
 
206
- #: inc/settings.php:141
207
  msgid "Email address"
208
  msgstr ""
209
 
210
- #: inc/settings.php:142
211
  msgid "Do you want the email address field be displayed?"
212
  msgstr ""
213
 
214
- #: inc/settings.php:153
215
- #: inc/settings.php:218
216
- #: inc/settings.php:221
217
  msgid "Subject"
218
  msgstr ""
219
 
220
- #: inc/settings.php:154
221
  msgid "Do you want the subject field be displayed?"
222
  msgstr ""
223
 
224
- #: inc/settings.php:165
225
- #: inc/settings.php:224
226
  msgid "Message"
227
  msgstr ""
228
 
229
- #: inc/settings.php:177
230
  msgid "Add a reCAPTCHA"
231
  msgstr ""
232
 
233
- #: inc/settings.php:184
234
  msgid "Site key"
235
  msgstr ""
236
 
237
- #: inc/settings.php:185
238
  msgid "Create an account here "
239
  msgstr ""
240
 
241
- #: inc/settings.php:185
242
  msgid "to get the Site key and the Secret key for the reCaptcha."
243
  msgstr ""
244
 
245
- #: inc/settings.php:191
246
  msgid "Secret key"
247
  msgstr ""
248
 
249
- #: inc/settings.php:200
250
- #: inc/settings.php:425
251
- msgid "Labels"
 
 
 
252
  msgstr ""
253
 
254
- #: inc/settings.php:209
255
  msgid "Your Name"
256
  msgstr ""
257
 
258
- #: inc/settings.php:212
259
  msgid "Email"
260
  msgstr ""
261
 
262
- #: inc/settings.php:215
263
  msgid "Your Email"
264
  msgstr ""
265
 
266
- #: inc/settings.php:227
267
  msgid "Your message"
268
  msgstr ""
269
 
270
- #: inc/settings.php:230
271
  msgid "Submit button"
272
  msgstr ""
273
 
274
- #: inc/settings.php:238
275
- #: inc/settings.php:426
276
- msgid "Messages"
277
  msgstr ""
278
 
279
- #: inc/settings.php:244
280
  msgid "Name required and missing"
281
  msgstr ""
282
 
283
- #: inc/settings.php:247
284
  msgid "Enter your name"
285
  msgstr ""
286
 
287
- #: inc/settings.php:250
288
  msgid "E-mail required and missing"
289
  msgstr ""
290
 
291
- #: inc/settings.php:253
292
  msgid "Enter a valid email"
293
  msgstr ""
294
 
295
- #: inc/settings.php:256
296
  msgid "Subject required and missing"
297
  msgstr ""
298
 
299
- #: inc/settings.php:259
300
  msgid "Please enter a subject"
301
  msgstr ""
302
 
303
- #: inc/settings.php:262
304
  msgid "Question/comment is missing"
305
  msgstr ""
306
 
307
- #: inc/settings.php:265
308
  msgid "Enter your question or comment"
309
  msgstr ""
310
 
311
- #: inc/settings.php:268
312
  msgid "Successful form submission text"
313
  msgstr ""
314
 
315
- #: inc/settings.php:269
316
- msgid "This text is used on the page if no \"Thank You\" URL is set above. This is also used as the confirmation email title, if one is set to send out."
 
 
317
  msgstr ""
318
 
319
- #: inc/settings.php:271
320
  msgid "Thanks, your email was sent successfully!"
321
  msgstr ""
322
 
323
- #: inc/settings.php:276
 
 
 
 
324
  msgid "Use SMTP to send emails?"
325
  msgstr ""
326
 
327
- #: inc/settings.php:277
328
  msgid "Instead of PHP mail function"
329
  msgstr ""
330
 
331
- #: inc/settings.php:282
332
  msgid "SMTP Host"
333
  msgstr ""
334
 
335
- #: inc/settings.php:288
336
  msgid "SMTP Port"
337
  msgstr ""
338
 
339
- #: inc/settings.php:294
340
  msgid "Use SMTP Authentication?"
341
  msgstr ""
342
 
343
- #: inc/settings.php:295
344
- msgid "If you check this box, make sure the SMTP Username and SMTP Password are completed."
 
 
345
  msgstr ""
346
 
347
- #: inc/settings.php:300
348
  msgid "SMTP Username"
349
  msgstr ""
350
 
351
- #: inc/settings.php:306
352
  msgid "SMTP Password"
353
  msgstr ""
354
 
355
- #: inc/settings.php:324
356
  msgid "Pirate Forms settings"
357
  msgstr ""
358
 
359
- #: inc/settings.php:325
360
- #: inc/settings.php:417
361
- #: inc/widget.php:15
362
- #: inc/widget.php:16
363
  msgid "Pirate Forms"
364
  msgstr ""
365
 
366
- #: inc/settings.php:422
367
  msgid "How to use"
368
  msgstr ""
369
 
370
- #: inc/settings.php:423
371
  msgid "Options"
372
  msgstr ""
373
 
374
- #: inc/settings.php:427
375
  msgid "SMTP"
376
  msgstr ""
377
 
378
- #: inc/settings.php:434
379
  msgid "Welcome to Pirate Forms!"
380
  msgstr ""
381
 
382
- #: inc/settings.php:435
383
  msgid "To get started, just "
384
  msgstr ""
385
 
386
- #: inc/settings.php:435
387
  msgid "configure all the options "
388
  msgstr ""
389
 
390
- #: inc/settings.php:435
391
  msgid "you need, hit save and start using the created form."
392
  msgstr ""
393
 
394
- #: inc/settings.php:439
395
  msgid "There are 3 ways of using the newly created form:"
396
  msgstr ""
397
 
398
- #: inc/settings.php:440
399
- msgid "1. Use the shortcode "
400
  msgstr ""
401
 
402
- #: inc/settings.php:440
403
- msgid "in any page or post."
404
  msgstr ""
405
 
406
- #: inc/settings.php:441
407
- msgid "2. Add a "
408
  msgstr ""
409
 
410
- #: inc/settings.php:441
411
- msgid "widget"
 
 
 
 
 
 
 
 
412
  msgstr ""
413
 
414
- #: inc/settings.php:442
415
- msgid "3. Use the shortcode "
416
  msgstr ""
417
 
418
- #: inc/settings.php:442
419
- msgid "in the theme's files."
 
 
420
  msgstr ""
421
 
422
- #: inc/settings.php:561
423
  msgid "Save changes"
424
  msgstr ""
425
 
426
- #: inc/settings.php:575
427
  msgid "Get Our Free Email Course"
428
  msgstr ""
429
 
430
- #: inc/settings.php:595
431
- msgid "Ready to learn how to reduce your website loading times by half? Come and join the 1st lesson here!"
 
 
432
  msgstr ""
433
 
434
- #: inc/settings.php:597
435
- msgid "Thank you for subscribing! You have been added to the mailing list and will receive the next email information in the coming weeks. If you ever wish to unsubscribe, simply use the \"Unsubscribe\" link included in each newsletter."
 
 
 
 
436
  msgstr ""
437
 
438
- #: inc/widget.php:75
 
 
 
 
439
  msgid "Title"
440
  msgstr ""
441
 
442
- #: inc/widget.php:76
443
  msgid "Text above form"
444
  msgstr ""
445
 
446
- #: inc/widget.php:79
447
  msgid "Title:"
448
  msgstr ""
449
 
450
- #: inc/widget.php:83
451
  msgid "Subtext:"
452
  msgstr ""
453
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (C) 2016 Themeisle
2
+ # This file is distributed under the GPLv2.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: Free & Simple Contact Form Plugin - PirateForms 1.1.2\n"
6
+ "Report-Msgid-Bugs-To: https://github.com/Codeinwp/pirate-forms/issues\n"
7
+ "POT-Creation-Date: 2016-12-20 16:33:52+00:00\n"
 
 
 
8
  "MIME-Version: 1.0\n"
9
+ "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
11
+ "PO-Revision-Date: 2016-MO-DA HO:MI+ZONE\n"
12
+ "Last-Translator: Themeisle Translate Team <friends@themeisle.com>\n"
13
+ "Language-Team: Themeisle Translate <friends@themeisle.com>\n"
14
+ "X-Generator: grunt-wp-i18n 0.5.4\n"
15
+ "X-Poedit-KeywordsList: "
16
+ "__;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;_nx_noop:1,2,3c;esc_"
17
+ "attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;esc_html_x:1,2c;\n"
18
+ "Language: en\n"
19
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
20
+ "X-Poedit-Country: United States\n"
21
+ "X-Poedit-SourceCharset: UTF-8\n"
22
  "X-Poedit-Basepath: ../\n"
23
  "X-Poedit-SearchPath-0: .\n"
24
+ "X-Poedit-Bookmarks: \n"
25
+ "X-Textdomain-Support: yes\n"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
 
27
  #: inc/helpers.php:16
28
  msgid "Sorry, an error occured."
29
  msgstr ""
30
 
31
+ #: inc/settings.php:27 inc/settings.php:148 inc/settings.php:160
32
+ #: inc/settings.php:172 inc/settings.php:184
33
+ msgid "None"
34
+ msgstr ""
35
+
36
+ #: inc/settings.php:71 inc/settings.php:75
37
  msgid "Send Message"
38
  msgstr ""
39
 
40
+ #: inc/settings.php:91
41
  msgid "Form processing options"
42
  msgstr ""
43
 
44
+ #: inc/settings.php:97
45
  msgid "Contact notification sender email"
46
  msgstr ""
47
 
48
+ #: inc/settings.php:98
49
  msgid "Insert [email] to use the contact form submitter's email."
50
  msgstr ""
51
 
52
+ #: inc/settings.php:98
53
+ msgid ""
54
+ "Email to use for the sender of the contact form emails both to the "
55
+ "recipients below and the contact form submitter (if this is activated "
56
+ "below). The domain for this email address should match your site's domain."
57
  msgstr ""
58
 
59
+ #: inc/settings.php:103
60
  msgid "Contact submission recipients"
61
  msgstr ""
62
 
63
+ #: inc/settings.php:104
64
+ msgid ""
65
+ "Email address(es) to receive contact submission notifications. You can "
66
+ "separate multiple emails with a comma."
67
  msgstr ""
68
 
69
+ #: inc/settings.php:109
70
  msgid "Store submissions in the database"
71
  msgstr ""
72
 
73
+ #: inc/settings.php:110
74
+ msgid ""
75
+ "Should the submissions be stored in the admin area? If chosen, contact form "
76
+ "submissions will be saved in Contacts on the left (appears after this "
77
+ "option is activated)."
78
  msgstr ""
79
 
80
+ #: inc/settings.php:115
81
+ msgid "Add a nonce to the contact form:"
82
  msgstr ""
83
 
84
+ #: inc/settings.php:116
85
+ msgid ""
86
+ "Should the form use a WordPress nonce? This helps reduce spam by ensuring "
87
+ "that the form submittor is on the site when submitting the form rather than "
88
+ "submitting remotely. This could, however, cause problems with sites using a "
89
+ "page caching plugin. Turn this off if you are getting complaints about "
90
+ "forms not being able to be submitted with an error of \"Nonce failed!\""
91
  msgstr ""
92
 
93
+ #: inc/settings.php:121
94
+ msgid "Send email confirmation to form submitter"
95
  msgstr ""
96
 
97
+ #: inc/settings.php:122
98
+ msgid ""
99
+ "Adding text here will send an email to the form submitter. The email uses "
100
+ "the \"Successful form submission text\" field from the \"Alert Messages\" "
101
+ "tab as the subject line. Plain text only here, no HTML."
102
  msgstr ""
103
 
104
+ #: inc/settings.php:127
105
+ msgid "\"Thank You\" URL"
106
  msgstr ""
107
 
108
+ #: inc/settings.php:128
109
+ msgid "Select the post-submit page for all forms submitted"
 
110
  msgstr ""
111
 
112
+ #: inc/settings.php:136 inc/settings.php:450
113
+ msgid "Fields Settings"
 
114
  msgstr ""
115
 
116
+ #: inc/settings.php:143 inc/settings.php:226
117
+ msgid "Name"
118
  msgstr ""
119
 
120
+ #: inc/settings.php:144
121
+ msgid "Do you want the name field to be displayed?"
 
 
 
122
  msgstr ""
123
 
124
+ #: inc/settings.php:149 inc/settings.php:161 inc/settings.php:173
125
+ #: inc/settings.php:185
 
 
126
  msgid "Yes but not required"
127
  msgstr ""
128
 
129
+ #: inc/settings.php:150 inc/settings.php:162 inc/settings.php:174
130
+ #: inc/settings.php:186
 
 
131
  msgid "Required"
132
  msgstr ""
133
 
134
+ #: inc/settings.php:155
135
  msgid "Email address"
136
  msgstr ""
137
 
138
+ #: inc/settings.php:156
139
  msgid "Do you want the email address field be displayed?"
140
  msgstr ""
141
 
142
+ #: inc/settings.php:167 inc/settings.php:238 inc/settings.php:241
 
 
143
  msgid "Subject"
144
  msgstr ""
145
 
146
+ #: inc/settings.php:168
147
  msgid "Do you want the subject field be displayed?"
148
  msgstr ""
149
 
150
+ #: inc/settings.php:179 inc/settings.php:244
 
151
  msgid "Message"
152
  msgstr ""
153
 
154
+ #: inc/settings.php:191
155
  msgid "Add a reCAPTCHA"
156
  msgstr ""
157
 
158
+ #: inc/settings.php:198
159
  msgid "Site key"
160
  msgstr ""
161
 
162
+ #: inc/settings.php:199
163
  msgid "Create an account here "
164
  msgstr ""
165
 
166
+ #: inc/settings.php:199
167
  msgid "to get the Site key and the Secret key for the reCaptcha."
168
  msgstr ""
169
 
170
+ #: inc/settings.php:205
171
  msgid "Secret key"
172
  msgstr ""
173
 
174
+ #: inc/settings.php:212
175
+ msgid "Add an attachment field"
176
+ msgstr ""
177
+
178
+ #: inc/settings.php:220 inc/settings.php:453
179
+ msgid "Fields Labels"
180
  msgstr ""
181
 
182
+ #: inc/settings.php:229
183
  msgid "Your Name"
184
  msgstr ""
185
 
186
+ #: inc/settings.php:232
187
  msgid "Email"
188
  msgstr ""
189
 
190
+ #: inc/settings.php:235
191
  msgid "Your Email"
192
  msgstr ""
193
 
194
+ #: inc/settings.php:247
195
  msgid "Your message"
196
  msgstr ""
197
 
198
+ #: inc/settings.php:250
199
  msgid "Submit button"
200
  msgstr ""
201
 
202
+ #: inc/settings.php:258 inc/settings.php:456
203
+ msgid "Alert Messages"
 
204
  msgstr ""
205
 
206
+ #: inc/settings.php:264
207
  msgid "Name required and missing"
208
  msgstr ""
209
 
210
+ #: inc/settings.php:267
211
  msgid "Enter your name"
212
  msgstr ""
213
 
214
+ #: inc/settings.php:270
215
  msgid "E-mail required and missing"
216
  msgstr ""
217
 
218
+ #: inc/settings.php:273
219
  msgid "Enter a valid email"
220
  msgstr ""
221
 
222
+ #: inc/settings.php:276
223
  msgid "Subject required and missing"
224
  msgstr ""
225
 
226
+ #: inc/settings.php:279
227
  msgid "Please enter a subject"
228
  msgstr ""
229
 
230
+ #: inc/settings.php:282
231
  msgid "Question/comment is missing"
232
  msgstr ""
233
 
234
+ #: inc/settings.php:285
235
  msgid "Enter your question or comment"
236
  msgstr ""
237
 
238
+ #: inc/settings.php:288
239
  msgid "Successful form submission text"
240
  msgstr ""
241
 
242
+ #: inc/settings.php:289
243
+ msgid ""
244
+ "This text is used on the page if no \"Thank You\" URL is set above. This is "
245
+ "also used as the confirmation email title, if one is set to send out."
246
  msgstr ""
247
 
248
+ #: inc/settings.php:291
249
  msgid "Thanks, your email was sent successfully!"
250
  msgstr ""
251
 
252
+ #: inc/settings.php:296
253
+ msgid "SMTP Options"
254
+ msgstr ""
255
+
256
+ #: inc/settings.php:302
257
  msgid "Use SMTP to send emails?"
258
  msgstr ""
259
 
260
+ #: inc/settings.php:303
261
  msgid "Instead of PHP mail function"
262
  msgstr ""
263
 
264
+ #: inc/settings.php:308
265
  msgid "SMTP Host"
266
  msgstr ""
267
 
268
+ #: inc/settings.php:314
269
  msgid "SMTP Port"
270
  msgstr ""
271
 
272
+ #: inc/settings.php:320
273
  msgid "Use SMTP Authentication?"
274
  msgstr ""
275
 
276
+ #: inc/settings.php:321
277
+ msgid ""
278
+ "If you check this box, make sure the SMTP Username and SMTP Password are "
279
+ "completed."
280
  msgstr ""
281
 
282
+ #: inc/settings.php:326
283
  msgid "SMTP Username"
284
  msgstr ""
285
 
286
+ #: inc/settings.php:332
287
  msgid "SMTP Password"
288
  msgstr ""
289
 
290
+ #: inc/settings.php:349
291
  msgid "Pirate Forms settings"
292
  msgstr ""
293
 
294
+ #: inc/settings.php:350 inc/settings.php:439 inc/widget.php:18
295
+ #: inc/widget.php:19
 
 
296
  msgid "Pirate Forms"
297
  msgstr ""
298
 
299
+ #: inc/settings.php:444
300
  msgid "How to use"
301
  msgstr ""
302
 
303
+ #: inc/settings.php:447
304
  msgid "Options"
305
  msgstr ""
306
 
307
+ #: inc/settings.php:459
308
  msgid "SMTP"
309
  msgstr ""
310
 
311
+ #: inc/settings.php:466
312
  msgid "Welcome to Pirate Forms!"
313
  msgstr ""
314
 
315
+ #: inc/settings.php:467
316
  msgid "To get started, just "
317
  msgstr ""
318
 
319
+ #: inc/settings.php:468
320
  msgid "configure all the options "
321
  msgstr ""
322
 
323
+ #: inc/settings.php:468
324
  msgid "you need, hit save and start using the created form."
325
  msgstr ""
326
 
327
+ #: inc/settings.php:473
328
  msgid "There are 3 ways of using the newly created form:"
329
  msgstr ""
330
 
331
+ #: inc/settings.php:475
332
+ msgid "Add a "
333
  msgstr ""
334
 
335
+ #: inc/settings.php:476
336
+ msgid "widget"
337
  msgstr ""
338
 
339
+ #: inc/settings.php:478 inc/settings.php:481
340
+ msgid "Use the shortcode "
341
  msgstr ""
342
 
343
+ #: inc/settings.php:479
344
+ msgid " in any page or post."
345
+ msgstr ""
346
+
347
+ #: inc/settings.php:483
348
+ msgid " in the theme's files."
349
+ msgstr ""
350
+
351
+ #: inc/settings.php:491
352
+ msgid "Are you enjoying Pirate Forms?"
353
  msgstr ""
354
 
355
+ #: inc/settings.php:493
356
+ msgid "Rate our plugin on %1$s WordPress.org %2$s. We'd really appreciate it!"
357
  msgstr ""
358
 
359
+ #: inc/settings.php:502
360
+ msgid ""
361
+ "If you want a more complex Contact Form Plugin please check %1$s this link "
362
+ "%2$s."
363
  msgstr ""
364
 
365
+ #: inc/settings.php:669
366
  msgid "Save changes"
367
  msgstr ""
368
 
369
+ #: inc/settings.php:686
370
  msgid "Get Our Free Email Course"
371
  msgstr ""
372
 
373
+ #: inc/settings.php:710
374
+ msgid ""
375
+ "Ready to learn how to reduce your website loading times by half? Come and "
376
+ "join the 1st lesson here!"
377
  msgstr ""
378
 
379
+ #: inc/settings.php:712
380
+ msgid ""
381
+ "Thank you for subscribing! You have been added to the mailing list and will "
382
+ "receive the next email information in the coming weeks. If you ever wish to "
383
+ "unsubscribe, simply use the \"Unsubscribe\" link included in each "
384
+ "newsletter."
385
  msgstr ""
386
 
387
+ #: inc/settings.php:720
388
+ msgid "Control Emails in WordPress"
389
+ msgstr ""
390
+
391
+ #: inc/widget.php:80
392
  msgid "Title"
393
  msgstr ""
394
 
395
+ #: inc/widget.php:81
396
  msgid "Text above form"
397
  msgstr ""
398
 
399
+ #: inc/widget.php:84
400
  msgid "Title:"
401
  msgstr ""
402
 
403
+ #: inc/widget.php:90
404
  msgid "Subtext:"
405
  msgstr ""
406
 
407
+ #: pirate-forms.php:245
408
+ msgid "Contact Referrer"
409
+ msgstr ""
410
+
411
+ #: pirate-forms.php:255
412
+ msgid "Referring page"
413
+ msgstr ""
414
+
415
+ #: pirate-forms.php:387
416
+ msgid "Nonce failed!"
417
+ msgstr ""
418
+
419
+ #: pirate-forms.php:394
420
+ msgid "Form submission failed!"
421
+ msgstr ""
422
+
423
+ #: pirate-forms.php:399
424
+ msgid "Contact form submission from"
425
+ msgstr ""
426
+
427
+ #: pirate-forms.php:452 pirate-forms.php:462
428
+ msgid "Wrong reCAPTCHA"
429
+ msgstr ""
430
+
431
+ #: pirate-forms.php:469
432
+ msgid "Please enter one or more Contact submission recipients"
433
+ msgstr ""
434
+
435
+ #: pirate-forms.php:483
436
+ msgid "IP address: "
437
+ msgstr ""
438
+
439
+ #: pirate-forms.php:483
440
+ msgid "IP search:"
441
+ msgstr ""
442
+
443
+ #: pirate-forms.php:487
444
+ msgid "Came from: "
445
+ msgstr ""
446
+
447
+ #: pirate-forms.php:490
448
+ msgid "Sent from page: "
449
+ msgstr ""
450
+
451
+ #: pirate-forms.php:498
452
+ msgid "Form submission blocked!"
453
+ msgstr ""
454
+
455
+ #: pirate-forms.php:554
456
+ msgid "Uploaded file is not allowed for file type"
457
+ msgstr ""
458
+
459
+ #: pirate-forms.php:559
460
+ msgid "Uploaded file is too large"
461
+ msgstr ""
462
+
463
+ #: pirate-forms.php:572 pirate-forms.php:576
464
+ msgid "There was an unknown error uploading the file."
465
+ msgstr ""
466
+
467
+ #: pirate-forms.php:721
468
+ msgid "Add New Contact"
469
+ msgstr ""
470
+
471
+ #: pirate-forms.php:722
472
+ msgid "New Contact"
473
+ msgstr ""
474
+
475
+ #: pirate-forms.php:723
476
+ msgid "Edit Contact"
477
+ msgstr ""
478
+
479
+ #: pirate-forms.php:724
480
+ msgid "View Contact"
481
+ msgstr ""
482
+
483
+ #: pirate-forms.php:725
484
+ msgid "All Contacts"
485
+ msgstr ""
486
+
487
+ #: pirate-forms.php:726
488
+ msgid "Search Contacts"
489
+ msgstr ""
490
+
491
+ #: pirate-forms.php:727
492
+ msgid "Parent Contacts:"
493
+ msgstr ""
494
+
495
+ #: pirate-forms.php:728
496
+ msgid "No contacts found."
497
+ msgstr ""
498
+
499
+ #: pirate-forms.php:729
500
+ msgid "No contacts found in Trash."
501
+ msgstr ""
502
+
503
+ #: pirate-forms.php:733
504
+ msgid "Contacts from Pirate Forms"
505
+ msgstr ""
506
+
507
+ #: pirate-forms.php:752
508
+ msgid "Settings"
509
+ msgstr ""
510
+
511
+ #. Plugin Name of the plugin/theme
512
+ msgid "Free & Simple Contact Form Plugin - PirateForms"
513
+ msgstr ""
514
+
515
+ #. Plugin URI of the plugin/theme
516
+ msgid "http://themeisle.com/plugins/pirate-forms/"
517
+ msgstr ""
518
+
519
+ #. Description of the plugin/theme
520
+ msgid "Easily creates a nice looking, simple contact form on your WP site."
521
+ msgstr ""
522
+
523
+ #. Author of the plugin/theme
524
+ msgid "Themeisle"
525
+ msgstr ""
526
+
527
+ #. Author URI of the plugin/theme
528
+ msgid "http://themeisle.com"
529
+ msgstr ""
530
+
531
+ #: pirate-forms.php:716
532
+ msgctxt "post type general name"
533
+ msgid "Contacts"
534
+ msgstr ""
535
+
536
+ #: pirate-forms.php:717
537
+ msgctxt "post type singular name"
538
+ msgid "Contact"
539
+ msgstr ""
540
+
541
+ #: pirate-forms.php:718
542
+ msgctxt "admin menu"
543
+ msgid "Contacts"
544
+ msgstr ""
545
+
546
+ #: pirate-forms.php:719
547
+ msgctxt "add new on admin bar"
548
+ msgid "Contact"
549
+ msgstr ""
550
+
551
+ #: pirate-forms.php:720
552
+ msgctxt "contact"
553
+ msgid "Add New"
554
+ msgstr ""
mailin.php CHANGED
@@ -4,83 +4,73 @@
4
  * SendinBlue REST client
5
  */
6
 
7
- class Mailin
8
- {
9
- public $api_key;
10
- public $base_url;
11
- public $curl_opts = array();
12
- public function __construct($base_url,$api_key)
13
- {
14
- if(!function_exists('curl_init'))
15
- {
16
- throw new Exception('Mailin requires CURL module');
17
- }
18
- $this->base_url = $base_url;
19
- $this->api_key = $api_key;
20
- }
21
- /**
22
- * Do CURL request with authorization
23
- */
24
- private function do_request($resource,$method,$input)
25
- {
26
- $called_url = $this->base_url."/".$resource;
27
- $ch = curl_init($called_url);
28
- $auth_header = 'api-key:'.$this->api_key;
29
- $content_header = "Content-Type:application/json";
30
- if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
31
- // Windows only over-ride
32
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
33
- }
34
- curl_setopt($ch, CURLOPT_HTTPHEADER, array($auth_header,$content_header));
35
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
36
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
37
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
38
- curl_setopt($ch, CURLOPT_HEADER, 0);
39
- curl_setopt($ch, CURLOPT_POSTFIELDS, $input);
40
- $data = curl_exec($ch);
41
- if(curl_errno($ch))
42
- {
43
- echo 'Curl error: ' . curl_error($ch). '\n';
44
- }
45
- curl_close($ch);
46
- return json_decode($data,true);
47
- }
48
- public function get($resource,$input)
49
- {
50
- return $this->do_request($resource,"GET",$input);
51
- }
52
- public function put($resource,$input)
53
- {
54
- return $this->do_request($resource,"PUT",$input);
55
- }
56
- public function post($resource,$input)
57
- {
58
- return $this->do_request($resource,"POST",$input);
59
- }
60
- public function delete($resource,$input)
61
- {
62
- return $this->do_request($resource,"DELETE",$input);
63
- }
64
-
65
- /*
66
  Get Account.
67
  No input required
68
  */
69
- public function get_account()
70
- {
71
- return $this->get("account","");
72
- }
73
 
74
- /*
75
  Get SMTP details.
76
  No input required
77
  */
78
- public function get_smtp_details()
79
- {
80
- return $this->get("account/smtpdetail","");
81
- }
82
 
83
- /*
84
  Create Child Account.
85
  @param {Array} data contains php array with key value pair.
86
  @options data {String} child_email: Email address of Reseller child [Mandatory]
@@ -93,12 +83,11 @@ class Mailin
93
  - sms_credit {Integer} Number of sms credts
94
  @options data {Array} associate_ip: Associate dedicated IPs to reseller child. You can use commas to separate multiple IPs [Optional]
95
  */
96
- public function create_child_account($data)
97
- {
98
- return $this->post("account",json_encode($data));
99
- }
100
 
101
- /*
102
  Update Child Account.
103
  @param {Array} data contains php array with key value pair.
104
  @options data {String} auth_key: 16 character authorization key of Reseller child to be modified [Mandatory]
@@ -109,32 +98,29 @@ class Mailin
109
  @options data {Array} associate_ip: Associate dedicated IPs to reseller child. You can use commas to separate multiple IPs [Optional]
110
  @options data {Array} disassociate_ip: Disassociate dedicated IPs from reseller child. You can use commas to separate multiple IPs [Optional]
111
  */
112
- public function update_child_account($data)
113
- {
114
- return $this->put("account",json_encode($data));
115
- }
116
 
117
- /*
118
  Delete Child Account.
119
  @param {Array} data contains php array with key value pair.
120
  @options data {String} auth_key: 16 character authorization key of Reseller child to be deleted [Mandatory]
121
  */
122
- public function delete_child_account($data)
123
- {
124
- return $this->delete("account/".$data['auth_key'],"");
125
- }
126
 
127
- /*
128
  Get Reseller child Account.
129
  @param {Array} data contains php array with key value pair.
130
  @options data {String} auth_key: 16 character authorization key of Reseller child. Example : To get the details of more than one child account, use, {"key1":"abC01De2fGHI3jkL","key2":"mnO45Pq6rSTU7vWX"} [Mandatory]
131
  */
132
- public function get_reseller_child($data)
133
- {
134
- return $this->post("account/getchildv2",json_encode($data));
135
- }
136
 
137
- /*
138
  Add/Remove Reseller child's Email/Sms credits.
139
  @param {Array} data contains php array with key value pair.
140
  @options data {String} auth_key: 16 character authorization key of Reseller child to modify credits [Mandatory]
@@ -145,22 +131,20 @@ class Mailin
145
  - email_credit {Integer} number of email credits
146
  - sms_credit {Integer} Number of sms credts
147
  */
148
- public function add_remove_child_credits($data)
149
- {
150
- return $this->post("account/addrmvcredit",json_encode($data));
151
- }
152
 
153
- /*
154
  Get a particular campaign detail.
155
  @param {Array} data contains php array with key value pair.
156
  @options data {Integer} id: Unique Id of the campaign [Mandatory]
157
  */
158
- public function get_campaign_v2($data)
159
- {
160
- return $this->get("campaign/".$data['id']."/detailsv2","");
161
- }
162
 
163
- /*
164
  Get all campaigns detail.
165
  @param {Array} data contains php array with key value pair.
166
  @options data {String} type: Type of campaign. Possible values – classic, trigger, sms, template ( case sensitive ) [Optional]
@@ -168,12 +152,11 @@ class Mailin
168
  @options data {Integer} page: Maximum number of records per request is 500, if there are more than 500 campaigns then you can use this parameter to get next 500 results [Optional]
169
  @options data {Integer} page_limit: This should be a valid number between 1-500 [Optional]
170
  */
171
- public function get_campaigns_v2($data)
172
- {
173
- return $this->get("campaign/detailsv2",json_encode($data));
174
- }
175
 
176
- /*
177
  Create and Schedule your campaigns. It returns the ID of the created campaign.
178
  @param {Array} data contains php array with key value pair.
179
  @options data {String} category: Tag name of the campaign [Optional]
@@ -195,12 +178,11 @@ class Mailin
195
  @options data {Integer} send_now: Flag to send campaign now. Possible values = 0 (default) & 1. send_now = 0 means campaign can’t be send now, & send_now = 1 means campaign ready to send now [Optional]
196
 
197
  */
198
- public function create_campaign($data)
199
- {
200
- return $this->post("campaign",json_encode($data));
201
- }
202
 
203
- /*
204
  Update your campaign.
205
  @param {Array} data contains php array with key value pair.
206
  @options data {Integer} id: Id of campaign to be modified [Mandatory]
@@ -222,24 +204,22 @@ class Mailin
222
  @options data {Integer} mirror_active: Status of mirror links in campaign. Possible values = 0 & 1 (default). mirror_active = 0 means mirror links are deactivated, & mirror_active = 1 means mirror links are activated, in the campaign [Optional]
223
  @options data {Integer} send_now: Flag to send campaign now. Possible values = 0 (default) & 1. send_now = 0 means campaign can’t be send now, & send_now = 1 means campaign ready to send now [Optional]
224
  */
225
- public function update_campaign($data)
226
- {
227
- $id = $data['id'];
228
- unset($data['id']);
229
- return $this->put("campaign/".$id,json_encode($data));
230
- }
231
 
232
- /*
233
  Delete your campaigns.
234
  @param {Array} data contains php array with key value pair.
235
  @options data {Integer} id: Id of campaign to be deleted [Mandatory]
236
  */
237
- public function delete_campaign($data)
238
- {
239
- return $this->delete("campaign/".$data['id'],"");
240
- }
241
 
242
- /*
243
  Send report of Sent and Archived campaign.
244
  @param {Array} data contains php array with key value pair.
245
  @options data {Integer} id: Id of campaign to send its report [Mandatory]
@@ -251,65 +231,60 @@ class Mailin
251
  @options data {Array} email_cc: Same as email_to but for Cc [Optional]
252
  @options data {String} email_body: Body of the message [Mandatory]
253
  */
254
- public function campaign_report_email($data)
255
- {
256
- $id = $data['id'];
257
- unset($data['id']);
258
- return $this->post("campaign/".$id."/report",json_encode($data));
259
- }
260
 
261
- /*
262
  Export the recipients of a specified campaign.
263
  @param {Array} data contains php array with key value pair.
264
  @options data {Integer} id: Id of campaign to export its recipients [Mandatory]
265
  @options data {String} notify_url: URL that will be called once the export process is finished [Mandatory]
266
  @options data {String} type: Type of recipients. Possible values – all, non_clicker, non_opener, clicker, opener, soft_bounces, hard_bounces & unsubscribes [Mandatory]
267
  */
268
- public function campaign_recipients_export($data)
269
- {
270
- $id = $data['id'];
271
- unset($data['id']);
272
- return $this->post("campaign/".$id."/recipients",json_encode($data));
273
- }
274
 
275
- /*
276
  Get the Campaign name, subject and share link of the classic type campaigns only which are sent, for those which are not sent and the rest of campaign types like trigger, template & sms, will return an error message of share link not available.
277
  @param {Array} data contains php array with key value pair.
278
  @options data {Array} camp_ids: Id of campaign to get share link. You can use commas to separate multiple ids [Mandatory]
279
  */
280
 
281
- public function share_campaign($data)
282
- {
283
- return $this->post("campaign/sharelinkv2",json_encode($data));
284
- }
285
 
286
- /*
287
  Send a Test Campaign.
288
  @param {Array} data contains php array with key value pair.
289
  @options data {Integer} id: Id of the campaign [Mandatory]
290
  @options data {Array} emails: Email address of recipient(s) existing in the one of the lists & should not be blacklisted. Example: "test@example.net". You can use commas to separate multiple recipients [Mandatory]
291
  */
292
- public function send_bat_email($data)
293
- {
294
- $id = $data['id'];
295
- unset($data['id']);
296
- return $this->post("campaign/".$id."/test",json_encode($data));
297
- }
298
 
299
- /*
300
  Update the Campaign status.
301
  @param {Array} data contains php array with key value pair.
302
  @options data {Integer} id: Id of campaign to update its status [Mandatory]
303
  @options data {String} status: Types of status. Possible values – suspended, archive, darchive, sent, queued, replicate and replicate_template ( case sensitive ) [Mandatory]
304
  */
305
- public function update_campaign_status($data)
306
- {
307
- $id = $data['id'];
308
- unset($data['id']);
309
- return $this->put("campaign/".$id."/updatecampstatus",json_encode($data));
310
- }
311
 
312
- /*
313
  Create and schedule your Trigger campaigns.
314
  @param {Array} data contains php array with key value pair.
315
  @options data {String} category: Tag name of the campaign [Optional]
@@ -331,12 +306,11 @@ class Mailin
331
  @options data {Integer} mirror_active: Status of mirror links in campaign. Possible values = 0 & 1 (default). mirror_active = 0 means mirror links are deactivated, & mirror_active = 1 means mirror links are activated, in the campaign [Optional]
332
  @options data {Integer} send_now: Flag to send campaign now. Possible values = 0 (default) & 1. send_now = 0 means campaign can’t be send now, & send_now = 1 means campaign ready to send now [Optional]
333
  */
334
- public function create_trigger_campaign($data)
335
- {
336
- return $this->post("campaign",json_encode($data));
337
- }
338
 
339
- /*
340
  Update and schedule your Trigger campaigns.
341
  @param {Array} data contains php array with key value pair.
342
  @options data {Integer} id: Id of Trigger campaign to be modified [Mandatory]
@@ -359,125 +333,114 @@ class Mailin
359
  @options data {Integer} mirror_active: Status of mirror links in campaign. Possible values = 0 & 1 (default). mirror_active = 0 means mirror links are deactivated, & mirror_active = 1 means mirror links are activated, in the campaign [Optional]
360
  @options data {Integer} send_now: Flag to send campaign now. Possible values = 0 (default) & 1. send_now = 0 means campaign can’t be send now, & send_now = 1 means campaign ready to send now [Optional]
361
  */
362
- public function update_trigger_campaign($data)
363
- {
364
- $id = $data['id'];
365
- unset($data['id']);
366
- return $this->put("campaign/".$id,json_encode($data));
367
- }
368
 
369
- /*
370
  Get all folders detail.
371
  @param {Array} data contains php array with key value pair.
372
  @options data {Integer} page: Maximum number of records per request is 50, if there are more than 50 folders then you can use this parameter to get next 50 results [Mandatory]
373
  @options data {Integer} page_limit: This should be a valid number between 1-50 [Mandatory]
374
  */
375
- public function get_folders($data)
376
- {
377
- return $this->get("folder",json_encode($data));
378
- }
379
 
380
- /*
381
  Get a particular folder detail.
382
  @param {Array} data contains php array with key value pair.
383
  @options data {Integer} id: Id of folder to get details [Mandatory]
384
  */
385
- public function get_folder($data)
386
- {
387
- return $this->get("folder/".$data['id'],"");
388
- }
389
 
390
- /*
391
  Create a new folder.
392
  @param {Array} data contains php array with key value pair.
393
  @options data {String} name: Desired name of the folder to be created [Mandatory]
394
  */
395
- public function create_folder($data)
396
- {
397
- return $this->post("folder",json_encode($data));
398
- }
399
 
400
- /*
401
  Delete a specific folder information.
402
  @param {Array} data contains php array with key value pair.
403
  @options data {Integer} id: Id of folder to be deleted [Mandatory]
404
  */
405
- public function delete_folder($data)
406
- {
407
- return $this->delete("folder/".$data['id'],"");
408
- }
409
 
410
- /*
411
  Update an existing folder.
412
  @param {Array} data contains php array with key value pair.
413
  @options data {Integer} id: Id of folder to be modified [Mandatory]
414
  @options data {String} name: Desired name of the folder to be modified [Mandatory]
415
  */
416
- public function update_folder($data)
417
- {
418
- $id = $data['id'];
419
- unset($data['id']);
420
- return $this->put("folder/".$id,json_encode($data));
421
- }
422
 
423
- /*
424
  Get all lists detail.
425
  @param {Array} data contains php array with key value pair.
426
  @options data {Integer} list_parent: This is the existing folder id & can be used to get all lists belonging to it [Optional]
427
  @options data {Integer} page: Maximum number of records per request is 50, if there are more than 50 processes then you can use this parameter to get next 50 results [Mandatory]
428
  @options data {Integer} page_limit: This should be a valid number between 1-50 [Mandatory]
429
  */
430
- public function get_lists($data)
431
- {
432
- return $this->get("list",json_encode($data));
433
- }
434
 
435
- /*
436
  Get a particular list detail.
437
  @param {Array} data contains php array with key value pair.
438
  @options data {Integer} id: Id of list to get details [Mandatory]
439
  */
440
- public function get_list($data)
441
- {
442
- return $this->get("list/".$data['id'],"");
443
- }
444
 
445
- /*
446
  Create a new list.
447
  @param {Array} data contains php array with key value pair.
448
  @options data {String} list_name: Desired name of the list to be created [Mandatory]
449
  @options data {Integer} list_parent: Folder ID [Mandatory]
450
  */
451
- public function create_list($data)
452
- {
453
- return $this->post("list",json_encode($data));
454
- }
455
 
456
- /*
457
  Update a list.
458
  @param {Array} data contains php array with key value pair.
459
  @options data {Integer} id: Id of list to be modified [Mandatory]
460
  @options data {String} list_name: Desired name of the list to be modified [Optional]
461
  @options data {Integer} list_parent: Folder ID [Mandatory]
462
  */
463
- public function update_list($data)
464
- {
465
- $id = $data['id'];
466
- unset($data['id']);
467
- return $this->put("list/".$id,json_encode($data));
468
- }
469
 
470
- /*
471
  Delete a specific list.
472
  @param {Array} data contains php array with key value pair.
473
  @options data {Integer} id: Id of list to be deleted [Mandatory]
474
  */
475
- public function delete_list($data)
476
- {
477
- return $this->delete("list/".$data['id'],"");
478
- }
479
 
480
- /*
481
  Display details of all users for the given lists.
482
  @param {Array} data contains php array with key value pair.
483
  @options data {Array} listids: These are the list ids to get their data. The ids found will display records [Mandatory]
@@ -485,82 +448,75 @@ class Mailin
485
  @options data {Integer} page: Maximum number of records per request is 500, if in your list there are more than 500 users then you can use this parameter to get next 500 results [Optional]
486
  @options data {Integer} page_limit: This should be a valid number between 1-500 [Optional]
487
  */
488
- public function display_list_users($data)
489
- {
490
- return $this->post("list/display",json_encode($data));
491
- }
492
 
493
- /*
494
  Add already existing users in the SendinBlue contacts to the list.
495
  @param {Array} data contains php array with key value pair.
496
  @options data {Integer} id: Id of list to link users in it [Mandatory]
497
  @options data {Array} users: Email address of the already existing user(s) in the SendinBlue contacts. Example: "test@example.net". You can use commas to separate multiple users [Mandatory]
498
  */
499
 
500
- public function add_users_list($data)
501
- {
502
- $id = $data['id'];
503
- unset($data['id']);
504
- return $this->post("list/".$id."/users",json_encode($data));
505
- }
506
 
507
- /*
508
  Delete already existing users in the SendinBlue contacts from the list.
509
  @param {Array} data contains php array with key value pair.
510
  @options data {Integer} id: Id of list to unlink users from it [Mandatory]
511
  @options data {Array} users: Email address of the already existing user(s) in the SendinBlue contacts to be modified. Example: "test@example.net". You can use commas to separate multiple users [Mandatory]
512
  */
513
- public function delete_users_list($data)
514
- {
515
- $id = $data['id'];
516
- unset($data['id']);
517
- return $this->delete("list/".$id."/delusers",json_encode($data));
518
- }
519
 
520
- /*
521
  Access all the attributes information under the account.
522
  No input required
523
  */
524
- public function get_attributes()
525
- {
526
- return $this->get("attribute","");
527
- }
528
 
529
- /*
530
  Access the specific type of attribute information.
531
  @param {Array} data contains php array with key value pair.
532
  @options data {String} type: Type of attribute. Possible values – normal, transactional, category, calculated & global [Optional]
533
  */
534
- public function get_attribute($data)
535
- {
536
- return $this->get("attribute/".$data['type'],"");
537
- }
538
 
539
- /*
540
  Create an Attribute.
541
  @param {Array} data contains php array with key value pair.
542
  @options data {String} type: Type of attribute. Possible values – normal, transactional, category, calculated & global ( case sensitive ) [Mandatory]
543
  @options data {Array} data: The name and data type of ‘normal’ & ‘transactional’ attribute to be created in your SendinBlue account. It should be sent as an associative array. Example: array(‘ATTRIBUTE_NAME1′ => ‘DATA_TYPE1′, ‘ATTRIBUTE_NAME2’=> ‘DATA_TYPE2′).
544
  The name and data value of ‘category’, ‘calculated’ & ‘global’, should be sent as JSON string. Example: ‘[{ "name":"ATTRIBUTE_NAME1", "value":"Attribute_value1" }, { "name":"ATTRIBUTE_NAME2", "value":"Attribute_value2" }]’. You can use commas to separate multiple attributes [Mandatory]
545
  */
546
- public function create_attribute($data)
547
- {
548
- return $this->post("attribute/",json_encode($data));
549
- }
550
 
551
- /*
552
  Delete a specific type of attribute information.
553
  @param {Array} data contains php array with key value pair.
554
  @options data {Integer} type: Type of attribute to be deleted [Mandatory]
555
  */
556
- public function delete_attribute($type,$data)
557
- {
558
- $type = $data['type'];
559
- unset($data['type']);
560
- return $this->post("attribute/".$type,json_encode($data));
561
- }
562
 
563
- /*
564
  Create a new user if an email provided as input, doesn’t exists in the contact list of your SendinBlue account, otherwise it will update the existing user.
565
  @param {Array} data contains php array with key value pair.
566
  @options data {String} email: Email address of the user to be created in SendinBlue contacts. Already existing email address of user in the SendinBlue contacts to be modified [Mandatory]
@@ -570,32 +526,29 @@ class Mailin
570
  @options data {Array} listid_unlink: The list id(s) to be unlinked from user [Optional]
571
  @options data {Array} blacklisted_sms: This is used to blacklist/ Unblacklist a user’s SMS number. Possible values – 0 & 1. blacklisted_sms = 1 means user’s SMS number has been blacklisted [Optional]
572
  */
573
- public function create_update_user($data)
574
- {
575
- return $this->post("user/createdituser",json_encode($data));
576
- }
577
 
578
- /*
579
  Get Access a specific user Information.
580
  @param {Array} data contains php array with key value pair.
581
  @options data {String} email: Email address of the already existing user in the SendinBlue contacts [Mandatory]
582
  */
583
- public function get_user($data)
584
- {
585
- return $this->get("user/".$data['email'],"");
586
- }
587
 
588
- /*
589
  Unlink existing user from all lists.
590
  @param {Array} data contains php array with key value pair.
591
  @options data {String} email: Email address of the already existing user in the SendinBlue contacts to be unlinked from all lists [Mandatory]
592
  */
593
- public function delete_user($data)
594
- {
595
- return $this->delete("user/".$data['email'],"");
596
- }
597
 
598
- /*
599
  Import Users Information.
600
  @param {Array} data contains php array with key value pair.
601
  @options data {String} url: The URL of the file to be imported. Possible file types – .txt, .csv [Mandatory: if body is empty]
@@ -605,65 +558,59 @@ class Mailin
605
  @options data {String} name: This is new list name which will be created first & then users will be imported in it [Mandatory: if listids is empty]
606
  @options data {Integer} list_parent: This is the existing folder id & can be used with name parameter to make newly created list’s desired parent [Optional]
607
  */
608
- public function import_users($data)
609
- {
610
- return $this->post("user/import",json_encode($data));
611
- }
612
 
613
- /*
614
  Export Users Information.
615
  @param {Array} data contains php array with key value pair.
616
  @options data {String} export_attrib: The name of attribute present in your SendinBlue account. You can use commas to separate multiple attributes. Example: "EMAIL,NAME,SMS" [Optional]
617
  @options data {String} filter: Filter can be added to export users. Example: "{\"blacklisted\":1}", will export all blacklisted users [Mandatory]
618
  @options data {String} notify_url: URL that will be called once the export process is finished [Optional]
619
  */
620
- public function export_users($data)
621
- {
622
- return $this->post("user/export",json_encode($data));
623
- }
624
 
625
- /*
626
  Get all the processes information under the account.
627
  @param {Array} data contains php array with key value pair.
628
  @options data {Integer} page: Maximum number of records per request is 50, if there are more than 50 processes then you can use this parameter to get next 50 results [Mandatory]
629
  @options data {Integer} page_limit: This should be a valid number between 1-50 [Mandatory]
630
  */
631
- public function get_processes($data)
632
- {
633
- return $this->get("process",json_encode($data));
634
- }
635
 
636
- /*
637
  Get the process information.
638
  @param {Array} data contains php array with key value pair.
639
  @options data {Integer} id: Id of process to get details [Mandatory]
640
  */
641
- public function get_process($data)
642
- {
643
- return $this->get("process/".$data['id'],"");
644
- }
645
 
646
- /*
647
  To retrieve details of all webhooks.
648
  @param {Array} data contains php array with key value pair.
649
  @options data {String} is_plat: Flag to get webhooks. Possible values – 0 & 1. Example: to get Transactional webhooks, use $is_plat=0, to get Marketing webhooks, use $is_plat=1, & to get all webhooks, use $is_plat="" [Optional]
650
  */
651
- public function get_webhooks($data)
652
- {
653
- return $this->get("webhook",json_encode($data));
654
- }
655
 
656
- /*
657
  To retrieve details of any particular webhook.
658
  @param {Array} data contains php array with key value pair.
659
  @options data {Integer} id: Id of webhook to get details [Mandatory]
660
  */
661
- public function get_webhook($data)
662
- {
663
- return $this->get("webhook/".$data['id'],"");
664
- }
665
 
666
- /*
667
  Create a Webhook.
668
  @param {Array} data contains php array with key value pair.
669
  @options data {String} url: URL that will be triggered by a webhook [Mandatory]
@@ -671,22 +618,20 @@ class Mailin
671
  @options data {Array} events: Set of events. You can use commas to separate multiple events. Possible values for Transcational webhook – request, delivered, hard_bounce, soft_bounce, blocked, spam, invalid_email, deferred, click, & opened and Possible Values for Marketing webhook – spam, opened, click, hard_bounce, unsubscribe, soft_bounce & list_addition ( case sensitive ) [Mandatory]
672
  @options data {Integer} is_plat: Flag to create webhook type. Possible values – 0 (default) & 1. Example: to create Transactional webhooks, use $is_plat=0, & to create Marketing webhooks, use $is_plat=1 [Optional]
673
  */
674
- public function create_webhook($data)
675
- {
676
- return $this->post("webhook",json_encode($data));
677
- }
678
 
679
- /*
680
  Delete a webhook.
681
  @param {Array} data contains php array with key value pair.
682
  @options data {Integer} id: Id of webhook to be deleted [Mandatory]
683
  */
684
- public function delete_webhook($data)
685
- {
686
- return $this->delete("webhook/".$data['id'],"");
687
- }
688
 
689
- /*
690
  Update a webhook.
691
  @param {Array} data contains php array with key value pair.
692
  @options data {Integer} id: Id of webhook to be modified [Mandatory]
@@ -694,60 +639,55 @@ class Mailin
694
  @options data {String} description: Webook description [Optional]
695
  @options data {Array} events: Set of events. You can use commas to separate multiple events. Possible values for Transcational webhook – request, delivered, hard_bounce, soft_bounce, blocked, spam, invalid_email, deferred, click, & opened and Possible Values for Marketing webhook – spam, opened, click, hard_bounce, unsubscribe, soft_bounce & list_addition ( case sensitive ) [Mandatory]
696
  */
697
- public function update_webhook($data)
698
- {
699
- $id = $data['id'];
700
- unset($data['id']);
701
- return $this->put("webhook/".$id,json_encode($data));
702
- }
703
 
704
- /*
705
  Get Access of created senders information.
706
  @param {Array} data contains php array with key value pair.
707
  @options data {String} option: Options to get senders. Possible options – IP-wise, & Domain-wise ( only for dedicated IP clients ). Example: to get senders with specific IP, use $option=’1.2.3.4′, to get senders with specific domain use, $option=’domain.com’, & to get all senders, use $option="" [Optional]
708
  */
709
- public function get_senders($data)
710
- {
711
- return $this->get("advanced",json_encode($data));
712
- }
713
 
714
- /*
715
  Create your Senders.
716
  @param {Array} data contains php array with key value pair.
717
  @options data {String} name: Name of the sender [Mandatory]
718
  @options data {String} email: Email address of the sender [Mandatory]
719
  @options data {Array} ip_domain: Pass pipe ( | ) separated Dedicated IP and its associated Domain. Example: "1.2.3.4|mydomain.com". You can use commas to separate multiple ip_domain’s [Mandatory: Only for Dedicated IP clients, for Shared IP clients, it should be kept blank]
720
  */
721
- public function create_sender($data)
722
- {
723
- return $this->post("advanced",json_encode($data));
724
- }
725
 
726
- /*
727
  Update your Senders.
728
  @param {Array} data contains php array with key value pair.
729
  @options data {Integer} id: Id of sender to be modified [Mandatory]
730
  @options data {String} name: Name of the sender [Mandatory]
731
  @options data {Array} ip_domain: Pass pipe ( | ) separated Dedicated IP and its associated Domain. Example: "1.2.3.4|mydomain.com". You can use commas to separate multiple ip_domain’s [Mandatory: Only for Dedicated IP clients, for Shared IP clients, it should be kept blank]
732
  */
733
- public function update_sender($data)
734
- {
735
- $id = $data['id'];
736
- unset($data['id']);
737
- return $this->put("advanced/".$id,json_encode($data));
738
- }
739
 
740
- /*
741
  Delete your Sender Information.
742
  @param {Array} data contains php array with key value pair.
743
  @options data {Integer} id: Id of sender to be deleted [Mandatory]
744
  */
745
- public function delete_sender($data)
746
- {
747
- return $this->delete("advanced/".$data['id'],"");
748
- }
749
 
750
- /*
751
  Send Transactional Email.
752
  @param {Array} data contains php array with key value pair.
753
  @options data {Array} to: Email address of the recipient(s). It should be sent as an associative array. Example: array("to@example.net"=>"to whom"). You can use commas to separate multiple recipients [Mandatory]
@@ -762,12 +702,11 @@ class Mailin
762
  @options data {Array} headers: The headers will be sent along with the mail headers in original email. Example: array("Content-Type"=>"text/html; charset=iso-8859-1"). You can use commas to separate multiple headers [Optional]
763
  @options data {Array} inline_image: Pass your inline image/s filename & its base64 encoded chunk data as an associative array. Example: array("YourFileName.Extension"=>"Base64EncodedChunkData"). You can use commas to separate multiple inline images [Optional]
764
  */
765
- public function send_email($data)
766
- {
767
- return $this->post("email",json_encode($data));
768
- }
769
 
770
- /*
771
  Aggregate / date-wise report of the SendinBlue SMTP account.
772
  @param {Array} data contains php array with key value pair.
773
  @options data {Integer} aggregate: This is used to indicate, you are interested in all-time totals. Possible values – 0 & 1. aggregate = 0 means it will not aggregate records, and will show stats per day/date wise [Optional]
@@ -776,12 +715,11 @@ class Mailin
776
  @options data {Integer} days: Number of days in the past to include statistics ( Includes today ). It must be an integer greater than 0 [Optional]
777
  @options data {String} tag: The tag you will specify to retrieve detailed stats. It must be an existing tag that has statistics [Optional]
778
  */
779
- public function get_statistics($data)
780
- {
781
- return $this->post("statistics",json_encode($data));
782
- }
783
 
784
- /*
785
  Get Email Event report.
786
  @param {Array} data contains php array with key value pair.
787
  @options data {Integer} limit: To limit the number of results returned. It should be an integer [Optional]
@@ -792,24 +730,22 @@ class Mailin
792
  @options data {Integer} days: Number of days in the past (includes today). If specified, must be an integer greater than 0 [Optional]
793
  @options data {String} email: Email address to search report for [Optional]
794
  */
795
- public function get_report($data)
796
- {
797
- return $this->post("report",json_encode($data));
798
- }
799
 
800
- /*
801
  Delete any hardbounce, which actually would have been blocked due to some temporary ISP failures.
802
  @param {Array} data contains php array with key value pair.
803
  @options data {String} start_date: The start date to get report from. Date must be in YYYY-MM-DD format and should be before the end_date [Optional]
804
  @options data {String} end_date: The end date to get report till date. Date must be in YYYY-MM-DD format and should be after the start_date [Optional]
805
  @options data {String} email: Email address to delete its bounces [Optional]
806
  */
807
- public function delete_bounces($data)
808
- {
809
- return $this->post("bounces",json_encode($data));
810
- }
811
 
812
- /*
813
  Send templates created on SendinBlue, through SendinBlue SMTP (transactional mails).
814
  @param {Array} data contains php array with key value pair.
815
  @options data {Integer} id: Id of the template created on SendinBlue account [Mandatory]
@@ -820,14 +756,13 @@ class Mailin
820
  @options data {String} attachment_url: Provide the absolute url of the attachment. Url not allowed from local machine. File must be hosted somewhere [Optional]
821
  @options data {Array} attachment: To send attachment/s generated on the fly you have to pass your attachment/s filename & its base64 encoded chunk data as an associative array [Optional]
822
  */
823
- public function send_transactional_template($data)
824
- {
825
- $id = $data['id'];
826
- unset($data['id']);
827
- return $this->put("template/".$id,json_encode($data));
828
- }
829
 
830
- /*
831
  Create a Template.
832
  @param {Array} data contains php array with key value pair.
833
  @options data {String} from_name: Sender name from which the campaign emails are sent [Mandatory: for Dedicated IP clients & for Shared IP clients, if sender exists]
@@ -842,12 +777,11 @@ class Mailin
842
  @options data {Integer} status: Status of template. Possible values = 0 (default) & 1. status = 0 means template is inactive, & status = 1 means template is active [Optional]
843
  @options data {Integer} attachment: Status of attachment. Possible values = 0 (default) & 1. attach = 0 means an attachment can’t be sent, & attach = 1 means an attachment can be sent, in the email [Optional]
844
  */
845
- public function create_template($data)
846
- {
847
- return $this->post("template",json_encode($data));
848
- }
849
 
850
- /*
851
  Update a Template.
852
  @param {Array} data contains php array with key value pair.
853
  @options data {Integer} id: Id of Template to be modified [Mandatory]
@@ -863,14 +797,13 @@ class Mailin
863
  @options data {Integer} status: Status of template. Possible values = 0 (default) & 1. status = 0 means template is inactive, & status = 1 means template is active [Optional]
864
  @options data {Integer} attachment: Status of attachment. Possible values = 0 (default) & 1. attach = 0 means an attachment can’t be sent, & attach = 1 means an attachment can be sent, in the email [Optional]
865
  */
866
- public function update_template($data)
867
- {
868
- $id = $data['id'];
869
- unset($data['id']);
870
- return $this->put("template/".$id,json_encode($data));
871
- }
872
 
873
- /*
874
  Send a transactional SMS.
875
  @param {Array} data contains php array with key value pair.
876
  @options data {String} to: The mobile number to send SMS to with country code [Mandatory]
@@ -880,12 +813,11 @@ class Mailin
880
  @options data {String} tag: The tag that you can associate with the message [Optional]
881
  @options data {String} type: Type of message. Possible values – marketing (default) & transactional. You can use marketing for sending marketing SMS, & for sending transactional SMS, use transactional type [Optional]
882
  */
883
- public function send_sms($data)
884
- {
885
- return $this->post("sms",json_encode($data));
886
- }
887
 
888
- /*
889
  Create & Schedule your SMS campaigns.
890
  @param {Array} data contains php array with key value pair.
891
  @options data {String} name: Name of the SMS campaign [Mandatory]
@@ -897,12 +829,11 @@ class Mailin
897
  @options data {String} scheduled_date: The day on which the SMS campaign is supposed to run [Optional]
898
  @options data {Integer} send_now: Flag to send campaign now. Possible values = 0 (default) & 1. send_now = 0 means campaign can’t be send now, & send_now = 1 means campaign ready to send now [Optional]
899
  */
900
- public function create_sms_campaign($data)
901
- {
902
- return $this->post("sms",json_encode($data));
903
- }
904
 
905
- /*
906
  Update your SMS campaigns.
907
  @param {Array} data contains php array with key value pair.
908
  @options data {Integer} id: Id of the SMS campaign [Mandatory]
@@ -915,25 +846,23 @@ class Mailin
915
  @options data {String} scheduled_date: The day on which the SMS campaign is supposed to run [Optional]
916
  @options data {Integer} send_now: Flag to send campaign now. Possible values = 0 (default) & 1. send_now = 0 means campaign can’t be send now, & send_now = 1 means campaign ready to send now [Optional]
917
  */
918
- public function update_sms_campaign($data)
919
- {
920
- $id = $data['id'];
921
- unset($data['id']);
922
- return $this->put("sms/".$id,json_encode($data));
923
- }
924
 
925
- /*
926
  Send a Test SMS.
927
  @param {Array} data contains php array with key value pair.
928
  @options data {Integer} id: Id of the SMS campaign [Mandatory]
929
  @options data {String} to: Mobile number with the country code to send test SMS. The mobile number defined here should belong to one of your contacts in SendinBlue account and should not be blacklisted [Mandatory]
930
  */
931
- public function send_bat_sms($data)
932
- {
933
- $id = $data['id'];
934
- unset($data['id']);
935
- return $this->get("sms/".$id,json_encode($data));
936
- }
937
 
938
  }
939
- ?>
4
  * SendinBlue REST client
5
  */
6
 
7
+ class Mailin {
8
+
9
+ public $api_key;
10
+ public $base_url;
11
+ public $curl_opts = array();
12
+ public function __construct( $base_url, $api_key ) {
13
+ if ( ! function_exists( 'curl_init' ) ) {
14
+ throw new Exception( 'Mailin requires CURL module' );
15
+ }
16
+ $this->base_url = $base_url;
17
+ $this->api_key = $api_key;
18
+ }
19
+ /**
20
+ * Do CURL request with authorization
21
+ */
22
+ private function do_request( $resource, $method, $input ) {
23
+ $called_url = $this->base_url . '/' . $resource;
24
+ $ch = curl_init( $called_url );
25
+ $auth_header = 'api-key:' . $this->api_key;
26
+ $content_header = 'Content-Type:application/json';
27
+ if ( strtoupper( substr( PHP_OS, 0, 3 ) ) === 'WIN' ) {
28
+ // Windows only over-ride
29
+ curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
30
+ }
31
+ curl_setopt( $ch, CURLOPT_HTTPHEADER, array( $auth_header, $content_header ) );
32
+ curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1 );
33
+ curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, $method );
34
+ curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
35
+ curl_setopt( $ch, CURLOPT_HEADER, 0 );
36
+ curl_setopt( $ch, CURLOPT_POSTFIELDS, $input );
37
+ $data = curl_exec( $ch );
38
+ if ( curl_errno( $ch ) ) {
39
+ echo 'Curl error: ' . curl_error( $ch ) . '\n';
40
+ }
41
+ curl_close( $ch );
42
+ return json_decode( $data,true );
43
+ }
44
+ public function get( $resource, $input ) {
45
+ return $this->do_request( $resource,'GET',$input );
46
+ }
47
+ public function put( $resource, $input ) {
48
+ return $this->do_request( $resource,'PUT',$input );
49
+ }
50
+ public function post( $resource, $input ) {
51
+ return $this->do_request( $resource,'POST',$input );
52
+ }
53
+ public function delete( $resource, $input ) {
54
+ return $this->do_request( $resource,'DELETE',$input );
55
+ }
56
+
57
+ /*
 
 
 
 
 
 
 
 
58
  Get Account.
59
  No input required
60
  */
61
+ public function get_account() {
62
+ return $this->get( 'account','' );
63
+ }
 
64
 
65
+ /*
66
  Get SMTP details.
67
  No input required
68
  */
69
+ public function get_smtp_details() {
70
+ return $this->get( 'account/smtpdetail','' );
71
+ }
 
72
 
73
+ /*
74
  Create Child Account.
75
  @param {Array} data contains php array with key value pair.
76
  @options data {String} child_email: Email address of Reseller child [Mandatory]
83
  - sms_credit {Integer} Number of sms credts
84
  @options data {Array} associate_ip: Associate dedicated IPs to reseller child. You can use commas to separate multiple IPs [Optional]
85
  */
86
+ public function create_child_account( $data ) {
87
+ return $this->post( 'account',json_encode( $data ) );
88
+ }
 
89
 
90
+ /*
91
  Update Child Account.
92
  @param {Array} data contains php array with key value pair.
93
  @options data {String} auth_key: 16 character authorization key of Reseller child to be modified [Mandatory]
98
  @options data {Array} associate_ip: Associate dedicated IPs to reseller child. You can use commas to separate multiple IPs [Optional]
99
  @options data {Array} disassociate_ip: Disassociate dedicated IPs from reseller child. You can use commas to separate multiple IPs [Optional]
100
  */
101
+ public function update_child_account( $data ) {
102
+ return $this->put( 'account',json_encode( $data ) );
103
+ }
 
104
 
105
+ /*
106
  Delete Child Account.
107
  @param {Array} data contains php array with key value pair.
108
  @options data {String} auth_key: 16 character authorization key of Reseller child to be deleted [Mandatory]
109
  */
110
+ public function delete_child_account( $data ) {
111
+ return $this->delete( 'account/' . $data['auth_key'],'' );
112
+ }
 
113
 
114
+ /*
115
  Get Reseller child Account.
116
  @param {Array} data contains php array with key value pair.
117
  @options data {String} auth_key: 16 character authorization key of Reseller child. Example : To get the details of more than one child account, use, {"key1":"abC01De2fGHI3jkL","key2":"mnO45Pq6rSTU7vWX"} [Mandatory]
118
  */
119
+ public function get_reseller_child( $data ) {
120
+ return $this->post( 'account/getchildv2',json_encode( $data ) );
121
+ }
 
122
 
123
+ /*
124
  Add/Remove Reseller child's Email/Sms credits.
125
  @param {Array} data contains php array with key value pair.
126
  @options data {String} auth_key: 16 character authorization key of Reseller child to modify credits [Mandatory]
131
  - email_credit {Integer} number of email credits
132
  - sms_credit {Integer} Number of sms credts
133
  */
134
+ public function add_remove_child_credits( $data ) {
135
+ return $this->post( 'account/addrmvcredit',json_encode( $data ) );
136
+ }
 
137
 
138
+ /*
139
  Get a particular campaign detail.
140
  @param {Array} data contains php array with key value pair.
141
  @options data {Integer} id: Unique Id of the campaign [Mandatory]
142
  */
143
+ public function get_campaign_v2( $data ) {
144
+ return $this->get( 'campaign/' . $data['id'] . '/detailsv2','' );
145
+ }
 
146
 
147
+ /*
148
  Get all campaigns detail.
149
  @param {Array} data contains php array with key value pair.
150
  @options data {String} type: Type of campaign. Possible values – classic, trigger, sms, template ( case sensitive ) [Optional]
152
  @options data {Integer} page: Maximum number of records per request is 500, if there are more than 500 campaigns then you can use this parameter to get next 500 results [Optional]
153
  @options data {Integer} page_limit: This should be a valid number between 1-500 [Optional]
154
  */
155
+ public function get_campaigns_v2( $data ) {
156
+ return $this->get( 'campaign/detailsv2',json_encode( $data ) );
157
+ }
 
158
 
159
+ /*
160
  Create and Schedule your campaigns. It returns the ID of the created campaign.
161
  @param {Array} data contains php array with key value pair.
162
  @options data {String} category: Tag name of the campaign [Optional]
178
  @options data {Integer} send_now: Flag to send campaign now. Possible values = 0 (default) & 1. send_now = 0 means campaign can’t be send now, & send_now = 1 means campaign ready to send now [Optional]
179
 
180
  */
181
+ public function create_campaign( $data ) {
182
+ return $this->post( 'campaign',json_encode( $data ) );
183
+ }
 
184
 
185
+ /*
186
  Update your campaign.
187
  @param {Array} data contains php array with key value pair.
188
  @options data {Integer} id: Id of campaign to be modified [Mandatory]
204
  @options data {Integer} mirror_active: Status of mirror links in campaign. Possible values = 0 & 1 (default). mirror_active = 0 means mirror links are deactivated, & mirror_active = 1 means mirror links are activated, in the campaign [Optional]
205
  @options data {Integer} send_now: Flag to send campaign now. Possible values = 0 (default) & 1. send_now = 0 means campaign can’t be send now, & send_now = 1 means campaign ready to send now [Optional]
206
  */
207
+ public function update_campaign( $data ) {
208
+ $id = $data['id'];
209
+ unset( $data['id'] );
210
+ return $this->put( 'campaign/' . $id,json_encode( $data ) );
211
+ }
 
212
 
213
+ /*
214
  Delete your campaigns.
215
  @param {Array} data contains php array with key value pair.
216
  @options data {Integer} id: Id of campaign to be deleted [Mandatory]
217
  */
218
+ public function delete_campaign( $data ) {
219
+ return $this->delete( 'campaign/' . $data['id'],'' );
220
+ }
 
221
 
222
+ /*
223
  Send report of Sent and Archived campaign.
224
  @param {Array} data contains php array with key value pair.
225
  @options data {Integer} id: Id of campaign to send its report [Mandatory]
231
  @options data {Array} email_cc: Same as email_to but for Cc [Optional]
232
  @options data {String} email_body: Body of the message [Mandatory]
233
  */
234
+ public function campaign_report_email( $data ) {
235
+ $id = $data['id'];
236
+ unset( $data['id'] );
237
+ return $this->post( 'campaign/' . $id . '/report',json_encode( $data ) );
238
+ }
 
239
 
240
+ /*
241
  Export the recipients of a specified campaign.
242
  @param {Array} data contains php array with key value pair.
243
  @options data {Integer} id: Id of campaign to export its recipients [Mandatory]
244
  @options data {String} notify_url: URL that will be called once the export process is finished [Mandatory]
245
  @options data {String} type: Type of recipients. Possible values – all, non_clicker, non_opener, clicker, opener, soft_bounces, hard_bounces & unsubscribes [Mandatory]
246
  */
247
+ public function campaign_recipients_export( $data ) {
248
+ $id = $data['id'];
249
+ unset( $data['id'] );
250
+ return $this->post( 'campaign/' . $id . '/recipients',json_encode( $data ) );
251
+ }
 
252
 
253
+ /*
254
  Get the Campaign name, subject and share link of the classic type campaigns only which are sent, for those which are not sent and the rest of campaign types like trigger, template & sms, will return an error message of share link not available.
255
  @param {Array} data contains php array with key value pair.
256
  @options data {Array} camp_ids: Id of campaign to get share link. You can use commas to separate multiple ids [Mandatory]
257
  */
258
 
259
+ public function share_campaign( $data ) {
260
+ return $this->post( 'campaign/sharelinkv2',json_encode( $data ) );
261
+ }
 
262
 
263
+ /*
264
  Send a Test Campaign.
265
  @param {Array} data contains php array with key value pair.
266
  @options data {Integer} id: Id of the campaign [Mandatory]
267
  @options data {Array} emails: Email address of recipient(s) existing in the one of the lists & should not be blacklisted. Example: "test@example.net". You can use commas to separate multiple recipients [Mandatory]
268
  */
269
+ public function send_bat_email( $data ) {
270
+ $id = $data['id'];
271
+ unset( $data['id'] );
272
+ return $this->post( 'campaign/' . $id . '/test',json_encode( $data ) );
273
+ }
 
274
 
275
+ /*
276
  Update the Campaign status.
277
  @param {Array} data contains php array with key value pair.
278
  @options data {Integer} id: Id of campaign to update its status [Mandatory]
279
  @options data {String} status: Types of status. Possible values – suspended, archive, darchive, sent, queued, replicate and replicate_template ( case sensitive ) [Mandatory]
280
  */
281
+ public function update_campaign_status( $data ) {
282
+ $id = $data['id'];
283
+ unset( $data['id'] );
284
+ return $this->put( 'campaign/' . $id . '/updatecampstatus',json_encode( $data ) );
285
+ }
 
286
 
287
+ /*
288
  Create and schedule your Trigger campaigns.
289
  @param {Array} data contains php array with key value pair.
290
  @options data {String} category: Tag name of the campaign [Optional]
306
  @options data {Integer} mirror_active: Status of mirror links in campaign. Possible values = 0 & 1 (default). mirror_active = 0 means mirror links are deactivated, & mirror_active = 1 means mirror links are activated, in the campaign [Optional]
307
  @options data {Integer} send_now: Flag to send campaign now. Possible values = 0 (default) & 1. send_now = 0 means campaign can’t be send now, & send_now = 1 means campaign ready to send now [Optional]
308
  */
309
+ public function create_trigger_campaign( $data ) {
310
+ return $this->post( 'campaign',json_encode( $data ) );
311
+ }
 
312
 
313
+ /*
314
  Update and schedule your Trigger campaigns.
315
  @param {Array} data contains php array with key value pair.
316
  @options data {Integer} id: Id of Trigger campaign to be modified [Mandatory]
333
  @options data {Integer} mirror_active: Status of mirror links in campaign. Possible values = 0 & 1 (default). mirror_active = 0 means mirror links are deactivated, & mirror_active = 1 means mirror links are activated, in the campaign [Optional]
334
  @options data {Integer} send_now: Flag to send campaign now. Possible values = 0 (default) & 1. send_now = 0 means campaign can’t be send now, & send_now = 1 means campaign ready to send now [Optional]
335
  */
336
+ public function update_trigger_campaign( $data ) {
337
+ $id = $data['id'];
338
+ unset( $data['id'] );
339
+ return $this->put( 'campaign/' . $id,json_encode( $data ) );
340
+ }
 
341
 
342
+ /*
343
  Get all folders detail.
344
  @param {Array} data contains php array with key value pair.
345
  @options data {Integer} page: Maximum number of records per request is 50, if there are more than 50 folders then you can use this parameter to get next 50 results [Mandatory]
346
  @options data {Integer} page_limit: This should be a valid number between 1-50 [Mandatory]
347
  */
348
+ public function get_folders( $data ) {
349
+ return $this->get( 'folder',json_encode( $data ) );
350
+ }
 
351
 
352
+ /*
353
  Get a particular folder detail.
354
  @param {Array} data contains php array with key value pair.
355
  @options data {Integer} id: Id of folder to get details [Mandatory]
356
  */
357
+ public function get_folder( $data ) {
358
+ return $this->get( 'folder/' . $data['id'],'' );
359
+ }
 
360
 
361
+ /*
362
  Create a new folder.
363
  @param {Array} data contains php array with key value pair.
364
  @options data {String} name: Desired name of the folder to be created [Mandatory]
365
  */
366
+ public function create_folder( $data ) {
367
+ return $this->post( 'folder',json_encode( $data ) );
368
+ }
 
369
 
370
+ /*
371
  Delete a specific folder information.
372
  @param {Array} data contains php array with key value pair.
373
  @options data {Integer} id: Id of folder to be deleted [Mandatory]
374
  */
375
+ public function delete_folder( $data ) {
376
+ return $this->delete( 'folder/' . $data['id'],'' );
377
+ }
 
378
 
379
+ /*
380
  Update an existing folder.
381
  @param {Array} data contains php array with key value pair.
382
  @options data {Integer} id: Id of folder to be modified [Mandatory]
383
  @options data {String} name: Desired name of the folder to be modified [Mandatory]
384
  */
385
+ public function update_folder( $data ) {
386
+ $id = $data['id'];
387
+ unset( $data['id'] );
388
+ return $this->put( 'folder/' . $id,json_encode( $data ) );
389
+ }
 
390
 
391
+ /*
392
  Get all lists detail.
393
  @param {Array} data contains php array with key value pair.
394
  @options data {Integer} list_parent: This is the existing folder id & can be used to get all lists belonging to it [Optional]
395
  @options data {Integer} page: Maximum number of records per request is 50, if there are more than 50 processes then you can use this parameter to get next 50 results [Mandatory]
396
  @options data {Integer} page_limit: This should be a valid number between 1-50 [Mandatory]
397
  */
398
+ public function get_lists( $data ) {
399
+ return $this->get( 'list',json_encode( $data ) );
400
+ }
 
401
 
402
+ /*
403
  Get a particular list detail.
404
  @param {Array} data contains php array with key value pair.
405
  @options data {Integer} id: Id of list to get details [Mandatory]
406
  */
407
+ public function get_list( $data ) {
408
+ return $this->get( 'list/' . $data['id'],'' );
409
+ }
 
410
 
411
+ /*
412
  Create a new list.
413
  @param {Array} data contains php array with key value pair.
414
  @options data {String} list_name: Desired name of the list to be created [Mandatory]
415
  @options data {Integer} list_parent: Folder ID [Mandatory]
416
  */
417
+ public function create_list( $data ) {
418
+ return $this->post( 'list',json_encode( $data ) );
419
+ }
 
420
 
421
+ /*
422
  Update a list.
423
  @param {Array} data contains php array with key value pair.
424
  @options data {Integer} id: Id of list to be modified [Mandatory]
425
  @options data {String} list_name: Desired name of the list to be modified [Optional]
426
  @options data {Integer} list_parent: Folder ID [Mandatory]
427
  */
428
+ public function update_list( $data ) {
429
+ $id = $data['id'];
430
+ unset( $data['id'] );
431
+ return $this->put( 'list/' . $id,json_encode( $data ) );
432
+ }
 
433
 
434
+ /*
435
  Delete a specific list.
436
  @param {Array} data contains php array with key value pair.
437
  @options data {Integer} id: Id of list to be deleted [Mandatory]
438
  */
439
+ public function delete_list( $data ) {
440
+ return $this->delete( 'list/' . $data['id'],'' );
441
+ }
 
442
 
443
+ /*
444
  Display details of all users for the given lists.
445
  @param {Array} data contains php array with key value pair.
446
  @options data {Array} listids: These are the list ids to get their data. The ids found will display records [Mandatory]
448
  @options data {Integer} page: Maximum number of records per request is 500, if in your list there are more than 500 users then you can use this parameter to get next 500 results [Optional]
449
  @options data {Integer} page_limit: This should be a valid number between 1-500 [Optional]
450
  */
451
+ public function display_list_users( $data ) {
452
+ return $this->post( 'list/display',json_encode( $data ) );
453
+ }
 
454
 
455
+ /*
456
  Add already existing users in the SendinBlue contacts to the list.
457
  @param {Array} data contains php array with key value pair.
458
  @options data {Integer} id: Id of list to link users in it [Mandatory]
459
  @options data {Array} users: Email address of the already existing user(s) in the SendinBlue contacts. Example: "test@example.net". You can use commas to separate multiple users [Mandatory]
460
  */
461
 
462
+ public function add_users_list( $data ) {
463
+ $id = $data['id'];
464
+ unset( $data['id'] );
465
+ return $this->post( 'list/' . $id . '/users',json_encode( $data ) );
466
+ }
 
467
 
468
+ /*
469
  Delete already existing users in the SendinBlue contacts from the list.
470
  @param {Array} data contains php array with key value pair.
471
  @options data {Integer} id: Id of list to unlink users from it [Mandatory]
472
  @options data {Array} users: Email address of the already existing user(s) in the SendinBlue contacts to be modified. Example: "test@example.net". You can use commas to separate multiple users [Mandatory]
473
  */
474
+ public function delete_users_list( $data ) {
475
+ $id = $data['id'];
476
+ unset( $data['id'] );
477
+ return $this->delete( 'list/' . $id . '/delusers',json_encode( $data ) );
478
+ }
 
479
 
480
+ /*
481
  Access all the attributes information under the account.
482
  No input required
483
  */
484
+ public function get_attributes() {
485
+ return $this->get( 'attribute','' );
486
+ }
 
487
 
488
+ /*
489
  Access the specific type of attribute information.
490
  @param {Array} data contains php array with key value pair.
491
  @options data {String} type: Type of attribute. Possible values – normal, transactional, category, calculated & global [Optional]
492
  */
493
+ public function get_attribute( $data ) {
494
+ return $this->get( 'attribute/' . $data['type'],'' );
495
+ }
 
496
 
497
+ /*
498
  Create an Attribute.
499
  @param {Array} data contains php array with key value pair.
500
  @options data {String} type: Type of attribute. Possible values – normal, transactional, category, calculated & global ( case sensitive ) [Mandatory]
501
  @options data {Array} data: The name and data type of ‘normal’ & ‘transactional’ attribute to be created in your SendinBlue account. It should be sent as an associative array. Example: array(‘ATTRIBUTE_NAME1′ => ‘DATA_TYPE1′, ‘ATTRIBUTE_NAME2’=> ‘DATA_TYPE2′).
502
  The name and data value of ‘category’, ‘calculated’ & ‘global’, should be sent as JSON string. Example: ‘[{ "name":"ATTRIBUTE_NAME1", "value":"Attribute_value1" }, { "name":"ATTRIBUTE_NAME2", "value":"Attribute_value2" }]’. You can use commas to separate multiple attributes [Mandatory]
503
  */
504
+ public function create_attribute( $data ) {
505
+ return $this->post( 'attribute/',json_encode( $data ) );
506
+ }
 
507
 
508
+ /*
509
  Delete a specific type of attribute information.
510
  @param {Array} data contains php array with key value pair.
511
  @options data {Integer} type: Type of attribute to be deleted [Mandatory]
512
  */
513
+ public function delete_attribute( $type, $data ) {
514
+ $type = $data['type'];
515
+ unset( $data['type'] );
516
+ return $this->post( 'attribute/' . $type,json_encode( $data ) );
517
+ }
 
518
 
519
+ /*
520
  Create a new user if an email provided as input, doesn’t exists in the contact list of your SendinBlue account, otherwise it will update the existing user.
521
  @param {Array} data contains php array with key value pair.
522
  @options data {String} email: Email address of the user to be created in SendinBlue contacts. Already existing email address of user in the SendinBlue contacts to be modified [Mandatory]
526
  @options data {Array} listid_unlink: The list id(s) to be unlinked from user [Optional]
527
  @options data {Array} blacklisted_sms: This is used to blacklist/ Unblacklist a user’s SMS number. Possible values – 0 & 1. blacklisted_sms = 1 means user’s SMS number has been blacklisted [Optional]
528
  */
529
+ public function create_update_user( $data ) {
530
+ return $this->post( 'user/createdituser',json_encode( $data ) );
531
+ }
 
532
 
533
+ /*
534
  Get Access a specific user Information.
535
  @param {Array} data contains php array with key value pair.
536
  @options data {String} email: Email address of the already existing user in the SendinBlue contacts [Mandatory]
537
  */
538
+ public function get_user( $data ) {
539
+ return $this->get( 'user/' . $data['email'],'' );
540
+ }
 
541
 
542
+ /*
543
  Unlink existing user from all lists.
544
  @param {Array} data contains php array with key value pair.
545
  @options data {String} email: Email address of the already existing user in the SendinBlue contacts to be unlinked from all lists [Mandatory]
546
  */
547
+ public function delete_user( $data ) {
548
+ return $this->delete( 'user/' . $data['email'],'' );
549
+ }
 
550
 
551
+ /*
552
  Import Users Information.
553
  @param {Array} data contains php array with key value pair.
554
  @options data {String} url: The URL of the file to be imported. Possible file types – .txt, .csv [Mandatory: if body is empty]
558
  @options data {String} name: This is new list name which will be created first & then users will be imported in it [Mandatory: if listids is empty]
559
  @options data {Integer} list_parent: This is the existing folder id & can be used with name parameter to make newly created list’s desired parent [Optional]
560
  */
561
+ public function import_users( $data ) {
562
+ return $this->post( 'user/import',json_encode( $data ) );
563
+ }
 
564
 
565
+ /*
566
  Export Users Information.
567
  @param {Array} data contains php array with key value pair.
568
  @options data {String} export_attrib: The name of attribute present in your SendinBlue account. You can use commas to separate multiple attributes. Example: "EMAIL,NAME,SMS" [Optional]
569
  @options data {String} filter: Filter can be added to export users. Example: "{\"blacklisted\":1}", will export all blacklisted users [Mandatory]
570
  @options data {String} notify_url: URL that will be called once the export process is finished [Optional]
571
  */
572
+ public function export_users( $data ) {
573
+ return $this->post( 'user/export',json_encode( $data ) );
574
+ }
 
575
 
576
+ /*
577
  Get all the processes information under the account.
578
  @param {Array} data contains php array with key value pair.
579
  @options data {Integer} page: Maximum number of records per request is 50, if there are more than 50 processes then you can use this parameter to get next 50 results [Mandatory]
580
  @options data {Integer} page_limit: This should be a valid number between 1-50 [Mandatory]
581
  */
582
+ public function get_processes( $data ) {
583
+ return $this->get( 'process',json_encode( $data ) );
584
+ }
 
585
 
586
+ /*
587
  Get the process information.
588
  @param {Array} data contains php array with key value pair.
589
  @options data {Integer} id: Id of process to get details [Mandatory]
590
  */
591
+ public function get_process( $data ) {
592
+ return $this->get( 'process/' . $data['id'],'' );
593
+ }
 
594
 
595
+ /*
596
  To retrieve details of all webhooks.
597
  @param {Array} data contains php array with key value pair.
598
  @options data {String} is_plat: Flag to get webhooks. Possible values – 0 & 1. Example: to get Transactional webhooks, use $is_plat=0, to get Marketing webhooks, use $is_plat=1, & to get all webhooks, use $is_plat="" [Optional]
599
  */
600
+ public function get_webhooks( $data ) {
601
+ return $this->get( 'webhook',json_encode( $data ) );
602
+ }
 
603
 
604
+ /*
605
  To retrieve details of any particular webhook.
606
  @param {Array} data contains php array with key value pair.
607
  @options data {Integer} id: Id of webhook to get details [Mandatory]
608
  */
609
+ public function get_webhook( $data ) {
610
+ return $this->get( 'webhook/' . $data['id'],'' );
611
+ }
 
612
 
613
+ /*
614
  Create a Webhook.
615
  @param {Array} data contains php array with key value pair.
616
  @options data {String} url: URL that will be triggered by a webhook [Mandatory]
618
  @options data {Array} events: Set of events. You can use commas to separate multiple events. Possible values for Transcational webhook – request, delivered, hard_bounce, soft_bounce, blocked, spam, invalid_email, deferred, click, & opened and Possible Values for Marketing webhook – spam, opened, click, hard_bounce, unsubscribe, soft_bounce & list_addition ( case sensitive ) [Mandatory]
619
  @options data {Integer} is_plat: Flag to create webhook type. Possible values – 0 (default) & 1. Example: to create Transactional webhooks, use $is_plat=0, & to create Marketing webhooks, use $is_plat=1 [Optional]
620
  */
621
+ public function create_webhook( $data ) {
622
+ return $this->post( 'webhook',json_encode( $data ) );
623
+ }
 
624
 
625
+ /*
626
  Delete a webhook.
627
  @param {Array} data contains php array with key value pair.
628
  @options data {Integer} id: Id of webhook to be deleted [Mandatory]
629
  */
630
+ public function delete_webhook( $data ) {
631
+ return $this->delete( 'webhook/' . $data['id'],'' );
632
+ }
 
633
 
634
+ /*
635
  Update a webhook.
636
  @param {Array} data contains php array with key value pair.
637
  @options data {Integer} id: Id of webhook to be modified [Mandatory]
639
  @options data {String} description: Webook description [Optional]
640
  @options data {Array} events: Set of events. You can use commas to separate multiple events. Possible values for Transcational webhook – request, delivered, hard_bounce, soft_bounce, blocked, spam, invalid_email, deferred, click, & opened and Possible Values for Marketing webhook – spam, opened, click, hard_bounce, unsubscribe, soft_bounce & list_addition ( case sensitive ) [Mandatory]
641
  */
642
+ public function update_webhook( $data ) {
643
+ $id = $data['id'];
644
+ unset( $data['id'] );
645
+ return $this->put( 'webhook/' . $id,json_encode( $data ) );
646
+ }
 
647
 
648
+ /*
649
  Get Access of created senders information.
650
  @param {Array} data contains php array with key value pair.
651
  @options data {String} option: Options to get senders. Possible options – IP-wise, & Domain-wise ( only for dedicated IP clients ). Example: to get senders with specific IP, use $option=’1.2.3.4′, to get senders with specific domain use, $option=’domain.com’, & to get all senders, use $option="" [Optional]
652
  */
653
+ public function get_senders( $data ) {
654
+ return $this->get( 'advanced',json_encode( $data ) );
655
+ }
 
656
 
657
+ /*
658
  Create your Senders.
659
  @param {Array} data contains php array with key value pair.
660
  @options data {String} name: Name of the sender [Mandatory]
661
  @options data {String} email: Email address of the sender [Mandatory]
662
  @options data {Array} ip_domain: Pass pipe ( | ) separated Dedicated IP and its associated Domain. Example: "1.2.3.4|mydomain.com". You can use commas to separate multiple ip_domain’s [Mandatory: Only for Dedicated IP clients, for Shared IP clients, it should be kept blank]
663
  */
664
+ public function create_sender( $data ) {
665
+ return $this->post( 'advanced',json_encode( $data ) );
666
+ }
 
667
 
668
+ /*
669
  Update your Senders.
670
  @param {Array} data contains php array with key value pair.
671
  @options data {Integer} id: Id of sender to be modified [Mandatory]
672
  @options data {String} name: Name of the sender [Mandatory]
673
  @options data {Array} ip_domain: Pass pipe ( | ) separated Dedicated IP and its associated Domain. Example: "1.2.3.4|mydomain.com". You can use commas to separate multiple ip_domain’s [Mandatory: Only for Dedicated IP clients, for Shared IP clients, it should be kept blank]
674
  */
675
+ public function update_sender( $data ) {
676
+ $id = $data['id'];
677
+ unset( $data['id'] );
678
+ return $this->put( 'advanced/' . $id,json_encode( $data ) );
679
+ }
 
680
 
681
+ /*
682
  Delete your Sender Information.
683
  @param {Array} data contains php array with key value pair.
684
  @options data {Integer} id: Id of sender to be deleted [Mandatory]
685
  */
686
+ public function delete_sender( $data ) {
687
+ return $this->delete( 'advanced/' . $data['id'],'' );
688
+ }
 
689
 
690
+ /*
691
  Send Transactional Email.
692
  @param {Array} data contains php array with key value pair.
693
  @options data {Array} to: Email address of the recipient(s). It should be sent as an associative array. Example: array("to@example.net"=>"to whom"). You can use commas to separate multiple recipients [Mandatory]
702
  @options data {Array} headers: The headers will be sent along with the mail headers in original email. Example: array("Content-Type"=>"text/html; charset=iso-8859-1"). You can use commas to separate multiple headers [Optional]
703
  @options data {Array} inline_image: Pass your inline image/s filename & its base64 encoded chunk data as an associative array. Example: array("YourFileName.Extension"=>"Base64EncodedChunkData"). You can use commas to separate multiple inline images [Optional]
704
  */
705
+ public function send_email( $data ) {
706
+ return $this->post( 'email',json_encode( $data ) );
707
+ }
 
708
 
709
+ /*
710
  Aggregate / date-wise report of the SendinBlue SMTP account.
711
  @param {Array} data contains php array with key value pair.
712
  @options data {Integer} aggregate: This is used to indicate, you are interested in all-time totals. Possible values – 0 & 1. aggregate = 0 means it will not aggregate records, and will show stats per day/date wise [Optional]
715
  @options data {Integer} days: Number of days in the past to include statistics ( Includes today ). It must be an integer greater than 0 [Optional]
716
  @options data {String} tag: The tag you will specify to retrieve detailed stats. It must be an existing tag that has statistics [Optional]
717
  */
718
+ public function get_statistics( $data ) {
719
+ return $this->post( 'statistics',json_encode( $data ) );
720
+ }
 
721
 
722
+ /*
723
  Get Email Event report.
724
  @param {Array} data contains php array with key value pair.
725
  @options data {Integer} limit: To limit the number of results returned. It should be an integer [Optional]
730
  @options data {Integer} days: Number of days in the past (includes today). If specified, must be an integer greater than 0 [Optional]
731
  @options data {String} email: Email address to search report for [Optional]
732
  */
733
+ public function get_report( $data ) {
734
+ return $this->post( 'report',json_encode( $data ) );
735
+ }
 
736
 
737
+ /*
738
  Delete any hardbounce, which actually would have been blocked due to some temporary ISP failures.
739
  @param {Array} data contains php array with key value pair.
740
  @options data {String} start_date: The start date to get report from. Date must be in YYYY-MM-DD format and should be before the end_date [Optional]
741
  @options data {String} end_date: The end date to get report till date. Date must be in YYYY-MM-DD format and should be after the start_date [Optional]
742
  @options data {String} email: Email address to delete its bounces [Optional]
743
  */
744
+ public function delete_bounces( $data ) {
745
+ return $this->post( 'bounces',json_encode( $data ) );
746
+ }
 
747
 
748
+ /*
749
  Send templates created on SendinBlue, through SendinBlue SMTP (transactional mails).
750
  @param {Array} data contains php array with key value pair.
751
  @options data {Integer} id: Id of the template created on SendinBlue account [Mandatory]
756
  @options data {String} attachment_url: Provide the absolute url of the attachment. Url not allowed from local machine. File must be hosted somewhere [Optional]
757
  @options data {Array} attachment: To send attachment/s generated on the fly you have to pass your attachment/s filename & its base64 encoded chunk data as an associative array [Optional]
758
  */
759
+ public function send_transactional_template( $data ) {
760
+ $id = $data['id'];
761
+ unset( $data['id'] );
762
+ return $this->put( 'template/' . $id,json_encode( $data ) );
763
+ }
 
764
 
765
+ /*
766
  Create a Template.
767
  @param {Array} data contains php array with key value pair.
768
  @options data {String} from_name: Sender name from which the campaign emails are sent [Mandatory: for Dedicated IP clients & for Shared IP clients, if sender exists]
777
  @options data {Integer} status: Status of template. Possible values = 0 (default) & 1. status = 0 means template is inactive, & status = 1 means template is active [Optional]
778
  @options data {Integer} attachment: Status of attachment. Possible values = 0 (default) & 1. attach = 0 means an attachment can’t be sent, & attach = 1 means an attachment can be sent, in the email [Optional]
779
  */
780
+ public function create_template( $data ) {
781
+ return $this->post( 'template',json_encode( $data ) );
782
+ }
 
783
 
784
+ /*
785
  Update a Template.
786
  @param {Array} data contains php array with key value pair.
787
  @options data {Integer} id: Id of Template to be modified [Mandatory]
797
  @options data {Integer} status: Status of template. Possible values = 0 (default) & 1. status = 0 means template is inactive, & status = 1 means template is active [Optional]
798
  @options data {Integer} attachment: Status of attachment. Possible values = 0 (default) & 1. attach = 0 means an attachment can’t be sent, & attach = 1 means an attachment can be sent, in the email [Optional]
799
  */
800
+ public function update_template( $data ) {
801
+ $id = $data['id'];
802
+ unset( $data['id'] );
803
+ return $this->put( 'template/' . $id,json_encode( $data ) );
804
+ }
 
805
 
806
+ /*
807
  Send a transactional SMS.
808
  @param {Array} data contains php array with key value pair.
809
  @options data {String} to: The mobile number to send SMS to with country code [Mandatory]
813
  @options data {String} tag: The tag that you can associate with the message [Optional]
814
  @options data {String} type: Type of message. Possible values – marketing (default) & transactional. You can use marketing for sending marketing SMS, & for sending transactional SMS, use transactional type [Optional]
815
  */
816
+ public function send_sms( $data ) {
817
+ return $this->post( 'sms',json_encode( $data ) );
818
+ }
 
819
 
820
+ /*
821
  Create & Schedule your SMS campaigns.
822
  @param {Array} data contains php array with key value pair.
823
  @options data {String} name: Name of the SMS campaign [Mandatory]
829
  @options data {String} scheduled_date: The day on which the SMS campaign is supposed to run [Optional]
830
  @options data {Integer} send_now: Flag to send campaign now. Possible values = 0 (default) & 1. send_now = 0 means campaign can’t be send now, & send_now = 1 means campaign ready to send now [Optional]
831
  */
832
+ public function create_sms_campaign( $data ) {
833
+ return $this->post( 'sms',json_encode( $data ) );
834
+ }
 
835
 
836
+ /*
837
  Update your SMS campaigns.
838
  @param {Array} data contains php array with key value pair.
839
  @options data {Integer} id: Id of the SMS campaign [Mandatory]
846
  @options data {String} scheduled_date: The day on which the SMS campaign is supposed to run [Optional]
847
  @options data {Integer} send_now: Flag to send campaign now. Possible values = 0 (default) & 1. send_now = 0 means campaign can’t be send now, & send_now = 1 means campaign ready to send now [Optional]
848
  */
849
+ public function update_sms_campaign( $data ) {
850
+ $id = $data['id'];
851
+ unset( $data['id'] );
852
+ return $this->put( 'sms/' . $id,json_encode( $data ) );
853
+ }
 
854
 
855
+ /*
856
  Send a Test SMS.
857
  @param {Array} data contains php array with key value pair.
858
  @options data {Integer} id: Id of the SMS campaign [Mandatory]
859
  @options data {String} to: Mobile number with the country code to send test SMS. The mobile number defined here should belong to one of your contacts in SendinBlue account and should not be blacklisted [Mandatory]
860
  */
861
+ public function send_bat_sms( $data ) {
862
+ $id = $data['id'];
863
+ unset( $data['id'] );
864
+ return $this->get( 'sms/' . $id,json_encode( $data ) );
865
+ }
 
866
 
867
  }
868
+
pirate-forms.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Free & Simple Contact Form Plugin - PirateForms
4
  Plugin URI: http://themeisle.com/plugins/pirate-forms/
5
  Description: Easily creates a nice looking, simple contact form on your WP site.
6
- Version: 1.0.18
7
  Author: Themeisle
8
  Author URI: http://themeisle.com
9
  Text Domain: pirate-forms
@@ -11,21 +11,17 @@ Domain Path: /languages
11
  License: GPLv2
12
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
13
  */
14
-
15
  if ( ! function_exists( 'add_action' ) ) {
16
  die( 'Nothing to do...' );
17
  }
18
-
19
  /* Important constants */
20
- define( 'PIRATE_FORMS_VERSION', '1.0.0' );
21
  define( 'PIRATE_FORMS_URL', plugin_dir_url( __FILE__ ) );
22
  define( 'PIRATE_FORMS_PATH', plugin_dir_path( __FILE__ ) );
23
-
24
  /* Required helper functions */
25
  include_once( dirname( __FILE__ ) . '/inc/helpers.php' );
26
  include_once( dirname( __FILE__ ) . '/inc/settings.php' );
27
  include_once( dirname( __FILE__ ) . '/inc/widget.php' );
28
-
29
  add_action( 'plugins_loaded', 'pirate_forms_load_textdomain' );
30
  /**
31
  * Load plugin textdomain.
@@ -45,79 +41,53 @@ function pirate_forms_load_textdomain() {
45
  * @return string
46
  */
47
  add_shortcode( 'pirate_forms', 'pirate_forms_display_form' );
48
-
49
- function pirate_forms_display_form( $atts, $content = NULL ) {
50
-
51
  /* thank you message */
52
  $pirate_forms_thankyou_message = '';
53
-
54
- if( ( isset( $_GET['pcf'] ) && $_GET['pcf'] == 1 ) || ( isset($_POST['pirate-forms-contact-submit']) ) ) {
55
  $pirate_forms_thankyou_message .= '
56
  <div class="col-sm-12 col-lg-12 pirate_forms_thankyou_wrap">
57
  <p>' . sanitize_text_field( pirate_forms_get_key( 'pirateformsopt_label_submit' ) ) . '</p>
58
  </div>';
59
  }
60
-
61
- /*********************************/
62
- /********** FormBuilder **********/
63
- /*********************************/
64
-
65
- if ( !class_exists('PhpFormBuilder')) {
66
  require_once( dirname( __FILE__ ) . '/inc/PhpFormBuilder.php' );
67
  }
68
-
69
  $pirate_form = new PhpFormBuilder();
70
-
71
  $pirate_form->set_att( 'id', 'pirate_forms_' . ( get_the_id() ? get_the_id() : 1 ) );
72
  $pirate_form->set_att( 'class', array( 'pirate_forms' ) );
73
-
74
  if ( 'yes' === pirate_forms_get_key( 'pirateformsopt_nonce' ) ) {
75
  $pirate_form->set_att( 'add_nonce', get_bloginfo( 'admin_email' ) );
76
  }
77
-
78
  $pirate_forms_options = get_option( 'pirate_forms_settings_array' );
79
-
80
- if( !empty($pirate_forms_options) ):
81
-
82
  /* Count the number of requested fields from Name, Email and Subject to add a certain class col-12, col-6 or col-4 */
83
  $pirate_forms_required_fields = 0;
84
-
85
- if( !empty($pirate_forms_options['pirateformsopt_name_field']) && !empty($pirate_forms_options['pirateformsopt_label_name']) ):
86
-
87
- $pirateformsopt_name_field = $pirate_forms_options['pirateformsopt_name_field'];
88
- $pirateformsopt_name_label = $pirate_forms_options['pirateformsopt_label_name'];
89
-
90
- if ( !empty($pirateformsopt_name_field) && !empty($pirateformsopt_name_label) && ($pirateformsopt_name_field != '') ):
91
- $pirate_forms_required_fields++;
92
- endif;
93
-
94
  endif;
95
-
96
- if( !empty($pirate_forms_options['pirateformsopt_email_field']) && !empty($pirate_forms_options['pirateformsopt_label_email']) ):
97
-
98
- $pirateformsopt_email_field = $pirate_forms_options['pirateformsopt_email_field'];
99
- $pirateformsopt_email_label = $pirate_forms_options['pirateformsopt_label_email'];
100
-
101
- if ( !empty($pirateformsopt_email_field) && !empty($pirateformsopt_email_label) && ($pirateformsopt_email_field != '') ):
102
- $pirate_forms_required_fields++;
103
- endif;
104
-
105
  endif;
106
-
107
- if( !empty($pirate_forms_options['pirateformsopt_subject_field']) && !empty($pirate_forms_options['pirateformsopt_label_subject']) ):
108
-
109
- $pirateformsopt_subject_field = $pirate_forms_options['pirateformsopt_subject_field'];
110
- $pirateformsopt_subject_label = $pirate_forms_options['pirateformsopt_label_subject'];
111
-
112
- if ( !empty($pirateformsopt_subject_field) && !empty($pirateformsopt_subject_label) && ($pirateformsopt_subject_field != '') ):
113
- $pirate_forms_required_fields++;
114
- endif;
115
-
116
  endif;
117
-
118
  $pirate_forms_layout_input = '';
119
-
120
- switch ($pirate_forms_required_fields) {
121
  case 1:
122
  $pirate_forms_layout_input = 'col-sm-12 col-lg-12';
123
  break;
@@ -130,209 +100,165 @@ function pirate_forms_display_form( $atts, $content = NULL ) {
130
  default:
131
  $pirate_forms_layout_input = 'col-sm-4 col-lg-4';
132
  }
133
-
134
- /******************************/
135
- /******** Name field *********/
136
- /******************************/
137
-
138
- if ( !empty($pirateformsopt_name_field) && !empty($pirateformsopt_name_label) ):
139
-
140
- $required = $pirateformsopt_name_field === 'req' ? TRUE : FALSE;
141
- $wrap_classes = array( $pirate_forms_layout_input.' form_field_wrap', 'contact_name_wrap pirate_forms_three_inputs ' );
142
-
143
- // If this field was submitted with invalid data
144
- if ( isset( $_SESSION['pirate_forms_contact_errors']['contact-name'] ) ) {
145
- $wrap_classes[] = 'error';
146
- }
147
-
148
- $pirate_form->add_input(
149
- '',
150
- array(
151
- 'placeholder' => stripslashes( sanitize_text_field($pirateformsopt_name_label) ),
152
- 'required' => $required,
153
- 'wrap_class' => $wrap_classes,
154
- ),
155
- 'pirate-forms-contact-name'
156
- );
157
-
158
- endif;
159
-
160
- /********************************/
161
- /******** Email field **********/
162
- /********************************/
163
-
164
- if ( !empty($pirateformsopt_email_field) && !empty($pirateformsopt_email_label) ):
165
-
166
- $required = $pirateformsopt_email_field === 'req' ? TRUE : FALSE;
167
- $wrap_classes = array( $pirate_forms_layout_input.' form_field_wrap', 'contact_email_wrap pirate_forms_three_inputs ' );
168
-
169
- // If this field was submitted with invalid data
170
- if ( isset( $_SESSION['pirate_forms_contact_errors']['contact-email'] ) ) {
171
- $wrap_classes[] = 'error';
172
- }
173
-
174
- $pirate_form->add_input(
175
- '',
176
- array(
177
- 'placeholder' => stripslashes( sanitize_text_field($pirateformsopt_email_label) ),
178
- 'required' => $required,
179
- 'type' => 'email',
180
- 'wrap_class' => $wrap_classes,
181
- ),
182
- 'pirate-forms-contact-email'
183
- );
184
-
185
- endif;
186
-
187
- /********************************/
188
- /******** Subject field ********/
189
- /********************************/
190
-
191
- if ( !empty($pirateformsopt_subject_field) && !empty($pirateformsopt_subject_label) ):
192
-
193
- $required = $pirateformsopt_subject_field === 'req' ? TRUE : FALSE;
194
- $wrap_classes = array( $pirate_forms_layout_input.' form_field_wrap', 'contact_subject_wrap pirate_forms_three_inputs ' );
195
-
 
 
 
 
 
 
 
 
 
 
 
 
196
  // If this field was submitted with invalid data
197
- if ( isset( $_SESSION['pirate_forms_contact_errors']['contact-subject'] ) ) {
198
  $wrap_classes[] = 'error';
199
  }
200
-
201
- $pirate_form->add_input(
202
- '',
203
- array(
204
- 'placeholder' => stripslashes( sanitize_text_field($pirateformsopt_subject_label) ),
205
- 'required' => $required,
206
- 'wrap_class' => $wrap_classes,
207
- ),
208
- 'pirate-forms-contact-subject'
209
- );
210
-
211
- endif;
212
-
213
- /********************************/
214
- /******** Message field ********/
215
- /********************************/
216
-
217
- if( !empty($pirate_forms_options['pirateformsopt_message_field']) && !empty($pirate_forms_options['pirateformsopt_label_message']) ):
218
-
219
- $pirateformsopt_message_field = $pirate_forms_options['pirateformsopt_message_field'];
220
- $pirateformsopt_message_label = $pirate_forms_options['pirateformsopt_label_message'];
221
-
222
- if ( !empty($pirateformsopt_message_field) && !empty($pirateformsopt_message_label) ):
223
-
224
-
225
- $required = $pirateformsopt_message_field === 'req' ? TRUE : FALSE;
226
- $wrap_classes = array( 'col-sm-12 col-lg-12 form_field_wrap', 'contact_message_wrap ' );
227
-
228
- // If this field was submitted with invalid data
229
- if ( isset( $_SESSION['pirate_forms_contact_errors']['contact-message'] ) ) {
230
- $wrap_classes[] = 'error';
231
- }
232
-
233
- $pirate_form->add_input(
234
- '',
235
- array(
236
- 'placeholder' => stripslashes( sanitize_text_field($pirateformsopt_message_label) ),
237
- 'required' => $required,
238
- 'wrap_class' => $wrap_classes,
239
- 'type' => 'textarea'
240
- ),
241
- 'pirate-forms-contact-message'
242
- );
243
-
244
- endif;
245
- endif;
246
-
247
- /******************************/
248
- /********* ReCaptcha **********/
249
- /******************************/
250
-
251
- 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') ):
252
-
253
- $pirateformsopt_recaptcha_sitekey = $pirate_forms_options['pirateformsopt_recaptcha_sitekey'];
254
- $pirateformsopt_recaptcha_secretkey = $pirate_forms_options['pirateformsopt_recaptcha_secretkey'];
255
-
256
  $pirate_form->add_input(
257
  '',
258
  array(
259
- 'value' => $pirateformsopt_recaptcha_sitekey,
260
- 'wrap_class' => 'col-xs-12 col-sm-6 col-lg-6 form_field_wrap form_captcha_wrap',
261
- 'type' => 'captcha',
 
262
  ),
263
- 'pirate-forms-captcha'
264
  );
265
-
266
  endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
267
 
268
- /*********************************/
269
- /********** Attachment ***********/
270
- /*********************************/
271
-
272
- if( !empty($pirate_forms_options['pirateformsopt_attachment_field']) && ($pirate_forms_options['pirateformsopt_attachment_field'] == 'yes') ) {
273
-
 
274
  $pirate_form->add_input(
275
  '',
276
  array(
 
277
  'wrap_class' => $wrap_classes,
278
- 'type' => 'file'
 
 
279
  ),
280
- 'pirate-forms-attachment'
281
  );
282
-
283
- }
284
-
285
- /********************************/
286
- /******** Submit button ********/
287
- /********************************/
288
-
289
- if( !empty($pirate_forms_options['pirateformsopt_label_submit_btn']) ):
290
-
291
- $pirateformsopt_label_submit_btn = $pirate_forms_options['pirateformsopt_label_submit_btn'];
292
-
293
- if ( !empty($pirateformsopt_label_submit_btn) ):
294
-
295
- $wrap_classes = array();
296
-
297
- $pirate_form->add_input(
298
- '',
299
- array(
300
- 'value' => stripslashes( sanitize_text_field($pirateformsopt_label_submit_btn) ),
301
- 'wrap_class' => $wrap_classes,
302
- 'type' => 'submit',
303
- 'wrap_tag' => '',
304
- 'class' => 'pirate-forms-submit-button'
305
- ),
306
- 'pirate-forms-contact-submit'
307
- );
308
-
309
- endif;
310
  endif;
311
-
312
  endif;
313
-
314
  /* Referring site or page, if any */
315
  if ( ! empty( $_SERVER['HTTP_REFERER'] ) ) {
316
  $pirate_form->add_input(
317
- __( 'Contact Referrer','pirate-forms' ),
318
  array(
319
  'type' => 'hidden',
320
- 'value' => $_SERVER['HTTP_REFERER']
321
  )
322
  );
323
  }
324
-
325
  /* Referring page, if sent via URL query */
326
  if ( ! empty( $_REQUEST['src'] ) || ! empty( $_REQUEST['ref'] ) ) {
327
  $pirate_form->add_input(
328
- __( 'Referring page','pirate-forms' ),
329
  array(
330
  'type' => 'hidden',
331
- 'value' => ! empty( $_REQUEST['src'] ) ? $_REQUEST['src'] : $_REQUEST['ref']
332
  )
333
  );
334
  }
335
-
336
  /* Are there any submission errors? */
337
  $errors = '';
338
  if ( ! empty( $_SESSION['pirate_forms_contact_errors'] ) ) {
@@ -341,10 +267,11 @@ function pirate_forms_display_form( $atts, $content = NULL ) {
341
  }
342
 
343
  /* Display the form */
344
- return $pirate_forms_thankyou_message.'
 
345
  <div class="pirate_forms_wrap">
346
  ' . $errors . '
347
- ' . $pirate_form->build_form( FALSE ) . '
348
  <div class="pirate_forms_clearfix"></div>
349
  </div>';
350
 
@@ -355,53 +282,53 @@ function pirate_forms_display_form( $atts, $content = NULL ) {
355
  */
356
  function pirate_forms_canonicalize( $text ) {
357
  if ( function_exists( 'mb_convert_kana' )
358
- && 'UTF-8' == get_option( 'blog_charset' ) ) {
 
359
  $text = mb_convert_kana( $text, 'asKV', 'UTF-8' );
360
  }
361
-
362
  $text = strtolower( $text );
363
  $text = trim( $text );
 
364
  return $text;
365
  }
366
 
367
  function pirate_forms_antiscript_file_name( $filename ) {
368
  $filename = basename( $filename );
369
- $parts = explode( '.', $filename );
370
-
371
- if ( count( $parts ) < 2 )
372
  return $filename;
373
-
374
  $script_pattern = '/^(php|phtml|pl|py|rb|cgi|asp|aspx)\d?$/i';
375
-
376
- $filename = array_shift( $parts );
377
- $extension = array_pop( $parts );
378
-
379
  foreach ( (array) $parts as $part ) {
380
- if ( preg_match( $script_pattern, $part ) )
381
  $filename .= '.' . $part . '_';
382
- else
383
  $filename .= '.' . $part;
 
384
  }
385
-
386
- if ( preg_match( $script_pattern, $extension ) )
387
  $filename .= '.' . $extension . '_.txt';
388
- else
389
  $filename .= '.' . $extension;
 
390
 
391
  return $filename;
392
  }
393
 
394
  function pirate_forms_upload_dir( $type = false ) {
395
  $uploads = wp_upload_dir();
396
-
397
  $uploads = apply_filters( 'pirate_forms_upload_dir', array(
398
  'dir' => $uploads['basedir'],
399
- 'url' => $uploads['baseurl'] ) );
400
-
401
- if ( 'dir' == $type )
402
  return $uploads['dir'];
403
- if ( 'url' == $type )
 
404
  return $uploads['url'];
 
405
 
406
  return $uploads;
407
  }
@@ -413,26 +340,29 @@ function pirate_forms_upload_tmp_dir() {
413
  function pirate_forms_init_uploads() {
414
  $dir = pirate_forms_upload_tmp_dir();
415
  wp_mkdir_p( $dir );
416
-
417
  $htaccess_file = trailingslashit( $dir ) . '.htaccess';
418
-
419
  if ( file_exists( $htaccess_file ) ) {
420
  return;
421
  }
 
 
 
 
 
 
 
 
 
422
 
423
- if ( $handle = @fopen( $htaccess_file, 'w' ) ) {
424
- fwrite( $handle, "Deny from all\n" );
425
- fclose( $handle );
426
  }
427
  }
428
 
429
  function pirate_forms_maybe_add_random_dir( $dir ) {
430
  do {
431
  $rand_max = mt_getrandmax();
432
- $rand = zeroise( mt_rand( 0, $rand_max ), strlen( $rand_max ) );
433
- $dir_new = path_join( $dir, $rand );
434
  } while ( file_exists( $dir_new ) );
435
-
436
  if ( wp_mkdir_p( $dir_new ) ) {
437
  return $dir_new;
438
  }
@@ -445,15 +375,12 @@ function pirate_forms_maybe_add_random_dir( $dir ) {
445
  */
446
  add_action( 'template_redirect', 'pirate_forms_process_contact' );
447
  function pirate_forms_process_contact() {
448
-
449
  // If POST and honeypot are not set, beat it
450
- if ( empty( $_POST ) || !isset( $_POST['honeypot'] )) {
451
  return false;
452
  }
453
-
454
  // Session variable for form errors
455
  $_SESSION['pirate_forms_contact_errors'] = array();
456
-
457
  // If nonce is not valid, beat it
458
  if ( 'yes' === pirate_forms_get_key( 'pirateformsopt_nonce' ) ) {
459
  if ( ! wp_verify_nonce( $_POST['wordpress-nonce'], get_bloginfo( 'admin_email' ) ) ) {
@@ -462,308 +389,208 @@ function pirate_forms_process_contact() {
462
  return false;
463
  }
464
  }
465
-
466
  // If the honeypot caught a bear, beat it
467
  if ( ! empty( $_POST['honeypot'] ) ) {
468
  $_SESSION['pirate_forms_contact_errors']['honeypot'] = __( 'Form submission failed!', 'pirate-forms' );
 
469
  return false;
470
  }
471
-
472
  // Start the body of the contact email
473
- $body = "*** " . __( 'Contact form submission from', 'pirate-forms' ) . " " .
474
- get_bloginfo( 'name' ) . " (" . site_url() . ") *** \n\n";
475
-
476
-
477
- /***********************************************/
478
- /********* Sanitize and validate name *******/
479
- /**********************************************/
480
-
481
  $pirate_forms_contact_name = isset( $_POST['pirate-forms-contact-name'] ) ? sanitize_text_field( trim( $_POST['pirate-forms-contact-name'] ) ) : '';
482
-
483
  // if name is required and is missing
484
- if ( (pirate_forms_get_key( 'pirateformsopt_name_field' ) === 'req') && empty( $pirate_forms_contact_name ) ) {
485
  $_SESSION['pirate_forms_contact_errors']['pirate-forms-contact-name'] = pirate_forms_get_key( 'pirateformsopt_label_err_name' );
486
- }
487
- // If not required and empty, leave it out
488
  elseif ( ! empty( $pirate_forms_contact_name ) ) {
489
  $body .= stripslashes( pirate_forms_get_key( 'pirateformsopt_label_name' ) ) . ": $pirate_forms_contact_name \r";
490
  }
491
-
492
-
493
- /***********************************************/
494
- /******* Sanitize and validate email **********/
495
- /***********************************************/
496
-
497
  $pirate_forms_contact_email = isset( $_POST['pirate-forms-contact-email'] ) ? sanitize_email( $_POST['pirate-forms-contact-email'] ) : '';
498
-
499
  // If required, is it valid?
500
- if ( (pirate_forms_get_key( 'pirateformsopt_email_field' ) === 'req') && ! filter_var( $pirate_forms_contact_email, FILTER_VALIDATE_EMAIL )) {
501
  $_SESSION['pirate_forms_contact_errors']['pirate-forms-contact-email'] = pirate_forms_get_key( 'pirateformsopt_label_err_email' );
502
- }
503
- // If not required and empty, leave it out
504
  elseif ( ! empty( $pirate_forms_contact_email ) ) {
505
  $body .= stripslashes( pirate_forms_get_key( 'pirateformsopt_label_email' ) )
506
- . ": $pirate_forms_contact_email \r";
507
  }
508
-
509
- /***********************************************/
510
- /********* Sanitize and validate subject *****/
511
- /**********************************************/
512
-
513
  $pirate_forms_contact_subject = isset( $_POST['pirate-forms-contact-subject'] ) ? sanitize_text_field( trim( $_POST['pirate-forms-contact-subject'] ) ) : '';
514
-
515
  // if subject is required and is missing
516
- if ( (pirate_forms_get_key( 'pirateformsopt_subject_field' ) === 'req') && empty( $pirate_forms_contact_subject ) ) {
517
  $_SESSION['pirate_forms_contact_errors']['pirate-forms-contact-subject'] = pirate_forms_get_key( 'pirateformsopt_label_err_subject' );
518
- }
519
- // If not required and empty, leave it out
520
  elseif ( ! empty( $pirate_forms_contact_subject ) ) {
521
  $body .= stripslashes( pirate_forms_get_key( 'pirateformsopt_label_subject' ) ) . ": $pirate_forms_contact_subject \r";
522
  }
523
-
524
- /***********************************************/
525
- /********* Sanitize and validate message *****/
526
- /**********************************************/
527
-
528
  $pirate_forms_contact_message = isset( $_POST['pirate-forms-contact-message'] ) ? sanitize_text_field( trim( $_POST['pirate-forms-contact-message'] ) ) : '';
529
-
530
  // if message is required and is missing
531
- if ( (pirate_forms_get_key( 'pirateformsopt_message_field' ) === 'req') && empty( $pirate_forms_contact_message ) ) {
532
  $_SESSION['pirate_forms_contact_errors']['pirate-forms-contact-message'] = pirate_forms_get_key( 'pirateformsopt_label_err_message' );
533
- }
534
- // If not required and empty, leave it out
535
  elseif ( ! empty( $pirate_forms_contact_message ) ) {
536
  $body .= stripslashes( pirate_forms_get_key( 'pirateformsopt_label_message' ) ) . ": $pirate_forms_contact_message \r";
537
  }
538
-
539
- /*************************************************/
540
- /************* Validate reCAPTCHA ****************/
541
- /*************************************************/
542
-
543
-
544
- $pirateformsopt_recaptcha_sitekey = pirate_forms_get_key('pirateformsopt_recaptcha_sitekey');
545
- $pirateformsopt_recaptcha_secretkey = pirate_forms_get_key('pirateformsopt_recaptcha_secretkey');
546
- $pirateformsopt_recaptcha_field = pirate_forms_get_key('pirateformsopt_recaptcha_field');
547
-
548
- if( !empty($pirateformsopt_recaptcha_secretkey) && !empty($pirateformsopt_recaptcha_sitekey) && !empty($pirateformsopt_recaptcha_field) && ($pirateformsopt_recaptcha_field == 'yes') ):
549
-
550
- if( isset($_POST['g-recaptcha-response']) ){
551
  $captcha = $_POST['g-recaptcha-response'];
552
  }
553
- if( !$captcha ){
554
- $_SESSION['pirate_forms_contact_errors']['pirate-forms-captcha'] = __( 'Wrong reCAPTCHA','pirate-forms' );
555
  }
556
- $response = wp_remote_get( "https://www.google.com/recaptcha/api/siteverify?secret=".$pirateformsopt_recaptcha_secretkey."&response=".$captcha."&remoteip=".$_SERVER['REMOTE_ADDR'] );
557
-
558
- if( !empty($response) ):
559
  $response_body = wp_remote_retrieve_body( $response );
560
  endif;
561
-
562
- if( !empty($response_body) ):
563
  $result = json_decode( $response_body, true );
564
  endif;
565
-
566
- if( isset($result['success']) && ($result['success'] == false) ) {
567
- $_SESSION['pirate_forms_contact_errors']['pirate-forms-captcha'] = __( 'Wrong reCAPTCHA','pirate-forms' );
568
  }
569
  endif;
570
-
571
- /************************************************/
572
- /********** Validate recipients email ***********/
573
- /************************************************/
574
  $site_recipients = sanitize_text_field( pirate_forms_get_key( 'pirateformsopt_email_recipients' ) );
575
-
576
-
577
- if ( empty($site_recipients) ) {
578
- $_SESSION['pirate_forms_contact_errors']['pirate-forms-recipients-email'] = __( 'Please enter one or more Contact submission recipients','pirate-forms' );
579
  }
580
-
581
- /**********************************************/
582
- /******** Sanitize and validate IP *********/
583
- /**********************************************/
584
-
585
  $contact_ip = filter_var( $_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP );
586
-
587
  /* for the case of a Web server behind a reverse proxy */
588
- if (array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER)) {
589
-
590
- $contact_ip_tmp = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
591
- if( !empty( $contact_ip_tmp ) ) {
592
  $contact_ip = array_pop( $contact_ip_tmp );
593
  }
594
-
595
  }
596
-
597
  // If valid and present, create a link to an IP search
598
  if ( ! empty( $contact_ip ) ) {
599
- $body .= __( 'IP address: ','pirate-forms' ). $contact_ip ."\r ".__( 'IP search:','pirate-forms' )." http://whatismyipaddress.com/ip/$contact_ip \n\n";
600
  }
601
-
602
  // Sanitize and prepare referrer;
603
  if ( ! empty( $_POST['pirate-forms-contact-referrer'] ) ) {
604
- $body .= __( 'Came from: ','pirate-forms' ) . sanitize_text_field( $_POST['pirate-forms-contact-referrer'] ) . " \r";
605
  }
606
-
607
  // Show the page this contact form was submitted on
608
- $body .= __( 'Sent from page: ','pirate-forms' ) . get_permalink( get_the_id() );
609
-
610
  // Check the blacklist
611
  $blocked = pirate_forms_get_blacklist();
612
  if ( ! empty( $blocked ) ) {
613
  if (
614
- in_array( $pirate_forms_contact_email, $blocked ) ||
615
- in_array( $contact_ip, $blocked )
616
  ) {
617
- $_SESSION['pirate_forms_contact_errors']['blacklist-blocked'] = __( 'Form submission blocked!','pirate-forms' );
 
618
  return false;
619
  }
620
  }
621
-
622
  // No errors? Go ahead and process the contact
623
  if ( empty( $_SESSION['pirate_forms_contact_errors'] ) ) {
624
-
625
  $pirate_forms_options_tmp = get_option( 'pirate_forms_settings_array' );
626
- if( isset($pirate_forms_options_tmp['pirateformsopt_email']) ) {
627
  $site_email = $pirate_forms_options_tmp['pirateformsopt_email'];
628
  }
629
-
630
- if( !empty($pirate_forms_contact_name) ):
631
  $site_name = $pirate_forms_contact_name;
632
- else:
633
- $site_name = htmlspecialchars_decode( get_bloginfo( 'name' ) );
634
  endif;
635
-
636
  // Notification recipients
637
  $site_recipients = sanitize_text_field( pirate_forms_get_key( 'pirateformsopt_email_recipients' ) );
638
- $site_recipients = explode(',', $site_recipients);
639
  $site_recipients = array_map( 'trim', $site_recipients );
640
  $site_recipients = array_map( 'sanitize_email', $site_recipients );
641
  $site_recipients = implode( ',', $site_recipients );
642
-
643
  // No name? Use the submitter email address, if one is present
644
  if ( empty( $pirate_forms_contact_name ) ) {
645
  $pirate_forms_contact_name = ! empty( $pirate_forms_contact_email ) ? $pirate_forms_contact_email : '[None given]';
646
  }
647
-
648
- // Need an email address for the email notification
649
- if( !empty($site_email) ) {
650
- if( $site_email == '[email]' ) {
651
- if( !empty($pirate_forms_contact_email) ) {
652
  $send_from = $pirate_forms_contact_email;
 
 
653
  }
654
- else {
655
- $send_from = pirate_forms_from_email();
656
- }
657
- }
658
- else {
659
  $send_from = $site_email;
660
  }
661
- }
662
- else {
663
  $send_from = pirate_forms_from_email();
664
  }
665
-
666
  $send_from_name = $site_name;
667
-
668
-
669
  // Sent an email notification to the correct address
670
- $headers = "From: $send_from_name <$send_from>\r\nReply-To: $pirate_forms_contact_name <$pirate_forms_contact_email>";
671
-
672
  add_action( 'phpmailer_init', 'pirate_forms_phpmailer' );
673
 
674
- function pirate_forms_phpmailer( $phpmailer ) {
675
-
676
- $pirateformsopt_use_smtp = pirate_forms_get_key( 'pirateformsopt_use_smtp' );
677
- $pirateformsopt_smtp_host = pirate_forms_get_key( 'pirateformsopt_smtp_host' );
678
- $pirateformsopt_smtp_port = pirate_forms_get_key( 'pirateformsopt_smtp_port' );
679
- $pirateformsopt_smtp_username = pirate_forms_get_key( 'pirateformsopt_smtp_username' );
680
- $pirateformsopt_smtp_password = pirate_forms_get_key( 'pirateformsopt_smtp_password' );
681
- $pirateformsopt_use_smtp_authentication = pirate_forms_get_key('pirateformsopt_use_smtp_authentication');
682
-
683
- if( !empty($pirateformsopt_use_smtp) && ($pirateformsopt_use_smtp == 'yes') && !empty($pirateformsopt_smtp_host) && !empty($pirateformsopt_smtp_port) ):
684
-
685
- $phpmailer->isSMTP();
686
- $phpmailer->Host = $pirateformsopt_smtp_host;
687
-
688
- if( !empty($pirateformsopt_use_smtp_authentication) && ($pirateformsopt_use_smtp_authentication == 'yes') && !empty($pirateformsopt_smtp_username) && !empty($pirateformsopt_smtp_password) ):
689
-
690
- $phpmailer->SMTPAuth = true; // Force it to use Username and Password to authenticate
691
- $phpmailer->Port = $pirateformsopt_smtp_port;
692
- $phpmailer->Username = $pirateformsopt_smtp_username;
693
- $phpmailer->Password = $pirateformsopt_smtp_password;
694
-
695
- endif;
696
-
697
- endif;
698
- }
699
-
700
- /*******************************************/
701
- /********* Validate Attachment *************/
702
- /*******************************************/
703
-
704
- $attachments = '';
705
-
706
  $pirate_forms_attach_file = isset( $_FILES['pirate-forms-attachment'] ) ? $_FILES['pirate-forms-attachment'] : '';
707
-
708
- if( !empty($pirate_forms_attach_file) && !empty($pirate_forms_attach_file['name']) ) {
709
-
710
  /* Validate file type */
711
  $pirate_forms_file_types_allowed = 'jpg|jpeg|png|gif|pdf|doc|docx|ppt|pptx|odt|avi|ogg|m4a|mov|mp3|mp4|mpg|wav|wmv';
712
-
713
  $pirate_forms_file_types_allowed = trim( $pirate_forms_file_types_allowed, '|' );
714
  $pirate_forms_file_types_allowed = '(' . $pirate_forms_file_types_allowed . ')';
715
  $pirate_forms_file_types_allowed = '/\.' . $pirate_forms_file_types_allowed . '$/i';
716
-
717
  if ( ! preg_match( $pirate_forms_file_types_allowed, $pirate_forms_attach_file['name'] ) ) {
718
  $_SESSION['pirate_forms_contact_errors']['pirate-forms-upload-failed-type'] = __( 'Uploaded file is not allowed for file type', 'pirate-forms' );
719
  }
720
-
721
  /* Validate file size */
722
  $pirate_forms_file_size_allowed = 1048576; // default size 1 MB
723
-
724
  if ( $pirate_forms_attach_file['size'] > $pirate_forms_file_size_allowed ) {
725
  $_SESSION['pirate_forms_contact_errors']['pirate-forms-upload-failed-size'] = __( 'Uploaded file is too large', 'pirate-forms' );
726
  }
727
-
728
  pirate_forms_init_uploads();
729
  $uploads_dir = pirate_forms_upload_tmp_dir();
730
  $uploads_dir = pirate_forms_maybe_add_random_dir( $uploads_dir );
731
-
732
- $filename = $pirate_forms_attach_file['name'];
733
- $filename = pirate_forms_canonicalize( $filename );
734
- $filename = sanitize_file_name( $filename );
735
- $filename = pirate_forms_antiscript_file_name( $filename );
736
- $filename = wp_unique_filename( $uploads_dir, $filename );
737
-
738
- $new_file = trailingslashit( $uploads_dir ) . $filename;
739
-
740
-
741
- if ( false === @move_uploaded_file( $pirate_forms_attach_file['tmp_name'], $new_file ) ) {
742
- $_SESSION['pirate_forms_contact_errors']['pirate-forms-upload-failed-general'] = __( 'There was an unknown error uploading the file.', 'pirate-forms' );
 
 
 
 
743
  }
744
-
745
- // Make sure the uploaded file is only readable for the owner process
746
- @chmod( $new_file, 0400 );
747
-
748
- if( !empty($new_file) ) {
749
  $attachments = $new_file;
750
  }
751
-
752
  }
753
-
754
  wp_mail( $site_recipients, 'Contact on ' . htmlspecialchars_decode( get_bloginfo( 'name' ) ), $body, $headers, $attachments );
755
-
756
  // Should a confirm email be sent?
757
  $confirm_body = stripslashes( trim( pirate_forms_get_key( 'pirateformsopt_confirm_email' ) ) );
758
  if ( ! empty( $confirm_body ) && ! empty( $pirate_forms_contact_email ) ) {
759
-
760
  // Removing entities
761
  $confirm_body = htmlspecialchars_decode( $confirm_body );
762
  $confirm_body = html_entity_decode( $confirm_body );
763
  $confirm_body = str_replace( '&#39;', "'", $confirm_body );
764
-
765
- $headers = "From: $site_name <$site_email>\r\nReply-To: $site_name <$site_email>";
766
-
767
  wp_mail(
768
  $pirate_forms_contact_email,
769
  pirate_forms_get_key( 'pirateformsopt_label_submit' ) . ' - ' . $site_name,
@@ -771,11 +598,8 @@ function pirate_forms_process_contact() {
771
  $headers
772
  );
773
  }
774
-
775
- /************************************************************/
776
- /************* Store the entries in the DB ****************/
777
- /************************************************************/
778
-
779
  if ( pirate_forms_get_key( 'pirateformsopt_store' ) === 'yes' ) {
780
  $new_post_id = wp_insert_post(
781
  array(
@@ -783,113 +607,111 @@ function pirate_forms_process_contact() {
783
  'post_title' => date( 'l, M j, Y', time() ) . ' by "' . $pirate_forms_contact_name . '"',
784
  'post_content' => $body,
785
  'post_author' => 1,
786
- 'post_status' => 'private'
787
  )
788
  );
789
-
790
  if ( isset( $pirate_forms_contact_email ) && ! empty( $pirate_forms_contact_email ) ) {
791
  add_post_meta( $new_post_id, 'Contact email', $pirate_forms_contact_email );
792
  }
793
  }
794
-
795
  $pirate_forms_current_theme = wp_get_theme();
796
-
797
  /* If a Thank you page is selected, redirect to that page */
798
  if ( pirate_forms_get_key( 'pirateformsopt_thank_you_url' ) ) {
799
  $redirect_id = intval( pirate_forms_get_key( 'pirateformsopt_thank_you_url' ) );
800
  $redirect = get_permalink( $redirect_id );
801
  wp_safe_redirect( $redirect );
802
- }
803
- /* Redirect to ?pcf=1#contact only if the theme is Zerif */
804
- 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 ) ) {
805
- $redirect = $_SERVER["HTTP_REFERER"] . ( strpos( $_SERVER["HTTP_REFERER"], '?' ) === FALSE ? '?' : '&' ) . 'pcf=1#contact';
806
  wp_safe_redirect( $redirect );
807
  }
808
-
809
  }
810
 
811
  }
812
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
813
  /* Get a settings value */
814
  function pirate_forms_get_key( $id ) {
815
  $pirate_forms_options = get_option( 'pirate_forms_settings_array' );
816
 
817
- return isset( $pirate_forms_options[$id] ) ? $pirate_forms_options[$id] : '';
818
  }
819
 
820
- /*************************************************************************/
821
- /**************************** Scripts and Styles *************************/
822
- /*************************************************************************/
823
-
824
-
825
  add_action( 'wp_enqueue_scripts', 'pirate_forms_add_styles_and_scripts' );
826
-
827
  function pirate_forms_add_styles_and_scripts() {
828
-
829
  /* style for frontpage contact */
830
  wp_enqueue_style( 'pirate_forms_front_styles', PIRATE_FORMS_URL . 'css/front.css' );
831
-
832
  /* recaptcha js */
833
  $pirate_forms_options = get_option( 'pirate_forms_settings_array' );
834
-
835
- if( !empty($pirate_forms_options) ):
836
-
837
- 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') ):
838
-
839
- if ( defined( 'POLYLANG_VERSION' ) && function_exists('pll_current_language') ) {
840
  $pirate_forms_contactus_language = pll_current_language();
841
  } else {
842
  $pirate_forms_contactus_language = get_locale();
843
  }
844
-
845
- wp_enqueue_script( 'recaptcha', 'https://www.google.com/recaptcha/api.js?hl='.$pirate_forms_contactus_language.'' );
846
-
847
- wp_enqueue_script( 'pirate_forms_scripts', plugins_url( 'js/scripts.js', __FILE__ ), array('jquery','recaptcha') );
848
-
849
  endif;
850
-
851
  endif;
852
-
853
- wp_enqueue_script( 'pirate_forms_scripts_general', plugins_url( 'js/scripts-general.js', __FILE__ ), array('jquery') );
854
-
855
  $pirate_forms_errors = '';
856
-
857
- if( !empty($_SESSION['pirate_forms_contact_errors'])):
858
  $pirate_forms_errors = $_SESSION['pirate_forms_contact_errors'];
859
  endif;
860
-
861
  wp_localize_script( 'pirate_forms_scripts_general', 'pirateFormsObject', array(
862
- 'errors' => $pirate_forms_errors
863
  ) );
864
 
865
  }
866
 
867
  add_action( 'admin_enqueue_scripts', 'pirate_forms_admin_css' );
868
-
869
  function pirate_forms_admin_css() {
870
-
871
  global $pagenow;
872
-
873
- if ( !empty($pagenow) && ( $pagenow == 'options-general.php' || $pagenow == 'admin.php' )
874
- && isset( $_GET['page'] ) && $_GET['page'] == 'pirate-forms-admin' ) {
875
-
876
  wp_enqueue_style( 'pirate_forms_admin_styles', PIRATE_FORMS_URL . 'css/wp-admin.css' );
877
-
878
- wp_enqueue_script( 'pirate_forms_scripts_admin', plugins_url( 'js/scripts-admin.js', __FILE__ ), array('jquery') );
879
  wp_localize_script( 'pirate_forms_scripts_admin', 'cwp_top_ajaxload', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );
880
  }
881
  }
882
 
883
- /**************************************************************************/
884
- /*** If submissions should be stored in the DB, create the Contacts CPT ***/
885
- /*************************************************************************/
886
-
887
  if ( pirate_forms_get_key( 'pirateformsopt_store' ) === 'yes' ) {
888
-
889
  add_action( 'init', 'pirate_forms_register_content_type' );
890
-
891
  function pirate_forms_register_content_type() {
892
-
893
  $labels = array(
894
  'name' => _x( 'Contacts', 'post type general name', 'pirate-forms' ),
895
  'singular_name' => _x( 'Contact', 'post type singular name', 'pirate-forms' ),
@@ -904,9 +726,9 @@ if ( pirate_forms_get_key( 'pirateformsopt_store' ) === 'yes' ) {
904
  'search_items' => __( 'Search Contacts', 'pirate-forms' ),
905
  'parent_item_colon' => __( 'Parent Contacts:', 'pirate-forms' ),
906
  'not_found' => __( 'No contacts found.', 'pirate-forms' ),
907
- 'not_found_in_trash' => __( 'No contacts found in Trash.', 'pirate-forms' )
908
  );
909
- $args = array(
910
  'labels' => $labels,
911
  'description' => __( 'Contacts from Pirate Forms', 'pirate-forms' ),
912
  'public' => true,
@@ -918,38 +740,35 @@ if ( pirate_forms_get_key( 'pirateformsopt_store' ) === 'yes' ) {
918
  'has_archive' => true,
919
  'hierarchical' => false,
920
  'menu_position' => null,
921
- 'supports' => array( 'title', 'editor', 'custom-fields' )
922
  );
923
-
924
  register_post_type( 'pf_contact', $args );
925
  }
926
-
927
  }
928
-
929
  /**
930
  * Add a Settings link in the plugins list for the Pirate Forms
931
  */
932
  function pirate_forms_add_settings_link( $links ) {
933
- $settings_link = '<a href="options-general.php?page=pirate-forms-admin">' . __( 'Settings','pirate-forms' ) . '</a>';
934
- if (function_exists('array_unshift')):
935
  array_unshift( $links, $settings_link );
936
- else:
937
  array_push( $links, $settings_link );
938
  endif;
 
939
  return $links;
940
  }
 
941
  $plugin = plugin_basename( __FILE__ );
942
  add_filter( "plugin_action_links_$plugin", 'pirate_forms_add_settings_link' );
943
-
944
  /**
945
  * Allow [pirate_forms] shortcode in text widget
946
  */
947
  add_filter( 'widget_text', 'pirate_forms_widget_text_filter', 9 );
948
-
949
  function pirate_forms_widget_text_filter( $content ) {
950
- if ( ! preg_match( '[pirate_forms]', $content ) )
951
  return $content;
952
-
953
  $content = do_shortcode( $content );
954
 
955
  return $content;
3
  Plugin Name: Free & Simple Contact Form Plugin - PirateForms
4
  Plugin URI: http://themeisle.com/plugins/pirate-forms/
5
  Description: Easily creates a nice looking, simple contact form on your WP site.
6
+ Version: 1.1.3
7
  Author: Themeisle
8
  Author URI: http://themeisle.com
9
  Text Domain: pirate-forms
11
  License: GPLv2
12
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
13
  */
 
14
  if ( ! function_exists( 'add_action' ) ) {
15
  die( 'Nothing to do...' );
16
  }
 
17
  /* Important constants */
18
+ define( 'PIRATE_FORMS_VERSION', '1.1.3' );
19
  define( 'PIRATE_FORMS_URL', plugin_dir_url( __FILE__ ) );
20
  define( 'PIRATE_FORMS_PATH', plugin_dir_path( __FILE__ ) );
 
21
  /* Required helper functions */
22
  include_once( dirname( __FILE__ ) . '/inc/helpers.php' );
23
  include_once( dirname( __FILE__ ) . '/inc/settings.php' );
24
  include_once( dirname( __FILE__ ) . '/inc/widget.php' );
 
25
  add_action( 'plugins_loaded', 'pirate_forms_load_textdomain' );
26
  /**
27
  * Load plugin textdomain.
41
  * @return string
42
  */
43
  add_shortcode( 'pirate_forms', 'pirate_forms_display_form' );
44
+ function pirate_forms_display_form( $atts, $content = null ) {
 
 
45
  /* thank you message */
46
  $pirate_forms_thankyou_message = '';
47
+ if ( ( isset( $_GET['pcf'] ) && $_GET['pcf'] == 1 ) || ( isset( $_POST['pirate-forms-contact-submit'] ) ) ) {
 
48
  $pirate_forms_thankyou_message .= '
49
  <div class="col-sm-12 col-lg-12 pirate_forms_thankyou_wrap">
50
  <p>' . sanitize_text_field( pirate_forms_get_key( 'pirateformsopt_label_submit' ) ) . '</p>
51
  </div>';
52
  }
53
+ /**
54
+ ******** FormBuilder */
55
+ if ( ! class_exists( 'PhpFormBuilder' ) ) {
 
 
 
56
  require_once( dirname( __FILE__ ) . '/inc/PhpFormBuilder.php' );
57
  }
 
58
  $pirate_form = new PhpFormBuilder();
 
59
  $pirate_form->set_att( 'id', 'pirate_forms_' . ( get_the_id() ? get_the_id() : 1 ) );
60
  $pirate_form->set_att( 'class', array( 'pirate_forms' ) );
 
61
  if ( 'yes' === pirate_forms_get_key( 'pirateformsopt_nonce' ) ) {
62
  $pirate_form->set_att( 'add_nonce', get_bloginfo( 'admin_email' ) );
63
  }
 
64
  $pirate_forms_options = get_option( 'pirate_forms_settings_array' );
65
+ if ( ! empty( $pirate_forms_options ) ) :
 
 
66
  /* Count the number of requested fields from Name, Email and Subject to add a certain class col-12, col-6 or col-4 */
67
  $pirate_forms_required_fields = 0;
68
+ if ( ! empty( $pirate_forms_options['pirateformsopt_name_field'] ) && ! empty( $pirate_forms_options['pirateformsopt_label_name'] ) ) :
69
+ $pirateformsopt_name_field = $pirate_forms_options['pirateformsopt_name_field'];
70
+ $pirateformsopt_name_label = $pirate_forms_options['pirateformsopt_label_name'];
71
+ if ( ! empty( $pirateformsopt_name_field ) && ! empty( $pirateformsopt_name_label ) && ( $pirateformsopt_name_field != '' ) ) :
72
+ $pirate_forms_required_fields ++;
73
+ endif;
 
 
 
 
74
  endif;
75
+ if ( ! empty( $pirate_forms_options['pirateformsopt_email_field'] ) && ! empty( $pirate_forms_options['pirateformsopt_label_email'] ) ) :
76
+ $pirateformsopt_email_field = $pirate_forms_options['pirateformsopt_email_field'];
77
+ $pirateformsopt_email_label = $pirate_forms_options['pirateformsopt_label_email'];
78
+ if ( ! empty( $pirateformsopt_email_field ) && ! empty( $pirateformsopt_email_label ) && ( $pirateformsopt_email_field != '' ) ) :
79
+ $pirate_forms_required_fields ++;
80
+ endif;
 
 
 
 
81
  endif;
82
+ if ( ! empty( $pirate_forms_options['pirateformsopt_subject_field'] ) && ! empty( $pirate_forms_options['pirateformsopt_label_subject'] ) ) :
83
+ $pirateformsopt_subject_field = $pirate_forms_options['pirateformsopt_subject_field'];
84
+ $pirateformsopt_subject_label = $pirate_forms_options['pirateformsopt_label_subject'];
85
+ if ( ! empty( $pirateformsopt_subject_field ) && ! empty( $pirateformsopt_subject_label ) && ( $pirateformsopt_subject_field != '' ) ) :
86
+ $pirate_forms_required_fields ++;
87
+ endif;
 
 
 
 
88
  endif;
 
89
  $pirate_forms_layout_input = '';
90
+ switch ( $pirate_forms_required_fields ) {
 
91
  case 1:
92
  $pirate_forms_layout_input = 'col-sm-12 col-lg-12';
93
  break;
100
  default:
101
  $pirate_forms_layout_input = 'col-sm-4 col-lg-4';
102
  }
103
+ /**
104
+ ****** Name field */
105
+ if ( ! empty( $pirateformsopt_name_field ) && ! empty( $pirateformsopt_name_label ) ) :
106
+ $required = $pirateformsopt_name_field === 'req' ? true : false;
107
+ $wrap_classes = array(
108
+ $pirate_forms_layout_input . ' form_field_wrap',
109
+ 'contact_name_wrap pirate_forms_three_inputs ',
110
+ );
111
+ // If this field was submitted with invalid data
112
+ if ( isset( $_SESSION['pirate_forms_contact_errors']['contact-name'] ) ) {
113
+ $wrap_classes[] = 'error';
114
+ }
115
+ $pirate_form->add_input(
116
+ '',
117
+ array(
118
+ 'placeholder' => stripslashes( sanitize_text_field( $pirateformsopt_name_label ) ),
119
+ 'required' => $required,
120
+ 'wrap_class' => $wrap_classes,
121
+ ),
122
+ 'pirate-forms-contact-name'
123
+ );
124
+ endif;
125
+ /**
126
+ ****** Email field */
127
+ if ( ! empty( $pirateformsopt_email_field ) && ! empty( $pirateformsopt_email_label ) ) :
128
+ $required = $pirateformsopt_email_field === 'req' ? true : false;
129
+ $wrap_classes = array(
130
+ $pirate_forms_layout_input . ' form_field_wrap',
131
+ 'contact_email_wrap pirate_forms_three_inputs ',
132
+ );
133
+ // If this field was submitted with invalid data
134
+ if ( isset( $_SESSION['pirate_forms_contact_errors']['contact-email'] ) ) {
135
+ $wrap_classes[] = 'error';
136
+ }
137
+ $pirate_form->add_input(
138
+ '',
139
+ array(
140
+ 'placeholder' => stripslashes( sanitize_text_field( $pirateformsopt_email_label ) ),
141
+ 'required' => $required,
142
+ 'type' => 'email',
143
+ 'wrap_class' => $wrap_classes,
144
+ ),
145
+ 'pirate-forms-contact-email'
146
+ );
147
+ endif;
148
+ /**
149
+ ****** Subject field */
150
+ if ( ! empty( $pirateformsopt_subject_field ) && ! empty( $pirateformsopt_subject_label ) ) :
151
+ $required = $pirateformsopt_subject_field === 'req' ? true : false;
152
+ $wrap_classes = array(
153
+ $pirate_forms_layout_input . ' form_field_wrap',
154
+ 'contact_subject_wrap pirate_forms_three_inputs ',
155
+ );
156
+ // If this field was submitted with invalid data
157
+ if ( isset( $_SESSION['pirate_forms_contact_errors']['contact-subject'] ) ) {
158
+ $wrap_classes[] = 'error';
159
+ }
160
+ $pirate_form->add_input(
161
+ '',
162
+ array(
163
+ 'placeholder' => stripslashes( sanitize_text_field( $pirateformsopt_subject_label ) ),
164
+ 'required' => $required,
165
+ 'wrap_class' => $wrap_classes,
166
+ ),
167
+ 'pirate-forms-contact-subject'
168
+ );
169
+ endif;
170
+ /**
171
+ ****** Message field */
172
+ if ( ! empty( $pirate_forms_options['pirateformsopt_message_field'] ) && ! empty( $pirate_forms_options['pirateformsopt_label_message'] ) ) :
173
+ $pirateformsopt_message_field = $pirate_forms_options['pirateformsopt_message_field'];
174
+ $pirateformsopt_message_label = $pirate_forms_options['pirateformsopt_label_message'];
175
+ if ( ! empty( $pirateformsopt_message_field ) && ! empty( $pirateformsopt_message_label ) ) :
176
+ $required = $pirateformsopt_message_field === 'req' ? true : false;
177
+ $wrap_classes = array( 'col-sm-12 col-lg-12 form_field_wrap', 'contact_message_wrap ' );
178
  // If this field was submitted with invalid data
179
+ if ( isset( $_SESSION['pirate_forms_contact_errors']['contact-message'] ) ) {
180
  $wrap_classes[] = 'error';
181
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
182
  $pirate_form->add_input(
183
  '',
184
  array(
185
+ 'placeholder' => stripslashes( sanitize_text_field( $pirateformsopt_message_label ) ),
186
+ 'required' => $required,
187
+ 'wrap_class' => $wrap_classes,
188
+ 'type' => 'textarea',
189
  ),
190
+ 'pirate-forms-contact-message'
191
  );
 
192
  endif;
193
+ endif;
194
+ /**
195
+ ******* ReCaptcha */
196
+ 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' ) ) :
197
+ $pirateformsopt_recaptcha_sitekey = $pirate_forms_options['pirateformsopt_recaptcha_sitekey'];
198
+ $pirateformsopt_recaptcha_secretkey = $pirate_forms_options['pirateformsopt_recaptcha_secretkey'];
199
+ $pirate_form->add_input(
200
+ '',
201
+ array(
202
+ 'value' => $pirateformsopt_recaptcha_sitekey,
203
+ 'wrap_class' => 'col-xs-12 col-sm-6 col-lg-6 form_field_wrap form_captcha_wrap',
204
+ 'type' => 'captcha',
205
+ ),
206
+ 'pirate-forms-captcha'
207
+ );
208
+ endif;
209
+ /**
210
+ ******** Attachment */
211
+ if ( ! empty( $pirate_forms_options['pirateformsopt_attachment_field'] ) && ( $pirate_forms_options['pirateformsopt_attachment_field'] == 'yes' ) ) {
212
+ $pirate_form->add_input(
213
+ '',
214
+ array(
215
+ 'wrap_class' => $wrap_classes,
216
+ 'type' => 'file',
217
+ ),
218
+ 'pirate-forms-attachment'
219
+ );
220
 
221
+ }
222
+ /**
223
+ ****** Submit button */
224
+ if ( ! empty( $pirate_forms_options['pirateformsopt_label_submit_btn'] ) ) :
225
+ $pirateformsopt_label_submit_btn = $pirate_forms_options['pirateformsopt_label_submit_btn'];
226
+ if ( ! empty( $pirateformsopt_label_submit_btn ) ) :
227
+ $wrap_classes = array();
228
  $pirate_form->add_input(
229
  '',
230
  array(
231
+ 'value' => stripslashes( sanitize_text_field( $pirateformsopt_label_submit_btn ) ),
232
  'wrap_class' => $wrap_classes,
233
+ 'type' => 'submit',
234
+ 'wrap_tag' => '',
235
+ 'class' => 'pirate-forms-submit-button',
236
  ),
237
+ 'pirate-forms-contact-submit'
238
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
239
  endif;
240
+ endif;
241
  endif;
 
242
  /* Referring site or page, if any */
243
  if ( ! empty( $_SERVER['HTTP_REFERER'] ) ) {
244
  $pirate_form->add_input(
245
+ __( 'Contact Referrer', 'pirate-forms' ),
246
  array(
247
  'type' => 'hidden',
248
+ 'value' => $_SERVER['HTTP_REFERER'],
249
  )
250
  );
251
  }
 
252
  /* Referring page, if sent via URL query */
253
  if ( ! empty( $_REQUEST['src'] ) || ! empty( $_REQUEST['ref'] ) ) {
254
  $pirate_form->add_input(
255
+ __( 'Referring page', 'pirate-forms' ),
256
  array(
257
  'type' => 'hidden',
258
+ 'value' => ! empty( $_REQUEST['src'] ) ? $_REQUEST['src'] : $_REQUEST['ref'],
259
  )
260
  );
261
  }
 
262
  /* Are there any submission errors? */
263
  $errors = '';
264
  if ( ! empty( $_SESSION['pirate_forms_contact_errors'] ) ) {
267
  }
268
 
269
  /* Display the form */
270
+
271
+ return $pirate_forms_thankyou_message . '
272
  <div class="pirate_forms_wrap">
273
  ' . $errors . '
274
+ ' . $pirate_form->build_form( false ) . '
275
  <div class="pirate_forms_clearfix"></div>
276
  </div>';
277
 
282
  */
283
  function pirate_forms_canonicalize( $text ) {
284
  if ( function_exists( 'mb_convert_kana' )
285
+ && 'UTF-8' == get_option( 'blog_charset' )
286
+ ) {
287
  $text = mb_convert_kana( $text, 'asKV', 'UTF-8' );
288
  }
 
289
  $text = strtolower( $text );
290
  $text = trim( $text );
291
+
292
  return $text;
293
  }
294
 
295
  function pirate_forms_antiscript_file_name( $filename ) {
296
  $filename = basename( $filename );
297
+ $parts = explode( '.', $filename );
298
+ if ( count( $parts ) < 2 ) {
 
299
  return $filename;
300
+ }
301
  $script_pattern = '/^(php|phtml|pl|py|rb|cgi|asp|aspx)\d?$/i';
302
+ $filename = array_shift( $parts );
303
+ $extension = array_pop( $parts );
 
 
304
  foreach ( (array) $parts as $part ) {
305
+ if ( preg_match( $script_pattern, $part ) ) {
306
  $filename .= '.' . $part . '_';
307
+ } else {
308
  $filename .= '.' . $part;
309
+ }
310
  }
311
+ if ( preg_match( $script_pattern, $extension ) ) {
 
312
  $filename .= '.' . $extension . '_.txt';
313
+ } else {
314
  $filename .= '.' . $extension;
315
+ }
316
 
317
  return $filename;
318
  }
319
 
320
  function pirate_forms_upload_dir( $type = false ) {
321
  $uploads = wp_upload_dir();
 
322
  $uploads = apply_filters( 'pirate_forms_upload_dir', array(
323
  'dir' => $uploads['basedir'],
324
+ 'url' => $uploads['baseurl'],
325
+ ) );
326
+ if ( 'dir' == $type ) {
327
  return $uploads['dir'];
328
+ }
329
+ if ( 'url' == $type ) {
330
  return $uploads['url'];
331
+ }
332
 
333
  return $uploads;
334
  }
340
  function pirate_forms_init_uploads() {
341
  $dir = pirate_forms_upload_tmp_dir();
342
  wp_mkdir_p( $dir );
 
343
  $htaccess_file = trailingslashit( $dir ) . '.htaccess';
 
344
  if ( file_exists( $htaccess_file ) ) {
345
  return;
346
  }
347
+ try {
348
+ if ( $handle = fopen( $htaccess_file, 'w' ) ) {
349
+ if ( ! $handle ) {
350
+ throw new Exception( 'File open failed.' );
351
+ }
352
+ fwrite( $handle, "Deny from all\n" );
353
+ fclose( $handle );
354
+ }
355
+ } catch ( Exception $e ) {
356
 
 
 
 
357
  }
358
  }
359
 
360
  function pirate_forms_maybe_add_random_dir( $dir ) {
361
  do {
362
  $rand_max = mt_getrandmax();
363
+ $rand = zeroise( mt_rand( 0, $rand_max ), strlen( $rand_max ) );
364
+ $dir_new = path_join( $dir, $rand );
365
  } while ( file_exists( $dir_new ) );
 
366
  if ( wp_mkdir_p( $dir_new ) ) {
367
  return $dir_new;
368
  }
375
  */
376
  add_action( 'template_redirect', 'pirate_forms_process_contact' );
377
  function pirate_forms_process_contact() {
 
378
  // If POST and honeypot are not set, beat it
379
+ if ( empty( $_POST ) || ! isset( $_POST['honeypot'] ) ) {
380
  return false;
381
  }
 
382
  // Session variable for form errors
383
  $_SESSION['pirate_forms_contact_errors'] = array();
 
384
  // If nonce is not valid, beat it
385
  if ( 'yes' === pirate_forms_get_key( 'pirateformsopt_nonce' ) ) {
386
  if ( ! wp_verify_nonce( $_POST['wordpress-nonce'], get_bloginfo( 'admin_email' ) ) ) {
389
  return false;
390
  }
391
  }
 
392
  // If the honeypot caught a bear, beat it
393
  if ( ! empty( $_POST['honeypot'] ) ) {
394
  $_SESSION['pirate_forms_contact_errors']['honeypot'] = __( 'Form submission failed!', 'pirate-forms' );
395
+
396
  return false;
397
  }
 
398
  // Start the body of the contact email
399
+ $body = '*** ' . __( 'Contact form submission from', 'pirate-forms' ) . ' ' .
400
+ get_bloginfo( 'name' ) . ' (' . site_url() . ") *** \n\n";
401
+ /**
402
+ ******* Sanitize and validate name */
 
 
 
 
403
  $pirate_forms_contact_name = isset( $_POST['pirate-forms-contact-name'] ) ? sanitize_text_field( trim( $_POST['pirate-forms-contact-name'] ) ) : '';
 
404
  // if name is required and is missing
405
+ if ( ( pirate_forms_get_key( 'pirateformsopt_name_field' ) === 'req' ) && empty( $pirate_forms_contact_name ) ) {
406
  $_SESSION['pirate_forms_contact_errors']['pirate-forms-contact-name'] = pirate_forms_get_key( 'pirateformsopt_label_err_name' );
407
+ } // If not required and empty, leave it out
 
408
  elseif ( ! empty( $pirate_forms_contact_name ) ) {
409
  $body .= stripslashes( pirate_forms_get_key( 'pirateformsopt_label_name' ) ) . ": $pirate_forms_contact_name \r";
410
  }
411
+ /**
412
+ ***** Sanitize and validate email */
 
 
 
 
413
  $pirate_forms_contact_email = isset( $_POST['pirate-forms-contact-email'] ) ? sanitize_email( $_POST['pirate-forms-contact-email'] ) : '';
 
414
  // If required, is it valid?
415
+ if ( ( pirate_forms_get_key( 'pirateformsopt_email_field' ) === 'req' ) && ! filter_var( $pirate_forms_contact_email, FILTER_VALIDATE_EMAIL ) ) {
416
  $_SESSION['pirate_forms_contact_errors']['pirate-forms-contact-email'] = pirate_forms_get_key( 'pirateformsopt_label_err_email' );
417
+ } // If not required and empty, leave it out
 
418
  elseif ( ! empty( $pirate_forms_contact_email ) ) {
419
  $body .= stripslashes( pirate_forms_get_key( 'pirateformsopt_label_email' ) )
420
+ . ": $pirate_forms_contact_email \r";
421
  }
422
+ /**
423
+ ******* Sanitize and validate subject */
 
 
 
424
  $pirate_forms_contact_subject = isset( $_POST['pirate-forms-contact-subject'] ) ? sanitize_text_field( trim( $_POST['pirate-forms-contact-subject'] ) ) : '';
 
425
  // if subject is required and is missing
426
+ if ( ( pirate_forms_get_key( 'pirateformsopt_subject_field' ) === 'req' ) && empty( $pirate_forms_contact_subject ) ) {
427
  $_SESSION['pirate_forms_contact_errors']['pirate-forms-contact-subject'] = pirate_forms_get_key( 'pirateformsopt_label_err_subject' );
428
+ } // If not required and empty, leave it out
 
429
  elseif ( ! empty( $pirate_forms_contact_subject ) ) {
430
  $body .= stripslashes( pirate_forms_get_key( 'pirateformsopt_label_subject' ) ) . ": $pirate_forms_contact_subject \r";
431
  }
432
+ /**
433
+ ******* Sanitize and validate message */
 
 
 
434
  $pirate_forms_contact_message = isset( $_POST['pirate-forms-contact-message'] ) ? sanitize_text_field( trim( $_POST['pirate-forms-contact-message'] ) ) : '';
 
435
  // if message is required and is missing
436
+ if ( ( pirate_forms_get_key( 'pirateformsopt_message_field' ) === 'req' ) && empty( $pirate_forms_contact_message ) ) {
437
  $_SESSION['pirate_forms_contact_errors']['pirate-forms-contact-message'] = pirate_forms_get_key( 'pirateformsopt_label_err_message' );
438
+ } // If not required and empty, leave it out
 
439
  elseif ( ! empty( $pirate_forms_contact_message ) ) {
440
  $body .= stripslashes( pirate_forms_get_key( 'pirateformsopt_label_message' ) ) . ": $pirate_forms_contact_message \r";
441
  }
442
+ /**
443
+ *********** Validate reCAPTCHA */
444
+ $pirateformsopt_recaptcha_sitekey = pirate_forms_get_key( 'pirateformsopt_recaptcha_sitekey' );
445
+ $pirateformsopt_recaptcha_secretkey = pirate_forms_get_key( 'pirateformsopt_recaptcha_secretkey' );
446
+ $pirateformsopt_recaptcha_field = pirate_forms_get_key( 'pirateformsopt_recaptcha_field' );
447
+ if ( ! empty( $pirateformsopt_recaptcha_secretkey ) && ! empty( $pirateformsopt_recaptcha_sitekey ) && ! empty( $pirateformsopt_recaptcha_field ) && ( $pirateformsopt_recaptcha_field == 'yes' ) ) :
448
+ if ( isset( $_POST['g-recaptcha-response'] ) ) {
 
 
 
 
 
 
449
  $captcha = $_POST['g-recaptcha-response'];
450
  }
451
+ if ( ! $captcha ) {
452
+ $_SESSION['pirate_forms_contact_errors']['pirate-forms-captcha'] = __( 'Wrong reCAPTCHA', 'pirate-forms' );
453
  }
454
+ $response = wp_remote_get( 'https://www.google.com/recaptcha/api/siteverify?secret=' . $pirateformsopt_recaptcha_secretkey . '&response=' . $captcha . '&remoteip=' . $_SERVER['REMOTE_ADDR'] );
455
+ if ( ! empty( $response ) ) :
 
456
  $response_body = wp_remote_retrieve_body( $response );
457
  endif;
458
+ if ( ! empty( $response_body ) ) :
 
459
  $result = json_decode( $response_body, true );
460
  endif;
461
+ if ( isset( $result['success'] ) && ( $result['success'] == false ) ) {
462
+ $_SESSION['pirate_forms_contact_errors']['pirate-forms-captcha'] = __( 'Wrong reCAPTCHA', 'pirate-forms' );
 
463
  }
464
  endif;
465
+ /**
466
+ ******** Validate recipients email */
 
 
467
  $site_recipients = sanitize_text_field( pirate_forms_get_key( 'pirateformsopt_email_recipients' ) );
468
+ if ( empty( $site_recipients ) ) {
469
+ $_SESSION['pirate_forms_contact_errors']['pirate-forms-recipients-email'] = __( 'Please enter one or more Contact submission recipients', 'pirate-forms' );
 
 
470
  }
471
+ /**
472
+ ****** Sanitize and validate IP */
 
 
 
473
  $contact_ip = filter_var( $_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP );
 
474
  /* for the case of a Web server behind a reverse proxy */
475
+ if ( array_key_exists( 'HTTP_X_FORWARDED_FOR', $_SERVER ) ) {
476
+ $contact_ip_tmp = explode( ',', $_SERVER['HTTP_X_FORWARDED_FOR'] );
477
+ if ( ! empty( $contact_ip_tmp ) ) {
 
478
  $contact_ip = array_pop( $contact_ip_tmp );
479
  }
 
480
  }
 
481
  // If valid and present, create a link to an IP search
482
  if ( ! empty( $contact_ip ) ) {
483
+ $body .= __( 'IP address: ', 'pirate-forms' ) . $contact_ip . "\r " . __( 'IP search:', 'pirate-forms' ) . " http://whatismyipaddress.com/ip/$contact_ip \n\n";
484
  }
 
485
  // Sanitize and prepare referrer;
486
  if ( ! empty( $_POST['pirate-forms-contact-referrer'] ) ) {
487
+ $body .= __( 'Came from: ', 'pirate-forms' ) . sanitize_text_field( $_POST['pirate-forms-contact-referrer'] ) . " \r";
488
  }
 
489
  // Show the page this contact form was submitted on
490
+ $body .= __( 'Sent from page: ', 'pirate-forms' ) . get_permalink( get_the_id() );
 
491
  // Check the blacklist
492
  $blocked = pirate_forms_get_blacklist();
493
  if ( ! empty( $blocked ) ) {
494
  if (
495
+ in_array( $pirate_forms_contact_email, $blocked ) ||
496
+ in_array( $contact_ip, $blocked )
497
  ) {
498
+ $_SESSION['pirate_forms_contact_errors']['blacklist-blocked'] = __( 'Form submission blocked!', 'pirate-forms' );
499
+
500
  return false;
501
  }
502
  }
 
503
  // No errors? Go ahead and process the contact
504
  if ( empty( $_SESSION['pirate_forms_contact_errors'] ) ) {
 
505
  $pirate_forms_options_tmp = get_option( 'pirate_forms_settings_array' );
506
+ if ( isset( $pirate_forms_options_tmp['pirateformsopt_email'] ) ) {
507
  $site_email = $pirate_forms_options_tmp['pirateformsopt_email'];
508
  }
509
+ if ( ! empty( $pirate_forms_contact_name ) ) :
 
510
  $site_name = $pirate_forms_contact_name;
511
+ else :
512
+ $site_name = htmlspecialchars_decode( get_bloginfo( 'name' ) );
513
  endif;
 
514
  // Notification recipients
515
  $site_recipients = sanitize_text_field( pirate_forms_get_key( 'pirateformsopt_email_recipients' ) );
516
+ $site_recipients = explode( ',', $site_recipients );
517
  $site_recipients = array_map( 'trim', $site_recipients );
518
  $site_recipients = array_map( 'sanitize_email', $site_recipients );
519
  $site_recipients = implode( ',', $site_recipients );
 
520
  // No name? Use the submitter email address, if one is present
521
  if ( empty( $pirate_forms_contact_name ) ) {
522
  $pirate_forms_contact_name = ! empty( $pirate_forms_contact_email ) ? $pirate_forms_contact_email : '[None given]';
523
  }
524
+ // Need an email address for the email notification
525
+ if ( ! empty( $site_email ) ) {
526
+ if ( $site_email == '[email]' ) {
527
+ if ( ! empty( $pirate_forms_contact_email ) ) {
 
528
  $send_from = $pirate_forms_contact_email;
529
+ } else {
530
+ $send_from = pirate_forms_from_email();
531
  }
532
+ } else {
 
 
 
 
533
  $send_from = $site_email;
534
  }
535
+ } else {
 
536
  $send_from = pirate_forms_from_email();
537
  }
 
538
  $send_from_name = $site_name;
 
 
539
  // Sent an email notification to the correct address
540
+ $headers = "From: $send_from_name <$send_from>\r\nReply-To: $pirate_forms_contact_name <$pirate_forms_contact_email>";
 
541
  add_action( 'phpmailer_init', 'pirate_forms_phpmailer' );
542
 
543
+ /**
544
+ ******* Validate Attachment */
545
+ $attachments = '';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
546
  $pirate_forms_attach_file = isset( $_FILES['pirate-forms-attachment'] ) ? $_FILES['pirate-forms-attachment'] : '';
547
+ if ( ! empty( $pirate_forms_attach_file ) && ! empty( $pirate_forms_attach_file['name'] ) ) {
 
 
548
  /* Validate file type */
549
  $pirate_forms_file_types_allowed = 'jpg|jpeg|png|gif|pdf|doc|docx|ppt|pptx|odt|avi|ogg|m4a|mov|mp3|mp4|mpg|wav|wmv';
 
550
  $pirate_forms_file_types_allowed = trim( $pirate_forms_file_types_allowed, '|' );
551
  $pirate_forms_file_types_allowed = '(' . $pirate_forms_file_types_allowed . ')';
552
  $pirate_forms_file_types_allowed = '/\.' . $pirate_forms_file_types_allowed . '$/i';
 
553
  if ( ! preg_match( $pirate_forms_file_types_allowed, $pirate_forms_attach_file['name'] ) ) {
554
  $_SESSION['pirate_forms_contact_errors']['pirate-forms-upload-failed-type'] = __( 'Uploaded file is not allowed for file type', 'pirate-forms' );
555
  }
 
556
  /* Validate file size */
557
  $pirate_forms_file_size_allowed = 1048576; // default size 1 MB
 
558
  if ( $pirate_forms_attach_file['size'] > $pirate_forms_file_size_allowed ) {
559
  $_SESSION['pirate_forms_contact_errors']['pirate-forms-upload-failed-size'] = __( 'Uploaded file is too large', 'pirate-forms' );
560
  }
 
561
  pirate_forms_init_uploads();
562
  $uploads_dir = pirate_forms_upload_tmp_dir();
563
  $uploads_dir = pirate_forms_maybe_add_random_dir( $uploads_dir );
564
+ $filename = $pirate_forms_attach_file['name'];
565
+ $filename = pirate_forms_canonicalize( $filename );
566
+ $filename = sanitize_file_name( $filename );
567
+ $filename = pirate_forms_antiscript_file_name( $filename );
568
+ $filename = wp_unique_filename( $uploads_dir, $filename );
569
+ $new_file = trailingslashit( $uploads_dir ) . $filename;
570
+ try {
571
+ if ( false === move_uploaded_file( $pirate_forms_attach_file['tmp_name'], $new_file ) ) {
572
+ throw new Exception( __( 'There was an unknown error uploading the file.', 'pirate-forms' ) );
573
+ }
574
+ // Make sure the uploaded file is only readable for the owner process
575
+ if ( false === chmod( $new_file, 0400 ) ) {
576
+ throw new Exception( __( 'There was an unknown error uploading the file.', 'pirate-forms' ) );
577
+ }
578
+ } catch ( Exception $ex ) {
579
+ $_SESSION['pirate_forms_contact_errors']['pirate-forms-upload-failed-general'] = $ex->getMessage();
580
  }
581
+ if ( ! empty( $new_file ) ) {
 
 
 
 
582
  $attachments = $new_file;
583
  }
 
584
  }
 
585
  wp_mail( $site_recipients, 'Contact on ' . htmlspecialchars_decode( get_bloginfo( 'name' ) ), $body, $headers, $attachments );
 
586
  // Should a confirm email be sent?
587
  $confirm_body = stripslashes( trim( pirate_forms_get_key( 'pirateformsopt_confirm_email' ) ) );
588
  if ( ! empty( $confirm_body ) && ! empty( $pirate_forms_contact_email ) ) {
 
589
  // Removing entities
590
  $confirm_body = htmlspecialchars_decode( $confirm_body );
591
  $confirm_body = html_entity_decode( $confirm_body );
592
  $confirm_body = str_replace( '&#39;', "'", $confirm_body );
593
+ $headers = "From: $site_name <$site_email>\r\nReply-To: $site_name <$site_email>";
 
 
594
  wp_mail(
595
  $pirate_forms_contact_email,
596
  pirate_forms_get_key( 'pirateformsopt_label_submit' ) . ' - ' . $site_name,
598
  $headers
599
  );
600
  }
601
+ /**
602
+ *********** Store the entries in the DB */
 
 
 
603
  if ( pirate_forms_get_key( 'pirateformsopt_store' ) === 'yes' ) {
604
  $new_post_id = wp_insert_post(
605
  array(
607
  'post_title' => date( 'l, M j, Y', time() ) . ' by "' . $pirate_forms_contact_name . '"',
608
  'post_content' => $body,
609
  'post_author' => 1,
610
+ 'post_status' => 'private',
611
  )
612
  );
 
613
  if ( isset( $pirate_forms_contact_email ) && ! empty( $pirate_forms_contact_email ) ) {
614
  add_post_meta( $new_post_id, 'Contact email', $pirate_forms_contact_email );
615
  }
616
  }
 
617
  $pirate_forms_current_theme = wp_get_theme();
 
618
  /* If a Thank you page is selected, redirect to that page */
619
  if ( pirate_forms_get_key( 'pirateformsopt_thank_you_url' ) ) {
620
  $redirect_id = intval( pirate_forms_get_key( 'pirateformsopt_thank_you_url' ) );
621
  $redirect = get_permalink( $redirect_id );
622
  wp_safe_redirect( $redirect );
623
+ } /* Redirect to ?pcf=1#contact only if the theme is Zerif */
624
+ 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 ) ) {
625
+ $redirect = $_SERVER['HTTP_REFERER'] . ( strpos( $_SERVER['HTTP_REFERER'], '?' ) === false ? '?' : '&' ) . 'pcf=1#contact';
 
626
  wp_safe_redirect( $redirect );
627
  }
 
628
  }
629
 
630
  }
631
 
632
+ /**
633
+ * Alter the phpmailer object
634
+ *
635
+ * @param $phpmailer PHPMailer object
636
+ */
637
+ function pirate_forms_phpmailer( $phpmailer ) {
638
+ $pirateformsopt_use_smtp = pirate_forms_get_key( 'pirateformsopt_use_smtp' );
639
+ $pirateformsopt_smtp_host = pirate_forms_get_key( 'pirateformsopt_smtp_host' );
640
+ $pirateformsopt_smtp_port = pirate_forms_get_key( 'pirateformsopt_smtp_port' );
641
+ $pirateformsopt_smtp_username = pirate_forms_get_key( 'pirateformsopt_smtp_username' );
642
+ $pirateformsopt_smtp_password = pirate_forms_get_key( 'pirateformsopt_smtp_password' );
643
+ $pirateformsopt_use_smtp_authentication = pirate_forms_get_key( 'pirateformsopt_use_smtp_authentication' );
644
+ if ( ! empty( $pirateformsopt_use_smtp ) && ( $pirateformsopt_use_smtp == 'yes' ) && ! empty( $pirateformsopt_smtp_host ) && ! empty( $pirateformsopt_smtp_port ) ) :
645
+ // @codingStandardsIgnoreStart
646
+ $phpmailer->isSMTP();
647
+ $phpmailer->Host = $pirateformsopt_smtp_host;
648
+ if ( ! empty( $pirateformsopt_use_smtp_authentication ) && ( $pirateformsopt_use_smtp_authentication == 'yes' ) && ! empty( $pirateformsopt_smtp_username ) && ! empty( $pirateformsopt_smtp_password ) ) :
649
+ $phpmailer->SMTPAuth = true; // Force it to use Username and Password to authenticate
650
+ $phpmailer->Port = $pirateformsopt_smtp_port;
651
+ $phpmailer->Username = $pirateformsopt_smtp_username;
652
+ $phpmailer->Password = $pirateformsopt_smtp_password;
653
+ endif;
654
+ // @codingStandardsIgnoreEnd
655
+ endif;
656
+ }
657
+
658
  /* Get a settings value */
659
  function pirate_forms_get_key( $id ) {
660
  $pirate_forms_options = get_option( 'pirate_forms_settings_array' );
661
 
662
+ return isset( $pirate_forms_options[ $id ] ) ? $pirate_forms_options[ $id ] : '';
663
  }
664
 
665
+ /**
666
+ ************************** Scripts and Styles */
 
 
 
667
  add_action( 'wp_enqueue_scripts', 'pirate_forms_add_styles_and_scripts' );
 
668
  function pirate_forms_add_styles_and_scripts() {
 
669
  /* style for frontpage contact */
670
  wp_enqueue_style( 'pirate_forms_front_styles', PIRATE_FORMS_URL . 'css/front.css' );
 
671
  /* recaptcha js */
672
  $pirate_forms_options = get_option( 'pirate_forms_settings_array' );
673
+ if ( ! empty( $pirate_forms_options ) ) :
674
+ 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' ) ) :
675
+ if ( defined( 'POLYLANG_VERSION' ) && function_exists( 'pll_current_language' ) ) {
 
 
 
676
  $pirate_forms_contactus_language = pll_current_language();
677
  } else {
678
  $pirate_forms_contactus_language = get_locale();
679
  }
680
+ wp_enqueue_script( 'recaptcha', 'https://www.google.com/recaptcha/api.js?hl=' . $pirate_forms_contactus_language . '' );
681
+ wp_enqueue_script( 'pirate_forms_scripts', plugins_url( 'js/scripts.js', __FILE__ ), array(
682
+ 'jquery',
683
+ 'recaptcha',
684
+ ) );
685
  endif;
 
686
  endif;
687
+ wp_enqueue_script( 'pirate_forms_scripts_general', plugins_url( 'js/scripts-general.js', __FILE__ ), array( 'jquery' ) );
 
 
688
  $pirate_forms_errors = '';
689
+ if ( ! empty( $_SESSION['pirate_forms_contact_errors'] ) ) :
 
690
  $pirate_forms_errors = $_SESSION['pirate_forms_contact_errors'];
691
  endif;
 
692
  wp_localize_script( 'pirate_forms_scripts_general', 'pirateFormsObject', array(
693
+ 'errors' => $pirate_forms_errors,
694
  ) );
695
 
696
  }
697
 
698
  add_action( 'admin_enqueue_scripts', 'pirate_forms_admin_css' );
 
699
  function pirate_forms_admin_css() {
 
700
  global $pagenow;
701
+ if ( ! empty( $pagenow ) && ( $pagenow == 'options-general.php' || $pagenow == 'admin.php' )
702
+ && isset( $_GET['page'] ) && $_GET['page'] == 'pirate-forms-admin'
703
+ ) {
 
704
  wp_enqueue_style( 'pirate_forms_admin_styles', PIRATE_FORMS_URL . 'css/wp-admin.css' );
705
+ wp_enqueue_script( 'pirate_forms_scripts_admin', plugins_url( 'js/scripts-admin.js', __FILE__ ), array( 'jquery' ) );
 
706
  wp_localize_script( 'pirate_forms_scripts_admin', 'cwp_top_ajaxload', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );
707
  }
708
  }
709
 
710
+ /**
711
+ * If submissions should be stored in the DB, create the Contacts CPT */
 
 
712
  if ( pirate_forms_get_key( 'pirateformsopt_store' ) === 'yes' ) {
 
713
  add_action( 'init', 'pirate_forms_register_content_type' );
 
714
  function pirate_forms_register_content_type() {
 
715
  $labels = array(
716
  'name' => _x( 'Contacts', 'post type general name', 'pirate-forms' ),
717
  'singular_name' => _x( 'Contact', 'post type singular name', 'pirate-forms' ),
726
  'search_items' => __( 'Search Contacts', 'pirate-forms' ),
727
  'parent_item_colon' => __( 'Parent Contacts:', 'pirate-forms' ),
728
  'not_found' => __( 'No contacts found.', 'pirate-forms' ),
729
+ 'not_found_in_trash' => __( 'No contacts found in Trash.', 'pirate-forms' ),
730
  );
731
+ $args = array(
732
  'labels' => $labels,
733
  'description' => __( 'Contacts from Pirate Forms', 'pirate-forms' ),
734
  'public' => true,
740
  'has_archive' => true,
741
  'hierarchical' => false,
742
  'menu_position' => null,
743
+ 'supports' => array( 'title', 'editor', 'custom-fields' ),
744
  );
 
745
  register_post_type( 'pf_contact', $args );
746
  }
 
747
  }
 
748
  /**
749
  * Add a Settings link in the plugins list for the Pirate Forms
750
  */
751
  function pirate_forms_add_settings_link( $links ) {
752
+ $settings_link = '<a href="options-general.php?page=pirate-forms-admin">' . __( 'Settings', 'pirate-forms' ) . '</a>';
753
+ if ( function_exists( 'array_unshift' ) ) :
754
  array_unshift( $links, $settings_link );
755
+ else :
756
  array_push( $links, $settings_link );
757
  endif;
758
+
759
  return $links;
760
  }
761
+
762
  $plugin = plugin_basename( __FILE__ );
763
  add_filter( "plugin_action_links_$plugin", 'pirate_forms_add_settings_link' );
 
764
  /**
765
  * Allow [pirate_forms] shortcode in text widget
766
  */
767
  add_filter( 'widget_text', 'pirate_forms_widget_text_filter', 9 );
 
768
  function pirate_forms_widget_text_filter( $content ) {
769
+ if ( ! preg_match( '[pirate_forms]', $content ) ) {
770
  return $content;
771
+ }
772
  $content = do_shortcode( $content );
773
 
774
  return $content;
readme.txt CHANGED
@@ -2,7 +2,7 @@
2
  Contributors: themeisle, codeinwp, rodicaelena, alexandrastan001, gouravwptech, hardeepasrani
3
  Tags: contact forms plugin, contact form, contact us, contact us form, contacts form plugin, custom form, subscribe form, feedback form, wordpress contact form
4
  Requires at least: 3.0
5
- Tested up to: 4.6
6
  Stable tag: trunk
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -77,6 +77,19 @@ Activating the Pirate Contact Form plugin is just like any other plugin. If you'
77
 
78
  == Changelog ==
79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  = 1.0.17 =
81
  * Fixed IP issue when using web server behind a reverse proxy
82
  * Fixed W3C compatibility issues
2
  Contributors: themeisle, codeinwp, rodicaelena, alexandrastan001, gouravwptech, hardeepasrani
3
  Tags: contact forms plugin, contact form, contact us, contact us form, contacts form plugin, custom form, subscribe form, feedback form, wordpress contact form
4
  Requires at least: 3.0
5
+ Tested up to: 4.7
6
  Stable tag: trunk
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
77
 
78
  == Changelog ==
79
 
80
+ = 1.1.3 =
81
+
82
+ * Added integration with custom emails plugin
83
+ * Fixed text domains errors
84
+
85
+ = 1.1.0 =
86
+ * Escape form fields ( Thanks to Gabriel Avramescu gabriel.avramescu@ituniversity.ro )
87
+
88
+ = 1.0.18 =
89
+ * Fixed php strict standards error
90
+ * Update tags
91
+ * Tested up to WordPress 4.6
92
+
93
  = 1.0.17 =
94
  * Fixed IP issue when using web server behind a reverse proxy
95
  * Fixed W3C compatibility issues