From b919086079bf393af368703180d79f832df9b5ee Mon Sep 17 00:00:00 2001 From: Stefan Kalscheuer Date: Sat, 10 Apr 2021 17:35:58 +0200 Subject: [PATCH 1/6] separate settings and manual scan in admin ui Manual theme file scan is not placed in a separate tab. Settings table uses default WP settings styles and the scan results are presented in a WP-like table structure. --- css/style.css | 107 +++++++++------------ inc/class-antivirus.php | 199 +++++++++++++++++++++++----------------- js/script.js | 66 +++++++------ 3 files changed, 201 insertions(+), 171 deletions(-) diff --git a/css/style.css b/css/style.css index 8c60929..6174848 100644 --- a/css/style.css +++ b/css/style.css @@ -1,93 +1,74 @@ -/* @group Manual Scan */ +/* Scan controls */ -#av_manual_scan { - height: 1%; - overflow: hidden; -} - -#av_manual_scan a.button { - float: left; -} - -#av_manual_scan .alert { - float: left; - color: #008a20; - margin: 0 10px; - border: 1px solid #007017; - display: none; - height: 26px; - line-height: 26px; - padding: 0 10px; +span.av-scan-complete { background: #fff; + border: 1px solid #007017; border-radius: 3px; + color: #008a20; + display: inline-block; + line-height: 2; + margin: 0 10px; + padding: 0 0.5em; } -#av_main .inside .output { - clear: both; - height: 1%; - margin: 0 0 0 -6px; - padding: 0 0 6px; - overflow: hidden; +#av-scan-process .spinner { + float: none; } -#av_main .inside .output div { - float: left; - color: #000; - margin: 12px 6px 0; - padding: 8px 12px 10px; - background: #dba617; - border-radius: 3px; - transition: background-color 0.5s linear; - -o-transition: background-color 0.5s linear; - -ms-transition: background-color 0.5s linear; - -moz-transition: background-color 0.5s linear; - -webkit-transition: background-color 0.5s linear; +/* Scan results table. */ + +table.av-scan-results .av-toggle-column { + width: 2.2em; } -#av_main .inside .output div.done { - background: #008a20; - color: #fff; +table.av-scan-results .av-file-column > p a.button { + float: right; } -#av_main .inside .output div.danger { - width: 97%; - background: #d63638; - color: #fff; +table.av-scan-results .av-status-column { + text-align: center; + width: 7em; } -#av_main .inside .output div p { - padding: 10px; - overflow: hidden; +table.av-scan-results .av-file-column > p { background: #f6f7f7; - white-space: nowrap; - border-radius: 3px; + line-height: 2; + padding: 0.5em; } -#av_main .inside .output div p a { - margin: 0 6px 12px 0; +table.av-scan-results .av-file-column > p a { + margin: 0 0.5em 0.5em 0.5em; } -#av_main .inside .output div p code { - clear: both; +table.av-scan-results .av-file-column > p code { float: left; - color: #000; - padding: 2px 5px; - border-radius: 3px; + padding: 0.2em 0.5em; } -#av_main .inside .output div p code span { - padding: 2px; +table.av-scan-results .av-file-column > p code span { + padding: 0.2em; background: #f2d675; } -/* @end group */ +tr.av-status-pending .av-status-column { + font-style: italic; +} +tr.av-status-ok td:first-of-type { + border-left: 4px solid #007017; +} -/* @group WordPress 3.8 Fix */ +tr.av-status-ok .av-status-column { + color: #008a20; + font-weight: 700; +} -#av_notify_email { - line-height: 1.5; +tr.av-status-warning td:first-of-type { + border-left: 4px solid #b32d2e; } -/* @end group */ +tr.av-status-warning td.av-status-column { + color: #d63638; + font-weight: 700; +} diff --git a/inc/class-antivirus.php b/inc/class-antivirus.php index 2c5c3d2..5e55409 100644 --- a/inc/class-antivirus.php +++ b/inc/class-antivirus.php @@ -354,10 +354,19 @@ public static function add_enqueue_script() { 'av_script', 'av_settings', array( - 'nonce' => wp_create_nonce( 'av_ajax_nonce' ), - 'msg_1' => esc_js( __( 'Dismiss', 'antivirus' ) ), - 'msg_3' => esc_js( __( 'Scan finished', 'antivirus' ) ), - 'msg_4' => esc_js( __( 'Dismiss false positive virus detection', 'antivirus' ) ), + 'nonce' => wp_create_nonce( 'av_ajax_nonce' ), + 'labels' => array( + 'dismiss' => esc_js( __( 'Dismiss', 'antivirus' ) ), + 'complete' => esc_js( __( 'Scan finished', 'antivirus' ) ), + 'file' => esc_js( __( 'Theme File', 'antivirus' ) ), + 'status' => esc_js( __( 'Check Status', 'antivirus' ) ), + ), + 'texts' => array( + 'dismiss' => esc_js( __( 'Dismiss false positive virus detection', 'antivirus' ) ), + 'ok' => esc_js( __( '✔ OK', 'antivirus' ) ), + 'pending' => esc_js( __( 'pending', 'antivirus' ) ), + 'warning' => esc_js( __( '! Warning', 'antivirus' ) ), + ), ) ); } @@ -660,66 +669,92 @@ public static function show_admin_menu() { - - - - - -
- - -
-

