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

Version Description

(2020-01-13) = * [Added] Support for WordPress Multisite

Download this release

Release Info

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

Code changes from version 2.1.3 to 2.2.0

app/Admin/Notice.php CHANGED
@@ -25,7 +25,8 @@
25
  if (get_option(Activation::NEW_INSTALLATION_OPTION) !== '1') return;
26
 
27
  new Assets();
28
- add_action('admin_notices', ['WebpConverter\Admin\Notice', 'loadWelcomeNotice']);
 
29
  }
30
 
31
  public static function loadWelcomeNotice()
@@ -35,11 +36,16 @@
35
 
36
  public function showThanksNotice()
37
  {
38
- if (($_SERVER['PHP_SELF'] !== '/wp-admin/index.php') ||
39
- (get_option(self::NOTICE_THANKS_OPTION, 0) >= time())) return;
40
-
41
- new Assets();
42
- add_action('admin_notices', [$this, 'loadThanksNotice']);
 
 
 
 
 
43
  }
44
 
45
  public function loadThanksNotice()
25
  if (get_option(Activation::NEW_INSTALLATION_OPTION) !== '1') return;
26
 
27
  new Assets();
28
+ add_action('admin_notices', ['WebpConverter\Admin\Notice', 'loadWelcomeNotice']);
29
+ add_action('network_admin_notices', ['WebpConverter\Admin\Notice', 'loadWelcomeNotice']);
30
  }
31
 
32
  public static function loadWelcomeNotice()
36
 
37
  public function showThanksNotice()
38
  {
39
+ if ((basename($_SERVER['PHP_SELF']) !== 'index.php')
40
+ || (get_option(self::NOTICE_THANKS_OPTION, 0) >= time())) return;
41
+
42
+ if (!is_multisite()) {
43
+ new Assets();
44
+ add_action('admin_notices', [$this, 'loadThanksNotice']);
45
+ } else if (is_network_admin()) {
46
+ new Assets();
47
+ add_action('network_admin_notices', [$this, 'loadThanksNotice']);
48
+ }
49
  }
50
 
51
  public function loadThanksNotice()
app/Admin/Plugin.php CHANGED
@@ -2,11 +2,14 @@
2
 
3
  namespace WebpConverter\Admin;
4
 
 
 
5
  class Plugin
