| 1 |
<?php |
| 2 |
/** |
| 3 |
* Contact form module. |
| 4 |
* |
| 5 |
* @package automattic/jetpack |
| 6 |
*/ |
| 7 |
|
| 8 |
use Automattic\Jetpack\Forms\Jetpack_Forms; |
| 9 |
|
| 10 |
/** |
| 11 |
* Module Name: Contact Form |
| 12 |
* Module Description: Add a customizable contact form to any post or page using the Jetpack Form Block. |
| 13 |
* Sort Order: 15 |
| 14 |
* Recommendation Order: 14 |
| 15 |
* First Introduced: 1.3 |
| 16 |
* Requires Connection: No |
| 17 |
* Auto Activate: Yes |
| 18 |
* Module Tags: Other |
| 19 |
* Feature: Writing |
| 20 |
* 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, creator |
| 21 |
*/ |
| 22 |
|
| 23 |
/** |
| 24 |
* Load the newer Jetpack Forms package. |
| 25 |
*/ |
| 26 |
Jetpack_Forms::load_contact_form(); |
| 27 |
|
| 28 |
/** |
| 29 |
* Register Jetpack Form patterns |
| 30 |
* |
| 31 |
* @deprecated 13.4 Use Automattic\Jetpack\Forms\ContactForm\Util::register_pattern |
| 32 |
*/ |
| 33 |
function jetpack_form_register_pattern() { |
| 34 |
_deprecated_function( __METHOD__, 'jetpack-13.4', 'Automattic\Jetpack\Forms\ContactForm\Util::register_pattern' ); |
| 35 |
$category_slug = 'forms'; |
| 36 |
register_block_pattern_category( $category_slug, array( 'label' => __( 'Forms', 'jetpack' ) ) ); |
| 37 |
|
| 38 |
$patterns = array( |
| 39 |
'contact-form' => array( |
| 40 |
'title' => 'Contact Form', |
| 41 |
'blockTypes' => array( 'jetpack/contact-form' ), |
| 42 |
'categories' => array( $category_slug ), |
| 43 |
'content' => '<!-- wp:jetpack/contact-form {"style":{"spacing":{"padding":{"top":"16px","right":"16px","bottom":"16px","left":"16px"}}}} --> |
| 44 |
<div class="wp-block-jetpack-contact-form" style="padding-top:16px;padding-right:16px;padding-bottom:16px;padding-left:16px"> |
| 45 |
<!-- wp:jetpack/field-name {"required":true} /--> |
| 46 |
<!-- wp:jetpack/field-email {"required":true} /--> |
| 47 |
<!-- wp:jetpack/field-textarea /--> |
| 48 |
<!-- wp:jetpack/button {"element":"button","text":"Contact Us","lock":{"remove":true}} /--> |
| 49 |
</div> |
| 50 |
<!-- /wp:jetpack/contact-form -->', |
| 51 |
), |
| 52 |
'newsletter-form' => array( |
| 53 |
'title' => 'Newsletter Subscription Form', |
| 54 |
'blockTypes' => array( 'jetpack/contact-form' ), |
| 55 |
'categories' => array( $category_slug ), |
| 56 |
'content' => '<!-- wp:jetpack/contact-form {"style":{"spacing":{"padding":{"top":"16px","right":"16px","bottom":"16px","left":"16px"}}}} --> |
| 57 |
<div class="wp-block-jetpack-contact-form" style="padding-top:16px;padding-right:16px;padding-bottom:16px;padding-left:16px"> |
| 58 |
<!-- wp:jetpack/field-name {"required":true} /--> |
| 59 |
<!-- wp:jetpack/field-email {"required":true} /--> |
| 60 |
<!-- wp:jetpack/field-consent /--> |
| 61 |
<!-- wp:jetpack/button {"element":"button","text":"Subscribe","lock":{"remove":true}} /--> |
| 62 |
</div> |
| 63 |
<!-- /wp:jetpack/contact-form -->', |
| 64 |
), |
| 65 |
'rsvp-form' => array( |
| 66 |
'title' => 'RSVP Form', |
| 67 |
'blockTypes' => array( 'jetpack/contact-form' ), |
| 68 |
'categories' => array( $category_slug ), |
| 69 |
'content' => '<!-- wp:jetpack/contact-form {"subject":"A new RSVP from your website","style":{"spacing":{"padding":{"top":"16px","right":"16px","bottom":"16px","left":"16px"}}}} --> |
| 70 |
<div class="wp-block-jetpack-contact-form" style="padding-top:16px;padding-right:16px;padding-bottom:16px;padding-left:16px"> |
| 71 |
<!-- wp:jetpack/field-name {"required":true} /--> |
| 72 |
<!-- wp:jetpack/field-email {"required":true} /--> |
| 73 |
<!-- wp:jetpack/field-radio {"label":"Attending?","required":true,"options":["Yes","No"]} /--> |
| 74 |
<!-- wp:jetpack/field-textarea {"label":"Other Details"} /--> |
| 75 |
<!-- wp:jetpack/button {"element":"button","text":"Send RSVP","lock":{"remove":true}} /--> |
| 76 |
</div> |
| 77 |
<!-- /wp:jetpack/contact-form -->', |
| 78 |
), |
| 79 |
'registration-form' => array( |
| 80 |
'title' => 'Registration Form', |
| 81 |
'blockTypes' => array( 'jetpack/contact-form' ), |
| 82 |
'categories' => array( $category_slug ), |
| 83 |
'content' => '<!-- wp:jetpack/contact-form {"subject":"A new registration from your website","style":{"spacing":{"padding":{"top":"16px","right":"16px","bottom":"16px","left":"16px"}}}} --> |
| 84 |
<div class="wp-block-jetpack-contact-form" style="padding-top:16px;padding-right:16px;padding-bottom:16px;padding-left:16px"> |
| 85 |
<!-- wp:jetpack/field-name {"required":true} /--> |
| 86 |
<!-- wp:jetpack/field-email {"required":true} /--> |
| 87 |
<!-- wp:jetpack/field-telephone {"label":"Phone Number"} /--> |
| 88 |
<!-- wp:jetpack/field-select {"label":"How did you hear about us?","options":["Search Engine","Social Media","TV","Radio","Friend or Family"]} /--> |
| 89 |
<!-- wp:jetpack/field-textarea {"label":"Other Details"} /--> |
| 90 |
<!-- wp:jetpack/button {"element":"button","text":"Send","lock":{"remove":true}} /--> |
| 91 |
</div> |
| 92 |
<!-- /wp:jetpack/contact-form -->', |
| 93 |
), |
| 94 |
'appointment-form' => array( |
| 95 |
'title' => 'Appointment Form', |
| 96 |
'blockTypes' => array( 'jetpack/contact-form' ), |
| 97 |
'categories' => array( $category_slug ), |
| 98 |
'content' => '<!-- wp:jetpack/contact-form {"subject":"A new appointment booked from your website","style":{"spacing":{"padding":{"top":"16px","right":"16px","bottom":"16px","left":"16px"}}}} --> |
| 99 |
<div class="wp-block-jetpack-contact-form" style="padding-top:16px;padding-right:16px;padding-bottom:16px;padding-left:16px"> |
| 100 |
<!-- wp:jetpack/field-name {"required":true} /--> |
| 101 |
<!-- wp:jetpack/field-email {"required":true} /--> |
| 102 |
<!-- wp:jetpack/field-telephone {"required":true} /--> |
| 103 |
<!-- wp:jetpack/field-date {"label":"Date","required":true} /--> |
| 104 |
<!-- wp:jetpack/field-radio {"label":"Time","required":true,"options":["Morning","Afternoon"]} /--> |
| 105 |
<!-- wp:jetpack/field-textarea {"label":"Notes"} /--> |
| 106 |
<!-- wp:jetpack/button {"element":"button","text":"Book Appointment","lock":{"remove":true}} /--> |
| 107 |
</div> |
| 108 |
<!-- /wp:jetpack/contact-form -->', |
| 109 |
), |
| 110 |
'feedback-form' => array( |
| 111 |
'title' => 'Feedback Form', |
| 112 |
'blockTypes' => array( 'jetpack/contact-form' ), |
| 113 |
'categories' => array( $category_slug ), |
| 114 |
'content' => '<!-- wp:jetpack/contact-form {"subject":"New feedback received from your website","style":{"spacing":{"padding":{"top":"16px","right":"16px","bottom":"16px","left":"16px"}}}} --> |
| 115 |
<div class="wp-block-jetpack-contact-form" style="padding-top:16px;padding-right:16px;padding-bottom:16px;padding-left:16px"> |
| 116 |
<!-- wp:jetpack/field-name {"required":true} /--> |
| 117 |
<!-- wp:jetpack/field-email {"required":true} /--> |
| 118 |
<!-- wp:jetpack/field-radio {"label":"Please rate our website","required":true,"options":["1 - Very Bad","2 - Poor","3 - Average","4 - Good","5 - Excellent"]} /--> |
| 119 |
<!-- wp:jetpack/field-textarea {"label":"How could we improve?"} /--> |
| 120 |
<!-- wp:jetpack/button {"element":"button","text":"Send Feedback","lock":{"remove":true}} /--> |
| 121 |
</div> |
| 122 |
<!-- /wp:jetpack/contact-form -->', |
| 123 |
), |
| 124 |
); |
| 125 |
|
| 126 |
foreach ( $patterns as $name => $pattern ) { |
| 127 |
register_block_pattern( $name, $pattern ); |
| 128 |
} |
| 129 |
} |
| 130 |
|
| 131 |
add_action( 'init', 'jetpack_form_register_pattern' ); |
| 132 |
|