Version Description
Download this release
Release Info
Developer | paultgoodchild |
Plugin | Shield Security for WordPress |
Version | 12.0.13 |
Comparing to | |
See all releases |
Code changes from version 12.0.12 to 12.0.13
- cl.json +6 -0
- icwp-wpsf.php +1 -1
- plugin-spec.php +3 -3
- plugin.json +3 -3
- readme.txt +1 -1
- src/lib/src/Modules/Autoupdates/Options.php +9 -34
- src/lib/src/Modules/Autoupdates/Processor.php +131 -132
- src/lib/src/Modules/Lockdown/Processor.php +2 -2
- src/lib/src/Modules/Sessions/Processor.php +18 -9
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Base/RepoBase.php +75 -75
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Cp/Repo.php +76 -76
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Plugin/Repo.php +65 -65
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Theme/Files.php +122 -122
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Theme/Repo.php +58 -58
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Wp/Repo.php +71 -71
cl.json
CHANGED
@@ -158,6 +158,12 @@
|
|
158 |
"title": "Issue with managing Shield Central profiles.",
|
159 |
"description": [],
|
160 |
"patch": "12.0.11"
|
|
|
|
|
|
|
|
|
|
|
|
|
161 |
}
|
162 |
]
|
163 |
},
|
158 |
"title": "Issue with managing Shield Central profiles.",
|
159 |
"description": [],
|
160 |
"patch": "12.0.11"
|
161 |
+
},
|
162 |
+
{
|
163 |
+
"type": "improved",
|
164 |
+
"title": "Improve support for auto-login systems like ManageWP admin login.",
|
165 |
+
"description": [],
|
166 |
+
"patch": "12.0.13"
|
167 |
}
|
168 |
]
|
169 |
},
|
icwp-wpsf.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: Shield Security
|
4 |
* Plugin URI: https://shsec.io/2f
|
5 |
* Description: Powerful, Easy-To-Use #1 Rated WordPress Security System
|
6 |
-
* Version: 12.0.
|
7 |
* Text Domain: wp-simple-firewall
|
8 |
* Domain Path: /languages
|
9 |
* Author: Shield Security
|
3 |
* Plugin Name: Shield Security
|
4 |
* Plugin URI: https://shsec.io/2f
|
5 |
* Description: Powerful, Easy-To-Use #1 Rated WordPress Security System
|
6 |
+
* Version: 12.0.13
|
7 |
* Text Domain: wp-simple-firewall
|
8 |
* Domain Path: /languages
|
9 |
* Author: Shield Security
|
plugin-spec.php
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
{
|
2 |
"properties": {
|
3 |
-
"version": "12.0.
|
4 |
-
"release_timestamp":
|
5 |
-
"build": "202110.
|
6 |
"slug_parent": "icwp",
|
7 |
"slug_plugin": "wpsf",
|
8 |
"human_name": "Shield Security",
|
1 |
{
|
2 |
"properties": {
|
3 |
+
"version": "12.0.13",
|
4 |
+
"release_timestamp": 1633856080,
|
5 |
+
"build": "202110.1001",
|
6 |
"slug_parent": "icwp",
|
7 |
"slug_plugin": "wpsf",
|
8 |
"human_name": "Shield Security",
|
plugin.json
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
{
|
2 |
"properties": {
|
3 |
-
"version": "12.0.
|
4 |
-
"release_timestamp":
|
5 |
-
"build": "202110.
|
6 |
"slug_parent": "icwp",
|
7 |
"slug_plugin": "wpsf",
|
8 |
"human_name": "Shield Security",
|
1 |
{
|
2 |
"properties": {
|
3 |
+
"version": "12.0.13",
|
4 |
+
"release_timestamp": 1633856080,
|
5 |
+
"build": "202110.1001",
|
6 |
"slug_parent": "icwp",
|
7 |
"slug_plugin": "wpsf",
|
8 |
"human_name": "Shield Security",
|
readme.txt
CHANGED
@@ -8,7 +8,7 @@ Requires at least: 3.7
|
|
8 |
Requires PHP: 7.0
|
9 |
Recommended PHP: 7.4
|
10 |
Tested up to: 5.8
|
11 |
-
Stable tag: 12.0.
|
12 |
|
13 |
No-Nonsense Security Hardening that protects WordPress against hackers, malicious bots, and spammers (no captchas!). Now with exclusive ShieldNET Technology.
|
14 |
|
8 |
Requires PHP: 7.0
|
9 |
Recommended PHP: 7.4
|
10 |
Tested up to: 5.8
|
11 |
+
Stable tag: 12.0.13
|
12 |
|
13 |
No-Nonsense Security Hardening that protects WordPress against hackers, malicious bots, and spammers (no captchas!). Now with exclusive ShieldNET Technology.
|
14 |
|
src/lib/src/Modules/Autoupdates/Options.php
CHANGED
@@ -42,60 +42,35 @@ class Options extends BaseShield\Options {
|
|
42 |
return $this->getOpt( 'autoupdate_plugin_self' );
|
43 |
}
|
44 |
|
45 |
-
|
46 |
-
* @return bool
|
47 |
-
*/
|
48 |
-
public function isAutoUpdateCoreNever() {
|
49 |
return $this->isOpt( 'autoupdate_core', 'core_never' );
|
50 |
}
|
51 |
|
52 |
-
|
53 |
-
* @return bool
|
54 |
-
*/
|
55 |
-
public function isAutoUpdateCoreMajor() {
|
56 |
return $this->isOpt( 'autoupdate_core', 'core_major' );
|
57 |
}
|
58 |
|
59 |
-
|
60 |
-
* @return bool
|
61 |
-
*/
|
62 |
-
public function isAutoUpdateCoreMinor() {
|
63 |
-
return !$this->isAutoUpdateCoreNever();
|
64 |
-
}
|
65 |
-
|
66 |
-
/**
|
67 |
-
* @return bool
|
68 |
-
*/
|
69 |
-
public function isAutoupdateAllPlugins() {
|
70 |
return $this->isOpt( 'enable_autoupdate_plugins', 'Y' );
|
71 |
}
|
72 |
|
73 |
-
|
74 |
-
* @return bool
|
75 |
-
*/
|
76 |
-
public function isDisableAllAutoUpdates() {
|
77 |
return $this->isOpt( 'enable_autoupdate_disable_all', 'Y' );
|
78 |
}
|
79 |
|
80 |
-
|
81 |
-
* @return bool
|
82 |
-
*/
|
83 |
-
public function isDelayUpdates() {
|
84 |
return $this->getDelayUpdatesPeriod() > 0;
|
85 |
}
|
86 |
|
87 |
-
|
88 |
-
* @return bool
|
89 |
-
*/
|
90 |
-
public function isSendAutoupdatesNotificationEmail() {
|
91 |
return $this->isOpt( 'enable_upgrade_notification_email', 'Y' );
|
92 |
}
|
93 |
|
94 |
/**
|
95 |
-
* @param array $
|
96 |
* @return $this
|
97 |
*/
|
98 |
-
public function setDelayTracking( $
|
99 |
-
return $this->setOpt( 'delay_tracking', $
|
100 |
}
|
101 |
}
|
42 |
return $this->getOpt( 'autoupdate_plugin_self' );
|
43 |
}
|
44 |
|
45 |
+
public function isAutoUpdateCoreNever() :bool {
|
|
|
|
|
|
|
46 |
return $this->isOpt( 'autoupdate_core', 'core_never' );
|
47 |
}
|
48 |
|
49 |
+
public function isAutoUpdateCoreMajor() :bool {
|
|
|
|
|
|
|
50 |
return $this->isOpt( 'autoupdate_core', 'core_major' );
|
51 |
}
|
52 |
|
53 |
+
public function isAutoupdateAllPlugins() :bool {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
return $this->isOpt( 'enable_autoupdate_plugins', 'Y' );
|
55 |
}
|
56 |
|
57 |
+
public function isDisableAllAutoUpdates() :bool {
|
|
|
|
|
|
|
58 |
return $this->isOpt( 'enable_autoupdate_disable_all', 'Y' );
|
59 |
}
|
60 |
|
61 |
+
public function isDelayUpdates() :bool {
|
|
|
|
|
|
|
62 |
return $this->getDelayUpdatesPeriod() > 0;
|
63 |
}
|
64 |
|
65 |
+
public function isSendAutoupdatesNotificationEmail() :bool {
|
|
|
|
|
|
|
66 |
return $this->isOpt( 'enable_upgrade_notification_email', 'Y' );
|
67 |
}
|
68 |
|
69 |
/**
|
70 |
+
* @param array $trackingInfo
|
71 |
* @return $this
|
72 |
*/
|
73 |
+
public function setDelayTracking( $trackingInfo ) {
|
74 |
+
return $this->setOpt( 'delay_tracking', $trackingInfo );
|
75 |
}
|
76 |
}
|
src/lib/src/Modules/Autoupdates/Processor.php
CHANGED
@@ -17,34 +17,34 @@ class Processor extends BaseShield\Processor {
|
|
17 |
* filter. What this filter decides will ultimately determine the fate of any core upgrade.
|
18 |
*/
|
19 |
protected function run() {
|
20 |
-
/** @var Options $
|
21 |
-
$
|
22 |
|
23 |
-
$
|
24 |
if ( Services::WpGeneral()->isClassicPress() ) {
|
25 |
-
add_filter( 'allow_patch_auto_core_updates', [ $this, 'autoupdate_core_minor' ], $
|
26 |
-
add_filter( 'allow_minor_auto_core_updates', [ $this, 'autoupdate_core_major' ], $
|
27 |
}
|
28 |
else {
|
29 |
-
add_filter( 'allow_minor_auto_core_updates', [ $this, 'autoupdate_core_minor' ], $
|
30 |
-
add_filter( 'allow_major_auto_core_updates', [ $this, 'autoupdate_core_major' ], $
|
31 |
}
|
32 |
|
33 |
-
add_filter( 'auto_update_plugin', [ $this, 'autoupdate_plugins' ], $
|
34 |
-
add_filter( 'auto_update_theme', [ $this, 'autoupdate_themes' ], $
|
35 |
-
add_filter( 'auto_update_core', [ $this, 'autoupdate_core' ], $
|
36 |
|
37 |
-
if ( !$
|
38 |
//more parameter options here for later
|
39 |
-
add_filter( 'auto_core_update_send_email', [ $this, 'autoupdate_send_email' ], $
|
40 |
-
add_filter( 'auto_core_update_email', [ $this, 'autoupdate_email_override' ], $
|
41 |
-
add_filter( 'auto_plugin_theme_update_email', [ $this, 'autoupdate_email_override' ], $
|
42 |
|
43 |
add_action( 'set_site_transient_update_core', [ $this, 'trackUpdateTimesCore' ] );
|
44 |
add_action( 'set_site_transient_update_plugins', [ $this, 'trackUpdateTimesPlugins' ] );
|
45 |
add_action( 'set_site_transient_update_themes', [ $this, 'trackUpdateTimesThemes' ] );
|
46 |
|
47 |
-
if ( $
|
48 |
&& !Services::WpGeneral()->getWordpressIsAtLeastVersion( '5.5' ) ) {
|
49 |
$this->trackAssetsVersions();
|
50 |
add_action( 'automatic_updates_complete', [ $this, 'sendNotificationEmail' ] );
|
@@ -98,11 +98,11 @@ class Processor extends BaseShield\Processor {
|
|
98 |
public function trackUpdateTimesCore( $oUpdates ) {
|
99 |
|
100 |
if ( !empty( $oUpdates ) && isset( $oUpdates->updates ) && is_array( $oUpdates->updates ) ) {
|
101 |
-
/** @var Options $
|
102 |
-
$
|
103 |
|
104 |
-
$
|
105 |
-
$aItemTk =
|
106 |
foreach ( $oUpdates->updates as $oUpdate ) {
|
107 |
if ( 'autoupdate' == $oUpdate->response ) {
|
108 |
$sVersion = $oUpdate->current;
|
@@ -111,219 +111,218 @@ class Processor extends BaseShield\Processor {
|
|
111 |
}
|
112 |
}
|
113 |
}
|
114 |
-
$
|
115 |
-
$
|
116 |
}
|
117 |
}
|
118 |
|
119 |
/**
|
120 |
-
* @param \stdClass $
|
121 |
*/
|
122 |
-
public function trackUpdateTimesPlugins( $
|
123 |
-
$this->trackUpdateTimeCommon( $
|
124 |
}
|
125 |
|
126 |
/**
|
127 |
-
* @param \stdClass $
|
128 |
*/
|
129 |
-
public function trackUpdateTimesThemes( $
|
130 |
-
$this->trackUpdateTimeCommon( $
|
131 |
}
|
132 |
|
133 |
/**
|
134 |
-
* @param \stdClass $
|
135 |
-
* @param string $
|
136 |
*/
|
137 |
-
protected function trackUpdateTimeCommon( $
|
138 |
-
/** @var Options $
|
139 |
-
$
|
140 |
|
141 |
-
if ( !empty( $
|
142 |
|
143 |
-
$
|
144 |
-
foreach ( $
|
145 |
-
$
|
146 |
-
if ( is_array( $
|
147 |
-
$
|
148 |
}
|
149 |
|
150 |
-
$
|
151 |
-
if ( !empty( $
|
152 |
-
if ( !isset( $
|
153 |
-
$
|
154 |
}
|
155 |
-
$
|
156 |
}
|
157 |
}
|
158 |
-
$
|
159 |
}
|
160 |
}
|
161 |
|
162 |
/**
|
163 |
* This is a filter method designed to say whether a major core WordPress upgrade should be permitted,
|
164 |
* based on the plugin settings.
|
165 |
-
* @param bool $
|
166 |
* @return bool
|
167 |
*/
|
168 |
-
public function autoupdate_core_major( $
|
169 |
-
/** @var Options $
|
170 |
-
$
|
171 |
|
172 |
-
if ( $
|
173 |
-
$
|
174 |
}
|
175 |
-
elseif ( !$
|
176 |
-
$
|
177 |
}
|
178 |
|
179 |
-
return $
|
180 |
}
|
181 |
|
182 |
/**
|
183 |
* This is a filter method designed to say whether a minor core WordPress upgrade should be permitted,
|
184 |
* based on the plugin settings.
|
185 |
-
* @param bool $
|
186 |
* @return bool
|
187 |
*/
|
188 |
-
public function autoupdate_core_minor( $
|
189 |
-
/** @var Options $
|
190 |
-
$
|
191 |
|
192 |
-
if ( $
|
193 |
-
$
|
194 |
}
|
195 |
-
elseif ( !$
|
196 |
-
$
|
197 |
}
|
198 |
-
return $
|
199 |
}
|
200 |
|
201 |
/**
|
202 |
-
* @param bool $
|
203 |
-
* @param \stdClass $
|
204 |
* @return bool
|
205 |
*/
|
206 |
-
public function autoupdate_core( $
|
207 |
-
/** @var Options $
|
208 |
-
$
|
209 |
|
210 |
-
if ( $
|
211 |
-
$
|
212 |
}
|
213 |
-
elseif ( $this->isDelayed( $
|
214 |
-
$
|
215 |
}
|
216 |
|
217 |
-
return $
|
218 |
}
|
219 |
|
220 |
/**
|
221 |
-
* @param bool $
|
222 |
* @param \stdClass|string $mItem
|
223 |
* @return bool
|
224 |
*/
|
225 |
-
public function autoupdate_plugins( $
|
226 |
-
/** @var Options $
|
227 |
-
$
|
228 |
|
229 |
-
if ( $
|
230 |
-
$
|
231 |
}
|
232 |
else {
|
233 |
$file = Services::WpGeneral()->getFileFromAutomaticUpdateItem( $mItem );
|
234 |
|
235 |
if ( $this->isDelayed( $file, 'plugins' ) ) {
|
236 |
-
$
|
237 |
}
|
238 |
-
elseif ( $
|
239 |
-
$
|
240 |
}
|
241 |
elseif ( $file === $this->getCon()->base_file ) {
|
242 |
-
$
|
243 |
-
if ( $
|
244 |
-
$
|
245 |
}
|
246 |
-
elseif ( $
|
247 |
-
$
|
248 |
}
|
249 |
}
|
250 |
}
|
251 |
|
252 |
-
return $
|
253 |
}
|
254 |
|
255 |
/**
|
256 |
-
* @param bool $
|
257 |
* @param \stdClass|string $mItem
|
258 |
* @return bool
|
259 |
*/
|
260 |
-
public function autoupdate_themes( $
|
261 |
/** @var Options $opts */
|
262 |
$opts = $this->getOptions();
|
263 |
|
264 |
if ( $opts->isDisableAllAutoUpdates() ) {
|
265 |
-
$
|
266 |
}
|
267 |
else {
|
268 |
$file = Services::WpGeneral()->getFileFromAutomaticUpdateItem( $mItem, 'theme' );
|
269 |
|
270 |
if ( $this->isDelayed( $file, 'themes' ) ) {
|
271 |
-
$
|
272 |
}
|
273 |
elseif ( $opts->isOpt( 'enable_autoupdate_themes', 'Y' ) ) {
|
274 |
-
$
|
275 |
}
|
276 |
}
|
277 |
|
278 |
-
return $
|
279 |
}
|
280 |
|
281 |
/**
|
282 |
-
* @param string|\stdClass $
|
283 |
-
* @param string $
|
284 |
-
* @return bool
|
285 |
*/
|
286 |
-
private function isDelayed( $
|
287 |
-
/** @var Options $
|
288 |
-
$
|
289 |
|
290 |
-
$
|
291 |
|
292 |
-
if ( $
|
293 |
|
294 |
-
$
|
295 |
|
296 |
-
$
|
297 |
-
if ( $
|
298 |
-
$
|
299 |
-
$
|
300 |
}
|
301 |
|
302 |
-
$
|
303 |
|
304 |
-
if ( $
|
305 |
-
$
|
306 |
-
$
|
307 |
}
|
308 |
-
elseif ( $
|
309 |
-
$
|
310 |
-
$
|
311 |
}
|
312 |
|
313 |
-
if ( !empty( $
|
314 |
-
$
|
315 |
}
|
316 |
}
|
317 |
|
318 |
-
return $
|
319 |
}
|
320 |
|
321 |
/**
|
322 |
-
* A filter on whether
|
323 |
-
* @param bool $
|
324 |
* @return bool
|
325 |
*/
|
326 |
-
public function autoupdate_send_email( $
|
327 |
/** @var Options $opts */
|
328 |
$opts = $this->getOptions();
|
329 |
return $opts->isSendAutoupdatesNotificationEmail();
|
@@ -331,15 +330,15 @@ class Processor extends BaseShield\Processor {
|
|
331 |
|
332 |
/**
|
333 |
* A filter on the target email address to which to send upgrade notification emails.
|
334 |
-
* @param array $
|
335 |
* @return array
|
336 |
*/
|
337 |
-
public function autoupdate_email_override( $
|
338 |
-
$
|
339 |
-
if ( Services::Data()->validEmail( $
|
340 |
-
$
|
341 |
}
|
342 |
-
return $
|
343 |
}
|
344 |
|
345 |
/**
|
@@ -361,16 +360,16 @@ class Processor extends BaseShield\Processor {
|
|
361 |
''
|
362 |
];
|
363 |
|
364 |
-
$
|
365 |
|
366 |
-
$
|
367 |
if ( !empty( $aUpdateResults[ 'plugin' ] ) && is_array( $aUpdateResults[ 'plugin' ] ) ) {
|
368 |
$bHasPluginUpdates = false;
|
369 |
-
$aTrkdPlugs = $
|
370 |
|
371 |
$aTempContent[] = __( 'Plugins Updated:', 'wp-simple-firewall' );
|
372 |
foreach ( $aUpdateResults[ 'plugin' ] as $oUpdate ) {
|
373 |
-
$oP = $
|
374 |
$bValidUpdate = !empty( $oUpdate->result ) && !empty( $oUpdate->name )
|
375 |
&& isset( $aTrkdPlugs[ $oP->file ] )
|
376 |
&& version_compare( $aTrkdPlugs[ $oP->file ], $oP->Version, '<' );
|
@@ -391,7 +390,7 @@ class Processor extends BaseShield\Processor {
|
|
391 |
|
392 |
if ( !empty( $aUpdateResults[ 'theme' ] ) && is_array( $aUpdateResults[ 'theme' ] ) ) {
|
393 |
$bHasThemesUpdates = false;
|
394 |
-
$aTrkdThemes = $
|
395 |
|
396 |
$aTempContent = [ __( 'Themes Updated:', 'wp-simple-firewall' ) ];
|
397 |
foreach ( $aUpdateResults[ 'theme' ] as $oUpdate ) {
|
@@ -440,9 +439,9 @@ class Processor extends BaseShield\Processor {
|
|
440 |
$this->getMod()
|
441 |
->getEmailProcessor()
|
442 |
->sendEmailWithWrap(
|
443 |
-
|
444 |
sprintf( __( "Notice: %s", 'wp-simple-firewall' ), __( "Automatic Updates Completed", 'wp-simple-firewall' ) ),
|
445 |
-
|
446 |
);
|
447 |
die();
|
448 |
}
|
17 |
* filter. What this filter decides will ultimately determine the fate of any core upgrade.
|
18 |
*/
|
19 |
protected function run() {
|
20 |
+
/** @var Options $opts */
|
21 |
+
$opts = $this->getOptions();
|
22 |
|
23 |
+
$priority = $this->getHookPriority();
|
24 |
if ( Services::WpGeneral()->isClassicPress() ) {
|
25 |
+
add_filter( 'allow_patch_auto_core_updates', [ $this, 'autoupdate_core_minor' ], $priority );
|
26 |
+
add_filter( 'allow_minor_auto_core_updates', [ $this, 'autoupdate_core_major' ], $priority );
|
27 |
}
|
28 |
else {
|
29 |
+
add_filter( 'allow_minor_auto_core_updates', [ $this, 'autoupdate_core_minor' ], $priority );
|
30 |
+
add_filter( 'allow_major_auto_core_updates', [ $this, 'autoupdate_core_major' ], $priority );
|
31 |
}
|
32 |
|
33 |
+
add_filter( 'auto_update_plugin', [ $this, 'autoupdate_plugins' ], $priority, 2 );
|
34 |
+
add_filter( 'auto_update_theme', [ $this, 'autoupdate_themes' ], $priority, 2 );
|
35 |
+
add_filter( 'auto_update_core', [ $this, 'autoupdate_core' ], $priority, 2 );
|
36 |
|
37 |
+
if ( !$opts->isDisableAllAutoUpdates() ) {
|
38 |
//more parameter options here for later
|
39 |
+
add_filter( 'auto_core_update_send_email', [ $this, 'autoupdate_send_email' ], $priority, 1 );
|
40 |
+
add_filter( 'auto_core_update_email', [ $this, 'autoupdate_email_override' ], $priority, 1 );
|
41 |
+
add_filter( 'auto_plugin_theme_update_email', [ $this, 'autoupdate_email_override' ], $priority, 1 );
|
42 |
|
43 |
add_action( 'set_site_transient_update_core', [ $this, 'trackUpdateTimesCore' ] );
|
44 |
add_action( 'set_site_transient_update_plugins', [ $this, 'trackUpdateTimesPlugins' ] );
|
45 |
add_action( 'set_site_transient_update_themes', [ $this, 'trackUpdateTimesThemes' ] );
|
46 |
|
47 |
+
if ( $opts->isSendAutoupdatesNotificationEmail()
|
48 |
&& !Services::WpGeneral()->getWordpressIsAtLeastVersion( '5.5' ) ) {
|
49 |
$this->trackAssetsVersions();
|
50 |
add_action( 'automatic_updates_complete', [ $this, 'sendNotificationEmail' ] );
|
98 |
public function trackUpdateTimesCore( $oUpdates ) {
|
99 |
|
100 |
if ( !empty( $oUpdates ) && isset( $oUpdates->updates ) && is_array( $oUpdates->updates ) ) {
|
101 |
+
/** @var Options $opts */
|
102 |
+
$opts = $this->getOptions();
|
103 |
|
104 |
+
$delayTracking = $opts->getDelayTracking();
|
105 |
+
$aItemTk = $delayTracking[ 'core' ][ 'wp' ] ?? [];
|
106 |
foreach ( $oUpdates->updates as $oUpdate ) {
|
107 |
if ( 'autoupdate' == $oUpdate->response ) {
|
108 |
$sVersion = $oUpdate->current;
|
111 |
}
|
112 |
}
|
113 |
}
|
114 |
+
$delayTracking[ 'core' ][ 'wp' ] = array_slice( $aItemTk, -5 );
|
115 |
+
$opts->setDelayTracking( $delayTracking );
|
116 |
}
|
117 |
}
|
118 |
|
119 |
/**
|
120 |
+
* @param \stdClass $updates
|
121 |
*/
|
122 |
+
public function trackUpdateTimesPlugins( $updates ) {
|
123 |
+
$this->trackUpdateTimeCommon( $updates, 'plugins' );
|
124 |
}
|
125 |
|
126 |
/**
|
127 |
+
* @param \stdClass $updates
|
128 |
*/
|
129 |
+
public function trackUpdateTimesThemes( $updates ) {
|
130 |
+
$this->trackUpdateTimeCommon( $updates, 'themes' );
|
131 |
}
|
132 |
|
133 |
/**
|
134 |
+
* @param \stdClass $updates
|
135 |
+
* @param string $context - plugins/themes
|
136 |
*/
|
137 |
+
protected function trackUpdateTimeCommon( $updates, $context ) {
|
138 |
+
/** @var Options $opts */
|
139 |
+
$opts = $this->getOptions();
|
140 |
|
141 |
+
if ( !empty( $updates ) && isset( $updates->response ) && is_array( $updates->response ) ) {
|
142 |
|
143 |
+
$delayTracking = $opts->getDelayTracking();
|
144 |
+
foreach ( $updates->response as $slug => $theUpdate ) {
|
145 |
+
$itemTrack = $delayTracking[ $context ][ $slug ] ?? [];
|
146 |
+
if ( is_array( $theUpdate ) ) {
|
147 |
+
$theUpdate = (object)$theUpdate;
|
148 |
}
|
149 |
|
150 |
+
$newVersion = $theUpdate->new_version ?? '';
|
151 |
+
if ( !empty( $newVersion ) ) {
|
152 |
+
if ( !isset( $itemTrack[ $newVersion ] ) ) {
|
153 |
+
$itemTrack[ $newVersion ] = Services::Request()->ts();
|
154 |
}
|
155 |
+
$delayTracking[ $context ][ $slug ] = array_slice( $itemTrack, -3 );
|
156 |
}
|
157 |
}
|
158 |
+
$opts->setDelayTracking( $delayTracking );
|
159 |
}
|
160 |
}
|
161 |
|
162 |
/**
|
163 |
* This is a filter method designed to say whether a major core WordPress upgrade should be permitted,
|
164 |
* based on the plugin settings.
|
165 |
+
* @param bool $toUpdate
|
166 |
* @return bool
|
167 |
*/
|
168 |
+
public function autoupdate_core_major( $toUpdate ) {
|
169 |
+
/** @var Options $opts */
|
170 |
+
$opts = $this->getOptions();
|
171 |
|
172 |
+
if ( $opts->isDisableAllAutoUpdates() || $opts->isAutoUpdateCoreNever() ) {
|
173 |
+
$toUpdate = false;
|
174 |
}
|
175 |
+
elseif ( !$opts->isDelayUpdates() ) { // delay handled elsewhere
|
176 |
+
$toUpdate = $opts->isAutoUpdateCoreMajor();
|
177 |
}
|
178 |
|
179 |
+
return $toUpdate;
|
180 |
}
|
181 |
|
182 |
/**
|
183 |
* This is a filter method designed to say whether a minor core WordPress upgrade should be permitted,
|
184 |
* based on the plugin settings.
|
185 |
+
* @param bool $toUpdate
|
186 |
* @return bool
|
187 |
*/
|
188 |
+
public function autoupdate_core_minor( $toUpdate ) {
|
189 |
+
/** @var Options $opts */
|
190 |
+
$opts = $this->getOptions();
|
191 |
|
192 |
+
if ( $opts->isDisableAllAutoUpdates() || $opts->isAutoUpdateCoreNever() ) {
|
193 |
+
$toUpdate = false;
|
194 |
}
|
195 |
+
elseif ( !$opts->isDelayUpdates() ) {
|
196 |
+
$toUpdate = !$opts->isAutoUpdateCoreNever();
|
197 |
}
|
198 |
+
return $toUpdate;
|
199 |
}
|
200 |
|
201 |
/**
|
202 |
+
* @param bool $isDoUpdate
|
203 |
+
* @param \stdClass $coreUpgrade
|
204 |
* @return bool
|
205 |
*/
|
206 |
+
public function autoupdate_core( $isDoUpdate, $coreUpgrade ) {
|
207 |
+
/** @var Options $opts */
|
208 |
+
$opts = $this->getOptions();
|
209 |
|
210 |
+
if ( $opts->isDisableAllAutoUpdates() ) {
|
211 |
+
$isDoUpdate = false;
|
212 |
}
|
213 |
+
elseif ( $this->isDelayed( $coreUpgrade, 'core' ) ) {
|
214 |
+
$isDoUpdate = false;
|
215 |
}
|
216 |
|
217 |
+
return $isDoUpdate;
|
218 |
}
|
219 |
|
220 |
/**
|
221 |
+
* @param bool $doUpdate
|
222 |
* @param \stdClass|string $mItem
|
223 |
* @return bool
|
224 |
*/
|
225 |
+
public function autoupdate_plugins( $doUpdate, $mItem ) {
|
226 |
+
/** @var Options $opts */
|
227 |
+
$opts = $this->getOptions();
|
228 |
|
229 |
+
if ( $opts->isDisableAllAutoUpdates() ) {
|
230 |
+
$doUpdate = false;
|
231 |
}
|
232 |
else {
|
233 |
$file = Services::WpGeneral()->getFileFromAutomaticUpdateItem( $mItem );
|
234 |
|
235 |
if ( $this->isDelayed( $file, 'plugins' ) ) {
|
236 |
+
$doUpdate = false;
|
237 |
}
|
238 |
+
elseif ( $opts->isAutoupdateAllPlugins() ) {
|
239 |
+
$doUpdate = true;
|
240 |
}
|
241 |
elseif ( $file === $this->getCon()->base_file ) {
|
242 |
+
$auto = $opts->getSelfAutoUpdateOpt();
|
243 |
+
if ( $auto === 'immediate' ) {
|
244 |
+
$doUpdate = true;
|
245 |
}
|
246 |
+
elseif ( $auto === 'disabled' ) {
|
247 |
+
$doUpdate = false;
|
248 |
}
|
249 |
}
|
250 |
}
|
251 |
|
252 |
+
return $doUpdate;
|
253 |
}
|
254 |
|
255 |
/**
|
256 |
+
* @param bool $doAutoUpdate
|
257 |
* @param \stdClass|string $mItem
|
258 |
* @return bool
|
259 |
*/
|
260 |
+
public function autoupdate_themes( $doAutoUpdate, $mItem ) {
|
261 |
/** @var Options $opts */
|
262 |
$opts = $this->getOptions();
|
263 |
|
264 |
if ( $opts->isDisableAllAutoUpdates() ) {
|
265 |
+
$doAutoUpdate = false;
|
266 |
}
|
267 |
else {
|
268 |
$file = Services::WpGeneral()->getFileFromAutomaticUpdateItem( $mItem, 'theme' );
|
269 |
|
270 |
if ( $this->isDelayed( $file, 'themes' ) ) {
|
271 |
+
$doAutoUpdate = false;
|
272 |
}
|
273 |
elseif ( $opts->isOpt( 'enable_autoupdate_themes', 'Y' ) ) {
|
274 |
+
$doAutoUpdate = true;
|
275 |
}
|
276 |
}
|
277 |
|
278 |
+
return $doAutoUpdate;
|
279 |
}
|
280 |
|
281 |
/**
|
282 |
+
* @param string|\stdClass $slug
|
283 |
+
* @param string $context
|
|
|
284 |
*/
|
285 |
+
private function isDelayed( $slug, $context = 'plugins' ) :bool {
|
286 |
+
/** @var Options $opts */
|
287 |
+
$opts = $this->getOptions();
|
288 |
|
289 |
+
$delayed = false;
|
290 |
|
291 |
+
if ( $opts->isDelayUpdates() ) {
|
292 |
|
293 |
+
$delayTrack = $opts->getDelayTracking();
|
294 |
|
295 |
+
$version = '';
|
296 |
+
if ( $context == 'core' ) {
|
297 |
+
$version = $slug->current; // \stdClass from transient update_core
|
298 |
+
$slug = 'wp';
|
299 |
}
|
300 |
|
301 |
+
$itemTrack = $delayTrack[ $context ][ $slug ] ?? [];
|
302 |
|
303 |
+
if ( $context == 'plugins' ) {
|
304 |
+
$pluginInfo = Services::WpPlugins()->getUpdateInfo( $slug );
|
305 |
+
$version = $pluginInfo->new_version ?? '';
|
306 |
}
|
307 |
+
elseif ( $context == 'themes' ) {
|
308 |
+
$themeInfo = Services::WpThemes()->getUpdateInfo( $slug );
|
309 |
+
$version = $themeInfo[ 'new_version' ] ?? '';
|
310 |
}
|
311 |
|
312 |
+
if ( !empty( $version ) && isset( $itemTrack[ $version ] ) ) {
|
313 |
+
$delayed = ( Services::Request()->ts() - $itemTrack[ $version ] ) < $opts->getDelayUpdatesPeriod();
|
314 |
}
|
315 |
}
|
316 |
|
317 |
+
return $delayed;
|
318 |
}
|
319 |
|
320 |
/**
|
321 |
+
* A filter on whether a notification email is sent after core upgrades are attempted.
|
322 |
+
* @param bool $sendEmail
|
323 |
* @return bool
|
324 |
*/
|
325 |
+
public function autoupdate_send_email( $sendEmail ) {
|
326 |
/** @var Options $opts */
|
327 |
$opts = $this->getOptions();
|
328 |
return $opts->isSendAutoupdatesNotificationEmail();
|
330 |
|
331 |
/**
|
332 |
* A filter on the target email address to which to send upgrade notification emails.
|
333 |
+
* @param array $emailParams
|
334 |
* @return array
|
335 |
*/
|
336 |
+
public function autoupdate_email_override( $emailParams ) {
|
337 |
+
$override = $this->getOptions()->getOpt( 'override_email_address', '' );
|
338 |
+
if ( Services::Data()->validEmail( $override ) ) {
|
339 |
+
$emailParams[ 'to' ] = $override;
|
340 |
}
|
341 |
+
return $emailParams;
|
342 |
}
|
343 |
|
344 |
/**
|
360 |
''
|
361 |
];
|
362 |
|
363 |
+
$assetVersionTrack = $this->getTrackedAssetsVersions();
|
364 |
|
365 |
+
$WPP = Services::WpPlugins();
|
366 |
if ( !empty( $aUpdateResults[ 'plugin' ] ) && is_array( $aUpdateResults[ 'plugin' ] ) ) {
|
367 |
$bHasPluginUpdates = false;
|
368 |
+
$aTrkdPlugs = $assetVersionTrack[ 'plugins' ];
|
369 |
|
370 |
$aTempContent[] = __( 'Plugins Updated:', 'wp-simple-firewall' );
|
371 |
foreach ( $aUpdateResults[ 'plugin' ] as $oUpdate ) {
|
372 |
+
$oP = $WPP->getPluginAsVo( $oUpdate->item->plugin, true );
|
373 |
$bValidUpdate = !empty( $oUpdate->result ) && !empty( $oUpdate->name )
|
374 |
&& isset( $aTrkdPlugs[ $oP->file ] )
|
375 |
&& version_compare( $aTrkdPlugs[ $oP->file ], $oP->Version, '<' );
|
390 |
|
391 |
if ( !empty( $aUpdateResults[ 'theme' ] ) && is_array( $aUpdateResults[ 'theme' ] ) ) {
|
392 |
$bHasThemesUpdates = false;
|
393 |
+
$aTrkdThemes = $assetVersionTrack[ 'themes' ];
|
394 |
|
395 |
$aTempContent = [ __( 'Themes Updated:', 'wp-simple-firewall' ) ];
|
396 |
foreach ( $aUpdateResults[ 'theme' ] as $oUpdate ) {
|
439 |
$this->getMod()
|
440 |
->getEmailProcessor()
|
441 |
->sendEmailWithWrap(
|
442 |
+
$this->getOptions()->getOpt( 'override_email_address' ),
|
443 |
sprintf( __( "Notice: %s", 'wp-simple-firewall' ), __( "Automatic Updates Completed", 'wp-simple-firewall' ) ),
|
444 |
+
$body
|
445 |
);
|
446 |
die();
|
447 |
}
|
src/lib/src/Modules/Lockdown/Processor.php
CHANGED
@@ -92,8 +92,8 @@ class Processor extends BaseShield\Processor {
|
|
92 |
private function interceptCanonicalRedirects() {
|
93 |
|
94 |
if ( $this->getOptions()->isOpt( 'block_author_discovery', 'Y' ) ) {
|
95 |
-
$
|
96 |
-
if ( !empty( $
|
97 |
Services::WpGeneral()->wpDie( sprintf(
|
98 |
__( 'The "author" query parameter has been blocked by %s to protect against user login name fishing.', 'wp-simple-firewall' )
|
99 |
.sprintf( '<br /><a href="%s" target="_blank">%s</a>',
|
92 |
private function interceptCanonicalRedirects() {
|
93 |
|
94 |
if ( $this->getOptions()->isOpt( 'block_author_discovery', 'Y' ) ) {
|
95 |
+
$author = Services::Request()->query( 'author', '' );
|
96 |
+
if ( !empty( $author ) ) {
|
97 |
Services::WpGeneral()->wpDie( sprintf(
|
98 |
__( 'The "author" query parameter has been blocked by %s to protect against user login name fishing.', 'wp-simple-firewall' )
|
99 |
.sprintf( '<br /><a href="%s" target="_blank">%s</a>',
|
src/lib/src/Modules/Sessions/Processor.php
CHANGED
@@ -41,14 +41,14 @@ class Processor extends BaseShield\Processor {
|
|
41 |
}
|
42 |
}
|
43 |
|
|
|
|
|
|
|
|
|
44 |
public function onWpLoaded() {
|
45 |
/** @var ModCon $mod */
|
46 |
$mod = $this->getMod();
|
47 |
|
48 |
-
if ( Services::WpUsers()->isUserLoggedIn() && !Services::Rest()->isRest() ) {
|
49 |
-
$this->autoAddSession();
|
50 |
-
}
|
51 |
-
|
52 |
if ( $mod->getSessionCon()->hasSession() ) {
|
53 |
/** @var Session\Update $update */
|
54 |
$update = $mod->getDbHandler_Sessions()->getQueryUpdater();
|
@@ -60,11 +60,9 @@ class Processor extends BaseShield\Processor {
|
|
60 |
/** @var ModCon $mod */
|
61 |
$mod = $this->getMod();
|
62 |
$sessCon = $mod->getSessionCon();
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
$sessCon->createSession( $user );
|
67 |
-
}
|
68 |
}
|
69 |
}
|
70 |
|
@@ -91,6 +89,17 @@ class Processor extends BaseShield\Processor {
|
|
91 |
return $msg;
|
92 |
}
|
93 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
protected function getHookPriority() :int {
|
95 |
return 100;
|
96 |
}
|
41 |
}
|
42 |
}
|
43 |
|
44 |
+
public function onWpInit() {
|
45 |
+
$this->autoAddSession();
|
46 |
+
}
|
47 |
+
|
48 |
public function onWpLoaded() {
|
49 |
/** @var ModCon $mod */
|
50 |
$mod = $this->getMod();
|
51 |
|
|
|
|
|
|
|
|
|
52 |
if ( $mod->getSessionCon()->hasSession() ) {
|
53 |
/** @var Session\Update $update */
|
54 |
$update = $mod->getDbHandler_Sessions()->getQueryUpdater();
|
60 |
/** @var ModCon $mod */
|
61 |
$mod = $this->getMod();
|
62 |
$sessCon = $mod->getSessionCon();
|
63 |
+
$user = Services::WpUsers()->getCurrentWpUser();
|
64 |
+
if ( $user instanceof \WP_User && !$sessCon->hasSession() ) {
|
65 |
+
$sessCon->createSession( $user );
|
|
|
|
|
66 |
}
|
67 |
}
|
68 |
|
89 |
return $msg;
|
90 |
}
|
91 |
|
92 |
+
protected function getWpHookPriority( string $hook ) :int {
|
93 |
+
switch ( $hook ) {
|
94 |
+
case 'init':
|
95 |
+
$pri = 1;
|
96 |
+
break;
|
97 |
+
default:
|
98 |
+
$pri = parent::getWpHookPriority( $hook );
|
99 |
+
}
|
100 |
+
return $pri;
|
101 |
+
}
|
102 |
+
|
103 |
protected function getHookPriority() :int {
|
104 |
return 100;
|
105 |
}
|
src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Base/RepoBase.php
CHANGED
@@ -1,76 +1,76 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace FernleafSystems\Wordpress\Services\Utilities\WpOrg\Base;
|
4 |
-
|
5 |
-
use FernleafSystems\Wordpress\Services;
|
6 |
-
|
7 |
-
abstract class RepoBase {
|
8 |
-
|
9 |
-
/**
|
10 |
-
* @param string $fileFragment
|
11 |
-
* @param string $version
|
12 |
-
* @param bool $useSiteLocale
|
13 |
-
* @return string|null
|
14 |
-
*/
|
15 |
-
public function downloadFromVcs( $fileFragment, $version = null, $useSiteLocale = true ) {
|
16 |
-
$url = $this->getVcsUrlForFileAndVersion( $fileFragment, $version, $useSiteLocale );
|
17 |
-
try {
|
18 |
-
$tmpFile = ( new Services\Utilities\HttpUtil() )
|
19 |
-
->checkUrl( $url )
|
20 |
-
->downloadUrl( $url );
|
21 |
-
}
|
22 |
-
catch ( \Exception $e ) {
|
23 |
-
$tmpFile = null;
|
24 |
-
}
|
25 |
-
return $tmpFile;
|
26 |
-
}
|
27 |
-
|
28 |
-
/**
|
29 |
-
* @param string $fileFragment
|
30 |
-
* @param string $version
|
31 |
-
* @param bool $useSiteLocale
|
32 |
-
* @return string|null
|
33 |
-
*/
|
34 |
-
public function getContentFromVcs( $fileFragment, $version = null, $useSiteLocale = true ) {
|
35 |
-
$url = $this->getVcsUrlForFileAndVersion( $fileFragment, $version, $useSiteLocale );
|
36 |
-
$content = null;
|
37 |
-
try {
|
38 |
-
$downloadedFile = ( new Services\Utilities\HttpUtil() )
|
39 |
-
->checkUrl( $url )
|
40 |
-
->downloadUrl( $url );
|
41 |
-
if ( is_string( $downloadedFile ) ) {
|
42 |
-
$content = Services\Services::WpFs()->getFileContent( $downloadedFile );
|
43 |
-
}
|
44 |
-
}
|
45 |
-
catch ( \Exception $e ) {
|
46 |
-
}
|
47 |
-
return $content;
|
48 |
-
}
|
49 |
-
|
50 |
-
/**
|
51 |
-
* @param string $fileFragment - path relative to the root dir of the object being tested. E.g. ABSPATH for
|
52 |
-
* WordPress or the plugin dir if it's a plugin.
|
53 |
-
* @param string $version - leave empty to use the current version
|
54 |
-
* @param bool $useSiteLocale
|
55 |
-
* @return bool
|
56 |
-
*/
|
57 |
-
public function existsInVcs( $fileFragment, $version = null, $useSiteLocale = true ) {
|
58 |
-
$url = $this->getVcsUrlForFileAndVersion( $fileFragment, $version, $useSiteLocale );
|
59 |
-
try {
|
60 |
-
( new Services\Utilities\HttpUtil() )->checkUrl( $url );
|
61 |
-
$exists = true;
|
62 |
-
}
|
63 |
-
catch ( \Exception $e ) {
|
64 |
-
$exists = false;
|
65 |
-
}
|
66 |
-
return $exists;
|
67 |
-
}
|
68 |
-
|
69 |
-
/**
|
70 |
-
* @param string $fileFragment
|
71 |
-
* @param string $version
|
72 |
-
* @param bool $useSiteLocale
|
73 |
-
* @return string
|
74 |
-
*/
|
75 |
-
abstract
|
76 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace FernleafSystems\Wordpress\Services\Utilities\WpOrg\Base;
|
4 |
+
|
5 |
+
use FernleafSystems\Wordpress\Services;
|
6 |
+
|
7 |
+
abstract class RepoBase {
|
8 |
+
|
9 |
+
/**
|
10 |
+
* @param string $fileFragment
|
11 |
+
* @param string $version
|
12 |
+
* @param bool $useSiteLocale
|
13 |
+
* @return string|null
|
14 |
+
*/
|
15 |
+
public function downloadFromVcs( $fileFragment, $version = null, $useSiteLocale = true ) {
|
16 |
+
$url = $this->getVcsUrlForFileAndVersion( $fileFragment, $version, $useSiteLocale );
|
17 |
+
try {
|
18 |
+
$tmpFile = ( new Services\Utilities\HttpUtil() )
|
19 |
+
->checkUrl( $url )
|
20 |
+
->downloadUrl( $url );
|
21 |
+
}
|
22 |
+
catch ( \Exception $e ) {
|
23 |
+
$tmpFile = null;
|
24 |
+
}
|
25 |
+
return $tmpFile;
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @param string $fileFragment
|
30 |
+
* @param string $version
|
31 |
+
* @param bool $useSiteLocale
|
32 |
+
* @return string|null
|
33 |
+
*/
|
34 |
+
public function getContentFromVcs( $fileFragment, $version = null, $useSiteLocale = true ) {
|
35 |
+
$url = $this->getVcsUrlForFileAndVersion( $fileFragment, $version, $useSiteLocale );
|
36 |
+
$content = null;
|
37 |
+
try {
|
38 |
+
$downloadedFile = ( new Services\Utilities\HttpUtil() )
|
39 |
+
->checkUrl( $url )
|
40 |
+
->downloadUrl( $url );
|
41 |
+
if ( is_string( $downloadedFile ) ) {
|
42 |
+
$content = Services\Services::WpFs()->getFileContent( $downloadedFile );
|
43 |
+
}
|
44 |
+
}
|
45 |
+
catch ( \Exception $e ) {
|
46 |
+
}
|
47 |
+
return $content;
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* @param string $fileFragment - path relative to the root dir of the object being tested. E.g. ABSPATH for
|
52 |
+
* WordPress or the plugin dir if it's a plugin.
|
53 |
+
* @param string $version - leave empty to use the current version
|
54 |
+
* @param bool $useSiteLocale
|
55 |
+
* @return bool
|
56 |
+
*/
|
57 |
+
public function existsInVcs( $fileFragment, $version = null, $useSiteLocale = true ) {
|
58 |
+
$url = $this->getVcsUrlForFileAndVersion( $fileFragment, $version, $useSiteLocale );
|
59 |
+
try {
|
60 |
+
( new Services\Utilities\HttpUtil() )->checkUrl( $url );
|
61 |
+
$exists = true;
|
62 |
+
}
|
63 |
+
catch ( \Exception $e ) {
|
64 |
+
$exists = false;
|
65 |
+
}
|
66 |
+
return $exists;
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* @param string $fileFragment
|
71 |
+
* @param string $version
|
72 |
+
* @param bool $useSiteLocale
|
73 |
+
* @return string
|
74 |
+
*/
|
75 |
+
abstract public function getVcsUrlForFileAndVersion( $fileFragment, $version, $useSiteLocale = true );
|
76 |
}
|
src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Cp/Repo.php
CHANGED
@@ -1,77 +1,77 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace FernleafSystems\Wordpress\Services\Utilities\WpOrg\Cp;
|
4 |
-
|
5 |
-
use FernleafSystems\Wordpress\Services;
|
6 |
-
|
7 |
-
class Repo extends Services\Utilities\WpOrg\Base\RepoBase {
|
8 |
-
|
9 |
-
const URL_VCS_ROOT = 'https://raw.githubusercontent.com/ClassicPress/ClassicPress-release';
|
10 |
-
const URL_VCS_ROOT_IL8N = self::URL_VCS_ROOT;
|
11 |
-
const URL_VCS_VERSIONS = 'https://api.github.com/repos/ClassicPress/ClassicPress-release/releases';
|
12 |
-
const URL_VCS_VERSION = 'https://github.com/ClassicPress/ClassicPress-release/releases/tag';
|
13 |
-
|
14 |
-
/**
|
15 |
-
* @param string $sVersion
|
16 |
-
* @return string
|
17 |
-
*/
|
18 |
-
public static function GetUrlForVersion( $sVersion ) {
|
19 |
-
return sprintf( '%s/%s', static::URL_VCS_VERSION, $sVersion );
|
20 |
-
}
|
21 |
-
|
22 |
-
/**
|
23 |
-
* @param string $sVersion
|
24 |
-
* @return string
|
25 |
-
*/
|
26 |
-
public static function GetUrlForFiles( $sVersion ) {
|
27 |
-
return sprintf( '%s/%s', static::URL_VCS_ROOT, $sVersion );
|
28 |
-
}
|
29 |
-
|
30 |
-
/**
|
31 |
-
* @return string
|
32 |
-
*/
|
33 |
-
public static function GetUrlForVersions() {
|
34 |
-
return static::URL_VCS_VERSIONS;
|
35 |
-
}
|
36 |
-
|
37 |
-
/**
|
38 |
-
* @param string $fileFragment
|
39 |
-
* @param string $version
|
40 |
-
* @param bool $useSiteLocale
|
41 |
-
* @return string|null
|
42 |
-
*/
|
43 |
-
public function downloadFromVcs( $fileFragment, $version = null, $useSiteLocale = true ) {
|
44 |
-
$sFile = parent::downloadFromVcs( $fileFragment, $version, $useSiteLocale );
|
45 |
-
if ( $useSiteLocale && empty( $sFile ) ) {
|
46 |
-
$sFile = parent::downloadFromVcs( $fileFragment, $version, false );
|
47 |
-
}
|
48 |
-
return $sFile;
|
49 |
-
}
|
50 |
-
|
51 |
-
/**
|
52 |
-
* @param string $fileFragment
|
53 |
-
* @param string $version - leave empty to use the current version
|
54 |
-
* @param bool $useSiteLocale
|
55 |
-
* @return bool
|
56 |
-
*/
|
57 |
-
public function existsInVcs( $fileFragment, $version = null, $useSiteLocale = true ) {
|
58 |
-
$sFile = parent::existsInVcs( $fileFragment, $version, $useSiteLocale );
|
59 |
-
if ( $useSiteLocale && empty( $sFile ) ) {
|
60 |
-
$sFile = parent::existsInVcs( $fileFragment, $version, false );
|
61 |
-
}
|
62 |
-
return $sFile;
|
63 |
-
}
|
64 |
-
|
65 |
-
/**
|
66 |
-
* @param string $fileFragment
|
67 |
-
* @param string $version
|
68 |
-
* @param bool $useSiteLocale - not yet used for ClassicPress
|
69 |
-
* @return string
|
70 |
-
*/
|
71 |
-
|
72 |
-
if ( empty( $version ) ) {
|
73 |
-
$version = Services\Services::WpGeneral()->getVersion();
|
74 |
-
}
|
75 |
-
return sprintf( '%s/%s', static::GetUrlForFiles( $version ), ltrim( $fileFragment, '/' ) );
|
76 |
-
}
|
77 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace FernleafSystems\Wordpress\Services\Utilities\WpOrg\Cp;
|
4 |
+
|
5 |
+
use FernleafSystems\Wordpress\Services;
|
6 |
+
|
7 |
+
class Repo extends Services\Utilities\WpOrg\Base\RepoBase {
|
8 |
+
|
9 |
+
const URL_VCS_ROOT = 'https://raw.githubusercontent.com/ClassicPress/ClassicPress-release';
|
10 |
+
const URL_VCS_ROOT_IL8N = self::URL_VCS_ROOT;
|
11 |
+
const URL_VCS_VERSIONS = 'https://api.github.com/repos/ClassicPress/ClassicPress-release/releases';
|
12 |
+
const URL_VCS_VERSION = 'https://github.com/ClassicPress/ClassicPress-release/releases/tag';
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @param string $sVersion
|
16 |
+
* @return string
|
17 |
+
*/
|
18 |
+
public static function GetUrlForVersion( $sVersion ) {
|
19 |
+
return sprintf( '%s/%s', static::URL_VCS_VERSION, $sVersion );
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* @param string $sVersion
|
24 |
+
* @return string
|
25 |
+
*/
|
26 |
+
public static function GetUrlForFiles( $sVersion ) {
|
27 |
+
return sprintf( '%s/%s', static::URL_VCS_ROOT, $sVersion );
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* @return string
|
32 |
+
*/
|
33 |
+
public static function GetUrlForVersions() {
|
34 |
+
return static::URL_VCS_VERSIONS;
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* @param string $fileFragment
|
39 |
+
* @param string $version
|
40 |
+
* @param bool $useSiteLocale
|
41 |
+
* @return string|null
|
42 |
+
*/
|
43 |
+
public function downloadFromVcs( $fileFragment, $version = null, $useSiteLocale = true ) {
|
44 |
+
$sFile = parent::downloadFromVcs( $fileFragment, $version, $useSiteLocale );
|
45 |
+
if ( $useSiteLocale && empty( $sFile ) ) {
|
46 |
+
$sFile = parent::downloadFromVcs( $fileFragment, $version, false );
|
47 |
+
}
|
48 |
+
return $sFile;
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* @param string $fileFragment
|
53 |
+
* @param string $version - leave empty to use the current version
|
54 |
+
* @param bool $useSiteLocale
|
55 |
+
* @return bool
|
56 |
+
*/
|
57 |
+
public function existsInVcs( $fileFragment, $version = null, $useSiteLocale = true ) {
|
58 |
+
$sFile = parent::existsInVcs( $fileFragment, $version, $useSiteLocale );
|
59 |
+
if ( $useSiteLocale && empty( $sFile ) ) {
|
60 |
+
$sFile = parent::existsInVcs( $fileFragment, $version, false );
|
61 |
+
}
|
62 |
+
return $sFile;
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* @param string $fileFragment
|
67 |
+
* @param string $version
|
68 |
+
* @param bool $useSiteLocale - not yet used for ClassicPress
|
69 |
+
* @return string
|
70 |
+
*/
|
71 |
+
public function getVcsUrlForFileAndVersion( $fileFragment, $version, $useSiteLocale = true ) {
|
72 |
+
if ( empty( $version ) ) {
|
73 |
+
$version = Services\Services::WpGeneral()->getVersion();
|
74 |
+
}
|
75 |
+
return sprintf( '%s/%s', static::GetUrlForFiles( $version ), ltrim( $fileFragment, '/' ) );
|
76 |
+
}
|
77 |
}
|
src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Plugin/Repo.php
CHANGED
@@ -1,66 +1,66 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace FernleafSystems\Wordpress\Services\Utilities\WpOrg\Plugin;
|
4 |
-
|
5 |
-
use FernleafSystems\Wordpress\Services;
|
6 |
-
|
7 |
-
class Repo extends Services\Utilities\WpOrg\Base\RepoBase {
|
8 |
-
|
9 |
-
use Base;
|
10 |
-
const URL_VCS_ROOT = 'https://plugins.svn.wordpress.org';
|
11 |
-
const URL_VCS_DOWNLOAD_VERSIONS = 'https://plugins.svn.wordpress.org/%s/tags/';
|
12 |
-
const URL_DOWNLOAD_SVN_FILE = 'https://plugins.svn.wordpress.org/%s/tags/%s/%s';
|
13 |
-
|
14 |
-
/**
|
15 |
-
* @param string $slug
|
16 |
-
* @return string
|
17 |
-
*/
|
18 |
-
public static function GetUrlForPlugin( $slug ) {
|
19 |
-
return sprintf( '%s/%s', static::URL_VCS_ROOT, $slug );
|
20 |
-
}
|
21 |
-
|
22 |
-
/**
|
23 |
-
* @param string $slug
|
24 |
-
* @param string $version
|
25 |
-
* @return string
|
26 |
-
*/
|
27 |
-
public static function GetUrlForPluginVersion( $slug, $version ) {
|
28 |
-
if ( $version != 'trunk' ) {
|
29 |
-
$version = sprintf( 'tags/%s', $version );
|
30 |
-
}
|
31 |
-
return sprintf( '%s/%s', static::GetUrlForPlugin( $slug ), $version );
|
32 |
-
}
|
33 |
-
|
34 |
-
/**
|
35 |
-
* @param string $slug
|
36 |
-
* @return string
|
37 |
-
*/
|
38 |
-
public static function GetUrlForPluginVersions( $slug ) {
|
39 |
-
return static::GetUrlForPluginVersion( $slug, '' );
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* @param string $fileFragment - relative to the working plugin directory
|
44 |
-
* @param string $version
|
45 |
-
* @param bool $useSiteLocale - unused
|
46 |
-
* @return string
|
47 |
-
* @throws \Exception
|
48 |
-
*/
|
49 |
-
|
50 |
-
if ( empty( $fileFragment ) ) {
|
51 |
-
throw new \InvalidArgumentException( 'Plugin file fragment path provided is empty' );
|
52 |
-
}
|
53 |
-
if ( empty( $version ) ) {
|
54 |
-
$version = $this->getWorkingVersion();
|
55 |
-
}
|
56 |
-
if ( empty( $version ) ) {
|
57 |
-
$version = ( new Versions() )
|
58 |
-
->setWorkingSlug( $this->getWorkingSlug() )
|
59 |
-
->latest();
|
60 |
-
}
|
61 |
-
return sprintf( '%s/%s',
|
62 |
-
rtrim( static::GetUrlForPluginVersion( $this->getWorkingSlug(), $version ), '/' ),
|
63 |
-
ltrim( $fileFragment, '/' )
|
64 |
-
);
|
65 |
-
}
|
66 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace FernleafSystems\Wordpress\Services\Utilities\WpOrg\Plugin;
|
4 |
+
|
5 |
+
use FernleafSystems\Wordpress\Services;
|
6 |
+
|
7 |
+
class Repo extends Services\Utilities\WpOrg\Base\RepoBase {
|
8 |
+
|
9 |
+
use Base;
|
10 |
+
const URL_VCS_ROOT = 'https://plugins.svn.wordpress.org';
|
11 |
+
const URL_VCS_DOWNLOAD_VERSIONS = 'https://plugins.svn.wordpress.org/%s/tags/';
|
12 |
+
const URL_DOWNLOAD_SVN_FILE = 'https://plugins.svn.wordpress.org/%s/tags/%s/%s';
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @param string $slug
|
16 |
+
* @return string
|
17 |
+
*/
|
18 |
+
public static function GetUrlForPlugin( $slug ) {
|
19 |
+
return sprintf( '%s/%s', static::URL_VCS_ROOT, $slug );
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* @param string $slug
|
24 |
+
* @param string $version
|
25 |
+
* @return string
|
26 |
+
*/
|
27 |
+
public static function GetUrlForPluginVersion( $slug, $version ) {
|
28 |
+
if ( $version != 'trunk' ) {
|
29 |
+
$version = sprintf( 'tags/%s', $version );
|
30 |
+
}
|
31 |
+
return sprintf( '%s/%s', static::GetUrlForPlugin( $slug ), $version );
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* @param string $slug
|
36 |
+
* @return string
|
37 |
+
*/
|
38 |
+
public static function GetUrlForPluginVersions( $slug ) {
|
39 |
+
return static::GetUrlForPluginVersion( $slug, '' );
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* @param string $fileFragment - relative to the working plugin directory
|
44 |
+
* @param string $version
|
45 |
+
* @param bool $useSiteLocale - unused
|
46 |
+
* @return string
|
47 |
+
* @throws \Exception
|
48 |
+
*/
|
49 |
+
public function getVcsUrlForFileAndVersion( $fileFragment, $version = null, $useSiteLocale = true ) {
|
50 |
+
if ( empty( $fileFragment ) ) {
|
51 |
+
throw new \InvalidArgumentException( 'Plugin file fragment path provided is empty' );
|
52 |
+
}
|
53 |
+
if ( empty( $version ) ) {
|
54 |
+
$version = $this->getWorkingVersion();
|
55 |
+
}
|
56 |
+
if ( empty( $version ) ) {
|
57 |
+
$version = ( new Versions() )
|
58 |
+
->setWorkingSlug( $this->getWorkingSlug() )
|
59 |
+
->latest();
|
60 |
+
}
|
61 |
+
return sprintf( '%s/%s',
|
62 |
+
rtrim( static::GetUrlForPluginVersion( $this->getWorkingSlug(), $version ), '/' ),
|
63 |
+
ltrim( $fileFragment, '/' )
|
64 |
+
);
|
65 |
+
}
|
66 |
}
|
src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Theme/Files.php
CHANGED
@@ -1,123 +1,123 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace FernleafSystems\Wordpress\Services\Utilities\WpOrg\Theme;
|
4 |
-
|
5 |
-
use FernleafSystems\Wordpress\Services;
|
6 |
-
|
7 |
-
class Files extends Services\Utilities\WpOrg\Base\PluginThemeFilesBase {
|
8 |
-
|
9 |
-
use Base;
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Given a full root path on the file system for a file, locate the plugin to which this file belongs.
|
13 |
-
* @param string $fullPath
|
14 |
-
* @return Services\Core\VOs\Assets\WpThemeVo|null
|
15 |
-
*/
|
16 |
-
public function findThemeFromFile( string $fullPath ) {
|
17 |
-
$theTheme = null;
|
18 |
-
|
19 |
-
$fragment = $this->getThemePathFragmentFromPath( $fullPath );
|
20 |
-
|
21 |
-
if ( !empty( $fragment ) && strpos( $fragment, '/' ) > 0 ) {
|
22 |
-
$WPT = Services\Services::WpThemes();
|
23 |
-
$dir = substr( $fragment, 0, strpos( $fragment, '/' ) );
|
24 |
-
foreach ( $WPT->getThemes() as $theme ) {
|
25 |
-
if ( $dir == $theme->get_stylesheet() ) {
|
26 |
-
$theTheme = $WPT->getThemeAsVo( $dir );
|
27 |
-
break;
|
28 |
-
}
|
29 |
-
}
|
30 |
-
}
|
31 |
-
return $theTheme;
|
32 |
-
}
|
33 |
-
|
34 |
-
/**
|
35 |
-
* Verifies the file exists on the SVN repository for the particular version that's installed.
|
36 |
-
* @param string $sFullFilePath
|
37 |
-
* @return bool
|
38 |
-
* @throws \InvalidArgumentException
|
39 |
-
*/
|
40 |
-
public function isValidFileFromTheme( $sFullFilePath ) {
|
41 |
-
|
42 |
-
$theTheme = $this->findThemeFromFile( $sFullFilePath );
|
43 |
-
if ( !$theTheme instanceof Services\Core\VOs\Assets\WpThemeVo ) {
|
44 |
-
throw new \InvalidArgumentException( 'Not actually a theme file.', 1 );
|
45 |
-
}
|
46 |
-
if ( !$theTheme->isWpOrg() ) {
|
47 |
-
throw new \InvalidArgumentException( 'Not a WordPress.org theme.', 2 );
|
48 |
-
}
|
49 |
-
|
50 |
-
// if uses SVN tags, use that version. Otherwise trunk.
|
51 |
-
return ( new Repo() )
|
52 |
-
->setWorkingSlug( $theTheme->stylesheet )
|
53 |
-
->setWorkingVersion( $theTheme->version )
|
54 |
-
->existsInVcs( $this->getRelativeFilePathFromItsInstallDir( $sFullFilePath ) );
|
55 |
-
}
|
56 |
-
|
57 |
-
/**
|
58 |
-
* @param string $fullPath
|
59 |
-
* @return bool
|
60 |
-
*/
|
61 |
-
public function replaceFileFromVcs( $fullPath ) :bool {
|
62 |
-
$tmpFile = $this->getOriginalFileFromVcs( $fullPath );
|
63 |
-
return !empty( $tmpFile ) && Services\Services::WpFs()->move( $tmpFile, $fullPath );
|
64 |
-
}
|
65 |
-
|
66 |
-
/**
|
67 |
-
* Verifies the file exists on the SVN repository for the particular version that's installed.
|
68 |
-
* @param string $fullPath
|
69 |
-
* @return bool
|
70 |
-
* @throws \InvalidArgumentException
|
71 |
-
*/
|
72 |
-
public function verifyFileContents( $fullPath ) :bool {
|
73 |
-
$tmpFile = $this->getOriginalFileFromVcs( $fullPath );
|
74 |
-
return !empty( $tmpFile )
|
75 |
-
&& ( new Services\Utilities\File\Compare\CompareHash() )->isEqualFiles( $tmpFile, $fullPath );
|
76 |
-
}
|
77 |
-
|
78 |
-
/**
|
79 |
-
* @param string $fullPath
|
80 |
-
* @return string|null
|
81 |
-
*/
|
82 |
-
public function getOriginalFileFromVcs( $fullPath ) {
|
83 |
-
$tmpFile = null;
|
84 |
-
$theTheme = $this->findThemeFromFile( $fullPath );
|
85 |
-
if ( $theTheme
|
86 |
-
$tmpFile = ( new Repo() )
|
87 |
-
->setWorkingSlug( $theTheme->stylesheet )
|
88 |
-
->setWorkingVersion( $theTheme->version )
|
89 |
-
->downloadFromVcs( $this->getRelativeFilePathFromItsInstallDir( $fullPath ) );
|
90 |
-
}
|
91 |
-
return $tmpFile;
|
92 |
-
}
|
93 |
-
|
94 |
-
/**
|
95 |
-
* @param string $sFile - can either be absolute, or relative to ABSPATH
|
96 |
-
* @return string|null - the path to the file relative to Plugins Dir.
|
97 |
-
*/
|
98 |
-
public function getThemePathFragmentFromPath( $sFile ) {
|
99 |
-
$sFragment = null;
|
100 |
-
|
101 |
-
if ( !Services\Services::WpFs()->isAbsPath( $sFile ) ) { // assume it's relative to ABSPATH
|
102 |
-
$sFile = path_join( ABSPATH, $sFile );
|
103 |
-
}
|
104 |
-
$sFile = wp_normalize_path( $sFile );
|
105 |
-
$sThemesDir = wp_normalize_path( get_theme_root() );
|
106 |
-
|
107 |
-
if ( strpos( $sFile, $sThemesDir ) === 0 ) {
|
108 |
-
$sFragment = ltrim( str_replace( $sThemesDir, '', $sFile ), '/' );
|
109 |
-
}
|
110 |
-
|
111 |
-
return $sFragment;
|
112 |
-
}
|
113 |
-
|
114 |
-
/**
|
115 |
-
* Gets the path of the plugin file relative to its own home plugin dir. (not wp-content/plugins/)
|
116 |
-
* @param string $file
|
117 |
-
* @return string
|
118 |
-
*/
|
119 |
-
public function getRelativeFilePathFromItsInstallDir( $file ) {
|
120 |
-
$sRelDirFragment = $this->getThemePathFragmentFromPath( $file );
|
121 |
-
return substr( $sRelDirFragment, strpos( $sRelDirFragment, '/' ) + 1 );
|
122 |
-
}
|
123 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace FernleafSystems\Wordpress\Services\Utilities\WpOrg\Theme;
|
4 |
+
|
5 |
+
use FernleafSystems\Wordpress\Services;
|
6 |
+
|
7 |
+
class Files extends Services\Utilities\WpOrg\Base\PluginThemeFilesBase {
|
8 |
+
|
9 |
+
use Base;
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Given a full root path on the file system for a file, locate the plugin to which this file belongs.
|
13 |
+
* @param string $fullPath
|
14 |
+
* @return Services\Core\VOs\Assets\WpThemeVo|null
|
15 |
+
*/
|
16 |
+
public function findThemeFromFile( string $fullPath ) {
|
17 |
+
$theTheme = null;
|
18 |
+
|
19 |
+
$fragment = $this->getThemePathFragmentFromPath( $fullPath );
|
20 |
+
|
21 |
+
if ( !empty( $fragment ) && strpos( $fragment, '/' ) > 0 ) {
|
22 |
+
$WPT = Services\Services::WpThemes();
|
23 |
+
$dir = substr( $fragment, 0, strpos( $fragment, '/' ) );
|
24 |
+
foreach ( $WPT->getThemes() as $theme ) {
|
25 |
+
if ( $dir == $theme->get_stylesheet() ) {
|
26 |
+
$theTheme = $WPT->getThemeAsVo( $dir );
|
27 |
+
break;
|
28 |
+
}
|
29 |
+
}
|
30 |
+
}
|
31 |
+
return $theTheme;
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Verifies the file exists on the SVN repository for the particular version that's installed.
|
36 |
+
* @param string $sFullFilePath
|
37 |
+
* @return bool
|
38 |
+
* @throws \InvalidArgumentException
|
39 |
+
*/
|
40 |
+
public function isValidFileFromTheme( $sFullFilePath ) {
|
41 |
+
|
42 |
+
$theTheme = $this->findThemeFromFile( $sFullFilePath );
|
43 |
+
if ( !$theTheme instanceof Services\Core\VOs\Assets\WpThemeVo ) {
|
44 |
+
throw new \InvalidArgumentException( 'Not actually a theme file.', 1 );
|
45 |
+
}
|
46 |
+
if ( !$theTheme->isWpOrg() ) {
|
47 |
+
throw new \InvalidArgumentException( 'Not a WordPress.org theme.', 2 );
|
48 |
+
}
|
49 |
+
|
50 |
+
// if uses SVN tags, use that version. Otherwise trunk.
|
51 |
+
return ( new Repo() )
|
52 |
+
->setWorkingSlug( $theTheme->stylesheet )
|
53 |
+
->setWorkingVersion( $theTheme->version )
|
54 |
+
->existsInVcs( $this->getRelativeFilePathFromItsInstallDir( $sFullFilePath ) );
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* @param string $fullPath
|
59 |
+
* @return bool
|
60 |
+
*/
|
61 |
+
public function replaceFileFromVcs( $fullPath ) :bool {
|
62 |
+
$tmpFile = $this->getOriginalFileFromVcs( $fullPath );
|
63 |
+
return !empty( $tmpFile ) && Services\Services::WpFs()->move( $tmpFile, $fullPath );
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Verifies the file exists on the SVN repository for the particular version that's installed.
|
68 |
+
* @param string $fullPath
|
69 |
+
* @return bool
|
70 |
+
* @throws \InvalidArgumentException
|
71 |
+
*/
|
72 |
+
public function verifyFileContents( $fullPath ) :bool {
|
73 |
+
$tmpFile = $this->getOriginalFileFromVcs( $fullPath );
|
74 |
+
return !empty( $tmpFile )
|
75 |
+
&& ( new Services\Utilities\File\Compare\CompareHash() )->isEqualFiles( $tmpFile, $fullPath );
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* @param string $fullPath
|
80 |
+
* @return string|null
|
81 |
+
*/
|
82 |
+
public function getOriginalFileFromVcs( $fullPath ) {
|
83 |
+
$tmpFile = null;
|
84 |
+
$theTheme = $this->findThemeFromFile( $fullPath );
|
85 |
+
if ( !empty( $theTheme ) ) {
|
86 |
+
$tmpFile = ( new Repo() )
|
87 |
+
->setWorkingSlug( $theTheme->stylesheet )
|
88 |
+
->setWorkingVersion( $theTheme->version )
|
89 |
+
->downloadFromVcs( $this->getRelativeFilePathFromItsInstallDir( $fullPath ) );
|
90 |
+
}
|
91 |
+
return $tmpFile;
|
92 |
+
}
|
93 |
+
|
94 |
+
/**
|
95 |
+
* @param string $sFile - can either be absolute, or relative to ABSPATH
|
96 |
+
* @return string|null - the path to the file relative to Plugins Dir.
|
97 |
+
*/
|
98 |
+
public function getThemePathFragmentFromPath( $sFile ) {
|
99 |
+
$sFragment = null;
|
100 |
+
|
101 |
+
if ( !Services\Services::WpFs()->isAbsPath( $sFile ) ) { // assume it's relative to ABSPATH
|
102 |
+
$sFile = path_join( ABSPATH, $sFile );
|
103 |
+
}
|
104 |
+
$sFile = wp_normalize_path( $sFile );
|
105 |
+
$sThemesDir = wp_normalize_path( get_theme_root() );
|
106 |
+
|
107 |
+
if ( strpos( $sFile, $sThemesDir ) === 0 ) {
|
108 |
+
$sFragment = ltrim( str_replace( $sThemesDir, '', $sFile ), '/' );
|
109 |
+
}
|
110 |
+
|
111 |
+
return $sFragment;
|
112 |
+
}
|
113 |
+
|
114 |
+
/**
|
115 |
+
* Gets the path of the plugin file relative to its own home plugin dir. (not wp-content/plugins/)
|
116 |
+
* @param string $file
|
117 |
+
* @return string
|
118 |
+
*/
|
119 |
+
public function getRelativeFilePathFromItsInstallDir( $file ) {
|
120 |
+
$sRelDirFragment = $this->getThemePathFragmentFromPath( $file );
|
121 |
+
return substr( $sRelDirFragment, strpos( $sRelDirFragment, '/' ) + 1 );
|
122 |
+
}
|
123 |
}
|
src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Theme/Repo.php
CHANGED
@@ -1,59 +1,59 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace FernleafSystems\Wordpress\Services\Utilities\WpOrg\Theme;
|
4 |
-
|
5 |
-
use FernleafSystems\Wordpress\Services;
|
6 |
-
|
7 |
-
class Repo extends Services\Utilities\WpOrg\Base\RepoBase {
|
8 |
-
|
9 |
-
use Base;
|
10 |
-
const URL_VCS_ROOT = 'https://themes.svn.wordpress.org';
|
11 |
-
|
12 |
-
/**
|
13 |
-
* @param string $slug
|
14 |
-
* @return string
|
15 |
-
*/
|
16 |
-
public static function GetUrlForTheme( $slug ) {
|
17 |
-
return sprintf( '%s/%s', static::URL_VCS_ROOT, $slug );
|
18 |
-
}
|
19 |
-
|
20 |
-
/**
|
21 |
-
* @param string $slug
|
22 |
-
* @param string $version
|
23 |
-
* @return string
|
24 |
-
*/
|
25 |
-
public static function GetUrlForThemeVersion( $slug, $version ) {
|
26 |
-
return sprintf( '%s/%s', static::GetUrlForTheme( $slug ), $version );
|
27 |
-
}
|
28 |
-
|
29 |
-
/**
|
30 |
-
* @param string $slug
|
31 |
-
* @return string
|
32 |
-
*/
|
33 |
-
public static function GetUrlForThemeVersions( $slug ) {
|
34 |
-
return static::GetUrlForThemeVersion( $slug, '' );
|
35 |
-
}
|
36 |
-
|
37 |
-
/**
|
38 |
-
* @param string $fileFragment - relative to the working plugin directory
|
39 |
-
* @param string $version
|
40 |
-
* @param bool $useSiteLocale - unused
|
41 |
-
* @return string
|
42 |
-
* @throws \Exception
|
43 |
-
*/
|
44 |
-
|
45 |
-
if ( empty( $fileFragment ) ) {
|
46 |
-
throw new \InvalidArgumentException( 'Theme file fragment path provided is empty' );
|
47 |
-
}
|
48 |
-
if ( empty( $version ) ) {
|
49 |
-
$version = $this->getWorkingVersion();
|
50 |
-
}
|
51 |
-
if ( empty( $version ) ) {
|
52 |
-
$version = ( new Versions() )
|
53 |
-
->setWorkingSlug( $this->getWorkingSlug() )
|
54 |
-
->latest();
|
55 |
-
}
|
56 |
-
return sprintf( '%s/%s',
|
57 |
-
static::GetUrlForThemeVersion( $this->getWorkingSlug(), $version ), ltrim( $fileFragment, '/' ) );
|
58 |
-
}
|
59 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace FernleafSystems\Wordpress\Services\Utilities\WpOrg\Theme;
|
4 |
+
|
5 |
+
use FernleafSystems\Wordpress\Services;
|
6 |
+
|
7 |
+
class Repo extends Services\Utilities\WpOrg\Base\RepoBase {
|
8 |
+
|
9 |
+
use Base;
|
10 |
+
const URL_VCS_ROOT = 'https://themes.svn.wordpress.org';
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @param string $slug
|
14 |
+
* @return string
|
15 |
+
*/
|
16 |
+
public static function GetUrlForTheme( $slug ) {
|
17 |
+
return sprintf( '%s/%s', static::URL_VCS_ROOT, $slug );
|
18 |
+
}
|
19 |
+
|
20 |
+
/**
|
21 |
+
* @param string $slug
|
22 |
+
* @param string $version
|
23 |
+
* @return string
|
24 |
+
*/
|
25 |
+
public static function GetUrlForThemeVersion( $slug, $version ) {
|
26 |
+
return sprintf( '%s/%s', static::GetUrlForTheme( $slug ), $version );
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @param string $slug
|
31 |
+
* @return string
|
32 |
+
*/
|
33 |
+
public static function GetUrlForThemeVersions( $slug ) {
|
34 |
+
return static::GetUrlForThemeVersion( $slug, '' );
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* @param string $fileFragment - relative to the working plugin directory
|
39 |
+
* @param string $version
|
40 |
+
* @param bool $useSiteLocale - unused
|
41 |
+
* @return string
|
42 |
+
* @throws \Exception
|
43 |
+
*/
|
44 |
+
public function getVcsUrlForFileAndVersion( $fileFragment, $version = null, $useSiteLocale = true ) {
|
45 |
+
if ( empty( $fileFragment ) ) {
|
46 |
+
throw new \InvalidArgumentException( 'Theme file fragment path provided is empty' );
|
47 |
+
}
|
48 |
+
if ( empty( $version ) ) {
|
49 |
+
$version = $this->getWorkingVersion();
|
50 |
+
}
|
51 |
+
if ( empty( $version ) ) {
|
52 |
+
$version = ( new Versions() )
|
53 |
+
->setWorkingSlug( $this->getWorkingSlug() )
|
54 |
+
->latest();
|
55 |
+
}
|
56 |
+
return sprintf( '%s/%s',
|
57 |
+
static::GetUrlForThemeVersion( $this->getWorkingSlug(), $version ), ltrim( $fileFragment, '/' ) );
|
58 |
+
}
|
59 |
}
|
src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Wp/Repo.php
CHANGED
@@ -1,72 +1,72 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace FernleafSystems\Wordpress\Services\Utilities\WpOrg\Wp;
|
4 |
-
|
5 |
-
use FernleafSystems\Wordpress\Services;
|
6 |
-
|
7 |
-
class Repo extends Services\Utilities\WpOrg\Base\RepoBase {
|
8 |
-
|
9 |
-
const URL_VCS_ROOT = 'https://core.svn.wordpress.org';
|
10 |
-
const URL_VCS_ROOT_IL8N = 'https://i18n.svn.wordpress.org';
|
11 |
-
|
12 |
-
/**
|
13 |
-
* @param string $version
|
14 |
-
* @param bool $useLocale
|
15 |
-
* @return string
|
16 |
-
*/
|
17 |
-
public static function GetUrlForVersion( $version, $useLocale = true ) {
|
18 |
-
return sprintf(
|
19 |
-
'%s/tags/%s',
|
20 |
-
$useLocale ? static::URL_VCS_ROOT_IL8N : static::URL_VCS_ROOT,
|
21 |
-
$useLocale ? $version.'/dist' : $version
|
22 |
-
);
|
23 |
-
}
|
24 |
-
|
25 |
-
/**
|
26 |
-
* @return string
|
27 |
-
*/
|
28 |
-
public static function GetUrlForVersions() {
|
29 |
-
return static::GetUrlForVersion( '' );
|
30 |
-
}
|
31 |
-
|
32 |
-
/**
|
33 |
-
* @param string $fileFragment
|
34 |
-
* @param string $version
|
35 |
-
* @param bool $useSiteLocale
|
36 |
-
* @return string|null
|
37 |
-
*/
|
38 |
-
public function downloadFromVcs( $fileFragment, $version = null, $useSiteLocale = true ) {
|
39 |
-
$file = parent::downloadFromVcs( $fileFragment, $version, $useSiteLocale );
|
40 |
-
if ( $useSiteLocale && empty( $file ) ) {
|
41 |
-
$file = parent::downloadFromVcs( $fileFragment, $version, false );
|
42 |
-
}
|
43 |
-
return $file;
|
44 |
-
}
|
45 |
-
|
46 |
-
/**
|
47 |
-
* @param string $fileFragment
|
48 |
-
* @param string $version - leave empty to use the current version
|
49 |
-
* @param bool $useSiteLocale
|
50 |
-
* @return bool
|
51 |
-
*/
|
52 |
-
public function existsInVcs( $fileFragment, $version = null, $useSiteLocale = true ) {
|
53 |
-
$file = parent::existsInVcs( $fileFragment, $version, $useSiteLocale );
|
54 |
-
if ( $useSiteLocale && empty( $file ) ) {
|
55 |
-
$file = parent::existsInVcs( $fileFragment, $version, false );
|
56 |
-
}
|
57 |
-
return $file;
|
58 |
-
}
|
59 |
-
|
60 |
-
/**
|
61 |
-
* @param string $fileFragment
|
62 |
-
* @param string $version
|
63 |
-
* @param bool $useSiteLocale
|
64 |
-
* @return string
|
65 |
-
*/
|
66 |
-
|
67 |
-
if ( empty( $version ) ) {
|
68 |
-
$version = Services\Services::WpGeneral()->getVersion();
|
69 |
-
}
|
70 |
-
return sprintf( '%s/%s', static::GetUrlForVersion( $version, $useSiteLocale ), ltrim( $fileFragment, '/' ) );
|
71 |
-
}
|
72 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace FernleafSystems\Wordpress\Services\Utilities\WpOrg\Wp;
|
4 |
+
|
5 |
+
use FernleafSystems\Wordpress\Services;
|
6 |
+
|
7 |
+
class Repo extends Services\Utilities\WpOrg\Base\RepoBase {
|
8 |
+
|
9 |
+
const URL_VCS_ROOT = 'https://core.svn.wordpress.org';
|
10 |
+
const URL_VCS_ROOT_IL8N = 'https://i18n.svn.wordpress.org';
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @param string $version
|
14 |
+
* @param bool $useLocale
|
15 |
+
* @return string
|
16 |
+
*/
|
17 |
+
public static function GetUrlForVersion( $version, $useLocale = true ) {
|
18 |
+
return sprintf(
|
19 |
+
'%s/tags/%s',
|
20 |
+
$useLocale ? static::URL_VCS_ROOT_IL8N : static::URL_VCS_ROOT,
|
21 |
+
$useLocale ? $version.'/dist' : $version
|
22 |
+
);
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* @return string
|
27 |
+
*/
|
28 |
+
public static function GetUrlForVersions() {
|
29 |
+
return static::GetUrlForVersion( '' );
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* @param string $fileFragment
|
34 |
+
* @param string $version
|
35 |
+
* @param bool $useSiteLocale
|
36 |
+
* @return string|null
|
37 |
+
*/
|
38 |
+
public function downloadFromVcs( $fileFragment, $version = null, $useSiteLocale = true ) {
|
39 |
+
$file = parent::downloadFromVcs( $fileFragment, $version, $useSiteLocale );
|
40 |
+
if ( $useSiteLocale && empty( $file ) ) {
|
41 |
+
$file = parent::downloadFromVcs( $fileFragment, $version, false );
|
42 |
+
}
|
43 |
+
return $file;
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* @param string $fileFragment
|
48 |
+
* @param string $version - leave empty to use the current version
|
49 |
+
* @param bool $useSiteLocale
|
50 |
+
* @return bool
|
51 |
+
*/
|
52 |
+
public function existsInVcs( $fileFragment, $version = null, $useSiteLocale = true ) {
|
53 |
+
$file = parent::existsInVcs( $fileFragment, $version, $useSiteLocale );
|
54 |
+
if ( $useSiteLocale && empty( $file ) ) {
|
55 |
+
$file = parent::existsInVcs( $fileFragment, $version, false );
|
56 |
+
}
|
57 |
+
return $file;
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* @param string $fileFragment
|
62 |
+
* @param string $version
|
63 |
+
* @param bool $useSiteLocale
|
64 |
+
* @return string
|
65 |
+
*/
|
66 |
+
public function getVcsUrlForFileAndVersion( $fileFragment, $version, $useSiteLocale = true ) {
|
67 |
+
if ( empty( $version ) ) {
|
68 |
+
$version = Services\Services::WpGeneral()->getVersion();
|
69 |
+
}
|
70 |
+
return sprintf( '%s/%s', static::GetUrlForVersion( $version, $useSiteLocale ), ltrim( $fileFragment, '/' ) );
|
71 |
+
}
|
72 |
}
|