6
  {
7
  public function __construct()
8
  {
9
- add_filter('plugin_action_links_' . WEBPC_NAME, [$this, 'addLinkToSettings']);
 
10
  add_filter('plugin_action_links_' . WEBPC_NAME, [$this, 'addLinkToDonate']);
11
  add_filter('network_admin_plugin_action_links_' . WEBPC_NAME, [$this, 'addLinkToDonate']);
12
  }
@@ -15,11 +18,25 @@
15
  Functions
16
  --- */
17
 
18
- public function addLinkToSettings($links)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  {
20
  array_unshift($links, sprintf(
21
  esc_html(__('%sSettings%s', 'webp-converter-for-media')),
22
- '<a href="' . menu_page_url('webpc_admin_page', false) . '">',
23
  '</a>'
24
  ));
25
  return $links;
2
 
3
  namespace WebpConverter\Admin;
4
 
5
+ use WebpConverter\Settings\Page;
6
+
7
  class Plugin
8
  {
9
  public function __construct()
10
  {
11
+ add_filter('plugin_action_links_' . WEBPC_NAME, [$this, 'addLinkToSettingsForAdmin']);
12
+ add_filter('network_admin_plugin_action_links_' . WEBPC_NAME, [$this, 'addLinkToSettingsForNetwork']);
13
  add_filter('plugin_action_links_' . WEBPC_NAME, [$this, 'addLinkToDonate']);
14
  add_filter('network_admin_plugin_action_links_' . WEBPC_NAME, [$this, 'addLinkToDonate']);
15
  }
18
  Functions
19
  --- */
20
 
21
+ public function addLinkToSettingsForAdmin($links)
22
+ {
23
+ if (is_multisite()) {
24
+ return $links;
25
+ }
26
+
27
+ return $this->addLinkToSettings($links);
28
+ }
29
+
30
+ public function addLinkToSettingsForNetwork($links)
31
+ {
32
+ return $this->addLinkToSettings($links);
33
+ }
34
+
35
+ private function addLinkToSettings($links)
36
  {
37
  array_unshift($links, sprintf(
38
  esc_html(__('%sSettings%s', 'webp-converter-for-media')),
39
+ '<a href="' . Page::getSettingsPageUrl() . '">',
40
  '</a>'
41
  ));
42
  return $links;
app/Settings/Page.php CHANGED
@@ -12,19 +12,40 @@
12
 
13
  public function __construct()
14
  {
15
- add_action('admin_menu', [$this, 'addSettingsPage']);
 
16
  }
17
 
18
  /* ---
19
  Functions
20
  --- */
21
 
22
- public function addSettingsPage()
23
  {
24
- if (is_network_admin()) return;
 
 
 
 
 
 
 
 
 
 
 
 
 
25
 
 
 
 
 
 
 
 
26
  $page = add_submenu_page(
27
- 'options-general.php',
28
  'WebP Converter for Media',
29
  'WebP Converter',
30
  'manage_options',
@@ -43,7 +64,8 @@
43
  public function loadScriptsForPage()
44
  {
45
  update_option(Activation::NEW_INSTALLATION_OPTION, '0');
46
- remove_action('admin_notices', ['WebpConverter\Admin\Notice', 'loadWelcomeNotice']);
 
47
 
48
  new Assets();
49
  }
12
 
13
  public function __construct()
14
  {
15
+ add_action('admin_menu', [$this, 'addSettingsPageForAdmin']);
16
+ add_action('network_admin_menu', [$this, 'addSettingsPageForNetwork']);
17
  }
18
 
19
  /* ---
20
  Functions
21
  --- */
22
 
23
+ public static function getSettingsPageUrl()
24
  {
25
+ if (!is_multisite()) {
26
+ return menu_page_url('webpc_admin_page', false);
27
+ } else {
28
+ return network_admin_url('settings.php?page=webpc_admin_page');
29
+ }
30
+ }
31
+
32
+ public function addSettingsPageForAdmin()
33
+ {
34
+ if (is_multisite()) {
35
+ return;
36
+ }
37
+ $this->addSettingsPage('options-general.php');
38
+ }
39
 
40
+ public function addSettingsPageForNetwork()
41
+ {
42
+ $this->addSettingsPage('settings.php');
43
+ }
44
+
45
+ private function addSettingsPage($menuPage)
46
+ {
47
  $page = add_submenu_page(
48
+ $menuPage,
49
  'WebP Converter for Media',
50
  'WebP Converter',
51
  'manage_options',
64
  public function loadScriptsForPage()
65
  {
66
  update_option(Activation::NEW_INSTALLATION_OPTION, '0');
67
+ remove_action('admin_notices', ['WebpConverter\Admin\Notice', 'loadWelcomeNotice']);
68
+ remove_action('network_admin_notices', ['WebpConverter\Admin\Notice', 'loadWelcomeNotice']);
69
 
70
  new Assets();
71
  }
readme.txt CHANGED
@@ -482,6 +482,9 @@ This is all very important to us and allows us to do even better things for you!
482
 
483
  == Changelog ==
484
 
 
 
 
485
  = 2.1.3 (2020-12-28) =
486
  * `[Fixed]` Regex for Pass Thru loading mode
487
 
482
 
483
  == Changelog ==
484
 
485
+ = 2.2.0 (2020-01-13) =
486
+ * `[Added]` Support for WordPress Multisite
487
+
488
  = 2.1.3 (2020-12-28) =
489
  * `[Fixed]` Regex for Pass Thru loading mode
490
 
resources/components/errors/libs-not-installed.php CHANGED
@@ -1,3 +1,8 @@
 
 
 
 
 
1
  <p>
2
  <?= wp_kses_post(sprintf(
3
  __('On your server is not installed %sGD%s or %sImagick%s library. Please read %sthe plugin FAQ%s and check your server configuration %shere%s. Compare it with the configuration given in the requirements of plugin in the FAQ. Please contact your server administrator.', 'webp-converter-for-media'),
@@ -7,7 +12,7 @@
7
  '</strong>',
8
  '<a href="https://wordpress.org/plugins/webp-converter-for-media/#faq" target="_blank">',
9
  '</a>',
10
- '<a href="' . sprintf('%s&action=server', menu_page_url('webpc_admin_page', false)) . '">',
11
  '</a>'
12
  )); ?>
13
  </p>
1
+ <?php
2
+
3
+ use WebpConverter\Settings\Page;
4
+
5
+ ?>
6
  <p>
7
  <?= wp_kses_post(sprintf(
8
  __('On your server is not installed %sGD%s or %sImagick%s library. Please read %sthe plugin FAQ%s and check your server configuration %shere%s. Compare it with the configuration given in the requirements of plugin in the FAQ. Please contact your server administrator.', 'webp-converter-for-media'),
12
  '</strong>',
13
  '<a href="https://wordpress.org/plugins/webp-converter-for-media/#faq" target="_blank">',
14
  '</a>',
15
+ '<a href="' . sprintf('%s&action=server', Page::getSettingsPageUrl()) . '">',
16
  '</a>'
17
  )); ?>
18
  </p>
resources/components/errors/libs-without-webp-support.php CHANGED
@@ -1,3 +1,8 @@
 
 
 
 
 
1
  <p>
2
  <?= wp_kses_post(sprintf(
3
  __('On your server installed GD or Imagick library %sdoes not support WebP format%s. Please read %sthe plugin FAQ%s and check your server configuration %shere%s. Compare it with the configuration given in the requirements of plugin in the FAQ. Please contact your server administrator.', 'webp-converter-for-media'),
@@ -5,7 +10,7 @@
5
  '</strong>',
6
  '<a href="https://wordpress.org/plugins/webp-converter-for-media/#faq" target="_blank">',
7
  '</a>',
8
- '<a href="' . sprintf('%s&action=server', menu_page_url('webpc_admin_page', false)) . '">',
9
  '</a>'
10
  )); ?>
11
  </p>
1
+ <?php
2
+
3
+ use WebpConverter\Settings\Page;
4
+
5
+ ?>
6
  <p>
7
  <?= wp_kses_post(sprintf(
8
  __('On your server installed GD or Imagick library %sdoes not support WebP format%s. Please read %sthe plugin FAQ%s and check your server configuration %shere%s. Compare it with the configuration given in the requirements of plugin in the FAQ. Please contact your server administrator.', 'webp-converter-for-media'),
10
  '</strong>',
11
  '<a href="https://wordpress.org/plugins/webp-converter-for-media/#faq" target="_blank">',
12
  '</a>',
13
+ '<a href="' . sprintf('%s&action=server', Page::getSettingsPageUrl()) . '">',
14
  '</a>'
15
  )); ?>
16
  </p>
resources/components/errors/passthru-execution.php CHANGED
@@ -1,8 +1,10 @@
1
  <?php
 
2
  use WebpConverter\Loader\Passthru;
 
3
  $url = Passthru::getLoaderUrl();
4
- ?>
5
 
 
6
  <p>
7
  <?= wp_kses_post(sprintf(
8
  __('Execution of the PHP file from path "%s" is blocked on your server, or access to this file is blocked. Add an exception and enable this file to be executed via HTTP request. To do this, check the security plugin settings (if you are using) or the security settings of your server.%sIn this case, please contact your server administrator.', 'webp-converter-for-media'),
1
  <?php
2
+
3
  use WebpConverter\Loader\Passthru;
4
+
5
  $url = Passthru::getLoaderUrl();
 
6
 
7
+ ?>
8
  <p>
9
  <?= wp_kses_post(sprintf(
10
  __('Execution of the PHP file from path "%s" is blocked on your server, or access to this file is blocked. Add an exception and enable this file to be executed via HTTP request. To do this, check the security plugin settings (if you are using) or the security settings of your server.%sIn this case, please contact your server administrator.', 'webp-converter-for-media'),
resources/components/notices/welcome.php CHANGED
@@ -1,3 +1,8 @@
 
 
 
 
 
1
  <div class="notice notice-success">
2
  <div class="webpContent webpContent--notice">
3
  <h4>
@@ -11,7 +16,7 @@
11
  )); ?>
12
  </p>
13
  <div class="webpContent__buttons">
14
- <a href="<?= esc_url(menu_page_url('webpc_admin_page', false)); ?>"
15
  class="webpContent__button webpButton webpButton--green">
16
  <?= esc_html(__('Speed up my website', 'webp-converter-for-media')); ?>
17
  </a>
1
+ <?php
2
+
3
+ use WebpConverter\Settings\Page;
4
+
5
+ ?>
6
  <div class="notice notice-success">
7
  <div class="webpContent webpContent--notice">
8
  <h4>
16
  )); ?>
17
  </p>
18
  <div class="webpContent__buttons">
19
+ <a href="<?= esc_url(Page::getSettingsPageUrl()); ?>"
20
  class="webpContent__button webpButton webpButton--green">
21
  <?= esc_html(__('Speed up my website', 'webp-converter-for-media')); ?>
22
  </a>
resources/components/widgets/options.php CHANGED
@@ -1,3 +1,8 @@
 
 
 
 
 
1
  <div class="webpPage__widget">
2
  <h3 class="webpPage__widgetTitle">
3
  <?= esc_html(__('Settings', 'webp-converter-for-media')); ?>
@@ -23,7 +28,7 @@
23
  '</a>',
24
  '<a href="https://wordpress.org/support/plugin/webp-converter-for-media/" target="_blank">',
25
  '</a>',
26
- '<a href="' . sprintf('%s&action=server', menu_page_url('webpc_admin_page', false)) . '">',
27
  '</a>'
28
  )); ?>
29
  </p>
1
+ <?php
2
+
3
+ use WebpConverter\Settings\Page;
4
+
5
+ ?>
6
  <div class="webpPage__widget">
7
  <h3 class="webpPage__widgetTitle">
8
  <?= esc_html(__('Settings', 'webp-converter-for-media')); ?>
28
  '</a>',
29
  '<a href="https://wordpress.org/support/plugin/webp-converter-for-media/" target="_blank">',
30
  '</a>',
31
+ '<a href="' . sprintf('%s&action=server', Page::getSettingsPageUrl()) . '">',
32
  '</a>'
33
  )); ?>
34
  </p>
resources/components/widgets/regenerate.php CHANGED
@@ -1,6 +1,8 @@
1
  <?php
 
2
  $apiPaths = apply_filters('webpc_rest_api_paths', '');
3
  $apiRegenerate = apply_filters('webpc_rest_api_regenerate', '');
 
4
  ?>
5
  <div class="webpPage__widget">
6
  <h3 class="webpPage__widgetTitle">
1
  <?php
2
+
3
  $apiPaths = apply_filters('webpc_rest_api_paths', '');
4
  $apiRegenerate = apply_filters('webpc_rest_api_regenerate', '');
5
+
6
  ?>
7
  <div class="webpPage__widget">
8
  <h3 class="webpPage__widgetTitle">
resources/components/widgets/server.php CHANGED
@@ -1,6 +1,9 @@
1
  <?php
2
- $pageUrl = menu_page_url('webpc_admin_page', false);
3
- $info = apply_filters('webpc_server_info', '');
 
 
 
4
  ?>
5
  <div class="webpPage__widget">
6
  <h3 class="webpPage__widgetTitle webpPage__widgetTitle--second">
@@ -14,7 +17,7 @@
14
  '</a>'
15
  )); ?>
16
  </p>
17
- <a href="<?= esc_url($pageUrl); ?>" class="webpLoader__button webpButton webpButton--blue">
18
  <?= esc_html(__('Back to settings', 'webp-converter-for-media')); ?>
19
  </a>
20
  </div>
@@ -22,7 +25,7 @@
22
  <div class="webpServerInfo"><?= wp_kses_post($info); ?></div>
23
  </div>
24
  <div class="webpPage__widgetRow">
25
- <a href="<?= esc_url($pageUrl); ?>" class="webpLoader__button webpButton webpButton--blue">
26
  <?= esc_html(__('Back to settings', 'webp-converter-for-media')); ?>
27
  </a>
28
  </div>
1
  <?php
2
+
3
+ use WebpConverter\Settings\Page;
4
+
5
+ $info = apply_filters('webpc_server_info', '');
6
+
7
  ?>
8
  <div class="webpPage__widget">
9
  <h3 class="webpPage__widgetTitle webpPage__widgetTitle--second">
17
  '</a>'
18
  )); ?>
