PluginProbe
Contact List – Online Staff Directory & Address Book / trunk
Contact List – Online Staff Directory & Address Book vtrunk
3.0.22 trunk 2.9.80 2.9.81 2.9.82 2.9.83 2.9.84 2.9.85 2.9.86 2.9.87 2.9.88 2.9.89 2.9.90 2.9.91 2.9.92 2.9.93 2.9.94 2.9.95 2.9.96 2.9.97 2.9.98 2.9.99 3.0.0 3.0.1 3.0.10 All 44 releases
contact-list / admin / class-cl-admin-inline-scripts.php

class-cl-admin-inline-scripts.php in Contact List – Online Staff Directory & Address Book trunk, at admin/class-cl-admin-inline-scripts.php

76 lines 5.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class ContactListAdminInlineScripts {
4 public static function inline_scripts( $context = '' ) {
5 $current_screen = get_current_screen();
6 $current_screen_id = '';
7 if ( isset( $current_screen->id ) ) {
8 $current_screen_id = $current_screen->id;
9 }
10 $js = '';
11 if ( $context == 'mail-log' ) {
12 $js .= "jQuery( document ).ready( function(\$) {\n\n \$('.contact-list-empty-mail-log-form').submit(function() {\n\n return confirm('" . esc_js( __( 'Are you sure that you want to empty the mail log?', 'contact-list' ) ) . ' ' . esc_js( __( 'This action is irreversible.', 'contact-list' ) ) . "');\n\n });\n\n });";
13 } elseif ( $context == 'search-log' ) {
14 $js .= "jQuery( document ).ready( function(\$) {\n\n \$('.contact-list-empty-search-log-form').submit(function() {\n\n return confirm('" . esc_js( __( 'Are you sure that you want to empty the search log?', 'contact-list' ) ) . ' ' . esc_js( __( 'This action is irreversible.', 'contact-list' ) ) . "');\n\n });\n\n });";
15 } elseif ( $context == 'import-log' ) {
16 $js .= "jQuery( document ).ready( function(\$) {\n\n \$('.contact-list-empty-import-log-form').submit(function() {\n\n return confirm('" . esc_js( __( 'Are you sure that you want to empty the import log?', 'contact-list' ) ) . ' ' . esc_js( __( 'This action is irreversible.', 'contact-list' ) ) . "');\n\n });\n\n });";
17 } elseif ( $current_screen_id === 'edit-contact' || $current_screen_id === 'edit-contact-group' ) {
18 $is_premium = 0;
19 $js .= "jQuery( document ).ready( function(\$) {";
20 if ( !$is_premium ) {
21 if ( $current_screen_id === 'edit-contact' ) {
22 $url = 'https://wordpress.org/support/plugin/contact-list/';
23 $support_html = sprintf( wp_kses(
24 /* translators: %s: link to the support forum */
25 __( 'If you have any questions in mind, please contact the author at <a href="%s" target="_blank">the support forum</a>. The forum is actively monitored and any kind of feedback is welcome.', 'contact-list' ),
26 array(
27 'a' => array(
28 'href' => array(),
29 'target' => array(),
30 ),
31 )
32 ), esc_url( $url ) );
33 $js .= "\n \$('.post-type-contact .page-title-action').after(function() {\n\n return '<div class=\"contact-list-admin-support-box\">" . $support_html . "</div>';\n\n });\n ";
34 }
35 $js .= "\n \$('.contact-list-copy-paid-only').tipso({\n content: '" . esc_js( __( 'This feature is available in the paid plans.', 'contact-list' ) ) . "',\n width: 280,\n background: '#2271b1',\n });\n ";
36 $js .= "\n \$('.contact-list-request-update').tipso({\n content: '" . esc_js( __( 'This feature is available in the paid plans.', 'contact-list' ) ) . "',\n width: 280,\n background: '#2271b1',\n });\n ";
37 $js .= "\n \$('.contact-list-request-update').on('click', function(e) {\n e.preventDefault();\n \$(this).prop( 'disabled', true );\n });\n ";
38 }
39 $js .= "});";
40 }
41 return $js;
42 }
43
44 public static function box_inline_scripts( $context = '' ) {
45 $current_screen = get_current_screen();
46 $current_screen_id = '';
47 if ( isset( $current_screen->id ) ) {
48 $current_screen_id = $current_screen->id;
49 }
50 $js = '';
51 $is_premium = 0;
52 $admin_pages = ContactListAdminToolbar::get_admin_pages();
53 if ( !$is_premium && in_array( $current_screen_id, $admin_pages ) ) {
54 if ( $current_screen_id == 'settings_page_contact-list' ) {
55 $js = "\n jQuery( document ).ready( function(\$) {\n \$( '.contact-list-admin-pro-features' ).appendTo( '.contact-list-admin-page-content-container' ).fadeIn(2000);\n });\n ";
56 } else {
57 $js = "\n jQuery( document ).ready( function(\$) {\n \$( '.contact-list-admin-pro-features' ).appendTo( '#wpbody-content .wrap' ).fadeIn(2000);\n });\n ";
58 }
59 }
60 return $js;
61 }
62
63 public static function contact_edit_scripts() {
64 $js = '';
65 $js .= "jQuery( document ).ready( function(\$) {\n \$('#post').submit(function() {\n if (\$('#_cl_last_name').val().length == 0) {\n alert('" . esc_js( __( 'Please insert at least last name first.', 'contact-list' ) ) . "');\n return false;\n }\n });\n });";
66 return $js;
67 }
68
69 public static function help_support_scripts() {
70 $js = '';
71 $js .= "jQuery( document ).ready( function(\$) {\n \$('.contact-list-toggle-debug-info').on('click', function() {\n if (\$('.contact-list-debug-info-container').is(':hidden')) {\n \$('.contact-list-debug-info-container').show();\n \$(this).text('" . esc_js( __( 'Close', 'contact-list' ) ) . "');\n } else {\n \$('.contact-list-debug-info-container').hide();\n \$(this).text('" . esc_js( __( 'Open', 'contact-list' ) ) . "');\n }\n });\n });";
72 return $js;
73 }
74
75 }
76