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 3.9 3.9-beta 3.9.1 3.9.2 3.9.3 4.0 4.0.1 4.0.2 4.0.3 4.1 4.1-beta 4.1.1 4.1.2 4.2 4.2-beta 4.2.1 4.2.2 4.3 4.3.1 4.4 4.4.1 4.4.2 4.5 4.5.1 4.6 4.6.1 4.7 4.8 4.8.1 4.9 4.9.1 4.9.2 5.0 5.0.1
contact-form-7 / settings.php
contact-form-7 Last commit date
admin 16 years ago images 18 years ago includes 16 years ago languages 16 years ago modules 16 years ago README.txt 16 years ago contact-form-7.js 17 years ago screenshot-1.png 16 years ago settings.php 16 years ago stylesheet-rtl.css 17 years ago stylesheet.css 17 years ago wp-contact-form-7.php 16 years ago
settings.php
318 lines
1 <?php
2
3 function wpcf7_plugin_path( $path = '' ) {
4 return path_join( WPCF7_PLUGIN_DIR, trim( $path, '/' ) );
5 }
6
7 function wpcf7_plugin_url( $path = '' ) {
8 global $wp_version;
9
10 if ( version_compare( $wp_version, '2.8', '<' ) ) { // Using WordPress 2.7
11 $path = path_join( WPCF7_PLUGIN_NAME, $path );
12 return plugins_url( $path );
13 }
14
15 return plugins_url( $path, WPCF7_PLUGIN_BASENAME );
16 }
17
18 function wpcf7_table_name() {
19 global $wpdb;
20
21 return $wpdb->prefix . "contact_form_7";
22 }
23
24 function wpcf7_table_exists() {
25 global $wpdb;
26
27 $table_name = wpcf7_table_name();
28
29 return $wpdb->get_var( "SHOW TABLES LIKE '$table_name'" ) == $table_name;
30 }
31
32 // Pre-2.8 compatibility
33 if ( ! function_exists( 'esc_js' ) ) {
34 function esc_js( $text ) {
35 return js_escape( $text );
36 }
37 }
38
39 if ( ! function_exists( 'esc_html' ) ) {
40 function esc_html( $text ) {
41 return wp_specialchars( $text );
42 }
43 }
44
45 if ( ! function_exists( 'esc_attr' ) ) {
46 function esc_attr( $text ) {
47 return attribute_escape( $text );
48 }
49 }
50
51 if ( ! function_exists( 'esc_sql' ) ) {
52 function esc_sql( $text ) {
53 global $wpdb;
54 return $wpdb->escape( $text );
55 }
56 }
57
58 require_once WPCF7_PLUGIN_DIR . '/includes/functions.php';
59 require_once WPCF7_PLUGIN_DIR . '/includes/formatting.php';
60 require_once WPCF7_PLUGIN_DIR . '/includes/pipe.php';
61 require_once WPCF7_PLUGIN_DIR . '/includes/shortcodes.php';
62 require_once WPCF7_PLUGIN_DIR . '/includes/classes.php';
63
64 if ( is_admin() )
65 require_once WPCF7_PLUGIN_DIR . '/admin/admin.php';
66
67 function wpcf7_contact_forms() {
68 global $wpdb;
69
70 $table_name = wpcf7_table_name();
71
72 return $wpdb->get_results( "SELECT cf7_unit_id as id, title FROM $table_name" );
73 }
74
75 $wpcf7_contact_form = null;
76 $wpcf7_request_uri = null;
77 $wpcf7_processing_within = null;
78 $wpcf7_unit_count = null;
79 $wpcf7_widget_count = null;
80
81 add_action( 'plugins_loaded', 'wpcf7_set_request_uri', 9 );
82
83 function wpcf7_set_request_uri() {
84 global $wpcf7_request_uri;
85
86 $wpcf7_request_uri = add_query_arg( array() );
87 }
88
89 function wpcf7_get_request_uri() {
90 global $wpcf7_request_uri;
91
92 return (string) $wpcf7_request_uri;
93 }
94
95 function wpcf7_ajax_json_echo() {
96 global $wpcf7_contact_form;
97
98 $echo = '';
99
100 if ( isset( $_POST['_wpcf7'] ) ) {
101 $id = (int) $_POST['_wpcf7'];
102 $unit_tag = $_POST['_wpcf7_unit_tag'];
103
104 if ( $wpcf7_contact_form = wpcf7_contact_form( $id ) ) {
105 $validation = $wpcf7_contact_form->validate();
106
107 $items = array(
108 'mailSent' => false,
109 'into' => '#' . $unit_tag,
110 'captcha' => null );
111
112 $items = apply_filters( 'wpcf7_ajax_json_echo', $items );
113
114 if ( ! $validation['valid'] ) { // Validation error occured
115 $invalids = array();
116 foreach ( $validation['reason'] as $name => $reason ) {
117 $invalids[] = array(
118 'into' => 'span.wpcf7-form-control-wrap.' . $name,
119 'message' => $reason );
120 }
121
122 $items['message'] = $wpcf7_contact_form->message( 'validation_error' );
123 $items['invalids'] = $invalids;
124
125 } elseif ( ! $wpcf7_contact_form->accepted() ) { // Not accepted terms
126 $items['message'] = $wpcf7_contact_form->message( 'accept_terms' );
127
128 } elseif ( $wpcf7_contact_form->akismet() ) { // Spam!
129 $items['message'] = $wpcf7_contact_form->message( 'akismet_says_spam' );
130 $items['spam'] = true;
131
132 } elseif ( $wpcf7_contact_form->mail() ) {
133 $items['mailSent'] = true;
134 $items['message'] = $wpcf7_contact_form->message( 'mail_sent_ok' );
135
136 $on_sent_ok = $wpcf7_contact_form->additional_setting( 'on_sent_ok', false );
137 if ( ! empty( $on_sent_ok ) ) {
138 $on_sent_ok = array_map( 'wpcf7_strip_quote', $on_sent_ok );
139 } else {
140 $on_sent_ok = null;
141 }
142 $items['onSentOk'] = $on_sent_ok;
143
144 do_action_ref_array( 'wpcf7_mail_sent', array( &$wpcf7_contact_form ) );
145
146 } else {
147 $items['message'] = $wpcf7_contact_form->message( 'mail_sent_ng' );
148 }
149
150 // remove upload files
151 foreach ( (array) $wpcf7_contact_form->uploaded_files as $name => $path ) {
152 @unlink( $path );
153 }
154
155 $wpcf7_contact_form = null;
156 }
157 }
158
159 $echo = wpcf7_json( $items );
160
161 if ( $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' ) {
162 @header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
163 echo $echo;
164 } else {
165 @header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
166 echo '<textarea>' . $echo . '</textarea>';
167 }
168 }
169
170 function wpcf7_process_nonajax_submitting() {
171 global $wpcf7_contact_form;
172
173 if ( ! isset($_POST['_wpcf7'] ) )
174 return;
175
176 $id = (int) $_POST['_wpcf7'];
177
178 if ( $wpcf7_contact_form = wpcf7_contact_form( $id ) ) {
179 $validation = $wpcf7_contact_form->validate();
180
181 if ( ! $validation['valid'] ) {
182 $_POST['_wpcf7_validation_errors'] = array( 'id' => $id, 'messages' => $validation['reason'] );
183 } elseif ( ! $wpcf7_contact_form->accepted() ) { // Not accepted terms
184 $_POST['_wpcf7_mail_sent'] = array( 'id' => $id, 'ok' => false, 'message' => $wpcf7_contact_form->message( 'accept_terms' ) );
185 } elseif ( $wpcf7_contact_form->akismet() ) { // Spam!
186 $_POST['_wpcf7_mail_sent'] = array( 'id' => $id, 'ok' => false, 'message' => $wpcf7_contact_form->message( 'akismet_says_spam' ), 'spam' => true );
187 } elseif ( $wpcf7_contact_form->mail() ) {
188 $_POST['_wpcf7_mail_sent'] = array( 'id' => $id, 'ok' => true, 'message' => $wpcf7_contact_form->message( 'mail_sent_ok' ) );
189
190 do_action_ref_array( 'wpcf7_mail_sent', array( &$wpcf7_contact_form ) );
191 } else {
192 $_POST['_wpcf7_mail_sent'] = array( 'id' => $id, 'ok' => false, 'message' => $wpcf7_contact_form->message( 'mail_sent_ng' ) );
193 }
194
195 // remove upload files
196 foreach ( (array) $wpcf7_contact_form->uploaded_files as $name => $path ) {
197 @unlink( $path );
198 }
199
200 $wpcf7_contact_form = null;
201 }
202 }
203
204 function wpcf7_the_content_filter( $content ) {
205 global $wpcf7_processing_within, $wpcf7_unit_count;
206
207 $wpcf7_processing_within = 'p' . get_the_ID();
208 $wpcf7_unit_count = 0;
209
210 return $content;
211 }
212
213 add_filter( 'the_content', 'wpcf7_the_content_filter', 9 );
214
215 function wpcf7_widget_text_filter( $content ) {
216 global $wpcf7_widget_count, $wpcf7_processing_within, $wpcf7_unit_count;
217
218 $wpcf7_widget_count += 1;
219 $wpcf7_processing_within = 'w' . $wpcf7_widget_count;
220 $wpcf7_unit_count = 0;
221
222 $regex = '/\[\s*contact-form\s+(\d+(?:\s+.*)?)\]/';
223 return preg_replace_callback( $regex, 'wpcf7_widget_text_filter_callback', $content );
224 }
225
226 add_filter( 'widget_text', 'wpcf7_widget_text_filter', 9 );
227
228 function wpcf7_widget_text_filter_callback( $matches ) {
229 return do_shortcode( $matches[0] );
230 }
231
232 function wpcf7_contact_form_tag_func( $atts ) {
233 global $wpcf7_contact_form, $wpcf7_unit_count, $wpcf7_processing_within;
234
235 if ( is_string( $atts ) )
236 $atts = explode( ' ', $atts, 2 );
237
238 $atts = (array) $atts;
239
240 $id = (int) array_shift( $atts );
241
242 if ( ! ( $wpcf7_contact_form = wpcf7_contact_form( $id ) ) )
243 return '[contact-form 404 "Not Found"]';
244
245 $wpcf7_unit_count += 1;
246
247 $unit_tag = 'wpcf7-f' . $id . '-' . $wpcf7_processing_within . '-o' . $wpcf7_unit_count;
248 $wpcf7_contact_form->unit_tag = $unit_tag;
249
250 $form = $wpcf7_contact_form->form_html();
251
252 $wpcf7_contact_form = null;
253
254 return $form;
255 }
256
257 add_shortcode( 'contact-form', 'wpcf7_contact_form_tag_func' );
258
259 function wpcf7_wp_head() {
260 $stylesheet_url = wpcf7_plugin_url( 'stylesheet.css' );
261 echo '<link rel="stylesheet" href="' . $stylesheet_url . '" type="text/css" />';
262
263 if ( 'rtl' == get_bloginfo( 'text_direction' ) ) {
264 $stylesheet_rtl_url = wpcf7_plugin_url( 'stylesheet-rtl.css' );
265 echo '<link rel="stylesheet" href="' . $stylesheet_rtl_url . '" type="text/css" />';
266 }
267 }
268
269 if ( WPCF7_LOAD_CSS )
270 add_action( 'wp_head', 'wpcf7_wp_head' );
271
272 /* Loading modules */
273
274 function wpcf7_load_modules() {
275 $dir = WPCF7_PLUGIN_MODULES_DIR;
276
277 if ( ! ( is_dir( $dir ) && $dh = opendir( $dir ) ) )
278 return false;
279
280 while ( ( $module = readdir( $dh ) ) !== false ) {
281 if ( substr( $module, -4 ) == '.php' )
282 include_once $dir . '/' . $module;
283 }
284 }
285
286 add_action( 'init', 'wpcf7_load_modules' );
287
288 function wpcf7_enqueue_scripts() {
289 $in_footer = true;
290 if ( 'header' === WPCF7_LOAD_JS )
291 $in_footer = false;
292
293 wp_enqueue_script( 'contact-form-7', wpcf7_plugin_url( 'contact-form-7.js' ),
294 array('jquery', 'jquery-form'), WPCF7_VERSION, $in_footer );
295 }
296
297 if ( ! is_admin() && WPCF7_LOAD_JS )
298 add_action( 'init', 'wpcf7_enqueue_scripts' );
299
300 function wpcf7_load_plugin_textdomain() { // l10n
301 load_plugin_textdomain( 'wpcf7',
302 'wp-content/plugins/contact-form-7/languages', 'contact-form-7/languages' );
303 }
304
305 add_action( 'init', 'wpcf7_load_plugin_textdomain' );
306
307 function wpcf7_init_switch() {
308 if ( 'POST' == $_SERVER['REQUEST_METHOD'] && 1 == (int) $_POST['_wpcf7_is_ajax_call'] ) {
309 wpcf7_ajax_json_echo();
310 exit();
311 } elseif ( ! is_admin() ) {
312 wpcf7_process_nonajax_submitting();
313 }
314 }
315
316 add_action( 'init', 'wpcf7_init_switch', 11 );
317
318 ?>