19
  </p>
20
+ <a href="<?= esc_url(Page::getSettingsPageUrl()); ?>" class="webpLoader__button webpButton webpButton--blue">
21
  <?= esc_html(__('Back to settings', 'webp-converter-for-media')); ?>
22
  </a>
23
  </div>
25
  <div class="webpServerInfo"><?= wp_kses_post($info); ?></div>
26
  </div>
27
  <div class="webpPage__widgetRow">
28
+ <a href="<?= esc_url(Page::getSettingsPageUrl()); ?>" class="webpLoader__button webpButton webpButton--blue">
29
  <?= esc_html(__('Back to settings', 'webp-converter-for-media')); ?>
30
  </a>
31
  </div>
resources/components/widgets/support.php CHANGED
@@ -1,3 +1,8 @@
 
 
 
 
 
1
  <div class="webpPage__widget">
2
  <h3 class="webpPage__widgetTitle webpPage__widgetTitle--second">
3
  <?= esc_html(__('We are waiting for your message', 'webp-converter-for-media')); ?>
@@ -16,7 +21,7 @@
16
  )); ?>
17
  </p>
18
  <p class="center">
19
- <a href="<?= esc_url(sprintf('%s&action=server', menu_page_url('webpc_admin_page', false))); ?>" class="webpButton webpButton--blue dashicons-admin-tools">
20
  <?= esc_html(__('Server configuration', 'webp-converter-for-media')); ?>
