PluginProbe
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF / trunk
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF vtrunk
2.3.4 2.3.3 2.3.2 2.3.1 2.3.0 2.2.9 2.2.8 trunk 1.10 1.3.3 1.3.4 1.3.5 1.3.5.1 1.3.5.2 1.3.6 1.3.6.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.5 All 103 releases
← All changes | classes/Optimization/Process/CustomFolders.php +20 -12 1.10 → trunk View file →
@@ -1,11 +1,9 @@
1 1 <?php
2 2 namespace Imagify\Optimization\Process;
3 3
4 -use Imagify\Optimization\File;
4 +use WP_Error;
5 5
6 -defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' );
7 -
8 6 /**
9 7 * Optimization class for the custom folders.
10 8 * This class constructor accepts:
11 9 * - A post ID (int).
@@ -52,29 +50,33 @@
52 50 */
53 51 public function get_missing_sizes() {
54 52 // The media must have been optimized once and have a backup.
55 53 if ( ! $this->is_valid() ) {
56 - return new \WP_Error( 'invalid_media', __( 'This media is not valid.', 'imagify' ) );
54 + return new WP_Error( 'invalid_media', __( 'This media is not valid.', 'imagify' ) );
57 55 }
58 56
59 57 $media = $this->get_media();
60 58
59 + if ( ! $media ) {
60 + return new WP_Error( 'no_media', __( 'No media found.', 'imagify' ) );
61 + }
62 +
61 63 if ( ! $media->is_supported() ) {
62 - return new \WP_Error( 'media_not_supported', __( 'This media is not supported.', 'imagify' ) );
64 + return new WP_Error( 'media_not_supported', __( 'This media is not supported.', 'imagify' ) );
63 65 }
64 66
65 67 $data = $this->get_data();
66 68
67 69 if ( ! $data->is_optimized() ) {
68 - return new \WP_Error( 'media_not_optimized', __( 'This media is not optimized yet.', 'imagify' ) );
70 + return new WP_Error( 'media_not_optimized', __( 'This media is not optimized yet.', 'imagify' ) );
69 71 }
70 72
71 73 if ( ! $media->has_backup() ) {
72 - return new \WP_Error( 'no_backup', __( 'This file has no backup file.', 'imagify' ) );
74 + return new WP_Error( 'no_backup', __( 'This file has no backup file.', 'imagify' ) );
73 75 }
74 76
75 77 if ( ! $media->is_image() ) {
76 - return new \WP_Error( 'media_not_an_image', __( 'This media is not an image.', 'imagify' ) );
78 + return new WP_Error( 'media_not_an_image', __( 'This media is not an image.', 'imagify' ) );
77 79 }
78 80
79 81 return [];
80 82 }
@@ -90,14 +92,20 @@
90 92 * @return bool|WP_Error True if successfully launched. A \WP_Error instance on failure.
91 93 */
92 94 public function optimize_missing_thumbnails() {
93 95 if ( ! $this->is_valid() ) {
94 - return new \WP_Error( 'invalid_media', __( 'This media is not valid.', 'imagify' ) );
96 + return new WP_Error( 'invalid_media', __( 'This media is not valid.', 'imagify' ) );
95 97 }
96 98
97 - if ( ! $this->get_media()->is_supported() ) {
98 - return new \WP_Error( 'media_not_supported', __( 'This media is not supported.', 'imagify' ) );
99 + $media = $this->get_media();
100 +
101 + if ( ! $media ) {
102 + return new WP_Error( 'no_media', __( 'No media found.', 'imagify' ) );
99 103 }
100 104
101 - return new \WP_Error( 'no_sizes', __( 'No thumbnails seem to be missing.', 'imagify' ) );
105 + if ( ! $media->is_supported() ) {
106 + return new WP_Error( 'media_not_supported', __( 'This media is not supported.', 'imagify' ) );
107 + }
108 +
109 + return new WP_Error( 'no_sizes', __( 'No thumbnails seem to be missing.', 'imagify' ) );
102 110 }
103 111 }