source: trunk/www.guidonia.net/wp/wp-content/plugins/contact-form-7/includes/functions.php@ 44

Last change on this file since 44 was 44, checked in by luciano, 15 years ago
File size: 5.8 KB
Line 
1<?php
2
3function wpcf7_default_message( $status ) {
4 switch ( $status ) {
5 case 'mail_sent_ok':
6 return __( 'Your message was sent successfully. Thanks.', 'wpcf7' );
7 case 'mail_sent_ng':
8 return __( 'Failed to send your message. Please try later or contact administrator by other way.', 'wpcf7' );
9 case 'akismet_says_spam':
10 return __( 'Failed to send your message. Please try later or contact administrator by other way.', 'wpcf7' );
11 case 'validation_error':
12 return __( 'Validation errors occurred. Please confirm the fields and submit it again.', 'wpcf7' );
13 case 'accept_terms':
14 return __( 'Please accept the terms to proceed.', 'wpcf7' );
15 case 'invalid_email':
16 return __( 'Email address seems invalid.', 'wpcf7' );
17 case 'invalid_required':
18 return __( 'Please fill the required field.', 'wpcf7' );
19 case 'captcha_not_match':
20 return __( 'Your entered code is incorrect.', 'wpcf7' );
21 case 'quiz_answer_not_correct':
22 return __( 'Your answer is not correct.', 'wpcf7' );
23 case 'upload_failed':
24 return __( 'Failed to upload file.', 'wpcf7' );
25 case 'upload_file_type_invalid':
26 return __( 'This file type is not allowed.', 'wpcf7' );
27 case 'upload_file_too_large':
28 return __( 'This file is too large.', 'wpcf7' );
29 case 'upload_failed_php_error':
30 return __( 'Failed to upload file. Error occurred.', 'wpcf7' );
31 }
32}
33
34function wpcf7_default_form_template() {
35 $template .= '<p>' . __( 'Your Name', 'wpcf7' ) . ' ' . __( '(required)', 'wpcf7' ) . '<br />' . "\n";
36 $template .= ' [text* your-name] </p>' . "\n\n";
37 $template .= '<p>' . __( 'Your Email', 'wpcf7' ) . ' ' . __( '(required)', 'wpcf7' ) . '<br />' . "\n";
38 $template .= ' [email* your-email] </p>' . "\n\n";
39 $template .= '<p>' . __( 'Subject', 'wpcf7' ) . '<br />' . "\n";
40 $template .= ' [text your-subject] </p>' . "\n\n";
41 $template .= '<p>' . __( 'Your Message', 'wpcf7' ) . '<br />' . "\n";
42 $template .= ' [textarea your-message] </p>' . "\n\n";
43 $template .= '<p>[submit "' . __( 'Send', 'wpcf7' ) . '"]</p>';
44 return $template;
45}
46
47function wpcf7_default_mail_template() {
48 $subject = '[your-subject]';
49 $sender = '[your-name] <[your-email]>';
50 $body = '[your-message]';
51 $recipient = get_option( 'admin_email' );
52 return compact( 'subject', 'sender', 'body', 'recipient' );
53}
54
55function wpcf7_default_mail_2_template() {
56 $active = false;
57 $subject = '[your-subject]';
58 $sender = '[your-name] <[your-email]>';
59 $body = '[your-message]';
60 $recipient = '[your-email]';
61 return compact( 'active', 'subject', 'sender', 'body', 'recipient' );
62}
63
64function wpcf7_default_messages_template() {
65 $mail_sent_ok = wpcf7_default_message( 'mail_sent_ok' );
66 $mail_sent_ng = wpcf7_default_message( 'mail_sent_ng' );
67 $akismet_says_spam = wpcf7_default_message( 'akismet_says_spam' );
68 $validation_error = wpcf7_default_message( 'validation_error' );
69 $accept_terms = wpcf7_default_message( 'accept_terms' );
70 $invalid_email = wpcf7_default_message( 'invalid_email' );
71 $invalid_required = wpcf7_default_message( 'invalid_required' );
72 $quiz_answer_not_correct = wpcf7_default_message( 'quiz_answer_not_correct' );
73 $captcha_not_match = wpcf7_default_message( 'captcha_not_match' );
74 $upload_failed = wpcf7_default_message( 'upload_failed' );
75 $upload_file_type_invalid = wpcf7_default_message( 'upload_file_type_invalid' );
76 $upload_file_too_large = wpcf7_default_message( 'upload_file_too_large' );
77
78 return compact( 'mail_sent_ok', 'mail_sent_ng', 'akismet_says_spam',
79 'validation_error', 'accept_terms', 'invalid_email', 'invalid_required', 'quiz_answer_not_correct',
80 'captcha_not_match', 'upload_failed', 'upload_file_type_invalid', 'upload_file_too_large' );
81}
82
83function wpcf7_upload_dir( $type = false ) {
84 $siteurl = get_option( 'siteurl' );
85 $upload_path = trim( get_option( 'upload_path' ) );
86 if ( empty( $upload_path ) )
87 $dir = WP_CONTENT_DIR . '/uploads';
88 else
89 $dir = $upload_path;
90
91 $dir = path_join( ABSPATH, $dir );
92
93 if ( ! $url = get_option( 'upload_url_path' ) ) {
94 if ( empty( $upload_path ) || $upload_path == $dir )
95 $url = WP_CONTENT_URL . '/uploads';
96 else
97 $url = trailingslashit( $siteurl ) . $upload_path;
98 }
99
100 if ( defined( 'UPLOADS' ) ) {
101 $dir = ABSPATH . UPLOADS;
102 $url = trailingslashit( $siteurl ) . UPLOADS;
103 }
104
105 if ( 'dir' == $type )
106 return $dir;
107 if ( 'url' == $type )
108 return $url;
109 return array( 'dir' => $dir, 'url' => $url );
110}
111
112function wpcf7_captcha_tmp_dir() {
113 if ( defined( 'WPCF7_CAPTCHA_TMP_DIR' ) )
114 return WPCF7_CAPTCHA_TMP_DIR;
115 else
116 return wpcf7_upload_dir( 'dir' ) . '/wpcf7_captcha';
117}
118
119function wpcf7_captcha_tmp_url() {
120 if ( defined( 'WPCF7_CAPTCHA_TMP_URL' ) )
121 return WPCF7_CAPTCHA_TMP_URL;
122 else
123 return wpcf7_upload_dir( 'url' ) . '/wpcf7_captcha';
124}
125
126function wpcf7_upload_tmp_dir() {
127 if ( defined( 'WPCF7_UPLOADS_TMP_DIR' ) )
128 return WPCF7_UPLOADS_TMP_DIR;
129 else
130 return wpcf7_upload_dir( 'dir' ) . '/wpcf7_uploads';
131}
132
133function wpcf7_json( $items ) {
134 if ( is_array( $items ) ) {
135 if ( empty( $items ) )
136 return 'null';
137
138 $keys = array_keys( $items );
139 $all_int = true;
140 foreach ( $keys as $key ) {
141 if ( ! is_int( $key ) ) {
142 $all_int = false;
143 break;
144 }
145 }
146
147 if ( $all_int ) {
148 $children = array();
149 foreach ( $items as $item ) {
150 $children[] = wpcf7_json( $item );
151 }
152 return '[' . join( ', ', $children ) . ']';
153 } else { // Object
154 $children = array();
155 foreach ( $items as $key => $item ) {
156 $key = esc_js( (string) $key );
157 if ( preg_match( '/[^a-zA-Z]/', $key ) )
158 $key = '"' . $key . '"';
159
160 $children[] = $key . ': ' . wpcf7_json( $item );
161 }
162 return '{ ' . join( ', ', $children ) . ' }';
163 }
164 } elseif ( is_numeric( $items ) ) {
165 return (string) $items;
166 } elseif ( is_bool( $items ) ) {
167 return $items ? '1' : '0';
168 } elseif ( is_null( $items ) ) {
169 return 'null';
170 } else {
171 return '"' . esc_js( (string) $items ) . '"';
172 }
173}
174
175?>
Note: See TracBrowser for help on using the repository browser.