PluginProbe
JCH Optimize / trunk
JCH Optimize vtrunk
6.0.2 6.0.1 trunk 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.2.0 1.2.1 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.1.0 2.10.0 2.2.0 2.2.1 All 58 releases
jch-optimize / src / Admin / Settings / ConfigurationSchema.php

ConfigurationSchema.php in JCH Optimize trunk, at src/Admin/Settings/ConfigurationSchema.php

1,207 lines 55.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * JCH Optimize - Performs several front-end optimizations for fast downloads
5 *
6 * @package jchoptimize/wordpress-platform
7 * @author Samuel Marshall <samuel@jch-optimize.net>
8 * @copyright Copyright (c) 2020 Samuel Marshall / JCH Optimize
9 * @license GNU/GPLv3, or later. See LICENSE file
10 *
11 * If LICENSE file missing, see <http://www.gnu.org/licenses/>.
12 */
13
14 namespace JchOptimize\WordPress\Admin\Settings;
15
16 use function __;
17 use function array_merge;
18 use function get_class_methods;
19 use function sprintf;
20 use function str_replace;
21
22 /**
23 * Schema for the Configurations page settings registered through the WordPress Settings API.
24 *
25 * Each method returns an array of sections of settings for each tab.
26 * Each setting contains an indexed array of the following information
27 * setting => ['title', 'description', 'new']
28 *
29 */
30 abstract class ConfigurationSchema
31 {
32 public static function getSettingsArray(): array
33 {
34 $aTabs = get_class_methods(__CLASS__);
35 $aSettingsArray = [];
36
37 foreach ($aTabs as $tab) {
38 if ($tab == str_replace(__CLASS__ . '::', '', __METHOD__)) {
39 continue;
40 }
41
42 $aSettingsArray = array_merge($aSettingsArray, self::$tab());
43 }
44
45 return $aSettingsArray;
46 }
47
48 public static function generalTab(): array
49 {
50 return [
51 /**
52 * Miscellaneous
53 */
54 'miscellaneousSection' => [
55 'pro_downloadid' => [
56 __('Download ID', 'jch-optimize'),
57 __(
58 'You\'ll find your Download ID in your account. Enter your Download ID here to enable automatic updates of the PRO version and to access our Optimize Image API.',
59 'jch-optimize'
60 ),
61 ],
62 'debug' => [
63 __('Debug Plugin', 'jch-optimize'),
64 __(
65 'This option will add the \'commented out\' url of the individual files inside the combined file above the contents that came from that file. This is useful when configuring the plugin and trying to resolve conflicts. <p>This will also add a Profiler menu to the AdminBar, so you can review the times that the plugin methods take to run.',
66 'jch-optimize'
67 )
68 ],
69 'order_plugin' => [
70 __('Order plugin', 'jch-optimize'),
71 __(
72 'If enabled, the plugin will ensure that the correct execution order of plugins to maintain compatibility with popular caching plugins are restored whenever a plugin is activated or deactivated.',
73 'jch-optimize'
74 )
75 ],
76 'disable_logged_in_users' => [
77 __('Disable logged in users', 'jch-optimize'),
78 __(
79 'When enabled, the plugin will be disabled for all users that are logged in',
80 'jch-optimize'
81 )
82 ],
83 ],
84 /**
85 * Elements Above Fold
86 */
87 'elementsAboveFoldSection' => [
88 'elements_above_fold_home' => [
89 __('Home page', 'jch-optimize'),
90 __('The number of elements above the fold on the home page.', 'jch-optimize'),
91 ],
92 'elements_above_fold' => [
93 __('Default', 'jch-optimize'),
94 __(
95 'This will be used on any page that is not the home page and is not listed below.',
96 'jch-optimize'
97 )
98 ],
99 'elements_above_fold_per_page' => [
100 __('Per page', 'jch-optimize'),
101 __(
102 'For any page that differs significantly from the default, you can specify its own value here.',
103 'jch-optimize'
104 ),
105 ],
106 'elements_above_fold_marker' => [
107 __('Above fold marker', 'jch-optimize'),
108 __(
109 'DO NOT LEAVE THIS ENABLED! This only works if Debug Plugin above is enabled. This prints the calculate number of elements above the fold in the console. For a visual indicator of where your configured \'Elements above fold\' falls on the page, run \'verifyElementMarkerOverlay()\' in the console.',
110 'jch-optimize'
111 )
112 ]
113 ],
114 /*
115 * Exclude Menu Items
116 */
117 'excludeMenuItemsSection' => [
118 'menuexcludedurl' => [
119 __('Exclude urls', 'jch-optimize'),
120 __(
121 'Enter a substring of the url you want to exclude here. Just type the string in the textbox then click the \'Add Item\' button for each url then save your settings',
122 'jch-optimize'
123 )
124 ]
125 ],
126 /**
127 * Cache Storage Settings
128 */
129 'cacheStorageSection' => [
130 'pro_cache_storage_adapter' => [
131 __('Storage Adapter', 'jch-optimize'),
132 __(
133 'Select the type of storage you want to use for caching. Available options are: <ul><li>Filesystem</li><li>Memcached</li><li>APCu</li><li>Redis</li><li>WinCache</li></ul>The default is filesystem and any storage not supported by your system will be disabled.'
134 )
135 ],
136 'cache_lifetime' => [
137 __('Cache lifetime', 'jch-optimize'),
138 __(
139 'The lifetime of the cache files generated by the plugin. <p>If you\'re using a Page Cache plugin be sure to set this higher than the lifetime set in Page Cache. <p>If you\'re having issue with excess amount of cache being generated then lowering this setting will help.',
140 'jch-optimize'
141 )
142 ],
143 'memcached_server_host' => [
144 __('Memcached server host', 'jch-optimize'),
145 __(
146 'Enter the host of the Memcached server you want to use, e.g, \'127.0.0.1\'',
147 'jch-optimize'
148 ),
149 false,
150 'jch-memcached-wrapper d-none'
151 ],
152 'memcached_server_port' => [
153 __('Memcached server port', 'jch-optimize'),
154 __(
155 'Enter the port number of the Memcached server you have configured, e.g \'11211\'',
156 'jch-optimize'
157 ),
158 false,
159 'jch-memcached-wrapper d-none'
160 ],
161 'redis_server_host' => [
162 __('Redis server host', 'jch-optimize'),
163 __('Set the Redis server host, e.g., \'127.0.0.1\'', 'jch-optimize'),
164 false,
165 'jch-redis-wrapper d-none'
166 ],
167 'redis_server_port' => [
168 __('Redis server port', 'jch-optimize'),
169 __('Set the Redis server port, e.g., \'6379\'', 'jch-optimize'),
170 false,
171 'jch-redis-wrapper d-none'
172 ],
173 'redis_server_password' => [
174 __('Redis server password', 'jch-optimize'),
175 __('Set the Redis server password if there\'s one configured', 'jch-optimize'),
176 false,
177 'jch-redis-wrapper d-none'
178 ],
179 'redis_server_database' => [
180 __('Redis database', 'jch-optimize'),
181 __('Set the database identifier', '0'),
182 false,
183 'jch-redis-wrapper d-none'
184 ],
185 'delete_expiry' => [
186 __('Delete expired cache', 'jch-optimize'),
187 __(
188 'JCH Optimize will delete cached files when they\'re expired to prevent an excess build-up of cache files on the server. <p> If you\'re using another page cache plugin, you may want to disable this to avoid having orphaned links to CSS or JavaScript files cached on the pages.'
189 )
190 ],
191 ],
192 /**
193 * Recache settings
194 */
195 'recacheSettingsSection' => [
196 'recache_base_url' => [
197 __('Base URL', 'jch-optimize'),
198 __(
199 'The URL the crawl will start from. By default it is the site\'s home page, but you can enter your HTML sitemap\'s URL for better coverage',
200 'jch-optimize'
201 )
202 ],
203 'recache_crawl_limit' => [
204 __('Crawl limit', 'jch-optimize'),
205 __('The maximum number of URLs that will be crawled', 'jch-optimize'),
206 ],
207 'recache_concurrency' => [
208 __('Concurrency', 'jch-optimize'),
209 __('The number of URLs that will be crawled simultaneously', 'jch-optimize')
210 ],
211 'recache_max_depth' => [
212 __('Maximum depth', 'jch-optimize'),
213 __(
214 'Starting from the base URL, all the URLs found on that page will be cralwed then all the URLs found on the crawled pages, and so on. This sets how deep the crawl will extend',
215 'jch-optimize'
216 )
217 ],
218 'recache_delete_cache' => [
219 __('Delete cache', 'jch-optimize'),
220 __('Will delete existing cache before crawl, if yes', 'jch-optimize')
221 ],
222 'recache_frequency' => [
223 __('Recache frequency', 'jch-optimize'),
224 __('Select how often you want the recache function to run using WP CRON, if at all', 'jch-optimize')
225 ]
226 ]
227
228 ];
229 }
230
231 public static function combineFilesTab(): array
232 {
233 return [
234 /**
235 * Combine CSS JS
236 */
237 'combineCssJsSection' => [
238 'combine_files_enable' => [
239 __('Enable', 'jch-optimize'),
240 ],
241 'combine_files' => [
242 __('Combine files', 'jch-optimize'),
243 __(
244 'Will combine CSS and JavaScript files into one respectively, except where intermediate files were excluded while preserving execution order. Not recommended in production, but may be useful for troubleshooting',
245 'jch-optimize'
246 )
247 ],
248 'smart_combine' => [
249 __('Smart combine (Bundling)', 'jch-optimize'),
250 __('Combines files into optimally sized bundles while preserving execution order, rather than one monolithic file. Best for HTTP/2, HTTP/3. Requires Combine files to be enabled.')
251 ],
252 /* 'try_catch' => [
253 __('Use try-catch', 'jch-optimize'),
254 __(
255 'If you\'re seeing JavaScript errors in the console, you can try enabling this option to wrap each JavaScript file in a \'try-catch\' block to prevent the errors from one file affecting the combined file. This setting is only used if Combine Files is enabled.',
256 'jch-optimize'
257 )
258 ], */
259 'html_minify_level' => [
260 __('HTML Minification level', 'jch-optimize'),
261 __(
262 'If \'Minify HTML\' is enabled, this will determine the level of minification. The incremental changes per level are as follows: <dl><dt>Basic - </dt><dd>Adjoining whitespaces outside of elements are reduced to one whitespace, HTML comments preserved;</dd><dt>Advanced - </dt><dd>Remove HTML comments, whitespace around block elements and undisplayed elements, Remove unnecessary whitespaces inside of elements and around their attributes;</dd> <dt>Ultra -</dt> <dd>Remove redundant attributes, for example, \'text/javascript\', and remove quotes from around selected attributes (HTML5)</dd> </dl>',
263 'jch-optimize'
264 )
265 ],
266 'htaccess' => [
267 __('Combined files delivery', 'jch-optimize'),
268 __(
269 'By default, the generated files will be loaded as static CSS and JavaScript files. You would need to include directives in your .htaccess file to gzip these files. <p>You can use PHP files instead that will be gzipped if that option is set. PHP files can be loaded with a query attached with the information to find the optimized files, or you can use url rewrite if it\'s available on the server so the files can be masked as static files. If your server prohibits the use of the Options +FollowSymLinks directive in .htaccess files use the respective option.',
270 'jch-optimize'
271 )
272 ],
273 ],
274
275 /**
276 *Combine Css Js Auto Settings
277 */
278 'combineCssJsAutoSection' => [
279 'gzip' => [
280 __('GZip JavaScript and CSS', 'jch-optimize'),
281 __(
282 'The plugin will compress the optimized JavaScript and CSS file respectively using gzip, if you\'ve selected one of the PHP options for \'Combined files delivery\'. This can decrease file size dramatically.',
283 'jch-optimize'
284 )
285 ],
286 'html_minify' => [
287 __('Minify HTML', 'jch-optimize'),
288 __(
289 'The plugin will remove all unnecessary whitespaces and comments from the HTML to reduce the total size of the web page.',
290 'jch-optimize'
291 )
292 ],
293 'includeAllExtensions' => [
294 __('Include all plugins', 'jch-optimize'),
295 __(
296 'By default, all files from third party plugins and external domains are excluded. If enabled, they will be included.',
297 'jch-optimize'
298 )
299 ],
300 'phpAndExternal' => [
301 __('Include PHP and external files', 'jch-optimize'),
302 __(
303 'JavaScript and CSS files with \'.php\' file extensions, and files from external domains will be included in the generated file. <p> This option requires that either cURL is installed on your server or your php option \'allow_url_fopen\' is enabled.',
304 'jch-optimize'
305 )
306 ]
307 ]
308 ];
309 }
310
311 public static function cssTab(): array
312 {
313 return [
314 /**
315 * CSS Automatic Settings
316 */
317 'cssAutoSettingsSection' => [
318 'css' => [
319 __('Combine CSS files', 'jch-optimize'),
320 __(
321 'This will process all CSS files removing all the links to the individual files from the page, replacing them with a link to the generated file.',
322 'jch-optimize'
323 )
324 ],
325 'css_minify' => [
326 __('Minify CSS', 'jch-optimize'),
327 __(
328 'The plugin will remove all unnecessary whitespaces and comments from the CSS file to reduce the total file size.',
329 'jch-optimize'
330 )
331 ],
332 'replaceImports' => [
333 __('Replace @imports in CSS', 'jch-optimize'),
334 sprintf(
335 __(
336 'The plugin will replace %s at-rules with the contents of the files they are importing. This will be done recursively.',
337 'jch-optimize'
338 ),
339 '@import'
340 )
341 ],
342 'inlineStyle' => [
343 __('Include in-page &lt;style&gt;\'s'),
344 sprintf(
345 __(
346 'In-page CSS inside %s tags will be processed in the order they appear on the page.',
347 'jch-optimize'
348 ),
349 '&lt;style$gt;'
350 )
351 ]
352 ],
353 /**
354 * Exclude CSS Settings
355 */
356 'excludeCssSection' => [
357 'excludeCSS' => [
358 __('Exclude CSS files', 'jch-optimize'),
359 __('Select the CSS files you want to exclude.', 'jch-optimize')
360 ],
361 'excludeCssComponents' => [
362 __('Exclude CSS from these plugins', 'jch-optimize'),
363 __(
364 'The plugin will exclude all CSS files from the extensions you have selected.',
365 'jch-optimize'
366 )
367 ],
368 'excludeStyles' => [
369 sprintf(__('Exclude individual in-page %s', 'jch-optimize'), '&lt;style&gt;\'s'),
370 sprintf(
371 __('Select the internal %s you want to exclude.', 'jch-optimize'),
372 '&lt;style&gt;'
373 )
374 ],
375 'excludeAllStyles' => [
376 sprintf(__('Exclude all in-page %s', 'jch-optimize'), '&lt;style&gt;s'),
377 sprintf(
378 __(
379 'This is useful if you are generating an excess amount of cache files due to the file name of the generated CSS file keeps changing and you can\'t identify which %s declaration is responsible',
380 'jch-optimize'
381 ),
382 '&lt;style&gt;'
383 )
384 ]
385 ],
386 /**
387 * Remove CSS
388 */
389 'removeCssSection' => [
390 'remove_css' => [
391 __('Remove CSS Files', 'jch-optimize'),
392 __(
393 'select or add the files you want to prevent from loading on the site\'s pages.',
394 'jch-optimize'
395 )
396 ]
397 ],
398 /**
399 * Optimize CSS Delivery
400 */
401 'optimizeCssDeliverySection' => [
402 'optimizeCssDelivery_enable' => [
403 __('Enable', 'jch-optimize'),
404 ],
405 'pro_reduce_unused_css' => [
406 __('Reduce unused CSS', 'jch-optimize'),
407 __(
408 'When enabled, the plugin will defer the loading of the CSS file until after the page is interacted with to prevent unnecessary processing of unused CSS before the page is loaded.',
409 'jch-optimize'
410 )
411 ],
412 'pro_dynamic_selectors' => [
413 __('CSS dynamic selectors', 'jch-optimize'),
414 __(
415 'In some cases when Reduce Unused CSS is enabled, you may need to add the CSS for some dynamic elements to the critical CSS for them to load properly. Add any substring from the CSS declaration here to have them included.',
416 'jch-optimize'
417 ),
418 false,
419 'd-none'
420 ],
421 'dynamic_css_selectors' => [
422 __('CSS dynamic selectors', 'jch-optimize'),
423 __('
424 In some cases when Remove Unused CSS is enabled, you may need to add the CSS Selector for some dynamic elements to the critical CSS for them to load properly. Enable Debug Plugin, then use the Configure Helper below to compile the list of Dynamic CSS Selector for your page.', 'jch-optimize')
425 ],
426 'critical_css_configure_helper' => [
427 __('Configure helper', 'jch-optimize'),
428 __(
429 'Prints the CSS Dynamic Selectors in the browser console. Run \'downloadDynamicSelectors()\' in the console to download a JSON file with these values and use the Bulk Settings feature on the Dashboard to import and merge them into your settings. DO NOT LEAVE ENABLED IN PRODUCTION!!',
430 'jch-optimize'
431 )
432 ]
433 ],
434 /**
435 * Custom CSS
436 */
437 'customCssSection' => [
438 'custom_css_enable' => [
439 __('Enable', 'jch-optimize'),
440 ],
441 'custom_css' => [
442 __('Global CSS', 'jch-optimize'),
443 __('Use this setting to add CSS for both mobile and desktop views.', 'jch-optimize')
444 ],
445 'mobile_css' => [
446 __('Mobile', 'jch-optimize'),
447 __(
448 'Add simple CSS declarations to allocate space for elements rendering on mobile.',
449 'jch-optimize'
450 )
451 ],
452 'desktop_css' => [
453 __('Desktop', 'jch-optimize'),
454 __('Add CSS for preventing CLS issues on desktop devices here.', 'jch-optimize')
455 ]
456 ]
457 ];
458 }
459
460 /**
461 * Settings found on the JavaScript Tab
462 *
463 * @return array
464 */
465
466 public static function javascriptTab(): array
467 {
468 return [
469 /**
470 * JavaScript Automatic Settings
471 */
472 'javascriptAutomaticSettingsSection' => [
473 'javascript' => [
474 __('Combine JavaScript files', 'jch-optimize'),
475 __(
476 'This will process JavaScript files, removing all the links to the individual files from the page, replacing them with a link to the file.',
477 'jch-optimize'
478 )
479 ],
480 'js_minify' => [
481 __('Minify JavaScript', 'jch-optimize'),
482 __(
483 'The plugin will remove all unnecessary whitespaces and comments from the JavaScript file to reduce the total file size.',
484 'jch-optimize'
485 )
486 ],
487 'inlineScripts' => [
488 sprintf(__('Include in-page %s declarations', 'jch-optimize'), '&lt;script&gt;'),
489 sprintf(
490 __(
491 'In-page JavaScript inside %s tags will be processed in the order they appear on the page.',
492 'jch-optimize'
493 ),
494 '&lt;script&gt;'
495 )
496 ],
497 'bottom_js' => [
498 __('Position JavaScript files at bottom of page', 'jch-optimize'),
499 sprintf(
500 __(
501 'Place JavaScript files at bottom of the page just before the ending %1$s tag.<p> If some JavaScript files are excluded while preserving execution order, only the files below the one(s) excluded will be placed at the bottom of the page.<p> If this is disabled, the plugin only processes files found in the %2$s section of the HTML. This option extends the search to the %3$s section.',
502 'jch-optimize'
503 ),
504 '&lt;/body&gt;',
505 '&lt;head&gt;',
506 '&lt;body&gt;'
507 )
508 ],
509 'loadAsynchronous' => [
510 __('Defer or load JavaScript asychronously', 'jch-optimize'),
511 __(
512 'The \'defer\' attribute is added to the generated JavaScript file to avoid render blocking and speed up download of the web page. <p> If other files/scripts are excluded while preserving execution order, the \'defer\' attribute is only added to the generated file(s) following the last excluded file/script. <p>This option only works when the combined JavaScript file is placed at the bottom of the page.',
513 'jch-optimize'
514 )
515 ]
516 ],
517 /**
518 * Exclude Preserving Execution Order
519 */
520 'excludePeoSection' => [
521 'excludeJs_peo' => [
522 __('Exclude JavaScript files', 'jch-optimize'),
523 __('Select or add the files you want to exclude', 'jch-optimize'),
524 false,
525 'jch-has-multiselect-with-options'
526 ],
527 'excludeJsComponents_peo' => [
528 __('Exclude JavaScript files from these plugins', 'jch-optimize'),
529 __(
530 'The plugin will exclude all JavaScript files from the plugins you have selected.',
531 'jch-optimize'
532 ),
533 false,
534 'jch-has-multiselect-with-options'
535 ],
536 'excludeScripts_peo' => [
537 sprintf(__('Exclude individual in-page %s', 'jch-optimize'), '&lt;script&gt;\'s'),
538 sprintf(
539 __('Select the internal %s you want to exclude.', 'jch-optimize'),
540 '&lt;script&gt;\'s'
541 ),
542 false,
543 'jch-has-multiselect-with-options'
544 ],
545 'excludeAllScripts' => [
546 __('Exclude all internal &lt;script&gt; declarations', 'jch-optimize'),
547 __(
548 'This is useful if you are generating an excess amount of cache files due to the file name of the generated JavaScript file keeps changing and you can\'t identify which SCRIPT declaration is responsible',
549 'jch-optimize'
550 )
551 ]
552 ],
553 /**
554 * Remove JS file
555 */
556 'removeJsSection' => [
557 'remove_js' => [
558 __('Remove JavaScript files', 'jch-optimize'),
559 __(
560 'select or add the JavaScript files you want to prevent from loading on the site\'s pages.',
561 'jch-optimize'
562 )
563 ]
564 ],
565 /**
566 * Reduce Unused JavaScript
567 */
568 'reduceUnusedJavascriptSection' => [
569 'pro_reduce_unused_js_enable' => [
570 __('Enable', 'jch-optimize')
571 ],
572 'pro_criticalJs' => [
573 __('Critical JavaScript files', 'jch-optimize'),
574 __(
575 'select any files required to perform initial render to exclude from the Reduce Unused JavaScript feature.',
576 'jch-optimize'
577 )
578 ],
579 'pro_criticalScripts' => [
580 __('Critical scripts', 'jch-optimize'),
581 __(
582 'Enter any substring of any scripts here that you need to perform any initial render.',
583 'jch-optimize'
584 )
585 ],
586 'pro_criticalModules' => [
587 __('Critical modules', 'jch-optimize'),
588 __(
589 'If your critical scripts you have added above is using any modules you may want to enter them here to exclude them from being dynamically loaded into the DOM.',
590 'jch-optimize'
591 )
592 ],
593 'pro_criticalModulesScripts' => [
594 __('Critical inline modules', 'jch-optimize'),
595 __('You can exclude inline modules in a similar manner as outlined above.', 'jch-optimize')
596 ],
597 'critical_js_configure_helper' => [
598 __('Configure helper', 'jch-optimize'),
599 __('Open the modal to help configure the Critical JavaScript', 'jch-optimize')
600 ]
601 ],
602 ];
603 }
604
605 /**
606 * Settings on Page Cache
607 *
608 * @return array
609 */
610 public static function pageCacheTab(): array
611 {
612 return [
613 /**
614 * Page Cache
615 */
616 'pageCacheSection' => [
617 'cache_enable' => [
618 __('Enable', 'jch-optimize'),
619 __('Enable page caching', 'jch-optimize')
620 ],
621 'pro_cache_platform' => [
622 __('Platform specific', 'jch-optimize'),
623 __('Enable if HTML output on mobile differs from desktop.', 'jch-optimize')
624 ],
625 'page_cache_exclude_form_users' => [
626 __('Exclude form users', 'jch_optimize'),
627 __(
628 'Disable caching for users who have posted a form until the cache expires. May be useful for some sites that update content on user interaction such as shopping carts.',
629 'jch-optimize'
630 )
631 ],
632 'page_cache_browser_caching' => [
633 __('Browser caching', 'jch-optimize'),
634 __(
635 'Allow browsers to cache pages served by the Page Cache plugin for the configured cache lifetime.',
636 'jch-optimize'
637 )
638 ],
639 'page_cache_lifetime' => [
640 __('Cache lifetime', 'jch-optimize'),
641 __(
642 'The period of time for which the page cache will be valid. Be sure to set this lower that the cache lifetime of the processed files at all times.',
643 'jch-optimize'
644 )
645 ],
646 'cache_exclude' => [
647 __('Exclude urls', 'jch-optimize'),
648 __('Enter any part of a url to exclude that page from caching.', 'jch-optimize')
649 ],
650 'page_cache_ignore_query_values' => [
651 __('Ignore queries', 'jch-optimize'),
652 __(
653 'Add the keys for any query parameter here that you do not want to be used to compute cache IDs. This is useful in cases where different query values do not translate to different content so you want a single cached page to be served to all users regardless of the value of this query parameter, as in the case of a marketing campaing, for e.g.',
654 'jch-optimize'
655 )
656 ],
657 'pro_capture_cache_enable' => [
658 __('Use Http Requests', 'jch-optimize'),
659 __(
660 '<p>Will generate static resources to return via HTTP request so pages are shipped without calling PHP again and significantly reduce server response time. Apache configuration is updated automatically. Nginx users must enable equivalent platform-specific routing manually.<p>Currently not compatible with multi-sites.',
661 'jch-optimize'
662 )
663 ],
664
665 ],
666 'cloudflareCachePurgeIntegrationSection' => [
667 'cf_enable' => [
668 __('Enable Cloudflare purge', 'jch-optimize')
669 ],
670 'cf_api_token' => [
671 __('API Bearer Token', 'jch-optimize')
672 ],
673 'cf_zone_id' => [
674 __('Zone ID', 'jch-optimize')
675 ],
676 'cf_mode_switcher_integration' => [
677 __('Mode switcher integration', 'jch-optimize'),
678 __(
679 'When switching JCH Optimize between Production and Development, automatically enable or disable Cloudflare Development Mode. Note: Cloudflare Development Mode automatically expires after 3 hours.'
680 )
681 ]
682 ]
683 ];
684 }
685
686 /**
687 * Settings on Media Tab
688 *
689 * @return array
690 */
691 public static function mediaTab(): array
692 {
693 return [
694 /**
695 * Add image Attributes
696 */
697 'addImageAttributesSection' => [
698 'img_attributes_enable' => [
699 __('Enable', 'jch-optimize')
700 ]
701 ],
702 /**
703 * Sprite Generator
704 */
705 'spriteGeneratorSection' => [
706 'csg_enable' => [
707 __('Enable', 'jch-optimize')
708 ],
709 'csg_direction' => [
710 __('Sprite build direction', 'jch-optimize'),
711 __('Determine in which direction the images must be placed in sprite.', 'jch-optimize')
712 ],
713 'csg_wrap_images' => [
714 __('Wrap images', 'jch-optimize'),
715 sprintf(
716 __(
717 'Will wrap images in sprite into another row or column if the length of the sprite becomes longer than %s',
718 'jch-optimize'
719 ),
720 '2000px'
721 )
722 ],
723 'csg_exclude_images' => [
724 __('Exclude image from sprite', 'jch-optimize'),
725 __(
726 'You can exclude one or more of the images if they are displayed incorrectly.',
727 'jch-optimize'
728 )
729 ],
730 'csg_include_images' => [
731 __('Include additional images in sprite', 'jch-optimize'),
732 __(
733 'You can include additional images in the sprite to the ones that were selected by default. Use this option cautiously, as these files are likely to display incorrectly.',
734 'jch-optimize'
735 )
736 ]
737 ],
738 /**
739 * Lazy-Load Images
740 */
741 'lazyLoadSection' => [
742 'lazyload_enable' => [
743 __('Enable', 'jch-optimize'),
744 ],
745 'pro_lazyload_iframe' => [
746 __('Lazy load iframes', 'jch-optimize'),
747 sprintf(
748 __('If enabled will also lazyload %s elements.', 'jch-optimize'),
749 '&lt;iframe&gt;'
750 )
751 ],
752 'pro_lazyload_audiovideo' => [
753 __('Audio/Video', 'jch-optimize'),
754 sprintf(
755 __('Will lazyload %1$s and %2$s elements that are below the fold.', 'jch-optimize'),
756 '&lt;audio&gt;',
757 '&lt;video&gt;'
758 )
759 ],
760 'pro_lazyload_bgimages' => [
761 __('Background images', 'jch-optimize'),
762 __('Will lazyload background images.', 'jch-optimize')
763 ],
764 'excludeLazyLoad' => [
765 __('Exclude these images', 'jch-optimize'),
766 __(
767 'select or manually add the urls of the images you want to exclude from lazy load.',
768 'jch-optimize'
769 )
770 ],
771 'pro_excludeLazyLoadFolders' => [
772 __('Exclude these folders', 'jch-optimize'),
773 __('Exclude all the images in the selected folders.', 'jch-optimize')
774 ],
775 'pro_excludeLazyLoadClass' => [
776 __('Exclude these classes/id', 'jch-optimize'),
777 sprintf(
778 __(
779 'Exclude all images that has these classes or id declared on the %s element',
780 'jch-optimize'
781 ),
782 '&lt;img&gt;'
783 )
784 ],
785 'includeLazyLoad' => [
786 __('Include hidden images', 'jch-optimize'),
787 __(
788 'Add URLs to lazy load images above the fold that are hidden on page load, e.g, secondary images in sliders and submenu icons.',
789 'jch-optimize'
790 )
791 ],
792 'includeLazyLoadFolders' => [
793 __('Include by folders', 'jch-optimize'),
794 __('Lazy load all hidden images above the fold that are under these folders.', 'jch-optimize')
795 ],
796 'includeLazyLoadClass' => [
797 __('Include by class/id', 'jch-optimize'),
798 __(
799 'Lazy load all hidden images above the fold with the selected class or id on the &lt;img&gt; element.',
800 'jch-optimize'
801 )
802 ]
803 ]
804 ];
805 }
806
807 /**
808 * Settings on Http/2 tab
809 *
810 * @return array
811 */
812 public static function preloadsTab(): array
813 {
814 return [
815 /**
816 * Http2 Push
817 */
818 'http2PushSection' => [
819 'http2_push_enable' => [
820 __('Enable', 'jch-optimize'),
821 ],
822 'pro_http2_preload_modules' => [
823 __('Preload JavaScript modules', 'jch-optimize'),
824 __(
825 'You may see the alert \'Avoid chaining critical requests\' on PageSpeed and the list includes JavaScript modules. Enable this setting to preload these files and remove them from the critical rendering path.',
826 'jch-optimize'
827 )
828 ],
829 'pro_http2_file_types' => [
830 __('File types', 'jch-optimize'),
831 __('Select the file types you want pushed by http/2', 'jch-optimize')
832 ],
833 'pro_http2_include' => [
834 __('Include files', 'jch-optimize'),
835 __(
836 'Sometimes some files are dynamically loaded so you can add these files here. Be sure any file added here are loaded on all pages and that you include the full file path including any queries etc. Only the following file extensions are supported: .js, .css, .webp, .gif, .png, .jpg, .woff, .woff2',
837 'jch-optimize'
838 ),
839 false,
840 'jch-has-multiselect-with-options'
841 ],
842 'pro_http2_exclude' => [
843 __('Exclude files', 'jch-optimize'),
844 __(
845 'If you see any warnings in the browser console that the preloaded files weren\'t used within a few seconds you can exclude these files here',
846 'jch-optimize'
847 )
848 ]
849 ],
850 /**
851 * Largest Contentful Paint Images
852 */
853 'largestContentfulPaintSection' => [
854 'pro_lcp_images_enable' => [
855 __('Enable', 'jch-optimize')
856 ],
857 'pro_lcp_images' => [
858 __('LCP images', 'jch-optimize'),
859 __(
860 'Add your LCP images here to have them preloaded with a high priority on whichever page they appear.',
861 'jch-optimize'
862 )
863 ],
864 'pro_lcp_identifiers' => [
865 __('LCP id/class', 'jch-optimize'),
866 __(
867 'Add the id or class of your LCP images here. Ensure the class is only shared by other LCP images, you only need one per page.',
868 'jch-optimize'
869 )
870 ],
871 'lcp_images_mobile' => [
872 __('Mobile only', 'jch-optimize'),
873 __('Add images here that will only be preloaded on mobile.', 'jch-optimize')
874 ],
875 'lcp_images_desktop' => [
876 __('Desktop only', 'jch-optimize'),
877 __('Add images here that will only be preloaded on desktop.', 'jch-optimize')
878 ]
879 ],
880 /**
881 * Optimize Fonts
882 */
883 'optimizeFontsSection' => [
884 'pro_optimizeFonts_enable' => [
885 __('Enable', 'jch-optimize')
886 ],
887 'pro_force_swap_policy' => [
888 __('Force swap policy', 'jch-optimize'),
889 __(
890 'If font-display is already set in your @font-face content, the policy will be set to \'swap\'. This ensures your text are visible while the sites load and improve your PageSpeed scores.',
891 'jch-optimize'
892 )
893 ],
894 'pro_optimize_font_files' => [
895 __('Optimize these files', 'jch-optimize'),
896 __(
897 'If you have CSS files only containing @font-face content, or font files you want preloaded, you can add them here so they\'ll be optimized like the Google Font files. You may need to manually enter any external domain below to have them preconnected.',
898 'jch-optimize'
899 )
900 ],
901
902 ],
903 'preconnectThirdPartySection' => [
904 'pro_preconnect_domains_enable' => [
905 __('Enable', 'jch-optimize'),
906 ],
907 'pro_preconnect_domains' => [
908 __('Preconnect domains', 'jch-optimize'),
909 __(
910 'Add external domains you want preconnected here. Be sure to include the scheme also, eg., \'https://example.com\'.',
911 'jch-optimize'
912 ),
913 false,
914 'jch-has-multiselect-with-options'
915 ],
916 'dns_prefetch_domains' => [
917 __('DNS-Prefetch domains', 'jch-optimize'),
918 __(
919 'JCH Optimize will add \'dns-prefetch\' hints for the origins entered here so the browser can improve the user experience by preemptively performing DNS resolution for these origins.',
920 'jch-optimize'
921 )
922 ]
923 ]
924 ];
925 }
926
927 /**
928 * Settings on CDN tab
929 *
930 * @return array
931 */
932 public static function cdnTab(): array
933 {
934 return [
935 /**
936 * CDN
937 */
938 'cdnSection' => [
939 'cookielessdomain_enable' => [
940 __('Enable', 'jch-optimize'),
941 ],
942 'cdn_scheme' => [
943 __('CDN scheme', 'jch-optimize'),
944 __(
945 'Select the scheme that you want prepended to the CDN/Cookieless domain',
946 'jch-optimize'
947 )
948 ],
949 'cookielessdomain' => [
950 __('Domain 1', 'jch-optimize'),
951 __('Enter value for Domain #1 here', 'jch-optimize')
952 ],
953 'staticfiles' => [
954 __('Static files 1', 'jch-optimize'),
955 __(
956 'Select the static file types that you want to be loaded over Domain #1',
957 'jch-optimize'
958 )
959 ],
960 'pro_customcdnextensions' => [
961 __('Custom extensions 1', 'jch-optimize'),
962 __(
963 'To add custom extensions of file types to be loaded over CDN on Domain 1, type the extension in the textbox and press the \'Add item\' button',
964 'jch-optimize'
965 )
966 ],
967 'pro_cookielessdomain_2' => [
968 __('Domain 2', 'jch-optimize'),
969 __('Enter value for Domain #2 here', 'jch-optimize')
970 ],
971 'pro_staticfiles_2' => [
972 __('Static files 2', 'jch-optimize'),
973 __(
974 'Select the static file types that you want to be loaded over Domain #2',
975 'jch-optimize'
976 )
977 ],
978 'pro_cookielessdomain_3' => [
979 __('Domain 3', 'jch-optimize'),
980 __('Enter value for Domain #3 here', 'jch-optimize')
981 ],
982 'pro_staticfiles_3' => [
983 __('Static files 3', 'jch-optimize'),
984 __(
985 'Select the static file types that you want to be loaded over Domain #3',
986 'jch-optimize'
987 )
988 ]
989 ]
990 ];
991 }
992
993 /**
994 * Settings on Optimize Image tab
995 *
996 * @return array
997 */
998 public static function optimizeImage(): array
999 {
1000 return [
1001 /**
1002 * Global Section
1003 */
1004 'globalSection' => [
1005 'ignore_optimized' => [
1006 __('Ignore optimized images', 'jch-optimize'),
1007 __(
1008 'Will not attempt to optimize any images in subfolders that have already been marked as optimized.',
1009 'jch-optimize'
1010 )
1011 ],
1012 ],
1013 /**
1014 * Next Generation Images Section
1015 */
1016 'nextGenImages' => [
1017 'pro_next_gen_images' => [
1018 __('Generate WEBP images', 'jch-optimize'),
1019 __(
1020 'While optimizing images, the WEBP formats will also be generated if they are smaller.',
1021 'jch-optimize'
1022 )
1023 ],
1024 'gen_avif_images' => [
1025 __('Generate AVIF images', 'jch-optimize'),
1026 __(
1027 'While optimizing images, the AVIF formats will also be generated if they are smaller.',
1028 'jch-optimize'
1029 ),
1030 ],
1031 'load_avif_webp_images' => [
1032 __('Loads AVIF/WEBP images', 'jch-optimize'),
1033 __(
1034 'Load AVIF or WEBP images in place of the original formats if they were generated. If both exists, priority is given to the AVIF image.'
1035 )
1036 ],
1037 'pro_load_webp_images' => [
1038 __('Load WEBP images', 'jch-optimize'),
1039 __('Loads available WEBP images, if \'Loads AVIF/WEBP images\' is enabled.', 'jch-optimize')
1040 ],
1041 'load_avif_images' => [
1042 __('Load AVIF images', 'jch-optimize'),
1043 __('Loads available AVIF images, if \'Loads AVIF/WEBP images\' is enabled.', 'jch-optimize'),
1044 ]
1045 ],
1046
1047 /**
1048 * Responsive Images Section
1049 */
1050 'responsiveImages' => [
1051 'pro_gen_responsive_images' => [
1052 __('Generate responsive images', 'jch-optimize'),
1053 __(
1054 'While optimizing images, will also create different sized images to be used at different CSS breakpoints',
1055 'jch-optimize'
1056 )
1057 ],
1058 'pro_load_responsive_images' => [
1059 __('Load responsive images', 'jch-optimize'),
1060 __(
1061 'Use responsive images where available by adding srcset attributes on image elements and creating CSS breakpoints for background images.',
1062 'jch-optimize'
1063 )
1064 ],
1065 'cropgravity' => [
1066 __('Crop these images', 'jch-optimize'),
1067 __(
1068 'By default, the component will resize the mobile images preserving aspect ratio. In some cases, you may want to crop the image vertically instead. Add the names of the images you want cropped and set the crop position and width.',
1069 'jch-optimize'
1070 ),
1071 false,
1072 'jch-has-multiselect-with-options'
1073 ]
1074 ],
1075 /**
1076 * Optimization Configuration Section
1077 */
1078 'optimizationConfigurations' => [
1079 'lossy' => [
1080 __('Lossy optimization', 'jch-optimize'),
1081 __(
1082 'Levels are either Lossy or Lossless, the default is Lossy. With Lossy optimization images will be more optimized and smaller but may result in a small reduction of quality, most times invisible to the untrained eye. If you don\'t want that then you can choose Lossless instead. The images will not be as optimized but there will be no loss of quality.',
1083 'jch-optimize'
1084 )
1085 ],
1086 'save_metadata' => [
1087 __('Save metadata', 'jch-optimize'),
1088 __(
1089 'The Optimize Image API will remove all metadata from images while optimizing including any copyrights or Exif textual content not part of the actual image to produce the smallest possible file size. If you wish to retain this information at a small loss in optimization then you should enable this option.',
1090 'jch-optimize'
1091 )
1092 ]
1093 ],
1094 /**
1095 * Upload Settings Section
1096 */
1097 'uploadSettings' => [
1098 'pro_api_concurrency' => [
1099 __('File upload concurrency', 'jch-optimize'),
1100 __(
1101 'Image files are packaged and posted to the API server. The plugin will try to send packages concurrently. You can increase this to speed up the optimization process, if your server and network can accommodate it, or lower this number if your network is slow or having connection issues.',
1102 'jch-optimize'
1103 ),
1104 ],
1105 'pro_api_num_files' => [
1106 __('No. of files per package', 'jch-optimize'),
1107 __(
1108 'The plugin will package files based on your system\'s \'upload_max_filesize\' and \'max_file_uploads\' configuration values, but if uploads are timing out, you can limit the number per package. Leave blank or put 0 to have the plugin automatically calculate the package size for you.',
1109 'jch-optimize'
1110 ),
1111 ],
1112 'pro_api_max_size' => [
1113 __('Max file size', 'jch-optimize'),
1114 __('Maximum file size that would be uploaded. Eg., 3K, 2G, 5M. The default is 2M', 'jch-optimize'),
1115 ],
1116 'api_connection_timeout' => [
1117 __('Connection timeout', 'jch-optimize'),
1118 __(
1119 'Maximum time in seconds that the plugin will wait to get a response from the API server.',
1120 'jch-optimize'
1121 )
1122 ],
1123 ],
1124 /**
1125 * Automatically Optimize Section
1126 */
1127 'autoApiSection' => [
1128 'pro_api_resize_mode' => [
1129 __('Auto resize images', 'jch-optimize'),
1130 __(
1131 'Images will be resized automatically to the dimensions as shown on screen. If you use an application that shows the images larger when you hover over them be sure to use different images for the large ones. For this to work the url to your site must be available publicly.',
1132 'jch-optimize'
1133 )
1134 ]
1135 ],
1136 /**
1137 * Manually optimize Section
1138 */
1139 'manualApiSection' => [
1140 'recursive' => [
1141 __('Recurse in subfolders', 'jch-optimize'),
1142 __(
1143 'Will optimize all images in selected folders and recurse into subfolders infinitely. If disabled, only the images in the selected folders will be optimized. Subfolders will be ignored.',
1144 'jch-optimize'
1145 )
1146 ]
1147 ]
1148 ];
1149 }
1150
1151 /**
1152 * Settings on Miscellaneous tab
1153 *
1154 * @return array
1155 */
1156 public static function miscellaneous(): array
1157 {
1158 return [
1159 /**
1160 * Reduce Dom Section
1161 */
1162 'reduceDomSection' => [
1163 'pro_reduce_dom' => [
1164 __('Enable', 'jch-optimize')
1165 ],
1166 'pro_html_sections' => [
1167 __('HTML sections', 'jch-optimize'),
1168 __('Select which HTML sections you would like to load asynchronously.', 'jch-optimize')
1169 ],
1170 'reduce_dom_identifiers' => [
1171 __('DIV id/class', 'jch-optimize'),
1172 __(
1173 'Add the id or class of any &lt;div&gt; element you want to be lazy loaded.',
1174 'jch-optimize'
1175 )
1176 ],
1177 'reduce_dom_exclude_identifiers' => [
1178 __('Exclude id/class', 'jch-optimize'),
1179 __(
1180 'Add the id or class of any section you want to be excluded from the Reduce DOM feature',
1181 'jch-optimize'
1182 )
1183 ],
1184 'reduce_dom_above_fold_identifiers' => [
1185 __('Above fold id/class', 'jch-optimize'),
1186 __(
1187 'Use this setting to target HTML5 sections and DIVs that are hidden above the fold, for instance, submenus.',
1188 'jch-optimize'
1189 )
1190 ]
1191 ],
1192 /**
1193 * Mode Switcher
1194 */
1195 'modeSwitcherSection' => [
1196 'pro_disableModeSwitcher' => [
1197 __('Disable Mode Switcher', 'jch-optimize'),
1198 __(
1199 'If you don\'t want the Mode Switcher menu to be displayed you can disable it here.',
1200 'jch-optimize'
1201 )
1202 ]
1203 ]
1204 ];
1205 }
1206 }
1207