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 / Platform / Excludes.php

Excludes.php in JCH Optimize trunk, at src/Platform/Excludes.php

103 lines 2.1 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\Platform;
15
16 use JchOptimize\Core\Platform\ExcludesInterface;
17 use JchOptimize\Core\Platform\PathsInterface;
18
19 use function preg_match;
20
21 defined('_WP_EXEC') or die('Restricted access');
22
23 class Excludes implements ExcludesInterface
24 {
25 public function __construct(private PathsInterface $paths)
26 {
27 }
28
29 /**
30 * @param string $type
31 * @param string $section
32 *
33 * @return array
34 */
35 public function body(string $type, string $section = 'file'): array
36 {
37 if ($type == 'js') {
38 if ($section == 'script') {
39 return array();
40 } else {
41 return array('js.stripe.com');
42 }
43 }
44
45 if ($type == 'css') {
46 return array();
47 }
48
49 return[];
50 }
51
52 /**
53 *
54 * @return string
55 */
56 public function extensions(): string
57 {
58 return $this->paths->rewriteBaseFolder();
59 }
60
61 /**
62 * @param string $type
63 * @param string $section
64 *
65 * @return array
66 */
67 public function head(string $type, string $section = 'file'): array
68 {
69 if ($type == 'js') {
70 if ($section == 'script') {
71 return array();
72 } else {
73 return array('js.stripe.com');
74 }
75 }
76
77 if ($type == 'css') {
78 return array();
79 }
80
81 return [];
82 }
83
84 /**
85 * @param string $url
86 *
87 * @return bool
88 */
89 public function editors(string $url): bool
90 {
91 return (bool)preg_match('#/editors/#i', $url);
92 }
93
94 public function smartCombine(): array
95 {
96 return [
97 'wp-includes/',
98 'wp-content/themes/',
99 '.'
100 ];
101 }
102 }
103