PluginProbe
PhastPress / 3.9
PhastPress v3.9
3.12 3.11 1.75 1.76 1.77 1.78 1.79 1.80 1.81 1.82 1.83 1.84 1.85 1.86 1.87 1.88 1.89 1.90 1.91 1.92 1.93 1.94 1.95 1.96 1.97 All 119 releases
phastpress / classes / ServiceSDKImplementation.php

ServiceSDKImplementation.php in PhastPress 3.9, at classes/ServiceSDKImplementation.php

48 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Kibo\PhastPlugins\PhastPress;
3
4 use Kibo\Phast\HTTP\Request;
5 use Kibo\PhastPlugins\SDK\ServiceHost;
6
7 class ServiceSDKImplementation implements ServiceHost {
8 public function getCacheRootCandidatesProvider() {
9 return new CacheRootCandidatesProviderImplementation();
10 }
11
12 public function onServiceConfigurationLoad(array $config) {
13 if (class_exists(\WpOrg\Requests\Requests::class)) {
14 $config['httpClient'] = RequestsHTTPClient::class;
15 }
16
17 if ($map = $this->getRetrieverMap()) {
18 $config['retrieverMap'] = $map;
19 }
20
21 return $config;
22 }
23
24 private function getRetrieverMap() {
25 if (!defined('MULTISITE')
26 || !MULTISITE
27 || !defined('SUBDOMAIN_INSTALL')
28 || SUBDOMAIN_INSTALL
29 ) {
30 return null;
31 }
32
33 $request = Request::fromGlobals();
34
35 $map = [
36 '/' => $request->getDocumentRoot(),
37 ];
38
39 foreach (['wp-content', 'wp-admin', 'wp-includes'] as $dir) {
40 $map["/[_0-9a-zA-Z-]+/$dir/"] = "{$request->getDocumentRoot()}/$dir";
41 }
42
43 return [
44 $request->getHost() => $map,
45 ];
46 }
47 }
48