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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 / admin / admin.php
contact-form-7 / admin Last commit date
admin.php 15 years ago edit.php 16 years ago scripts.js 15 years ago styles-rtl.css 15 years ago styles.css 15 years ago taggenerator.js 16 years ago
admin.php
370 lines
1 <?php
2
3 function wpcf7_admin_has_edit_cap() {
4 return current_user_can( WPCF7_ADMIN_READ_WRITE_CAPABILITY );
5 }
6
7 add_action( 'admin_menu', 'wpcf7_admin_add_pages', 9 );
8
9 function wpcf7_admin_add_pages() {
10
11 if ( isset( $_POST['wpcf7-save'] ) && wpcf7_admin_has_edit_cap() ) {
12 $id = $_POST['wpcf7-id'];
13 check_admin_referer( 'wpcf7-save_' . $id );
14
15 if ( ! $contact_form = wpcf7_contact_form( $id ) ) {
16 $contact_form = new WPCF7_ContactForm();
17 $contact_form->initial = true;
18 }
19
20 $title = trim( $_POST['wpcf7-title'] );
21
22 $form = trim( $_POST['wpcf7-form'] );
23
24 $mail = array(
25 'subject' => trim( $_POST['wpcf7-mail-subject'] ),
26 'sender' => trim( $_POST['wpcf7-mail-sender'] ),
27 'body' => trim( $_POST['wpcf7-mail-body'] ),
28 'recipient' => trim( $_POST['wpcf7-mail-recipient'] ),
29 'additional_headers' => trim( $_POST['wpcf7-mail-additional-headers'] ),
30 'attachments' => trim( $_POST['wpcf7-mail-attachments'] ),
31 'use_html' =>
32 isset( $_POST['wpcf7-mail-use-html'] ) && 1 == $_POST['wpcf7-mail-use-html']
33 );
34
35 $mail_2 = array(
36 'active' =>
37 isset( $_POST['wpcf7-mail-2-active'] ) && 1 == $_POST['wpcf7-mail-2-active'],
38 'subject' => trim( $_POST['wpcf7-mail-2-subject'] ),
39 'sender' => trim( $_POST['wpcf7-mail-2-sender'] ),
40 'body' => trim( $_POST['wpcf7-mail-2-body'] ),
41 'recipient' => trim( $_POST['wpcf7-mail-2-recipient'] ),
42 'additional_headers' => trim( $_POST['wpcf7-mail-2-additional-headers'] ),
43 'attachments' => trim( $_POST['wpcf7-mail-2-attachments'] ),
44 'use_html' =>
45 isset( $_POST['wpcf7-mail-2-use-html'] ) && 1 == $_POST['wpcf7-mail-2-use-html']
46 );
47
48 $messages = $contact_form->messages;
49 foreach ( wpcf7_messages() as $key => $arr ) {
50 $field_name = 'wpcf7-message-' . strtr( $key, '_', '-' );
51 if ( isset( $_POST[$field_name] ) )
52 $messages[$key] = trim( $_POST[$field_name] );
53 }
54
55 $additional_settings = trim( $_POST['wpcf7-additional-settings'] );
56
57 $query = array();
58 $query['message'] = ( $contact_form->initial ) ? 'created' : 'saved';
59
60 $contact_form->title = $title;
61 $contact_form->form = $form;
62 $contact_form->mail = $mail;
63 $contact_form->mail_2 = $mail_2;
64 $contact_form->messages = $messages;
65 $contact_form->additional_settings = $additional_settings;
66
67 $contact_form->save();
68
69 $query['contactform'] = $contact_form->id;
70 $redirect_to = wpcf7_admin_url( $query );
71 wp_redirect( $redirect_to );
72 exit();
73 } elseif ( isset( $_POST['wpcf7-copy'] ) && wpcf7_admin_has_edit_cap() ) {
74 $id = $_POST['wpcf7-id'];
75 check_admin_referer( 'wpcf7-copy_' . $id );
76
77 $query = array();
78
79 if ( $contact_form = wpcf7_contact_form( $id ) ) {
80 $new_contact_form = $contact_form->copy();
81 $new_contact_form->save();
82
83 $query['contactform'] = $new_contact_form->id;
84 $query['message'] = 'created';
85 } else {
86 $query['contactform'] = $contact_form->id;
87 }
88
89 $redirect_to = wpcf7_admin_url( $query );
90 wp_redirect( $redirect_to );
91 exit();
92 } elseif ( isset( $_POST['wpcf7-delete'] ) && wpcf7_admin_has_edit_cap() ) {
93 $id = $_POST['wpcf7-id'];
94 check_admin_referer( 'wpcf7-delete_' . $id );
95
96 if ( $contact_form = wpcf7_contact_form( $id ) )
97 $contact_form->delete();
98
99 $redirect_to = wpcf7_admin_url( array( 'message' => 'deleted' ) );
100 wp_redirect( $redirect_to );
101 exit();
102 } elseif ( isset( $_GET['wpcf7-create-table'] ) ) {
103 check_admin_referer( 'wpcf7-create-table' );
104
105 $query = array();
106
107 if ( ! wpcf7_table_exists() && current_user_can( 'activate_plugins' ) ) {
108 wpcf7_install();
109 if ( wpcf7_table_exists() ) {
110 $query['message'] = 'table_created';
111 } else {
112 $query['message'] = 'table_not_created';
113 }
114 }
115
116 wp_redirect( wpcf7_admin_url( $query ) );
117 exit();
118 }
119
120 add_menu_page( __( 'Contact Form 7', 'wpcf7' ), __( 'Contact', 'wpcf7' ),
121 WPCF7_ADMIN_READ_CAPABILITY, 'wpcf7', 'wpcf7_admin_management_page' );
122
123 add_submenu_page( 'wpcf7', __( 'Edit Contact Forms', 'wpcf7' ), __( 'Edit', 'wpcf7' ),
124 WPCF7_ADMIN_READ_CAPABILITY, 'wpcf7', 'wpcf7_admin_management_page' );
125 }
126
127 add_action( 'admin_print_styles', 'wpcf7_admin_enqueue_styles' );
128
129 function wpcf7_admin_enqueue_styles() {
130 global $plugin_page;
131
132 if ( ! isset( $plugin_page ) || 'wpcf7' != $plugin_page )
133 return;
134
135 wp_enqueue_style( 'thickbox' );
136
137 wp_enqueue_style( 'contact-form-7-admin', wpcf7_plugin_url( 'admin/styles.css' ),
138 array(), WPCF7_VERSION, 'all' );
139
140 if ( 'rtl' == get_bloginfo( 'text_direction' ) ) {
141 wp_enqueue_style( 'contact-form-7-admin-rtl',
142 wpcf7_plugin_url( 'admin/styles-rtl.css' ), array(), WPCF7_VERSION, 'all' );
143 }
144 }
145
146 add_action( 'admin_print_scripts', 'wpcf7_admin_enqueue_scripts' );
147
148 function wpcf7_admin_enqueue_scripts() {
149 global $plugin_page;
150
151 if ( ! isset( $plugin_page ) || 'wpcf7' != $plugin_page )
152 return;
153
154 wp_enqueue_script( 'thickbox' );
155
156 wp_enqueue_script( 'wpcf7-admin-taggenerator', wpcf7_plugin_url( 'admin/taggenerator.js' ),
157 array( 'jquery' ), WPCF7_VERSION, true );
158
159 wp_enqueue_script( 'wpcf7-admin', wpcf7_plugin_url( 'admin/scripts.js' ),
160 array( 'jquery', 'wpcf7-admin-taggenerator' ), WPCF7_VERSION, true );
161 wp_localize_script( 'wpcf7-admin', '_wpcf7L10n', array(
162 'generateTag' => __( 'Generate Tag', 'wpcf7' ),
163 'show' => __( "Show", 'wpcf7' ),
164 'hide' => __( "Hide", 'wpcf7' ) ) );
165 }
166
167 add_action( 'admin_footer', 'wpcf7_admin_footer' );
168
169 function wpcf7_admin_footer() {
170 global $plugin_page;
171
172 if ( ! isset( $plugin_page ) || 'wpcf7' != $plugin_page )
173 return;
174
175 ?>
176 <script type="text/javascript">
177 /* <![CDATA[ */
178 var _wpcf7 = {
179 pluginUrl: '<?php echo wpcf7_plugin_url(); ?>',
180 tagGenerators: {
181 <?php wpcf7_print_tag_generators(); ?>
182 }
183 };
184 /* ]]> */
185 </script>
186 <?php
187 }
188
189 function wpcf7_admin_management_page() {
190 $contact_forms = wpcf7_contact_forms();
191
192 $unsaved = false;
193
194 if ( ! isset( $_GET['contactform'] ) )
195 $_GET['contactform'] = '';
196
197 if ( 'new' == $_GET['contactform'] ) {
198 $unsaved = true;
199 $current = -1;
200 $cf = wpcf7_contact_form_default_pack( isset( $_GET['locale'] ) ? $_GET['locale'] : '' );
201 } elseif ( $cf = wpcf7_contact_form( $_GET['contactform'] ) ) {
202 $current = (int) $_GET['contactform'];
203 } else {
204 $first = reset( $contact_forms ); // Returns first item
205 $current = $first->id;
206 $cf = wpcf7_contact_form( $current );
207 }
208
209 require_once WPCF7_PLUGIN_DIR . '/admin/edit.php';
210 }
211
212 /* Install and default settings */
213
214 add_action( 'activate_' . WPCF7_PLUGIN_BASENAME, 'wpcf7_install' );
215
216 function wpcf7_install() {
217 global $wpdb, $wpcf7;
218
219 if ( wpcf7_table_exists() )
220 return; // Exists already
221
222 $charset_collate = '';
223 if ( $wpdb->has_cap( 'collation' ) ) {
224 if ( ! empty( $wpdb->charset ) )
225 $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
226 if ( ! empty( $wpdb->collate ) )
227 $charset_collate .= " COLLATE $wpdb->collate";
228 }
229
230 $wpdb->query( "CREATE TABLE IF NOT EXISTS $wpcf7->contactforms (
231 cf7_unit_id bigint(20) unsigned NOT NULL auto_increment,
232 title varchar(200) NOT NULL default '',
233 form text NOT NULL,
234 mail text NOT NULL,
235 mail_2 text NOT NULL,
236 messages text NOT NULL,
237 additional_settings text NOT NULL,
238 PRIMARY KEY (cf7_unit_id)) $charset_collate;" );
239
240 if ( ! wpcf7_table_exists() )
241 return false; // Failed to create
242
243 $legacy_data = get_option( 'wpcf7' );
244 if ( is_array( $legacy_data )
245 && is_array( $legacy_data['contact_forms'] ) && $legacy_data['contact_forms'] ) {
246 foreach ( $legacy_data['contact_forms'] as $key => $value ) {
247 $wpdb->insert( $wpcf7->contactforms, array(
248 'cf7_unit_id' => $key,
249 'title' => $value['title'],
250 'form' => maybe_serialize( $value['form'] ),
251 'mail' => maybe_serialize( $value['mail'] ),
252 'mail_2' => maybe_serialize( $value['mail_2'] ),
253 'messages' => maybe_serialize( $value['messages'] ),
254 'additional_settings' => maybe_serialize( $value['additional_settings'] )
255 ), array( '%d', '%s', '%s', '%s', '%s', '%s', '%s' ) );
256 }
257 } else {
258 wpcf7_load_plugin_textdomain();
259
260 $wpdb->insert( $wpcf7->contactforms, array(
261 'title' => __( 'Contact form', 'wpcf7' ) . ' 1',
262 'form' => maybe_serialize( wpcf7_default_form_template() ),
263 'mail' => maybe_serialize( wpcf7_default_mail_template() ),
264 'mail_2' => maybe_serialize ( wpcf7_default_mail_2_template() ),
265 'messages' => maybe_serialize( wpcf7_default_messages_template() ) ) );
266 }
267 }
268
269 /* Misc */
270
271 add_filter( 'plugin_action_links', 'wpcf7_plugin_action_links', 10, 2 );
272
273 function wpcf7_plugin_action_links( $links, $file ) {
274 if ( $file != WPCF7_PLUGIN_BASENAME )
275 return $links;
276
277 $url = wpcf7_admin_url( array( 'page' => 'wpcf7' ) );
278
279 $settings_link = '<a href="' . esc_attr( $url ) . '">'
280 . esc_html( __( 'Settings', 'wpcf7' ) ) . '</a>';
281
282 array_unshift( $links, $settings_link );
283
284 return $links;
285 }
286
287 add_action( 'wpcf7_admin_before_subsubsub', 'wpcf7_cf7com_links', 9 );
288
289 function wpcf7_cf7com_links( &$contact_form ) {
290 $links = '<div class="cf7com-links">'
291 . '<a href="' . esc_url_raw( __( 'http://contactform7.com/', 'wpcf7' ) ) . '" target="_blank">'
292 . esc_html( __( 'Contactform7.com', 'wpcf7' ) ) . '</a>&ensp;'
293 . '<a href="' . esc_url_raw( __( 'http://contactform7.com/docs/', 'wpcf7' ) ) . '" target="_blank">'
294 . esc_html( __( 'Docs', 'wpcf7' ) ) . '</a> - '
295 . '<a href="' . esc_url_raw( __( 'http://contactform7.com/faq/', 'wpcf7' ) ) . '" target="_blank">'
296 . esc_html( __( 'FAQ', 'wpcf7' ) ) . '</a> - '
297 . '<a href="' . esc_url_raw( __( 'http://contactform7.com/support/', 'wpcf7' ) ) . '" target="_blank">'
298 . esc_html( __( 'Support', 'wpcf7' ) ) . '</a>'
299 . '</div>';
300
301 echo apply_filters( 'wpcf7_cf7com_links', $links );
302 }
303
304 add_action( 'wpcf7_admin_before_subsubsub', 'wpcf7_updated_message' );
305
306 function wpcf7_updated_message( &$contact_form ) {
307 if ( ! isset( $_GET['message'] ) )
308 return;
309
310 switch ( $_GET['message'] ) {
311 case 'created':
312 $updated_message = __( "Contact form created.", 'wpcf7' );
313 break;
314 case 'saved':
315 $updated_message = __( "Contact form saved.", 'wpcf7' );
316 break;
317 case 'deleted':
318 $updated_message = __( "Contact form deleted.", 'wpcf7' );
319 break;
320 case 'table_created':
321 $updated_message = __( "Database table created.", 'wpcf7' );
322 break;
323 case 'table_not_created':
324 $updated_message = __( "Failed to create database table.", 'wpcf7' );
325 break;
326 }
327
328 if ( ! $updated_message )
329 return;
330
331 ?>
332 <div id="message" class="updated fade"><p><?php echo esc_html( $updated_message ); ?></p></div>
333 <?php
334 }
335
336 add_action( 'wpcf7_admin_before_subsubsub', 'wpcf7_donation_link' );
337
338 function wpcf7_donation_link( &$contact_form ) {
339 if ( ! WPCF7_SHOW_DONATION_LINK )
340 return;
341
342 if ( 'new' == $_GET['contactform'] || ! empty($_GET['message']) )
343 return;
344
345 $show_link = true;
346
347 $num = mt_rand( 0, 99 );
348
349 if ( $num >= 20 )
350 $show_link = false;
351
352 $show_link = apply_filters( 'wpcf7_show_donation_link', $show_link );
353
354 if ( ! $show_link )
355 return;
356
357 $texts = array(
358 __( "Contact Form 7 needs your support. Please donate today.", 'wpcf7' ),
359 __( "Your contribution is needed for making this plugin better.", 'wpcf7' ) );
360
361 $text = $texts[array_rand( $texts )];
362
363 ?>
364 <div class="donation">
365 <p><a href="<?php echo esc_url_raw( __( 'http://contactform7.com/donate/', 'wpcf7' ) ); ?>"><?php echo esc_html( $text ); ?></a> <a href="<?php echo esc_url_raw( __( 'http://contactform7.com/donate/', 'wpcf7' ) ); ?>" class="button"><?php echo esc_html( __( "Donate", 'wpcf7' ) ); ?></a></p>
366 </div>
367 <?php
368 }
369
370 ?>