block-editor
1 year ago
config-validator
11 months ago
css
2 weeks ago
js
1 year ago
swv
9 months ago
capabilities.php
7 years ago
contact-form-functions.php
11 months ago
contact-form-template.php
11 months ago
contact-form.php
11 months ago
controller.php
11 months ago
file.php
9 months ago
filesystem.php
11 months ago
form-tag.php
7 months ago
form-tags-manager.php
11 months ago
formatting.php
11 months ago
functions.php
9 months ago
html-formatter.php
9 months ago
integration.php
11 months ago
l10n.php
11 months ago
mail-tag.php
11 months ago
mail.php
3 months ago
pipe.php
11 months ago
pocket-holder.php
3 years ago
rest-api.php
11 months ago
shortcodes.php
11 months ago
special-mail-tags.php
9 months ago
submission.php
9 months ago
upgrade.php
11 months ago
validation-functions.php
11 months ago
validation.php
11 months ago
contact-form-template.php
205 lines
| 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 is a notification that a contact form was submitted on your website (%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 email is a receipt for your contact form submission on our website (%1$s %2$s) in which your email address was used. If that was not you, please ignore this message.', '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' => __( 'Sender’s message was sent successfully', 'contact-form-7' ), |
| 164 | 'default' => __( 'Thank you for your message. It has been sent.', 'contact-form-7' ), |
| 165 | ), |
| 166 | |
| 167 | 'mail_sent_ng' => array( |
| 168 | 'description' => __( 'Sender’s message failed to send', 'contact-form-7' ), |
| 169 | 'default' => __( 'There was an error trying to send your message. Please try again later.', 'contact-form-7' ), |
| 170 | ), |
| 171 | |
| 172 | 'validation_error' => array( |
| 173 | 'description' => __( 'Validation errors occurred', 'contact-form-7' ), |
| 174 | 'default' => __( 'One or more fields have an error. Please check and try again.', 'contact-form-7' ), |
| 175 | ), |
| 176 | |
| 177 | 'spam' => array( |
| 178 | 'description' => __( 'Submission was referred to as spam', 'contact-form-7' ), |
| 179 | 'default' => __( 'There was an error trying to send your message. Please try again later.', 'contact-form-7' ), |
| 180 | ), |
| 181 | |
| 182 | 'accept_terms' => array( |
| 183 | 'description' => __( 'There are terms that the sender must accept', 'contact-form-7' ), |
| 184 | 'default' => __( 'You must accept the terms and conditions before sending your message.', 'contact-form-7' ), |
| 185 | ), |
| 186 | |
| 187 | 'invalid_required' => array( |
| 188 | 'description' => __( 'There is a field that the sender must fill in', 'contact-form-7' ), |
| 189 | 'default' => __( 'Please fill out this field.', 'contact-form-7' ), |
| 190 | ), |
| 191 | |
| 192 | 'invalid_too_long' => array( |
| 193 | 'description' => __( 'There is a field with input that is longer than the maximum allowed length', 'contact-form-7' ), |
| 194 | 'default' => __( 'This field has a too long input.', 'contact-form-7' ), |
| 195 | ), |
| 196 | |
| 197 | 'invalid_too_short' => array( |
| 198 | 'description' => __( 'There is a field with input that is shorter than the minimum allowed length', 'contact-form-7' ), |
| 199 | 'default' => __( 'This field has a too short input.', 'contact-form-7' ), |
| 200 | ), |
| 201 | ); |
| 202 | |
| 203 | return apply_filters( 'wpcf7_messages', $messages ); |
| 204 | } |
| 205 |