Version Description
(2021-12-17) =
* [Fixed]
Fetching large list of files to conversion
* [Fixed]
Rewrites caching for some servers
* [Changed]
Connection when converting using remote server
Download this release
Release Info
Developer | mateuszgbiorczyk |
Plugin | Converter for Media – Optimize images | Convert WebP & AVIF |
Version | 4.0.2 |
Comparing to | |
See all releases |
Code changes from version 4.0.1 to 4.0.2
- changelog.txt +5 -0
- readme.txt +17 -18
- src/Action/RegenerateAll.php +13 -3
- src/Conversion/DirectoryFiles.php +12 -2
- src/Conversion/Endpoint/EndpointAbstract.php +0 -11
- src/Conversion/Endpoint/ImagesCounterEndpoint.php +19 -1
- src/Conversion/Endpoint/PathsEndpoint.php +48 -15
- src/Conversion/Endpoint/RegenerateEndpoint.php +10 -0
- src/Conversion/Method/LibraryMethodAbstract.php +16 -4
- src/Conversion/Method/MethodAbstract.php +0 -10
- src/Conversion/Method/MethodFactory.php +15 -7
- src/Conversion/Method/RemoteMethod.php +16 -3
- src/Error/Detector/RewritesErrorsDetector.php +1 -1
- src/Error/Detector/TokenStatusDetector.php +2 -2
- src/Error/Notice/BypassingApacheNotice.php +2 -26
- src/Error/Notice/LibsWithoutWebpSupportNotice.php +2 -6
- src/Loader/HtaccessLoader.php +1 -0
- src/Service/ServerConfigurator.php +27 -0
- src/Settings/Option/ConversionMethodOption.php +1 -1
- src/Settings/Option/OutputFormatsOption.php +1 -1
- src/Settings/Page/SettingsPage.php +4 -4
- src/Settings/SettingsSave.php +11 -1
- src/WebpConverter.php +7 -5
- vendor/autoload.php +1 -1
- vendor/composer/InstalledVersions.php +337 -0
- vendor/composer/autoload_classmap.php +1 -0
- vendor/composer/autoload_real.php +4 -4
- vendor/composer/autoload_static.php +5 -4
- vendor/composer/installed.php +23 -0
- webp-converter-for-media.php +3 -3
changelog.txt
CHANGED
@@ -1,5 +1,10 @@
|
|
1 |
== Changelog ==
|
2 |
|
|
|
|
|
|
|
|
|
|
|
3 |
= 4.0.1 (2021-12-10) =
|
4 |
* `[Added]` Informational banners on plugin settings page
|
5 |
|
1 |
== Changelog ==
|
2 |
|
3 |
+
= 4.0.2 (2021-12-17) =
|
4 |
+
* `[Fixed]` Fetching large list of files to conversion
|
5 |
+
* `[Fixed]` Rewrites caching for some servers
|
6 |
+
* `[Changed]` Connection when converting using remote server
|
7 |
+
|
8 |
= 4.0.1 (2021-12-10) =
|
9 |
* `[Added]` Informational banners on plugin settings page
|
10 |
|
readme.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
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,11 +9,11 @@ Stable tag: trunk
|
|
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 |
|
16 |
-
Speed up your website by serving WebP images. By replacing files in standard JPEG, PNG and GIF formats with WebP
|
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 |
|
@@ -383,27 +383,21 @@ Then find the configuration file in one of the paths *(remember to select config
|
|
383 |
- `/etc/nginx/sites-enabled/`
|
384 |
- `/etc/nginx/conf.d/`
|
385 |
|
386 |
-
and add below code in this file *(add these lines to very beginning of file if possible
|
387 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
388 |
`server {`
|
389 |
` location ~ /wp-content/(?<path>.+)\.(?<ext>jpe?g|png|gif)$ {`
|
390 |
-
` if ($http_accept !~* "image/avif") {`
|
391 |
-
` break;`
|
392 |
-
` }`
|
393 |
-
` add_header Vary Accept;`
|
394 |
-
` add_header Cache-Control "private" always;`
|
395 |
-
` expires 365d;`
|
396 |
-
` try_files /wp-content/uploads-webpc/$path.$ext.avif /wp-content/uploads-webpc/$path.$ext.webp $uri =404;`
|
397 |
-
` }`
|
398 |
-
` `
|
399 |
-
` location ~ /wp-content/(?<path>.+)\.(?<ext>jpe?g|png|gif)$ {`
|
400 |
-
` if ($http_accept !~* "image/webp") {`
|
401 |
-
` break;`
|
402 |
-
` }`
|
403 |
` add_header Vary Accept;`
|
404 |
` add_header Cache-Control "private" always;`
|
405 |
` expires 365d;`
|
406 |
-
` try_files
|
407 |
` }`
|
408 |
` # ...`
|
409 |
`}`
|
@@ -487,6 +481,11 @@ This is all very important to us and allows us to do even better things for you!
|
|
487 |
|
488 |
== Changelog ==
|
489 |
|
|
|
|
|
|
|
|
|
|
|
490 |
= 4.0.1 (2021-12-10) =
|
491 |
* `[Added]` Informational banners on plugin settings page
|
492 |
|
1 |
+
=== WebP Converter for Media - Convert WebP and AVIF & 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 and AVIF just now! Speed up your website by serving WebP and AVIF images instead of standard formats JPEG, PNG and GIF.
|
13 |
|
14 |
== Description ==
|
15 |
|
16 |
+
Speed up your website by serving WebP and AVIF images. By replacing files in standard JPEG, PNG and GIF formats with WebP and AVIF formats, you can save over a half of the page weight without losing quality.
|
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 |
|
383 |
- `/etc/nginx/sites-enabled/`
|
384 |
- `/etc/nginx/conf.d/`
|
385 |
|
386 |
+
and add below code in this file *(add these lines to very beginning of file if possible)*:
|
387 |
|
388 |
+
`map $http_accept $load_avif {`
|
389 |
+
` ~image/avif "/wp-content/uploads-webpc/$path.$ext.avif";`
|
390 |
+
`}`
|
391 |
+
`map $http_accept $load_webp {`
|
392 |
+
` ~image/webp "/wp-content/uploads-webpc/$path.$ext.webp";`
|
393 |
+
`}`
|
394 |
+
``
|
395 |
`server {`
|
396 |
` location ~ /wp-content/(?<path>.+)\.(?<ext>jpe?g|png|gif)$ {`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
397 |
` add_header Vary Accept;`
|
398 |
` add_header Cache-Control "private" always;`
|
399 |
` expires 365d;`
|
400 |
+
` try_files $load_avif $load_webp $uri =404;`
|
401 |
` }`
|
402 |
` # ...`
|
403 |
`}`
|
481 |
|
482 |
== Changelog ==
|
483 |
|
484 |
+
= 4.0.2 (2021-12-17) =
|
485 |
+
* `[Fixed]` Fetching large list of files to conversion
|
486 |
+
* `[Fixed]` Rewrites caching for some servers
|
487 |
+
* `[Changed]` Connection when converting using remote server
|
488 |
+
|
489 |
= 4.0.1 (2021-12-10) =
|
490 |
* `[Added]` Informational banners on plugin settings page
|
491 |
|
src/Action/RegenerateAll.php
CHANGED
@@ -5,6 +5,7 @@ namespace WebpConverter\Action;
|
|
5 |
use WebpConverter\Conversion\Endpoint\PathsEndpoint;
|
6 |
use WebpConverter\HookableInterface;
|
7 |
use WebpConverter\PluginData;
|
|
|
8 |
|
9 |
/**
|
10 |
* Initializes conversion of all image sizes in all directories.
|
@@ -16,8 +17,14 @@ class RegenerateAll implements HookableInterface {
|
|
16 |
*/
|
17 |
private $plugin_data;
|
18 |
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
}
|
22 |
|
23 |
/**
|
@@ -34,6 +41,9 @@ class RegenerateAll implements HookableInterface {
|
|
34 |
* @internal
|
35 |
*/
|
36 |
public function regenerate_all_images() {
|
37 |
-
do_action(
|
|
|
|
|
|
|
38 |
}
|
39 |
}
|
5 |
use WebpConverter\Conversion\Endpoint\PathsEndpoint;
|
6 |
use WebpConverter\HookableInterface;
|
7 |
use WebpConverter\PluginData;
|
8 |
+
use WebpConverter\Repository\TokenRepository;
|
9 |
|
10 |
/**
|
11 |
* Initializes conversion of all image sizes in all directories.
|
17 |
*/
|
18 |
private $plugin_data;
|
19 |
|
20 |
+
/**
|
21 |
+
* @var TokenRepository
|
22 |
+
*/
|
23 |
+
private $token_repository;
|
24 |
+
|
25 |
+
public function __construct( PluginData $plugin_data, TokenRepository $token_repository ) {
|
26 |
+
$this->plugin_data = $plugin_data;
|
27 |
+
$this->token_repository = $token_repository;
|
28 |
}
|
29 |
|
30 |
/**
|
41 |
* @internal
|
42 |
*/
|
43 |
public function regenerate_all_images() {
|
44 |
+
do_action(
|
45 |
+
'webpc_convert_paths',
|
46 |
+
( new PathsEndpoint( $this->plugin_data, $this->token_repository ) )->get_paths( true )
|
47 |
+
);
|
48 |
}
|
49 |
}
|
src/Conversion/DirectoryFiles.php
CHANGED
@@ -4,6 +4,7 @@ namespace WebpConverter\Conversion;
|
|
4 |
|
5 |
use WebpConverter\HookableInterface;
|
6 |
use WebpConverter\PluginData;
|
|
|
7 |
use WebpConverter\Settings\Option\SupportedExtensionsOption;
|
8 |
|
9 |
/**
|
@@ -18,8 +19,14 @@ class DirectoryFiles implements HookableInterface {
|
|
18 |
*/
|
19 |
private $plugin_data;
|
20 |
|
21 |
-
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
}
|
24 |
|
25 |
/**
|
@@ -44,6 +51,9 @@ class DirectoryFiles implements HookableInterface {
|
|
44 |
return $value;
|
45 |
}
|
46 |
|
|
|
|
|
|
|
47 |
$settings = $this->plugin_data->get_plugin_settings();
|
48 |
return $this->find_files_in_directory( $dir_path, $settings[ SupportedExtensionsOption::OPTION_NAME ], $skip_converted );
|
49 |
}
|
4 |
|
5 |
use WebpConverter\HookableInterface;
|
6 |
use WebpConverter\PluginData;
|
7 |
+
use WebpConverter\Service\ServerConfigurator;
|
8 |
use WebpConverter\Settings\Option\SupportedExtensionsOption;
|
9 |
|
10 |
/**
|
19 |
*/
|
20 |
private $plugin_data;
|
21 |
|
22 |
+
/**
|
23 |
+
* @var ServerConfigurator
|
24 |
+
*/
|
25 |
+
private $server_configurator;
|
26 |
+
|
27 |
+
public function __construct( PluginData $plugin_data, ServerConfigurator $server_configurator = null ) {
|
28 |
+
$this->plugin_data = $plugin_data;
|
29 |
+
$this->server_configurator = $server_configurator ?: new ServerConfigurator();
|
30 |
}
|
31 |
|
32 |
/**
|
51 |
return $value;
|
52 |
}
|
53 |
|
54 |
+
$this->server_configurator->set_memory_limit();
|
55 |
+
$this->server_configurator->set_execution_time();
|
56 |
+
|
57 |
$settings = $this->plugin_data->get_plugin_settings();
|
58 |
return $this->find_files_in_directory( $dir_path, $settings[ SupportedExtensionsOption::OPTION_NAME ], $skip_converted );
|
59 |
}
|
src/Conversion/Endpoint/EndpointAbstract.php
CHANGED
@@ -2,22 +2,11 @@
|
|
2 |
|
3 |
namespace WebpConverter\Conversion\Endpoint;
|
4 |
|
5 |
-
use WebpConverter\PluginData;
|
6 |
-
|
7 |
/**
|
8 |
* Abstract class for class that supports image conversion method.
|
9 |
*/
|
10 |
abstract class EndpointAbstract implements EndpointInterface {
|
11 |
|
12 |
-
/**
|
13 |
-
* @var PluginData
|
14 |
-
*/
|
15 |
-
protected $plugin_data;
|
16 |
-
|
17 |
-
public function __construct( PluginData $plugin_data ) {
|
18 |
-
$this->plugin_data = $plugin_data;
|
19 |
-
}
|
20 |
-
|
21 |
/**
|
22 |
* {@inheritdoc}
|
23 |
*/
|
2 |
|
3 |
namespace WebpConverter\Conversion\Endpoint;
|
4 |
|
|
|
|
|
5 |
/**
|
6 |
* Abstract class for class that supports image conversion method.
|
7 |
*/
|
8 |
abstract class EndpointAbstract implements EndpointInterface {
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
/**
|
11 |
* {@inheritdoc}
|
12 |
*/
|
src/Conversion/Endpoint/ImagesCounterEndpoint.php
CHANGED
@@ -2,11 +2,29 @@
|
|
2 |
|
3 |
namespace WebpConverter\Conversion\Endpoint;
|
4 |
|
|
|
|
|
|
|
5 |
/**
|
6 |
* Calculates the number of all images to be converted.
|
7 |
*/
|
8 |
class ImagesCounterEndpoint extends EndpointAbstract {
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
/**
|
11 |
* {@inheritdoc}
|
12 |
*/
|
@@ -19,7 +37,7 @@ class ImagesCounterEndpoint extends EndpointAbstract {
|
|
19 |
*/
|
20 |
public function get_route_response( \WP_REST_Request $request ) {
|
21 |
$images_count = number_format(
|
22 |
-
count( ( new PathsEndpoint( $this->plugin_data ) )->get_paths( false ) ),
|
23 |
0,
|
24 |
'',
|
25 |
' '
|
2 |
|
3 |
namespace WebpConverter\Conversion\Endpoint;
|
4 |
|
5 |
+
use WebpConverter\PluginData;
|
6 |
+
use WebpConverter\Repository\TokenRepository;
|
7 |
+
|
8 |
/**
|
9 |
* Calculates the number of all images to be converted.
|
10 |
*/
|
11 |
class ImagesCounterEndpoint extends EndpointAbstract {
|
12 |
|
13 |
+
/**
|
14 |
+
* @var PluginData
|
15 |
+
*/
|
16 |
+
private $plugin_data;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @var TokenRepository
|
20 |
+
*/
|
21 |
+
private $token_repository;
|
22 |
+
|
23 |
+
public function __construct( PluginData $plugin_data, TokenRepository $token_repository ) {
|
24 |
+
$this->plugin_data = $plugin_data;
|
25 |
+
$this->token_repository = $token_repository;
|
26 |
+
}
|
27 |
+
|
28 |
/**
|
29 |
* {@inheritdoc}
|
30 |
*/
|
37 |
*/
|
38 |
public function get_route_response( \WP_REST_Request $request ) {
|
39 |
$images_count = number_format(
|
40 |
+
count( ( new PathsEndpoint( $this->plugin_data, $this->token_repository ) )->get_paths( false ) ),
|
41 |
0,
|
42 |
'',
|
43 |
' '
|
src/Conversion/Endpoint/PathsEndpoint.php
CHANGED
@@ -3,7 +3,10 @@
|
|
3 |
namespace WebpConverter\Conversion\Endpoint;
|
4 |
|
5 |
use WebpConverter\Conversion\Method\RemoteMethod;
|
|
|
|
|
6 |
use WebpConverter\Settings\Option\ConversionMethodOption;
|
|
|
7 |
use WebpConverter\Settings\Option\SupportedDirectoriesOption;
|
8 |
|
9 |
/**
|
@@ -11,8 +14,26 @@ use WebpConverter\Settings\Option\SupportedDirectoriesOption;
|
|
11 |
*/
|
12 |
class PathsEndpoint extends EndpointAbstract {
|
13 |
|
14 |
-
const PATHS_PER_REQUEST_LOCAL
|
15 |
-
const
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
/**
|
18 |
* {@inheritdoc}
|
@@ -43,17 +64,12 @@ class PathsEndpoint extends EndpointAbstract {
|
|
43 |
public function get_route_response( \WP_REST_Request $request ) {
|
44 |
$params = $request->get_params();
|
45 |
$skip_converted = ( $params['regenerate_force'] !== true );
|
46 |
-
$settings = $this->plugin_data->get_plugin_settings();
|
47 |
|
48 |
-
$
|
49 |
-
|
50 |
-
( $settings[ ConversionMethodOption::OPTION_NAME ] !== RemoteMethod::METHOD_NAME )
|
51 |
-
? self::PATHS_PER_REQUEST_LOCAL
|
52 |
-
: self::PATHS_PER_REQUEST_REMOTE
|
53 |
-
);
|
54 |
|
55 |
return new \WP_REST_Response(
|
56 |
-
$
|
57 |
200
|
58 |
);
|
59 |
}
|
@@ -62,11 +78,10 @@ class PathsEndpoint extends EndpointAbstract {
|
|
62 |
* Returns list of server paths of source images to be converted.
|
63 |
*
|
64 |
* @param bool $skip_converted Skip converted images?
|
65 |
-
* @param int $chunk_size Number of files per one conversion request.
|
66 |
*
|
67 |
* @return array[] Server paths of source images.
|
68 |
*/
|
69 |
-
public function get_paths( bool $skip_converted = false
|
70 |
$settings = $this->plugin_data->get_plugin_settings();
|
71 |
$dirs = array_filter(
|
72 |
array_map(
|
@@ -84,10 +99,28 @@ class PathsEndpoint extends EndpointAbstract {
|
|
84 |
}
|
85 |
|
86 |
rsort( $list );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
|
88 |
-
if ( $
|
89 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
}
|
91 |
-
return array_chunk( $list, $chunk_size );
|
92 |
}
|
93 |
}
|
3 |
namespace WebpConverter\Conversion\Endpoint;
|
4 |
|
5 |
use WebpConverter\Conversion\Method\RemoteMethod;
|
6 |
+
use WebpConverter\PluginData;
|
7 |
+
use WebpConverter\Repository\TokenRepository;
|
8 |
use WebpConverter\Settings\Option\ConversionMethodOption;
|
9 |
+
use WebpConverter\Settings\Option\OutputFormatsOption;
|
10 |
use WebpConverter\Settings\Option\SupportedDirectoriesOption;
|
11 |
|
12 |
/**
|
14 |
*/
|
15 |
class PathsEndpoint extends EndpointAbstract {
|
16 |
|
17 |
+
const PATHS_PER_REQUEST_LOCAL = 10;
|
18 |
+
const PATHS_PER_REQUEST_REMOTE_SMALL = 1;
|
19 |
+
const PATHS_PER_REQUEST_REMOTE_MEDIUM = 2;
|
20 |
+
const PATHS_PER_REQUEST_REMOTE_LARGE = 3;
|
21 |
+
const PATHS_PER_REQUEST_REMOTE_MAX = 5;
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @var PluginData
|
25 |
+
*/
|
26 |
+
private $plugin_data;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @var TokenRepository
|
30 |
+
*/
|
31 |
+
private $token_repository;
|
32 |
+
|
33 |
+
public function __construct( PluginData $plugin_data, TokenRepository $token_repository ) {
|
34 |
+
$this->plugin_data = $plugin_data;
|
35 |
+
$this->token_repository = $token_repository;
|
36 |
+
}
|
37 |
|
38 |
/**
|
39 |
* {@inheritdoc}
|
64 |
public function get_route_response( \WP_REST_Request $request ) {
|
65 |
$params = $request->get_params();
|
66 |
$skip_converted = ( $params['regenerate_force'] !== true );
|
|
|
67 |
|
68 |
+
$paths = $this->get_paths( $skip_converted );
|
69 |
+
$paths = array_chunk( $paths, $this->get_paths_chunk_size( count( $paths ) ) );
|
|
|
|
|
|
|
|
|
70 |
|
71 |
return new \WP_REST_Response(
|
72 |
+
$paths,
|
73 |
200
|
74 |
);
|
75 |
}
|
78 |
* Returns list of server paths of source images to be converted.
|
79 |
*
|
80 |
* @param bool $skip_converted Skip converted images?
|
|
|
81 |
*
|
82 |
* @return array[] Server paths of source images.
|
83 |
*/
|
84 |
+
public function get_paths( bool $skip_converted = false ): array {
|
85 |
$settings = $this->plugin_data->get_plugin_settings();
|
86 |
$dirs = array_filter(
|
87 |
array_map(
|
99 |
}
|
100 |
|
101 |
rsort( $list );
|
102 |
+
return $list;
|
103 |
+
}
|
104 |
+
|
105 |
+
private function get_paths_chunk_size( int $paths_count ): int {
|
106 |
+
$settings = $this->plugin_data->get_plugin_settings();
|
107 |
+
if ( $settings[ ConversionMethodOption::OPTION_NAME ] !== RemoteMethod::METHOD_NAME ) {
|
108 |
+
return self::PATHS_PER_REQUEST_LOCAL;
|
109 |
+
}
|
110 |
+
|
111 |
+
$output_formats = count( $settings[ OutputFormatsOption::OPTION_NAME ] ) ?: 1;
|
112 |
+
$images_count = $paths_count * $output_formats;
|
113 |
+
$images_limit = $this->token_repository->get_token()->get_images_limit();
|
114 |
+
$images_to_conversion = min( $images_count, $images_limit );
|
115 |
|
116 |
+
if ( $images_to_conversion <= 10000 ) {
|
117 |
+
return self::PATHS_PER_REQUEST_REMOTE_SMALL;
|
118 |
+
} elseif ( $images_to_conversion <= 25000 ) {
|
119 |
+
return self::PATHS_PER_REQUEST_REMOTE_MEDIUM;
|
120 |
+
} elseif ( $images_to_conversion <= 120000 ) {
|
121 |
+
return self::PATHS_PER_REQUEST_REMOTE_LARGE;
|
122 |
+
} else {
|
123 |
+
return self::PATHS_PER_REQUEST_REMOTE_MAX;
|
124 |
}
|
|
|
125 |
}
|
126 |
}
|
src/Conversion/Endpoint/RegenerateEndpoint.php
CHANGED
@@ -3,12 +3,22 @@
|
|
3 |
namespace WebpConverter\Conversion\Endpoint;
|
4 |
|
5 |
use WebpConverter\Conversion\Method\MethodIntegrator;
|
|
|
6 |
|
7 |
/**
|
8 |
* Supports endpoint for converting list of paths to images.
|
9 |
*/
|
10 |
class RegenerateEndpoint extends EndpointAbstract {
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* {@inheritdoc}
|
14 |
*/
|
3 |
namespace WebpConverter\Conversion\Endpoint;
|
4 |
|
5 |
use WebpConverter\Conversion\Method\MethodIntegrator;
|
6 |
+
use WebpConverter\PluginData;
|
7 |
|
8 |
/**
|
9 |
* Supports endpoint for converting list of paths to images.
|
10 |
*/
|
11 |
class RegenerateEndpoint extends EndpointAbstract {
|
12 |
|
13 |
+
/**
|
14 |
+
* @var PluginData
|
15 |
+
*/
|
16 |
+
private $plugin_data;
|
17 |
+
|
18 |
+
public function __construct( PluginData $plugin_data ) {
|
19 |
+
$this->plugin_data = $plugin_data;
|
20 |
+
}
|
21 |
+
|
22 |
/**
|
23 |
* {@inheritdoc}
|
24 |
*/
|
src/Conversion/Method/LibraryMethodAbstract.php
CHANGED
@@ -5,6 +5,7 @@ namespace WebpConverter\Conversion\Method;
|
|
5 |
use WebpConverter\Conversion\SkipCrashed;
|
6 |
use WebpConverter\Conversion\SkipLarger;
|
7 |
use WebpConverter\Exception;
|
|
|
8 |
use WebpConverter\Settings\Option\OutputFormatsOption;
|
9 |
|
10 |
/**
|
@@ -22,9 +23,19 @@ abstract class LibraryMethodAbstract extends MethodAbstract implements LibraryMe
|
|
22 |
*/
|
23 |
private $skip_larger;
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
}
|
29 |
|
30 |
/**
|
@@ -57,7 +68,8 @@ abstract class LibraryMethodAbstract extends MethodAbstract implements LibraryMe
|
|
57 |
* @throws Exception\LargerThanOriginalException
|
58 |
*/
|
59 |
private function convert_path( string $path, string $format, array $plugin_settings ) {
|
60 |
-
$this->
|
|
|
61 |
|
62 |
try {
|
63 |
$source_path = $this->get_image_source_path( $path );
|
5 |
use WebpConverter\Conversion\SkipCrashed;
|
6 |
use WebpConverter\Conversion\SkipLarger;
|
7 |
use WebpConverter\Exception;
|
8 |
+
use WebpConverter\Service\ServerConfigurator;
|
9 |
use WebpConverter\Settings\Option\OutputFormatsOption;
|
10 |
|
11 |
/**
|
23 |
*/
|
24 |
private $skip_larger;
|
25 |
|
26 |
+
/**
|
27 |
+
* @var ServerConfigurator
|
28 |
+
*/
|
29 |
+
private $server_configurator;
|
30 |
+
|
31 |
+
public function __construct(
|
32 |
+
SkipCrashed $skip_crashed,
|
33 |
+
SkipLarger $skip_larger,
|
34 |
+
ServerConfigurator $server_configurator
|
35 |
+
) {
|
36 |
+
$this->skip_crashed = $skip_crashed;
|
37 |
+
$this->skip_larger = $skip_larger;
|
38 |
+
$this->server_configurator = $server_configurator;
|
39 |
}
|
40 |
|
41 |
/**
|
68 |
* @throws Exception\LargerThanOriginalException
|
69 |
*/
|
70 |
private function convert_path( string $path, string $format, array $plugin_settings ) {
|
71 |
+
$this->server_configurator->set_memory_limit();
|
72 |
+
$this->server_configurator->set_execution_time();
|
73 |
|
74 |
try {
|
75 |
$source_path = $this->get_image_source_path( $path );
|
src/Conversion/Method/MethodAbstract.php
CHANGED
@@ -72,16 +72,6 @@ abstract class MethodAbstract implements MethodInterface {
|
|
72 |
return $this->size_after;
|
73 |
}
|
74 |
|
75 |
-
/**
|
76 |
-
* @return void
|
77 |
-
*/
|
78 |
-
protected function set_server_config() {
|
79 |
-
ini_set( 'memory_limit', '1G' ); // phpcs:ignore
|
80 |
-
if ( strpos( ini_get( 'disable_functions' ) ?: '', 'set_time_limit' ) === false ) {
|
81 |
-
set_time_limit( 120 );
|
82 |
-
}
|
83 |
-
}
|
84 |
-
|
85 |
/**
|
86 |
* Checks server path of source image.
|
87 |
*
|
72 |
return $this->size_after;
|
73 |
}
|
74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
/**
|
76 |
* Checks server path of source image.
|
77 |
*
|
src/Conversion/Method/MethodFactory.php
CHANGED
@@ -6,6 +6,7 @@ use WebpConverter\Conversion\Format\FormatFactory;
|
|
6 |
use WebpConverter\Conversion\SkipCrashed;
|
7 |
use WebpConverter\Conversion\SkipLarger;
|
8 |
use WebpConverter\Repository\TokenRepository;
|
|
|
9 |
|
10 |
/**
|
11 |
* Adds support for all conversion methods and returns information about them.
|
@@ -27,6 +28,11 @@ class MethodFactory {
|
|
27 |
*/
|
28 |
private $token_repository;
|
29 |
|
|
|
|
|
|
|
|
|
|
|
30 |
/**
|
31 |
* Objects of supported conversion methods.
|
32 |
*
|
@@ -37,15 +43,17 @@ class MethodFactory {
|
|
37 |
public function __construct(
|
38 |
SkipCrashed $skip_crashed = null,
|
39 |
SkipLarger $skip_larger = null,
|
40 |
-
TokenRepository $token_repository = null
|
|
|
41 |
) {
|
42 |
-
$this->skip_crashed
|
43 |
-
$this->skip_larger
|
44 |
-
$this->token_repository
|
|
|
45 |
|
46 |
-
$this->set_integration( new ImagickMethod( $this->skip_crashed, $this->skip_larger ) );
|
47 |
-
$this->set_integration( new GdMethod( $this->skip_crashed, $this->skip_larger ) );
|
48 |
-
$this->set_integration( new RemoteMethod( $this->skip_larger ) );
|
49 |
}
|
50 |
|
51 |
/**
|
6 |
use WebpConverter\Conversion\SkipCrashed;
|
7 |
use WebpConverter\Conversion\SkipLarger;
|
8 |
use WebpConverter\Repository\TokenRepository;
|
9 |
+
use WebpConverter\Service\ServerConfigurator;
|
10 |
|
11 |
/**
|
12 |
* Adds support for all conversion methods and returns information about them.
|
28 |
*/
|
29 |
private $token_repository;
|
30 |
|
31 |
+
/**
|
32 |
+
* @var ServerConfigurator
|
33 |
+
*/
|
34 |
+
private $server_configurator;
|
35 |
+
|
36 |
/**
|
37 |
* Objects of supported conversion methods.
|
38 |
*
|
43 |
public function __construct(
|
44 |
SkipCrashed $skip_crashed = null,
|
45 |
SkipLarger $skip_larger = null,
|
46 |
+
TokenRepository $token_repository = null,
|
47 |
+
ServerConfigurator $server_configurator = null
|
48 |
) {
|
49 |
+
$this->skip_crashed = $skip_crashed ?: new SkipCrashed();
|
50 |
+
$this->skip_larger = $skip_larger ?: new SkipLarger();
|
51 |
+
$this->token_repository = $token_repository ?: new TokenRepository();
|
52 |
+
$this->server_configurator = $server_configurator ?: new ServerConfigurator();
|
53 |
|
54 |
+
$this->set_integration( new ImagickMethod( $this->skip_crashed, $this->skip_larger, $this->server_configurator ) );
|
55 |
+
$this->set_integration( new GdMethod( $this->skip_crashed, $this->skip_larger, $this->server_configurator ) );
|
56 |
+
$this->set_integration( new RemoteMethod( $this->skip_larger, $this->token_repository, $this->server_configurator ) );
|
57 |
}
|
58 |
|
59 |
/**
|
src/Conversion/Method/RemoteMethod.php
CHANGED
@@ -6,6 +6,7 @@ use WebpConverter\Conversion\SkipLarger;
|
|
6 |
use WebpConverter\Exception;
|
7 |
use WebpConverter\Model\Token;
|
8 |
use WebpConverter\Repository\TokenRepository;
|
|
|
9 |
use WebpConverter\Settings\Option\AccessTokenOption;
|
10 |
use WebpConverter\Settings\Option\ExtraFeaturesOption;
|
11 |
use WebpConverter\Settings\Option\ImagesQualityOption;
|
@@ -35,9 +36,18 @@ class RemoteMethod extends MethodAbstract {
|
|
35 |
*/
|
36 |
private $token;
|
37 |
|
38 |
-
|
39 |
-
|
40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
}
|
42 |
|
43 |
/**
|
@@ -92,6 +102,9 @@ class RemoteMethod extends MethodAbstract {
|
|
92 |
* @throws Exception\OutputPathException
|
93 |
*/
|
94 |
public function convert_paths( array $paths, array $plugin_settings, bool $regenerate_force ) {
|
|
|
|
|
|
|
95 |
$output_formats = $plugin_settings[ OutputFormatsOption::OPTION_NAME ];
|
96 |
$file_paths = $this->get_source_paths( $paths, $plugin_settings );
|
97 |
|
6 |
use WebpConverter\Exception;
|
7 |
use WebpConverter\Model\Token;
|
8 |
use WebpConverter\Repository\TokenRepository;
|
9 |
+
use WebpConverter\Service\ServerConfigurator;
|
10 |
use WebpConverter\Settings\Option\AccessTokenOption;
|
11 |
use WebpConverter\Settings\Option\ExtraFeaturesOption;
|
12 |
use WebpConverter\Settings\Option\ImagesQualityOption;
|
36 |
*/
|
37 |
private $token;
|
38 |
|
39 |
+
/**
|
40 |
+
* @var ServerConfigurator
|
41 |
+
*/
|
42 |
+
private $server_configurator;
|
43 |
+
|
44 |
+
public function __construct(
|
45 |
+
SkipLarger $skip_larger,
|
46 |
+
TokenRepository $token_repository,
|
47 |
+
ServerConfigurator $server_configurator ) {
|
48 |
+
$this->skip_larger = $skip_larger;
|
49 |
+
$this->token_repository = $token_repository;
|
50 |
+
$this->server_configurator = $server_configurator;
|
51 |
}
|
52 |
|
53 |
/**
|
102 |
* @throws Exception\OutputPathException
|
103 |
*/
|
104 |
public function convert_paths( array $paths, array $plugin_settings, bool $regenerate_force ) {
|
105 |
+
$this->server_configurator->set_memory_limit();
|
106 |
+
$this->server_configurator->set_execution_time();
|
107 |
+
|
108 |
$output_formats = $plugin_settings[ OutputFormatsOption::OPTION_NAME ];
|
109 |
$file_paths = $this->get_source_paths( $paths, $plugin_settings );
|
110 |
|
src/Error/Detector/RewritesErrorsDetector.php
CHANGED
@@ -86,7 +86,7 @@ class RewritesErrorsDetector implements ErrorDetector {
|
|
86 |
}
|
87 |
|
88 |
if ( $this->if_bypassing_apache_is_active() === true ) {
|
89 |
-
return new BypassingApacheNotice(
|
90 |
} elseif ( $this->if_htaccess_can_be_overwritten() !== true ) {
|
91 |
return new RewritesNotExecutedNotice();
|
92 |
}
|
86 |
}
|
87 |
|
88 |
if ( $this->if_bypassing_apache_is_active() === true ) {
|
89 |
+
return new BypassingApacheNotice();
|
90 |
} elseif ( $this->if_htaccess_can_be_overwritten() !== true ) {
|
91 |
return new RewritesNotExecutedNotice();
|
92 |
}
|
src/Error/Detector/TokenStatusDetector.php
CHANGED
@@ -54,12 +54,12 @@ class TokenStatusDetector implements ErrorDetector {
|
|
54 |
return new AccessTokenInvalidNotice();
|
55 |
}
|
56 |
|
57 |
-
$images_usage = ( $token->get_images_usage() + ( PathsEndpoint::
|
58 |
if ( $images_usage > $token->get_images_limit() ) {
|
59 |
$token = $this->token_validator->validate_token( $token->get_token_value() );
|
60 |
}
|
61 |
|
62 |
-
$images_usage = ( $token->get_images_usage() + ( PathsEndpoint::
|
63 |
if ( $images_usage > $token->get_images_limit() ) {
|
64 |
return new ApiLimitExceededNotice();
|
65 |
}
|
54 |
return new AccessTokenInvalidNotice();
|
55 |
}
|
56 |
|
57 |
+
$images_usage = ( $token->get_images_usage() + ( PathsEndpoint::PATHS_PER_REQUEST_REMOTE_SMALL * 2 ) );
|
58 |
if ( $images_usage > $token->get_images_limit() ) {
|
59 |
$token = $this->token_validator->validate_token( $token->get_token_value() );
|
60 |
}
|
61 |
|
62 |
+
$images_usage = ( $token->get_images_usage() + ( PathsEndpoint::PATHS_PER_REQUEST_REMOTE_SMALL * 2 ) );
|
63 |
if ( $images_usage > $token->get_images_limit() ) {
|
64 |
return new ApiLimitExceededNotice();
|
65 |
}
|
src/Error/Notice/BypassingApacheNotice.php
CHANGED
@@ -2,8 +2,6 @@
|
|
2 |
|
3 |
namespace WebpConverter\Error\Notice;
|
4 |
|
5 |
-
use WebpConverter\PluginInfo;
|
6 |
-
|
7 |
/**
|
8 |
* {@inheritdoc}
|
9 |
*/
|
@@ -11,15 +9,6 @@ class BypassingApacheNotice implements ErrorNotice {
|
|
11 |
|
12 |
const ERROR_KEY = 'bypassing_apache';
|
13 |
|
14 |
-
/**
|
15 |
-
* @var PluginInfo
|
16 |
-
*/
|
17 |
-
private $plugin_info;
|
18 |
-
|
19 |
-
public function __construct( PluginInfo $plugin_info ) {
|
20 |
-
$this->plugin_info = $plugin_info;
|
21 |
-
}
|
22 |
-
|
23 |
/**
|
24 |
* {@inheritdoc}
|
25 |
*/
|
@@ -32,22 +21,9 @@ class BypassingApacheNotice implements ErrorNotice {
|
|
32 |
*/
|
33 |
public function get_message(): array {
|
34 |
return [
|
35 |
-
|
36 |
-
|
37 |
-
__( 'Requests to images are processed by your server bypassing Apache. When loading images, rules from the .htaccess file are not executed. Occasionally, this only applies to known file extensions: .jpg, .png, etc. and when e.g. .png2 extension is loaded, then the redirections from the .htaccess file work, because the server does not understand this format and does not treat it as image files. Check the redirects for %1$s.png file%2$s (for which the redirection does not work) and for %3$s.png2 file%4$s (for which the redirection works correctly). Change the server settings to stop ignoring the rules from the .htaccess file.', 'webp-converter-for-media' ),
|
38 |
-
'<a href="' . $this->plugin_info->get_plugin_directory_url() . 'assets/img/debug/icon-before.png" target="_blank">',
|
39 |
-
'</a>',
|
40 |
-
'<a href="' . $this->plugin_info->get_plugin_directory_url() . 'assets/img/debug/icon-before.png2" target="_blank">',
|
41 |
-
'</a>'
|
42 |
-
),
|
43 |
__( 'In this case, please contact your server administrator.', 'webp-converter-for-media' ),
|
44 |
-
sprintf(
|
45 |
-
/* translators: %1$s: open strong tag, %2$s: close strong tag, %3$s: loader name */
|
46 |
-
__( '%1$sAlso try changing option "Image loading mode" to a different one.%2$s Issues about rewrites can often be resolved by setting this option to "%3$s". You can do this in plugin settings below. After changing settings, remember to flush cache if you use caching plugin or caching via hosting.', 'webp-converter-for-media' ),
|
47 |
-
'<strong>',
|
48 |
-
'</strong>',
|
49 |
-
'Pass Thru'
|
50 |
-
),
|
51 |
];
|
52 |
}
|
53 |
}
|
2 |
|
3 |
namespace WebpConverter\Error\Notice;
|
4 |
|
|
|
|
|
5 |
/**
|
6 |
* {@inheritdoc}
|
7 |
*/
|
9 |
|
10 |
const ERROR_KEY = 'bypassing_apache';
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* {@inheritdoc}
|
14 |
*/
|
21 |
*/
|
22 |
public function get_message(): array {
|
23 |
return [
|
24 |
+
__( 'Requests to images are processed by your server bypassing Apache. When loading images, rules from the .htaccess file are not executed. Change the server settings to handle the rules in the .htaccess file when loading static files.', 'webp-converter-for-media' ),
|
25 |
+
__( 'Find options similar to "Smart static files processing" or "Serve static files directly by Nginx" in your server settings for Apache and Nginx configuration. These types of options should be turned off for the rules in the .htaccess file to function properly. If you have "Nginx caching" or similar setting active, disable it or remove the following extensions from the list of saved to the cache: .jpg, .jpeg, .png and .gif.', 'webp-converter-for-media' ),
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
__( 'In this case, please contact your server administrator.', 'webp-converter-for-media' ),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
];
|
28 |
}
|
29 |
}
|
src/Error/Notice/LibsWithoutWebpSupportNotice.php
CHANGED
@@ -21,13 +21,9 @@ class LibsWithoutWebpSupportNotice implements ErrorNotice {
|
|
21 |
*/
|
22 |
public function get_message(): array {
|
23 |
return [
|
24 |
-
|
25 |
-
/* translators: %1$s: open anchor tag, %2$s: close anchor tag */
|
26 |
-
__( 'The selected option of "Conversion method" does not support WebP format. Please read %1$sthe plugin FAQ%2$s, specifically question about requirements of plugin. GD or Imagick library is installed on your server, but it does not support the WebP format. This issue is plugin-independent.', 'webp-converter-for-media' ),
|
27 |
-
'<a href="https://wordpress.org/plugins/webp-converter-for-media/#faq" target="_blank">',
|
28 |
-
'</a>'
|
29 |
-
),
|
30 |
__( 'You can also use "Remote server" option in "Conversion method" field in the plugin settings. This option allows you to convert your images using a remote server, so your server does not have to meet all technical requirements for libraries.', 'webp-converter-for-media' ),
|
|
|
31 |
];
|
32 |
}
|
33 |
}
|
21 |
*/
|
22 |
public function get_message(): array {
|
23 |
return [
|
24 |
+
__( 'The selected option of "Conversion method" does not support WebP format. GD or Imagick library is installed on your server, but it does not support the WebP format. This means that you cannot convert images to WebP format on your server, because it does not meet the technical requirements of the plugin. This issue is plugin-independent.', 'webp-converter-for-media' ),
|
|
|
|
|
|
|
|
|
|
|
25 |
__( 'You can also use "Remote server" option in "Conversion method" field in the plugin settings. This option allows you to convert your images using a remote server, so your server does not have to meet all technical requirements for libraries.', 'webp-converter-for-media' ),
|
26 |
+
__( 'This will allow you to convert your images to WebP without any problems and thus speed up your website.', 'webp-converter-for-media' ),
|
27 |
];
|
28 |
}
|
29 |
}
|
src/Loader/HtaccessLoader.php
CHANGED
@@ -180,6 +180,7 @@ class HtaccessLoader extends LoaderAbstract {
|
|
180 |
|
181 |
$content .= '<IfModule mod_headers.c>' . PHP_EOL;
|
182 |
$content .= ' Header always set Cache-Control "private"' . PHP_EOL;
|
|
|
183 |
$content .= '</IfModule>';
|
184 |
|
185 |
return apply_filters( 'webpc_htaccess_mod_headers', $content );
|
180 |
|
181 |
$content .= '<IfModule mod_headers.c>' . PHP_EOL;
|
182 |
$content .= ' Header always set Cache-Control "private"' . PHP_EOL;
|
183 |
+
$content .= ' Header append Vary "Accept"' . PHP_EOL;
|
184 |
$content .= '</IfModule>';
|
185 |
|
186 |
return apply_filters( 'webpc_htaccess_mod_headers', $content );
|
src/Service/ServerConfigurator.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace WebpConverter\Service;
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Manages required server configuration.
|
7 |
+
*/
|
8 |
+
class ServerConfigurator {
|
9 |
+
|
10 |
+
/**
|
11 |
+
* @return void
|
12 |
+
*/
|
13 |
+
public function set_memory_limit() {
|
14 |
+
ini_set( 'memory_limit', '1G' ); // phpcs:ignore
|
15 |
+
}
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @param int $seconds .
|
19 |
+
*
|
20 |
+
* @return void
|
21 |
+
*/
|
22 |
+
public function set_execution_time( int $seconds = 120 ) {
|
23 |
+
if ( strpos( ini_get( 'disable_functions' ) ?: '', 'set_time_limit' ) === false ) {
|
24 |
+
set_time_limit( $seconds );
|
25 |
+
}
|
26 |
+
}
|
27 |
+
}
|
src/Settings/Option/ConversionMethodOption.php
CHANGED
@@ -58,7 +58,7 @@ class ConversionMethodOption extends OptionAbstract {
|
|
58 |
return [
|
59 |
__( 'The Remote server allows you to reduce the server load, because your images are converted by our server. This option is also useful when the server does not meet all of the plugin\'s technical requirements.', 'webp-converter-for-media' ),
|
60 |
sprintf(
|
61 |
-
|
62 |
__( '%1$sRead more %2$s%3$s', 'webp-converter-for-media' ),
|
63 |
'<a href="' . esc_url( sprintf( WebpConverterConstants::UPGRADE_PRO_PREFIX_URL, 'field-conversion-method-info' ) ) . '" target="_blank">',
|
64 |
'<span class="dashicons dashicons-arrow-right-alt"></span>',
|
58 |
return [
|
59 |
__( 'The Remote server allows you to reduce the server load, because your images are converted by our server. This option is also useful when the server does not meet all of the plugin\'s technical requirements.', 'webp-converter-for-media' ),
|
60 |
sprintf(
|
61 |
+
/* translators: %1$s: open anchor tag, %2$s: arrow icon, %3$s: close anchor tag */
|
62 |
__( '%1$sRead more %2$s%3$s', 'webp-converter-for-media' ),
|
63 |
'<a href="' . esc_url( sprintf( WebpConverterConstants::UPGRADE_PRO_PREFIX_URL, 'field-conversion-method-info' ) ) . '" target="_blank">',
|
64 |
'<span class="dashicons dashicons-arrow-right-alt"></span>',
|
src/Settings/Option/OutputFormatsOption.php
CHANGED
@@ -65,7 +65,7 @@ class OutputFormatsOption extends OptionAbstract {
|
|
65 |
return [
|
66 |
__( 'The AVIF format is a new extension - is the successor to WebP. It allows you to achieve even higher levels of image compression, and the quality of the converted images is better than in WebP.', 'webp-converter-for-media' ),
|
67 |
sprintf(
|
68 |
-
|
69 |
__( '%1$sRead more %2$s%3$s', 'webp-converter-for-media' ),
|
70 |
'<a href="' . esc_url( sprintf( WebpConverterConstants::UPGRADE_PRO_PREFIX_URL, 'field-output-formats-info' ) ) . '" target="_blank">',
|
71 |
'<span class="dashicons dashicons-arrow-right-alt"></span>',
|
65 |
return [
|
66 |
__( 'The AVIF format is a new extension - is the successor to WebP. It allows you to achieve even higher levels of image compression, and the quality of the converted images is better than in WebP.', 'webp-converter-for-media' ),
|
67 |
sprintf(
|
68 |
+
/* translators: %1$s: open anchor tag, %2$s: arrow icon, %3$s: close anchor tag */
|
69 |
__( '%1$sRead more %2$s%3$s', 'webp-converter-for-media' ),
|
70 |
'<a href="' . esc_url( sprintf( WebpConverterConstants::UPGRADE_PRO_PREFIX_URL, 'field-output-formats-info' ) ) . '" target="_blank">',
|
71 |
'<span class="dashicons dashicons-arrow-right-alt"></span>',
|
src/Settings/Page/SettingsPage.php
CHANGED
@@ -39,11 +39,11 @@ class SettingsPage extends PageAbstract {
|
|
39 |
public function __construct(
|
40 |
PluginInfo $plugin_info,
|
41 |
PluginData $plugin_data,
|
42 |
-
TokenRepository $token_repository
|
43 |
) {
|
44 |
$this->plugin_info = $plugin_info;
|
45 |
$this->plugin_data = $plugin_data;
|
46 |
-
$this->token_repository = $token_repository
|
47 |
}
|
48 |
|
49 |
/**
|
@@ -79,8 +79,8 @@ class SettingsPage extends PageAbstract {
|
|
79 |
'%s&action=server',
|
80 |
PageIntegration::get_settings_page_url()
|
81 |
),
|
82 |
-
'api_calculate_url' => ( new ImagesCounterEndpoint( $this->plugin_data ) )->get_route_url(),
|
83 |
-
'api_paths_url' => ( new PathsEndpoint( $this->plugin_data ) )->get_route_url(),
|
84 |
'api_regenerate_url' => ( new RegenerateEndpoint( $this->plugin_data ) )->get_route_url(),
|
85 |
]
|
86 |
);
|
39 |
public function __construct(
|
40 |
PluginInfo $plugin_info,
|
41 |
PluginData $plugin_data,
|
42 |
+
TokenRepository $token_repository
|
43 |
) {
|
44 |
$this->plugin_info = $plugin_info;
|
45 |
$this->plugin_data = $plugin_data;
|
46 |
+
$this->token_repository = $token_repository;
|
47 |
}
|
48 |
|
49 |
/**
|
79 |
'%s&action=server',
|
80 |
PageIntegration::get_settings_page_url()
|
81 |
),
|
82 |
+
'api_calculate_url' => ( new ImagesCounterEndpoint( $this->plugin_data, $this->token_repository ) )->get_route_url(),
|
83 |
+
'api_paths_url' => ( new PathsEndpoint( $this->plugin_data, $this->token_repository ) )->get_route_url(),
|
84 |
'api_regenerate_url' => ( new RegenerateEndpoint( $this->plugin_data ) )->get_route_url(),
|
85 |
]
|
86 |
);
|
src/Settings/SettingsSave.php
CHANGED
@@ -72,7 +72,17 @@ class SettingsSave {
|
|
72 |
$token = $this->token_validator->validate_token( $plugin_settings[ AccessTokenOption::OPTION_NAME ] );
|
73 |
if ( $token->get_valid_status() ) {
|
74 |
$plugin_settings[ ConversionMethodOption::OPTION_NAME ] = RemoteMethod::METHOD_NAME;
|
75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
}
|
77 |
|
78 |
OptionsAccessManager::update_option(
|
72 |
$token = $this->token_validator->validate_token( $plugin_settings[ AccessTokenOption::OPTION_NAME ] );
|
73 |
if ( $token->get_valid_status() ) {
|
74 |
$plugin_settings[ ConversionMethodOption::OPTION_NAME ] = RemoteMethod::METHOD_NAME;
|
75 |
+
|
76 |
+
if ( isset( $_POST[ self::SUBMIT_TOKEN_ACTIVATE ] ) ) {
|
77 |
+
$plugin_settings[ OutputFormatsOption::OPTION_NAME ] = [
|
78 |
+
AvifFormat::FORMAT_EXTENSION,
|
79 |
+
WebpFormat::FORMAT_EXTENSION,
|
80 |
+
];
|
81 |
+
} elseif ( ! $plugin_settings[ OutputFormatsOption::OPTION_NAME ] ) {
|
82 |
+
$plugin_settings[ OutputFormatsOption::OPTION_NAME ] = [
|
83 |
+
WebpFormat::FORMAT_EXTENSION,
|
84 |
+
];
|
85 |
+
}
|
86 |
}
|
87 |
|
88 |
OptionsAccessManager::update_option(
|
src/WebpConverter.php
CHANGED
@@ -10,6 +10,7 @@ use WebpConverter\Conversion\Media;
|
|
10 |
use WebpConverter\Error\ErrorDetectorAggregator;
|
11 |
use WebpConverter\Notice;
|
12 |
use WebpConverter\Plugin;
|
|
|
13 |
use WebpConverter\Settings\Page;
|
14 |
|
15 |
/**
|
@@ -18,17 +19,18 @@ use WebpConverter\Settings\Page;
|
|
18 |
class WebpConverter {
|
19 |
|
20 |
public function __construct( PluginInfo $plugin_info ) {
|
21 |
-
$plugin_data
|
|
|
22 |
|
23 |
( new Action\ConvertAttachment( $plugin_data ) )->init_hooks();
|
24 |
( new Action\ConvertDir() )->init_hooks();
|
25 |
( new Action\ConvertPaths( $plugin_data ) )->init_hooks();
|
26 |
( new Action\DeletePaths() )->init_hooks();
|
27 |
-
( new Action\RegenerateAll( $plugin_data ) )->init_hooks();
|
28 |
( new Conversion\Directory\DirectoryFactory() )->init_hooks();
|
29 |
( new Conversion\DirectoryFiles( $plugin_data ) )->init_hooks();
|
30 |
-
( new Endpoint\EndpointIntegration( new Endpoint\ImagesCounterEndpoint( $plugin_data ) ) )->init_hooks();
|
31 |
-
( new Endpoint\EndpointIntegration( new Endpoint\PathsEndpoint( $plugin_data ) ) )->init_hooks();
|
32 |
( new Endpoint\EndpointIntegration( new Endpoint\RegenerateEndpoint( $plugin_data ) ) )->init_hooks();
|
33 |
( new Conversion\SkipConvertedPaths( $plugin_data ) )->init_hooks();
|
34 |
( new Conversion\SkipExcludedPaths() )->init_hooks();
|
@@ -47,7 +49,7 @@ class WebpConverter {
|
|
47 |
( new Plugin\Uninstall( $plugin_info ) )->init_hooks();
|
48 |
( new Plugin\Update( $plugin_info ) )->init_hooks();
|
49 |
( new Page\PageIntegration( $plugin_info ) )
|
50 |
-
->set_page_integration( new Page\SettingsPage( $plugin_info, $plugin_data ) )
|
51 |
->set_page_integration( new Page\DebugPage( $plugin_info, $plugin_data ) )
|
52 |
->init_hooks();
|
53 |
}
|
10 |
use WebpConverter\Error\ErrorDetectorAggregator;
|
11 |
use WebpConverter\Notice;
|
12 |
use WebpConverter\Plugin;
|
13 |
+
use WebpConverter\Repository\TokenRepository;
|
14 |
use WebpConverter\Settings\Page;
|
15 |
|
16 |
/**
|
19 |
class WebpConverter {
|
20 |
|
21 |
public function __construct( PluginInfo $plugin_info ) {
|
22 |
+
$plugin_data = new PluginData();
|
23 |
+
$token_repository = new TokenRepository();
|
24 |
|
25 |
( new Action\ConvertAttachment( $plugin_data ) )->init_hooks();
|
26 |
( new Action\ConvertDir() )->init_hooks();
|
27 |
( new Action\ConvertPaths( $plugin_data ) )->init_hooks();
|
28 |
( new Action\DeletePaths() )->init_hooks();
|
29 |
+
( new Action\RegenerateAll( $plugin_data, $token_repository ) )->init_hooks();
|
30 |
( new Conversion\Directory\DirectoryFactory() )->init_hooks();
|
31 |
( new Conversion\DirectoryFiles( $plugin_data ) )->init_hooks();
|
32 |
+
( new Endpoint\EndpointIntegration( new Endpoint\ImagesCounterEndpoint( $plugin_data, $token_repository ) ) )->init_hooks();
|
33 |
+
( new Endpoint\EndpointIntegration( new Endpoint\PathsEndpoint( $plugin_data, $token_repository ) ) )->init_hooks();
|
34 |
( new Endpoint\EndpointIntegration( new Endpoint\RegenerateEndpoint( $plugin_data ) ) )->init_hooks();
|
35 |
( new Conversion\SkipConvertedPaths( $plugin_data ) )->init_hooks();
|
36 |
( new Conversion\SkipExcludedPaths() )->init_hooks();
|
49 |
( new Plugin\Uninstall( $plugin_info ) )->init_hooks();
|
50 |
( new Plugin\Update( $plugin_info ) )->init_hooks();
|
51 |
( new Page\PageIntegration( $plugin_info ) )
|
52 |
+
->set_page_integration( new Page\SettingsPage( $plugin_info, $plugin_data, $token_repository ) )
|
53 |
->set_page_integration( new Page\DebugPage( $plugin_info, $plugin_data ) )
|
54 |
->init_hooks();
|
55 |
}
|
vendor/autoload.php
CHANGED
@@ -4,4 +4,4 @@
|
|
4 |
|
5 |
require_once __DIR__ . '/composer/autoload_real.php';
|
6 |
|
7 |
-
return
|
4 |
|
5 |
require_once __DIR__ . '/composer/autoload_real.php';
|
6 |
|
7 |
+
return ComposerAutoloaderInit80287993f128e7a857f0f2db132eda4f::getLoader();
|
vendor/composer/InstalledVersions.php
ADDED
@@ -0,0 +1,337 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* This file is part of Composer.
|
5 |
+
*
|
6 |
+
* (c) Nils Adermann <naderman@naderman.de>
|
7 |
+
* Jordi Boggiano <j.boggiano@seld.be>
|
8 |
+
*
|
9 |
+
* For the full copyright and license information, please view the LICENSE
|
10 |
+
* file that was distributed with this source code.
|
11 |
+
*/
|
12 |
+
|
13 |
+
namespace Composer;
|
14 |
+
|
15 |
+
use Composer\Autoload\ClassLoader;
|
16 |
+
use Composer\Semver\VersionParser;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* This class is copied in every Composer installed project and available to all
|
20 |
+
*
|
21 |
+
* See also https://getcomposer.org/doc/07-runtime.md#installed-versions
|
22 |
+
*
|
23 |
+
* To require it's presence, you can require `composer-runtime-api ^2.0`
|
24 |
+
*/
|
25 |
+
class InstalledVersions
|
26 |
+
{
|
27 |
+
private static $installed;
|
28 |
+
private static $canGetVendors;
|
29 |
+
private static $installedByVendor = array();
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Returns a list of all package names which are present, either by being installed, replaced or provided
|
33 |
+
*
|
34 |
+
* @return string[]
|
35 |
+
* @psalm-return list<string>
|
36 |
+
*/
|
37 |
+
public static function getInstalledPackages()
|
38 |
+
{
|
39 |
+
$packages = array();
|
40 |
+
foreach (self::getInstalled() as $installed) {
|
41 |
+
$packages[] = array_keys($installed['versions']);
|
42 |
+
}
|
43 |
+
|
44 |
+
if (1 === \count($packages)) {
|
45 |
+
return $packages[0];
|
46 |
+
}
|
47 |
+
|
48 |
+
return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Returns a list of all package names with a specific type e.g. 'library'
|
53 |
+
*
|
54 |
+
* @param string $type
|
55 |
+
* @return string[]
|
56 |
+
* @psalm-return list<string>
|
57 |
+
*/
|
58 |
+
public static function getInstalledPackagesByType($type)
|
59 |
+
{
|
60 |
+
$packagesByType = array();
|
61 |
+
|
62 |
+
foreach (self::getInstalled() as $installed) {
|
63 |
+
foreach ($installed['versions'] as $name => $package) {
|
64 |
+
if (isset($package['type']) && $package['type'] === $type) {
|
65 |
+
$packagesByType[] = $name;
|
66 |
+
}
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
+
return $packagesByType;
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Checks whether the given package is installed
|
75 |
+
*
|
76 |
+
* This also returns true if the package name is provided or replaced by another package
|
77 |
+
*
|
78 |
+
* @param string $packageName
|
79 |
+
* @param bool $includeDevRequirements
|
80 |
+
* @return bool
|
81 |
+
*/
|
82 |
+
public static function isInstalled($packageName, $includeDevRequirements = true)
|
83 |
+
{
|
84 |
+
foreach (self::getInstalled() as $installed) {
|
85 |
+
if (isset($installed['versions'][$packageName])) {
|
86 |
+
return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']);
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
return false;
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Checks whether the given package satisfies a version constraint
|
95 |
+
*
|
96 |
+
* e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call:
|
97 |
+
*
|
98 |
+
* Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3')
|
99 |
+
*
|
100 |
+
* @param VersionParser $parser Install composer/semver to have access to this class and functionality
|
101 |
+
* @param string $packageName
|
102 |
+
* @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package
|
103 |
+
* @return bool
|
104 |
+
*/
|
105 |
+
public static function satisfies(VersionParser $parser, $packageName, $constraint)
|
106 |
+
{
|
107 |
+
$constraint = $parser->parseConstraints($constraint);
|
108 |
+
$provided = $parser->parseConstraints(self::getVersionRanges($packageName));
|
109 |
+
|
110 |
+
return $provided->matches($constraint);
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Returns a version constraint representing all the range(s) which are installed for a given package
|
115 |
+
*
|
116 |
+
* It is easier to use this via isInstalled() with the $constraint argument if you need to check
|
117 |
+
* whether a given version of a package is installed, and not just whether it exists
|
118 |
+
*
|
119 |
+
* @param string $packageName
|
120 |
+
* @return string Version constraint usable with composer/semver
|
121 |
+
*/
|
122 |
+
public static function getVersionRanges($packageName)
|
123 |
+
{
|
124 |
+
foreach (self::getInstalled() as $installed) {
|
125 |
+
if (!isset($installed['versions'][$packageName])) {
|
126 |
+
continue;
|
127 |
+
}
|
128 |
+
|
129 |
+
$ranges = array();
|
130 |
+
if (isset($installed['versions'][$packageName]['pretty_version'])) {
|
131 |
+
$ranges[] = $installed['versions'][$packageName]['pretty_version'];
|
132 |
+
}
|
133 |
+
if (array_key_exists('aliases', $installed['versions'][$packageName])) {
|
134 |
+
$ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
|
135 |
+
}
|
136 |
+
if (array_key_exists('replaced', $installed['versions'][$packageName])) {
|
137 |
+
$ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
|
138 |
+
}
|
139 |
+
if (array_key_exists('provided', $installed['versions'][$packageName])) {
|
140 |
+
$ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
|
141 |
+
}
|
142 |
+
|
143 |
+
return implode(' || ', $ranges);
|
144 |
+
}
|
145 |
+
|
146 |
+
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
147 |
+
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
* @param string $packageName
|
151 |
+
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
|
152 |
+
*/
|
153 |
+
public static function getVersion($packageName)
|
154 |
+
{
|
155 |
+
foreach (self::getInstalled() as $installed) {
|
156 |
+
if (!isset($installed['versions'][$packageName])) {
|
157 |
+
continue;
|
158 |
+
}
|
159 |
+
|
160 |
+
if (!isset($installed['versions'][$packageName]['version'])) {
|
161 |
+
return null;
|
162 |
+
}
|
163 |
+
|
164 |
+
return $installed['versions'][$packageName]['version'];
|
165 |
+
}
|
166 |
+
|
167 |
+
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
168 |
+
}
|
169 |
+
|
170 |
+
/**
|
171 |
+
* @param string $packageName
|
172 |
+
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
|
173 |
+
*/
|
174 |
+
public static function getPrettyVersion($packageName)
|
175 |
+
{
|
176 |
+
foreach (self::getInstalled() as $installed) {
|
177 |
+
if (!isset($installed['versions'][$packageName])) {
|
178 |
+
continue;
|
179 |
+
}
|
180 |
+
|
181 |
+
if (!isset($installed['versions'][$packageName]['pretty_version'])) {
|
182 |
+
return null;
|
183 |
+
}
|
184 |
+
|
185 |
+
return $installed['versions'][$packageName]['pretty_version'];
|
186 |
+
}
|
187 |
+
|
188 |
+
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
189 |
+
}
|
190 |
+
|
191 |
+
/**
|
192 |
+
* @param string $packageName
|
193 |
+
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference
|
194 |
+
*/
|
195 |
+
public static function getReference($packageName)
|
196 |
+
{
|
197 |
+
foreach (self::getInstalled() as $installed) {
|
198 |
+
if (!isset($installed['versions'][$packageName])) {
|
199 |
+
continue;
|
200 |
+
}
|
201 |
+
|
202 |
+
if (!isset($installed['versions'][$packageName]['reference'])) {
|
203 |
+
return null;
|
204 |
+
}
|
205 |
+
|
206 |
+
return $installed['versions'][$packageName]['reference'];
|
207 |
+
}
|
208 |
+
|
209 |
+
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
210 |
+
}
|
211 |
+
|
212 |
+
/**
|
213 |
+
* @param string $packageName
|
214 |
+
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path.
|
215 |
+
*/
|
216 |
+
public static function getInstallPath($packageName)
|
217 |
+
{
|
218 |
+
foreach (self::getInstalled() as $installed) {
|
219 |
+
if (!isset($installed['versions'][$packageName])) {
|
220 |
+
continue;
|
221 |
+
}
|
222 |
+
|
223 |
+
return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null;
|
224 |
+
}
|
225 |
+
|
226 |
+
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
227 |
+
}
|
228 |
+
|
229 |
+
/**
|
230 |
+
* @return array
|
231 |
+
* @psalm-return array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string}
|
232 |
+
*/
|
233 |
+
public static function getRootPackage()
|
234 |
+
{
|
235 |
+
$installed = self::getInstalled();
|
236 |
+
|
237 |
+
return $installed[0]['root'];
|
238 |
+
}
|
239 |
+
|
240 |
+
/**
|
241 |
+
* Returns the raw installed.php data for custom implementations
|
242 |
+
*
|
243 |
+
* @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect.
|
244 |
+
* @return array[]
|
245 |
+
* @psalm-return array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string}>}
|
246 |
+
*/
|
247 |
+
public static function getRawData()
|
248 |
+
{
|
249 |
+
@trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED);
|
250 |
+
|
251 |
+
if (null === self::$installed) {
|
252 |
+
// only require the installed.php file if this file is loaded from its dumped location,
|
253 |
+
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
|
254 |
+
if (substr(__DIR__, -8, 1) !== 'C') {
|
255 |
+
self::$installed = include __DIR__ . '/installed.php';
|
256 |
+
} else {
|
257 |
+
self::$installed = array();
|
258 |
+
}
|
259 |
+
}
|
260 |
+
|
261 |
+
return self::$installed;
|
262 |
+
}
|
263 |
+
|
264 |
+
/**
|
265 |
+
* Returns the raw data of all installed.php which are currently loaded for custom implementations
|
266 |
+
*
|
267 |
+
* @return array[]
|
268 |
+
* @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string}>}>
|
269 |
+
*/
|
270 |
+
public static function getAllRawData()
|
271 |
+
{
|
272 |
+
return self::getInstalled();
|
273 |
+
}
|
274 |
+
|
275 |
+
/**
|
276 |
+
* Lets you reload the static array from another file
|
277 |
+
*
|
278 |
+
* This is only useful for complex integrations in which a project needs to use
|
279 |
+
* this class but then also needs to execute another project's autoloader in process,
|
280 |
+
* and wants to ensure both projects have access to their version of installed.php.
|
281 |
+
*
|
282 |
+
* A typical case would be PHPUnit, where it would need to make sure it reads all
|
283 |
+
* the data it needs from this class, then call reload() with
|
284 |
+
* `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure
|
285 |
+
* the project in which it runs can then also use this class safely, without
|
286 |
+
* interference between PHPUnit's dependencies and the project's dependencies.
|
287 |
+
*
|
288 |
+
* @param array[] $data A vendor/composer/installed.php data set
|
289 |
+
* @return void
|
290 |
+
*
|
291 |
+
* @psalm-param array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string}>} $data
|
292 |
+
*/
|
293 |
+
public static function reload($data)
|
294 |
+
{
|
295 |
+
self::$installed = $data;
|
296 |
+
self::$installedByVendor = array();
|
297 |
+
}
|
298 |
+
|
299 |
+
/**
|
300 |
+
* @return array[]
|
301 |
+
* @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string}>}>
|
302 |
+
*/
|
303 |
+
private static function getInstalled()
|
304 |
+
{
|
305 |
+
if (null === self::$canGetVendors) {
|
306 |
+
self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
|
307 |
+
}
|
308 |
+
|
309 |
+
$installed = array();
|
310 |
+
|
311 |
+
if (self::$canGetVendors) {
|
312 |
+
foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
|
313 |
+
if (isset(self::$installedByVendor[$vendorDir])) {
|
314 |
+
$installed[] = self::$installedByVendor[$vendorDir];
|
315 |
+
} elseif (is_file($vendorDir.'/composer/installed.php')) {
|
316 |
+
$installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
|
317 |
+
if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
|
318 |
+
self::$installed = $installed[count($installed) - 1];
|
319 |
+
}
|
320 |
+
}
|
321 |
+
}
|
322 |
+
}
|
323 |
+
|
324 |
+
if (null === self::$installed) {
|
325 |
+
// only require the installed.php file if this file is loaded from its dumped location,
|
326 |
+
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
|
327 |
+
if (substr(__DIR__, -8, 1) !== 'C') {
|
328 |
+
self::$installed = require __DIR__ . '/installed.php';
|
329 |
+
} else {
|
330 |
+
self::$installed = array();
|
331 |
+
}
|
332 |
+
}
|
333 |
+
$installed[] = self::$installed;
|
334 |
+
|
335 |
+
return $installed;
|
336 |
+
}
|
337 |
+
}
|
vendor/composer/autoload_classmap.php
CHANGED
@@ -132,6 +132,7 @@ return array(
|
|
132 |
'WebpConverter\\Repository\\TokenRepository' => $baseDir . '/src/Repository/TokenRepository.php',
|
133 |
'WebpConverter\\Service\\FileLoader' => $baseDir . '/src/Service/FileLoader.php',
|
134 |
'WebpConverter\\Service\\OptionsAccessManager' => $baseDir . '/src/Service/OptionsAccessManager.php',
|
|
|
135 |
'WebpConverter\\Service\\TokenValidator' => $baseDir . '/src/Service/TokenValidator.php',
|
136 |
'WebpConverter\\Service\\ViewLoader' => $baseDir . '/src/Service/ViewLoader.php',
|
137 |
'WebpConverter\\Settings\\AdminAssets' => $baseDir . '/src/Settings/AdminAssets.php',
|
132 |
'WebpConverter\\Repository\\TokenRepository' => $baseDir . '/src/Repository/TokenRepository.php',
|
133 |
'WebpConverter\\Service\\FileLoader' => $baseDir . '/src/Service/FileLoader.php',
|
134 |
'WebpConverter\\Service\\OptionsAccessManager' => $baseDir . '/src/Service/OptionsAccessManager.php',
|
135 |
+
'WebpConverter\\Service\\ServerConfigurator' => $baseDir . '/src/Service/ServerConfigurator.php',
|
136 |
'WebpConverter\\Service\\TokenValidator' => $baseDir . '/src/Service/TokenValidator.php',
|
137 |
'WebpConverter\\Service\\ViewLoader' => $baseDir . '/src/Service/ViewLoader.php',
|
138 |
'WebpConverter\\Settings\\AdminAssets' => $baseDir . '/src/Settings/AdminAssets.php',
|
vendor/composer/autoload_real.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
-
class
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
@@ -22,15 +22,15 @@ class ComposerAutoloaderInit81a63acb7741cc0c24b38c3ceaaf4622
|
|
22 |
return self::$loader;
|
23 |
}
|
24 |
|
25 |
-
spl_autoload_register(array('
|
26 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
27 |
-
spl_autoload_unregister(array('
|
28 |
|
29 |
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
30 |
if ($useStaticLoader) {
|
31 |
require_once __DIR__ . '/autoload_static.php';
|
32 |
|
33 |
-
call_user_func(\Composer\Autoload\
|
34 |
} else {
|
35 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
36 |
foreach ($map as $namespace => $path) {
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
+
class ComposerAutoloaderInit80287993f128e7a857f0f2db132eda4f
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
22 |
return self::$loader;
|
23 |
}
|
24 |
|
25 |
+
spl_autoload_register(array('ComposerAutoloaderInit80287993f128e7a857f0f2db132eda4f', 'loadClassLoader'), true, true);
|
26 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
27 |
+
spl_autoload_unregister(array('ComposerAutoloaderInit80287993f128e7a857f0f2db132eda4f', 'loadClassLoader'));
|
28 |
|
29 |
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
30 |
if ($useStaticLoader) {
|
31 |
require_once __DIR__ . '/autoload_static.php';
|
32 |
|
33 |
+
call_user_func(\Composer\Autoload\ComposerStaticInit80287993f128e7a857f0f2db132eda4f::getInitializer($loader));
|
34 |
} else {
|
35 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
36 |
foreach ($map as $namespace => $path) {
|
vendor/composer/autoload_static.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
-
class
|
8 |
{
|
9 |
public static $prefixLengthsPsr4 = array (
|
10 |
'W' =>
|
@@ -147,6 +147,7 @@ class ComposerStaticInit81a63acb7741cc0c24b38c3ceaaf4622
|
|
147 |
'WebpConverter\\Repository\\TokenRepository' => __DIR__ . '/../..' . '/src/Repository/TokenRepository.php',
|
148 |
'WebpConverter\\Service\\FileLoader' => __DIR__ . '/../..' . '/src/Service/FileLoader.php',
|
149 |
'WebpConverter\\Service\\OptionsAccessManager' => __DIR__ . '/../..' . '/src/Service/OptionsAccessManager.php',
|
|
|
150 |
'WebpConverter\\Service\\TokenValidator' => __DIR__ . '/../..' . '/src/Service/TokenValidator.php',
|
151 |
'WebpConverter\\Service\\ViewLoader' => __DIR__ . '/../..' . '/src/Service/ViewLoader.php',
|
152 |
'WebpConverter\\Settings\\AdminAssets' => __DIR__ . '/../..' . '/src/Settings/AdminAssets.php',
|
@@ -176,9 +177,9 @@ class ComposerStaticInit81a63acb7741cc0c24b38c3ceaaf4622
|
|
176 |
public static function getInitializer(ClassLoader $loader)
|
177 |
{
|
178 |
return \Closure::bind(function () use ($loader) {
|
179 |
-
$loader->prefixLengthsPsr4 =
|
180 |
-
$loader->prefixDirsPsr4 =
|
181 |
-
$loader->classMap =
|
182 |
|
183 |
}, null, ClassLoader::class);
|
184 |
}
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
+
class ComposerStaticInit80287993f128e7a857f0f2db132eda4f
|
8 |
{
|
9 |
public static $prefixLengthsPsr4 = array (
|
10 |
'W' =>
|
147 |
'WebpConverter\\Repository\\TokenRepository' => __DIR__ . '/../..' . '/src/Repository/TokenRepository.php',
|
148 |
'WebpConverter\\Service\\FileLoader' => __DIR__ . '/../..' . '/src/Service/FileLoader.php',
|
149 |
'WebpConverter\\Service\\OptionsAccessManager' => __DIR__ . '/../..' . '/src/Service/OptionsAccessManager.php',
|
150 |
+
'WebpConverter\\Service\\ServerConfigurator' => __DIR__ . '/../..' . '/src/Service/ServerConfigurator.php',
|
151 |
'WebpConverter\\Service\\TokenValidator' => __DIR__ . '/../..' . '/src/Service/TokenValidator.php',
|
152 |
'WebpConverter\\Service\\ViewLoader' => __DIR__ . '/../..' . '/src/Service/ViewLoader.php',
|
153 |
'WebpConverter\\Settings\\AdminAssets' => __DIR__ . '/../..' . '/src/Settings/AdminAssets.php',
|
177 |
public static function getInitializer(ClassLoader $loader)
|
178 |
{
|
179 |
return \Closure::bind(function () use ($loader) {
|
180 |
+
$loader->prefixLengthsPsr4 = ComposerStaticInit80287993f128e7a857f0f2db132eda4f::$prefixLengthsPsr4;
|
181 |
+
$loader->prefixDirsPsr4 = ComposerStaticInit80287993f128e7a857f0f2db132eda4f::$prefixDirsPsr4;
|
182 |
+
$loader->classMap = ComposerStaticInit80287993f128e7a857f0f2db132eda4f::$classMap;
|
183 |
|
184 |
}, null, ClassLoader::class);
|
185 |
}
|
vendor/composer/installed.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php return array(
|
2 |
+
'root' => array(
|
3 |
+
'pretty_version' => 'dev-master',
|
4 |
+
'version' => 'dev-master',
|
5 |
+
'type' => 'library',
|
6 |
+
'install_path' => __DIR__ . '/../../',
|
7 |
+
'aliases' => array(),
|
8 |
+
'reference' => 'f9ceb37afe91236b323011131111c3dd7378a53c',
|
9 |
+
'name' => 'gbiorczyk/webp-converter-for-media',
|
10 |
+
'dev' => false,
|
11 |
+
),
|
12 |
+
'versions' => array(
|
13 |
+
'gbiorczyk/webp-converter-for-media' => array(
|
14 |
+
'pretty_version' => 'dev-master',
|
15 |
+
'version' => 'dev-master',
|
16 |
+
'type' => 'library',
|
17 |
+
'install_path' => __DIR__ . '/../../',
|
18 |
+
'aliases' => array(),
|
19 |
+
'reference' => 'f9ceb37afe91236b323011131111c3dd7378a53c',
|
20 |
+
'dev_requirement' => false,
|
21 |
+
),
|
22 |
+
),
|
23 |
+
);
|
webp-converter-for-media.php
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
|
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: 4.0.
|
7 |
* Author: Mateusz Gbiorczyk
|
8 |
* Author URI: https://mattplugins.com/
|
9 |
* Text Domain: webp-converter-for-media
|
@@ -13,5 +13,5 @@
|
|
13 |
require_once __DIR__ . '/vendor/autoload.php';
|
14 |
|
15 |
new WebpConverter\WebpConverter(
|
16 |
-
new WebpConverter\PluginInfo( __FILE__, '4.0.
|
17 |
);
|
2 |
|
3 |
/**
|
4 |
* Plugin Name: WebP Converter for Media
|
5 |
+
* Description: Speed up your website by serving WebP and AVIF images instead of standard formats JPEG, PNG and GIF.
|
6 |
+
* Version: 4.0.2
|
7 |
* Author: Mateusz Gbiorczyk
|
8 |
* Author URI: https://mattplugins.com/
|
9 |
* Text Domain: webp-converter-for-media
|
13 |
require_once __DIR__ . '/vendor/autoload.php';
|
14 |
|
15 |
new WebpConverter\WebpConverter(
|
16 |
+
new WebpConverter\PluginInfo( __FILE__, '4.0.2' )
|
17 |
);
|