5eced8df by Jeff Balicki

Removed contact 7

Signed-off-by: Jeff <jeff@gotenzing.com>
1 parent 94b354bf
Showing 132 changed files with 0 additions and 4916 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' => ! current_user_can( 'wpcf7_edit_contact_form', $post_id ),
106 );
107
108 echo sprintf( '<input %s />', wpcf7_format_atts( $posttitle_atts ) );
109 ?>
110 </div><!-- #titlewrap -->
111
112 <div class="inside">
113 <?php
114 if ( ! $post->initial() ) :
115 ?>
116 <p class="description">
117 <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>
118 <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>
119 </p>
120 <?php
121 if ( $old_shortcode = $post->shortcode( array( 'use_old_format' => true ) ) ) :
122 ?>
123 <p class="description">
124 <label for="wpcf7-shortcode-old"><?php echo esc_html( __( "You can also use this old-style shortcode:", 'contact-form-7' ) ); ?></label>
125 <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>
126 </p>
127 <?php
128 endif;
129 endif;
130 ?>
131 </div>
132 </div><!-- #titlediv -->
133 </div><!-- #post-body-content -->
134
135 <div id="postbox-container-1" class="postbox-container">
136 <?php if ( current_user_can( 'wpcf7_edit_contact_form', $post_id ) ) : ?>
137 <div id="submitdiv" class="postbox">
138 <h3><?php echo esc_html( __( 'Status', 'contact-form-7' ) ); ?></h3>
139 <div class="inside">
140 <div class="submitbox" id="submitpost">
141
142 <div id="minor-publishing-actions">
143
144 <div class="hidden">
145 <input type="submit" class="button-primary" name="wpcf7-save" value="<?php echo esc_attr( __( 'Save', 'contact-form-7' ) ); ?>" />
146 </div>
147
148 <?php
149 if ( ! $post->initial() ) :
150 $copy_nonce = wp_create_nonce( 'wpcf7-copy-contact-form_' . $post_id );
151 ?>
152 <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;\""; ?> />
153 <?php endif; ?>
154 </div><!-- #minor-publishing-actions -->
155
156 <div id="misc-publishing-actions">
157 <?php do_action( 'wpcf7_admin_misc_pub_section', $post_id ); ?>
158 </div><!-- #misc-publishing-actions -->
159
160 <div id="major-publishing-actions">
161
162 <?php
163 if ( ! $post->initial() ) :
164 $delete_nonce = wp_create_nonce( 'wpcf7-delete-contact-form_' . $post_id );
165 ?>
166 <div id="delete-action">
167 <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;\""; ?> />
168 </div><!-- #delete-action -->
169 <?php endif; ?>
170
171 <div id="publishing-action">
172 <span class="spinner"></span>
173 <?php wpcf7_admin_save_button( $post_id ); ?>
174 </div>
175 <div class="clear"></div>
176 </div><!-- #major-publishing-actions -->
177 </div><!-- #submitpost -->
178 </div>
179 </div><!-- #submitdiv -->
180 <?php endif; ?>
181
182 <div id="informationdiv" class="postbox">
183 <h3><?php echo esc_html( __( "Do you need help?", 'contact-form-7' ) ); ?></h3>
184 <div class="inside">
185 <p><?php echo esc_html( __( "Here are some available options to help solve your problems.", 'contact-form-7' ) ); ?></p>
186 <ol>
187 <li><?php echo sprintf(
188 /* translators: 1: FAQ, 2: Docs ("FAQ & Docs") */
189 __( '%1$s and %2$s', 'contact-form-7' ),
190 wpcf7_link(
191 __( 'https://contactform7.com/faq/', 'contact-form-7' ),
192 __( 'FAQ', 'contact-form-7' )
193 ),
194 wpcf7_link(
195 __( 'https://contactform7.com/docs/', 'contact-form-7' ),
196 __( 'docs', 'contact-form-7' )
197 )
198 ); ?></li>
199 <li><?php echo wpcf7_link(
200 __( 'https://wordpress.org/support/plugin/contact-form-7/', 'contact-form-7' ),
201 __( 'Support forums', 'contact-form-7' )
202 ); ?></li>
203 <li><?php echo wpcf7_link(
204 __( 'https://contactform7.com/custom-development/', 'contact-form-7' ),
205 __( 'Professional services', 'contact-form-7' )
206 ); ?></li>
207 </ol>
208 </div>
209 </div><!-- #informationdiv -->
210
211 </div><!-- #postbox-container-1 -->
212
213 <div id="postbox-container-2" class="postbox-container">
214 <div id="contact-form-editor">
215 <div class="keyboard-interaction"><?php
216 echo sprintf(
217 /* translators: 1: ◀ ▶ dashicon, 2: screen reader text for the dashicon */
218 esc_html( __( '%1$s %2$s keys switch panels', 'contact-form-7' ) ),
219 '<span class="dashicons dashicons-leftright" aria-hidden="true"></span>',
220 sprintf(
221 '<span class="screen-reader-text">%s</span>',
222 /* translators: screen reader text */
223 esc_html( __( '(left and right arrow)', 'contact-form-7' ) )
224 )
225 );
226 ?></div>
227
228 <?php
229
230 $editor = new WPCF7_Editor( $post );
231 $panels = array();
232
233 if ( current_user_can( 'wpcf7_edit_contact_form', $post_id ) ) {
234 $panels = array(
235 'form-panel' => array(
236 'title' => __( 'Form', 'contact-form-7' ),
237 'callback' => 'wpcf7_editor_panel_form',
238 ),
239 'mail-panel' => array(
240 'title' => __( 'Mail', 'contact-form-7' ),
241 'callback' => 'wpcf7_editor_panel_mail',
242 ),
243 'messages-panel' => array(
244 'title' => __( 'Messages', 'contact-form-7' ),
245 'callback' => 'wpcf7_editor_panel_messages',
246 ),
247 );
248
249 $additional_settings = $post->prop( 'additional_settings' );
250
251 if ( ! is_scalar( $additional_settings ) ) {
252 $additional_settings = '';
253 }
254
255 $additional_settings = trim( $additional_settings );
256 $additional_settings = explode( "\n", $additional_settings );
257 $additional_settings = array_filter( $additional_settings );
258 $additional_settings = count( $additional_settings );
259
260 $panels['additional-settings-panel'] = array(
261 'title' => $additional_settings
262 ? sprintf(
263 /* translators: %d: number of additional settings */
264 __( 'Additional Settings (%d)', 'contact-form-7' ),
265 $additional_settings )
266 : __( 'Additional Settings', 'contact-form-7' ),
267 'callback' => 'wpcf7_editor_panel_additional_settings',
268 );
269 }
270
271 $panels = apply_filters( 'wpcf7_editor_panels', $panels );
272
273 foreach ( $panels as $id => $panel ) {
274 $editor->add_panel( $id, $panel['title'], $panel['callback'] );
275 }
276
277 $editor->display();
278 ?>
279 </div><!-- #contact-form-editor -->
280
281 <?php if ( current_user_can( 'wpcf7_edit_contact_form', $post_id ) ) : ?>
282 <p class="submit"><?php wpcf7_admin_save_button( $post_id ); ?></p>
283 <?php endif; ?>
284
285 </div><!-- #postbox-container-2 -->
286
287 </div><!-- #post-body -->
288 <br class="clear" />
289 </div><!-- #poststuff -->
290 </form>
291
292 <?php endif; ?>
293
294 </div><!-- .wrap -->
295
296 <?php
297
298 $tag_generator = WPCF7_TagGenerator::get_instance();
299 $tag_generator->print_panels( $post );
300
301 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 'Brevo', 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 __( 'Brevo', '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,
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(
4 'init',
5 'wpcf7_init_block_editor_assets',
6 10, 0
7 );
8
9 function wpcf7_init_block_editor_assets() {
10 $assets = array();
11
12 $asset_file = wpcf7_plugin_path(
13 'includes/block-editor/index.asset.php'
14 );
15
16 if ( file_exists( $asset_file ) ) {
17 $assets = include( $asset_file );
18 }
19
20 $assets = wp_parse_args( $assets, array(
21 'dependencies' => array(
22 'wp-api-fetch',
23 'wp-block-editor',
24 'wp-blocks',
25 'wp-components',
26 'wp-element',
27 'wp-i18n',
28 'wp-url',
29 ),
30 'version' => WPCF7_VERSION,
31 ) );
32
33 wp_register_script(
34 'contact-form-7-block-editor',
35 wpcf7_plugin_url( 'includes/block-editor/index.js' ),
36 $assets['dependencies'],
37 $assets['version']
38 );
39
40 wp_set_script_translations(
41 'contact-form-7-block-editor',
42 'contact-form-7'
43 );
44
45 register_block_type(
46 wpcf7_plugin_path( 'includes/block-editor' ),
47 array(
48 'editor_script' => 'contact-form-7-block-editor',
49 )
50 );
51 }
52
53
54 add_action(
55 'enqueue_block_editor_assets',
56 'wpcf7_enqueue_block_editor_assets',
57 10, 0
58 );
59
60 function wpcf7_enqueue_block_editor_assets() {
61 $contact_forms = array_map(
62 static function ( $contact_form ) {
63 return array(
64 'id' => $contact_form->id(),
65 'slug' => $contact_form->name(),
66 'title' => $contact_form->title(),
67 'locale' => $contact_form->locale(),
68 );
69 },
70 WPCF7_ContactForm::find( array(
71 'posts_per_page' => 20,
72 'orderby' => 'modified',
73 'order' => 'DESC',
74 ) )
75 );
76
77 wp_add_inline_script(
78 'contact-form-7-block-editor',
79 sprintf(
80 'window.wpcf7 = {contactForms:%s};',
81 json_encode( $contact_forms )
82 ),
83 'before'
84 );
85 }
1 {
2 "$schema": "https://schemas.wp.org/trunk/block.json",
3 "apiVersion": 2,
4 "name": "contact-form-7/contact-form-selector",
5 "title": "Contact Form 7",
6 "category": "widgets",
7 "description": "Insert a contact form you have created with Contact Form 7.",
8 "keywords": [ "form" ],
9 "textdomain": "contact-form-7",
10 "attributes": {
11 "id": {
12 "type": "integer"
13 },
14 "title": {
15 "type": "string"
16 },
17 "htmlId": {
18 "type": "string"
19 },
20 "htmlName": {
21 "type": "string"
22 },
23 "htmlTitle": {
24 "type": "string"
25 },
26 "htmlClass": {
27 "type": "string"
28 },
29 "output": {
30 "enum": [ "form", "raw_form" ],
31 "default": "form"
32 }
33 },
34 "editorScript": "file:./index.js"
35 }
1 <?php
2
3 return array(
4 'dependencies' => array(
5 'wp-api-fetch',
6 'wp-block-editor',
7 'wp-blocks',
8 'wp-components',
9 'wp-element',
10 'wp-i18n',
11 'wp-url',
12 ),
13 'version' => WPCF7_VERSION,
14 );
1 (()=>{"use strict";var e={n:t=>{var l=t&&t.__esModule?()=>t.default:()=>t;return e.d(l,{a:l}),l},d:(t,l)=>{for(var a in l)e.o(l,a)&&!e.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:l[a]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.wp.element,l=window.wp.i18n,a=window.wp.blocks,r=window.wp.blockEditor,o=(0,t.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 242.5 239.46"},(0,t.createElement)("defs",null,(0,t.createElement)("clipPath",{id:"clip-path",transform:"translate(1.72)"},(0,t.createElement)("circle",{className:"cls-1",cx:"119.73",cy:"119.73",r:"116.15",fill:"none"}))),(0,t.createElement)("g",{id:"Layer_2","data-name":"Layer 2"},(0,t.createElement)("g",{id:"Layer_1","data-name":"Layer 1"},(0,t.createElement)("g",{className:"cls-2",clipPath:"url(#clip-path)"},(0,t.createElement)("circle",{className:"cls-3",cx:"121.45",cy:"119.73",r:"116.15",fill:"#33c6f4"}),(0,t.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,t.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,t.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,t.createElement)("circle",{className:"cls-6",cx:"121.45",cy:"119.73",r:"116.15",fill:"none",stroke:"#1b447e",strokeMiterlimit:"10",strokeWidth:"8px"})))),n=window.wp.components,c=window.wp.apiFetch;var s=e.n(c);const m=window.wp.url,i=e=>{let t="[contact-form-7]";return e.id&&(t=t.replace(/\]$/,` id="${e.id}"]`)),e.title&&(t=t.replace(/\]$/,` title="${e.title}"]`)),e.htmlId&&(t=t.replace(/\]$/,` html_id="${e.htmlId}"]`)),e.htmlName&&(t=t.replace(/\]$/,` html_name="${e.htmlName}"]`)),e.htmlTitle&&(t=t.replace(/\]$/,` html_title="${e.htmlTitle}"]`)),e.htmlClass&&(t=t.replace(/\]$/,` html_class="${e.htmlClass}"]`)),"raw_form"===e.output&&(t=t.replace(/\]$/,` output="${e.output}"]`)),t},d=e=>{const t=ajaxurl.replace(/\/admin-ajax\.php$/,"/admin.php");return(0,m.addQueryArgs)(t,{page:"wpcf7",post:e.id,action:"edit"})},p={from:[{type:"shortcode",tag:"contact-form-7",attributes:{id:{type:"integer",shortcode:e=>{let{named:{id:t}}=e;return parseInt(t)}},title:{type:"string",shortcode:e=>{let{named:{title:t}}=e;return t}}}}],to:[{type:"block",blocks:["core/shortcode"],transform:e=>{const t=i(e);return(0,a.createBlock)("core/shortcode",{text:t})}}]};var h;window.wpcf7=null!==(h=window.wpcf7)&&void 0!==h?h:{contactForms:[]},(0,a.registerBlockType)("contact-form-7/contact-form-selector",{icon:o,transforms:p,edit:function(e){let{attributes:a,setAttributes:o}=e;const c=e=>e.reduce(((e,t)=>e.set(t.id,t)),new Map),[i,p]=(0,t.useState)((()=>{var e;return c(null!==(e=window.wpcf7.contactForms)&&void 0!==e?e:[])}));return(0,t.createElement)(t.Fragment,null,(0,t.createElement)(r.InspectorControls,null,a.id&&(0,t.createElement)(n.PanelBody,{title:a.title},(0,t.createElement)(n.ExternalLink,{href:d(a)},(0,l.__)("Edit this contact form","contact-form-7"))),a.id&&(0,t.createElement)(n.PanelBody,{title:(0,l.__)("Form attributes","contact-form-7"),initialOpen:!1},(0,t.createElement)(n.TextControl,{label:(0,l.__)("ID","contact-form-7"),value:a.htmlId,onChange:e=>o({htmlId:e}),help:(0,l.__)("Used for the id attribute value of the form element.","contact-form-7")}),(0,t.createElement)(n.TextControl,{label:(0,l.__)("Name","contact-form-7"),value:a.htmlName,onChange:e=>o({htmlName:e}),help:(0,l.__)("Used for the name attribute value of the form element.","contact-form-7")}),(0,t.createElement)(n.TextControl,{label:(0,l.__)("Title","contact-form-7"),value:a.htmlTitle,onChange:e=>o({htmlTitle:e}),help:(0,l.__)("Used for the aria-label attribute value of the form element.","contact-form-7")}),(0,t.createElement)(n.TextControl,{label:(0,l.__)("Class","contact-form-7"),value:a.htmlClass,onChange:e=>o({htmlClass:e}),help:(0,l.__)("Used for the class attribute value of the form element.","contact-form-7")}))),(0,t.createElement)("div",(0,r.useBlockProps)({className:"components-placeholder",style:{marginTop:"28px",marginBottom:"28px"}}),(0,t.createElement)(n.ComboboxControl,{label:(0,l.__)("Select a contact form:","contact-form-7"),options:(e=>{const t=[];for(const[l,a]of e)t.push({value:l,label:a.title});return t})(i),value:a.id,onChange:e=>{var t;return o({id:parseInt(e),title:null===(t=i.get(parseInt(e)))||void 0===t?void 0:t.title})},onFilterValueChange:e=>{(async e=>s()({path:(0,m.addQueryArgs)("/contact-form-7/v1/contact-forms",{posts_per_page:20,orderby:"modified",order:"DESC",...e})}).then((e=>e)))({search:e}).then((e=>{p(c(e))}))}})))},save:e=>{let{attributes:l}=e;const a=i(l);return(0,t.createElement)("div",r.useBlockProps.save(),a)}})})();
...\ 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 WPCF7_ContactForm|WP_Post|int $post Object or post ID.
11 * @return WPCF7_ContactForm|null Contact form object. Null if unset.
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 if ( ! is_string( $title ) or '' === $title ) {
44 return null;
45 }
46
47 $contact_forms = WPCF7_ContactForm::find( array(
48 'title' => $title,
49 'posts_per_page' => 1,
50 ) );
51
52 if ( $contact_forms ) {
53 return wpcf7_contact_form( reset( $contact_forms ) );
54 }
55 }
56
57
58 /**
59 * Wrapper function of WPCF7_ContactForm::get_current().
60 *
61 * @return WPCF7_ContactForm Contact form object.
62 */
63 function wpcf7_get_current_contact_form() {
64 if ( $current = WPCF7_ContactForm::get_current() ) {
65 return $current;
66 }
67 }
68
69
70 /**
71 * Returns true if it is in the state that a non-Ajax submission is accepted.
72 */
73 function wpcf7_is_posted() {
74 if ( ! $contact_form = wpcf7_get_current_contact_form() ) {
75 return false;
76 }
77
78 return $contact_form->is_posted();
79 }
80
81
82 /**
83 * Retrieves the user input value through a non-Ajax submission.
84 *
85 * @param string $name Name of form control.
86 * @param string $default_value Optional default value.
87 * @return string The user input value through the form-control.
88 */
89 function wpcf7_get_hangover( $name, $default_value = null ) {
90 if ( ! wpcf7_is_posted() ) {
91 return $default_value;
92 }
93
94 $submission = WPCF7_Submission::get_instance();
95
96 if ( ! $submission
97 or $submission->is( 'mail_sent' ) ) {
98 return $default_value;
99 }
100
101 return isset( $_POST[$name] ) ? wp_unslash( $_POST[$name] ) : $default_value;
102 }
103
104
105 /**
106 * Retrieves an HTML snippet of validation error on the given form control.
107 *
108 * @param string $name Name of form control.
109 * @return string Validation error message in a form of HTML snippet.
110 */
111 function wpcf7_get_validation_error( $name ) {
112 if ( ! $contact_form = wpcf7_get_current_contact_form() ) {
113 return '';
114 }
115
116 return $contact_form->validation_error( $name );
117 }
118
119
120 /**
121 * Returns a reference key to a validation error message.
122 *
123 * @param string $name Name of form control.
124 * @param string $unit_tag Optional. Unit tag of the contact form.
125 * @return string Reference key code.
126 */
127 function wpcf7_get_validation_error_reference( $name, $unit_tag = '' ) {
128 if ( '' === $unit_tag ) {
129 $contact_form = wpcf7_get_current_contact_form();
130
131 if ( $contact_form and $contact_form->validation_error( $name ) ) {
132 $unit_tag = $contact_form->unit_tag();
133 } else {
134 return null;
135 }
136 }
137
138 return preg_replace( '/[^0-9a-z_-]+/i', '',
139 sprintf(
140 '%1$s-ve-%2$s',
141 $unit_tag,
142 $name
143 )
144 );
145 }
146
147
148 /**
149 * Retrieves a message for the given status.
150 */
151 function wpcf7_get_message( $status ) {
152 if ( ! $contact_form = wpcf7_get_current_contact_form() ) {
153 return '';
154 }
155
156 return $contact_form->message( $status );
157 }
158
159
160 /**
161 * Returns a class names list for a form-tag of the specified type.
162 *
163 * @param string $type Form-tag type.
164 * @param string $default_classes Optional default classes.
165 * @return string Whitespace-separated list of class names.
166 */
167 function wpcf7_form_controls_class( $type, $default_classes = '' ) {
168 $type = trim( $type );
169 $default_classes = array_filter( explode( ' ', $default_classes ) );
170
171 $classes = array_merge( array( 'wpcf7-form-control' ), $default_classes );
172
173 $typebase = rtrim( $type, '*' );
174 $required = ( '*' == substr( $type, -1 ) );
175
176 $classes[] = 'wpcf7-' . $typebase;
177
178 if ( $required ) {
179 $classes[] = 'wpcf7-validates-as-required';
180 }
181
182 $classes = array_unique( $classes );
183
184 return implode( ' ', $classes );
185 }
186
187
188 /**
189 * Callback function for the contact-form-7 shortcode.
190 */
191 function wpcf7_contact_form_tag_func( $atts, $content = null, $code = '' ) {
192 if ( is_feed() ) {
193 return '[contact-form-7]';
194 }
195
196 if ( 'contact-form-7' == $code ) {
197 $atts = shortcode_atts(
198 array(
199 'id' => 0,
200 'title' => '',
201 'html_id' => '',
202 'html_name' => '',
203 'html_title' => '',
204 'html_class' => '',
205 'output' => 'form',
206 ),
207 $atts, 'wpcf7'
208 );
209
210 $id = (int) $atts['id'];
211 $title = trim( $atts['title'] );
212
213 if ( ! $contact_form = wpcf7_contact_form( $id ) ) {
214 $contact_form = wpcf7_get_contact_form_by_title( $title );
215 }
216
217 } else {
218 if ( is_string( $atts ) ) {
219 $atts = explode( ' ', $atts, 2 );
220 }
221
222 $id = (int) array_shift( $atts );
223 $contact_form = wpcf7_get_contact_form_by_old_id( $id );
224 }
225
226 if ( ! $contact_form ) {
227 return sprintf(
228 '<p class="wpcf7-contact-form-not-found"><strong>%1$s</strong> %2$s</p>',
229 esc_html( __( 'Error:', 'contact-form-7' ) ),
230 esc_html( __( "Contact form not found.", 'contact-form-7' ) )
231 );
232 }
233
234 $callback = static function ( $contact_form, $atts ) {
235 return $contact_form->form_html( $atts );
236 };
237
238 return wpcf7_switch_locale(
239 $contact_form->locale(),
240 $callback,
241 $contact_form, $atts
242 );
243 }
244
245
246 /**
247 * Saves the contact form data.
248 */
249 function wpcf7_save_contact_form( $args = '', $context = 'save' ) {
250 $args = wp_parse_args( $args, array(
251 'id' => -1,
252 'title' => null,
253 'locale' => null,
254 'form' => null,
255 'mail' => null,
256 'mail_2' => null,
257 'messages' => null,
258 'additional_settings' => null,
259 ) );
260
261 $args = wp_unslash( $args );
262
263 $args['id'] = (int) $args['id'];
264
265 if ( -1 == $args['id'] ) {
266 $contact_form = WPCF7_ContactForm::get_template();
267 } else {
268 $contact_form = wpcf7_contact_form( $args['id'] );
269 }
270
271 if ( empty( $contact_form ) ) {
272 return false;
273 }
274
275 if ( null !== $args['title'] ) {
276 $contact_form->set_title( $args['title'] );
277 }
278
279 if ( null !== $args['locale'] ) {
280 $contact_form->set_locale( $args['locale'] );
281 }
282
283 $properties = array();
284
285 if ( null !== $args['form'] ) {
286 $properties['form'] = wpcf7_sanitize_form( $args['form'] );
287 }
288
289 if ( null !== $args['mail'] ) {
290 $properties['mail'] = wpcf7_sanitize_mail( $args['mail'] );
291 $properties['mail']['active'] = true;
292 }
293
294 if ( null !== $args['mail_2'] ) {
295 $properties['mail_2'] = wpcf7_sanitize_mail( $args['mail_2'] );
296 }
297
298 if ( null !== $args['messages'] ) {
299 $properties['messages'] = wpcf7_sanitize_messages( $args['messages'] );
300 }
301
302 if ( null !== $args['additional_settings'] ) {
303 $properties['additional_settings'] = wpcf7_sanitize_additional_settings(
304 $args['additional_settings']
305 );
306 }
307
308 $contact_form->set_properties( $properties );
309
310 do_action( 'wpcf7_save_contact_form', $contact_form, $args, $context );
311
312 if ( 'save' == $context ) {
313 $contact_form->save();
314 }
315
316 return $contact_form;
317 }
318
319
320 /**
321 * Sanitizes the form property data.
322 */
323 function wpcf7_sanitize_form( $input, $default_template = '' ) {
324 if ( null === $input ) {
325 return $default_template;
326 }
327
328 $output = trim( $input );
329
330 if ( ! current_user_can( 'unfiltered_html' ) ) {
331 $output = wpcf7_kses( $output, 'form' );
332 }
333
334 return $output;
335 }
336
337
338 /**
339 * Sanitizes the mail property data.
340 */
341 function wpcf7_sanitize_mail( $input, $defaults = array() ) {
342 $input = wp_parse_args( $input, array(
343 'active' => false,
344 'subject' => '',
345 'sender' => '',
346 'recipient' => '',
347 'body' => '',
348 'additional_headers' => '',
349 'attachments' => '',
350 'use_html' => false,
351 'exclude_blank' => false,
352 ) );
353
354 $input = wp_parse_args( $input, $defaults );
355
356 $output = array();
357 $output['active'] = (bool) $input['active'];
358 $output['subject'] = trim( $input['subject'] );
359 $output['sender'] = trim( $input['sender'] );
360 $output['recipient'] = trim( $input['recipient'] );
361 $output['body'] = trim( $input['body'] );
362
363 if ( ! current_user_can( 'unfiltered_html' ) ) {
364 $output['body'] = wpcf7_kses( $output['body'], 'mail' );
365 }
366
367 $output['additional_headers'] = '';
368
369 $headers = str_replace( "\r\n", "\n", $input['additional_headers'] );
370 $headers = explode( "\n", $headers );
371
372 foreach ( $headers as $header ) {
373 $header = trim( $header );
374
375 if ( '' !== $header ) {
376 $output['additional_headers'] .= $header . "\n";
377 }
378 }
379
380 $output['additional_headers'] = trim( $output['additional_headers'] );
381 $output['attachments'] = trim( $input['attachments'] );
382 $output['use_html'] = (bool) $input['use_html'];
383 $output['exclude_blank'] = (bool) $input['exclude_blank'];
384
385 return $output;
386 }
387
388
389 /**
390 * Sanitizes the messages property data.
391 */
392 function wpcf7_sanitize_messages( $input, $defaults = array() ) {
393 $output = array();
394
395 foreach ( wpcf7_messages() as $key => $val ) {
396 if ( isset( $input[$key] ) ) {
397 $output[$key] = trim( $input[$key] );
398 } elseif ( isset( $defaults[$key] ) ) {
399 $output[$key] = $defaults[$key];
400 }
401 }
402
403 return $output;
404 }
405
406
407 /**
408 * Sanitizes the additional settings property data.
409 */
410 function wpcf7_sanitize_additional_settings( $input, $default_template = '' ) {
411 if ( null === $input ) {
412 return $default_template;
413 }
414
415 $output = trim( $input );
416 return $output;
417 }
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 autocomplete:name] </label>
26
27 <label> %3$s
28 [email* your-email autocomplete: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 static 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 'dependencies' => array(),
46 'version' => WPCF7_VERSION,
47 ) );
48
49 wp_register_script(
50 'contact-form-7',
51 wpcf7_plugin_url( 'includes/js/index.js' ),
52 array_merge(
53 $assets['dependencies'],
54 array( 'swv' )
55 ),
56 $assets['version'],
57 true
58 );
59
60 wp_register_script(
61 'contact-form-7-html5-fallback',
62 wpcf7_plugin_url( 'includes/js/html5-fallback.js' ),
63 array( 'jquery-ui-datepicker' ),
64 WPCF7_VERSION,
65 true
66 );
67
68 if ( wpcf7_load_js() ) {
69 wpcf7_enqueue_scripts();
70 }
71
72 wp_register_style(
73 'contact-form-7',
74 wpcf7_plugin_url( 'includes/css/styles.css' ),
75 array(),
76 WPCF7_VERSION,
77 'all'
78 );
79
80 wp_register_style(
81 'contact-form-7-rtl',
82 wpcf7_plugin_url( 'includes/css/styles-rtl.css' ),
83 array( 'contact-form-7' ),
84 WPCF7_VERSION,
85 'all'
86 );
87
88 wp_register_style(
89 'jquery-ui-smoothness',
90 wpcf7_plugin_url(
91 'includes/js/jquery-ui/themes/smoothness/jquery-ui.min.css'
92 ),
93 array(),
94 '1.12.1',
95 'screen'
96 );
97
98 if ( wpcf7_load_css() ) {
99 wpcf7_enqueue_styles();
100 }
101 },
102 10, 0
103 );
104
105
106 /**
107 * Enqueues scripts.
108 */
109 function wpcf7_enqueue_scripts() {
110 wp_enqueue_script( 'contact-form-7' );
111
112 $wpcf7 = array(
113 'api' => array(
114 'root' => sanitize_url( get_rest_url() ),
115 'namespace' => 'contact-form-7/v1',
116 ),
117 );
118
119 if ( defined( 'WP_CACHE' ) and WP_CACHE ) {
120 $wpcf7['cached'] = 1;
121 }
122
123 wp_localize_script( 'contact-form-7', 'wpcf7', $wpcf7 );
124
125 do_action( 'wpcf7_enqueue_scripts' );
126 }
127
128
129 /**
130 * Returns true if the main script is enqueued.
131 */
132 function wpcf7_script_is() {
133 return wp_script_is( 'contact-form-7' );
134 }
135
136
137 /**
138 * Enqueues styles.
139 */
140 function wpcf7_enqueue_styles() {
141 wp_enqueue_style( 'contact-form-7' );
142
143 if ( wpcf7_is_rtl() ) {
144 wp_enqueue_style( 'contact-form-7-rtl' );
145 }
146
147 do_action( 'wpcf7_enqueue_styles' );
148 }
149
150
151 /**
152 * Returns true if the main stylesheet is enqueued.
153 */
154 function wpcf7_style_is() {
155 return wp_style_is( 'contact-form-7' );
156 }
157
158
159 add_action(
160 'wp_enqueue_scripts',
161 'wpcf7_html5_fallback',
162 20, 0
163 );
164
165 /**
166 * Enqueues scripts and styles for the HTML5 fallback.
167 */
168 function wpcf7_html5_fallback() {
169 if ( ! wpcf7_support_html5_fallback() ) {
170 return;
171 }
172
173 if ( wpcf7_script_is() ) {
174 wp_enqueue_script( 'contact-form-7-html5-fallback' );
175 }
176
177 if ( wpcf7_style_is() ) {
178 wp_enqueue_style( 'jquery-ui-smoothness' );
179 }
180 }
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 }
160
161 .wpcf7-reflection > output {
162 display: list-item;
163 list-style: none;
164 }
165
166 .wpcf7-reflection > output[hidden] {
167 display: none;
168 }
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( sanitize_url( $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( sanitize_url( $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( sanitize_url( $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( sanitize_url( $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 return array(
4 'dependencies' => array(),
5 'version' => WPCF7_VERSION,
6 );
1 <?php
2
3 /**
4 * Retrieves an associative array of languages to which
5 * this plugin is translated.
6 *
7 * @return array Array of languages.
8 */
9 function wpcf7_l10n() {
10 static $l10n = array();
11
12 if ( ! empty( $l10n ) ) {
13 return $l10n;
14 }
15
16 if ( ! is_admin() ) {
17 return $l10n;
18 }
19
20 require_once( ABSPATH . 'wp-admin/includes/translation-install.php' );
21
22 $api = translations_api( 'plugins', array(
23 'slug' => 'contact-form-7',
24 'version' => WPCF7_VERSION,
25 ) );
26
27 if ( is_wp_error( $api )
28 or empty( $api['translations'] ) ) {
29 return $l10n;
30 }
31
32 foreach ( (array) $api['translations'] as $translation ) {
33 if ( ! empty( $translation['language'] )
34 and ! empty( $translation['english_name'] ) ) {
35 $l10n[$translation['language']] = $translation['english_name'];
36 }
37 }
38
39 return $l10n;
40 }
41
42
43 /**
44 * Returns true if the given locale code looks valid.
45 *
46 * @param string $locale Locale code.
47 */
48 function wpcf7_is_valid_locale( $locale ) {
49 if ( ! is_string( $locale ) ) {
50 return false;
51 }
52
53 $pattern = '/^[a-z]{2,3}(?:_[a-zA-Z_]{2,})?$/';
54 return (bool) preg_match( $pattern, $locale );
55 }
56
57
58 /**
59 * Returns true if the given locale is an RTL language.
60 */
61 function wpcf7_is_rtl( $locale = '' ) {
62 static $rtl_locales = array(
63 'ar' => 'Arabic',
64 'ary' => 'Moroccan Arabic',
65 'azb' => 'South Azerbaijani',
66 'fa_IR' => 'Persian',
67 'haz' => 'Hazaragi',
68 'he_IL' => 'Hebrew',
69 'ps' => 'Pashto',
70 'ug_CN' => 'Uighur',
71 );
72
73 if ( empty( $locale )
74 and function_exists( 'is_rtl' ) ) {
75 return is_rtl();
76 }
77
78 if ( empty( $locale ) ) {
79 $locale = determine_locale();
80 }
81
82 return isset( $rtl_locales[$locale] );
83 }
84
85
86 /**
87 * Loads a translation file into the plugin's text domain.
88 *
89 * @param string $locale Locale code.
90 * @return bool True on success, false on failure.
91 */
92 function wpcf7_load_textdomain( $locale = '' ) {
93 $mofile = path_join(
94 WP_LANG_DIR . '/plugins/',
95 sprintf( '%s-%s.mo', WPCF7_TEXT_DOMAIN, $locale )
96 );
97
98 return load_textdomain( WPCF7_TEXT_DOMAIN, $mofile, $locale );
99 }
100
101
102 /**
103 * Unloads translations for the plugin's text domain.
104 *
105 * @param bool $reloadable Whether the text domain can be loaded
106 * just-in-time again.
107 * @return bool True on success, false on failure.
108 */
109 function wpcf7_unload_textdomain( $reloadable = false ) {
110 return unload_textdomain( WPCF7_TEXT_DOMAIN, $reloadable );
111 }
112
113
114 /**
115 * Switches translation locale, calls the callback, then switches back
116 * to the original locale.
117 *
118 * @param string $locale Locale code.
119 * @param callable $callback The callable to be called.
120 * @param mixed $args Parameters to be passed to the callback.
121 * @return mixed The return value of the callback.
122 */
123 function wpcf7_switch_locale( $locale, callable $callback, ...$args ) {
124 static $available_locales = null;
125
126 if ( ! isset( $available_locales ) ) {
127 $available_locales = array_merge(
128 array( 'en_US' ),
129 get_available_languages()
130 );
131 }
132
133 $previous_locale = determine_locale();
134
135 $do_switch_locale = (
136 $locale !== $previous_locale &&
137 in_array( $locale, $available_locales, true ) &&
138 in_array( $previous_locale, $available_locales, true )
139 );
140
141 if ( $do_switch_locale ) {
142 wpcf7_unload_textdomain();
143 switch_to_locale( $locale );
144 wpcf7_load_textdomain( $locale );
145 }
146
147 $result = call_user_func( $callback, ...$args );
148
149 if ( $do_switch_locale ) {
150 wpcf7_unload_textdomain( true );
151 restore_previous_locale();
152 wpcf7_load_textdomain( $previous_locale );
153 }
154
155 return $result;
156 }
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 static 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 /**
4 * Handy trait provides methods to handle dynamic properties.
5 */
6 trait WPCF7_PocketHolder {
7
8 protected $pocket = array();
9
10 public function pull( $key ) {
11 if ( isset( $this->pocket[$key] ) ) {
12 return $this->pocket[$key];
13 }
14 }
15
16 public function push( $key, $value ) {
17 $this->pocket[$key] = $value;
18 }
19
20 }
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 $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 }
1 <?php
2
3 return array(
4 'dependencies' => array(),
5 'version' => WPCF7_VERSION,
6 );
1 <?php
2
3 class WPCF7_SWV_DateRule extends WPCF7_SWV_Rule {
4
5 const rule_name = 'date';
6
7 public function matches( $context ) {
8 if ( false === parent::matches( $context ) ) {
9 return false;
10 }
11
12 if ( empty( $context['text'] ) ) {
13 return false;
14 }
15
16 return true;
17 }
18
19 public function validate( $context ) {
20 $field = $this->get_property( 'field' );
21 $input = isset( $_POST[$field] ) ? $_POST[$field] : '';
22 $input = wpcf7_array_flatten( $input );
23 $input = wpcf7_exclude_blank( $input );
24
25 foreach ( $input as $i ) {
26 if ( ! wpcf7_is_date( $i ) ) {
27 return new WP_Error( 'wpcf7_invalid_date',
28 $this->get_property( 'error' )
29 );
30 }
31 }
32
33 return true;
34 }
35
36 public function to_array() {
37 return array( 'rule' => self::rule_name ) + (array) $this->properties;
38 }
39 }