21
  </a>
22
  <br>
1
+ <?php
2
+
3
+ use WebpConverter\Settings\Page;
4
+
5
+ ?>
6
  <div class="webpPage__widget">
7
  <h3 class="webpPage__widgetTitle webpPage__widgetTitle--second">
8
  <?= esc_html(__('We are waiting for your message', 'webp-converter-for-media')); ?>
21
  )); ?>
22
  </p>
23
  <p class="center">
24
+ <a href="<?= esc_url(sprintf('%s&action=server', Page::getSettingsPageUrl())); ?>" class="webpButton webpButton--blue dashicons-admin-tools">
25
  <?= esc_html(__('Server configuration', 'webp-converter-for-media')); ?>
26
  </a>
27
  <br>
resources/views/settings.php CHANGED
@@ -1,7 +1,11 @@
1
  <?php
2
- $path = sprintf('%s&_wpnonce=%s', menu_page_url('webpc_admin_page', false), wp_create_nonce('webpc-save'));
 
 
 
3
  $options = apply_filters('webpc_get_options', []);
4
  $values = apply_filters('webpc_get_values', []);
 
5
  ?>
6
  <div class="wrap">
7
  <h1><?= esc_html(__('WebP Converter for Media', 'webp-converter-for-media')); ?></h1>
1
  <?php
2
+
3
+ use WebpConverter\Settings\Page;
4
+
5
+ $path = sprintf('%s&_wpnonce=%s', Page::getSettingsPageUrl(), wp_create_nonce('webpc-save'));
6
  $options = apply_filters('webpc_get_options', []);
7
  $values = apply_filters('webpc_get_values', []);
8
+
9
  ?>
10
  <div class="wrap">
11
  <h1><?= esc_html(__('WebP Converter for Media', 'webp-converter-for-media')); ?></h1>
webp-converter-for-media.php CHANGED
@@ -3,13 +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: 2.1.3
7
  Author: Mateusz Gbiorczyk
8
  Author URI: https://gbiorczyk.pl/
9
  Text Domain: webp-converter-for-media
 
10
  */
11
 
12
- define('WEBPC_VERSION', '2.1.3');
13
  define('WEBPC_FILE', __FILE__);
14
  define('WEBPC_NAME', plugin_basename(__FILE__));
15
  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: 2.2.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', '2.2.0');
14
  define('WEBPC_FILE', __FILE__);
15
  define('WEBPC_NAME', plugin_basename(__FILE__));
16
  define('WEBPC_PATH', plugin_dir_path(__FILE__));