| @@ -45,8 +45,13 @@ | ||
| 45 | 45 | $settings = new Optml_Settings(); |
| 46 | 46 | if ( $settings->get( 'offload_media' ) === 'disabled' ) { |
| 47 | 47 | return \WP_CLI::error( __( 'You need to have the offload_media option enabled in order to use this command', 'optimole-wp' ) ); |
| 48 | 48 | } |
| 49 | + | |
| 50 | + Optml_Media_Offload::clear_offload_errors_meta(); | |
| 51 | + if ( $action === 'rollback' ) { | |
| 52 | + Optml_Media_Offload::clear_rollback_errors_meta(); | |
| 53 | + } | |
| 49 | 54 | WP_CLI::line( $strings[ $action ]['info'] ); |
| 50 | 55 | $number_of_images_for = 'offload_images'; |
| 51 | 56 | if ( $action === 'rollback' ) { |
| 52 | 57 | $number_of_images_for = 'rollback_images'; |
| @@ -53,8 +58,13 @@ | ||
| 53 | 58 | } |
| 54 | 59 | $number_of_images = Optml_Media_Offload::number_of_images_and_pages( $number_of_images_for ); |
| 55 | 60 | Optml_Media_Offload::record_process_meta( $number_of_images ); |
| 56 | 61 | $batch = 5; |
| 62 | + if ( $number_of_images === 0 ) { | |
| 63 | + WP_CLI::success( $strings[ $action ]['success'] ); | |
| 64 | + | |
| 65 | + return; | |
| 66 | + } | |
| 57 | 67 | $possible_batch = ceil( $number_of_images / 10 ); |
| 58 | 68 | if ( $possible_batch < $batch ) { |
| 59 | 69 | $batch = $possible_batch; |
| 60 | 70 | } |
| @@ -82,11 +92,10 @@ | ||
| 82 | 92 | WP_CLI::error( $strings['limit_exceeded'], true ); |
| 83 | 93 | } |
| 84 | 94 | |
| 85 | 95 | $progress->tick(); |
| 86 | - $tick++; | |
| 96 | + ++$tick; | |
| 87 | 97 | } |
| 88 | 98 | $progress->finish(); |
| 89 | 99 | WP_CLI::line( $strings[ $action ]['success'] ); |
| 90 | 100 | } |
| 91 | 101 | } |
| 92 | - | |