Contact Form 7 - Version 4.2-beta

Version Description

Download this release

Release Info

Developer takayukister
Plugin Icon 128x128 Contact Form 7
Version 4.2-beta
Comparing to
See all releases

Code changes from version 4.1.2 to 4.2-beta

admin/admin-functions.php CHANGED
@@ -15,38 +15,16 @@ function wpcf7_admin_has_edit_cap() {
15
}
16
17
function wpcf7_add_tag_generator( $name, $title, $elm_id, $callback, $options = array() ) {
18
- global $wpcf7_tag_generators;
19
-
20
- $name = trim( $name );
21
- if ( '' == $name )
22
- return false;
23
-
24
- if ( ! is_array( $wpcf7_tag_generators ) )
25
- $wpcf7_tag_generators = array();
26
-
27
- $wpcf7_tag_generators[$name] = array(
28
- 'title' => $title,
29
- 'content' => $elm_id,
30
- 'options' => $options );
31
-
32
- if ( is_callable( $callback ) )
33
- add_action( 'wpcf7_admin_footer', $callback );
34
-
35
- return true;
36
}
37
38
- function wpcf7_tag_generators() {
39
- global $wpcf7_tag_generators;
40
-
41
- $taggenerators = array();
42
-
43
- foreach ( (array) $wpcf7_tag_generators as $name => $tg ) {
44
- $taggenerators[$name] = array_merge(
45
- (array) $tg['options'],
46
- array( 'title' => $tg['title'], 'content' => $tg['content'] ) );
47
}
48
-
49
- return $taggenerators;
50
}
51
52
function wpcf7_save_contact_form( $post_id = -1 ) {
@@ -58,8 +36,8 @@ function wpcf7_save_contact_form( $post_id = -1 ) {
58
$contact_form = WPCF7_ContactForm::get_template();
59
}
60
61
- if ( isset( $_POST['wpcf7-title'] ) ) {
62
- $contact_form->set_title( $_POST['wpcf7-title'] );
63
}
64
65
if ( isset( $_POST['wpcf7-locale'] ) ) {
@@ -160,5 +138,3 @@ function wpcf7_save_contact_form( $post_id = -1 ) {
160
161
return $contact_form->save();
162
}
163
-
164
- ?>
15
}
16
17
function wpcf7_add_tag_generator( $name, $title, $elm_id, $callback, $options = array() ) {
18
+ $tag_generator = WPCF7_TagGenerator::get_instance();
19
+ return $tag_generator->add( $name, $title, $callback, $options );
20
}
21
22
+ function wpcf7_mail_tags_suggestion( WPCF7_ContactForm $contact_form ) {
23
+ foreach ( $contact_form->collect_mail_tags() as $mailtag ) {
24
+ echo sprintf(
25
+ '<span class="mailtag code">[%s]</span>',
26
+ esc_html( $mailtag ) );
27
}
28
}
29
30
function wpcf7_save_contact_form( $post_id = -1 ) {
36
$contact_form = WPCF7_ContactForm::get_template();
37
}
38
39
+ if ( isset( $_POST['post_title'] ) ) {
40
+ $contact_form->set_title( $_POST['post_title'] );
41
}
42
43
if ( isset( $_POST['wpcf7-locale'] ) ) {
138
139
return $contact_form->save();
140
}
admin/admin.php CHANGED
@@ -1,6 +1,7 @@
1
<?php
2
3
require_once WPCF7_PLUGIN_DIR . '/admin/admin-functions.php';
4
5
add_action( 'admin_menu', 'wpcf7_admin_menu', 9 );
6
@@ -55,7 +56,8 @@ function wpcf7_load_contact_form_admin() {
55
56
$query = array(
57
'message' => ( -1 == $_POST['post_ID'] ) ? 'created' : 'saved',
58
- 'post' => $id );
59
60
$redirect_to = add_query_arg( $query, menu_page_url( 'wpcf7', false ) );
61
wp_safe_redirect( $redirect_to );
@@ -146,7 +148,6 @@ function wpcf7_load_contact_form_admin() {
146
147
if ( $post && current_user_can( 'wpcf7_edit_contact_form', $post->id() ) ) {
148
$help_tabs->set_help_tabs( 'edit' );
149
- wpcf7_add_meta_boxes( $post->id() );
150
151
} else if ( 'wpcf7-new' == $plugin_page ) {
152
$help_tabs->set_help_tabs( 'add_new' );
@@ -171,8 +172,9 @@ function wpcf7_load_contact_form_admin() {
171
add_action( 'admin_enqueue_scripts', 'wpcf7_admin_enqueue_scripts' );
172
173
function wpcf7_admin_enqueue_scripts( $hook_suffix ) {
174
- if ( false === strpos( $hook_suffix, 'wpcf7' ) )
175
return;
176
177
wp_enqueue_style( 'contact-form-7-admin',
178
wpcf7_plugin_url( 'admin/css/styles.css' ),
@@ -184,29 +186,30 @@ function wpcf7_admin_enqueue_scripts( $hook_suffix ) {
184
array(), WPCF7_VERSION, 'all' );
185
}
186
187
wp_enqueue_script( 'wpcf7-admin-taggenerator',
188
- wpcf7_plugin_url( 'admin/js/taggenerator.js' ),
189
array( 'jquery' ), WPCF7_VERSION, true );
190
191
wp_enqueue_script( 'wpcf7-admin',
192
wpcf7_plugin_url( 'admin/js/scripts.js' ),
193
- array( 'jquery', 'postbox', 'wpcf7-admin-taggenerator' ),
194
WPCF7_VERSION, true );
195
196
$current_screen = get_current_screen();
197
198
wp_localize_script( 'wpcf7-admin', '_wpcf7', array(
199
- 'screenId' => $current_screen->id,
200
- 'generateTag' => __( 'Generate Tag', 'contact-form-7' ),
201
'pluginUrl' => wpcf7_plugin_url(),
202
- 'tagGenerators' => wpcf7_tag_generators() ) );
203
}
204
205
function wpcf7_admin_management_page() {
206
if ( $post = wpcf7_get_current_contact_form() ) {
207
$post_id = $post->initial() ? -1 : $post->id();
208
209
- require_once WPCF7_PLUGIN_DIR . '/admin/includes/meta-boxes.php';
210
require_once WPCF7_PLUGIN_DIR . '/admin/edit-contact-form.php';
211
return;
212
}
@@ -220,7 +223,9 @@ function wpcf7_admin_management_page() {
220
<h2><?php
221
echo esc_html( __( 'Contact Forms', 'contact-form-7' ) );
222
223
- echo ' <a href="' . esc_url( menu_page_url( 'wpcf7-new', false ) ) . '" class="add-new-h2">' . esc_html( __( 'Add New', 'contact-form-7' ) ) . '</a>';
224
225
if ( ! empty( $_REQUEST['s'] ) ) {
226
echo sprintf( '<span class="subtitle">'
@@ -245,7 +250,7 @@ function wpcf7_admin_add_new_page() {
245
if ( $post = wpcf7_get_current_contact_form() ) {
246
$post_id = -1;
247
248
- require_once WPCF7_PLUGIN_DIR . '/admin/includes/meta-boxes.php';
249
require_once WPCF7_PLUGIN_DIR . '/admin/edit-contact-form.php';
250
return;
251
}
@@ -283,29 +288,6 @@ function wpcf7_admin_add_new_page() {
283
<?php
284
}
285
286
- function wpcf7_add_meta_boxes( $post_id ) {
287
- add_meta_box( 'formdiv', __( 'Form', 'contact-form-7' ),
288
- 'wpcf7_form_meta_box', null, 'form', 'core' );
289
-
290
- add_meta_box( 'maildiv', __( 'Mail', 'contact-form-7' ),
291
- 'wpcf7_mail_meta_box', null, 'mail', 'core' );
292
-
293
- add_meta_box( 'mail2div', __( 'Mail (2)', 'contact-form-7' ),
294
- 'wpcf7_mail_meta_box', null, 'mail_2', 'core',
295
- array(
296
- 'id' => 'wpcf7-mail-2',
297
- 'name' => 'mail_2',
298
- 'use' => __( 'Use mail (2)', 'contact-form-7' ) ) );
299
-
300
- add_meta_box( 'messagesdiv', __( 'Messages', 'contact-form-7' ),
301
- 'wpcf7_messages_meta_box', null, 'messages', 'core' );
302
-
303
- add_meta_box( 'additionalsettingsdiv', __( 'Additional Settings', 'contact-form-7' ),
304
- 'wpcf7_additional_settings_meta_box', null, 'additional_settings', 'core' );
305
-
306
- do_action( 'wpcf7_add_meta_boxes', $post_id );
307
- }
308
-
309
/* Misc */
310
311
add_action( 'wpcf7_admin_notices', 'wpcf7_admin_updated_message' );
@@ -343,23 +325,6 @@ function wpcf7_plugin_action_links( $links, $file ) {
343
return $links;
344
}
345
346
- add_action( 'wpcf7_admin_notices', 'wpcf7_cf7com_links', 9 );
347
-
348
- function wpcf7_cf7com_links() {
349
- $links = '<div class="cf7com-links">'
350
- . '<a href="' . esc_url( __( 'http://contactform7.com/docs/', 'contact-form-7' ) ) . '" target="_blank">'
351
- . esc_html( __( 'Docs', 'contact-form-7' ) ) . '</a> - '
352
- . '<a href="' . esc_url( __( 'http://contactform7.com/faq/', 'contact-form-7' ) ) . '" target="_blank">'
353
- . esc_html( __( 'FAQ', 'contact-form-7' ) ) . '</a> - '
354
- . '<a href="' . esc_url( __( 'http://contactform7.com/support/', 'contact-form-7' ) ) . '" target="_blank">'
355
- . esc_html( __( 'Support', 'contact-form-7' ) ) . '</a> - '
356
- . '<a href="' . esc_url( __( 'http://contactform7.com/donate/', 'contact-form-7' ) ) . '" target="_blank">'
357
- . esc_html( __( 'Donate', 'contact-form-7' ) ) . '</a>'
358
- . '</div>';
359
-
360
- echo apply_filters( 'wpcf7_cf7com_links', $links );
361
- }
362
-
363
add_action( 'admin_notices', 'wpcf7_old_wp_version_error', 9 );
364
365
function wpcf7_old_wp_version_error() {
@@ -409,26 +374,26 @@ function wpcf7_welcome_panel() {
409
<div class="welcome-panel-column">
410
<h4><?php echo esc_html( __( 'Contact Form 7 Needs Your Support', 'contact-form-7' ) ); ?></h4>
411
<p class="message"><?php echo esc_html( __( "It is hard to continue development and support for this plugin without contributions from users like you. If you enjoy using Contact Form 7 and find it useful, please consider making a donation.", 'contact-form-7' ) ); ?></p>
412
- <p><a href="<?php echo esc_url( __( 'http://contactform7.com/donate/', 'contact-form-7' ) ); ?>" class="button button-primary" target="_blank"><?php echo esc_html( __( 'Donate', 'contact-form-7' ) ); ?></a></p>
413
</div>
414
415
<div class="welcome-panel-column">
416
<h4><?php echo esc_html( __( 'Get Started', 'contact-form-7' ) ); ?></h4>
417
<ul>
418
- <li><a href="<?php echo esc_url( __( 'http://contactform7.com/getting-started-with-contact-form-7/', 'contact-form-7' ) ); ?>" target="_blank"><?php echo esc_html( __( "Getting Started with Contact Form 7", 'contact-form-7' ) ); ?></a></li>
419
- <li><a href="<?php echo esc_url( __( 'http://contactform7.com/admin-screen/', 'contact-form-7' ) ); ?>" target="_blank"><?php echo esc_html( __( "Admin Screen", 'contact-form-7' ) ); ?></a></li>
420
- <li><a href="<?php echo esc_url( __( 'http://contactform7.com/tag-syntax/', 'contact-form-7' ) ); ?>" target="_blank"><?php echo esc_html( __( "How Tags Work", 'contact-form-7' ) ); ?></a></li>
421
- <li><a href="<?php echo esc_url( __( 'http://contactform7.com/setting-up-mail/', 'contact-form-7' ) ); ?>" target="_blank"><?php echo esc_html( __( "Setting Up Mail", 'contact-form-7' ) ); ?></a></li>
422
</ul>
423
</div>
424
425
<div class="welcome-panel-column">
426
<h4><?php echo esc_html( __( 'Did You Know?', 'contact-form-7' ) ); ?></h4>
427
<ul>
428
- <li><a href="<?php echo esc_url( __( 'http://contactform7.com/spam-filtering-with-akismet/', 'contact-form-7' ) ); ?>" target="_blank"><?php echo esc_html( __( "Spam Filtering with Akismet", 'contact-form-7' ) ); ?></a></li>
429
- <li><a href="<?php echo esc_url( __( 'http://contactform7.com/save-submitted-messages-with-flamingo/', 'contact-form-7' ) ); ?>" target="_blank"><?php echo esc_html( __( "Save Messages with Flamingo", 'contact-form-7' ) ); ?></a></li>
430
- <li><a href="<?php echo esc_url( __( 'http://contactform7.com/selectable-recipient-with-pipes/', 'contact-form-7' ) ); ?>" target="_blank"><?php echo esc_html( __( "Selectable Recipient with Pipes", 'contact-form-7' ) ); ?></a></li>
431
- <li><a href="<?php echo esc_url( __( 'http://contactform7.com/tracking-form-submissions-with-google-analytics/', 'contact-form-7' ) ); ?>" target="_blank"><?php echo esc_html( __( "Tracking with Google Analytics", 'contact-form-7' ) ); ?></a></li>
432
</ul>
433
</div>
434
</div>
@@ -460,4 +425,22 @@ function wpcf7_admin_ajax_welcome_panel() {
460
wp_die( 1 );
461
}
462
463
- ?>
1
<?php
2
3
require_once WPCF7_PLUGIN_DIR . '/admin/admin-functions.php';
4
+ require_once WPCF7_PLUGIN_DIR . '/admin/includes/tag-generator.php';
5
6
add_action( 'admin_menu', 'wpcf7_admin_menu', 9 );
7
56
57
$query = array(
58
'message' => ( -1 == $_POST['post_ID'] ) ? 'created' : 'saved',
59
+ 'post' => $id,
60
+ 'active-tab' => isset( $_POST['active-tab'] ) ? (int) $_POST['active-tab'] : 0 );
61
62
$redirect_to = add_query_arg( $query, menu_page_url( 'wpcf7', false ) );
63
wp_safe_redirect( $redirect_to );
148
149
if ( $post && current_user_can( 'wpcf7_edit_contact_form', $post->id() ) ) {
150
$help_tabs->set_help_tabs( 'edit' );
151
152
} else if ( 'wpcf7-new' == $plugin_page ) {
153
$help_tabs->set_help_tabs( 'add_new' );
172
add_action( 'admin_enqueue_scripts', 'wpcf7_admin_enqueue_scripts' );
173
174
function wpcf7_admin_enqueue_scripts( $hook_suffix ) {
175
+ if ( false === strpos( $hook_suffix, 'wpcf7' ) ) {
176
return;
177
+ }
178
179
wp_enqueue_style( 'contact-form-7-admin',
180
wpcf7_plugin_url( 'admin/css/styles.css' ),
186
array(), WPCF7_VERSION, 'all' );
187
}
188
189
+ add_thickbox();
190
+
191
wp_enqueue_script( 'wpcf7-admin-taggenerator',
192
+ wpcf7_plugin_url( 'admin/js/tag-generator.js' ),
193
array( 'jquery' ), WPCF7_VERSION, true );
194
195
wp_enqueue_script( 'wpcf7-admin',
196
wpcf7_plugin_url( 'admin/js/scripts.js' ),
197
+ array( 'jquery', 'jquery-ui-tabs', 'wpcf7-admin-taggenerator' ),
198
WPCF7_VERSION, true );
199
200
$current_screen = get_current_screen();
201
202
wp_localize_script( 'wpcf7-admin', '_wpcf7', array(
203
'pluginUrl' => wpcf7_plugin_url(),
204
+ 'saveAlert' => __( "The changes you made will be lost if you navigate away from this page.", 'contact-form-7' ),
205
+ 'activeTab' => isset( $_GET['active-tab'] ) ? (int) $_GET['active-tab'] : 0 ) );
206
}
207
208
function wpcf7_admin_management_page() {
209
if ( $post = wpcf7_get_current_contact_form() ) {
210
$post_id = $post->initial() ? -1 : $post->id();
211
212
+ require_once WPCF7_PLUGIN_DIR . '/admin/includes/editor.php';
213
require_once WPCF7_PLUGIN_DIR . '/admin/edit-contact-form.php';
214
return;
215
}
223
<h2><?php
224
echo esc_html( __( 'Contact Forms', 'contact-form-7' ) );
225
226
+ if ( current_user_can( 'wpcf7_edit_contact_forms' ) ) {
227
+ echo ' <a href="' . esc_url( menu_page_url( 'wpcf7-new', false ) ) . '" class="add-new-h2">' . esc_html( __( 'Add New', 'contact-form-7' ) ) . '</a>';
228
+ }
229
230
if ( ! empty( $_REQUEST['s'] ) ) {
231
echo sprintf( '<span class="subtitle">'
250
if ( $post = wpcf7_get_current_contact_form() ) {
251
$post_id = -1;
252
253
+ require_once WPCF7_PLUGIN_DIR . '/admin/includes/editor.php';
254
require_once WPCF7_PLUGIN_DIR . '/admin/edit-contact-form.php';
255
return;
256
}
288
<?php
289
}
290
291
/* Misc */
292
293
add_action( 'wpcf7_admin_notices', 'wpcf7_admin_updated_message' );
325
return $links;
326
}
327
328
add_action( 'admin_notices', 'wpcf7_old_wp_version_error', 9 );
329
330
function wpcf7_old_wp_version_error() {
374
<div class="welcome-panel-column">
375
<h4><?php echo esc_html( __( 'Contact Form 7 Needs Your Support', 'contact-form-7' ) ); ?></h4>
376
<p class="message"><?php echo esc_html( __( "It is hard to continue development and support for this plugin without contributions from users like you. If you enjoy using Contact Form 7 and find it useful, please consider making a donation.", 'contact-form-7' ) ); ?></p>
377
+ <p><?php echo wpcf7_link( __( 'http://contactform7.com/donate/', 'contact-form-7' ), __( 'Donate', 'contact-form-7' ), array( 'class' => 'button button-primary' ) ); ?></p>
378
</div>
379
380
<div class="welcome-panel-column">
381
<h4><?php echo esc_html( __( 'Get Started', 'contact-form-7' ) ); ?></h4>
382
<ul>
383
+ <li><?php echo wpcf7_link( __( 'http://contactform7.com/getting-started-with-contact-form-7/', 'contact-form-7' ), __( 'Getting Started with Contact Form 7', 'contact-form-7' ) ); ?></li>
384
+ <li><?php echo wpcf7_link( __( 'http://contactform7.com/admin-screen/', 'contact-form-7' ), __( 'Admin Screen', 'contact-form-7' ) ); ?></li>
385
+ <li><?php echo wpcf7_link( __( 'http://contactform7.com/tag-syntax/', 'contact-form-7' ), __( 'How Tags Work', 'contact-form-7' ) ); ?></li>
386
+ <li><?php echo wpcf7_link( __( 'http://contactform7.com/setting-up-mail/', 'contact-form-7' ), __( 'Setting Up Mail', 'contact-form-7' ) ); ?></li>
387
</ul>
388
</div>
389
390
<div class="welcome-panel-column">
391
<h4><?php echo esc_html( __( 'Did You Know?', 'contact-form-7' ) ); ?></h4>
392
<ul>
393
+ <li><?php echo wpcf7_link( __( 'http://contactform7.com/spam-filtering-with-akismet/', 'contact-form-7' ), __( 'Spam Filtering with Akismet', 'contact-form-7' ) ); ?></li>
394
+ <li><?php echo wpcf7_link( __( 'http://contactform7.com/save-submitted-messages-with-flamingo/', 'contact-form-7' ), __( 'Save Messages with Flamingo', 'contact-form-7' ) ); ?></li>
395
+ <li><?php echo wpcf7_link( __( 'http://contactform7.com/selectable-recipient-with-pipes/', 'contact-form-7' ), __( 'Selectable Recipient with Pipes', 'contact-form-7' ) ); ?></li>
396
+ <li><?php echo wpcf7_link( __( 'http://contactform7.com/tracking-form-submissions-with-google-analytics/', 'contact-form-7' ), __( 'Tracking with Google Analytics', 'contact-form-7' ) ); ?></li>
397
</ul>
398
</div>
399
</div>
425
wp_die( 1 );
426
}
427
428
+ add_action( 'wpcf7_admin_notices', 'wpcf7_not_allowed_to_edit' );
429
+
430
+ function wpcf7_not_allowed_to_edit() {
431
+ if ( ! $contact_form = wpcf7_get_current_contact_form() ) {
432
+ return;
433
+ }
434
+
435
+ $post_id = $contact_form->id();
436
+
437
+ if ( current_user_can( 'wpcf7_edit_contact_form', $post_id ) ) {
438
+ return;
439
+ }
440
+
441
+ $message = __( "You are not allowed to edit this contact form.",
442
+ 'contact-form-7' );
443
+
444
+ echo sprintf( '<div class="notice notice-warning"><p>%s</p></div>',
445
+ esc_html( $message ) );
446
+ }
admin/css/styles-rtl.css CHANGED
@@ -1,21 +1,16 @@
1
- div.save-contact-form {
2
- direction: rtl;
3
}
4
5
- div.actions-link {
6
- right: auto;
7
- left: 0;
8
}
9
10
- div.tg-pane table caption {
11
- text-align: right;
12
}
13
14
- div.tg-dropdown {
15
- left: auto;
16
- right: 0;
17
}
18
-
19
- div.wrap div.cf7com-links {
20
- text-align: left;
21
- }
1
+ .tag-generator-panel {
2
+ text-align: right;
3
}
4
5
+ .tag-generator-panel .control-box > fieldset legend {
6
+ border: 1px solid #dfdfdf;
7
+ border-right: 4px solid #00a0d2;
8
}
9
10
+ .tag-generator-panel .insert-box input.tag {
11
+ float: right;
12
}
13
14
+ .tag-generator-panel .insert-box .submitbox input[type="button"] {
15
+ float: left;
16
}
admin/css/styles.css CHANGED
@@ -1,253 +1,258 @@
1
- #icon-wpcf7 {
2
- background: transparent url(../images/screen-icon.png) no-repeat 2px 1px;
3
}
4
5
- div.wrap div.cf7com-links {
6
- text-align: right;
7
- font-size: .9em;
8
- margin: -20px 1em 1em 0;
9
}
10
11
- div.wrap div.cf7com-links a {
12
- text-decoration: none;
13
- font-weight: bold;
14
}
15
16
- #titlediv {
17
- margin-bottom: 20px;
18
- position: relative;
19
- border: 1px solid #c7c7c7;
20
- padding: 6px;
21
- background-color: #fff;
22
- }
23
-
24
- div.save-contact-form {
25
- padding: 1.4em 0 0 0;
26
- text-align: right;
27
}
28
29
- div.actions-link {
30
- position: absolute;
31
- top: 0;
32
- right: 0;
33
- margin: 0;
34
- padding: 6px;
35
}
36
37
- div.actions-link input {
38
padding: 0;
39
margin: 0;
40
border: none;
41
- font-size: 11px;
42
cursor: pointer;
43
background: inherit;
44
}
45
46
- div.actions-link input.copy {
47
- color: #006505;
48
}
49
50
- div.actions-link input.delete {
51
- color: #bc0b0b;
52
}
53
54
- input#wpcf7-title {
55
- color: #5f5f5f;
56
- border: none;
57
- font-weight: bold;
58
- font-size: 1.5em;
59
- cursor: pointer;
60
- background-color: transparent;
61
- box-shadow: none;
62
- width: 80%;
63
}
64
65
- input#wpcf7-title.focus {
66
- color: #3f3f3f;
67
- border: 1px solid #aaa;
68
- cursor: text;
69
- background-color: transparent;
70
- box-shadow: inset 0 1px 2px rgba(0,0,0,0.07);
71
}
72
73
- input#wpcf7-title.mouseover {
74
- background-color: #ffffdd;
75
}
76
77
- p.tagcode {
78
- color: #333;
79
- margin: 2ex 0 1ex 0;
80
}
81
82
- input#contact-form-anchor-text, input#contact-form-anchor-text-old {
83
- width: 100%;
84
}
85
86
- .postbox .half, .postbox .half-left, .postbox .half-right {
87
- float: left;
88
- width: 50%;
89
}
90
91
- .postbox .half-right > * {
92
- margin-left: 10px;
93
}
94
95
- @media only screen and (max-width: 768px) {
96
- .postbox .half, .postbox .half-left, .postbox .half-right {
97
- width: 100%;
98
- }
99
100
- .postbox .half-right {
101
- margin-top: 1em;
102
- }
103
104
- .postbox .half-right > * {
105
- margin-left: inherit;
106
- }
107
}
108
109
- .postbox .mail-field, .postbox .message-field {
110
- margin-top: 6px;
111
- margin-bottom: 8px;
112
}
113
114
- .postbox .mail-field label, .postbox .message-field label {
115
- line-height: 1.4em;
116
}
117
118
- div.pseudo-hr {
119
- border-bottom: 1px solid transparent;
120
- margin: 8px 0;
121
}
122
123
- input, textarea {
124
- border: 1px solid #dfdfdf;
125
}
126
127
- input.wide {
128
- width: 100%;
129
}
130
131
- textarea {
132
width: 100%;
133
}
134
135
- label.disabled {
136
- color: #777;
137
}
138
139
- #messagesdiv .hide-initially {
140
- display: none;
141
}
142
143
- div.tag-generator {
144
- position: relative;
145
- background: transparent;
146
- padding: 0 0 5px 1px;
147
}
148
149
- div.tg-pane {
150
- border: 1px solid #e1e1e1;
151
- background: #f7f7f7;
152
- margin: 1ex 0 0 0;
153
- padding: 10px;
154
- line-height: 140%;
155
}
156
157
- div.tg-pane table {
158
- width: 100%;
159
- margin: 0 0 0.7em 0;
160
}
161
162
- div.tg-pane table caption {
163
text-align: left;
164
- padding: 0 0 0.2em 0;
165
- font-weight: bolder;
166
color: #777;
167
}
168
169
- div.tg-pane table code {
170
- background-color: inherit;
171
}
172
173
- div.tg-pane table td {
174
- vertical-align: top;
175
- width: 50%;
176
- border: none;
177
- padding: 2px 0;
178
}
179
180
- div.tg-pane input.tag, div.tg-pane input.mail-tag {
181
width: 100%;
182
- font-size: 90%;
183
- }
184
-
185
- div.tg-pane input.mail-tag {
186
- width: 65%;
187
- }
188
-
189
- div.tg-mail-tag {
190
- margin-top: 2.4em;
191
- text-align: right;
192
- }
193
-
194
- div.tg-pane input.tg-name {
195
- border-color: #555;
196
- }
197
-
198
- div.tg-pane input.oneline {
199
- width: 94%;
200
- font-size: smaller;
201
- -moz-box-sizing: border-box;
202
}
203
204
- div.tg-pane textarea {
205
- width: 94%;
206
- height: 100px;
207
- font-size: smaller;
208
}
209
210
- div.tg-pane div.tg-tag {
211
- margin: .4em 0;
212
}
213
214
- div.tg-dropdown {
215
- position: absolute;
216
- top: 26px;
217
- left: 0;
218
- z-index: 10;
219
- border: 1px solid #ddd;
220
}
221
222
- span.tg-closebutton {
223
- color: #777;
224
- font: bold 18px monospace;
225
- padding: 1px 4px;
226
- cursor: pointer;
227
}
228
229
- div.tg-panetitle {
230
- font-weight: bold;
231
- font-size: 1.5em;
232
- margin: 0 0 .5em;
233
- color: #5f5f5f;
234
}
235
236
.fixed .column-title {
237
- width: 32%;
238
}
239
240
- input.shortcode-in-list-table {
241
- width: 100%;
242
- font-size: 90%;
243
- }
244
-
245
- input[readonly].code {
246
- background: #f3f3f3;
247
- color: #3f3f3f;
248
}
249
250
- /* welcome panel */
251
.welcome-panel p.message {
252
line-height: 1.4em;
253
margin-right: 25px;
@@ -259,4 +264,4 @@ input[readonly].code {
259
260
.welcome-panel-close {
261
z-index: 2;
262
- }
1
+ #titlediv .inside p.description {
2
+ margin: 8px 2px 0;
3
}
4
5
+ #titlediv .inside p.description label {
6
+ cursor: pointer;
7
}
8
9
+ span.shortcode {
10
+ display: block;
11
+ margin: 2px 0;
12
}
13
14
+ span.shortcode > input {
15
+ background: inherit;
16
+ color: inherit;
17
+ font-size: 12px;
18
+ border: none;
19
+ box-shadow: none;
20
+ padding: 4px 8px;
21
+ margin: 0;
22
}
23
24
+ #submitpost input.copy {
25
+ margin-bottom: 10px;
26
}
27
28
+ #submitpost input.delete {
29
padding: 0;
30
margin: 0;
31
border: none;
32
cursor: pointer;
33
background: inherit;
34
+ color: #a00;
35
}
36
37
+ #submitpost input.delete:focus {
38
+ outline: thin dotted;
39
}
40
41
+ .postbox-container .postbox h3 {
42
+ border-bottom: 1px solid transparent;
43
}
44
45
+ /*
46
+ * Tabs
47
+ */
48
+ #contact-form-editor-tabs {
49
+ border-bottom: 1px solid #aaa;
50
+ padding: 9px 15px 0 10px;
51
+ margin: 0;
52
}
53
54
+ #contact-form-editor-tabs li {
55
+ display: inline-block;
56
+ list-style: none;
57
+ border: 1px solid #ccc;
58
+ border-bottom: 1px solid #aaa;
59
+ padding: 0;
60
+ margin: 0 4px -1px;
61
+ background-color: #e4e4e4;
62
}
63
64
+ #contact-form-editor-tabs li:hover {
65
+ background-color: #fff;
66
}
67
68
+ #contact-form-editor-tabs li.ui-tabs-active,
69
+ #contact-form-editor-tabs li.ui-tabs-active:hover {
70
+ border-top: 1px solid #aaa;
71
+ border-right: 1px solid #aaa;
72
+ border-left: 1px solid #aaa;
73
+ border-bottom: 1px solid #f5f5f5;
74
+ background-color: #f5f5f5;
75
}
76
77
+ #contact-form-editor-tabs li a {
78
+ padding: 6px 10px;
79
+ font-size: 14px;
80
+ font-weight: normal;
81
+ line-height: 30px;
82
+ color: #333;
83
+ text-decoration: none;
84
}
85
86
+ #contact-form-editor-tabs li.ui-tabs-active a {
87
+ color: #000;
88
+ font-size: 14px;
89
+ font-weight: bold;
90
}
91
92
+ #contact-form-editor-tabs li a:hover {
93
+ color: #000;
94
}
95
96
+ #contact-form-editor .contact-form-editor-panel h3 {
97
+ font-size: 18px;
98
+ font-weight: 400;
99
+ line-height: 24px;
100
+ margin: 8px 0;
101
+ padding: 0;
102
+ }
103
104
+ #contact-form-editor .contact-form-editor-panel {
105
+ background-color: #f5f5f5;
106
+ border: 1px solid #aaa;
107
+ border-top: none;
108
+ padding: 16px;
109
+ }
110
111
+ #contact-form-editor .form-table th {
112
+ width: 100px;
113
}
114
115
+ #contact-form-editor .contact-form-editor-panel fieldset legend {
116
+ line-height: 1.5;
117
+ margin: .6em 0 .4em;
118
}
119
120
+ /*
121
+ * Form Panel
122
+ */
123
+ #tag-generator-list a.button {
124
+ font-size: 12px;
125
+ height: 26px;
126
+ line-height: 24px;
127
+ margin: 2px;
128
+ padding: 0 8px 1px;
129
}
130
131
+ .tag-generator-panel {
132
+ position: relative;
133
+ height: 495px;
134
}
135
136
+ .tag-generator-panel .control-box {
137
+ padding: 0;
138
+ margin: 0;
139
+ height: 380px;
140
+ overflow: auto;
141
}
142
143
+ .tag-generator-panel .control-box > fieldset legend {
144
+ border: 1px solid #dfdfdf;
145
+ border-left: 4px solid #00a0d2;
146
+ background: #f7fcfe;
147
+ padding: 4px 12px;
148
+ margin: 4px 0;
149
+ line-height: 1.4em;
150
+ width: 95%;
151
}
152
153
+ .tag-generator-panel table {
154
width: 100%;
155
}
156
157
+ .tag-generator-panel table.form-table th {
158
+ width: 120px;
159
+ padding: 4px 10px 4px 0;
160
+ font-size: 13px;
161
}
162
163
+ .tag-generator-panel table.form-table td {
164
+ padding: 4px 10px;
165
+ font-size: 13px;
166
}
167
168
+ .tag-generator-panel .control-box input.oneline {
169
+ width: 200px;
170
}
171
172
+ .tag-generator-panel .control-box textarea.values {
173
+ width: 200px;
174
+ height: 6em;
175
}
176
177
+ .tag-generator-panel .control-box input[type="number"],
178
+ .tag-generator-panel .control-box input[type="date"] {
179
+ width: 88px;
180
}
181
182
+ .tag-generator-panel .control-box table caption {
183
text-align: left;
184
+ font-size: 110%;
185
+ font-weight: bold;
186
color: #777;
187
+ margin: 10px 0 5px;
188
}
189
190
+ .tag-generator-panel .control-box table.form-table td label {
191
+ line-height: 1.1em;
192
}
193
194
+ .tag-generator-panel .control-box table.form-table td label .description {
195
+ line-height: 1.4em;
196
}
197
198
+ .tag-generator-panel .insert-box {
199
+ position: absolute;
200
+ left: -15px;
201
+ right: -15px;
202
+ bottom: -15px;
203
width: 100%;
204
+ height: 84px;
205
+ margin: 0;
206
+ padding: 8px 16px;
207
+ background-color: #fcfcfc;
208
+ border-top: 1px solid #dfdfdf;
209
+ overflow: auto;
210
}
211
212
+ .tag-generator-panel .insert-box input.tag {
213
+ width: 480px;
214
+ float: left;
215
+ background-color: transparent;
216
+ box-shadow: none;
217
}
218
219
+ .tag-generator-panel .insert-box .submitbox {
220
+ padding: 2px 4px;
221
}
222
223
+ .tag-generator-panel .insert-box .submitbox input[type="button"] {
224
+ float: right;
225
}
226
227
+ .tag-generator-panel .insert-box .description label {
228
+ cursor: text;
229
}
230
231
+ /*
232
+ * Mail Panel
233
+ */
234
+ .contact-form-editor-box-mail span.mailtag {
235
+ display: inline-block;
236
+ margin: 0 0 0 4px;
237
+ padding: 1px 2px;
238
+ cursor: pointer;
239
+ color: #000;
240
}
241
242
+ /*
243
+ * List Table
244
+ */
245
.fixed .column-title {
246
+ width: 38%;
247
}
248
249
+ .fixed .column-shortcode {
250
+ width: 38%;
251
}
252
253
+ /*
254
+ * Welcome Panel
255
+ */
256
.welcome-panel p.message {
257
line-height: 1.4em;
258
margin-right: 25px;
264
265
.welcome-panel-close {
266
z-index: 2;
267
+ }
admin/edit-contact-form.php CHANGED
@@ -1,8 +1,9 @@
1
<?php
2
3
// don't load directly
4
- if ( ! defined( 'ABSPATH' ) )
5
die( '-1' );
6
7
?><div class="wrap">
8
@@ -12,106 +13,195 @@ if ( ! defined( 'ABSPATH' ) )
12
} else {
13
echo esc_html( __( 'Edit Contact Form', 'contact-form-7' ) );
14
15
- echo ' <a href="' . esc_url( menu_page_url( 'wpcf7-new', false ) ) . '" class="add-new-h2">' . esc_html( __( 'Add New', 'contact-form-7' ) ) . '</a>';
16
}
17
?></h2>
18
19
<?php do_action( 'wpcf7_admin_notices' ); ?>
20
21
- <br class="clear" />
22
-
23
<?php
24
if ( $post ) :
25
26
- if ( current_user_can( 'wpcf7_edit_contact_form', $post_id ) )
27
$disabled = '';
28
- else
29
$disabled = ' disabled="disabled"';
30
?>
31
32
<form method="post" action="<?php echo esc_url( add_query_arg( array( 'post' => $post_id ), menu_page_url( 'wpcf7', false ) ) ); ?>" id="wpcf7-admin-form-element"<?php do_action( 'wpcf7_post_edit_form_tag' ); ?>>
33
- <?php if ( current_user_can( 'wpcf7_edit_contact_form', $post_id ) )
34
- wp_nonce_field( 'wpcf7-save-contact-form_' . $post_id ); ?>
35
- <input type="hidden" id="post_ID" name="post_ID" value="<?php echo (int) $post_id; ?>" />
36
- <input type="hidden" id="wpcf7-id" name="wpcf7-id" value="<?php echo (int) get_post_meta( $post->id(), '_old_cf7_unit_id', true ); ?>" />
37
- <input type="hidden" id="wpcf7-locale" name="wpcf7-locale" value="<?php echo esc_attr( $post->locale ); ?>" />
38
- <input type="hidden" id="hiddenaction" name="action" value="save" />
39
-
40
- <div id="poststuff" class="metabox-holder">
41
-
42
- <div id="titlediv">
43
- <input type="text" id="wpcf7-title" name="wpcf7-title" size="80" value="<?php echo esc_attr( $post->title() ); ?>"<?php echo $disabled; ?> />
44
-
45
- <?php if ( ! $post->initial() ) : ?>
46
- <p class="tagcode">
47
- <?php echo esc_html( __( "Copy this code and paste it into your post, page or text widget content.", 'contact-form-7' ) ); ?><br />
48
-
49
- <input type="text" id="contact-form-anchor-text" onfocus="this.select();" readonly="readonly" class="wp-ui-text-highlight code" />
50
- </p>
51
-
52
- <p class="tagcode" style="display: none;">
53
- <?php echo esc_html( __( "Old code is also available.", 'contact-form-7' ) ); ?><br />
54
-
55
- <input type="text" id="contact-form-anchor-text-old" onfocus="this.select();" readonly="readonly" class="wp-ui-text-highlight code" />
56
- </p>
57
- <?php endif; ?>
58
-
59
- <?php if ( current_user_can( 'wpcf7_edit_contact_form', $post_id ) ) : ?>
60
- <div class="save-contact-form">
61
- <input type="submit" class="button-primary" name="wpcf7-save" value="<?php echo esc_attr( __( 'Save', 'contact-form-7' ) ); ?>" />
62
- </div>
63
- <?php endif; ?>
64
-
65
- <?php if ( current_user_can( 'wpcf7_edit_contact_form', $post_id ) && ! $post->initial() ) : ?>
66
- <div class="actions-link">
67
- <?php $copy_nonce = wp_create_nonce( 'wpcf7-copy-contact-form_' . $post_id ); ?>
68
- <input type="submit" name="wpcf7-copy" class="copy" value="<?php echo esc_attr( __( 'Duplicate', 'contact-form-7' ) ); ?>"
69
- <?php echo "onclick=\"this.form._wpnonce.value = '$copy_nonce'; this.form.action.value = 'copy'; return true;\""; ?> />
70
- |
71
-
72
- <?php $delete_nonce = wp_create_nonce( 'wpcf7-delete-contact-form_' . $post_id ); ?>
73
- <input type="submit" name="wpcf7-delete" class="delete" value="<?php echo esc_attr( __( 'Delete', 'contact-form-7' ) ); ?>"
74
- <?php echo "onclick=\"if (confirm('" .
75
- esc_js( __( "You are about to delete this contact form.\n 'Cancel' to stop, 'OK' to delete.", 'contact-form-7' ) ) .
76
- "')) {this.form._wpnonce.value = '$delete_nonce'; this.form.action.value = 'delete'; return true;} return false;\""; ?> />
77
- </div>
78
- <?php endif; ?>
79
- </div>
80
81
<?php
82
83
- do_action( 'wpcf7_admin_after_general_settings', $post );
84
85
- do_meta_boxes( null, 'form', $post );
86
87
- do_action( 'wpcf7_admin_after_form', $post );
88
89
- do_meta_boxes( null, 'mail', $post );
90
91
- do_action( 'wpcf7_admin_after_mail', $post );
92
93
- do_meta_boxes( null, 'mail_2', $post );
94
95
- do_action( 'wpcf7_admin_after_mail_2', $post );
96
97
- do_meta_boxes( null, 'messages', $post );
98
99
- do_action( 'wpcf7_admin_after_messages', $post );
100
101
- do_meta_boxes( null, 'additional_settings', $post );
102
103
- do_action( 'wpcf7_admin_after_additional_settings', $post );
104
105
- wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
106
- wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
107
108
?>
109
- </div>
110
111
</form>
112
113
<?php endif; ?>
114
115
- </div>
116
117
- <?php do_action( 'wpcf7_admin_footer', $post ); ?>
1
<?php
2
3
// don't load directly
4
+ if ( ! defined( 'ABSPATH' ) ) {
5
die( '-1' );
6
+ }
7
8
?><div class="wrap">
9
13
} else {
14
echo esc_html( __( 'Edit Contact Form', 'contact-form-7' ) );
15
16
+ if ( current_user_can( 'wpcf7_edit_contact_forms' ) ) {
17
+ echo ' <a href="' . esc_url( menu_page_url( 'wpcf7-new', false ) ) . '" class="add-new-h2">' . esc_html( __( 'Add New', 'contact-form-7' ) ) . '</a>';
18
+ }
19
}
20
?></h2>
21
22
<?php do_action( 'wpcf7_admin_notices' ); ?>
23
24
<?php
25
if ( $post ) :
26
27
+ if ( current_user_can( 'wpcf7_edit_contact_form', $post_id ) ) {
28
$disabled = '';
29
+ } else {
30
$disabled = ' disabled="disabled"';
31
+ }
32
?>
33
34
<form method="post" action="<?php echo esc_url( add_query_arg( array( 'post' => $post_id ), menu_page_url( 'wpcf7', false ) ) ); ?>" id="wpcf7-admin-form-element"<?php do_action( 'wpcf7_post_edit_form_tag' ); ?>>
35
+ <?php
36
+ if ( current_user_can( 'wpcf7_edit_contact_form', $post_id ) ) {
37
+ wp_nonce_field( 'wpcf7-save-contact-form_' . $post_id );
38
+ }
39
+ ?>
40
+ <input type="hidden" id="post_ID" name="post_ID" value="<?php echo (int) $post_id; ?>" />
41
+ <input type="hidden" id="wpcf7-locale" name="wpcf7-locale" value="<?php echo esc_attr( $post->locale ); ?>" />
42
+ <input type="hidden" id="hiddenaction" name="action" value="save" />
43
+ <input type="hidden" id="active-tab" name="active-tab" value="<?php echo isset( $_GET['active-tab'] ) ? (int) $_GET['active-tab'] : '0'; ?>" />
44
+
45
+ <div id="poststuff">
46
+ <div id="post-body" class="metabox-holder columns-2">
47
+ <div id="post-body-content">
48
+ <div id="titlediv">
49
+ <div id="titlewrap">
50
+ <label class="screen-reader-text" id="title-prompt-text" for="title"><?php echo esc_html( __( 'Enter title here', 'contact-form-7' ) ); ?></label>
51
+ <?php
52
+ $posttitle_atts = array(
53
+ 'type' => 'text',
54
+ 'name' => 'post_title',
55
+ 'size' => 30,
56
+ 'value' => $post->initial() ? '' : $post->title(),
57
+ 'id' => 'title',
58
+ 'spellcheck' => 'true',
59
+ 'autocomplete' => 'off',
60
+ 'disabled' => current_user_can( 'wpcf7_edit_contact_form', $post_id )
61
+ ? '' : 'disabled' );
62
+
63
+ echo sprintf( '<input %s />', wpcf7_format_atts( $posttitle_atts ) );
64
+ ?>
65
+ </div><!-- #titlewrap -->
66
67
+ <div class="inside">
68
<?php
69
+ if ( ! $post->initial() ) :
70
+ ?>
71
+ <p class="description">
72
+ <label for="wpcf7-shortcode"><?php echo esc_html( __( "Copy this shortcode and paste it into your post, page, or text widget content:", 'contact-form-7' ) ); ?></label>
73
+ <span class="shortcode wp-ui-highlight"><input type="text" id="wpcf7-shortcode" onfocus="this.select();" readonly="readonly" class="large-text code" value="<?php echo esc_attr( $post->shortcode() ); ?>" /></span>
74
+ </p>
75
+ <?php
76
+ if ( $old_shortcode = $post->shortcode( array( 'use_old_format' => true ) ) ) :
77
+ ?>
78
+ <p class="description">
79
+ <label for="wpcf7-shortcode-old"><?php echo esc_html( __( "You can also use this old-style shortcode:", 'contact-form-7' ) ); ?></label>
80
+ <span class="shortcode old"><input type="text" id="wpcf7-shortcode-old" onfocus="this.select();" readonly="readonly" class="large-text code" value="<?php echo esc_attr( $old_shortcode ); ?>" /></span>
81
+ </p>
82
+ <?php
83
+ endif;
84
+ endif;
85
+ ?>
86
+ </div>
87
+ </div><!-- #titlediv -->
88
+ </div><!-- #post-body-content -->
89
90
+ <div id="postbox-container-1" class="postbox-container">
91
+ <?php if ( current_user_can( 'wpcf7_edit_contact_form', $post_id ) ) : ?>
92
+ <div id="submitdiv" class="postbox">
93
+ <h3><?php echo esc_html( __( 'Status', 'contact-form-7' ) ); ?></h3>
94
+ <div class="inside">
95
+ <div class="submitbox" id="submitpost">
96
97
+ <div id="minor-publishing-actions">
98
99
+ <div class="hidden">
100
+ <input type="submit" class="button-primary" name="wpcf7-save" value="<?php echo esc_attr( __( 'Save', 'contact-form-7' ) ); ?>" />
101
+ </div>
102
+
103
+ <?php
104
+ if ( ! $post->initial() ) :
105
+ $copy_nonce = wp_create_nonce( 'wpcf7-copy-contact-form_' . $post_id );
106
+ ?>
107
+ <input type="submit" name="wpcf7-copy" class="copy button" value="<?php echo esc_attr( __( 'Duplicate', 'contact-form-7' ) ); ?>" <?php echo "onclick=\"this.form._wpnonce.value = '$copy_nonce'; this.form.action.value = 'copy'; return true;\""; ?> />
108
+ <?php endif; ?>
109
+ </div><!-- #minor-publishing-actions -->
110
111
+ <div id="major-publishing-actions">
112
113
+ <?php
114
+ if ( ! $post->initial() ) :
115
+ $delete_nonce = wp_create_nonce( 'wpcf7-delete-contact-form_' . $post_id );
116
+ ?>
117
+ <div id="delete-action">
118
+ <input type="submit" name="wpcf7-delete" class="delete submitdelete" value="<?php echo esc_attr( __( 'Delete', 'contact-form-7' ) ); ?>" <?php echo "onclick=\"if (confirm('" . esc_js( __( "You are about to delete this contact form.\n 'Cancel' to stop, 'OK' to delete.", 'contact-form-7' ) ) . "')) {this.form._wpnonce.value = '$delete_nonce'; this.form.action.value = 'delete'; return true;} return false;\""; ?> />
119
+ </div><!-- #delete-action -->
120
+ <?php endif; ?>
121
122
+ <div class="save-contact-form textright">
123
+ <input type="submit" class="button-primary" name="wpcf7-save" value="<?php echo esc_attr( __( 'Save', 'contact-form-7' ) ); ?>" />
124
+ </div>
125
+ </div><!-- #major-publishing-actions -->
126
+ </div><!-- #submitpost -->
127
+ </div>
128
+ </div><!-- #submitdiv -->
129
+ <?php endif; ?>
130
131
+ <div id="informationdiv" class="postbox">
132
+ <h3><?php echo esc_html( __( 'Information', 'contact-form-7' ) ); ?></h3>
133
+ <div class="inside">
134
+ <ul>
135
+ <li><?php echo wpcf7_link( __( 'http://contactform7.com/docs/', 'contact-form-7' ), __( 'Docs', 'contact-form-7' ) ); ?></li>
136
+ <li><?php echo wpcf7_link( __( 'http://contactform7.com/faq/', 'contact-form-7' ), __( 'FAQ', 'contact-form-7' ) ); ?></li>
137
+ <li><?php echo wpcf7_link( __( 'http://contactform7.com/support/', 'contact-form-7' ), __( 'Support', 'contact-form-7' ) ); ?></li>
138
+ </ul>
139
+ </div>
140
+ </div><!-- #informationdiv -->
141
142
+ </div><!-- #postbox-container-1 -->
143
144
+ <div id="postbox-container-2" class="postbox-container">
145
+ <div id="contact-form-editor">
146
+ <?php
147
148
+ $editor = new WPCF7_Editor( $post );
149
+ $panels = array();
150
+
151
+ if ( current_user_can( 'wpcf7_edit_contact_form', $post_id ) ) {
152
+ $panels = array(
153
+ 'form-panel' => array(
154
+ 'title' => __( 'Form', 'contact-form-7' ),
155
+ 'callback' => 'wpcf7_editor_panel_form' ),
156
+ 'mail-panel' => array(
157
+ 'title' => __( 'Mail', 'contact-form-7' ),
158
+ 'callback' => 'wpcf7_editor_panel_mail' ),
159
+ 'messages-panel' => array(
160
+ 'title' => __( 'Messages', 'contact-form-7' ),
161
+ 'callback' => 'wpcf7_editor_panel_messages' ) );
162
+
163
+ $additional_settings = trim( $post->prop( 'additional_settings' ) );
164
+ $additional_settings = explode( "\n", $additional_settings );
165
+ $additional_settings = array_filter( $additional_settings );
166
+ $additional_settings = count( $additional_settings );
167
+
168
+ $panels['additional-settings-panel'] = array(
169
+ 'title' => $additional_settings
170
+ ? sprintf(
171
+ __( 'Additional Settings (%d)', 'contact-form-7' ),
172
+ $additional_settings )
173
+ : __( 'Additional Settings', 'contact-form-7' ),
174
+ 'callback' => 'wpcf7_editor_panel_additional_settings' );
175
+ }
176
177
+ $panels = apply_filters( 'wpcf7_editor_panels', $panels );
178
179
+ foreach ( $panels as $id => $panel ) {
180
+ $editor->add_panel( $id, $panel['title'], $panel['callback'] );
181
+ }
182
183
+ $editor->display();
184
?>
185
+ </div><!-- #contact-form-editor -->
186
+
187
+ <?php if ( current_user_can( 'wpcf7_edit_contact_form', $post_id ) ) : ?>
188
+ <p class="submit"><input type="submit" class="button-primary" name="wpcf7-save" value="<?php echo esc_attr( __( 'Save', 'contact-form-7' ) ); ?>" /></p>
189
+ <?php endif; ?>
190
191
+ </div><!-- #postbox-container-2 -->
192
+
193
+ </div><!-- #post-body -->
194
+ <br class="clear" />
195
+ </div><!-- #poststuff -->
196
</form>
197
198
<?php endif; ?>
199
200
+ </div><!-- .wrap -->
201
+
202
+ <?php
203
+
204
+ $tag_generator = WPCF7_TagGenerator::get_instance();
205
+ $tag_generator->print_panels( $post );
206
207
+ do_action( 'wpcf7_admin_footer', $post );
admin/images/dropdown.gif DELETED
Binary file
admin/images/fade-butt.png DELETED
Binary file
admin/includes/class-contact-forms-list-table.php CHANGED
@@ -137,17 +137,15 @@ class WPCF7_Contact_Form_List_Table extends WP_List_Table {
137
}
138
139
function column_shortcode( $item ) {
140
- $shortcodes = array(
141
- sprintf( '[contact-form-7 id="%1$d" title="%2$s"]',
142
- $item->id(), $item->title() ) );
143
144
$output = '';
145
146
foreach ( $shortcodes as $shortcode ) {
147
- $output .= "\n" . '<input type="text"'
148
. ' onfocus="this.select();" readonly="readonly"'
149
. ' value="' . esc_attr( $shortcode ) . '"'
150
- . ' class="shortcode-in-list-table wp-ui-text-highlight code" />';
151
}
152
153
return trim( $output );
@@ -173,5 +171,3 @@ class WPCF7_Contact_Form_List_Table extends WP_List_Table {
173
return '<abbr title="' . $t_time . '">' . $h_time . '</abbr>';
174
}
175
}
176
-
177
- ?>
137
}
138
139
function column_shortcode( $item ) {
140
+ $shortcodes = array( $item->shortcode() );
141
142
$output = '';
143
144
foreach ( $shortcodes as $shortcode ) {
145
+ $output .= "\n" . '<span class="shortcode"><input type="text"'
146
. ' onfocus="this.select();" readonly="readonly"'
147
. ' value="' . esc_attr( $shortcode ) . '"'
148
+ . ' class="large-text code" /></span>';
149
}
150
151
return trim( $output );
171
return '<abbr title="' . $t_time . '">' . $h_time . '</abbr>';
172
}
173
}
admin/includes/editor.php ADDED
@@ -0,0 +1,201 @@
1
+ <?php
2
+
3
+ class WPCF7_Editor {
4
+
5
+ private $contact_form;
6
+ private $panels = array();
7
+
8
+ public function __construct( WPCF7_ContactForm $contact_form ) {
9
+ $this->contact_form = $contact_form;
10
+ }
11
+
12
+ public function add_panel( $id, $title, $callback ) {
13
+ if ( wpcf7_is_name( $id ) ) {
14
+ $this->panels[$id] = array(
15
+ 'title' => $title,
16
+ 'callback' => $callback );
17
+ }
18
+ }
19
+
20
+ public function display() {
21
+ if ( empty( $this->panels ) ) {
22
+ return;
23
+ }
24
+
25
+ echo '<ul id="contact-form-editor-tabs">';
26
+
27
+ foreach ( $this->panels as $id => $panel ) {
28
+ echo sprintf( '<li id="%1$s-tab"><a href="#%1$s">%2$s</a></li>',
29
+ esc_attr( $id ), esc_html( $panel['title'] ) );
30
+ }
31
+
32
+ echo '</ul>';
33
+
34
+ foreach ( $this->panels as $id => $panel ) {
35
+ echo sprintf( '<div class="contact-form-editor-panel" id="%1$s">',
36
+ esc_attr( $id ) );
37
+ call_user_func( $panel['callback'], $this->contact_form );
38
+ echo '</div>';
39
+ }
40
+ }
41
+ }
42
+
43
+ function wpcf7_editor_panel_form( $post ) {
44
+ ?>
45
+ <h3><?php echo esc_html( __( 'Form', 'contact-form-7' ) ); ?></h3>
46
+
47
+ <?php
48
+ $tag_generator = WPCF7_TagGenerator::get_instance();
49
+ $tag_generator->print_buttons();
50
+ ?>
51
+
52
+ <textarea id="wpcf7-form" name="wpcf7-form" cols="100" rows="24" class="large-text code"><?php echo esc_textarea( $post->prop( 'form' ) ); ?></textarea>
53
+ <?php
54
+ }
55
+
56
+ function wpcf7_editor_panel_mail( $post ) {
57
+ wpcf7_editor_box_mail( $post );
58
+
59
+ echo '<br class="clear" />';
60
+
61
+ wpcf7_editor_box_mail( $post, array(
62
+ 'id' => 'wpcf7-mail-2',
63
+ 'name' => 'mail_2',
64
+ 'title' => __( 'Mail (2)', 'contact-form-7' ),
65
+ 'use' => __( 'Use Mail (2)', 'contact-form-7' ) ) );
66
+ }
67
+
68
+ function wpcf7_editor_box_mail( $post, $args = '' ) {
69
+ $args = wp_parse_args( $args, array(
70
+ 'id' => 'wpcf7-mail',
71
+ 'name' => 'mail',
72
+ 'title' => __( 'Mail', 'contact-form-7' ),
73
+ 'use' => null ) );
74
+
75
+ $id = esc_attr( $args['id'] );
76
+
77
+ $mail = wp_parse_args( $post->prop( $args['name'] ), array(
78
+ 'active' => false, 'recipient' => '', 'sender' => '',
79
+ 'subject' => '', 'body' => '', 'additional_headers' => '',
80
+ 'attachments' => '', 'use_html' => false, 'exclude_blank' => false ) );
81
+
82
+ ?>
83
+ <div class="contact-form-editor-box-mail" id="<?php echo $id; ?>">
84
+ <h3><?php echo esc_html( $args['title'] ); ?></h3>
85
+
86
+ <?php
87
+ if ( ! empty( $args['use'] ) ) :
88
+ ?>
89
+ <label for="<?php echo $id; ?>-active"><input type="checkbox" id="<?php echo $id; ?>-active" name="<?php echo $id; ?>-active" class="toggle-form-table" value="1"<?php echo ( $mail['active'] ) ? ' checked="checked"' : ''; ?> /> <?php echo esc_html( $args['use'] ); ?></label>
90
+ <p class="description"><?php echo esc_html( __( "Mail (2) is an additional mail template often used as an autoresponder.", 'contact-form-7' ) ); ?></p>
91
+ <?php
92
+ endif;
93
+ ?>
94
+
95
+ <fieldset>
96
+ <legend><?php echo esc_html( __( "In the following fields, you can use these mail-tags:", 'contact-form-7' ) ); ?><br />
97
+ <?php wpcf7_mail_tags_suggestion( $post ); ?></legend>
98
+ <table class="form-table">
99
+ <tbody>
100
+ <tr>
101
+ <th scope="row">
102
+ <label for="<?php echo $id; ?>-recipient"><?php echo esc_html( __( 'To', 'contact-form-7' ) ); ?></label>
103
+ </th>
104
+ <td>
105
+ <input type="text" id="<?php echo $id; ?>-recipient" name="<?php echo $id; ?>-recipient" class="large-text code" size="70" value="<?php echo esc_attr( $mail['recipient'] ); ?>" />
106
+ </td>
107
+ </tr>
108
+
109
+ <tr>
110
+ <th scope="row">
111
+ <label for="<?php echo $id; ?>-sender"><?php echo esc_html( __( 'From', 'contact-form-7' ) ); ?></label>
112
+ </th>
113
+ <td>
114
+ <input type="text" id="<?php echo $id; ?>-sender" name="<?php echo $id; ?>-sender" class="large-text code" size="70" value="<?php echo esc_attr( $mail['sender'] ); ?>" />
115
+ </td>
116
+ </tr>
117
+
118
+ <tr>
119
+ <th scope="row">
120
+ <label for="<?php echo $id; ?>-subject"><?php echo esc_html( __( 'Subject', 'contact-form-7' ) ); ?></label>
121
+ </th>
122
+ <td>
123
+ <input type="text" id="<?php echo $id; ?>-subject" name="<?php echo $id; ?>-subject" class="large-text code" size="70" value="<?php echo esc_attr( $mail['subject'] ); ?>" />
124
+ </td>
125
+ </tr>
126
+
127
+ <tr>
128
+ <th scope="row">
129
+ <label for="<?php echo $id; ?>-additional-headers"><?php echo esc_html( __( 'Additional Headers', 'contact-form-7' ) ); ?></label>
130
+ </th>
131
+ <td>
132
+ <textarea id="<?php echo $id; ?>-additional-headers" name="<?php echo $id; ?>-additional-headers" cols="100" rows="4" class="large-text code"><?php echo esc_textarea( $mail['additional_headers'] ); ?></textarea>
133
+ </td>
134
+ </tr>
135
+
136
+ <tr>
137
+ <th scope="row">
138
+ <label for="<?php echo $id; ?>-body"><?php echo esc_html( __( 'Message Body', 'contact-form-7' ) ); ?></label>
139
+ </th>
140
+ <td>
141
+ <textarea id="<?php echo $id; ?>-body" name="<?php echo $id; ?>-body" cols="100" rows="18" class="large-text code"><?php echo esc_textarea( $mail['body'] ); ?></textarea>
142
+
143
+ <p><label for="<?php echo $id; ?>-exclude-blank"><input type="checkbox" id="<?php echo $id; ?>-exclude-blank" name="<?php echo $id; ?>-exclude-blank" value="1"<?php echo ( ! empty( $mail['exclude_blank'] ) ) ? ' checked="checked"' : ''; ?> /> <?php echo esc_html( __( 'Exclude lines with blank mail-tags from output', 'contact-form-7' ) ); ?></label></p>
144
+
145
+ <p><label for="<?php echo $id; ?>-use-html"><input type="checkbox" id="<?php echo $id; ?>-use-html" name="<?php echo $id; ?>-use-html" value="1"<?php echo ( $mail['use_html'] ) ? ' checked="checked"' : ''; ?> /> <?php echo esc_html( __( 'Use HTML content type', 'contact-form-7' ) ); ?></label></p>
146
+ </td>
147
+ </tr>
148
+
149
+ <tr>
150
+ <th scope="row">
151
+ <label for="<?php echo $id; ?>-attachments"><?php echo esc_html( __( 'File Attachments', 'contact-form-7' ) ); ?></label>
152
+ </th>
153
+ <td>
154
+ <textarea id="<?php echo $id; ?>-attachments" name="<?php echo $id; ?>-attachments" cols="100" rows="4" class="large-text code"><?php echo esc_textarea( $mail['attachments'] ); ?></textarea>
155
+ </td>
156
+ </tr>
157
+ </tbody>
158
+ </table>
159
+ </fieldset>
160
+ </div>
161
+ <?php
162
+ }
163
+
164
+ function wpcf7_editor_panel_messages( $post ) {
165
+ $messages = wpcf7_messages();
166
+ ?>
167
+ <h3><?php echo esc_html( __( 'Messages', 'contact-form-7' ) ); ?></h3>
168
+ <fieldset>
169
+ <legend><?php echo esc_html( __( 'Edit messages used in the following situations.', 'contact-form-7' ) ); ?></legend>
170
+ <?php
171
+
172
+ foreach ( $messages as $key => $arr ) {
173
+ $field_name = 'wpcf7-message-' . strtr( $key, '_', '-' );
174
+ ?>
175
+ <p class="description">
176
+ <label for="<?php echo $field_name; ?>"><?php echo esc_html( $arr['description'] ); ?><br />
177
+ <input type="text" id="<?php echo $field_name; ?>" name="<?php echo $field_name; ?>" class="large-text" size="70" value="<?php echo esc_attr( $post->message( $key, false ) ); ?>" />
178
+ </label>
179
+ </p>
180
+ <?php
181
+ }
182
+ ?>
183
+ </fieldset>
184
+ <?php
185
+ }
186
+
187
+ function wpcf7_editor_panel_additional_settings( $post ) {
188
+ $desc_link = wpcf7_link(
189
+ __( 'http://contactform7.com/additional-settings/', 'contact-form-7' ),
190
+ __( 'Additional Settings', 'contact-form-7' ) );
191
+ $description = __( "You can add customization code snippets here. For details, see %s.", 'contact-form-7' );
192
+ $description = sprintf( esc_html( $description ), $desc_link );
193
+
194
+ ?>
195
+ <h3><?php echo esc_html( __( 'Additional Settings', 'contact-form-7' ) ); ?></h3>
196
+ <fieldset>
197
+ <legend><?php echo $description; ?></legend>
198
+ <textarea id="wpcf7-additional-settings" name="wpcf7-additional-settings" cols="100" rows="8" class="large-text"><?php echo esc_textarea( $post->prop( 'additional_settings' ) ); ?></textarea>
199
+ </fieldset>
200
+ <?php
201
+ }
admin/includes/help-tabs.php CHANGED
@@ -87,12 +87,10 @@ class WPCF7_Help_Tabs {
87
88
public function sidebar() {
89
$content = '<p><strong>' . __( 'For more information:', 'contact-form-7' ) . '</strong></p>';
90
- $content .= '<p>' . __( '<a href="http://contactform7.com/docs/" target="_blank">Docs</a>', 'contact-form-7' ) . '</p>';
91
- $content .= '<p>' . __( '<a href="http://contactform7.com/faq/" target="_blank">FAQ</a>', 'contact-form-7' ) . '</p>';
92
- $content .= '<p>' . __( '<a href="http://contactform7.com/support/" target="_blank">Support</a>', 'contact-form-7' ) . '</p>';
93
94
$this->screen->set_help_sidebar( $content );
95
}
96
}
97
-
98
- ?>
87
88
public function sidebar() {
89
$content = '<p><strong>' . __( 'For more information:', 'contact-form-7' ) . '</strong></p>';
90
+ $content .= '<p>' . wpcf7_link( __( 'http://contactform7.com/docs/', 'contact-form-7' ), __( 'Docs', 'contact-form-7' ) ) . '</p>';
91
+ $content .= '<p>' . wpcf7_link( __( 'http://contactform7.com/faq/', 'contact-form-7' ), __( 'FAQ', 'contact-form-7' ) ) . '</p>';
92
+ $content .= '<p>' . wpcf7_link( __( 'http://contactform7.com/support/', 'contact-form-7' ), __( 'Support', 'contact-form-7' ) ) . '</p>';
93
94
$this->screen->set_help_sidebar( $content );
95
}
96
}
admin/includes/meta-boxes.php DELETED
@@ -1,142 +0,0 @@
1
- <?php
2
-
3
- /* Form */
4
-
5
- function wpcf7_form_meta_box( $post ) {
6
- ?>
7
- <div class="half-left"><textarea id="wpcf7-form" name="wpcf7-form" cols="100" rows="24"><?php echo esc_textarea( $post->prop( 'form' ) ); ?></textarea></div>
8
-
9
- <div class="half-right"><div id="taggenerator"></div></div>
10
-
11
- <br class="clear" />
12
- <?php
13
- }
14
-
15
- /* Mail */
16
-
17
- function wpcf7_mail_meta_box( $post, $box ) {
18
- $args = isset( $box['args'] ) && is_array( $box['args'] )
19
- ? $box['args'] : array();
20
-
21
- $args = wp_parse_args( $args, array(
22
- 'id' => 'wpcf7-mail',
23
- 'name' => 'mail',
24
- 'use' => null ) );
25
-
26
- $id = esc_attr( $args['id'] );
27
-
28
- $mail = wp_parse_args( $post->prop( $args['name'] ), array(
29
- 'active' => false, 'recipient' => '', 'sender' => '',
30
- 'subject' => '', 'body' => '', 'additional_headers' => '',
31
- 'attachments' => '', 'use_html' => false, 'exclude_blank' => false ) );
32
-
33
- if ( ! empty( $args['use'] ) ) :
34
- ?>
35
- <div class="mail-field">
36
- <label for="<?php echo $id; ?>-active">
37
- <input type="checkbox" id="<?php echo $id; ?>-active" name="<?php echo $id; ?>-active" class="check-if-these-fields-are-active" value="1"<?php echo ( $mail['active'] ) ? ' checked="checked"' : ''; ?> />
38
- <?php echo esc_html( $args['use'] ); ?>
39
- </label>
40
- <div class="pseudo-hr"></div>
41
- </div>
42
-
43
- <br class="clear" />
44
- <?php endif; ?>
45
-
46
- <div class="mail-fields">
47
- <div class="half-left">
48
- <div class="mail-field">
49
- <label for="<?php echo $id; ?>-recipient"><?php echo esc_html( __( 'To:', 'contact-form-7' ) ); ?></label><br />
50
- <input type="text" id="<?php echo $id; ?>-recipient" name="<?php echo $id; ?>-recipient" class="wide" size="70" value="<?php echo esc_attr( $mail['recipient'] ); ?>" />
51
- </div>
52
-
53
- <div class="mail-field">
54
- <label for="<?php echo $id; ?>-sender"><?php echo esc_html( __( 'From:', 'contact-form-7' ) ); ?></label><br />
55
- <input type="text" id="<?php echo $id; ?>-sender" name="<?php echo $id; ?>-sender" class="wide" size="70" value="<?php echo esc_attr( $mail['sender'] ); ?>" />
56
- </div>
57
-
58
- <div class="mail-field">
59
- <label for="<?php echo $id; ?>-subject"><?php echo esc_html( __( 'Subject:', 'contact-form-7' ) ); ?></label><br />
60
- <input type="text" id="<?php echo $id; ?>-subject" name="<?php echo $id; ?>-subject" class="wide" size="70" value="<?php echo esc_attr( $mail['subject'] ); ?>" />
61
- </div>
62
-
63
- <div class="pseudo-hr"></div>
64
-
65
- <div class="mail-field">
66
- <label for="<?php echo $id; ?>-additional-headers"><?php echo esc_html( __( 'Additional headers:', 'contact-form-7' ) ); ?></label><br />
67
- <textarea id="<?php echo $id; ?>-additional-headers" name="<?php echo $id; ?>-additional-headers" cols="100" rows="2"><?php echo esc_textarea( $mail['additional_headers'] ); ?></textarea>
68
- </div>
69
-
70
- <div class="mail-field">
71
- <label for="<?php echo $id; ?>-attachments"><?php echo esc_html( __( 'File attachments:', 'contact-form-7' ) ); ?></label><br />
72
- <textarea id="<?php echo $id; ?>-attachments" name="<?php echo $id; ?>-attachments" cols="100" rows="2"><?php echo esc_textarea( $mail['attachments'] ); ?></textarea>
73
- </div>
74
-
75
- <div class="pseudo-hr"></div>
76
-
77
- <div class="mail-field">
78
-
79
- <label for="<?php echo $id; ?>-use-html">
80
- <input type="checkbox" id="<?php echo $id; ?>-use-html" name="<?php echo $id; ?>-use-html" value="1"<?php echo ( $mail['use_html'] ) ? ' checked="checked"' : ''; ?> />
81
- <?php echo esc_html( __( 'Use HTML content type', 'contact-form-7' ) ); ?>
82
- </label>
83
- </div>
84
- </div>
85
-
86
- <div class="half-right">
87
- <div class="mail-field">
88
- <label for="<?php echo $id; ?>-body"><?php echo esc_html( __( 'Message body:', 'contact-form-7' ) ); ?></label><br />
89
- <textarea id="<?php echo $id; ?>-body" name="<?php echo $id; ?>-body" cols="100" rows="18"><?php echo esc_textarea( $mail['body'] ); ?></textarea>
90
- </div>
91
-
92
- <div class="mail-field">
93
-
94
- <label for="<?php echo $id; ?>-exclude-blank">
95
- <input type="checkbox" id="<?php echo $id; ?>-exclude-blank" name="<?php echo $id; ?>-exclude-blank" value="1"<?php echo ( ! empty( $mail['exclude_blank'] ) ) ? ' checked="checked"' : ''; ?> />
96
- <?php echo esc_html( __( 'Exclude lines with blank mail-tags from output', 'contact-form-7' ) ); ?>
97
- </label>
98
- </div>
99
- </div>
100
-
101
- <br class="clear" />
102
- </div>
103
- <?php
104
- }
105
-
106
- function wpcf7_messages_meta_box( $post ) {
107
- $updated = isset( $_REQUEST['message'] )
108
- && in_array( $_REQUEST['message'], array( 'saved', 'created' ) );
109
- $count = 0;
110
- $messages = wpcf7_messages();
111
-
112
- foreach ( $messages as $key => $arr ) {
113
- $count += 1;
114
- $field_name = 'wpcf7-message-' . strtr( $key, '_', '-' );
115
-
116
- ?>
117
- <div class="message-field">
118
- <p class="description"><label for="<?php echo $field_name; ?>"><?php echo esc_html( $arr['description'] ); ?></label></p>
119
- <input type="text" id="<?php echo $field_name; ?>" name="<?php echo $field_name; ?>" class="wide" size="70" value="<?php echo esc_attr( $post->message( $key, false ) ); ?>" />
120
- </div>
121
- <?php
122
-
123
- if ( ! $updated && 10 <= count( $messages ) ) {
124
- if ( 6 == $count ) {
125
- echo '<p><a href="#" id="show-all-messages">' . esc_html( __( 'Show all messages', 'contact-form-7' ) ) . '</a></p>' . "\n";
126
- echo '<div class="hide-initially">';
127
- }
128
-
129
- if ( count( $messages ) == $count ) {
130
- echo '</div>';
131
- }
132
- }
133
- }
134
- }
135
-
136
- function wpcf7_additional_settings_meta_box( $post ) {
137
- ?>
138
- <textarea id="wpcf7-additional-settings" name="wpcf7-additional-settings" cols="100" rows="8"><?php echo esc_textarea( $post->prop( 'additional_settings' ) ); ?></textarea>
139
- <?php
140
- }
141
-
142
- ?>
admin/includes/tag-generator.php ADDED
@@ -0,0 +1,75 @@
1
+ <?php
2
+
3
+ class WPCF7_TagGenerator {
4
+
5
+ private static $instance;
6
+
7
+ private $panels = array();
8
+
9
+ private function __construct() {}
10
+
11
+ public static function get_instance() {
12
+ if ( empty( self::$instance ) ) {
13
+ self::$instance = new self;
14
+ }
15
+
16
+ return self::$instance;
17
+ }
18
+
19
+ public function add( $id, $title, $callback, $options = array() ) {
20
+ $id = trim( $id );
21
+
22
+ if ( '' === $id || ! wpcf7_is_name( $id ) ) {
23
+ return false;
24
+ }
25
+
26
+ $this->panels[$id] = array(
27
+ 'title' => $title,
28
+ 'content' => 'tag-generator-panel-' . $id,
29
+ 'options' => $options,
30
+ 'callback' => $callback );
31
+
32
+ return true;
33
+ }
34
+
35
+ public function print_buttons() {
36
+ echo '<span id="tag-generator-list">';
37
+
38
+ foreach ( (array) $this->panels as $panel ) {
39
+ echo sprintf(
40
+ '<a href="#TB_inline?width=900&height=500&inlineId=%1$s" class="thickbox button" title="%2$s">%3$s</a>',
41
+ esc_attr( $panel['content'] ),
42
+ esc_attr( sprintf(
43
+ __( 'Form-tag Generator: %s', 'contact-form-7' ),
44
+ $panel['title'] ) ),
45
+ esc_html( $panel['title'] ) );
46
+ }
47
+
48
+ echo '</span>';
49
+ }
50
+
51
+ public function print_panels( WPCF7_ContactForm $contact_form ) {
52
+ foreach ( (array) $this->panels as $id => $panel ) {
53
+ $callback = $panel['callback'];
54
+
55
+ $options = wp_parse_args( $panel['options'], array() );
56
+ $options = array_merge( $options, array(
57
+ 'id' => $id,
58
+ 'title' => $panel['title'],
59
+ 'content' => $panel['content'] ) );
60
+
61
+ if ( is_callable( $callback ) ) {
62
+ echo sprintf( '<div id="%s" class="hidden">',
63
+ esc_attr( $options['content'] ) );
64
+ echo sprintf(
65
+ '<form action="" class="tag-generator-panel" data-id="%s">',
66
+ $options['id'] );
67
+
68
+ call_user_func( $callback, $contact_form, $options );
69
+
70
+ echo '</form></div>';
71
+ }
72
+ }
73
+ }
74
+
75
+ }
admin/js/scripts.js CHANGED
@@ -1,99 +1,116 @@
1
(function($) {
2
3
- $(function() {
4
- try {
5
- var welcomePanel = $('#welcome-panel');
6
- var updateWelcomePanel;
7
-
8
- updateWelcomePanel = function( visible ) {
9
- $.post( ajaxurl, {
10
- action: 'wpcf7-update-welcome-panel',
11
- visible: visible,
12
- welcomepanelnonce: $( '#welcomepanelnonce' ).val()
13
- });
14
- };
15
-
16
- $('a.welcome-panel-close', welcomePanel).click(function(event) {
17
- event.preventDefault();
18
- welcomePanel.addClass('hidden');
19
- updateWelcomePanel( 0 );
20
- });
21
-
22
- $('div.cf7com-links').insertAfter($('div.wrap h2:first'));
23
-
24
- $.extend($.tgPanes, _wpcf7.tagGenerators);
25
- $('#taggenerator').tagGenerator(_wpcf7.generateTag, {
26
- dropdownIconUrl: _wpcf7.pluginUrl + '/admin/images/dropdown.gif',
27
- fadebuttImageUrl: _wpcf7.pluginUrl + '/admin/images/fade-butt.png' });
28
-
29
- $('input#wpcf7-title:disabled').css({cursor: 'default'});
30
-
31
- $('input#wpcf7-title').mouseover(function() {
32
- $(this).not('.focus').addClass('mouseover');
33
- });
34
-
35
- $('input#wpcf7-title').mouseout(function() {
36
- $(this).removeClass('mouseover');
37
- });
38
-
39
- $('input#wpcf7-title').focus(function() {
40
- $(this).addClass('focus').removeClass('mouseover');
41
- });
42
-
43
- $('input#wpcf7-title').blur(function() {
44
- $(this).removeClass('focus');
45
- });
46
47
- $('input#wpcf7-title').change(function() {
48
- updateTag();
49
});
50
51
- $('#show-all-messages').click(function() {
52
- $('#messagesdiv .hide-initially').slideDown();
53
- $(this).closest('p').remove();
54
- return false;
55
- });
56
57
- updateTag();
58
59
- $('.check-if-these-fields-are-active').each(function(index) {
60
- if (! $(this).is(':checked'))
61
- $(this).parent().siblings('.mail-fields').hide();
62
63
- $(this).click(function() {
64
- if ($(this).parent().siblings('.mail-fields').is(':hidden')
65
- && $(this).is(':checked')) {
66
- $(this).parent().siblings('.mail-fields').slideDown('fast');
67
- } else if ($(this).parent().siblings('.mail-fields').is(':visible')
68
- && $(this).not(':checked')) {
69
- $(this).parent().siblings('.mail-fields').slideUp('fast');
70
}
71
- });
72
});
73
74
- postboxes.add_postbox_toggles(_wpcf7.screenId);
75
-
76
- } catch (e) {
77
- }
78
});
79
80
- function updateTag() {
81
- var title = $('input#wpcf7-title').val();
82
-
83
- if (title)
84
- title = title.replace(/["'\[\]]/g, '');
85
-
86
- $('input#wpcf7-title').val(title);
87
- var postId = $('input#post_ID').val();
88
- var tag = '[contact-form-7 id="' + postId + '" title="' + title + '"]';
89
- $('input#contact-form-anchor-text').val(tag);
90
-
91
- var oldId = $('input#wpcf7-id').val();
92
-
93
- if (0 != oldId) {
94
- var tagOld = '[contact-form ' + oldId + ' "' + title + '"]';
95
- $('input#contact-form-anchor-text-old').val(tagOld).parent('p.tagcode').show();
96
}
97
- }
98
99
- })(jQuery);
1
(function($) {
2
3
+ if (typeof _wpcf7 == 'undefined' || _wpcf7 === null) {
4
+ _wpcf7 = {};
5
+ }
6
7
+ $(function() {
8
+ var welcomePanel = $('#welcome-panel');
9
+ var updateWelcomePanel;
10
+
11
+ updateWelcomePanel = function( visible ) {
12
+ $.post( ajaxurl, {
13
+ action: 'wpcf7-update-welcome-panel',
14
+ visible: visible,
15
+ welcomepanelnonce: $( '#welcomepanelnonce' ).val()
16
});
17
+ };
18
+
19
+ $('a.welcome-panel-close', welcomePanel).click(function(event) {
20
+ event.preventDefault();
21
+ welcomePanel.addClass('hidden');
22
+ updateWelcomePanel( 0 );
23
+ });
24
+
25
+ $('#contact-form-editor').tabs({
26
+ active: _wpcf7.activeTab,
27
+ activate: function(event, ui) {
28
+ $('#active-tab').val(ui.newTab.index());
29
+ }
30
+ });
31
+
32
+ $('input:checkbox.toggle-form-table').click(function(event) {
33
+ $(this).wpcf7ToggleFormTable();
34
+ }).wpcf7ToggleFormTable();
35
+
36
+ if ('' == $('#title').val()) {
37
+ $('#title').focus();
38
+ }
39
40
+ $.wpcf7TitleHint();
41
42
+ $('.contact-form-editor-box-mail span.mailtag').click(function(event) {
43
+ var range = document.createRange();
44
+ range.selectNodeContents(this);
45
+ window.getSelection().addRange(range);
46
+ });
47
48
+ $(window).on('beforeunload', function(event) {
49
+ var changed = false;
50
51
+ $('#wpcf7-admin-form-element :input[type!="hidden"]').each(function() {
52
+ if ($(this).is(':checkbox, :radio')) {
53
+ if (this.defaultChecked != $(this).is(':checked')) {
54
+ changed = true;
55
+ }
56
+ } else {
57
+ if (this.defaultValue != $(this).val()) {
58
+ changed = true;
59
}
60
+ }
61
});
62
63
+ if (changed) {
64
+ event.returnValue = _wpcf7.saveAlert;
65
+ return _wpcf7.saveAlert;
66
+ }
67
+ });
68
+
69
+ $('#wpcf7-admin-form-element').submit(function() {
70
+ if ('copy' != this.action.value) {
71
+ $(window).off('beforeunload');
72
+ }
73
+ });
74
});
75
76
+ $.fn.wpcf7ToggleFormTable = function() {
77
+ return this.each(function() {
78
+ var formtable = $(this).closest('.contact-form-editor-box-mail').find('fieldset');
79
+
80
+ if ($(this).is(':checked')) {
81
+ formtable.removeClass('hidden');
82
+ } else {
83
+ formtable.addClass('hidden');
84
+ }
85
+ });
86
+ };
87
+
88
+ /**
89
+ * Copied from wptitlehint() in wp-admin/js/post.js
90
+ */
91
+ $.wpcf7TitleHint = function() {
92
+ var title = $('#title');
93
+ var titleprompt = $('#title-prompt-text');
94
+
95
+ if ('' == title.val()) {
96
+ titleprompt.removeClass('screen-reader-text');
97
}
98
99
+ titleprompt.click(function() {
100
+ $(this).addClass('screen-reader-text');
101
+ title.focus();
102
+ });
103
+
104
+ title.blur(function() {
105
+ if ('' == $(this).val()) {
106
+ titleprompt.removeClass('screen-reader-text');
107
+ }
108
+ }).focus(function() {
109
+ titleprompt.addClass('screen-reader-text');
110
+ }).keydown(function(e) {
111
+ titleprompt.addClass('screen-reader-text');
112
+ $(this).unbind(e);
113
+ });
114
+ };
115
+
116
+ })(jQuery);
admin/js/tag-generator.js ADDED
@@ -0,0 +1,241 @@
1
+ (function($) {
2
+
3
+ if (typeof _wpcf7 == 'undefined' || _wpcf7 === null) {
4
+ _wpcf7 = {};
5
+ }
6
+
7
+ _wpcf7.taggen = {};
8
+
9
+ $(function() {
10
+ $('form.tag-generator-panel').each(function() {
11
+ _wpcf7.taggen.update($(this));
12
+ });
13
+ });
14
+
15
+ $('form.tag-generator-panel').submit(function(event) {
16
+ return false;
17
+ });
18
+
19
+ $('form.tag-generator-panel .control-box :input').change(function(event) {
20
+ var form = $(this).closest('form.tag-generator-panel');
21
+ _wpcf7.taggen.normalize($(this));
22
+ _wpcf7.taggen.update(form);
23
+ });
24
+
25
+ $('input.insert-tag').click(function(event) {
26
+ var form = $(this).closest('form.tag-generator-panel');
27
+ var tag = form.find('input.tag').val();
28
+ _wpcf7.taggen.insert(tag);
29
+ tb_remove(); // close thickbox
30
+ return false;
31
+ });
32
+
33
+ _wpcf7.taggen.update = function($form) {
34
+ var id = $form.attr('data-id');
35
+ var name = '';
36
+ var name_fields = $form.find('input[name="name"]');
37
+
38
+ if (name_fields.length) {
39
+ name = name_fields.val();
40
+
41
+ if ('' == name) {
42
+ name = id + '-' + Math.floor(Math.random() * 1000);
43
+ name_fields.val(name);
44
+ }
45
+ }
46
+
47
+ if ($.isFunction(_wpcf7.taggen.update[id])) {
48
+ return _wpcf7.taggen.update[id].call(this, $form);
49
+ }
50
+
51
+ $form.find('input.tag').each(function() {
52
+ var tag_type = $(this).attr('name');
53
+
54
+ if ($form.find(':input[name="tagtype"]').length) {
55
+ tag_type = $form.find(':input[name="tagtype"]').val();
56
+ }
57
+
58
+ if ($form.find(':input[name="required"]').is(':checked')) {
59
+ tag_type += '*';
60
+ }
61
+
62
+ components = _wpcf7.taggen.compose(tag_type, $form);
63
+ $(this).val(components);
64
+ });
65
+
66
+ $form.find('span.mail-tag').text('[' + name + ']');
67
+
68
+ $form.find('input.mail-tag').each(function() {
69
+ $(this).val('[' + name + ']');
70
+ });
71
+
72
+ };
73
+
74
+ _wpcf7.taggen.update.captcha = function($form) {
75
+ var captchac = _wpcf7.taggen.compose('captchac', $form);
76
+ var captchar = _wpcf7.taggen.compose('captchar', $form);
77
+
78
+ $form.find('input.tag').val(captchac + ' ' + captchar);
79
+ };
80
+
81
+ _wpcf7.taggen.compose = function(tagType, $form) {
82
+ var name = $form.find('input[name="name"]').val();
83
+ var scope = $form.find('.scope.' + tagType);
84
+
85
+ if (! scope.length) {
86
+ scope = $form;
87
+ }
88
+
89
+ var options = [];
90
+
91
+ var size = scope.find(':input[name="size"]').val() || '';
92
+ var maxlength = scope.find(':input[name="maxlength"]').val() || '';
93
+ var cols = scope.find(':input[name="cols"]').val() || '';
94
+ var rows = scope.find(':input[name="rows"]').val() || '';
95
+
96
+ if ((cols || rows) && maxlength) {
97
+ options.push(cols + 'x' + rows + '/' + maxlength);
98
+ } else if (cols || rows) {
99
+ options.push(cols + 'x' + rows);
100
+ } else if (size || maxlength) {
101
+ options.push(size + '/' + maxlength);
102
+ }
103
+
104
+ scope.find('input.option').not(':checkbox,:radio').each(function(i) {
105
+ var excluded = ['size', 'maxlength', 'cols', 'rows'];
106
+
107
+ if (-1 < $.inArray($(this).attr('name'), excluded)) {
108
+ return;
109
+ }
110
+
111
+ var val = $(this).val();
112
+
113
+ if (! val) {
114
+ return;
115
+ }
116
+
117
+ if ($(this).hasClass('filetype')) {
118
+ val = val.split(/[,|\s]+/).join('|');
119
+ }
120
+
121
+ if ($(this).hasClass('color')) {
122
+ val = '#' + val;
123
+ }
124
+
125
+ if ('class' == $(this).attr('name')) {
126
+ $.each(val.split(' '), function(i, n) { options.push('class:' + n) });
127
+ } else {
128
+ options.push($(this).attr('name') + ':' + val);
129
+ }
130
+ });
131
+
132
+ scope.find('input:checkbox.option').each(function(i) {
133
+ if ($(this).is(':checked')) {
134
+ options.push($(this).attr('name'));
135
+ }
136
+ });
137
+
138
+ options = (options.length > 0) ? options.join(' ') : '';
139
+
140
+ var value = '';
141
+
142
+ if (scope.find(':input[name="values"]').val()) {
143
+ $.each(scope.find(':input[name="values"]').val().split("\n"), function(i, n) {
144
+ value += ' "' + n.replace(/["]/g, '&quot;') + '"';
145
+ });
146
+ }
147
+
148
+ var components = [];
149
+
150
+ $.each([tagType, name, options, value], function(i, v) {
151
+ v = $.trim(v);
152
+
153
+ if ('' != v) {
154
+ components.push(v);
155
+ }
156
+ });
157
+
158
+ components = $.trim(components.join(' '));
159
+ return '[' + components + ']';
160
+ }
161
+
162
+ _wpcf7.taggen.normalize = function($input) {
163
+ var val = $input.val();
164
+
165
+ if ($input.is('input[name="name"]')) {
166
+ val = val.replace(/[^0-9a-zA-Z:._-]/g, '').replace(/^[^a-zA-Z]+/, '');
167
+ }
168
+
169
+ if ($input.is('.numeric')) {
170
+ val = val.replace(/[^0-9.-]/g, '');
171
+ }
172
+
173
+ if ($input.is('.idvalue')) {
174
+ val = val.replace(/[^-0-9a-zA-Z_]/g, '');
175
+ }
176
+
177
+ if ($input.is('.classvalue')) {
178
+ val = $.map(val.split(' '), function(n) {
179
+ return n.replace(/[^-0-9a-zA-Z_]/g, '');
180
+ }).join(' ');
181
+
182
+ val = $.trim(val.replace(/\s+/g, ' '));
183
+ }
184
+
185
+ if ($input.is('.color')) {
186
+ val = val.replace(/[^0-9a-fA-F]/g, '');
187
+ }
188
+
189
+ if ($input.is('.filesize')) {
190
+ val = val.replace(/[^0-9kKmMbB]/g, '');
191
+ }
192
+
193
+ if ($input.is('.filetype')) {
194
+ val = val.replace(/[^0-9a-zA-Z.,|\s]/g, '');
195
+ }
196
+
197
+ if ($input.is('.date')) {
198
+ if (! val.match(/^\d{4}-\d{2}-\d{2}#x2F;)) { // 'yyyy-mm-dd' ISO 8601 format
199
+ val = '';
200
+ }
201
+ }
202
+
203
+ if ($input.is(':input[name="values"]')) {
204
+ val = $.trim(val);
205
+ }
206
+
207
+ $input.val(val);
208
+
209
+ if ($input.is(':checkbox.exclusive')) {
210
+ _wpcf7.taggen.exclusiveCheckbox($input);
211
+ }
212
+ }
213
+
214
+ _wpcf7.taggen.exclusiveCheckbox = function($cb) {
215
+ if ($cb.is(':checked')) {
216
+ $cb.siblings(':checkbox.exclusive').prop('checked', false);
217
+ }
218
+ };
219
+
220
+ _wpcf7.taggen.insert = function(content) {
221
+ $('textarea#wpcf7-form').each(function() {
222
+ this.focus();
223
+
224
+ if (document.selection) { // IE
225
+ var selection = document.selection.createRange();
226
+ selection.text = content;
227
+ } else if (this.selectionEnd || 0 === this.selectionEnd) {
228
+ var val = $(this).val();
229
+ var end = this.selectionEnd;
230
+ $(this).val(val.substring(0, end) + content + val.substring(end, val.length));
231
+ this.selectionStart = end + content.length;
232
+ this.selectionEnd = end + content.length;
233
+ } else {
234
+ $(this).val($(this).val() + content);
235
+ }
236
+
237
+ this.focus();
238
+ });
239
+ };
240
+
241
+ })(jQuery);
admin/js/taggenerator.js DELETED
@@ -1,266 +0,0 @@
1
- (function($) {
2
-
3
- $.fn.tagGenerator = function(title, options) {
4
- var menu = $('<div class="tag-generator"></div>');
5
-
6
- var selector = $('<span>' + title + '</span>');
7
-
8
- selector.css({
9
- border: '1px solid #ddd',
10
- padding: '2px 4px',
11
- background: '#fff url(' + options.fadebuttImageUrl + ') repeat-x 0 0',
12
- '-moz-border-radius': '3px',
13
- '-khtml-border-radius': '3px',
14
- '-webkit-border-radius': '3px',
15
- 'border-radius': '3px'
16
- });
17
-
18
- selector.mouseover(function() {
19
- $(this).css({ 'border-color': '#bbb' });
20
- });
21
- selector.mouseout(function() {
22
- $(this).css({ 'border-color': '#ddd' });
23
- });
24
- selector.mousedown(function() {
25
- $(this).css({ background: '#ddd' });
26
- });
27
- selector.mouseup(function() {
28
- $(this).css({
29
- background: '#fff url(' + options.fadebuttImageUrl + ') repeat-x 0 0'
30
- });
31
- });
32
- selector.click(function() {
33
- dropdown.slideDown('fast');
34
- return false;
35
- });
36
- $('body').click(function() {
37
- dropdown.hide();
38
- });
39
-
40
- if (options.dropdownIconUrl) {
41
- var dropdown_icon = $('<img src="' + options.dropdownIconUrl + '" />');
42
- dropdown_icon.css({ 'vertical-align': 'bottom' });
43
- selector.append(dropdown_icon);
44
- }
45
-
46
- menu.append(selector);
47
-
48
- var pane = $('<div class="tg-pane"></div>');
49
- pane.hide();
50
- menu.append(pane);
51
-
52
- var dropdown = $('<div class="tg-dropdown"></div>');
53
- dropdown.hide();
54
- menu.append(dropdown);
55
-
56
- $.each($.tgPanes, function(i, n) {
57
- var submenu = $('<div>' + $.tgPanes[i].title + '</div>');
58
- submenu.css({
59
- margin: 0,
60
- padding: '0 4px',
61
- 'line-height': '180%',
62
- background: '#fff'
63
- });
64
- submenu.mouseover(function() {
65
- $(this).css({ background: '#d4f2f2' });
66
- });
67
- submenu.mouseout(function() {
68
- $(this).css({ background: '#fff' });
69
- });
70
- submenu.click(function() {
71
- dropdown.hide();
72
- pane.hide();
73
- pane.empty();
74
- $.tgPane(pane, i);
75
- pane.slideDown('fast');
76
- return false;
77
- });
78
- dropdown.append(submenu);
79
- });
80
-
81
- this.append(menu);
82
- };
83
-
84
- $.tgPane = function(pane, tagType) {
85
- var closeButtonDiv = $('<div></div>');
86
- closeButtonDiv.css({ float: 'right' });
87
-
88
- var closeButton = $('<span class="tg-closebutton">&#215;</span>');
89
- closeButton.click(function() {
90
- pane.slideUp('fast').empty();
91
- });
92
- closeButtonDiv.append(closeButton);
93
-
94
- pane.append(closeButtonDiv);
95
-
96
- var paneTitle = $('<div class="tg-panetitle">' + $.tgPanes[tagType].title + '</div>');
97
- pane.append(paneTitle);
98
-
99
- pane.append($('#' + $.tgPanes[tagType].content).clone().contents());
100
-
101
- pane.find(':checkbox.exclusive').change(function() {
102
- if ($(this).is(':checked'))
103
- $(this).siblings(':checkbox.exclusive').removeAttr('checked');
104
- });
105
-
106
- if ($.isFunction($.tgPanes[tagType].change))
107
- $.tgPanes[tagType].change(pane, tagType);
108
- else
109
- $.tgCreateTag(pane, tagType);
110
-
111
- pane.find(':input').change(function() {
112
- if ($.isFunction($.tgPanes[tagType].change))
113
- $.tgPanes[tagType].change(pane, tagType);
114
- else
115
- $.tgCreateTag(pane, tagType);
116
- });
117
- }
118
-
119
- $.tgCreateTag = function(pane, tagType) {
120
- pane.find('input[name="name"]').each(function(i) {
121
- var val = $(this).val();
122
- val = val.replace(/[^0-9a-zA-Z:._-]/g, '').replace(/^[^a-zA-Z]+/, '');
123
- if ('' == val) {
124
- var rand = Math.floor(Math.random() * 1000);
125
- val = tagType + '-' + rand;
126
- }
127
- $(this).val(val);
128
- });
129
-
130
- pane.find(':input.numeric').each(function(i) {
131
- var val = $(this).val();
132
- val = val.replace(/[^0-9.-]/g, '');
133
- $(this).val(val);
134
- });
135
-
136
- pane.find(':input.idvalue').each(function(i) {
137
- var val = $(this).val();
138
- val = val.replace(/[^-0-9a-zA-Z_]/g, '');
139
- $(this).val(val);
140
- });
141
-
142
- pane.find(':input.classvalue').each(function(i) {
143
- var val = $(this).val();
144
- val = $.map(val.split(' '), function(n) {
145
- return n.replace(/[^-0-9a-zA-Z_]/g, '');
146
- }).join(' ');
147
- val = $.trim(val.replace(/\s+/g, ' '));
148
- $(this).val(val);
149
- });
150
-
151
- pane.find(':input.color').each(function(i) {
152
- var val = $(this).val();
153
- val = val.replace(/[^0-9a-fA-F]/g, '');
154
- $(this).val(val);
155
- });
156
-
157
- pane.find(':input.filesize').each(function(i) {
158
- var val = $(this).val();
159
- val = val.replace(/[^0-9kKmMbB]/g, '');
160
- $(this).val(val);
161
- });
162
-
163
- pane.find(':input.filetype').each(function(i) {
164
- var val = $(this).val();
165
- val = val.replace(/[^0-9a-zA-Z.,|\s]/g, '');
166
- $(this).val(val);
167
- });
168
-
169
- pane.find(':input.date').each(function(i) {
170
- var val = $(this).val();
171
- if (! val.match(/^\d{4}-\d{2}-\d{2}#x2F;)) // 'yyyy-mm-dd' ISO 8601 format
172
- $(this).val('');
173
- });
174
-
175
- pane.find(':input[name="values"]').each(function(i) {
176
- var val = $(this).val();
177
- val = $.trim(val);
178
- $(this).val(val);
179
- });
180
-
181
- pane.find('input.tag').each(function(i) {
182
- var type = $(this).attr('name');
183
-
18