@@ -23,9 +23,11 @@ class Extension_AlwaysCached_Worker {
2323 *
2424 * @since 2.8.0
2525 *
26+ * @param bool $html Print HTML.
27+ *
2628 * @return void
2729 */
28- public static function run () {
30+ public static function run ( $ html = true ) {
2931 $ timeslot_seconds = 60 ;
3032 $ timeslot_seconds = apply_filters (
3133 'w3tc_alwayscached_worker_timeslot ' ,
@@ -34,26 +36,30 @@ public static function run() {
3436
3537 $ time_exit = time () + $ timeslot_seconds ;
3638
37- echo '<div style="white-space: pre-line;"> ' ;
39+ if ( $ html ) {
40+ echo '<div style="white-space: pre-line;"> ' ;
41+ }
3842
39- esc_html_e ( " Processing queue. \n" , 'w3-total-cache ' );
43+ esc_html_e ( ' Processing queue. ' , 'w3-total-cache ' );
4044
41- for ( ; ; ) {
45+ // Infinite loop to process queue items until the time slot is exhausted or the queue is empty.
46+ while ( true ) {
4247 if ( time () >= $ time_exit ) {
43- esc_html_e ( "\n\ nQueue worker time slot exhaused. " , 'w3-total-cache ' );
48+ esc_html_e ( "\nQueue worker time slot exhaused. " , 'w3-total-cache ' );
4449 break ;
4550 }
4651
4752 $ item = Extension_AlwaysCached_Queue::pop_item_begin ();
4853
4954 if ( empty ( $ item ) ) {
50- esc_html_e ( "\n\ nQueue is empty. " , 'w3-total-cache ' );
55+ esc_html_e ( "\nQueue is empty. " , 'w3-total-cache ' );
5156 break ;
5257 }
5358
5459 echo esc_html ( sprintf ( "\n%s " , $ item ['key ' ] ) );
5560
5661 $ result = self ::process_item ( $ item );
62+
5763 if ( 'ok ' === $ result ) {
5864 esc_html_e ( 'ok ' , 'w3-total-cache ' );
5965 Extension_AlwaysCached_Queue::pop_item_finish ( $ item );
@@ -65,7 +71,11 @@ public static function run() {
6571 }
6672 }
6773
68- echo "\n</div> \n" ;
74+ if ( $ html ) {
75+ echo "\n</div> \n" ;
76+ } else {
77+ echo "\n" ;
78+ }
6979 }
7080
7181 /**
0 commit comments