Converter for Media – Optimize images | Convert WebP & AVIF - Version 3.0.5

Version Description

(2021-06-09) = * [Fixed] Handling of filters for changing directory paths * [Fixed] Converting using Imagick method for 100% image quality * [Changed] Default conversion method from Gd to Imagick

Download this release

Release Info

Developer mateuszgbiorczyk
Plugin Icon 128x128 Converter for Media – Optimize images | Convert WebP & AVIF
Version 3.0.5
Comparing to
See all releases

Code changes from version 3.0.4 to 3.0.5

Files changed (83) hide show
  1. readme.txt +77 -70
  2. src/Conversion/Cron/Event.php +0 -1
  3. src/Conversion/Directory/DirectoryAbstract.php +6 -6
  4. src/Conversion/{Directories.php → Directory/DirectoryFactory.php} +23 -16
  5. src/Conversion/Directory/{DirectoriesIntegration.php → DirectoryIntegration.php} +2 -7
  6. src/Conversion/Directory/GalleryDirectory.php +0 -3
  7. src/Conversion/Directory/PluginsDirectory.php +0 -3
  8. src/Conversion/Directory/ThemesDirectory.php +0 -3
  9. src/Conversion/Directory/UploadsDirectory.php +0 -3
  10. src/Conversion/Directory/UploadsWebpcDirectory.php +0 -3
  11. src/Conversion/Endpoint/EndpointAbstract.php +0 -1
  12. src/Conversion/{Endpoints.php → Endpoint/EndpointFactory.php} +2 -6
  13. src/Conversion/Endpoint/EndpointIntegration.php +0 -1
  14. src/Conversion/Endpoint/PathsEndpoint.php +0 -4
  15. src/Conversion/Endpoint/RegenerateEndpoint.php +0 -2
  16. src/Conversion/Exception/ConversionErrorException.php +0 -3
  17. src/Conversion/Exception/ExceptionAbstract.php +0 -2
  18. src/Conversion/Exception/ExtensionUnsupportedException.php +0 -3
  19. src/Conversion/Exception/FunctionUnavailableException.php +0 -3
  20. src/Conversion/Exception/ImageInvalidException.php +0 -3
  21. src/Conversion/Exception/ImagickNotSupportWebpException.php +0 -3
  22. src/Conversion/Exception/ImagickUnavailableException.php +0 -3
  23. src/Conversion/Exception/LargerThanOriginalException.php +0 -3
  24. src/Conversion/Exception/OutputPathException.php +0 -3
  25. src/Conversion/Exception/ResolutionOversizeException.php +0 -3
  26. src/Conversion/Exception/ServerConfigurationException.php +0 -3
  27. src/Conversion/Exception/SourcePathException.php +0 -3
  28. src/Conversion/Format/AvifFormat.php +0 -3
  29. src/Conversion/Format/FormatAbstract.php +2 -3
  30. src/Conversion/{Formats.php → Format/FormatFactory.php} +15 -8
  31. src/Conversion/Format/WebpFormat.php +0 -3
  32. src/Conversion/Method/GdMethod.php +7 -8
  33. src/Conversion/Method/ImagickMethod.php +9 -8
  34. src/Conversion/{Methods.php → Method/MethodFactory.php} +18 -8
  35. src/Conversion/Method/MethodIntegrator.php +1 -5
  36. src/Conversion/OutputPath.php +2 -3
  37. src/Conversion/SkipExists.php +2 -4
  38. src/Error/ErrorAbstract.php +0 -1
  39. src/Error/{Errors.php → ErrorFactory.php} +1 -9
  40. src/Error/LibsInstalledError.php +0 -2
  41. src/Error/LibsSupportAvifError.php +0 -2
  42. src/Error/LibsSupportWebpError.php +1 -3
  43. src/Error/PassthruError.php +0 -2
  44. src/Error/PathsError.php +0 -3
  45. src/Error/RestapiError.php +0 -3
  46. src/Error/RewritesError.php +0 -2
  47. src/Error/SettingsError.php +0 -2
  48. src/Loader/HtaccessLoader.php +1 -4
  49. src/Loader/LoaderAbstract.php +2 -3
  50. src/Loader/{Loaders.php → LoaderFactory.php} +1 -5
  51. src/Loader/LoaderIntegration.php +0 -2
  52. src/Loader/PassthruLoader.php +0 -3
  53. src/Notice/NoticeAbstract.php +0 -2
  54. src/Notice/NoticeFactory.php +32 -0
  55. src/Notice/NoticeIntegration.php +0 -1
  56. src/Notice/Notices.php +0 -23
  57. src/Notice/ThanksNotice.php +0 -3
  58. src/Notice/WelcomeNotice.php +2 -4
  59. src/Plugin/Links.php +2 -2
  60. src/Plugin/Uninstall/PluginSettings.php +2 -2
  61. src/Plugin/Uninstall/WebpFiles.php +7 -5
  62. src/Plugin/Update.php +0 -2
  63. src/PluginAccessAbstract.php +0 -4
  64. src/PluginAccessInterface.php +0 -3
  65. src/Settings/Option/ConversionMethodOption.php +5 -6
  66. src/Settings/Option/ExtraFeaturesOption.php +0 -4
  67. src/Settings/Option/ImagesQualityOption.php +0 -3
  68. src/Settings/Option/LoaderTypeOption.php +0 -2
  69. src/Settings/Option/OptionAbstract.php +0 -2
  70. src/Settings/{Options.php → Option/OptionFactory.php} +35 -29
  71. src/Settings/Option/OptionIntegration.php +0 -3
  72. src/Settings/Option/OptionInterface.php +0 -5
  73. src/Settings/Option/OutputFormatsOption.php +3 -6
  74. src/Settings/Option/SupportedDirectoriesOption.php +2 -4
  75. src/Settings/Option/SupportedExtensionsOption.php +0 -3
  76. src/Settings/Page/DebugPage.php +2 -5
  77. src/Settings/Page/PageAbstract.php +0 -1
  78. src/Settings/Page/PageFactory.php +45 -0
  79. src/Settings/{Pages.php → Page/PageIntegration.php} +29 -9
  80. src/Settings/Page/SettingsPage.php +4 -7
  81. src/Settings/SettingsSave.php +4 -4
  82. src/WebpConverter.php +8 -8
  83. webp-converter-for-media.php +2 -2
readme.txt CHANGED
@@ -1,4 +1,4 @@
1
- === WebP Converter for Media ===
2
  Contributors: mateuszgbiorczyk
3
  Donate link: https://ko-fi.com/gbiorczyk/?utm_source=webp-converter-for-media&utm_medium=readme-donate
4
  Tags: convert webp, webp, optimize images, compress images, webp converter
@@ -9,7 +9,7 @@ Stable tag: trunk
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
 
12
- Speed up your website by serving WebP images instead of standard formats JPEG, PNG and GIF.
13
 
14
  == Description ==
15
 
@@ -17,17 +17,17 @@ Speed up your website by serving WebP images. By replacing files in standard JPE
17
 
18
  After installing the plugin you do not have to do anything more. Your current images will be converted into a new format. When compress images is finished, users will automatically receive new, much lighter images than the original ones.
19
 
20
- As of today, over 90% of users use browsers that support the WebP format. The loading time of your website depends to a large extent on its weight. Now you can speed up it in a few seconds without much effort!
21
 
22
  This will be a profit both for your users who will not have to download so much data, but also for a server that will be less loaded. Remember that a better optimized website also affects your Google ranking.
23
 
24
  #### Support for additional directories
25
 
26
- Now you can optimize images not only from `/uploads` directory but also from `/plugins` and `/themes` directories. This allows full integration with the WebP format!
27
 
28
  #### How does this work?
29
 
30
- - By adding images to your Media Library, they are automatically converted and saved in a separate directory.
31
  - If you have just installed the plugin, you can optimize images with one click.
32
  - As WebP you will see all the images added to the Media Library and other selected directories.
33
  - When the browser tries to download an image file, the server verifies if it supports `image/webp` files and if the file exists.
@@ -38,7 +38,7 @@ Now you can optimize images not only from `/uploads` directory but also from `/p
38
  - In case rewriting by rules from .htaccess file is blocked, a mode is available which loads images via PHP file. Then image URLs are changed, but the logic of operation is the same as in the case of the default mode.
39
  - The final result is that your users download less than half of the data, and the website itself loads faster!
40
 
41
- #### WebP images are the future!
42
 
43
  Optimize images and raise your website to a new level now! Install the plugin and enjoy the website that loads faster by image optimization. Surely you and your users will appreciate it.
44
 
@@ -70,7 +70,7 @@ When adding a thread, follow these steps and reply to each of them:
70
 
71
  **1.** Do you have any error on the plugin settings page? Please read [this thread](https://wordpress.org/support/topic/server-configuration-error-what-to-do/) if you have any errors.
72
 
73
- **2.** URL of your website. If your site is not publicly available, add it to test environment.
74
 
75
  **3.** Configuration of your server *(link to it can be found on the settings page of plugin in the section **"We are waiting for your message"**)* - please take a screenshot of the ENTIRE page and send it to me.
76
 
@@ -78,11 +78,13 @@ When adding a thread, follow these steps and reply to each of them:
78
 
79
  **5.** Please do the test, which is described in the FAQ in question `How to check if plugin works?`. Please send a screenshot of Devtools with test results.
80
 
81
- **6.** Do you use any plugin filters or actions from this FAQ? If so, list them all.
82
 
83
- **7.** What plugin version are you using? If it is not the latest then update and check everything again.
84
 
85
- **8.** A list of all the plugins you use. Have you tried checking the plugin operation by turning off all others and activating the default theme? If not, please try whenever possible. **This is very important because other plugins or themes can cause problems.** Therefore, we recommend disabling all necessary plugins and enabling the default theme.
 
 
86
 
87
  Please remember to include the answers for all questions by adding a thread. It is much easier and accelerate the solution of your problem.
88
 
@@ -164,25 +166,25 @@ This is possible using the following types of filters to change default paths. I
164
  Path to the root installation directory of WordPress *(`ABSPATH` by default)*:
165
 
166
  `add_filter( 'webpc_site_root', function( $path ) {
167
- return ABSPATH;
168
  } );`
169
 
170
  Path to `/uploads` directory *(relative to the root directory)*:
171
 
172
  `add_filter( 'webpc_dir_name', function( $path, $directory ) {
173
- if ( $directory !== 'uploads' ) {
174
- return $path;
175
- }
176
- return 'wp-content/uploads';
177
  }, 10, 2 );`
178
 
179
  Directory path with converted WebP files *(relative to the root directory)*:
180
 
181
  `add_filter( 'webpc_dir_name', function( $path, $directory ) {
182
- if ( $directory !== 'webp' ) {
183
- return $path;
184
- }
185
- return 'wp-content/uploads-webpc';
186
  }, 10, 2 );`
187
 
188
  **Note that the `/uploads-webpc` directory must be at the same nesting level as the `/uploads`, `/plugins` and `/themes` directories.**
@@ -190,41 +192,41 @@ Directory path with converted WebP files *(relative to the root directory)*:
190
  Prefix in URL of `/wp-content/` directory or equivalent *(used in .htaccess)*:
191
 
192
  `add_filter( 'webpc_uploads_prefix', function( $prefix ) {
193
- return '/';
194
  } );`
195
 
196
  For the following sample custom WordPress structure:
197
 
198
  `...
199
  ├── web
200
- ...
201
- ├── app
202
- ├── mu-plugins
203
- ├── plugins
204
- ├── themes
205
- └── uploads
206
- ├── wp-config.php
207
- ...`
208
 
209
  Use the following filters:
210
 
211
  `add_filter( 'webpc_site_root', function( $path ) {
212
- return 'C:/WAMP/www/project/webp'; // your valid path to root
213
  } );
214
  add_filter( 'webpc_dir_name', function( $path, $directory ) {
215
- if ( $directory !== 'uploads' ) {
216
- return $path;
217
- }
218
- return 'app/uploads';
219
  }, 10, 2 );
220
  add_filter( 'webpc_dir_name', function( $path, $directory ) {
221
- if ( $directory !== 'webp' ) {
222
- return $path;
223
- }
224
- return 'app/uploads-webpc';
225
  }, 10, 2 );`
226
  `add_filter( 'webpc_uploads_prefix', function( $prefix ) {
227
- return '/';
228
  } );`
229
 
230
  After setting the filters go to `Settings -> WebP Converter` in the admin panel and click the `Save Changes` button. `.htaccess` files with appropriate rules should be created in the directories `/uploads` and `/uploads-webpc`.
@@ -246,7 +248,7 @@ You can automatically run the option to regenerate all new images. This is usefu
246
  Below is an example of how to use this action to automatically regenerate images after changing the theme:
247
 
248
  `add_action('init', function() {
249
- do_action( 'webpc_regenerate_all' );
250
  });`
251
 
252
  To manually start converting selected files, you can use the action to which you will pass an array with a list of paths *(they must be absolute server paths)*:
@@ -260,7 +262,7 @@ An alternative method is to manually start converting the selected attachment by
260
  In addition, you can edit the list of files that will be converted. For example, to add some to the exceptions. To do this, use the following filter, which by default returns a list of all paths:
261
 
262
  `add_filter( 'webpc_files_paths', function( $paths, $skip_exists ) {
263
- return $paths;
264
  }, 10, 2 );`
265
 
266
  Argument `$paths` is array of absolute server paths and `$skip_exists` means whether to skip converted images.
@@ -268,7 +270,7 @@ Argument `$paths` is array of absolute server paths and `$skip_exists` means whe
268
  You can also modify the list of image paths for an attachment, e.g. to exclude one image size. To do this, use the following filter:
269
 
270
  `add_filter( 'webpc_attachment_paths', function( $paths, $attachment_id ) {
271
- return $paths;
272
  }, 10, 2 );`
273
 
274
  Argument `$paths` is array of absolute server paths and `$attachment_id` is the post ID of attachment, added to the Media Library.
@@ -288,7 +290,7 @@ Returning an empty string will delete these rules the next time you save the plu
288
  Rules for redirects: *(returns rules for `mod_rewrite` module)*:
289
 
290
  `add_filter( 'webpc_htaccess_mod_rewrite', function( $rules, $path ) {
291
- return '';
292
  }, 10, 2 );`
293
 
294
  Argument `$path` is absolute server path for `.htaccess` file *(`/wp-content/.htaccess` or `/wp-content/uploads/.htaccess`)*.
@@ -296,19 +298,19 @@ Argument `$path` is absolute server path for `.htaccess` file *(`/wp-content/.ht
296
  Rules for `image/webp` MIME type: *(returns rules for `mod_mime` module)*:
297
 
298
  `add_filter( 'webpc_htaccess_mod_mime', function( $rules ) {
299
- return '';
300
  } );`
301
 
302
  Rules for Browser Caching: *(returns rules for `mod_expires` module)*:
303
 
304
  `add_filter( 'webpc_htaccess_mod_expires', function( $rules ) {
305
- return '';
306
  } );`
307
 
308
  All rules from the files `/wp-content/.htaccess`, `/wp-content/uploads/.htaccess` and `/wp-content/uploads-webpc/.htaccess`: *(returns rules for modules: `mod_rewrite`, `mod_mime` and `mod_expires`)*:
309
 
310
  `add_filter( 'webpc_htaccess_rules', function( $rules, $path ) {
311
- return '';
312
  }, 10, 2 );`
313
 
314
  Argument `$path` is absolute server path for `.htaccess` file.
@@ -346,8 +348,8 @@ Please edit the configuration file:
346
  and add this code line:
347
 
348
  `types {`
349
- ` # ...`
350
- ` image/webp webp;`
351
  `}`
352
 
353
  Then find the configuration file in one of the paths *(remember to select configuration file used by your vhost)*:
