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

Version Description

(2021-07-25) = * [Fixed] Compatibility of plugin settings for multisite websites

Download this release

Release Info

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

Code changes from version 3.0.7 to 3.0.8

readme.txt CHANGED
@@ -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.7 (2021-07-19) =
440
  * `[Added]` Changes to improve performance of plugin
441
 
436
 
437
  == Changelog ==
438
 
439
+ = 3.0.8 (2021-07-25) =
440
+ * `[Fixed]` Compatibility of plugin settings for multisite websites
441
+
442
  = 3.0.7 (2021-07-19) =
443
  * `[Added]` Changes to improve performance of plugin
444
 
src/Action/ConvertAttachment.php CHANGED
@@ -2,9 +2,9 @@
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.
2
 
3
  namespace WebpConverter\Action;
4
 
5
+ use WebpConverter\Conversion\Media\Attachment;
6
  use WebpConverter\HookableInterface;
7
  use WebpConverter\PluginData;
 
8
 
9
  /**
10
  * Initializes conversion of all image sizes for attachment.
src/Action/ConvertPaths.php CHANGED
@@ -2,9 +2,9 @@
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.
2
 
3
  namespace WebpConverter\Action;
4
 
5
+ use WebpConverter\Conversion\Method\MethodIntegrator;
6
  use WebpConverter\HookableInterface;
7
  use WebpConverter\PluginData;
 
8
 
9
  /**
10
  * Initializes conversion of all images in list of paths.
src/Action/DeletePaths.php CHANGED
@@ -2,9 +2,9 @@
2
 
3
  namespace WebpConverter\Action;
4
 
5
- use WebpConverter\HookableInterface;
6
  use WebpConverter\Conversion\OutputPath;
7
  use WebpConverter\Conversion\SkipLarger;
 
8
 
9
  /**
10
  * Deletes all images in list of paths.
2
 
3
  namespace WebpConverter\Action;
4
 
 
5
  use WebpConverter\Conversion\OutputPath;
6
  use WebpConverter\Conversion\SkipLarger;
7
+ use WebpConverter\HookableInterface;
8
 
9
  /**
10
  * Deletes all images in list of paths.
src/Action/RegenerateAll.php CHANGED
@@ -2,9 +2,9 @@
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.
2
 
3
  namespace WebpConverter\Action;
4
 
5
+ use WebpConverter\Conversion\Endpoint\PathsEndpoint;
6
  use WebpConverter\HookableInterface;
7
  use WebpConverter\PluginData;
 
8
 
9
  /**
10
  * Initializes conversion of all image sizes in all directories.
src/Conversion/Directory/DirectoryIntegration.php CHANGED
@@ -2,8 +2,8 @@
2
 
3
  namespace WebpConverter\Conversion\Directory;
4
 
5
- use WebpConverter\HookableInterface;
6
  use WebpConverter\Conversion\OutputPath;
 
7
 
8
  /**
9
  * Returns various types of paths for directories.
2
 
3
  namespace WebpConverter\Conversion\Directory;
4
 
 
5
  use WebpConverter\Conversion\OutputPath;
6
+ use WebpConverter\HookableInterface;
7
 
8
  /**
9
  * Returns various types of paths for directories.
src/Conversion/Method/GdMethod.php CHANGED
@@ -2,9 +2,9 @@
2
 
3
  namespace WebpConverter\Conversion\Method;
4
 
5
- use WebpConverter\Conversion\Format\WebpFormat;
6
- use WebpConverter\Conversion\Format\AvifFormat;
7
  use WebpConverter\Conversion\Exception;
 
 
8
 
9
  /**
10
  * Supports image conversion method using GD library.
2
 
3
  namespace WebpConverter\Conversion\Method;
4
 
 
 
5
  use WebpConverter\Conversion\Exception;
6
+ use WebpConverter\Conversion\Format\AvifFormat;
7
+ use WebpConverter\Conversion\Format\WebpFormat;
8
 
9
  /**
10
  * Supports image conversion method using GD library.
src/Conversion/Method/ImagickMethod.php CHANGED
@@ -2,9 +2,9 @@
2
 
3
  namespace WebpConverter\Conversion\Method;
4
 
5
- use WebpConverter\Conversion\Format\WebpFormat;
6
- use WebpConverter\Conversion\Format\AvifFormat;
7
  use WebpConverter\Conversion\Exception;
 
 
8
 
9
  /**
10
  * Supports image conversion method using Imagick library.
2
 
3
  namespace WebpConverter\Conversion\Method;
4
 
 
 
5
  use WebpConverter\Conversion\Exception;
6
+ use WebpConverter\Conversion\Format\AvifFormat;
7
+ use WebpConverter\Conversion\Format\WebpFormat;
8
 
9
  /**
10
  * Supports image conversion method using Imagick library.
src/Conversion/SkipExists.php CHANGED
@@ -2,8 +2,8 @@
2
 
3
  namespace WebpConverter\Conversion;
4
 
5
- use WebpConverter\HookableInterface;
6
  use WebpConverter\Conversion\Format\FormatFactory;
 
7
  use WebpConverter\PluginData;
8
 
9
  /**
2
 
3
  namespace WebpConverter\Conversion;
4
 
 
5
  use WebpConverter\Conversion\Format\FormatFactory;
6
+ use WebpConverter\HookableInterface;
7
  use WebpConverter\PluginData;
8
 
9
  /**
src/Conversion/SkipLarger.php CHANGED
@@ -2,8 +2,8 @@
2
 
3
  namespace WebpConverter\Conversion;
4
 
5
- use WebpConverter\HookableInterface;
6
  use WebpConverter\Conversion\Exception;
 
7
  use WebpConverter\PluginData;
8
 
9
  /**
2
 
3
  namespace WebpConverter\Conversion;
4
 
 
5
  use WebpConverter\Conversion\Exception;
6
+ use WebpConverter\HookableInterface;
7
  use WebpConverter\PluginData;
8
 
9
  /**
src/Error/ErrorFactory.php CHANGED
@@ -2,9 +2,10 @@
2
 
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
  /**
@@ -54,7 +55,7 @@ class ErrorFactory implements HookableInterface {
54
  * @return string[] Errors codes.
55
  */
