clearfy-component-card.php
6 months ago
modal-bulk-optimization.php
6 months ago
modal-webp-conversion.php
6 months ago
part-bulk-convert-avif-button.php
6 months ago
part-bulk-convert-webp-button.php
6 months ago
part-bulk-optimization-button.php
6 months ago
part-bulk-optimization-log.php
5 months ago
part-bulk-optimization-select-site.php
6 months ago
part-bulk-optimization-servers.php
6 months ago
part-bulk-optimization-statistic.php
6 months ago
part-bulk-optimization-tabs.php
6 months ago
part-bulk-optimization-total.php
6 months ago
part-page-header.php
6 months ago
part-settings-page-error-log-options.php
6 months ago
part-bulk-optimization-button.php
61 lines
| 1 | <?php |
| 2 | |
| 3 | defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' ); |
| 4 | |
| 5 | /** |
| 6 | * @var array $data |
| 7 | * @var WRIO_Page $page |
| 8 | */ |
| 9 | |
| 10 | $cron_running = WRIO_Plugin::app()->getPopulateOption( 'cron_running', false ); |
| 11 | $process_running = WRIO_Plugin::app()->getPopulateOption( 'process_running', false ); |
| 12 | |
| 13 | if ( ! $cron_running || $cron_running != $data['scope'] ) { |
| 14 | $cron_running = false; |
| 15 | } |
| 16 | |
| 17 | if ( ! $process_running || $process_running != $data['scope'] ) { |
| 18 | $process_running = false; |
| 19 | } |
| 20 | |
| 21 | $button_classes = [ |
| 22 | 'wio-optimize-button', |
| 23 | ]; |
| 24 | |
| 25 | $button_name = ''; |
| 26 | |
| 27 | if ( $cron_running || $process_running ) { |
| 28 | $button_classes[] = 'wrio-cron-mode wio-running'; |
| 29 | $button_name = $process_running ? __( 'Stop background optimization', 'robin-image-optimizer' ) : __( 'Stop schedule optimization', 'robin-image-optimizer' ); |
| 30 | } else { |
| 31 | $button_name = __( 'Start Optimization', 'robin-image-optimizer' ); |
| 32 | } |
| 33 | |
| 34 | // Get enabled formats for the message |
| 35 | $enabled_formats = []; |
| 36 | |
| 37 | // For custom-folders and nextgen, only show "Compression" since format conversion is only for Media Library for the moments. |
| 38 | $show_formats = ! in_array( $data['scope'], [ 'custom-folders', 'nextgen-gallery' ], true ); |
| 39 | if ( $show_formats && class_exists( 'WRIO_Format_Converter_Factory' ) ) { |
| 40 | $enabled_formats = WRIO_Format_Converter_Factory::get_enabled_formats(); |
| 41 | } |
| 42 | |
| 43 | // Build dynamic message based on enabled formats |
| 44 | $format_message = ''; |
| 45 | if ( $show_formats && ! empty( $enabled_formats ) ) { |
| 46 | $features = [ __( 'Compression', 'robin-image-optimizer' ) ]; |
| 47 | $features = array_merge( $features, array_map( 'strtoupper', $enabled_formats ) ); |
| 48 | $format_message = implode( ' • ', $features ); |
| 49 | } else { |
| 50 | $format_message = __( 'Only Compression', 'robin-image-optimizer' ); |
| 51 | } |
| 52 | |
| 53 | ?> |
| 54 | <button type="button" id="wrio-start-optimization" class="<?php echo join( ' ', $button_classes ); ?>"> |
| 55 | <?php echo esc_attr( $button_name ); ?> |
| 56 | </button> |
| 57 | <?php if ( ! empty( $format_message ) ) : ?> |
| 58 | <p class="wrio-optimization-format-info"> |
| 59 | <?php echo esc_html( $format_message ); ?> |
| 60 | </p> |
| 61 | <?php endif; ?> |