PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 11.7.2
Jetpack – WP Security, Backup, Speed, & Growth v11.7.2
16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 13.9.2 14.0.1 14.1.1 14.2.2 14.3.1 All 501 releases
jetpack / modules / contact-form.php

contact-form.php in Jetpack – WP Security, Backup, Speed, & Growth 11.7.2, at modules/contact-form.php

139 lines 7.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Contact form module.
4 *
5 * @package automattic/jetpack
6 */
7
8 /**
9 * Module Name: Contact Form
10 * Module Description: Add a customizable contact form to any post or page using the Jetpack Form Block.
11 * Sort Order: 15
12 * Recommendation Order: 14
13 * First Introduced: 1.3
14 * Requires Connection: No
15 * Auto Activate: Yes
16 * Module Tags: Other
17 * Feature: Writing
18 * Additional Search Queries: contact, form, grunion, feedback, submission, contact form, email, feedback, contact form plugin, custom form, custom form plugin, form builder, forms, form maker, survey, contact by jetpack, contact us, forms free
19 */
20
21 require_once __DIR__ . '/contact-form/grunion-contact-form.php';
22
23 /*
24 * Filters if the new Contact Form Editor View should be used.
25 *
26 * A temporary filter to disable the new Editor View for the older UI.
27 * Please note this filter and the old UI will be removed in the future.
28 * Expected to be removed in Jetpack 5.8 or if a security issue merits removing the old code sooner.
29 *
30 * @since 5.2.0
31 *
32 * @param boolean $view Use new Editor View. Default true.
33 */
34 if ( is_admin() && apply_filters( 'tmp_grunion_allow_editor_view', true ) ) {
35 require_once __DIR__ . '/contact-form/grunion-editor-view.php';
36 }
37
38 /**
39 * Register Jetpack Form patterns
40 */
41 function jetpack_form_register_pattern() {
42 $category_slug = 'forms';
43 register_block_pattern_category( $category_slug, array( 'label' => __( 'Forms', 'jetpack' ) ) );
44
45 $patterns = array(
46 'contact-form' => array(
47 'title' => 'Contact Form',
48 'blockTypes' => array( 'jetpack/contact-form' ),
49 'categories' => array( $category_slug ),
50 'content' => '<!-- wp:jetpack/contact-form {"style":{"spacing":{"padding":{"top":"16px","right":"16px","bottom":"16px","left":"16px"}}}} -->
51 <div class="wp-block-jetpack-contact-form" style="padding-top:16px;padding-right:16px;padding-bottom:16px;padding-left:16px">
52 <!-- wp:jetpack/field-name {"required":true} /-->
53 <!-- wp:jetpack/field-email {"required":true} /-->
54 <!-- wp:jetpack/field-textarea /-->
55 <!-- wp:jetpack/button {"element":"button","text":"Contact Us","lock":{"remove":true}} /-->
56 </div>
57 <!-- /wp:jetpack/contact-form -->',
58 ),
59 'newsletter-form' => array(
60 'title' => 'Newsletter Subscription Form',
61 'blockTypes' => array( 'jetpack/contact-form' ),
62 'categories' => array( $category_slug ),
63 'content' => '<!-- wp:jetpack/contact-form {"style":{"spacing":{"padding":{"top":"16px","right":"16px","bottom":"16px","left":"16px"}}}} -->
64 <div class="wp-block-jetpack-contact-form" style="padding-top:16px;padding-right:16px;padding-bottom:16px;padding-left:16px">
65 <!-- wp:jetpack/field-name {"required":true} /-->
66 <!-- wp:jetpack/field-email {"required":true} /-->
67 <!-- wp:jetpack/field-consent /-->
68 <!-- wp:jetpack/button {"element":"button","text":"Subscribe","lock":{"remove":true}} /-->
69 </div>
70 <!-- /wp:jetpack/contact-form -->',
71 ),
72 'rsvp-form' => array(
73 'title' => 'RSVP Form',
74 'blockTypes' => array( 'jetpack/contact-form' ),
75 'categories' => array( $category_slug ),
76 'content' => '<!-- wp:jetpack/contact-form {"subject":"A new RSVP from your website","style":{"spacing":{"padding":{"top":"16px","right":"16px","bottom":"16px","left":"16px"}}}} -->
77 <div class="wp-block-jetpack-contact-form" style="padding-top:16px;padding-right:16px;padding-bottom:16px;padding-left:16px">
78 <!-- wp:jetpack/field-name {"required":true} /-->
79 <!-- wp:jetpack/field-email {"required":true} /-->
80 <!-- wp:jetpack/field-radio {"label":"Attending?","required":true,"options":["Yes","No"]} /-->
81 <!-- wp:jetpack/field-textarea {"label":"Other Details"} /-->
82 <!-- wp:jetpack/button {"element":"button","text":"Send RSVP","lock":{"remove":true}} /-->
83 </div>
84 <!-- /wp:jetpack/contact-form -->',
85 ),
86 'registration-form' => array(
87 'title' => 'Registration Form',
88 'blockTypes' => array( 'jetpack/contact-form' ),
89 'categories' => array( $category_slug ),
90 'content' => '<!-- wp:jetpack/contact-form {"subject":"A new registration from your website","style":{"spacing":{"padding":{"top":"16px","right":"16px","bottom":"16px","left":"16px"}}}} -->
91 <div class="wp-block-jetpack-contact-form" style="padding-top:16px;padding-right:16px;padding-bottom:16px;padding-left:16px">
92 <!-- wp:jetpack/field-name {"required":true} /-->
93 <!-- wp:jetpack/field-email {"required":true} /-->
94 <!-- wp:jetpack/field-telephone {"label":"Phone Number"} /-->
95 <!-- wp:jetpack/field-select {"label":"How did you hear about us?","options":["Search Engine","Social Media","TV","Radio","Friend or Family"]} /-->
96 <!-- wp:jetpack/field-textarea {"label":"Other Details"} /-->
97 <!-- wp:jetpack/button {"element":"button","text":"Send","lock":{"remove":true}} /-->
98 </div>
99 <!-- /wp:jetpack/contact-form -->',
100 ),
101 'appointment-form' => array(
102 'title' => 'Appointment Form',
103 'blockTypes' => array( 'jetpack/contact-form' ),
104 'categories' => array( $category_slug ),
105 'content' => '<!-- wp:jetpack/contact-form {"subject":"A new appointment booked from your website","style":{"spacing":{"padding":{"top":"16px","right":"16px","bottom":"16px","left":"16px"}}}} -->
106 <div class="wp-block-jetpack-contact-form" style="padding-top:16px;padding-right:16px;padding-bottom:16px;padding-left:16px">
107 <!-- wp:jetpack/field-name {"required":true} /-->
108 <!-- wp:jetpack/field-email {"required":true} /-->
109 <!-- wp:jetpack/field-telephone {"required":true} /-->
110 <!-- wp:jetpack/field-date {"label":"Date","required":true} /-->
111 <!-- wp:jetpack/field-radio {"label":"Time","required":true,"options":["Morning","Afternoon"]} /-->
112 <!-- wp:jetpack/field-textarea {"label":"Notes"} /-->
113 <!-- wp:jetpack/button {"element":"button","text":"Book Appointment","lock":{"remove":true}} /-->
114 </div>
115 <!-- /wp:jetpack/contact-form -->',
116 ),
117 'feedback-form' => array(
118 'title' => 'Feedback Form',
119 'blockTypes' => array( 'jetpack/contact-form' ),
120 'categories' => array( $category_slug ),
121 'content' => '<!-- wp:jetpack/contact-form {"subject":"New feedback received from your website","style":{"spacing":{"padding":{"top":"16px","right":"16px","bottom":"16px","left":"16px"}}}} -->
122 <div class="wp-block-jetpack-contact-form" style="padding-top:16px;padding-right:16px;padding-bottom:16px;padding-left:16px">
123 <!-- wp:jetpack/field-name {"required":true} /-->
124 <!-- wp:jetpack/field-email {"required":true} /-->
125 <!-- wp:jetpack/field-radio {"label":"Please rate our website","required":true,"options":["1 - Very Bad","2 - Poor","3 - Average","4 - Good","5 - Excellent"]} /-->
126 <!-- wp:jetpack/field-textarea {"label":"How could we improve?"} /-->
127 <!-- wp:jetpack/button {"element":"button","text":"Send Feedback","lock":{"remove":true}} /-->
128 </div>
129 <!-- /wp:jetpack/contact-form -->',
130 ),
131 );
132
133 foreach ( $patterns as $name => $pattern ) {
134 register_block_pattern( $name, $pattern );
135 }
136 }
137
138 add_action( 'init', 'jetpack_form_register_pattern' );
139