56
  public function get_server_errors( array $values, bool $only_errors = false, bool $is_force_refresh = false ): array {
57
- $errors = get_option( self::ERRORS_CACHE_OPTION, $this->cache );
58
  if ( $is_force_refresh ) {
59
  $errors = $this->get_errors_list();
60
  }
@@ -141,7 +142,7 @@ class ErrorFactory implements HookableInterface {
141
  }
142
 
143
  $this->cache = $errors;
144
- update_option( self::ERRORS_CACHE_OPTION, $errors );
145
 
146
  return $errors;
147
  }
2
 
3
  namespace WebpConverter\Error;
4
 
5
+ use WebpConverter\Helper\OptionsAccess;
 
6
  use WebpConverter\Helper\ViewLoader;
7
+ use WebpConverter\HookableInterface;
8
+ use WebpConverter\Loader\PassthruLoader;
9
  use WebpConverter\PluginData;
10
 
11
  /**
55
  * @return string[] Errors codes.
56
  */
57
  public function get_server_errors( array $values, bool $only_errors = false, bool $is_force_refresh = false ): array {
58
+ $errors = OptionsAccess::get_option( self::ERRORS_CACHE_OPTION, $this->cache );
59
  if ( $is_force_refresh ) {
60
  $errors = $this->get_errors_list();
61
  }
142
  }
143
 
144
  $this->cache = $errors;
145
+ OptionsAccess::update_option( self::ERRORS_CACHE_OPTION, $errors );
146
 
147
  return $errors;
148
  }
src/Error/LibsSupportAvifError.php CHANGED
@@ -2,9 +2,9 @@
2
 
3
  namespace WebpConverter\Error;
4
 
 
5
  use WebpConverter\Conversion\Method\GdMethod;
6
  use WebpConverter\Conversion\Method\ImagickMethod;
7
- use WebpConverter\Conversion\Format\AvifFormat;
8
  use WebpConverter\PluginData;
