@@ -131,22 +131,28 @@ function displayReport( response ) {
131131 resetDisplay ( ) ;
132132 var $ = jQuery ;
133133 var compatible = 1 ;
134+ // Keep track of the number of failed plugins/themes.
135+ var failedCount = 0 ;
134136 var errorsRegex = / ( \d * ) E R R O R S ? / g;
135137 var warningRegex = / ( \d * ) W A R N I N G S ? / g;
136138 var updateVersionRegex = / e : ( .* ?) ; / g;
137139 var currentVersionRegex = / n : ( .* ?) ; / g;
140+ // Grab and compile our template.
141+ var source = $ ( '#result-template' ) . html ( ) ;
142+ var template = Handlebars . compile ( source ) ;
138143 $ ( '#runButton' ) . removeClass ( 'button-primary-disabled' ) ;
139144 $ ( '.spinner' ) . hide ( ) ;
140145 $ ( '#testResults' ) . text ( response ) ;
141146 $ ( '#footer' ) . show ( ) ;
142147 $ ( '#runButton' ) . val ( 'Re-run' ) ;
143148 // Separate plugins/themes.
144149 var plugins = response . replace ( / ^ \s + | \s + $ / g, '' ) . split ( 'Name: ' ) ;
150+
151+ // Remove the first item, it's empty.
152+ plugins . shift ( ) ;
153+
145154 // Loop through them.
146155 for ( var x in plugins ) {
147- if ( '' === plugins [ x ] . trim ( ) ) {
148- continue ;
149- }
150156 var updateVersion ;
151157 var updateAvailable = 0 ;
152158 var passed = 1 ;
@@ -166,6 +172,7 @@ function displayReport( response ) {
166172 if ( parseInt ( errors ) > 0 ) {
167173 compatible = 0 ;
168174 passed = 0 ;
175+ failedCount ++ ;
169176 }
170177 // Trim whitespace and newlines from report.
171178 log = log . replace ( / ^ \s + | \s + $ / g, '' ) ;
@@ -174,8 +181,6 @@ function displayReport( response ) {
174181 skipped = 1 ;
175182 }
176183 // Use handlebars to build our template.
177- var source = $ ( '#result-template' ) . html ( ) ;
178- var template = Handlebars . compile ( source ) ;
179184 var context = {
180185 plugin_name : name ,
181186 warnings : warnings ,
@@ -189,10 +194,14 @@ function displayReport( response ) {
189194 var html = template ( context ) ;
190195 $ ( '#standardMode' ) . append ( html ) ;
191196 }
197+
192198 // Display global compatibility status.
193199 if ( compatible ) {
194200 $ ( '#standardMode' ) . prepend ( '<h3>Your WordPress install is PHP ' + test_version + ' compatible.</h3>' ) ;
195201 } else {
202+ // Display scan stats.
203+ $ ( '#standardMode' ) . prepend ( '<p>' + failedCount + ' out of ' + plugins . length + ' plugins/themes are not compatible.</p>' ) ;
204+
196205 $ ( '#standardMode' ) . prepend ( '<h3>Your WordPress install is not PHP ' + test_version + ' compatible.</h3>' ) ;
197206 }
198- }
207+ }
0 commit comments