Shield Security for WordPress - Version 12.0.13

Version Description

Download this release

Release Info

Developer paultgoodchild
Plugin Icon 128x128 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 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.12
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.12",
4
- "release_timestamp": 1633596601,
5
- "build": "202110.0702",
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.12",
4
- "release_timestamp": 1633596601,
5
- "build": "202110.0702",
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
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 $aTrackingInfo
96
  * @return $this
97
  */
98
- public function setDelayTracking( $aTrackingInfo ) {
99
- return $this->setOpt( 'delay_tracking', $aTrackingInfo );
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 $oOpts */
21
- $oOpts = $this->getOptions();
22
 
23
- $nPriority = $this->getHookPriority();
24
  if ( Services::WpGeneral()->isClassicPress() ) {
25
- add_filter( 'allow_patch_auto_core_updates', [ $this, 'autoupdate_core_minor' ], $nPriority );
26
- add_filter( 'allow_minor_auto_core_updates', [ $this, 'autoupdate_core_major' ], $nPriority );
27
  }
28
  else {
29
- add_filter( 'allow_minor_auto_core_updates', [ $this, 'autoupdate_core_minor' ], $nPriority );
30
- add_filter( 'allow_major_auto_core_updates', [ $this, 'autoupdate_core_major' ], $nPriority );
31
  }
32
 
33
- add_filter( 'auto_update_plugin', [ $this, 'autoupdate_plugins' ], $nPriority, 2 );
34
- add_filter( 'auto_update_theme', [ $this, 'autoupdate_themes' ], $nPriority, 2 );
35
- add_filter( 'auto_update_core', [ $this, 'autoupdate_core' ], $nPriority, 2 );
36
 
37
- if ( !$oOpts->isDisableAllAutoUpdates() ) {
38
  //more parameter options here for later
39
- add_filter( 'auto_core_update_send_email', [ $this, 'autoupdate_send_email' ], $nPriority, 1 );
40
- add_filter( 'auto_core_update_email', [ $this, 'autoupdate_email_override' ], $nPriority, 1 );
41
- add_filter( 'auto_plugin_theme_update_email', [ $this, 'autoupdate_email_override' ], $nPriority, 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 ( $oOpts->isSendAutoupdatesNotificationEmail()
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 $oOpts */
102
- $oOpts = $this->getOptions();
103
 
104
- $aTk = $oOpts->getDelayTracking();
105
- $aItemTk = isset( $aTk[ 'core' ][ 'wp' ] ) ? $aTk[ 'core' ][ 'wp' ] : [];
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
- $aTk[ 'core' ][ 'wp' ] = array_slice( $aItemTk, -5 );
115
- $oOpts->setDelayTracking( $aTk );
116
  }
117
  }
118
 
119
  /**
120
- * @param \stdClass $oUpdates
121
  */
122
- public function trackUpdateTimesPlugins( $oUpdates ) {
123
- $this->trackUpdateTimeCommon( $oUpdates, 'plugins' );
124
  }
125
 
126
  /**
127
- * @param \stdClass $oUpdates
128
  */
129
- public function trackUpdateTimesThemes( $oUpdates ) {
130
- $this->trackUpdateTimeCommon( $oUpdates, 'themes' );
131
  }
132
 
133
  /**
134
- * @param \stdClass $oUpdates
135
- * @param string $sContext - plugins/themes
136
  */
137
- protected function trackUpdateTimeCommon( $oUpdates, $sContext ) {
138
- /** @var Options $oOpts */
139
- $oOpts = $this->getOptions();
140
 
141
- if ( !empty( $oUpdates ) && isset( $oUpdates->response ) && is_array( $oUpdates->response ) ) {
142
 
143
- $aTk = $oOpts->getDelayTracking();
144
- foreach ( $oUpdates->response as $sSlug => $oUpdate ) {
145
- $aItemTk = isset( $aTk[ $sContext ][ $sSlug ] ) ? $aTk[ $sContext ][ $sSlug ] : [];
146
- if ( is_array( $oUpdate ) ) {
147
- $oUpdate = (object)$oUpdate;
148
  }
149
 
150
- $sNewVersion = isset( $oUpdate->new_version ) ? $oUpdate->new_version : '';
151
- if ( !empty( $sNewVersion ) ) {
152
- if ( !isset( $aItemTk[ $sNewVersion ] ) ) {
153
- $aItemTk[ $sNewVersion ] = Services::Request()->ts();
154
  }
155
- $aTk[ $sContext ][ $sSlug ] = array_slice( $aItemTk, -3 );
156
  }
157
  }
158
- $oOpts->setDelayTracking( $aTk );
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 $bUpdate
166
  * @return bool
167
  */
168
- public function autoupdate_core_major( $bUpdate ) {
169
- /** @var Options $oOpts */
170
- $oOpts = $this->getOptions();
171
 
172
- if ( $oOpts->isDisableAllAutoUpdates() || $oOpts->isAutoUpdateCoreNever() ) {
173
- $bUpdate = false;
174
  }
175
- elseif ( !$oOpts->isDelayUpdates() ) { // delay handled elsewhere
176
- $bUpdate = $oOpts->isAutoUpdateCoreMajor();
177
  }
178
 
179
- return $bUpdate;
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 $bUpdate
186
  * @return bool
187
  */
188
- public function autoupdate_core_minor( $bUpdate ) {
189
- /** @var Options $oOpts */
190
- $oOpts = $this->getOptions();
191
 
192
- if ( $oOpts->isDisableAllAutoUpdates() || $oOpts->isAutoUpdateCoreNever() ) {
193
- $bUpdate = false;
194
  }
195
- elseif ( !$oOpts->isDelayUpdates() ) {
196
- $bUpdate = !$oOpts->isAutoUpdateCoreNever();
197
  }
198
- return $bUpdate;
199
  }
200
 
201
  /**
202
- * @param bool $bDoAutoUpdate
203
- * @param \stdClass $oCoreUpdate
204
  * @return bool
205
  */
206
- public function autoupdate_core( $bDoAutoUpdate, $oCoreUpdate ) {
207
- /** @var Options $oOpts */
208
- $oOpts = $this->getOptions();
209
 
210
- if ( $oOpts->isDisableAllAutoUpdates() ) {
211
- $bDoAutoUpdate = false;
212
  }
213
- elseif ( $this->isDelayed( $oCoreUpdate, 'core' ) ) {
214
- $bDoAutoUpdate = false;
215
  }
216
 
217
- return $bDoAutoUpdate;
218
  }
219
 
220
  /**
221
- * @param bool $bDoAutoUpdate
222
  * @param \stdClass|string $mItem
223
  * @return bool
224
  */
225
- public function autoupdate_plugins( $bDoAutoUpdate, $mItem ) {
226
- /** @var Options $oOpts */
227
- $oOpts = $this->getOptions();
228
 
229
- if ( $oOpts->isDisableAllAutoUpdates() ) {
230
- $bDoAutoUpdate = false;
231
  }
232
  else {
233
  $file = Services::WpGeneral()->getFileFromAutomaticUpdateItem( $mItem );
234
 
235
  if ( $this->isDelayed( $file, 'plugins' ) ) {
236
- $bDoAutoUpdate = false;
237
  }
238
- elseif ( $oOpts->isAutoupdateAllPlugins() ) {
239
- $bDoAutoUpdate = true;
240
  }
241
  elseif ( $file === $this->getCon()->base_file ) {
242
- $sAuto = $oOpts->getSelfAutoUpdateOpt();
243
- if ( $sAuto === 'immediate' ) {
244
- $bDoAutoUpdate = true;
245
  }
246
- elseif ( $sAuto === 'disabled' ) {
247
- $bDoAutoUpdate = false;
248
  }
249
  }
250
  }
251
 
252
- return $bDoAutoUpdate;
253
  }
254
 
255
  /**
256
- * @param bool $bDoAutoUpdate
257
  * @param \stdClass|string $mItem
258
  * @return bool
259
  */
260
- public function autoupdate_themes( $bDoAutoUpdate, $mItem ) {
261
  /** @var Options $opts */
262
  $opts = $this->getOptions();
263
 
264
  if ( $opts->isDisableAllAutoUpdates() ) {
265
- $bDoAutoUpdate = false;
266
  }
267
  else {
268
  $file = Services::WpGeneral()->getFileFromAutomaticUpdateItem( $mItem, 'theme' );
269
 
270
  if ( $this->isDelayed( $file, 'themes' ) ) {
271
- $bDoAutoUpdate = false;
272
  }
273
  elseif ( $opts->isOpt( 'enable_autoupdate_themes', 'Y' ) ) {
274
- $bDoAutoUpdate = true;
275
  }
276
  }
277
 
278
- return $bDoAutoUpdate;
279
  }
280
 
281
  /**
282
- * @param string|\stdClass $sSlug
283
- * @param string $sContext
284
- * @return bool
285
  */
286
- private function isDelayed( $sSlug, $sContext = 'plugins' ) {
287
- /** @var Options $oOpts */
288
- $oOpts = $this->getOptions();
289
 
290
- $bDelayed = false;
291
 
292
- if ( $oOpts->isDelayUpdates() ) {
293
 
294
- $aTk = $oOpts->getDelayTracking();
295
 
296
- $sVersion = '';
297
- if ( $sContext == 'core' ) {
298
- $sVersion = $sSlug->current; // \stdClass from transient update_core
299
- $sSlug = 'wp';
300
  }
301
 
302
- $aItemTk = isset( $aTk[ $sContext ][ $sSlug ] ) ? $aTk[ $sContext ][ $sSlug ] : [];
303
 
304
- if ( $sContext == 'plugins' ) {
305
- $oPlugin = Services::WpPlugins()->getUpdateInfo( $sSlug );
306
- $sVersion = isset( $oPlugin->new_version ) ? $oPlugin->new_version : '';
307
  }
308
- elseif ( $sContext == 'themes' ) {
309
- $aThemeInfo = Services::WpThemes()->getUpdateInfo( $sSlug );
310
- $sVersion = isset( $aThemeInfo[ 'new_version' ] ) ? $aThemeInfo[ 'new_version' ] : '';
311
  }
312
 
313
- if ( !empty( $sVersion ) && isset( $aItemTk[ $sVersion ] ) ) {
314
- $bDelayed = ( Services::Request()->ts() - $aItemTk[ $sVersion ] < $oOpts->getDelayUpdatesPeriod() );
315
  }
316
  }
317
 
318
- return $bDelayed;
319
  }
320
 
321
  /**
322
- * A filter on whether or not a notification email is sent after core upgrades are attempted.
323
- * @param bool $bSendEmail
324
  * @return bool
325
  */
326
- public function autoupdate_send_email( $bSendEmail ) {
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 $aEmailParams
335
  * @return array
336
  */
337
- public function autoupdate_email_override( $aEmailParams ) {
338
- $sOverride = $this->getOptions()->getOpt( 'override_email_address', '' );
339
- if ( Services::Data()->validEmail( $sOverride ) ) {
340
- $aEmailParams[ 'to' ] = $sOverride;
341
  }
342
- return $aEmailParams;
343
  }
344
 
345
  /**
@@ -361,16 +360,16 @@ class Processor extends BaseShield\Processor {
361
  ''
362
  ];
363
 
364
- $aTrkd = $this->getTrackedAssetsVersions();
365
 
366
- $oWpPlugins = Services::WpPlugins();
367
  if ( !empty( $aUpdateResults[ 'plugin' ] ) && is_array( $aUpdateResults[ 'plugin' ] ) ) {
368
  $bHasPluginUpdates = false;
369
- $aTrkdPlugs = $aTrkd[ 'plugins' ];
370
 
371
  $aTempContent[] = __( 'Plugins Updated:', 'wp-simple-firewall' );
372
  foreach ( $aUpdateResults[ 'plugin' ] as $oUpdate ) {
373
- $oP = $oWpPlugins->getPluginAsVo( $oUpdate->item->plugin, true );
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 = $aTrkd[ 'themes' ];
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
- $this->getOptions()->getOpt( 'override_email_address' ),
444
  sprintf( __( "Notice: %s", 'wp-simple-firewall' ), __( "Automatic Updates Completed", 'wp-simple-firewall' ) ),
445
- $body
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
- $sAuthor = Services::Request()->query( 'author', '' );
96
- if ( !empty( $sAuthor ) ) {
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
- if ( !$sessCon->hasSession() && $mod->isAutoAddSessions() ) {
64
- $user = Services::WpUsers()->getCurrentWpUser();
65
- if ( $user instanceof \WP_User ) {
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 protected function getVcsUrlForFileAndVersion( $fileFragment, $version, $useSiteLocale = true );
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
- protected 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
  }
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
- protected 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
  }
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 instanceof Services\Core\VOs\Assets\WpThemeVo ) {
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
- protected 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
  }
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
- protected 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
  }
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
  }