9
 
10
  /**
2
 
3
  namespace WebpConverter\Error;
4
 
5
+ use WebpConverter\Conversion\Format\AvifFormat;
6
  use WebpConverter\Conversion\Method\GdMethod;
7
  use WebpConverter\Conversion\Method\ImagickMethod;
 
8
  use WebpConverter\PluginData;
9
 
10
  /**
src/Error/LibsSupportWebpError.php CHANGED
@@ -2,10 +2,9 @@
2
 
3
  namespace WebpConverter\Error;
4
 
 
5
  use WebpConverter\Conversion\Method\GdMethod;
6
  use WebpConverter\Conversion\Method\ImagickMethod;
7
- use WebpConverter\Conversion\Format\WebpFormat;
8
- use WebpConverter\Conversion\Format\FormatFactory;
9
 
10
  /**
11
  * Checks for configuration errors about image conversion methods that do not support WebP output format.
2
 
3
  namespace WebpConverter\Error;
4
 
5
+ use WebpConverter\Conversion\Format\WebpFormat;
6
  use WebpConverter\Conversion\Method\GdMethod;
7
  use WebpConverter\Conversion\Method\ImagickMethod;
 
 
8
 
9
  /**
10
  * Checks for configuration errors about image conversion methods that do not support WebP output format.
src/Error/RewritesError.php CHANGED
@@ -2,10 +2,10 @@
2
 
3
  namespace WebpConverter\Error;
4
 
5
- use WebpConverter\Conversion\OutputPath;
6
  use WebpConverter\Conversion\Format\WebpFormat;
7
- use WebpConverter\Loader\LoaderAbstract;
8
  use WebpConverter\Helper\FileLoader;
 
9
  use WebpConverter\PluginData;
10
 
11
  /**
2
 
3
  namespace WebpConverter\Error;
4
 
 
5
  use WebpConverter\Conversion\Format\WebpFormat;
6
+ use WebpConverter\Conversion\OutputPath;
7
  use WebpConverter\Helper\FileLoader;
8
+ use WebpConverter\Loader\LoaderAbstract;
9
  use WebpConverter\PluginData;
10
 
11
  /**
src/Helper/OptionsAccess.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WebpConverter\Helper;
4
+
5
+ /**
6
+ * Provides access to options stored in database.
7
+ */
8
+ class OptionsAccess {
9
+
10
+ /**
11
+ * @param string $option_name .
12
+ * @param mixed $default_value .
13
+ *
14
+ * @return mixed|null
15
+ */
16
+ public static function get_option( string $option_name, $default_value = null ) {
17
+ if ( is_multisite() ) {
18
+ return get_site_option( $option_name, $default_value );
19
+ } else {
20
+ return get_option( $option_name, $default_value );
21
+ }
22
+ }
23
+
24
+ /**
25
+ * @param string $option_name .
26
+ * @param mixed $option_value .
27
+ *
28
+ * @return void
29
+ */
30
+ public static function update_option( string $option_name, $option_value ) {
31
+ if ( is_multisite() ) {
32
+ update_site_option( $option_name, $option_value );
33
+ } else {
34
+ update_option( $option_name, $option_value );
35
+ }
36
+ }
37
+
38
+ /**
39
+ * @param string $option_name .
40
+ *
41
+ * @return void
42
+ */
43
+ public static function delete_option( string $option_name ) {
44
+ if ( is_multisite() ) {
45
+ delete_site_option( $option_name );
46
+ } else {
47
+ delete_option( $option_name );
48
+ }
49
+ }
50
+ }
src/Notice/NoticeIntegration.php CHANGED
@@ -2,9 +2,10 @@
2
 
3
  namespace WebpConverter\Notice;
4
 
 
 
5
  use WebpConverter\HookableInterface;
6
  use WebpConverter\Settings\AdminAssets;
7
- use WebpConverter\Helper\ViewLoader;
8
 
