PluginProbe
Optimole – Optimize Images | Convert WebP & AVIF | CDN & Lazy Load | Image Optimization / 2.5.7
Optimole – Optimize Images | Convert WebP & AVIF | CDN & Lazy Load | Image Optimization v2.5.7
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 3.12.1 All 134 releases
optimole-wp / inc / config.php

config.php in Optimole – Optimize Images | Convert WebP & AVIF | CDN & Lazy Load | Image Optimization 2.5.7, at inc/config.php

114 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Class Optml_Config holds configuration for the service.
5 *
6 * @package \Optml\Inc
7 * @author Optimole <friends@optimole.com>
8 */
9 class Optml_Config {
10
11 /**
12 * A list of allowed extensions.
13 *
14 * @var array
15 */
16 public static $image_extensions = [
17 'jpg' => 'image/jpeg',
18 'jpeg' => 'image/jpeg',
19 'jpe' => 'image/jpeg',
20 'png' => 'image/png',
21 'webp' => 'image/webp',
22 'svg' => 'image/svg+xml',
23 'gif' => 'image/gif',
24 ];
25 /**
26 * CSS/Js mimetypes.
27 *
28 * @var string[]
29 */
30 public static $assets_extensions = [
31 'css' => 'text/css',
32 'js' => 'text/javascript',
33 ];
34 /**
35 * All extensions that Optimole process.
36 *
37 * @var string[]
38 */
39 public static $all_extensions = [
40 'jpg|jpeg|jpe' => 'image/jpeg',
41 'png' => 'image/png',
42 'webp' => 'image/webp',
43 'svg' => 'image/svg+xml',
44 'gif' => 'image/gif',
45 'css' => 'text/css',
46 'js' => 'text/javascript',
47 ];
48 /**
49 * A string of allowed chars.
50 *
51 * @var string
52 */
53
54 public static $chars = '\/:,~\\\\.\-\–\d_@%A-Za-z\p{L}\p{M}\p{N}';
55 /**
56 * Service api key.
57 *
58 * @var string Service key.
59 */
60 public static $key = '';
61 /**
62 * Service secret key used for signing the requests.
63 *
64 * @var string Secret key.
65 */
66 public static $secret = '';
67 /**
68 * Service url.
69 *
70 * @var string Service url.
71 */
72 public static $service_url = '';
73
74 /**
75 * Service settings.
76 *
77 * @param array $service_settings Service settings.
78 *
79 * @throws \InvalidArgumentException In case that key or secret is not provided.
80 */
81 public static function init( $service_settings = [] ) {
82
83 if ( empty( $service_settings['key'] ) && ! defined( 'OPTML_KEY' ) ) {
84 throw new \InvalidArgumentException( 'Optimole SDK requires service api key.' ); // @codeCoverageIgnore
85 }
86 if ( empty( $service_settings['secret'] ) && ! defined( 'OPTML_SECRET' ) ) {
87 throw new \InvalidArgumentException( 'Optimole SDK requires service secret key.' ); // @codeCoverageIgnore
88 }
89
90 if ( defined( 'OPTML_KEY' ) && constant( 'OPTML_KEY' ) ) {
91 self::$key = constant( 'OPTML_KEY' );
92 }
93
94 if ( defined( 'OPTML_SECRET' ) && constant( 'OPTML_SECRET' ) ) {
95 self::$secret = constant( 'OPTML_SECRET' );
96 }
97
98 if ( ! empty( $service_settings['key'] ) ) {
99 self::$key = trim( strtolower( $service_settings['key'] ) );
100 }
101
102 if ( ! empty( $service_settings['secret'] ) ) {
103 self::$secret = trim( $service_settings['secret'] );
104 }
105
106 self::$service_url = sprintf( 'https://%s.i.optimole.com', self::$key );
107 if ( isset( $service_settings['domain'] ) && ! empty( $service_settings['domain'] ) ) {
108 self::$service_url = $service_settings['domain'];
109 } elseif ( defined( 'OPTML_CUSTOM_DOMAIN' ) && constant( 'OPTML_CUSTOM_DOMAIN' ) ) {
110 self::$service_url = constant( 'OPTML_CUSTOM_DOMAIN' );
111 }
112 }
113 }
114