@@ -357,16 +359,16 @@ Then find the configuration file in one of the paths *(remember to select config
357
  and add below code in this file *(add these lines to very beginning of file if possible - if they will be at the bottom, other rules may block the rules for WebP from working)*:
358
 
359
  `server {`
360
- ` location ~ /wp-content/(?<path>.+)\.(?<ext>jpe?g|png|gif)$ {`
361
- ` if ($http_accept !~* "image/webp") {`
362
- ` break;`
363
- ` }`
364
- ` add_header Vary Accept;`
365
- ` add_header Cache-Control "private";
366
- ` expires 365d;`
367
- ` try_files /wp-content/uploads-webpc/$path.$ext.webp $uri =404;`
368
- ` }`
369
- ` # ...`
370
  `}`
371
 
372
  After making changes, remember to restart the machine: `systemctl restart nginx`.
@@ -380,16 +382,16 @@ Please manually paste the following code **at the beginning of .htaccess file**
380
  `# BEGIN WebP Converter`
381
  `# ! --- DO NOT EDIT PREVIOUS LINE --- !`
382
  `<IfModule mod_rewrite.c>
383
- RewriteEngine On
384
- RewriteCond %{HTTP_ACCEPT} image/webp
385
- RewriteCond %{DOCUMENT_ROOT}/wp-content/uploads-webpc/$1.jpg.webp -f
386
- RewriteRule (.+)\.jpg$ /wp-content/uploads-webpc/$1.jpg.webp [NC,T=image/webp,L]
387
- RewriteCond %{HTTP_ACCEPT} image/webp
388
- RewriteCond %{DOCUMENT_ROOT}/wp-content/uploads-webpc/$1.jpeg.webp -f
389
- RewriteRule (.+)\.jpeg$ /wp-content/uploads-webpc/$1.jpeg.webp [NC,T=image/webp,L]
390
- RewriteCond %{HTTP_ACCEPT} image/webp
391
- RewriteCond %{DOCUMENT_ROOT}/wp-content/uploads-webpc/$1.png.webp -f
392
- RewriteRule (.+)\.png$ /wp-content/uploads-webpc/$1.png.webp [NC,T=image/webp,L]
393
  </IfModule>
394
  <IfModule mod_headers.c>
395
  Header Set Cache-Control "private"
@@ -402,11 +404,11 @@ And the following code **at the beginning of .htaccess file** in the `/wp-conten
402
  `# BEGIN WebP Converter`
403
  `# ! --- DO NOT EDIT PREVIOUS LINE --- !`
404
  `<IfModule mod_mime.c>
405
- AddType image/webp .webp
406
  </IfModule>
407
  <IfModule mod_expires.c>
408
- ExpiresActive On
409
- ExpiresByType image/webp "access plus 1 year"
410
  </IfModule>
411
  <IfModule mod_headers.c>
412
  Header Set Cache-Control "private"
@@ -434,6 +436,11 @@ This is all very important to us and allows us to do even better things for you!
434
 
435
  == Changelog ==
436
 
 
 
 
 
 
437
  = 3.0.4 (2021-05-28) =
438
  * `[Fixed]` Caching rewrites on CDN and Proxy servers
439
 
1
+ === WebP Converter for Media - Convert WebP & Optimize Images ===
2
  Contributors: mateuszgbiorczyk
3
  Donate link: https://ko-fi.com/gbiorczyk/?utm_source=webp-converter-for-media&utm_medium=readme-donate
4
  Tags: convert webp, webp, optimize images, compress images, webp converter
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
 
12
+ Convert WebP just now! Speed up your website by serving WebP images instead of standard formats JPEG, PNG and GIF.
13
 
14
  == Description ==
15
 
17
 
18
  After installing the plugin you do not have to do anything more. Your current images will be converted into a new format. When compress images is finished, users will automatically receive new, much lighter images than the original ones.
19
 
20
+ As of today, over 90% of users use browsers that support the WebP format. The loading time of your website depends to a large extent on its weight. Using convert WebP, now you can and speed up it in a few seconds without much effort!
21
 
22
  This will be a profit both for your users who will not have to download so much data, but also for a server that will be less loaded. Remember that a better optimized website also affects your Google ranking.
23
 
24
  #### Support for additional directories
25
 
26
+ Now you can convert WebP and optimize images not only from `/uploads` directory but also from `/plugins` and `/themes` directories. This allows full integration with the WebP format!
27
 
28
  #### How does this work?
29
 
30
+ - By adding images to your Media Library, convert WebP starts automatically and WebP images are saved in a separate directory.
31
  - If you have just installed the plugin, you can optimize images with one click.
32
  - As WebP you will see all the images added to the Media Library and other selected directories.
33
  - When the browser tries to download an image file, the server verifies if it supports `image/webp` files and if the file exists.
38
  - In case rewriting by rules from .htaccess file is blocked, a mode is available which loads images via PHP file. Then image URLs are changed, but the logic of operation is the same as in the case of the default mode.
39
  - The final result is that your users download less than half of the data, and the website itself loads faster!
40
 
41
+ #### Convert WebP - it is the future!
42
 
43
  Optimize images and raise your website to a new level now! Install the plugin and enjoy the website that loads faster by image optimization. Surely you and your users will appreciate it.
44
 
70
 
71
  **1.** Do you have any error on the plugin settings page? Please read [this thread](https://wordpress.org/support/topic/server-configuration-error-what-to-do/) if you have any errors.
72
 
73
+ **2.** URL of your website.
74
 
75
  **3.** Configuration of your server *(link to it can be found on the settings page of plugin in the section **"We are waiting for your message"**)* - please take a screenshot of the ENTIRE page and send it to me.
76
 
78
 
79
  **5.** Please do the test, which is described in the FAQ in question `How to check if plugin works?`. Please send a screenshot of Devtools with test results.
80
 
81
+ **6.** Enable [debugging to the file](https://wordpress.org/support/article/debugging-in-wordpress/#wp_debug_log) and check if any errors are generated in the debug.log file when the works. Provide their content.
82
 
83
+ **7.** Do you use any plugin filters or actions from this FAQ? If so, list them all.
84
 
85
+ **8.** What plugin version are you using? If it is not the latest then update and check everything again.
86
+
87
+ **9.** A list of all the plugins you use. Have you tried checking the plugin operation by turning off all others and activating the default theme? If not, please try whenever possible. **This is very important because other plugins or themes can cause problems.** Therefore, we recommend disabling all necessary plugins and enabling the default theme.
88
 
89
  Please remember to include the answers for all questions by adding a thread. It is much easier and accelerate the solution of your problem.
90
 
166
  Path to the root installation directory of WordPress *(`ABSPATH` by default)*:
167
 
168
  `add_filter( 'webpc_site_root', function( $path ) {
169
+ return ABSPATH;
170
  } );`
171
 
172
  Path to `/uploads` directory *(relative to the root directory)*:
173
 
174
  `add_filter( 'webpc_dir_name', function( $path, $directory ) {
175
+ if ( $directory !== 'uploads' ) {
176
+ return $path;
177
+ }
178
+ return 'wp-content/uploads';
179
  }, 10, 2 );`
180
 
181
  Directory path with converted WebP files *(relative to the root directory)*:
182
 
183
  `add_filter( 'webpc_dir_name', function( $path, $directory ) {
184
+ if ( $directory !== 'webp' ) {
185
+ return $path;
186
+ }
187
+ return 'wp-content/uploads-webpc';
188
  }, 10, 2 );`
189
 
190
  **Note that the `/uploads-webpc` directory must be at the same nesting level as the `/uploads`, `/plugins` and `/themes` directories.**
192
  Prefix in URL of `/wp-content/` directory or equivalent *(used in .htaccess)*:
193
 
194
  `add_filter( 'webpc_uploads_prefix', function( $prefix ) {
195
+ return '/';
196
  } );`
197
 
198
  For the following sample custom WordPress structure:
199
 
200
  `...
201
  ├── web
202
+ ...
203
+ ├── app
204
+ ├── mu-plugins
205
+ ├── plugins
206
+ ├── themes
207
+ └── uploads
208
+ ├── wp-config.php
209
+ ...`
210
 
211
  Use the following filters:
212
 
213
  `add_filter( 'webpc_site_root', function( $path ) {
214
+ return 'C:/WAMP/www/project/webp'; // your valid path to root
215
  } );
216
  add_filter( 'webpc_dir_name', function( $path, $directory ) {
217
+ if ( $directory !== 'uploads' ) {
218
+ return $path;
219
+ }
220
+ return 'app/uploads';
221
  }, 10, 2 );
