PluginProbe
Seraphinite Accelerator / trunk
Seraphinite Accelerator vtrunk
2.29.24 2.29.23 2.29.22 2.29.21 2.29.20 2.29.19 2.29.18 2.29.17 2.29.16 2.29.15 2.29.14 2.29.13 2.29.12 2.29.11 2.29.10 2.29.9 2.20.18 2.20.19 2.20.2 2.20.20 2.20.21 2.20.22 2.20.23 2.20.24 2.20.25 All 418 releases
seraphinite-accelerator / tune.php

tune.php in Seraphinite Accelerator trunk, at tune.php

556 lines 28.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace seraph_accel;
4
5 if( !defined( 'ABSPATH' ) )
6 exit;
7
8 function GetCodeViewHtmlBlock( $cont )
9 {
10 return( Ui::Tag( 'div', str_replace( array( "\r", "\n", "\t", " " ), array( '', '<br>', '&#9;', '&nbsp;' ), htmlspecialchars( $cont ) ), array( 'class' => array( 'seraph_accel_textarea' ), 'style' => array( 'overflow' => 'scroll', 'height' => '5em', 'min-height' => '3em', 'max-height' => '20em', 'resize' => 'vertical' ) ) ) );
11 }
12
13 function SelfDiag_DetectStateAnd3rdPartySettConflicts( $cb, $ext = false )
14 {
15 global $seraph_accel_g_phpCfgFileChangedInCurrentSession;
16
17 $sett = Plugin::SettGet();
18 $settGlob = Plugin::SettGetGlobal();
19 $rmtCfg = PluginRmtCfg::Get();
20
21 $contRemindRefreshCache = vsprintf( Wp::safe_html_x( 'RemindRefreshCache_%1$s%2$s', 'admin.Notice', 'seraphinite-accelerator' ), Ui::Link( array( '', '' ), menu_page_url( 'seraph_accel_manage', false ) . '#operate' ) );
22
23 $isCacheEnabled = Gen::GetArrField( $sett, 'cache/enable', false, '/' );
24 $isContProcEnabled = Gen::GetArrField( $sett, 'contPr/enable', false, '/' );
25 $isScriptsDelayLoadEnabled = $isContProcEnabled && Gen::GetArrField( $sett, 'contPr/js/optLoad', false, '/' ) && Gen::GetArrField( $sett, 'contPr/js/nonCrit/timeout/enable', false, '/' ) && Gen::GetArrField( $sett, 'contPr/js/nonCrit/timeout/v', 0, '/' );
26 $isExtCacheAllowed = Gen::GetArrField( $sett, array( 'cache', 'srv' ), false ) || Gen::GetArrField( $sett, array( 'cache', 'srvClr' ), false );
27
28 if( $isCacheEnabled )
29 {
30 {
31 $dir = GetCacheDir();
32 if( ( !@is_dir( $dir ) && Gen::HrFail( Gen::MakeDir( $dir, true ) ) ) || !@is_writable( $dir ) )
33 call_user_func_array( $cb, array( Ui::MsgErr, sprintf( Wp::safe_html_x( 'CacheDirNotWrittable_%1$s', 'admin.Notice', 'seraphinite-accelerator' ), $dir ) ) );
34 }
35
36 if( !$seraph_accel_g_phpCfgFileChangedInCurrentSession )
37 {
38 if( IsWpCacheActive() )
39 {
40 $verifyEnvDropin = new AnyObj(); $verifyEnvDropin -> file = null;
41 if( !CacheVerifyEnvDropin( $verifyEnvDropin -> file, $sett, $verifyEnvDropin ) && !isset( $sett[ PluginOptions::VERPREV ] ) && ( ($_SERVER[ 'REQUEST_METHOD' ]??null) == 'GET' ) )
42 {
43 if( !@file_exists( $verifyEnvDropin -> file ) && !@is_writable( dirname( $verifyEnvDropin -> file ) ) )
44 call_user_func_array( $cb, array( Ui::MsgErr, sprintf( Wp::safe_html_x( 'ContentDirNotWrittable_%1$s%2$s', 'admin.Notice', 'seraphinite-accelerator' ), Gen::GetFileName( dirname( $verifyEnvDropin -> file ) ), Gen::GetFileName( $verifyEnvDropin -> file ) ) ) );
45 else if( !@is_writable( $verifyEnvDropin -> file ) )
46 call_user_func_array( $cb, array( Ui::MsgErr, sprintf( Wp::safe_html_x( 'ContentDropinNotWrittable_%1$s%2$s', 'admin.Notice', 'seraphinite-accelerator' ), Gen::GetFileName( dirname( $verifyEnvDropin -> file ) ), Gen::GetFileName( $verifyEnvDropin -> file ) ) ) );
47
48 call_user_func_array( $cb, array( Ui::MsgErr, sprintf( Wp::safe_html_x( 'ContentDropinNotMatch_%1$s%2$s', 'admin.Notice', 'seraphinite-accelerator' ), Gen::GetFileName( dirname( $verifyEnvDropin -> file ) ), Gen::GetFileName( $verifyEnvDropin -> file ) ) . ( $ext ? '' : sprintf( Wp::safe_html_x( 'ContentDropinNotMatchEx_%1$s%2$s', 'admin.Notice', 'seraphinite-accelerator' ), GetCodeViewHtmlBlock( $verifyEnvDropin -> needed ), GetCodeViewHtmlBlock( $verifyEnvDropin -> actual ) ) ) ) );
49 }
50 else if( !Gen::DoesFuncExist( 'seraph_accel_siteSettInlineDetach' ) )
51 call_user_func_array( $cb, array( Ui::MsgErr, sprintf( Wp::safe_html_x( 'ContentDropinNotLoaded_%1$s%2$s', 'admin.Notice', 'seraphinite-accelerator' ), Gen::GetFileName( dirname( $verifyEnvDropin -> file ) ), Gen::GetFileName( $verifyEnvDropin -> file ) ) ) );
52 }
53 else
54 {
55 $cfgFile = Wp::GetConfigFilePath();
56 if( !@is_writable( $cfgFile ) )
57 call_user_func_array( $cb, array( Ui::MsgErr, sprintf( Wp::safe_html_x( 'ConfigFileNotWrittable_%1$s', 'admin.Notice', 'seraphinite-accelerator' ), $cfgFile ) ) );
58 else
59 call_user_func_array( $cb, array( Ui::MsgErr, Wp::safe_html_x( 'WpCacheNotActive', 'admin.Notice', 'seraphinite-accelerator' ) ) );
60 }
61 }
62
63 if( !GetSalt() )
64 call_user_func_array( $cb, array( Ui::MsgErr, Wp::safe_html_x( 'WpSaltNotDefined', 'admin.Notice', 'seraphinite-accelerator' ) ) );
65
66 if( ( in_array( 'br', Gen::GetArrField( $sett, 'cache/encs', array(), '/' ) ) || in_array( 'brotli', Gen::GetArrField( $sett, 'cache/dataCompr', array(), '/' ) ) ) && @version_compare( @phpversion( 'brotli' ), '0.1.0' ) === -1 )
67 call_user_func_array( $cb, array( Ui::MsgErr, sprintf( Wp::safe_html_x( 'PhpBrotliNotActive_%1$s%2$s', 'admin.Notice', 'seraphinite-accelerator' ), 'BROTLI', '0.1.0' ) ) );
68
69 $aLocksInfo = array( array( 'pl', GetCacheDir() ), array( 'dl', GetCacheDir() ) );
70 foreach( GetSiteIds() as $siteId )
71 $aLocksInfo[] = array( 'l', GetCacheDir() . '/q/' . $siteId );
72 foreach( $aLocksInfo as $d )
73 {
74 $lock = new Lock( $d[ 0 ], $d[ 1 ] );
75 if( $lock -> Acquire() )
76 {
77 $lock -> Release();
78 unset( $lock );
79 continue;
80 }
81
82 call_user_func_array( $cb, array( Ui::MsgErr, sprintf( Wp::safe_html_x( 'TmpFileNotWrittable_%1$s', 'admin.Notice', 'seraphinite-accelerator' ), $lock -> GetFileName() ) ) );
83 unset( $lock );
84 break;
85 }
86
87 }
88
89 if( !$seraph_accel_g_phpCfgFileChangedInCurrentSession && Gen::GetArrField( $settGlob, array( 'cacheObj', 'enable' ), false ) )
90 {
91 $verifyEnvDropin = new AnyObj();
92 if( !isset( $sett[ PluginOptions::VERPREV ] ) && ( ($_SERVER[ 'REQUEST_METHOD' ]??null) == 'GET' ) && !CacheVerifyEnvObjDropin( $settGlob, $verifyEnvDropin ) )
93 {
94 if( !@file_exists( WP_CONTENT_DIR . '/object-cache.php' ) && !@is_writable( WP_CONTENT_DIR ) )
95 call_user_func_array( $cb, array( Ui::MsgErr, sprintf( Wp::safe_html_x( 'ContentDirNotWrittable_%1$s%2$s', 'admin.Notice', 'seraphinite-accelerator' ), Gen::GetFileName( WP_CONTENT_DIR ), 'object-cache.php' ) ) );
96 else if( !@is_writable( WP_CONTENT_DIR . '/object-cache.php' ) )
97 call_user_func_array( $cb, array( Ui::MsgErr, sprintf( Wp::safe_html_x( 'ContentDropinNotWrittable_%1$s%2$s', 'admin.Notice', 'seraphinite-accelerator' ), Gen::GetFileName( WP_CONTENT_DIR ), 'object-cache.php' ) ) );
98 else
99 call_user_func_array( $cb, array( Ui::MsgErr, sprintf( Wp::safe_html_x( 'ContentDropinNotMatch_%1$s%2$s', 'admin.Notice', 'seraphinite-accelerator' ), Gen::GetFileName( WP_CONTENT_DIR ), 'object-cache.php' ) . ( $ext ? '' : sprintf( Wp::safe_html_x( 'ContentDropinNotMatchEx_%1$s%2$s', 'admin.Notice', 'seraphinite-accelerator' ), GetCodeViewHtmlBlock( $verifyEnvDropin -> needed ), GetCodeViewHtmlBlock( $verifyEnvDropin -> actual ) ) ) ) );
100 }
101 else
102 {
103 global $seraph_accel_settObjCache;
104 if( $seraph_accel_settObjCache === null )
105 call_user_func_array( $cb, array( Ui::MsgErr, sprintf( Wp::safe_html_x( 'ContentDropinNotLoaded_%1$s%2$s', 'admin.Notice', 'seraphinite-accelerator' ), Gen::GetFileName( WP_CONTENT_DIR ), 'object-cache.php' ) ) );
106 }
107 }
108
109 $verifyEnvDropin = new AnyObj();
110 if( !isset( $sett[ PluginOptions::VERPREV ] ) && ( ($_SERVER[ 'REQUEST_METHOD' ]??null) == 'GET' ) && !CacheVerifyEnvNginxConf( $settGlob, $sett, $verifyEnvDropin ) )
111 {
112
113 call_user_func_array( $cb, array( Ui::MsgErr, sprintf( Wp::safe_html_x( 'ContentDropinNotMatch_%1$s%2$s', 'admin.Notice', 'seraphinite-accelerator' ), Gen::GetFileDir( CacheGetEnvNginxConfFile() ), Gen::GetFileName( CacheGetEnvNginxConfFile() ) ) . ( $ext ? '' : sprintf( Wp::safe_html_x( 'ContentDropinNotMatchEx_%1$s%2$s', 'admin.Notice', 'seraphinite-accelerator' ), GetCodeViewHtmlBlock( $verifyEnvDropin -> needed ), GetCodeViewHtmlBlock( $verifyEnvDropin -> actual ) ) ) ) );
114 }
115
116 if( !Gen::DoesFuncExist( 'fsockopen' ) && !Gen::DoesFuncExist( 'curl_exec' ) )
117 call_user_func_array( $cb, array( Ui::MsgWarn, sprintf( Wp::safe_html_x( 'PhpExtNotActive_%1$s', 'admin.Notice', 'seraphinite-accelerator' ), 'CURL' ) ) );
118
119 if( $isContProcEnabled )
120 {
121 if( ( Gen::GetArrField( $sett, 'contPr/normalize', 0, '/' ) & 524288 ) && !Gen::DoesFuncExist( 'tidy_parse_string' ) )
122 call_user_func_array( $cb, array( Ui::MsgWarn, sprintf( Wp::safe_html_x( 'PhpTidyNotActive_%1$s%2$s%3$s', 'admin.Notice', 'seraphinite-accelerator' ), 'TIDY', esc_html_x( 'TidyChk', 'admin.Settings_Html_Fix', 'seraphinite-accelerator' ), Ui::Link( esc_html_x( 'Title', 'admin.Settings_Html', 'seraphinite-accelerator' ), menu_page_url( 'seraph_accel_settings', false ) . '#html' ) ) ) );
123
124 if( !Gen::DoesFuncExist( 'iconv' ) )
125 call_user_func_array( $cb, array( Ui::MsgWarn, sprintf( Wp::safe_html_x( 'PhpExtNotActive_%1$s', 'admin.Notice', 'seraphinite-accelerator' ), 'ICONV' ) ) );
126
127 if( !Gen::DoesFuncExist( 'mb_detect_encoding' ) || !Gen::DoesFuncExist( 'mb_convert_encoding' ) )
128 call_user_func_array( $cb, array( Ui::MsgWarn, sprintf( Wp::safe_html_x( 'PhpExtNotActive_%1$s', 'admin.Notice', 'seraphinite-accelerator' ), 'MBSTRING' ) ) );
129
130 if( !Gen::DoesFuncExist( '\\DOMElement::getAttribute' ) )
131 call_user_func_array( $cb, array( Ui::MsgErr, sprintf( Wp::safe_html_x( 'PhpExtNotActive_%1$s', 'admin.Notice', 'seraphinite-accelerator' ), 'LIBXML' ) ) );
132
133 if( !Gen::DoesFuncExist( 'imagecreatefromstring' ) )
134 {
135 foreach( array( 'webp','avif' ) as $comprType )
136 if( Gen::GetArrField( $sett, array( 'contPr', 'img', $comprType, 'enable' ), false, '/' ) )
137 call_user_func_array( $cb, array( Ui::MsgWarn, sprintf( Wp::safe_html_x( 'PhpGdNotActive_%1$s%2$s%3$s', 'admin.Notice', 'seraphinite-accelerator' ), 'GD',
138 sprintf( Plugin::GetPluginString( 'SubjectTitle_%1$s%2$s' ), esc_html_x( 'Lbl', 'admin.Settings_Images_Compr', 'seraphinite-accelerator' ), Gen::GetArrField( array( 'avif' => sprintf( esc_html_x( 'AvifChk_%1$s%2$s', 'admin.Settings_Images_Compr', 'seraphinite-accelerator' ), '', '' ), 'webp' => sprintf( esc_html_x( 'WebpChk_%1$s', 'admin.Settings_Images_Compr', 'seraphinite-accelerator' ), '' ) ), $comprType, '' ) ),
139 Ui::Link( esc_html_x( 'Title', 'admin.Settings_Images', 'seraphinite-accelerator' ), menu_page_url( 'seraph_accel_settings', false ) . '#images' ) ) ) );
140
141 if( Gen::GetArrField( $sett, 'contPr/img/szAdaptImg', false, '/' ) || Gen::GetArrField( $sett, 'contPr/img/szAdaptBg', false, '/' ) )
142 call_user_func_array( $cb, array( Ui::MsgWarn, sprintf( Wp::safe_html_x( 'PhpGdNotActive_%1$s%2$s%3$s', 'admin.Notice', 'seraphinite-accelerator' ), 'GD',
143 sprintf( Plugin::GetPluginString( 'SubjectTitle_%1$s%2$s' ), esc_html_x( 'Title', 'admin.Settings_Images', 'seraphinite-accelerator' ), esc_html_x( 'Lbl', 'admin.Settings_Images_Adapt', 'seraphinite-accelerator' ) ),
144 Ui::Link( esc_html_x( 'Title', 'admin.Settings_Images', 'seraphinite-accelerator' ), menu_page_url( 'seraph_accel_settings', false ) . '#images' ) ) ) );
145 }
146 }
147
148 $themeCh = wp_get_theme();
149 for( $theme = $themeCh; $theme && $theme -> parent(); )
150 $theme = $theme -> parent();
151
152 if( $theme )
153 {
154 switch( $theme -> template )
155 {
156 case 'woostroid2':
157
158 break;
159 case 'woodmart':
160 $themeOpts = get_option( 'xts-woodmart-options' );
161
162 break;
163
164 case 'dt-the7':
165 $themeOpts = get_option( $themeCh -> stylesheet == 'dt-the7-child' ? 'the7dtchild' : 'the7' );
166
167 break;
168
169 case 'themify-ultra':
170 $themeOpts = get_option( 'themify_data' );
171
172 break;
173
174 case 'thegem':
175 $themeOpts = get_option( 'thegem_theme_options' );
176
177 break;
178
179 case 'xstore':
180
181 break;
182
183 case 'superio':
184 $themeOpts = get_option( 'superio_theme_options' );
185
186 break;
187 }
188 }
189
190 $availablePlugins = Plugin::GetAvailablePluginsEx();
191
192 $plg = ($availablePlugins[ 'wp-smushit' ]??null);
193 if( !$plg || !($plg[ 'IsActive' ]??null) )
194 $plg = ($availablePlugins[ 'wp-smush-pro' ]??null);
195 if( $plg && ($plg[ 'IsActive' ]??null) )
196 {
197 $plgOpts = get_option( 'wp-smush-settings' );
198
199 }
200
201 $plg = ($availablePlugins[ 'elementor' ]??null);
202 if( !$plg || !($plg[ 'IsActive' ]??null) )
203 $plg = ($availablePlugins[ 'elementor-pro' ]??null);
204 if( $plg && ($plg[ 'IsActive' ]??null) )
205 {
206
207 }
208
209 $plg = ($availablePlugins[ 'ewww-image-optimizer' ]??null);
210 if( $plg && ($plg[ 'IsActive' ]??null) )
211 {
212
213 }
214
215 $plg = ($availablePlugins[ 'webp-express' ]??null);
216 if( $plg && ($plg[ 'IsActive' ]??null) )
217 {
218
219 }
220
221 $plg = ($availablePlugins[ 'rocket-lazy-load' ]??null);
222 if( $plg && ($plg[ 'IsActive' ]??null) )
223 {
224
225 }
226
227 $plg = ($availablePlugins[ 'a3-lazy-load' ]??null);
228 if( $plg && ($plg[ 'IsActive' ]??null) )
229 {
230 $plgOpts = get_option( 'a3_lazy_load_global_settings' );
231
232 }
233
234 $plg = ($availablePlugins[ 'optimole-wp' ]??null);
235 if( $plg && ($plg[ 'IsActive' ]??null) )
236 {
237 $plgOpts = wp_parse_args( get_option( 'optml_settings' ) );
238
239 }
240
241 $plg = ($availablePlugins[ 'shortpixel-adaptive-images' ]??null);
242 if( $plg && ($plg[ 'IsActive' ]??null) )
243 {
244
245 }
246
247 $plg = ($availablePlugins[ 'async-javascript' ]??null);
248 if( $plg && ($plg[ 'IsActive' ]??null) )
249 {
250
251 }
252
253 $plg = ($availablePlugins[ 'revslider' ]??null);
254 if( $plg && ($plg[ 'IsActive' ]??null) )
255 {
256 $plgOpts = get_option( 'revslider-global-settings' );
257 if( !is_array( $plgOpts ) )
258 $plgOpts = @json_decode( $plgOpts, true );
259
260 }
261
262 $plg = ($availablePlugins[ 'wp-optimize' ]??null);
263 if( $plg && ($plg[ 'IsActive' ]??null) )
264 {
265
266 $plgOpts = get_option( 'wpo_cache_config' );
267 if( $isCacheEnabled && Gen::GetArrField( $plgOpts, 'enable_page_caching' ) )
268 call_user_func_array( $cb, array( Gen::SevErr, sprintf( Wp::safe_html_x( '3rdSett_Conflict_%1$s%2$s', 'admin.Notice', 'seraphinite-accelerator' ), $plg[ 'Name' ], Wp::GetLocString( 'Enable page caching', null, 'wp-optimize' ) ) ) );
269
270 }
271
272 $plg = ($availablePlugins[ 'wp-rocket' ]??null);
273 if( $plg && ($plg[ 'IsActive' ]??null) )
274 {
275 call_user_func_array( $cb, array( Gen::SevErr, sprintf( Wp::safe_html_x( '3rdMdl_Conflict_%1$s', 'admin.Notice', 'seraphinite-accelerator' ), $plg[ 'Name' ] ) ) );
276
277 }
278
279 $plg = ($availablePlugins[ 'w3-total-cache' ]??null);
280 if( $plg && ($plg[ 'IsActive' ]??null) )
281 {
282 call_user_func_array( $cb, array( Gen::SevErr, sprintf( Wp::safe_html_x( '3rdMdl_Conflict_%1$s', 'admin.Notice', 'seraphinite-accelerator' ), $plg[ 'Name' ] ) ) );
283
284 }
285
286 $plg = ($availablePlugins[ 'nitropack' ]??null);
287 if( $plg && ($plg[ 'IsActive' ]??null) )
288 {
289 call_user_func_array( $cb, array( Gen::SevErr, sprintf( Wp::safe_html_x( '3rdMdl_Conflict_%1$s', 'admin.Notice', 'seraphinite-accelerator' ), $plg[ 'Name' ] ) ) );
290 }
291
292 $plg = ($availablePlugins[ 'wp-fastest-cache' ]??null);
293 if( $plg && ($plg[ 'IsActive' ]??null) )
294 {
295 call_user_func_array( $cb, array( Gen::SevErr, sprintf( Wp::safe_html_x( '3rdMdl_Conflict_%1$s', 'admin.Notice', 'seraphinite-accelerator' ), $plg[ 'Name' ] ) ) );
296
297 }
298
299 $plg = ($availablePlugins[ 'hummingbird-performance' ]??null);
300 if( $plg && ($plg[ 'IsActive' ]??null) )
301 {
302 call_user_func_array( $cb, array( Gen::SevErr, sprintf( Wp::safe_html_x( '3rdMdl_Conflict_%1$s', 'admin.Notice', 'seraphinite-accelerator' ), $plg[ 'Name' ] ) ) );
303
304 }
305
306 $plg = ($availablePlugins[ 'wp-hummingbird' ]??null);
307 if( $plg && ($plg[ 'IsActive' ]??null) )
308 {
309 call_user_func_array( $cb, array( Gen::SevErr, sprintf( Wp::safe_html_x( '3rdMdl_Conflict_%1$s', 'admin.Notice', 'seraphinite-accelerator' ), $plg[ 'Name' ] ) ) );
310
311 }
312
313 $plg = ($availablePlugins[ 'jetpack' ]??null);
314 if( $plg && ($plg[ 'IsActive' ]??null) )
315 {
316 $plgOpts = Gen::GetArrField( get_option( 'jetpack_active_modules' ), array( '' ), array() );
317 if( $isCacheEnabled && in_array( 'photon', $plgOpts ) )
318 call_user_func_array( $cb, array( Gen::SevErr, sprintf( Wp::safe_html_x( '3rdSett_Conflict_%1$s%2$s', 'admin.Notice', 'seraphinite-accelerator' ), $plg[ 'Name' ], Wp::GetLocString( 'Enable site accelerator', null, 'jetpack' ) ) ) );
319
320 }
321
322 $plg = ($availablePlugins[ 'jetpack-boost' ]??null);
323 if( $plg && ($plg[ 'IsActive' ]??null) )
324 {
325
326 }
327
328 $plg = ($availablePlugins[ 'autoptimize' ]??null);
329 if( $plg && ($plg[ 'IsActive' ]??null) )
330 {
331
332 }
333
334 $plg = ($availablePlugins[ 'litespeed-cache' ]??null);
335 if( $plg && ($plg[ 'IsActive' ]??null) )
336 {
337
338 if( $isCacheEnabled && get_option( 'litespeed.conf.cache' ) )
339 call_user_func_array( $cb, array( Gen::SevErr, sprintf( Wp::safe_html_x( '3rdSett_ConflictSoft_%1$s%2$s', 'admin.Notice', 'seraphinite-accelerator' ), $plg[ 'Name' ], Wp::GetLocString( 'Enable Cache', null, 'litespeed-cache' ) ) ) );
340 }
341
342 $plg = ($availablePlugins[ 'sg-cachepress' ]??null);
343 if( $plg )
344 {
345 if( ($plg[ 'IsActive' ]??null) )
346 {
347 if( $isCacheEnabled && get_option( 'siteground_optimizer_enable_cache' ) && !$isExtCacheAllowed )
348 call_user_func_array( $cb, array( Gen::SevErr, sprintf( Wp::safe_html_x( '3rdSett_ConflictSoft_%1$s%2$s', 'admin.Notice', 'seraphinite-accelerator' ), $plg[ 'Name' ], Wp::GetLocString( 'Dynamic Caching', null, 'sg-cachepress' ) ) ) );
349
350 }
351 else
352 {
353 if( $isCacheEnabled )
354 call_user_func_array( $cb, array( Gen::SevWarn, sprintf( Wp::safe_html_x( '3rdMdl_ConflictOff_%1$s', 'admin.Notice', 'seraphinite-accelerator' ), $plg[ 'Name' ] ) ) );
355 }
356 }
357
358 $plg = ($availablePlugins[ 'fast-velocity-minify' ]??null);
359 if( $plg && ($plg[ 'IsActive' ]??null) )
360 {
361 if( $isCacheEnabled )
362 call_user_func_array( $cb, array( Gen::SevErr, sprintf( Wp::safe_html_x( '3rdMdl_Conflict_%1$s', 'admin.Notice', 'seraphinite-accelerator' ), $plg[ 'Name' ] ) ) );
363 }
364
365 $plg = ($availablePlugins[ 'breeze' ]??null);
366 if( $plg && ($plg[ 'IsActive' ]??null) )
367 {
368 call_user_func_array( $cb, array( Gen::SevErr, sprintf( Wp::safe_html_x( '3rdMdl_Conflict_%1$s', 'admin.Notice', 'seraphinite-accelerator' ), $plg[ 'Name' ] ) ) );
369 }
370
371 $plg = ($availablePlugins[ 'wp-meteor' ]??null);
372 if( $plg && ($plg[ 'IsActive' ]??null) )
373 {
374 call_user_func_array( $cb, array( Gen::SevErr, sprintf( Wp::safe_html_x( '3rdMdl_Conflict_%1$s', 'admin.Notice', 'seraphinite-accelerator' ), $plg[ 'Name' ] ) ) );
375 }
376
377 $plg = ($availablePlugins[ 'wp-cloudflare-page-cache' ]??null);
378 if( $plg && ($plg[ 'IsActive' ]??null) )
379 {
380 call_user_func_array( $cb, array( Gen::SevErr, sprintf( Wp::safe_html_x( '3rdMdl_Conflict_%1$s', 'admin.Notice', 'seraphinite-accelerator' ), $plg[ 'Name' ] ) ) );
381 }
382
383 $plg = ($availablePlugins[ 'wp-super-cache' ]??null);
384 if( $plg && ($plg[ 'IsActive' ]??null) )
385 {
386 call_user_func_array( $cb, array( Gen::SevErr, sprintf( Wp::safe_html_x( '3rdMdl_Conflict_%1$s', 'admin.Notice', 'seraphinite-accelerator' ), $plg[ 'Name' ] ) ) );
387 }
388
389 $plg = ($availablePlugins[ 'a2-optimized-wp' ]??null);
390 if( $plg && ($plg[ 'IsActive' ]??null) )
391 {
392 call_user_func_array( $cb, array( Gen::SevErr, sprintf( Wp::safe_html_x( '3rdMdl_Conflict_%1$s', 'admin.Notice', 'seraphinite-accelerator' ), $plg[ 'Name' ] ) ) );
393 }
394
395 $plg = ($availablePlugins[ 'wp-asset-clean-up' ]??null);
396 if( $plg && ($plg[ 'IsActive' ]??null) )
397 {
398 call_user_func_array( $cb, array( Gen::SevErr, sprintf( Wp::safe_html_x( '3rdMdl_Conflict_%1$s', 'admin.Notice', 'seraphinite-accelerator' ), $plg[ 'Name' ] ) ) );
399 }
400
401 $plg = ($availablePlugins[ 'perfmatters' ]??null);
402 if( $plg && ($plg[ 'IsActive' ]??null) )
403 {
404 $plgOpts = get_option( 'perfmatters_options' );
405
406 }
407
408 $plg = ($availablePlugins[ 'flying-pages' ]??null);
409 if( $plg && ($plg[ 'IsActive' ]??null) )
410 {
411 call_user_func_array( $cb, array( Gen::SevErr, sprintf( Wp::safe_html_x( '3rdMdl_Conflict_%1$s', 'admin.Notice', 'seraphinite-accelerator' ), $plg[ 'Name' ] ) ) );
412 }
413
414 $plg = ($availablePlugins[ 'flying-scripts' ]??null);
415 if( $plg && ($plg[ 'IsActive' ]??null) )
416 {
417 call_user_func_array( $cb, array( Gen::SevErr, sprintf( Wp::safe_html_x( '3rdMdl_Conflict_%1$s', 'admin.Notice', 'seraphinite-accelerator' ), $plg[ 'Name' ] ) ) );
418 }
419
420 $plg = ($availablePlugins[ 'debloat' ]??null);
421 if( $plg && ($plg[ 'IsActive' ]??null) )
422 {
423 call_user_func_array( $cb, array( Gen::SevErr, sprintf( Wp::safe_html_x( '3rdMdl_Conflict_%1$s', 'admin.Notice', 'seraphinite-accelerator' ), $plg[ 'Name' ] ) ) );
424 }
425
426 $plg = ($availablePlugins[ 'clearfy' ]??null);
427 if( $plg && ($plg[ 'IsActive' ]??null) )
428 {
429
430 $deactive_preinstall_components = Gen::GetArrField( get_option( 'wbcr_clearfy_deactive_preinstall_components' ), array( '' ), array() );
431
432 if( $isCacheEnabled && get_option( 'wbcr_clearfy_enable_cache' ) && !in_array( 'cache', $deactive_preinstall_components ) )
433 call_user_func_array( $cb, array( Gen::SevErr, sprintf( Wp::safe_html_x( '3rdSett_Conflict_%1$s%2$s', 'admin.Notice', 'seraphinite-accelerator' ), $plg[ 'Name' ], Wp::GetLocString( 'Enable cache', null, 'clearfy' ) ) ) );
434
435 if( $isContProcEnabled && !in_array( 'minify_and_combine', $deactive_preinstall_components ) )
436 {
437 if( get_option( 'wbcr_clearfy_css_optimize' ) )
438 call_user_func_array( $cb, array( Gen::SevErr, sprintf( Wp::safe_html_x( '3rdSett_Conflict_%1$s%2$s', 'admin.Notice', 'seraphinite-accelerator' ), $plg[ 'Name' ], Wp::GetLocString( 'Optimize CSS Code?', null, 'minify-and-combine' ) ) ) );
439 if( get_option( 'wbcr_clearfy_css_aggregate' ) )
440 call_user_func_array( $cb, array( Gen::SevErr, sprintf( Wp::safe_html_x( '3rdSett_Conflict_%1$s%2$s', 'admin.Notice', 'seraphinite-accelerator' ), $plg[ 'Name' ], Wp::GetLocString( 'Aggregate CSS-files?', null, 'minify-and-combine' ) ) ) );
441 if( get_option( 'wbcr_clearfy_css_include_inline' ) )
442 call_user_func_array( $cb, array( Gen::SevErr, sprintf( Wp::safe_html_x( '3rdSett_Conflict_%1$s%2$s', 'admin.Notice', 'seraphinite-accelerator' ), $plg[ 'Name' ], Wp::GetLocString( 'Also aggregate inline CSS?', null, 'minify-and-combine' ) ) ) );
443 if( get_option( 'wbcr_clearfy_css_defer' ) )
444 call_user_func_array( $cb, array( Gen::SevErr, sprintf( Wp::safe_html_x( '3rdSett_Conflict_%1$s%2$s', 'admin.Notice', 'seraphinite-accelerator' ), $plg[ 'Name' ], Wp::GetLocString( 'Inline and Defer CSS?', null, 'minify-and-combine' ) ) ) );
445 if( get_option( 'wbcr_clearfy_css_inline' ) )
446 call_user_func_array( $cb, array( Gen::SevErr, sprintf( Wp::safe_html_x( '3rdSett_Conflict_%1$s%2$s', 'admin.Notice', 'seraphinite-accelerator' ), $plg[ 'Name' ], Wp::GetLocString( 'Inline all CSS?', null, 'minify-and-combine' ) ) ) );
447
448 if( get_option( 'wbcr_clearfy_js_optimize' ) )
449 call_user_func_array( $cb, array( Gen::SevErr, sprintf( Wp::safe_html_x( '3rdSett_Conflict_%1$s%2$s', 'admin.Notice', 'seraphinite-accelerator' ), $plg[ 'Name' ], Wp::GetLocString( 'Optimize JavaScript Code?', null, 'minify-and-combine' ) ) ) );
450 if( get_option( 'wbcr_clearfy_js_aggregate' ) )
451 call_user_func_array( $cb, array( Gen::SevErr, sprintf( Wp::safe_html_x( '3rdSett_Conflict_%1$s%2$s', 'admin.Notice', 'seraphinite-accelerator' ), $plg[ 'Name' ], Wp::GetLocString( 'Aggregate JS-files?', null, 'minify-and-combine' ) ) ) );
452 if( get_option( 'wbcr_clearfy_js_include_inline' ) )
453 call_user_func_array( $cb, array( Gen::SevErr, sprintf( Wp::safe_html_x( '3rdSett_Conflict_%1$s%2$s', 'admin.Notice', 'seraphinite-accelerator' ), $plg[ 'Name' ], Wp::GetLocString( 'Also aggregate inline JS?', null, 'minify-and-combine' ) ) ) );
454 }
455 }
456
457 if( !$ext )
458 return;
459
460 if( $isContProcEnabled )
461 {
462 $requestRes = Wp::RemoteGet( Wp::GetSiteRootUrl(), array( 'timeout' => 30, 'sslverify' => false ) );
463 if( Net::GetHrFromWpRemoteGet( $requestRes ) === Gen::S_OK )
464 {
465 $data = wp_remote_retrieve_body( $requestRes );
466
467 if( $isContProcEnabled )
468 {
469 if( preg_match( '@<script[^>]+type\\s*=\\s*text/ez-screx\\W@', $data ) )
470 call_user_func_array( $cb, array( Gen::SevErr, sprintf( Wp::safe_html_x( '3rdExtSett_Conflict_%1$s%2$s', 'admin.SelfDiag', 'seraphinite-accelerator' ), 'Ezoic', 'Leap' ) ) );
471
472 if( preg_match( '@<script[^>]+src\\s*=[\'"][^\'"]+cloudflare-static/rocket-loader\\.@', $data ) )
473 call_user_func_array( $cb, array( Gen::SevErr, sprintf( Wp::safe_html_x( '3rdExtSett_Conflict_%1$s%2$s', 'admin.SelfDiag', 'seraphinite-accelerator' ), 'CloudFlare', 'Rocket Loader' ) ) );
474 }
475
476 if( preg_match( '@<script[^>]+src\\s*=[\'"][^\'"]+/challenge-platform/[^\'"]+/scripts/invisible\\.@', $data ) )
477 call_user_func_array( $cb, array( Gen::SevInfo, sprintf( Wp::safe_html_x( '3rdExtSett_SpeedDecr_%1$s%2$s', 'admin.SelfDiag', 'seraphinite-accelerator' ), 'CloudFlare', 'Bot Fight Mode' ) ) );
478 }
479 }
480
481 if( $isContProcEnabled )
482 {
483
484 $bRedirOwn = Gen::GetArrField( $sett, array( 'contPr', 'img', 'redirOwn' ), false );
485 foreach( array( 'webp','avif' ) as $comprType )
486 {
487 if( !Gen::GetArrField( $sett, array( 'contPr', 'img', $comprType, 'enable' ), false ) )
488 continue;
489
490 $contMimeTypeTest = 'image/' . $comprType;
491
492 $optionText = sprintf( Plugin::GetPluginString( 'SubjectTitle_%1$s%2$s' ), esc_html_x( 'Lbl', 'admin.Settings_Images_Compr', 'seraphinite-accelerator' ), Gen::GetArrField( array( 'avif' => sprintf( esc_html_x( 'AvifChk_%1$s%2$s', 'admin.Settings_Images_Compr', 'seraphinite-accelerator' ), '', '' ), 'webp' => sprintf( esc_html_x( 'WebpChk_%1$s', 'admin.Settings_Images_Compr', 'seraphinite-accelerator' ), '' ) ), $comprType, '' ) );
493
494 if( $bRedirOwn )
495 $testUrl = add_query_arg( array_merge( Image_MakeOwnRedirUrlArgs( GetSalt(), ltrim( Net::Url2Uri( plugins_url( '/Images/Test.png', __FILE__ ), true ), '/' ) ), array( '_' => Gen::MicroTimeStamp() ) ), Wp::GetSiteWpRootUrl() );
496 else
497 $testUrl = add_query_arg( array( '_' => Gen::MicroTimeStamp() ), plugins_url( '/Images/Test.png', __FILE__ ) );
498
499 $requestRes = Wp::RemoteGet( $testUrl, array( 'timeout' => 30, 'sslverify' => false, 'headers' => array( 'Accept' => $contMimeTypeTest . ',image/*,*/*;q=0.8' ) ) );
500 if( Net::GetHrFromWpRemoteGet( $requestRes ) !== Gen::S_OK )
501 {
502 if( $bRedirOwn )
503 call_user_func_array( $cb, array( Gen::SevWarn, _SelfDiag_GetResponseResString( $testUrl, $requestRes ) ) );
504 }
505 else
506 {
507 $contMimeType = ( string )Net::GetHeaderFromWpRemoteRequestRes( $requestRes, 'content-type' );
508
509 if( strpos( $contMimeType, $contMimeTypeTest ) === false )
510 call_user_func_array( $cb, array( Gen::SevWarn, vsprintf( Wp::safe_html_x( 'ImgConvRedir_NotActive_%1$s%2$s%3$s%4$s%5$s', 'admin.Notice', 'seraphinite-accelerator' ), array_merge( Ui::Link( array( '', '' ), Plugin::RmtCfgFld_GetLoc( $rmtCfg, 'Help.Settings_Images_Compr' ), true, array( ) ), array( $comprType, $optionText, esc_html_x( 'RedirOwnChk', 'admin.Settings_Images_Compr', 'seraphinite-accelerator' ) ) ) ) ) );
511 }
512
513 $hr = Img::ConvertDataEx( $dataCnv, @file_get_contents( __DIR__ . '/Images/Test.png' ), $contMimeTypeTest );
514 if( Gen::HrFail( $hr ) )
515 if( $hr == Gen::E_UNSUPPORTED )
516 call_user_func_array( $cb, array( Gen::SevWarn, vsprintf( Wp::safe_html_x( 'ImgConv_NotSupp_%1$s%2$s%3$s%4$s', 'admin.Notice', 'seraphinite-accelerator' ), array_merge( Ui::Link( array( '', '' ), Plugin::RmtCfgFld_GetLoc( $rmtCfg, 'Help.Settings_Images_Compr' ), true, array( ) ), array( $comprType, $optionText ) ) ) ) );
517 else
518 call_user_func_array( $cb, array( Gen::SevWarn, vsprintf( Wp::safe_html_x( 'ImgConv_NotWork_%1$s%2$s%3$s%4$s%5$s', 'admin.Notice', 'seraphinite-accelerator' ), array_merge( Ui::Link( array( '', '' ), Plugin::RmtCfgFld_GetLoc( $rmtCfg, 'Help.Settings_Images_Compr' ), true, array( ) ), array( $comprType, $optionText, Gen::LastErrDsc_Is() ? MsgUnpackLocIds( Gen::LastErrDsc_Get() ) : sprintf( '0x%08X', $hr ) ) ) ) ) );
519 }
520 }
521
522 if( UseGzAssets( Gen::GetArrField( $sett, array( 'cache' ), array() ) ) )
523 {
524 foreach( array( 'js', 'css' ) as $assetType )
525 {
526 $dataTest = @file_get_contents( __DIR__ . '/Images/Test.' . $assetType );
527
528 $testUrl = add_query_arg( array( '_' => Gen::MicroTimeStamp() ), plugins_url( '/Images/Test.' . $assetType, __FILE__ ) );
529 $requestRes = Wp::RemoteGet( $testUrl, array( 'timeout' => 30, 'sslverify' => false, 'headers' => array( 'Accept' => 'text/' . $assetType . ',*/*;q=0.1', 'Accept-Encoding' => 'gzip, deflate, br' ) ) );
530 if( Net::GetHrFromWpRemoteGet( $requestRes ) !== Gen::S_OK )
531 {
532
533 }
534 else
535 {
536 $data = wp_remote_retrieve_body( $requestRes );
537 if( $data )
538 {
539 if( $data !== $dataTest )
540 call_user_func_array( $cb, array( Gen::SevWarn, sprintf( Wp::safe_html_x( 'AssetCompr_Bad_%1$s', 'admin.Notice', 'seraphinite-accelerator' ), $assetType ) ) );
541 }
542 }
543 }
544 }
545 }
546
547 function _3rdParty_to_boolean( $value )
548 {
549 if( in_array( $value, [ 'yes', 'enabled', 'true', '1', 'on' ], true ) )
550 return( true );
551 if( in_array( $value, [ 'no', 'disabled', 'false', '0', 'off' ], true ) )
552 return( false );
553 return( boolval( $value ) );
554 }
555
556