PluginProbe
Optimole – Optimize Images | Convert WebP & AVIF | CDN & Lazy Load | Image Optimization / trunk
Optimole – Optimize Images | Convert WebP & AVIF | CDN & Lazy Load | Image Optimization vtrunk
4.2.14 4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 2.5.5 2.5.6 2.5.7 3.0.0 3.0.1 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.11.0 3.11.1 3.11.2 3.11.3 3.12.0 All 135 releases
← All changes | inc/config.php +30 -6 3.10.0 → trunk View file →
@@ -1,6 +1,8 @@
1 1 <?php
2 2
3 +use Optimole\Sdk\Optimole;
4 +
3 5 /**
4 6 * Class Optml_Config holds configuration for the service.
5 7 *
6 8 * @package \Optml\Inc
@@ -18,8 +20,9 @@
18 20 'jpeg' => 'image/jpeg',
19 21 'jpe' => 'image/jpeg',
20 22 'png' => 'image/png',
21 23 'heic' => 'image/heif',
24 + 'ico' => 'image/x-icon',
22 25 'avif' => 'image/avif',
23 26 'webp' => 'image/webp',
24 27 'svg' => 'image/svg+xml',
25 28 'gif' => 'image/gif',
@@ -41,8 +44,9 @@
41 44 public static $all_extensions = [
42 45 'jpg|jpeg|jpe' => 'image/jpeg',
43 46 'png' => 'image/png',
44 47 'webp' => 'image/webp',
48 + 'ico' => 'image/x-icon',
45 49 'heic' => 'image/heif',
46 50 'avif' => 'image/avif',
47 51 'svg' => 'image/svg+xml',
48 52 'gif' => 'image/gif',
@@ -96,17 +100,17 @@
96 100 if ( empty( $service_settings['secret'] ) && ! defined( 'OPTML_SECRET' ) ) {
97 101 throw new \InvalidArgumentException( 'Optimole SDK requires service secret key.' ); // @codeCoverageIgnore
98 102 }
99 103
100 - if ( defined( 'OPTML_KEY' ) && constant( 'OPTML_KEY' ) ) {
104 + if ( defined( 'OPTML_KEY' ) ) {
101 105 self::$key = constant( 'OPTML_KEY' );
102 106 }
103 107
104 - if ( defined( 'OPTML_SECRET' ) && constant( 'OPTML_SECRET' ) ) {
108 + if ( defined( 'OPTML_SECRET' ) ) {
105 109 self::$secret = constant( 'OPTML_SECRET' );
106 110 }
107 111
108 - if ( defined( 'OPTML_BASE_DOMAIN' ) && constant( 'OPTML_BASE_DOMAIN' ) ) {
112 + if ( defined( 'OPTML_BASE_DOMAIN' ) ) {
109 113 self::$base_domain = constant( 'OPTML_BASE_DOMAIN' );
110 114 }
111 115
112 116 if ( ! empty( $service_settings['key'] ) ) {
@@ -116,11 +120,31 @@
116 120 if ( ! empty( $service_settings['secret'] ) ) {
117 121 self::$secret = trim( $service_settings['secret'] );
118 122 }
119 123 self::$service_url = sprintf( 'https://%s.%s', self::$key, self::$base_domain );
120 - if ( isset( $service_settings['domain'] ) && ! empty( $service_settings['domain'] ) ) {
124 + if ( defined( 'OPTML_CUSTOM_DOMAIN' ) ) {
125 + self::$service_url = constant( 'OPTML_CUSTOM_DOMAIN' );
126 + } elseif ( isset( $service_settings['domain'] ) && ! empty( $service_settings['domain'] ) ) {
121 127 self::$service_url = sprintf( 'https://%s', $service_settings['domain'] );
122 - } elseif ( defined( 'OPTML_CUSTOM_DOMAIN' ) && constant( 'OPTML_CUSTOM_DOMAIN' ) ) {
123 - self::$service_url = constant( 'OPTML_CUSTOM_DOMAIN' );
124 128 }
129 +
130 + $options = [ 'domain' => parse_url( self::$service_url, PHP_URL_HOST ) ];
131 +
132 + if ( defined( 'OPTIML_API_ROOT' ) ) {
133 + $options['dashboard_api_url'] = OPTIML_API_ROOT;
134 + }
135 +
136 + if ( defined( 'OPTIML_UPLOAD_API_ROOT' ) ) {
137 + $options['upload_api_url'] = OPTIML_UPLOAD_API_ROOT;
138 + }
139 +
140 + if ( isset( $service_settings['key'], $service_settings['secret'], $service_settings['api_key'] ) ) {
141 + $options['upload_api_credentials'] = [
142 + 'userKey' => $service_settings['key'],
143 + 'secret' => $service_settings['secret'],
144 + ];
145 + $options['dashboard_api_key'] = $service_settings['api_key'];
146 + }
147 +
148 + Optimole::init( self::$key, $options );
125 149 }
126 150 }