31d3bf62 by Jeff Balicki

Get the whole story…

Signed-off-by: Jeff <jeff@gotenzing.com>
1 parent a0a26288
Showing 128 changed files with 5113 additions and 0 deletions
1 /*
2 * Tabs
3 */
4 #contact-form-editor-tabs {
5 padding: 9px 10px 0 15px;
6 }
7
8 /*
9 * Form Tab
10 */
11 .tag-generator-panel {
12 text-align: right;
13 }
14
15 .tag-generator-panel .control-box > fieldset > legend {
16 border: 1px solid #dfdfdf;
17 border-right: 4px solid #00a0d2;
18 }
19
20 .tag-generator-panel .insert-box input.tag {
21 float: right;
22 }
23
24 .tag-generator-panel .insert-box .submitbox input[type="button"] {
25 float: left;
26 }
27
28 /*
29 * Mail Tab
30 */
31 .contact-form-editor-box-mail span.mailtag {
32 margin: 0 4px 0 0;
33 }
34
35 /*
36 * Welcome Panel
37 */
38 .wpcf7-welcome-panel .welcome-panel-close {
39 left: 10px;
40 right: auto;
41 padding: 10px 21px 10px 15px;
42 }
43
44 .wpcf7-welcome-panel .welcome-panel-close::before {
45 right: 0;
46 left: auto;
47 }
48
49 .wpcf7-welcome-panel .welcome-panel-content {
50 margin-right: 13px;
51 }
52
53 .wpcf7-welcome-panel .welcome-panel-column {
54 float: right;
55 padding: 0 0 0 2%;
56 }
57
58 /*
59 * Integration
60 */
61 .card {
62 border-left: 1px solid #e5e5e5;
63 border-right: 4px solid #e5e5e5;
64 }
65
66 .card img.icon {
67 float: right;
68 margin: 8px -8px 8px 8px;
69 }
70
71 .card h2.title {
72 float: right;
73 }
74
75 .card .infobox {
76 float: left;
77 }
1 #titlediv .inside p.description {
2 margin: 8px 2px 0;
3 }
4
5 #titlediv .inside p.description label {
6 cursor: pointer;
7 }
8
9 span.shortcode {
10 display: block;
11 margin: 2px 0;
12 }
13
14 span.shortcode.old {
15 background: #777;
16 color: #fff;
17 }
18
19 span.shortcode input {
20 font-size: 12px;
21 border: none;
22 box-shadow: none;
23 padding: 4px 8px;
24 margin: 0;
25 }
26
27 #wpcf7-contact-form-list-table span.shortcode input,
28 #wpcf7-contact-form-editor span.shortcode input {
29 background: transparent;
30 }
31
32 #wpcf7-contact-form-list-table span.shortcode input {
33 color: #444;
34 }
35
36 #wpcf7-contact-form-editor span.shortcode input {
37 color: #fff;
38 }
39
40 #submitpost input.copy {
41 margin-bottom: 10px;
42 }
43
44 #submitpost input.delete {
45 padding: 0;
46 margin: 0;
47 border: none;
48 cursor: pointer;
49 background: inherit;
50 color: #a00;
51 }
52
53 #submitpost input.delete:hover {
54 color: #dc3232; /* Red */
55 }
56
57 #submitpost input.delete:focus {
58 outline: thin dotted;
59 }
60
61 .postbox-container .postbox h3 {
62 border-bottom: 1px solid transparent;
63 }
64
65 .keyboard-interaction {
66 visibility: hidden;
67 color: #23282d; /* Dark Gray 800 */
68 }
69
70 div.config-error, span.config-error, ul.config-error {
71 color: #444;
72 font-style: normal;
73 font-size: 13px;
74 }
75
76 ul.config-error {
77 margin: 2px 0;
78 }
79
80 ul.config-error li {
81 list-style: none;
82 padding: 2px 2px;
83 margin: 0;
84 }
85
86 [data-config-field][aria-invalid="true"] {
87 border-color: #dc3232;
88 }
89
90 #contact-form-editor-tabs li a .icon-in-circle,
91 #contact-form-editor .config-error .icon-in-circle,
92 .wp-list-table .config-error .icon-in-circle,
93 .icon-in-circle {
94 display: inline-block;
95 vertical-align: text-top;
96 margin: 1px 6px 0;
97 padding: 0 5px;
98 min-width: 7px;
99 height: 17px;
100 border-radius: 11px;
101 background-color: #ca4a1f;
102 color: #fff;
103 font-size: 12px;
104 font-weight: bold;
105 line-height: 17px;
106 text-align: center;
107 z-index: 26;
108 }
109
110 /*
111 * Tabs
112 */
113 #contact-form-editor-tabs {
114 border-bottom: 1px solid #aaa;
115 padding: 9px 15px 0 10px;
116 margin: 0;
117 }
118
119 #contact-form-editor-tabs li {
120 display: inline-block;
121 list-style: none;
122 border: 1px solid #ccc;
123 border-bottom: 1px solid #aaa;
124 padding: 0;
125 margin: 0 4px -1px;
126 background-color: #e4e4e4;
127 }
128
129 #contact-form-editor-tabs li:hover {
130 background-color: #fff;
131 }
132
133 #contact-form-editor-tabs li.ui-tabs-active,
134 #contact-form-editor-tabs li.ui-tabs-active:hover {
135 border-top: 1px solid #aaa;
136 border-right: 1px solid #aaa;
137 border-left: 1px solid #aaa;
138 border-bottom: 1px solid #f5f5f5;
139 background-color: #f5f5f5;
140 }
141
142 #contact-form-editor-tabs li a {
143 padding: 6px 10px;
144 font-size: 14px;
145 font-weight: normal;
146 line-height: 30px;
147 color: #333;
148 text-decoration: none;
149 }
150
151 #contact-form-editor-tabs li.ui-tabs-active a {
152 color: #000;
153 font-size: 14px;
154 font-weight: bold;
155 }
156
157 #contact-form-editor-tabs li a:hover {
158 color: #000;
159 }
160
161 #contact-form-editor .contact-form-editor-panel > div.config-error {
162 margin-bottom: 1.4em;
163 }
164
165 #contact-form-editor-tabs li.ui-tabs-active a .icon-in-circle {
166 display: none;
167 }
168
169 #contact-form-editor .contact-form-editor-panel h2 {
170 font-size: 18px;
171 font-weight: 400;
172 line-height: 24px;
173 margin: 8px 0;
174 padding: 0;
175 }
176
177 #contact-form-editor .contact-form-editor-panel {
178 background-color: #f5f5f5;
179 border: 1px solid #aaa;
180 border-top: none;
181 padding: 16px;
182 }
183
184 #contact-form-editor .form-table th {
185 width: 100px;
186 }
187
188 #contact-form-editor .contact-form-editor-panel fieldset legend {
189 line-height: 1.5;
190 margin: .6em 0 .4em;
191 }
192
193 /*
194 * Form Tab
195 */
196 #tag-generator-list a.button {
197 font-size: 12px;
198 height: 26px;
199 line-height: 24px;
200 margin: 2px;
201 padding: 0 8px 1px;
202 }
203
204 .tag-generator-panel {
205 height: 495px;
206 display: flex;
207 flex-direction: column;
208 }
209
210 .tag-generator-panel .control-box {
211 padding: 0;
212 margin: 0;
213 overflow: auto;
214 flex-grow: 1;
215 }
216
217 .tag-generator-panel .control-box > fieldset > legend {
218 border: 1px solid #dfdfdf;
219 border-left: 4px solid #00a0d2;
220 background: #f7fcfe;
221 padding: 4px 12px;
222 margin: 4px 0;
223 line-height: 1.4em;
224 width: 100%;
225 box-sizing: border-box;
226 }
227
228 .tag-generator-panel table {
229 width: 100%;
230 }
231
232 .tag-generator-panel table.form-table th {
233 width: 120px;
234 padding: 4px 10px 4px 0;
235 font-size: 13px;
236 }
237
238 .tag-generator-panel table.form-table td {
239 padding: 4px 10px;
240 font-size: 13px;
241 }
242
243 .tag-generator-panel .control-box input.oneline {
244 width: 200px;
245 }
246
247 .tag-generator-panel .control-box input.large-text {
248 width: 400px;
249 }
250
251 .tag-generator-panel .control-box textarea.values {
252 width: 200px;
253 height: 6em;
254 }
255
256 .tag-generator-panel .control-box input[type="number"],
257 .tag-generator-panel .control-box input[type="date"] {
258 width: 88px;
259 }
260
261 .tag-generator-panel .control-box table caption {
262 text-align: left;
263 font-size: 110%;
264 font-weight: bold;
265 color: #777;
266 margin: 10px 0 5px;
267 }
268
269 .tag-generator-panel .control-box table.form-table td label {
270 line-height: 1.1em;
271 }
272
273 .tag-generator-panel .control-box table.form-table td label .description {
274 line-height: 1.4em;
275 }
276
277 .tag-generator-panel .insert-box {
278 margin: 0 -15px -15px;
279 padding: 8px 16px;
280 background-color: #fcfcfc;
281 border-top: 1px solid #dfdfdf;
282 overflow: auto;
283 }
284
285 .tag-generator-panel .insert-box input.tag {
286 width: 510px;
287 float: left;
288 background-color: transparent;
289 box-shadow: none;
290 }
291
292 .tag-generator-panel .insert-box .submitbox {
293 padding: 0;
294 }
295
296 .tag-generator-panel .insert-box .submitbox input[type="button"] {
297 float: right;
298 }
299
300 .tag-generator-panel .insert-box .description label {
301 cursor: text;
302 }
303
304 /*
305 * Mail Tab
306 */
307 .contact-form-editor-box-mail span.mailtag {
308 display: inline-block;
309 margin: 0 0 0 4px;
310 padding: 1px 2px;
311 cursor: pointer;
312 color: #000;
313 }
314
315 .contact-form-editor-box-mail span.mailtag.used {
316 color: #666;
317 }
318
319 .contact-form-editor-box-mail span.mailtag.unused {
320 font-weight: bold;
321 }
322
323 /*
324 * Messages Tab
325 */
326 #messages-panel p.description {
327 margin: 5px 0 10px;
328 }
329
330 /*
331 * Tabs for integration modules
332 */
333 #ctct-panel table tr.inactive ~ tr,
334 #sendinblue-panel table tr.inactive ~ tr {
335 display: none;
336 }
337
338 #ctct-panel .dashicons,
339 #sendinblue-panel .dashicons {
340 text-decoration: none;
341 }
342
343 #ctct-panel td p,
344 #sendinblue-panel td p {
345 margin-top: 12px;
346 }
347
348 /*
349 * List Table
350 */
351 .fixed .column-title {
352 width: 38%;
353 }
354
355 .fixed .column-shortcode {
356 width: 38%;
357 }
358
359 /*
360 * Welcome Panel
361 */
362 .wpcf7-welcome-panel {
363 position: relative;
364 overflow: auto;
365 margin: 16px 0;
366 padding: 23px 10px 0;
367 border: 1px solid #c3c4c7;
368 box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
369 background: #fff;
370 font-size: 13px;
371 line-height: 1.7;
372 }
373
374 .wpcf7-welcome-panel h3 {
375 font-size: 16px;
376 font-weight: 600;
377 line-height: 2.1em;
378 margin: 1em 0 1.2em;
379 }
380
381 .wpcf7-welcome-panel h3 .dashicons {
382 position: relative;
383 top: -2px;
384 display: inline-block;
385 width: 60px;
386 color: #575757;
387 font-size: 40px;
388 }
389
390 .wpcf7-welcome-panel p {
391 color: #646970;
392 }
393
394 .wpcf7-welcome-panel p a {
395 font-weight: bold;
396 }
397
398 .wpcf7-welcome-panel .welcome-panel-close {
399 position: absolute;
400 z-index: 2;
401 top: 10px;
402 right: 10px;
403 padding: 10px 15px 10px 21px;
404 font-size: 13px;
405 line-height: 1.23076923; /* Chrome rounding, needs to be 16px equivalent */
406 text-decoration: none;
407 }
408
409 .wpcf7-welcome-panel .welcome-panel-close::before {
410 background: 0 0;
411 color: #787c82;
412 content: "\f153";
413 display: block;
414 font: normal 16px/20px dashicons;
415 speak: never;
416 height: 20px;
417 text-align: center;
418 width: 20px;
419 -webkit-font-smoothing: antialiased;
420 -moz-osx-font-smoothing: grayscale;
421 position: absolute;
422 top: 8px;
423 left: 0;
424 transition: all .1s ease-in-out;
425 }
426
427 .wpcf7-welcome-panel .welcome-panel-content {
428 display: block;
429 margin-left: 13px;
430 max-width: 1500px;
431 min-height: auto;
432 }
433
434 .wpcf7-welcome-panel .welcome-panel-column-container {
435 clear: both;
436 position: relative;
437 }
438
439 .wpcf7-welcome-panel .welcome-panel-column {
440 display: block;
441 width: 48%;
442 min-width: 200px;
443 float: left;
444 padding: 0 2% 0 0;
445 margin: 0 0 1em 0;
446 }
447
448 @media screen and (max-width: 870px) {
449 .wpcf7-welcome-panel .welcome-panel-column {
450 display: block;
451 float: none;
452 width: 100%;
453 }
454 }
455
456 .wpcf7-welcome-panel .welcome-panel-column p {
457 margin-top: 7px;
458 color: #3c434a;
459 }
460
461 /*
462 * Integration
463 */
464 .card {
465 background: #fff none repeat scroll 0 0;
466 border: 1px solid #e5e5e5;
467 border-left: 4px solid #e5e5e5;
468 box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
469 margin-top: 20px;
470 max-width: 520px;
471 min-width: 255px;
472 padding: 0.7em 2em 1em;
473 position: relative;
474 }
475
476 .card.active {
477 border-color: #00a0d2;
478 }
479
480 .card img.icon {
481 float: left;
482 margin: 8px 8px 8px -8px;
483 }
484
485 .card h2.title {
486 float: left;
487 max-width: 240px;
488 font-size: 1.3em;
489 font-weight: 600;
490 }
491
492 .card .infobox {
493 float: right;
494 font-size: 13px;
495 color: #666;
496 margin: 1em;
497 line-height: 1.5;
498 max-width: 240px;
499 }
500
501 .card .inside .form-table th {
502 padding: 15px 10px 15px 0;
503 width: 160px;
504 }
505
506 .card .inside .form-table td {
507 padding: 10px 10px;
508 }
509
510 .card .checkboxes li {
511 margin: 0;
512 }
1 <?php
2
3 // don't load directly
4 if ( ! defined( 'ABSPATH' ) ) {
5 die( '-1' );
6 }
7
8 function wpcf7_admin_save_button( $post_id ) {
9 static $button = '';
10
11 if ( ! empty( $button ) ) {
12 echo $button;
13 return;
14 }
15
16 $nonce = wp_create_nonce( 'wpcf7-save-contact-form_' . $post_id );
17
18 $onclick = sprintf(
19 "this.form._wpnonce.value = '%s';"
20 . " this.form.action.value = 'save';"
21 . " return true;",
22 $nonce );
23
24 $button = sprintf(
25 '<input type="submit" class="button-primary" name="wpcf7-save" value="%1$s" onclick="%2$s" />',
26 esc_attr( __( 'Save', 'contact-form-7' ) ),
27 $onclick );
28
29 echo $button;
30 }
31
32 ?><div class="wrap" id="wpcf7-contact-form-editor">
33
34 <h1 class="wp-heading-inline"><?php
35 if ( $post->initial() ) {
36 echo esc_html( __( 'Add New Contact Form', 'contact-form-7' ) );
37 } else {
38 echo esc_html( __( 'Edit Contact Form', 'contact-form-7' ) );
39 }
40 ?></h1>
41
42 <?php
43 if ( ! $post->initial()
44 and current_user_can( 'wpcf7_edit_contact_forms' ) ) {
45 echo wpcf7_link(
46 menu_page_url( 'wpcf7-new', false ),
47 __( 'Add New', 'contact-form-7' ),
48 array( 'class' => 'page-title-action' )
49 );
50 }
51 ?>
52
53 <hr class="wp-header-end">
54
55 <?php
56 do_action( 'wpcf7_admin_warnings',
57 $post->initial() ? 'wpcf7-new' : 'wpcf7',
58 wpcf7_current_action(),
59 $post
60 );
61
62 do_action( 'wpcf7_admin_notices',
63 $post->initial() ? 'wpcf7-new' : 'wpcf7',
64 wpcf7_current_action(),
65 $post
66 );
67 ?>
68
69 <?php
70 if ( $post ) :
71
72 if ( current_user_can( 'wpcf7_edit_contact_form', $post_id ) ) {
73 $disabled = '';
74 } else {
75 $disabled = ' disabled="disabled"';
76 }
77 ?>
78
79 <form method="post" action="<?php echo esc_url( add_query_arg( array( 'post' => $post_id ), menu_page_url( 'wpcf7', false ) ) ); ?>" id="wpcf7-admin-form-element"<?php do_action( 'wpcf7_post_edit_form_tag' ); ?>>
80 <?php
81 if ( current_user_can( 'wpcf7_edit_contact_form', $post_id ) ) {
82 wp_nonce_field( 'wpcf7-save-contact-form_' . $post_id );
83 }
84 ?>
85 <input type="hidden" id="post_ID" name="post_ID" value="<?php echo (int) $post_id; ?>" />
86 <input type="hidden" id="wpcf7-locale" name="wpcf7-locale" value="<?php echo esc_attr( $post->locale() ); ?>" />
87 <input type="hidden" id="hiddenaction" name="action" value="save" />
88 <input type="hidden" id="active-tab" name="active-tab" value="<?php echo isset( $_GET['active-tab'] ) ? (int) $_GET['active-tab'] : '0'; ?>" />
89
90 <div id="poststuff">
91 <div id="post-body" class="metabox-holder columns-2">
92 <div id="post-body-content">
93 <div id="titlediv">
94 <div id="titlewrap">
95 <label class="screen-reader-text" id="title-prompt-text" for="title"><?php echo esc_html( __( 'Enter title here', 'contact-form-7' ) ); ?></label>
96 <?php
97 $posttitle_atts = array(
98 'type' => 'text',
99 'name' => 'post_title',
100 'size' => 30,
101 'value' => $post->initial() ? '' : $post->title(),
102 'id' => 'title',
103 'spellcheck' => 'true',
104 'autocomplete' => 'off',
105 'disabled' =>
106 current_user_can( 'wpcf7_edit_contact_form', $post_id ) ? '' : 'disabled',
107 );
108
109 echo sprintf( '<input %s />', wpcf7_format_atts( $posttitle_atts ) );
110 ?>
111 </div><!-- #titlewrap -->
112
113 <div class="inside">
114 <?php
115 if ( ! $post->initial() ) :
116 ?>
117 <p class="description">
118 <label for="wpcf7-shortcode"><?php echo esc_html( __( "Copy this shortcode and paste it into your post, page, or text widget content:", 'contact-form-7' ) ); ?></label>
119 <span class="shortcode wp-ui-highlight"><input type="text" id="wpcf7-shortcode" onfocus="this.select();" readonly="readonly" class="large-text code" value="<?php echo esc_attr( $post->shortcode() ); ?>" /></span>
120 </p>
121 <?php
122 if ( $old_shortcode = $post->shortcode( array( 'use_old_format' => true ) ) ) :
123 ?>
124 <p class="description">
125 <label for="wpcf7-shortcode-old"><?php echo esc_html( __( "You can also use this old-style shortcode:", 'contact-form-7' ) ); ?></label>
126 <span class="shortcode old"><input type="text" id="wpcf7-shortcode-old" onfocus="this.select();" readonly="readonly" class="large-text code" value="<?php echo esc_attr( $old_shortcode ); ?>" /></span>
127 </p>
128 <?php
129 endif;
130 endif;
131 ?>
132 </div>
133 </div><!-- #titlediv -->
134 </div><!-- #post-body-content -->
135
136 <div id="postbox-container-1" class="postbox-container">
137 <?php if ( current_user_can( 'wpcf7_edit_contact_form', $post_id ) ) : ?>
138 <div id="submitdiv" class="postbox">
139 <h3><?php echo esc_html( __( 'Status', 'contact-form-7' ) ); ?></h3>
140 <div class="inside">
141 <div class="submitbox" id="submitpost">
142
143 <div id="minor-publishing-actions">
144
145 <div class="hidden">
146 <input type="submit" class="button-primary" name="wpcf7-save" value="<?php echo esc_attr( __( 'Save', 'contact-form-7' ) ); ?>" />
147 </div>
148
149 <?php
150 if ( ! $post->initial() ) :
151 $copy_nonce = wp_create_nonce( 'wpcf7-copy-contact-form_' . $post_id );
152 ?>
153 <input type="submit" name="wpcf7-copy" class="copy button" value="<?php echo esc_attr( __( 'Duplicate', 'contact-form-7' ) ); ?>" <?php echo "onclick=\"this.form._wpnonce.value = '$copy_nonce'; this.form.action.value = 'copy'; return true;\""; ?> />
154 <?php endif; ?>
155 </div><!-- #minor-publishing-actions -->
156
157 <div id="misc-publishing-actions">
158 <?php do_action( 'wpcf7_admin_misc_pub_section', $post_id ); ?>
159 </div><!-- #misc-publishing-actions -->
160
161 <div id="major-publishing-actions">
162
163 <?php
164 if ( ! $post->initial() ) :
165 $delete_nonce = wp_create_nonce( 'wpcf7-delete-contact-form_' . $post_id );
166 ?>
167 <div id="delete-action">
168 <input type="submit" name="wpcf7-delete" class="delete submitdelete" value="<?php echo esc_attr( __( 'Delete', 'contact-form-7' ) ); ?>" <?php echo "onclick=\"if (confirm('" . esc_js( __( "You are about to delete this contact form.\n 'Cancel' to stop, 'OK' to delete.", 'contact-form-7' ) ) . "')) {this.form._wpnonce.value = '$delete_nonce'; this.form.action.value = 'delete'; return true;} return false;\""; ?> />
169 </div><!-- #delete-action -->
170 <?php endif; ?>
171
172 <div id="publishing-action">
173 <span class="spinner"></span>
174 <?php wpcf7_admin_save_button( $post_id ); ?>
175 </div>
176 <div class="clear"></div>
177 </div><!-- #major-publishing-actions -->
178 </div><!-- #submitpost -->
179 </div>
180 </div><!-- #submitdiv -->
181 <?php endif; ?>
182
183 <div id="informationdiv" class="postbox">
184 <h3><?php echo esc_html( __( "Do you need help?", 'contact-form-7' ) ); ?></h3>
185 <div class="inside">
186 <p><?php echo esc_html( __( "Here are some available options to help solve your problems.", 'contact-form-7' ) ); ?></p>
187 <ol>
188 <li><?php echo sprintf(
189 /* translators: 1: FAQ, 2: Docs ("FAQ & Docs") */
190 __( '%1$s and %2$s', 'contact-form-7' ),
191 wpcf7_link(
192 __( 'https://contactform7.com/faq/', 'contact-form-7' ),
193 __( 'FAQ', 'contact-form-7' )
194 ),
195 wpcf7_link(
196 __( 'https://contactform7.com/docs/', 'contact-form-7' ),
197 __( 'docs', 'contact-form-7' )
198 )
199 ); ?></li>
200 <li><?php echo wpcf7_link(
201 __( 'https://wordpress.org/support/plugin/contact-form-7/', 'contact-form-7' ),
202 __( 'Support forums', 'contact-form-7' )
203 ); ?></li>
204 <li><?php echo wpcf7_link(
205 __( 'https://contactform7.com/custom-development/', 'contact-form-7' ),
206 __( 'Professional services', 'contact-form-7' )
207 ); ?></li>
208 </ol>
209 </div>
210 </div><!-- #informationdiv -->
211
212 </div><!-- #postbox-container-1 -->
213
214 <div id="postbox-container-2" class="postbox-container">
215 <div id="contact-form-editor">
216 <div class="keyboard-interaction"><?php
217 echo sprintf(
218 /* translators: 1: ◀ ▶ dashicon, 2: screen reader text for the dashicon */
219 esc_html( __( '%1$s %2$s keys switch panels', 'contact-form-7' ) ),
220 '<span class="dashicons dashicons-leftright" aria-hidden="true"></span>',
221 sprintf(
222 '<span class="screen-reader-text">%s</span>',
223 /* translators: screen reader text */
224 esc_html( __( '(left and right arrow)', 'contact-form-7' ) )
225 )
226 );
227 ?></div>
228
229 <?php
230
231 $editor = new WPCF7_Editor( $post );
232 $panels = array();
233
234 if ( current_user_can( 'wpcf7_edit_contact_form', $post_id ) ) {
235 $panels = array(
236 'form-panel' => array(
237 'title' => __( 'Form', 'contact-form-7' ),
238 'callback' => 'wpcf7_editor_panel_form',
239 ),
240 'mail-panel' => array(
241 'title' => __( 'Mail', 'contact-form-7' ),
242 'callback' => 'wpcf7_editor_panel_mail',
243 ),
244 'messages-panel' => array(
245 'title' => __( 'Messages', 'contact-form-7' ),
246 'callback' => 'wpcf7_editor_panel_messages',
247 ),
248 );
249
250 $additional_settings = $post->prop( 'additional_settings' );
251
252 if ( ! is_scalar( $additional_settings ) ) {
253 $additional_settings = '';
254 }
255
256 $additional_settings = trim( $additional_settings );
257 $additional_settings = explode( "\n", $additional_settings );
258 $additional_settings = array_filter( $additional_settings );
259 $additional_settings = count( $additional_settings );
260
261 $panels['additional-settings-panel'] = array(
262 'title' => $additional_settings
263 ? sprintf(
264 /* translators: %d: number of additional settings */
265 __( 'Additional Settings (%d)', 'contact-form-7' ),
266 $additional_settings )
267 : __( 'Additional Settings', 'contact-form-7' ),
268 'callback' => 'wpcf7_editor_panel_additional_settings',
269 );
270 }
271
272 $panels = apply_filters( 'wpcf7_editor_panels', $panels );
273
274 foreach ( $panels as $id => $panel ) {
275 $editor->add_panel( $id, $panel['title'], $panel['callback'] );
276 }
277
278 $editor->display();
279 ?>
280 </div><!-- #contact-form-editor -->
281
282 <?php if ( current_user_can( 'wpcf7_edit_contact_form', $post_id ) ) : ?>
283 <p class="submit"><?php wpcf7_admin_save_button( $post_id ); ?></p>
284 <?php endif; ?>
285
286 </div><!-- #postbox-container-2 -->
287
288 </div><!-- #post-body -->
289 <br class="clear" />
290 </div><!-- #poststuff -->
291 </form>
292
293 <?php endif; ?>
294
295 </div><!-- .wrap -->
296
297 <?php
298
299 $tag_generator = WPCF7_TagGenerator::get_instance();
300 $tag_generator->print_panels( $post );
301
302 do_action( 'wpcf7_admin_footer', $post );
1 <?php
2
3 function wpcf7_current_action() {
4 if ( isset( $_REQUEST['action'] ) and -1 != $_REQUEST['action'] ) {
5 return $_REQUEST['action'];
6 }
7
8 if ( isset( $_REQUEST['action2'] ) and -1 != $_REQUEST['action2'] ) {
9 return $_REQUEST['action2'];
10 }
11
12 return false;
13 }
14
15 function wpcf7_admin_has_edit_cap() {
16 return current_user_can( 'wpcf7_edit_contact_forms' );
17 }
18
19 function wpcf7_add_tag_generator( $name, $title, $elm_id, $callback, $options = array() ) {
20 $tag_generator = WPCF7_TagGenerator::get_instance();
21 return $tag_generator->add( $name, $title, $callback, $options );
22 }
1 <?php
2
3 if ( ! class_exists( 'WP_List_Table' ) ) {
4 require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
5 }
6
7 class WPCF7_Contact_Form_List_Table extends WP_List_Table {
8
9 public static function define_columns() {
10 $columns = array(
11 'cb' => '<input type="checkbox" />',
12 'title' => __( 'Title', 'contact-form-7' ),
13 'shortcode' => __( 'Shortcode', 'contact-form-7' ),
14 'author' => __( 'Author', 'contact-form-7' ),
15 'date' => __( 'Date', 'contact-form-7' ),
16 );
17
18 return $columns;
19 }
20
21 public function __construct() {
22 parent::__construct( array(
23 'singular' => 'post',
24 'plural' => 'posts',
25 'ajax' => false,
26 ) );
27 }
28
29 public function prepare_items() {
30 $current_screen = get_current_screen();
31 $per_page = $this->get_items_per_page( 'wpcf7_contact_forms_per_page' );
32
33 $args = array(
34 'posts_per_page' => $per_page,
35 'orderby' => 'title',
36 'order' => 'ASC',
37 'offset' => ( $this->get_pagenum() - 1 ) * $per_page,
38 );
39
40 if ( ! empty( $_REQUEST['s'] ) ) {
41 $args['s'] = $_REQUEST['s'];
42 }
43
44 if ( ! empty( $_REQUEST['orderby'] ) ) {
45 if ( 'title' == $_REQUEST['orderby'] ) {
46 $args['orderby'] = 'title';
47 } elseif ( 'author' == $_REQUEST['orderby'] ) {
48 $args['orderby'] = 'author';
49 } elseif ( 'date' == $_REQUEST['orderby'] ) {
50 $args['orderby'] = 'date';
51 }
52 }
53
54 if ( ! empty( $_REQUEST['order'] ) ) {
55 if ( 'asc' == strtolower( $_REQUEST['order'] ) ) {
56 $args['order'] = 'ASC';
57 } elseif ( 'desc' == strtolower( $_REQUEST['order'] ) ) {
58 $args['order'] = 'DESC';
59 }
60 }
61
62 $this->items = WPCF7_ContactForm::find( $args );
63
64 $total_items = WPCF7_ContactForm::count();
65 $total_pages = ceil( $total_items / $per_page );
66
67 $this->set_pagination_args( array(
68 'total_items' => $total_items,
69 'total_pages' => $total_pages,
70 'per_page' => $per_page,
71 ) );
72 }
73
74 public function get_columns() {
75 return get_column_headers( get_current_screen() );
76 }
77
78 protected function get_sortable_columns() {
79 $columns = array(
80 'title' => array( 'title', true ),
81 'author' => array( 'author', false ),
82 'date' => array( 'date', false ),
83 );
84
85 return $columns;
86 }
87
88 protected function get_bulk_actions() {
89 $actions = array(
90 'delete' => __( 'Delete', 'contact-form-7' ),
91 );
92
93 return $actions;
94 }
95
96 protected function column_default( $item, $column_name ) {
97 return '';
98 }
99
100 public function column_cb( $item ) {
101 return sprintf(
102 '<input type="checkbox" name="%1$s[]" value="%2$s" />',
103 $this->_args['singular'],
104 $item->id()
105 );
106 }
107
108 public function column_title( $item ) {
109 $edit_link = add_query_arg(
110 array(
111 'post' => absint( $item->id() ),
112 'action' => 'edit',
113 ),
114 menu_page_url( 'wpcf7', false )
115 );
116
117 $output = sprintf(
118 '<a class="row-title" href="%1$s" aria-label="%2$s">%3$s</a>',
119 esc_url( $edit_link ),
120 esc_attr( sprintf(
121 /* translators: %s: title of contact form */
122 __( 'Edit &#8220;%s&#8221;', 'contact-form-7' ),
123 $item->title()
124 ) ),
125 esc_html( $item->title() )
126 );
127
128 $output = sprintf( '<strong>%s</strong>', $output );
129
130 if ( wpcf7_validate_configuration()
131 and current_user_can( 'wpcf7_edit_contact_form', $item->id() ) ) {
132 $config_validator = new WPCF7_ConfigValidator( $item );
133 $config_validator->restore();
134
135 if ( $count_errors = $config_validator->count_errors() ) {
136 $error_notice = sprintf(
137 _n(
138 /* translators: %s: number of errors detected */
139 '%s configuration error detected',
140 '%s configuration errors detected',
141 $count_errors, 'contact-form-7' ),
142 number_format_i18n( $count_errors )
143 );
144
145 $output .= sprintf(
146 '<div class="config-error"><span class="icon-in-circle" aria-hidden="true">!</span> %s</div>',
147 $error_notice
148 );
149 }
150 }
151
152 return $output;
153 }
154
155 protected function handle_row_actions( $item, $column_name, $primary ) {
156 if ( $column_name !== $primary ) {
157 return '';
158 }
159
160 $edit_link = add_query_arg(
161 array(
162 'post' => absint( $item->id() ),
163 'action' => 'edit',
164 ),
165 menu_page_url( 'wpcf7', false )
166 );
167
168 $actions = array(
169 'edit' => wpcf7_link( $edit_link, __( 'Edit', 'contact-form-7' ) ),
170 );
171
172 if ( current_user_can( 'wpcf7_edit_contact_form', $item->id() ) ) {
173 $copy_link = add_query_arg(
174 array(
175 'post' => absint( $item->id() ),
176 'action' => 'copy',
177 ),
178 menu_page_url( 'wpcf7', false )
179 );
180
181 $copy_link = wp_nonce_url(
182 $copy_link,
183 'wpcf7-copy-contact-form_' . absint( $item->id() )
184 );
185
186 $actions = array_merge( $actions, array(
187 'copy' => wpcf7_link( $copy_link, __( 'Duplicate', 'contact-form-7' ) ),
188 ) );
189 }
190
191 return $this->row_actions( $actions );
192 }
193
194 public function column_author( $item ) {
195 $post = get_post( $item->id() );
196
197 if ( ! $post ) {
198 return;
199 }
200
201 $author = get_userdata( $post->post_author );
202
203 if ( false === $author ) {
204 return;
205 }
206
207 return esc_html( $author->display_name );
208 }
209
210 public function column_shortcode( $item ) {
211 $shortcodes = array( $item->shortcode() );
212
213 $output = '';
214
215 foreach ( $shortcodes as $shortcode ) {
216 $output .= "\n" . '<span class="shortcode"><input type="text"'
217 . ' onfocus="this.select();" readonly="readonly"'
218 . ' value="' . esc_attr( $shortcode ) . '"'
219 . ' class="large-text code" /></span>';
220 }
221
222 return trim( $output );
223 }
224
225 public function column_date( $item ) {
226 $datetime = get_post_datetime( $item->id() );
227
228 if ( false === $datetime ) {
229 return '';
230 }
231
232 $t_time = sprintf(
233 /* translators: 1: date, 2: time */
234 __( '%1$s at %2$s', 'contact-form-7' ),
235 /* translators: date format, see https://www.php.net/date */
236 $datetime->format( __( 'Y/m/d', 'contact-form-7' ) ),
237 /* translators: time format, see https://www.php.net/date */
238 $datetime->format( __( 'g:i a', 'contact-form-7' ) )
239 );
240
241 return $t_time;
242 }
243 }
1 <?php
2
3 add_action( 'wpcf7_admin_menu', 'wpcf7_admin_init_bulk_cv', 10, 0 );
4
5 function wpcf7_admin_init_bulk_cv() {
6 if ( ! wpcf7_validate_configuration()
7 or ! current_user_can( 'wpcf7_edit_contact_forms' ) ) {
8 return;
9 }
10
11 $result = WPCF7::get_option( 'bulk_validate' );
12 $last_important_update = WPCF7_ConfigValidator::last_important_update;
13
14 if ( ! empty( $result['version'] )
15 and version_compare( $last_important_update, $result['version'], '<=' ) ) {
16 return;
17 }
18
19 add_filter( 'wpcf7_admin_menu_change_notice',
20 'wpcf7_admin_menu_change_notice_bulk_cv',
21 10, 1
22 );
23
24 add_action( 'wpcf7_admin_warnings',
25 'wpcf7_admin_warnings_bulk_cv',
26 5, 3
27 );
28 }
29
30 function wpcf7_admin_menu_change_notice_bulk_cv( $counts ) {
31 $counts['wpcf7'] += 1;
32 return $counts;
33 }
34
35 function wpcf7_admin_warnings_bulk_cv( $page, $action, $object ) {
36 if ( 'wpcf7' === $page and 'validate' === $action ) {
37 return;
38 }
39
40 $link = wpcf7_link(
41 add_query_arg(
42 array( 'action' => 'validate' ),
43 menu_page_url( 'wpcf7', false )
44 ),
45 __( 'Validate Contact Form 7 Configuration', 'contact-form-7' )
46 );
47
48 $message = __( "Misconfiguration leads to mail delivery failure or other troubles. Validate your contact forms now.", 'contact-form-7' );
49
50 echo sprintf(
51 '<div class="notice notice-warning"><p>%1$s &raquo; %2$s</p></div>',
52 esc_html( $message ),
53 $link
54 );
55 }
56
57 add_action( 'wpcf7_admin_load', 'wpcf7_load_bulk_validate_page', 10, 2 );
58
59 function wpcf7_load_bulk_validate_page( $page, $action ) {
60 if ( 'wpcf7' != $page
61 or 'validate' != $action
62 or ! wpcf7_validate_configuration()
63 or 'POST' != $_SERVER['REQUEST_METHOD'] ) {
64 return;
65 }
66
67 check_admin_referer( 'wpcf7-bulk-validate' );
68
69 if ( ! current_user_can( 'wpcf7_edit_contact_forms' ) ) {
70 wp_die( __( "You are not allowed to validate configuration.", 'contact-form-7' ) );
71 }
72
73 $contact_forms = WPCF7_ContactForm::find();
74
75 $result = array(
76 'timestamp' => time(),
77 'version' => WPCF7_VERSION,
78 'count_valid' => 0,
79 'count_invalid' => 0,
80 );
81
82 foreach ( $contact_forms as $contact_form ) {
83 $config_validator = new WPCF7_ConfigValidator( $contact_form );
84 $config_validator->validate();
85 $config_validator->save();
86
87 if ( $config_validator->is_valid() ) {
88 $result['count_valid'] += 1;
89 } else {
90 $result['count_invalid'] += 1;
91 }
92 }
93
94 WPCF7::update_option( 'bulk_validate', $result );
95
96 $redirect_to = add_query_arg(
97 array(
98 'message' => 'validated',
99 ),
100 menu_page_url( 'wpcf7', false )
101 );
102
103 wp_safe_redirect( $redirect_to );
104 exit();
105 }
106
107 function wpcf7_admin_bulk_validate_page() {
108 $contact_forms = WPCF7_ContactForm::find();
109 $count = WPCF7_ContactForm::count();
110
111 $submit_text = sprintf(
112 _n(
113 /* translators: %s: number of contact forms */
114 "Validate %s contact form now",
115 "Validate %s contact forms now",
116 $count, 'contact-form-7'
117 ),
118 number_format_i18n( $count )
119 );
120
121 ?>
122 <div class="wrap">
123
124 <h1><?php echo esc_html( __( 'Validate Configuration', 'contact-form-7' ) ); ?></h1>
125
126 <form method="post" action="">
127 <input type="hidden" name="action" value="validate" />
128 <?php wp_nonce_field( 'wpcf7-bulk-validate' ); ?>
129 <p><input type="submit" class="button" value="<?php echo esc_attr( $submit_text ); ?>" /></p>
130 </form>
131
132 <?php
133 echo wpcf7_link(
134 __( 'https://contactform7.com/configuration-validator-faq/', 'contact-form-7' ),
135 __( 'FAQ about Configuration Validator', 'contact-form-7' )
136 );
137 ?>
138
139 </div>
140 <?php
141 }
1 <?php
2
3 class WPCF7_Editor {
4
5 private $contact_form;
6 private $panels = array();
7
8 public function __construct( WPCF7_ContactForm $contact_form ) {
9 $this->contact_form = $contact_form;
10 }
11
12 public function add_panel( $panel_id, $title, $callback ) {
13 if ( wpcf7_is_name( $panel_id ) ) {
14 $this->panels[$panel_id] = array(
15 'title' => $title,
16 'callback' => $callback,
17 );
18 }
19 }
20
21 public function display() {
22 if ( empty( $this->panels ) ) {
23 return;
24 }
25
26 echo '<ul id="contact-form-editor-tabs">';
27
28 foreach ( $this->panels as $panel_id => $panel ) {
29 echo sprintf(
30 '<li id="%1$s-tab"><a href="#%1$s">%2$s</a></li>',
31 esc_attr( $panel_id ),
32 esc_html( $panel['title'] )
33 );
34 }
35
36 echo '</ul>';
37
38 foreach ( $this->panels as $panel_id => $panel ) {
39 echo sprintf(
40 '<div class="contact-form-editor-panel" id="%1$s">',
41 esc_attr( $panel_id )
42 );
43
44 if ( is_callable( $panel['callback'] ) ) {
45 $this->notice( $panel_id, $panel );
46 call_user_func( $panel['callback'], $this->contact_form );
47 }
48
49 echo '</div>';
50 }
51 }
52
53 public function notice( $panel_id, $panel ) {
54 echo '<div class="config-error"></div>';
55 }
56 }
57
58 function wpcf7_editor_panel_form( $post ) {
59 $desc_link = wpcf7_link(
60 __( 'https://contactform7.com/editing-form-template/', 'contact-form-7' ),
61 __( 'Editing form template', 'contact-form-7' ) );
62 $description = __( "You can edit the form template here. For details, see %s.", 'contact-form-7' );
63 $description = sprintf( esc_html( $description ), $desc_link );
64 ?>
65
66 <h2><?php echo esc_html( __( 'Form', 'contact-form-7' ) ); ?></h2>
67
68 <fieldset>
69 <legend><?php echo $description; ?></legend>
70
71 <?php
72 $tag_generator = WPCF7_TagGenerator::get_instance();
73 $tag_generator->print_buttons();
74 ?>
75
76 <textarea id="wpcf7-form" name="wpcf7-form" cols="100" rows="24" class="large-text code" data-config-field="form.body"><?php echo esc_textarea( $post->prop( 'form' ) ); ?></textarea>
77 </fieldset>
78 <?php
79 }
80
81 function wpcf7_editor_panel_mail( $post ) {
82 wpcf7_editor_box_mail( $post );
83
84 echo '<br class="clear" />';
85
86 wpcf7_editor_box_mail( $post, array(
87 'id' => 'wpcf7-mail-2',
88 'name' => 'mail_2',
89 'title' => __( 'Mail (2)', 'contact-form-7' ),
90 'use' => __( 'Use Mail (2)', 'contact-form-7' ),
91 ) );
92 }
93
94 function wpcf7_editor_box_mail( $post, $args = '' ) {
95 $args = wp_parse_args( $args, array(
96 'id' => 'wpcf7-mail',
97 'name' => 'mail',
98 'title' => __( 'Mail', 'contact-form-7' ),
99 'use' => null,
100 ) );
101
102 $id = esc_attr( $args['id'] );
103
104 $mail = wp_parse_args( $post->prop( $args['name'] ), array(
105 'active' => false,
106 'recipient' => '',
107 'sender' => '',
108 'subject' => '',
109 'body' => '',
110 'additional_headers' => '',
111 'attachments' => '',
112 'use_html' => false,
113 'exclude_blank' => false,
114 ) );
115
116 ?>
117 <div class="contact-form-editor-box-mail" id="<?php echo $id; ?>">
118 <h2><?php echo esc_html( $args['title'] ); ?></h2>
119
120 <?php
121 if ( ! empty( $args['use'] ) ) :
122 ?>
123 <label for="<?php echo $id; ?>-active"><input type="checkbox" id="<?php echo $id; ?>-active" name="<?php echo $id; ?>[active]" class="toggle-form-table" value="1"<?php echo ( $mail['active'] ) ? ' checked="checked"' : ''; ?> /> <?php echo esc_html( $args['use'] ); ?></label>
124 <p class="description"><?php echo esc_html( __( "Mail (2) is an additional mail template often used as an autoresponder.", 'contact-form-7' ) ); ?></p>
125 <?php
126 endif;
127 ?>
128
129 <fieldset>
130 <legend>
131 <?php
132 $desc_link = wpcf7_link(
133 __( 'https://contactform7.com/setting-up-mail/', 'contact-form-7' ),
134 __( 'Setting up mail', 'contact-form-7' ) );
135 $description = __( "You can edit the mail template here. For details, see %s.", 'contact-form-7' );
136 $description = sprintf( esc_html( $description ), $desc_link );
137 echo $description;
138 echo '<br />';
139
140 echo esc_html( __( "In the following fields, you can use these mail-tags:",
141 'contact-form-7' ) );
142 echo '<br />';
143 $post->suggest_mail_tags( $args['name'] );
144 ?>
145 </legend>
146 <table class="form-table">
147 <tbody>
148 <tr>
149 <th scope="row">
150 <label for="<?php echo $id; ?>-recipient"><?php echo esc_html( __( 'To', 'contact-form-7' ) ); ?></label>
151 </th>
152 <td>
153 <input type="text" id="<?php echo $id; ?>-recipient" name="<?php echo $id; ?>[recipient]" class="large-text code" size="70" value="<?php echo esc_attr( $mail['recipient'] ); ?>" data-config-field="<?php echo sprintf( '%s.recipient', esc_attr( $args['name'] ) ); ?>" />
154 </td>
155 </tr>
156
157 <tr>
158 <th scope="row">
159 <label for="<?php echo $id; ?>-sender"><?php echo esc_html( __( 'From', 'contact-form-7' ) ); ?></label>
160 </th>
161 <td>
162 <input type="text" id="<?php echo $id; ?>-sender" name="<?php echo $id; ?>[sender]" class="large-text code" size="70" value="<?php echo esc_attr( $mail['sender'] ); ?>" data-config-field="<?php echo sprintf( '%s.sender', esc_attr( $args['name'] ) ); ?>" />
163 </td>
164 </tr>
165
166 <tr>
167 <th scope="row">
168 <label for="<?php echo $id; ?>-subject"><?php echo esc_html( __( 'Subject', 'contact-form-7' ) ); ?></label>
169 </th>
170 <td>
171 <input type="text" id="<?php echo $id; ?>-subject" name="<?php echo $id; ?>[subject]" class="large-text code" size="70" value="<?php echo esc_attr( $mail['subject'] ); ?>" data-config-field="<?php echo sprintf( '%s.subject', esc_attr( $args['name'] ) ); ?>" />
172 </td>
173 </tr>
174
175 <tr>
176 <th scope="row">
177 <label for="<?php echo $id; ?>-additional-headers"><?php echo esc_html( __( 'Additional headers', 'contact-form-7' ) ); ?></label>
178 </th>
179 <td>
180 <textarea id="<?php echo $id; ?>-additional-headers" name="<?php echo $id; ?>[additional_headers]" cols="100" rows="4" class="large-text code" data-config-field="<?php echo sprintf( '%s.additional_headers', esc_attr( $args['name'] ) ); ?>"><?php echo esc_textarea( $mail['additional_headers'] ); ?></textarea>
181 </td>
182 </tr>
183
184 <tr>
185 <th scope="row">
186 <label for="<?php echo $id; ?>-body"><?php echo esc_html( __( 'Message body', 'contact-form-7' ) ); ?></label>
187 </th>
188 <td>
189 <textarea id="<?php echo $id; ?>-body" name="<?php echo $id; ?>[body]" cols="100" rows="18" class="large-text code" data-config-field="<?php echo sprintf( '%s.body', esc_attr( $args['name'] ) ); ?>"><?php echo esc_textarea( $mail['body'] ); ?></textarea>
190
191 <p><label for="<?php echo $id; ?>-exclude-blank"><input type="checkbox" id="<?php echo $id; ?>-exclude-blank" name="<?php echo $id; ?>[exclude_blank]" value="1"<?php echo ( ! empty( $mail['exclude_blank'] ) ) ? ' checked="checked"' : ''; ?> /> <?php echo esc_html( __( 'Exclude lines with blank mail-tags from output', 'contact-form-7' ) ); ?></label></p>
192
193 <p><label for="<?php echo $id; ?>-use-html"><input type="checkbox" id="<?php echo $id; ?>-use-html" name="<?php echo $id; ?>[use_html]" value="1"<?php echo ( $mail['use_html'] ) ? ' checked="checked"' : ''; ?> /> <?php echo esc_html( __( 'Use HTML content type', 'contact-form-7' ) ); ?></label></p>
194 </td>
195 </tr>
196
197 <tr>
198 <th scope="row">
199 <label for="<?php echo $id; ?>-attachments"><?php echo esc_html( __( 'File attachments', 'contact-form-7' ) ); ?></label>
200 </th>
201 <td>
202 <textarea id="<?php echo $id; ?>-attachments" name="<?php echo $id; ?>[attachments]" cols="100" rows="4" class="large-text code" data-config-field="<?php echo sprintf( '%s.attachments', esc_attr( $args['name'] ) ); ?>"><?php echo esc_textarea( $mail['attachments'] ); ?></textarea>
203 </td>
204 </tr>
205 </tbody>
206 </table>
207 </fieldset>
208 </div>
209 <?php
210 }
211
212 function wpcf7_editor_panel_messages( $post ) {
213 $desc_link = wpcf7_link(
214 __( 'https://contactform7.com/editing-messages/', 'contact-form-7' ),
215 __( 'Editing messages', 'contact-form-7' ) );
216 $description = __( "You can edit messages used in various situations here. For details, see %s.", 'contact-form-7' );
217 $description = sprintf( esc_html( $description ), $desc_link );
218
219 $messages = wpcf7_messages();
220
221 if ( isset( $messages['captcha_not_match'] )
222 and ! wpcf7_use_really_simple_captcha() ) {
223 unset( $messages['captcha_not_match'] );
224 }
225
226 ?>
227 <h2><?php echo esc_html( __( 'Messages', 'contact-form-7' ) ); ?></h2>
228 <fieldset>
229 <legend><?php echo $description; ?></legend>
230 <?php
231
232 foreach ( $messages as $key => $arr ) {
233 $field_id = sprintf( 'wpcf7-message-%s', strtr( $key, '_', '-' ) );
234 $field_name = sprintf( 'wpcf7-messages[%s]', $key );
235
236 ?>
237 <p class="description">
238 <label for="<?php echo $field_id; ?>"><?php echo esc_html( $arr['description'] ); ?><br />
239 <input type="text" id="<?php echo $field_id; ?>" name="<?php echo $field_name; ?>" class="large-text" size="70" value="<?php echo esc_attr( $post->message( $key, false ) ); ?>" data-config-field="<?php echo sprintf( 'messages.%s', esc_attr( $key ) ); ?>" />
240 </label>
241 </p>
242 <?php
243 }
244 ?>
245 </fieldset>
246 <?php
247 }
248
249 function wpcf7_editor_panel_additional_settings( $post ) {
250 $desc_link = wpcf7_link(
251 __( 'https://contactform7.com/additional-settings/', 'contact-form-7' ),
252 __( 'Additional settings', 'contact-form-7' ) );
253 $description = __( "You can add customization code snippets here. For details, see %s.", 'contact-form-7' );
254 $description = sprintf( esc_html( $description ), $desc_link );
255
256 ?>
257 <h2><?php echo esc_html( __( 'Additional Settings', 'contact-form-7' ) ); ?></h2>
258 <fieldset>
259 <legend><?php echo $description; ?></legend>
260 <textarea id="wpcf7-additional-settings" name="wpcf7-additional-settings" cols="100" rows="8" class="large-text" data-config-field="additional_settings.body"><?php echo esc_textarea( $post->prop( 'additional_settings' ) ); ?></textarea>
261 </fieldset>
262 <?php
263 }
1 <?php
2
3 class WPCF7_Help_Tabs {
4
5 private $screen;
6
7 public function __construct( WP_Screen $screen ) {
8 $this->screen = $screen;
9 }
10
11 public function set_help_tabs( $screen_type ) {
12 switch ( $screen_type ) {
13 case 'list':
14 $this->screen->add_help_tab( array(
15 'id' => 'list_overview',
16 'title' => __( 'Overview', 'contact-form-7' ),
17 'content' => $this->content( 'list_overview' ),
18 ) );
19
20 $this->screen->add_help_tab( array(
21 'id' => 'list_available_actions',
22 'title' => __( 'Available Actions', 'contact-form-7' ),
23 'content' => $this->content( 'list_available_actions' ),
24 ) );
25
26 $this->sidebar();
27
28 return;
29 case 'edit':
30 $this->screen->add_help_tab( array(
31 'id' => 'edit_overview',
32 'title' => __( 'Overview', 'contact-form-7' ),
33 'content' => $this->content( 'edit_overview' ),
34 ) );
35
36 $this->screen->add_help_tab( array(
37 'id' => 'edit_form_tags',
38 'title' => __( 'Form-tags', 'contact-form-7' ),
39 'content' => $this->content( 'edit_form_tags' ),
40 ) );
41
42 $this->screen->add_help_tab( array(
43 'id' => 'edit_mail_tags',
44 'title' => __( 'Mail-tags', 'contact-form-7' ),
45 'content' => $this->content( 'edit_mail_tags' ),
46 ) );
47
48 $this->sidebar();
49
50 return;
51 case 'integration':
52 $this->screen->add_help_tab( array(
53 'id' => 'integration_overview',
54 'title' => __( 'Overview', 'contact-form-7' ),
55 'content' => $this->content( 'integration_overview' ),
56 ) );
57
58 $this->sidebar();
59
60 return;
61 }
62 }
63
64 private function content( $name ) {
65 $content = array();
66
67 $content['list_overview'] = '<p>' . __( "On this screen, you can manage contact forms provided by Contact Form 7. You can manage an unlimited number of contact forms. Each contact form has a unique ID and Contact Form 7 shortcode ([contact-form-7 ...]). To insert a contact form into a post or a text widget, insert the shortcode into the target.", 'contact-form-7' ) . '</p>';
68
69 $content['list_available_actions'] = '<p>' . __( "Hovering over a row in the contact forms list will display action links that allow you to manage your contact form. You can perform the following actions:", 'contact-form-7' ) . '</p>';
70 $content['list_available_actions'] .= '<p>' . __( "<strong>Edit</strong> - Navigates to the editing screen for that contact form. You can also reach that screen by clicking on the contact form title.", 'contact-form-7' ) . '</p>';
71 $content['list_available_actions'] .= '<p>' . __( "<strong>Duplicate</strong> - Clones that contact form. A cloned contact form inherits all content from the original, but has a different ID.", 'contact-form-7' ) . '</p>';
72
73 $content['edit_overview'] = '<p>' . __( "On this screen, you can edit a contact form. A contact form is comprised of the following components:", 'contact-form-7' ) . '</p>';
74 $content['edit_overview'] .= '<p>' . __( "<strong>Title</strong> is the title of a contact form. This title is only used for labeling a contact form, and can be edited.", 'contact-form-7' ) . '</p>';
75 $content['edit_overview'] .= '<p>' . __( "<strong>Form</strong> is a content of HTML form. You can use arbitrary HTML, which is allowed inside a form element. You can also use Contact Form 7&#8217;s form-tags here.", 'contact-form-7' ) . '</p>';
76 $content['edit_overview'] .= '<p>' . __( "<strong>Mail</strong> manages a mail template (headers and message body) that this contact form will send when users submit it. You can use Contact Form 7&#8217;s mail-tags here.", 'contact-form-7' ) . '</p>';
77 $content['edit_overview'] .= '<p>' . __( "<strong>Mail (2)</strong> is an additional mail template that works similar to Mail. Mail (2) is different in that it is sent only when Mail has been sent successfully.", 'contact-form-7' ) . '</p>';
78 $content['edit_overview'] .= '<p>' . __( "In <strong>Messages</strong>, you can edit various types of messages used for this contact form. These messages are relatively short messages, like a validation error message you see when you leave a required field blank.", 'contact-form-7' ) . '</p>';
79 $content['edit_overview'] .= '<p>' . __( "<strong>Additional Settings</strong> provides a place where you can customize the behavior of this contact form by adding code snippets.", 'contact-form-7' ) . '</p>';
80
81 $content['edit_form_tags'] = '<p>' . __( "A form-tag is a short code enclosed in square brackets used in a form content. A form-tag generally represents an input field, and its components can be separated into four parts: type, name, options, and values. Contact Form 7 supports several types of form-tags including text fields, number fields, date fields, checkboxes, radio buttons, menus, file-uploading fields, CAPTCHAs, and quiz fields.", 'contact-form-7' ) . '</p>';
82 $content['edit_form_tags'] .= '<p>' . __( "While form-tags have a comparatively complex syntax, you do not need to know the syntax to add form-tags because you can use the straightforward tag generator (<strong>Generate Tag</strong> button on this screen).", 'contact-form-7' ) . '</p>';
83
84 $content['edit_mail_tags'] = '<p>' . __( "A mail-tag is also a short code enclosed in square brackets that you can use in every Mail and Mail (2) field. A mail-tag represents a user input value through an input field of a corresponding form-tag.", 'contact-form-7' ) . '</p>';
85 $content['edit_mail_tags'] .= '<p>' . __( "There are also special mail-tags that have specific names, but do not have corresponding form-tags. They are used to represent meta information of form submissions like the submitter&#8217;s IP address or the URL of the page.", 'contact-form-7' ) . '</p>';
86
87 $content['integration_overview'] = '<p>' . __( "On this screen, you can manage services that are available through Contact Form 7. Using API will allow you to collaborate with any services that are available.", 'contact-form-7' ) . '</p>';
88 $content['integration_overview'] .= '<p>' . __( "You may need to first sign up for an account with the service that you plan to use. When you do so, you would need to authorize Contact Form 7 to access the service with your account.", 'contact-form-7' ) . '</p>';
89 $content['integration_overview'] .= '<p>' . __( "Any information you provide will not be shared with service providers without your authorization.", 'contact-form-7' ) . '</p>';
90
91 if ( ! empty( $content[$name] ) ) {
92 return $content[$name];
93 }
94 }
95
96 public function sidebar() {
97 $content = '<p><strong>' . __( 'For more information:', 'contact-form-7' ) . '</strong></p>';
98 $content .= '<p>' . wpcf7_link( __( 'https://contactform7.com/docs/', 'contact-form-7' ), __( 'Docs', 'contact-form-7' ) ) . '</p>';
99 $content .= '<p>' . wpcf7_link( __( 'https://contactform7.com/faq/', 'contact-form-7' ), __( 'FAQ', 'contact-form-7' ) ) . '</p>';
100 $content .= '<p>' . wpcf7_link( __( 'https://contactform7.com/support/', 'contact-form-7' ), __( 'Support', 'contact-form-7' ) ) . '</p>';
101
102 $this->screen->set_help_sidebar( $content );
103 }
104 }
1 <?php
2
3 class WPCF7_TagGenerator {
4
5 private static $instance;
6
7 private $panels = array();
8
9 private function __construct() {}
10
11 public static function get_instance() {
12 if ( empty( self::$instance ) ) {
13 self::$instance = new self;
14 }
15
16 return self::$instance;
17 }
18
19 public function add( $id, $title, $callback, $options = array() ) {
20 $id = trim( $id );
21
22 if ( '' === $id
23 or ! wpcf7_is_name( $id ) ) {
24 return false;
25 }
26
27 $this->panels[$id] = array(
28 'title' => $title,
29 'content' => 'tag-generator-panel-' . $id,
30 'options' => $options,
31 'callback' => $callback,
32 );
33
34 return true;
35 }
36
37 public function print_buttons() {
38 echo '<span id="tag-generator-list">';
39
40 foreach ( (array) $this->panels as $panel ) {
41 echo sprintf(
42 '<a href="#TB_inline?width=900&height=500&inlineId=%1$s" class="thickbox button" title="%2$s">%3$s</a>',
43 esc_attr( $panel['content'] ),
44 esc_attr( sprintf(
45 /* translators: %s: title of form-tag like 'email' or 'checkboxes' */
46 __( 'Form-tag Generator: %s', 'contact-form-7' ),
47 $panel['title'] ) ),
48 esc_html( $panel['title'] )
49 );
50 }
51
52 echo '</span>';
53 }
54
55 public function print_panels( WPCF7_ContactForm $contact_form ) {
56 foreach ( (array) $this->panels as $id => $panel ) {
57 $callback = $panel['callback'];
58
59 $options = wp_parse_args( $panel['options'], array() );
60 $options = array_merge( $options, array(
61 'id' => $id,
62 'title' => $panel['title'],
63 'content' => $panel['content'],
64 ) );
65
66 if ( is_callable( $callback ) ) {
67 echo sprintf( '<div id="%s" class="hidden">',
68 esc_attr( $options['content'] ) );
69 echo sprintf(
70 '<form action="" class="tag-generator-panel" data-id="%s">',
71 $options['id'] );
72
73 call_user_func( $callback, $contact_form, $options );
74
75 echo '</form></div>';
76 }
77 }
78 }
79
80 }
1 <?php
2
3 abstract class WPCF7_WelcomePanelColumn {
4
5 abstract protected function icon();
6 abstract protected function title();
7 abstract protected function content();
8
9 public function print_content() {
10 $icon = sprintf(
11 '<span class="dashicons dashicons-%s" aria-hidden="true"></span>',
12 esc_attr( $this->icon() )
13 );
14
15 $title = sprintf(
16 '<h3>%1$s %2$s</h3>',
17 $icon,
18 $this->title()
19 );
20
21 $content = $this->content();
22
23 if ( is_array( $content ) ) {
24 $content = implode( "\n\n", $content );
25 }
26
27 $content = wp_kses_post( $content );
28 $content = wptexturize( $content );
29 $content = convert_chars( $content );
30 $content = wpautop( $content );
31
32 echo "\n";
33 echo '<div class="welcome-panel-column">';
34 echo $title;
35 echo $content;
36 echo '</div>';
37 }
38 }
39
40
41 class WPCF7_WelcomePanelColumn_AntiSpam extends WPCF7_WelcomePanelColumn {
42
43 protected function icon() {
44 return 'shield';
45 }
46
47 protected function title() {
48 return esc_html(
49 __( "Getting spammed? You have protection.", 'contact-form-7' )
50 );
51 }
52
53 protected function content() {
54 return array(
55 esc_html( __( "Spammers target everything; your contact forms are not an exception. Before you get spammed, protect your contact forms with the powerful anti-spam features Contact Form 7 provides.", 'contact-form-7' ) ),
56 sprintf(
57 /* translators: links labeled 1: 'Akismet', 2: 'reCAPTCHA', 3: 'disallowed list' */
58 esc_html( __( 'Contact Form 7 supports spam-filtering with %1$s. Intelligent %2$s blocks annoying spambots. Plus, using %3$s, you can block messages containing specified keywords or those sent from specified IP addresses.', 'contact-form-7' ) ),
59 wpcf7_link(
60 __( 'https://contactform7.com/spam-filtering-with-akismet/', 'contact-form-7' ),
61 __( 'Akismet', 'contact-form-7' )
62 ),
63 wpcf7_link(
64 __( 'https://contactform7.com/recaptcha/', 'contact-form-7' ),
65 __( 'reCAPTCHA', 'contact-form-7' )
66 ),
67 wpcf7_link(
68 __( 'https://contactform7.com/comment-blacklist/', 'contact-form-7' ),
69 __( 'disallowed list', 'contact-form-7' )
70 )
71 ),
72 );
73 }
74 }
75
76
77 class WPCF7_WelcomePanelColumn_Donation extends WPCF7_WelcomePanelColumn {
78
79 protected function icon() {
80 return 'megaphone';
81 }
82
83 protected function title() {
84 return esc_html(
85 __( "Contact Form 7 needs your support.", 'contact-form-7' )
86 );
87 }
88
89 protected function content() {
90 return array(
91 esc_html( __( "It is hard to continue development and support for this plugin without contributions from users like you.", 'contact-form-7' ) ),
92 sprintf(
93 /* translators: %s: link labeled 'making a donation' */
94 esc_html( __( 'If you enjoy using Contact Form 7 and find it useful, please consider %s.', 'contact-form-7' ) ),
95 wpcf7_link(
96 __( 'https://contactform7.com/donate/', 'contact-form-7' ),
97 __( 'making a donation', 'contact-form-7' )
98 )
99 ),
100 esc_html( __( "Your donation will help encourage and support the plugin&#8217;s continued development and better user support.", 'contact-form-7' ) ),
101 );
102 }
103 }
104
105
106 class WPCF7_WelcomePanelColumn_Flamingo extends WPCF7_WelcomePanelColumn {
107
108 protected function icon() {
109 return 'editor-help';
110 }
111
112 protected function title() {
113 return esc_html(
114 __( "Before you cry over spilt mail&#8230;", 'contact-form-7' )
115 );
116 }
117
118 protected function content() {
119 return array(
120 esc_html( __( "Contact Form 7 does not store submitted messages anywhere. Therefore, you may lose important messages forever if your mail server has issues or you make a mistake in mail configuration.", 'contact-form-7' ) ),
121 sprintf(
122 /* translators: %s: link labeled 'Flamingo' */
123 esc_html( __( 'Install a message storage plugin before this happens to you. %s saves all messages through contact forms into the database. Flamingo is a free WordPress plugin created by the same author as Contact Form 7.', 'contact-form-7' ) ),
124 wpcf7_link(
125 __( 'https://contactform7.com/save-submitted-messages-with-flamingo/', 'contact-form-7' ),
126 __( 'Flamingo', 'contact-form-7' )
127 )
128 ),
129 );
130 }
131 }
132
133
134 class WPCF7_WelcomePanelColumn_Integration extends WPCF7_WelcomePanelColumn {
135
136 protected function icon() {
137 return 'superhero-alt';
138 }
139
140 protected function title() {
141 return esc_html(
142 __( "You have strong allies to back you up.", 'contact-form-7' )
143 );
144 }
145
146 protected function content() {
147 return array(
148 sprintf(
149 /* translators: 1: link labeled 'Sendinblue', 2: link labeled 'Constant Contact' */
150 esc_html( __( 'Your contact forms will become more powerful and versatile by integrating them with external APIs. With CRM and email marketing services, you can build your own contact lists (%1$s and %2$s).', 'contact-form-7' ) ),
151 wpcf7_link(
152 __( 'https://contactform7.com/sendinblue-integration/', 'contact-form-7' ),
153 __( 'Sendinblue', 'contact-form-7' )
154 ),
155 wpcf7_link(
156 __( 'https://contactform7.com/constant-contact-integration/', 'contact-form-7' ),
157 __( 'Constant Contact', 'contact-form-7' )
158 )
159 ),
160 sprintf(
161 /* translators: 1: link labeled 'reCAPTCHA', 2: link labeled 'Stripe' */
162 esc_html( __( 'With help from cloud-based machine learning, anti-spam services will protect your forms (%1$s). Even payment services are natively supported (%2$s).', 'contact-form-7' ) ),
163 wpcf7_link(
164 __( 'https://contactform7.com/recaptcha/', 'contact-form-7' ),
165 __( 'reCAPTCHA', 'contact-form-7' )
166 ),
167 wpcf7_link(
168 __( 'https://contactform7.com/stripe-integration/', 'contact-form-7' ),
169 __( 'Stripe', 'contact-form-7' )
170 )
171 ),
172 );
173 }
174 }
175
176
177 function wpcf7_welcome_panel() {
178 $columns = array();
179
180 $flamingo_is_active = defined( 'FLAMINGO_VERSION' );
181
182 $sendinblue_is_active = false;
183
184 if ( class_exists( 'WPCF7_Sendinblue' )
185 and $sendinblue = WPCF7_Sendinblue::get_instance() ) {
186 $sendinblue_is_active = $sendinblue->is_active();
187 }
188
189 if ( $flamingo_is_active and $sendinblue_is_active ) {
190 $columns[] = new WPCF7_WelcomePanelColumn_AntiSpam();
191 $columns[] = new WPCF7_WelcomePanelColumn_Donation();
192 } elseif ( $flamingo_is_active ) {
193 $columns[] = new WPCF7_WelcomePanelColumn_Integration();
194 $columns[] = new WPCF7_WelcomePanelColumn_AntiSpam();
195 } elseif ( $sendinblue_is_active ) {
196 $columns[] = new WPCF7_WelcomePanelColumn_Flamingo();
197 $columns[] = new WPCF7_WelcomePanelColumn_AntiSpam();
198 } else {
199 $columns[] = new WPCF7_WelcomePanelColumn_Flamingo();
200 $columns[] = new WPCF7_WelcomePanelColumn_Integration();
201 }
202
203 $classes = 'wpcf7-welcome-panel';
204
205 $vers = (array) get_user_meta( get_current_user_id(),
206 'wpcf7_hide_welcome_panel_on', true
207 );
208
209 if ( wpcf7_version_grep( wpcf7_version( 'only_major=1' ), $vers ) ) {
210 $classes .= ' hidden';
211 }
212
213 ?>
214 <div id="wpcf7-welcome-panel" class="<?php echo esc_attr( $classes ); ?>">
215 <?php wp_nonce_field( 'wpcf7-welcome-panel-nonce', 'welcomepanelnonce', false ); ?>
216 <a class="welcome-panel-close" href="<?php echo esc_url( menu_page_url( 'wpcf7', false ) ); ?>"><?php echo esc_html( __( 'Dismiss', 'contact-form-7' ) ); ?></a>
217
218 <div class="welcome-panel-content">
219 <div class="welcome-panel-column-container">
220 <?php
221
222 foreach ( $columns as $column ) {
223 $column->print_content();
224 }
225
226 ?>
227 </div>
228 </div>
229 </div>
230 <?php
231 }
232
233
234 add_action(
235 'wp_ajax_wpcf7-update-welcome-panel',
236 'wpcf7_admin_ajax_welcome_panel',
237 10, 0
238 );
239
240 function wpcf7_admin_ajax_welcome_panel() {
241 check_ajax_referer( 'wpcf7-welcome-panel-nonce', 'welcomepanelnonce' );
242
243 $vers = get_user_meta( get_current_user_id(),
244 'wpcf7_hide_welcome_panel_on', true
245 );
246
247 if ( empty( $vers ) or ! is_array( $vers ) ) {
248 $vers = array();
249 }
250
251 if ( empty( $_POST['visible'] ) ) {
252 $vers[] = wpcf7_version( 'only_major=1' );
253 } else {
254 $vers = array_diff( $vers, array( wpcf7_version( 'only_major=1' ) ) );
255 }
256
257 $vers = array_unique( $vers );
258
259 update_user_meta( get_current_user_id(),
260 'wpcf7_hide_welcome_panel_on', $vers
261 );
262
263 wp_die( 1 );
264 }
265
266
267 add_filter(
268 'screen_settings',
269 'wpcf7_welcome_panel_screen_settings',
270 10, 2
271 );
272
273 function wpcf7_welcome_panel_screen_settings( $screen_settings, $screen ) {
274
275 if ( 'toplevel_page_wpcf7' !== $screen->id ) {
276 return $screen_settings;
277 }
278
279 $vers = (array) get_user_meta( get_current_user_id(),
280 'wpcf7_hide_welcome_panel_on', true
281 );
282
283 $checkbox_id = 'wpcf7-welcome-panel-show';
284 $checked = ! in_array( wpcf7_version( 'only_major=1' ), $vers );
285
286 $checkbox = sprintf(
287 '<input %s />',
288 wpcf7_format_atts( array(
289 'id' => $checkbox_id,
290 'type' => 'checkbox',
291 'checked' => $checked ? 'checked' : null,
292 ) )
293 );
294
295 $screen_settings .= sprintf( '
296 <fieldset class="wpcf7-welcome-panel-options">
297 <legend>%1$s</legend>
298 <label for="%2$s">%3$s %4$s</label>
299 </fieldset>',
300 esc_html( __( 'Welcome panel', 'contact-form-7' ) ),
301 esc_attr( $checkbox_id ),
302 $checkbox,
303 esc_html( __( 'Show welcome panel', 'contact-form-7' ) )
304 );
305
306 return $screen_settings;
307 }
1 ( function( $ ) {
2
3 'use strict';
4
5 if ( typeof wpcf7 === 'undefined' || wpcf7 === null ) {
6 return;
7 }
8
9 $( function() {
10 var welcomePanel = $( '#wpcf7-welcome-panel' );
11 var updateWelcomePanel;
12
13 updateWelcomePanel = function( visible ) {
14 $.post( ajaxurl, {
15 action: 'wpcf7-update-welcome-panel',
16 visible: visible,
17 welcomepanelnonce: $( '#welcomepanelnonce' ).val()
18 } );
19 };
20
21 $( 'a.welcome-panel-close', welcomePanel ).click( function( event ) {
22 event.preventDefault();
23 welcomePanel.addClass( 'hidden' );
24 updateWelcomePanel( 0 );
25 $( '#wpcf7-welcome-panel-show' ).prop( 'checked', false );
26 } );
27
28 $( '#wpcf7-welcome-panel-show' ).click( function( event ) {
29 if ( this.checked ) {
30 welcomePanel.removeClass( 'hidden' );
31 updateWelcomePanel( 1 );
32 } else {
33 welcomePanel.addClass( 'hidden' );
34 updateWelcomePanel( 0 );
35 }
36 } );
37
38 $( '#contact-form-editor' ).tabs( {
39 active: wpcf7.activeTab,
40 activate: function( event, ui ) {
41 $( '#active-tab' ).val( ui.newTab.index() );
42 }
43 } );
44
45 $( '#contact-form-editor-tabs' ).focusin( function( event ) {
46 $( '#contact-form-editor .keyboard-interaction' ).css(
47 'visibility', 'visible' );
48 } ).focusout( function( event ) {
49 $( '#contact-form-editor .keyboard-interaction' ).css(
50 'visibility', 'hidden' );
51 } );
52
53 wpcf7.toggleMail2( 'input:checkbox.toggle-form-table' );
54
55 $( 'input:checkbox.toggle-form-table' ).click( function( event ) {
56 wpcf7.toggleMail2( this );
57 } );
58
59 if ( '' === $( '#title' ).val() ) {
60 $( '#title' ).focus();
61 }
62
63 wpcf7.titleHint();
64
65 $( '.contact-form-editor-box-mail span.mailtag' ).click( function( event ) {
66 var range = document.createRange();
67 range.selectNodeContents( this );
68 window.getSelection().addRange( range );
69 } );
70
71 wpcf7.updateConfigErrors();
72
73 $( '[data-config-field]' ).change( function() {
74 var postId = $( '#post_ID' ).val();
75
76 if ( ! postId || -1 == postId ) {
77 return;
78 }
79
80 var data = [];
81
82 $( this ).closest( 'form' ).find( '[data-config-field]' ).each( function() {
83 data.push( {
84 'name': $( this ).attr( 'name' ).replace( /^wpcf7-/, '' ).replace( /-/g, '_' ),
85 'value': $( this ).val()
86 } );
87 } );
88
89 data.push( { 'name': 'context', 'value': 'dry-run' } );
90
91 $.ajax( {
92 method: 'POST',
93 url: wpcf7.apiSettings.getRoute( '/contact-forms/' + postId ),
94 beforeSend: function( xhr ) {
95 xhr.setRequestHeader( 'X-WP-Nonce', wpcf7.apiSettings.nonce );
96 },
97 data: data
98 } ).done( function( response ) {
99 wpcf7.configValidator.errors = response.config_errors;
100 wpcf7.updateConfigErrors();
101 } );
102 } );
103
104 $( window ).on( 'beforeunload', function( event ) {
105 var changed = false;
106
107 $( '#wpcf7-admin-form-element :input[type!="hidden"]' ).each( function() {
108 if ( $( this ).is( ':checkbox, :radio' ) ) {
109 if ( this.defaultChecked != $( this ).is( ':checked' ) ) {
110 changed = true;
111 }
112 } else if ( $( this ).is( 'select' ) ) {
113 $( this ).find( 'option' ).each( function() {
114 if ( this.defaultSelected != $( this ).is( ':selected' ) ) {
115 changed = true;
116 }
117 } );
118 } else {
119 if ( this.defaultValue != $( this ).val() ) {
120 changed = true;
121 }
122 }
123 } );
124
125 if ( changed ) {
126 event.returnValue = wpcf7.saveAlert;
127 return wpcf7.saveAlert;
128 }
129 } );
130
131 $( '#wpcf7-admin-form-element' ).submit( function() {
132 if ( 'copy' != this.action.value ) {
133 $( window ).off( 'beforeunload' );
134 }
135
136 if ( 'save' == this.action.value ) {
137 $( '#publishing-action .spinner' ).addClass( 'is-active' );
138 }
139 } );
140
141 $( '#wpcf7-ctct-enable-contact-list, #wpcf7-sendinblue-enable-contact-list, #wpcf7-sendinblue-enable-transactional-email' ).on( 'change', function() {
142 if ( $( this ).is( ':checked' ) ) {
143 $( this ).closest( 'tr' ).removeClass( 'inactive' );
144 } else {
145 $( this ).closest( 'tr' ).addClass( 'inactive' );
146 }
147 } );
148
149 } );
150
151 wpcf7.toggleMail2 = function( checkbox ) {
152 var $checkbox = $( checkbox );
153 var $fieldset = $( 'fieldset',
154 $checkbox.closest( '.contact-form-editor-box-mail' ) );
155
156 if ( $checkbox.is( ':checked' ) ) {
157 $fieldset.removeClass( 'hidden' );
158 } else {
159 $fieldset.addClass( 'hidden' );
160 }
161 };
162
163 wpcf7.updateConfigErrors = function() {
164 var errors = wpcf7.configValidator.errors;
165 var errorCount = { total: 0 };
166
167 $( '[data-config-field]' ).each( function() {
168 $( this ).removeAttr( 'aria-invalid' );
169 $( this ).next( 'ul.config-error' ).remove();
170
171 var section = $( this ).attr( 'data-config-field' );
172
173 $( this ).attr( 'aria-describedby', 'wpcf7-config-error-for-' + section );
174
175 if ( errors[ section ] ) {
176 var $list = $( '<ul></ul>' ).attr( {
177 'id': 'wpcf7-config-error-for-' + section,
178 'class': 'config-error'
179 } );
180
181 $.each( errors[ section ], function( i, val ) {
182 var $li = $( '<li></li>' ).append(
183 wpcf7.iconInCircle( '!' )
184 ).append(
185 $( '<span class="screen-reader-text"></span>' ).text( wpcf7.configValidator.iconAlt )
186 ).append( ' ' );
187
188 if ( val.link ) {
189 $li.append(
190 $( '<a></a>' ).attr( 'href', val.link ).text( val.message )
191 );
192 } else {
193 $li.text( val.message );
194 }
195
196 $li.appendTo( $list );
197
198 var tab = section
199 .replace( /^mail_\d+\./, 'mail.' ).replace( /\..*$/, '' );
200
201 if ( ! errorCount[ tab ] ) {
202 errorCount[ tab ] = 0;
203 }
204
205 errorCount[ tab ] += 1;
206
207 errorCount.total += 1;
208 } );
209
210 $( this ).after( $list ).attr( { 'aria-invalid': 'true' } );
211 }
212 } );
213
214 $( '#contact-form-editor-tabs > li' ).each( function() {
215 var $item = $( this );
216 $item.find( '.icon-in-circle' ).remove();
217 var tab = $item.attr( 'id' ).replace( /-panel-tab$/, '' );
218
219 $.each( errors, function( key, val ) {
220 key = key.replace( /^mail_\d+\./, 'mail.' );
221
222 if ( key.replace( /\..*$/, '' ) == tab.replace( '-', '_' ) ) {
223 var $mark = wpcf7.iconInCircle( '!' );
224 $item.find( 'a.ui-tabs-anchor' ).first().append( $mark );
225 return false;
226 }
227 } );
228
229 var $tabPanelError = $( '#' + tab + '-panel > div.config-error:first' );
230 $tabPanelError.empty();
231
232 if ( errorCount[ tab.replace( '-', '_' ) ] ) {
233 $tabPanelError.append( wpcf7.iconInCircle( '!' ) );
234
235 if ( 1 < errorCount[ tab.replace( '-', '_' ) ] ) {
236 var manyErrorsInTab = wpcf7.configValidator.manyErrorsInTab
237 .replace( '%d', errorCount[ tab.replace( '-', '_' ) ] );
238 $tabPanelError.append( manyErrorsInTab );
239 } else {
240 $tabPanelError.append( wpcf7.configValidator.oneErrorInTab );
241 }
242 }
243 } );
244
245 $( '#misc-publishing-actions .misc-pub-section.config-error' ).remove();
246
247 if ( errorCount.total ) {
248 var $warning = $( '<div></div>' )
249 .addClass( 'misc-pub-section config-error' )
250 .append( wpcf7.iconInCircle( '!' ) );
251
252 if ( 1 < errorCount.total ) {
253 $warning.append(
254 wpcf7.configValidator.manyErrors.replace( '%d', errorCount.total )
255 );
256 } else {
257 $warning.append( wpcf7.configValidator.oneError );
258 }
259
260 $warning.append( '<br />' ).append(
261 $( '<a></a>' )
262 .attr( 'href', wpcf7.configValidator.docUrl )
263 .text( wpcf7.configValidator.howToCorrect )
264 );
265
266 $( '#misc-publishing-actions' ).append( $warning );
267 }
268 };
269
270 /**
271 * Copied from wptitlehint() in wp-admin/js/post.js
272 */
273 wpcf7.titleHint = function() {
274 var $title = $( '#title' );
275 var $titleprompt = $( '#title-prompt-text' );
276
277 if ( '' === $title.val() ) {
278 $titleprompt.removeClass( 'screen-reader-text' );
279 }
280
281 $titleprompt.click( function() {
282 $( this ).addClass( 'screen-reader-text' );
283 $title.focus();
284 } );
285
286 $title.blur( function() {
287 if ( '' === $(this).val() ) {
288 $titleprompt.removeClass( 'screen-reader-text' );
289 }
290 } ).focus( function() {
291 $titleprompt.addClass( 'screen-reader-text' );
292 } ).keydown( function( e ) {
293 $titleprompt.addClass( 'screen-reader-text' );
294 $( this ).unbind( e );
295 } );
296 };
297
298 wpcf7.iconInCircle = function( icon ) {
299 var $span = $( '<span class="icon-in-circle" aria-hidden="true"></span>' );
300 return $span.text( icon );
301 };
302
303 wpcf7.apiSettings.getRoute = function( path ) {
304 var url = wpcf7.apiSettings.root;
305
306 url = url.replace(
307 wpcf7.apiSettings.namespace,
308 wpcf7.apiSettings.namespace + path );
309
310 return url;
311 };
312
313 } )( jQuery );
1 ( function( $ ) {
2
3 'use strict';
4
5 if ( typeof wpcf7 === 'undefined' || wpcf7 === null ) {
6 return;
7 }
8
9 wpcf7.taggen = {};
10
11 $( function() {
12 $( 'form.tag-generator-panel' ).each( function() {
13 wpcf7.taggen.update( $( this ) );
14 } );
15 } );
16
17 $( 'form.tag-generator-panel' ).submit( function() {
18 return false;
19 } );
20
21 $( 'form.tag-generator-panel .control-box :input' ).change( function() {
22 var $form = $( this ).closest( 'form.tag-generator-panel' );
23 wpcf7.taggen.normalize( $( this ) );
24 wpcf7.taggen.update( $form );
25 } );
26
27 $( 'input.insert-tag' ).click( function() {
28 var $form = $( this ).closest( 'form.tag-generator-panel' );
29 var tag = $form.find( 'input.tag' ).val();
30 wpcf7.taggen.insert( tag );
31 tb_remove(); // close thickbox
32 return false;
33 } );
34
35 wpcf7.taggen.update = function( $form ) {
36 var id = $form.attr( 'data-id' );
37 var name = '';
38 var name_fields = $form.find( 'input[name="name"]' );
39
40 if ( name_fields.length ) {
41 name = name_fields.val();
42
43 if ( '' === name ) {
44 name = id + '-' + Math.floor( Math.random() * 1000 );
45 name_fields.val( name );
46 }
47 }
48
49 if ( $.isFunction( wpcf7.taggen.update[ id ] ) ) {
50 return wpcf7.taggen.update[ id ].call( this, $form );
51 }
52
53 $form.find( 'input.tag' ).each( function() {
54 var tag_type = $( this ).attr( 'name' );
55
56 if ( $form.find( ':input[name="tagtype"]' ).length ) {
57 tag_type = $form.find( ':input[name="tagtype"]' ).val();
58 }
59
60 if ( $form.find( ':input[name="required"]' ).is( ':checked' ) ) {
61 tag_type += '*';
62 }
63
64 var components = wpcf7.taggen.compose( tag_type, $form );
65 $( this ).val( components );
66 } );
67
68 $form.find( 'span.mail-tag' ).text( '[' + name + ']' );
69
70 $form.find( 'input.mail-tag' ).each( function() {
71 $( this ).val( '[' + name + ']' );
72 } );
73 };
74
75 wpcf7.taggen.update.captcha = function( $form ) {
76 var captchac = wpcf7.taggen.compose( 'captchac', $form );
77 var captchar = wpcf7.taggen.compose( 'captchar', $form );
78
79 $form.find( 'input.tag' ).val( captchac + ' ' + captchar );
80 };
81
82 wpcf7.taggen.compose = function( tagType, $form ) {
83 var name = $form.find( 'input[name="name"]' ).val();
84 var scope = $form.find( '.scope.' + tagType );
85
86 if ( ! scope.length ) {
87 scope = $form;
88 }
89
90 var options = [];
91
92 scope.find( 'input.option' ).not( ':checkbox,:radio' ).each( function( i ) {
93 var val = $( this ).val();
94
95 if ( ! val ) {
96 return;
97 }
98
99 if ( $( this ).hasClass( 'filetype' ) ) {
100 val = val.split( /[,|\s]+/ ).join( '|' );
101 }
102
103 if ( $( this ).hasClass( 'color' ) ) {
104 val = '#' + val;
105 }
106
107 if ( 'class' == $( this ).attr( 'name' ) ) {
108 $.each( val.split( ' ' ), function( i, n ) {
109 options.push( 'class:' + n );
110 } );
111 } else {
112 options.push( $( this ).attr( 'name' ) + ':' + val );
113 }
114 } );
115
116 scope.find( 'input:checkbox.option' ).each( function( i ) {
117 if ( $( this ).is( ':checked' ) ) {
118 options.push( $( this ).attr( 'name' ) );
119 }
120 } );
121
122 scope.find( 'input:radio.option' ).each( function( i ) {
123 if ( $( this ).is( ':checked' ) && ! $( this ).hasClass( 'default' ) ) {
124 options.push( $( this ).attr( 'name' ) + ':' + $( this ).val() );
125 }
126 } );
127
128 if ( 'radio' == tagType ) {
129 options.push( 'default:1' );
130 }
131
132 options = ( options.length > 0 ) ? options.join( ' ' ) : '';
133
134 var value = '';
135
136 if ( scope.find( ':input[name="values"]' ).val() ) {
137 $.each(
138 scope.find( ':input[name="values"]' ).val().split( "\n" ),
139 function( i, n ) {
140 value += ' "' + n.replace( /["]/g, '&quot;' ) + '"';
141 }
142 );
143 }
144
145 var components = [];
146
147 $.each( [ tagType, name, options, value ], function( i, v ) {
148 v = $.trim( v );
149
150 if ( '' != v ) {
151 components.push( v );
152 }
153 } );
154
155 components = $.trim( components.join( ' ' ) );
156 components = '[' + components + ']';
157
158 var content = scope.find( ':input[name="content"]' ).val();
159 content = $.trim( content );
160
161 if ( content ) {
162 components += ' ' + content + ' [/' + tagType + ']';
163 }
164
165 return components;
166 };
167
168 wpcf7.taggen.normalize = function( $input ) {
169 var val = $input.val();
170
171 if ( $input.is( 'input[name="name"]' ) ) {
172 val = val.replace( /[^0-9a-zA-Z:._-]/g, '' ).replace( /^[^a-zA-Z]+/, '' );
173 }
174
175 if ( $input.is( '.numeric' ) ) {
176 val = val.replace( /[^0-9.-]/g, '' );
177 }
178
179 if ( $input.is( '.idvalue' ) ) {
180 val = val.replace( /[^-0-9a-zA-Z_]/g, '' );
181 }
182
183 if ( $input.is( '.classvalue' ) ) {
184 val = $.map( val.split( ' ' ), function( n ) {
185 return n.replace( /[^-0-9a-zA-Z_]/g, '' );
186 } ).join( ' ' );
187
188 val = $.trim( val.replace( /\s+/g, ' ' ) );
189 }
190
191 if ( $input.is( '.color' ) ) {
192 val = val.replace( /[^0-9a-fA-F]/g, '' );
193 }
194
195 if ( $input.is( '.filesize' ) ) {
196 val = val.replace( /[^0-9kKmMbB]/g, '' );
197 }
198
199 if ( $input.is( '.filetype' ) ) {
200 val = val.replace( /[^0-9a-zA-Z.,|\s]/g, '' );
201 }
202
203 if ( $input.is( '.date' ) ) {
204 // 'yyyy-mm-dd' ISO 8601 format
205 if ( ! val.match( /^\d{4}-\d{2}-\d{2}$/ ) ) {
206 val = '';
207 }
208 }
209
210 if ( $input.is( ':input[name="values"]' ) ) {
211 val = $.trim( val );
212 }
213
214 $input.val( val );
215
216 if ( $input.is( ':checkbox.exclusive' ) ) {
217 wpcf7.taggen.exclusiveCheckbox( $input );
218 }
219 };
220
221 wpcf7.taggen.exclusiveCheckbox = function( $cb ) {
222 if ( $cb.is( ':checked' ) ) {
223 $cb.siblings( ':checkbox.exclusive' ).prop( 'checked', false );
224 }
225 };
226
227 wpcf7.taggen.insert = function( content ) {
228 $( 'textarea#wpcf7-form' ).each( function() {
229 this.focus();
230
231 if ( document.selection ) { // IE
232 var selection = document.selection.createRange();
233 selection.text = content;
234 } else if ( this.selectionEnd || 0 === this.selectionEnd ) {
235 var val = $( this ).val();
236 var end = this.selectionEnd;
237 $( this ).val( val.substring( 0, end ) +
238 content + val.substring( end, val.length ) );
239 this.selectionStart = end + content.length;
240 this.selectionEnd = end + content.length;
241 } else {
242 $( this ).val( $( this ).val() + content );
243 }
244
245 this.focus();
246 } );
247 };
248
249 } )( jQuery );
1 <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 242.5 239.46"><defs><style>.cls-1,.cls-6{fill:none;}.cls-2{clip-path:url(#clip-path);}.cls-3{fill:#33c6f4;}.cls-4{fill:#1b447e;}.cls-5{fill:#fff;}.cls-6{stroke:#221e1f;stroke-miterlimit:10;stroke-width:7.16px;}</style><clipPath id="clip-path" transform="translate(1.72)"><circle class="cls-1" cx="119.73" cy="119.73" r="116.15"/></clipPath></defs><g id="Layer_2" data-name="Layer 2"><g id="Layer_1" data-name="Layer 1"><g class="cls-2"><circle class="cls-3" cx="121.45" cy="119.73" r="116.15"/><path class="cls-4" d="M239.32,167.79c-53.41-24-108.37-91.46-113-94.55s-10.84.77-10.84.77c-3.87-6.19-10.06.77-10.06.77C76.77,123.55.14,170.11.14,170.11S36.94,237.79,122,237.79C208.48,237.79,239.32,167.79,239.32,167.79Z" transform="translate(1.72)"/><path class="cls-5" d="M67.48,116.58s15.48-7,12.38,4.65-15.48,28.64-11.61,29.41S83,140.58,86.06,142.12s5.42.78,3.87,6.2-3.1,9.29,0,9.29,5.42-7,9.29-13.94,10.06-3.87,12.38-1.55,9.29,15.49,14.71,13.94,8.51-8.52,6.19-24,1.55-20.12,1.55-20.12,4.64-2.32,13.16,8.51,24,27.09,26.31,26.32-10.83-17.8-7.74-19.35,15.48,2.32,21.68,7.74c0,0,2.12,8.87,2.12.36L126.31,73.24,115.47,74l-10.06.77S80.64,111.94,67.48,116.58Z" transform="translate(1.72)"/><path class="cls-6" d="M239.32,170.11c-53.41-24-108.37-93.78-113-96.87s-10.84.77-10.84.77c-3.87-6.19-10.06.77-10.06.77C76.77,123.55.14,170.11.14,170.11" transform="translate(1.72)"/></g><circle class="cls-6" cx="121.45" cy="119.73" r="116.15"/></g></g></svg>
1 <?php
2
3 add_action( 'init', 'wpcf7_init_block_editor_assets', 10, 0 );
4
5 function wpcf7_init_block_editor_assets() {
6 $assets = array();
7
8 $asset_file = wpcf7_plugin_path(
9 'includes/block-editor/index.asset.php'
10 );
11
12 if ( file_exists( $asset_file ) ) {
13 $assets = include( $asset_file );
14 }
15
16 $assets = wp_parse_args( $assets, array(
17 'src' => wpcf7_plugin_url( 'includes/block-editor/index.js' ),
18 'dependencies' => array(
19 'wp-api-fetch',
20 'wp-components',
21 'wp-compose',
22 'wp-blocks',
23 'wp-element',
24 'wp-i18n',
25 ),
26 'version' => WPCF7_VERSION,
27 ) );
28
29 wp_register_script(
30 'contact-form-7-block-editor',
31 $assets['src'],
32 $assets['dependencies'],
33 $assets['version']
34 );
35
36 wp_set_script_translations(
37 'contact-form-7-block-editor',
38 'contact-form-7'
39 );
40
41 register_block_type(
42 'contact-form-7/contact-form-selector',
43 array(
44 'editor_script' => 'contact-form-7-block-editor',
45 )
46 );
47
48 $contact_forms = array_map(
49 function ( $contact_form ) {
50 return array(
51 'id' => $contact_form->id(),
52 'slug' => $contact_form->name(),
53 'title' => $contact_form->title(),
54 'locale' => $contact_form->locale(),
55 );
56 },
57 WPCF7_ContactForm::find( array(
58 'posts_per_page' => 20,
59 ) )
60 );
61
62 wp_add_inline_script(
63 'contact-form-7-block-editor',
64 sprintf(
65 'window.wpcf7 = {contactForms:%s};',
66 json_encode( $contact_forms )
67 ),
68 'before'
69 );
70
71 }
1 !function(){"use strict";var t,e=window.wp.element,c=window.wp.i18n,l=window.wp.blocks,r=(0,e.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 242.5 239.46"},(0,e.createElement)("defs",null,(0,e.createElement)("clipPath",{id:"clip-path",transform:"translate(1.72)"},(0,e.createElement)("circle",{className:"cls-1",cx:"119.73",cy:"119.73",r:"116.15",fill:"none"}))),(0,e.createElement)("g",{id:"Layer_2","data-name":"Layer 2"},(0,e.createElement)("g",{id:"Layer_1","data-name":"Layer 1"},(0,e.createElement)("g",{className:"cls-2",clipPath:"url(#clip-path)"},(0,e.createElement)("circle",{className:"cls-3",cx:"121.45",cy:"119.73",r:"116.15",fill:"#33c6f4"}),(0,e.createElement)("path",{className:"cls-4",d:"M239.32,167.79c-53.41-24-108.37-91.46-113-94.55s-10.84.77-10.84.77c-3.87-6.19-10.06.77-10.06.77C76.77,123.55.14,170.11.14,170.11S36.94,237.79,122,237.79C208.48,237.79,239.32,167.79,239.32,167.79Z",transform:"translate(1.72)",fill:"#1b447e"}),(0,e.createElement)("path",{className:"cls-5",d:"M67.48,116.58s15.48-7,12.38,4.65-15.48,28.64-11.61,29.41S83,140.58,86.06,142.12s5.42.78,3.87,6.2-3.1,9.29,0,9.29,5.42-7,9.29-13.94,10.06-3.87,12.38-1.55,9.29,15.49,14.71,13.94,8.51-8.52,6.19-24,1.55-20.12,1.55-20.12,4.64-2.32,13.16,8.51,24,27.09,26.31,26.32-10.83-17.8-7.74-19.35,15.48,2.32,21.68,7.74c0,0,2.12,8.87,2.12.36L126.31,73.24,115.47,74l-10.06.77S80.64,111.94,67.48,116.58Z",transform:"translate(1.72)",fill:"#fff"}),(0,e.createElement)("path",{className:"cls-6",d:"M239.32,170.11c-53.41-24-108.37-93.78-113-96.87s-10.84.77-10.84.77c-3.87-6.19-10.06.77-10.06.77C76.77,123.55.14,170.11.14,170.11",transform:"translate(1.72)",fill:"none",stroke:"#221e1f",strokeMiterlimit:"10",strokeWidth:"8px"})),(0,e.createElement)("circle",{className:"cls-6",cx:"121.45",cy:"119.73",r:"116.15",fill:"none",stroke:"#1b447e",strokeMiterlimit:"10",strokeWidth:"8px"})))),a=window.wp.compose,o=window.wp.components,n={from:[{type:"shortcode",tag:"contact-form-7",attributes:{id:{type:"integer",shortcode:t=>{let{named:{id:e}}=t;return parseInt(e)}},title:{type:"string",shortcode:t=>{let{named:{title:e}}=t;return e}}}}],to:[{type:"block",blocks:["core/shortcode"],transform:t=>(0,l.createBlock)("core/shortcode",{text:`[contact-form-7 id="${t.id}" title="${t.title}"]`})}]};window.wpcf7=null!==(t=window.wpcf7)&&void 0!==t?t:{contactForms:[]},(0,l.registerBlockType)("contact-form-7/contact-form-selector",{title:(0,c.__)("Contact Form 7","contact-form-7"),description:(0,c.__)("Insert a contact form you have created with Contact Form 7.","contact-form-7"),category:"widgets",attributes:{id:{type:"integer"},title:{type:"string"}},icon:r,transforms:n,edit:function t(l){let{attributes:r,setAttributes:n}=l;const i=new Map;if(Object.entries(window.wpcf7.contactForms).forEach((t=>{let[e,c]=t;i.set(c.id,c)})),!i.size&&!r.id)return(0,e.createElement)("div",{className:"components-placeholder"},(0,e.createElement)("p",null,(0,c.__)("No contact forms were found. Create a contact form first.","contact-form-7")));const s=Array.from(i.values(),(t=>({value:t.id,label:t.title})));if(r.id)s.length||s.push({value:r.id,label:r.title});else{const t=s[0];r={id:parseInt(t.value),title:t.label}}const m=`contact-form-7-contact-form-selector-${(0,a.useInstanceId)(t)}`;return(0,e.createElement)("div",{className:"components-placeholder"},(0,e.createElement)("label",{htmlFor:m,className:"components-placeholder__label"},(0,c.__)("Select a contact form:","contact-form-7")),(0,e.createElement)(o.SelectControl,{id:m,options:s,value:r.id,onChange:t=>n({id:parseInt(t),title:i.get(parseInt(t)).title})}))},save:t=>{var c,l,r,a;let{attributes:o}=t;return o={id:null!==(c=o.id)&&void 0!==c?c:null===(l=window.wpcf7.contactForms[0])||void 0===l?void 0:l.id,title:null!==(r=o.title)&&void 0!==r?r:null===(a=window.wpcf7.contactForms[0])||void 0===a?void 0:a.title},(0,e.createElement)("div",null,'[contact-form-7 id="',o.id,'" title="',o.title,'"]')}})}();
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 add_filter( 'map_meta_cap', 'wpcf7_map_meta_cap', 10, 4 );
4
5 function wpcf7_map_meta_cap( $caps, $cap, $user_id, $args ) {
6 $meta_caps = array(
7 'wpcf7_edit_contact_form' => WPCF7_ADMIN_READ_WRITE_CAPABILITY,
8 'wpcf7_edit_contact_forms' => WPCF7_ADMIN_READ_WRITE_CAPABILITY,
9 'wpcf7_read_contact_form' => WPCF7_ADMIN_READ_CAPABILITY,
10 'wpcf7_read_contact_forms' => WPCF7_ADMIN_READ_CAPABILITY,
11 'wpcf7_delete_contact_form' => WPCF7_ADMIN_READ_WRITE_CAPABILITY,
12 'wpcf7_delete_contact_forms' => WPCF7_ADMIN_READ_WRITE_CAPABILITY,
13 'wpcf7_manage_integration' => 'manage_options',
14 'wpcf7_submit' => 'read',
15 );
16
17 $meta_caps = apply_filters( 'wpcf7_map_meta_cap', $meta_caps );
18
19 $caps = array_diff( $caps, array_keys( $meta_caps ) );
20
21 if ( isset( $meta_caps[$cap] ) ) {
22 $caps[] = $meta_caps[$cap];
23 }
24
25 return $caps;
26 }
1 <?php
2 /**
3 * Contact form helper functions
4 */
5
6
7 /**
8 * Wrapper function of WPCF7_ContactForm::get_instance().
9 *
10 * @param int|WP_Post $post Post ID or post object.
11 * @return WPCF7_ContactForm Contact form object.
12 */
13 function wpcf7_contact_form( $post ) {
14 return WPCF7_ContactForm::get_instance( $post );
15 }
16
17
18 /**
19 * Searches for a contact form by an old unit ID.
20 *
21 * @param int $old_id Old unit ID.
22 * @return WPCF7_ContactForm Contact form object.
23 */
24 function wpcf7_get_contact_form_by_old_id( $old_id ) {
25 global $wpdb;
26
27 $q = "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_old_cf7_unit_id'"
28 . $wpdb->prepare( " AND meta_value = %d", $old_id );
29
30 if ( $new_id = $wpdb->get_var( $q ) ) {
31 return wpcf7_contact_form( $new_id );
32 }
33 }
34
35
36 /**
37 * Searches for a contact form by title.
38 *
39 * @param string $title Title of contact form.
40 * @return WPCF7_ContactForm|null Contact form object if found, null otherwise.
41 */
42 function wpcf7_get_contact_form_by_title( $title ) {
43 $page = get_page_by_title( $title, OBJECT, WPCF7_ContactForm::post_type );
44
45 if ( $page ) {
46 return wpcf7_contact_form( $page->ID );
47 }
48
49 return null;
50 }
51
52
53 /**
54 * Wrapper function of WPCF7_ContactForm::get_current().
55 *
56 * @return WPCF7_ContactForm Contact form object.
57 */
58 function wpcf7_get_current_contact_form() {
59 if ( $current = WPCF7_ContactForm::get_current() ) {
60 return $current;
61 }
62 }
63
64
65 /**
66 * Returns true if it is in the state that a non-Ajax submission is accepted.
67 */
68 function wpcf7_is_posted() {
69 if ( ! $contact_form = wpcf7_get_current_contact_form() ) {
70 return false;
71 }
72
73 return $contact_form->is_posted();
74 }
75
76
77 /**
78 * Retrieves the user input value through a non-Ajax submission.
79 *
80 * @param string $name Name of form control.
81 * @param string $default_value Optional default value.
82 * @return string The user input value through the form-control.
83 */
84 function wpcf7_get_hangover( $name, $default_value = null ) {
85 if ( ! wpcf7_is_posted() ) {
86 return $default_value;
87 }
88
89 $submission = WPCF7_Submission::get_instance();
90
91 if ( ! $submission
92 or $submission->is( 'mail_sent' ) ) {
93 return $default_value;
94 }
95
96 return isset( $_POST[$name] ) ? wp_unslash( $_POST[$name] ) : $default_value;
97 }
98
99
100 /**
101 * Retrieves an HTML snippet of validation error on the given form control.
102 *
103 * @param string $name Name of form control.
104 * @return string Validation error message in a form of HTML snippet.
105 */
106 function wpcf7_get_validation_error( $name ) {
107 if ( ! $contact_form = wpcf7_get_current_contact_form() ) {
108 return '';
109 }
110
111 return $contact_form->validation_error( $name );
112 }
113
114
115 /**
116 * Returns a reference key to a validation error message.
117 *
118 * @param string $name Name of form control.
119 * @param string $unit_tag Optional. Unit tag of the contact form.
120 * @return string Reference key code.
121 */
122 function wpcf7_get_validation_error_reference( $name, $unit_tag = '' ) {
123 if ( '' === $unit_tag ) {
124 $contact_form = wpcf7_get_current_contact_form();
125
126 if ( $contact_form and $contact_form->validation_error( $name ) ) {
127 $unit_tag = $contact_form->unit_tag();
128 } else {
129 return null;
130 }
131 }
132
133 return preg_replace( '/[^0-9a-z_-]+/i', '',
134 sprintf(
135 '%1$s-ve-%2$s',
136 $unit_tag,
137 $name
138 )
139 );
140 }
141
142
143 /**
144 * Retrieves a message for the given status.
145 */
146 function wpcf7_get_message( $status ) {
147 if ( ! $contact_form = wpcf7_get_current_contact_form() ) {
148 return '';
149 }
150
151 return $contact_form->message( $status );
152 }
153
154
155 /**
156 * Returns a class names list for a form-tag of the specified type.
157 *
158 * @param string $type Form-tag type.
159 * @param string $default_classes Optional default classes.
160 * @return string Whitespace-separated list of class names.
161 */
162 function wpcf7_form_controls_class( $type, $default_classes = '' ) {
163 $type = trim( $type );
164 $default_classes = array_filter( explode( ' ', $default_classes ) );
165
166 $classes = array_merge( array( 'wpcf7-form-control' ), $default_classes );
167
168 $typebase = rtrim( $type, '*' );
169 $required = ( '*' == substr( $type, -1 ) );
170
171 $classes[] = 'wpcf7-' . $typebase;
172
173 if ( $required ) {
174 $classes[] = 'wpcf7-validates-as-required';
175 }
176
177 $classes = array_unique( $classes );
178
179 return implode( ' ', $classes );
180 }
181
182
183 /**
184 * Callback function for the contact-form-7 shortcode.
185 */
186 function wpcf7_contact_form_tag_func( $atts, $content = null, $code = '' ) {
187 if ( is_feed() ) {
188 return '[contact-form-7]';
189 }
190
191 if ( 'contact-form-7' == $code ) {
192 $atts = shortcode_atts(
193 array(
194 'id' => 0,
195 'title' => '',
196 'html_id' => '',
197 'html_name' => '',
198 'html_class' => '',
199 'output' => 'form',
200 ),
201 $atts, 'wpcf7'
202 );
203
204 $id = (int) $atts['id'];
205 $title = trim( $atts['title'] );
206
207 if ( ! $contact_form = wpcf7_contact_form( $id ) ) {
208 $contact_form = wpcf7_get_contact_form_by_title( $title );
209 }
210
211 } else {
212 if ( is_string( $atts ) ) {
213 $atts = explode( ' ', $atts, 2 );
214 }
215
216 $id = (int) array_shift( $atts );
217 $contact_form = wpcf7_get_contact_form_by_old_id( $id );
218 }
219
220 if ( ! $contact_form ) {
221 return sprintf(
222 '[contact-form-7 404 "%s"]',
223 esc_html( __( 'Not Found', 'contact-form-7' ) )
224 );
225 }
226
227 return $contact_form->form_html( $atts );
228 }
229
230
231 /**
232 * Saves the contact form data.
233 */
234 function wpcf7_save_contact_form( $args = '', $context = 'save' ) {
235 $args = wp_parse_args( $args, array(
236 'id' => -1,
237 'title' => null,
238 'locale' => null,
239 'form' => null,
240 'mail' => null,
241 'mail_2' => null,
242 'messages' => null,
243 'additional_settings' => null,
244 ) );
245
246 $args = wp_unslash( $args );
247
248 $args['id'] = (int) $args['id'];
249
250 if ( -1 == $args['id'] ) {
251 $contact_form = WPCF7_ContactForm::get_template();
252 } else {
253 $contact_form = wpcf7_contact_form( $args['id'] );
254 }
255
256 if ( empty( $contact_form ) ) {
257 return false;
258 }
259
260 if ( null !== $args['title'] ) {
261 $contact_form->set_title( $args['title'] );
262 }
263
264 if ( null !== $args['locale'] ) {
265 $contact_form->set_locale( $args['locale'] );
266 }
267
268 $properties = array();
269
270 if ( null !== $args['form'] ) {
271 $properties['form'] = wpcf7_sanitize_form( $args['form'] );
272 }
273
274 if ( null !== $args['mail'] ) {
275 $properties['mail'] = wpcf7_sanitize_mail( $args['mail'] );
276 $properties['mail']['active'] = true;
277 }
278
279 if ( null !== $args['mail_2'] ) {
280 $properties['mail_2'] = wpcf7_sanitize_mail( $args['mail_2'] );
281 }
282
283 if ( null !== $args['messages'] ) {
284 $properties['messages'] = wpcf7_sanitize_messages( $args['messages'] );
285 }
286
287 if ( null !== $args['additional_settings'] ) {
288 $properties['additional_settings'] = wpcf7_sanitize_additional_settings(
289 $args['additional_settings']
290 );
291 }
292
293 $contact_form->set_properties( $properties );
294
295 do_action( 'wpcf7_save_contact_form', $contact_form, $args, $context );
296
297 if ( 'save' == $context ) {
298 $contact_form->save();
299 }
300
301 return $contact_form;
302 }
303
304
305 /**
306 * Sanitizes the form property data.
307 */
308 function wpcf7_sanitize_form( $input, $default_template = '' ) {
309 if ( null === $input ) {
310 return $default_template;
311 }
312
313 $output = trim( $input );
314
315 if ( ! current_user_can( 'unfiltered_html' ) ) {
316 $output = wpcf7_kses( $output, 'form' );
317 }
318
319 return $output;
320 }
321
322
323 /**
324 * Sanitizes the mail property data.
325 */
326 function wpcf7_sanitize_mail( $input, $defaults = array() ) {
327 $input = wp_parse_args( $input, array(
328 'active' => false,
329 'subject' => '',
330 'sender' => '',
331 'recipient' => '',
332 'body' => '',
333 'additional_headers' => '',
334 'attachments' => '',
335 'use_html' => false,
336 'exclude_blank' => false,
337 ) );
338
339 $input = wp_parse_args( $input, $defaults );
340
341 $output = array();
342 $output['active'] = (bool) $input['active'];
343 $output['subject'] = trim( $input['subject'] );
344 $output['sender'] = trim( $input['sender'] );
345 $output['recipient'] = trim( $input['recipient'] );
346 $output['body'] = trim( $input['body'] );
347
348 if ( ! current_user_can( 'unfiltered_html' ) ) {
349 $output['body'] = wpcf7_kses( $output['body'], 'mail' );
350 }
351
352 $output['additional_headers'] = '';
353
354 $headers = str_replace( "\r\n", "\n", $input['additional_headers'] );
355 $headers = explode( "\n", $headers );
356
357 foreach ( $headers as $header ) {
358 $header = trim( $header );
359
360 if ( '' !== $header ) {
361 $output['additional_headers'] .= $header . "\n";
362 }
363 }
364
365 $output['additional_headers'] = trim( $output['additional_headers'] );
366 $output['attachments'] = trim( $input['attachments'] );
367 $output['use_html'] = (bool) $input['use_html'];
368 $output['exclude_blank'] = (bool) $input['exclude_blank'];
369
370 return $output;
371 }
372
373
374 /**
375 * Sanitizes the messages property data.
376 */
377 function wpcf7_sanitize_messages( $input, $defaults = array() ) {
378 $output = array();
379
380 foreach ( wpcf7_messages() as $key => $val ) {
381 if ( isset( $input[$key] ) ) {
382 $output[$key] = trim( $input[$key] );
383 } elseif ( isset( $defaults[$key] ) ) {
384 $output[$key] = $defaults[$key];
385 }
386 }
387
388 return $output;
389 }
390
391
392 /**
393 * Sanitizes the additional settings property data.
394 */
395 function wpcf7_sanitize_additional_settings( $input, $default_template = '' ) {
396 if ( null === $input ) {
397 return $default_template;
398 }
399
400 $output = trim( $input );
401 return $output;
402 }
1 <?php
2
3 class WPCF7_ContactFormTemplate {
4
5 public static function get_default( $prop = 'form' ) {
6 if ( 'form' == $prop ) {
7 $template = self::form();
8 } elseif ( 'mail' == $prop ) {
9 $template = self::mail();
10 } elseif ( 'mail_2' == $prop ) {
11 $template = self::mail_2();
12 } elseif ( 'messages' == $prop ) {
13 $template = self::messages();
14 } else {
15 $template = null;
16 }
17
18 return apply_filters( 'wpcf7_default_template', $template, $prop );
19 }
20
21 public static function form() {
22 $template = sprintf(
23 '
24 <label> %2$s
25 [text* your-name] </label>
26
27 <label> %3$s
28 [email* your-email] </label>
29
30 <label> %4$s
31 [text* your-subject] </label>
32
33 <label> %5$s %1$s
34 [textarea your-message] </label>
35
36 [submit "%6$s"]',
37 __( '(optional)', 'contact-form-7' ),
38 __( 'Your name', 'contact-form-7' ),
39 __( 'Your email', 'contact-form-7' ),
40 __( 'Subject', 'contact-form-7' ),
41 __( 'Your message', 'contact-form-7' ),
42 __( 'Submit', 'contact-form-7' )
43 );
44
45 return trim( $template );
46 }
47
48 public static function mail() {
49 $template = array(
50 'subject' => sprintf(
51 /* translators: 1: blog name, 2: [your-subject] */
52 _x( '%1$s "%2$s"', 'mail subject', 'contact-form-7' ),
53 '[_site_title]',
54 '[your-subject]'
55 ),
56 'sender' => sprintf(
57 '%s <%s>',
58 '[_site_title]',
59 self::from_email()
60 ),
61 'body' =>
62 sprintf(
63 /* translators: %s: [your-name] <[your-email]> */
64 __( 'From: %s', 'contact-form-7' ),
65 '[your-name] <[your-email]>'
66 ) . "\n"
67 . sprintf(
68 /* translators: %s: [your-subject] */
69 __( 'Subject: %s', 'contact-form-7' ),
70 '[your-subject]'
71 ) . "\n\n"
72 . __( 'Message Body:', 'contact-form-7' )
73 . "\n" . '[your-message]' . "\n\n"
74 . '-- ' . "\n"
75 . sprintf(
76 /* translators: 1: blog name, 2: blog URL */
77 __( 'This e-mail was sent from a contact form on %1$s (%2$s)', 'contact-form-7' ),
78 '[_site_title]',
79 '[_site_url]'
80 ),
81 'recipient' => '[_site_admin_email]',
82 'additional_headers' => 'Reply-To: [your-email]',
83 'attachments' => '',
84 'use_html' => 0,
85 'exclude_blank' => 0,
86 );
87
88 return $template;
89 }
90
91 public static function mail_2() {
92 $template = array(
93 'active' => false,
94 'subject' => sprintf(
95 /* translators: 1: blog name, 2: [your-subject] */
96 _x( '%1$s "%2$s"', 'mail subject', 'contact-form-7' ),
97 '[_site_title]',
98 '[your-subject]'
99 ),
100 'sender' => sprintf(
101 '%s <%s>',
102 '[_site_title]',
103 self::from_email()
104 ),
105 'body' =>
106 __( 'Message Body:', 'contact-form-7' )
107 . "\n" . '[your-message]' . "\n\n"
108 . '-- ' . "\n"
109 . sprintf(
110 /* translators: 1: blog name, 2: blog URL */
111 __( 'This e-mail was sent from a contact form on %1$s (%2$s)', 'contact-form-7' ),
112 '[_site_title]',
113 '[_site_url]'
114 ),
115 'recipient' => '[your-email]',
116 'additional_headers' => sprintf(
117 'Reply-To: %s',
118 '[_site_admin_email]'
119 ),
120 'attachments' => '',
121 'use_html' => 0,
122 'exclude_blank' => 0,
123 );
124
125 return $template;
126 }
127
128 public static function from_email() {
129 $admin_email = get_option( 'admin_email' );
130
131 if ( wpcf7_is_localhost() ) {
132 return $admin_email;
133 }
134
135 $sitename = wp_parse_url( network_home_url(), PHP_URL_HOST );
136 $sitename = strtolower( $sitename );
137
138 if ( 'www.' === substr( $sitename, 0, 4 ) ) {
139 $sitename = substr( $sitename, 4 );
140 }
141
142 if ( strpbrk( $admin_email, '@' ) === '@' . $sitename ) {
143 return $admin_email;
144 }
145
146 return 'wordpress@' . $sitename;
147 }
148
149 public static function messages() {
150 $messages = array();
151
152 foreach ( wpcf7_messages() as $key => $arr ) {
153 $messages[$key] = $arr['default'];
154 }
155
156 return $messages;
157 }
158 }
159
160 function wpcf7_messages() {
161 $messages = array(
162 'mail_sent_ok' => array(
163 'description'
164 => __( "Sender's message was sent successfully", 'contact-form-7' ),
165 'default'
166 => __( "Thank you for your message. It has been sent.", 'contact-form-7' ),
167 ),
168
169 'mail_sent_ng' => array(
170 'description'
171 => __( "Sender's message failed to send", 'contact-form-7' ),
172 'default'
173 => __( "There was an error trying to send your message. Please try again later.", 'contact-form-7' ),
174 ),
175
176 'validation_error' => array(
177 'description'
178 => __( "Validation errors occurred", 'contact-form-7' ),
179 'default'
180 => __( "One or more fields have an error. Please check and try again.", 'contact-form-7' ),
181 ),
182
183 'spam' => array(
184 'description'
185 => __( "Submission was referred to as spam", 'contact-form-7' ),
186 'default'
187 => __( "There was an error trying to send your message. Please try again later.", 'contact-form-7' ),
188 ),
189
190 'accept_terms' => array(
191 'description'
192 => __( "There are terms that the sender must accept", 'contact-form-7' ),
193 'default'
194 => __( "You must accept the terms and conditions before sending your message.", 'contact-form-7' ),
195 ),
196
197 'invalid_required' => array(
198 'description'
199 => __( "There is a field that the sender must fill in", 'contact-form-7' ),
200 'default'
201 => __( "Please fill out this field.", 'contact-form-7' ),
202 ),
203
204 'invalid_too_long' => array(
205 'description'
206 => __( "There is a field with input that is longer than the maximum allowed length", 'contact-form-7' ),
207 'default'
208 => __( "This field has a too long input.", 'contact-form-7' ),
209 ),
210
211 'invalid_too_short' => array(
212 'description'
213 => __( "There is a field with input that is shorter than the minimum allowed length", 'contact-form-7' ),
214 'default'
215 => __( "This field has a too short input.", 'contact-form-7' ),
216 ),
217 );
218
219 return apply_filters( 'wpcf7_messages', $messages );
220 }
1 <?php
2 /**
3 * Controller for front-end requests, scripts, and styles
4 */
5
6
7 add_action(
8 'parse_request',
9 'wpcf7_control_init',
10 20, 0
11 );
12
13 /**
14 * Handles a submission in non-Ajax mode.
15 */
16 function wpcf7_control_init() {
17 if ( WPCF7_Submission::is_restful() ) {
18 return;
19 }
20
21 if ( isset( $_POST['_wpcf7'] ) ) {
22 $contact_form = wpcf7_contact_form( (int) $_POST['_wpcf7'] );
23
24 if ( $contact_form ) {
25 $contact_form->submit();
26 }
27 }
28 }
29
30
31 /**
32 * Registers main scripts and styles.
33 */
34 add_action(
35 'wp_enqueue_scripts',
36 function () {
37 $assets = array();
38 $asset_file = wpcf7_plugin_path( 'includes/js/index.asset.php' );
39
40 if ( file_exists( $asset_file ) ) {
41 $assets = include( $asset_file );
42 }
43
44 $assets = wp_parse_args( $assets, array(
45 'src' => wpcf7_plugin_url( 'includes/js/index.js' ),
46 'dependencies' => array(
47 'wp-polyfill',
48 ),
49 'version' => WPCF7_VERSION,
50 'in_footer' => ( 'header' !== wpcf7_load_js() ),
51 ) );
52
53 wp_register_script(
54 'contact-form-7',
55 $assets['src'],
56 $assets['dependencies'],
57 $assets['version'],
58 $assets['in_footer']
59 );
60
61 wp_register_script(
62 'contact-form-7-html5-fallback',
63 wpcf7_plugin_url( 'includes/js/html5-fallback.js' ),
64 array( 'jquery-ui-datepicker' ),
65 WPCF7_VERSION,
66 true
67 );
68
69 if ( wpcf7_load_js() ) {
70 wpcf7_enqueue_scripts();
71 }
72
73 wp_register_style(
74 'contact-form-7',
75 wpcf7_plugin_url( 'includes/css/styles.css' ),
76 array(),
77 WPCF7_VERSION,
78 'all'
79 );
80
81 wp_register_style(
82 'contact-form-7-rtl',
83 wpcf7_plugin_url( 'includes/css/styles-rtl.css' ),
84 array(),
85 WPCF7_VERSION,
86 'all'
87 );
88
89 wp_register_style(
90 'jquery-ui-smoothness',
91 wpcf7_plugin_url(
92 'includes/js/jquery-ui/themes/smoothness/jquery-ui.min.css'
93 ),
94 array(),
95 '1.12.1',
96 'screen'
97 );
98
99 if ( wpcf7_load_css() ) {
100 wpcf7_enqueue_styles();
101 }
102 },
103 10, 0
104 );
105
106
107 /**
108 * Enqueues scripts.
109 */
110 function wpcf7_enqueue_scripts() {
111 wp_enqueue_script( 'contact-form-7' );
112
113 $wpcf7 = array(
114 'api' => array(
115 'root' => esc_url_raw( get_rest_url() ),
116 'namespace' => 'contact-form-7/v1',
117 ),
118 );
119
120 if ( defined( 'WP_CACHE' ) and WP_CACHE ) {
121 $wpcf7['cached'] = 1;
122 }
123
124 wp_localize_script( 'contact-form-7', 'wpcf7', $wpcf7 );
125
126 do_action( 'wpcf7_enqueue_scripts' );
127 }
128
129
130 /**
131 * Returns true if the main script is enqueued.
132 */
133 function wpcf7_script_is() {
134 return wp_script_is( 'contact-form-7' );
135 }
136
137
138 /**
139 * Enqueues styles.
140 */
141 function wpcf7_enqueue_styles() {
142 wp_enqueue_style( 'contact-form-7' );
143
144 if ( wpcf7_is_rtl() ) {
145 wp_enqueue_style( 'contact-form-7-rtl' );
146 }
147
148 do_action( 'wpcf7_enqueue_styles' );
149 }
150
151
152 /**
153 * Returns true if the main stylesheet is enqueued.
154 */
155 function wpcf7_style_is() {
156 return wp_style_is( 'contact-form-7' );
157 }
158
159
160 add_action(
161 'wp_enqueue_scripts',
162 'wpcf7_html5_fallback',
163 20, 0
164 );
165
166 /**
167 * Enqueues scripts and styles for the HTML5 fallback.
168 */
169 function wpcf7_html5_fallback() {
170 if ( ! wpcf7_support_html5_fallback() ) {
171 return;
172 }
173
174 if ( wpcf7_script_is() ) {
175 wp_enqueue_script( 'contact-form-7-html5-fallback' );
176 }
177
178 if ( wpcf7_style_is() ) {
179 wp_enqueue_style( 'jquery-ui-smoothness' );
180 }
181 }
1 .wpcf7-not-valid-tip {
2 direction: rtl;
3 }
4
5 .use-floating-validation-tip .wpcf7-not-valid-tip {
6 right: 1em;
7 }
8
9 .wpcf7-list-item {
10 margin: 0 1em 0 0;
11 }
1 .wpcf7 .screen-reader-response {
2 position: absolute;
3 overflow: hidden;
4 clip: rect(1px, 1px, 1px, 1px);
5 clip-path: inset(50%);
6 height: 1px;
7 width: 1px;
8 margin: -1px;
9 padding: 0;
10 border: 0;
11 word-wrap: normal !important;
12 }
13
14 .wpcf7 form .wpcf7-response-output {
15 margin: 2em 0.5em 1em;
16 padding: 0.2em 1em;
17 border: 2px solid #00a0d2; /* Blue */
18 }
19
20 .wpcf7 form.init .wpcf7-response-output,
21 .wpcf7 form.resetting .wpcf7-response-output,
22 .wpcf7 form.submitting .wpcf7-response-output {
23 display: none;
24 }
25
26 .wpcf7 form.sent .wpcf7-response-output {
27 border-color: #46b450; /* Green */
28 }
29
30 .wpcf7 form.failed .wpcf7-response-output,
31 .wpcf7 form.aborted .wpcf7-response-output {
32 border-color: #dc3232; /* Red */
33 }
34
35 .wpcf7 form.spam .wpcf7-response-output {
36 border-color: #f56e28; /* Orange */
37 }
38
39 .wpcf7 form.invalid .wpcf7-response-output,
40 .wpcf7 form.unaccepted .wpcf7-response-output,
41 .wpcf7 form.payment-required .wpcf7-response-output {
42 border-color: #ffb900; /* Yellow */
43 }
44
45 .wpcf7-form-control-wrap {
46 position: relative;
47 }
48
49 .wpcf7-not-valid-tip {
50 color: #dc3232; /* Red */
51 font-size: 1em;
52 font-weight: normal;
53 display: block;
54 }
55
56 .use-floating-validation-tip .wpcf7-not-valid-tip {
57 position: relative;
58 top: -2ex;
59 left: 1em;
60 z-index: 100;
61 border: 1px solid #dc3232;
62 background: #fff;
63 padding: .2em .8em;
64 width: 24em;
65 }
66
67 .wpcf7-list-item {
68 display: inline-block;
69 margin: 0 0 0 1em;
70 }
71
72 .wpcf7-list-item-label::before,
73 .wpcf7-list-item-label::after {
74 content: " ";
75 }
76
77 .wpcf7-spinner {
78 visibility: hidden;
79 display: inline-block;
80 background-color: #23282d; /* Dark Gray 800 */
81 opacity: 0.75;
82 width: 24px;
83 height: 24px;
84 border: none;
85 border-radius: 100%;
86 padding: 0;
87 margin: 0 24px;
88 position: relative;
89 }
90
91 form.submitting .wpcf7-spinner {
92 visibility: visible;
93 }
94
95 .wpcf7-spinner::before {
96 content: '';
97 position: absolute;
98 background-color: #fbfbfc; /* Light Gray 100 */
99 top: 4px;
100 left: 4px;
101 width: 6px;
102 height: 6px;
103 border: none;
104 border-radius: 100%;
105 transform-origin: 8px 8px;
106 animation-name: spin;
107 animation-duration: 1000ms;
108 animation-timing-function: linear;
109 animation-iteration-count: infinite;
110 }
111
112 @media (prefers-reduced-motion: reduce) {
113 .wpcf7-spinner::before {
114 animation-name: blink;
115 animation-duration: 2000ms;
116 }
117 }
118
119 @keyframes spin {
120 from {
121 transform: rotate(0deg);
122 }
123
124 to {
125 transform: rotate(360deg);
126 }
127 }
128
129 @keyframes blink {
130 from {
131 opacity: 0;
132 }
133
134 50% {
135 opacity: 1;
136 }
137
138 to {
139 opacity: 0;
140 }
141 }
142
143 .wpcf7 input[type="file"] {
144 cursor: pointer;
145 }
146
147 .wpcf7 input[type="file"]:disabled {
148 cursor: default;
149 }
150
151 .wpcf7 .wpcf7-submit:disabled {
152 cursor: not-allowed;
153 }
154
155 .wpcf7 input[type="url"],
156 .wpcf7 input[type="email"],
157 .wpcf7 input[type="tel"] {
158 direction: ltr;
159 }
1 <?php
2
3 /**
4 * Validates uploaded files and moves them to the temporary directory.
5 *
6 * @param array $file An item of `$_FILES`.
7 * @param string|array $args Optional. Arguments to control behavior.
8 * @return array|WP_Error Array of file paths, or WP_Error if validation fails.
9 */
10 function wpcf7_unship_uploaded_file( $file, $args = '' ) {
11 $args = wp_parse_args( $args, array(
12 'required' => false,
13 'filetypes' => '',
14 'limit' => MB_IN_BYTES,
15 ) );
16
17 foreach ( array( 'name', 'size', 'tmp_name', 'error' ) as $key ) {
18 if ( ! isset( $file[$key] ) ) {
19 $file[$key] = array();
20 }
21 }
22
23 $names = wpcf7_array_flatten( $file['name'] );
24 $sizes = wpcf7_array_flatten( $file['size'] );
25 $tmp_names = wpcf7_array_flatten( $file['tmp_name'] );
26 $errors = wpcf7_array_flatten( $file['error'] );
27
28 foreach ( $errors as $error ) {
29 if ( ! empty( $error ) and UPLOAD_ERR_NO_FILE !== $error ) {
30 return new WP_Error( 'wpcf7_upload_failed_php_error',
31 wpcf7_get_message( 'upload_failed_php_error' )
32 );
33 }
34 }
35
36 if ( isset( $args['schema'] ) and isset( $args['name'] ) ) {
37 $result = $args['schema']->validate( array(
38 'file' => true,
39 'field' => $args['name'],
40 ) );
41
42 if ( is_wp_error( $result ) ) {
43 return $result;
44 }
45 }
46
47 // Move uploaded file to tmp dir
48 $uploads_dir = wpcf7_upload_tmp_dir();
49 $uploads_dir = wpcf7_maybe_add_random_dir( $uploads_dir );
50
51 $uploaded_files = array();
52
53 foreach ( $names as $key => $name ) {
54 $tmp_name = $tmp_names[$key];
55
56 if ( empty( $tmp_name ) or ! is_uploaded_file( $tmp_name ) ) {
57 continue;
58 }
59
60 $filename = $name;
61 $filename = wpcf7_canonicalize( $filename, array( 'strto' => 'as-is' ) );
62 $filename = wpcf7_antiscript_file_name( $filename );
63
64 $filename = apply_filters( 'wpcf7_upload_file_name',
65 $filename, $name, $args
66 );
67
68 $filename = wp_unique_filename( $uploads_dir, $filename );
69 $new_file = path_join( $uploads_dir, $filename );
70
71 if ( false === @move_uploaded_file( $tmp_name, $new_file ) ) {
72 return new WP_Error( 'wpcf7_upload_failed',
73 wpcf7_get_message( 'upload_failed' )
74 );
75 }
76
77 // Make sure the uploaded file is only readable for the owner process
78 chmod( $new_file, 0400 );
79
80 $uploaded_files[] = $new_file;
81 }
82
83 return $uploaded_files;
84 }
85
86
87 add_filter(
88 'wpcf7_messages',
89 'wpcf7_file_messages',
90 10, 1
91 );
92
93 /**
94 * A wpcf7_messages filter callback that adds messages for
95 * file-uploading fields.
96 */
97 function wpcf7_file_messages( $messages ) {
98 return array_merge( $messages, array(
99 'upload_failed' => array(
100 'description' => __( "Uploading a file fails for any reason", 'contact-form-7' ),
101 'default' => __( "There was an unknown error uploading the file.", 'contact-form-7' ),
102 ),
103
104 'upload_file_type_invalid' => array(
105 'description' => __( "Uploaded file is not allowed for file type", 'contact-form-7' ),
106 'default' => __( "You are not allowed to upload files of this type.", 'contact-form-7' ),
107 ),
108
109 'upload_file_too_large' => array(
110 'description' => __( "Uploaded file is too large", 'contact-form-7' ),
111 'default' => __( "The uploaded file is too large.", 'contact-form-7' ),
112 ),
113
114 'upload_failed_php_error' => array(
115 'description' => __( "Uploading a file fails for PHP error", 'contact-form-7' ),
116 'default' => __( "There was an error uploading the file.", 'contact-form-7' ),
117 ),
118 ) );
119 }
120
121
122 add_filter(
123 'wpcf7_form_enctype',
124 'wpcf7_file_form_enctype_filter',
125 10, 1
126 );
127
128 /**
129 * A wpcf7_form_enctype filter callback that sets the enctype attribute
130 * to multipart/form-data if the form has file-uploading fields.
131 */
132 function wpcf7_file_form_enctype_filter( $enctype ) {
133 $multipart = (bool) wpcf7_scan_form_tags( array(
134 'feature' => 'file-uploading',
135 ) );
136
137 if ( $multipart ) {
138 $enctype = 'multipart/form-data';
139 }
140
141 return $enctype;
142 }
143
144
145 /**
146 * Converts a MIME type string to an array of corresponding file extensions.
147 *
148 * @param string $mime MIME type.
149 * Wildcard (*) is available for the subtype part.
150 * @return array Corresponding file extensions.
151 */
152 function wpcf7_convert_mime_to_ext( $mime ) {
153 static $mime_types = array();
154
155 $mime_types = wp_get_mime_types();
156
157 $results = array();
158
159 if ( preg_match( '%^([a-z]+)/([*]|[a-z0-9.+-]+)$%i', $mime, $matches ) ) {
160 foreach ( $mime_types as $key => $val ) {
161 if ( '*' === $matches[2] and str_starts_with( $val, $matches[1] . '/' )
162 or $val === $matches[0] ) {
163 $results = array_merge( $results, explode( '|', $key ) );
164 }
165 }
166 }
167
168 $results = array_unique( $results );
169 $results = array_filter( $results );
170 $results = array_values( $results );
171
172 return $results;
173 }
174
175
176 /**
177 * Returns a formatted list of acceptable filetypes.
178 *
179 * @param string|array $types Optional. Array of filetypes.
180 * @param string $format Optional. Pre-defined format designator.
181 * @return string Formatted list of acceptable filetypes.
182 */
183 function wpcf7_acceptable_filetypes( $types = 'default', $format = 'regex' ) {
184 if ( 'default' === $types or empty( $types ) ) {
185 $types = array(
186 'audio/*',
187 'video/*',
188 'image/*',
189 );
190 } else {
191 $types = array_map(
192 function ( $type ) {
193 if ( is_string( $type ) ) {
194 return preg_split( '/[\s|,]+/', strtolower( $type ) );
195 }
196 },
197 (array) $types
198 );
199
200 $types = wpcf7_array_flatten( $types );
201 $types = array_filter( array_unique( $types ) );
202 }
203
204 if ( 'attr' === $format or 'attribute' === $format ) {
205 $types = array_map(
206 function ( $type ) {
207 if ( false === strpos( $type, '/' ) ) {
208 return sprintf( '.%s', trim( $type, '.' ) );
209 } elseif ( preg_match( '%^([a-z]+)/[*]$%i', $type, $matches ) ) {
210 if ( in_array( $matches[1], array( 'audio', 'video', 'image' ) ) ) {
211 return $type;
212 } else {
213 return '';
214 }
215 } elseif ( wpcf7_convert_mime_to_ext( $type ) ) {
216 return $type;
217 }
218 },
219 $types
220 );
221
222 $types = array_filter( $types );
223
224 return implode( ',', $types );
225
226 } elseif ( 'regex' === $format ) {
227 $types = array_map(
228 function ( $type ) {
229 if ( false === strpos( $type, '/' ) ) {
230 return preg_quote( trim( $type, '.' ) );
231 } elseif ( $type = wpcf7_convert_mime_to_ext( $type ) ) {
232 return $type;
233 }
234 },
235 $types
236 );
237
238 $types = wpcf7_array_flatten( $types );
239 $types = array_filter( array_unique( $types ) );
240
241 return implode( '|', $types );
242 }
243
244 return '';
245 }
246
247
248 add_action(
249 'wpcf7_init',
250 'wpcf7_init_uploads',
251 10, 0
252 );
253
254 /**
255 * Initializes the temporary directory for uploaded files.
256 */
257 function wpcf7_init_uploads() {
258 $dir = wpcf7_upload_tmp_dir();
259
260 if ( is_dir( $dir ) and is_writable( $dir ) ) {
261 $htaccess_file = path_join( $dir, '.htaccess' );
262
263 if ( ! file_exists( $htaccess_file )
264 and $handle = @fopen( $htaccess_file, 'w' ) ) {
265 fwrite( $handle, "Deny from all\n" );
266 fclose( $handle );
267 }
268 }
269 }
270
271
272 /**
273 * Creates a child directory with a randomly generated name.
274 *
275 * @param string $dir The parent directory path.
276 * @return string The child directory path if created, otherwise the parent.
277 */
278 function wpcf7_maybe_add_random_dir( $dir ) {
279 do {
280 $rand_max = mt_getrandmax();
281 $rand = zeroise( mt_rand( 0, $rand_max ), strlen( $rand_max ) );
282 $dir_new = path_join( $dir, $rand );
283 } while ( file_exists( $dir_new ) );
284
285 if ( wp_mkdir_p( $dir_new ) ) {
286 return $dir_new;
287 }
288
289 return $dir;
290 }
291
292
293 /**
294 * Returns the directory path for uploaded files.
295 *
296 * @return string Directory path.
297 */
298 function wpcf7_upload_tmp_dir() {
299 if ( defined( 'WPCF7_UPLOADS_TMP_DIR' ) ) {
300 $dir = path_join( WP_CONTENT_DIR, WPCF7_UPLOADS_TMP_DIR );
301 wp_mkdir_p( $dir );
302
303 if ( wpcf7_is_file_path_in_content_dir( $dir ) ) {
304 return $dir;
305 }
306 }
307
308 $dir = path_join( wpcf7_upload_dir( 'dir' ), 'wpcf7_uploads' );
309 wp_mkdir_p( $dir );
310 return $dir;
311 }
312
313
314 add_action(
315 'shutdown',
316 'wpcf7_cleanup_upload_files',
317 20, 0
318 );
319
320 /**
321 * Cleans up files in the temporary directory for uploaded files.
322 *
323 * @param int $seconds Files older than this are removed. Default 60.
324 * @param int $max Maximum number of files to be removed in a function call.
325 * Default 100.
326 */
327 function wpcf7_cleanup_upload_files( $seconds = 60, $max = 100 ) {
328 $dir = trailingslashit( wpcf7_upload_tmp_dir() );
329
330 if ( ! is_dir( $dir )
331 or ! is_readable( $dir )
332 or ! wp_is_writable( $dir ) ) {
333 return;
334 }
335
336 $seconds = absint( $seconds );
337 $max = absint( $max );
338 $count = 0;
339
340 if ( $handle = opendir( $dir ) ) {
341 while ( false !== ( $file = readdir( $handle ) ) ) {
342 if ( '.' == $file
343 or '..' == $file
344 or '.htaccess' == $file ) {
345 continue;
346 }
347
348 $mtime = @filemtime( path_join( $dir, $file ) );
349
350 if ( $mtime and time() < $mtime + $seconds ) { // less than $seconds old
351 continue;
352 }
353
354 wpcf7_rmdir_p( path_join( $dir, $file ) );
355 $count += 1;
356
357 if ( $max <= $count ) {
358 break;
359 }
360 }
361
362 closedir( $handle );
363 }
364 }
365
366
367 add_action(
368 'wpcf7_admin_warnings',
369 'wpcf7_file_display_warning_message',
370 10, 3
371 );
372
373 /**
374 * Displays warning messages about file-uploading fields.
375 */
376 function wpcf7_file_display_warning_message( $page, $action, $object ) {
377 if ( $object instanceof WPCF7_ContactForm ) {
378 $contact_form = $object;
379 } else {
380 return;
381 }
382
383 $has_tags = (bool) $contact_form->scan_form_tags( array(
384 'feature' => 'file-uploading',
385 ) );
386
387 if ( ! $has_tags ) {
388 return;
389 }
390
391 $uploads_dir = wpcf7_upload_tmp_dir();
392
393 if ( ! is_dir( $uploads_dir ) or ! wp_is_writable( $uploads_dir ) ) {
394 $message = sprintf(
395 /* translators: %s: the path of the temporary folder */
396 __( 'This contact form has file uploading fields, but the temporary folder for the files (%s) does not exist or is not writable. You can create the folder or change its permission manually.', 'contact-form-7' ),
397 $uploads_dir
398 );
399
400 echo sprintf(
401 '<div class="notice notice-warning"><p>%s</p></div>',
402 esc_html( $message )
403 );
404 }
405 }
1 <?php
2 /**
3 * Integration API
4 *
5 * @link https://contactform7.com/integration-with-external-apis/
6 */
7
8 class WPCF7_Integration {
9
10 private static $instance;
11
12 private $services = array();
13 private $categories = array();
14
15 private function __construct() {}
16
17
18 /**
19 * Returns initially supported service categories.
20 *
21 * @return array Service categories.
22 */
23 public static function get_builtin_categories() {
24 return array(
25 'spam_protection' => __( 'Spam protection', 'contact-form-7' ),
26 'email_marketing' => __( 'Email marketing', 'contact-form-7' ),
27 'payments' => __( 'Payments', 'contact-form-7' ),
28 );
29 }
30
31
32 /**
33 * Returns the singleton instance of this class.
34 *
35 * @return WPCF7_Integration The instance.
36 */
37 public static function get_instance() {
38 if ( empty( self::$instance ) ) {
39 self::$instance = new self;
40 self::$instance->categories = self::get_builtin_categories();
41 }
42
43 return self::$instance;
44 }
45
46
47 /**
48 * Adds a service to the services list.
49 */
50 public function add_service( $name, WPCF7_Service $service ) {
51 $name = sanitize_key( $name );
52
53 if ( empty( $name )
54 or isset( $this->services[$name] ) ) {
55 return false;
56 }
57
58 $this->services[$name] = $service;
59 }
60
61
62 /**
63 * Adds a service category to the categories list.
64 */
65 public function add_category( $name, $title ) {
66 $name = sanitize_key( $name );
67
68 if ( empty( $name )
69 or isset( $this->categories[$name] ) ) {
70 return false;
71 }
72
73 $this->categories[$name] = $title;
74 }
75
76
77 /**
78 * Returns true if a service with the name exists in the services list.
79 *
80 * @param string $name The name of service to search.
81 */
82 public function service_exists( $name = '' ) {
83 if ( '' == $name ) {
84 return (bool) count( $this->services );
85 } else {
86 return isset( $this->services[$name] );
87 }
88 }
89
90
91 /**
92 * Returns a service object with the name.
93 *
94 * @param string $name The name of service.
95 * @return WPCF7_Service|bool The service object if it exists,
96 * false otherwise.
97 */
98 public function get_service( $name ) {
99 if ( $this->service_exists( $name ) ) {
100 return $this->services[$name];
101 } else {
102 return false;
103 }
104 }
105
106
107 /**
108 * Prints services list.
109 */
110 public function list_services( $args = '' ) {
111 $args = wp_parse_args( $args, array(
112 'include' => array(),
113 ) );
114
115 $singular = false;
116 $services = (array) $this->services;
117
118 if ( ! empty( $args['include'] ) ) {
119 $services = array_intersect_key( $services,
120 array_flip( (array) $args['include'] )
121 );
122
123 if ( 1 == count( $services ) ) {
124 $singular = true;
125 }
126 }
127
128 if ( empty( $services ) ) {
129 return;
130 }
131
132 $action = wpcf7_current_action();
133
134 foreach ( $services as $name => $service ) {
135 $cats = array_intersect_key( $this->categories,
136 array_flip( $service->get_categories() )
137 );
138 ?>
139 <div class="card<?php echo $service->is_active() ? ' active' : ''; ?>" id="<?php echo esc_attr( $name ); ?>">
140 <?php $service->icon(); ?>
141 <h2 class="title"><?php echo esc_html( $service->get_title() ); ?></h2>
142 <div class="infobox">
143 <?php echo esc_html( implode( ', ', $cats ) ); ?>
144 </div>
145 <br class="clear" />
146
147 <div class="inside">
148 <?php
149 if ( $singular ) {
150 $service->display( $action );
151 } else {
152 $service->display();
153 }
154 ?>
155 </div>
156 </div>
157 <?php
158 }
159 }
160
161 }
162
163
164 /**
165 * Abstract class for services.
166 *
167 * Only instances of this class's subclasses are allowed to be
168 * listed on the Integration page.
169 */
170 abstract class WPCF7_Service {
171
172 abstract public function get_title();
173 abstract public function is_active();
174
175
176 public function get_categories() {
177 return array();
178 }
179
180
181 public function icon() {
182 return '';
183 }
184
185
186 public function link() {
187 return '';
188 }
189
190
191 public function load( $action = '' ) {
192 }
193
194
195 public function display( $action = '' ) {
196 }
197
198
199 public function admin_notice( $message = '' ) {
200 }
201
202 }
203
204
205 /**
206 * Class for services that use OAuth.
207 *
208 * While this is not an abstract class, subclassing this class for
209 * your aim is advised.
210 */
211 class WPCF7_Service_OAuth2 extends WPCF7_Service {
212
213 protected $client_id = '';
214 protected $client_secret = '';
215 protected $access_token = '';
216 protected $refresh_token = '';
217 protected $authorization_endpoint = 'https://example.com/authorization';
218 protected $token_endpoint = 'https://example.com/token';
219
220
221 public function get_title() {
222 return '';
223 }
224
225
226 public function is_active() {
227 return ! empty( $this->refresh_token );
228 }
229
230
231 protected function save_data() {
232 }
233
234
235 protected function reset_data() {
236 }
237
238
239 protected function get_redirect_uri() {
240 return admin_url();
241 }
242
243
244 protected function menu_page_url( $args = '' ) {
245 return menu_page_url( 'wpcf7-integration', false );
246 }
247
248
249 public function load( $action = '' ) {
250 if ( 'auth_redirect' == $action ) {
251 $code = isset( $_GET['code'] ) ? $_GET['code'] : '';
252
253 if ( $code ) {
254 $this->request_token( $code );
255 }
256
257 if ( ! empty( $this->access_token ) ) {
258 $message = 'success';
259 } else {
260 $message = 'failed';
261 }
262
263 wp_safe_redirect( $this->menu_page_url(
264 array(
265 'action' => 'setup',
266 'message' => $message,
267 )
268 ) );
269
270 exit();
271 }
272 }
273
274
275 protected function authorize( $scope = '' ) {
276 $endpoint = add_query_arg(
277 array(
278 'response_type' => 'code',
279 'client_id' => $this->client_id,
280 'redirect_uri' => urlencode( $this->get_redirect_uri() ),
281 'scope' => $scope,
282 ),
283 $this->authorization_endpoint
284 );
285
286 if ( wp_redirect( esc_url_raw( $endpoint ) ) ) {
287 exit();
288 }
289 }
290
291
292 protected function get_http_authorization_header( $scheme = 'basic' ) {
293 $scheme = strtolower( trim( $scheme ) );
294
295 switch ( $scheme ) {
296 case 'bearer':
297 return sprintf( 'Bearer %s', $this->access_token );
298 case 'basic':
299 default:
300 return sprintf( 'Basic %s',
301 base64_encode( $this->client_id . ':' . $this->client_secret )
302 );
303 }
304 }
305
306
307 protected function request_token( $authorization_code ) {
308 $endpoint = add_query_arg(
309 array(
310 'code' => $authorization_code,
311 'redirect_uri' => urlencode( $this->get_redirect_uri() ),
312 'grant_type' => 'authorization_code',
313 ),
314 $this->token_endpoint
315 );
316
317 $request = array(
318 'headers' => array(
319 'Authorization' => $this->get_http_authorization_header( 'basic' ),
320 ),
321 );
322
323 $response = wp_remote_post( esc_url_raw( $endpoint ), $request );
324 $response_code = (int) wp_remote_retrieve_response_code( $response );
325 $response_body = wp_remote_retrieve_body( $response );
326 $response_body = json_decode( $response_body, true );
327
328 if ( WP_DEBUG and 400 <= $response_code ) {
329 $this->log( $endpoint, $request, $response );
330 }
331
332 if ( 401 == $response_code ) { // Unauthorized
333 $this->access_token = null;
334 $this->refresh_token = null;
335 } else {
336 if ( isset( $response_body['access_token'] ) ) {
337 $this->access_token = $response_body['access_token'];
338 } else {
339 $this->access_token = null;
340 }
341
342 if ( isset( $response_body['refresh_token'] ) ) {
343 $this->refresh_token = $response_body['refresh_token'];
344 } else {
345 $this->refresh_token = null;
346 }
347 }
348
349 $this->save_data();
350
351 return $response;
352 }
353
354
355 protected function refresh_token() {
356 $endpoint = add_query_arg(
357 array(
358 'refresh_token' => $this->refresh_token,
359 'grant_type' => 'refresh_token',
360 ),
361 $this->token_endpoint
362 );
363
364 $request = array(
365 'headers' => array(
366 'Authorization' => $this->get_http_authorization_header( 'basic' ),
367 ),
368 );
369
370 $response = wp_remote_post( esc_url_raw( $endpoint ), $request );
371 $response_code = (int) wp_remote_retrieve_response_code( $response );
372 $response_body = wp_remote_retrieve_body( $response );
373 $response_body = json_decode( $response_body, true );
374
375 if ( WP_DEBUG and 400 <= $response_code ) {
376 $this->log( $endpoint, $request, $response );
377 }
378
379 if ( 401 == $response_code ) { // Unauthorized
380 $this->access_token = null;
381 $this->refresh_token = null;
382 } else {
383 if ( isset( $response_body['access_token'] ) ) {
384 $this->access_token = $response_body['access_token'];
385 } else {
386 $this->access_token = null;
387 }
388
389 if ( isset( $response_body['refresh_token'] ) ) {
390 $this->refresh_token = $response_body['refresh_token'];
391 }
392 }
393
394 $this->save_data();
395
396 return $response;
397 }
398
399
400 protected function remote_request( $url, $request = array() ) {
401 static $refreshed = false;
402
403 $request = wp_parse_args( $request, array() );
404
405 $request['headers'] = array_merge(
406 $request['headers'],
407 array(
408 'Authorization' => $this->get_http_authorization_header( 'bearer' ),
409 )
410 );
411
412 $response = wp_remote_request( esc_url_raw( $url ), $request );
413
414 if ( 401 === wp_remote_retrieve_response_code( $response )
415 and ! $refreshed ) {
416 $this->refresh_token();
417 $refreshed = true;
418
419 $response = $this->remote_request( $url, $request );
420 }
421
422 return $response;
423 }
424
425
426 protected function log( $url, $request, $response ) {
427 wpcf7_log_remote_request( $url, $request, $response );
428 }
429
430 }
1 ( function( $ ) {
2 $( function() {
3 var supportHtml5 = ( function() {
4 var features = {};
5 var input = document.createElement( 'input' );
6 var inputTypes = [ 'date' ];
7
8 $.each( inputTypes, function( index, value ) {
9 input.setAttribute( 'type', value );
10 features[ value ] = input.type !== 'text';
11 } );
12
13 return features;
14 } )();
15
16 if ( ! supportHtml5.date ) {
17 $( 'input.wpcf7-date[type="date"]' ).each( function() {
18 $( this ).datepicker( {
19 dateFormat: 'yy-mm-dd',
20 minDate: new Date( $( this ).attr( 'min' ) ),
21 maxDate: new Date( $( this ).attr( 'max' ) )
22 } );
23 } );
24 }
25 } );
26 } )( jQuery );
1 <?php
2
3 function wpcf7_l10n() {
4 static $l10n = array();
5
6 if ( ! empty( $l10n ) ) {
7 return $l10n;
8 }
9
10 if ( ! is_admin() ) {
11 return $l10n;
12 }
13
14 require_once( ABSPATH . 'wp-admin/includes/translation-install.php' );
15
16 $api = translations_api( 'plugins', array(
17 'slug' => 'contact-form-7',
18 'version' => WPCF7_VERSION,
19 ) );
20
21 if ( is_wp_error( $api )
22 or empty( $api['translations'] ) ) {
23 return $l10n;
24 }
25
26 foreach ( (array) $api['translations'] as $translation ) {
27 if ( ! empty( $translation['language'] )
28 and ! empty( $translation['english_name'] ) ) {
29 $l10n[$translation['language']] = $translation['english_name'];
30 }
31 }
32
33 return $l10n;
34 }
35
36 function wpcf7_is_valid_locale( $locale ) {
37 $pattern = '/^[a-z]{2,3}(?:_[a-zA-Z_]{2,})?$/';
38 return (bool) preg_match( $pattern, $locale );
39 }
40
41 function wpcf7_is_rtl( $locale = '' ) {
42 static $rtl_locales = array(
43 'ar' => 'Arabic',
44 'ary' => 'Moroccan Arabic',
45 'azb' => 'South Azerbaijani',
46 'fa_IR' => 'Persian',
47 'haz' => 'Hazaragi',
48 'he_IL' => 'Hebrew',
49 'ps' => 'Pashto',
50 'ug_CN' => 'Uighur',
51 );
52
53 if ( empty( $locale )
54 and function_exists( 'is_rtl' ) ) {
55 return is_rtl();
56 }
57
58 if ( empty( $locale ) ) {
59 $locale = determine_locale();
60 }
61
62 return isset( $rtl_locales[$locale] );
63 }
64
65 function wpcf7_load_textdomain( $locale = '' ) {
66 static $locales = array();
67
68 if ( empty( $locales ) ) {
69 $locales = array( determine_locale() );
70 }
71
72 $available_locales = array_merge(
73 array( 'en_US' ),
74 get_available_languages()
75 );
76
77 if ( ! in_array( $locale, $available_locales ) ) {
78 $locale = $locales[0];
79 }
80
81 if ( $locale === end( $locales ) ) {
82 return false;
83 } else {
84 $locales[] = $locale;
85 }
86
87 $domain = WPCF7_TEXT_DOMAIN;
88
89 if ( is_textdomain_loaded( $domain ) ) {
90 unload_textdomain( $domain );
91 }
92
93 $mofile = sprintf( '%s-%s.mo', $domain, $locale );
94
95 $domain_path = path_join( WPCF7_PLUGIN_DIR, 'languages' );
96 $loaded = load_textdomain( $domain, path_join( $domain_path, $mofile ) );
97
98 if ( ! $loaded ) {
99 $domain_path = path_join( WP_LANG_DIR, 'plugins' );
100 load_textdomain( $domain, path_join( $domain_path, $mofile ) );
101 }
102
103 return true;
104 }
1 <?php
2 /**
3 * Pipe-related classes.
4 *
5 * @link https://contactform7.com/selectable-recipient-with-pipes/
6 */
7
8
9 /**
10 * Class representing a pair of pipe.
11 */
12 class WPCF7_Pipe {
13
14 public $before = '';
15 public $after = '';
16
17 public function __construct( $text ) {
18 $text = (string) $text;
19
20 $pipe_pos = strpos( $text, '|' );
21
22 if ( false === $pipe_pos ) {
23 $this->before = $this->after = trim( $text );
24 } else {
25 $this->before = trim( substr( $text, 0, $pipe_pos ) );
26 $this->after = trim( substr( $text, $pipe_pos + 1 ) );
27 }
28 }
29 }
30
31
32 /**
33 * Class representing a list of pipes.
34 */
35 class WPCF7_Pipes {
36
37 private $pipes = array();
38
39 public function __construct( array $texts ) {
40 foreach ( $texts as $text ) {
41 $this->add_pipe( $text );
42 }
43 }
44
45 private function add_pipe( $text ) {
46 $pipe = new WPCF7_Pipe( $text );
47 $this->pipes[] = $pipe;
48 }
49
50 public function do_pipe( $input ) {
51 $input_canonical = wpcf7_canonicalize( $input, array(
52 'strto' => 'as-is',
53 ) );
54
55 foreach ( $this->pipes as $pipe ) {
56 $before_canonical = wpcf7_canonicalize( $pipe->before, array(
57 'strto' => 'as-is',
58 ) );
59
60 if ( $input_canonical === $before_canonical ) {
61 return $pipe->after;
62 }
63 }
64
65 return $input;
66 }
67
68 public function collect_befores() {
69 $befores = array();
70
71 foreach ( $this->pipes as $pipe ) {
72 $befores[] = $pipe->before;
73 }
74
75 return $befores;
76 }
77
78 public function collect_afters() {
79 $afters = array();
80
81 foreach ( $this->pipes as $pipe ) {
82 $afters[] = $pipe->after;
83 }
84
85 return $afters;
86 }
87
88 public function zero() {
89 return empty( $this->pipes );
90 }
91
92 public function random_pipe() {
93 if ( $this->zero() ) {
94 return null;
95 }
96
97 return $this->pipes[array_rand( $this->pipes )];
98 }
99
100 public function to_array() {
101 return array_map(
102 function( WPCF7_Pipe $pipe ) {
103 return array(
104 $pipe->before,
105 $pipe->after,
106 );
107 },
108 $this->pipes
109 );
110 }
111 }
1 <?php
2 /**
3 * All the functions and classes in this file are deprecated.
4 * You should not use them. The functions and classes will be
5 * removed in a later version.
6 */
7
8 function wpcf7_add_shortcode( $tag, $callback, $has_name = false ) {
9 wpcf7_deprecated_function( __FUNCTION__, '4.6', 'wpcf7_add_form_tag' );
10
11 return wpcf7_add_form_tag( $tag, $callback, $has_name );
12 }
13
14 function wpcf7_remove_shortcode( $tag ) {
15 wpcf7_deprecated_function( __FUNCTION__, '4.6', 'wpcf7_remove_form_tag' );
16
17 return wpcf7_remove_form_tag( $tag );
18 }
19
20 function wpcf7_do_shortcode( $content ) {
21 wpcf7_deprecated_function( __FUNCTION__, '4.6',
22 'wpcf7_replace_all_form_tags' );
23
24 return wpcf7_replace_all_form_tags( $content );
25 }
26
27 function wpcf7_scan_shortcode( $cond = null ) {
28 wpcf7_deprecated_function( __FUNCTION__, '4.6', 'wpcf7_scan_form_tags' );
29
30 return wpcf7_scan_form_tags( $cond );
31 }
32
33 class WPCF7_ShortcodeManager {
34
35 private static $form_tags_manager;
36
37 private function __construct() {}
38
39 public static function get_instance() {
40 wpcf7_deprecated_function( __METHOD__, '4.6',
41 'WPCF7_FormTagsManager::get_instance' );
42
43 self::$form_tags_manager = WPCF7_FormTagsManager::get_instance();
44 return new self;
45 }
46
47 public function get_scanned_tags() {
48 wpcf7_deprecated_function( __METHOD__, '4.6',
49 'WPCF7_FormTagsManager::get_scanned_tags' );
50
51 return self::$form_tags_manager->get_scanned_tags();
52 }
53
54 public function add_shortcode( $tag, $callback, $has_name = false ) {
55 wpcf7_deprecated_function( __METHOD__, '4.6',
56 'WPCF7_FormTagsManager::add' );
57
58 return self::$form_tags_manager->add( $tag, $callback, $has_name );
59 }
60
61 public function remove_shortcode( $tag ) {
62 wpcf7_deprecated_function( __METHOD__, '4.6',
63 'WPCF7_FormTagsManager::remove' );
64
65 return self::$form_tags_manager->remove( $tag );
66 }
67
68 public function normalize_shortcode( $content ) {
69 wpcf7_deprecated_function( __METHOD__, '4.6',
70 'WPCF7_FormTagsManager::normalize' );
71
72 return self::$form_tags_manager->normalize( $content );
73 }
74
75 public function do_shortcode( $content, $exec = true ) {
76 wpcf7_deprecated_function( __METHOD__, '4.6',
77 'WPCF7_FormTagsManager::replace_all' );
78
79 if ( $exec ) {
80 return self::$form_tags_manager->replace_all( $content );
81 } else {
82 return self::$form_tags_manager->scan( $content );
83 }
84 }
85
86 public function scan_shortcode( $content ) {
87 wpcf7_deprecated_function( __METHOD__, '4.6',
88 'WPCF7_FormTagsManager::scan' );
89
90 return self::$form_tags_manager->scan( $content );
91 }
92 }
93
94 class WPCF7_Shortcode extends WPCF7_FormTag {
95
96 public function __construct( $tag ) {
97 wpcf7_deprecated_function( 'WPCF7_Shortcode', '4.6', 'WPCF7_FormTag' );
98
99 parent::__construct( $tag );
100 }
101 }
1 <?php
2 /**
3 ** Special Mail Tags
4 ** https://contactform7.com/special-mail-tags/
5 **/
6
7 add_filter( 'wpcf7_special_mail_tags', 'wpcf7_special_mail_tag', 10, 4 );
8
9 /**
10 * Returns output string of a special mail-tag.
11 *
12 * @param string $output The string to be output.
13 * @param string $name The tag name of the special mail-tag.
14 * @param bool $html Whether the mail-tag is used in an HTML content.
15 * @param WPCF7_MailTag $mail_tag An object representation of the mail-tag.
16 * @return string Output of the given special mail-tag.
17 */
18 function wpcf7_special_mail_tag( $output, $name, $html, $mail_tag = null ) {
19 if ( ! $mail_tag instanceof WPCF7_MailTag ) {
20 wpcf7_doing_it_wrong(
21 sprintf( '%s()', __FUNCTION__ ),
22 __( 'The fourth parameter ($mail_tag) must be an instance of the WPCF7_MailTag class.', 'contact-form-7' ),
23 '5.2.2'
24 );
25 }
26
27 $name = preg_replace( '/^wpcf7\./', '_', $name ); // for back-compat
28
29 $submission = WPCF7_Submission::get_instance();
30
31 if ( ! $submission ) {
32 return $output;
33 }
34
35 if ( '_remote_ip' == $name ) {
36 if ( $remote_ip = $submission->get_meta( 'remote_ip' ) ) {
37 return $remote_ip;
38 } else {
39 return '';
40 }
41 }
42
43 if ( '_user_agent' == $name ) {
44 if ( $user_agent = $submission->get_meta( 'user_agent' ) ) {
45 return $html ? esc_html( $user_agent ) : $user_agent;
46 } else {
47 return '';
48 }
49 }
50
51 if ( '_url' == $name ) {
52 if ( $url = $submission->get_meta( 'url' ) ) {
53 return esc_url( $url );
54 } else {
55 return '';
56 }
57 }
58
59 if ( '_date' == $name
60 or '_time' == $name ) {
61 if ( $timestamp = $submission->get_meta( 'timestamp' ) ) {
62 if ( '_date' == $name ) {
63 return wp_date( get_option( 'date_format' ), $timestamp );
64 }
65
66 if ( '_time' == $name ) {
67 return wp_date( get_option( 'time_format' ), $timestamp );
68 }
69 }
70
71 return '';
72 }
73
74 if ( '_invalid_fields' == $name ) {
75 return count( $submission->get_invalid_fields() );
76 }
77
78 return $output;
79 }
80
81
82 add_filter( 'wpcf7_special_mail_tags', 'wpcf7_post_related_smt', 10, 4 );
83
84 /**
85 * Returns output string of a special mail-tag.
86 *
87 * @param string $output The string to be output.
88 * @param string $name The tag name of the special mail-tag.
89 * @param bool $html Whether the mail-tag is used in an HTML content.
90 * @param WPCF7_MailTag $mail_tag An object representation of the mail-tag.
91 * @return string Output of the given special mail-tag.
92 */
93 function wpcf7_post_related_smt( $output, $name, $html, $mail_tag = null ) {
94 if ( ! $mail_tag instanceof WPCF7_MailTag ) {
95 wpcf7_doing_it_wrong(
96 sprintf( '%s()', __FUNCTION__ ),
97 __( 'The fourth parameter ($mail_tag) must be an instance of the WPCF7_MailTag class.', 'contact-form-7' ),
98 '5.2.2'
99 );
100 }
101
102 if ( '_post_' != substr( $name, 0, 6 ) ) {
103 return $output;
104 }
105
106 $submission = WPCF7_Submission::get_instance();
107
108 if ( ! $submission ) {
109 return $output;
110 }
111
112 $post_id = (int) $submission->get_meta( 'container_post_id' );
113
114 if ( ! $post_id
115 or ! $post = get_post( $post_id ) ) {
116 return '';
117 }
118
119 if ( '_post_id' == $name ) {
120 return (string) $post->ID;
121 }
122
123 if ( '_post_name' == $name ) {
124 return $post->post_name;
125 }
126
127 if ( '_post_title' == $name ) {
128 return $html ? esc_html( $post->post_title ) : $post->post_title;
129 }
130
131 if ( '_post_url' == $name ) {
132 return get_permalink( $post->ID );
133 }
134
135 $user = new WP_User( $post->post_author );
136
137 if ( '_post_author' == $name ) {
138 return $user->display_name;
139 }
140
141 if ( '_post_author_email' == $name ) {
142 return $user->user_email;
143 }
144
145 return $output;
146 }
147
148
149 add_filter( 'wpcf7_special_mail_tags', 'wpcf7_site_related_smt', 10, 4 );
150
151 /**
152 * Returns output string of a special mail-tag.
153 *
154 * @param string $output The string to be output.
155 * @param string $name The tag name of the special mail-tag.
156 * @param bool $html Whether the mail-tag is used in an HTML content.
157 * @param WPCF7_MailTag $mail_tag An object representation of the mail-tag.
158 * @return string Output of the given special mail-tag.
159 */
160 function wpcf7_site_related_smt( $output, $name, $html, $mail_tag = null ) {
161 if ( ! $mail_tag instanceof WPCF7_MailTag ) {
162 wpcf7_doing_it_wrong(
163 sprintf( '%s()', __FUNCTION__ ),
164 __( 'The fourth parameter ($mail_tag) must be an instance of the WPCF7_MailTag class.', 'contact-form-7' ),
165 '5.2.2'
166 );
167 }
168
169 $filter = $html ? 'display' : 'raw';
170
171 if ( '_site_title' == $name ) {
172 $output = get_bloginfo( 'name', $filter );
173
174 if ( ! $html ) {
175 $output = wp_specialchars_decode( $output, ENT_QUOTES );
176 }
177
178 return $output;
179 }
180
181 if ( '_site_description' == $name ) {
182 $output = get_bloginfo( 'description', $filter );
183
184 if ( ! $html ) {
185 $output = wp_specialchars_decode( $output, ENT_QUOTES );
186 }
187
188 return $output;
189 }
190
191 if ( '_site_url' == $name ) {
192 return get_bloginfo( 'url', $filter );
193 }
194
195 if ( '_site_admin_email' == $name ) {
196 return get_bloginfo( 'admin_email', $filter );
197 }
198
199 return $output;
200 }
201
202
203 add_filter( 'wpcf7_special_mail_tags', 'wpcf7_user_related_smt', 10, 4 );
204
205 /**
206 * Returns output string of a special mail-tag.
207 *
208 * @param string $output The string to be output.
209 * @param string $name The tag name of the special mail-tag.
210 * @param bool $html Whether the mail-tag is used in an HTML content.
211 * @param WPCF7_MailTag $mail_tag An object representation of the mail-tag.
212 * @return string Output of the given special mail-tag.
213 */
214 function wpcf7_user_related_smt( $output, $name, $html, $mail_tag = null ) {
215 if ( ! $mail_tag instanceof WPCF7_MailTag ) {
216 wpcf7_doing_it_wrong(
217 sprintf( '%s()', __FUNCTION__ ),
218 __( 'The fourth parameter ($mail_tag) must be an instance of the WPCF7_MailTag class.', 'contact-form-7' ),
219 '5.2.2'
220 );
221 }
222
223 if ( '_user_' != substr( $name, 0, 6 )
224 or '_user_agent' == $name ) {
225 return $output;
226 }
227
228 $submission = WPCF7_Submission::get_instance();
229
230 if ( ! $submission ) {
231 return $output;
232 }
233
234 $user_id = (int) $submission->get_meta( 'current_user_id' );
235
236 if ( ! $user_id ) {
237 return '';
238 }
239
240 $primary_props = array( 'user_login', 'user_email', 'user_url' );
241 $opt = ltrim( $name, '_' );
242 $opt = in_array( $opt, $primary_props ) ? $opt : substr( $opt, 5 );
243
244 $user = new WP_User( $user_id );
245
246 if ( $user->has_prop( $opt ) ) {
247 return $user->get( $opt );
248 }
249
250 return '';
251 }
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.