| 1 |
<?php |
| 2 |
/** |
| 3 |
* Render the queue panel. |
| 4 |
*/ |
| 5 |
|
| 6 |
/** |
| 7 |
* Function to render the queue panel. |
| 8 |
*/ |
| 9 |
function ao_ccss_render_queue() { |
| 10 |
// Attach required arrays. |
| 11 |
$criticalcss = autoptimize()->criticalcss(); |
| 12 |
$ao_ccss_queue = $criticalcss->get_option( 'queue' ); |
| 13 |
|
| 14 |
// Prepare the queue object. |
| 15 |
if ( empty( $ao_ccss_queue ) ) { |
| 16 |
$ao_ccss_queue = ''; |
| 17 |
} else { |
| 18 |
$ao_ccss_queue = json_encode( $ao_ccss_queue ); |
| 19 |
} |
| 20 |
?> |
| 21 |
|
| 22 |
<ul id="queue-panel"> |
| 23 |
<li class="itemDetail"> |
| 24 |
<h2 class="itemTitle fleft"><?php _e( 'Job Queue', 'autoptimize' ); ?></h2> |
| 25 |
<button type="button" class="toggle-btn"> |
| 26 |
<span class="toggle-indicator dashicons dashicons-arrow-up dashicons-arrow-down"></span> |
| 27 |
</button> |
| 28 |
<?php |
| 29 |
if ( $criticalcss->has_autorules() ) { |
| 30 |
$_queue_visibility = 'hidden'; |
| 31 |
} else { |
| 32 |
$_queue_visibility = 'visible'; |
| 33 |
} |
| 34 |
?> |
| 35 |
<div class="collapsible <?php echo $_queue_visibility; ?>"> |
| 36 |
<!-- BEGIN Queue dialogs --> |
| 37 |
<!-- Retry dialog --> |
| 38 |
<div id="queue-confirm-retry" title="<?php _e( 'Retry Job', 'autoptimize' ); ?>" class="hidden"> |
| 39 |
<p><?php _e( 'Are you sure you want to retry this job?', 'autoptimize' ); ?></p> |
| 40 |
</div> |
| 41 |
|
| 42 |
<!-- Remove dialog --> |
| 43 |
<div id="queue-confirm-rm" title="<?php _e( 'Delete Job', 'autoptimize' ); ?>" class="hidden"> |
| 44 |
<p><?php _e( 'Are you sure you want to delete this job?', 'autoptimize' ); ?></p> |
| 45 |
</div> |
| 46 |
|
| 47 |
<!-- Remove all dialog --> |
| 48 |
<div id="queue-confirm-rm-all" title="<?php _e( 'Delete all jobs', 'autoptimize' ); ?>" class="hidden"> |
| 49 |
<p><?php _e( 'This will delete all jobs, are you sure?', 'autoptimize' ); ?></p> |
| 50 |
</div> |
| 51 |
<!-- END Queue dialogs --> |
| 52 |
|
| 53 |
<!-- BEGIN Queue UI --> |
| 54 |
<div class="howto"> |
| 55 |
<div class="title-wrap"> |
| 56 |
<h4 class="title"><?php _e( 'How To Use Autoptimize CriticalCSS Queue', 'autoptimize' ); ?></h4> |
| 57 |
<p class="subtitle"><?php _e( 'Click the side arrow to toggle instructions', 'autoptimize' ); ?></p> |
| 58 |
</div> |
| 59 |
<button type="button" class="toggle-btn"> |
| 60 |
<span class="toggle-indicator dashicons dashicons-arrow-up dashicons-arrow-down"></span> |
| 61 |
</button> |
| 62 |
<div class="howto-wrap hidden"> |
| 63 |
<p><?php _e( 'TL;DR:<br /><strong>Queue runs every 10 minutes.</strong> Job statuses are <span class="badge new">N</span> for NEW, <span class="badge pending">P</span> for PENDING, <span class="badge error">E</span> for ERROR and <span class="badge unknown">U</span> for UNKOWN.', 'autoptimize' ); ?></p> |
| 64 |
<ol> |
| 65 |
<li><?php _e( 'The queue operates <strong>automatically, asynchronously and on regular intervals of 10 minutes.</strong> To view updated queue status, refresh this page.', 'autoptimize' ); ?></li> |
| 66 |
<li><?php _e( 'When the conditions to create a job are met (i.e. user not logged in, no matching <span class="badge manual">MANUAL</span> rule or CSS files has changed for an <span class="badge auto">AUTO</span> rule), a <span class="badge new">N</span> job is created in the queue.', 'autoptimize' ); ?></li> |
| 67 |
<li><?php _e( "Autoptimize constantly queries the queue for <span class='badge new'>N</span> jobs. When it finds one, gears spins and jobs becomes <span class='badge pending'>P</span> while they are running and <a href='https://criticalcss.com/?aff=1' target='_blank'>criticalcss.com</a> doesn't return a result.", 'autoptimize' ); ?></li> |
| 68 |
<li><?php _e( 'As soon as <a href="https://criticalcss.com/?aff=1" target="_blank">criticalcss.com</a> returns a valid critical CSS file, the job is then finished and removed from the queue.', 'autoptimize' ); ?></li> |
| 69 |
<li><?php _e( 'When things go wrong, a job is marked as <span class="badge error">E</span>. You can retry faulty jobs, delete them or get in touch with <a href="https://criticalcss.com/?aff=1" target="_blank">criticalcss.com</a> for assistance.', 'autoptimize' ); ?></li> |
| 70 |
<li><?php _e( 'Sometimes an unknown condition can happen. In this case, the job status becomes <span class="badge unknown">U</span> and you may want to ask <a href="https://criticalcss.com/?aff=1" target="_blank">criticalcss.com</a> for help or just delete it.', 'autoptimize' ); ?></li> |
| 71 |
<li><?php _e( 'To get more information about jobs statuses, specially the ones with <span class="badge error">E</span> and <span class="badge unknown">U</span> status, hover your mouse in the status badge of that job. This information might be crucial when contacting <a href="https://criticalcss.com/?aff=1" target="_blank">criticalcss.com</a> for assistance.', 'autoptimize' ); ?></li> |
| 72 |
<li><?php _e( '<strong>A word about WordPress cron:</strong> Autoptimize watches the queue by using WordPress Cron (or WP-Cron for short.) It <a href="https://www.smashingmagazine.com/2013/10/schedule-events-using-wordpress-cron/#limitations-of-wordpress-cron-and-solutions-to-fix-em" target="_blank">could be faulty</a> on very light or very heavy loads. If your site receives just a few or thousands visits a day, it might be a good idea to <a href="https://developer.wordpress.org/plugins/cron/hooking-wp-cron-into-the-system-task-scheduler/" target="_blank">turn WP-Cron off and use your system task scheduler</a> to fire it instead.', 'autoptimize' ); ?></li> |
| 73 |
</ol> |
| 74 |
</div> |
| 75 |
</div> |
| 76 |
<table id="queue-tbl" class="queue tablesorter" cellspacing="0"> |
| 77 |
<thead> |
| 78 |
<tr><th class="status"><?php _e( 'Status', 'autoptimize' ); ?></th><th><?php _e( 'Target Rule', 'autoptimize' ); ?></th><th><?php _e( 'Page Path', 'autoptimize' ); ?></th><th><?php _e( 'Page Type', 'autoptimize' ); ?></th><th><?php _e( 'Creation Date', 'autoptimize' ); ?></th><th><?php _e( 'Finish Date', 'autoptimize' ); ?></th><th class="btn"><?php _e( 'Actions', 'autoptimize' ); ?></th></tr> |
| 79 |
</thead> |
| 80 |
<tbody id="queue"></tbody> |
| 81 |
</table> |
| 82 |
<input class="hidden" type="text" id="ao-ccss-queue" name="autoptimize_ccss_queue" value='<?php echo( $ao_ccss_queue ); ?>'> |
| 83 |
<div class="submit jobs-btn"> |
| 84 |
<div id="queuerunner-container" class="alignleft hidden"> |
| 85 |
<span id="queuerunner" class="button-secondary"><?php _e( 'Manually process the job queue', 'autoptimize' ); ?></span> |
| 86 |
</div> |
| 87 |
<div class="alignright"> |
| 88 |
<span id="removeAllJobs" class="button-secondary" style="color:red;"><?php _e( 'Remove all jobs', 'autoptimize' ); ?></span> |
| 89 |
</div> |
| 90 |
</div> |
| 91 |
</div> |
| 92 |
<!-- END Queue UI --> |
| 93 |
</li> |
| 94 |
</ul> |
| 95 |
<?php |
| 96 |
} |
| 97 |
|