9
  /**
10
  * Supports ability to display notice and its management.
@@ -32,7 +33,7 @@ class NoticeIntegration implements HookableInterface {
32
  add_action( 'admin_init', [ $this, 'init_notice_hooks' ] );
33
 
34
  if ( $ajax_action = $this->notice->get_ajax_action_to_disable() ) {
35
- add_action( 'wp_ajax_' . $ajax_action, [ $this->notice, 'disable_notice' ] );
36
  }
37
  }
38
 
@@ -43,13 +44,16 @@ class NoticeIntegration implements HookableInterface {
43
  * @internal
44
  */
45
  public function init_notice_hooks() {
46
- if ( ! $this->notice->is_available() ) {
47
  return;
48
  }
49
 
50
  ( new AdminAssets() )->init_hooks();
51
- add_action( 'admin_notices', [ $this, 'load_notice' ] );
52
- add_action( 'network_admin_notices', [ $this, 'load_notice' ] );
 
 
 
53
  }
54
 
55
  /**
@@ -59,10 +63,6 @@ class NoticeIntegration implements HookableInterface {
59
  * @internal
60
  */
61
  public function load_notice() {
62
- if ( ! $this->notice->is_available() ) {
63
- return;
64
- }
65
-
66
  ViewLoader::load_view(
67
  $this->notice->get_output_path(),
68
  $this->notice->get_vars_for_view()
@@ -75,9 +75,19 @@ class NoticeIntegration implements HookableInterface {
75
  * @return void
76
  */
77
  public function set_default_value() {
78
- if ( get_option( $this->notice->get_option_name(), null ) !== null ) {
79
  return;
80
  }
81
- update_option( $this->notice->get_option_name(), $this->notice->get_default_value() );
 
 
 
 
 
 
 
 
 
 
82
  }
83
  }
2
 
3
  namespace WebpConverter\Notice;
4
 
5
+ use WebpConverter\Helper\OptionsAccess;
6
+ use WebpConverter\Helper\ViewLoader;
7
  use WebpConverter\HookableInterface;
8
  use WebpConverter\Settings\AdminAssets;
 
9
 
10
  /**
11
  * Supports ability to display notice and its management.
33
  add_action( 'admin_init', [ $this, 'init_notice_hooks' ] );
34
 
35
  if ( $ajax_action = $this->notice->get_ajax_action_to_disable() ) {
36
+ add_action( 'wp_ajax_' . $ajax_action, [ $this, 'set_disable_value' ] );
37
  }
38
  }
39
 
44
  * @internal
45
  */
46
  public function init_notice_hooks() {
47
+ if ( ! $this->notice->is_available() || ! $this->notice->is_active() ) {
48
  return;
49
  }
50
 
51
  ( new AdminAssets() )->init_hooks();
52
+ if ( ! is_multisite() ) {
53
+ add_action( 'admin_notices', [ $this, 'load_notice' ] );
54
+ } else {
55
+ add_action( 'network_admin_notices', [ $this, 'load_notice' ] );
56
+ }
57
  }
58
 
59
  /**
63
  * @internal
64
  */
65
  public function load_notice() {
 
 
 
 
66
  ViewLoader::load_view(
67
  $this->notice->get_output_path(),
68
  $this->notice->get_vars_for_view()
75
  * @return void
76
  */
77
  public function set_default_value() {
78
+ if ( OptionsAccess::get_option( $this->notice->get_option_name() ) !== null ) {
79
  return;
80
  }
81
+
82
+ OptionsAccess::update_option( $this->notice->get_option_name(), $this->notice->get_default_value() );
83
+ }
84
+
85
+ /**
86
+ * Sets options to disable notice.
87
+ *
88
+ * @return void
89
+ */
90
+ public function set_disable_value() {
91
+ OptionsAccess::update_option( $this->notice->get_option_name(), $this->notice->get_disable_value() );
92
  }
93
  }
src/Notice/NoticeInterface.php CHANGED
@@ -22,12 +22,26 @@ interface NoticeInterface {
22
  public function get_default_value(): string;
23
 
24
  /**
25
- * Returns status if notice is active.
26
  *
27
  * @return bool Is notice available?
28
  */
29
  public function is_available(): bool;
30
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  /**
32
  * Returns server path for view template.
33
  *
@@ -48,12 +62,4 @@ interface NoticeInterface {
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.
54
- *
55
- * @return void
56
- * @internal
57
- */
58
- public static function disable_notice();
59
  }
22
  public function get_default_value(): string;
23
 
24
  /**
25
+ * Returns status if notice is available.
26
  *
27
  * @return bool Is notice available?
28
  */
29
  public function is_available(): bool;
30
 
31
+ /**
32
+ * Returns status if notice is active.
33
+ *
34
+ * @return bool Is notice active?
35
+ */
36
+ public function is_active(): bool;
37
+
38
+ /**
39
+ * Returns value of option meaning to hide notice.
40
+ *
41
+ * @return string
42
+ */
43
+ public function get_disable_value(): string;
44
+
45
  /**
46
  * Returns server path for view template.
47
  *
62
  * @return string|null Name of ajax action.
63
  */
64
  public function get_ajax_action_to_disable();
 
 
 
 
 
 
 
 
65
  }
src/Notice/ThanksNotice.php CHANGED
@@ -2,6 +2,8 @@
2
 
3
  namespace WebpConverter\Notice;
4
 
 
 
5
  /**
6
  * Supports notice displayed as thank you for using plugin.
7
  */
@@ -29,12 +31,23 @@ class ThanksNotice extends NoticeAbstract implements NoticeInterface {
29
  * {@inheritdoc}
30
  */
31
  public function is_available(): bool {
32
- if ( basename( $_SERVER['PHP_SELF'] ) !== 'index.php' ) { // phpcs:ignore
33
- return false;
34
- }
 
 
 
 
 
 
 
35
 
36
- $value = get_option( self::NOTICE_OPTION, 0 );
37
- return ( $value < time() );
 
 
 
 
38
  }
39
 
40
  /**
@@ -59,14 +72,4 @@ class ThanksNotice extends NoticeAbstract implements NoticeInterface {
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
- }
72
  }
2
 
3
  namespace WebpConverter\Notice;
4
 
5
+ use WebpConverter\Helper\OptionsAccess;
6
+
7
  /**
8
  * Supports notice displayed as thank you for using plugin.
9
  */
31
  * {@inheritdoc}
32
  */
33
  public function is_available(): bool {
34
+ return ( basename( $_SERVER['PHP_SELF'] ) === 'index.php' ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
35
+ }
36
+
37
+ /**
38
+ * {@inheritdoc}
39
+ */
40
+ public function is_active(): bool {
41
+ $option_value = OptionsAccess::get_option( $this->get_option_name() );
42
+ return ( ( $option_value !== null ) && ( $option_value < time() ) );
43
+ }
44
 
45
+ /**
46
+ * {@inheritdoc}
47
+ */
48
+ public function get_disable_value(): string {
49
+ $is_permanent = ( isset( $_REQUEST['is_permanently'] ) && $_REQUEST['is_permanently'] ); // phpcs:ignore
50
+ return (string) strtotime( ( $is_permanent ) ? '+6 months' : '+ 1 month' );
51
  }
52
 
53
  /**
72
  public function get_ajax_action_to_disable(): string {
73
  return 'webpc_notice';
74
  }
 
 
 
 
 
 
 
 
 
 
75
  }
src/Notice/WelcomeNotice.php CHANGED
@@ -2,6 +2,7 @@
2
 
3
  namespace WebpConverter\Notice;
4
 
 
5
  use WebpConverter\Settings\Page\PageIntegration;
6
 
7
  /**
@@ -30,7 +31,21 @@ class WelcomeNotice extends NoticeAbstract implements NoticeInterface {
30
  * {@inheritdoc}
31
  */
32
  public function is_available(): bool {
33
- return ( get_option( self::NOTICE_OPTION, 0 ) === $this->get_default_value() );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  }
35
 
36
  /**
@@ -48,11 +63,4 @@ class WelcomeNotice extends NoticeAbstract implements NoticeInterface {
48
  'settings_url' => PageIntegration::get_settings_page_url(),
49
  ];
50
  }
51
-
52
- /**
53
- * {@inheritdoc}
54
- */
55
- public static function disable_notice() {
56
- update_option( self::NOTICE_OPTION, '0' );
57
- }
58
  }
2
 
3
  namespace WebpConverter\Notice;
4
 
5
+ use WebpConverter\Helper\OptionsAccess;
6
  use WebpConverter\Settings\Page\PageIntegration;
7
 
8
  /**
31
  * {@inheritdoc}
32
  */
33
  public function is_available(): bool {
34
+ return ( ! isset( $_GET['page'] ) || ( $_GET['page'] !== PageIntegration::ADMIN_MENU_PAGE ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
35
+ }
36
+
37
+ /**
38
+ * {@inheritdoc}
39
+ */
40
+ public function is_active(): bool {
41
+ return ( OptionsAccess::get_option( $this->get_option_name() ) === $this->get_default_value() );
42
+ }
43
+
44
+ /**
45
+ * {@inheritdoc}
46
+ */
47
+ public function get_disable_value(): string {
48
+ return '0';
49
  }
50
 
51
  /**
63
  'settings_url' => PageIntegration::get_settings_page_url(),
64
  ];
65
  }
 
 
 
 
 
 
 
66
  }
src/Plugin/Deactivation/Modal.php CHANGED
@@ -2,10 +2,10 @@
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.
2
 
3
  namespace WebpConverter\Plugin\Deactivation;
4
 
5
+ use WebpConverter\Helper\ViewLoader;
6
  use WebpConverter\HookableInterface;
7
  use WebpConverter\PluginData;
8
  use WebpConverter\Settings\AdminAssets;
 
9
 
10
  /**
11
  * Displays modal with poll in list of plugins when you try to deactivate plugin.
src/Plugin/Uninstall/PluginSettings.php CHANGED
@@ -3,6 +3,7 @@
3
  namespace WebpConverter\Plugin\Uninstall;
4
 
5
  use WebpConverter\Error\ErrorFactory;
 
6
  use WebpConverter\Notice\ThanksNotice;
7
  use WebpConverter\Notice\WelcomeNotice;
8
  use WebpConverter\Plugin\Update;
@@ -19,11 +20,11 @@ class PluginSettings {
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 );
26
- delete_option( SettingsSave::SETTINGS_OPTION );
27
- delete_option( Update::VERSION_OPTION );
28
  }
29
  }
3
  namespace WebpConverter\Plugin\Uninstall;
4
 
5
  use WebpConverter\Error\ErrorFactory;
6
+ use WebpConverter\Helper\OptionsAccess;
7
  use WebpConverter\Notice\ThanksNotice;
8
  use WebpConverter\Notice\WelcomeNotice;
9
  use WebpConverter\Plugin\Update;
20
  * @return void
21
  */
22
  public static function remove_plugin_settings() {
23
+ OptionsAccess::delete_option( ThanksNotice::NOTICE_OLD_OPTION );
24
+ OptionsAccess::delete_option( ThanksNotice::NOTICE_OPTION );
25
+ OptionsAccess::delete_option( WelcomeNotice::NOTICE_OPTION );
26
+ OptionsAccess::delete_option( ErrorFactory::ERRORS_CACHE_OPTION );
27
+ OptionsAccess::delete_option( SettingsSave::SETTINGS_OPTION );
28
+ OptionsAccess::delete_option( Update::VERSION_OPTION );
29
  }
30
  }
src/Plugin/Uninstall/WebpFiles.php CHANGED
@@ -2,8 +2,8 @@
2
 
3
  namespace WebpConverter\Plugin\Uninstall;
4
 
5
- use WebpConverter\Conversion\SkipLarger;
6
  use WebpConverter\Conversion\Format\FormatFactory;
 
7
 
8
  /**
9
  * Removes all output files /uploads-webpc directory.
2
 
3
  namespace WebpConverter\Plugin\Uninstall;
4
 
 
5
  use WebpConverter\Conversion\Format\FormatFactory;
6
+ use WebpConverter\Conversion\SkipLarger;
7
 
8
  /**
9
  * Removes all output files /uploads-webpc directory.
src/Plugin/Update.php CHANGED
@@ -2,6 +2,7 @@
2
 
3
  namespace WebpConverter\Plugin;
4
 
 
5
  use WebpConverter\HookableInterface;
6
  use WebpConverter\Loader\LoaderAbstract;
7
  use WebpConverter\Plugin\Activation\DefaultSettings;
@@ -27,7 +28,7 @@ class Update implements HookableInterface {
27
  * @internal
28
  */
29
  public function run_actions_after_update() {
30
- $version = get_option( self::VERSION_OPTION, null );
31
  if ( $version === WEBPC_VERSION ) {
32
  return;
33
  }
@@ -35,6 +36,6 @@ class Update implements HookableInterface {
35
  ( new DefaultSettings() )->add_default_options();
36
  do_action( LoaderAbstract::ACTION_NAME, true );
37
 
38
- update_option( self::VERSION_OPTION, WEBPC_VERSION );
39
  }
40
  }
2
 
3
  namespace WebpConverter\Plugin;
4
 
5
+ use WebpConverter\Helper\OptionsAccess;
6
  use WebpConverter\HookableInterface;
7
  use WebpConverter\Loader\LoaderAbstract;
8
  use WebpConverter\Plugin\Activation\DefaultSettings;
28
  * @internal
29
  */
30
  public function run_actions_after_update() {
31
+ $version = OptionsAccess::get_option( self::VERSION_OPTION );
32
  if ( $version === WEBPC_VERSION ) {
33
  return;
34
  }
36
  ( new DefaultSettings() )->add_default_options();
37
  do_action( LoaderAbstract::ACTION_NAME, true );
38
 
39
+ OptionsAccess::update_option( self::VERSION_OPTION, WEBPC_VERSION );
40
  }
41
  }
src/Settings/Option/ConversionMethodOption.php CHANGED
@@ -3,7 +3,6 @@
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.
3
  namespace WebpConverter\Settings\Option;
4
 
5
  use WebpConverter\Conversion\Method\MethodFactory;
 
6
 
7
  /**
8
  * Handles data about "Conversion method" field in plugin settings.
src/Settings/Option/OptionFactory.php CHANGED
@@ -2,6 +2,7 @@
2
 
3
  namespace WebpConverter\Settings\Option;
4
 
 
5
  use WebpConverter\Settings\SettingsSave;
6
 
7
  /**
@@ -47,7 +48,7 @@ class OptionFactory {
47
  */
48
  public function get_options( bool $is_debug = false, array $posted_settings = null ): array {
49
  $is_save = ( $posted_settings !== null );
50
- $settings = ( $is_save ) ? $posted_settings : get_option( SettingsSave::SETTINGS_OPTION, [] );
51
 
52
  $options = [];
53
  foreach ( $this->options as $option_object ) {
2
 
3
  namespace WebpConverter\Settings\Option;
4
 
5
+ use WebpConverter\Helper\OptionsAccess;
6
  use WebpConverter\Settings\SettingsSave;
7
 
8
  /**
48
  */
49
  public function get_options( bool $is_debug = false, array $posted_settings = null ): array {
50
  $is_save = ( $posted_settings !== null );
51
+ $settings = ( $is_save ) ? $posted_settings : OptionsAccess::get_option( SettingsSave::SETTINGS_OPTION, [] );
52
 
53
  $options = [];
54
  foreach ( $this->options as $option_object ) {
src/Settings/Page/DebugPage.php CHANGED
@@ -3,11 +3,11 @@
3
 
4
  namespace WebpConverter\Settings\Page;
5
 
 
 
 
6
  use WebpConverter\Loader\LoaderAbstract;
7
  use WebpConverter\Settings\SettingsSave;
8
- use WebpConverter\Helper\ViewLoader;
9
- use WebpConverter\Helper\FileLoader;
10
- use WebpConverter\Error\RewritesError;
11
 
12
  /**
13
  * Supports debug tab in plugin settings page.
@@ -20,7 +20,7 @@ class DebugPage extends PageAbstract {
20
  * {@inheritdoc}
21
  */
22
  public function is_page_active(): bool {
23
- return ( isset( $_GET['action'] ) && ( $_GET['action'] === 'server' ) ); // phpcs:ignore
24
  }
25
 
26
  /**
3
 
4
  namespace WebpConverter\Settings\Page;
5
 
6
+ use WebpConverter\Error\RewritesError;
7
+ use WebpConverter\Helper\FileLoader;
8
+ use WebpConverter\Helper\ViewLoader;
9
  use WebpConverter\Loader\LoaderAbstract;
10
  use WebpConverter\Settings\SettingsSave;
 
 
 
11
 
12
  /**
13
  * Supports debug tab in plugin settings page.
20
  * {@inheritdoc}
21
  */
22
  public function is_page_active(): bool {
23
+ return ( isset( $_GET['action'] ) && ( $_GET['action'] === 'server' ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
24
  }
25
 
26
  /**
src/Settings/Page/PageIntegration.php CHANGED
@@ -3,6 +3,7 @@
3
  namespace WebpConverter\Settings\Page;
4
 
5
  use WebpConverter\HookableInterface;
 
6
  use WebpConverter\Notice\WelcomeNotice;
7
  use WebpConverter\Settings\AdminAssets;
8
 
@@ -130,7 +131,7 @@ class PageIntegration implements HookableInterface {
130
  * @internal
131
  */
132
  public function load_scripts_for_page() {
133
- WelcomeNotice::disable_notice();
134
  ( new AdminAssets() )->init_hooks();
135
  }
136
  }
3
  namespace WebpConverter\Settings\Page;
4
 
5
  use WebpConverter\HookableInterface;
6
+ use WebpConverter\Notice\NoticeIntegration;
7
  use WebpConverter\Notice\WelcomeNotice;
8
  use WebpConverter\Settings\AdminAssets;
9
 
131
  * @internal
132
  */
133
  public function load_scripts_for_page() {
134
+ ( new NoticeIntegration( new WelcomeNotice() ) )->set_disable_value();
135
  ( new AdminAssets() )->init_hooks();
136
  }
137
  }
src/Settings/SettingsSave.php CHANGED
@@ -2,11 +2,12 @@
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;
9
- use WebpConverter\Conversion\Directory\DirectoryFactory;
10
 
11
  /**
12
  * Supports saving plugin settings on plugin settings page.
@@ -42,7 +43,7 @@ class SettingsSave {
42
  return;
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
  }
2
 
3
  namespace WebpConverter\Settings;
4
 
 
5
  use WebpConverter\Conversion\Cron\Event;
6
+ use WebpConverter\Conversion\Directory\DirectoryFactory;
7
+ use WebpConverter\Helper\OptionsAccess;
8
  use WebpConverter\Loader\LoaderAbstract;
9
+ use WebpConverter\PluginData;
10
  use WebpConverter\Settings\Option\OptionFactory;
 
11
 
12
  /**
13
  * Supports saving plugin settings on plugin settings page.
43
  return;
44
  }
45
 
46
+ OptionsAccess::update_option( self::SETTINGS_OPTION, ( new OptionFactory() )->get_values( false, $_POST ) );
47
  $this->plugin_data->invalidate_plugin_settings();
48
  $this->init_actions_after_save();
49
  }
src/WebpConverter.php CHANGED
@@ -4,10 +4,10 @@ namespace WebpConverter;
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;
4
 
5
  use WebpConverter\Action;
6
  use WebpConverter\Conversion;
 
7
  use WebpConverter\Conversion\Cron;
8
+ use WebpConverter\Conversion\Endpoint;
9
  use WebpConverter\Conversion\Media;
10
+ use WebpConverter\Error;
11
  use WebpConverter\Notice;
12
  use WebpConverter\Plugin;
13
  use WebpConverter\Settings\Page;
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
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__ ) );
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.8
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.8' );
14
  define( 'WEBPC_FILE', __FILE__ );
15
  define( 'WEBPC_NAME', plugin_basename( __FILE__ ) );
16
  define( 'WEBPC_PATH', plugin_dir_path( __FILE__ ) );