PluginProbe
RabbitLoader / 3.2.0
RabbitLoader v3.2.0
4.0.2 4.0.1 4.0 3.2.0 3.1.1 3.1.0 3.0.5 3.0.3 3.0.4 2.17.1 2.17.2 2.17.3 2.17.4 2.17.5 2.17.6 2.17.7 2.18.0 2.18.1 2.18.2 2.18.3 2.18.4 2.18.5 2.18.6 2.18.7 2.18.8 All 129 releases
rabbit-loader / inc / tab_exclusions.php

tab_exclusions.php in RabbitLoader 3.2.0, at inc/tab_exclusions.php

158 lines 6.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if (class_exists('RabbitLoader_21_Tab_Exclusions')) {
4 #it seems we have a conflict
5 return;
6 }
7
8 class RabbitLoader_21_Tab_Exclusions extends RabbitLoader_21_Tab_Init
9 {
10
11 public static function init() {}
12
13 public static function echoMainContent()
14 {
15 $isConnected = self::isPluginActivated();
16
17 $urlparts = parse_url(home_url());
18 $domain = $urlparts['scheme'] . '://' . $urlparts['host'];
19 if (!empty($urlparts['port'])) {
20 $domain .= ':' . $urlparts['port'];
21 }
22
23
24 if ($isConnected) {
25 ?>
26 <div class="" style="max-width: 1160px; margin:40px auto;">
27 <?php
28 self::excludeUrls();
29 self::ignoreParams();
30 ?>
31 </div>
32 <?php
33 } ?>
34 <?php
35 }
36
37 private static function saveNotice()
38 {
39 if (RL21UtilWP::is_flywheel()) {
40 echo '<span class="d-block mt-2">', sprintf(RL21UtilWP::__('Flywheel Note: You need to Flush Cache manually from Flywheel dashboard after saving the settings <a href="%s">check details</a>'), "https://rabbitloader.com/kb/settings-for-flywheel/"), '</span>';
41 }
42 }
43 private static function excludeUrls()
44 {
45 //depreciated@2.14.0
46 RabbitLoader_21_Core::getWpOption($rl_wp_options);
47 if (empty($rl_wp_options['exclude_patterns'])) {
48 $rl_wp_options['exclude_patterns'] = '';
49 }
50 $exclude_patterns = $rl_wp_options['exclude_patterns'];
51
52 //introduced@2.14.0
53 RabbitLoader_21_Core::getWpUserOption($user_options);
54 $shouldMigrate = !empty($exclude_patterns) && empty($user_options['exclude_patterns']);
55 $userUpdating = isset($_POST['exclude_patterns']);
56 if ($userUpdating || $shouldMigrate) {
57 if ($userUpdating) {
58 $user_options['exclude_patterns'] = sanitize_textarea_field($_POST['exclude_patterns']);
59 RL21UtilWP::onPostChange(RL21UtilWP::POST_ID_ALL);
60 } else {
61 $user_options['exclude_patterns'] = $exclude_patterns;
62 }
63 RabbitLoader_21_Core::updateUserOption($user_options);
64 }
65 $exclude_patterns = $user_options['exclude_patterns'];
66
67 ?>
68 <div class="row mb-4">
69 <div class="col">
70 <div class="rl-mfe-card">
71 <div class="row">
72 <div class="col-sm-12 col-md-8 text-secondary">
73 <h5 class="mt-0">Exclude URLs</h5>
74 <span>Add URLs below to exclude them from optimization. Matching URLs will be skipped by RabbitLoader.</span>
75 <div class="mt-4">
76 <form method="post">
77 <textarea class="form-control" rows="5" placeholder="e.g. /path/* without domain name" name="exclude_patterns"><?php echo $exclude_patterns; ?></textarea>
78 <button type="submit" class="rl-mfe-btn mt-2">Save</button>
79 </form>
80 <?php
81 self::saveNotice();
82 ?>
83 </div>
84 </div>
85 <div class="col-sm-12 col-md-4">
86 <h5 class="mt-0">Guidelines</h5>
87 <ul class="" style="list-style:circle;">
88 <li>If the request URL matches the given <b>shell wildcard pattern</b>, it will not be optimized.</li>
89 <li>You can put one pattern per line</li>
90 <li>A wildcard character (*) can be used in the pattern. For example, /category/* will exclude all URLs starting with /category/.</li>
91 <li><a target="_blank" href="https://rabbitloader.com/kb/exclude-urls-from-cached/" title="Excluding URLs from being cached">Read documentation</a>
92 </ul>
93 </div>
94 </div>
95 </div>
96 </div>
97 </div>
98 <?php
99 }
100
101 private static function ignoreParams()
102 {
103 //depreciated@2.14.0
104 RabbitLoader_21_Core::getWpOption($rl_wp_options);
105 if (empty($rl_wp_options['ignore_params'])) {
106 $rl_wp_options['ignore_params'] = '';
107 }
108 $ignore_params = $rl_wp_options['ignore_params'];
109
110 //introduced@2.14.0
111 RabbitLoader_21_Core::getWpUserOption($user_options);
112 $shouldMigrate = !empty($ignore_params) && empty($user_options['ignore_params']);
113 $userUpdating = isset($_POST['ignore_params']);
114 if ($userUpdating || $shouldMigrate) {
115 if ($userUpdating) {
116 $user_options['ignore_params'] = sanitize_textarea_field($_POST['ignore_params']);
117 } else {
118 $user_options['ignore_params'] = $ignore_params;
119 }
120 RabbitLoader_21_Core::updateUserOption($user_options);
121 }
122 $ignore_params = $user_options['ignore_params'];
123 ?>
124 <div class="row mb-4">
125 <div class="col">
126 <div class="rl-mfe-card">
127 <div class="row">
128 <div class="col-sm-12 col-md-8 text-secondary">
129 <h5 class="mt-0">Ignore Parameters</h5>
130 <span>Query/GET parameters mentioned below will be ignored when creating cached copy of a page.</span>
131 <div class="mt-4">
132 <form method="post">
133 <textarea class="form-control" rows="5" placeholder="e.g. fbclid" name="ignore_params"><?php echo $ignore_params; ?></textarea>
134 <button type="submit" class="rl-mfe-btn mt-2">Save</button>
135 </form>
136 <?php
137 self::saveNotice();
138 ?>
139 </div>
140 </div>
141 <div class="col-sm-12 col-md-4">
142 <h5 class="mt-0">Guidelines</h5>
143 <ul class="" style="list-style:circle;">
144 <li>You can put one parameter per line.</li>
145 <li>Parameter name should be without any special characters such as &amp;, ?or =.</li>
146 <li>Regex or shell wildcard pattern can not be used here.</li>
147 <li>Many popular params are ignored by default, <a target="_blank" href="https://rabbitloader.com/kb/ignori-url-parameters-caching/" title="Ignoring URL parameters from caching key">read documentation</a>
148 </ul>
149 </div>
150 </div>
151 </div>
152 </div>
153 </div>
154 <?php
155 }
156 }
157
158 ?>