Version Description
(2021-07-19) =
* [Added]
Changes to improve performance of plugin
Download this release
Release Info
Developer | mateuszgbiorczyk |
Plugin | Converter for Media – Optimize images | Convert WebP & AVIF |
Version | 3.0.7 |
Comparing to | |
See all releases |
Code changes from version 3.0.6 to 3.0.7
- readme.txt +4 -1
- src/Action/ConvertAttachment.php +16 -8
- src/Action/ConvertDir.php +1 -3
- src/Action/ConvertPaths.php +17 -9
- src/Action/DeletePaths.php +1 -3
- src/Action/RegenerateAll.php +16 -10
- src/Conversion/Cron/Event.php +16 -7
- src/Conversion/Cron/Schedules.php +1 -3
- src/Conversion/Directory/DirectoryAbstract.php +5 -15
- src/Conversion/Directory/DirectoryFactory.php +1 -6
- src/Conversion/Directory/DirectoryIntegration.php +1 -3
- src/Conversion/Directory/GalleryDirectory.php +4 -10
- src/Conversion/Directory/PluginsDirectory.php +4 -10
- src/Conversion/Directory/ThemesDirectory.php +4 -10
- src/Conversion/Directory/UploadsDirectory.php +5 -13
- src/Conversion/Directory/UploadsWebpcDirectory.php +5 -13
- src/Conversion/DirectoryFiles.php +16 -7
- src/Conversion/Endpoint/EndpointAbstract.php +16 -9
- src/Conversion/Endpoint/EndpointFactory.php +0 -35
- src/Conversion/Endpoint/EndpointIntegration.php +1 -5
- src/Conversion/Endpoint/EndpointInterface.php +1 -3
- src/Conversion/Endpoint/PathsEndpoint.php +4 -8
- src/Conversion/Endpoint/RegenerateEndpoint.php +5 -17
- src/Conversion/Exception/ConversionErrorException.php +3 -9
- src/Conversion/Exception/ExceptionAbstract.php +1 -3
- src/Conversion/Exception/ExceptionInterface.php +0 -2
- src/Conversion/Exception/ExtensionUnsupportedException.php +3 -9
- src/Conversion/Exception/FunctionUnavailableException.php +3 -9
- src/Conversion/Exception/ImageInvalidException.php +3 -9
- src/Conversion/Exception/ImagickNotSupportWebpException.php +3 -9
- src/Conversion/Exception/ImagickUnavailableException.php +3 -9
- src/Conversion/Exception/LargerThanOriginalException.php +3 -9
- src/Conversion/Exception/OutputPathException.php +3 -9
- src/Conversion/Exception/ResolutionOversizeException.php +3 -9
- src/Conversion/Exception/ServerConfigurationException.php +3 -9
- src/Conversion/Exception/SourcePathException.php +3 -9
- src/Conversion/Format/AvifFormat.php +5 -15
- src/Conversion/Format/FormatAbstract.php +4 -9
- src/Conversion/Format/FormatFactory.php +0 -3
- src/Conversion/Format/WebpFormat.php +4 -10
- src/Conversion/Media/Attachment.php +11 -6
- src/Conversion/Media/Delete.php +1 -3
- src/Conversion/Media/Upload.php +16 -7
- src/Conversion/Method/GdMethod.php +11 -31
- src/Conversion/Method/ImagickMethod.php +14 -34
- src/Conversion/Method/MethodAbstract.php +17 -46
- src/Conversion/Method/MethodFactory.php +0 -3
- src/Conversion/Method/MethodIntegrator.php +16 -6
- src/Conversion/Method/MethodInterface.php +17 -23
- src/Conversion/SkipExists.php +16 -7
- src/Conversion/SkipLarger.php +16 -7
- src/Error/ErrorAbstract.php +0 -21
- src/Error/ErrorFactory.php +23 -26
- src/Error/ErrorInterface.php +1 -3
- src/Error/LibsInstalledError.php +2 -4
- src/Error/LibsSupportAvifError.php +16 -5
- src/Error/LibsSupportWebpError.php +2 -4
- src/Error/PassthruError.php +16 -6
- src/Error/PathsError.php +2 -4
- src/Error/RestapiError.php +2 -4
- src/Error/RewritesError.php +21 -10
- src/Error/SettingsError.php +16 -6
- src/Helper/FileLoader.php +7 -10
- src/Loader/HtaccessLoader.php +10 -16
- src/Loader/LoaderAbstract.php +17 -10
- src/Loader/LoaderFactory.php +0 -35
- src/Loader/LoaderIntegration.php +2 -8
- src/Loader/LoaderInterface.php +1 -2
- src/Loader/PassthruLoader.php +8 -18
- src/Notice/NoticeAbstract.php +4 -8
- src/Notice/NoticeFactory.php +1 -3
- src/Notice/NoticeIntegration.php +1 -5
- src/Notice/NoticeInterface.php +2 -2
- src/Notice/ThanksNotice.php +11 -25
- src/Notice/WelcomeNotice.php +6 -19
- src/Plugin/Activation.php +1 -3
- src/Plugin/Deactivation.php +2 -11
- src/Plugin/Deactivation/Modal.php +18 -8
- src/Plugin/Links.php +13 -14
- src/Plugin/Uninstall.php +1 -3
- src/Plugin/Uninstall/PluginSettings.php +1 -0
- src/Plugin/Update.php +5 -11
- src/PluginAccessAbstract.php +0 -50
- src/PluginAccessInterface.php +0 -34
- src/PluginData.php +70 -0
- src/Settings/AdminAssets.php +1 -3
- src/Settings/Option/ConversionMethodOption.php +10 -31
- src/Settings/Option/ExtraFeaturesOption.php +7 -23
- src/Settings/Option/ImagesQualityOption.php +7 -23
- src/Settings/Option/LoaderTypeOption.php +7 -23
- src/Settings/Option/OptionAbstract.php +2 -8
- src/Settings/Option/OptionFactory.php +0 -3
- src/Settings/Option/OptionIntegration.php +0 -2
- src/Settings/Option/OutputFormatsOption.php +6 -23
- src/Settings/Option/SupportedDirectoriesOption.php +6 -18
- src/Settings/Option/SupportedExtensionsOption.php +5 -15
- src/Settings/Page/DebugPage.php +7 -12
- src/Settings/Page/PageAbstract.php +14 -3
- src/Settings/Page/PageFactory.php +0 -45
- src/Settings/Page/PageIntegration.php +2 -7
- src/Settings/Page/PageInterface.php +1 -3
- src/Settings/Page/SettingsPage.php +6 -12
- src/Settings/SettingsSave.php +19 -9
- src/WebpConverter.php +23 -68
- templates/components/notices/thanks.php +7 -17
- vendor/autoload.php +1 -1
- vendor/composer/InstalledVersions.php +2 -2
- vendor/composer/autoload_classmap.php +9 -13
- vendor/composer/autoload_real.php +4 -4
- vendor/composer/autoload_static.php +13 -17
- vendor/composer/installed.php +2 -2
- webp-converter-for-media.php +2 -2
readme.txt
CHANGED
@@ -3,7 +3,7 @@ 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
|
5 |
Requires at least: 4.9
|
6 |
-
Tested up to: 5.
|
7 |
Requires PHP: 7.0
|
8 |
Stable tag: trunk
|
9 |
License: GPLv2 or later
|
@@ -436,6 +436,9 @@ This is all very important to us and allows us to do even better things for you!
|
|
436 |
|
437 |
== Changelog ==
|
438 |
|
|
|
|
|
|
|
439 |
= 3.0.6 (2021-06-20) =
|
440 |
* `[Fixed]` Generating URLs for images using Pass Thru method
|
441 |
* `[Added]` Filter `webpc_passthru_url_nocache` to remove nocache param from URL using Pass Thru method
|
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
|
5 |
Requires at least: 4.9
|
6 |
+
Tested up to: 5.8
|
7 |
Requires PHP: 7.0
|
8 |
Stable tag: trunk
|
9 |
License: GPLv2 or later
|
436 |
|
437 |
== Changelog ==
|
438 |
|
439 |
+
= 3.0.7 (2021-07-19) =
|
440 |
+
* `[Added]` Changes to improve performance of plugin
|
441 |
+
|
442 |
= 3.0.6 (2021-06-20) =
|
443 |
* `[Fixed]` Generating URLs for images using Pass Thru method
|
444 |
* `[Added]` Filter `webpc_passthru_url_nocache` to remove nocache param from URL using Pass Thru method
|
src/Action/ConvertAttachment.php
CHANGED
@@ -2,20 +2,29 @@
|
|
2 |
|
3 |
namespace WebpConverter\Action;
|
4 |
|
5 |
-
use WebpConverter\PluginAccessAbstract;
|
6 |
-
use WebpConverter\PluginAccessInterface;
|
7 |
use WebpConverter\HookableInterface;
|
|
|
8 |
use WebpConverter\Conversion\Media\Attachment;
|
9 |
|
10 |
/**
|
11 |
* Initializes conversion of all image sizes for attachment.
|
12 |
*/
|
13 |
-
class ConvertAttachment
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
*/
|
20 |
public function init_hooks() {
|
21 |
add_action( 'webpc_convert_attachment', [ $this, 'convert_files_by_attachment' ] );
|
@@ -30,8 +39,7 @@ class ConvertAttachment extends PluginAccessAbstract implements PluginAccessInte
|
|
30 |
* @internal
|
31 |
*/
|
32 |
public function convert_files_by_attachment( int $post_id ) {
|
33 |
-
$attachment = new Attachment();
|
34 |
-
$attachment->set_plugin( $this->get_plugin() );
|
35 |
|
36 |
do_action( 'webpc_convert_paths', $attachment->get_attachment_paths( $post_id ) );
|
37 |
}
|
2 |
|
3 |
namespace WebpConverter\Action;
|
4 |
|
|
|
|
|
5 |
use WebpConverter\HookableInterface;
|
6 |
+
use WebpConverter\PluginData;
|
7 |
use WebpConverter\Conversion\Media\Attachment;
|
8 |
|
9 |
/**
|
10 |
* Initializes conversion of all image sizes for attachment.
|
11 |
*/
|
12 |
+
class ConvertAttachment implements HookableInterface {
|
13 |
|
14 |
/**
|
15 |
+
* @var PluginData .
|
16 |
+
*/
|
17 |
+
private $plugin_data;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* @param PluginData $plugin_data .
|
21 |
+
*/
|
22 |
+
public function __construct( PluginData $plugin_data ) {
|
23 |
+
$this->plugin_data = $plugin_data;
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* {@inheritdoc}
|
28 |
*/
|
29 |
public function init_hooks() {
|
30 |
add_action( 'webpc_convert_attachment', [ $this, 'convert_files_by_attachment' ] );
|
39 |
* @internal
|
40 |
*/
|
41 |
public function convert_files_by_attachment( int $post_id ) {
|
42 |
+
$attachment = new Attachment( $this->plugin_data );
|
|
|
43 |
|
44 |
do_action( 'webpc_convert_paths', $attachment->get_attachment_paths( $post_id ) );
|
45 |
}
|
src/Action/ConvertDir.php
CHANGED
@@ -10,9 +10,7 @@ use WebpConverter\HookableInterface;
|
|
10 |
class ConvertDir implements HookableInterface {
|
11 |
|
12 |
/**
|
13 |
-
*
|
14 |
-
*
|
15 |
-
* @return void
|
16 |
*/
|
17 |
public function init_hooks() {
|
18 |
add_action( 'webpc_convert_dir', [ $this, 'convert_files_by_directory' ], 10, 2 );
|
10 |
class ConvertDir implements HookableInterface {
|
11 |
|
12 |
/**
|
13 |
+
* {@inheritdoc}
|
|
|
|
|
14 |
*/
|
15 |
public function init_hooks() {
|
16 |
add_action( 'webpc_convert_dir', [ $this, 'convert_files_by_directory' ], 10, 2 );
|
src/Action/ConvertPaths.php
CHANGED
@@ -2,20 +2,29 @@
|
|
2 |
|
3 |
namespace WebpConverter\Action;
|
4 |
|
5 |
-
use WebpConverter\PluginAccessAbstract;
|
6 |
-
use WebpConverter\PluginAccessInterface;
|
7 |
use WebpConverter\HookableInterface;
|
|
|
8 |
use WebpConverter\Conversion\Method\MethodIntegrator;
|
9 |
|
10 |
/**
|
11 |
* Initializes conversion of all images in list of paths.
|
12 |
*/
|
13 |
-
class ConvertPaths
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
*/
|
20 |
public function init_hooks() {
|
21 |
add_action( 'webpc_convert_paths', [ $this, 'convert_files_by_paths' ] );
|
@@ -30,9 +39,8 @@ class ConvertPaths extends PluginAccessAbstract implements PluginAccessInterface
|
|
30 |
* @internal
|
31 |
*/
|
32 |
public function convert_files_by_paths( array $paths ) {
|
33 |
-
|
34 |
-
|
35 |
-
$method_integrator->init_conversion( $this->remove_paths_of_excluded_dirs( $paths ) );
|
36 |
}
|
37 |
|
38 |
/**
|
2 |
|
3 |
namespace WebpConverter\Action;
|
4 |
|
|
|
|
|
5 |
use WebpConverter\HookableInterface;
|
6 |
+
use WebpConverter\PluginData;
|
7 |
use WebpConverter\Conversion\Method\MethodIntegrator;
|
8 |
|
9 |
/**
|
10 |
* Initializes conversion of all images in list of paths.
|
11 |
*/
|
12 |
+
class ConvertPaths implements HookableInterface {
|
13 |
|
14 |
/**
|
15 |
+
* @var PluginData .
|
16 |
+
*/
|
17 |
+
private $plugin_data;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* @param PluginData $plugin_data .
|
21 |
+
*/
|
22 |
+
public function __construct( PluginData $plugin_data ) {
|
23 |
+
$this->plugin_data = $plugin_data;
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* {@inheritdoc}
|
28 |
*/
|
29 |
public function init_hooks() {
|
30 |
add_action( 'webpc_convert_paths', [ $this, 'convert_files_by_paths' ] );
|
39 |
* @internal
|
40 |
*/
|
41 |
public function convert_files_by_paths( array $paths ) {
|
42 |
+
( new MethodIntegrator( $this->plugin_data ) )
|
43 |
+
->init_conversion( $this->remove_paths_of_excluded_dirs( $paths ) );
|
|
|
44 |
}
|
45 |
|
46 |
/**
|
src/Action/DeletePaths.php
CHANGED
@@ -12,9 +12,7 @@ use WebpConverter\Conversion\SkipLarger;
|
|
12 |
class DeletePaths implements HookableInterface {
|
13 |
|
14 |
/**
|
15 |
-
*
|
16 |
-
*
|
17 |
-
* @return void
|
18 |
*/
|
19 |
public function init_hooks() {
|
20 |
add_action( 'webpc_delete_paths', [ $this, 'delete_files_by_paths' ] );
|
12 |
class DeletePaths implements HookableInterface {
|
13 |
|
14 |
/**
|
15 |
+
* {@inheritdoc}
|
|
|
|
|
16 |
*/
|
17 |
public function init_hooks() {
|
18 |
add_action( 'webpc_delete_paths', [ $this, 'delete_files_by_paths' ] );
|
src/Action/RegenerateAll.php
CHANGED
@@ -2,20 +2,29 @@
|
|
2 |
|
3 |
namespace WebpConverter\Action;
|
4 |
|
5 |
-
use WebpConverter\PluginAccessAbstract;
|
6 |
-
use WebpConverter\PluginAccessInterface;
|
7 |
use WebpConverter\HookableInterface;
|
|
|
8 |
use WebpConverter\Conversion\Endpoint\PathsEndpoint;
|
9 |
|
10 |
/**
|
11 |
* Initializes conversion of all image sizes in all directories.
|
12 |
*/
|
13 |
-
class RegenerateAll
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
*/
|
20 |
public function init_hooks() {
|
21 |
add_action( 'webpc_regenerate_all', [ $this, 'regenerate_all_images' ] );
|
@@ -28,9 +37,6 @@ class RegenerateAll extends PluginAccessAbstract implements PluginAccessInterfac
|
|
28 |
* @internal
|
29 |
*/
|
30 |
public function regenerate_all_images() {
|
31 |
-
|
32 |
-
$paths_endpoint->set_plugin( $this->get_plugin() );
|
33 |
-
|
34 |
-
do_action( 'webpc_convert_paths', $paths_endpoint->get_paths( true ) );
|
35 |
}
|
36 |
}
|
2 |
|
3 |
namespace WebpConverter\Action;
|
4 |
|
|
|
|
|
5 |
use WebpConverter\HookableInterface;
|
6 |
+
use WebpConverter\PluginData;
|
7 |
use WebpConverter\Conversion\Endpoint\PathsEndpoint;
|
8 |
|
9 |
/**
|
10 |
* Initializes conversion of all image sizes in all directories.
|
11 |
*/
|
12 |
+
class RegenerateAll implements HookableInterface {
|
13 |
|
14 |
/**
|
15 |
+
* @var PluginData .
|
16 |
+
*/
|
17 |
+
private $plugin_data;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* @param PluginData $plugin_data .
|
21 |
+
*/
|
22 |
+
public function __construct( PluginData $plugin_data ) {
|
23 |
+
$this->plugin_data = $plugin_data;
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* {@inheritdoc}
|
28 |
*/
|
29 |
public function init_hooks() {
|
30 |
add_action( 'webpc_regenerate_all', [ $this, 'regenerate_all_images' ] );
|
37 |
* @internal
|
38 |
*/
|
39 |
public function regenerate_all_images() {
|
40 |
+
do_action( 'webpc_convert_paths', ( new PathsEndpoint( $this->plugin_data ) )->get_paths( true ) );
|
|
|
|
|
|
|
41 |
}
|
42 |
}
|
src/Conversion/Cron/Event.php
CHANGED
@@ -2,21 +2,30 @@
|
|
2 |
|
3 |
namespace WebpConverter\Conversion\Cron;
|
4 |
|
5 |
-
use WebpConverter\PluginAccessAbstract;
|
6 |
-
use WebpConverter\PluginAccessInterface;
|
7 |
use WebpConverter\HookableInterface;
|
|
|
8 |
|
9 |
/**
|
10 |
* Adds cron event that converts images.
|
11 |
*/
|
12 |
-
class Event
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
const CRON_ACTION = 'webpc_regenerate_all';
|
15 |
|
16 |
/**
|
17 |
-
*
|
18 |
-
*
|
19 |
-
* @return void
|
20 |
*/
|
21 |
public function init_hooks() {
|
22 |
add_action( 'init', [ $this, 'add_cron_event' ] );
|
@@ -30,7 +39,7 @@ class Event extends PluginAccessAbstract implements PluginAccessInterface, Hooka
|
|
30 |
*/
|
31 |
public function add_cron_event() {
|
32 |
if ( wp_next_scheduled( self::CRON_ACTION )
|
33 |
-
|| ! ( $settings = $this->
|
34 |
|| ! in_array( 'cron_enabled', $settings['features'] ) ) {
|
35 |
return;
|
36 |
}
|
2 |
|
3 |
namespace WebpConverter\Conversion\Cron;
|
4 |
|
|
|
|
|
5 |
use WebpConverter\HookableInterface;
|
6 |
+
use WebpConverter\PluginData;
|
7 |
|
8 |
/**
|
9 |
* Adds cron event that converts images.
|
10 |
*/
|
11 |
+
class Event implements HookableInterface {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @var PluginData .
|
15 |
+
*/
|
16 |
+
private $plugin_data;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @param PluginData $plugin_data .
|
20 |
+
*/
|
21 |
+
public function __construct( PluginData $plugin_data ) {
|
22 |
+
$this->plugin_data = $plugin_data;
|
23 |
+
}
|
24 |
|
25 |
const CRON_ACTION = 'webpc_regenerate_all';
|
26 |
|
27 |
/**
|
28 |
+
* {@inheritdoc}
|
|
|
|
|
29 |
*/
|
30 |
public function init_hooks() {
|
31 |
add_action( 'init', [ $this, 'add_cron_event' ] );
|
39 |
*/
|
40 |
public function add_cron_event() {
|
41 |
if ( wp_next_scheduled( self::CRON_ACTION )
|
42 |
+
|| ! ( $settings = $this->plugin_data->get_plugin_settings() )
|
43 |
|| ! in_array( 'cron_enabled', $settings['features'] ) ) {
|
44 |
return;
|
45 |
}
|
src/Conversion/Cron/Schedules.php
CHANGED
@@ -12,9 +12,7 @@ class Schedules implements HookableInterface {
|
|
12 |
const CRON_SCHEDULE = 'webpc_cron';
|
13 |
|
14 |
/**
|
15 |
-
*
|
16 |
-
*
|
17 |
-
* @return void
|
18 |
*/
|
19 |
public function init_hooks() {
|
20 |
add_filter( 'cron_schedules', [ $this, 'add_cron_interval' ] );
|
12 |
const CRON_SCHEDULE = 'webpc_cron';
|
13 |
|
14 |
/**
|
15 |
+
* {@inheritdoc}
|
|
|
|
|
16 |
*/
|
17 |
public function init_hooks() {
|
18 |
add_filter( 'cron_schedules', [ $this, 'add_cron_interval' ] );
|
src/Conversion/Directory/DirectoryAbstract.php
CHANGED
@@ -8,36 +8,28 @@ namespace WebpConverter\Conversion\Directory;
|
|
8 |
abstract class DirectoryAbstract implements DirectoryInterface {
|
9 |
|
10 |
/**
|
11 |
-
*
|
12 |
-
*
|
13 |
-
* @return string Directory label.
|
14 |
*/
|
15 |
public function get_label(): string {
|
16 |
return '';
|
17 |
}
|
18 |
|
19 |
/**
|
20 |
-
*
|
21 |
-
*
|
22 |
-
* @return bool Directory is available?
|
23 |
*/
|
24 |
public function is_available(): bool {
|
25 |
return ( file_exists( $this->get_server_path() ) );
|
26 |
}
|
27 |
|
28 |
/**
|
29 |
-
*
|
30 |
-
*
|
31 |
-
* @return bool Directory for output?
|
32 |
*/
|
33 |
public function is_output_directory(): bool {
|
34 |
return false;
|
35 |
}
|
36 |
|
37 |
/**
|
38 |
-
*
|
39 |
-
*
|
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 ) );
|
@@ -46,9 +38,7 @@ abstract class DirectoryAbstract implements DirectoryInterface {
|
|
46 |
}
|
47 |
|
48 |
/**
|
49 |
-
*
|
50 |
-
*
|
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() );
|
8 |
abstract class DirectoryAbstract implements DirectoryInterface {
|
9 |
|
10 |
/**
|
11 |
+
* {@inheritdoc}
|
|
|
|
|
12 |
*/
|
13 |
public function get_label(): string {
|
14 |
return '';
|
15 |
}
|
16 |
|
17 |
/**
|
18 |
+
* {@inheritdoc}
|
|
|
|
|
19 |
*/
|
20 |
public function is_available(): bool {
|
21 |
return ( file_exists( $this->get_server_path() ) );
|
22 |
}
|
23 |
|
24 |
/**
|
25 |
+
* {@inheritdoc}
|
|
|
|
|
26 |
*/
|
27 |
public function is_output_directory(): bool {
|
28 |
return false;
|
29 |
}
|
30 |
|
31 |
/**
|
32 |
+
* {@inheritdoc}
|
|
|
|
|
33 |
*/
|
34 |
public function get_server_path(): string {
|
35 |
$source_path = apply_filters( 'webpc_site_root', realpath( ABSPATH ) );
|
38 |
}
|
39 |
|
40 |
/**
|
41 |
+
* {@inheritdoc}
|
|
|
|
|
42 |
*/
|
43 |
public function get_path_url(): string {
|
44 |
$source_url = apply_filters( 'webpc_site_url', get_site_url() );
|
src/Conversion/Directory/DirectoryFactory.php
CHANGED
@@ -17,9 +17,6 @@ class DirectoryFactory implements HookableInterface {
|
|
17 |
*/
|
18 |
private $directories_integration;
|
19 |
|
20 |
-
/**
|
21 |
-
* Directories constructor.
|
22 |
-
*/
|
23 |
public function __construct() {
|
24 |
$this->set_integration( new GalleryDirectory() );
|
25 |
$this->set_integration( new PluginsDirectory() );
|
@@ -43,9 +40,7 @@ class DirectoryFactory implements HookableInterface {
|
|
43 |
}
|
44 |
|
45 |
/**
|
46 |
-
*
|
47 |
-
*
|
48 |
-
* @return void
|
49 |
*/
|
50 |
public function init_hooks() {
|
51 |
$this->directories_integration->init_hooks();
|
17 |
*/
|
18 |
private $directories_integration;
|
19 |
|
|
|
|
|
|
|
20 |
public function __construct() {
|
21 |
$this->set_integration( new GalleryDirectory() );
|
22 |
$this->set_integration( new PluginsDirectory() );
|
40 |
}
|
41 |
|
42 |
/**
|
43 |
+
* {@inheritdoc}
|
|
|
|
|
44 |
*/
|
45 |
public function init_hooks() {
|
46 |
$this->directories_integration->init_hooks();
|
src/Conversion/Directory/DirectoryIntegration.php
CHANGED
@@ -20,9 +20,7 @@ class DirectoryIntegration implements HookableInterface {
|
|
20 |
private $directories = [];
|
21 |
|
22 |
/**
|
23 |
-
*
|
24 |
-
*
|
25 |
-
* @return void
|
26 |
*/
|
27 |
public function init_hooks() {
|
28 |
add_filter( 'webpc_dir_name', [ $this, 'get_dir_as_name' ], 0, 2 );
|
20 |
private $directories = [];
|
21 |
|
22 |
/**
|
23 |
+
* {@inheritdoc}
|
|
|
|
|
24 |
*/
|
25 |
public function init_hooks() {
|
26 |
add_filter( 'webpc_dir_name', [ $this, 'get_dir_as_name' ], 0, 2 );
|
src/Conversion/Directory/GalleryDirectory.php
CHANGED
@@ -5,33 +5,27 @@ namespace WebpConverter\Conversion\Directory;
|
|
5 |
/**
|
6 |
* Supports data about /gallery directory.
|
7 |
*/
|
8 |
-
class GalleryDirectory extends DirectoryAbstract
|
9 |
|
10 |
const DIRECTORY_TYPE = 'gallery';
|
11 |
const DIRECTORY_PATH = 'wp-content/gallery';
|
12 |
|
13 |
/**
|
14 |
-
*
|
15 |
-
*
|
16 |
-
* @return string Directory type.
|
17 |
*/
|
18 |
public function get_type(): string {
|
19 |
return self::DIRECTORY_TYPE;
|
20 |
}
|
21 |
|
22 |
/**
|
23 |
-
*
|
24 |
-
*
|
25 |
-
* @return string Directory label.
|
26 |
*/
|
27 |
public function get_label(): string {
|
28 |
return '/' . self::DIRECTORY_TYPE;
|
29 |
}
|
30 |
|
31 |
/**
|
32 |
-
*
|
33 |
-
*
|
34 |
-
* @return string Relative path of directory.
|
35 |
*/
|
36 |
public function get_relative_path(): string {
|
37 |
return self::DIRECTORY_PATH;
|
5 |
/**
|
6 |
* Supports data about /gallery directory.
|
7 |
*/
|
8 |
+
class GalleryDirectory extends DirectoryAbstract {
|
9 |
|
10 |
const DIRECTORY_TYPE = 'gallery';
|
11 |
const DIRECTORY_PATH = 'wp-content/gallery';
|
12 |
|
13 |
/**
|
14 |
+
* {@inheritdoc}
|
|
|
|
|
15 |
*/
|
16 |
public function get_type(): string {
|
17 |
return self::DIRECTORY_TYPE;
|
18 |
}
|
19 |
|
20 |
/**
|
21 |
+
* {@inheritdoc}
|
|
|
|
|
22 |
*/
|
23 |
public function get_label(): string {
|
24 |
return '/' . self::DIRECTORY_TYPE;
|
25 |
}
|
26 |
|
27 |
/**
|
28 |
+
* {@inheritdoc}
|
|
|
|
|
29 |
*/
|
30 |
public function get_relative_path(): string {
|
31 |
return self::DIRECTORY_PATH;
|
src/Conversion/Directory/PluginsDirectory.php
CHANGED
@@ -5,33 +5,27 @@ namespace WebpConverter\Conversion\Directory;
|
|
5 |
/**
|
6 |
* Supports data about /plugins directory.
|
7 |
*/
|
8 |
-
class PluginsDirectory extends DirectoryAbstract
|
9 |
|
10 |
const DIRECTORY_TYPE = 'plugins';
|
11 |
const DIRECTORY_PATH = 'wp-content/plugins';
|
12 |
|
13 |
/**
|
14 |
-
*
|
15 |
-
*
|
16 |
-
* @return string Directory type.
|
17 |
*/
|
18 |
public function get_type(): string {
|
19 |
return self::DIRECTORY_TYPE;
|
20 |
}
|
21 |
|
22 |
/**
|
23 |
-
*
|
24 |
-
*
|
25 |
-
* @return string Directory label.
|
26 |
*/
|
27 |
public function get_label(): string {
|
28 |
return '/' . self::DIRECTORY_TYPE;
|
29 |
}
|
30 |
|
31 |
/**
|
32 |
-
*
|
33 |
-
*
|
34 |
-
* @return string Relative path of directory.
|
35 |
*/
|
36 |
public function get_relative_path(): string {
|
37 |
return self::DIRECTORY_PATH;
|
5 |
/**
|
6 |
* Supports data about /plugins directory.
|
7 |
*/
|
8 |
+
class PluginsDirectory extends DirectoryAbstract {
|
9 |
|
10 |
const DIRECTORY_TYPE = 'plugins';
|
11 |
const DIRECTORY_PATH = 'wp-content/plugins';
|
12 |
|
13 |
/**
|
14 |
+
* {@inheritdoc}
|
|
|
|
|
15 |
*/
|
16 |
public function get_type(): string {
|
17 |
return self::DIRECTORY_TYPE;
|
18 |
}
|
19 |
|
20 |
/**
|
21 |
+
* {@inheritdoc}
|
|
|
|
|
22 |
*/
|
23 |
public function get_label(): string {
|
24 |
return '/' . self::DIRECTORY_TYPE;
|
25 |
}
|
26 |
|
27 |
/**
|
28 |
+
* {@inheritdoc}
|
|
|
|
|
29 |
*/
|
30 |
public function get_relative_path(): string {
|
31 |
return self::DIRECTORY_PATH;
|
src/Conversion/Directory/ThemesDirectory.php
CHANGED
@@ -5,33 +5,27 @@ namespace WebpConverter\Conversion\Directory;
|
|
5 |
/**
|
6 |
* Supports data about /themes directory.
|
7 |
*/
|
8 |
-
class ThemesDirectory extends DirectoryAbstract
|
9 |
|
10 |
const DIRECTORY_TYPE = 'themes';
|
11 |
const DIRECTORY_PATH = 'wp-content/themes';
|
12 |
|
13 |
/**
|
14 |
-
*
|
15 |
-
*
|
16 |
-
* @return string Directory type.
|
17 |
*/
|
18 |
public function get_type(): string {
|
19 |
return self::DIRECTORY_TYPE;
|
20 |
}
|
21 |
|
22 |
/**
|
23 |
-
*
|
24 |
-
*
|
25 |
-
* @return string Directory label.
|
26 |
*/
|
27 |
public function get_label(): string {
|
28 |
return '/' . self::DIRECTORY_TYPE;
|
29 |
}
|
30 |
|
31 |
/**
|
32 |
-
*
|
33 |
-
*
|
34 |
-
* @return string Relative path of directory.
|
35 |
*/
|
36 |
public function get_relative_path(): string {
|
37 |
return self::DIRECTORY_PATH;
|
5 |
/**
|
6 |
* Supports data about /themes directory.
|
7 |
*/
|
8 |
+
class ThemesDirectory extends DirectoryAbstract {
|
9 |
|
10 |
const DIRECTORY_TYPE = 'themes';
|
11 |
const DIRECTORY_PATH = 'wp-content/themes';
|
12 |
|
13 |
/**
|
14 |
+
* {@inheritdoc}
|
|
|
|
|
15 |
*/
|
16 |
public function get_type(): string {
|
17 |
return self::DIRECTORY_TYPE;
|
18 |
}
|
19 |
|
20 |
/**
|
21 |
+
* {@inheritdoc}
|
|
|
|
|
22 |
*/
|
23 |
public function get_label(): string {
|
24 |
return '/' . self::DIRECTORY_TYPE;
|
25 |
}
|
26 |
|
27 |
/**
|
28 |
+
* {@inheritdoc}
|
|
|
|
|
29 |
*/
|
30 |
public function get_relative_path(): string {
|
31 |
return self::DIRECTORY_PATH;
|
src/Conversion/Directory/UploadsDirectory.php
CHANGED
@@ -5,42 +5,34 @@ namespace WebpConverter\Conversion\Directory;
|
|
5 |
/**
|
6 |
* Supports data about /uploads directory.
|
7 |
*/
|
8 |
-
class UploadsDirectory extends DirectoryAbstract
|
9 |
|
10 |
const DIRECTORY_TYPE = 'uploads';
|
11 |
const DIRECTORY_PATH = 'wp-content/uploads';
|
12 |
|
13 |
/**
|
14 |
-
*
|
15 |
-
*
|
16 |
-
* @return string Directory type.
|
17 |
*/
|
18 |
public function get_type(): string {
|
19 |
return self::DIRECTORY_TYPE;
|
20 |
}
|
21 |
|
22 |
/**
|
23 |
-
*
|
24 |
-
*
|
25 |
-
* @return bool Directory is available?
|
26 |
*/
|
27 |
public function is_available(): bool {
|
28 |
return true;
|
29 |
}
|
30 |
|
31 |
/**
|
32 |
-
*
|
33 |
-
*
|
34 |
-
* @return string Directory label.
|
35 |
*/
|
36 |
public function get_label(): string {
|
37 |
return '/' . self::DIRECTORY_TYPE;
|
38 |
}
|
39 |
|
40 |
/**
|
41 |
-
*
|
42 |
-
*
|
43 |
-
* @return string Relative path of directory.
|
44 |
*/
|
45 |
public function get_relative_path(): string {
|
46 |
return self::DIRECTORY_PATH;
|
5 |
/**
|
6 |
* Supports data about /uploads directory.
|
7 |
*/
|
8 |
+
class UploadsDirectory extends DirectoryAbstract {
|
9 |
|
10 |
const DIRECTORY_TYPE = 'uploads';
|
11 |
const DIRECTORY_PATH = 'wp-content/uploads';
|
12 |
|
13 |
/**
|
14 |
+
* {@inheritdoc}
|
|
|
|
|
15 |
*/
|
16 |
public function get_type(): string {
|
17 |
return self::DIRECTORY_TYPE;
|
18 |
}
|
19 |
|
20 |
/**
|
21 |
+
* {@inheritdoc}
|
|
|
|
|
22 |
*/
|
23 |
public function is_available(): bool {
|
24 |
return true;
|
25 |
}
|
26 |
|
27 |
/**
|
28 |
+
* {@inheritdoc}
|
|
|
|
|
29 |
*/
|
30 |
public function get_label(): string {
|
31 |
return '/' . self::DIRECTORY_TYPE;
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* {@inheritdoc}
|
|
|
|
|
36 |
*/
|
37 |
public function get_relative_path(): string {
|
38 |
return self::DIRECTORY_PATH;
|
src/Conversion/Directory/UploadsWebpcDirectory.php
CHANGED
@@ -5,42 +5,34 @@ namespace WebpConverter\Conversion\Directory;
|
|
5 |
/**
|
6 |
* Supports data about /uploads-webpc directory.
|
7 |
*/
|
8 |
-
class UploadsWebpcDirectory extends DirectoryAbstract
|
9 |
|
10 |
const DIRECTORY_TYPE = 'webp';
|
11 |
const DIRECTORY_PATH = 'wp-content/uploads-webpc';
|
12 |
|
13 |
/**
|
14 |
-
*
|
15 |
-
*
|
16 |
-
* @return string Directory type.
|
17 |
*/
|
18 |
public function get_type(): string {
|
19 |
return self::DIRECTORY_TYPE;
|
20 |
}
|
21 |
|
22 |
/**
|
23 |
-
*
|
24 |
-
*
|
25 |
-
* @return bool Directory is available?
|
26 |
*/
|
27 |
public function is_available(): bool {
|
28 |
return true;
|
29 |
}
|
30 |
|
31 |
/**
|
32 |
-
*
|
33 |
-
*
|
34 |
-
* @return bool Directory for output?
|
35 |
*/
|
36 |
public function is_output_directory(): bool {
|
37 |
return true;
|
38 |
}
|
39 |
|
40 |
/**
|
41 |
-
*
|
42 |
-
*
|
43 |
-
* @return string Relative path of directory.
|
44 |
*/
|
45 |
public function get_relative_path(): string {
|
46 |
return self::DIRECTORY_PATH;
|
5 |
/**
|
6 |
* Supports data about /uploads-webpc directory.
|
7 |
*/
|
8 |
+
class UploadsWebpcDirectory extends DirectoryAbstract {
|
9 |
|
10 |
const DIRECTORY_TYPE = 'webp';
|
11 |
const DIRECTORY_PATH = 'wp-content/uploads-webpc';
|
12 |
|
13 |
/**
|
14 |
+
* {@inheritdoc}
|
|
|
|
|
15 |
*/
|
16 |
public function get_type(): string {
|
17 |
return self::DIRECTORY_TYPE;
|
18 |
}
|
19 |
|
20 |
/**
|
21 |
+
* {@inheritdoc}
|
|
|
|
|
22 |
*/
|
23 |
public function is_available(): bool {
|
24 |
return true;
|
25 |
}
|
26 |
|
27 |
/**
|
28 |
+
* {@inheritdoc}
|
|
|
|
|
29 |
*/
|
30 |
public function is_output_directory(): bool {
|
31 |
return true;
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* {@inheritdoc}
|
|
|
|
|
36 |
*/
|
37 |
public function get_relative_path(): string {
|
38 |
return self::DIRECTORY_PATH;
|
src/Conversion/DirectoryFiles.php
CHANGED
@@ -2,19 +2,28 @@
|
|
2 |
|
3 |
namespace WebpConverter\Conversion;
|
4 |
|
5 |
-
use WebpConverter\PluginAccessAbstract;
|
6 |
-
use WebpConverter\PluginAccessInterface;
|
7 |
use WebpConverter\HookableInterface;
|
|
|
8 |
|
9 |
/**
|
10 |
* Returns paths to files in given directory.
|
11 |
*/
|
12 |
-
class DirectoryFiles
|
13 |
|
14 |
/**
|
15 |
-
*
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
*/
|
19 |
public function init_hooks() {
|
20 |
add_filter( 'webpc_dir_files', [ $this, 'get_files_by_directory' ], 10, 3 );
|
@@ -35,7 +44,7 @@ class DirectoryFiles extends PluginAccessAbstract implements PluginAccessInterfa
|
|
35 |
return $value;
|
36 |
}
|
37 |
|
38 |
-
$settings = $this->
|
39 |
$excluded = apply_filters( 'webpc_dir_excluded', [] );
|
40 |
|
41 |
$paths = $this->find_files_in_directory( $dir_path, $settings['extensions'], $excluded );
|
2 |
|
3 |
namespace WebpConverter\Conversion;
|
4 |
|
|
|
|
|
5 |
use WebpConverter\HookableInterface;
|
6 |
+
use WebpConverter\PluginData;
|
7 |
|
8 |
/**
|
9 |
* Returns paths to files in given directory.
|
10 |
*/
|
11 |
+
class DirectoryFiles implements HookableInterface {
|
12 |
|
13 |
/**
|
14 |
+
* @var PluginData .
|
15 |
+
*/
|
16 |
+
private $plugin_data;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @param PluginData $plugin_data .
|
20 |
+
*/
|
21 |
+
public function __construct( PluginData $plugin_data ) {
|
22 |
+
$this->plugin_data = $plugin_data;
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* {@inheritdoc}
|
27 |
*/
|
28 |
public function init_hooks() {
|
29 |
add_filter( 'webpc_dir_files', [ $this, 'get_files_by_directory' ], 10, 3 );
|
44 |
return $value;
|
45 |
}
|
46 |
|
47 |
+
$settings = $this->plugin_data->get_plugin_settings();
|
48 |
$excluded = apply_filters( 'webpc_dir_excluded', [] );
|
49 |
|
50 |
$paths = $this->find_files_in_directory( $dir_path, $settings['extensions'], $excluded );
|
src/Conversion/Endpoint/EndpointAbstract.php
CHANGED
@@ -2,27 +2,34 @@
|
|
2 |
|
3 |
namespace WebpConverter\Conversion\Endpoint;
|
4 |
|
5 |
-
use WebpConverter\
|
6 |
-
use WebpConverter\PluginAccessInterface;
|
7 |
|
8 |
/**
|
9 |
* Abstract class for class that supports image conversion method.
|
10 |
*/
|
11 |
-
abstract class EndpointAbstract
|
12 |
|
13 |
/**
|
14 |
-
*
|
15 |
-
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
*/
|
18 |
public function get_route_args(): array {
|
19 |
return [];
|
20 |
}
|
21 |
|
22 |
/**
|
23 |
-
*
|
24 |
-
*
|
25 |
-
* @return string Endpoint URL.
|
26 |
*/
|
27 |
public function get_route_url(): string {
|
28 |
return get_rest_url(
|
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 |
+
/**
|
18 |
+
* @param PluginData $plugin_data .
|
19 |
+
*/
|
20 |
+
public function __construct( PluginData $plugin_data ) {
|
21 |
+
$this->plugin_data = $plugin_data;
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* {@inheritdoc}
|
26 |
*/
|
27 |
public function get_route_args(): array {
|
28 |
return [];
|
29 |
}
|
30 |
|
31 |
/**
|
32 |
+
* {@inheritdoc}
|
|
|
|
|
33 |
*/
|
34 |
public function get_route_url(): string {
|
35 |
return get_rest_url(
|
src/Conversion/Endpoint/EndpointFactory.php
DELETED
@@ -1,35 +0,0 @@
|
|
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.
|
16 |
-
*
|
17 |
-
* @return void
|
18 |
-
*/
|
19 |
-
public function init_hooks() {
|
20 |
-
$this->set_integration( new PathsEndpoint() );
|
21 |
-
$this->set_integration( new RegenerateEndpoint() );
|
22 |
-
}
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Sets integration for endpoint.
|
26 |
-
*
|
27 |
-
* @param EndpointInterface $endpoint .
|
28 |
-
*
|
29 |
-
* @return void
|
30 |
-
*/
|
31 |
-
private function set_integration( EndpointInterface $endpoint ) {
|
32 |
-
$endpoint->set_plugin( $this->get_plugin() );
|
33 |
-
( new EndpointIntegration( $endpoint ) )->init_hooks();
|
34 |
-
}
|
35 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/Conversion/Endpoint/EndpointIntegration.php
CHANGED
@@ -19,8 +19,6 @@ class EndpointIntegration implements HookableInterface {
|
|
19 |
private $endpoint_object;
|
20 |
|
21 |
/**
|
22 |
-
* EndpointIntegration constructor.
|
23 |
-
*
|
24 |
* @param EndpointInterface $endpoint_object .
|
25 |
*/
|
26 |
public function __construct( EndpointInterface $endpoint_object ) {
|
@@ -28,9 +26,7 @@ class EndpointIntegration implements HookableInterface {
|
|
28 |
}
|
29 |
|
30 |
/**
|
31 |
-
*
|
32 |
-
*
|
33 |
-
* @return void
|
34 |
*/
|
35 |
public function init_hooks() {
|
36 |
add_action( 'rest_api_init', [ $this, 'register_rest_route' ] );
|
19 |
private $endpoint_object;
|
20 |
|
21 |
/**
|
|
|
|
|
22 |
* @param EndpointInterface $endpoint_object .
|
23 |
*/
|
24 |
public function __construct( EndpointInterface $endpoint_object ) {
|
26 |
}
|
27 |
|
28 |
/**
|
29 |
+
* {@inheritdoc}
|
|
|
|
|
30 |
*/
|
31 |
public function init_hooks() {
|
32 |
add_action( 'rest_api_init', [ $this, 'register_rest_route' ] );
|
src/Conversion/Endpoint/EndpointInterface.php
CHANGED
@@ -2,12 +2,10 @@
|
|
2 |
|
3 |
namespace WebpConverter\Conversion\Endpoint;
|
4 |
|
5 |
-
use WebpConverter\PluginAccessInterface;
|
6 |
-
|
7 |
/**
|
8 |
* Interface for class that supports endpoint.
|
9 |
*/
|
10 |
-
interface EndpointInterface
|
11 |
|
12 |
/**
|
13 |
* Returns route of endpoint.
|
2 |
|
3 |
namespace WebpConverter\Conversion\Endpoint;
|
4 |
|
|
|
|
|
5 |
/**
|
6 |
* Interface for class that supports endpoint.
|
7 |
*/
|
8 |
+
interface EndpointInterface {
|
9 |
|
10 |
/**
|
11 |
* Returns route of endpoint.
|
src/Conversion/Endpoint/PathsEndpoint.php
CHANGED
@@ -5,23 +5,19 @@ namespace WebpConverter\Conversion\Endpoint;
|
|
5 |
/**
|
6 |
* Supports endpoint to get list of image paths to be converted.
|
7 |
*/
|
8 |
-
class PathsEndpoint extends EndpointAbstract
|
9 |
|
10 |
const PATHS_PER_REQUEST = 10;
|
11 |
|
12 |
/**
|
13 |
-
*
|
14 |
-
*
|
15 |
-
* @return string Endpoint route.
|
16 |
*/
|
17 |
public function get_route_name(): string {
|
18 |
return 'paths';
|
19 |
}
|
20 |
|
21 |
/**
|
22 |
-
*
|
23 |
-
*
|
24 |
-
* @return array[] Params of endpoint.
|
25 |
*/
|
26 |
public function get_route_args(): array {
|
27 |
return [
|
@@ -64,7 +60,7 @@ class PathsEndpoint extends EndpointAbstract implements EndpointInterface {
|
|
64 |
* @return array[] Server paths of source images.
|
65 |
*/
|
66 |
public function get_paths( bool $skip_exists = false, int $chunk_size = 0 ): array {
|
67 |
-
$settings = $this->
|
68 |
$dirs = array_filter(
|
69 |
array_map(
|
70 |
function ( $dir_name ) {
|
5 |
/**
|
6 |
* Supports endpoint to get list of image paths to be converted.
|
7 |
*/
|
8 |
+
class PathsEndpoint extends EndpointAbstract {
|
9 |
|
10 |
const PATHS_PER_REQUEST = 10;
|
11 |
|
12 |
/**
|
13 |
+
* {@inheritdoc}
|
|
|
|
|
14 |
*/
|
15 |
public function get_route_name(): string {
|
16 |
return 'paths';
|
17 |
}
|
18 |
|
19 |
/**
|
20 |
+
* {@inheritdoc}
|
|
|
|
|
21 |
*/
|
22 |
public function get_route_args(): array {
|
23 |
return [
|
60 |
* @return array[] Server paths of source images.
|
61 |
*/
|
62 |
public function get_paths( bool $skip_exists = false, int $chunk_size = 0 ): array {
|
63 |
+
$settings = $this->plugin_data->get_plugin_settings();
|
64 |
$dirs = array_filter(
|
65 |
array_map(
|
66 |
function ( $dir_name ) {
|
src/Conversion/Endpoint/RegenerateEndpoint.php
CHANGED
@@ -7,21 +7,17 @@ use WebpConverter\Conversion\Method\MethodIntegrator;
|
|
7 |
/**
|
8 |
* Supports endpoint for converting list of paths to images.
|
9 |
*/
|
10 |
-
class RegenerateEndpoint extends EndpointAbstract
|
11 |
|
12 |
/**
|
13 |
-
*
|
14 |
-
*
|
15 |
-
* @return string Endpoint route.
|
16 |
*/
|
17 |
public function get_route_name(): string {
|
18 |
return 'regenerate';
|
19 |
}
|
20 |
|
21 |
/**
|
22 |
-
*
|
23 |
-
*
|
24 |
-
* @return array[] Params of endpoint.
|
25 |
*/
|
26 |
public function get_route_args(): array {
|
27 |
return [
|
@@ -37,12 +33,7 @@ class RegenerateEndpoint extends EndpointAbstract implements EndpointInterface {
|
|
37 |
}
|
38 |
|
39 |
/**
|
40 |
-
*
|
41 |
-
*
|
42 |
-
* @param \WP_REST_Request $request REST request object.
|
43 |
-
*
|
44 |
-
* @return \WP_REST_Response|\WP_Error REST response object or WordPress Error object.
|
45 |
-
* @internal
|
46 |
*/
|
47 |
public function get_route_response( \WP_REST_Request $request ) {
|
48 |
$params = $request->get_params();
|
@@ -71,10 +62,7 @@ class RegenerateEndpoint extends EndpointAbstract implements EndpointInterface {
|
|
71 |
* @return array[]|false Status of conversion.
|
72 |
*/
|
73 |
public function convert_images( array $paths ) {
|
74 |
-
$
|
75 |
-
$method_integrator->set_plugin( $this->get_plugin() );
|
76 |
-
|
77 |
-
$response = $method_integrator->init_conversion( $paths );
|
78 |
if ( $response === null ) {
|
79 |
return false;
|
80 |
}
|
7 |
/**
|
8 |
* Supports endpoint for converting list of paths to images.
|
9 |
*/
|
10 |
+
class RegenerateEndpoint extends EndpointAbstract {
|
11 |
|
12 |
/**
|
13 |
+
* {@inheritdoc}
|
|
|
|
|
14 |
*/
|
15 |
public function get_route_name(): string {
|
16 |
return 'regenerate';
|
17 |
}
|
18 |
|
19 |
/**
|
20 |
+
* {@inheritdoc}
|
|
|
|
|
21 |
*/
|
22 |
public function get_route_args(): array {
|
23 |
return [
|
33 |
}
|
34 |
|
35 |
/**
|
36 |
+
* {@inheritdoc}
|
|
|
|
|
|
|
|
|
|
|
37 |
*/
|
38 |
public function get_route_response( \WP_REST_Request $request ) {
|
39 |
$params = $request->get_params();
|
62 |
* @return array[]|false Status of conversion.
|
63 |
*/
|
64 |
public function convert_images( array $paths ) {
|
65 |
+
$response = ( new MethodIntegrator( $this->plugin_data ) )->init_conversion( $paths );
|
|
|
|
|
|
|
66 |
if ( $response === null ) {
|
67 |
return false;
|
68 |
}
|
src/Conversion/Exception/ConversionErrorException.php
CHANGED
@@ -5,26 +5,20 @@ namespace WebpConverter\Conversion\Exception;
|
|
5 |
/**
|
6 |
* Handles "convert_error" exception when converting images.
|
7 |
*/
|
8 |
-
class ConversionErrorException extends ExceptionAbstract
|
9 |
|
10 |
const ERROR_MESSAGE = 'Error occurred while converting image: "%s".';
|
11 |
const ERROR_CODE = 'convert_error';
|
12 |
|
13 |
/**
|
14 |
-
*
|
15 |
-
*
|
16 |
-
* @param string[] $values Params from class constructor.
|
17 |
-
*
|
18 |
-
* @return string Error message.
|
19 |
*/
|
20 |
public function get_error_message( array $values ): string {
|
21 |
return sprintf( self::ERROR_MESSAGE, $values[0] );
|
22 |
}
|
23 |
|
24 |
/**
|
25 |
-
*
|
26 |
-
*
|
27 |
-
* @return string Error status.
|
28 |
*/
|
29 |
public function get_error_status(): string {
|
30 |
return self::ERROR_CODE;
|
5 |
/**
|
6 |
* Handles "convert_error" exception when converting images.
|
7 |
*/
|
8 |
+
class ConversionErrorException extends ExceptionAbstract {
|
9 |
|
10 |
const ERROR_MESSAGE = 'Error occurred while converting image: "%s".';
|
11 |
const ERROR_CODE = 'convert_error';
|
12 |
|
13 |
/**
|
14 |
+
* {@inheritdoc}
|
|
|
|
|
|
|
|
|
15 |
*/
|
16 |
public function get_error_message( array $values ): string {
|
17 |
return sprintf( self::ERROR_MESSAGE, $values[0] );
|
18 |
}
|
19 |
|
20 |
/**
|
21 |
+
* {@inheritdoc}
|
|
|
|
|
22 |
*/
|
23 |
public function get_error_status(): string {
|
24 |
return self::ERROR_CODE;
|
src/Conversion/Exception/ExceptionAbstract.php
CHANGED
@@ -8,9 +8,7 @@ namespace WebpConverter\Conversion\Exception;
|
|
8 |
abstract class ExceptionAbstract extends \Exception implements ExceptionInterface {
|
9 |
|
10 |
/**
|
11 |
-
*
|
12 |
-
*
|
13 |
-
* @param string[]|string $value Params of exception.
|
14 |
*/
|
15 |
final public function __construct( $value = [] ) {
|
16 |
$this->code = $this->get_error_status();
|
8 |
abstract class ExceptionAbstract extends \Exception implements ExceptionInterface {
|
9 |
|
10 |
/**
|
11 |
+
* {@inheritdoc}
|
|
|
|
|
12 |
*/
|
13 |
final public function __construct( $value = [] ) {
|
14 |
$this->code = $this->get_error_status();
|
src/Conversion/Exception/ExceptionInterface.php
CHANGED
@@ -8,8 +8,6 @@ namespace WebpConverter\Conversion\Exception;
|
|
8 |
interface ExceptionInterface {
|
9 |
|
10 |
/**
|
11 |
-
* ExceptionInterface constructor.
|
12 |
-
*
|
13 |
* @param string[]|string $value Params of exception.
|
14 |
*/
|
15 |
public function __construct( $value = [] );
|
8 |
interface ExceptionInterface {
|
9 |
|
10 |
/**
|
|
|
|
|
11 |
* @param string[]|string $value Params of exception.
|
12 |
*/
|
13 |
public function __construct( $value = [] );
|
src/Conversion/Exception/ExtensionUnsupportedException.php
CHANGED
@@ -5,26 +5,20 @@ namespace WebpConverter\Conversion\Exception;
|
|
5 |
/**
|
6 |
* Handles "unsupported_extension" exception when converting images.
|
7 |
*/
|
8 |
-
class ExtensionUnsupportedException extends ExceptionAbstract
|
9 |
|
10 |
const ERROR_MESSAGE = 'Unsupported extension "%s" for file "%s".';
|
11 |
const ERROR_CODE = 'unsupported_extension';
|
12 |
|
13 |
/**
|
14 |
-
*
|
15 |
-
*
|
16 |
-
* @param string[] $values Params from class constructor.
|
17 |
-
*
|
18 |
-
* @return string Error message.
|
19 |
*/
|
20 |
public function get_error_message( array $values ): string {
|
21 |
return sprintf( self::ERROR_MESSAGE, $values[0], $values[1] );
|
22 |
}
|
23 |
|
24 |
/**
|
25 |
-
*
|
26 |
-
*
|
27 |
-
* @return string Error status.
|
28 |
*/
|
29 |
public function get_error_status(): string {
|
30 |
return self::ERROR_CODE;
|
5 |
/**
|
6 |
* Handles "unsupported_extension" exception when converting images.
|
7 |
*/
|
8 |
+
class ExtensionUnsupportedException extends ExceptionAbstract {
|
9 |
|
10 |
const ERROR_MESSAGE = 'Unsupported extension "%s" for file "%s".';
|
11 |
const ERROR_CODE = 'unsupported_extension';
|
12 |
|
13 |
/**
|
14 |
+
* {@inheritdoc}
|
|
|
|
|
|
|
|
|
15 |
*/
|
16 |
public function get_error_message( array $values ): string {
|
17 |
return sprintf( self::ERROR_MESSAGE, $values[0], $values[1] );
|
18 |
}
|
19 |
|
20 |
/**
|
21 |
+
* {@inheritdoc}
|
|
|
|
|
22 |
*/
|
23 |
public function get_error_status(): string {
|
24 |
return self::ERROR_CODE;
|
src/Conversion/Exception/FunctionUnavailableException.php
CHANGED
@@ -5,26 +5,20 @@ namespace WebpConverter\Conversion\Exception;
|
|
5 |
/**
|
6 |
* Handles "server_configuration" exception when converting images.
|
7 |
*/
|
8 |
-
class FunctionUnavailableException extends ExceptionAbstract
|
9 |
|
10 |
const ERROR_MESSAGE = 'Server configuration: "%s" function is not available.';
|
11 |
const ERROR_CODE = 'server_configuration';
|
12 |
|
13 |
/**
|
14 |
-
*
|
15 |
-
*
|
16 |
-
* @param string[] $values Params from class constructor.
|
17 |
-
*
|
18 |
-
* @return string Error message.
|
19 |
*/
|
20 |
public function get_error_message( array $values ): string {
|
21 |
return sprintf( self::ERROR_MESSAGE, $values[0] );
|
22 |
}
|
23 |
|
24 |
/**
|
25 |
-
*
|
26 |
-
*
|
27 |
-
* @return string Error status.
|
28 |
*/
|
29 |
public function get_error_status(): string {
|
30 |
return self::ERROR_CODE;
|
5 |
/**
|
6 |
* Handles "server_configuration" exception when converting images.
|
7 |
*/
|
8 |
+
class FunctionUnavailableException extends ExceptionAbstract {
|
9 |
|
10 |
const ERROR_MESSAGE = 'Server configuration: "%s" function is not available.';
|
11 |
const ERROR_CODE = 'server_configuration';
|
12 |
|
13 |
/**
|
14 |
+
* {@inheritdoc}
|
|
|
|
|
|
|
|
|
15 |
*/
|
16 |
public function get_error_message( array $values ): string {
|
17 |
return sprintf( self::ERROR_MESSAGE, $values[0] );
|
18 |
}
|
19 |
|
20 |
/**
|
21 |
+
* {@inheritdoc}
|
|
|
|
|
22 |
*/
|
23 |
public function get_error_status(): string {
|
24 |
return self::ERROR_CODE;
|
src/Conversion/Exception/ImageInvalidException.php
CHANGED
@@ -5,26 +5,20 @@ namespace WebpConverter\Conversion\Exception;
|
|
5 |
/**
|
6 |
* Handles "invalid_image" exception when converting images.
|
7 |
*/
|
8 |
-
class ImageInvalidException extends ExceptionAbstract
|
9 |
|
10 |
const ERROR_MESSAGE = '"%s" is not a valid image file.';
|
11 |
const ERROR_CODE = 'invalid_image';
|
12 |
|
13 |
/**
|
14 |
-
*
|
15 |
-
*
|
16 |
-
* @param string[] $values Params from class constructor.
|
17 |
-
*
|
18 |
-
* @return string Error message.
|
19 |
*/
|
20 |
public function get_error_message( array $values ): string {
|
21 |
return sprintf( self::ERROR_MESSAGE, $values[0] );
|
22 |
}
|
23 |
|
24 |
/**
|
25 |
-
*
|
26 |
-
*
|
27 |
-
* @return string Error status.
|
28 |
*/
|
29 |
public function get_error_status(): string {
|
30 |
return self::ERROR_CODE;
|
5 |
/**
|
6 |
* Handles "invalid_image" exception when converting images.
|
7 |
*/
|
8 |
+
class ImageInvalidException extends ExceptionAbstract {
|
9 |
|
10 |
const ERROR_MESSAGE = '"%s" is not a valid image file.';
|
11 |
const ERROR_CODE = 'invalid_image';
|
12 |
|
13 |
/**
|
14 |
+
* {@inheritdoc}
|
|
|
|
|
|
|
|
|
15 |
*/
|
16 |
public function get_error_message( array $values ): string {
|
17 |
return sprintf( self::ERROR_MESSAGE, $values[0] );
|
18 |
}
|
19 |
|
20 |
/**
|
21 |
+
* {@inheritdoc}
|
|
|
|
|
22 |
*/
|
23 |
public function get_error_status(): string {
|
24 |
return self::ERROR_CODE;
|
src/Conversion/Exception/ImagickNotSupportWebpException.php
CHANGED
@@ -5,26 +5,20 @@ namespace WebpConverter\Conversion\Exception;
|
|
5 |
/**
|
6 |
* Handles "server_configuration" exception when converting images.
|
7 |
*/
|
8 |
-
class ImagickNotSupportWebpException extends ExceptionAbstract
|
9 |
|
10 |
const ERROR_MESSAGE = 'Server configuration: Imagick does not support WebP format.';
|
11 |
const ERROR_CODE = 'server_configuration';
|
12 |
|
13 |
/**
|
14 |
-
*
|
15 |
-
*
|
16 |
-
* @param string[] $values Params from class constructor.
|
17 |
-
*
|
18 |
-
* @return string Error message.
|
19 |
*/
|
20 |
public function get_error_message( array $values ): string {
|
21 |
return self::ERROR_MESSAGE;
|
22 |
}
|
23 |
|
24 |
/**
|
25 |
-
*
|
26 |
-
*
|
27 |
-
* @return string Error status.
|
28 |
*/
|
29 |
public function get_error_status(): string {
|
30 |
return self::ERROR_CODE;
|
5 |
/**
|
6 |
* Handles "server_configuration" exception when converting images.
|
7 |
*/
|
8 |
+
class ImagickNotSupportWebpException extends ExceptionAbstract {
|
9 |
|
10 |
const ERROR_MESSAGE = 'Server configuration: Imagick does not support WebP format.';
|
11 |
const ERROR_CODE = 'server_configuration';
|
12 |
|
13 |
/**
|
14 |
+
* {@inheritdoc}
|
|
|
|
|
|
|
|
|
15 |
*/
|
16 |
public function get_error_message( array $values ): string {
|
17 |
return self::ERROR_MESSAGE;
|
18 |
}
|
19 |
|
20 |
/**
|
21 |
+
* {@inheritdoc}
|
|
|
|
|
22 |
*/
|
23 |
public function get_error_status(): string {
|
24 |
return self::ERROR_CODE;
|
src/Conversion/Exception/ImagickUnavailableException.php
CHANGED
@@ -5,26 +5,20 @@ namespace WebpConverter\Conversion\Exception;
|
|
5 |
/**
|
6 |
* Handles "server_configuration" exception when converting images.
|
7 |
*/
|
8 |
-
class ImagickUnavailableException extends ExceptionAbstract
|
9 |
|
10 |
const ERROR_MESSAGE = 'Server configuration: Imagick module is not available with this PHP installation.';
|
11 |
const ERROR_CODE = 'server_configuration';
|
12 |
|
13 |
/**
|
14 |
-
*
|
15 |
-
*
|
16 |
-
* @param string[] $values Params from class constructor.
|
17 |
-
*
|
18 |
-
* @return string Error message.
|
19 |
*/
|
20 |
public function get_error_message( array $values ): string {
|
21 |
return self::ERROR_MESSAGE;
|
22 |
}
|
23 |
|
24 |
/**
|
25 |
-
*
|
26 |
-
*
|
27 |
-
* @return string Error status.
|
28 |
*/
|
29 |
public function get_error_status(): string {
|
30 |
return self::ERROR_CODE;
|
5 |
/**
|
6 |
* Handles "server_configuration" exception when converting images.
|
7 |
*/
|
8 |
+
class ImagickUnavailableException extends ExceptionAbstract {
|
9 |
|
10 |
const ERROR_MESSAGE = 'Server configuration: Imagick module is not available with this PHP installation.';
|
11 |
const ERROR_CODE = 'server_configuration';
|
12 |
|
13 |
/**
|
14 |
+
* {@inheritdoc}
|
|
|
|
|
|
|
|
|
15 |
*/
|
16 |
public function get_error_message( array $values ): string {
|
17 |
return self::ERROR_MESSAGE;
|
18 |
}
|
19 |
|
20 |
/**
|
21 |
+
* {@inheritdoc}
|
|
|
|
|
22 |
*/
|
23 |
public function get_error_status(): string {
|
24 |
return self::ERROR_CODE;
|
src/Conversion/Exception/LargerThanOriginalException.php
CHANGED
@@ -5,26 +5,20 @@ namespace WebpConverter\Conversion\Exception;
|
|
5 |
/**
|
6 |
* Handles "larger_than_original" exception when converting images.
|
7 |
*/
|
8 |
-
class LargerThanOriginalException extends ExceptionAbstract
|
9 |
|
10 |
const ERROR_MESSAGE = 'Image "%s" converted to WebP is larger than original and has been deleted.';
|
11 |
const ERROR_CODE = 'larger_than_original';
|
12 |
|
13 |
/**
|
14 |
-
*
|
15 |
-
*
|
16 |
-
* @param string[] $values Params from class constructor.
|
17 |
-
*
|
18 |
-
* @return string Error message.
|
19 |
*/
|
20 |
public function get_error_message( array $values ): string {
|
21 |
return sprintf( self::ERROR_MESSAGE, $values[0] );
|
22 |
}
|
23 |
|
24 |
/**
|
25 |
-
*
|
26 |
-
*
|
27 |
-
* @return string Error status.
|
28 |
*/
|
29 |
public function get_error_status(): string {
|
30 |
return self::ERROR_CODE;
|
5 |
/**
|
6 |
* Handles "larger_than_original" exception when converting images.
|
7 |
*/
|
8 |
+
class LargerThanOriginalException extends ExceptionAbstract {
|
9 |
|
10 |
const ERROR_MESSAGE = 'Image "%s" converted to WebP is larger than original and has been deleted.';
|
11 |
const ERROR_CODE = 'larger_than_original';
|
12 |
|
13 |
/**
|
14 |
+
* {@inheritdoc}
|
|
|
|
|
|
|
|
|
15 |
*/
|
16 |
public function get_error_message( array $values ): string {
|
17 |
return sprintf( self::ERROR_MESSAGE, $values[0] );
|
18 |
}
|
19 |
|
20 |
/**
|
21 |
+
* {@inheritdoc}
|
|
|
|
|
22 |
*/
|
23 |
public function get_error_status(): string {
|
24 |
return self::ERROR_CODE;
|
src/Conversion/Exception/OutputPathException.php
CHANGED
@@ -5,26 +5,20 @@ namespace WebpConverter\Conversion\Exception;
|
|
5 |
/**
|
6 |
* Handles "output_path" exception when converting images.
|
7 |
*/
|
8 |
-
class OutputPathException extends ExceptionAbstract
|
9 |
|
10 |
const ERROR_MESSAGE = 'An error occurred creating destination directory for "%s" file.';
|
11 |
const ERROR_CODE = 'output_path';
|
12 |
|
13 |
/**
|
14 |
-
*
|
15 |
-
*
|
16 |
-
* @param string[] $values Params from class constructor.
|
17 |
-
*
|
18 |
-
* @return string Error message.
|
19 |
*/
|
20 |
public function get_error_message( array $values ): string {
|
21 |
return sprintf( self::ERROR_MESSAGE, $values[0] );
|
22 |
}
|
23 |
|
24 |
/**
|
25 |
-
*
|
26 |
-
*
|
27 |
-
* @return string Error status.
|
28 |
*/
|
29 |
public function get_error_status(): string {
|
30 |
return self::ERROR_CODE;
|
5 |
/**
|
6 |
* Handles "output_path" exception when converting images.
|
7 |
*/
|
8 |
+
class OutputPathException extends ExceptionAbstract {
|
9 |
|
10 |
const ERROR_MESSAGE = 'An error occurred creating destination directory for "%s" file.';
|
11 |
const ERROR_CODE = 'output_path';
|
12 |
|
13 |
/**
|
14 |
+
* {@inheritdoc}
|
|
|
|
|
|
|
|
|
15 |
*/
|
16 |
public function get_error_message( array $values ): string {
|
17 |
return sprintf( self::ERROR_MESSAGE, $values[0] );
|
18 |
}
|
19 |
|
20 |
/**
|
21 |
+
* {@inheritdoc}
|
|
|
|
|
22 |
*/
|
23 |
public function get_error_status(): string {
|
24 |
return self::ERROR_CODE;
|
src/Conversion/Exception/ResolutionOversizeException.php
CHANGED
@@ -5,26 +5,20 @@ namespace WebpConverter\Conversion\Exception;
|
|
5 |
/**
|
6 |
* Handles "max_resolution" exception when converting images.
|
7 |
*/
|
8 |
-
class ResolutionOversizeException extends ExceptionAbstract
|
9 |
|
10 |
const ERROR_MESSAGE = 'Image is larger than maximum 8K resolution: "%s".';
|
11 |
const ERROR_CODE = 'max_resolution';
|
12 |
|
13 |
/**
|
14 |
-
*
|
15 |
-
*
|
16 |
-
* @param string[] $values Params from class constructor.
|
17 |
-
*
|
18 |
-
* @return string Error message.
|
19 |
*/
|
20 |
public function get_error_message( array $values ): string {
|
21 |
return sprintf( self::ERROR_MESSAGE, $values[0] );
|
22 |
}
|
23 |
|
24 |
/**
|
25 |
-
*
|
26 |
-
*
|
27 |
-
* @return string Error status.
|
28 |
*/
|
29 |
public function get_error_status(): string {
|
30 |
return self::ERROR_CODE;
|
5 |
/**
|
6 |
* Handles "max_resolution" exception when converting images.
|
7 |
*/
|
8 |
+
class ResolutionOversizeException extends ExceptionAbstract {
|
9 |
|
10 |
const ERROR_MESSAGE = 'Image is larger than maximum 8K resolution: "%s".';
|
11 |
const ERROR_CODE = 'max_resolution';
|
12 |
|
13 |
/**
|
14 |
+
* {@inheritdoc}
|
|
|
|
|
|
|
|
|
15 |
*/
|
16 |
public function get_error_message( array $values ): string {
|
17 |
return sprintf( self::ERROR_MESSAGE, $values[0] );
|
18 |
}
|
19 |
|
20 |
/**
|
21 |
+
* {@inheritdoc}
|
|
|
|
|
22 |
*/
|
23 |
public function get_error_status(): string {
|
24 |
return self::ERROR_CODE;
|
src/Conversion/Exception/ServerConfigurationException.php
CHANGED
@@ -5,26 +5,20 @@ namespace WebpConverter\Conversion\Exception;
|
|
5 |
/**
|
6 |
* Handles "server_configuration" exception when converting images.
|
7 |
*/
|
8 |
-
class ServerConfigurationException extends ExceptionAbstract
|
9 |
|
10 |
const ERROR_MESSAGE = 'Server configuration: "%s" function is not available.';
|
11 |
const ERROR_CODE = 'server_configuration';
|
12 |
|
13 |
/**
|
14 |
-
*
|
15 |
-
*
|
16 |
-
* @param string[] $values Params from class constructor.
|
17 |
-
*
|
18 |
-
* @return string Error message.
|
19 |
*/
|
20 |
public function get_error_message( array $values ): string {
|
21 |
return sprintf( self::ERROR_MESSAGE, $values[0] );
|
22 |
}
|
23 |
|
24 |
/**
|
25 |
-
*
|
26 |
-
*
|
27 |
-
* @return string Error status.
|
28 |
*/
|
29 |
public function get_error_status(): string {
|
30 |
return self::ERROR_CODE;
|
5 |
/**
|
6 |
* Handles "server_configuration" exception when converting images.
|
7 |
*/
|
8 |
+
class ServerConfigurationException extends ExceptionAbstract {
|
9 |
|
10 |
const ERROR_MESSAGE = 'Server configuration: "%s" function is not available.';
|
11 |
const ERROR_CODE = 'server_configuration';
|
12 |
|
13 |
/**
|
14 |
+
* {@inheritdoc}
|
|
|
|
|
|
|
|
|
15 |
*/
|
16 |
public function get_error_message( array $values ): string {
|
17 |
return sprintf( self::ERROR_MESSAGE, $values[0] );
|
18 |
}
|
19 |
|
20 |
/**
|
21 |
+
* {@inheritdoc}
|
|
|
|
|
22 |
*/
|
23 |
public function get_error_status(): string {
|
24 |
return self::ERROR_CODE;
|
src/Conversion/Exception/SourcePathException.php
CHANGED
@@ -5,26 +5,20 @@ namespace WebpConverter\Conversion\Exception;
|
|
5 |
/**
|
6 |
* Handles "file_unreadable" exception when converting images.
|
7 |
*/
|
8 |
-
class SourcePathException extends ExceptionAbstract
|
9 |
|
10 |
const ERROR_MESSAGE = 'Source path "%s" for image does not exist or is unreadable.';
|
11 |
const ERROR_CODE = 'file_unreadable';
|
12 |
|
13 |
/**
|
14 |
-
*
|
15 |
-
*
|
16 |
-
* @param string[] $values Params from class constructor.
|
17 |
-
*
|
18 |
-
* @return string Error message.
|
19 |
*/
|
20 |
public function get_error_message( array $values ): string {
|
21 |
return sprintf( self::ERROR_MESSAGE, $values[0] );
|
22 |
}
|
23 |
|
24 |
/**
|
25 |
-
*
|
26 |
-
*
|
27 |
-
* @return string Error status.
|
28 |
*/
|
29 |
public function get_error_status(): string {
|
30 |
return self::ERROR_CODE;
|
5 |
/**
|
6 |
* Handles "file_unreadable" exception when converting images.
|
7 |
*/
|
8 |
+
class SourcePathException extends ExceptionAbstract {
|
9 |
|
10 |
const ERROR_MESSAGE = 'Source path "%s" for image does not exist or is unreadable.';
|
11 |
const ERROR_CODE = 'file_unreadable';
|
12 |
|
13 |
/**
|
14 |
+
* {@inheritdoc}
|
|
|
|
|
|
|
|
|
15 |
*/
|
16 |
public function get_error_message( array $values ): string {
|
17 |
return sprintf( self::ERROR_MESSAGE, $values[0] );
|
18 |
}
|
19 |
|
20 |
/**
|
21 |
+
* {@inheritdoc}
|
|
|
|
|
22 |
*/
|
23 |
public function get_error_status(): string {
|
24 |
return self::ERROR_CODE;
|
src/Conversion/Format/AvifFormat.php
CHANGED
@@ -5,32 +5,26 @@ namespace WebpConverter\Conversion\Format;
|
|
5 |
/**
|
6 |
* Supports AVIF as output format for images.
|
7 |
*/
|
8 |
-
class AvifFormat extends FormatAbstract
|
9 |
|
10 |
const FORMAT_EXTENSION = 'avif';
|
11 |
|
12 |
/**
|
13 |
-
*
|
14 |
-
*
|
15 |
-
* @return string Format extension
|
16 |
*/
|
17 |
public function get_extension(): string {
|
18 |
return self::FORMAT_EXTENSION;
|
19 |
}
|
20 |
|
21 |
/**
|
22 |
-
*
|
23 |
-
*
|
24 |
-
* @return string Format mime type
|
25 |
*/
|
26 |
public function get_mime_type(): string {
|
27 |
return 'image/avif';
|
28 |
}
|
29 |
|
30 |
/**
|
31 |
-
*
|
32 |
-
*
|
33 |
-
* @return string Format label.
|
34 |
*/
|
35 |
public function get_label(): string {
|
36 |
/* translators: %s format name */
|
@@ -38,11 +32,7 @@ class AvifFormat extends FormatAbstract implements FormatInterface {
|
|
38 |
}
|
39 |
|
40 |
/**
|
41 |
-
*
|
42 |
-
*
|
43 |
-
* @param string $conversion_method Type of conversion method.
|
44 |
-
*
|
45 |
-
* @return bool Is format available?
|
46 |
*/
|
47 |
public function is_available( string $conversion_method ): bool {
|
48 |
return false;
|
5 |
/**
|
6 |
* Supports AVIF as output format for images.
|
7 |
*/
|
8 |
+
class AvifFormat extends FormatAbstract {
|
9 |
|
10 |
const FORMAT_EXTENSION = 'avif';
|
11 |
|
12 |
/**
|
13 |
+
* {@inheritdoc}
|
|
|
|
|
14 |
*/
|
15 |
public function get_extension(): string {
|
16 |
return self::FORMAT_EXTENSION;
|
17 |
}
|
18 |
|
19 |
/**
|
20 |
+
* {@inheritdoc}
|
|
|
|
|
21 |
*/
|
22 |
public function get_mime_type(): string {
|
23 |
return 'image/avif';
|
24 |
}
|
25 |
|
26 |
/**
|
27 |
+
* {@inheritdoc}
|
|
|
|
|
28 |
*/
|
29 |
public function get_label(): string {
|
30 |
/* translators: %s format name */
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* {@inheritdoc}
|
|
|
|
|
|
|
|
|
36 |
*/
|
37 |
public function is_available( string $conversion_method ): bool {
|
38 |
return false;
|
src/Conversion/Format/FormatAbstract.php
CHANGED
@@ -10,22 +10,17 @@ use WebpConverter\Conversion\Method\MethodFactory;
|
|
10 |
abstract class FormatAbstract implements FormatInterface {
|
11 |
|
12 |
/**
|
13 |
-
*
|
14 |
-
*
|
15 |
-
* @return string Format label.
|
16 |
*/
|
17 |
public function get_label(): string {
|
18 |
return sprintf( '.%s', $this->get_extension() );
|
19 |
}
|
20 |
|
21 |
/**
|
22 |
-
*
|
23 |
-
*
|
24 |
-
* @param string $conversion_method Type of conversion method.
|
25 |
-
*
|
26 |
-
* @return bool Is format available?
|
27 |
*/
|
28 |
public function is_available( string $conversion_method ): bool {
|
29 |
-
return ( new MethodFactory() )
|
|
|
30 |
}
|
31 |
}
|
10 |
abstract class FormatAbstract implements FormatInterface {
|
11 |
|
12 |
/**
|
13 |
+
* {@inheritdoc}
|
|
|
|
|
14 |
*/
|
15 |
public function get_label(): string {
|
16 |
return sprintf( '.%s', $this->get_extension() );
|
17 |
}
|
18 |
|
19 |
/**
|
20 |
+
* {@inheritdoc}
|
|
|
|
|
|
|
|
|
21 |
*/
|
22 |
public function is_available( string $conversion_method ): bool {
|
23 |
+
return ( new MethodFactory() )
|
24 |
+
->is_method_available( $conversion_method, $this->get_extension() );
|
25 |
}
|
26 |
}
|
src/Conversion/Format/FormatFactory.php
CHANGED
@@ -14,9 +14,6 @@ class FormatFactory {
|
|
14 |
*/
|
15 |
private $formats = [];
|
16 |
|
17 |
-
/**
|
18 |
-
* Formats constructor.
|
19 |
-
*/
|
20 |
public function __construct() {
|
21 |
$this->set_integration( new AvifFormat() );
|
22 |
$this->set_integration( new WebpFormat() );
|
14 |
*/
|
15 |
private $formats = [];
|
16 |
|
|
|
|
|
|
|
17 |
public function __construct() {
|
18 |
$this->set_integration( new AvifFormat() );
|
19 |
$this->set_integration( new WebpFormat() );
|
src/Conversion/Format/WebpFormat.php
CHANGED
@@ -5,32 +5,26 @@ namespace WebpConverter\Conversion\Format;
|
|
5 |
/**
|
6 |
* Supports WebP as output format for images.
|
7 |
*/
|
8 |
-
class WebpFormat extends FormatAbstract
|
9 |
|
10 |
const FORMAT_EXTENSION = 'webp';
|
11 |
|
12 |
/**
|
13 |
-
*
|
14 |
-
*
|
15 |
-
* @return string Format extension
|
16 |
*/
|
17 |
public function get_extension(): string {
|
18 |
return self::FORMAT_EXTENSION;
|
19 |
}
|
20 |
|
21 |
/**
|
22 |
-
*
|
23 |
-
*
|
24 |
-
* @return string Format mime type
|
25 |
*/
|
26 |
public function get_mime_type(): string {
|
27 |
return 'image/webp';
|
28 |
}
|
29 |
|
30 |
/**
|
31 |
-
*
|
32 |
-
*
|
33 |
-
* @return string Format label.
|
34 |
*/
|
35 |
public function get_label(): string {
|
36 |
return 'WebP';
|
5 |
/**
|
6 |
* Supports WebP as output format for images.
|
7 |
*/
|
8 |
+
class WebpFormat extends FormatAbstract {
|
9 |
|
10 |
const FORMAT_EXTENSION = 'webp';
|
11 |
|
12 |
/**
|
13 |
+
* {@inheritdoc}
|
|
|
|
|
14 |
*/
|
15 |
public function get_extension(): string {
|
16 |
return self::FORMAT_EXTENSION;
|
17 |
}
|
18 |
|
19 |
/**
|
20 |
+
* {@inheritdoc}
|
|
|
|
|
21 |
*/
|
22 |
public function get_mime_type(): string {
|
23 |
return 'image/webp';
|
24 |
}
|
25 |
|
26 |
/**
|
27 |
+
* {@inheritdoc}
|
|
|
|
|
28 |
*/
|
29 |
public function get_label(): string {
|
30 |
return 'WebP';
|
src/Conversion/Media/Attachment.php
CHANGED
@@ -2,13 +2,17 @@
|
|
2 |
|
3 |
namespace WebpConverter\Conversion\Media;
|
4 |
|
5 |
-
use WebpConverter\
|
6 |
-
use WebpConverter\PluginAccessInterface;
|
7 |
|
8 |
/**
|
9 |
* Returns all image paths for attachment.
|
10 |
*/
|
11 |
-
class Attachment
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
/**
|
14 |
* Current upload directory path and URL.
|
@@ -25,9 +29,10 @@ class Attachment extends PluginAccessAbstract implements PluginAccessInterface {
|
|
25 |
private $image_sizes;
|
26 |
|
27 |
/**
|
28 |
-
*
|
29 |
*/
|
30 |
-
public function __construct() {
|
|
|
31 |
$this->upload_dir = wp_upload_dir();
|
32 |
$this->image_sizes = get_intermediate_image_sizes();
|
33 |
}
|
@@ -40,7 +45,7 @@ class Attachment extends PluginAccessAbstract implements PluginAccessInterface {
|
|
40 |
* @return string[] Server paths of source images.
|
41 |
*/
|
42 |
public function get_attachment_paths( int $attachment_id ): array {
|
43 |
-
$settings = $this->
|
44 |
return $this->get_paths_by_attachment( $attachment_id, $settings );
|
45 |
}
|
46 |
|
2 |
|
3 |
namespace WebpConverter\Conversion\Media;
|
4 |
|
5 |
+
use WebpConverter\PluginData;
|
|
|
6 |
|
7 |
/**
|
8 |
* Returns all image paths for attachment.
|
9 |
*/
|
10 |
+
class Attachment {
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @var PluginData .
|
14 |
+
*/
|
15 |
+
private $plugin_data;
|
16 |
|
17 |
/**
|
18 |
* Current upload directory path and URL.
|
29 |
private $image_sizes;
|
30 |
|
31 |
/**
|
32 |
+
* @param PluginData $plugin_data .
|
33 |
*/
|
34 |
+
public function __construct( PluginData $plugin_data ) {
|
35 |
+
$this->plugin_data = $plugin_data;
|
36 |
$this->upload_dir = wp_upload_dir();
|
37 |
$this->image_sizes = get_intermediate_image_sizes();
|
38 |
}
|
45 |
* @return string[] Server paths of source images.
|
46 |
*/
|
47 |
public function get_attachment_paths( int $attachment_id ): array {
|
48 |
+
$settings = $this->plugin_data->get_plugin_settings();
|
49 |
return $this->get_paths_by_attachment( $attachment_id, $settings );
|
50 |
}
|
51 |
|
src/Conversion/Media/Delete.php
CHANGED
@@ -10,9 +10,7 @@ use WebpConverter\HookableInterface;
|
|
10 |
class Delete implements HookableInterface {
|
11 |
|
12 |
/**
|
13 |
-
*
|
14 |
-
*
|
15 |
-
* @return void
|
16 |
*/
|
17 |
public function init_hooks() {
|
18 |
add_filter( 'wp_delete_file', [ $this, 'delete_attachment_file' ] );
|
10 |
class Delete implements HookableInterface {
|
11 |
|
12 |
/**
|
13 |
+
* {@inheritdoc}
|
|
|
|
|
14 |
*/
|
15 |
public function init_hooks() {
|
16 |
add_filter( 'wp_delete_file', [ $this, 'delete_attachment_file' ] );
|
src/Conversion/Media/Upload.php
CHANGED
@@ -2,14 +2,18 @@
|
|
2 |
|
3 |
namespace WebpConverter\Conversion\Media;
|
4 |
|
5 |
-
use WebpConverter\PluginAccessAbstract;
|
6 |
-
use WebpConverter\PluginAccessInterface;
|
7 |
use WebpConverter\HookableInterface;
|
|
|
8 |
|
9 |
/**
|
10 |
* Initializes image conversion when uploading images to media library.
|
11 |
*/
|
12 |
-
class Upload
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
/**
|
15 |
* Paths of converted images.
|
@@ -19,9 +23,14 @@ class Upload extends PluginAccessAbstract implements PluginAccessInterface, Hook
|
|
19 |
private $converted_paths = [];
|
20 |
|
21 |
/**
|
22 |
-
*
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
25 |
*/
|
26 |
public function init_hooks() {
|
27 |
add_filter( 'wp_update_attachment_metadata', [ $this, 'init_attachment_convert' ], 10, 2 );
|
@@ -95,7 +104,7 @@ class Upload extends PluginAccessAbstract implements PluginAccessInterface, Hook
|
|
95 |
* @return void
|
96 |
*/
|
97 |
private function init_conversion( array $paths ) {
|
98 |
-
$settings = $this->
|
99 |
|
100 |
if ( in_array( 'cron_conversion', $settings['features'] ) ) {
|
101 |
wp_schedule_single_event( ( time() + 1 ), 'webpc_convert_paths', [ $paths ] );
|
2 |
|
3 |
namespace WebpConverter\Conversion\Media;
|
4 |
|
|
|
|
|
5 |
use WebpConverter\HookableInterface;
|
6 |
+
use WebpConverter\PluginData;
|
7 |
|
8 |
/**
|
9 |
* Initializes image conversion when uploading images to media library.
|
10 |
*/
|
11 |
+
class Upload implements HookableInterface {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @var PluginData .
|
15 |
+
*/
|
16 |
+
private $plugin_data;
|
17 |
|
18 |
/**
|
19 |
* Paths of converted images.
|
23 |
private $converted_paths = [];
|
24 |
|
25 |
/**
|
26 |
+
* @param PluginData $plugin_data .
|
27 |
+
*/
|
28 |
+
public function __construct( PluginData $plugin_data ) {
|
29 |
+
$this->plugin_data = $plugin_data;
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* {@inheritdoc}
|
34 |
*/
|
35 |
public function init_hooks() {
|
36 |
add_filter( 'wp_update_attachment_metadata', [ $this, 'init_attachment_convert' ], 10, 2 );
|
104 |
* @return void
|
105 |
*/
|
106 |
private function init_conversion( array $paths ) {
|
107 |
+
$settings = $this->plugin_data->get_plugin_settings();
|
108 |
|
109 |
if ( in_array( 'cron_conversion', $settings['features'] ) ) {
|
110 |
wp_schedule_single_event( ( time() + 1 ), 'webpc_convert_paths', [ $paths ] );
|
src/Conversion/Method/GdMethod.php
CHANGED
@@ -9,44 +9,34 @@ use WebpConverter\Conversion\Exception;
|
|
9 |
/**
|
10 |
* Supports image conversion method using GD library.
|
11 |
*/
|
12 |
-
class GdMethod extends MethodAbstract
|
13 |
|
14 |
const METHOD_NAME = 'gd';
|
15 |
const MAX_METHOD_QUALITY = 99.9;
|
16 |
|
17 |
/**
|
18 |
-
*
|
19 |
-
*
|
20 |
-
* @return string Method name.
|
21 |
*/
|
22 |
public function get_name(): string {
|
23 |
return self::METHOD_NAME;
|
24 |
}
|
25 |
|
26 |
/**
|
27 |
-
*
|
28 |
-
*
|
29 |
-
* @return string Method label.
|
30 |
*/
|
31 |
public function get_label(): string {
|
32 |
return 'GD';
|
33 |
}
|
34 |
|
35 |
/**
|
36 |
-
*
|
37 |
-
*
|
38 |
-
* @return bool Is method installed?
|
39 |
*/
|
40 |
public static function is_method_installed(): bool {
|
41 |
return ( extension_loaded( 'gd' ) );
|
42 |
}
|
43 |
|
44 |
/**
|
45 |
-
*
|
46 |
-
*
|
47 |
-
* @param string $format Extension of output format.
|
48 |
-
*
|
49 |
-
* @return bool Is method active?
|
50 |
*/
|
51 |
public static function is_method_active( string $format ): bool {
|
52 |
if ( ! self::is_method_installed() || ! ( $function = self::get_format_function( $format ) ) ) {
|
@@ -74,16 +64,14 @@ class GdMethod extends MethodAbstract implements MethodInterface {
|
|
74 |
}
|
75 |
|
76 |
/**
|
77 |
-
*
|
78 |
-
*
|
79 |
-
* @param string $source_path Server path of source image.
|
80 |
*
|
81 |
* @return resource Image object.
|
82 |
* @throws Exception\ExtensionUnsupportedException
|
83 |
* @throws Exception\FunctionUnavailableException
|
84 |
* @throws Exception\ImageInvalidException
|
85 |
*/
|
86 |
-
public function create_image_by_path( string $source_path ) {
|
87 |
$extension = strtolower( pathinfo( $source_path, PATHINFO_EXTENSION ) );
|
88 |
$methods = apply_filters(
|
89 |
'webpc_gd_create_methods',
|
@@ -93,10 +81,9 @@ class GdMethod extends MethodAbstract implements MethodInterface {
|
|
93 |
'imagecreatefromgif' => [ 'gif' ],
|
94 |
]
|
95 |
);
|
96 |
-
$settings = $this->get_plugin()->get_settings();
|
97 |
|
98 |
foreach ( $methods as $method => $extensions ) {
|
99 |
-
if ( ! in_array( $extension, $
|
100 |
continue;
|
101 |
} elseif ( ! function_exists( $method ) ) {
|
102 |
throw new Exception\FunctionUnavailableException( $method );
|
@@ -151,27 +138,20 @@ class GdMethod extends MethodAbstract implements MethodInterface {
|
|
151 |
}
|
152 |
|
153 |
/**
|
154 |
-
*
|
155 |
-
*
|
156 |
-
* @param resource $image Image object.
|
157 |
-
* @param string $source_path Server path of source image.
|
158 |
-
* @param string $output_path Server path for output image.
|
159 |
-
* @param string $format Extension of output format.
|
160 |
*
|
161 |
-
* @return void
|
162 |
* @throws Exception\ConversionErrorException
|
163 |
* @throws Exception\FunctionUnavailableException
|
164 |
* @throws Exception\ResolutionOversizeException
|
165 |
*/
|
166 |
-
public function convert_image_to_output( $image, string $source_path, string $output_path, string $format ) {
|
167 |
$function = self::get_format_function( $format );
|
168 |
if ( $function === null ) {
|
169 |
return;
|
170 |
}
|
171 |
|
172 |
$image = apply_filters( 'webpc_gd_before_saving', $image, $source_path );
|
173 |
-
$
|
174 |
-
$output_quality = min( $settings['quality'], self::MAX_METHOD_QUALITY );
|
175 |
|
176 |
if ( ! function_exists( $function ) ) {
|
177 |
throw new Exception\FunctionUnavailableException( $function );
|
9 |
/**
|
10 |
* Supports image conversion method using GD library.
|
11 |
*/
|
12 |
+
class GdMethod extends MethodAbstract {
|
13 |
|
14 |
const METHOD_NAME = 'gd';
|
15 |
const MAX_METHOD_QUALITY = 99.9;
|
16 |
|
17 |
/**
|
18 |
+
* {@inheritdoc}
|
|
|
|
|
19 |
*/
|
20 |
public function get_name(): string {
|
21 |
return self::METHOD_NAME;
|
22 |
}
|
23 |
|
24 |
/**
|
25 |
+
* {@inheritdoc}
|
|
|
|
|
26 |
*/
|
27 |
public function get_label(): string {
|
28 |
return 'GD';
|
29 |
}
|
30 |
|
31 |
/**
|
32 |
+
* {@inheritdoc}
|
|
|
|
|
33 |
*/
|
34 |
public static function is_method_installed(): bool {
|
35 |
return ( extension_loaded( 'gd' ) );
|
36 |
}
|
37 |
|
38 |
/**
|
39 |
+
* {@inheritdoc}
|
|
|
|
|
|
|
|
|
40 |
*/
|
41 |
public static function is_method_active( string $format ): bool {
|
42 |
if ( ! self::is_method_installed() || ! ( $function = self::get_format_function( $format ) ) ) {
|
64 |
}
|
65 |
|
66 |
/**
|
67 |
+
* {@inheritdoc}
|
|
|
|
|
68 |
*
|
69 |
* @return resource Image object.
|
70 |
* @throws Exception\ExtensionUnsupportedException
|
71 |
* @throws Exception\FunctionUnavailableException
|
72 |
* @throws Exception\ImageInvalidException
|
73 |
*/
|
74 |
+
public function create_image_by_path( string $source_path, array $plugin_settings ) {
|
75 |
$extension = strtolower( pathinfo( $source_path, PATHINFO_EXTENSION ) );
|
76 |
$methods = apply_filters(
|
77 |
'webpc_gd_create_methods',
|
81 |
'imagecreatefromgif' => [ 'gif' ],
|
82 |
]
|
83 |
);
|
|
|
84 |
|
85 |
foreach ( $methods as $method => $extensions ) {
|
86 |
+
if ( ! in_array( $extension, $plugin_settings['extensions'] ) || ! in_array( $extension, $extensions ) ) {
|
87 |
continue;
|
88 |
} elseif ( ! function_exists( $method ) ) {
|
89 |
throw new Exception\FunctionUnavailableException( $method );
|
138 |
}
|
139 |
|
140 |
/**
|
141 |
+
* {@inheritdoc}
|
|
|
|
|
|
|
|
|
|
|
142 |
*
|
|
|
143 |
* @throws Exception\ConversionErrorException
|
144 |
* @throws Exception\FunctionUnavailableException
|
145 |
* @throws Exception\ResolutionOversizeException
|
146 |
*/
|
147 |
+
public function convert_image_to_output( $image, string $source_path, string $output_path, string $format, array $plugin_settings ) {
|
148 |
$function = self::get_format_function( $format );
|
149 |
if ( $function === null ) {
|
150 |
return;
|
151 |
}
|
152 |
|
153 |
$image = apply_filters( 'webpc_gd_before_saving', $image, $source_path );
|
154 |
+
$output_quality = min( $plugin_settings['quality'], self::MAX_METHOD_QUALITY );
|
|
|
155 |
|
156 |
if ( ! function_exists( $function ) ) {
|
157 |
throw new Exception\FunctionUnavailableException( $function );
|
src/Conversion/Method/ImagickMethod.php
CHANGED
@@ -9,24 +9,20 @@ use WebpConverter\Conversion\Exception;
|
|
9 |
/**
|
10 |
* Supports image conversion method using Imagick library.
|
11 |
*/
|
12 |
-
class ImagickMethod extends MethodAbstract
|
13 |
|
14 |
const METHOD_NAME = 'imagick';
|
15 |
const MAX_METHOD_QUALITY = 99.9;
|
16 |
|
17 |
/**
|
18 |
-
*
|
19 |
-
*
|
20 |
-
* @return string Method name.
|
21 |
*/
|
22 |
public function get_name(): string {
|
23 |
return self::METHOD_NAME;
|
24 |
}
|
25 |
|
26 |
/**
|
27 |
-
*
|
28 |
-
*
|
29 |
-
* @return string Method label.
|
30 |
*/
|
31 |
public function get_label(): string {
|
32 |
/* translators: %s method name */
|
@@ -34,20 +30,14 @@ class ImagickMethod extends MethodAbstract implements MethodInterface {
|
|
34 |
}
|
35 |
|
36 |
/**
|
37 |
-
*
|
38 |
-
*
|
39 |
-
* @return bool Is method installed?
|
40 |
*/
|
41 |
public static function is_method_installed(): bool {
|
42 |
return ( extension_loaded( 'imagick' ) && class_exists( '\Imagick' ) );
|
43 |
}
|
44 |
|
45 |
/**
|
46 |
-
*
|
47 |
-
*
|
48 |
-
* @param string $format Extension of output format.
|
49 |
-
*
|
50 |
-
* @return bool Is method active?
|
51 |
*/
|
52 |
public static function is_method_active( string $format ): bool {
|
53 |
if ( ! self::is_method_installed()
|
@@ -77,22 +67,19 @@ class ImagickMethod extends MethodAbstract implements MethodInterface {
|
|
77 |
}
|
78 |
|
79 |
/**
|
80 |
-
*
|
81 |
-
*
|
82 |
-
* @param string $source_path Server path of source image.
|
83 |
*
|
84 |
-
* @return \Imagick
|
85 |
-
* @throws Exception\ImagickUnavailableException
|
86 |
* @throws Exception\ExtensionUnsupportedException
|
|
|
87 |
* @throws Exception\ImageInvalidException
|
88 |
*/
|
89 |
-
public function create_image_by_path( string $source_path ) {
|
90 |
$extension = strtolower( pathinfo( $source_path, PATHINFO_EXTENSION ) );
|
91 |
-
$settings = $this->get_plugin()->get_settings();
|
92 |
|
93 |
if ( ! extension_loaded( 'imagick' ) || ! class_exists( 'Imagick' ) ) {
|
94 |
throw new Exception\ImagickUnavailableException();
|
95 |
-
} elseif ( ! in_array( $extension, $
|
96 |
throw new Exception\ExtensionUnsupportedException( [ $extension, $source_path ] );
|
97 |
}
|
98 |
|
@@ -104,29 +91,22 @@ class ImagickMethod extends MethodAbstract implements MethodInterface {
|
|
104 |
}
|
105 |
|
106 |
/**
|
107 |
-
*
|
108 |
-
*
|
109 |
-
* @param \Imagick $image Image object.
|
110 |
-
* @param string $source_path Server path of source image.
|
111 |
-
* @param string $output_path Server path for output image.
|
112 |
-
* @param string $format Extension of output format.
|
113 |
*
|
114 |
-
* @return void
|
115 |
* @throws Exception\ConversionErrorException
|
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 |
-
$
|
122 |
-
$output_quality = min( $settings['quality'], self::MAX_METHOD_QUALITY );
|
123 |
|
124 |
if ( ! in_array( $extension, $image->queryFormats() ) ) {
|
125 |
throw new Exception\ImagickNotSupportWebpException();
|
126 |
}
|
127 |
|
128 |
$image->setImageFormat( $extension );
|
129 |
-
if ( ! in_array( 'keep_metadata', $
|
130 |
$image->stripImage();
|
131 |
}
|
132 |
$image->setImageCompressionQuality( $output_quality );
|
9 |
/**
|
10 |
* Supports image conversion method using Imagick library.
|
11 |
*/
|
12 |
+
class ImagickMethod extends MethodAbstract {
|
13 |
|
14 |
const METHOD_NAME = 'imagick';
|
15 |
const MAX_METHOD_QUALITY = 99.9;
|
16 |
|
17 |
/**
|
18 |
+
* {@inheritdoc}
|
|
|
|
|
19 |
*/
|
20 |
public function get_name(): string {
|
21 |
return self::METHOD_NAME;
|
22 |
}
|
23 |
|
24 |
/**
|
25 |
+
* {@inheritdoc}
|
|
|
|
|
26 |
*/
|
27 |
public function get_label(): string {
|
28 |
/* translators: %s method name */
|
30 |
}
|
31 |
|
32 |
/**
|
33 |
+
* {@inheritdoc}
|
|
|
|
|
34 |
*/
|
35 |
public static function is_method_installed(): bool {
|
36 |
return ( extension_loaded( 'imagick' ) && class_exists( '\Imagick' ) );
|
37 |
}
|
38 |
|
39 |
/**
|
40 |
+
* {@inheritdoc}
|
|
|
|
|
|
|
|
|
41 |
*/
|
42 |
public static function is_method_active( string $format ): bool {
|
43 |
if ( ! self::is_method_installed()
|
67 |
}
|
68 |
|
69 |
/**
|
70 |
+
* {@inheritdoc}
|
|
|
|
|
71 |
*
|
72 |
+
* @return \Imagick .
|
|
|
73 |
* @throws Exception\ExtensionUnsupportedException
|
74 |
+
* @throws Exception\ImagickUnavailableException
|
75 |
* @throws Exception\ImageInvalidException
|
76 |
*/
|
77 |
+
public function create_image_by_path( string $source_path, array $plugin_settings ) {
|
78 |
$extension = strtolower( pathinfo( $source_path, PATHINFO_EXTENSION ) );
|
|
|
79 |
|
80 |
if ( ! extension_loaded( 'imagick' ) || ! class_exists( 'Imagick' ) ) {
|
81 |
throw new Exception\ImagickUnavailableException();
|
82 |
+
} elseif ( ! in_array( $extension, $plugin_settings['extensions'] ) ) {
|
83 |
throw new Exception\ExtensionUnsupportedException( [ $extension, $source_path ] );
|
84 |
}
|
85 |
|
91 |
}
|
92 |
|
93 |
/**
|
94 |
+
* {@inheritdoc}
|
|
|
|
|
|
|
|
|
|
|
95 |
*
|
|
|
96 |
* @throws Exception\ConversionErrorException
|
97 |
* @throws Exception\ImagickNotSupportWebpException
|
98 |
*/
|
99 |
+
public function convert_image_to_output( $image, string $source_path, string $output_path, string $format, array $plugin_settings ) {
|
100 |
$extension = self::get_format_extension( $format );
|
101 |
$image = apply_filters( 'webpc_imagick_before_saving', $image, $source_path );
|
102 |
+
$output_quality = min( $plugin_settings['quality'], self::MAX_METHOD_QUALITY );
|
|
|
103 |
|
104 |
if ( ! in_array( $extension, $image->queryFormats() ) ) {
|
105 |
throw new Exception\ImagickNotSupportWebpException();
|
106 |
}
|
107 |
|
108 |
$image->setImageFormat( $extension );
|
109 |
+
if ( ! in_array( 'keep_metadata', $plugin_settings['features'] ) ) {
|
110 |
$image->stripImage();
|
111 |
}
|
112 |
$image->setImageCompressionQuality( $output_quality );
|
src/Conversion/Method/MethodAbstract.php
CHANGED
@@ -2,17 +2,14 @@
|
|
2 |
|
3 |
namespace WebpConverter\Conversion\Method;
|
4 |
|
5 |
-
use WebpConverter\PluginAccessAbstract;
|
6 |
-
use WebpConverter\PluginAccessInterface;
|
7 |
use WebpConverter\Conversion\Exception;
|
8 |
-
use WebpConverter\Conversion\Method\MethodInterface;
|
9 |
use WebpConverter\Conversion\OutputPath;
|
10 |
use WebpConverter\Conversion\SkipLarger;
|
11 |
|
12 |
/**
|
13 |
* Abstract class for class that supports endpoint.
|
14 |
*/
|
15 |
-
abstract class MethodAbstract
|
16 |
|
17 |
/**
|
18 |
* Messages of errors that occurred during conversion.
|
@@ -36,45 +33,35 @@ abstract class MethodAbstract extends PluginAccessAbstract implements PluginAcce
|
|
36 |
private $size_after = 0;
|
37 |
|
38 |
/**
|
39 |
-
*
|
40 |
-
*
|
41 |
-
* @return string[] Errors messages.
|
42 |
*/
|
43 |
public function get_errors(): array {
|
44 |
return $this->errors;
|
45 |
}
|
46 |
|
47 |
/**
|
48 |
-
*
|
49 |
-
*
|
50 |
-
* @return int Source files weight.
|
51 |
*/
|
52 |
public function get_size_before(): int {
|
53 |
return $this->size_before;
|
54 |
}
|
55 |
|
56 |
/**
|
57 |
-
*
|
58 |
-
*
|
59 |
-
* @return int Output files weight.
|
60 |
*/
|
61 |
public function get_size_after(): int {
|
62 |
return $this->size_after;
|
63 |
}
|
64 |
|
65 |
/**
|
66 |
-
*
|
67 |
-
*
|
68 |
-
* @param string[] $paths Server paths of source images.
|
69 |
-
*
|
70 |
-
* @return void
|
71 |
*/
|
72 |
-
public function convert_paths( array $paths ) {
|
73 |
-
$output_formats = $
|
74 |
foreach ( $output_formats as $output_format ) {
|
75 |
foreach ( $paths as $path ) {
|
76 |
try {
|
77 |
-
$response = $this->convert_path( $path, $output_format );
|
78 |
|
79 |
$this->size_before += $response['data']['size_before'];
|
80 |
$this->size_after += $response['data']['size_after'];
|
@@ -86,16 +73,12 @@ abstract class MethodAbstract extends PluginAccessAbstract implements PluginAcce
|
|
86 |
}
|
87 |
|
88 |
/**
|
89 |
-
*
|
90 |
-
*
|
91 |
-
* @param string $path Server path of source image.
|
92 |
-
* @param string $format Extension of output format.
|
93 |
*
|
94 |
-
* @return mixed[] Results data of conversion.
|
95 |
-
* @throws Exception\SourcePathException
|
96 |
* @throws Exception\OutputPathException
|
|
|
97 |
*/
|
98 |
-
public function convert_path( string $path, string $format ): array {
|
99 |
ini_set( 'memory_limit', '1G' ); // phpcs:ignore
|
100 |
if ( strpos( ini_get( 'disable_functions' ) ?: '', 'set_time_limit' ) === false ) {
|
101 |
set_time_limit( 120 );
|
@@ -103,14 +86,14 @@ abstract class MethodAbstract extends PluginAccessAbstract implements PluginAcce
|
|
103 |
|
104 |
try {
|
105 |
$source_path = $this->get_image_source_path( $path );
|
106 |
-
$image = $this->create_image_by_path( $source_path );
|
107 |
$output_path = $this->get_image_output_path( $source_path, $format );
|
108 |
|
109 |
if ( file_exists( $output_path . '.' . SkipLarger::DELETED_FILE_EXTENSION ) ) {
|
110 |
unlink( $output_path . '.' . SkipLarger::DELETED_FILE_EXTENSION );
|
111 |
}
|
112 |
|
113 |
-
$this->convert_image_to_output( $image, $source_path, $output_path, $format );
|
114 |
do_action( 'webpc_convert_after', $output_path, $source_path );
|
115 |
|
116 |
return [
|
@@ -119,7 +102,7 @@ abstract class MethodAbstract extends PluginAccessAbstract implements PluginAcce
|
|
119 |
'data' => $this->get_conversion_stats( $source_path, $output_path ),
|
120 |
];
|
121 |
} catch ( \Exception $e ) {
|
122 |
-
$features = $
|
123 |
if ( in_array( 'debug_enabled', $features ) ) {
|
124 |
error_log( sprintf( 'WebP Converter for Media: %s', $e->getMessage() ) ); // phpcs:ignore
|
125 |
}
|
@@ -129,11 +112,8 @@ abstract class MethodAbstract extends PluginAccessAbstract implements PluginAcce
|
|
129 |
}
|
130 |
|
131 |
/**
|
132 |
-
*
|
133 |
-
*
|
134 |
-
* @param string $source_path Server path of source image.
|
135 |
*
|
136 |
-
* @return string Server path of source image.
|
137 |
* @throws Exception\SourcePathException
|
138 |
*/
|
139 |
public function get_image_source_path( string $source_path ): string {
|
@@ -146,12 +126,8 @@ abstract class MethodAbstract extends PluginAccessAbstract implements PluginAcce
|
|
146 |
}
|
147 |
|
148 |
/**
|
149 |
-
*
|
150 |
*
|
151 |
-
* @param string $source_path Server path of source image.
|
152 |
-
* @param string $format Extension of output format.
|
153 |
-
*
|
154 |
-
* @return string Server path of output image.
|
155 |
* @throws Exception\OutputPathException
|
156 |
*/
|
157 |
public function get_image_output_path( string $source_path, string $format ): string {
|
@@ -163,12 +139,7 @@ abstract class MethodAbstract extends PluginAccessAbstract implements PluginAcce
|
|
163 |
}
|
164 |
|
165 |
/**
|
166 |
-
*
|
167 |
-
*
|
168 |
-
* @param string $source_path Server path of source image.
|
169 |
-
* @param string $output_path Server path of output image.
|
170 |
-
*
|
171 |
-
* @return int[] Results data of conversion.
|
172 |
*/
|
173 |
public function get_conversion_stats( string $source_path, string $output_path ): array {
|
174 |
$size_before = filesize( $source_path );
|
2 |
|
3 |
namespace WebpConverter\Conversion\Method;
|
4 |
|
|
|
|
|
5 |
use WebpConverter\Conversion\Exception;
|
|
|
6 |
use WebpConverter\Conversion\OutputPath;
|
7 |
use WebpConverter\Conversion\SkipLarger;
|
8 |
|
9 |
/**
|
10 |
* Abstract class for class that supports endpoint.
|
11 |
*/
|
12 |
+
abstract class MethodAbstract implements MethodInterface {
|
13 |
|
14 |
/**
|
15 |
* Messages of errors that occurred during conversion.
|
33 |
private $size_after = 0;
|
34 |
|
35 |
/**
|
36 |
+
* {@inheritdoc}
|
|
|
|
|
37 |
*/
|
38 |
public function get_errors(): array {
|
39 |
return $this->errors;
|
40 |
}
|
41 |
|
42 |
/**
|
43 |
+
* {@inheritdoc}
|
|
|
|
|
44 |
*/
|
45 |
public function get_size_before(): int {
|
46 |
return $this->size_before;
|
47 |
}
|
48 |
|
49 |
/**
|
50 |
+
* {@inheritdoc}
|
|
|
|
|
51 |
*/
|
52 |
public function get_size_after(): int {
|
53 |
return $this->size_after;
|
54 |
}
|
55 |
|
56 |
/**
|
57 |
+
* {@inheritdoc}
|
|
|
|
|
|
|
|
|
58 |
*/
|
59 |
+
public function convert_paths( array $paths, array $plugin_settings ) {
|
60 |
+
$output_formats = $plugin_settings['output_formats'];
|
61 |
foreach ( $output_formats as $output_format ) {
|
62 |
foreach ( $paths as $path ) {
|
63 |
try {
|
64 |
+
$response = $this->convert_path( $path, $output_format, $plugin_settings );
|
65 |
|
66 |
$this->size_before += $response['data']['size_before'];
|
67 |
$this->size_after += $response['data']['size_after'];
|
73 |
}
|
74 |
|
75 |
/**
|
76 |
+
* {@inheritdoc}
|
|
|
|
|
|
|
77 |
*
|
|
|
|
|
78 |
* @throws Exception\OutputPathException
|
79 |
+
* @throws Exception\SourcePathException
|
80 |
*/
|
81 |
+
public function convert_path( string $path, string $format, array $plugin_settings ): array {
|
82 |
ini_set( 'memory_limit', '1G' ); // phpcs:ignore
|
83 |
if ( strpos( ini_get( 'disable_functions' ) ?: '', 'set_time_limit' ) === false ) {
|
84 |
set_time_limit( 120 );
|
86 |
|
87 |
try {
|
88 |
$source_path = $this->get_image_source_path( $path );
|
89 |
+
$image = $this->create_image_by_path( $source_path, $plugin_settings );
|
90 |
$output_path = $this->get_image_output_path( $source_path, $format );
|
91 |
|
92 |
if ( file_exists( $output_path . '.' . SkipLarger::DELETED_FILE_EXTENSION ) ) {
|
93 |
unlink( $output_path . '.' . SkipLarger::DELETED_FILE_EXTENSION );
|
94 |
}
|
95 |
|
96 |
+
$this->convert_image_to_output( $image, $source_path, $output_path, $format, $plugin_settings );
|
97 |
do_action( 'webpc_convert_after', $output_path, $source_path );
|
98 |
|
99 |
return [
|
102 |
'data' => $this->get_conversion_stats( $source_path, $output_path ),
|
103 |
];
|
104 |
} catch ( \Exception $e ) {
|
105 |
+
$features = $plugin_settings['features'] ?? [];
|
106 |
if ( in_array( 'debug_enabled', $features ) ) {
|
107 |
error_log( sprintf( 'WebP Converter for Media: %s', $e->getMessage() ) ); // phpcs:ignore
|
108 |
}
|
112 |
}
|
113 |
|
114 |
/**
|
115 |
+
* {@inheritdoc}
|
|
|
|
|
116 |
*
|
|
|
117 |
* @throws Exception\SourcePathException
|
118 |
*/
|
119 |
public function get_image_source_path( string $source_path ): string {
|
126 |
}
|
127 |
|
128 |
/**
|
129 |
+
* {@inheritdoc}
|
130 |
*
|
|
|
|
|
|
|
|
|
131 |
* @throws Exception\OutputPathException
|
132 |
*/
|
133 |
public function get_image_output_path( string $source_path, string $format ): string {
|
139 |
}
|
140 |
|
141 |
/**
|
142 |
+
* {@inheritdoc}
|
|
|
|
|
|
|
|
|
|
|
143 |
*/
|
144 |
public function get_conversion_stats( string $source_path, string $output_path ): array {
|
145 |
$size_before = filesize( $source_path );
|
src/Conversion/Method/MethodFactory.php
CHANGED
@@ -16,9 +16,6 @@ class MethodFactory {
|
|
16 |
*/
|
17 |
private $methods = [];
|
18 |
|
19 |
-
/**
|
20 |
-
* Methods constructor.
|
21 |
-
*/
|
22 |
public function __construct() {
|
23 |
$this->set_integration( new ImagickMethod() );
|
24 |
$this->set_integration( new GdMethod() );
|
16 |
*/
|
17 |
private $methods = [];
|
18 |
|
|
|
|
|
|
|
19 |
public function __construct() {
|
20 |
$this->set_integration( new ImagickMethod() );
|
21 |
$this->set_integration( new GdMethod() );
|
src/Conversion/Method/MethodIntegrator.php
CHANGED
@@ -2,13 +2,24 @@
|
|
2 |
|
3 |
namespace WebpConverter\Conversion\Method;
|
4 |
|
5 |
-
use WebpConverter\
|
6 |
-
use WebpConverter\PluginAccessInterface;
|
7 |
|
8 |
/**
|
9 |
* Initializes image conversion using active image conversion method.
|
10 |
*/
|
11 |
-
class MethodIntegrator
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
/**
|
14 |
* Initializes converting source images using active and set conversion method.
|
@@ -22,7 +33,7 @@ class MethodIntegrator extends PluginAccessAbstract implements PluginAccessInter
|
|
22 |
return null;
|
23 |
}
|
24 |
|
25 |
-
$method->convert_paths( $paths );
|
26 |
return [
|
27 |
'errors' => apply_filters( 'webpc_convert_errors', $method->get_errors() ),
|
28 |
'size' => [
|
@@ -42,11 +53,10 @@ class MethodIntegrator extends PluginAccessAbstract implements PluginAccessInter
|
|
42 |
return null;
|
43 |
}
|
44 |
|
45 |
-
$method_key = $this->
|
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() );
|
50 |
return $method;
|
51 |
}
|
52 |
}
|
2 |
|
3 |
namespace WebpConverter\Conversion\Method;
|
4 |
|
5 |
+
use WebpConverter\PluginData;
|
|
|
6 |
|
7 |
/**
|
8 |
* Initializes image conversion using active image conversion method.
|
9 |
*/
|
10 |
+
class MethodIntegrator {
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @var PluginData .
|
14 |
+
*/
|
15 |
+
private $plugin_data;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @param PluginData $plugin_data .
|
19 |
+
*/
|
20 |
+
public function __construct( PluginData $plugin_data ) {
|
21 |
+
$this->plugin_data = $plugin_data;
|
22 |
+
}
|
23 |
|
24 |
/**
|
25 |
* Initializes converting source images using active and set conversion method.
|
33 |
return null;
|
34 |
}
|
35 |
|
36 |
+
$method->convert_paths( $paths, $this->plugin_data->get_plugin_settings() );
|
37 |
return [
|
38 |
'errors' => apply_filters( 'webpc_convert_errors', $method->get_errors() ),
|
39 |
'size' => [
|
53 |
return null;
|
54 |
}
|
55 |
|
56 |
+
$method_key = $this->plugin_data->get_plugin_settings()['method'] ?? '';
|
57 |
$methods = ( new MethodFactory() )->get_methods_objects();
|
58 |
foreach ( $methods as $method_name => $method ) {
|
59 |
if ( $method_key === $method_name ) {
|
|
|
60 |
return $method;
|
61 |
}
|
62 |
}
|
src/Conversion/Method/MethodInterface.php
CHANGED
@@ -2,13 +2,10 @@
|
|
2 |
|
3 |
namespace WebpConverter\Conversion\Method;
|
4 |
|
5 |
-
use WebpConverter\PluginAccessInterface;
|
6 |
-
use WebpConverter\Conversion\Exception;
|
7 |
-
|
8 |
/**
|
9 |
* Interface for class that supports image conversion method.
|
10 |
*/
|
11 |
-
interface MethodInterface
|
12 |
|
13 |
/**
|
14 |
* Returns name of conversion method.
|
@@ -64,23 +61,23 @@ interface MethodInterface extends PluginAccessInterface {
|
|
64 |
/**
|
65 |
* Converts source paths to output formats.
|
66 |
*
|
67 |
-
* @param string[] $paths
|
|
|
68 |
*
|
69 |
* @return void
|
70 |
*/
|
71 |
-
public function convert_paths( array $paths );
|
72 |
|
73 |
/**
|
74 |
* Converts source path to output formats.
|
75 |
*
|
76 |
-
* @param string
|
77 |
-
* @param string
|
|
|
78 |
*
|
79 |
* @return mixed[] Results data of conversion.
|
80 |
-
* @throws Exception\OutputPathException
|
81 |
-
* @throws Exception\SourcePathException
|
82 |
*/
|
83 |
-
public function convert_path( string $path, string $format ): array;
|
84 |
|
85 |
/**
|
86 |
* Checks server path of source image.
|
@@ -88,21 +85,18 @@ interface MethodInterface extends PluginAccessInterface {
|
|
88 |
* @param string $source_path Server path of source image.
|
89 |
*
|
90 |
* @return string Server path of source image.
|
91 |
-
* @throws Exception\SourcePathException
|
92 |
*/
|
93 |
public function get_image_source_path( string $source_path ): string;
|
94 |
|
95 |
/**
|
96 |
* Creates image object based on source path.
|
97 |
*
|
98 |
-
* @param string
|
|
|
99 |
*
|
100 |
* @return mixed Image object.
|
101 |
-
* @throws Exception\ExtensionUnsupportedException
|
102 |
-
* @throws Exception\FunctionUnavailableException
|
103 |
-
* @throws Exception\ImageInvalidException
|
104 |
*/
|
105 |
-
public function create_image_by_path( string $source_path );
|
106 |
|
107 |
/**
|
108 |
* Returns server path for output image.
|
@@ -111,21 +105,21 @@ interface MethodInterface extends PluginAccessInterface {
|
|
111 |
* @param string $format Extension of output format.
|
112 |
*
|
113 |
* @return string Server path of output image.
|
114 |
-
* @throws Exception\OutputPathException
|
115 |
*/
|
116 |
public function get_image_output_path( string $source_path, string $format ): string;
|
117 |
|
118 |
/**
|
119 |
* Converts image and saves to output location.
|
120 |
*
|
121 |
-
* @param mixed
|
122 |
-
* @param string
|
123 |
-
* @param string
|
124 |
-
* @param string
|
|
|
125 |
*
|
126 |
* @return void
|
127 |
*/
|
128 |
-
public function convert_image_to_output( $image, string $source_path, string $output_path, string $format );
|
129 |
|
130 |
/**
|
131 |
* Returns results data of conversion.
|
2 |
|
3 |
namespace WebpConverter\Conversion\Method;
|
4 |
|
|
|
|
|
|
|
5 |
/**
|
6 |
* Interface for class that supports image conversion method.
|
7 |
*/
|
8 |
+
interface MethodInterface {
|
9 |
|
10 |
/**
|
11 |
* Returns name of conversion method.
|
61 |
/**
|
62 |
* Converts source paths to output formats.
|
63 |
*
|
64 |
+
* @param string[] $paths Server paths of source images.
|
65 |
+
* @param mixed[] $plugin_settings Settings of plugin.
|
66 |
*
|
67 |
* @return void
|
68 |
*/
|
69 |
+
public function convert_paths( array $paths, array $plugin_settings );
|
70 |
|
71 |
/**
|
72 |
* Converts source path to output formats.
|
73 |
*
|
74 |
+
* @param string $path Server path of source image.
|
75 |
+
* @param string $format Extension of output format.
|
76 |
+
* @param mixed[] $plugin_settings Settings of plugin.
|
77 |
*
|
78 |
* @return mixed[] Results data of conversion.
|
|
|
|
|
79 |
*/
|
80 |
+
public function convert_path( string $path, string $format, array $plugin_settings ): array;
|
81 |
|
82 |
/**
|
83 |
* Checks server path of source image.
|
85 |
* @param string $source_path Server path of source image.
|
86 |
*
|
87 |
* @return string Server path of source image.
|
|
|
88 |
*/
|
89 |
public function get_image_source_path( string $source_path ): string;
|
90 |
|
91 |
/**
|
92 |
* Creates image object based on source path.
|
93 |
*
|
94 |
+
* @param string $source_path Server path of source image.
|
95 |
+
* @param mixed[] $plugin_settings Settings of plugin.
|
96 |
*
|
97 |
* @return mixed Image object.
|
|
|
|
|
|
|
98 |
*/
|
99 |
+
public function create_image_by_path( string $source_path, array $plugin_settings );
|
100 |
|
101 |
/**
|
102 |
* Returns server path for output image.
|
105 |
* @param string $format Extension of output format.
|
106 |
*
|
107 |
* @return string Server path of output image.
|
|
|
108 |
*/
|
109 |
public function get_image_output_path( string $source_path, string $format ): string;
|
110 |
|
111 |
/**
|
112 |
* Converts image and saves to output location.
|
113 |
*
|
114 |
+
* @param mixed $image Image object.
|
115 |
+
* @param string $source_path Server path of source image.
|
116 |
+
* @param string $output_path Server path for output image.
|
117 |
+
* @param string $format Extension of output format.
|
118 |
+
* @param mixed[] $plugin_settings Settings of plugin.
|
119 |
*
|
120 |
* @return void
|
121 |
*/
|
122 |
+
public function convert_image_to_output( $image, string $source_path, string $output_path, string $format, array $plugin_settings );
|
123 |
|
124 |
/**
|
125 |
* Returns results data of conversion.
|
src/Conversion/SkipExists.php
CHANGED
@@ -2,20 +2,29 @@
|
|
2 |
|
3 |
namespace WebpConverter\Conversion;
|
4 |
|
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.
|
12 |
*/
|
13 |
-
class SkipExists
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
*/
|
20 |
public function init_hooks() {
|
21 |
add_filter( 'webpc_files_paths', [ $this, 'skip_exists_images' ], 10, 2 );
|
@@ -60,7 +69,7 @@ class SkipExists extends PluginAccessAbstract implements PluginAccessInterface,
|
|
60 |
* @return string[] Available output extensions.
|
61 |
*/
|
62 |
private function get_output_extensions(): array {
|
63 |
-
$settings = $this->
|
64 |
$extensions = ( new FormatFactory() )->get_available_formats( $settings['method'] );
|
65 |
|
66 |
$values = [];
|
2 |
|
3 |
namespace WebpConverter\Conversion;
|
4 |
|
|
|
|
|
5 |
use WebpConverter\HookableInterface;
|
6 |
use WebpConverter\Conversion\Format\FormatFactory;
|
7 |
+
use WebpConverter\PluginData;
|
8 |
|
9 |
/**
|
10 |
* Removes from list of source file paths those that have already been converted.
|
11 |
*/
|
12 |
+
class SkipExists implements HookableInterface {
|
13 |
|
14 |
/**
|
15 |
+
* @var PluginData .
|
16 |
+
*/
|
17 |
+
private $plugin_data;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* @param PluginData $plugin_data .
|
21 |
+
*/
|
22 |
+
public function __construct( PluginData $plugin_data ) {
|
23 |
+
$this->plugin_data = $plugin_data;
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* {@inheritdoc}
|
28 |
*/
|
29 |
public function init_hooks() {
|
30 |
add_filter( 'webpc_files_paths', [ $this, 'skip_exists_images' ], 10, 2 );
|
69 |
* @return string[] Available output extensions.
|
70 |
*/
|
71 |
private function get_output_extensions(): array {
|
72 |
+
$settings = $this->plugin_data->get_plugin_settings();
|
73 |
$extensions = ( new FormatFactory() )->get_available_formats( $settings['method'] );
|
74 |
|
75 |
$values = [];
|
src/Conversion/SkipLarger.php
CHANGED
@@ -2,22 +2,31 @@
|
|
2 |
|
3 |
namespace WebpConverter\Conversion;
|
4 |
|
5 |
-
use WebpConverter\PluginAccessAbstract;
|
6 |
-
use WebpConverter\PluginAccessInterface;
|
7 |
use WebpConverter\HookableInterface;
|
8 |
use WebpConverter\Conversion\Exception;
|
|
|
9 |
|
10 |
/**
|
11 |
* Deletes output after conversion if it is larger than original.
|
12 |
*/
|
13 |
-
class SkipLarger
|
14 |
|
15 |
const DELETED_FILE_EXTENSION = 'deleted';
|
16 |
|
17 |
/**
|
18 |
-
*
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
*/
|
22 |
public function init_hooks() {
|
23 |
add_action( 'webpc_convert_after', [ $this, 'remove_image_if_is_larger' ], 10, 2 );
|
@@ -34,7 +43,7 @@ class SkipLarger extends PluginAccessAbstract implements PluginAccessInterface,
|
|
34 |
* @internal
|
35 |
*/
|
36 |
public function remove_image_if_is_larger( string $webp_path, string $original_path ) {
|
37 |
-
if ( ( ! $settings = $this->
|
38 |
|| ! in_array( 'only_smaller', $settings['features'] )
|
39 |
|| ( ! file_exists( $webp_path ) || ! file_exists( $original_path ) )
|
40 |
|| ( filesize( $webp_path ) < filesize( $original_path ) ) ) {
|
2 |
|
3 |
namespace WebpConverter\Conversion;
|
4 |
|
|
|
|
|
5 |
use WebpConverter\HookableInterface;
|
6 |
use WebpConverter\Conversion\Exception;
|
7 |
+
use WebpConverter\PluginData;
|
8 |
|
9 |
/**
|
10 |
* Deletes output after conversion if it is larger than original.
|
11 |
*/
|
12 |
+
class SkipLarger implements HookableInterface {
|
13 |
|
14 |
const DELETED_FILE_EXTENSION = 'deleted';
|
15 |
|
16 |
/**
|
17 |
+
* @var PluginData .
|
18 |
+
*/
|
19 |
+
private $plugin_data;
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @param PluginData $plugin_data .
|
23 |
+
*/
|
24 |
+
public function __construct( PluginData $plugin_data ) {
|
25 |
+
$this->plugin_data = $plugin_data;
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* {@inheritdoc}
|
30 |
*/
|
31 |
public function init_hooks() {
|
32 |
add_action( 'webpc_convert_after', [ $this, 'remove_image_if_is_larger' ], 10, 2 );
|
43 |
* @internal
|
44 |
*/
|
45 |
public function remove_image_if_is_larger( string $webp_path, string $original_path ) {
|
46 |
+
if ( ( ! $settings = $this->plugin_data->get_plugin_settings() )
|
47 |
|| ! in_array( 'only_smaller', $settings['features'] )
|
48 |
|| ( ! file_exists( $webp_path ) || ! file_exists( $original_path ) )
|
49 |
|| ( filesize( $webp_path ) < filesize( $original_path ) ) ) {
|
src/Error/ErrorAbstract.php
DELETED
@@ -1,21 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WebpConverter\Error;
|
4 |
-
|
5 |
-
use WebpConverter\PluginAccessAbstract;
|
6 |
-
use WebpConverter\PluginAccessInterface;
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Abstract class for class that checks for configuration errors.
|
10 |
-
*/
|
11 |
-
abstract class ErrorAbstract extends PluginAccessAbstract implements PluginAccessInterface, ErrorInterface {
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Returns list of error codes.
|
15 |
-
*
|
16 |
-
* @return string[] Error codes.
|
17 |
-
*/
|
18 |
-
public function get_error_codes(): array {
|
19 |
-
return [];
|
20 |
-
}
|
21 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/Error/ErrorFactory.php
CHANGED
@@ -3,20 +3,24 @@
|
|
3 |
namespace WebpConverter\Error;
|
4 |
|
5 |
use WebpConverter\Loader\PassthruLoader;
|
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
|
15 |
|
16 |
const ERRORS_CACHE_OPTION = 'webpc_errors_cache';
|
17 |
const ALLOWED_ERROR_KEYS = [ 'rewrites_cached' ];
|
18 |
const ERROR_FILE_PATH = 'components/errors/%s.php';
|
19 |
|
|
|
|
|
|
|
|
|
|
|
20 |
/**
|
21 |
* List of error codes saved in cache.
|
22 |
*
|
@@ -25,9 +29,14 @@ class ErrorFactory extends PluginAccessAbstract implements PluginAccessInterface
|
|
25 |
private $cache = [];
|
26 |
|
27 |
/**
|
28 |
-
*
|
29 |
-
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
31 |
*/
|
32 |
public function init_hooks() {
|
33 |
add_filter( 'webpc_server_errors', [ $this, 'get_server_errors' ], 10, 3 );
|
@@ -105,29 +114,29 @@ class ErrorFactory extends PluginAccessAbstract implements PluginAccessInterface
|
|
105 |
private function get_errors_list(): array {
|
106 |
$errors = [];
|
107 |
|
108 |
-
if ( $new_errors =
|
109 |
$errors = array_merge( $errors, $new_errors );
|
110 |
-
} elseif ( $new_errors =
|
111 |
$errors = array_merge( $errors, $new_errors );
|
112 |
-
} elseif ( $new_errors =
|
113 |
$errors = array_merge( $errors, $new_errors );
|
114 |
}
|
115 |
|
116 |
-
if ( $new_errors =
|
117 |
$errors = array_merge( $errors, $new_errors );
|
118 |
}
|
119 |
|
120 |
-
if ( $new_errors =
|
121 |
$errors = array_merge( $errors, $new_errors );
|
122 |
}
|
123 |
|
124 |
-
if ( $new_errors =
|
125 |
$errors = array_merge( $errors, $new_errors );
|
126 |
-
} elseif ( $new_errors =
|
127 |
$errors = array_merge( $errors, $new_errors );
|
128 |
}
|
129 |
|
130 |
-
if ( ! $errors && ( $new_errors =
|
131 |
$errors = array_merge( $errors, $new_errors );
|
132 |
}
|
133 |
|
@@ -136,16 +145,4 @@ class ErrorFactory extends PluginAccessAbstract implements PluginAccessInterface
|
|
136 |
|
137 |
return $errors;
|
138 |
}
|
139 |
-
|
140 |
-
/**
|
141 |
-
* Returns list of error codes for errors detector.
|
142 |
-
*
|
143 |
-
* @param ErrorInterface $error .
|
144 |
-
*
|
145 |
-
* @return string[] Error codes.
|
146 |
-
*/
|
147 |
-
private function get_errors_by_detector( ErrorInterface $error ): array {
|
148 |
-
$error->set_plugin( $this->get_plugin() );
|
149 |
-
return $error->get_error_codes();
|
150 |
-
}
|
151 |
}
|
3 |
namespace WebpConverter\Error;
|
4 |
|
5 |
use WebpConverter\Loader\PassthruLoader;
|
|
|
|
|
6 |
use WebpConverter\HookableInterface;
|
7 |
use WebpConverter\Helper\ViewLoader;
|
8 |
+
use WebpConverter\PluginData;
|
9 |
|
10 |
/**
|
11 |
* Supports generating list of server configuration errors.
|
12 |
*/
|
13 |
+
class ErrorFactory implements HookableInterface {
|
14 |
|
15 |
const ERRORS_CACHE_OPTION = 'webpc_errors_cache';
|
16 |
const ALLOWED_ERROR_KEYS = [ 'rewrites_cached' ];
|
17 |
const ERROR_FILE_PATH = 'components/errors/%s.php';
|
18 |
|
19 |
+
/**
|
20 |
+
* @var PluginData .
|
21 |
+
*/
|
22 |
+
private $plugin_data;
|
23 |
+
|
24 |
/**
|
25 |
* List of error codes saved in cache.
|
26 |
*
|
29 |
private $cache = [];
|
30 |
|
31 |
/**
|
32 |
+
* @param PluginData $plugin_data .
|
33 |
+
*/
|
34 |
+
public function __construct( PluginData $plugin_data ) {
|
35 |
+
$this->plugin_data = $plugin_data;
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* {@inheritdoc}
|
40 |
*/
|
41 |
public function init_hooks() {
|
42 |
add_filter( 'webpc_server_errors', [ $this, 'get_server_errors' ], 10, 3 );
|
114 |
private function get_errors_list(): array {
|
115 |
$errors = [];
|
116 |
|
117 |
+
if ( $new_errors = ( new LibsInstalledError() )->get_error_codes() ) {
|
118 |
$errors = array_merge( $errors, $new_errors );
|
119 |
+
} elseif ( $new_errors = ( new LibsSupportWebpError() )->get_error_codes() ) {
|
120 |
$errors = array_merge( $errors, $new_errors );
|
121 |
+
} elseif ( $new_errors = ( new LibsSupportAvifError( $this->plugin_data ) )->get_error_codes() ) {
|
122 |
$errors = array_merge( $errors, $new_errors );
|
123 |
}
|
124 |
|
125 |
+
if ( $new_errors = ( new RestapiError() )->get_error_codes() ) {
|
126 |
$errors = array_merge( $errors, $new_errors );
|
127 |
}
|
128 |
|
129 |
+
if ( $new_errors = ( new PathsError() )->get_error_codes() ) {
|
130 |
$errors = array_merge( $errors, $new_errors );
|
131 |
}
|
132 |
|
133 |
+
if ( $new_errors = ( new PassthruError( $this->plugin_data ) )->get_error_codes() ) {
|
134 |
$errors = array_merge( $errors, $new_errors );
|
135 |
+
} elseif ( $new_errors = ( new RewritesError( $this->plugin_data ) )->get_error_codes() ) {
|
136 |
$errors = array_merge( $errors, $new_errors );
|
137 |
}
|
138 |
|
139 |
+
if ( ! $errors && ( $new_errors = ( new SettingsError( $this->plugin_data ) )->get_error_codes() ) ) {
|
140 |
$errors = array_merge( $errors, $new_errors );
|
141 |
}
|
142 |
|
145 |
|
146 |
return $errors;
|
147 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
}
|
src/Error/ErrorInterface.php
CHANGED
@@ -2,12 +2,10 @@
|
|
2 |
|
3 |
namespace WebpConverter\Error;
|
4 |
|
5 |
-
use WebpConverter\PluginAccessInterface;
|
6 |
-
|
7 |
/**
|
8 |
* Interface for class that checks for configuration errors.
|
9 |
*/
|
10 |
-
interface ErrorInterface
|
11 |
|
12 |
/**
|
13 |
* Returns list of error codes.
|
2 |
|
3 |
namespace WebpConverter\Error;
|
4 |
|
|
|
|
|
5 |
/**
|
6 |
* Interface for class that checks for configuration errors.
|
7 |
*/
|
8 |
+
interface ErrorInterface {
|
9 |
|
10 |
/**
|
11 |
* Returns list of error codes.
|
src/Error/LibsInstalledError.php
CHANGED
@@ -8,12 +8,10 @@ use WebpConverter\Conversion\Method\ImagickMethod;
|
|
8 |
/**
|
9 |
* Checks for configuration errors about non-installed methods for converting images.
|
10 |
*/
|
11 |
-
class LibsInstalledError
|
12 |
|
13 |
/**
|
14 |
-
*
|
15 |
-
*
|
16 |
-
* @return string[] Error codes.
|
17 |
*/
|
18 |
public function get_error_codes(): array {
|
19 |
$errors = [];
|
8 |
/**
|
9 |
* Checks for configuration errors about non-installed methods for converting images.
|
10 |
*/
|
11 |
+
class LibsInstalledError implements ErrorInterface {
|
12 |
|
13 |
/**
|
14 |
+
* {@inheritdoc}
|
|
|
|
|
15 |
*/
|
16 |
public function get_error_codes(): array {
|
17 |
$errors = [];
|
src/Error/LibsSupportAvifError.php
CHANGED
@@ -5,19 +5,30 @@ namespace WebpConverter\Error;
|
|
5 |
use WebpConverter\Conversion\Method\GdMethod;
|
6 |
use WebpConverter\Conversion\Method\ImagickMethod;
|
7 |
use WebpConverter\Conversion\Format\AvifFormat;
|
|
|
8 |
|
9 |
/**
|
10 |
* Checks for configuration errors about image conversion methods that do not support AVIF output format.
|
11 |
*/
|
12 |
-
class LibsSupportAvifError
|
13 |
|
14 |
/**
|
15 |
-
*
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
*/
|
19 |
public function get_error_codes(): array {
|
20 |
-
$output_formats = $this->
|
21 |
$errors = [];
|
22 |
|
23 |
if ( in_array( AvifFormat::FORMAT_EXTENSION, $output_formats )
|
5 |
use WebpConverter\Conversion\Method\GdMethod;
|
6 |
use WebpConverter\Conversion\Method\ImagickMethod;
|
7 |
use WebpConverter\Conversion\Format\AvifFormat;
|
8 |
+
use WebpConverter\PluginData;
|
9 |
|
10 |
/**
|
11 |
* Checks for configuration errors about image conversion methods that do not support AVIF output format.
|
12 |
*/
|
13 |
+
class LibsSupportAvifError implements ErrorInterface {
|
14 |
|
15 |
/**
|
16 |
+
* @var PluginData .
|
17 |
+
*/
|
18 |
+
private $plugin_data;
|
19 |
+
|
20 |
+
/**
|
21 |
+
* @param PluginData $plugin_data .
|
22 |
+
*/
|
23 |
+
public function __construct( PluginData $plugin_data ) {
|
24 |
+
$this->plugin_data = $plugin_data;
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* {@inheritdoc}
|
29 |
*/
|
30 |
public function get_error_codes(): array {
|
31 |
+
$output_formats = $this->plugin_data->get_plugin_settings()['output_formats'] ?? [];
|
32 |
$errors = [];
|
33 |
|
34 |
if ( in_array( AvifFormat::FORMAT_EXTENSION, $output_formats )
|
src/Error/LibsSupportWebpError.php
CHANGED
@@ -10,12 +10,10 @@ use WebpConverter\Conversion\Format\FormatFactory;
|
|
10 |
/**
|
11 |
* Checks for configuration errors about image conversion methods that do not support WebP output format.
|
12 |
*/
|
13 |
-
class LibsSupportWebpError
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
-
*
|
18 |
-
* @return string[] Error codes.
|
19 |
*/
|
20 |
public function get_error_codes(): array {
|
21 |
$errors = [];
|
10 |
/**
|
11 |
* Checks for configuration errors about image conversion methods that do not support WebP output format.
|
12 |
*/
|
13 |
+
class LibsSupportWebpError implements ErrorInterface {
|
14 |
|
15 |
/**
|
16 |
+
* {@inheritdoc}
|
|
|
|
|
17 |
*/
|
18 |
public function get_error_codes(): array {
|
19 |
$errors = [];
|
src/Error/PassthruError.php
CHANGED
@@ -4,16 +4,27 @@ namespace WebpConverter\Error;
|
|
4 |
|
5 |
use WebpConverter\Loader\LoaderAbstract;
|
6 |
use WebpConverter\Loader\PassthruLoader;
|
|
|
7 |
|
8 |
/**
|
9 |
* Checks for configuration errors about disabled file supports Pass Thru loader.
|
10 |
*/
|
11 |
-
class PassthruError
|
12 |
|
13 |
/**
|
14 |
-
*
|
15 |
-
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
*/
|
18 |
public function get_error_codes(): array {
|
19 |
$errors = [];
|
@@ -35,8 +46,7 @@ class PassthruError extends ErrorAbstract implements ErrorInterface {
|
|
35 |
* @return bool Verification status.
|
36 |
*/
|
37 |
private function if_passthru_execution_allowed(): bool {
|
38 |
-
$loader = new PassthruLoader();
|
39 |
-
$loader->set_plugin( $this->get_plugin() );
|
40 |
if ( $loader->is_active_loader() !== true ) {
|
41 |
return true;
|
42 |
}
|
4 |
|
5 |
use WebpConverter\Loader\LoaderAbstract;
|
6 |
use WebpConverter\Loader\PassthruLoader;
|
7 |
+
use WebpConverter\PluginData;
|
8 |
|
9 |
/**
|
10 |
* Checks for configuration errors about disabled file supports Pass Thru loader.
|
11 |
*/
|
12 |
+
class PassthruError implements ErrorInterface {
|
13 |
|
14 |
/**
|
15 |
+
* @var PluginData .
|
16 |
+
*/
|
17 |
+
private $plugin_data;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* @param PluginData $plugin_data .
|
21 |
+
*/
|
22 |
+
public function __construct( PluginData $plugin_data ) {
|
23 |
+
$this->plugin_data = $plugin_data;
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* {@inheritdoc}
|
28 |
*/
|
29 |
public function get_error_codes(): array {
|
30 |
$errors = [];
|
46 |
* @return bool Verification status.
|
47 |
*/
|
48 |
private function if_passthru_execution_allowed(): bool {
|
49 |
+
$loader = new PassthruLoader( $this->plugin_data );
|
|
|
50 |
if ( $loader->is_active_loader() !== true ) {
|
51 |
return true;
|
52 |
}
|
src/Error/PathsError.php
CHANGED
@@ -5,12 +5,10 @@ namespace WebpConverter\Error;
|
|
5 |
/**
|
6 |
* Checks for configuration errors about incorrect paths of directories.
|
7 |
*/
|
8 |
-
class PathsError
|
9 |
|
10 |
/**
|
11 |
-
*
|
12 |
-
*
|
13 |
-
* @return string[] Error codes.
|
14 |
*/
|
15 |
public function get_error_codes(): array {
|
16 |
$errors = [];
|
5 |
/**
|
6 |
* Checks for configuration errors about incorrect paths of directories.
|
7 |
*/
|
8 |
+
class PathsError implements ErrorInterface {
|
9 |
|
10 |
/**
|
11 |
+
* {@inheritdoc}
|
|
|
|
|
12 |
*/
|
13 |
public function get_error_codes(): array {
|
14 |
$errors = [];
|
src/Error/RestapiError.php
CHANGED
@@ -5,12 +5,10 @@ namespace WebpConverter\Error;
|
|
5 |
/**
|
6 |
* Checks for configuration errors about disabled REST API.
|
7 |
*/
|
8 |
-
class RestapiError
|
9 |
|
10 |
/**
|
11 |
-
*
|
12 |
-
*
|
13 |
-
* @return string[] Error codes.
|
14 |
*/
|
15 |
public function get_error_codes(): array {
|
16 |
$errors = [];
|
5 |
/**
|
6 |
* Checks for configuration errors about disabled REST API.
|
7 |
*/
|
8 |
+
class RestapiError implements ErrorInterface {
|
9 |
|
10 |
/**
|
11 |
+
* {@inheritdoc}
|
|
|
|
|
12 |
*/
|
13 |
public function get_error_codes(): array {
|
14 |
$errors = [];
|
src/Error/RewritesError.php
CHANGED
@@ -6,11 +6,12 @@ use WebpConverter\Conversion\OutputPath;
|
|
6 |
use WebpConverter\Conversion\Format\WebpFormat;
|
7 |
use WebpConverter\Loader\LoaderAbstract;
|
8 |
use WebpConverter\Helper\FileLoader;
|
|
|
9 |
|
10 |
/**
|
11 |
* Checks for configuration errors about non-working HTTP rewrites.
|
12 |
*/
|
13 |
-
class RewritesError
|
14 |
|
15 |
const PATH_SOURCE_FILE_PNG = '/assets/img/icon-test.png';
|
16 |
const PATH_SOURCE_FILE_WEBP = '/assets/img/icon-test.webp';
|
@@ -18,12 +19,22 @@ class RewritesError extends ErrorAbstract implements ErrorInterface {
|
|
18 |
const PATH_OUTPUT_FILE_PNG2 = '/webp-converter-for-media-test.png2';
|
19 |
|
20 |
/**
|
21 |
-
*
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
*/
|
25 |
public function get_error_codes(): array {
|
26 |
-
$settings = $this->
|
27 |
$errors = [];
|
28 |
if ( ! $settings['dirs'] || ! $settings['output_formats'] ) {
|
29 |
return $errors;
|
@@ -90,7 +101,7 @@ class RewritesError extends ErrorAbstract implements ErrorInterface {
|
|
90 |
);
|
91 |
$file_webp = FileLoader::get_file_size_by_url(
|
92 |
$uploads_url . self::PATH_OUTPUT_FILE_PNG,
|
93 |
-
$this->
|
94 |
true,
|
95 |
$ver_param
|
96 |
);
|
@@ -109,13 +120,13 @@ class RewritesError extends ErrorAbstract implements ErrorInterface {
|
|
109 |
|
110 |
$file_png = FileLoader::get_file_size_by_url(
|
111 |
$uploads_url . self::PATH_OUTPUT_FILE_PNG,
|
112 |
-
$this->
|
113 |
true,
|
114 |
$ver_param
|
115 |
);
|
116 |
$file_png2 = FileLoader::get_file_size_by_url(
|
117 |
$uploads_url . self::PATH_OUTPUT_FILE_PNG2,
|
118 |
-
$this->
|
119 |
true,
|
120 |
$ver_param
|
121 |
);
|
@@ -134,13 +145,13 @@ class RewritesError extends ErrorAbstract implements ErrorInterface {
|
|
134 |
|
135 |
$file_webp = FileLoader::get_file_size_by_url(
|
136 |
$uploads_url . self::PATH_OUTPUT_FILE_PNG,
|
137 |
-
$this->
|
138 |
true,
|
139 |
$ver_param
|
140 |
);
|
141 |
$file_original = FileLoader::get_file_size_by_url(
|
142 |
$uploads_url . self::PATH_OUTPUT_FILE_PNG,
|
143 |
-
$this->
|
144 |
false,
|
145 |
$ver_param
|
146 |
);
|
6 |
use WebpConverter\Conversion\Format\WebpFormat;
|
7 |
use WebpConverter\Loader\LoaderAbstract;
|
8 |
use WebpConverter\Helper\FileLoader;
|
9 |
+
use WebpConverter\PluginData;
|
10 |
|
11 |
/**
|
12 |
* Checks for configuration errors about non-working HTTP rewrites.
|
13 |
*/
|
14 |
+
class RewritesError implements ErrorInterface {
|
15 |
|
16 |
const PATH_SOURCE_FILE_PNG = '/assets/img/icon-test.png';
|
17 |
const PATH_SOURCE_FILE_WEBP = '/assets/img/icon-test.webp';
|
19 |
const PATH_OUTPUT_FILE_PNG2 = '/webp-converter-for-media-test.png2';
|
20 |
|
21 |
/**
|
22 |
+
* @var PluginData .
|
23 |
+
*/
|
24 |
+
private $plugin_data;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* @param PluginData $plugin_data .
|
28 |
+
*/
|
29 |
+
public function __construct( PluginData $plugin_data ) {
|
30 |
+
$this->plugin_data = $plugin_data;
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* {@inheritdoc}
|
35 |
*/
|
36 |
public function get_error_codes(): array {
|
37 |
+
$settings = $this->plugin_data->get_plugin_settings();
|
38 |
$errors = [];
|
39 |
if ( ! $settings['dirs'] || ! $settings['output_formats'] ) {
|
40 |
return $errors;
|
101 |
);
|
102 |
$file_webp = FileLoader::get_file_size_by_url(
|
103 |
$uploads_url . self::PATH_OUTPUT_FILE_PNG,
|
104 |
+
$this->plugin_data,
|
105 |
true,
|
106 |
$ver_param
|
107 |
);
|
120 |
|
121 |
$file_png = FileLoader::get_file_size_by_url(
|
122 |
$uploads_url . self::PATH_OUTPUT_FILE_PNG,
|
123 |
+
$this->plugin_data,
|
124 |
true,
|
125 |
$ver_param
|
126 |
);
|
127 |
$file_png2 = FileLoader::get_file_size_by_url(
|
128 |
$uploads_url . self::PATH_OUTPUT_FILE_PNG2,
|
129 |
+
$this->plugin_data,
|
130 |
true,
|
131 |
$ver_param
|
132 |
);
|
145 |
|
146 |
$file_webp = FileLoader::get_file_size_by_url(
|
147 |
$uploads_url . self::PATH_OUTPUT_FILE_PNG,
|
148 |
+
$this->plugin_data,
|
149 |
true,
|
150 |
$ver_param
|
151 |
);
|
152 |
$file_original = FileLoader::get_file_size_by_url(
|
153 |
$uploads_url . self::PATH_OUTPUT_FILE_PNG,
|
154 |
+
$this->plugin_data,
|
155 |
false,
|
156 |
$ver_param
|
157 |
);
|
src/Error/SettingsError.php
CHANGED
@@ -2,17 +2,27 @@
|
|
2 |
|
3 |
namespace WebpConverter\Error;
|
4 |
|
5 |
-
use WebpConverter\
|
6 |
|
7 |
/**
|
8 |
* Checks for configuration errors about incorrectly saved plugin settings.
|
9 |
*/
|
10 |
-
class SettingsError
|
11 |
|
12 |
/**
|
13 |
-
*
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
*/
|
17 |
public function get_error_codes(): array {
|
18 |
$errors = [];
|
@@ -29,7 +39,7 @@ class SettingsError extends ErrorAbstract implements PluginAccessInterface, Erro
|
|
29 |
* @return bool Verification status.
|
30 |
*/
|
31 |
private function if_settings_are_correct(): bool {
|
32 |
-
$settings = $this->
|
33 |
if ( ( ! isset( $settings['extensions'] ) || ! $settings['extensions'] )
|
34 |
|| ( ! isset( $settings['dirs'] ) || ! $settings['dirs'] )
|
35 |
|| ( ! isset( $settings['method'] ) || ! $settings['method'] )
|
2 |
|
3 |
namespace WebpConverter\Error;
|
4 |
|
5 |
+
use WebpConverter\PluginData;
|
6 |
|
7 |
/**
|
8 |
* Checks for configuration errors about incorrectly saved plugin settings.
|
9 |
*/
|
10 |
+
class SettingsError implements ErrorInterface {
|
11 |
|
12 |
/**
|
13 |
+
* @var PluginData .
|
14 |
+
*/
|
15 |
+
private $plugin_data;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @param PluginData $plugin_data .
|
19 |
+
*/
|
20 |
+
public function __construct( PluginData $plugin_data ) {
|
21 |
+
$this->plugin_data = $plugin_data;
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* {@inheritdoc}
|
26 |
*/
|
27 |
public function get_error_codes(): array {
|
28 |
$errors = [];
|
39 |
* @return bool Verification status.
|
40 |
*/
|
41 |
private function if_settings_are_correct(): bool {
|
42 |
+
$settings = $this->plugin_data->get_plugin_settings();
|
43 |
if ( ( ! isset( $settings['extensions'] ) || ! $settings['extensions'] )
|
44 |
|| ( ! isset( $settings['dirs'] ) || ! $settings['dirs'] )
|
45 |
|| ( ! isset( $settings['method'] ) || ! $settings['method'] )
|
src/Helper/FileLoader.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
namespace WebpConverter\Helper;
|
4 |
|
5 |
use WebpConverter\Loader\PassthruLoader;
|
6 |
-
use WebpConverter\
|
7 |
|
8 |
/**
|
9 |
* Returns size of image downloaded based on server path or URL.
|
@@ -13,23 +13,20 @@ class FileLoader {
|
|
13 |
/**
|
14 |
* Checks size of file by sending request using active image loader.
|
15 |
*
|
16 |
-
* @param string
|
17 |
-
* @param
|
18 |
-
* @param bool
|
19 |
-
* @param string
|
20 |
*
|
21 |
* @return int Size of retrieved file.
|
22 |
*/
|
23 |
-
public static function get_file_size_by_url( string $url,
|
24 |
$headers = [
|
25 |
'Accept: image/webp',
|
26 |
'Referer: ' . WEBPC_URL,
|
27 |
];
|
28 |
|
29 |
-
$
|
30 |
-
$loader->set_plugin( $plugin );
|
31 |
-
|
32 |
-
$image_url = $loader->update_image_urls( $url, true );
|
33 |
if ( $extra_param ) {
|
34 |
$image_url .= ( ( strpos( $image_url, '?' ) !== false ) ? '&' : '?' ) . $extra_param;
|
35 |
}
|
3 |
namespace WebpConverter\Helper;
|
4 |
|
5 |
use WebpConverter\Loader\PassthruLoader;
|
6 |
+
use WebpConverter\PluginData;
|
7 |
|
8 |
/**
|
9 |
* Returns size of image downloaded based on server path or URL.
|
13 |
/**
|
14 |
* Checks size of file by sending request using active image loader.
|
15 |
*
|
16 |
+
* @param string $url URL of image.
|
17 |
+
* @param PluginData $plugin_data .
|
18 |
+
* @param bool $set_headers Whether to send headers to confirm that browser supports WebP?
|
19 |
+
* @param string $extra_param Additional GET param.
|
20 |
*
|
21 |
* @return int Size of retrieved file.
|
22 |
*/
|
23 |
+
public static function get_file_size_by_url( string $url, PluginData $plugin_data, bool $set_headers = true, string $extra_param = '' ): int {
|
24 |
$headers = [
|
25 |
'Accept: image/webp',
|
26 |
'Referer: ' . WEBPC_URL,
|
27 |
];
|
28 |
|
29 |
+
$image_url = ( new PassthruLoader( $plugin_data ) )->update_image_urls( $url, true );
|
|
|
|
|
|
|
30 |
if ( $extra_param ) {
|
31 |
$image_url .= ( ( strpos( $image_url, '?' ) !== false ) ? '&' : '?' ) . $extra_param;
|
32 |
}
|
src/Loader/HtaccessLoader.php
CHANGED
@@ -5,29 +5,23 @@ namespace WebpConverter\Loader;
|
|
5 |
/**
|
6 |
* Supports method of loading images using rewrites from .htaccess file.
|
7 |
*/
|
8 |
-
class HtaccessLoader extends LoaderAbstract
|
9 |
|
10 |
const LOADER_TYPE = 'htaccess';
|
11 |
|
12 |
/**
|
13 |
-
*
|
14 |
-
*
|
15 |
-
* @return bool Is loader active?
|
16 |
*/
|
17 |
public function is_active_loader(): bool {
|
18 |
-
$settings = $this->
|
19 |
return ( ! isset( $settings['loader_type'] ) || ( $settings['loader_type'] === self::LOADER_TYPE ) );
|
20 |
}
|
21 |
|
22 |
/**
|
23 |
-
*
|
24 |
-
*
|
25 |
-
* @param bool $is_debug Is debugging?
|
26 |
-
*
|
27 |
-
* @return void
|
28 |
*/
|
29 |
public function activate_loader( bool $is_debug = false ) {
|
30 |
-
$settings = ( $is_debug ) ? $this->
|
31 |
|
32 |
$this->add_rewrite_rules_to_wp_content( true, $settings );
|
33 |
$this->add_rewrite_rules_to_uploads( true, $settings );
|
@@ -35,12 +29,10 @@ class HtaccessLoader extends LoaderAbstract implements LoaderInterface {
|
|
35 |
}
|
36 |
|
37 |
/**
|
38 |
-
*
|
39 |
-
*
|
40 |
-
* @return void
|
41 |
*/
|
42 |
public function deactivate_loader() {
|
43 |
-
$settings = $this->
|
44 |
|
45 |
$this->add_rewrite_rules_to_wp_content( false, $settings );
|
46 |
$this->add_rewrite_rules_to_uploads( false, $settings );
|
@@ -172,7 +164,9 @@ class HtaccessLoader extends LoaderAbstract implements LoaderInterface {
|
|
172 |
* @return string Rules for .htaccess file.
|
173 |
*/
|
174 |
private function get_mod_headers_rules( array $settings ): string {
|
175 |
-
$content
|
|
|
|
|
176 |
$content .= ' Header always set Cache-Control "private"' . PHP_EOL;
|
177 |
$content .= '</IfModule>';
|
178 |
|
5 |
/**
|
6 |
* Supports method of loading images using rewrites from .htaccess file.
|
7 |
*/
|
8 |
+
class HtaccessLoader extends LoaderAbstract {
|
9 |
|
10 |
const LOADER_TYPE = 'htaccess';
|
11 |
|
12 |
/**
|
13 |
+
* {@inheritdoc}
|
|
|
|
|
14 |
*/
|
15 |
public function is_active_loader(): bool {
|
16 |
+
$settings = $this->plugin_data->get_plugin_settings();
|
17 |
return ( ! isset( $settings['loader_type'] ) || ( $settings['loader_type'] === self::LOADER_TYPE ) );
|
18 |
}
|
19 |
|
20 |
/**
|
21 |
+
* {@inheritdoc}
|
|
|
|
|
|
|
|
|
22 |
*/
|
23 |
public function activate_loader( bool $is_debug = false ) {
|
24 |
+
$settings = ( $is_debug ) ? $this->plugin_data->get_debug_settings() : $this->plugin_data->get_plugin_settings();
|
25 |
|
26 |
$this->add_rewrite_rules_to_wp_content( true, $settings );
|
27 |
$this->add_rewrite_rules_to_uploads( true, $settings );
|
29 |
}
|
30 |
|
31 |
/**
|
32 |
+
* {@inheritdoc}
|
|
|
|
|
33 |
*/
|
34 |
public function deactivate_loader() {
|
35 |
+
$settings = $this->plugin_data->get_plugin_settings();
|
36 |
|
37 |
$this->add_rewrite_rules_to_wp_content( false, $settings );
|
38 |
$this->add_rewrite_rules_to_uploads( false, $settings );
|
164 |
* @return string Rules for .htaccess file.
|
165 |
*/
|
166 |
private function get_mod_headers_rules( array $settings ): string {
|
167 |
+
$content = '';
|
168 |
+
|
169 |
+
$content .= '<IfModule mod_headers.c>' . PHP_EOL;
|
170 |
$content .= ' Header always set Cache-Control "private"' . PHP_EOL;
|
171 |
$content .= '</IfModule>';
|
172 |
|
src/Loader/LoaderAbstract.php
CHANGED
@@ -2,32 +2,39 @@
|
|
2 |
|
3 |
namespace WebpConverter\Loader;
|
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.
|
11 |
*/
|
12 |
-
abstract class LoaderAbstract
|
13 |
|
14 |
const ACTION_NAME = 'webpc_refresh_loader';
|
15 |
|
16 |
/**
|
17 |
-
*
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
*/
|
21 |
public function init_hooks() {
|
22 |
}
|
23 |
|
24 |
/**
|
25 |
-
*
|
26 |
-
*
|
27 |
-
* @return string[] Output formats with mime types.
|
28 |
*/
|
29 |
public function get_mime_types(): array {
|
30 |
-
$settings = $this->
|
31 |
return ( new FormatFactory() )->get_mime_types( $settings['output_formats'] );
|
32 |
}
|
33 |
}
|
2 |
|
3 |
namespace WebpConverter\Loader;
|
4 |
|
|
|
|
|
5 |
use WebpConverter\Conversion\Format\FormatFactory;
|
6 |
+
use WebpConverter\PluginData;
|
7 |
|
8 |
/**
|
9 |
* Abstract class for class that supports method of loading images.
|
10 |
*/
|
11 |
+
abstract class LoaderAbstract implements LoaderInterface {
|
12 |
|
13 |
const ACTION_NAME = 'webpc_refresh_loader';
|
14 |
|
15 |
/**
|
16 |
+
* @var PluginData .
|
17 |
+
*/
|
18 |
+
protected $plugin_data;
|
19 |
+
|
20 |
+
/**
|
21 |
+
* @param PluginData $plugin_data .
|
22 |
+
*/
|
23 |
+
public function __construct( PluginData $plugin_data ) {
|
24 |
+
$this->plugin_data = $plugin_data;
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* {@inheritdoc}
|
29 |
*/
|
30 |
public function init_hooks() {
|
31 |
}
|
32 |
|
33 |
/**
|
34 |
+
* {@inheritdoc}
|
|
|
|
|
35 |
*/
|
36 |
public function get_mime_types(): array {
|
37 |
+
$settings = $this->plugin_data->get_plugin_settings();
|
38 |
return ( new FormatFactory() )->get_mime_types( $settings['output_formats'] );
|
39 |
}
|
40 |
}
|
src/Loader/LoaderFactory.php
DELETED
@@ -1,35 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WebpConverter\Loader;
|
4 |
-
|
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.
|
16 |
-
*
|
17 |
-
* @return void
|
18 |
-
*/
|
19 |
-
public function init_hooks() {
|
20 |
-
$this->set_integration( new HtaccessLoader() );
|
21 |
-
$this->set_integration( new PassthruLoader() );
|
22 |
-
}
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Sets integration for loader.
|
26 |
-
*
|
27 |
-
* @param LoaderInterface $loader .
|
28 |
-
*
|
29 |
-
* @return void
|
30 |
-
*/
|
31 |
-
private function set_integration( LoaderInterface $loader ) {
|
32 |
-
$loader->set_plugin( $this->get_plugin() );
|
33 |
-
( new LoaderIntegration( $loader ) )->set_plugin_hookable( $this->get_plugin() );
|
34 |
-
}
|
35 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/Loader/LoaderIntegration.php
CHANGED
@@ -2,14 +2,12 @@
|
|
2 |
|
3 |
namespace WebpConverter\Loader;
|
4 |
|
5 |
-
use WebpConverter\PluginAccessAbstract;
|
6 |
-
use WebpConverter\PluginAccessInterface;
|
7 |
use WebpConverter\HookableInterface;
|
8 |
|
9 |
/**
|
10 |
* Adds integration with active method of loading images.
|
11 |
*/
|
12 |
-
class LoaderIntegration
|
13 |
|
14 |
/**
|
15 |
* Object of image loader method.
|
@@ -19,8 +17,6 @@ class LoaderIntegration extends PluginAccessAbstract implements PluginAccessInte
|
|
19 |
private $loader;
|
20 |
|
21 |
/**
|
22 |
-
* LoaderIntegration constructor.
|
23 |
-
*
|
24 |
* @param LoaderInterface $loader .
|
25 |
*/
|
26 |
public function __construct( LoaderInterface $loader ) {
|
@@ -28,9 +24,7 @@ class LoaderIntegration extends PluginAccessAbstract implements PluginAccessInte
|
|
28 |
}
|
29 |
|
30 |
/**
|
31 |
-
*
|
32 |
-
*
|
33 |
-
* @return void
|
34 |
*/
|
35 |
public function init_hooks() {
|
36 |
add_action( 'plugins_loaded', [ $this, 'load_loader_actions' ] );
|
2 |
|
3 |
namespace WebpConverter\Loader;
|
4 |
|
|
|
|
|
5 |
use WebpConverter\HookableInterface;
|
6 |
|
7 |
/**
|
8 |
* Adds integration with active method of loading images.
|
9 |
*/
|
10 |
+
class LoaderIntegration implements HookableInterface {
|
11 |
|
12 |
/**
|
13 |
* Object of image loader method.
|
17 |
private $loader;
|
18 |
|
19 |
/**
|
|
|
|
|
20 |
* @param LoaderInterface $loader .
|
21 |
*/
|
22 |
public function __construct( LoaderInterface $loader ) {
|
24 |
}
|
25 |
|
26 |
/**
|
27 |
+
* {@inheritdoc}
|
|
|
|
|
28 |
*/
|
29 |
public function init_hooks() {
|
30 |
add_action( 'plugins_loaded', [ $this, 'load_loader_actions' ] );
|
src/Loader/LoaderInterface.php
CHANGED
@@ -3,12 +3,11 @@
|
|
3 |
namespace WebpConverter\Loader;
|
4 |
|
5 |
use WebpConverter\HookableInterface;
|
6 |
-
use WebpConverter\PluginAccessInterface;
|
7 |
|
8 |
/**
|
9 |
* Interface for class that supports method of loading images.
|
10 |
*/
|
11 |
-
interface LoaderInterface extends HookableInterface
|
12 |
|
13 |
/**
|
14 |
* Returns mime types for loader.
|
3 |
namespace WebpConverter\Loader;
|
4 |
|
5 |
use WebpConverter\HookableInterface;
|
|
|
6 |
|
7 |
/**
|
8 |
* Interface for class that supports method of loading images.
|
9 |
*/
|
10 |
+
interface LoaderInterface extends HookableInterface {
|
11 |
|
12 |
/**
|
13 |
* Returns mime types for loader.
|
src/Loader/PassthruLoader.php
CHANGED
@@ -5,37 +5,29 @@ namespace WebpConverter\Loader;
|
|
5 |
/**
|
6 |
* Supports method of loading images using .php file as Pass Thru.
|
7 |
*/
|
8 |
-
class PassthruLoader extends LoaderAbstract
|
9 |
|
10 |
const LOADER_TYPE = 'passthru';
|
11 |
const PATH_LOADER = '/webpc-passthru.php';
|
12 |
const LOADER_SOURCE = '/includes/passthru.php';
|
13 |
|
14 |
/**
|
15 |
-
*
|
16 |
-
*
|
17 |
-
* @return void
|
18 |
*/
|
19 |
public function init_hooks() {
|
20 |
add_action( 'get_header', [ $this, 'start_buffer' ] );
|
21 |
}
|
22 |
|
23 |
/**
|
24 |
-
*
|
25 |
-
*
|
26 |
-
* @return bool Is loader active?
|
27 |
*/
|
28 |
public function is_active_loader(): bool {
|
29 |
-
$settings = $this->
|
30 |
return ( isset( $settings['loader_type'] ) && ( $settings['loader_type'] === self::LOADER_TYPE ) );
|
31 |
}
|
32 |
|
33 |
/**
|
34 |
-
*
|
35 |
-
*
|
36 |
-
* @param bool $is_debug Is debugging?
|
37 |
-
*
|
38 |
-
* @return void
|
39 |
*/
|
40 |
public function activate_loader( bool $is_debug = false ) {
|
41 |
$path_source = WEBPC_PATH . self::LOADER_SOURCE;
|
@@ -71,9 +63,7 @@ class PassthruLoader extends LoaderAbstract implements LoaderInterface {
|
|
71 |
}
|
72 |
|
73 |
/**
|
74 |
-
*
|
75 |
-
*
|
76 |
-
* @return void
|
77 |
*/
|
78 |
public function deactivate_loader() {
|
79 |
$dir_output = dirname( apply_filters( 'webpc_dir_path', '', 'uploads' ) ) . self::PATH_LOADER;
|
@@ -90,7 +80,7 @@ class PassthruLoader extends LoaderAbstract implements LoaderInterface {
|
|
90 |
*/
|
91 |
public function start_buffer() {
|
92 |
ob_start(
|
93 |
-
function( $buffer ) {
|
94 |
return $this->update_image_urls( $buffer );
|
95 |
}
|
96 |
);
|
@@ -110,7 +100,7 @@ class PassthruLoader extends LoaderAbstract implements LoaderInterface {
|
|
110 |
return $buffer;
|
111 |
}
|
112 |
|
113 |
-
$settings = ( ! $is_debug ) ? $this->
|
114 |
$extensions = implode( '|', $settings['extensions'] ?? [] );
|
115 |
if ( ! $extensions || ( ! $source_dir = self::get_loader_url() )
|
116 |
|| ( ! $allowed_dirs = $this->get_allowed_dirs( $settings ) ) ) {
|
5 |
/**
|
6 |
* Supports method of loading images using .php file as Pass Thru.
|
7 |
*/
|
8 |
+
class PassthruLoader extends LoaderAbstract {
|
9 |
|
10 |
const LOADER_TYPE = 'passthru';
|
11 |
const PATH_LOADER = '/webpc-passthru.php';
|
12 |
const LOADER_SOURCE = '/includes/passthru.php';
|
13 |
|
14 |
/**
|
15 |
+
* {@inheritdoc}
|
|
|
|
|
16 |
*/
|
17 |
public function init_hooks() {
|
18 |
add_action( 'get_header', [ $this, 'start_buffer' ] );
|
19 |
}
|
20 |
|
21 |
/**
|
22 |
+
* {@inheritdoc}
|
|
|
|
|
23 |
*/
|
24 |
public function is_active_loader(): bool {
|
25 |
+
$settings = $this->plugin_data->get_plugin_settings();
|
26 |
return ( isset( $settings['loader_type'] ) && ( $settings['loader_type'] === self::LOADER_TYPE ) );
|
27 |
}
|
28 |
|
29 |
/**
|
30 |
+
* {@inheritdoc}
|
|
|
|
|
|
|
|
|
31 |
*/
|
32 |
public function activate_loader( bool $is_debug = false ) {
|
33 |
$path_source = WEBPC_PATH . self::LOADER_SOURCE;
|
63 |
}
|
64 |
|
65 |
/**
|
66 |
+
* {@inheritdoc}
|
|
|
|
|
67 |
*/
|
68 |
public function deactivate_loader() {
|
69 |
$dir_output = dirname( apply_filters( 'webpc_dir_path', '', 'uploads' ) ) . self::PATH_LOADER;
|
80 |
*/
|
81 |
public function start_buffer() {
|
82 |
ob_start(
|
83 |
+
function ( $buffer ) {
|
84 |
return $this->update_image_urls( $buffer );
|
85 |
}
|
86 |
);
|
100 |
return $buffer;
|
101 |
}
|
102 |
|
103 |
+
$settings = ( ! $is_debug ) ? $this->plugin_data->get_plugin_settings() : $this->plugin_data->get_debug_settings();
|
104 |
$extensions = implode( '|', $settings['extensions'] ?? [] );
|
105 |
if ( ! $extensions || ( ! $source_dir = self::get_loader_url() )
|
106 |
|| ( ! $allowed_dirs = $this->get_allowed_dirs( $settings ) ) ) {
|
src/Notice/NoticeAbstract.php
CHANGED
@@ -8,18 +8,14 @@ namespace WebpConverter\Notice;
|
|
8 |
abstract class NoticeAbstract implements NoticeInterface {
|
9 |
|
10 |
/**
|
11 |
-
*
|
12 |
-
*
|
13 |
-
* @return string Name of ajax action.
|
14 |
*/
|
15 |
-
public function get_ajax_action_to_disable()
|
16 |
-
return
|
17 |
}
|
18 |
|
19 |
/**
|
20 |
-
*
|
21 |
-
*
|
22 |
-
* @return string[] Args extract in view template.
|
23 |
*/
|
24 |
public function get_vars_for_view(): array {
|
25 |
return [];
|
8 |
abstract class NoticeAbstract implements NoticeInterface {
|
9 |
|
10 |
/**
|
11 |
+
* {@inheritdoc}
|
|
|
|
|
12 |
*/
|
13 |
+
public function get_ajax_action_to_disable() {
|
14 |
+
return null;
|
15 |
}
|
16 |
|
17 |
/**
|
18 |
+
* {@inheritdoc}
|
|
|
|
|
19 |
*/
|
20 |
public function get_vars_for_view(): array {
|
21 |
return [];
|
src/Notice/NoticeFactory.php
CHANGED
@@ -10,9 +10,7 @@ use WebpConverter\HookableInterface;
|
|
10 |
class NoticeFactory implements HookableInterface {
|
11 |
|
12 |
/**
|
13 |
-
*
|
14 |
-
*
|
15 |
-
* @return void
|
16 |
*/
|
17 |
public function init_hooks() {
|
18 |
$this->set_integration( new ThanksNotice() );
|
10 |
class NoticeFactory implements HookableInterface {
|
11 |
|
12 |
/**
|
13 |
+
* {@inheritdoc}
|
|
|
|
|
14 |
*/
|
15 |
public function init_hooks() {
|
16 |
$this->set_integration( new ThanksNotice() );
|
src/Notice/NoticeIntegration.php
CHANGED
@@ -19,8 +19,6 @@ class NoticeIntegration implements HookableInterface {
|
|
19 |
private $notice;
|
20 |
|
21 |
/**
|
22 |
-
* NoticeIntegration constructor.
|
23 |
-
*
|
24 |
* @param NoticeInterface $notice .
|
25 |
*/
|
26 |
public function __construct( NoticeInterface $notice ) {
|
@@ -28,9 +26,7 @@ class NoticeIntegration implements HookableInterface {
|
|
28 |
}
|
29 |
|
30 |
/**
|
31 |
-
*
|
32 |
-
*
|
33 |
-
* @return void
|
34 |
*/
|
35 |
public function init_hooks() {
|
36 |
add_action( 'admin_init', [ $this, 'init_notice_hooks' ] );
|
19 |
private $notice;
|
20 |
|
21 |
/**
|
|
|
|
|
22 |
* @param NoticeInterface $notice .
|
23 |
*/
|
24 |
public function __construct( NoticeInterface $notice ) {
|
26 |
}
|
27 |
|
28 |
/**
|
29 |
+
* {@inheritdoc}
|
|
|
|
|
30 |
*/
|
31 |
public function init_hooks() {
|
32 |
add_action( 'admin_init', [ $this, 'init_notice_hooks' ] );
|
src/Notice/NoticeInterface.php
CHANGED
@@ -45,9 +45,9 @@ interface NoticeInterface {
|
|
45 |
/**
|
46 |
* Returns name of action using in WP Ajax.
|
47 |
*
|
48 |
-
* @return string Name of ajax action.
|
49 |
*/
|
50 |
-
public function get_ajax_action_to_disable()
|
51 |
|
52 |
/**
|
53 |
* Sets options to disable notice.
|
45 |
/**
|
46 |
* Returns name of action using in WP Ajax.
|
47 |
*
|
48 |
+
* @return string|null Name of ajax action.
|
49 |
*/
|
50 |
+
public function get_ajax_action_to_disable();
|
51 |
|
52 |
/**
|
53 |
* Sets options to disable notice.
|
src/Notice/ThanksNotice.php
CHANGED
@@ -7,31 +7,26 @@ namespace WebpConverter\Notice;
|
|
7 |
*/
|
8 |
class ThanksNotice extends NoticeAbstract implements NoticeInterface {
|
9 |
|
10 |
-
const NOTICE_OPTION
|
11 |
-
const
|
|
|
12 |
|
13 |
/**
|
14 |
-
*
|
15 |
-
*
|
16 |
-
* @return string Option name.
|
17 |
*/
|
18 |
public function get_option_name(): string {
|
19 |
return self::NOTICE_OPTION;
|
20 |
}
|
21 |
|
22 |
/**
|
23 |
-
*
|
24 |
-
*
|
25 |
-
* @return string Default value.
|
26 |
*/
|
27 |
public function get_default_value(): string {
|
28 |
return (string) strtotime( '+ 1 week' );
|
29 |
}
|
30 |
|
31 |
/**
|
32 |
-
*
|
33 |
-
*
|
34 |
-
* @return bool Is notice available?
|
35 |
*/
|
36 |
public function is_available(): bool {
|
37 |
if ( basename( $_SERVER['PHP_SELF'] ) !== 'index.php' ) { // phpcs:ignore
|
@@ -43,18 +38,14 @@ class ThanksNotice extends NoticeAbstract implements NoticeInterface {
|
|
43 |
}
|
44 |
|
45 |
/**
|
46 |
-
*
|
47 |
-
*
|
48 |
-
* @return string Server path relative to plugin root.
|
49 |
*/
|
50 |
public function get_output_path(): string {
|
51 |
return self::NOTICE_VIEW_PATH;
|
52 |
}
|
53 |
|
54 |
/**
|
55 |
-
*
|
56 |
-
*
|
57 |
-
* @return string[] Args extract in view template.
|
58 |
*/
|
59 |
public function get_vars_for_view(): array {
|
60 |
return [
|
@@ -63,23 +54,18 @@ class ThanksNotice extends NoticeAbstract implements NoticeInterface {
|
|
63 |
}
|
64 |
|
65 |
/**
|
66 |
-
*
|
67 |
-
*
|
68 |
-
* @return string Name of ajax action.
|
69 |
*/
|
70 |
public function get_ajax_action_to_disable(): string {
|
71 |
return 'webpc_notice';
|
72 |
}
|
73 |
|
74 |
/**
|
75 |
-
*
|
76 |
-
*
|
77 |
-
* @return void
|
78 |
-
* @internal
|
79 |
*/
|
80 |
public static function disable_notice() {
|
81 |
$is_permanent = ( isset( $_POST['is_permanently'] ) && $_POST['is_permanently'] ); // phpcs:ignore
|
82 |
-
$expires_date = strtotime( ( $is_permanent ) ? '+
|
83 |
|
84 |
update_option( self::NOTICE_OPTION, $expires_date );
|
85 |
}
|
7 |
*/
|
8 |
class ThanksNotice extends NoticeAbstract implements NoticeInterface {
|
9 |
|
10 |
+
const NOTICE_OPTION = 'webpc_notice_thanks';
|
11 |
+
const NOTICE_OLD_OPTION = 'webpc_notice_hidden';
|
12 |
+
const NOTICE_VIEW_PATH = 'components/notices/thanks.php';
|
13 |
|
14 |
/**
|
15 |
+
* {@inheritdoc}
|
|
|
|
|
16 |
*/
|
17 |
public function get_option_name(): string {
|
18 |
return self::NOTICE_OPTION;
|
19 |
}
|
20 |
|
21 |
/**
|
22 |
+
* {@inheritdoc}
|
|
|
|
|
23 |
*/
|
24 |
public function get_default_value(): string {
|
25 |
return (string) strtotime( '+ 1 week' );
|
26 |
}
|
27 |
|
28 |
/**
|
29 |
+
* {@inheritdoc}
|
|
|
|
|
30 |
*/
|
31 |
public function is_available(): bool {
|
32 |
if ( basename( $_SERVER['PHP_SELF'] ) !== 'index.php' ) { // phpcs:ignore
|
38 |
}
|
39 |
|
40 |
/**
|
41 |
+
* {@inheritdoc}
|
|
|
|
|
42 |
*/
|
43 |
public function get_output_path(): string {
|
44 |
return self::NOTICE_VIEW_PATH;
|
45 |
}
|
46 |
|
47 |
/**
|
48 |
+
* {@inheritdoc}
|
|
|
|
|
49 |
*/
|
50 |
public function get_vars_for_view(): array {
|
51 |
return [
|
54 |
}
|
55 |
|
56 |
/**
|
57 |
+
* {@inheritdoc}
|
|
|
|
|
58 |
*/
|
59 |
public function get_ajax_action_to_disable(): string {
|
60 |
return 'webpc_notice';
|
61 |
}
|
62 |
|
63 |
/**
|
64 |
+
* {@inheritdoc}
|
|
|
|
|
|
|
65 |
*/
|
66 |
public static function disable_notice() {
|
67 |
$is_permanent = ( isset( $_POST['is_permanently'] ) && $_POST['is_permanently'] ); // phpcs:ignore
|
68 |
+
$expires_date = strtotime( ( $is_permanent ) ? '+6 months' : '+ 1 month' );
|
69 |
|
70 |
update_option( self::NOTICE_OPTION, $expires_date );
|
71 |
}
|
src/Notice/WelcomeNotice.php
CHANGED
@@ -13,45 +13,35 @@ class WelcomeNotice extends NoticeAbstract implements NoticeInterface {
|
|
13 |
const NOTICE_VIEW_PATH = 'components/notices/welcome.php';
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
-
*
|
18 |
-
* @return string Option name.
|
19 |
*/
|
20 |
public function get_option_name(): string {
|
21 |
return self::NOTICE_OPTION;
|
22 |
}
|
23 |
|
24 |
/**
|
25 |
-
*
|
26 |
-
*
|
27 |
-
* @return string Default value.
|
28 |
*/
|
29 |
public function get_default_value(): string {
|
30 |
return '1';
|
31 |
}
|
32 |
|
33 |
/**
|
34 |
-
*
|
35 |
-
*
|
36 |
-
* @return bool Is notice available?
|
37 |
*/
|
38 |
public function is_available(): bool {
|
39 |
return ( get_option( self::NOTICE_OPTION, 0 ) === $this->get_default_value() );
|
40 |
}
|
41 |
|
42 |
/**
|
43 |
-
*
|
44 |
-
*
|
45 |
-
* @return string Server path relative to plugin root.
|
46 |
*/
|
47 |
public function get_output_path(): string {
|
48 |
return self::NOTICE_VIEW_PATH;
|
49 |
}
|
50 |
|
51 |
/**
|
52 |
-
*
|
53 |
-
*
|
54 |
-
* @return string[] Args extract in view template.
|
55 |
*/
|
56 |
public function get_vars_for_view(): array {
|
57 |
return [
|
@@ -60,10 +50,7 @@ class WelcomeNotice extends NoticeAbstract implements NoticeInterface {
|
|
60 |
}
|
61 |
|
62 |
/**
|
63 |
-
*
|
64 |
-
*
|
65 |
-
* @return void
|
66 |
-
* @internal
|
67 |
*/
|
68 |
public static function disable_notice() {
|
69 |
update_option( self::NOTICE_OPTION, '0' );
|
13 |
const NOTICE_VIEW_PATH = 'components/notices/welcome.php';
|
14 |
|
15 |
/**
|
16 |
+
* {@inheritdoc}
|
|
|
|
|
17 |
*/
|
18 |
public function get_option_name(): string {
|
19 |
return self::NOTICE_OPTION;
|
20 |
}
|
21 |
|
22 |
/**
|
23 |
+
* {@inheritdoc}
|
|
|
|
|
24 |
*/
|
25 |
public function get_default_value(): string {
|
26 |
return '1';
|
27 |
}
|
28 |
|
29 |
/**
|
30 |
+
* {@inheritdoc}
|
|
|
|
|
31 |
*/
|
32 |
public function is_available(): bool {
|
33 |
return ( get_option( self::NOTICE_OPTION, 0 ) === $this->get_default_value() );
|
34 |
}
|
35 |
|
36 |
/**
|
37 |
+
* {@inheritdoc}
|
|
|
|
|
38 |
*/
|
39 |
public function get_output_path(): string {
|
40 |
return self::NOTICE_VIEW_PATH;
|
41 |
}
|
42 |
|
43 |
/**
|
44 |
+
* {@inheritdoc}
|
|
|
|
|
45 |
*/
|
46 |
public function get_vars_for_view(): array {
|
47 |
return [
|
50 |
}
|
51 |
|
52 |
/**
|
53 |
+
* {@inheritdoc}
|
|
|
|
|
|
|
54 |
*/
|
55 |
public static function disable_notice() {
|
56 |
update_option( self::NOTICE_OPTION, '0' );
|
src/Plugin/Activation.php
CHANGED
@@ -13,9 +13,7 @@ use WebpConverter\Plugin\Activation\WebpDirectory;
|
|
13 |
class Activation implements HookableInterface {
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
-
*
|
18 |
-
* @return void
|
19 |
*/
|
20 |
public function init_hooks() {
|
21 |
register_activation_hook( WEBPC_FILE, [ $this, 'load_activation_actions' ] );
|
13 |
class Activation implements HookableInterface {
|
14 |
|
15 |
/**
|
16 |
+
* {@inheritdoc}
|
|
|
|
|
17 |
*/
|
18 |
public function init_hooks() {
|
19 |
register_activation_hook( WEBPC_FILE, [ $this, 'load_activation_actions' ] );
|
src/Plugin/Deactivation.php
CHANGED
@@ -2,29 +2,20 @@
|
|
2 |
|
3 |
namespace WebpConverter\Plugin;
|
4 |
|
5 |
-
use WebpConverter\PluginAccessAbstract;
|
6 |
-
use WebpConverter\PluginAccessInterface;
|
7 |
use WebpConverter\HookableInterface;
|
8 |
use WebpConverter\Plugin\Deactivation\CronReset;
|
9 |
-
use WebpConverter\Plugin\Deactivation\Modal;
|
10 |
use WebpConverter\Plugin\Deactivation\RefreshLoader;
|
11 |
|
12 |
/**
|
13 |
* Runs actions after plugin deactivation.
|
14 |
*/
|
15 |
-
class Deactivation
|
16 |
|
17 |
/**
|
18 |
-
*
|
19 |
-
*
|
20 |
-
* @return void
|
21 |
*/
|
22 |
public function init_hooks() {
|
23 |
register_deactivation_hook( WEBPC_FILE, [ $this, 'load_deactivation_actions' ] );
|
24 |
-
|
25 |
-
$modal = new Modal();
|
26 |
-
$modal->set_plugin( $this->get_plugin() );
|
27 |
-
$modal->show_deactivation_modal();
|
28 |
}
|
29 |
|
30 |
/**
|
2 |
|
3 |
namespace WebpConverter\Plugin;
|
4 |
|
|
|
|
|
5 |
use WebpConverter\HookableInterface;
|
6 |
use WebpConverter\Plugin\Deactivation\CronReset;
|
|
|
7 |
use WebpConverter\Plugin\Deactivation\RefreshLoader;
|
8 |
|
9 |
/**
|
10 |
* Runs actions after plugin deactivation.
|
11 |
*/
|
12 |
+
class Deactivation implements HookableInterface {
|
13 |
|
14 |
/**
|
15 |
+
* {@inheritdoc}
|
|
|
|
|
16 |
*/
|
17 |
public function init_hooks() {
|
18 |
register_deactivation_hook( WEBPC_FILE, [ $this, 'load_deactivation_actions' ] );
|
|
|
|
|
|
|
|
|
19 |
}
|
20 |
|
21 |
/**
|
src/Plugin/Deactivation/Modal.php
CHANGED
@@ -2,24 +2,34 @@
|
|
2 |
|
3 |
namespace WebpConverter\Plugin\Deactivation;
|
4 |
|
5 |
-
use WebpConverter\
|
6 |
-
use WebpConverter\
|
7 |
use WebpConverter\Settings\AdminAssets;
|
8 |
use WebpConverter\Helper\ViewLoader;
|
9 |
|
10 |
/**
|
11 |
* Displays modal with poll in list of plugins when you try to deactivate plugin.
|
12 |
*/
|
13 |
-
class Modal
|
14 |
|
15 |
const FEEDBACK_API_URL = 'https://feedback.gbiorczyk.pl/';
|
16 |
|
17 |
/**
|
18 |
-
*
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
*/
|
22 |
-
public function
|
23 |
if ( basename( ( $_SERVER['SCRIPT_FILENAME'] ?? '' ), '.php' ) !== 'plugins' ) { // phpcs:ignore
|
24 |
return;
|
25 |
}
|
@@ -39,7 +49,7 @@ class Modal extends PluginAccessAbstract implements PluginAccessInterface {
|
|
39 |
[
|
40 |
'errors' => apply_filters( 'webpc_server_errors', [] ),
|
41 |
'reasons' => $this->get_reasons(),
|
42 |
-
'settings' => $this->
|
43 |
'api_url' => self::FEEDBACK_API_URL,
|
44 |
]
|
45 |
);
|
2 |
|
3 |
namespace WebpConverter\Plugin\Deactivation;
|
4 |
|
5 |
+
use WebpConverter\HookableInterface;
|
6 |
+
use WebpConverter\PluginData;
|
7 |
use WebpConverter\Settings\AdminAssets;
|
8 |
use WebpConverter\Helper\ViewLoader;
|
9 |
|
10 |
/**
|
11 |
* Displays modal with poll in list of plugins when you try to deactivate plugin.
|
12 |
*/
|
13 |
+
class Modal implements HookableInterface {
|
14 |
|
15 |
const FEEDBACK_API_URL = 'https://feedback.gbiorczyk.pl/';
|
16 |
|
17 |
/**
|
18 |
+
* @var PluginData .
|
19 |
+
*/
|
20 |
+
private $plugin_data;
|
21 |
+
|
22 |
+
/**
|
23 |
+
* @param PluginData $plugin_data .
|
24 |
+
*/
|
25 |
+
public function __construct( PluginData $plugin_data ) {
|
26 |
+
$this->plugin_data = $plugin_data;
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* {@inheritdoc}
|
31 |
*/
|
32 |
+
public function init_hooks() {
|
33 |
if ( basename( ( $_SERVER['SCRIPT_FILENAME'] ?? '' ), '.php' ) !== 'plugins' ) { // phpcs:ignore
|
34 |
return;
|
35 |
}
|
49 |
[
|
50 |
'errors' => apply_filters( 'webpc_server_errors', [] ),
|
51 |
'reasons' => $this->get_reasons(),
|
52 |
+
'settings' => $this->plugin_data->get_plugin_settings(),
|
53 |
'api_url' => self::FEEDBACK_API_URL,
|
54 |
]
|
55 |
);
|
src/Plugin/Links.php
CHANGED
@@ -13,42 +13,41 @@ class Links implements HookableInterface {
|
|
13 |
const DONATION_URL = 'https://ko-fi.com/gbiorczyk/?utm_source=webp-converter-for-media&utm_medium=plugin-links';
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
-
*
|
18 |
-
* @return void
|
19 |
*/
|
20 |
public function init_hooks() {
|
21 |
-
add_filter( 'plugin_action_links_' . WEBPC_NAME, [ $this, '
|
22 |
-
add_filter( 'network_admin_plugin_action_links_' . WEBPC_NAME, [ $this, '
|
23 |
-
add_filter( 'plugin_action_links_' . WEBPC_NAME, [ $this, 'add_link_to_donate' ] );
|
24 |
-
add_filter( 'network_admin_plugin_action_links_' . WEBPC_NAME, [ $this, 'add_link_to_donate' ] );
|
25 |
}
|
26 |
|
27 |
/**
|
28 |
-
* Adds links to plugin for non-multisite websites.
|
29 |
*
|
30 |
* @param string[] $links Plugin action links.
|
31 |
*
|
32 |
* @return string[] Plugin action links.
|
33 |
* @internal
|
34 |
*/
|
35 |
-
public function
|
36 |
if ( is_multisite() ) {
|
37 |
return $links;
|
38 |
}
|
39 |
-
|
|
|
|
|
40 |
}
|
41 |
|
42 |
/**
|
43 |
-
* Adds links to plugin for multisite websites.
|
44 |
*
|
45 |
* @param string[] $links Plugin action links.
|
46 |
*
|
47 |
* @return string[] Plugin action links.
|
48 |
* @internal
|
49 |
*/
|
50 |
-
public function
|
51 |
-
|
|
|
52 |
}
|
53 |
|
54 |
/**
|
@@ -79,7 +78,7 @@ class Links implements HookableInterface {
|
|
79 |
* @return string[] Plugin action links.
|
80 |
* @internal
|
81 |
*/
|
82 |
-
|
83 |
$links[] = sprintf(
|
84 |
/* translators: %1$s: open anchor tag, %2$s: close anchor tag */
|
85 |
esc_html( __( '%1$sProvide us a coffee%2$s', 'webp-converter-for-media' ) ),
|
13 |
const DONATION_URL = 'https://ko-fi.com/gbiorczyk/?utm_source=webp-converter-for-media&utm_medium=plugin-links';
|
14 |
|
15 |
/**
|
16 |
+
* {@inheritdoc}
|
|
|
|
|
17 |
*/
|
18 |
public function init_hooks() {
|
19 |
+
add_filter( 'plugin_action_links_' . WEBPC_NAME, [ $this, 'add_plugin_links_for_admin' ] );
|
20 |
+
add_filter( 'network_admin_plugin_action_links_' . WEBPC_NAME, [ $this, 'add_plugin_links_for_network' ] );
|
|
|
|
|
21 |
}
|
22 |
|
23 |
/**
|
24 |
+
* Adds new links to list of plugin actions for non-multisite websites.
|
25 |
*
|
26 |
* @param string[] $links Plugin action links.
|
27 |
*
|
28 |
* @return string[] Plugin action links.
|
29 |
* @internal
|
30 |
*/
|
31 |
+
public function add_plugin_links_for_admin( array $links ): array {
|
32 |
if ( is_multisite() ) {
|
33 |
return $links;
|
34 |
}
|
35 |
+
|
36 |
+
$links = $this->add_link_to_settings( $links );
|
37 |
+
return $this->add_link_to_donate( $links );
|
38 |
}
|
39 |
|
40 |
/**
|
41 |
+
* Adds new links to list of plugin actions for multisite websites.
|
42 |
*
|
43 |
* @param string[] $links Plugin action links.
|
44 |
*
|
45 |
* @return string[] Plugin action links.
|
46 |
* @internal
|
47 |
*/
|
48 |
+
public function add_plugin_links_for_network( array $links ): array {
|
49 |
+
$links = $this->add_link_to_settings( $links );
|
50 |
+
return $this->add_link_to_donate( $links );
|
51 |
}
|
52 |
|
53 |
/**
|
78 |
* @return string[] Plugin action links.
|
79 |
* @internal
|
80 |
*/
|
81 |
+
private function add_link_to_donate( array $links ): array {
|
82 |
$links[] = sprintf(
|
83 |
/* translators: %1$s: open anchor tag, %2$s: close anchor tag */
|
84 |
esc_html( __( '%1$sProvide us a coffee%2$s', 'webp-converter-for-media' ) ),
|
src/Plugin/Uninstall.php
CHANGED
@@ -14,9 +14,7 @@ use WebpConverter\Plugin\Uninstall\WebpFiles;
|
|
14 |
class Uninstall implements HookableInterface {
|
15 |
|
16 |
/**
|
17 |
-
*
|
18 |
-
*
|
19 |
-
* @return void
|
20 |
*/
|
21 |
public function init_hooks() {
|
22 |
register_uninstall_hook( WEBPC_FILE, [ 'WebpConverter\Plugin\Uninstall', 'load_uninstall_actions' ] );
|
14 |
class Uninstall implements HookableInterface {
|
15 |
|
16 |
/**
|
17 |
+
* {@inheritdoc}
|
|
|
|
|
18 |
*/
|
19 |
public function init_hooks() {
|
20 |
register_uninstall_hook( WEBPC_FILE, [ 'WebpConverter\Plugin\Uninstall', 'load_uninstall_actions' ] );
|
src/Plugin/Uninstall/PluginSettings.php
CHANGED
@@ -19,6 +19,7 @@ class PluginSettings {
|
|
19 |
* @return void
|
20 |
*/
|
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 );
|
19 |
* @return void
|
20 |
*/
|
21 |
public static function remove_plugin_settings() {
|
22 |
+
delete_option( ThanksNotice::NOTICE_OLD_OPTION );
|
23 |
delete_option( ThanksNotice::NOTICE_OPTION );
|
24 |
delete_option( WelcomeNotice::NOTICE_OPTION );
|
25 |
delete_option( ErrorFactory::ERRORS_CACHE_OPTION );
|
src/Plugin/Update.php
CHANGED
@@ -2,23 +2,19 @@
|
|
2 |
|
3 |
namespace WebpConverter\Plugin;
|
4 |
|
5 |
-
use WebpConverter\PluginAccessAbstract;
|
6 |
-
use WebpConverter\PluginAccessInterface;
|
7 |
use WebpConverter\HookableInterface;
|
8 |
use WebpConverter\Loader\LoaderAbstract;
|
9 |
-
use WebpConverter\
|
10 |
|
11 |
/**
|
12 |
* Runs actions after plugin update to new version.
|
13 |
*/
|
14 |
-
class Update
|
15 |
|
16 |
const VERSION_OPTION = 'webpc_latest_version';
|
17 |
|
18 |
/**
|
19 |
-
*
|
20 |
-
*
|
21 |
-
* @return void
|
22 |
*/
|
23 |
public function init_hooks() {
|
24 |
add_action( 'admin_init', [ $this, 'run_actions_after_update' ], 0 );
|
@@ -36,11 +32,9 @@ class Update extends PluginAccessAbstract implements PluginAccessInterface, Hook
|
|
36 |
return;
|
37 |
}
|
38 |
|
39 |
-
|
40 |
-
WelcomeNotice::disable_notice();
|
41 |
-
}
|
42 |
-
|
43 |
do_action( LoaderAbstract::ACTION_NAME, true );
|
|
|
44 |
update_option( self::VERSION_OPTION, WEBPC_VERSION );
|
45 |
}
|
46 |
}
|
2 |
|
3 |
namespace WebpConverter\Plugin;
|
4 |
|
|
|
|
|
5 |
use WebpConverter\HookableInterface;
|
6 |
use WebpConverter\Loader\LoaderAbstract;
|
7 |
+
use WebpConverter\Plugin\Activation\DefaultSettings;
|
8 |
|
9 |
/**
|
10 |
* Runs actions after plugin update to new version.
|
11 |
*/
|
12 |
+
class Update implements HookableInterface {
|
13 |
|
14 |
const VERSION_OPTION = 'webpc_latest_version';
|
15 |
|
16 |
/**
|
17 |
+
* {@inheritdoc}
|
|
|
|
|
18 |
*/
|
19 |
public function init_hooks() {
|
20 |
add_action( 'admin_init', [ $this, 'run_actions_after_update' ], 0 );
|
32 |
return;
|
33 |
}
|
34 |
|
35 |
+
( new DefaultSettings() )->add_default_options();
|
|
|
|
|
|
|
36 |
do_action( LoaderAbstract::ACTION_NAME, true );
|
37 |
+
|
38 |
update_option( self::VERSION_OPTION, WEBPC_VERSION );
|
39 |
}
|
40 |
}
|
src/PluginAccessAbstract.php
DELETED
@@ -1,50 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WebpConverter;
|
4 |
-
|
5 |
-
/**
|
6 |
-
* Allows class to access handle to main plugin class.
|
7 |
-
*/
|
8 |
-
abstract class PluginAccessAbstract implements PluginAccessInterface {
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Object of main plugin class.
|
12 |
-
*
|
13 |
-
* @var WebpConverter
|
14 |
-
*/
|
15 |
-
private $plugin;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Saves handler for object of plugin main class.
|
19 |
-
*
|
20 |
-
* @param WebpConverter $plugin Main class of plugin.
|
21 |
-
*
|
22 |
-
* @return void
|
23 |
-
*/
|
24 |
-
public function set_plugin( WebpConverter $plugin ) {
|
25 |
-
$this->plugin = $plugin;
|
26 |
-
}
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Saves handler for object of plugin main class and initializes integration with WordPress hooks.
|
30 |
-
*
|
31 |
-
* @param WebpConverter $plugin Main class of plugin.
|
32 |
-
*
|
33 |
-
* @return void
|
34 |
-
*/
|
35 |
-
public function set_plugin_hookable( WebpConverter $plugin ) {
|
36 |
-
$this->set_plugin( $plugin );
|
37 |
-
if ( $this instanceof HookableInterface ) {
|
38 |
-
$this->init_hooks();
|
39 |
-
}
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Returns handler for object of plugin main class.
|
44 |
-
*
|
45 |
-
* @return WebpConverter Main class of plugin.
|
46 |
-
*/
|
47 |
-
public function get_plugin(): WebpConverter {
|
48 |
-
return $this->plugin;
|
49 |
-
}
|
50 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/PluginAccessInterface.php
DELETED
@@ -1,34 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WebpConverter;
|
4 |
-
|
5 |
-
/**
|
6 |
-
* Interface for class having access handle to main plugin class.
|
7 |
-
*/
|
8 |
-
interface PluginAccessInterface {
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Saves handler for object of plugin main class.
|
12 |
-
*
|
13 |
-
* @param WebpConverter $plugin Main class of plugin.
|
14 |
-
*
|
15 |
-
* @return void
|
16 |
-
*/
|
17 |
-
public function set_plugin( WebpConverter $plugin );
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Integrates with WordPress hooks.
|
21 |
-
*
|
22 |
-
* @param WebpConverter $plugin Main class of plugin.
|
23 |
-
*
|
24 |
-
* @return void
|
25 |
-
*/
|
26 |
-
public function set_plugin_hookable( WebpConverter $plugin );
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Returns handler for object of plugin main class.
|
30 |
-
*
|
31 |
-
* @return WebpConverter Main class of plugin.
|
32 |
-
*/
|
33 |
-
public function get_plugin(): WebpConverter;
|
34 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/PluginData.php
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace WebpConverter;
|
4 |
+
|
5 |
+
use WebpConverter\Settings\Option\OptionFactory;
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Manages plugin values.
|
9 |
+
*/
|
10 |
+
class PluginData {
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Handler of class with plugin settings.
|
14 |
+
*
|
15 |
+
* @var OptionFactory
|
16 |
+
*/
|
17 |
+
private $settings_object;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Cached settings of plugin.
|
21 |
+
*
|
22 |
+
* @var mixed[]|null
|
23 |
+
*/
|
24 |
+
private $plugin_settings = null;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Cached settings of plugin for debug.
|
28 |
+
*
|
29 |
+
* @var mixed[]|null
|
30 |
+
*/
|
31 |
+
private $debug_settings = null;
|
32 |
+
|
33 |
+
public function __construct() {
|
34 |
+
$this->settings_object = new OptionFactory();
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Returns settings of plugin.
|
39 |
+
*
|
40 |
+
* @return mixed[] Settings of plugin.
|
41 |
+
*/
|
42 |
+
public function get_plugin_settings(): array {
|
43 |
+
if ( $this->plugin_settings === null ) {
|
44 |
+
$this->plugin_settings = $this->settings_object->get_values();
|
45 |
+
}
|
46 |
+
return $this->plugin_settings;
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Returns settings of plugin for debug.
|
51 |
+
*
|
52 |
+
* @return mixed[] Settings of plugin for debug.
|
53 |
+
*/
|
54 |
+
public function get_debug_settings(): array {
|
55 |
+
if ( $this->debug_settings === null ) {
|
56 |
+
$this->debug_settings = $this->settings_object->get_values( true );
|
57 |
+
}
|
58 |
+
return $this->debug_settings;
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Clears cache for settings of plugin.
|
63 |
+
*
|
64 |
+
* @return void
|
65 |
+
*/
|
66 |
+
public function invalidate_plugin_settings() {
|
67 |
+
$this->plugin_settings = null;
|
68 |
+
$this->debug_settings = null;
|
69 |
+
}
|
70 |
+
}
|
src/Settings/AdminAssets.php
CHANGED
@@ -24,9 +24,7 @@ class AdminAssets implements HookableInterface {
|
|
24 |
private $path_js = WEBPC_URL . 'assets/build/js/scripts.js';
|
25 |
|
26 |
/**
|
27 |
-
*
|
28 |
-
*
|
29 |
-
* @return void
|
30 |
*/
|
31 |
public function init_hooks() {
|
32 |
add_filter( 'admin_enqueue_scripts', [ $this, 'load_styles' ] );
|
24 |
private $path_js = WEBPC_URL . 'assets/build/js/scripts.js';
|
25 |
|
26 |
/**
|
27 |
+
* {@inheritdoc}
|
|
|
|
|
28 |
*/
|
29 |
public function init_hooks() {
|
30 |
add_filter( 'admin_enqueue_scripts', [ $this, 'load_styles' ] );
|
src/Settings/Option/ConversionMethodOption.php
CHANGED
@@ -3,11 +3,12 @@
|
|
3 |
namespace WebpConverter\Settings\Option;
|
4 |
|
5 |
use WebpConverter\Conversion\Method\MethodFactory;
|
|
|
6 |
|
7 |
/**
|
8 |
* Handles data about "Conversion method" field in plugin settings.
|
9 |
*/
|
10 |
-
class ConversionMethodOption extends OptionAbstract
|
11 |
|
12 |
const LOADER_TYPE = 'method';
|
13 |
|
@@ -18,66 +19,48 @@ class ConversionMethodOption extends OptionAbstract implements OptionInterface {
|
|
18 |
*/
|
19 |
private $methods_integration;
|
20 |
|
21 |
-
|
22 |
-
* ConversionMethodOption constructor.
|
23 |
-
*/
|
24 |
public function __construct() {
|
25 |
$this->methods_integration = new MethodFactory();
|
26 |
}
|
27 |
|
28 |
/**
|
29 |
-
*
|
30 |
-
*
|
31 |
-
* @return string Option name.
|
32 |
*/
|
33 |
public function get_name(): string {
|
34 |
return self::LOADER_TYPE;
|
35 |
}
|
36 |
|
37 |
/**
|
38 |
-
*
|
39 |
-
*
|
40 |
-
* @return string Field type.
|
41 |
*/
|
42 |
public function get_type(): string {
|
43 |
return OptionAbstract::OPTION_TYPE_RADIO;
|
44 |
}
|
45 |
|
46 |
/**
|
47 |
-
*
|
48 |
-
*
|
49 |
-
* @return string Option label.
|
50 |
*/
|
51 |
public function get_label(): string {
|
52 |
return __( 'Conversion method', 'webp-converter-for-media' );
|
53 |
}
|
54 |
|
55 |
/**
|
56 |
-
*
|
57 |
-
*
|
58 |
-
* @return string Additional information.
|
59 |
*/
|
60 |
public function get_info(): string {
|
61 |
return __( 'The configuration for advanced users.', 'webp-converter-for-media' );
|
62 |
}
|
63 |
|
64 |
/**
|
65 |
-
*
|
66 |
-
*
|
67 |
-
* @param mixed[] $settings Plugin settings.
|
68 |
-
*
|
69 |
-
* @return string[] Values for field.
|
70 |
*/
|
71 |
public function get_values( array $settings ): array {
|
72 |
return $this->methods_integration->get_methods();
|
73 |
}
|
74 |
|
75 |
/**
|
76 |
-
*
|
77 |
-
*
|
78 |
-
* @param mixed[] $settings Plugin settings.
|
79 |
-
*
|
80 |
-
* @return string[] Disabled values for field.
|
81 |
*/
|
82 |
public function get_disabled_values( array $settings ): array {
|
83 |
$methods = $this->methods_integration->get_methods();
|
@@ -86,11 +69,7 @@ class ConversionMethodOption extends OptionAbstract implements OptionInterface {
|
|
86 |
}
|
87 |
|
88 |
/**
|
89 |
-
*
|
90 |
-
*
|
91 |
-
* @param mixed[]|null $settings Plugin settings.
|
92 |
-
*
|
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();
|
3 |
namespace WebpConverter\Settings\Option;
|
4 |
|
5 |
use WebpConverter\Conversion\Method\MethodFactory;
|
6 |
+
use WebpConverter\PluginData;
|
7 |
|
8 |
/**
|
9 |
* Handles data about "Conversion method" field in plugin settings.
|
10 |
*/
|
11 |
+
class ConversionMethodOption extends OptionAbstract {
|
12 |
|
13 |
const LOADER_TYPE = 'method';
|
14 |
|
19 |
*/
|
20 |
private $methods_integration;
|
21 |
|
22 |
+
|
|
|
|
|
23 |
public function __construct() {
|
24 |
$this->methods_integration = new MethodFactory();
|
25 |
}
|
26 |
|
27 |
/**
|
28 |
+
* {@inheritdoc}
|
|
|
|
|
29 |
*/
|
30 |
public function get_name(): string {
|
31 |
return self::LOADER_TYPE;
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* {@inheritdoc}
|
|
|
|
|
36 |
*/
|
37 |
public function get_type(): string {
|
38 |
return OptionAbstract::OPTION_TYPE_RADIO;
|
39 |
}
|
40 |
|
41 |
/**
|
42 |
+
* {@inheritdoc}
|
|
|
|
|
43 |
*/
|
44 |
public function get_label(): string {
|
45 |
return __( 'Conversion method', 'webp-converter-for-media' );
|
46 |
}
|
47 |
|
48 |
/**
|
49 |
+
* {@inheritdoc}
|
|
|
|
|
50 |
*/
|
51 |
public function get_info(): string {
|
52 |
return __( 'The configuration for advanced users.', 'webp-converter-for-media' );
|
53 |
}
|
54 |
|
55 |
/**
|
56 |
+
* {@inheritdoc}
|
|
|
|
|
|
|
|
|
57 |
*/
|
58 |
public function get_values( array $settings ): array {
|
59 |
return $this->methods_integration->get_methods();
|
60 |
}
|
61 |
|
62 |
/**
|
63 |
+
* {@inheritdoc}
|
|
|
|
|
|
|
|
|
64 |
*/
|
65 |
public function get_disabled_values( array $settings ): array {
|
66 |
$methods = $this->methods_integration->get_methods();
|
69 |
}
|
70 |
|
71 |
/**
|
72 |
+
* {@inheritdoc}
|
|
|
|
|
|
|
|
|
73 |
*/
|
74 |
public function get_default_value( array $settings = null ): string {
|
75 |
$methods_available = $this->methods_integration->get_available_methods();
|
src/Settings/Option/ExtraFeaturesOption.php
CHANGED
@@ -8,52 +8,40 @@ use WebpConverter\Loader\HtaccessLoader;
|
|
8 |
/**
|
9 |
* Handles data about "Extra features" field in plugin settings.
|
10 |
*/
|
11 |
-
class ExtraFeaturesOption extends OptionAbstract
|
12 |
|
13 |
const LOADER_TYPE = 'features';
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
-
*
|
18 |
-
* @return string Option name.
|
19 |
*/
|
20 |
public function get_name(): string {
|
21 |
return self::LOADER_TYPE;
|
22 |
}
|
23 |
|
24 |
/**
|
25 |
-
*
|
26 |
-
*
|
27 |
-
* @return string Field type.
|
28 |
*/
|
29 |
public function get_type(): string {
|
30 |
return OptionAbstract::OPTION_TYPE_CHECKBOX;
|
31 |
}
|
32 |
|
33 |
/**
|
34 |
-
*
|
35 |
-
*
|
36 |
-
* @return string Option label.
|
37 |
*/
|
38 |
public function get_label(): string {
|
39 |
return __( 'Extra features', 'webp-converter-for-media' );
|
40 |
}
|
41 |
|
42 |
/**
|
43 |
-
*
|
44 |
-
*
|
45 |
-
* @return string Additional information.
|
46 |
*/
|
47 |
public function get_info(): string {
|
48 |
return __( 'Options allow you to enable new functionalities that will increase capabilities of plugin', 'webp-converter-for-media' );
|
49 |
}
|
50 |
|
51 |
/**
|
52 |
-
*
|
53 |
-
*
|
54 |
-
* @param mixed[] $settings Plugin settings.
|
55 |
-
*
|
56 |
-
* @return string[] Values for field.
|
57 |
*/
|
58 |
public function get_values( array $settings ): array {
|
59 |
return [
|
@@ -89,11 +77,7 @@ class ExtraFeaturesOption extends OptionAbstract implements OptionInterface {
|
|
89 |
}
|
90 |
|
91 |
/**
|
92 |
-
*
|
93 |
-
*
|
94 |
-
* @param mixed[] $settings Plugin settings.
|
95 |
-
*
|
96 |
-
* @return string[] Disabled values for field.
|
97 |
*/
|
98 |
public function get_disabled_values( array $settings ): array {
|
99 |
$values = [];
|
8 |
/**
|
9 |
* Handles data about "Extra features" field in plugin settings.
|
10 |
*/
|
11 |
+
class ExtraFeaturesOption extends OptionAbstract {
|
12 |
|
13 |
const LOADER_TYPE = 'features';
|
14 |
|
15 |
/**
|
16 |
+
* {@inheritdoc}
|
|
|
|
|
17 |
*/
|
18 |
public function get_name(): string {
|
19 |
return self::LOADER_TYPE;
|
20 |
}
|
21 |
|
22 |
/**
|
23 |
+
* {@inheritdoc}
|
|
|
|
|
24 |
*/
|
25 |
public function get_type(): string {
|
26 |
return OptionAbstract::OPTION_TYPE_CHECKBOX;
|
27 |
}
|
28 |
|
29 |
/**
|
30 |
+
* {@inheritdoc}
|
|
|
|
|
31 |
*/
|
32 |
public function get_label(): string {
|
33 |
return __( 'Extra features', 'webp-converter-for-media' );
|
34 |
}
|
35 |
|
36 |
/**
|
37 |
+
* {@inheritdoc}
|
|
|
|
|
38 |
*/
|
39 |
public function get_info(): string {
|
40 |
return __( 'Options allow you to enable new functionalities that will increase capabilities of plugin', 'webp-converter-for-media' );
|
41 |
}
|
42 |
|
43 |
/**
|
44 |
+
* {@inheritdoc}
|
|
|
|
|
|
|
|
|
45 |
*/
|
46 |
public function get_values( array $settings ): array {
|
47 |
return [
|
77 |
}
|
78 |
|
79 |
/**
|
80 |
+
* {@inheritdoc}
|
|
|
|
|
|
|
|
|
81 |
*/
|
82 |
public function get_disabled_values( array $settings ): array {
|
83 |
$values = [];
|
src/Settings/Option/ImagesQualityOption.php
CHANGED
@@ -5,52 +5,40 @@ namespace WebpConverter\Settings\Option;
|
|
5 |
/**
|
6 |
* Handles data about "Images quality" field in plugin settings.
|
7 |
*/
|
8 |
-
class ImagesQualityOption extends OptionAbstract
|
9 |
|
10 |
const LOADER_TYPE = 'quality';
|
11 |
|
12 |
/**
|
13 |
-
*
|
14 |
-
*
|
15 |
-
* @return string Option name.
|
16 |
*/
|
17 |
public function get_name(): string {
|
18 |
return self::LOADER_TYPE;
|
19 |
}
|
20 |
|
21 |
/**
|
22 |
-
*
|
23 |
-
*
|
24 |
-
* @return string Field type.
|
25 |
*/
|
26 |
public function get_type(): string {
|
27 |
return OptionAbstract::OPTION_TYPE_QUALITY;
|
28 |
}
|
29 |
|
30 |
/**
|
31 |
-
*
|
32 |
-
*
|
33 |
-
* @return string Option label.
|
34 |
*/
|
35 |
public function get_label(): string {
|
36 |
return __( 'Images quality', 'webp-converter-for-media' );
|
37 |
}
|
38 |
|
39 |
/**
|
40 |
-
*
|
41 |
-
*
|
42 |
-
* @return string Additional information.
|
43 |
*/
|
44 |
public function get_info(): string {
|
45 |
return __( 'Adjust the quality of the images being converted. Remember that higher quality also means larger file sizes. The recommended value is 85%.', 'webp-converter-for-media' );
|
46 |
}
|
47 |
|
48 |
/**
|
49 |
-
*
|
50 |
-
*
|
51 |
-
* @param mixed[] $settings Plugin settings.
|
52 |
-
*
|
53 |
-
* @return string[] Values for field.
|
54 |
*/
|
55 |
public function get_values( array $settings ): array {
|
56 |
return [
|
@@ -64,11 +52,7 @@ class ImagesQualityOption extends OptionAbstract implements OptionInterface {
|
|
64 |
}
|
65 |
|
66 |
/**
|
67 |
-
*
|
68 |
-
*
|
69 |
-
* @param mixed[]|null $settings Plugin settings.
|
70 |
-
*
|
71 |
-
* @return string Default value of field.
|
72 |
*/
|
73 |
public function get_default_value( array $settings = null ): string {
|
74 |
return '85';
|
5 |
/**
|
6 |
* Handles data about "Images quality" field in plugin settings.
|
7 |
*/
|
8 |
+
class ImagesQualityOption extends OptionAbstract {
|
9 |
|
10 |
const LOADER_TYPE = 'quality';
|
11 |
|
12 |
/**
|
13 |
+
* {@inheritdoc}
|
|
|
|
|
14 |
*/
|
15 |
public function get_name(): string {
|
16 |
return self::LOADER_TYPE;
|
17 |
}
|
18 |
|
19 |
/**
|
20 |
+
* {@inheritdoc}
|
|
|
|
|
21 |
*/
|
22 |
public function get_type(): string {
|
23 |
return OptionAbstract::OPTION_TYPE_QUALITY;
|
24 |
}
|
25 |
|
26 |
/**
|
27 |
+
* {@inheritdoc}
|
|
|
|
|
28 |
*/
|
29 |
public function get_label(): string {
|
30 |
return __( 'Images quality', 'webp-converter-for-media' );
|
31 |
}
|
32 |
|
33 |
/**
|
34 |
+
* {@inheritdoc}
|
|
|
|
|
35 |
*/
|
36 |
public function get_info(): string {
|
37 |
return __( 'Adjust the quality of the images being converted. Remember that higher quality also means larger file sizes. The recommended value is 85%.', 'webp-converter-for-media' );
|
38 |
}
|
39 |
|
40 |
/**
|
41 |
+
* {@inheritdoc}
|
|
|
|
|
|
|
|
|
42 |
*/
|
43 |
public function get_values( array $settings ): array {
|
44 |
return [
|
52 |
}
|
53 |
|
54 |
/**
|
55 |
+
* {@inheritdoc}
|
|
|
|
|
|
|
|
|
56 |
*/
|
57 |
public function get_default_value( array $settings = null ): string {
|
58 |
return '85';
|
src/Settings/Option/LoaderTypeOption.php
CHANGED
@@ -8,52 +8,40 @@ use WebpConverter\Loader\PassthruLoader;
|
|
8 |
/**
|
9 |
* Handles data about "Image loading mode" field in plugin settings.
|
10 |
*/
|
11 |
-
class LoaderTypeOption extends OptionAbstract
|
12 |
|
13 |
const LOADER_TYPE = 'loader_type';
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
-
*
|
18 |
-
* @return string Option name.
|
19 |
*/
|
20 |
public function get_name(): string {
|
21 |
return self::LOADER_TYPE;
|
22 |
}
|
23 |
|
24 |
/**
|
25 |
-
*
|
26 |
-
*
|
27 |
-
* @return string Field type.
|
28 |
*/
|
29 |
public function get_type(): string {
|
30 |
return OptionAbstract::OPTION_TYPE_RADIO;
|
31 |
}
|
32 |
|
33 |
/**
|
34 |
-
*
|
35 |
-
*
|
36 |
-
* @return string Option label.
|
37 |
*/
|
38 |
public function get_label(): string {
|
39 |
return __( 'Image loading mode', 'webp-converter-for-media' );
|
40 |
}
|
41 |
|
42 |
/**
|
43 |
-
*
|
44 |
-
*
|
45 |
-
* @return string Additional information.
|
46 |
*/
|
47 |
public function get_info(): string {
|
48 |
return __( 'By changing image loading mode it allows you to bypass some server configuration problems.', 'webp-converter-for-media' );
|
49 |
}
|
50 |
|
51 |
/**
|
52 |
-
*
|
53 |
-
*
|
54 |
-
* @param mixed[] $settings Plugin settings.
|
55 |
-
*
|
56 |
-
* @return string[] Values for field.
|
57 |
*/
|
58 |
public function get_values( array $settings ): array {
|
59 |
return [
|
@@ -71,11 +59,7 @@ class LoaderTypeOption extends OptionAbstract implements OptionInterface {
|
|
71 |
}
|
72 |
|
73 |
/**
|
74 |
-
*
|
75 |
-
*
|
76 |
-
* @param mixed[]|null $settings Plugin settings.
|
77 |
-
*
|
78 |
-
* @return string Default value of field.
|
79 |
*/
|
80 |
public function get_default_value( array $settings = null ): string {
|
81 |
return HtaccessLoader::LOADER_TYPE;
|
8 |
/**
|
9 |
* Handles data about "Image loading mode" field in plugin settings.
|
10 |
*/
|
11 |
+
class LoaderTypeOption extends OptionAbstract {
|
12 |
|
13 |
const LOADER_TYPE = 'loader_type';
|
14 |
|
15 |
/**
|
16 |
+
* {@inheritdoc}
|
|
|
|
|
17 |
*/
|
18 |
public function get_name(): string {
|
19 |
return self::LOADER_TYPE;
|
20 |
}
|
21 |
|
22 |
/**
|
23 |
+
* {@inheritdoc}
|
|
|
|
|
24 |
*/
|
25 |
public function get_type(): string {
|
26 |
return OptionAbstract::OPTION_TYPE_RADIO;
|
27 |
}
|
28 |
|
29 |
/**
|
30 |
+
* {@inheritdoc}
|
|
|
|
|
31 |
*/
|
32 |
public function get_label(): string {
|
33 |
return __( 'Image loading mode', 'webp-converter-for-media' );
|
34 |
}
|
35 |
|
36 |
/**
|
37 |
+
* {@inheritdoc}
|
|
|
|
|
38 |
*/
|
39 |
public function get_info(): string {
|
40 |
return __( 'By changing image loading mode it allows you to bypass some server configuration problems.', 'webp-converter-for-media' );
|
41 |
}
|
42 |
|
43 |
/**
|
44 |
+
* {@inheritdoc}
|
|
|
|
|
|
|
|
|
45 |
*/
|
46 |
public function get_values( array $settings ): array {
|
47 |
return [
|
59 |
}
|
60 |
|
61 |
/**
|
62 |
+
* {@inheritdoc}
|
|
|
|
|
|
|
|
|
63 |
*/
|
64 |
public function get_default_value( array $settings = null ): string {
|
65 |
return HtaccessLoader::LOADER_TYPE;
|
src/Settings/Option/OptionAbstract.php
CHANGED
@@ -12,20 +12,14 @@ abstract class OptionAbstract implements OptionInterface {
|
|
12 |
const OPTION_TYPE_QUALITY = 'quality';
|
13 |
|
14 |
/**
|
15 |
-
*
|
16 |
-
*
|
17 |
-
* @return string Additional information.
|
18 |
*/
|
19 |
public function get_info(): string {
|
20 |
return '';
|
21 |
}
|
22 |
|
23 |
/**
|
24 |
-
*
|
25 |
-
*
|
26 |
-
* @param mixed[] $settings Plugin settings.
|
27 |
-
*
|
28 |
-
* @return string[] Disabled values for field.
|
29 |
*/
|
30 |
public function get_disabled_values( array $settings ): array {
|
31 |
return [];
|
12 |
const OPTION_TYPE_QUALITY = 'quality';
|
13 |
|
14 |
/**
|
15 |
+
* {@inheritdoc}
|
|
|
|
|
16 |
*/
|
17 |
public function get_info(): string {
|
18 |
return '';
|
19 |
}
|
20 |
|
21 |
/**
|
22 |
+
* {@inheritdoc}
|
|
|
|
|
|
|
|
|
23 |
*/
|
24 |
public function get_disabled_values( array $settings ): array {
|
25 |
return [];
|
src/Settings/Option/OptionFactory.php
CHANGED
@@ -16,9 +16,6 @@ class OptionFactory {
|
|
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() );
|
16 |
*/
|
17 |
private $options = [];
|
18 |
|
|
|
|
|
|
|
19 |
public function __construct() {
|
20 |
$this->set_integration( new LoaderTypeOption() );
|
21 |
$this->set_integration( new SupportedExtensionsOption() );
|
src/Settings/Option/OptionIntegration.php
CHANGED
@@ -15,8 +15,6 @@ class OptionIntegration {
|
|
15 |
private $option;
|
16 |
|
17 |
/**
|
18 |
-
* OptionIntegration constructor.
|
19 |
-
*
|
20 |
* @param OptionInterface $option .
|
21 |
*/
|
22 |
public function __construct( OptionInterface $option ) {
|
15 |
private $option;
|
16 |
|
17 |
/**
|
|
|
|
|
18 |
* @param OptionInterface $option .
|
19 |
*/
|
20 |
public function __construct( OptionInterface $option ) {
|
src/Settings/Option/OutputFormatsOption.php
CHANGED
@@ -8,7 +8,7 @@ use WebpConverter\Conversion\Format\WebpFormat;
|
|
8 |
/**
|
9 |
* Handles data about "Supported output formats" field in plugin settings.
|
10 |
*/
|
11 |
-
class OutputFormatsOption extends OptionAbstract
|
12 |
|
13 |
const LOADER_TYPE = 'output_formats';
|
14 |
|
@@ -19,46 +19,33 @@ class OutputFormatsOption extends OptionAbstract implements OptionInterface {
|
|
19 |
*/
|
20 |
private $formats_integration;
|
21 |
|
22 |
-
/**
|
23 |
-
* OutputFormatsOption constructor.
|
24 |
-
*/
|
25 |
public function __construct() {
|
26 |
$this->formats_integration = new FormatFactory();
|
27 |
}
|
28 |
|
29 |
/**
|
30 |
-
*
|
31 |
-
*
|
32 |
-
* @return string Option name.
|
33 |
*/
|
34 |
public function get_name(): string {
|
35 |
return self::LOADER_TYPE;
|
36 |
}
|
37 |
|
38 |
/**
|
39 |
-
*
|
40 |
-
*
|
41 |
-
* @return string Field type.
|
42 |
*/
|
43 |
public function get_type(): string {
|
44 |
return OptionAbstract::OPTION_TYPE_CHECKBOX;
|
45 |
}
|
46 |
|
47 |
/**
|
48 |
-
*
|
49 |
-
*
|
50 |
-
* @return string Option label.
|
51 |
*/
|
52 |
public function get_label(): string {
|
53 |
return __( 'List of supported output formats', 'webp-converter-for-media' );
|
54 |
}
|
55 |
|
56 |
/**
|
57 |
-
*
|
58 |
-
*
|
59 |
-
* @param mixed[] $settings Plugin settings.
|
60 |
-
*
|
61 |
-
* @return string[] Values for field.
|
62 |
*/
|
63 |
public function get_values( array $settings ): array {
|
64 |
return $this->formats_integration->get_formats();
|
@@ -79,11 +66,7 @@ class OutputFormatsOption extends OptionAbstract implements OptionInterface {
|
|
79 |
}
|
80 |
|
81 |
/**
|
82 |
-
*
|
83 |
-
*
|
84 |
-
* @param mixed[] $settings Plugin settings.
|
85 |
-
*
|
86 |
-
* @return string[] Disabled values for field.
|
87 |
*/
|
88 |
public function get_disabled_values( array $settings ): array {
|
89 |
$method = $settings['method'] ?? ( new ConversionMethodOption() )->get_default_value();
|
8 |
/**
|
9 |
* Handles data about "Supported output formats" field in plugin settings.
|
10 |
*/
|
11 |
+
class OutputFormatsOption extends OptionAbstract {
|
12 |
|
13 |
const LOADER_TYPE = 'output_formats';
|
14 |
|
19 |
*/
|
20 |
private $formats_integration;
|
21 |
|
|
|
|
|
|
|
22 |
public function __construct() {
|
23 |
$this->formats_integration = new FormatFactory();
|
24 |
}
|
25 |
|
26 |
/**
|
27 |
+
* {@inheritdoc}
|
|
|
|
|
28 |
*/
|
29 |
public function get_name(): string {
|
30 |
return self::LOADER_TYPE;
|
31 |
}
|
32 |
|
33 |
/**
|
34 |
+
* {@inheritdoc}
|
|
|
|
|
35 |
*/
|
36 |
public function get_type(): string {
|
37 |
return OptionAbstract::OPTION_TYPE_CHECKBOX;
|
38 |
}
|
39 |
|
40 |
/**
|
41 |
+
* {@inheritdoc}
|
|
|
|
|
42 |
*/
|
43 |
public function get_label(): string {
|
44 |
return __( 'List of supported output formats', 'webp-converter-for-media' );
|
45 |
}
|
46 |
|
47 |
/**
|
48 |
+
* {@inheritdoc}
|
|
|
|
|
|
|
|
|
49 |
*/
|
50 |
public function get_values( array $settings ): array {
|
51 |
return $this->formats_integration->get_formats();
|
66 |
}
|
67 |
|
68 |
/**
|
69 |
+
* {@inheritdoc}
|
|
|
|
|
|
|
|
|
70 |
*/
|
71 |
public function get_disabled_values( array $settings ): array {
|
72 |
$method = $settings['method'] ?? ( new ConversionMethodOption() )->get_default_value();
|
src/Settings/Option/SupportedDirectoriesOption.php
CHANGED
@@ -7,52 +7,40 @@ use WebpConverter\Conversion\Directory\DirectoryFactory;
|
|
7 |
/**
|
8 |
* Handles data about "Supported directories" field in plugin settings.
|
9 |
*/
|
10 |
-
class SupportedDirectoriesOption extends OptionAbstract
|
11 |
|
12 |
const LOADER_TYPE = 'dirs';
|
13 |
|
14 |
/**
|
15 |
-
*
|
16 |
-
*
|
17 |
-
* @return string Option name.
|
18 |
*/
|
19 |
public function get_name(): string {
|
20 |
return self::LOADER_TYPE;
|
21 |
}
|
22 |
|
23 |
/**
|
24 |
-
*
|
25 |
-
*
|
26 |
-
* @return string Field type.
|
27 |
*/
|
28 |
public function get_type(): string {
|
29 |
return OptionAbstract::OPTION_TYPE_CHECKBOX;
|
30 |
}
|
31 |
|
32 |
/**
|
33 |
-
*
|
34 |
-
*
|
35 |
-
* @return string Option label.
|
36 |
*/
|
37 |
public function get_label(): string {
|
38 |
return __( 'List of supported directories', 'webp-converter-for-media' );
|
39 |
}
|
40 |
|
41 |
/**
|
42 |
-
*
|
43 |
-
*
|
44 |
-
* @return string Additional information.
|
45 |
*/
|
46 |
public function get_info(): string {
|
47 |
return __( 'Files from these directories will be supported in output formats.', 'webp-converter-for-media' );
|
48 |
}
|
49 |
|
50 |
/**
|
51 |
-
*
|
52 |
-
*
|
53 |
-
* @param mixed[] $settings Plugin settings.
|
54 |
-
*
|
55 |
-
* @return string[] Values for field.
|
56 |
*/
|
57 |
public function get_values( array $settings ): array {
|
58 |
return ( new DirectoryFactory() )->get_directories();
|
7 |
/**
|
8 |
* Handles data about "Supported directories" field in plugin settings.
|
9 |
*/
|
10 |
+
class SupportedDirectoriesOption extends OptionAbstract {
|
11 |
|
12 |
const LOADER_TYPE = 'dirs';
|
13 |
|
14 |
/**
|
15 |
+
* {@inheritdoc}
|
|
|
|
|
16 |
*/
|
17 |
public function get_name(): string {
|
18 |
return self::LOADER_TYPE;
|
19 |
}
|
20 |
|
21 |
/**
|
22 |
+
* {@inheritdoc}
|
|
|
|
|
23 |
*/
|
24 |
public function get_type(): string {
|
25 |
return OptionAbstract::OPTION_TYPE_CHECKBOX;
|
26 |
}
|
27 |
|
28 |
/**
|
29 |
+
* {@inheritdoc}
|
|
|
|
|
30 |
*/
|
31 |
public function get_label(): string {
|
32 |
return __( 'List of supported directories', 'webp-converter-for-media' );
|
33 |
}
|
34 |
|
35 |
/**
|
36 |
+
* {@inheritdoc}
|
|
|
|
|
37 |
*/
|
38 |
public function get_info(): string {
|
39 |
return __( 'Files from these directories will be supported in output formats.', 'webp-converter-for-media' );
|
40 |
}
|
41 |
|
42 |
/**
|
43 |
+
* {@inheritdoc}
|
|
|
|
|
|
|
|
|
44 |
*/
|
45 |
public function get_values( array $settings ): array {
|
46 |
return ( new DirectoryFactory() )->get_directories();
|
src/Settings/Option/SupportedExtensionsOption.php
CHANGED
@@ -5,43 +5,33 @@ namespace WebpConverter\Settings\Option;
|
|
5 |
/**
|
6 |
* Handles data about "Supported files extensions" field in plugin settings.
|
7 |
*/
|
8 |
-
class SupportedExtensionsOption extends OptionAbstract
|
9 |
|
10 |
const LOADER_TYPE = 'extensions';
|
11 |
|
12 |
/**
|
13 |
-
*
|
14 |
-
*
|
15 |
-
* @return string Option name.
|
16 |
*/
|
17 |
public function get_name(): string {
|
18 |
return self::LOADER_TYPE;
|
19 |
}
|
20 |
|
21 |
/**
|
22 |
-
*
|
23 |
-
*
|
24 |
-
* @return string Field type.
|
25 |
*/
|
26 |
public function get_type(): string {
|
27 |
return OptionAbstract::OPTION_TYPE_CHECKBOX;
|
28 |
}
|
29 |
|
30 |
/**
|
31 |
-
*
|
32 |
-
*
|
33 |
-
* @return string Option label.
|
34 |
*/
|
35 |
public function get_label(): string {
|
36 |
return __( 'List of supported files extensions', 'webp-converter-for-media' );
|
37 |
}
|
38 |
|
39 |
/**
|
40 |
-
*
|
41 |
-
*
|
42 |
-
* @param mixed[] $settings Plugin settings.
|
43 |
-
*
|
44 |
-
* @return string[] Values for field.
|
45 |
*/
|
46 |
public function get_values( array $settings ): array {
|
47 |
return [
|
5 |
/**
|
6 |
* Handles data about "Supported files extensions" field in plugin settings.
|
7 |
*/
|
8 |
+
class SupportedExtensionsOption extends OptionAbstract {
|
9 |
|
10 |
const LOADER_TYPE = 'extensions';
|
11 |
|
12 |
/**
|
13 |
+
* {@inheritdoc}
|
|
|
|
|
14 |
*/
|
15 |
public function get_name(): string {
|
16 |
return self::LOADER_TYPE;
|
17 |
}
|
18 |
|
19 |
/**
|
20 |
+
* {@inheritdoc}
|
|
|
|
|
21 |
*/
|
22 |
public function get_type(): string {
|
23 |
return OptionAbstract::OPTION_TYPE_CHECKBOX;
|
24 |
}
|
25 |
|
26 |
/**
|
27 |
+
* {@inheritdoc}
|
|
|
|
|
28 |
*/
|
29 |
public function get_label(): string {
|
30 |
return __( 'List of supported files extensions', 'webp-converter-for-media' );
|
31 |
}
|
32 |
|
33 |
/**
|
34 |
+
* {@inheritdoc}
|
|
|
|
|
|
|
|
|
35 |
*/
|
36 |
public function get_values( array $settings ): array {
|
37 |
return [
|
src/Settings/Page/DebugPage.php
CHANGED
@@ -12,26 +12,21 @@ use WebpConverter\Error\RewritesError;
|
|
12 |
/**
|
13 |
* Supports debug tab in plugin settings page.
|
14 |
*/
|
15 |
-
class DebugPage extends PageAbstract
|
16 |
|
17 |
const PAGE_VIEW_PATH = 'views/settings-debug.php';
|
18 |
|
19 |
/**
|
20 |
-
*
|
21 |
-
*
|
22 |
-
* @return bool Is view active?
|
23 |
*/
|
24 |
public function is_page_active(): bool {
|
25 |
return ( isset( $_GET['action'] ) && ( $_GET['action'] === 'server' ) ); // phpcs:ignore
|
26 |
}
|
27 |
|
28 |
/**
|
29 |
-
*
|
30 |
-
*
|
31 |
-
* @return void
|
32 |
*/
|
33 |
public function show_page_view() {
|
34 |
-
$plugin = $this->get_plugin();
|
35 |
$uploads_url = apply_filters( 'webpc_dir_url', '', 'uploads' );
|
36 |
$uploads_path = apply_filters( 'webpc_dir_path', '', 'uploads' );
|
37 |
$ver_param = sprintf( 'ver=%s', time() );
|
@@ -59,25 +54,25 @@ class DebugPage extends PageAbstract implements PageInterface {
|
|
59 |
),
|
60 |
'size_png_url' => FileLoader::get_file_size_by_url(
|
61 |
$uploads_url . RewritesError::PATH_OUTPUT_FILE_PNG,
|
62 |
-
$
|
63 |
false,
|
64 |
$ver_param
|
65 |
),
|
66 |
'size_png2_url' => FileLoader::get_file_size_by_url(
|
67 |
$uploads_url . RewritesError::PATH_OUTPUT_FILE_PNG2,
|
68 |
-
$
|
69 |
false,
|
70 |
$ver_param
|
71 |
),
|
72 |
'size_png_as_webp_url' => FileLoader::get_file_size_by_url(
|
73 |
$uploads_url . RewritesError::PATH_OUTPUT_FILE_PNG,
|
74 |
-
$
|
75 |
true,
|
76 |
$ver_param
|
77 |
),
|
78 |
'size_png2_as_webp_url' => FileLoader::get_file_size_by_url(
|
79 |
$uploads_url . RewritesError::PATH_OUTPUT_FILE_PNG2,
|
80 |
-
$
|
81 |
true,
|
82 |
$ver_param
|
83 |
),
|
12 |
/**
|
13 |
* Supports debug tab in plugin settings page.
|
14 |
*/
|
15 |
+
class DebugPage extends PageAbstract {
|
16 |
|
17 |
const PAGE_VIEW_PATH = 'views/settings-debug.php';
|
18 |
|
19 |
/**
|
20 |
+
* {@inheritdoc}
|
|
|
|
|
21 |
*/
|
22 |
public function is_page_active(): bool {
|
23 |
return ( isset( $_GET['action'] ) && ( $_GET['action'] === 'server' ) ); // phpcs:ignore
|
24 |
}
|
25 |
|
26 |
/**
|
27 |
+
* {@inheritdoc}
|
|
|
|
|
28 |
*/
|
29 |
public function show_page_view() {
|
|
|
30 |
$uploads_url = apply_filters( 'webpc_dir_url', '', 'uploads' );
|
31 |
$uploads_path = apply_filters( 'webpc_dir_path', '', 'uploads' );
|
32 |
$ver_param = sprintf( 'ver=%s', time() );
|
54 |
),
|
55 |
'size_png_url' => FileLoader::get_file_size_by_url(
|
56 |
$uploads_url . RewritesError::PATH_OUTPUT_FILE_PNG,
|
57 |
+
$this->plugin_data,
|
58 |
false,
|
59 |
$ver_param
|
60 |
),
|
61 |
'size_png2_url' => FileLoader::get_file_size_by_url(
|
62 |
$uploads_url . RewritesError::PATH_OUTPUT_FILE_PNG2,
|
63 |
+
$this->plugin_data,
|
64 |
false,
|
65 |
$ver_param
|
66 |
),
|
67 |
'size_png_as_webp_url' => FileLoader::get_file_size_by_url(
|
68 |
$uploads_url . RewritesError::PATH_OUTPUT_FILE_PNG,
|
69 |
+
$this->plugin_data,
|
70 |
true,
|
71 |
$ver_param
|
72 |
),
|
73 |
'size_png2_as_webp_url' => FileLoader::get_file_size_by_url(
|
74 |
$uploads_url . RewritesError::PATH_OUTPUT_FILE_PNG2,
|
75 |
+
$this->plugin_data,
|
76 |
true,
|
77 |
$ver_param
|
78 |
),
|
src/Settings/Page/PageAbstract.php
CHANGED
@@ -2,13 +2,24 @@
|
|
2 |
|
3 |
namespace WebpConverter\Settings\Page;
|
4 |
|
5 |
-
use WebpConverter\
|
6 |
-
use WebpConverter\PluginAccessInterface;
|
7 |
|
8 |
/**
|
9 |
* Abstract class for class that supports tab in plugin settings page.
|
10 |
*/
|
11 |
-
abstract class PageAbstract
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
/**
|
14 |
* Returns status if view is active.
|
2 |
|
3 |
namespace WebpConverter\Settings\Page;
|
4 |
|
5 |
+
use WebpConverter\PluginData;
|
|
|
6 |
|
7 |
/**
|
8 |
* Abstract class for class that supports tab in plugin settings page.
|
9 |
*/
|
10 |
+
abstract class PageAbstract implements PageInterface {
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @var PluginData .
|
14 |
+
*/
|
15 |
+
protected $plugin_data;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @param PluginData $plugin_data .
|
19 |
+
*/
|
20 |
+
public function __construct( PluginData $plugin_data ) {
|
21 |
+
$this->plugin_data = $plugin_data;
|
22 |
+
}
|
23 |
|
24 |
/**
|
25 |
* Returns status if view is active.
|
src/Settings/Page/PageFactory.php
DELETED
@@ -1,45 +0,0 @@
|
|
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/Page/PageIntegration.php
CHANGED
@@ -2,8 +2,6 @@
|
|
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;
|
@@ -11,7 +9,7 @@ use WebpConverter\Settings\AdminAssets;
|
|
11 |
/**
|
12 |
* Adds plugin settings page in admin panel.
|
13 |
*/
|
14 |
-
class PageIntegration
|
15 |
|
16 |
const ADMIN_MENU_PAGE = 'webpc_admin_page';
|
17 |
|
@@ -23,9 +21,7 @@ class PageIntegration extends PluginAccessAbstract implements PluginAccessInterf
|
|
23 |
private $pages = [];
|
24 |
|
25 |
/**
|
26 |
-
*
|
27 |
-
*
|
28 |
-
* @return void
|
29 |
*/
|
30 |
public function init_hooks() {
|
31 |
add_action( 'admin_menu', [ $this, 'add_settings_page_for_admin' ] );
|
@@ -120,7 +116,6 @@ class PageIntegration extends PluginAccessAbstract implements PluginAccessInterf
|
|
120 |
* @return void
|
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 |
}
|
2 |
|
3 |
namespace WebpConverter\Settings\Page;
|
4 |
|
|
|
|
|
5 |
use WebpConverter\HookableInterface;
|
6 |
use WebpConverter\Notice\WelcomeNotice;
|
7 |
use WebpConverter\Settings\AdminAssets;
|
9 |
/**
|
10 |
* Adds plugin settings page in admin panel.
|
11 |
*/
|
12 |
+
class PageIntegration implements HookableInterface {
|
13 |
|
14 |
const ADMIN_MENU_PAGE = 'webpc_admin_page';
|
15 |
|
21 |
private $pages = [];
|
22 |
|
23 |
/**
|
24 |
+
* {@inheritdoc}
|
|
|
|
|
25 |
*/
|
26 |
public function init_hooks() {
|
27 |
add_action( 'admin_menu', [ $this, 'add_settings_page_for_admin' ] );
|
116 |
* @return void
|
117 |
*/
|
118 |
private function init_page_is_active( PageInterface $page ) {
|
|
|
119 |
if ( ! $page->is_page_active() ) {
|
120 |
return;
|
121 |
}
|
src/Settings/Page/PageInterface.php
CHANGED
@@ -2,12 +2,10 @@
|
|
2 |
|
3 |
namespace WebpConverter\Settings\Page;
|
4 |
|
5 |
-
use WebpConverter\PluginAccessInterface;
|
6 |
-
|
7 |
/**
|
8 |
* Interface for class that supports tab in plugin settings page.
|
9 |
*/
|
10 |
-
interface PageInterface
|
11 |
|
12 |
/**
|
13 |
* Returns status if view is active.
|
2 |
|
3 |
namespace WebpConverter\Settings\Page;
|
4 |
|
|
|
|
|
5 |
/**
|
6 |
* Interface for class that supports tab in plugin settings page.
|
7 |
*/
|
8 |
+
interface PageInterface {
|
9 |
|
10 |
/**
|
11 |
* Returns status if view is active.
|
src/Settings/Page/SettingsPage.php
CHANGED
@@ -13,28 +13,22 @@ use WebpConverter\Settings\SettingsSave;
|
|
13 |
/**
|
14 |
* Supports default tab in plugin settings page.
|
15 |
*/
|
16 |
-
class SettingsPage extends PageAbstract
|
17 |
|
18 |
const PAGE_VIEW_PATH = 'views/settings.php';
|
19 |
|
20 |
/**
|
21 |
-
*
|
22 |
-
*
|
23 |
-
* @return bool Is view active?
|
24 |
*/
|
25 |
public function is_page_active(): bool {
|
26 |
return ( ! isset( $_GET['action'] ) || ( $_GET['action'] !== 'server' ) ); // phpcs:ignore
|
27 |
}
|
28 |
|
29 |
/**
|
30 |
-
*
|
31 |
-
*
|
32 |
-
* @return void
|
33 |
*/
|
34 |
public function show_page_view() {
|
35 |
-
|
36 |
-
$settings_save->set_plugin( $this->get_plugin() );
|
37 |
-
$settings_save->save_settings();
|
38 |
|
39 |
ViewLoader::load_view(
|
40 |
self::PAGE_VIEW_PATH,
|
@@ -52,8 +46,8 @@ class SettingsPage extends PageAbstract implements PageInterface {
|
|
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(),
|
57 |
]
|
58 |
);
|
59 |
|
13 |
/**
|
14 |
* Supports default tab in plugin settings page.
|
15 |
*/
|
16 |
+
class SettingsPage extends PageAbstract {
|
17 |
|
18 |
const PAGE_VIEW_PATH = 'views/settings.php';
|
19 |
|
20 |
/**
|
21 |
+
* {@inheritdoc}
|
|
|
|
|
22 |
*/
|
23 |
public function is_page_active(): bool {
|
24 |
return ( ! isset( $_GET['action'] ) || ( $_GET['action'] !== 'server' ) ); // phpcs:ignore
|
25 |
}
|
26 |
|
27 |
/**
|
28 |
+
* {@inheritdoc}
|
|
|
|
|
29 |
*/
|
30 |
public function show_page_view() {
|
31 |
+
( new SettingsSave( $this->plugin_data ) )->save_settings();
|
|
|
|
|
32 |
|
33 |
ViewLoader::load_view(
|
34 |
self::PAGE_VIEW_PATH,
|
46 |
'%s&action=server',
|
47 |
PageIntegration::get_settings_page_url()
|
48 |
),
|
49 |
+
'api_paths_url' => ( new PathsEndpoint( $this->plugin_data ) )->get_route_url(),
|
50 |
+
'api_regenerate_url' => ( new RegenerateEndpoint( $this->plugin_data ) )->get_route_url(),
|
51 |
]
|
52 |
);
|
53 |
|
src/Settings/SettingsSave.php
CHANGED
@@ -2,8 +2,7 @@
|
|
2 |
|
3 |
namespace WebpConverter\Settings;
|
4 |
|
5 |
-
use WebpConverter\
|
6 |
-
use WebpConverter\PluginAccessInterface;
|
7 |
use WebpConverter\Conversion\Cron\Event;
|
8 |
use WebpConverter\Loader\LoaderAbstract;
|
9 |
use WebpConverter\Settings\Option\OptionFactory;
|
@@ -12,7 +11,19 @@ use WebpConverter\Conversion\Directory\DirectoryFactory;
|
|
12 |
/**
|
13 |
* Supports saving plugin settings on plugin settings page.
|
14 |
*/
|
15 |
-
class SettingsSave
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
const SETTINGS_OPTION = 'webpc_settings';
|
18 |
const SUBMIT_VALUE = 'webpc_save';
|
@@ -32,21 +43,20 @@ class SettingsSave extends PluginAccessAbstract implements PluginAccessInterface
|
|
32 |
}
|
33 |
|
34 |
update_option( self::SETTINGS_OPTION, ( new OptionFactory() )->get_values( false, $_POST ) );
|
35 |
-
$
|
36 |
-
$this->
|
37 |
-
$this->init_actions_after_save( $settings );
|
38 |
}
|
39 |
|
40 |
/**
|
41 |
* Runs actions needed after saving plugin settings.
|
42 |
*
|
43 |
-
* @param mixed[] $settings Plugin settings.
|
44 |
-
*
|
45 |
* @return void
|
46 |
*/
|
47 |
-
private function init_actions_after_save(
|
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 |
}
|
2 |
|
3 |
namespace WebpConverter\Settings;
|
4 |
|
5 |
+
use WebpConverter\PluginData;
|
|
|
6 |
use WebpConverter\Conversion\Cron\Event;
|
7 |
use WebpConverter\Loader\LoaderAbstract;
|
8 |
use WebpConverter\Settings\Option\OptionFactory;
|
11 |
/**
|
12 |
* Supports saving plugin settings on plugin settings page.
|
13 |
*/
|
14 |
+
class SettingsSave {
|
15 |
+
|
16 |
+
/**
|
17 |
+
* @var PluginData .
|
18 |
+
*/
|
19 |
+
private $plugin_data;
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @param PluginData $plugin_data .
|
23 |
+
*/
|
24 |
+
public function __construct( PluginData $plugin_data ) {
|
25 |
+
$this->plugin_data = $plugin_data;
|
26 |
+
}
|
27 |
|
28 |
const SETTINGS_OPTION = 'webpc_settings';
|
29 |
const SUBMIT_VALUE = 'webpc_save';
|
43 |
}
|
44 |
|
45 |
update_option( self::SETTINGS_OPTION, ( new OptionFactory() )->get_values( false, $_POST ) );
|
46 |
+
$this->plugin_data->invalidate_plugin_settings();
|
47 |
+
$this->init_actions_after_save();
|
|
|
48 |
}
|
49 |
|
50 |
/**
|
51 |
* Runs actions needed after saving plugin settings.
|
52 |
*
|
|
|
|
|
53 |
* @return void
|
54 |
*/
|
55 |
+
private function init_actions_after_save() {
|
56 |
do_action( LoaderAbstract::ACTION_NAME, true );
|
57 |
wp_clear_scheduled_hook( Event::CRON_ACTION );
|
58 |
+
|
59 |
+
$settings = $this->plugin_data->get_plugin_settings();
|
60 |
( new DirectoryFactory() )->remove_unused_output_directories( $settings['dirs'] );
|
61 |
}
|
62 |
}
|
src/WebpConverter.php
CHANGED
@@ -4,95 +4,50 @@ namespace WebpConverter;
|
|
4 |
|
5 |
use WebpConverter\Action;
|
6 |
use WebpConverter\Conversion;
|
|
|
7 |
use WebpConverter\Conversion\Cron;
|
8 |
use WebpConverter\Error;
|
9 |
use WebpConverter\Conversion\Media;
|
10 |
use WebpConverter\Notice;
|
11 |
use WebpConverter\Plugin;
|
12 |
-
use WebpConverter\Settings;
|
13 |
|
14 |
/**
|
15 |
* Class initializes all plugin actions.
|
16 |
*/
|
17 |
class WebpConverter {
|
18 |
|
19 |
-
/**
|
20 |
-
* Handler of class with plugin settings.
|
21 |
-
*
|
22 |
-
* @var Settings\Option\OptionFactory
|
23 |
-
*/
|
24 |
-
private $settings_object;
|
25 |
-
|
26 |
-
/**
|
27 |
-
* Cached settings of plugin.
|
28 |
-
*
|
29 |
-
* @var array[]
|
30 |
-
*/
|
31 |
-
private $plugin_settings = null;
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Cached settings of plugin for debugging.
|
35 |
-
*
|
36 |
-
* @var array[]
|
37 |
-
*/
|
38 |
-
private $plugin_settings_debug = null;
|
39 |
-
|
40 |
-
/**
|
41 |
-
* WebpConverter constructor.
|
42 |
-
*/
|
43 |
public function __construct() {
|
44 |
-
$
|
45 |
|
46 |
-
( new Action\ConvertAttachment() )->
|
47 |
( new Action\ConvertDir() )->init_hooks();
|
48 |
-
( new Action\ConvertPaths() )->
|
49 |
( new Action\DeletePaths() )->init_hooks();
|
50 |
-
( new Action\RegenerateAll() )->
|
51 |
( new Conversion\Directory\DirectoryFactory() )->init_hooks();
|
52 |
-
( new Conversion\DirectoryFiles() )->
|
53 |
-
( new
|
54 |
-
( new
|
55 |
-
( new Conversion\
|
56 |
-
( new
|
|
|
57 |
( new Cron\Schedules() )->init_hooks();
|
58 |
-
( new Error\ErrorFactory() )->
|
59 |
( new Notice\NoticeFactory() )->init_hooks();
|
60 |
-
( new Loader\
|
|
|
61 |
( new Media\Delete() )->init_hooks();
|
62 |
-
( new Media\Upload() )->
|
63 |
( new Plugin\Activation() )->init_hooks();
|
64 |
-
( new Plugin\Deactivation() )->
|
|
|
65 |
( new Plugin\Links() )->init_hooks();
|
66 |
( new Plugin\Uninstall() )->init_hooks();
|
67 |
-
( new Plugin\Update() )->
|
68 |
-
( new
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
* Returns settings of plugin.
|
73 |
-
*
|
74 |
-
* @param bool $is_force_refresh Force refresh of current settings?
|
75 |
-
*
|
76 |
-
* @return mixed[] Settings of plugin.
|
77 |
-
*/
|
78 |
-
public function get_settings( bool $is_force_refresh = false ): array {
|
79 |
-
if ( ( $this->plugin_settings === null ) || $is_force_refresh ) {
|
80 |
-
$this->plugin_settings = $this->settings_object->get_values();
|
81 |
-
}
|
82 |
-
return $this->plugin_settings;
|
83 |
-
}
|
84 |
-
|
85 |
-
/**
|
86 |
-
* Returns settings of plugin using for debugging.
|
87 |
-
*
|
88 |
-
* @param bool $is_force_refresh Force refresh of current settings?
|
89 |
-
*
|
90 |
-
* @return mixed[] Settings of plugin.
|
91 |
-
*/
|
92 |
-
public function get_settings_debug( bool $is_force_refresh = false ): array {
|
93 |
-
if ( ( $this->plugin_settings_debug === null ) || $is_force_refresh ) {
|
94 |
-
$this->plugin_settings_debug = $this->settings_object->get_values( true );
|
95 |
-
}
|
96 |
-
return $this->plugin_settings_debug;
|
97 |
}
|
98 |
}
|
4 |
|
5 |
use WebpConverter\Action;
|
6 |
use WebpConverter\Conversion;
|
7 |
+
use WebpConverter\Conversion\Endpoint;
|
8 |
use WebpConverter\Conversion\Cron;
|
9 |
use WebpConverter\Error;
|
10 |
use WebpConverter\Conversion\Media;
|
11 |
use WebpConverter\Notice;
|
12 |
use WebpConverter\Plugin;
|
13 |
+
use WebpConverter\Settings\Page;
|
14 |
|
15 |
/**
|
16 |
* Class initializes all plugin actions.
|
17 |
*/
|
18 |
class WebpConverter {
|
19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
public function __construct() {
|
21 |
+
$plugin_data = new PluginData();
|
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\PathsEndpoint( $plugin_data ) ) )->init_hooks();
|
31 |
+
( new Endpoint\EndpointIntegration( new Endpoint\RegenerateEndpoint( $plugin_data ) ) )->init_hooks();
|
32 |
+
( new Conversion\SkipExists( $plugin_data ) )->init_hooks();
|
33 |
+
( new Conversion\SkipLarger( $plugin_data ) )->init_hooks();
|
34 |
+
( new Cron\Event( $plugin_data ) )->init_hooks();
|
35 |
( new Cron\Schedules() )->init_hooks();
|
36 |
+
( new Error\ErrorFactory( $plugin_data ) )->init_hooks();
|
37 |
( new Notice\NoticeFactory() )->init_hooks();
|
38 |
+
( new Loader\LoaderIntegration( new Loader\HtaccessLoader( $plugin_data ) ) )->init_hooks();
|
39 |
+
( new Loader\LoaderIntegration( new Loader\PassthruLoader( $plugin_data ) ) )->init_hooks();
|
40 |
( new Media\Delete() )->init_hooks();
|
41 |
+
( new Media\Upload( $plugin_data ) )->init_hooks();
|
42 |
( new Plugin\Activation() )->init_hooks();
|
43 |
+
( new Plugin\Deactivation() )->init_hooks();
|
44 |
+
( new Plugin\Deactivation\Modal( $plugin_data ) )->init_hooks();
|
45 |
( new Plugin\Links() )->init_hooks();
|
46 |
( new Plugin\Uninstall() )->init_hooks();
|
47 |
+
( new Plugin\Update() )->init_hooks();
|
48 |
+
( new Page\PageIntegration() )
|
49 |
+
->set_page_integration( new Page\SettingsPage( $plugin_data ) )
|
50 |
+
->set_page_integration( new Page\DebugPage( $plugin_data ) )
|
51 |
+
->init_hooks();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
}
|
53 |
}
|
templates/components/notices/thanks.php
CHANGED
@@ -18,37 +18,27 @@
|
|
18 |
<p>
|
19 |
<?php
|
20 |
echo wp_kses_post(
|
21 |
-
|
22 |
-
/* translators: %1$s: open anchor tag, %2$s: close anchor tag */
|
23 |
-
__( 'Please let us know what you think about our plugin. It is important that we can develop this tool. Thank you for all the ratings, reviews and donates. If you have a technical problem, please before you add a review %1$scheck our FAQ%2$s or contact us if you did not find help there. We will try to help you!', 'webp-converter-for-media' ),
|
24 |
-
'<a href="https://wordpress.org/plugins/webp-converter-for-media/#faq" target="_blank">',
|
25 |
-
'</a>'
|
26 |
-
)
|
27 |
);
|
28 |
?>
|
29 |
</p>
|
30 |
<div class="webpContent__buttons">
|
31 |
-
<a href="https://
|
32 |
-
|
|
|
33 |
>
|
34 |
-
<?php echo esc_html( __( '
|
35 |
</a>
|
36 |
<a href="https://wordpress.org/support/plugin/webp-converter-for-media/reviews/?rate=5#new-post"
|
37 |
target="_blank"
|
38 |
class="webpContent__button webpButton webpButton--green"
|
39 |
>
|
40 |
-
<?php echo esc_html( __( 'Add review', 'webp-converter-for-media' ) ); ?>
|
41 |
-
</a>
|
42 |
-
<a href="https://ko-fi.com/gbiorczyk/?utm_source=webp-converter-for-media&utm_medium=notice-thanks"
|
43 |
-
target="_blank"
|
44 |
-
class="webpContent__button webpButton webpButton--green dashicons-heart"
|
45 |
-
>
|
46 |
-
<?php echo esc_html( __( 'Provide us a coffee', 'webp-converter-for-media' ) ); ?>
|
47 |
</a>
|
48 |
<button type="button" data-permanently
|
49 |
class="webpContent__button webpButton webpButton--blue"
|
50 |
>
|
51 |
-
<?php echo esc_html( __( '
|
52 |
</button>
|
53 |
</div>
|
54 |
</div>
|
18 |
<p>
|
19 |
<?php
|
20 |
echo wp_kses_post(
|
21 |
+
__( 'We are glad that you are using our plugin and we hope you are satisfied with it. If you want, you can support us in the development of the plugin by providing us a coffee and adding a plugin review. This is very important and gives us the opportunity to create even better tools for you. Thank you to everyone.', 'webp-converter-for-media' )
|
|
|
|
|
|
|
|
|
|
|
22 |
);
|
23 |
?>
|
24 |
</p>
|
25 |
<div class="webpContent__buttons">
|
26 |
+
<a href="https://ko-fi.com/gbiorczyk/?utm_source=webp-converter-for-media&utm_medium=notice-thanks"
|
27 |
+
target="_blank"
|
28 |
+
class="webpContent__button webpButton webpButton--green dashicons-heart"
|
29 |
>
|
30 |
+
<?php echo esc_html( __( 'Provide us a coffee', 'webp-converter-for-media' ) ); ?>
|
31 |
</a>
|
32 |
<a href="https://wordpress.org/support/plugin/webp-converter-for-media/reviews/?rate=5#new-post"
|
33 |
target="_blank"
|
34 |
class="webpContent__button webpButton webpButton--green"
|
35 |
>
|
36 |
+
<?php echo esc_html( __( 'Add plugin review', 'webp-converter-for-media' ) ); ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
</a>
|
38 |
<button type="button" data-permanently
|
39 |
class="webpContent__button webpButton webpButton--blue"
|
40 |
>
|
41 |
+
<?php echo esc_html( __( 'Hide, do not show again', 'webp-converter-for-media' ) ); ?>
|
42 |
</button>
|
43 |
</div>
|
44 |
</div>
|
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 ComposerAutoloaderInit86c856d7af1950143b554dace890ec99::getLoader();
|
vendor/composer/InstalledVersions.php
CHANGED
@@ -32,7 +32,7 @@ private static $installed = array (
|
|
32 |
'aliases' =>
|
33 |
array (
|
34 |
),
|
35 |
-
'reference' => '
|
36 |
'name' => 'gbiorczyk/webp-converter-for-media',
|
37 |
),
|
38 |
'versions' =>
|
@@ -44,7 +44,7 @@ private static $installed = array (
|
|
44 |
'aliases' =>
|
45 |
array (
|
46 |
),
|
47 |
-
'reference' => '
|
48 |
),
|
49 |
),
|
50 |
);
|
32 |
'aliases' =>
|
33 |
array (
|
34 |
),
|
35 |
+
'reference' => 'a960ecb8763cea51e64d1f4d36b956ccb3106f64',
|
36 |
'name' => 'gbiorczyk/webp-converter-for-media',
|
37 |
),
|
38 |
'versions' =>
|
44 |
'aliases' =>
|
45 |
array (
|
46 |
),
|
47 |
+
'reference' => 'a960ecb8763cea51e64d1f4d36b956ccb3106f64',
|
48 |
),
|
49 |
),
|
50 |
);
|
vendor/composer/autoload_classmap.php
CHANGED
@@ -14,10 +14,10 @@ return array(
|
|
14 |
'WebpConverter\\Action\\RegenerateAll' => $baseDir . '/src/Action/RegenerateAll.php',
|
15 |
'WebpConverter\\Conversion\\Cron\\Event' => $baseDir . '/src/Conversion/Cron/Event.php',
|
16 |
'WebpConverter\\Conversion\\Cron\\Schedules' => $baseDir . '/src/Conversion/Cron/Schedules.php',
|
17 |
-
'WebpConverter\\Conversion\\Directories' => $baseDir . '/src/Conversion/Directories.php',
|
18 |
'WebpConverter\\Conversion\\DirectoryFiles' => $baseDir . '/src/Conversion/DirectoryFiles.php',
|
19 |
-
'WebpConverter\\Conversion\\Directory\\DirectoriesIntegration' => $baseDir . '/src/Conversion/Directory/DirectoriesIntegration.php',
|
20 |
'WebpConverter\\Conversion\\Directory\\DirectoryAbstract' => $baseDir . '/src/Conversion/Directory/DirectoryAbstract.php',
|
|
|
|
|
21 |
'WebpConverter\\Conversion\\Directory\\DirectoryInterface' => $baseDir . '/src/Conversion/Directory/DirectoryInterface.php',
|
22 |
'WebpConverter\\Conversion\\Directory\\GalleryDirectory' => $baseDir . '/src/Conversion/Directory/GalleryDirectory.php',
|
23 |
'WebpConverter\\Conversion\\Directory\\PluginsDirectory' => $baseDir . '/src/Conversion/Directory/PluginsDirectory.php',
|
@@ -29,7 +29,6 @@ return array(
|
|
29 |
'WebpConverter\\Conversion\\Endpoint\\EndpointInterface' => $baseDir . '/src/Conversion/Endpoint/EndpointInterface.php',
|
30 |
'WebpConverter\\Conversion\\Endpoint\\PathsEndpoint' => $baseDir . '/src/Conversion/Endpoint/PathsEndpoint.php',
|
31 |
'WebpConverter\\Conversion\\Endpoint\\RegenerateEndpoint' => $baseDir . '/src/Conversion/Endpoint/RegenerateEndpoint.php',
|
32 |
-
'WebpConverter\\Conversion\\Endpoints' => $baseDir . '/src/Conversion/Endpoints.php',
|
33 |
'WebpConverter\\Conversion\\Exception\\ConversionErrorException' => $baseDir . '/src/Conversion/Exception/ConversionErrorException.php',
|
34 |
'WebpConverter\\Conversion\\Exception\\ExceptionAbstract' => $baseDir . '/src/Conversion/Exception/ExceptionAbstract.php',
|
35 |
'WebpConverter\\Conversion\\Exception\\ExceptionInterface' => $baseDir . '/src/Conversion/Exception/ExceptionInterface.php',
|
@@ -45,24 +44,23 @@ return array(
|
|
45 |
'WebpConverter\\Conversion\\Exception\\SourcePathException' => $baseDir . '/src/Conversion/Exception/SourcePathException.php',
|
46 |
'WebpConverter\\Conversion\\Format\\AvifFormat' => $baseDir . '/src/Conversion/Format/AvifFormat.php',
|
47 |
'WebpConverter\\Conversion\\Format\\FormatAbstract' => $baseDir . '/src/Conversion/Format/FormatAbstract.php',
|
|
|
48 |
'WebpConverter\\Conversion\\Format\\FormatInterface' => $baseDir . '/src/Conversion/Format/FormatInterface.php',
|
49 |
'WebpConverter\\Conversion\\Format\\WebpFormat' => $baseDir . '/src/Conversion/Format/WebpFormat.php',
|
50 |
-
'WebpConverter\\Conversion\\Formats' => $baseDir . '/src/Conversion/Formats.php',
|
51 |
'WebpConverter\\Conversion\\Media\\Attachment' => $baseDir . '/src/Conversion/Media/Attachment.php',
|
52 |
'WebpConverter\\Conversion\\Media\\Delete' => $baseDir . '/src/Conversion/Media/Delete.php',
|
53 |
'WebpConverter\\Conversion\\Media\\Upload' => $baseDir . '/src/Conversion/Media/Upload.php',
|
54 |
'WebpConverter\\Conversion\\Method\\GdMethod' => $baseDir . '/src/Conversion/Method/GdMethod.php',
|
55 |
'WebpConverter\\Conversion\\Method\\ImagickMethod' => $baseDir . '/src/Conversion/Method/ImagickMethod.php',
|
56 |
'WebpConverter\\Conversion\\Method\\MethodAbstract' => $baseDir . '/src/Conversion/Method/MethodAbstract.php',
|
|
|
57 |
'WebpConverter\\Conversion\\Method\\MethodIntegrator' => $baseDir . '/src/Conversion/Method/MethodIntegrator.php',
|
58 |
'WebpConverter\\Conversion\\Method\\MethodInterface' => $baseDir . '/src/Conversion/Method/MethodInterface.php',
|
59 |
-
'WebpConverter\\Conversion\\Methods' => $baseDir . '/src/Conversion/Methods.php',
|
60 |
'WebpConverter\\Conversion\\OutputPath' => $baseDir . '/src/Conversion/OutputPath.php',
|
61 |
'WebpConverter\\Conversion\\SkipExists' => $baseDir . '/src/Conversion/SkipExists.php',
|
62 |
'WebpConverter\\Conversion\\SkipLarger' => $baseDir . '/src/Conversion/SkipLarger.php',
|
63 |
-
'WebpConverter\\Error\\
|
64 |
'WebpConverter\\Error\\ErrorInterface' => $baseDir . '/src/Error/ErrorInterface.php',
|
65 |
-
'WebpConverter\\Error\\Errors' => $baseDir . '/src/Error/Errors.php',
|
66 |
'WebpConverter\\Error\\LibsInstalledError' => $baseDir . '/src/Error/LibsInstalledError.php',
|
67 |
'WebpConverter\\Error\\LibsSupportAvifError' => $baseDir . '/src/Error/LibsSupportAvifError.php',
|
68 |
'WebpConverter\\Error\\LibsSupportWebpError' => $baseDir . '/src/Error/LibsSupportWebpError.php',
|
@@ -78,16 +76,14 @@ return array(
|
|
78 |
'WebpConverter\\Loader\\LoaderAbstract' => $baseDir . '/src/Loader/LoaderAbstract.php',
|
79 |
'WebpConverter\\Loader\\LoaderIntegration' => $baseDir . '/src/Loader/LoaderIntegration.php',
|
80 |
'WebpConverter\\Loader\\LoaderInterface' => $baseDir . '/src/Loader/LoaderInterface.php',
|
81 |
-
'WebpConverter\\Loader\\Loaders' => $baseDir . '/src/Loader/Loaders.php',
|
82 |
'WebpConverter\\Loader\\PassthruLoader' => $baseDir . '/src/Loader/PassthruLoader.php',
|
83 |
'WebpConverter\\Notice\\NoticeAbstract' => $baseDir . '/src/Notice/NoticeAbstract.php',
|
|
|
84 |
'WebpConverter\\Notice\\NoticeIntegration' => $baseDir . '/src/Notice/NoticeIntegration.php',
|
85 |
'WebpConverter\\Notice\\NoticeInterface' => $baseDir . '/src/Notice/NoticeInterface.php',
|
86 |
-
'WebpConverter\\Notice\\Notices' => $baseDir . '/src/Notice/Notices.php',
|
87 |
'WebpConverter\\Notice\\ThanksNotice' => $baseDir . '/src/Notice/ThanksNotice.php',
|
88 |
'WebpConverter\\Notice\\WelcomeNotice' => $baseDir . '/src/Notice/WelcomeNotice.php',
|
89 |
-
'WebpConverter\\
|
90 |
-
'WebpConverter\\PluginAccessInterface' => $baseDir . '/src/PluginAccessInterface.php',
|
91 |
'WebpConverter\\Plugin\\Activation' => $baseDir . '/src/Plugin/Activation.php',
|
92 |
'WebpConverter\\Plugin\\Activation\\DefaultSettings' => $baseDir . '/src/Plugin/Activation/DefaultSettings.php',
|
93 |
'WebpConverter\\Plugin\\Activation\\RefreshLoader' => $baseDir . '/src/Plugin/Activation/RefreshLoader.php',
|
@@ -109,17 +105,17 @@ return array(
|
|
109 |
'WebpConverter\\Settings\\Option\\ImagesQualityOption' => $baseDir . '/src/Settings/Option/ImagesQualityOption.php',
|
110 |
'WebpConverter\\Settings\\Option\\LoaderTypeOption' => $baseDir . '/src/Settings/Option/LoaderTypeOption.php',
|
111 |
'WebpConverter\\Settings\\Option\\OptionAbstract' => $baseDir . '/src/Settings/Option/OptionAbstract.php',
|
|
|
112 |
'WebpConverter\\Settings\\Option\\OptionIntegration' => $baseDir . '/src/Settings/Option/OptionIntegration.php',
|
113 |
'WebpConverter\\Settings\\Option\\OptionInterface' => $baseDir . '/src/Settings/Option/OptionInterface.php',
|
114 |
'WebpConverter\\Settings\\Option\\OutputFormatsOption' => $baseDir . '/src/Settings/Option/OutputFormatsOption.php',
|
115 |
'WebpConverter\\Settings\\Option\\SupportedDirectoriesOption' => $baseDir . '/src/Settings/Option/SupportedDirectoriesOption.php',
|
116 |
'WebpConverter\\Settings\\Option\\SupportedExtensionsOption' => $baseDir . '/src/Settings/Option/SupportedExtensionsOption.php',
|
117 |
-
'WebpConverter\\Settings\\Options' => $baseDir . '/src/Settings/Options.php',
|
118 |
'WebpConverter\\Settings\\Page\\DebugPage' => $baseDir . '/src/Settings/Page/DebugPage.php',
|
119 |
'WebpConverter\\Settings\\Page\\PageAbstract' => $baseDir . '/src/Settings/Page/PageAbstract.php',
|
|
|
120 |
'WebpConverter\\Settings\\Page\\PageInterface' => $baseDir . '/src/Settings/Page/PageInterface.php',
|
121 |
'WebpConverter\\Settings\\Page\\SettingsPage' => $baseDir . '/src/Settings/Page/SettingsPage.php',
|
122 |
-
'WebpConverter\\Settings\\Pages' => $baseDir . '/src/Settings/Pages.php',
|
123 |
'WebpConverter\\Settings\\SettingsSave' => $baseDir . '/src/Settings/SettingsSave.php',
|
124 |
'WebpConverter\\WebpConverter' => $baseDir . '/src/WebpConverter.php',
|
125 |
);
|
14 |
'WebpConverter\\Action\\RegenerateAll' => $baseDir . '/src/Action/RegenerateAll.php',
|
15 |
'WebpConverter\\Conversion\\Cron\\Event' => $baseDir . '/src/Conversion/Cron/Event.php',
|
16 |
'WebpConverter\\Conversion\\Cron\\Schedules' => $baseDir . '/src/Conversion/Cron/Schedules.php',
|
|
|
17 |
'WebpConverter\\Conversion\\DirectoryFiles' => $baseDir . '/src/Conversion/DirectoryFiles.php',
|
|
|
18 |
'WebpConverter\\Conversion\\Directory\\DirectoryAbstract' => $baseDir . '/src/Conversion/Directory/DirectoryAbstract.php',
|
19 |
+
'WebpConverter\\Conversion\\Directory\\DirectoryFactory' => $baseDir . '/src/Conversion/Directory/DirectoryFactory.php',
|
20 |
+
'WebpConverter\\Conversion\\Directory\\DirectoryIntegration' => $baseDir . '/src/Conversion/Directory/DirectoryIntegration.php',
|
21 |
'WebpConverter\\Conversion\\Directory\\DirectoryInterface' => $baseDir . '/src/Conversion/Directory/DirectoryInterface.php',
|
22 |
'WebpConverter\\Conversion\\Directory\\GalleryDirectory' => $baseDir . '/src/Conversion/Directory/GalleryDirectory.php',
|
23 |
'WebpConverter\\Conversion\\Directory\\PluginsDirectory' => $baseDir . '/src/Conversion/Directory/PluginsDirectory.php',
|
29 |
'WebpConverter\\Conversion\\Endpoint\\EndpointInterface' => $baseDir . '/src/Conversion/Endpoint/EndpointInterface.php',
|
30 |
'WebpConverter\\Conversion\\Endpoint\\PathsEndpoint' => $baseDir . '/src/Conversion/Endpoint/PathsEndpoint.php',
|
31 |
'WebpConverter\\Conversion\\Endpoint\\RegenerateEndpoint' => $baseDir . '/src/Conversion/Endpoint/RegenerateEndpoint.php',
|
|
|
32 |
'WebpConverter\\Conversion\\Exception\\ConversionErrorException' => $baseDir . '/src/Conversion/Exception/ConversionErrorException.php',
|
33 |
'WebpConverter\\Conversion\\Exception\\ExceptionAbstract' => $baseDir . '/src/Conversion/Exception/ExceptionAbstract.php',
|
34 |
'WebpConverter\\Conversion\\Exception\\ExceptionInterface' => $baseDir . '/src/Conversion/Exception/ExceptionInterface.php',
|
44 |
'WebpConverter\\Conversion\\Exception\\SourcePathException' => $baseDir . '/src/Conversion/Exception/SourcePathException.php',
|
45 |
'WebpConverter\\Conversion\\Format\\AvifFormat' => $baseDir . '/src/Conversion/Format/AvifFormat.php',
|
46 |
'WebpConverter\\Conversion\\Format\\FormatAbstract' => $baseDir . '/src/Conversion/Format/FormatAbstract.php',
|
47 |
+
'WebpConverter\\Conversion\\Format\\FormatFactory' => $baseDir . '/src/Conversion/Format/FormatFactory.php',
|
48 |
'WebpConverter\\Conversion\\Format\\FormatInterface' => $baseDir . '/src/Conversion/Format/FormatInterface.php',
|
49 |
'WebpConverter\\Conversion\\Format\\WebpFormat' => $baseDir . '/src/Conversion/Format/WebpFormat.php',
|
|
|
50 |
'WebpConverter\\Conversion\\Media\\Attachment' => $baseDir . '/src/Conversion/Media/Attachment.php',
|
51 |
'WebpConverter\\Conversion\\Media\\Delete' => $baseDir . '/src/Conversion/Media/Delete.php',
|
52 |
'WebpConverter\\Conversion\\Media\\Upload' => $baseDir . '/src/Conversion/Media/Upload.php',
|
53 |
'WebpConverter\\Conversion\\Method\\GdMethod' => $baseDir . '/src/Conversion/Method/GdMethod.php',
|
54 |
'WebpConverter\\Conversion\\Method\\ImagickMethod' => $baseDir . '/src/Conversion/Method/ImagickMethod.php',
|
55 |
'WebpConverter\\Conversion\\Method\\MethodAbstract' => $baseDir . '/src/Conversion/Method/MethodAbstract.php',
|
56 |
+
'WebpConverter\\Conversion\\Method\\MethodFactory' => $baseDir . '/src/Conversion/Method/MethodFactory.php',
|
57 |
'WebpConverter\\Conversion\\Method\\MethodIntegrator' => $baseDir . '/src/Conversion/Method/MethodIntegrator.php',
|
58 |
'WebpConverter\\Conversion\\Method\\MethodInterface' => $baseDir . '/src/Conversion/Method/MethodInterface.php',
|
|
|
59 |
'WebpConverter\\Conversion\\OutputPath' => $baseDir . '/src/Conversion/OutputPath.php',
|
60 |
'WebpConverter\\Conversion\\SkipExists' => $baseDir . '/src/Conversion/SkipExists.php',
|
61 |
'WebpConverter\\Conversion\\SkipLarger' => $baseDir . '/src/Conversion/SkipLarger.php',
|
62 |
+
'WebpConverter\\Error\\ErrorFactory' => $baseDir . '/src/Error/ErrorFactory.php',
|
63 |
'WebpConverter\\Error\\ErrorInterface' => $baseDir . '/src/Error/ErrorInterface.php',
|
|
|
64 |
'WebpConverter\\Error\\LibsInstalledError' => $baseDir . '/src/Error/LibsInstalledError.php',
|
65 |
'WebpConverter\\Error\\LibsSupportAvifError' => $baseDir . '/src/Error/LibsSupportAvifError.php',
|
66 |
'WebpConverter\\Error\\LibsSupportWebpError' => $baseDir . '/src/Error/LibsSupportWebpError.php',
|
76 |
'WebpConverter\\Loader\\LoaderAbstract' => $baseDir . '/src/Loader/LoaderAbstract.php',
|
77 |
'WebpConverter\\Loader\\LoaderIntegration' => $baseDir . '/src/Loader/LoaderIntegration.php',
|
78 |
'WebpConverter\\Loader\\LoaderInterface' => $baseDir . '/src/Loader/LoaderInterface.php',
|
|
|
79 |
'WebpConverter\\Loader\\PassthruLoader' => $baseDir . '/src/Loader/PassthruLoader.php',
|
80 |
'WebpConverter\\Notice\\NoticeAbstract' => $baseDir . '/src/Notice/NoticeAbstract.php',
|
81 |
+
'WebpConverter\\Notice\\NoticeFactory' => $baseDir . '/src/Notice/NoticeFactory.php',
|
82 |
'WebpConverter\\Notice\\NoticeIntegration' => $baseDir . '/src/Notice/NoticeIntegration.php',
|
83 |
'WebpConverter\\Notice\\NoticeInterface' => $baseDir . '/src/Notice/NoticeInterface.php',
|
|
|
84 |
'WebpConverter\\Notice\\ThanksNotice' => $baseDir . '/src/Notice/ThanksNotice.php',
|
85 |
'WebpConverter\\Notice\\WelcomeNotice' => $baseDir . '/src/Notice/WelcomeNotice.php',
|
86 |
+
'WebpConverter\\PluginData' => $baseDir . '/src/PluginData.php',
|
|
|
87 |
'WebpConverter\\Plugin\\Activation' => $baseDir . '/src/Plugin/Activation.php',
|
88 |
'WebpConverter\\Plugin\\Activation\\DefaultSettings' => $baseDir . '/src/Plugin/Activation/DefaultSettings.php',
|
89 |
'WebpConverter\\Plugin\\Activation\\RefreshLoader' => $baseDir . '/src/Plugin/Activation/RefreshLoader.php',
|
105 |
'WebpConverter\\Settings\\Option\\ImagesQualityOption' => $baseDir . '/src/Settings/Option/ImagesQualityOption.php',
|
106 |
'WebpConverter\\Settings\\Option\\LoaderTypeOption' => $baseDir . '/src/Settings/Option/LoaderTypeOption.php',
|
107 |
'WebpConverter\\Settings\\Option\\OptionAbstract' => $baseDir . '/src/Settings/Option/OptionAbstract.php',
|
108 |
+
'WebpConverter\\Settings\\Option\\OptionFactory' => $baseDir . '/src/Settings/Option/OptionFactory.php',
|
109 |
'WebpConverter\\Settings\\Option\\OptionIntegration' => $baseDir . '/src/Settings/Option/OptionIntegration.php',
|
110 |
'WebpConverter\\Settings\\Option\\OptionInterface' => $baseDir . '/src/Settings/Option/OptionInterface.php',
|
111 |
'WebpConverter\\Settings\\Option\\OutputFormatsOption' => $baseDir . '/src/Settings/Option/OutputFormatsOption.php',
|
112 |
'WebpConverter\\Settings\\Option\\SupportedDirectoriesOption' => $baseDir . '/src/Settings/Option/SupportedDirectoriesOption.php',
|
113 |
'WebpConverter\\Settings\\Option\\SupportedExtensionsOption' => $baseDir . '/src/Settings/Option/SupportedExtensionsOption.php',
|
|
|
114 |
'WebpConverter\\Settings\\Page\\DebugPage' => $baseDir . '/src/Settings/Page/DebugPage.php',
|
115 |
'WebpConverter\\Settings\\Page\\PageAbstract' => $baseDir . '/src/Settings/Page/PageAbstract.php',
|
116 |
+
'WebpConverter\\Settings\\Page\\PageIntegration' => $baseDir . '/src/Settings/Page/PageIntegration.php',
|
117 |
'WebpConverter\\Settings\\Page\\PageInterface' => $baseDir . '/src/Settings/Page/PageInterface.php',
|
118 |
'WebpConverter\\Settings\\Page\\SettingsPage' => $baseDir . '/src/Settings/Page/SettingsPage.php',
|
|
|
119 |
'WebpConverter\\Settings\\SettingsSave' => $baseDir . '/src/Settings/SettingsSave.php',
|
120 |
'WebpConverter\\WebpConverter' => $baseDir . '/src/WebpConverter.php',
|
121 |
);
|
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 ComposerAutoloaderInitd3fdbdc9a6d7ece90487f43492ad1f81
|
|
22 |
return self::$loader;
|
23 |
}
|
24 |
|
25 |
-
spl_autoload_register(array('
|
26 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
|
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 __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 ComposerAutoloaderInit86c856d7af1950143b554dace890ec99
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
22 |
return self::$loader;
|
23 |
}
|
24 |
|
25 |
+
spl_autoload_register(array('ComposerAutoloaderInit86c856d7af1950143b554dace890ec99', 'loadClassLoader'), true, true);
|
26 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
|
27 |
+
spl_autoload_unregister(array('ComposerAutoloaderInit86c856d7af1950143b554dace890ec99', '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 __DIR__ . '/autoload_static.php';
|
32 |
|
33 |
+
call_user_func(\Composer\Autoload\ComposerStaticInit86c856d7af1950143b554dace890ec99::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' =>
|
@@ -29,10 +29,10 @@ class ComposerStaticInitd3fdbdc9a6d7ece90487f43492ad1f81
|
|
29 |
'WebpConverter\\Action\\RegenerateAll' => __DIR__ . '/../..' . '/src/Action/RegenerateAll.php',
|
30 |
'WebpConverter\\Conversion\\Cron\\Event' => __DIR__ . '/../..' . '/src/Conversion/Cron/Event.php',
|
31 |
'WebpConverter\\Conversion\\Cron\\Schedules' => __DIR__ . '/../..' . '/src/Conversion/Cron/Schedules.php',
|
32 |
-
'WebpConverter\\Conversion\\Directories' => __DIR__ . '/../..' . '/src/Conversion/Directories.php',
|
33 |
'WebpConverter\\Conversion\\DirectoryFiles' => __DIR__ . '/../..' . '/src/Conversion/DirectoryFiles.php',
|
34 |
-
'WebpConverter\\Conversion\\Directory\\DirectoriesIntegration' => __DIR__ . '/../..' . '/src/Conversion/Directory/DirectoriesIntegration.php',
|
35 |
'WebpConverter\\Conversion\\Directory\\DirectoryAbstract' => __DIR__ . '/../..' . '/src/Conversion/Directory/DirectoryAbstract.php',
|
|
|
|
|
36 |
'WebpConverter\\Conversion\\Directory\\DirectoryInterface' => __DIR__ . '/../..' . '/src/Conversion/Directory/DirectoryInterface.php',
|
37 |
'WebpConverter\\Conversion\\Directory\\GalleryDirectory' => __DIR__ . '/../..' . '/src/Conversion/Directory/GalleryDirectory.php',
|
38 |
'WebpConverter\\Conversion\\Directory\\PluginsDirectory' => __DIR__ . '/../..' . '/src/Conversion/Directory/PluginsDirectory.php',
|
@@ -44,7 +44,6 @@ class ComposerStaticInitd3fdbdc9a6d7ece90487f43492ad1f81
|
|
44 |
'WebpConverter\\Conversion\\Endpoint\\EndpointInterface' => __DIR__ . '/../..' . '/src/Conversion/Endpoint/EndpointInterface.php',
|
45 |
'WebpConverter\\Conversion\\Endpoint\\PathsEndpoint' => __DIR__ . '/../..' . '/src/Conversion/Endpoint/PathsEndpoint.php',
|
46 |
'WebpConverter\\Conversion\\Endpoint\\RegenerateEndpoint' => __DIR__ . '/../..' . '/src/Conversion/Endpoint/RegenerateEndpoint.php',
|
47 |
-
'WebpConverter\\Conversion\\Endpoints' => __DIR__ . '/../..' . '/src/Conversion/Endpoints.php',
|
48 |
'WebpConverter\\Conversion\\Exception\\ConversionErrorException' => __DIR__ . '/../..' . '/src/Conversion/Exception/ConversionErrorException.php',
|
49 |
'WebpConverter\\Conversion\\Exception\\ExceptionAbstract' => __DIR__ . '/../..' . '/src/Conversion/Exception/ExceptionAbstract.php',
|
50 |
'WebpConverter\\Conversion\\Exception\\ExceptionInterface' => __DIR__ . '/../..' . '/src/Conversion/Exception/ExceptionInterface.php',
|
@@ -60,24 +59,23 @@ class ComposerStaticInitd3fdbdc9a6d7ece90487f43492ad1f81
|
|
60 |
'WebpConverter\\Conversion\\Exception\\SourcePathException' => __DIR__ . '/../..' . '/src/Conversion/Exception/SourcePathException.php',
|
61 |
'WebpConverter\\Conversion\\Format\\AvifFormat' => __DIR__ . '/../..' . '/src/Conversion/Format/AvifFormat.php',
|
62 |
'WebpConverter\\Conversion\\Format\\FormatAbstract' => __DIR__ . '/../..' . '/src/Conversion/Format/FormatAbstract.php',
|
|
|
63 |
'WebpConverter\\Conversion\\Format\\FormatInterface' => __DIR__ . '/../..' . '/src/Conversion/Format/FormatInterface.php',
|
64 |
'WebpConverter\\Conversion\\Format\\WebpFormat' => __DIR__ . '/../..' . '/src/Conversion/Format/WebpFormat.php',
|
65 |
-
'WebpConverter\\Conversion\\Formats' => __DIR__ . '/../..' . '/src/Conversion/Formats.php',
|
66 |
'WebpConverter\\Conversion\\Media\\Attachment' => __DIR__ . '/../..' . '/src/Conversion/Media/Attachment.php',
|
67 |
'WebpConverter\\Conversion\\Media\\Delete' => __DIR__ . '/../..' . '/src/Conversion/Media/Delete.php',
|
68 |
'WebpConverter\\Conversion\\Media\\Upload' => __DIR__ . '/../..' . '/src/Conversion/Media/Upload.php',
|
69 |
'WebpConverter\\Conversion\\Method\\GdMethod' => __DIR__ . '/../..' . '/src/Conversion/Method/GdMethod.php',
|
70 |
'WebpConverter\\Conversion\\Method\\ImagickMethod' => __DIR__ . '/../..' . '/src/Conversion/Method/ImagickMethod.php',
|
71 |
'WebpConverter\\Conversion\\Method\\MethodAbstract' => __DIR__ . '/../..' . '/src/Conversion/Method/MethodAbstract.php',
|
|
|
72 |
'WebpConverter\\Conversion\\Method\\MethodIntegrator' => __DIR__ . '/../..' . '/src/Conversion/Method/MethodIntegrator.php',
|
73 |
'WebpConverter\\Conversion\\Method\\MethodInterface' => __DIR__ . '/../..' . '/src/Conversion/Method/MethodInterface.php',
|
74 |
-
'WebpConverter\\Conversion\\Methods' => __DIR__ . '/../..' . '/src/Conversion/Methods.php',
|
75 |
'WebpConverter\\Conversion\\OutputPath' => __DIR__ . '/../..' . '/src/Conversion/OutputPath.php',
|
76 |
'WebpConverter\\Conversion\\SkipExists' => __DIR__ . '/../..' . '/src/Conversion/SkipExists.php',
|
77 |
'WebpConverter\\Conversion\\SkipLarger' => __DIR__ . '/../..' . '/src/Conversion/SkipLarger.php',
|
78 |
-
'WebpConverter\\Error\\
|
79 |
'WebpConverter\\Error\\ErrorInterface' => __DIR__ . '/../..' . '/src/Error/ErrorInterface.php',
|
80 |
-
'WebpConverter\\Error\\Errors' => __DIR__ . '/../..' . '/src/Error/Errors.php',
|
81 |
'WebpConverter\\Error\\LibsInstalledError' => __DIR__ . '/../..' . '/src/Error/LibsInstalledError.php',
|
82 |
'WebpConverter\\Error\\LibsSupportAvifError' => __DIR__ . '/../..' . '/src/Error/LibsSupportAvifError.php',
|
83 |
'WebpConverter\\Error\\LibsSupportWebpError' => __DIR__ . '/../..' . '/src/Error/LibsSupportWebpError.php',
|
@@ -93,16 +91,14 @@ class ComposerStaticInitd3fdbdc9a6d7ece90487f43492ad1f81
|
|
93 |
'WebpConverter\\Loader\\LoaderAbstract' => __DIR__ . '/../..' . '/src/Loader/LoaderAbstract.php',
|
94 |
'WebpConverter\\Loader\\LoaderIntegration' => __DIR__ . '/../..' . '/src/Loader/LoaderIntegration.php',
|
95 |
'WebpConverter\\Loader\\LoaderInterface' => __DIR__ . '/../..' . '/src/Loader/LoaderInterface.php',
|
96 |
-
'WebpConverter\\Loader\\Loaders' => __DIR__ . '/../..' . '/src/Loader/Loaders.php',
|
97 |
'WebpConverter\\Loader\\PassthruLoader' => __DIR__ . '/../..' . '/src/Loader/PassthruLoader.php',
|
98 |
'WebpConverter\\Notice\\NoticeAbstract' => __DIR__ . '/../..' . '/src/Notice/NoticeAbstract.php',
|
|
|
99 |
'WebpConverter\\Notice\\NoticeIntegration' => __DIR__ . '/../..' . '/src/Notice/NoticeIntegration.php',
|
100 |
'WebpConverter\\Notice\\NoticeInterface' => __DIR__ . '/../..' . '/src/Notice/NoticeInterface.php',
|
101 |
-
'WebpConverter\\Notice\\Notices' => __DIR__ . '/../..' . '/src/Notice/Notices.php',
|
102 |
'WebpConverter\\Notice\\ThanksNotice' => __DIR__ . '/../..' . '/src/Notice/ThanksNotice.php',
|
103 |
'WebpConverter\\Notice\\WelcomeNotice' => __DIR__ . '/../..' . '/src/Notice/WelcomeNotice.php',
|
104 |
-
'WebpConverter\\
|
105 |
-
'WebpConverter\\PluginAccessInterface' => __DIR__ . '/../..' . '/src/PluginAccessInterface.php',
|
106 |
'WebpConverter\\Plugin\\Activation' => __DIR__ . '/../..' . '/src/Plugin/Activation.php',
|
107 |
'WebpConverter\\Plugin\\Activation\\DefaultSettings' => __DIR__ . '/../..' . '/src/Plugin/Activation/DefaultSettings.php',
|
108 |
'WebpConverter\\Plugin\\Activation\\RefreshLoader' => __DIR__ . '/../..' . '/src/Plugin/Activation/RefreshLoader.php',
|
@@ -124,17 +120,17 @@ class ComposerStaticInitd3fdbdc9a6d7ece90487f43492ad1f81
|
|
124 |
'WebpConverter\\Settings\\Option\\ImagesQualityOption' => __DIR__ . '/../..' . '/src/Settings/Option/ImagesQualityOption.php',
|
125 |
'WebpConverter\\Settings\\Option\\LoaderTypeOption' => __DIR__ . '/../..' . '/src/Settings/Option/LoaderTypeOption.php',
|
126 |
'WebpConverter\\Settings\\Option\\OptionAbstract' => __DIR__ . '/../..' . '/src/Settings/Option/OptionAbstract.php',
|
|
|
127 |
'WebpConverter\\Settings\\Option\\OptionIntegration' => __DIR__ . '/../..' . '/src/Settings/Option/OptionIntegration.php',
|
128 |
'WebpConverter\\Settings\\Option\\OptionInterface' => __DIR__ . '/../..' . '/src/Settings/Option/OptionInterface.php',
|
129 |
'WebpConverter\\Settings\\Option\\OutputFormatsOption' => __DIR__ . '/../..' . '/src/Settings/Option/OutputFormatsOption.php',
|
130 |
'WebpConverter\\Settings\\Option\\SupportedDirectoriesOption' => __DIR__ . '/../..' . '/src/Settings/Option/SupportedDirectoriesOption.php',
|
131 |
'WebpConverter\\Settings\\Option\\SupportedExtensionsOption' => __DIR__ . '/../..' . '/src/Settings/Option/SupportedExtensionsOption.php',
|
132 |
-
'WebpConverter\\Settings\\Options' => __DIR__ . '/../..' . '/src/Settings/Options.php',
|
133 |
'WebpConverter\\Settings\\Page\\DebugPage' => __DIR__ . '/../..' . '/src/Settings/Page/DebugPage.php',
|
134 |
'WebpConverter\\Settings\\Page\\PageAbstract' => __DIR__ . '/../..' . '/src/Settings/Page/PageAbstract.php',
|
|
|
135 |
'WebpConverter\\Settings\\Page\\PageInterface' => __DIR__ . '/../..' . '/src/Settings/Page/PageInterface.php',
|
136 |
'WebpConverter\\Settings\\Page\\SettingsPage' => __DIR__ . '/../..' . '/src/Settings/Page/SettingsPage.php',
|
137 |
-
'WebpConverter\\Settings\\Pages' => __DIR__ . '/../..' . '/src/Settings/Pages.php',
|
138 |
'WebpConverter\\Settings\\SettingsSave' => __DIR__ . '/../..' . '/src/Settings/SettingsSave.php',
|
139 |
'WebpConverter\\WebpConverter' => __DIR__ . '/../..' . '/src/WebpConverter.php',
|
140 |
);
|
@@ -142,9 +138,9 @@ class ComposerStaticInitd3fdbdc9a6d7ece90487f43492ad1f81
|
|
142 |
public static function getInitializer(ClassLoader $loader)
|
143 |
{
|
144 |
return \Closure::bind(function () use ($loader) {
|
145 |
-
$loader->prefixLengthsPsr4 =
|
146 |
-
$loader->prefixDirsPsr4 =
|
147 |
-
$loader->classMap =
|
148 |
|
149 |
}, null, ClassLoader::class);
|
150 |
}
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
+
class ComposerStaticInit86c856d7af1950143b554dace890ec99
|
8 |
{
|
9 |
public static $prefixLengthsPsr4 = array (
|
10 |
'W' =>
|
29 |
'WebpConverter\\Action\\RegenerateAll' => __DIR__ . '/../..' . '/src/Action/RegenerateAll.php',
|
30 |
'WebpConverter\\Conversion\\Cron\\Event' => __DIR__ . '/../..' . '/src/Conversion/Cron/Event.php',
|
31 |
'WebpConverter\\Conversion\\Cron\\Schedules' => __DIR__ . '/../..' . '/src/Conversion/Cron/Schedules.php',
|
|
|
32 |
'WebpConverter\\Conversion\\DirectoryFiles' => __DIR__ . '/../..' . '/src/Conversion/DirectoryFiles.php',
|
|
|
33 |
'WebpConverter\\Conversion\\Directory\\DirectoryAbstract' => __DIR__ . '/../..' . '/src/Conversion/Directory/DirectoryAbstract.php',
|
34 |
+
'WebpConverter\\Conversion\\Directory\\DirectoryFactory' => __DIR__ . '/../..' . '/src/Conversion/Directory/DirectoryFactory.php',
|
35 |
+
'WebpConverter\\Conversion\\Directory\\DirectoryIntegration' => __DIR__ . '/../..' . '/src/Conversion/Directory/DirectoryIntegration.php',
|
36 |
'WebpConverter\\Conversion\\Directory\\DirectoryInterface' => __DIR__ . '/../..' . '/src/Conversion/Directory/DirectoryInterface.php',
|
37 |
'WebpConverter\\Conversion\\Directory\\GalleryDirectory' => __DIR__ . '/../..' . '/src/Conversion/Directory/GalleryDirectory.php',
|
38 |
'WebpConverter\\Conversion\\Directory\\PluginsDirectory' => __DIR__ . '/../..' . '/src/Conversion/Directory/PluginsDirectory.php',
|
44 |
'WebpConverter\\Conversion\\Endpoint\\EndpointInterface' => __DIR__ . '/../..' . '/src/Conversion/Endpoint/EndpointInterface.php',
|
45 |
'WebpConverter\\Conversion\\Endpoint\\PathsEndpoint' => __DIR__ . '/../..' . '/src/Conversion/Endpoint/PathsEndpoint.php',
|
46 |
'WebpConverter\\Conversion\\Endpoint\\RegenerateEndpoint' => __DIR__ . '/../..' . '/src/Conversion/Endpoint/RegenerateEndpoint.php',
|
|
|
47 |
'WebpConverter\\Conversion\\Exception\\ConversionErrorException' => __DIR__ . '/../..' . '/src/Conversion/Exception/ConversionErrorException.php',
|
48 |
'WebpConverter\\Conversion\\Exception\\ExceptionAbstract' => __DIR__ . '/../..' . '/src/Conversion/Exception/ExceptionAbstract.php',
|
49 |
'WebpConverter\\Conversion\\Exception\\ExceptionInterface' => __DIR__ . '/../..' . '/src/Conversion/Exception/ExceptionInterface.php',
|
59 |
'WebpConverter\\Conversion\\Exception\\SourcePathException' => __DIR__ . '/../..' . '/src/Conversion/Exception/SourcePathException.php',
|
60 |
'WebpConverter\\Conversion\\Format\\AvifFormat' => __DIR__ . '/../..' . '/src/Conversion/Format/AvifFormat.php',
|
61 |
'WebpConverter\\Conversion\\Format\\FormatAbstract' => __DIR__ . '/../..' . '/src/Conversion/Format/FormatAbstract.php',
|
62 |
+
'WebpConverter\\Conversion\\Format\\FormatFactory' => __DIR__ . '/../..' . '/src/Conversion/Format/FormatFactory.php',
|
63 |
'WebpConverter\\Conversion\\Format\\FormatInterface' => __DIR__ . '/../..' . '/src/Conversion/Format/FormatInterface.php',
|
64 |
'WebpConverter\\Conversion\\Format\\WebpFormat' => __DIR__ . '/../..' . '/src/Conversion/Format/WebpFormat.php',
|
|
|
65 |
'WebpConverter\\Conversion\\Media\\Attachment' => __DIR__ . '/../..' . '/src/Conversion/Media/Attachment.php',
|
66 |
'WebpConverter\\Conversion\\Media\\Delete' => __DIR__ . '/../..' . '/src/Conversion/Media/Delete.php',
|
67 |
'WebpConverter\\Conversion\\Media\\Upload' => __DIR__ . '/../..' . '/src/Conversion/Media/Upload.php',
|
68 |
'WebpConverter\\Conversion\\Method\\GdMethod' => __DIR__ . '/../..' . '/src/Conversion/Method/GdMethod.php',
|
69 |
'WebpConverter\\Conversion\\Method\\ImagickMethod' => __DIR__ . '/../..' . '/src/Conversion/Method/ImagickMethod.php',
|
70 |
'WebpConverter\\Conversion\\Method\\MethodAbstract' => __DIR__ . '/../..' . '/src/Conversion/Method/MethodAbstract.php',
|
71 |
+
'WebpConverter\\Conversion\\Method\\MethodFactory' => __DIR__ . '/../..' . '/src/Conversion/Method/MethodFactory.php',
|
72 |
'WebpConverter\\Conversion\\Method\\MethodIntegrator' => __DIR__ . '/../..' . '/src/Conversion/Method/MethodIntegrator.php',
|
73 |
'WebpConverter\\Conversion\\Method\\MethodInterface' => __DIR__ . '/../..' . '/src/Conversion/Method/MethodInterface.php',
|
|
|
74 |
'WebpConverter\\Conversion\\OutputPath' => __DIR__ . '/../..' . '/src/Conversion/OutputPath.php',
|
75 |
'WebpConverter\\Conversion\\SkipExists' => __DIR__ . '/../..' . '/src/Conversion/SkipExists.php',
|
76 |
'WebpConverter\\Conversion\\SkipLarger' => __DIR__ . '/../..' . '/src/Conversion/SkipLarger.php',
|
77 |
+
'WebpConverter\\Error\\ErrorFactory' => __DIR__ . '/../..' . '/src/Error/ErrorFactory.php',
|
78 |
'WebpConverter\\Error\\ErrorInterface' => __DIR__ . '/../..' . '/src/Error/ErrorInterface.php',
|
|
|
79 |
'WebpConverter\\Error\\LibsInstalledError' => __DIR__ . '/../..' . '/src/Error/LibsInstalledError.php',
|
80 |
'WebpConverter\\Error\\LibsSupportAvifError' => __DIR__ . '/../..' . '/src/Error/LibsSupportAvifError.php',
|
81 |
'WebpConverter\\Error\\LibsSupportWebpError' => __DIR__ . '/../..' . '/src/Error/LibsSupportWebpError.php',
|
91 |
'WebpConverter\\Loader\\LoaderAbstract' => __DIR__ . '/../..' . '/src/Loader/LoaderAbstract.php',
|
92 |
'WebpConverter\\Loader\\LoaderIntegration' => __DIR__ . '/../..' . '/src/Loader/LoaderIntegration.php',
|
93 |
'WebpConverter\\Loader\\LoaderInterface' => __DIR__ . '/../..' . '/src/Loader/LoaderInterface.php',
|
|
|
94 |
'WebpConverter\\Loader\\PassthruLoader' => __DIR__ . '/../..' . '/src/Loader/PassthruLoader.php',
|
95 |
'WebpConverter\\Notice\\NoticeAbstract' => __DIR__ . '/../..' . '/src/Notice/NoticeAbstract.php',
|
96 |
+
'WebpConverter\\Notice\\NoticeFactory' => __DIR__ . '/../..' . '/src/Notice/NoticeFactory.php',
|
97 |
'WebpConverter\\Notice\\NoticeIntegration' => __DIR__ . '/../..' . '/src/Notice/NoticeIntegration.php',
|
98 |
'WebpConverter\\Notice\\NoticeInterface' => __DIR__ . '/../..' . '/src/Notice/NoticeInterface.php',
|
|
|
99 |
'WebpConverter\\Notice\\ThanksNotice' => __DIR__ . '/../..' . '/src/Notice/ThanksNotice.php',
|
100 |
'WebpConverter\\Notice\\WelcomeNotice' => __DIR__ . '/../..' . '/src/Notice/WelcomeNotice.php',
|
101 |
+
'WebpConverter\\PluginData' => __DIR__ . '/../..' . '/src/PluginData.php',
|
|
|
102 |
'WebpConverter\\Plugin\\Activation' => __DIR__ . '/../..' . '/src/Plugin/Activation.php',
|
103 |
'WebpConverter\\Plugin\\Activation\\DefaultSettings' => __DIR__ . '/../..' . '/src/Plugin/Activation/DefaultSettings.php',
|
104 |
'WebpConverter\\Plugin\\Activation\\RefreshLoader' => __DIR__ . '/../..' . '/src/Plugin/Activation/RefreshLoader.php',
|
120 |
'WebpConverter\\Settings\\Option\\ImagesQualityOption' => __DIR__ . '/../..' . '/src/Settings/Option/ImagesQualityOption.php',
|
121 |
'WebpConverter\\Settings\\Option\\LoaderTypeOption' => __DIR__ . '/../..' . '/src/Settings/Option/LoaderTypeOption.php',
|
122 |
'WebpConverter\\Settings\\Option\\OptionAbstract' => __DIR__ . '/../..' . '/src/Settings/Option/OptionAbstract.php',
|
123 |
+
'WebpConverter\\Settings\\Option\\OptionFactory' => __DIR__ . '/../..' . '/src/Settings/Option/OptionFactory.php',
|
124 |
'WebpConverter\\Settings\\Option\\OptionIntegration' => __DIR__ . '/../..' . '/src/Settings/Option/OptionIntegration.php',
|
125 |
'WebpConverter\\Settings\\Option\\OptionInterface' => __DIR__ . '/../..' . '/src/Settings/Option/OptionInterface.php',
|
126 |
'WebpConverter\\Settings\\Option\\OutputFormatsOption' => __DIR__ . '/../..' . '/src/Settings/Option/OutputFormatsOption.php',
|
127 |
'WebpConverter\\Settings\\Option\\SupportedDirectoriesOption' => __DIR__ . '/../..' . '/src/Settings/Option/SupportedDirectoriesOption.php',
|
128 |
'WebpConverter\\Settings\\Option\\SupportedExtensionsOption' => __DIR__ . '/../..' . '/src/Settings/Option/SupportedExtensionsOption.php',
|
|
|
129 |
'WebpConverter\\Settings\\Page\\DebugPage' => __DIR__ . '/../..' . '/src/Settings/Page/DebugPage.php',
|
130 |
'WebpConverter\\Settings\\Page\\PageAbstract' => __DIR__ . '/../..' . '/src/Settings/Page/PageAbstract.php',
|
131 |
+
'WebpConverter\\Settings\\Page\\PageIntegration' => __DIR__ . '/../..' . '/src/Settings/Page/PageIntegration.php',
|
132 |
'WebpConverter\\Settings\\Page\\PageInterface' => __DIR__ . '/../..' . '/src/Settings/Page/PageInterface.php',
|
133 |
'WebpConverter\\Settings\\Page\\SettingsPage' => __DIR__ . '/../..' . '/src/Settings/Page/SettingsPage.php',
|
|
|
134 |
'WebpConverter\\Settings\\SettingsSave' => __DIR__ . '/../..' . '/src/Settings/SettingsSave.php',
|
135 |
'WebpConverter\\WebpConverter' => __DIR__ . '/../..' . '/src/WebpConverter.php',
|
136 |
);
|
138 |
public static function getInitializer(ClassLoader $loader)
|
139 |
{
|
140 |
return \Closure::bind(function () use ($loader) {
|
141 |
+
$loader->prefixLengthsPsr4 = ComposerStaticInit86c856d7af1950143b554dace890ec99::$prefixLengthsPsr4;
|
142 |
+
$loader->prefixDirsPsr4 = ComposerStaticInit86c856d7af1950143b554dace890ec99::$prefixDirsPsr4;
|
143 |
+
$loader->classMap = ComposerStaticInit86c856d7af1950143b554dace890ec99::$classMap;
|
144 |
|
145 |
}, null, ClassLoader::class);
|
146 |
}
|
vendor/composer/installed.php
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
'aliases' =>
|
7 |
array (
|
8 |
),
|
9 |
-
'reference' => '
|
10 |
'name' => 'gbiorczyk/webp-converter-for-media',
|
11 |
),
|
12 |
'versions' =>
|
@@ -18,7 +18,7 @@
|
|
18 |
'aliases' =>
|
19 |
array (
|
20 |
),
|
21 |
-
'reference' => '
|
22 |
),
|
23 |
),
|
24 |
);
|
6 |
'aliases' =>
|
7 |
array (
|
8 |
),
|
9 |
+
'reference' => 'a960ecb8763cea51e64d1f4d36b956ccb3106f64',
|
10 |
'name' => 'gbiorczyk/webp-converter-for-media',
|
11 |
),
|
12 |
'versions' =>
|
18 |
'aliases' =>
|
19 |
array (
|
20 |
),
|
21 |
+
'reference' => 'a960ecb8763cea51e64d1f4d36b956ccb3106f64',
|
22 |
),
|
23 |
),
|
24 |
);
|
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.
|
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.
|
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.7
|
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.7' );
|
14 |
define( 'WEBPC_FILE', __FILE__ );
|
15 |
define( 'WEBPC_NAME', plugin_basename( __FILE__ ) );
|
16 |
define( 'WEBPC_PATH', plugin_dir_path( __FILE__ ) );
|