part-bulk-convert-avif-button.php
| 1 | <?php |
| 2 | |
| 3 | defined( 'ABSPATH' ) || die( 'Cheatin uh?' ); |
| 4 | |
| 5 | /** |
| 6 | * AVIF conversion button template. |
| 7 | * Premium feature only. |
| 8 | * |
| 9 | * @var array $data |
| 10 | * @var WRIO_Page $page |
| 11 | */ |
| 12 | |
| 13 | $cron_running = WRIO_Plugin::app()->getPopulateOption( 'avif_conversion_cron_running', false ); |
| 14 | $process_running = WRIO_Plugin::app()->getPopulateOption( $data['scope'] . '_avif_process_running', false ); |
| 15 | |
| 16 | if ( ! $cron_running || $cron_running != $data['scope'] ) { |
| 17 | $cron_running = false; |
| 18 | } |
| 19 | |
| 20 | if ( ! $process_running || $process_running != $data['scope'] . '_avif' ) { |
| 21 | $process_running = false; |
| 22 | } |
| 23 | |
| 24 | $button_classes = [ |
| 25 | 'wio-optimize-button', |
| 26 | ]; |
| 27 | |
| 28 | $button_name = __( 'Convert to AVIF', 'robin-image-optimizer' ); |
| 29 | |
| 30 | if ( $cron_running || $process_running ) { |
| 31 | $button_classes[] = 'wrio-cron-mode wio-running'; |
| 32 | $button_name = $process_running ? __( 'Stop conversion', 'robin-image-optimizer' ) : __( 'Stop schedule conversion', 'robin-image-optimizer' ); |
| 33 | } |
| 34 | |
| 35 | ?> |
| 36 | <button type="button" id="wrio-start-avif-conversion" data-format="avif" class="<?php echo join( ' ', $button_classes ); ?>"> |
| 37 | <?php echo esc_attr( $button_name ); ?> |
| 38 | </button> |
| 39 |