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.1 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 / includes / controller.php
contact-form-7 / includes Last commit date
css 11 years ago js 11 years ago capabilities.php 13 years ago contact-form-template.php 11 years ago contact-form.php 11 years ago controller.php 11 years ago formatting.php 11 years ago functions.php 11 years ago mail.php 11 years ago pipe.php 12 years ago shortcodes.php 11 years ago submission.php 11 years ago upgrade.php 11 years ago validation.php 11 years ago
controller.php
266 lines
1 <?php
2
3 add_action( 'init', 'wpcf7_control_init', 11 );
4
5 function wpcf7_control_init() {
6 if ( ! isset( $_SERVER['REQUEST_METHOD'] ) ) {
7 return;
8 }
9
10 if ( 'GET' == $_SERVER['REQUEST_METHOD'] ) {
11 if ( isset( $_GET['_wpcf7_is_ajax_call'] ) ) {
12 wpcf7_ajax_onload();
13 }
14 }
15
16 if ( 'POST' == $_SERVER['REQUEST_METHOD'] ) {
17 if ( isset( $_POST['_wpcf7_is_ajax_call'] ) ) {
18 wpcf7_ajax_json_echo();
19 }
20
21 wpcf7_submit_nonajax();
22 }
23 }
24
25 function wpcf7_ajax_onload() {
26 $echo = '';
27 $items = array();
28
29 if ( isset( $_GET['_wpcf7'] )
30 && $contact_form = wpcf7_contact_form( (int) $_GET['_wpcf7'] ) ) {
31 $items = apply_filters( 'wpcf7_ajax_onload', $items );
32 }
33
34 $echo = json_encode( $items );
35
36 if ( wpcf7_is_xhr() ) {
37 @header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
38 echo $echo;
39 }
40
41 exit();
42 }
43
44 function wpcf7_ajax_json_echo() {
45 $echo = '';
46
47 if ( isset( $_POST['_wpcf7'] ) ) {
48 $id = (int) $_POST['_wpcf7'];
49 $unit_tag = wpcf7_sanitize_unit_tag( $_POST['_wpcf7_unit_tag'] );
50
51 if ( $contact_form = wpcf7_contact_form( $id ) ) {
52 $items = array(
53 'mailSent' => false,
54 'into' => '#' . $unit_tag,
55 'captcha' => null );
56
57 $result = $contact_form->submit( true );
58
59 if ( ! empty( $result['message'] ) ) {
60 $items['message'] = $result['message'];
61 }
62
63 if ( 'mail_sent' == $result['status'] ) {
64 $items['mailSent'] = true;
65 }
66
67 if ( 'validation_failed' == $result['status'] ) {
68 $invalids = array();
69
70 foreach ( $result['invalid_fields'] as $name => $field ) {
71 $invalids[] = array(
72 'into' => 'span.wpcf7-form-control-wrap.'
73 . sanitize_html_class( $name ),
74 'message' => $field['reason'],
75 'idref' => $field['idref'] );
76 }
77
78 $items['invalids'] = $invalids;
79 }
80
81 if ( 'spam' == $result['status'] ) {
82 $items['spam'] = true;
83 }
84
85 if ( ! empty( $result['scripts_on_sent_ok'] ) ) {
86 $items['onSentOk'] = $result['scripts_on_sent_ok'];
87 }
88
89 if ( ! empty( $result['scripts_on_submit'] ) ) {
90 $items['onSubmit'] = $result['scripts_on_submit'];
91 }
92
93 $items = apply_filters( 'wpcf7_ajax_json_echo', $items, $result );
94 }
95 }
96
97 $echo = json_encode( $items );
98
99 if ( wpcf7_is_xhr() ) {
100 @header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
101 echo $echo;
102 } else {
103 @header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
104 echo '<textarea>' . $echo . '</textarea>';
105 }
106
107 exit();
108 }
109
110 function wpcf7_is_xhr() {
111 if ( ! isset( $_SERVER['HTTP_X_REQUESTED_WITH'] ) )
112 return false;
113
114 return $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest';
115 }
116
117 function wpcf7_submit_nonajax() {
118 if ( ! isset( $_POST['_wpcf7'] ) )
119 return;
120
121 if ( $contact_form = wpcf7_contact_form( (int) $_POST['_wpcf7'] ) ) {
122 $contact_form->submit();
123 }
124 }
125
126 add_filter( 'widget_text', 'wpcf7_widget_text_filter', 9 );
127
128 function wpcf7_widget_text_filter( $content ) {
129 if ( ! preg_match( '/\[[\r\n\t ]*contact-form(-7)?[\r\n\t ].*?\]/', $content ) )
130 return $content;
131
132 $content = do_shortcode( $content );
133
134 return $content;
135 }
136
137 /* Shortcodes */
138
139 add_action( 'plugins_loaded', 'wpcf7_add_shortcodes' );
140
141 function wpcf7_add_shortcodes() {
142 add_shortcode( 'contact-form-7', 'wpcf7_contact_form_tag_func' );
143 add_shortcode( 'contact-form', 'wpcf7_contact_form_tag_func' );
144 }
145
146 function wpcf7_contact_form_tag_func( $atts, $content = null, $code = '' ) {
147 if ( is_feed() )
148 return '[contact-form-7]';
149
150 if ( 'contact-form-7' == $code ) {
151 $atts = shortcode_atts( array(
152 'id' => 0,
153 'title' => '',
154 'html_id' => '',
155 'html_name' => '',
156 'html_class' => '',
157 'output' => 'form' ), $atts );
158
159 $id = (int) $atts['id'];
160 $title = trim( $atts['title'] );
161
162 if ( ! $contact_form = wpcf7_contact_form( $id ) )
163 $contact_form = wpcf7_get_contact_form_by_title( $title );
164
165 } else {
166 if ( is_string( $atts ) )
167 $atts = explode( ' ', $atts, 2 );
168
169 $id = (int) array_shift( $atts );
170 $contact_form = wpcf7_get_contact_form_by_old_id( $id );
171 }
172
173 if ( ! $contact_form )
174 return '[contact-form-7 404 "Not Found"]';
175
176 return $contact_form->form_html( $atts );
177 }
178
179 add_action( 'wp_enqueue_scripts', 'wpcf7_do_enqueue_scripts' );
180
181 function wpcf7_do_enqueue_scripts() {
182 if ( wpcf7_load_js() ) {
183 wpcf7_enqueue_scripts();
184 }
185
186 if ( wpcf7_load_css() ) {
187 wpcf7_enqueue_styles();
188 }
189 }
190
191 function wpcf7_enqueue_scripts() {
192 // jquery.form.js originally bundled with WordPress is out of date and deprecated
193 // so we need to deregister it and re-register the latest one
194 wp_deregister_script( 'jquery-form' );
195 wp_register_script( 'jquery-form',
196 wpcf7_plugin_url( 'includes/js/jquery.form.min.js' ),
197 array( 'jquery' ), '3.51.0-2014.06.20', true );
198
199 $in_footer = true;
200
201 if ( 'header' === wpcf7_load_js() ) {
202 $in_footer = false;
203 }
204
205 wp_enqueue_script( 'contact-form-7',
206 wpcf7_plugin_url( 'includes/js/scripts.js' ),
207 array( 'jquery', 'jquery-form' ), WPCF7_VERSION, $in_footer );
208
209 $_wpcf7 = array(
210 'loaderUrl' => wpcf7_ajax_loader(),
211 'sending' => __( 'Sending ...', 'contact-form-7' ) );
212
213 if ( defined( 'WP_CACHE' ) && WP_CACHE )
214 $_wpcf7['cached'] = 1;
215
216 if ( wpcf7_support_html5_fallback() )
217 $_wpcf7['jqueryUi'] = 1;
218
219 wp_localize_script( 'contact-form-7', '_wpcf7', $_wpcf7 );
220
221 do_action( 'wpcf7_enqueue_scripts' );
222 }
223
224 function wpcf7_script_is() {
225 return wp_script_is( 'contact-form-7' );
226 }
227
228 function wpcf7_enqueue_styles() {
229 wp_enqueue_style( 'contact-form-7',
230 wpcf7_plugin_url( 'includes/css/styles.css' ),
231 array(), WPCF7_VERSION, 'all' );
232
233 if ( wpcf7_is_rtl() ) {
234 wp_enqueue_style( 'contact-form-7-rtl',
235 wpcf7_plugin_url( 'includes/css/styles-rtl.css' ),
236 array(), WPCF7_VERSION, 'all' );
237 }
238
239 do_action( 'wpcf7_enqueue_styles' );
240 }
241
242 function wpcf7_style_is() {
243 return wp_style_is( 'contact-form-7' );
244 }
245
246 /* HTML5 Fallback */
247
248 add_action( 'wp_enqueue_scripts', 'wpcf7_html5_fallback', 20 );
249
250 function wpcf7_html5_fallback() {
251 if ( ! wpcf7_support_html5_fallback() ) {
252 return;
253 }
254
255 if ( wpcf7_script_is() ) {
256 wp_enqueue_script( 'jquery-ui-datepicker' );
257 wp_enqueue_script( 'jquery-ui-spinner' );
258 }
259
260 if ( wpcf7_style_is() ) {
261 wp_enqueue_style( 'jquery-ui-smoothness',
262 wpcf7_plugin_url( 'includes/js/jquery-ui/themes/smoothness/jquery-ui.min.css' ), array(), '1.10.3', 'screen' );
263 }
264 }
265
266 ?>