- - - - -

+ + + -
-
-
+

+ + + + +

+
+ +
+

+ + + + + + + + + + + + + @@ -822,8 +854,11 @@ class="regular-text" ?> +
- - + /> +

+ +

+
+ +
- - -

- -

-
- -
- -
- - + />

- -
- +

-

- -
- -
- - +
+ + + + />

- - -
- -
- - - -

- -

-
+
+ + + + +

+ +

+ + ' ).replace( /@\/span@/g, '' ); - item.append( '

' + avMsg1 + ' ' + line + '

' ); + row.find( 'td.av-file-column' ) + .append( '

' + line + ' ' + av_settings.labels.dismiss + '

' ); - $( '#' + md5 ).click( + $( '#av-dismiss-' + md5 ).click( function() { $.post( ajaxurl, { action: 'get_ajax_response', _ajax_nonce: avNonce, - _file_md5: $( this ).attr( 'id' ), + _file_md5: $( this ).attr( 'id' ).substr( 11 ), _action_request: 'update_white_list', }, function( res ) { @@ -80,12 +79,13 @@ jQuery( document ).ready( return; } - parent = $( '#' + res.data[0] ).parent(); + // Get table column above the dismiss button. + parent = $( '#av-dismiss-' + res.data[0] ).parent().parent(); - if ( parent.parent().children().length <= 1 ) { - parent.parent().hide( 'slow' ).remove(); - } - parent.hide( 'slow' ).remove(); + // Hide code details and mark row as "OK". + parent.find( 'p' ).hide( 'slow' ).remove(); + parent.parent().addClass( 'av-status-ok' ).removeClass( 'av-status-warning' ); + parent.parent().find( 'td.av-status-column' ).text( av_settings.texts.ok ); } ); @@ -94,7 +94,8 @@ jQuery( document ).ready( ); } } else { - item.addClass( 'done' ); + row.addClass( 'av-status-ok' ).removeClass( 'av-status-pending' ); + row.find( 'td.av-status-column' ).text( av_settings.texts.ok ); } // Increment counter. @@ -102,12 +103,9 @@ jQuery( document ).ready( // Output notification. if ( avFilesLoaded >= avFiles.length ) { - $( '#av_manual_scan .alert' ).text( avMsg3 ).fadeIn().fadeOut().fadeIn().fadeOut().fadeIn().animate( { opacity: 1.0 }, 500 ).fadeOut( - 'slow', - function() { - $( this ).empty(); - } - ); + $( '#av-scan-process' ).html( '' + av_settings.labels.complete + '' ) + .fadeOut().fadeIn().fadeOut().fadeIn().fadeOut().fadeIn() + .animate( { opacity: 1.0 }, 500 ); } else { checkThemeFile( id + 1 ); } @@ -116,7 +114,7 @@ jQuery( document ).ready( } // Check templates. - $( '#av_manual_scan a.button' ).click( + $( '#av-scan-trigger' ).click( function() { // Request. $.post( @@ -128,7 +126,13 @@ jQuery( document ).ready( }, function( input ) { // Initialize output value. - var output = ''; + var output = '' + + '' + + '' + + '' + + '' + + '' + + ''; // No data received? if ( ! input ) { @@ -145,16 +149,26 @@ jQuery( document ).ready( avFilesLoaded = 0; // Visualize files. - jQuery.each( + $.each( avFiles, function( i, val ) { - output += '
' + val + '
'; + output += '' + + '' + + '' + + '' + + ''; } ); + output += '' + + '' + + '' + + '' + + '
Theme FileCheck Status
' + val + '' + av_settings.texts.pending + '
' + av_settings.labels.file + '' + av_settings.labels.status + '
'; + // assign values. - $( '#av_manual_scan .alert' ).empty(); - $( '#av_manual_scan .output' ).empty().append( output ); + $( '#av-scan-process' ).html( '' ); + $( '#av-scan-output' ).empty().append( output ); // Start loop through files. checkThemeFile(); From 23d6f84dfce0a4f81b5bc9e497e43b87e6852e70 Mon Sep 17 00:00:00 2001 From: Stefan Kalscheuer Date: Thu, 13 May 2021 15:55:26 +0200 Subject: [PATCH 2/6] background-color for result rows --- css/style.css | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/css/style.css b/css/style.css index 6174848..7ab55f9 100644 --- a/css/style.css +++ b/css/style.css @@ -32,7 +32,6 @@ table.av-scan-results .av-status-column { } table.av-scan-results .av-file-column > p { - background: #f6f7f7; line-height: 2; padding: 0.5em; } @@ -42,8 +41,9 @@ table.av-scan-results .av-file-column > p a { } table.av-scan-results .av-file-column > p code { - float: left; - padding: 0.2em 0.5em; + background-color: #f0f0f1; + border: 1px solid #a7aaad; + padding: 0.5em; } table.av-scan-results .av-file-column > p code span { @@ -51,24 +51,32 @@ table.av-scan-results .av-file-column > p code span { background: #f2d675; } -tr.av-status-pending .av-status-column { +table.av-scan-results tr.av-status-pending .av-status-column { font-style: italic; } -tr.av-status-ok td:first-of-type { +table.av-scan-results tr.av-status-ok { + background-color: #edfaef; +} + +table.av-scan-results tr.av-status-ok td:first-of-type { border-left: 4px solid #007017; } -tr.av-status-ok .av-status-column { - color: #008a20; +table.av-scan-results tr.av-status-ok .av-status-column { + color: #005c12; font-weight: 700; } -tr.av-status-warning td:first-of-type { +table.av-scan-results tr.av-status-warning { + background-color: #fcf0f1; +} + +table.av-scan-results tr.av-status-warning td:first-of-type { border-left: 4px solid #b32d2e; } -tr.av-status-warning td.av-status-column { - color: #d63638; +table.av-scan-results tr.av-status-warning td.av-status-column { + color: #8a2424; font-weight: 700; } From 60351d37581c14e62d9347af5cec94cfb16545be Mon Sep 17 00:00:00 2001 From: Stefan Kalscheuer Date: Thu, 13 May 2021 15:59:57 +0200 Subject: [PATCH 3/6] add check-column class to prevent auto-width on mobile devices --- js/script.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/js/script.js b/js/script.js index ffaed0d..33bb006 100644 --- a/js/script.js +++ b/js/script.js @@ -128,7 +128,7 @@ jQuery( document ).ready( // Initialize output value. var output = '' + '' + - '' + + '' + '' + '' + '' + @@ -153,7 +153,7 @@ jQuery( document ).ready( avFiles, function( i, val ) { output += '' + - '' + + '' + '' + '' + ''; @@ -161,7 +161,7 @@ jQuery( document ).ready( ); output += '' + - '' + + '' + '' + '' + '
Theme FileCheck Status
' + val + '' + av_settings.texts.pending + '
' + av_settings.labels.file + '' + av_settings.labels.status + '
'; From ccddd1bed444ce8dbfe3316539125b602807ac3a Mon Sep 17 00:00:00 2001 From: Stefan Kalscheuer Date: Thu, 13 May 2021 18:11:10 +0200 Subject: [PATCH 4/6] use gray 70 instead of gray 60 for text in results table --- css/style.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/css/style.css b/css/style.css index 7ab55f9..145b5aa 100644 --- a/css/style.css +++ b/css/style.css @@ -51,6 +51,10 @@ table.av-scan-results .av-file-column > p code span { background: #f2d675; } +table.av-scan-results td { + color: #3c434a; +} + table.av-scan-results tr.av-status-pending .av-status-column { font-style: italic; } From 7a213eef0972d566270ea4443aadb98039463049 Mon Sep 17 00:00:00 2001 From: Stefan Kalscheuer Date: Fri, 28 May 2021 17:53:43 +0200 Subject: [PATCH 5/6] place labels next to checkboxes on settings page Shorten the row header and add descriptive labels directly after the checkboxes to enable certain checks. --- inc/class-antivirus.php | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/inc/class-antivirus.php b/inc/class-antivirus.php index 5e55409..67774c6 100644 --- a/inc/class-antivirus.php +++ b/inc/class-antivirus.php @@ -725,12 +725,15 @@ public static function show_admin_menu() { /> +

- +

/> +

/> -

- -

+ +

+ +

From 47974628f29f561197b0ad11b61e68f016ddf675 Mon Sep 17 00:00:00 2001 From: Stefan Kalscheuer Date: Fri, 13 May 2022 18:06:13 +0200 Subject: [PATCH 6/6] point link for manual scan to scan-tab directly --- inc/class-antivirus.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/inc/class-antivirus.php b/inc/class-antivirus.php index 67774c6..e3dfe51 100644 --- a/inc/class-antivirus.php +++ b/inc/class-antivirus.php @@ -600,7 +600,8 @@ public static function show_dashboard_notice() { esc_url( add_query_arg( array( - 'page' => 'antivirus', + 'page' => 'antivirus', + 'av_tab' => 'scan', ), admin_url( 'options-general.php' ) )