222
  add_filter( 'webpc_dir_name', function( $path, $directory ) {
223
+ if ( $directory !== 'webp' ) {
224
+ return $path;
225
+ }
226
+ return 'app/uploads-webpc';
227
  }, 10, 2 );`
228
  `add_filter( 'webpc_uploads_prefix', function( $prefix ) {
229
+ return '/';
230
  } );`
231
 
232
  After setting the filters go to `Settings -> WebP Converter` in the admin panel and click the `Save Changes` button. `.htaccess` files with appropriate rules should be created in the directories `/uploads` and `/uploads-webpc`.
248
  Below is an example of how to use this action to automatically regenerate images after changing the theme:
249
 
250
  `add_action('init', function() {
251
+ do_action( 'webpc_regenerate_all' );
252
  });`
253
 
254
  To manually start converting selected files, you can use the action to which you will pass an array with a list of paths *(they must be absolute server paths)*:
262
  In addition, you can edit the list of files that will be converted. For example, to add some to the exceptions. To do this, use the following filter, which by default returns a list of all paths:
263
 
264
  `add_filter( 'webpc_files_paths', function( $paths, $skip_exists ) {
265
+ return $paths;
266
  }, 10, 2 );`
267
 
268
  Argument `$paths` is array of absolute server paths and `$skip_exists` means whether to skip converted images.
270
  You can also modify the list of image paths for an attachment, e.g. to exclude one image size. To do this, use the following filter:
271
 
272
  `add_filter( 'webpc_attachment_paths', function( $paths, $attachment_id ) {
273
+ return $paths;
274
  }, 10, 2 );`
275
 
276
  Argument `$paths` is array of absolute server paths and `$attachment_id` is the post ID of attachment, added to the Media Library.
290
  Rules for redirects: *(returns rules for `mod_rewrite` module)*:
291
 
292
  `add_filter( 'webpc_htaccess_mod_rewrite', function( $rules, $path ) {
293
+ return '';
294
  }, 10, 2 );`
295
 
296
  Argument `$path` is absolute server path for `.htaccess` file *(`/wp-content/.htaccess` or `/wp-content/uploads/.htaccess`)*.
298
  Rules for `image/webp` MIME type: *(returns rules for `mod_mime` module)*:
299
 
300
  `add_filter( 'webpc_htaccess_mod_mime', function( $rules ) {
301
+ return '';
302
  } );`
303
 
304
  Rules for Browser Caching: *(returns rules for `mod_expires` module)*:
305
 
306
  `add_filter( 'webpc_htaccess_mod_expires', function( $rules ) {
307
+ return '';
308
  } );`
309
 
310
  All rules from the files `/wp-content/.htaccess`, `/wp-content/uploads/.htaccess` and `/wp-content/uploads-webpc/.htaccess`: *(returns rules for modules: `mod_rewrite`, `mod_mime` and `mod_expires`)*:
311
 
312
  `add_filter( 'webpc_htaccess_rules', function( $rules, $path ) {
313
+ return '';
314
  }, 10, 2 );`
315
 
316
  Argument `$path` is absolute server path for `.htaccess` file.
348
  and add this code line:
349
 
350
  `types {`
351
+ ` # ...`
352
+ ` image/webp webp;`
353
  `}`
354
 
355
  Then find the configuration file in one of the paths *(remember to select configuration file used by your vhost)*:
359
  and add below code in this file *(add these lines to very beginning of file if possible - if they will be at the bottom, other rules may block the rules for WebP from working)*:
360
 
361
  `server {`
362
+ ` location ~ /wp-content/(?<path>.+)\.(?<ext>jpe?g|png|gif)$ {`
363
+ ` if ($http_accept !~* "image/webp") {`
364
+ ` break;`
365
+ ` }`
366
+ ` add_header Vary Accept;`
367
+ ` add_header Cache-Control "private" always;`
368
+ ` expires 365d;`
369
+ ` try_files /wp-content/uploads-webpc/$path.$ext.webp $uri =404;`
370
+ ` }`
371
+ ` # ...`
372
  `}`
373
 
374
  After making changes, remember to restart the machine: `systemctl restart nginx`.
382
  `# BEGIN WebP Converter`
383
  `# ! --- DO NOT EDIT PREVIOUS LINE --- !`
384
  `<IfModule mod_rewrite.c>
385
+ RewriteEngine On
386
+ RewriteCond %{HTTP_ACCEPT} image/webp
387
+ RewriteCond %{DOCUMENT_ROOT}/wp-content/uploads-webpc/$1.jpg.webp -f
388
+ RewriteRule (.+)\.jpg$ /wp-content/uploads-webpc/$1.jpg.webp [NC,T=image/webp,L]
389
+ RewriteCond %{HTTP_ACCEPT} image/webp
390
+ RewriteCond %{DOCUMENT_ROOT}/wp-content/uploads-webpc/$1.jpeg.webp -f
391
+ RewriteRule (.+)\.jpeg$ /wp-content/uploads-webpc/$1.jpeg.webp [NC,T=image/webp,L]
392
+ RewriteCond %{HTTP_ACCEPT} image/webp
393
+ RewriteCond %{DOCUMENT_ROOT}/wp-content/uploads-webpc/$1.png.webp -f
394
+ RewriteRule (.+)\.png$ /wp-content/uploads-webpc/$1.png.webp [NC,T=image/webp,L]
395
  </IfModule>
396
  <IfModule mod_headers.c>
397
  Header Set Cache-Control "private"
404
  `# BEGIN WebP Converter`
405
  `# ! --- DO NOT EDIT PREVIOUS LINE --- !`
406
  `<IfModule mod_mime.c>
407
+ AddType image/webp .webp
408
  </IfModule>
409
  <IfModule mod_expires.c>
410
+ ExpiresActive On
411
+ ExpiresByType image/webp "access plus 1 year"
412
  </IfModule>
413
  <IfModule mod_headers.c>
414
  Header Set Cache-Control "private"
436
 
437
  == Changelog ==
438
 
439
+ = 3.0.5 (2021-06-09) =
440
+ * `[Fixed]` Handling of filters for changing directory paths
441
+ * `[Fixed]` Converting using Imagick method for 100% image quality
442
+ * `[Changed]` Default conversion method from Gd to Imagick
443
+
444
  = 3.0.4 (2021-05-28) =
445
  * `[Fixed]` Caching rewrites on CDN and Proxy servers
446
 
src/Conversion/Cron/Event.php CHANGED
@@ -5,7 +5,6 @@ namespace WebpConverter\Conversion\Cron;
5
  use WebpConverter\PluginAccessAbstract;
6
  use WebpConverter\PluginAccessInterface;
7
  use WebpConverter\HookableInterface;
8
- use WebpConverter\Conversion\Cron\Schedules;
9
 
10
  /**
11
  * Adds cron event that converts images.
5
  use WebpConverter\PluginAccessAbstract;
6
  use WebpConverter\PluginAccessInterface;
7
  use WebpConverter\HookableInterface;
 
8
 
9
  /**
10
  * Adds cron event that converts images.
src/Conversion/Directory/DirectoryAbstract.php CHANGED
@@ -2,8 +2,6 @@
2
 
3
  namespace WebpConverter\Conversion\Directory;
4
 
5
- use WebpConverter\Conversion\Directory\DirectoryInterface;
6
-
7
  /**
8
  * Abstract class for class that supports data about directory.
9
  */
@@ -42,8 +40,9 @@ abstract class DirectoryAbstract implements DirectoryInterface {
42
  * @return string Server path of directory.
43
  */
44
  public function get_server_path(): string {
45
- $source_path = apply_filters( 'webpc_site_root', realpath( ABSPATH ) );
46
- return sprintf( '%1$s/%2$s', $source_path, $this->get_relative_path() );
 
47
  }
48
 
49
  /**
@@ -52,7 +51,8 @@ abstract class DirectoryAbstract implements DirectoryInterface {
52
  * @return string URL of directory.
53
  */
54
  public function get_path_url(): string {
55
- $source_url = apply_filters( 'webpc_site_url', get_site_url() );
56
- return sprintf( '%1$s/%2$s', $source_url, $this->get_relative_path() );
 
57
  }
58
  }
2
 
3
  namespace WebpConverter\Conversion\Directory;
4
 
 
 
5
  /**
6
  * Abstract class for class that supports data about directory.
7
  */
40
  * @return string Server path of directory.
41
  */
42
  public function get_server_path(): string {
43
+ $source_path = apply_filters( 'webpc_site_root', realpath( ABSPATH ) );
44
+ $directory_name = apply_filters( 'webpc_dir_name', $this->get_relative_path(), $this->get_type() );
45
+ return sprintf( '%1$s/%2$s', $source_path, $directory_name );
46
  }
47
 
48
  /**
51
  * @return string URL of directory.
52
  */
53
  public function get_path_url(): string {
54
+ $source_url = apply_filters( 'webpc_site_url', get_site_url() );
55
+ $directory_name = apply_filters( 'webpc_dir_name', $this->get_relative_path(), $this->get_type() );
56
+ return sprintf( '%1$s/%2$s', $source_url, $directory_name );
57
  }
58
  }
src/Conversion/{Directories.php → Directory/DirectoryFactory.php} RENAMED
@@ -1,25 +1,19 @@
1
  <?php
2
 
3
- namespace WebpConverter\Conversion;
4
 
5
  use WebpConverter\HookableInterface;
6
- use WebpConverter\Conversion\Directory\DirectoriesIntegration;
7
- use WebpConverter\Conversion\Directory\UploadsDirectory;
8
- use WebpConverter\Conversion\Directory\GalleryDirectory;
9
- use WebpConverter\Conversion\Directory\UploadsWebpcDirectory;
10
- use WebpConverter\Conversion\Directory\PluginsDirectory;
11
- use WebpConverter\Conversion\Directory\ThemesDirectory;
12
  use WebpConverter\Plugin\Uninstall\WebpFiles;
13
 
14
  /**
15
  * Initializes integration for all directories.
16
  */
17
- class Directories implements HookableInterface {
18
 
19
  /**
20
- * Objects of supported directories.
21
  *
22
- * @var DirectoriesIntegration
23
  */
24
  private $directories_integration;
25
 
@@ -27,12 +21,25 @@ class Directories implements HookableInterface {
27
  * Directories constructor.
28
  */
29
  public function __construct() {
30
- $this->directories_integration = ( new DirectoriesIntegration() )
31
- ->add_directory( new GalleryDirectory() )
32
- ->add_directory( new PluginsDirectory() )
33
- ->add_directory( new ThemesDirectory() )
34
- ->add_directory( new UploadsDirectory() )
35
- ->add_directory( new UploadsWebpcDirectory() );
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  }
37
 
38
  /**
1
  <?php
2
 
3
+ namespace WebpConverter\Conversion\Directory;
4
 
5
  use WebpConverter\HookableInterface;
 
 
 
 
 
 
6
  use WebpConverter\Plugin\Uninstall\WebpFiles;
7
 
8
  /**
9
  * Initializes integration for all directories.
10
  */
11
+ class DirectoryFactory implements HookableInterface {
12
 
13
  /**
14
+ * Object of directories integration.
15
  *
16
+ * @var DirectoryIntegration
17
  */
18
  private $directories_integration;
19
 
21
  * Directories constructor.
22
  */
23
  public function __construct() {
24
+ $this->set_integration( new GalleryDirectory() );
25
+ $this->set_integration( new PluginsDirectory() );
26
+ $this->set_integration( new ThemesDirectory() );
27
+ $this->set_integration( new UploadsDirectory() );
28
+ $this->set_integration( new UploadsWebpcDirectory() );
29
+ }
30
+
31
+ /**
32
+ * Sets integration for directory.
33
+ *
34
+ * @param DirectoryInterface $directory .
35
+ *
36
+ * @return void
37
+ */
38
+ private function set_integration( DirectoryInterface $directory ) {
39
+ if ( $this->directories_integration === null ) {
40
+ $this->directories_integration = new DirectoryIntegration();
41
+ }
42
+ $this->directories_integration->add_directory( $directory );
43
  }
44
 
45
  /**
src/Conversion/Directory/{DirectoriesIntegration.php → DirectoryIntegration.php} RENAMED
@@ -2,14 +2,13 @@
2
 
3
  namespace WebpConverter\Conversion\Directory;
4
 
5
- use WebpConverter\Conversion\Directory\DirectoryInterface;
6
  use WebpConverter\HookableInterface;
7
  use WebpConverter\Conversion\OutputPath;
8
 
9
  /**
10
  * Returns various types of paths for directories.
11
  */
12
- class DirectoriesIntegration implements HookableInterface {
13
 
14
  const DIRS_EXCLUDED = [ '.', '..', '.git', '.svn', 'node_modules' ];
15
 
@@ -41,10 +40,6 @@ class DirectoriesIntegration implements HookableInterface {
41
  * @return self
42
  */
43
  public function add_directory( DirectoryInterface $directory ): self {
44
- if ( ! $directory->is_available() ) {
45
- return $this;
46
- }
47
-
48
  $this->directories[ $directory->get_type() ] = $directory;
49
  return $this;
50
  }
@@ -57,7 +52,7 @@ class DirectoriesIntegration implements HookableInterface {
57
  public function get_input_directories(): array {
58
  $values = [];
59
  foreach ( $this->directories as $directory ) {
60
- if ( ! $directory->is_output_directory() ) {
61
  $values[ $directory->get_type() ] = $directory->get_label();
62
  }
63
  }
2
 
3
  namespace WebpConverter\Conversion\Directory;
4
 
 
5
  use WebpConverter\HookableInterface;
6
  use WebpConverter\Conversion\OutputPath;
7
 
8
  /**
9
  * Returns various types of paths for directories.
10
  */
11
+ class DirectoryIntegration implements HookableInterface {
12
 
13
  const DIRS_EXCLUDED = [ '.', '..', '.git', '.svn', 'node_modules' ];
14
 
40
  * @return self
41
  */
42
  public function add_directory( DirectoryInterface $directory ): self {
 
 
 
 
43
  $this->directories[ $directory->get_type() ] = $directory;
44
  return $this;
45
  }
52
  public function get_input_directories(): array {
53
  $values = [];
54
  foreach ( $this->directories as $directory ) {
55
+ if ( ! $directory->is_output_directory() && $directory->is_available() ) {
56
  $values[ $directory->get_type() ] = $directory->get_label();
57
  }
58
  }
src/Conversion/Directory/GalleryDirectory.php CHANGED
@@ -2,9 +2,6 @@
2
 
3
  namespace WebpConverter\Conversion\Directory;
4
 
5
- use WebpConverter\Conversion\Directory\DirectoryAbstract;
6
- use WebpConverter\Conversion\Directory\DirectoryInterface;
7
-
8
  /**
9
  * Supports data about /gallery directory.
10
  */
2
 
3
  namespace WebpConverter\Conversion\Directory;
4
 
 
 
 
5
  /**
6
  * Supports data about /gallery directory.
7
  */
src/Conversion/Directory/PluginsDirectory.php CHANGED
@@ -2,9 +2,6 @@
2
 
3
  namespace WebpConverter\Conversion\Directory;
4
 
5
- use WebpConverter\Conversion\Directory\DirectoryAbstract;
6
- use WebpConverter\Conversion\Directory\DirectoryInterface;
7
-
8
  /**
9
  * Supports data about /plugins directory.
10
  */
2
 
3
  namespace WebpConverter\Conversion\Directory;
4
 
 
 
 
5
  /**
6
  * Supports data about /plugins directory.
7
  */
src/Conversion/Directory/ThemesDirectory.php CHANGED
@@ -2,9 +2,6 @@
2
 
3
  namespace WebpConverter\Conversion\Directory;
4
 
5
- use WebpConverter\Conversion\Directory\DirectoryAbstract;
6
- use WebpConverter\Conversion\Directory\DirectoryInterface;
7
-
8
  /**
9
  * Supports data about /themes directory.
10
  */
2
 
3
  namespace WebpConverter\Conversion\Directory;
4
 
 
 
 
5
  /**
6
  * Supports data about /themes directory.
7
  */
src/Conversion/Directory/UploadsDirectory.php CHANGED
@@ -2,9 +2,6 @@
2
 
3
  namespace WebpConverter\Conversion\Directory;
4
 
5
- use WebpConverter\Conversion\Directory\DirectoryAbstract;
6
- use WebpConverter\Conversion\Directory\DirectoryInterface;
7
-
8
  /**
9
  * Supports data about /uploads directory.
10
  */
2
 
3
  namespace WebpConverter\Conversion\Directory;
4
 
 
 
 
5
  /**
6
  * Supports data about /uploads directory.
7
  */
src/Conversion/Directory/UploadsWebpcDirectory.php CHANGED
@@ -2,9 +2,6 @@
2
 
3
  namespace WebpConverter\Conversion\Directory;
4
 
5
- use WebpConverter\Conversion\Directory\DirectoryAbstract;
6
- use WebpConverter\Conversion\Directory\DirectoryInterface;
7
-
8
  /**
9
  * Supports data about /uploads-webpc directory.
10
  */
2
 
3
  namespace WebpConverter\Conversion\Directory;
4
 
 
 
 
5
  /**
6
  * Supports data about /uploads-webpc directory.
7
  */
src/Conversion/Endpoint/EndpointAbstract.php CHANGED
@@ -4,7 +4,6 @@ namespace WebpConverter\Conversion\Endpoint;
4
 
5
  use WebpConverter\PluginAccessAbstract;
6
  use WebpConverter\PluginAccessInterface;
7
- use WebpConverter\Conversion\Endpoint\EndpointInterface;
8
 
9
  /**
10
  * Abstract class for class that supports image conversion method.
4
 
5
  use WebpConverter\PluginAccessAbstract;
6
  use WebpConverter\PluginAccessInterface;
 
7
 
8
  /**
9
  * Abstract class for class that supports image conversion method.
src/Conversion/{Endpoints.php → Endpoint/EndpointFactory.php} RENAMED
@@ -1,19 +1,15 @@
1
  <?php
2
 
3
- namespace WebpConverter\Conversion;
4
 
5
  use WebpConverter\PluginAccessAbstract;
6
  use WebpConverter\PluginAccessInterface;
7
  use WebpConverter\HookableInterface;
8
- use WebpConverter\Conversion\Endpoint\EndpointInterface;
9
- use WebpConverter\Conversion\Endpoint\EndpointIntegration;
10
- use WebpConverter\Conversion\Endpoint\PathsEndpoint;
11
- use WebpConverter\Conversion\Endpoint\RegenerateEndpoint;
12
 
13
  /**
14
  * Initializes integration for all endpoints.
15
  */
16
- class Endpoints extends PluginAccessAbstract implements PluginAccessInterface, HookableInterface {
17
 
18
  /**
19
  * Integrates with WordPress hooks.
1
  <?php
2
 
3
+ namespace WebpConverter\Conversion\Endpoint;
4
 
5
  use WebpConverter\PluginAccessAbstract;
6
  use WebpConverter\PluginAccessInterface;
7
  use WebpConverter\HookableInterface;
 
 
 
 
8
 
9
  /**
10
  * Initializes integration for all endpoints.
11
  */
12
+ class EndpointFactory extends PluginAccessAbstract implements PluginAccessInterface, HookableInterface {
13
 
14
  /**
15
  * Integrates with WordPress hooks.
src/Conversion/Endpoint/EndpointIntegration.php CHANGED
@@ -2,7 +2,6 @@
2
 
3
  namespace WebpConverter\Conversion\Endpoint;
4
 
5
- use WebpConverter\Conversion\Endpoint\EndpointInterface;
6
  use WebpConverter\HookableInterface;
7
 
8
  /**
2
 
3
  namespace WebpConverter\Conversion\Endpoint;
4
 
 
5
  use WebpConverter\HookableInterface;
6
 
7
  /**
src/Conversion/Endpoint/PathsEndpoint.php CHANGED
@@ -2,10 +2,6 @@
2
 
3
  namespace WebpConverter\Conversion\Endpoint;
4
 
5
- use WebpConverter\Conversion\Endpoint\EndpointAbstract;
6
- use WebpConverter\Conversion\Endpoint\EndpointInterface;
7
- use WebpConverter\Conversion\Endpoint\EndpointIntegration;
8
-
9
  /**
10
  * Supports endpoint to get list of image paths to be converted.
11
  */
2
 
3
  namespace WebpConverter\Conversion\Endpoint;
4
 
 
 
 
 
5
  /**
6
  * Supports endpoint to get list of image paths to be converted.
7
  */
src/Conversion/Endpoint/RegenerateEndpoint.php CHANGED
@@ -2,8 +2,6 @@
2
 
3
  namespace WebpConverter\Conversion\Endpoint;
4
 
5
- use WebpConverter\Conversion\Endpoint\EndpointAbstract;
6
- use WebpConverter\Conversion\Endpoint\EndpointInterface;
7
  use WebpConverter\Conversion\Method\MethodIntegrator;
8
 
9
  /**
2
 
3
  namespace WebpConverter\Conversion\Endpoint;
4
 
 
 
5
  use WebpConverter\Conversion\Method\MethodIntegrator;
6
 
7
  /**
src/Conversion/Exception/ConversionErrorException.php CHANGED
@@ -2,9 +2,6 @@
2
 
3
  namespace WebpConverter\Conversion\Exception;
4
 
5
- use WebpConverter\Conversion\Exception\ExceptionAbstract;
6
- use WebpConverter\Conversion\Exception\ExceptionInterface;
7
-
8
  /**
9
  * Handles "convert_error" exception when converting images.
10
  */
2
 
3
  namespace WebpConverter\Conversion\Exception;
4
 
 
 
 
5
  /**
6
  * Handles "convert_error" exception when converting images.
7
  */
src/Conversion/Exception/ExceptionAbstract.php CHANGED
@@ -2,8 +2,6 @@
2
 
3
  namespace WebpConverter\Conversion\Exception;
4
 
5
- use WebpConverter\Conversion\Exception\ExceptionInterface;
6
-
7
  /**
8
  * Abstract class for class that supports exception when converting images.
9
  */
2
 
3
  namespace WebpConverter\Conversion\Exception;
4
 
 
 
5
  /**
6
  * Abstract class for class that supports exception when converting images.
7
  */
src/Conversion/Exception/ExtensionUnsupportedException.php CHANGED
@@ -2,9 +2,6 @@
2
 
3
  namespace WebpConverter\Conversion\Exception;
4
 
5
- use WebpConverter\Conversion\Exception\ExceptionAbstract;
6
- use WebpConverter\Conversion\Exception\ExceptionInterface;
7
-
8
  /**
9
  * Handles "unsupported_extension" exception when converting images.
10
  */
2
 
3
  namespace WebpConverter\Conversion\Exception;
4
 
 
 
 
5
  /**
6
  * Handles "unsupported_extension" exception when converting images.
7
  */
src/Conversion/Exception/FunctionUnavailableException.php CHANGED
@@ -2,9 +2,6 @@
2
 
3
  namespace WebpConverter\Conversion\Exception;
4
 
5
- use WebpConverter\Conversion\Exception\ExceptionAbstract;
6
- use WebpConverter\Conversion\Exception\ExceptionInterface;
7
-
8
  /**
9
  * Handles "server_configuration" exception when converting images.
10
  */
2
 
3
  namespace WebpConverter\Conversion\Exception;
4
 
 
 
 
5
  /**
6
  * Handles "server_configuration" exception when converting images.
7
  */
src/Conversion/Exception/ImageInvalidException.php CHANGED
@@ -2,9 +2,6 @@
2
 
3
  namespace WebpConverter\Conversion\Exception;
4
 
5
- use WebpConverter\Conversion\Exception\ExceptionAbstract;
6
- use WebpConverter\Conversion\Exception\ExceptionInterface;
7
-
8
  /**
9
  * Handles "invalid_image" exception when converting images.
10
  */
2
 
3
  namespace WebpConverter\Conversion\Exception;
4
 
 
 
 
5
  /**
6
  * Handles "invalid_image" exception when converting images.
7
  */
src/Conversion/Exception/ImagickNotSupportWebpException.php CHANGED
@@ -2,9 +2,6 @@
2
 
3
  namespace WebpConverter\Conversion\Exception;
4
 
5
- use WebpConverter\Conversion\Exception\ExceptionAbstract;
6
- use WebpConverter\Conversion\Exception\ExceptionInterface;
7
-
8
  /**
9
  * Handles "server_configuration" exception when converting images.
10
  */
2
 
3
  namespace WebpConverter\Conversion\Exception;
4
 
 
 
 
5
  /**
6
  * Handles "server_configuration" exception when converting images.
7
  */
src/Conversion/Exception/ImagickUnavailableException.php CHANGED
@@ -2,9 +2,6 @@
2
 
3
  namespace WebpConverter\Conversion\Exception;
4
 
5
- use WebpConverter\Conversion\Exception\ExceptionAbstract;
6
- use WebpConverter\Conversion\Exception\ExceptionInterface;
7
-
8
  /**
9
  * Handles "server_configuration" exception when converting images.
10
  */
2
 
3
  namespace WebpConverter\Conversion\Exception;
4
 
 
 
 
5
  /**
6
  * Handles "server_configuration" exception when converting images.
7
  */
src/Conversion/Exception/LargerThanOriginalException.php CHANGED
@@ -2,9 +2,6 @@
2
 
3
  namespace WebpConverter\Conversion\Exception;
4
 
5
- use WebpConverter\Conversion\Exception\ExceptionAbstract;
6
- use WebpConverter\Conversion\Exception\ExceptionInterface;
7
-
8
  /**
9
  * Handles "larger_than_original" exception when converting images.
10
  */
2
 
3
  namespace WebpConverter\Conversion\Exception;
4
 
 
 
 
5
  /**
6
  * Handles "larger_than_original" exception when converting images.
7
  */
src/Conversion/Exception/OutputPathException.php CHANGED
@@ -2,9 +2,6 @@
2
 
3
  namespace WebpConverter\Conversion\Exception;
4
 
5
- use WebpConverter\Conversion\Exception\ExceptionAbstract;
6
- use WebpConverter\Conversion\Exception\ExceptionInterface;
7
-
8
  /**
9
  * Handles "output_path" exception when converting images.
10
  */
2
 
3
  namespace WebpConverter\Conversion\Exception;
4
 
 
 
 
5
  /**
6
  * Handles "output_path" exception when converting images.
7
  */
src/Conversion/Exception/ResolutionOversizeException.php CHANGED
@@ -2,9 +2,6 @@
2
 
3
  namespace WebpConverter\Conversion\Exception;
4
 
5
- use WebpConverter\Conversion\Exception\ExceptionAbstract;
6
- use WebpConverter\Conversion\Exception\ExceptionInterface;
7
-
8
  /**
9
  * Handles "max_resolution" exception when converting images.
10
  */
2
 
3
  namespace WebpConverter\Conversion\Exception;
4
 
 
 
 
5
  /**
6
  * Handles "max_resolution" exception when converting images.
7
  */
src/Conversion/Exception/ServerConfigurationException.php CHANGED
@@ -2,9 +2,6 @@
2
 
3
  namespace WebpConverter\Conversion\Exception;
4
 
5
- use WebpConverter\Conversion\Exception\ExceptionAbstract;
6
- use WebpConverter\Conversion\Exception\ExceptionInterface;
7
-
8
  /**
9
  * Handles "server_configuration" exception when converting images.
10
  */
2
 
3
  namespace WebpConverter\Conversion\Exception;
4
 
 
 
 
5
  /**
6
  * Handles "server_configuration" exception when converting images.
7
  */
src/Conversion/Exception/SourcePathException.php CHANGED
@@ -2,9 +2,6 @@
2
 
3
  namespace WebpConverter\Conversion\Exception;
4
 
5
- use WebpConverter\Conversion\Exception\ExceptionAbstract;
6
- use WebpConverter\Conversion\Exception\ExceptionInterface;
7
-
8
  /**
9
  * Handles "file_unreadable" exception when converting images.
10
  */
2
 
3
  namespace WebpConverter\Conversion\Exception;
4
 
 
 
 
5
  /**
6
  * Handles "file_unreadable" exception when converting images.
7
  */
src/Conversion/Format/AvifFormat.php CHANGED
@@ -2,9 +2,6 @@
2
 
3
  namespace WebpConverter\Conversion\Format;
4
 
5
- use WebpConverter\Conversion\Format\FormatAbstract;
6
- use WebpConverter\Conversion\Format\FormatInterface;
7
-
8
  /**
9
  * Supports AVIF as output format for images.
10
  */
2
 
3
  namespace WebpConverter\Conversion\Format;
4
 
 
 
 
5
  /**
6
  * Supports AVIF as output format for images.
7
  */
src/Conversion/Format/FormatAbstract.php CHANGED
@@ -2,8 +2,7 @@
2
 
3
  namespace WebpConverter\Conversion\Format;
4
 
5
- use WebpConverter\Conversion\Format\FormatInterface;
6
- use WebpConverter\Conversion\Methods;
7
 
8
  /**
9
  * Abstract class for class that supports output format for images.
@@ -27,6 +26,6 @@ abstract class FormatAbstract implements FormatInterface {
27
  * @return bool Is format available?
28
  */
29
  public function is_available( string $conversion_method ): bool {
30
- return ( new Methods() )->is_method_available( $conversion_method, $this->get_extension() );
31
  }
32
  }
2
 
3
  namespace WebpConverter\Conversion\Format;
4
 
5
+ use WebpConverter\Conversion\Method\MethodFactory;
 
6
 
7
  /**
8
  * Abstract class for class that supports output format for images.
26
  * @return bool Is format available?
27
  */
28
  public function is_available( string $conversion_method ): bool {
29
+ return ( new MethodFactory() )->is_method_available( $conversion_method, $this->get_extension() );
30
  }
31
  }
src/Conversion/{Formats.php → Format/FormatFactory.php} RENAMED
@@ -1,15 +1,11 @@
1
  <?php
2
 
3
- namespace WebpConverter\Conversion;
4
-
5
- use WebpConverter\Conversion\Format\FormatInterface;
6
- use WebpConverter\Conversion\Format\AvifFormat;
7
- use WebpConverter\Conversion\Format\WebpFormat;
8
 
9
  /**
10
  * Adds support for all output formats and returns information about them.
11
  */
12
- class Formats {
13
 
14
  /**
15
  * Objects of supported output formats.
@@ -22,8 +18,19 @@ class Formats {
22
  * Formats constructor.
23
  */
24
  public function __construct() {
25
- $this->formats[] = new AvifFormat();
26
- $this->formats[] = new WebpFormat();
 
 
 
 
 
 
 
 
 
 
 
27
  }
28
 
29
  /**
1
  <?php
2
 
3
+ namespace WebpConverter\Conversion\Format;
 
 
 
 
4
 
5
  /**
6
  * Adds support for all output formats and returns information about them.
7
  */
8
+ class FormatFactory {
9
 
10
  /**
11
  * Objects of supported output formats.
18
  * Formats constructor.
19
  */
20
  public function __construct() {
21
+ $this->set_integration( new AvifFormat() );
22
+ $this->set_integration( new WebpFormat() );
23
+ }
24
+
25
+ /**
26
+ * Sets integration for format.
27
+ *
28
+ * @param FormatInterface $format .
29
+ *
30
+ * @return void
31
+ */
32
+ private function set_integration( FormatInterface $format ) {
33
+ $this->formats[] = $format;
34
  }
35
 
36
  /**
src/Conversion/Format/WebpFormat.php CHANGED
@@ -2,9 +2,6 @@
2
 
3
  namespace WebpConverter\Conversion\Format;
4
 
5
- use WebpConverter\Conversion\Format\FormatAbstract;
6
- use WebpConverter\Conversion\Format\FormatInterface;
7
-
8
  /**
9
  * Supports WebP as output format for images.
10
  */
2
 
3
  namespace WebpConverter\Conversion\Format;
4
 
 
 
 
5
  /**
6
  * Supports WebP as output format for images.
7
  */
src/Conversion/Method/GdMethod.php CHANGED
@@ -2,8 +2,6 @@
2
 
3
  namespace WebpConverter\Conversion\Method;
4
 
5
- use WebpConverter\Conversion\Method\MethodAbstract;
6
- use WebpConverter\Conversion\Method\MethodInterface;
7
  use WebpConverter\Conversion\Format\WebpFormat;
8
  use WebpConverter\Conversion\Format\AvifFormat;
9
  use WebpConverter\Conversion\Exception;
@@ -13,7 +11,8 @@ use WebpConverter\Conversion\Exception;
13
  */
14
  class GdMethod extends MethodAbstract implements MethodInterface {
15
 
16
- const METHOD_NAME = 'gd';
 
17
 
18
  /**
19
  * Returns name of conversion method.
@@ -30,8 +29,7 @@ class GdMethod extends MethodAbstract implements MethodInterface {
30
  * @return string Method label.
31
  */
32
  public function get_label(): string {
33
- /* translators: %s method name */
34
- return sprintf( __( '%s (recommended)', 'webp-converter-for-media' ), 'GD' );
35
  }
36
 
37
  /**
@@ -171,14 +169,15 @@ class GdMethod extends MethodAbstract implements MethodInterface {
171
  return;
172
  }
173
 
174
- $image = apply_filters( 'webpc_gd_before_saving', $image, $source_path );
175
- $settings = $this->get_plugin()->get_settings();
 
176
 
177
  if ( ! function_exists( $function ) ) {
178
  throw new Exception\FunctionUnavailableException( $function );
179
  } elseif ( ( imagesx( $image ) > 8192 ) || ( imagesy( $image ) > 8192 ) ) {
180
  throw new Exception\ResolutionOversizeException( $source_path );
181
- } elseif ( is_callable( $function ) && ! $function( $image, $output_path, $settings['quality'] ) ) {
182
  throw new Exception\ConversionErrorException( $source_path );
183
  }
184
 
2
 
3
  namespace WebpConverter\Conversion\Method;
4
 
 
 
5
  use WebpConverter\Conversion\Format\WebpFormat;
6
  use WebpConverter\Conversion\Format\AvifFormat;
7
  use WebpConverter\Conversion\Exception;
11
  */
12
  class GdMethod extends MethodAbstract implements MethodInterface {
13
 
14
+ const METHOD_NAME = 'gd';
15
+ const MAX_METHOD_QUALITY = 99.9;
16
 
17
  /**
18
  * Returns name of conversion method.
29
  * @return string Method label.
30
  */
31
  public function get_label(): string {
32
+ return 'GD';
 
33
  }
34
 
35
  /**
169
  return;
170
  }
171
 
172
+ $image = apply_filters( 'webpc_gd_before_saving', $image, $source_path );
173
+ $settings = $this->get_plugin()->get_settings();
174
+ $output_quality = min( $settings['quality'], self::MAX_METHOD_QUALITY );
175
 
176
  if ( ! function_exists( $function ) ) {
177
  throw new Exception\FunctionUnavailableException( $function );
178
  } elseif ( ( imagesx( $image ) > 8192 ) || ( imagesy( $image ) > 8192 ) ) {
179
  throw new Exception\ResolutionOversizeException( $source_path );
180
+ } elseif ( is_callable( $function ) && ! $function( $image, $output_path, $output_quality ) ) {
181
  throw new Exception\ConversionErrorException( $source_path );
182
  }
183
 
src/Conversion/Method/ImagickMethod.php CHANGED
@@ -2,8 +2,6 @@
2
 
3
  namespace WebpConverter\Conversion\Method;
4
 
5
- use WebpConverter\Conversion\Method\MethodAbstract;
6
- use WebpConverter\Conversion\Method\MethodInterface;
7
  use WebpConverter\Conversion\Format\WebpFormat;
8
  use WebpConverter\Conversion\Format\AvifFormat;
9
  use WebpConverter\Conversion\Exception;
@@ -13,7 +11,8 @@ use WebpConverter\Conversion\Exception;
13
  */
14
  class ImagickMethod extends MethodAbstract implements MethodInterface {
15
 
16
- const METHOD_NAME = 'imagick';
 
17
 
18
  /**
19
  * Returns name of conversion method.
@@ -30,7 +29,8 @@ class ImagickMethod extends MethodAbstract implements MethodInterface {
30
  * @return string Method label.
31
  */
32
  public function get_label(): string {
33
- return 'Imagick';
 
34
  }
35
 
36
  /**
@@ -116,9 +116,10 @@ class ImagickMethod extends MethodAbstract implements MethodInterface {
116
  * @throws Exception\ImagickNotSupportWebpException
117
  */
118
  public function convert_image_to_output( $image, string $source_path, string $output_path, string $format ) {
119
- $extension = self::get_format_extension( $format );
120
- $image = apply_filters( 'webpc_imagick_before_saving', $image, $source_path );
121
- $settings = $this->get_plugin()->get_settings();
 
122
 
123
  if ( ! in_array( $extension, $image->queryFormats() ) ) {
124
  throw new Exception\ImagickNotSupportWebpException();
@@ -128,7 +129,7 @@ class ImagickMethod extends MethodAbstract implements MethodInterface {
128
  if ( ! in_array( 'keep_metadata', $settings['features'] ) ) {
129
  $image->stripImage();
130
  }
131
- $image->setImageCompressionQuality( $settings['quality'] );
132
  $blob = $image->getImageBlob();
133
 
134
  if ( ! file_put_contents( $output_path, $blob ) ) {
2
 
3
  namespace WebpConverter\Conversion\Method;
4
 
 
 
5
  use WebpConverter\Conversion\Format\WebpFormat;
6
  use WebpConverter\Conversion\Format\AvifFormat;
7
  use WebpConverter\Conversion\Exception;
11
  */
12
  class ImagickMethod extends MethodAbstract implements MethodInterface {
13
 
14
+ const METHOD_NAME = 'imagick';
15
+ const MAX_METHOD_QUALITY = 99.9;
16
 
17
  /**
18
  * Returns name of conversion method.
29
  * @return string Method label.
30
  */
31
  public function get_label(): string {
32
+ /* translators: %s method name */
33
+ return sprintf( __( '%s (recommended)', 'webp-converter-for-media' ), 'Imagick' );
34
  }
35
 
36
  /**
116
  * @throws Exception\ImagickNotSupportWebpException
117
  */
118
  public function convert_image_to_output( $image, string $source_path, string $output_path, string $format ) {
119
+ $extension = self::get_format_extension( $format );
120
+ $image = apply_filters( 'webpc_imagick_before_saving', $image, $source_path );
121
+ $settings = $this->get_plugin()->get_settings();
122
+ $output_quality = min( $settings['quality'], self::MAX_METHOD_QUALITY );
123
 
124
  if ( ! in_array( $extension, $image->queryFormats() ) ) {
125
  throw new Exception\ImagickNotSupportWebpException();
129
  if ( ! in_array( 'keep_metadata', $settings['features'] ) ) {
130
  $image->stripImage();
131
  }
132
+ $image->setImageCompressionQuality( $output_quality );
133
  $blob = $image->getImageBlob();
134
 
135
  if ( ! file_put_contents( $output_path, $blob ) ) {
src/Conversion/{Methods.php → Method/MethodFactory.php} RENAMED
@@ -1,15 +1,13 @@
1
  <?php
2
 
3
- namespace WebpConverter\Conversion;
4
 
5
- use WebpConverter\Conversion\Method\MethodInterface;
6
- use WebpConverter\Conversion\Method\GdMethod;
7
- use WebpConverter\Conversion\Method\ImagickMethod;
8
 
9
  /**
10
  * Adds support for all conversion methods and returns information about them.
11
  */
12
- class Methods {
13
 
14
  /**
15
  * Objects of supported conversion methods.
@@ -22,8 +20,19 @@ class Methods {
22
  * Methods constructor.
23
  */
24
  public function __construct() {
25
- $this->methods[ GdMethod::METHOD_NAME ] = new GdMethod();
26
- $this->methods[ ImagickMethod::METHOD_NAME ] = new ImagickMethod();
 
 
 
 
 
 
 
 
 
 
 
27
  }
28
 
29
  /**
@@ -60,7 +69,8 @@ class Methods {
60
  public function get_available_methods(): array {
61
  $values = [];
62
  foreach ( $this->get_methods_objects() as $method_name => $method ) {
63
- if ( ! $method::is_method_installed() ) {
 
64
  continue;
65
  }
66
  $values[ $method_name ] = $method->get_label();
1
  <?php
2
 
3
+ namespace WebpConverter\Conversion\Method;
4
 
5
+ use WebpConverter\Conversion\Format\FormatFactory;
 
 
6
 
7
  /**
8
  * Adds support for all conversion methods and returns information about them.
9
  */
10
+ class MethodFactory {
11
 
12
  /**
13
  * Objects of supported conversion methods.
20
  * Methods constructor.
21
  */
22
  public function __construct() {
23
+ $this->set_integration( new ImagickMethod() );
24
+ $this->set_integration( new GdMethod() );
25
+ }
26
+
27
+ /**
28
+ * Sets integration for method.
29
+ *
30
+ * @param MethodInterface $method .
31
+ *
32
+ * @return void
33
+ */
34
+ private function set_integration( MethodInterface $method ) {
35
+ $this->methods[ $method->get_name() ] = $method;
36
  }
37
 
38
  /**
69
  public function get_available_methods(): array {
70
  $values = [];
71
  foreach ( $this->get_methods_objects() as $method_name => $method ) {
72
+ if ( ! $method::is_method_installed()
73
+ || ( ! ( new FormatFactory() )->get_available_formats( $method_name ) ) ) {
74
  continue;
75
  }
76
  $values[ $method_name ] = $method->get_label();
src/Conversion/Method/MethodIntegrator.php CHANGED
@@ -4,10 +4,6 @@ namespace WebpConverter\Conversion\Method;
4
 
5
  use WebpConverter\PluginAccessAbstract;
6
  use WebpConverter\PluginAccessInterface;
7
- use WebpConverter\Conversion\Methods;
8
- use WebpConverter\Conversion\Method\GdMethod;
9
- use WebpConverter\Conversion\Method\ImagickMethod;
10
- use WebpConverter\Conversion\Method\RemoteMethod;
11
 
12
  /**
13
  * Initializes image conversion using active image conversion method.
@@ -47,7 +43,7 @@ class MethodIntegrator extends PluginAccessAbstract implements PluginAccessInter
47
  }
48
 
49
  $method_key = $this->get_plugin()->get_settings()['method'] ?? '';
50
- $methods = ( new Methods() )->get_methods_objects();
51
  foreach ( $methods as $method_name => $method ) {
52
  if ( $method_key === $method_name ) {
53
  $method->set_plugin( $this->get_plugin() );
4
 
5
  use WebpConverter\PluginAccessAbstract;
6
  use WebpConverter\PluginAccessInterface;
 
 
 
 
7
 
8
  /**
9
  * Initializes image conversion using active image conversion method.
43
  }
44
 
45
  $method_key = $this->get_plugin()->get_settings()['method'] ?? '';
46
+ $methods = ( new MethodFactory() )->get_methods_objects();
47
  foreach ( $methods as $method_name => $method ) {
48
  if ( $method_key === $method_name ) {
49
  $method->set_plugin( $this->get_plugin() );
src/Conversion/OutputPath.php CHANGED
@@ -2,8 +2,7 @@
2
 
3
  namespace WebpConverter\Conversion;
4
 
5
- use WebpConverter\Conversion\Formats;
6
- use WebpConverter\Conversion\Format\WebpFormat;
7
 
8
  /**
9
  * Generates output paths from source paths.
@@ -40,7 +39,7 @@ class OutputPath {
40
  return [];
41
  }
42
 
43
- $extensions = ( new Formats() )->get_format_extensions();
44
  $paths = [];
45
  foreach ( $extensions as $extension ) {
46
  $output_path = sprintf( '%1$s.%2$s', $new_path, $extension );
2
 
3
  namespace WebpConverter\Conversion;
4
 
5
+ use WebpConverter\Conversion\Format\FormatFactory;
 
6
 
7
  /**
8
  * Generates output paths from source paths.
39
  return [];
40
  }
41
 
42
+ $extensions = ( new FormatFactory() )->get_format_extensions();
43
  $paths = [];
44
  foreach ( $extensions as $extension ) {
45
  $output_path = sprintf( '%1$s.%2$s', $new_path, $extension );
src/Conversion/SkipExists.php CHANGED
@@ -5,9 +5,7 @@ namespace WebpConverter\Conversion;
5
  use WebpConverter\PluginAccessAbstract;
6
  use WebpConverter\PluginAccessInterface;
7
  use WebpConverter\HookableInterface;
8
- use WebpConverter\Conversion\OutputPath;
9
- use WebpConverter\Conversion\SkipLarger;
10
- use WebpConverter\Conversion\Formats;
11
 
12
  /**
13
  * Removes from list of source file paths those that have already been converted.
@@ -63,7 +61,7 @@ class SkipExists extends PluginAccessAbstract implements PluginAccessInterface,
63
  */
64
  private function get_output_extensions(): array {
65
  $settings = $this->get_plugin()->get_settings();
66
- $extensions = ( new Formats() )->get_available_formats( $settings['method'] );
67
 
68
  $values = [];
69
  foreach ( $extensions as $extension => $format_label ) {
5
  use WebpConverter\PluginAccessAbstract;
6
  use WebpConverter\PluginAccessInterface;
7
  use WebpConverter\HookableInterface;
8
+ use WebpConverter\Conversion\Format\FormatFactory;
 
 
9
 
10
  /**
11
  * Removes from list of source file paths those that have already been converted.
61
  */
62
  private function get_output_extensions(): array {
63
  $settings = $this->get_plugin()->get_settings();
64
+ $extensions = ( new FormatFactory() )->get_available_formats( $settings['method'] );
65
 
66
  $values = [];
67
  foreach ( $extensions as $extension => $format_label ) {
src/Error/ErrorAbstract.php CHANGED
@@ -4,7 +4,6 @@ namespace WebpConverter\Error;
4
 
5
  use WebpConverter\PluginAccessAbstract;
6
  use WebpConverter\PluginAccessInterface;
7
- use WebpConverter\Error\ErrorInterface;
8
 
9
  /**
10
  * Abstract class for class that checks for configuration errors.
4
 
5
  use WebpConverter\PluginAccessAbstract;
6
  use WebpConverter\PluginAccessInterface;
 
7
 
8
  /**
9
  * Abstract class for class that checks for configuration errors.
src/Error/{Errors.php → ErrorFactory.php} RENAMED
@@ -6,20 +6,12 @@ use WebpConverter\Loader\PassthruLoader;
6
  use WebpConverter\PluginAccessAbstract;
7
  use WebpConverter\PluginAccessInterface;
8
  use WebpConverter\HookableInterface;
9
- use WebpConverter\Error\LibsInstalledError;
10
- use WebpConverter\Error\LibsSupportWebpError;
11
- use WebpConverter\Error\LibsSupportAvifError;
12
- use WebpConverter\Error\PassthruError;
13
- use WebpConverter\Error\PathsError;
14
- use WebpConverter\Error\RestapiError;
15
- use WebpConverter\Error\RewritesError;
16
- use WebpConverter\Error\SettingsError;
17
  use WebpConverter\Helper\ViewLoader;
18
 
19
  /**
20
  * Supports generating list of server configuration errors.
21
  */
22
- class Errors extends PluginAccessAbstract implements PluginAccessInterface, HookableInterface {
23
 
24
  const ERRORS_CACHE_OPTION = 'webpc_errors_cache';
25
  const ALLOWED_ERROR_KEYS = [ 'rewrites_cached' ];
6
  use WebpConverter\PluginAccessAbstract;
7
  use WebpConverter\PluginAccessInterface;
8
  use WebpConverter\HookableInterface;
 
 
 
 
 
 
 
 
9
  use WebpConverter\Helper\ViewLoader;
10
 
11
  /**
12
  * Supports generating list of server configuration errors.
13
  */
14
+ class ErrorFactory extends PluginAccessAbstract implements PluginAccessInterface, HookableInterface {
15
 
16
  const ERRORS_CACHE_OPTION = 'webpc_errors_cache';
17
  const ALLOWED_ERROR_KEYS = [ 'rewrites_cached' ];
src/Error/LibsInstalledError.php CHANGED
@@ -2,8 +2,6 @@
2
 
3
  namespace WebpConverter\Error;
4
 
5
- use WebpConverter\Error\ErrorAbstract;
6
- use WebpConverter\Error\ErrorInterface;
7
  use WebpConverter\Conversion\Method\GdMethod;
8
  use WebpConverter\Conversion\Method\ImagickMethod;
9
 
2
 
3
  namespace WebpConverter\Error;
4
 
 
 
5
  use WebpConverter\Conversion\Method\GdMethod;
6
  use WebpConverter\Conversion\Method\ImagickMethod;
7
 
src/Error/LibsSupportAvifError.php CHANGED
@@ -2,8 +2,6 @@
2
 
3
  namespace WebpConverter\Error;
4
 
5
- use WebpConverter\Error\ErrorAbstract;
6
- use WebpConverter\Error\ErrorInterface;
7
  use WebpConverter\Conversion\Method\GdMethod;
8
  use WebpConverter\Conversion\Method\ImagickMethod;
9
  use WebpConverter\Conversion\Format\AvifFormat;
2
 
3
  namespace WebpConverter\Error;
4
 
 
 
5
  use WebpConverter\Conversion\Method\GdMethod;
6
  use WebpConverter\Conversion\Method\ImagickMethod;
7
  use WebpConverter\Conversion\Format\AvifFormat;
src/Error/LibsSupportWebpError.php CHANGED
@@ -2,12 +2,10 @@
2
 
3
  namespace WebpConverter\Error;
4
 
5
- use WebpConverter\Error\ErrorAbstract;
6
- use WebpConverter\Error\ErrorInterface;
7
  use WebpConverter\Conversion\Method\GdMethod;
8
  use WebpConverter\Conversion\Method\ImagickMethod;
9
  use WebpConverter\Conversion\Format\WebpFormat;
10
- use WebpConverter\Conversion\Formats;
11
 
12
  /**
13
  * Checks for configuration errors about image conversion methods that do not support WebP output format.
2
 
3
  namespace WebpConverter\Error;
4
 
 
 
5
  use WebpConverter\Conversion\Method\GdMethod;
6
  use WebpConverter\Conversion\Method\ImagickMethod;
7
  use WebpConverter\Conversion\Format\WebpFormat;
8
+ use WebpConverter\Conversion\Format\FormatFactory;
9
 
10
  /**
11
  * Checks for configuration errors about image conversion methods that do not support WebP output format.
src/Error/PassthruError.php CHANGED
@@ -2,8 +2,6 @@
2
 
3
  namespace WebpConverter\Error;
4
 
5
- use WebpConverter\Error\ErrorAbstract;
6
- use WebpConverter\Error\ErrorInterface;
7
  use WebpConverter\Loader\LoaderAbstract;
8
  use WebpConverter\Loader\PassthruLoader;
9
 
2
 
3
  namespace WebpConverter\Error;
4
 
 
 
5
  use WebpConverter\Loader\LoaderAbstract;
6
  use WebpConverter\Loader\PassthruLoader;
7
 
src/Error/PathsError.php CHANGED
@@ -2,9 +2,6 @@
2
 
3
  namespace WebpConverter\Error;
4
 
5
- use WebpConverter\Error\ErrorAbstract;
6
- use WebpConverter\Error\ErrorInterface;
7
-
8
  /**
9
  * Checks for configuration errors about incorrect paths of directories.
10
  */
2
 
3
  namespace WebpConverter\Error;
4
 
 
 
 
5
  /**
6
  * Checks for configuration errors about incorrect paths of directories.
7
  */
src/Error/RestapiError.php CHANGED
@@ -2,9 +2,6 @@
2
 
3
  namespace WebpConverter\Error;
4
 
5
- use WebpConverter\Error\ErrorAbstract;
6
- use WebpConverter\Error\ErrorInterface;
7
-
8
  /**
9
  * Checks for configuration errors about disabled REST API.
10
  */
2
 
3
  namespace WebpConverter\Error;
4
 
 
 
 
5
  /**
6
  * Checks for configuration errors about disabled REST API.
7
  */
src/Error/RewritesError.php CHANGED
@@ -2,8 +2,6 @@
2
 
3
  namespace WebpConverter\Error;
4
 
5
- use WebpConverter\Error\ErrorAbstract;
6
- use WebpConverter\Error\ErrorInterface;
7
  use WebpConverter\Conversion\OutputPath;
8
  use WebpConverter\Conversion\Format\WebpFormat;
9
  use WebpConverter\Loader\LoaderAbstract;
2
 
3
  namespace WebpConverter\Error;
4
 
 
 
5
  use WebpConverter\Conversion\OutputPath;
6
  use WebpConverter\Conversion\Format\WebpFormat;
7
  use WebpConverter\Loader\LoaderAbstract;
src/Error/SettingsError.php CHANGED
@@ -3,8 +3,6 @@
3
  namespace WebpConverter\Error;
4
 
5
  use WebpConverter\PluginAccessInterface;
6
- use WebpConverter\Error\ErrorAbstract;
7
- use WebpConverter\Error\ErrorInterface;
8
 
9
  /**
10
  * Checks for configuration errors about incorrectly saved plugin settings.
3
  namespace WebpConverter\Error;
4
 
5
  use WebpConverter\PluginAccessInterface;
 
 
6
 
7
  /**
8
  * Checks for configuration errors about incorrectly saved plugin settings.
src/Loader/HtaccessLoader.php CHANGED
@@ -2,9 +2,6 @@
2
 
3
  namespace WebpConverter\Loader;
4
 
5
- use WebpConverter\Loader\LoaderAbstract;
6
- use WebpConverter\Loader\LoaderInterface;
7
-
8
  /**
9
  * Supports method of loading images using rewrites from .htaccess file.
10
  */
@@ -176,7 +173,7 @@ class HtaccessLoader extends LoaderAbstract implements LoaderInterface {
176
  */
177
  private function get_mod_headers_rules( array $settings ): string {
178
  $content = '<IfModule mod_headers.c>' . PHP_EOL;
179
- $content .= ' Header Set Cache-Control "private"' . PHP_EOL;
180
  $content .= '</IfModule>';
181
 
182
  return apply_filters( 'webpc_htaccess_mod_headers', $content );
2
 
3
  namespace WebpConverter\Loader;
4
 
 
 
 
5
  /**
6
  * Supports method of loading images using rewrites from .htaccess file.
7
  */
173
  */
174
  private function get_mod_headers_rules( array $settings ): string {
175
  $content = '<IfModule mod_headers.c>' . PHP_EOL;
176
+ $content .= ' Header always set Cache-Control "private"' . PHP_EOL;
177
  $content .= '</IfModule>';
178
 
179
  return apply_filters( 'webpc_htaccess_mod_headers', $content );
src/Loader/LoaderAbstract.php CHANGED
@@ -4,8 +4,7 @@ namespace WebpConverter\Loader;
4
 
5
  use WebpConverter\PluginAccessAbstract;
6
  use WebpConverter\PluginAccessInterface;
7
- use WebpConverter\Loader\LoaderInterface;
8
- use WebpConverter\Conversion\Formats;
9
 
10
  /**
11
  * Abstract class for class that supports method of loading images.
@@ -29,6 +28,6 @@ abstract class LoaderAbstract extends PluginAccessAbstract implements PluginAcce
29
  */
30
  public function get_mime_types(): array {
31
  $settings = $this->get_plugin()->get_settings();
32
- return ( new Formats() )->get_mime_types( $settings['output_formats'] );
33
  }
34
  }
4
 
5
  use WebpConverter\PluginAccessAbstract;
6
  use WebpConverter\PluginAccessInterface;
7
+ use WebpConverter\Conversion\Format\FormatFactory;
 
8
 
9
  /**
10
  * Abstract class for class that supports method of loading images.
28
  */
29
  public function get_mime_types(): array {
30
  $settings = $this->get_plugin()->get_settings();
31
+ return ( new FormatFactory() )->get_mime_types( $settings['output_formats'] );
32
  }
33
  }
src/Loader/{Loaders.php → LoaderFactory.php} RENAMED
@@ -5,15 +5,11 @@ namespace WebpConverter\Loader;
5
  use WebpConverter\PluginAccessAbstract;
6
  use WebpConverter\PluginAccessInterface;
7
  use WebpConverter\HookableInterface;
8
- use WebpConverter\Loader\LoaderInterface;
9
- use WebpConverter\Loader\LoaderIntegration;
10
- use WebpConverter\Loader\HtaccessLoader;
11
- use WebpConverter\Loader\PassthruLoader;
12
 
13
  /**
14
  * Adds integration with methods of loading images.
15
  */
16
- class Loaders extends PluginAccessAbstract implements PluginAccessInterface, HookableInterface {
17
 
18
  /**
19
  * Integrates with WordPress hooks.
5
  use WebpConverter\PluginAccessAbstract;
6
  use WebpConverter\PluginAccessInterface;
7
  use WebpConverter\HookableInterface;
 
 
 
 
8
 
9
  /**
10
  * Adds integration with methods of loading images.
11
  */
12
+ class LoaderFactory extends PluginAccessAbstract implements PluginAccessInterface, HookableInterface {
13
 
14
  /**
15
  * Integrates with WordPress hooks.
src/Loader/LoaderIntegration.php CHANGED
@@ -5,8 +5,6 @@ namespace WebpConverter\Loader;
5
  use WebpConverter\PluginAccessAbstract;
6
  use WebpConverter\PluginAccessInterface;
7
  use WebpConverter\HookableInterface;
8
- use WebpConverter\Loader\LoaderInterface;
9
- use WebpConverter\Loader\LoaderAbstract;
10
 
11
  /**
12
  * Adds integration with active method of loading images.
5
  use WebpConverter\PluginAccessAbstract;
6
  use WebpConverter\PluginAccessInterface;
7
  use WebpConverter\HookableInterface;
 
 
8
 
9
  /**
10
  * Adds integration with active method of loading images.
src/Loader/PassthruLoader.php CHANGED
@@ -2,9 +2,6 @@
2
 
3
  namespace WebpConverter\Loader;
4
 
5
- use WebpConverter\Loader\LoaderAbstract;
6
- use WebpConverter\Loader\LoaderInterface;
7
-
8
  /**
9
  * Supports method of loading images using .php file as Pass Thru.
10
  */
2
 
3
  namespace WebpConverter\Loader;
4
 
 
 
 
5
  /**
6
  * Supports method of loading images using .php file as Pass Thru.
7
  */
src/Notice/NoticeAbstract.php CHANGED
@@ -2,8 +2,6 @@
2
 
3
  namespace WebpConverter\Notice;
4
 
5
- use WebpConverter\Notice\NoticeInterface;
6
-
7
  /**
8
  * Abstract class for class that supports data field in plugin settings.
9
  */
2
 
3
  namespace WebpConverter\Notice;
4
 
 
 
5
  /**
6
  * Abstract class for class that supports data field in plugin settings.
7
  */
src/Notice/NoticeFactory.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WebpConverter\Notice;
4
+
5
+ use WebpConverter\HookableInterface;
6
+
7
+ /**
8
+ * Adds integration for list of notices.
9
+ */
10
+ class NoticeFactory implements HookableInterface {
11
+
12
+ /**
13
+ * Integrates with WordPress hooks.
14
+ *
15
+ * @return void
16
+ */
17
+ public function init_hooks() {
18
+ $this->set_integration( new ThanksNotice() );
19
+ $this->set_integration( new WelcomeNotice() );
20
+ }
21
+
22
+ /**
23
+ * Sets integration for notice.
24
+ *
25
+ * @param NoticeInterface $notice .
26
+ *
27
+ * @return void
28
+ */
29
+ private function set_integration( NoticeInterface $notice ) {
30
+ ( new NoticeIntegration( $notice ) )->init_hooks();
31
+ }
32
+ }
src/Notice/NoticeIntegration.php CHANGED
@@ -2,7 +2,6 @@
2
 
3
  namespace WebpConverter\Notice;
4
 
5
- use WebpConverter\Notice\NoticeInterface;
6
  use WebpConverter\HookableInterface;
7
  use WebpConverter\Settings\AdminAssets;
8
  use WebpConverter\Helper\ViewLoader;
2
 
3
  namespace WebpConverter\Notice;
4
 
 
5
  use WebpConverter\HookableInterface;
6
  use WebpConverter\Settings\AdminAssets;
7
  use WebpConverter\Helper\ViewLoader;
src/Notice/Notices.php DELETED
@@ -1,23 +0,0 @@
1
- <?php
2
-
3
- namespace WebpConverter\Notice;
4
-
5
- use WebpConverter\Notice\NoticeIntegration;
6
- use WebpConverter\Notice\ThanksNotice;
7
- use WebpConverter\HookableInterface;
8
-
9
- /**
10
- * Adds integration for list of notices.
11
- */
12
- class Notices implements HookableInterface {
13
-
14
- /**
15
- * Integrates with WordPress hooks.
16
- *
17
- * @return void
18
- */
19
- public function init_hooks() {
20
- ( new NoticeIntegration( new ThanksNotice() ) )->init_hooks();
21
- ( new NoticeIntegration( new WelcomeNotice() ) )->init_hooks();
22
- }
23
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/Notice/ThanksNotice.php CHANGED
@@ -2,9 +2,6 @@
2
 
3
  namespace WebpConverter\Notice;
4
 
5
- use WebpConverter\Notice\NoticeAbstract;
6
- use WebpConverter\Notice\NoticeInterface;
7
-
8
  /**
9
  * Supports notice displayed as thank you for using plugin.
10
  */
2
 
3
  namespace WebpConverter\Notice;
4
 
 
 
 
5
  /**
6
  * Supports notice displayed as thank you for using plugin.
7
  */
src/Notice/WelcomeNotice.php CHANGED
@@ -2,9 +2,7 @@
2
 
3
  namespace WebpConverter\Notice;
4
 
5
- use WebpConverter\Notice\NoticeAbstract;
6
- use WebpConverter\Notice\NoticeInterface;
7
- use WebpConverter\Settings\Pages;
8
 
9
  /**
10
  * Supports notice displayed after plugin installation.
@@ -57,7 +55,7 @@ class WelcomeNotice extends NoticeAbstract implements NoticeInterface {
57
  */
58
  public function get_vars_for_view(): array {
59
  return [
60
- 'settings_url' => Pages::get_settings_page_url(),
61
  ];
62
  }
63
 
2
 
3
  namespace WebpConverter\Notice;
4
 
5
+ use WebpConverter\Settings\Page\PageIntegration;
 
 
6
 
7
  /**
8
  * Supports notice displayed after plugin installation.
55
  */
56
  public function get_vars_for_view(): array {
57
  return [
58
+ 'settings_url' => PageIntegration::get_settings_page_url(),
59
  ];
60
  }
61
 
src/Plugin/Links.php CHANGED
@@ -3,7 +3,7 @@
3
  namespace WebpConverter\Plugin;
4
 
5
  use WebpConverter\HookableInterface;
6
- use WebpConverter\Settings\Pages;
7
 
8
  /**
9
  * Adds links to plugin in list of plugins in panel.
@@ -64,7 +64,7 @@ class Links implements HookableInterface {
64
  sprintf(
65
  /* translators: %1$s: open anchor tag, %2$s: close anchor tag */
66
  esc_html( __( '%1$sSettings%2$s', 'webp-converter-for-media' ) ),
67
- '<a href="' . Pages::get_settings_page_url() . '">',
68
  '</a>'
69
  )
70
  );
3
  namespace WebpConverter\Plugin;
4
 
5
  use WebpConverter\HookableInterface;
6
+ use WebpConverter\Settings\Page\PageIntegration;
7
 
8
  /**
9
  * Adds links to plugin in list of plugins in panel.
64
  sprintf(
65
  /* translators: %1$s: open anchor tag, %2$s: close anchor tag */
66
  esc_html( __( '%1$sSettings%2$s', 'webp-converter-for-media' ) ),
67
+ '<a href="' . PageIntegration::get_settings_page_url() . '">',
68
  '</a>'
69
  )
70
  );
src/Plugin/Uninstall/PluginSettings.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  namespace WebpConverter\Plugin\Uninstall;
4
 
5
- use WebpConverter\Error\Errors;
6
  use WebpConverter\Notice\ThanksNotice;
7
  use WebpConverter\Notice\WelcomeNotice;
8
  use WebpConverter\Plugin\Update;
@@ -21,7 +21,7 @@ class PluginSettings {
21
  public static function remove_plugin_settings() {
22
  delete_option( ThanksNotice::NOTICE_OPTION );
23
  delete_option( WelcomeNotice::NOTICE_OPTION );
24
- delete_option( Errors::ERRORS_CACHE_OPTION );
25
  delete_option( SettingsSave::SETTINGS_OPTION );
26
  delete_option( Update::VERSION_OPTION );
27
  }
2
 
3
  namespace WebpConverter\Plugin\Uninstall;
4
 
5
+ use WebpConverter\Error\ErrorFactory;
6
  use WebpConverter\Notice\ThanksNotice;
7
  use WebpConverter\Notice\WelcomeNotice;
8
  use WebpConverter\Plugin\Update;
21
  public static function remove_plugin_settings() {
22
  delete_option( ThanksNotice::NOTICE_OPTION );
23
  delete_option( WelcomeNotice::NOTICE_OPTION );
24
+ delete_option( ErrorFactory::ERRORS_CACHE_OPTION );
25
  delete_option( SettingsSave::SETTINGS_OPTION );
26
  delete_option( Update::VERSION_OPTION );
27
  }
src/Plugin/Uninstall/WebpFiles.php CHANGED
@@ -3,7 +3,7 @@
3
  namespace WebpConverter\Plugin\Uninstall;
4
 
5
  use WebpConverter\Conversion\SkipLarger;
6
- use WebpConverter\Conversion\Formats;
7
 
8
  /**
9
  * Removes all output files /uploads-webpc directory.
@@ -18,9 +18,11 @@ class WebpFiles {
18
  * @return void
19
  */
20
  public static function remove_webp_files( string $output_path = null ) {
21
- $path = ( $output_path !== null ) ? $output_path : apply_filters( 'webpc_dir_path', '', 'webp' );
22
- $paths = self::get_paths_from_location( $path );
23
- $paths[] = $path;
 
 
24
  self::remove_files( $paths );
25
  }
26
 
@@ -59,7 +61,7 @@ class WebpFiles {
59
  return;
60
  }
61
 
62
- $extensions = ( new Formats() )->get_format_extensions();
63
  $extensions[] = SkipLarger::DELETED_FILE_EXTENSION;
64
 
65
  foreach ( $paths as $path ) {
3
  namespace WebpConverter\Plugin\Uninstall;
4
 
5
  use WebpConverter\Conversion\SkipLarger;
6
+ use WebpConverter\Conversion\Format\FormatFactory;
7
 
8
  /**
9
  * Removes all output files /uploads-webpc directory.
18
  * @return void
19
  */
20
  public static function remove_webp_files( string $output_path = null ) {
21
+ $path = ( $output_path !== null ) ? $output_path : apply_filters( 'webpc_dir_path', '', 'webp' );
22
+ $paths = self::get_paths_from_location( $path );
23
+ if ( $output_path === null ) {
24
+ $paths[] = $path;
25
+ }
26
  self::remove_files( $paths );
27
  }
28
 
61
  return;
62
  }
63
 
64
+ $extensions = ( new FormatFactory() )->get_format_extensions();
65
  $extensions[] = SkipLarger::DELETED_FILE_EXTENSION;
66
 
67
  foreach ( $paths as $path ) {
src/Plugin/Update.php CHANGED
@@ -6,8 +6,6 @@ use WebpConverter\PluginAccessAbstract;
6
  use WebpConverter\PluginAccessInterface;
7
  use WebpConverter\HookableInterface;
8
  use WebpConverter\Loader\LoaderAbstract;
9
- use WebpConverter\Plugin\Uninstall\WebpFiles;
10
- use WebpConverter\Settings\SettingsSave;
11
  use WebpConverter\Notice\WelcomeNotice;
12
 
13
  /**
6
  use WebpConverter\PluginAccessInterface;
7
  use WebpConverter\HookableInterface;
8
  use WebpConverter\Loader\LoaderAbstract;
 
 
9
  use WebpConverter\Notice\WelcomeNotice;
10
 
11
  /**
src/PluginAccessAbstract.php CHANGED
@@ -2,10 +2,6 @@
2
 
3
  namespace WebpConverter;
4
 
5
- use WebpConverter\PluginAccessInterface;
6
- use WebpConverter\WebpConverter;
7
- use WebpConverter\HookableInterface;
8
-
9
  /**
10
  * Allows class to access handle to main plugin class.
11
  */
2
 
3
  namespace WebpConverter;
4
 
 
 
 
 
5
  /**
6
  * Allows class to access handle to main plugin class.
7
  */
src/PluginAccessInterface.php CHANGED
@@ -2,9 +2,6 @@
2
 
3
  namespace WebpConverter;
4
 
5
- use WebpConverter\WebpConverter;
6
- use WebpConverter\PluginAccessAbstract;
7
-
8
  /**
9
  * Interface for class having access handle to main plugin class.
10
  */
2
 
3
  namespace WebpConverter;
4
 
 
 
 
5
  /**
6
  * Interface for class having access handle to main plugin class.
7
  */
src/Settings/Option/ConversionMethodOption.php CHANGED
@@ -2,9 +2,7 @@
2
 
3
  namespace WebpConverter\Settings\Option;
4
 
5
- use WebpConverter\Settings\Option\OptionAbstract;
6
- use WebpConverter\Settings\Option\OptionInterface;
7
- use WebpConverter\Conversion\Methods;
8
 
9
  /**
10
  * Handles data about "Conversion method" field in plugin settings.
@@ -16,7 +14,7 @@ class ConversionMethodOption extends OptionAbstract implements OptionInterface {
16
  /**
17
  * Object of integration class supports all output formats.
18
  *
19
- * @var Methods
20
  */
21
  private $methods_integration;
22
 
@@ -24,7 +22,7 @@ class ConversionMethodOption extends OptionAbstract implements OptionInterface {
24
  * ConversionMethodOption constructor.
25
  */
26
  public function __construct() {
27
- $this->methods_integration = new Methods();
28
  }
29
 
30
  /**
@@ -95,6 +93,7 @@ class ConversionMethodOption extends OptionAbstract implements OptionInterface {
95
  * @return string Default value of field.
96
  */
97
  public function get_default_value( array $settings = null ): string {
98
- return array_keys( $this->methods_integration->get_available_methods() )[0] ?? '';
 
99
  }
100
  }
2
 
3
  namespace WebpConverter\Settings\Option;
4
 
5
+ use WebpConverter\Conversion\Method\MethodFactory;
 
 
6
 
7
  /**
8
  * Handles data about "Conversion method" field in plugin settings.
14
  /**
15
  * Object of integration class supports all output formats.
16
  *
17
+ * @var MethodFactory
18
  */
19
  private $methods_integration;
20
 
22
  * ConversionMethodOption constructor.
23
  */
24
  public function __construct() {
25
+ $this->methods_integration = new MethodFactory();
26
  }
27
 
28
  /**
93
  * @return string Default value of field.
94
  */
95
  public function get_default_value( array $settings = null ): string {
96
+ $methods_available = $this->methods_integration->get_available_methods();
97
+ return array_keys( $methods_available )[0] ?? '';
98
  }
99
  }
src/Settings/Option/ExtraFeaturesOption.php CHANGED
@@ -2,10 +2,6 @@
2
 
3
  namespace WebpConverter\Settings\Option;
4
 
5
- use WebpConverter\Settings\Option\OptionAbstract;
6
- use WebpConverter\Settings\Option\OptionInterface;
7
- use WebpConverter\Settings\Option\ConversionMethodOption;
8
- use WebpConverter\Settings\Option\LoaderTypeOption;
9
  use WebpConverter\Conversion\Method\ImagickMethod;
10
  use WebpConverter\Loader\HtaccessLoader;
11
 
2
 
3
  namespace WebpConverter\Settings\Option;
4
 
 
 
 
 
5
  use WebpConverter\Conversion\Method\ImagickMethod;
6
  use WebpConverter\Loader\HtaccessLoader;
7
 
src/Settings/Option/ImagesQualityOption.php CHANGED
@@ -2,9 +2,6 @@
2
 
3
  namespace WebpConverter\Settings\Option;
4
 
5
- use WebpConverter\Settings\Option\OptionAbstract;
6
- use WebpConverter\Settings\Option\OptionInterface;
7
-
8
  /**
9
  * Handles data about "Images quality" field in plugin settings.
10
  */
2
 
3
  namespace WebpConverter\Settings\Option;
4
 
 
 
 
5
  /**
6
  * Handles data about "Images quality" field in plugin settings.
7
  */
src/Settings/Option/LoaderTypeOption.php CHANGED
@@ -2,8 +2,6 @@
2
 
3
  namespace WebpConverter\Settings\Option;
4
 
5
- use WebpConverter\Settings\Option\OptionAbstract;
6
- use WebpConverter\Settings\Option\OptionInterface;
7
  use WebpConverter\Loader\HtaccessLoader;
8
  use WebpConverter\Loader\PassthruLoader;
9
 
2
 
3
  namespace WebpConverter\Settings\Option;
4
 
 
 
5
  use WebpConverter\Loader\HtaccessLoader;
6
  use WebpConverter\Loader\PassthruLoader;
7
 
src/Settings/Option/OptionAbstract.php CHANGED
@@ -2,8 +2,6 @@
2
 
3
  namespace WebpConverter\Settings\Option;
4
 
5
- use WebpConverter\Settings\Option\OptionInterface;
6
-
7
  /**
8
  * Abstract class for class that supports notice displayed in admin panel.
9
  */
2
 
3
  namespace WebpConverter\Settings\Option;
4
 
 
 
5
  /**
6
  * Abstract class for class that supports notice displayed in admin panel.
7
  */
src/Settings/{Options.php → Option/OptionFactory.php} RENAMED
@@ -1,21 +1,44 @@
1
  <?php
2
 
3
- namespace WebpConverter\Settings;
4
 
5
- use WebpConverter\Settings\Option\OptionInterface;
6
- use WebpConverter\Settings\Option\OptionIntegration;
7
- use WebpConverter\Settings\Option\LoaderTypeOption;
8
- use WebpConverter\Settings\Option\OutputFormatsOption;
9
- use WebpConverter\Settings\Option\SupportedExtensionsOption;
10
- use WebpConverter\Settings\Option\SupportedDirectoriesOption;
11
- use WebpConverter\Settings\Option\ConversionMethodOption;
12
- use WebpConverter\Settings\Option\ImagesQualityOption;
13
- use WebpConverter\Settings\Option\ExtraFeaturesOption;
14
 
15
  /**
16
  * Allows to integration with plugin settings by providing list of settings fields and saved values.
17
  */
18
- class Options {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
20
  /**
21
  * Returns options of plugin settings.
@@ -30,29 +53,12 @@ class Options {
30
  $settings = ( $is_save ) ? $posted_settings : get_option( SettingsSave::SETTINGS_OPTION, [] );
31
 
32
  $options = [];
33
- foreach ( $this->get_option_objects() as $option_object ) {
34
  $options[] = ( new OptionIntegration( $option_object ) )->get_option_data( $settings, $is_debug, $is_save );
35
  }
36
  return $options;
37
  }
38
 
39
- /**
40
- * Returns objects for options of plugin settings.
41
- *
42
- * @return OptionInterface[] .
43
- */
44
- private function get_option_objects(): array {
45
- return [
46
- new LoaderTypeOption(),
47
- new SupportedExtensionsOption(),
48
- new SupportedDirectoriesOption(),
49
- new ConversionMethodOption(),
50
- new OutputFormatsOption(),
51
- new ImagesQualityOption(),
52
- new ExtraFeaturesOption(),
53
- ];
54
- }
55
-
56
  /**
57
  * Returns values of plugin settings.
58
  *
1
  <?php
2
 
3
+ namespace WebpConverter\Settings\Option;
4
 
5
+ use WebpConverter\Settings\SettingsSave;
 
 
 
 
 
 
 
 
6
 
7
  /**
8
  * Allows to integration with plugin settings by providing list of settings fields and saved values.
9
  */
10
+ class OptionFactory {
11
+
12
+ /**
13
+ * Objects of supported options.
14
+ *
15
+ * @var OptionInterface[]
16
+ */
17
+ private $options = [];
18
+
19
+ /**
20
+ * OptionFactory constructor.
21
+ */
22
+ public function __construct() {
23
+ $this->set_integration( new LoaderTypeOption() );
24
+ $this->set_integration( new SupportedExtensionsOption() );
25
+ $this->set_integration( new SupportedDirectoriesOption() );
26
+ $this->set_integration( new ConversionMethodOption() );
27
+ $this->set_integration( new OutputFormatsOption() );
28
+ $this->set_integration( new ImagesQualityOption() );
29
+ $this->set_integration( new ExtraFeaturesOption() );
30
+ }
31
+
32
+ /**
33
+ * Sets integration for option.
34
+ *
35
+ * @param OptionInterface $option .
36
+ *
37
+ * @return void
38
+ */
39
+ private function set_integration( OptionInterface $option ) {
40
+ $this->options[] = $option;
41
+ }
42
 
43
  /**
44
  * Returns options of plugin settings.
53
  $settings = ( $is_save ) ? $posted_settings : get_option( SettingsSave::SETTINGS_OPTION, [] );
54
 
55
  $options = [];
56
+ foreach ( $this->options as $option_object ) {
57
  $options[] = ( new OptionIntegration( $option_object ) )->get_option_data( $settings, $is_debug, $is_save );
58
  }
59
  return $options;
60
  }
61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  /**
63
  * Returns values of plugin settings.
64
  *
src/Settings/Option/OptionIntegration.php CHANGED
@@ -2,9 +2,6 @@
2
 
3
  namespace WebpConverter\Settings\Option;
4
 
5
- use WebpConverter\Settings\Option\OptionInterface;
6
- use WebpConverter\Settings\Option\OptionAbstract;
7
-
8
  /**
9
  * Allows to integrate with field in plugin settings by specifying its settings and value.
10
  */
2
 
3
  namespace WebpConverter\Settings\Option;
4
 
 
 
 
5
  /**
6
  * Allows to integrate with field in plugin settings by specifying its settings and value.
7
  */
src/Settings/Option/OptionInterface.php CHANGED
@@ -2,11 +2,6 @@
2
 
3
  namespace WebpConverter\Settings\Option;
4
 
5
- use WebpConverter\Loader\HtaccessLoader;
6
- use WebpConverter\Loader\PassthruLoader;
7
- use WebpConverter\Conversion\Method\GdMethod;
8
- use WebpConverter\Conversion\Method\ImagickMethod;
9
-
10
  /**
11
  * Interface for class that supports data field in plugin settings.
12
  */
2
 
3
  namespace WebpConverter\Settings\Option;
4
 
 
 
 
 
 
5
  /**
6
  * Interface for class that supports data field in plugin settings.
7
  */
src/Settings/Option/OutputFormatsOption.php CHANGED
@@ -2,10 +2,7 @@
2
 
3
  namespace WebpConverter\Settings\Option;
4
 
5
- use WebpConverter\Settings\Option\OptionAbstract;
6
- use WebpConverter\Settings\Option\OptionInterface;
7
- use WebpConverter\Settings\Option\ConversionMethodOption;
8
- use WebpConverter\Conversion\Formats;
9
  use WebpConverter\Conversion\Format\WebpFormat;
10
 
11
  /**
@@ -18,7 +15,7 @@ class OutputFormatsOption extends OptionAbstract implements OptionInterface {
18
  /**
19
  * Object of integration class supports all conversion methods.
20
  *
21
- * @var Formats
22
  */
23
  private $formats_integration;
24
 
@@ -26,7 +23,7 @@ class OutputFormatsOption extends OptionAbstract implements OptionInterface {
26
  * OutputFormatsOption constructor.
27
  */
28
  public function __construct() {
29
- $this->formats_integration = new Formats();
30
  }
31
 
32
  /**
2
 
3
  namespace WebpConverter\Settings\Option;
4
 
5
+ use WebpConverter\Conversion\Format\FormatFactory;
 
 
 
6
  use WebpConverter\Conversion\Format\WebpFormat;
7
 
8
  /**
15
  /**
16
  * Object of integration class supports all conversion methods.
17
  *
18
+ * @var FormatFactory
19
  */
20
  private $formats_integration;
21
 
23
  * OutputFormatsOption constructor.
24
  */
25
  public function __construct() {
26
+ $this->formats_integration = new FormatFactory();
27
  }
28
 
29
  /**
src/Settings/Option/SupportedDirectoriesOption.php CHANGED
@@ -2,9 +2,7 @@
2
 
3
  namespace WebpConverter\Settings\Option;
4
 
5
- use WebpConverter\Settings\Option\OptionAbstract;
6
- use WebpConverter\Settings\Option\OptionInterface;
7
- use WebpConverter\Conversion\Directories;
8
 
9
  /**
10
  * Handles data about "Supported directories" field in plugin settings.
@@ -57,7 +55,7 @@ class SupportedDirectoriesOption extends OptionAbstract implements OptionInterfa
57
  * @return string[] Values for field.
58
  */
59
  public function get_values( array $settings ): array {
60
- return ( new Directories() )->get_directories();
61
  }
62
 
63
  /**
2
 
3
  namespace WebpConverter\Settings\Option;
4
 
5
+ use WebpConverter\Conversion\Directory\DirectoryFactory;
 
 
6
 
7
  /**
8
  * Handles data about "Supported directories" field in plugin settings.
55
  * @return string[] Values for field.
56
  */
57
  public function get_values( array $settings ): array {
58
+ return ( new DirectoryFactory() )->get_directories();
59
  }
60
 
61
  /**
src/Settings/Option/SupportedExtensionsOption.php CHANGED
@@ -2,9 +2,6 @@
2
 
3
  namespace WebpConverter\Settings\Option;
4
 
5
- use WebpConverter\Settings\Option\OptionAbstract;
6
- use WebpConverter\Settings\Option\OptionInterface;
7
-
8
  /**
9
  * Handles data about "Supported files extensions" field in plugin settings.
10
  */
2
 
3
  namespace WebpConverter\Settings\Option;
4
 
 
 
 
5
  /**
6
  * Handles data about "Supported files extensions" field in plugin settings.
7
  */
src/Settings/Page/DebugPage.php CHANGED
@@ -3,14 +3,11 @@
3
 
4
  namespace WebpConverter\Settings\Page;
5
 
6
- use WebpConverter\Settings\Page\PageAbstract;
7
- use WebpConverter\Settings\Page\PageInterface;
8
  use WebpConverter\Loader\LoaderAbstract;
9
  use WebpConverter\Settings\SettingsSave;
10
  use WebpConverter\Helper\ViewLoader;
11
  use WebpConverter\Helper\FileLoader;
12
  use WebpConverter\Error\RewritesError;
13
- use WebpConverter\Settings\Pages;
14
 
15
  /**
16
  * Supports debug tab in plugin settings page.
@@ -46,13 +43,13 @@ class DebugPage extends PageAbstract implements PageInterface {
46
  [
47
  'settings_url' => sprintf(
48
  '%1$s&%2$s=%3$s',
49
- Pages::get_settings_page_url(),
50
  SettingsSave::NONCE_PARAM_KEY,
51
  wp_create_nonce( SettingsSave::NONCE_PARAM_VALUE )
52
  ),
53
  'settings_debug_url' => sprintf(
54
  '%s&action=server',
55
- Pages::get_settings_page_url()
56
  ),
57
  'size_png_path' => FileLoader::get_file_size_by_path(
58
  $uploads_path . RewritesError::PATH_OUTPUT_FILE_PNG
3
 
4
  namespace WebpConverter\Settings\Page;
5
 
 
 
6
  use WebpConverter\Loader\LoaderAbstract;
7
  use WebpConverter\Settings\SettingsSave;
8
  use WebpConverter\Helper\ViewLoader;
9
  use WebpConverter\Helper\FileLoader;
10
  use WebpConverter\Error\RewritesError;
 
11
 
12
  /**
13
  * Supports debug tab in plugin settings page.
43
  [
44
  'settings_url' => sprintf(
45
  '%1$s&%2$s=%3$s',
46
+ PageIntegration::get_settings_page_url(),
47
  SettingsSave::NONCE_PARAM_KEY,
48
  wp_create_nonce( SettingsSave::NONCE_PARAM_VALUE )
49
  ),
50
  'settings_debug_url' => sprintf(
51
  '%s&action=server',
52
+ PageIntegration::get_settings_page_url()
53
  ),
54
  'size_png_path' => FileLoader::get_file_size_by_path(
55
  $uploads_path . RewritesError::PATH_OUTPUT_FILE_PNG
src/Settings/Page/PageAbstract.php CHANGED
@@ -4,7 +4,6 @@ namespace WebpConverter\Settings\Page;
4
 
5
  use WebpConverter\PluginAccessAbstract;
6
  use WebpConverter\PluginAccessInterface;
7
- use WebpConverter\Settings\Page\PageInterface;
8
 
9
  /**
10
  * Abstract class for class that supports tab in plugin settings page.
4
 
5
  use WebpConverter\PluginAccessAbstract;
6
  use WebpConverter\PluginAccessInterface;
 
7
 
8
  /**
9
  * Abstract class for class that supports tab in plugin settings page.
src/Settings/Page/PageFactory.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WebpConverter\Settings\Page;
4
+
5
+ use WebpConverter\PluginAccessAbstract;
6
+ use WebpConverter\PluginAccessInterface;
7
+ use WebpConverter\HookableInterface;
8
+
9
+ /**
10
+ * Initializes integration for all plugin settings pages.
11
+ */
12
+ class PageFactory extends PluginAccessAbstract implements PluginAccessInterface, HookableInterface {
13
+
14
+ /**
15
+ * Object of pages integration.
16
+ *
17
+ * @var PageIntegration
18
+ */
19
+ private $page_integration;
20
+
21
+ /**
22
+ * Integrates with WordPress hooks.
23
+ *
24
+ * @return void
25
+ */
26
+ public function init_hooks() {
27
+ $this->set_integration( new SettingsPage() );
28
+ $this->set_integration( new DebugPage() );
29
+ }
30
+
31
+ /**
32
+ * Sets integration for page.
33
+ *
34
+ * @param PageInterface $page .
35
+ *
36
+ * @return void
37
+ */
38
+ private function set_integration( PageInterface $page ) {
39
+ if ( $this->page_integration === null ) {
40
+ $this->page_integration = new PageIntegration();
41
+ $this->page_integration->set_plugin_hookable( $this->get_plugin() );
42
+ }
43
+ $this->page_integration->set_page_integration( $page );
44
+ }
45
+ }
src/Settings/{Pages.php → Page/PageIntegration.php} RENAMED
@@ -1,23 +1,27 @@
1
  <?php
2
 
3
- namespace WebpConverter\Settings;
4
 
5
  use WebpConverter\PluginAccessAbstract;
6
  use WebpConverter\PluginAccessInterface;
7
  use WebpConverter\HookableInterface;
8
  use WebpConverter\Notice\WelcomeNotice;
9
  use WebpConverter\Settings\AdminAssets;
10
- use WebpConverter\Settings\Page\DebugPage;
11
- use WebpConverter\Settings\Page\PageInterface;
12
- use WebpConverter\Settings\Page\SettingsPage;
13
 
14
  /**
15
  * Adds plugin settings page in admin panel.
16
  */
17
- class Pages extends PluginAccessAbstract implements PluginAccessInterface, HookableInterface {
18
 
19
  const ADMIN_MENU_PAGE = 'webpc_admin_page';
20
 
 
 
 
 
 
 
 
21
  /**
22
  * Integrates with WordPress hooks.
23
  *
@@ -28,6 +32,19 @@ class Pages extends PluginAccessAbstract implements PluginAccessInterface, Hooka
28
  add_action( 'network_admin_menu', [ $this, 'add_settings_page_for_network' ] );
29
  }
30
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  /**
32
  * Returns URL of plugin settings page.
33
  *
@@ -90,8 +107,9 @@ class Pages extends PluginAccessAbstract implements PluginAccessInterface, Hooka
90
  * @internal
91
  */
92
  public function load_settings_page() {
93
- $this->init_page_is_active( new DebugPage() );
94
- $this->init_page_is_active( new SettingsPage() );
 
95
  }
96
 
97
  /**
@@ -103,9 +121,11 @@ class Pages extends PluginAccessAbstract implements PluginAccessInterface, Hooka
103
  */
104
  private function init_page_is_active( PageInterface $page ) {
105
  $page->set_plugin( $this->get_plugin() );
106
- if ( $page->is_page_active() ) {
107
- $page->show_page_view();
108
  }
 
 
109
  }
110
 
111
  /**
1
  <?php
2
 
3
+ namespace WebpConverter\Settings\Page;
4
 
5
  use WebpConverter\PluginAccessAbstract;
6
  use WebpConverter\PluginAccessInterface;
7
  use WebpConverter\HookableInterface;
8
  use WebpConverter\Notice\WelcomeNotice;
9
  use WebpConverter\Settings\AdminAssets;
 
 
 
10
 
11
  /**
12
  * Adds plugin settings page in admin panel.
13
  */
14
+ class PageIntegration extends PluginAccessAbstract implements PluginAccessInterface, HookableInterface {
15
 
16
  const ADMIN_MENU_PAGE = 'webpc_admin_page';
17
 
18
+ /**
19
+ * Objects of supported plugin settings pages.
20
+ *
21
+ * @var PageInterface[]
22
+ */
23
+ private $pages = [];
24
+
25
  /**
26
  * Integrates with WordPress hooks.
27
  *
32
  add_action( 'network_admin_menu', [ $this, 'add_settings_page_for_network' ] );
33
  }
34
 
35
+ /**
36
+ * Sets integration for page.
37
+ *
38
+ * @param PageInterface $page .
39
+ *
40
+ * @return self
41
+ */
42
+ public function set_page_integration( PageInterface $page ) {
43
+ $this->pages[] = $page;
44
+
45
+ return $this;
46
+ }
47
+
48
  /**
49
  * Returns URL of plugin settings page.
50
  *
107
  * @internal
108
  */
109
  public function load_settings_page() {
110
+ foreach ( $this->pages as $page ) {
111
+ $this->init_page_is_active( $page );
112
+ }
113
  }
114
 
115
  /**
121
  */
122
  private function init_page_is_active( PageInterface $page ) {
123
  $page->set_plugin( $this->get_plugin() );
124
+ if ( ! $page->is_page_active() ) {
125
+ return;
126
  }
127
+
128
+ $page->show_page_view();
129
  }
130
 
131
  /**
src/Settings/Page/SettingsPage.php CHANGED
@@ -3,14 +3,11 @@
3
 
4
  namespace WebpConverter\Settings\Page;
5
 
6
- use WebpConverter\Settings\Page\PageAbstract;
7
- use WebpConverter\Settings\Page\PageInterface;
8
  use WebpConverter\Conversion\Endpoint\PathsEndpoint;
9
  use WebpConverter\Conversion\Endpoint\RegenerateEndpoint;
10
  use WebpConverter\Helper\ViewLoader;
11
  use WebpConverter\Loader\LoaderAbstract;
12
- use WebpConverter\Settings\Options;
13
- use WebpConverter\Settings\Pages;
14
  use WebpConverter\Settings\SettingsSave;
15
 
16
  /**
@@ -43,17 +40,17 @@ class SettingsPage extends PageAbstract implements PageInterface {
43
  self::PAGE_VIEW_PATH,
44
  [
45
  'errors' => apply_filters( 'webpc_server_errors_messages', [], false, true ),
46
- 'options' => ( new Options() )->get_options(),
47
  'submit_value' => SettingsSave::SUBMIT_VALUE,
48
  'settings_url' => sprintf(
49
  '%1$s&%2$s=%3$s',
50
- Pages::get_settings_page_url(),
51
  SettingsSave::NONCE_PARAM_KEY,
52
  wp_create_nonce( SettingsSave::NONCE_PARAM_VALUE )
53
  ),
54
  'settings_debug_url' => sprintf(
55
  '%s&action=server',
56
- Pages::get_settings_page_url()
57
  ),
58
  'api_paths_url' => ( new PathsEndpoint() )->get_route_url(),
59
  'api_regenerate_url' => ( new RegenerateEndpoint() )->get_route_url(),
3
 
4
  namespace WebpConverter\Settings\Page;
5
 
 
 
6
  use WebpConverter\Conversion\Endpoint\PathsEndpoint;
7
  use WebpConverter\Conversion\Endpoint\RegenerateEndpoint;
8
  use WebpConverter\Helper\ViewLoader;
9
  use WebpConverter\Loader\LoaderAbstract;
10
+ use WebpConverter\Settings\Option\OptionFactory;
 
11
  use WebpConverter\Settings\SettingsSave;
12
 
13
  /**
40
  self::PAGE_VIEW_PATH,
41
  [
42
  'errors' => apply_filters( 'webpc_server_errors_messages', [], false, true ),
43
+ 'options' => ( new OptionFactory() )->get_options(),
44
  'submit_value' => SettingsSave::SUBMIT_VALUE,
45
  'settings_url' => sprintf(
46
  '%1$s&%2$s=%3$s',
47
+ PageIntegration::get_settings_page_url(),
48
  SettingsSave::NONCE_PARAM_KEY,
49
  wp_create_nonce( SettingsSave::NONCE_PARAM_VALUE )
50
  ),
51
  'settings_debug_url' => sprintf(
52
  '%s&action=server',
53
+ PageIntegration::get_settings_page_url()
54
  ),
55
  'api_paths_url' => ( new PathsEndpoint() )->get_route_url(),
56
  'api_regenerate_url' => ( new RegenerateEndpoint() )->get_route_url(),
src/Settings/SettingsSave.php CHANGED
@@ -6,8 +6,8 @@ use WebpConverter\PluginAccessAbstract;
6
  use WebpConverter\PluginAccessInterface;
7
  use WebpConverter\Conversion\Cron\Event;
8
  use WebpConverter\Loader\LoaderAbstract;
9
- use WebpConverter\Settings\Options;
10
- use WebpConverter\Conversion\Directories;
11
 
12
  /**
13
  * Supports saving plugin settings on plugin settings page.
@@ -31,7 +31,7 @@ class SettingsSave extends PluginAccessAbstract implements PluginAccessInterface
31
  return;
32
  }
33
 
34
- update_option( self::SETTINGS_OPTION, ( new Options() )->get_values( false, $_POST ) );
35
  $settings = $this->get_plugin()->get_settings( true );
36
  $this->get_plugin()->get_settings_debug( true );
37
  $this->init_actions_after_save( $settings );
@@ -47,6 +47,6 @@ class SettingsSave extends PluginAccessAbstract implements PluginAccessInterface
47
  private function init_actions_after_save( array $settings ) {
48
  do_action( LoaderAbstract::ACTION_NAME, true );
49
  wp_clear_scheduled_hook( Event::CRON_ACTION );
50
- ( new Directories() )->remove_unused_output_directories( $settings['dirs'] );
51
  }
52
  }
6
  use WebpConverter\PluginAccessInterface;
7
  use WebpConverter\Conversion\Cron\Event;
8
  use WebpConverter\Loader\LoaderAbstract;
9
+ use WebpConverter\Settings\Option\OptionFactory;
10
+ use WebpConverter\Conversion\Directory\DirectoryFactory;
11
 
12
  /**
13
  * Supports saving plugin settings on plugin settings page.
31
  return;
32
  }
33
 
34
+ update_option( self::SETTINGS_OPTION, ( new OptionFactory() )->get_values( false, $_POST ) );
35
  $settings = $this->get_plugin()->get_settings( true );
36
  $this->get_plugin()->get_settings_debug( true );
37
  $this->init_actions_after_save( $settings );
47
  private function init_actions_after_save( array $settings ) {
48
  do_action( LoaderAbstract::ACTION_NAME, true );
49
  wp_clear_scheduled_hook( Event::CRON_ACTION );
50
+ ( new DirectoryFactory() )->remove_unused_output_directories( $settings['dirs'] );
51
  }
52
  }
src/WebpConverter.php CHANGED
@@ -19,7 +19,7 @@ class WebpConverter {
19
  /**
20
  * Handler of class with plugin settings.
21
  *
22
- * @var Settings\Options
23
  */
24
  private $settings_object;
25
 
@@ -41,23 +41,23 @@ class WebpConverter {
41
  * WebpConverter constructor.
42
  */
43
  public function __construct() {
44
- $this->settings_object = new Settings\Options();
45
 
46
  ( new Action\ConvertAttachment() )->set_plugin_hookable( $this );
47
  ( new Action\ConvertDir() )->init_hooks();
48
  ( new Action\ConvertPaths() )->set_plugin_hookable( $this );
49
  ( new Action\DeletePaths() )->init_hooks();
50
  ( new Action\RegenerateAll() )->set_plugin_hookable( $this );
51
- ( new Conversion\Directories() )->init_hooks();
52
  ( new Conversion\DirectoryFiles() )->set_plugin_hookable( $this );
53
- ( new Conversion\Endpoints() )->set_plugin_hookable( $this );
54
  ( new Conversion\SkipExists() )->set_plugin_hookable( $this );
55
  ( new Conversion\SkipLarger() )->set_plugin_hookable( $this );
56
  ( new Cron\Event() )->set_plugin_hookable( $this );
57
  ( new Cron\Schedules() )->init_hooks();
58
- ( new Error\Errors() )->set_plugin_hookable( $this );
59
- ( new Notice\Notices() )->init_hooks();
60
- ( new Loader\Loaders() )->set_plugin_hookable( $this );
61
  ( new Media\Delete() )->init_hooks();
62
  ( new Media\Upload() )->set_plugin_hookable( $this );
63
  ( new Plugin\Activation() )->init_hooks();
@@ -65,7 +65,7 @@ class WebpConverter {
65
  ( new Plugin\Links() )->init_hooks();
66
  ( new Plugin\Uninstall() )->init_hooks();
67
  ( new Plugin\Update() )->set_plugin_hookable( $this );
68
- ( new Settings\Pages() )->set_plugin_hookable( $this );
69
  }
70
 
71
  /**
19
  /**
20
  * Handler of class with plugin settings.
21
  *
22
+ * @var Settings\Option\OptionFactory
23
  */
24
  private $settings_object;
25
 
41
  * WebpConverter constructor.
42
  */
43
  public function __construct() {
44
+ $this->settings_object = new Settings\Option\OptionFactory();
45
 
46
  ( new Action\ConvertAttachment() )->set_plugin_hookable( $this );
47
  ( new Action\ConvertDir() )->init_hooks();
48
  ( new Action\ConvertPaths() )->set_plugin_hookable( $this );
49
  ( new Action\DeletePaths() )->init_hooks();
50
  ( new Action\RegenerateAll() )->set_plugin_hookable( $this );
51
+ ( new Conversion\Directory\DirectoryFactory() )->init_hooks();
52
  ( new Conversion\DirectoryFiles() )->set_plugin_hookable( $this );
53
+ ( new Conversion\Endpoint\EndpointFactory() )->set_plugin_hookable( $this );
54
  ( new Conversion\SkipExists() )->set_plugin_hookable( $this );
55
  ( new Conversion\SkipLarger() )->set_plugin_hookable( $this );
56
  ( new Cron\Event() )->set_plugin_hookable( $this );
57
  ( new Cron\Schedules() )->init_hooks();
58
+ ( new Error\ErrorFactory() )->set_plugin_hookable( $this );
59
+ ( new Notice\NoticeFactory() )->init_hooks();
60
+ ( new Loader\LoaderFactory() )->set_plugin_hookable( $this );
61
  ( new Media\Delete() )->init_hooks();
62
  ( new Media\Upload() )->set_plugin_hookable( $this );
63
  ( new Plugin\Activation() )->init_hooks();
65
  ( new Plugin\Links() )->init_hooks();
66
  ( new Plugin\Uninstall() )->init_hooks();
67
  ( new Plugin\Update() )->set_plugin_hookable( $this );
68
+ ( new Settings\Page\PageFactory() )->set_plugin_hookable( $this );
69
  }
70
 
71
  /**
webp-converter-for-media.php CHANGED
@@ -3,14 +3,14 @@
3
  /**
4
  * Plugin Name: WebP Converter for Media
5
  * Description: Speed up your website by serving WebP images instead of standard formats JPEG, PNG and GIF.
6
- * Version: 3.0.4
7
  * Author: Mateusz Gbiorczyk
8
  * Author URI: https://gbiorczyk.pl/
9
  * Text Domain: webp-converter-for-media
10
  * Network: true
11
  */
12
 
13
- define( 'WEBPC_VERSION', '3.0.4' );
14
  define( 'WEBPC_FILE', __FILE__ );
15
  define( 'WEBPC_NAME', plugin_basename( __FILE__ ) );
16
  define( 'WEBPC_PATH', plugin_dir_path( __FILE__ ) );
3
  /**
4
  * Plugin Name: WebP Converter for Media
5
  * Description: Speed up your website by serving WebP images instead of standard formats JPEG, PNG and GIF.
6
+ * Version: 3.0.5
7
  * Author: Mateusz Gbiorczyk
8
  * Author URI: https://gbiorczyk.pl/
9
  * Text Domain: webp-converter-for-media
10
  * Network: true
11
  */
12
 
13
+ define( 'WEBPC_VERSION', '3.0.5' );
14
  define( 'WEBPC_FILE', __FILE__ );
15
  define( 'WEBPC_NAME', plugin_basename( __FILE__ ) );
16
  define( 'WEBPC_PATH', plugin_dir_path( __FILE__ ) );