PluginProbe
Optimole – Optimize Images | Convert WebP & AVIF | CDN & Lazy Load | Image Optimization / trunk
Optimole – Optimize Images | Convert WebP & AVIF | CDN & Lazy Load | Image Optimization vtrunk
4.2.14 4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 2.5.5 2.5.6 2.5.7 3.0.0 3.0.1 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.11.0 3.11.1 3.11.2 3.11.3 3.12.0 All 135 releases
← All changes | inc/cli/cli_media.php +18 -2 3.11.2 → trunk View file →
@@ -39,13 +39,19 @@
39 39 'rollback' => [
40 40 'info' => __( 'Moving all images back to your media library', 'optimole-wp' ),
41 41 'success' => __( 'All images have been uploaded to your media library', 'optimole-wp' ),
42 42 ],
43 + 'limit_exceeded' => __( 'You have reached the maximum offloading limit of images. To increase the offload limit and for more information, contact our support.', 'optimole-wp' ),
43 44 ];
44 45 $settings = new Optml_Settings();
45 46 if ( $settings->get( 'offload_media' ) === 'disabled' ) {
46 47 return \WP_CLI::error( __( 'You need to have the offload_media option enabled in order to use this command', 'optimole-wp' ) );
47 48 }
49 +
50 + Optml_Media_Offload::clear_offload_errors_meta();
51 + if ( $action === 'rollback' ) {
52 + Optml_Media_Offload::clear_rollback_errors_meta();
53 + }
48 54 WP_CLI::line( $strings[ $action ]['info'] );
49 55 $number_of_images_for = 'offload_images';
50 56 if ( $action === 'rollback' ) {
51 57 $number_of_images_for = 'rollback_images';
@@ -50,9 +56,15 @@
50 56 if ( $action === 'rollback' ) {
51 57 $number_of_images_for = 'rollback_images';
52 58 }
53 59 $number_of_images = Optml_Media_Offload::number_of_images_and_pages( $number_of_images_for );
60 + Optml_Media_Offload::record_process_meta( $number_of_images );
54 61 $batch = 5;
62 + if ( $number_of_images === 0 ) {
63 + WP_CLI::success( $strings[ $action ]['success'] );
64 +
65 + return;
66 + }
55 67 $possible_batch = ceil( $number_of_images / 10 );
56 68 if ( $possible_batch < $batch ) {
57 69 $batch = $possible_batch;
58 70 }
@@ -74,12 +86,16 @@
74 86 }
75 87 } else {
76 88 $action === 'rollback' ? Optml_Media_Offload::instance()->rollback_images( $batch ) : Optml_Media_Offload::instance()->upload_images( $batch );
77 89 }
90 +
91 + if ( Optml_Media_Offload::instance()->settings->is_offload_limit_reached() ) {
92 + WP_CLI::error( $strings['limit_exceeded'], true );
93 + }
94 +
78 95 $progress->tick();
79 - $tick++;
96 + ++$tick;
80 97 }
81 98 $progress->finish();
82 99 WP_CLI::line( $strings[ $action ]['success'] );
83 100 }
84 101 }
85 -