@@ -6,6 +6,6 @@ |
||
6 | 6 | $baseDir = dirname($vendorDir); |
7 | 7 | |
8 | 8 | return array( |
9 | - '5255c38a0faeba867671b61dfda6d864' => $vendorDir . '/paragonie/random_compat/lib/random.php', |
|
10 | - '3109cb1a231dcd04bee1f9f620d46975' => $vendorDir . '/paragonie/sodium_compat/autoload.php', |
|
9 | + '5255c38a0faeba867671b61dfda6d864' => $vendorDir . '/paragonie/random_compat/lib/random.php', |
|
10 | + '3109cb1a231dcd04bee1f9f620d46975' => $vendorDir . '/paragonie/sodium_compat/autoload.php', |
|
11 | 11 | ); |
@@ -2,8 +2,8 @@ |
||
2 | 2 | |
3 | 3 | // autoload_files.php @generated by Composer |
4 | 4 | |
5 | -$vendorDir = dirname(dirname(__FILE__)); |
|
6 | -$baseDir = dirname($vendorDir); |
|
5 | +$vendorDir = dirname( dirname( __FILE__ ) ); |
|
6 | +$baseDir = dirname( $vendorDir ); |
|
7 | 7 | |
8 | 8 | return array( |
9 | 9 | '5255c38a0faeba867671b61dfda6d864' => $vendorDir . '/paragonie/random_compat/lib/random.php', |
@@ -6,185 +6,185 @@ |
||
6 | 6 | |
7 | 7 | class ComposerStaticInit984ed95bef2b0e3d4eeb0208a88dc67d |
8 | 8 | { |
9 | - public static $files = array ( |
|
10 | - '5255c38a0faeba867671b61dfda6d864' => __DIR__ . '/..' . '/paragonie/random_compat/lib/random.php', |
|
11 | - '3109cb1a231dcd04bee1f9f620d46975' => __DIR__ . '/..' . '/paragonie/sodium_compat/autoload.php', |
|
12 | - ); |
|
9 | + public static $files = array ( |
|
10 | + '5255c38a0faeba867671b61dfda6d864' => __DIR__ . '/..' . '/paragonie/random_compat/lib/random.php', |
|
11 | + '3109cb1a231dcd04bee1f9f620d46975' => __DIR__ . '/..' . '/paragonie/sodium_compat/autoload.php', |
|
12 | + ); |
|
13 | 13 | |
14 | - public static $prefixLengthsPsr4 = array ( |
|
15 | - 'T' => |
|
16 | - array ( |
|
17 | - 'TrustedLogin\\' => 13, |
|
18 | - ), |
|
19 | - 'P' => |
|
20 | - array ( |
|
21 | - 'Psr\\Log\\' => 8, |
|
22 | - ), |
|
23 | - 'K' => |
|
24 | - array ( |
|
25 | - 'Katzgrau\\KLogger\\' => 17, |
|
26 | - 'KatzGrau\\KLogger\\' => 17, |
|
27 | - ), |
|
28 | - ); |
|
14 | + public static $prefixLengthsPsr4 = array ( |
|
15 | + 'T' => |
|
16 | + array ( |
|
17 | + 'TrustedLogin\\' => 13, |
|
18 | + ), |
|
19 | + 'P' => |
|
20 | + array ( |
|
21 | + 'Psr\\Log\\' => 8, |
|
22 | + ), |
|
23 | + 'K' => |
|
24 | + array ( |
|
25 | + 'Katzgrau\\KLogger\\' => 17, |
|
26 | + 'KatzGrau\\KLogger\\' => 17, |
|
27 | + ), |
|
28 | + ); |
|
29 | 29 | |
30 | - public static $prefixDirsPsr4 = array ( |
|
31 | - 'TrustedLogin\\' => |
|
32 | - array ( |
|
33 | - 0 => __DIR__ . '/../..' . '/src', |
|
34 | - 1 => __DIR__ . '/..' . '/trustedlogin/client/src', |
|
35 | - ), |
|
36 | - 'Psr\\Log\\' => |
|
37 | - array ( |
|
38 | - 0 => __DIR__ . '/..' . '/psr/log/Psr/Log', |
|
39 | - ), |
|
40 | - 'Katzgrau\\KLogger\\' => |
|
41 | - array ( |
|
42 | - 0 => __DIR__ . '/..' . '/katzgrau/klogger/src', |
|
43 | - ), |
|
44 | - 'KatzGrau\\KLogger\\' => |
|
45 | - array ( |
|
46 | - 0 => __DIR__ . '/../..' . '/src', |
|
47 | - ), |
|
48 | - ); |
|
30 | + public static $prefixDirsPsr4 = array ( |
|
31 | + 'TrustedLogin\\' => |
|
32 | + array ( |
|
33 | + 0 => __DIR__ . '/../..' . '/src', |
|
34 | + 1 => __DIR__ . '/..' . '/trustedlogin/client/src', |
|
35 | + ), |
|
36 | + 'Psr\\Log\\' => |
|
37 | + array ( |
|
38 | + 0 => __DIR__ . '/..' . '/psr/log/Psr/Log', |
|
39 | + ), |
|
40 | + 'Katzgrau\\KLogger\\' => |
|
41 | + array ( |
|
42 | + 0 => __DIR__ . '/..' . '/katzgrau/klogger/src', |
|
43 | + ), |
|
44 | + 'KatzGrau\\KLogger\\' => |
|
45 | + array ( |
|
46 | + 0 => __DIR__ . '/../..' . '/src', |
|
47 | + ), |
|
48 | + ); |
|
49 | 49 | |
50 | - public static $classMap = array ( |
|
51 | - 'ComposerAutoloaderInitb5638313a52df4893eb45c04efdaa356' => __DIR__ . '/..' . '/trustedlogin/client/vendor/composer/autoload_real.php', |
|
52 | - 'Composer\\Autoload\\ClassLoader' => __DIR__ . '/..' . '/trustedlogin/client/vendor/composer/ClassLoader.php', |
|
53 | - 'Composer\\Autoload\\ComposerStaticInitb5638313a52df4893eb45c04efdaa356' => __DIR__ . '/..' . '/trustedlogin/client/vendor/composer/autoload_static.php', |
|
54 | - 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', |
|
55 | - 'Error' => __DIR__ . '/..' . '/paragonie/random_compat/lib/error_polyfill.php', |
|
56 | - 'Katzgrau\\KLogger\\Logger' => __DIR__ . '/..' . '/katzgrau/klogger/src/Logger.php', |
|
57 | - 'Katzgrau\\KLogger\\TrustedLogin_Logger' => __DIR__ . '/..' . '/trustedlogin/client/vendor/TrustedLogin/katzgrau/klogger/src/Logger.php', |
|
58 | - 'LoggerTest' => __DIR__ . '/..' . '/katzgrau/klogger/tests/LoggerTest.php', |
|
59 | - 'ParagonIE\\Sodium\\Compat' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/Compat.php', |
|
60 | - 'ParagonIE\\Sodium\\Core\\BLAKE2b' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/Core/BLAKE2b.php', |
|
61 | - 'ParagonIE\\Sodium\\Core\\ChaCha20' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/Core/ChaCha20.php', |
|
62 | - 'ParagonIE\\Sodium\\Core\\ChaCha20\\Ctx' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/Core/ChaCha20/Ctx.php', |
|
63 | - 'ParagonIE\\Sodium\\Core\\ChaCha20\\IetfCtx' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/Core/ChaCha20/IetfCtx.php', |
|
64 | - 'ParagonIE\\Sodium\\Core\\Curve25519' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/Core/Curve25519.php', |
|
65 | - 'ParagonIE\\Sodium\\Core\\Curve25519\\Fe' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/Core/Curve25519/Fe.php', |
|
66 | - 'ParagonIE\\Sodium\\Core\\Curve25519\\Ge\\Cached' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/Core/Curve25519/Ge/Cached.php', |
|
67 | - 'ParagonIE\\Sodium\\Core\\Curve25519\\Ge\\P1p1' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/Core/Curve25519/Ge/P1p1.php', |
|
68 | - 'ParagonIE\\Sodium\\Core\\Curve25519\\Ge\\P2' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/Core/Curve25519/Ge/P2.php', |
|
69 | - 'ParagonIE\\Sodium\\Core\\Curve25519\\Ge\\P3' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/Core/Curve25519/Ge/P3.php', |
|
70 | - 'ParagonIE\\Sodium\\Core\\Curve25519\\Ge\\Precomp' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/Core/Curve25519/Ge/Precomp.php', |
|
71 | - 'ParagonIE\\Sodium\\Core\\Curve25519\\H' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/Core/Curve25519/H.php', |
|
72 | - 'ParagonIE\\Sodium\\Core\\Ed25519' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/Core/Ed25519.php', |
|
73 | - 'ParagonIE\\Sodium\\Core\\HChaCha20' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/Core/HChaCha20.php', |
|
74 | - 'ParagonIE\\Sodium\\Core\\HSalsa20' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/Core/HSalsa20.php', |
|
75 | - 'ParagonIE\\Sodium\\Core\\Poly1305' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/Core/Poly1305.php', |
|
76 | - 'ParagonIE\\Sodium\\Core\\Poly1305\\State' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/Core/Poly1305/State.php', |
|
77 | - 'ParagonIE\\Sodium\\Core\\Salsa20' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/Core/Salsa20.php', |
|
78 | - 'ParagonIE\\Sodium\\Core\\SipHash' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/Core/SipHash.php', |
|
79 | - 'ParagonIE\\Sodium\\Core\\Util' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/Core/Util.php', |
|
80 | - 'ParagonIE\\Sodium\\Core\\X25519' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/Core/X25519.php', |
|
81 | - 'ParagonIE\\Sodium\\Core\\XChaCha20' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/Core/XChaCha20.php', |
|
82 | - 'ParagonIE\\Sodium\\Core\\Xsalsa20' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/Core/Xsalsa20.php', |
|
83 | - 'ParagonIE\\Sodium\\Crypto' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/Crypto.php', |
|
84 | - 'ParagonIE\\Sodium\\File' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/File.php', |
|
85 | - 'ParagonIE_Sodium_Compat' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Compat.php', |
|
86 | - 'ParagonIE_Sodium_Core32_BLAKE2b' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/BLAKE2b.php', |
|
87 | - 'ParagonIE_Sodium_Core32_ChaCha20' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/ChaCha20.php', |
|
88 | - 'ParagonIE_Sodium_Core32_ChaCha20_Ctx' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/ChaCha20/Ctx.php', |
|
89 | - 'ParagonIE_Sodium_Core32_ChaCha20_IetfCtx' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/ChaCha20/IetfCtx.php', |
|
90 | - 'ParagonIE_Sodium_Core32_Curve25519' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/Curve25519.php', |
|
91 | - 'ParagonIE_Sodium_Core32_Curve25519_Fe' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/Curve25519/Fe.php', |
|
92 | - 'ParagonIE_Sodium_Core32_Curve25519_Ge_Cached' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/Curve25519/Ge/Cached.php', |
|
93 | - 'ParagonIE_Sodium_Core32_Curve25519_Ge_P1p1' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/Curve25519/Ge/P1p1.php', |
|
94 | - 'ParagonIE_Sodium_Core32_Curve25519_Ge_P2' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/Curve25519/Ge/P2.php', |
|
95 | - 'ParagonIE_Sodium_Core32_Curve25519_Ge_P3' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/Curve25519/Ge/P3.php', |
|
96 | - 'ParagonIE_Sodium_Core32_Curve25519_Ge_Precomp' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/Curve25519/Ge/Precomp.php', |
|
97 | - 'ParagonIE_Sodium_Core32_Curve25519_H' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/Curve25519/H.php', |
|
98 | - 'ParagonIE_Sodium_Core32_Ed25519' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/Ed25519.php', |
|
99 | - 'ParagonIE_Sodium_Core32_HChaCha20' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/HChaCha20.php', |
|
100 | - 'ParagonIE_Sodium_Core32_HSalsa20' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/HSalsa20.php', |
|
101 | - 'ParagonIE_Sodium_Core32_Int32' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/Int32.php', |
|
102 | - 'ParagonIE_Sodium_Core32_Int64' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/Int64.php', |
|
103 | - 'ParagonIE_Sodium_Core32_Poly1305' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/Poly1305.php', |
|
104 | - 'ParagonIE_Sodium_Core32_Poly1305_State' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/Poly1305/State.php', |
|
105 | - 'ParagonIE_Sodium_Core32_Salsa20' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/Salsa20.php', |
|
106 | - 'ParagonIE_Sodium_Core32_SecretStream_State' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/SecretStream/State.php', |
|
107 | - 'ParagonIE_Sodium_Core32_SipHash' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/SipHash.php', |
|
108 | - 'ParagonIE_Sodium_Core32_Util' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/Util.php', |
|
109 | - 'ParagonIE_Sodium_Core32_X25519' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/X25519.php', |
|
110 | - 'ParagonIE_Sodium_Core32_XChaCha20' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/XChaCha20.php', |
|
111 | - 'ParagonIE_Sodium_Core32_XSalsa20' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/XSalsa20.php', |
|
112 | - 'ParagonIE_Sodium_Core_BLAKE2b' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/BLAKE2b.php', |
|
113 | - 'ParagonIE_Sodium_Core_Base64_Common' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/Base64/Common.php', |
|
114 | - 'ParagonIE_Sodium_Core_Base64_Original' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/Base64/Original.php', |
|
115 | - 'ParagonIE_Sodium_Core_Base64_UrlSafe' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/Base64/UrlSafe.php', |
|
116 | - 'ParagonIE_Sodium_Core_ChaCha20' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/ChaCha20.php', |
|
117 | - 'ParagonIE_Sodium_Core_ChaCha20_Ctx' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/ChaCha20/Ctx.php', |
|
118 | - 'ParagonIE_Sodium_Core_ChaCha20_IetfCtx' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/ChaCha20/IetfCtx.php', |
|
119 | - 'ParagonIE_Sodium_Core_Curve25519' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/Curve25519.php', |
|
120 | - 'ParagonIE_Sodium_Core_Curve25519_Fe' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/Curve25519/Fe.php', |
|
121 | - 'ParagonIE_Sodium_Core_Curve25519_Ge_Cached' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/Curve25519/Ge/Cached.php', |
|
122 | - 'ParagonIE_Sodium_Core_Curve25519_Ge_P1p1' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/Curve25519/Ge/P1p1.php', |
|
123 | - 'ParagonIE_Sodium_Core_Curve25519_Ge_P2' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/Curve25519/Ge/P2.php', |
|
124 | - 'ParagonIE_Sodium_Core_Curve25519_Ge_P3' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/Curve25519/Ge/P3.php', |
|
125 | - 'ParagonIE_Sodium_Core_Curve25519_Ge_Precomp' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/Curve25519/Ge/Precomp.php', |
|
126 | - 'ParagonIE_Sodium_Core_Curve25519_H' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/Curve25519/H.php', |
|
127 | - 'ParagonIE_Sodium_Core_Ed25519' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/Ed25519.php', |
|
128 | - 'ParagonIE_Sodium_Core_HChaCha20' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/HChaCha20.php', |
|
129 | - 'ParagonIE_Sodium_Core_HSalsa20' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/HSalsa20.php', |
|
130 | - 'ParagonIE_Sodium_Core_Poly1305' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/Poly1305.php', |
|
131 | - 'ParagonIE_Sodium_Core_Poly1305_State' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/Poly1305/State.php', |
|
132 | - 'ParagonIE_Sodium_Core_Ristretto255' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/Ristretto255.php', |
|
133 | - 'ParagonIE_Sodium_Core_Salsa20' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/Salsa20.php', |
|
134 | - 'ParagonIE_Sodium_Core_SecretStream_State' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/SecretStream/State.php', |
|
135 | - 'ParagonIE_Sodium_Core_SipHash' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/SipHash.php', |
|
136 | - 'ParagonIE_Sodium_Core_Util' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/Util.php', |
|
137 | - 'ParagonIE_Sodium_Core_X25519' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/X25519.php', |
|
138 | - 'ParagonIE_Sodium_Core_XChaCha20' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/XChaCha20.php', |
|
139 | - 'ParagonIE_Sodium_Core_XSalsa20' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/XSalsa20.php', |
|
140 | - 'ParagonIE_Sodium_Crypto' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Crypto.php', |
|
141 | - 'ParagonIE_Sodium_Crypto32' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Crypto32.php', |
|
142 | - 'ParagonIE_Sodium_File' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/File.php', |
|
143 | - 'Psr\\Log\\AbstractLogger' => __DIR__ . '/..' . '/psr/log/Psr/Log/AbstractLogger.php', |
|
144 | - 'Psr\\Log\\InvalidArgumentException' => __DIR__ . '/..' . '/psr/log/Psr/Log/InvalidArgumentException.php', |
|
145 | - 'Psr\\Log\\LogLevel' => __DIR__ . '/..' . '/psr/log/Psr/Log/LogLevel.php', |
|
146 | - 'Psr\\Log\\LoggerAwareInterface' => __DIR__ . '/..' . '/psr/log/Psr/Log/LoggerAwareInterface.php', |
|
147 | - 'Psr\\Log\\LoggerAwareTrait' => __DIR__ . '/..' . '/psr/log/Psr/Log/LoggerAwareTrait.php', |
|
148 | - 'Psr\\Log\\LoggerInterface' => __DIR__ . '/..' . '/psr/log/Psr/Log/LoggerInterface.php', |
|
149 | - 'Psr\\Log\\LoggerTrait' => __DIR__ . '/..' . '/psr/log/Psr/Log/LoggerTrait.php', |
|
150 | - 'Psr\\Log\\NullLogger' => __DIR__ . '/..' . '/psr/log/Psr/Log/NullLogger.php', |
|
151 | - 'Psr\\Log\\Test\\DummyTest' => __DIR__ . '/..' . '/psr/log/Psr/Log/Test/DummyTest.php', |
|
152 | - 'Psr\\Log\\Test\\LoggerInterfaceTest' => __DIR__ . '/..' . '/psr/log/Psr/Log/Test/LoggerInterfaceTest.php', |
|
153 | - 'Psr\\Log\\Test\\TestLogger' => __DIR__ . '/..' . '/psr/log/Psr/Log/Test/TestLogger.php', |
|
154 | - 'SodiumException' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/SodiumException.php', |
|
155 | - 'SplFixedArray' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/PHP52/SplFixedArray.php', |
|
156 | - 'TrustedLoginAJAXTest' => __DIR__ . '/..' . '/trustedlogin/client/tests/test-ajax.php', |
|
157 | - 'TrustedLoginConfigTest' => __DIR__ . '/..' . '/trustedlogin/client/tests/test-config.php', |
|
158 | - 'TrustedLoginUsersTest' => __DIR__ . '/..' . '/trustedlogin/client/tests/test-users.php', |
|
159 | - 'TrustedLogin\\Admin' => __DIR__ . '/..' . '/trustedlogin/client/src/Admin.php', |
|
160 | - 'TrustedLogin\\Ajax' => __DIR__ . '/..' . '/trustedlogin/client/src/Ajax.php', |
|
161 | - 'TrustedLogin\\Client' => __DIR__ . '/..' . '/trustedlogin/client/src/Client.php', |
|
162 | - 'TrustedLogin\\Config' => __DIR__ . '/..' . '/trustedlogin/client/src/Config.php', |
|
163 | - 'TrustedLogin\\Cron' => __DIR__ . '/..' . '/trustedlogin/client/src/Cron.php', |
|
164 | - 'TrustedLogin\\Encryption' => __DIR__ . '/..' . '/trustedlogin/client/src/Encryption.php', |
|
165 | - 'TrustedLogin\\Endpoint' => __DIR__ . '/..' . '/trustedlogin/client/src/Endpoint.php', |
|
166 | - 'TrustedLogin\\Envelope' => __DIR__ . '/..' . '/trustedlogin/client/src/Envelope.php', |
|
167 | - 'TrustedLogin\\Logging' => __DIR__ . '/..' . '/trustedlogin/client/src/Logging.php', |
|
168 | - 'TrustedLogin\\Remote' => __DIR__ . '/..' . '/trustedlogin/client/src/Remote.php', |
|
169 | - 'TrustedLogin\\SecurityChecks' => __DIR__ . '/..' . '/trustedlogin/client/src/SecurityChecks.php', |
|
170 | - 'TrustedLogin\\SiteAccess' => __DIR__ . '/..' . '/trustedlogin/client/src/SiteAccess.php', |
|
171 | - 'TrustedLogin\\SupportRole' => __DIR__ . '/..' . '/trustedlogin/client/src/SupportRole.php', |
|
172 | - 'TrustedLogin\\SupportUser' => __DIR__ . '/..' . '/trustedlogin/client/src/SupportUser.php', |
|
173 | - 'TrustedLogin\\TrustedLoginClientTest' => __DIR__ . '/..' . '/trustedlogin/client/tests/test-client.php', |
|
174 | - 'TrustedLogin\\TrustedLoginEncryptionTest' => __DIR__ . '/..' . '/trustedlogin/client/tests/test-encryption.php', |
|
175 | - 'TrustedLogin\\TrustedLoginLoggingTest' => __DIR__ . '/..' . '/trustedlogin/client/tests/test-logging.php', |
|
176 | - 'TrustedLogin\\TrustedLoginRemoteTest' => __DIR__ . '/..' . '/trustedlogin/client/tests/test-remote.php', |
|
177 | - 'TrustedLogin\\TrustedLoginSiteAccessTest' => __DIR__ . '/..' . '/trustedlogin/client/tests/test-siteaccess.php', |
|
178 | - 'TypeError' => __DIR__ . '/..' . '/paragonie/random_compat/lib/error_polyfill.php', |
|
179 | - ); |
|
50 | + public static $classMap = array ( |
|
51 | + 'ComposerAutoloaderInitb5638313a52df4893eb45c04efdaa356' => __DIR__ . '/..' . '/trustedlogin/client/vendor/composer/autoload_real.php', |
|
52 | + 'Composer\\Autoload\\ClassLoader' => __DIR__ . '/..' . '/trustedlogin/client/vendor/composer/ClassLoader.php', |
|
53 | + 'Composer\\Autoload\\ComposerStaticInitb5638313a52df4893eb45c04efdaa356' => __DIR__ . '/..' . '/trustedlogin/client/vendor/composer/autoload_static.php', |
|
54 | + 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', |
|
55 | + 'Error' => __DIR__ . '/..' . '/paragonie/random_compat/lib/error_polyfill.php', |
|
56 | + 'Katzgrau\\KLogger\\Logger' => __DIR__ . '/..' . '/katzgrau/klogger/src/Logger.php', |
|
57 | + 'Katzgrau\\KLogger\\TrustedLogin_Logger' => __DIR__ . '/..' . '/trustedlogin/client/vendor/TrustedLogin/katzgrau/klogger/src/Logger.php', |
|
58 | + 'LoggerTest' => __DIR__ . '/..' . '/katzgrau/klogger/tests/LoggerTest.php', |
|
59 | + 'ParagonIE\\Sodium\\Compat' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/Compat.php', |
|
60 | + 'ParagonIE\\Sodium\\Core\\BLAKE2b' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/Core/BLAKE2b.php', |
|
61 | + 'ParagonIE\\Sodium\\Core\\ChaCha20' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/Core/ChaCha20.php', |
|
62 | + 'ParagonIE\\Sodium\\Core\\ChaCha20\\Ctx' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/Core/ChaCha20/Ctx.php', |
|
63 | + 'ParagonIE\\Sodium\\Core\\ChaCha20\\IetfCtx' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/Core/ChaCha20/IetfCtx.php', |
|
64 | + 'ParagonIE\\Sodium\\Core\\Curve25519' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/Core/Curve25519.php', |
|
65 | + 'ParagonIE\\Sodium\\Core\\Curve25519\\Fe' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/Core/Curve25519/Fe.php', |
|
66 | + 'ParagonIE\\Sodium\\Core\\Curve25519\\Ge\\Cached' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/Core/Curve25519/Ge/Cached.php', |
|
67 | + 'ParagonIE\\Sodium\\Core\\Curve25519\\Ge\\P1p1' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/Core/Curve25519/Ge/P1p1.php', |
|
68 | + 'ParagonIE\\Sodium\\Core\\Curve25519\\Ge\\P2' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/Core/Curve25519/Ge/P2.php', |
|
69 | + 'ParagonIE\\Sodium\\Core\\Curve25519\\Ge\\P3' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/Core/Curve25519/Ge/P3.php', |
|
70 | + 'ParagonIE\\Sodium\\Core\\Curve25519\\Ge\\Precomp' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/Core/Curve25519/Ge/Precomp.php', |
|
71 | + 'ParagonIE\\Sodium\\Core\\Curve25519\\H' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/Core/Curve25519/H.php', |
|
72 | + 'ParagonIE\\Sodium\\Core\\Ed25519' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/Core/Ed25519.php', |
|
73 | + 'ParagonIE\\Sodium\\Core\\HChaCha20' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/Core/HChaCha20.php', |
|
74 | + 'ParagonIE\\Sodium\\Core\\HSalsa20' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/Core/HSalsa20.php', |
|
75 | + 'ParagonIE\\Sodium\\Core\\Poly1305' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/Core/Poly1305.php', |
|
76 | + 'ParagonIE\\Sodium\\Core\\Poly1305\\State' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/Core/Poly1305/State.php', |
|
77 | + 'ParagonIE\\Sodium\\Core\\Salsa20' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/Core/Salsa20.php', |
|
78 | + 'ParagonIE\\Sodium\\Core\\SipHash' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/Core/SipHash.php', |
|
79 | + 'ParagonIE\\Sodium\\Core\\Util' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/Core/Util.php', |
|
80 | + 'ParagonIE\\Sodium\\Core\\X25519' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/Core/X25519.php', |
|
81 | + 'ParagonIE\\Sodium\\Core\\XChaCha20' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/Core/XChaCha20.php', |
|
82 | + 'ParagonIE\\Sodium\\Core\\Xsalsa20' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/Core/Xsalsa20.php', |
|
83 | + 'ParagonIE\\Sodium\\Crypto' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/Crypto.php', |
|
84 | + 'ParagonIE\\Sodium\\File' => __DIR__ . '/..' . '/paragonie/sodium_compat/namespaced/File.php', |
|
85 | + 'ParagonIE_Sodium_Compat' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Compat.php', |
|
86 | + 'ParagonIE_Sodium_Core32_BLAKE2b' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/BLAKE2b.php', |
|
87 | + 'ParagonIE_Sodium_Core32_ChaCha20' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/ChaCha20.php', |
|
88 | + 'ParagonIE_Sodium_Core32_ChaCha20_Ctx' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/ChaCha20/Ctx.php', |
|
89 | + 'ParagonIE_Sodium_Core32_ChaCha20_IetfCtx' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/ChaCha20/IetfCtx.php', |
|
90 | + 'ParagonIE_Sodium_Core32_Curve25519' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/Curve25519.php', |
|
91 | + 'ParagonIE_Sodium_Core32_Curve25519_Fe' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/Curve25519/Fe.php', |
|
92 | + 'ParagonIE_Sodium_Core32_Curve25519_Ge_Cached' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/Curve25519/Ge/Cached.php', |
|
93 | + 'ParagonIE_Sodium_Core32_Curve25519_Ge_P1p1' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/Curve25519/Ge/P1p1.php', |
|
94 | + 'ParagonIE_Sodium_Core32_Curve25519_Ge_P2' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/Curve25519/Ge/P2.php', |
|
95 | + 'ParagonIE_Sodium_Core32_Curve25519_Ge_P3' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/Curve25519/Ge/P3.php', |
|
96 | + 'ParagonIE_Sodium_Core32_Curve25519_Ge_Precomp' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/Curve25519/Ge/Precomp.php', |
|
97 | + 'ParagonIE_Sodium_Core32_Curve25519_H' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/Curve25519/H.php', |
|
98 | + 'ParagonIE_Sodium_Core32_Ed25519' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/Ed25519.php', |
|
99 | + 'ParagonIE_Sodium_Core32_HChaCha20' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/HChaCha20.php', |
|
100 | + 'ParagonIE_Sodium_Core32_HSalsa20' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/HSalsa20.php', |
|
101 | + 'ParagonIE_Sodium_Core32_Int32' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/Int32.php', |
|
102 | + 'ParagonIE_Sodium_Core32_Int64' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/Int64.php', |
|
103 | + 'ParagonIE_Sodium_Core32_Poly1305' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/Poly1305.php', |
|
104 | + 'ParagonIE_Sodium_Core32_Poly1305_State' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/Poly1305/State.php', |
|
105 | + 'ParagonIE_Sodium_Core32_Salsa20' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/Salsa20.php', |
|
106 | + 'ParagonIE_Sodium_Core32_SecretStream_State' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/SecretStream/State.php', |
|
107 | + 'ParagonIE_Sodium_Core32_SipHash' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/SipHash.php', |
|
108 | + 'ParagonIE_Sodium_Core32_Util' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/Util.php', |
|
109 | + 'ParagonIE_Sodium_Core32_X25519' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/X25519.php', |
|
110 | + 'ParagonIE_Sodium_Core32_XChaCha20' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/XChaCha20.php', |
|
111 | + 'ParagonIE_Sodium_Core32_XSalsa20' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core32/XSalsa20.php', |
|
112 | + 'ParagonIE_Sodium_Core_BLAKE2b' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/BLAKE2b.php', |
|
113 | + 'ParagonIE_Sodium_Core_Base64_Common' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/Base64/Common.php', |
|
114 | + 'ParagonIE_Sodium_Core_Base64_Original' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/Base64/Original.php', |
|
115 | + 'ParagonIE_Sodium_Core_Base64_UrlSafe' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/Base64/UrlSafe.php', |
|
116 | + 'ParagonIE_Sodium_Core_ChaCha20' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/ChaCha20.php', |
|
117 | + 'ParagonIE_Sodium_Core_ChaCha20_Ctx' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/ChaCha20/Ctx.php', |
|
118 | + 'ParagonIE_Sodium_Core_ChaCha20_IetfCtx' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/ChaCha20/IetfCtx.php', |
|
119 | + 'ParagonIE_Sodium_Core_Curve25519' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/Curve25519.php', |
|
120 | + 'ParagonIE_Sodium_Core_Curve25519_Fe' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/Curve25519/Fe.php', |
|
121 | + 'ParagonIE_Sodium_Core_Curve25519_Ge_Cached' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/Curve25519/Ge/Cached.php', |
|
122 | + 'ParagonIE_Sodium_Core_Curve25519_Ge_P1p1' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/Curve25519/Ge/P1p1.php', |
|
123 | + 'ParagonIE_Sodium_Core_Curve25519_Ge_P2' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/Curve25519/Ge/P2.php', |
|
124 | + 'ParagonIE_Sodium_Core_Curve25519_Ge_P3' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/Curve25519/Ge/P3.php', |
|
125 | + 'ParagonIE_Sodium_Core_Curve25519_Ge_Precomp' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/Curve25519/Ge/Precomp.php', |
|
126 | + 'ParagonIE_Sodium_Core_Curve25519_H' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/Curve25519/H.php', |
|
127 | + 'ParagonIE_Sodium_Core_Ed25519' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/Ed25519.php', |
|
128 | + 'ParagonIE_Sodium_Core_HChaCha20' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/HChaCha20.php', |
|
129 | + 'ParagonIE_Sodium_Core_HSalsa20' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/HSalsa20.php', |
|
130 | + 'ParagonIE_Sodium_Core_Poly1305' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/Poly1305.php', |
|
131 | + 'ParagonIE_Sodium_Core_Poly1305_State' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/Poly1305/State.php', |
|
132 | + 'ParagonIE_Sodium_Core_Ristretto255' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/Ristretto255.php', |
|
133 | + 'ParagonIE_Sodium_Core_Salsa20' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/Salsa20.php', |
|
134 | + 'ParagonIE_Sodium_Core_SecretStream_State' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/SecretStream/State.php', |
|
135 | + 'ParagonIE_Sodium_Core_SipHash' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/SipHash.php', |
|
136 | + 'ParagonIE_Sodium_Core_Util' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/Util.php', |
|
137 | + 'ParagonIE_Sodium_Core_X25519' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/X25519.php', |
|
138 | + 'ParagonIE_Sodium_Core_XChaCha20' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/XChaCha20.php', |
|
139 | + 'ParagonIE_Sodium_Core_XSalsa20' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Core/XSalsa20.php', |
|
140 | + 'ParagonIE_Sodium_Crypto' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Crypto.php', |
|
141 | + 'ParagonIE_Sodium_Crypto32' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/Crypto32.php', |
|
142 | + 'ParagonIE_Sodium_File' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/File.php', |
|
143 | + 'Psr\\Log\\AbstractLogger' => __DIR__ . '/..' . '/psr/log/Psr/Log/AbstractLogger.php', |
|
144 | + 'Psr\\Log\\InvalidArgumentException' => __DIR__ . '/..' . '/psr/log/Psr/Log/InvalidArgumentException.php', |
|
145 | + 'Psr\\Log\\LogLevel' => __DIR__ . '/..' . '/psr/log/Psr/Log/LogLevel.php', |
|
146 | + 'Psr\\Log\\LoggerAwareInterface' => __DIR__ . '/..' . '/psr/log/Psr/Log/LoggerAwareInterface.php', |
|
147 | + 'Psr\\Log\\LoggerAwareTrait' => __DIR__ . '/..' . '/psr/log/Psr/Log/LoggerAwareTrait.php', |
|
148 | + 'Psr\\Log\\LoggerInterface' => __DIR__ . '/..' . '/psr/log/Psr/Log/LoggerInterface.php', |
|
149 | + 'Psr\\Log\\LoggerTrait' => __DIR__ . '/..' . '/psr/log/Psr/Log/LoggerTrait.php', |
|
150 | + 'Psr\\Log\\NullLogger' => __DIR__ . '/..' . '/psr/log/Psr/Log/NullLogger.php', |
|
151 | + 'Psr\\Log\\Test\\DummyTest' => __DIR__ . '/..' . '/psr/log/Psr/Log/Test/DummyTest.php', |
|
152 | + 'Psr\\Log\\Test\\LoggerInterfaceTest' => __DIR__ . '/..' . '/psr/log/Psr/Log/Test/LoggerInterfaceTest.php', |
|
153 | + 'Psr\\Log\\Test\\TestLogger' => __DIR__ . '/..' . '/psr/log/Psr/Log/Test/TestLogger.php', |
|
154 | + 'SodiumException' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/SodiumException.php', |
|
155 | + 'SplFixedArray' => __DIR__ . '/..' . '/paragonie/sodium_compat/src/PHP52/SplFixedArray.php', |
|
156 | + 'TrustedLoginAJAXTest' => __DIR__ . '/..' . '/trustedlogin/client/tests/test-ajax.php', |
|
157 | + 'TrustedLoginConfigTest' => __DIR__ . '/..' . '/trustedlogin/client/tests/test-config.php', |
|
158 | + 'TrustedLoginUsersTest' => __DIR__ . '/..' . '/trustedlogin/client/tests/test-users.php', |
|
159 | + 'TrustedLogin\\Admin' => __DIR__ . '/..' . '/trustedlogin/client/src/Admin.php', |
|
160 | + 'TrustedLogin\\Ajax' => __DIR__ . '/..' . '/trustedlogin/client/src/Ajax.php', |
|
161 | + 'TrustedLogin\\Client' => __DIR__ . '/..' . '/trustedlogin/client/src/Client.php', |
|
162 | + 'TrustedLogin\\Config' => __DIR__ . '/..' . '/trustedlogin/client/src/Config.php', |
|
163 | + 'TrustedLogin\\Cron' => __DIR__ . '/..' . '/trustedlogin/client/src/Cron.php', |
|
164 | + 'TrustedLogin\\Encryption' => __DIR__ . '/..' . '/trustedlogin/client/src/Encryption.php', |
|
165 | + 'TrustedLogin\\Endpoint' => __DIR__ . '/..' . '/trustedlogin/client/src/Endpoint.php', |
|
166 | + 'TrustedLogin\\Envelope' => __DIR__ . '/..' . '/trustedlogin/client/src/Envelope.php', |
|
167 | + 'TrustedLogin\\Logging' => __DIR__ . '/..' . '/trustedlogin/client/src/Logging.php', |
|
168 | + 'TrustedLogin\\Remote' => __DIR__ . '/..' . '/trustedlogin/client/src/Remote.php', |
|
169 | + 'TrustedLogin\\SecurityChecks' => __DIR__ . '/..' . '/trustedlogin/client/src/SecurityChecks.php', |
|
170 | + 'TrustedLogin\\SiteAccess' => __DIR__ . '/..' . '/trustedlogin/client/src/SiteAccess.php', |
|
171 | + 'TrustedLogin\\SupportRole' => __DIR__ . '/..' . '/trustedlogin/client/src/SupportRole.php', |
|
172 | + 'TrustedLogin\\SupportUser' => __DIR__ . '/..' . '/trustedlogin/client/src/SupportUser.php', |
|
173 | + 'TrustedLogin\\TrustedLoginClientTest' => __DIR__ . '/..' . '/trustedlogin/client/tests/test-client.php', |
|
174 | + 'TrustedLogin\\TrustedLoginEncryptionTest' => __DIR__ . '/..' . '/trustedlogin/client/tests/test-encryption.php', |
|
175 | + 'TrustedLogin\\TrustedLoginLoggingTest' => __DIR__ . '/..' . '/trustedlogin/client/tests/test-logging.php', |
|
176 | + 'TrustedLogin\\TrustedLoginRemoteTest' => __DIR__ . '/..' . '/trustedlogin/client/tests/test-remote.php', |
|
177 | + 'TrustedLogin\\TrustedLoginSiteAccessTest' => __DIR__ . '/..' . '/trustedlogin/client/tests/test-siteaccess.php', |
|
178 | + 'TypeError' => __DIR__ . '/..' . '/paragonie/random_compat/lib/error_polyfill.php', |
|
179 | + ); |
|
180 | 180 | |
181 | - public static function getInitializer(ClassLoader $loader) |
|
182 | - { |
|
183 | - return \Closure::bind(function () use ($loader) { |
|
184 | - $loader->prefixLengthsPsr4 = ComposerStaticInit984ed95bef2b0e3d4eeb0208a88dc67d::$prefixLengthsPsr4; |
|
185 | - $loader->prefixDirsPsr4 = ComposerStaticInit984ed95bef2b0e3d4eeb0208a88dc67d::$prefixDirsPsr4; |
|
186 | - $loader->classMap = ComposerStaticInit984ed95bef2b0e3d4eeb0208a88dc67d::$classMap; |
|
181 | + public static function getInitializer(ClassLoader $loader) |
|
182 | + { |
|
183 | + return \Closure::bind(function () use ($loader) { |
|
184 | + $loader->prefixLengthsPsr4 = ComposerStaticInit984ed95bef2b0e3d4eeb0208a88dc67d::$prefixLengthsPsr4; |
|
185 | + $loader->prefixDirsPsr4 = ComposerStaticInit984ed95bef2b0e3d4eeb0208a88dc67d::$prefixDirsPsr4; |
|
186 | + $loader->classMap = ComposerStaticInit984ed95bef2b0e3d4eeb0208a88dc67d::$classMap; |
|
187 | 187 | |
188 | - }, null, ClassLoader::class); |
|
189 | - } |
|
188 | + }, null, ClassLoader::class); |
|
189 | + } |
|
190 | 190 | } |
@@ -6,48 +6,48 @@ discard block |
||
6 | 6 | |
7 | 7 | class ComposerStaticInit984ed95bef2b0e3d4eeb0208a88dc67d |
8 | 8 | { |
9 | - public static $files = array ( |
|
9 | + public static $files = array( |
|
10 | 10 | '5255c38a0faeba867671b61dfda6d864' => __DIR__ . '/..' . '/paragonie/random_compat/lib/random.php', |
11 | 11 | '3109cb1a231dcd04bee1f9f620d46975' => __DIR__ . '/..' . '/paragonie/sodium_compat/autoload.php', |
12 | 12 | ); |
13 | 13 | |
14 | - public static $prefixLengthsPsr4 = array ( |
|
14 | + public static $prefixLengthsPsr4 = array( |
|
15 | 15 | 'T' => |
16 | - array ( |
|
16 | + array( |
|
17 | 17 | 'TrustedLogin\\' => 13, |
18 | 18 | ), |
19 | 19 | 'P' => |
20 | - array ( |
|
20 | + array( |
|
21 | 21 | 'Psr\\Log\\' => 8, |
22 | 22 | ), |
23 | 23 | 'K' => |
24 | - array ( |
|
24 | + array( |
|
25 | 25 | 'Katzgrau\\KLogger\\' => 17, |
26 | 26 | 'KatzGrau\\KLogger\\' => 17, |
27 | 27 | ), |
28 | 28 | ); |
29 | 29 | |
30 | - public static $prefixDirsPsr4 = array ( |
|
30 | + public static $prefixDirsPsr4 = array( |
|
31 | 31 | 'TrustedLogin\\' => |
32 | - array ( |
|
32 | + array( |
|
33 | 33 | 0 => __DIR__ . '/../..' . '/src', |
34 | 34 | 1 => __DIR__ . '/..' . '/trustedlogin/client/src', |
35 | 35 | ), |
36 | 36 | 'Psr\\Log\\' => |
37 | - array ( |
|
37 | + array( |
|
38 | 38 | 0 => __DIR__ . '/..' . '/psr/log/Psr/Log', |
39 | 39 | ), |
40 | 40 | 'Katzgrau\\KLogger\\' => |
41 | - array ( |
|
41 | + array( |
|
42 | 42 | 0 => __DIR__ . '/..' . '/katzgrau/klogger/src', |
43 | 43 | ), |
44 | 44 | 'KatzGrau\\KLogger\\' => |
45 | - array ( |
|
45 | + array( |
|
46 | 46 | 0 => __DIR__ . '/../..' . '/src', |
47 | 47 | ), |
48 | 48 | ); |
49 | 49 | |
50 | - public static $classMap = array ( |
|
50 | + public static $classMap = array( |
|
51 | 51 | 'ComposerAutoloaderInitb5638313a52df4893eb45c04efdaa356' => __DIR__ . '/..' . '/trustedlogin/client/vendor/composer/autoload_real.php', |
52 | 52 | 'Composer\\Autoload\\ClassLoader' => __DIR__ . '/..' . '/trustedlogin/client/vendor/composer/ClassLoader.php', |
53 | 53 | 'Composer\\Autoload\\ComposerStaticInitb5638313a52df4893eb45c04efdaa356' => __DIR__ . '/..' . '/trustedlogin/client/vendor/composer/autoload_static.php', |
@@ -178,13 +178,13 @@ discard block |
||
178 | 178 | 'TypeError' => __DIR__ . '/..' . '/paragonie/random_compat/lib/error_polyfill.php', |
179 | 179 | ); |
180 | 180 | |
181 | - public static function getInitializer(ClassLoader $loader) |
|
181 | + public static function getInitializer( ClassLoader $loader ) |
|
182 | 182 | { |
183 | - return \Closure::bind(function () use ($loader) { |
|
183 | + return \Closure::bind( function() use ( $loader ) { |
|
184 | 184 | $loader->prefixLengthsPsr4 = ComposerStaticInit984ed95bef2b0e3d4eeb0208a88dc67d::$prefixLengthsPsr4; |
185 | 185 | $loader->prefixDirsPsr4 = ComposerStaticInit984ed95bef2b0e3d4eeb0208a88dc67d::$prefixDirsPsr4; |
186 | 186 | $loader->classMap = ComposerStaticInit984ed95bef2b0e3d4eeb0208a88dc67d::$classMap; |
187 | 187 | |
188 | - }, null, ClassLoader::class); |
|
188 | + }, null, ClassLoader::class ); |
|
189 | 189 | } |
190 | 190 | } |
@@ -4,8 +4,7 @@ discard block |
||
4 | 4 | |
5 | 5 | namespace Composer\Autoload; |
6 | 6 | |
7 | -class ComposerStaticInit984ed95bef2b0e3d4eeb0208a88dc67d |
|
8 | -{ |
|
7 | +class ComposerStaticInit984ed95bef2b0e3d4eeb0208a88dc67d { |
|
9 | 8 | public static $files = array ( |
10 | 9 | '5255c38a0faeba867671b61dfda6d864' => __DIR__ . '/..' . '/paragonie/random_compat/lib/random.php', |
11 | 10 | '3109cb1a231dcd04bee1f9f620d46975' => __DIR__ . '/..' . '/paragonie/sodium_compat/autoload.php', |
@@ -178,8 +177,7 @@ discard block |
||
178 | 177 | 'TypeError' => __DIR__ . '/..' . '/paragonie/random_compat/lib/error_polyfill.php', |
179 | 178 | ); |
180 | 179 | |
181 | - public static function getInitializer(ClassLoader $loader) |
|
182 | - { |
|
180 | + public static function getInitializer(ClassLoader $loader) { |
|
183 | 181 | return \Closure::bind(function () use ($loader) { |
184 | 182 | $loader->prefixLengthsPsr4 = ComposerStaticInit984ed95bef2b0e3d4eeb0208a88dc67d::$prefixLengthsPsr4; |
185 | 183 | $loader->prefixDirsPsr4 = ComposerStaticInit984ed95bef2b0e3d4eeb0208a88dc67d::$prefixDirsPsr4; |
@@ -4,65 +4,65 @@ discard block |
||
4 | 4 | |
5 | 5 | class ComposerAutoloaderInit984ed95bef2b0e3d4eeb0208a88dc67d |
6 | 6 | { |
7 | - private static $loader; |
|
7 | + private static $loader; |
|
8 | 8 | |
9 | - public static function loadClassLoader($class) |
|
10 | - { |
|
11 | - if ('Composer\Autoload\ClassLoader' === $class) { |
|
12 | - require __DIR__ . '/ClassLoader.php'; |
|
13 | - } |
|
14 | - } |
|
9 | + public static function loadClassLoader($class) |
|
10 | + { |
|
11 | + if ('Composer\Autoload\ClassLoader' === $class) { |
|
12 | + require __DIR__ . '/ClassLoader.php'; |
|
13 | + } |
|
14 | + } |
|
15 | 15 | |
16 | - /** |
|
17 | - * @return \Composer\Autoload\ClassLoader |
|
18 | - */ |
|
19 | - public static function getLoader() |
|
20 | - { |
|
21 | - if (null !== self::$loader) { |
|
22 | - return self::$loader; |
|
23 | - } |
|
16 | + /** |
|
17 | + * @return \Composer\Autoload\ClassLoader |
|
18 | + */ |
|
19 | + public static function getLoader() |
|
20 | + { |
|
21 | + if (null !== self::$loader) { |
|
22 | + return self::$loader; |
|
23 | + } |
|
24 | 24 | |
25 | - require __DIR__ . '/platform_check.php'; |
|
25 | + require __DIR__ . '/platform_check.php'; |
|
26 | 26 | |
27 | - spl_autoload_register(array('ComposerAutoloaderInit984ed95bef2b0e3d4eeb0208a88dc67d', 'loadClassLoader'), true, true); |
|
28 | - self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__))); |
|
29 | - spl_autoload_unregister(array('ComposerAutoloaderInit984ed95bef2b0e3d4eeb0208a88dc67d', 'loadClassLoader')); |
|
27 | + spl_autoload_register(array('ComposerAutoloaderInit984ed95bef2b0e3d4eeb0208a88dc67d', 'loadClassLoader'), true, true); |
|
28 | + self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__))); |
|
29 | + spl_autoload_unregister(array('ComposerAutoloaderInit984ed95bef2b0e3d4eeb0208a88dc67d', 'loadClassLoader')); |
|
30 | 30 | |
31 | - $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); |
|
32 | - if ($useStaticLoader) { |
|
33 | - require __DIR__ . '/autoload_static.php'; |
|
31 | + $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); |
|
32 | + if ($useStaticLoader) { |
|
33 | + require __DIR__ . '/autoload_static.php'; |
|
34 | 34 | |
35 | - call_user_func(\Composer\Autoload\ComposerStaticInit984ed95bef2b0e3d4eeb0208a88dc67d::getInitializer($loader)); |
|
36 | - } else { |
|
37 | - $map = require __DIR__ . '/autoload_namespaces.php'; |
|
38 | - foreach ($map as $namespace => $path) { |
|
39 | - $loader->set($namespace, $path); |
|
40 | - } |
|
35 | + call_user_func(\Composer\Autoload\ComposerStaticInit984ed95bef2b0e3d4eeb0208a88dc67d::getInitializer($loader)); |
|
36 | + } else { |
|
37 | + $map = require __DIR__ . '/autoload_namespaces.php'; |
|
38 | + foreach ($map as $namespace => $path) { |
|
39 | + $loader->set($namespace, $path); |
|
40 | + } |
|
41 | 41 | |
42 | - $map = require __DIR__ . '/autoload_psr4.php'; |
|
43 | - foreach ($map as $namespace => $path) { |
|
44 | - $loader->setPsr4($namespace, $path); |
|
45 | - } |
|
42 | + $map = require __DIR__ . '/autoload_psr4.php'; |
|
43 | + foreach ($map as $namespace => $path) { |
|
44 | + $loader->setPsr4($namespace, $path); |
|
45 | + } |
|
46 | 46 | |
47 | - $classMap = require __DIR__ . '/autoload_classmap.php'; |
|
48 | - if ($classMap) { |
|
49 | - $loader->addClassMap($classMap); |
|
50 | - } |
|
51 | - } |
|
47 | + $classMap = require __DIR__ . '/autoload_classmap.php'; |
|
48 | + if ($classMap) { |
|
49 | + $loader->addClassMap($classMap); |
|
50 | + } |
|
51 | + } |
|
52 | 52 | |
53 | - $loader->register(true); |
|
53 | + $loader->register(true); |
|
54 | 54 | |
55 | - if ($useStaticLoader) { |
|
56 | - $includeFiles = Composer\Autoload\ComposerStaticInit984ed95bef2b0e3d4eeb0208a88dc67d::$files; |
|
57 | - } else { |
|
58 | - $includeFiles = require __DIR__ . '/autoload_files.php'; |
|
59 | - } |
|
60 | - foreach ($includeFiles as $fileIdentifier => $file) { |
|
61 | - composerRequire984ed95bef2b0e3d4eeb0208a88dc67d($fileIdentifier, $file); |
|
62 | - } |
|
55 | + if ($useStaticLoader) { |
|
56 | + $includeFiles = Composer\Autoload\ComposerStaticInit984ed95bef2b0e3d4eeb0208a88dc67d::$files; |
|
57 | + } else { |
|
58 | + $includeFiles = require __DIR__ . '/autoload_files.php'; |
|
59 | + } |
|
60 | + foreach ($includeFiles as $fileIdentifier => $file) { |
|
61 | + composerRequire984ed95bef2b0e3d4eeb0208a88dc67d($fileIdentifier, $file); |
|
62 | + } |
|
63 | 63 | |
64 | - return $loader; |
|
65 | - } |
|
64 | + return $loader; |
|
65 | + } |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
@@ -72,9 +72,9 @@ discard block |
||
72 | 72 | */ |
73 | 73 | function composerRequire984ed95bef2b0e3d4eeb0208a88dc67d($fileIdentifier, $file) |
74 | 74 | { |
75 | - if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { |
|
76 | - $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; |
|
75 | + if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { |
|
76 | + $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; |
|
77 | 77 | |
78 | - require $file; |
|
79 | - } |
|
78 | + require $file; |
|
79 | + } |
|
80 | 80 | } |
@@ -6,9 +6,9 @@ discard block |
||
6 | 6 | { |
7 | 7 | private static $loader; |
8 | 8 | |
9 | - public static function loadClassLoader($class) |
|
9 | + public static function loadClassLoader( $class ) |
|
10 | 10 | { |
11 | - if ('Composer\Autoload\ClassLoader' === $class) { |
|
11 | + if ( 'Composer\Autoload\ClassLoader' === $class ) { |
|
12 | 12 | require __DIR__ . '/ClassLoader.php'; |
13 | 13 | } |
14 | 14 | } |
@@ -18,47 +18,47 @@ discard block |
||
18 | 18 | */ |
19 | 19 | public static function getLoader() |
20 | 20 | { |
21 | - if (null !== self::$loader) { |
|
21 | + if ( null !== self::$loader ) { |
|
22 | 22 | return self::$loader; |
23 | 23 | } |
24 | 24 | |
25 | 25 | require __DIR__ . '/platform_check.php'; |
26 | 26 | |
27 | - spl_autoload_register(array('ComposerAutoloaderInit984ed95bef2b0e3d4eeb0208a88dc67d', 'loadClassLoader'), true, true); |
|
28 | - self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__))); |
|
29 | - spl_autoload_unregister(array('ComposerAutoloaderInit984ed95bef2b0e3d4eeb0208a88dc67d', 'loadClassLoader')); |
|
27 | + spl_autoload_register( array( 'ComposerAutoloaderInit984ed95bef2b0e3d4eeb0208a88dc67d', 'loadClassLoader' ), true, true ); |
|
28 | + self::$loader = $loader = new \Composer\Autoload\ClassLoader( \dirname( \dirname( __FILE__ ) ) ); |
|
29 | + spl_autoload_unregister( array( 'ComposerAutoloaderInit984ed95bef2b0e3d4eeb0208a88dc67d', 'loadClassLoader' ) ); |
|
30 | 30 | |
31 | - $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); |
|
32 | - if ($useStaticLoader) { |
|
31 | + $useStaticLoader = PHP_VERSION_ID >= 50600 && ! defined( 'HHVM_VERSION' ) && ( ! function_exists( 'zend_loader_file_encoded' ) || ! zend_loader_file_encoded() ); |
|
32 | + if ( $useStaticLoader ) { |
|
33 | 33 | require __DIR__ . '/autoload_static.php'; |
34 | 34 | |
35 | - call_user_func(\Composer\Autoload\ComposerStaticInit984ed95bef2b0e3d4eeb0208a88dc67d::getInitializer($loader)); |
|
35 | + call_user_func( \Composer\Autoload\ComposerStaticInit984ed95bef2b0e3d4eeb0208a88dc67d::getInitializer( $loader ) ); |
|
36 | 36 | } else { |
37 | 37 | $map = require __DIR__ . '/autoload_namespaces.php'; |
38 | - foreach ($map as $namespace => $path) { |
|
39 | - $loader->set($namespace, $path); |
|
38 | + foreach ( $map as $namespace => $path ) { |
|
39 | + $loader->set( $namespace, $path ); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | $map = require __DIR__ . '/autoload_psr4.php'; |
43 | - foreach ($map as $namespace => $path) { |
|
44 | - $loader->setPsr4($namespace, $path); |
|
43 | + foreach ( $map as $namespace => $path ) { |
|
44 | + $loader->setPsr4( $namespace, $path ); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | $classMap = require __DIR__ . '/autoload_classmap.php'; |
48 | - if ($classMap) { |
|
49 | - $loader->addClassMap($classMap); |
|
48 | + if ( $classMap ) { |
|
49 | + $loader->addClassMap( $classMap ); |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
53 | - $loader->register(true); |
|
53 | + $loader->register( true ); |
|
54 | 54 | |
55 | - if ($useStaticLoader) { |
|
55 | + if ( $useStaticLoader ) { |
|
56 | 56 | $includeFiles = Composer\Autoload\ComposerStaticInit984ed95bef2b0e3d4eeb0208a88dc67d::$files; |
57 | 57 | } else { |
58 | 58 | $includeFiles = require __DIR__ . '/autoload_files.php'; |
59 | 59 | } |
60 | - foreach ($includeFiles as $fileIdentifier => $file) { |
|
61 | - composerRequire984ed95bef2b0e3d4eeb0208a88dc67d($fileIdentifier, $file); |
|
60 | + foreach ( $includeFiles as $fileIdentifier => $file ) { |
|
61 | + composerRequire984ed95bef2b0e3d4eeb0208a88dc67d( $fileIdentifier, $file ); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | return $loader; |
@@ -70,10 +70,10 @@ discard block |
||
70 | 70 | * @param string $file |
71 | 71 | * @return void |
72 | 72 | */ |
73 | -function composerRequire984ed95bef2b0e3d4eeb0208a88dc67d($fileIdentifier, $file) |
|
73 | +function composerRequire984ed95bef2b0e3d4eeb0208a88dc67d( $fileIdentifier, $file ) |
|
74 | 74 | { |
75 | - if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { |
|
76 | - $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; |
|
75 | + if ( empty( $GLOBALS[ '__composer_autoload_files' ][ $fileIdentifier ] ) ) { |
|
76 | + $GLOBALS[ '__composer_autoload_files' ][ $fileIdentifier ] = true; |
|
77 | 77 | |
78 | 78 | require $file; |
79 | 79 | } |
@@ -2,12 +2,10 @@ discard block |
||
2 | 2 | |
3 | 3 | // autoload_real.php @generated by Composer |
4 | 4 | |
5 | -class ComposerAutoloaderInit984ed95bef2b0e3d4eeb0208a88dc67d |
|
6 | -{ |
|
5 | +class ComposerAutoloaderInit984ed95bef2b0e3d4eeb0208a88dc67d { |
|
7 | 6 | private static $loader; |
8 | 7 | |
9 | - public static function loadClassLoader($class) |
|
10 | - { |
|
8 | + public static function loadClassLoader($class) { |
|
11 | 9 | if ('Composer\Autoload\ClassLoader' === $class) { |
12 | 10 | require __DIR__ . '/ClassLoader.php'; |
13 | 11 | } |
@@ -16,8 +14,7 @@ discard block |
||
16 | 14 | /** |
17 | 15 | * @return \Composer\Autoload\ClassLoader |
18 | 16 | */ |
19 | - public static function getLoader() |
|
20 | - { |
|
17 | + public static function getLoader() { |
|
21 | 18 | if (null !== self::$loader) { |
22 | 19 | return self::$loader; |
23 | 20 | } |
@@ -70,8 +67,7 @@ discard block |
||
70 | 67 | * @param string $file |
71 | 68 | * @return void |
72 | 69 | */ |
73 | -function composerRequire984ed95bef2b0e3d4eeb0208a88dc67d($fileIdentifier, $file) |
|
74 | -{ |
|
70 | +function composerRequire984ed95bef2b0e3d4eeb0208a88dc67d($fileIdentifier, $file) { |
|
75 | 71 | if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { |
76 | 72 | $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; |
77 | 73 |
@@ -1,70 +1,70 @@ |
||
1 | 1 | <?php return array( |
2 | - 'root' => array( |
|
3 | - 'pretty_version' => 'dev-develop', |
|
4 | - 'version' => 'dev-develop', |
|
5 | - 'type' => 'wordpress-plugin', |
|
6 | - 'install_path' => __DIR__ . '/../../', |
|
7 | - 'aliases' => array(), |
|
8 | - 'reference' => '863c13683df548e907875904b7532d599446ed18', |
|
9 | - 'name' => 'gravityview/gravityview', |
|
10 | - 'dev' => false, |
|
11 | - ), |
|
12 | - 'versions' => array( |
|
13 | - 'gravityview/gravityview' => array( |
|
14 | - 'pretty_version' => 'dev-develop', |
|
15 | - 'version' => 'dev-develop', |
|
16 | - 'type' => 'wordpress-plugin', |
|
17 | - 'install_path' => __DIR__ . '/../../', |
|
18 | - 'aliases' => array(), |
|
19 | - 'reference' => '863c13683df548e907875904b7532d599446ed18', |
|
20 | - 'dev_requirement' => false, |
|
21 | - ), |
|
22 | - 'katzgrau/klogger' => array( |
|
23 | - 'pretty_version' => 'dev-master', |
|
24 | - 'version' => 'dev-master', |
|
25 | - 'type' => 'library', |
|
26 | - 'install_path' => __DIR__ . '/../katzgrau/klogger', |
|
27 | - 'aliases' => array( |
|
28 | - 0 => '9999999-dev', |
|
29 | - ), |
|
30 | - 'reference' => 'de2d3ab6777a393a9879e0496ebb8e0644066e3f', |
|
31 | - 'dev_requirement' => false, |
|
32 | - ), |
|
33 | - 'paragonie/random_compat' => array( |
|
34 | - 'pretty_version' => 'v2.0.20', |
|
35 | - 'version' => '2.0.20.0', |
|
36 | - 'type' => 'library', |
|
37 | - 'install_path' => __DIR__ . '/../paragonie/random_compat', |
|
38 | - 'aliases' => array(), |
|
39 | - 'reference' => '0f1f60250fccffeaf5dda91eea1c018aed1adc2a', |
|
40 | - 'dev_requirement' => false, |
|
41 | - ), |
|
42 | - 'paragonie/sodium_compat' => array( |
|
43 | - 'pretty_version' => 'v1.17.0', |
|
44 | - 'version' => '1.17.0.0', |
|
45 | - 'type' => 'library', |
|
46 | - 'install_path' => __DIR__ . '/../paragonie/sodium_compat', |
|
47 | - 'aliases' => array(), |
|
48 | - 'reference' => 'c59cac21abbcc0df06a3dd18076450ea4797b321', |
|
49 | - 'dev_requirement' => false, |
|
50 | - ), |
|
51 | - 'psr/log' => array( |
|
52 | - 'pretty_version' => '1.1.4', |
|
53 | - 'version' => '1.1.4.0', |
|
54 | - 'type' => 'library', |
|
55 | - 'install_path' => __DIR__ . '/../psr/log', |
|
56 | - 'aliases' => array(), |
|
57 | - 'reference' => 'd49695b909c3b7628b6289db5479a1c204601f11', |
|
58 | - 'dev_requirement' => false, |
|
59 | - ), |
|
60 | - 'trustedlogin/client' => array( |
|
61 | - 'pretty_version' => 'dev-main', |
|
62 | - 'version' => 'dev-main', |
|
63 | - 'type' => 'library', |
|
64 | - 'install_path' => __DIR__ . '/../trustedlogin/client', |
|
65 | - 'aliases' => array(), |
|
66 | - 'reference' => '8c0be03dac771f157625ee6029e3850a199f6310', |
|
67 | - 'dev_requirement' => false, |
|
68 | - ), |
|
69 | - ), |
|
2 | + 'root' => array( |
|
3 | + 'pretty_version' => 'dev-develop', |
|
4 | + 'version' => 'dev-develop', |
|
5 | + 'type' => 'wordpress-plugin', |
|
6 | + 'install_path' => __DIR__ . '/../../', |
|
7 | + 'aliases' => array(), |
|
8 | + 'reference' => '863c13683df548e907875904b7532d599446ed18', |
|
9 | + 'name' => 'gravityview/gravityview', |
|
10 | + 'dev' => false, |
|
11 | + ), |
|
12 | + 'versions' => array( |
|
13 | + 'gravityview/gravityview' => array( |
|
14 | + 'pretty_version' => 'dev-develop', |
|
15 | + 'version' => 'dev-develop', |
|
16 | + 'type' => 'wordpress-plugin', |
|
17 | + 'install_path' => __DIR__ . '/../../', |
|
18 | + 'aliases' => array(), |
|
19 | + 'reference' => '863c13683df548e907875904b7532d599446ed18', |
|
20 | + 'dev_requirement' => false, |
|
21 | + ), |
|
22 | + 'katzgrau/klogger' => array( |
|
23 | + 'pretty_version' => 'dev-master', |
|
24 | + 'version' => 'dev-master', |
|
25 | + 'type' => 'library', |
|
26 | + 'install_path' => __DIR__ . '/../katzgrau/klogger', |
|
27 | + 'aliases' => array( |
|
28 | + 0 => '9999999-dev', |
|
29 | + ), |
|
30 | + 'reference' => 'de2d3ab6777a393a9879e0496ebb8e0644066e3f', |
|
31 | + 'dev_requirement' => false, |
|
32 | + ), |
|
33 | + 'paragonie/random_compat' => array( |
|
34 | + 'pretty_version' => 'v2.0.20', |
|
35 | + 'version' => '2.0.20.0', |
|
36 | + 'type' => 'library', |
|
37 | + 'install_path' => __DIR__ . '/../paragonie/random_compat', |
|
38 | + 'aliases' => array(), |
|
39 | + 'reference' => '0f1f60250fccffeaf5dda91eea1c018aed1adc2a', |
|
40 | + 'dev_requirement' => false, |
|
41 | + ), |
|
42 | + 'paragonie/sodium_compat' => array( |
|
43 | + 'pretty_version' => 'v1.17.0', |
|
44 | + 'version' => '1.17.0.0', |
|
45 | + 'type' => 'library', |
|
46 | + 'install_path' => __DIR__ . '/../paragonie/sodium_compat', |
|
47 | + 'aliases' => array(), |
|
48 | + 'reference' => 'c59cac21abbcc0df06a3dd18076450ea4797b321', |
|
49 | + 'dev_requirement' => false, |
|
50 | + ), |
|
51 | + 'psr/log' => array( |
|
52 | + 'pretty_version' => '1.1.4', |
|
53 | + 'version' => '1.1.4.0', |
|
54 | + 'type' => 'library', |
|
55 | + 'install_path' => __DIR__ . '/../psr/log', |
|
56 | + 'aliases' => array(), |
|
57 | + 'reference' => 'd49695b909c3b7628b6289db5479a1c204601f11', |
|
58 | + 'dev_requirement' => false, |
|
59 | + ), |
|
60 | + 'trustedlogin/client' => array( |
|
61 | + 'pretty_version' => 'dev-main', |
|
62 | + 'version' => 'dev-main', |
|
63 | + 'type' => 'library', |
|
64 | + 'install_path' => __DIR__ . '/../trustedlogin/client', |
|
65 | + 'aliases' => array(), |
|
66 | + 'reference' => '8c0be03dac771f157625ee6029e3850a199f6310', |
|
67 | + 'dev_requirement' => false, |
|
68 | + ), |
|
69 | + ), |
|
70 | 70 | ); |
@@ -5,30 +5,30 @@ |
||
5 | 5 | $trustedlogin = dirname(__FILE__); |
6 | 6 | |
7 | 7 | return [ |
8 | - 'GravityView\Psr\Log\LoggerAwareTrait' => $trustedlogin.'/psr/log/Psr/Log/LoggerAwareTrait.php', |
|
9 | - 'GravityView\Psr\Log\LoggerInterface' => $trustedlogin.'/psr/log/Psr/Log/LoggerInterface.php', |
|
10 | - 'GravityView\Psr\Log\LoggerAwareInterface' => $trustedlogin.'/psr/log/Psr/Log/LoggerAwareInterface.php', |
|
11 | - 'GravityView\Psr\Log\NullLogger' => $trustedlogin.'/psr/log/Psr/Log/NullLogger.php', |
|
12 | - 'GravityView\Psr\Log\LogLevel' => $trustedlogin.'/psr/log/Psr/Log/LogLevel.php', |
|
13 | - 'GravityView\Psr\Log\Test\LoggerInterfaceTest' => $trustedlogin.'/psr/log/Psr/Log/Test/LoggerInterfaceTest.php', |
|
14 | - 'GravityView\Psr\Log\Test\TestLogger' => $trustedlogin.'/psr/log/Psr/Log/Test/TestLogger.php', |
|
15 | - 'GravityView\Psr\Log\Test\DummyTest' => $trustedlogin.'/psr/log/Psr/Log/Test/DummyTest.php', |
|
16 | - 'GravityView\Psr\Log\AbstractLogger' => $trustedlogin.'/psr/log/Psr/Log/AbstractLogger.php', |
|
17 | - 'GravityView\Psr\Log\LoggerTrait' => $trustedlogin.'/psr/log/Psr/Log/LoggerTrait.php', |
|
18 | - 'GravityView\Psr\Log\InvalidArgumentException' => $trustedlogin.'/psr/log/Psr/Log/InvalidArgumentException.php', |
|
19 | - 'GravityView\Katzgrau\KLogger\Logger' => $trustedlogin.'/katzgrau/klogger/src/Logger.php', |
|
20 | - 'GravityView\TrustedLogin\Admin' => $trustedlogin.'/trustedlogin/client/src/Admin.php', |
|
21 | - 'GravityView\TrustedLogin\Remote' => $trustedlogin.'/trustedlogin/client/src/Remote.php', |
|
22 | - 'GravityView\TrustedLogin\Endpoint' => $trustedlogin.'/trustedlogin/client/src/Endpoint.php', |
|
23 | - 'GravityView\TrustedLogin\SiteAccess' => $trustedlogin.'/trustedlogin/client/src/SiteAccess.php', |
|
24 | - 'GravityView\TrustedLogin\Envelope' => $trustedlogin.'/trustedlogin/client/src/Envelope.php', |
|
25 | - 'GravityView\TrustedLogin\Encryption' => $trustedlogin.'/trustedlogin/client/src/Encryption.php', |
|
26 | - 'GravityView\TrustedLogin\Config' => $trustedlogin.'/trustedlogin/client/src/Config.php', |
|
27 | - 'GravityView\TrustedLogin\SecurityChecks' => $trustedlogin.'/trustedlogin/client/src/SecurityChecks.php', |
|
28 | - 'GravityView\TrustedLogin\SupportUser' => $trustedlogin.'/trustedlogin/client/src/SupportUser.php', |
|
29 | - 'GravityView\TrustedLogin\Client' => $trustedlogin.'/trustedlogin/client/src/Client.php', |
|
30 | - 'GravityView\TrustedLogin\Cron' => $trustedlogin.'/trustedlogin/client/src/Cron.php', |
|
31 | - 'GravityView\TrustedLogin\SupportRole' => $trustedlogin.'/trustedlogin/client/src/SupportRole.php', |
|
32 | - 'GravityView\TrustedLogin\Ajax' => $trustedlogin.'/trustedlogin/client/src/Ajax.php', |
|
33 | - 'GravityView\TrustedLogin\Logging' => $trustedlogin.'/trustedlogin/client/src/Logging.php', |
|
8 | + 'GravityView\Psr\Log\LoggerAwareTrait' => $trustedlogin.'/psr/log/Psr/Log/LoggerAwareTrait.php', |
|
9 | + 'GravityView\Psr\Log\LoggerInterface' => $trustedlogin.'/psr/log/Psr/Log/LoggerInterface.php', |
|
10 | + 'GravityView\Psr\Log\LoggerAwareInterface' => $trustedlogin.'/psr/log/Psr/Log/LoggerAwareInterface.php', |
|
11 | + 'GravityView\Psr\Log\NullLogger' => $trustedlogin.'/psr/log/Psr/Log/NullLogger.php', |
|
12 | + 'GravityView\Psr\Log\LogLevel' => $trustedlogin.'/psr/log/Psr/Log/LogLevel.php', |
|
13 | + 'GravityView\Psr\Log\Test\LoggerInterfaceTest' => $trustedlogin.'/psr/log/Psr/Log/Test/LoggerInterfaceTest.php', |
|
14 | + 'GravityView\Psr\Log\Test\TestLogger' => $trustedlogin.'/psr/log/Psr/Log/Test/TestLogger.php', |
|
15 | + 'GravityView\Psr\Log\Test\DummyTest' => $trustedlogin.'/psr/log/Psr/Log/Test/DummyTest.php', |
|
16 | + 'GravityView\Psr\Log\AbstractLogger' => $trustedlogin.'/psr/log/Psr/Log/AbstractLogger.php', |
|
17 | + 'GravityView\Psr\Log\LoggerTrait' => $trustedlogin.'/psr/log/Psr/Log/LoggerTrait.php', |
|
18 | + 'GravityView\Psr\Log\InvalidArgumentException' => $trustedlogin.'/psr/log/Psr/Log/InvalidArgumentException.php', |
|
19 | + 'GravityView\Katzgrau\KLogger\Logger' => $trustedlogin.'/katzgrau/klogger/src/Logger.php', |
|
20 | + 'GravityView\TrustedLogin\Admin' => $trustedlogin.'/trustedlogin/client/src/Admin.php', |
|
21 | + 'GravityView\TrustedLogin\Remote' => $trustedlogin.'/trustedlogin/client/src/Remote.php', |
|
22 | + 'GravityView\TrustedLogin\Endpoint' => $trustedlogin.'/trustedlogin/client/src/Endpoint.php', |
|
23 | + 'GravityView\TrustedLogin\SiteAccess' => $trustedlogin.'/trustedlogin/client/src/SiteAccess.php', |
|
24 | + 'GravityView\TrustedLogin\Envelope' => $trustedlogin.'/trustedlogin/client/src/Envelope.php', |
|
25 | + 'GravityView\TrustedLogin\Encryption' => $trustedlogin.'/trustedlogin/client/src/Encryption.php', |
|
26 | + 'GravityView\TrustedLogin\Config' => $trustedlogin.'/trustedlogin/client/src/Config.php', |
|
27 | + 'GravityView\TrustedLogin\SecurityChecks' => $trustedlogin.'/trustedlogin/client/src/SecurityChecks.php', |
|
28 | + 'GravityView\TrustedLogin\SupportUser' => $trustedlogin.'/trustedlogin/client/src/SupportUser.php', |
|
29 | + 'GravityView\TrustedLogin\Client' => $trustedlogin.'/trustedlogin/client/src/Client.php', |
|
30 | + 'GravityView\TrustedLogin\Cron' => $trustedlogin.'/trustedlogin/client/src/Cron.php', |
|
31 | + 'GravityView\TrustedLogin\SupportRole' => $trustedlogin.'/trustedlogin/client/src/SupportRole.php', |
|
32 | + 'GravityView\TrustedLogin\Ajax' => $trustedlogin.'/trustedlogin/client/src/Ajax.php', |
|
33 | + 'GravityView\TrustedLogin\Logging' => $trustedlogin.'/trustedlogin/client/src/Logging.php', |
|
34 | 34 | ]; |
@@ -2,33 +2,33 @@ |
||
2 | 2 | |
3 | 3 | // autoload-classmap.php @generated by Strauss |
4 | 4 | |
5 | -$trustedlogin = dirname(__FILE__); |
|
5 | +$trustedlogin = dirname( __FILE__ ); |
|
6 | 6 | |
7 | 7 | return [ |
8 | - 'GravityView\Psr\Log\LoggerAwareTrait' => $trustedlogin.'/psr/log/Psr/Log/LoggerAwareTrait.php', |
|
9 | - 'GravityView\Psr\Log\LoggerInterface' => $trustedlogin.'/psr/log/Psr/Log/LoggerInterface.php', |
|
10 | - 'GravityView\Psr\Log\LoggerAwareInterface' => $trustedlogin.'/psr/log/Psr/Log/LoggerAwareInterface.php', |
|
11 | - 'GravityView\Psr\Log\NullLogger' => $trustedlogin.'/psr/log/Psr/Log/NullLogger.php', |
|
12 | - 'GravityView\Psr\Log\LogLevel' => $trustedlogin.'/psr/log/Psr/Log/LogLevel.php', |
|
13 | - 'GravityView\Psr\Log\Test\LoggerInterfaceTest' => $trustedlogin.'/psr/log/Psr/Log/Test/LoggerInterfaceTest.php', |
|
14 | - 'GravityView\Psr\Log\Test\TestLogger' => $trustedlogin.'/psr/log/Psr/Log/Test/TestLogger.php', |
|
15 | - 'GravityView\Psr\Log\Test\DummyTest' => $trustedlogin.'/psr/log/Psr/Log/Test/DummyTest.php', |
|
16 | - 'GravityView\Psr\Log\AbstractLogger' => $trustedlogin.'/psr/log/Psr/Log/AbstractLogger.php', |
|
17 | - 'GravityView\Psr\Log\LoggerTrait' => $trustedlogin.'/psr/log/Psr/Log/LoggerTrait.php', |
|
18 | - 'GravityView\Psr\Log\InvalidArgumentException' => $trustedlogin.'/psr/log/Psr/Log/InvalidArgumentException.php', |
|
19 | - 'GravityView\Katzgrau\KLogger\Logger' => $trustedlogin.'/katzgrau/klogger/src/Logger.php', |
|
20 | - 'GravityView\TrustedLogin\Admin' => $trustedlogin.'/trustedlogin/client/src/Admin.php', |
|
21 | - 'GravityView\TrustedLogin\Remote' => $trustedlogin.'/trustedlogin/client/src/Remote.php', |
|
22 | - 'GravityView\TrustedLogin\Endpoint' => $trustedlogin.'/trustedlogin/client/src/Endpoint.php', |
|
23 | - 'GravityView\TrustedLogin\SiteAccess' => $trustedlogin.'/trustedlogin/client/src/SiteAccess.php', |
|
24 | - 'GravityView\TrustedLogin\Envelope' => $trustedlogin.'/trustedlogin/client/src/Envelope.php', |
|
25 | - 'GravityView\TrustedLogin\Encryption' => $trustedlogin.'/trustedlogin/client/src/Encryption.php', |
|
26 | - 'GravityView\TrustedLogin\Config' => $trustedlogin.'/trustedlogin/client/src/Config.php', |
|
27 | - 'GravityView\TrustedLogin\SecurityChecks' => $trustedlogin.'/trustedlogin/client/src/SecurityChecks.php', |
|
28 | - 'GravityView\TrustedLogin\SupportUser' => $trustedlogin.'/trustedlogin/client/src/SupportUser.php', |
|
29 | - 'GravityView\TrustedLogin\Client' => $trustedlogin.'/trustedlogin/client/src/Client.php', |
|
30 | - 'GravityView\TrustedLogin\Cron' => $trustedlogin.'/trustedlogin/client/src/Cron.php', |
|
31 | - 'GravityView\TrustedLogin\SupportRole' => $trustedlogin.'/trustedlogin/client/src/SupportRole.php', |
|
32 | - 'GravityView\TrustedLogin\Ajax' => $trustedlogin.'/trustedlogin/client/src/Ajax.php', |
|
33 | - 'GravityView\TrustedLogin\Logging' => $trustedlogin.'/trustedlogin/client/src/Logging.php', |
|
8 | + 'GravityView\Psr\Log\LoggerAwareTrait' => $trustedlogin . '/psr/log/Psr/Log/LoggerAwareTrait.php', |
|
9 | + 'GravityView\Psr\Log\LoggerInterface' => $trustedlogin . '/psr/log/Psr/Log/LoggerInterface.php', |
|
10 | + 'GravityView\Psr\Log\LoggerAwareInterface' => $trustedlogin . '/psr/log/Psr/Log/LoggerAwareInterface.php', |
|
11 | + 'GravityView\Psr\Log\NullLogger' => $trustedlogin . '/psr/log/Psr/Log/NullLogger.php', |
|
12 | + 'GravityView\Psr\Log\LogLevel' => $trustedlogin . '/psr/log/Psr/Log/LogLevel.php', |
|
13 | + 'GravityView\Psr\Log\Test\LoggerInterfaceTest' => $trustedlogin . '/psr/log/Psr/Log/Test/LoggerInterfaceTest.php', |
|
14 | + 'GravityView\Psr\Log\Test\TestLogger' => $trustedlogin . '/psr/log/Psr/Log/Test/TestLogger.php', |
|
15 | + 'GravityView\Psr\Log\Test\DummyTest' => $trustedlogin . '/psr/log/Psr/Log/Test/DummyTest.php', |
|
16 | + 'GravityView\Psr\Log\AbstractLogger' => $trustedlogin . '/psr/log/Psr/Log/AbstractLogger.php', |
|
17 | + 'GravityView\Psr\Log\LoggerTrait' => $trustedlogin . '/psr/log/Psr/Log/LoggerTrait.php', |
|
18 | + 'GravityView\Psr\Log\InvalidArgumentException' => $trustedlogin . '/psr/log/Psr/Log/InvalidArgumentException.php', |
|
19 | + 'GravityView\Katzgrau\KLogger\Logger' => $trustedlogin . '/katzgrau/klogger/src/Logger.php', |
|
20 | + 'GravityView\TrustedLogin\Admin' => $trustedlogin . '/trustedlogin/client/src/Admin.php', |
|
21 | + 'GravityView\TrustedLogin\Remote' => $trustedlogin . '/trustedlogin/client/src/Remote.php', |
|
22 | + 'GravityView\TrustedLogin\Endpoint' => $trustedlogin . '/trustedlogin/client/src/Endpoint.php', |
|
23 | + 'GravityView\TrustedLogin\SiteAccess' => $trustedlogin . '/trustedlogin/client/src/SiteAccess.php', |
|
24 | + 'GravityView\TrustedLogin\Envelope' => $trustedlogin . '/trustedlogin/client/src/Envelope.php', |
|
25 | + 'GravityView\TrustedLogin\Encryption' => $trustedlogin . '/trustedlogin/client/src/Encryption.php', |
|
26 | + 'GravityView\TrustedLogin\Config' => $trustedlogin . '/trustedlogin/client/src/Config.php', |
|
27 | + 'GravityView\TrustedLogin\SecurityChecks' => $trustedlogin . '/trustedlogin/client/src/SecurityChecks.php', |
|
28 | + 'GravityView\TrustedLogin\SupportUser' => $trustedlogin . '/trustedlogin/client/src/SupportUser.php', |
|
29 | + 'GravityView\TrustedLogin\Client' => $trustedlogin . '/trustedlogin/client/src/Client.php', |
|
30 | + 'GravityView\TrustedLogin\Cron' => $trustedlogin . '/trustedlogin/client/src/Cron.php', |
|
31 | + 'GravityView\TrustedLogin\SupportRole' => $trustedlogin . '/trustedlogin/client/src/SupportRole.php', |
|
32 | + 'GravityView\TrustedLogin\Ajax' => $trustedlogin . '/trustedlogin/client/src/Ajax.php', |
|
33 | + 'GravityView\TrustedLogin\Logging' => $trustedlogin . '/trustedlogin/client/src/Logging.php', |
|
34 | 34 | ]; |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | // Exit if accessed directly |
16 | 16 | if (!defined('ABSPATH')) { |
17 | - exit; |
|
17 | + exit; |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | use ArrayAccess; |
@@ -23,393 +23,393 @@ discard block |
||
23 | 23 | |
24 | 24 | final class Config |
25 | 25 | { |
26 | - /** |
|
27 | - * @var string[] These namespaces cannot be used, lest they result in confusion. |
|
28 | - */ |
|
29 | - private static $reserved_namespaces = ['trustedlogin', 'client', 'vendor', 'admin', 'wordpress']; |
|
30 | - |
|
31 | - /** |
|
32 | - * @var array Default settings values |
|
33 | - * |
|
34 | - * @link https://www.trustedlogin.com/configuration/ Read the configuration settings documentation |
|
35 | - * @since 1.0.0 |
|
36 | - */ |
|
37 | - private $default_settings = [ |
|
38 | - 'auth' => [ |
|
39 | - 'api_key' => null, |
|
40 | - 'license_key' => null, |
|
41 | - ], |
|
42 | - 'caps' => [ |
|
43 | - 'add' => [], |
|
44 | - 'remove' => [], |
|
45 | - ], |
|
46 | - 'decay' => WEEK_IN_SECONDS, |
|
47 | - 'logging' => [ |
|
48 | - 'enabled' => false, |
|
49 | - 'directory' => null, |
|
50 | - 'threshold' => 'notice', |
|
51 | - 'options' => [ |
|
52 | - 'extension' => 'log', |
|
53 | - 'dateFormat' => 'Y-m-d G:i:s.u', |
|
54 | - 'filename' => null, // Overridden in Logging.php |
|
55 | - 'flushFrequency' => false, |
|
56 | - 'logFormat' => false, |
|
57 | - 'appendContext' => true, |
|
58 | - ], |
|
59 | - ], |
|
60 | - 'menu' => [ |
|
61 | - 'slug' => null, |
|
62 | - 'title' => null, |
|
63 | - 'priority' => null, |
|
64 | - 'icon_url' => '', |
|
65 | - 'position' => null, |
|
66 | - ], |
|
67 | - 'paths' => [ |
|
68 | - 'css' => null, |
|
69 | - 'js' => null, // Default is defined in get_default_settings() |
|
70 | - ], |
|
71 | - 'reassign_posts' => true, |
|
72 | - 'require_ssl' => true, |
|
73 | - 'role' => 'editor', |
|
74 | - 'vendor' => [ |
|
75 | - 'namespace' => null, |
|
76 | - 'title' => null, |
|
77 | - 'email' => null, |
|
78 | - 'website' => null, |
|
79 | - 'support_url' => null, |
|
80 | - 'display_name' => null, |
|
81 | - 'logo_url' => null, |
|
82 | - 'about_live_access_url' => null, |
|
83 | - ], |
|
84 | - 'webhook_url' => null, |
|
85 | - ]; |
|
86 | - |
|
87 | - /** |
|
88 | - * @var array Configuration array after parsed and validated |
|
89 | - * |
|
90 | - * @since 1.0.0 |
|
91 | - */ |
|
92 | - private $settings = []; |
|
93 | - |
|
94 | - /** |
|
95 | - * Config constructor. |
|
96 | - * |
|
97 | - * @param array $settings |
|
98 | - * |
|
99 | - * @throws \Exception |
|
100 | - */ |
|
101 | - public function __construct(array $settings = []) |
|
102 | - { |
|
103 | - if (empty($settings)) { |
|
104 | - throw new Exception('Developer: TrustedLogin requires a configuration array. See https://trustedlogin.com/configuration/ for more information.', 400); |
|
105 | - } |
|
106 | - |
|
107 | - $this->settings = $settings; |
|
108 | - } |
|
109 | - |
|
110 | - /** |
|
111 | - * @throws \Exception |
|
112 | - * |
|
113 | - * @return true|\WP_Error[] |
|
114 | - */ |
|
115 | - public function validate() |
|
116 | - { |
|
117 | - if (in_array(__NAMESPACE__, ['ReplaceMe', 'ReplaceMe\GravityView\GravityView\TrustedLogin']) && !defined('TL_DOING_TESTS')) { |
|
118 | - throw new Exception('Developer: make sure to change the namespace for the TrustedLogin class. See https://trustedlogin.com/configuration/ for more information.', 501); |
|
119 | - } |
|
120 | - |
|
121 | - $errors = []; |
|
122 | - |
|
123 | - if (!isset($this->settings['auth']['api_key'])) { |
|
124 | - $errors[] = new WP_Error('missing_configuration', 'You need to set an API key. Get yours at https://app.trustedlogin.com'); |
|
125 | - } |
|
126 | - |
|
127 | - if (isset($this->settings['vendor']['website']) && 'https://www.example.com' === $this->settings['vendor']['website'] && !defined('TL_DOING_TESTS')) { |
|
128 | - $errors[] = new WP_Error('missing_configuration', 'You need to configure the "website" URL to point to the URL where the Vendor plugin is installed.'); |
|
129 | - } |
|
130 | - |
|
131 | - foreach (['namespace', 'title', 'website', 'support_url', 'email'] as $required_vendor_field) { |
|
132 | - if (!isset($this->settings['vendor'][$required_vendor_field])) { |
|
133 | - $errors[] = new WP_Error('missing_configuration', sprintf('Missing required configuration: `vendor/%s`', $required_vendor_field)); |
|
134 | - } |
|
135 | - } |
|
136 | - |
|
137 | - if (isset($this->settings['decay'])) { |
|
138 | - if (!is_int($this->settings['decay'])) { |
|
139 | - $errors[] = new WP_Error('invalid_configuration', 'Decay must be an integer (number of seconds).'); |
|
140 | - } elseif ($this->settings['decay'] > MONTH_IN_SECONDS) { |
|
141 | - $errors[] = new WP_Error('invalid_configuration', 'Decay must be less than or equal to 30 days.'); |
|
142 | - } elseif ($this->settings['decay'] < DAY_IN_SECONDS) { |
|
143 | - $errors[] = new WP_Error('invalid_configuration', 'Decay must be greater than 1 day.'); |
|
144 | - } |
|
145 | - } |
|
146 | - |
|
147 | - if (isset($this->settings['vendor']['namespace'])) { |
|
148 | - |
|
149 | - // This seems like a reasonable max limit on namespace length. |
|
150 | - // @see https://developer.wordpress.org/reference/functions/set_transient/#more-information |
|
151 | - if (strlen($this->settings['vendor']['namespace']) > 96) { |
|
152 | - $errors[] = new WP_Error('invalid_configuration', 'Namespace length must be shorter than 96 characters.'); |
|
153 | - } |
|
154 | - |
|
155 | - if (in_array(strtolower($this->settings['vendor']['namespace']), self::$reserved_namespaces, true)) { |
|
156 | - $errors[] = new WP_Error('invalid_configuration', 'The defined namespace is reserved.'); |
|
157 | - } |
|
158 | - } |
|
159 | - |
|
160 | - if (isset($this->settings['vendor']['email']) && !filter_var($this->settings['vendor']['email'], FILTER_VALIDATE_EMAIL)) { |
|
161 | - $errors[] = new WP_Error('invalid_configuration', 'An invalid `vendor/email` setting was passed to the TrustedLogin Client.'); |
|
162 | - } |
|
163 | - |
|
164 | - // TODO: Add namespace collision check? |
|
165 | - foreach (['webhook_url', 'vendor/support_url', 'vendor/website'] as $settings_key) { |
|
166 | - $value = $this->get_setting($settings_key, null, $this->settings); |
|
167 | - $url = wp_kses_bad_protocol($value, ['http', 'https']); |
|
168 | - if ($value && !filter_var($url, FILTER_VALIDATE_URL)) { |
|
169 | - $errors[] = new WP_Error( |
|
170 | - 'invalid_configuration', |
|
171 | - sprintf( |
|
172 | - 'An invalid `%s` setting was passed to the TrustedLogin Client: %s', |
|
173 | - $settings_key, |
|
174 | - print_r($this->get_setting($settings_key, null, $this->settings), true) |
|
175 | - ) |
|
176 | - ); |
|
177 | - } |
|
178 | - } |
|
179 | - |
|
180 | - $added_caps = $this->get_setting('caps/add', [], $this->settings); |
|
181 | - |
|
182 | - foreach (SupportRole::$prevented_caps as $invalid_cap) { |
|
183 | - if (array_key_exists($invalid_cap, $added_caps)) { |
|
184 | - $errors[] = new WP_Error('invalid_configuration', 'TrustedLogin users cannot be allowed to: '.$invalid_cap); |
|
185 | - } |
|
186 | - } |
|
187 | - |
|
188 | - if ($errors) { |
|
189 | - $error_text = []; |
|
190 | - foreach ($errors as $error) { |
|
191 | - if (is_wp_error($error)) { |
|
192 | - $error_text[] = $error->get_error_message(); |
|
193 | - } |
|
194 | - } |
|
195 | - |
|
196 | - $exception_text = 'Invalid TrustedLogin Configuration. Learn more at https://www.trustedlogin.com/configuration/'; |
|
197 | - $exception_text .= "\n- ".implode("\n- ", $error_text); |
|
198 | - |
|
199 | - throw new Exception($exception_text, 406); |
|
200 | - } |
|
201 | - |
|
202 | - return true; |
|
203 | - } |
|
204 | - |
|
205 | - /** |
|
206 | - * Returns a timestamp that is the current time + decay time setting. |
|
207 | - * |
|
208 | - * Note: This is a server timestamp, not a WordPress timestamp |
|
209 | - * |
|
210 | - * @param int $decay_time If passed, override the `decay` setting |
|
211 | - * @param bool $gmt Whether to use server time (false) or GMT time (true). Default: false. |
|
212 | - * |
|
213 | - * @return int|false Timestamp in seconds. Default is WEEK_IN_SECONDS from creation (`time()` + 604800). False if no expiration. |
|
214 | - */ |
|
215 | - public function get_expiration_timestamp($decay_time = null, $gmt = false) |
|
216 | - { |
|
217 | - if (is_null($decay_time)) { |
|
218 | - $decay_time = $this->get_setting('decay'); |
|
219 | - } |
|
220 | - |
|
221 | - if (0 === $decay_time) { |
|
222 | - return false; |
|
223 | - } |
|
224 | - |
|
225 | - $time = current_time('timestamp', $gmt); |
|
226 | - |
|
227 | - return $time + (int) $decay_time; |
|
228 | - } |
|
229 | - |
|
230 | - /** |
|
231 | - * Returns the display name for the vendor; otherwise, the title. |
|
232 | - * |
|
233 | - * @return string |
|
234 | - */ |
|
235 | - public function get_display_name() |
|
236 | - { |
|
237 | - return $this->get_setting('vendor/display_name', $this->get_setting('vendor/title', '')); |
|
238 | - } |
|
239 | - |
|
240 | - /** |
|
241 | - * Validate and initialize settings array passed to the Client contructor. |
|
242 | - * |
|
243 | - * @param array|string $config Configuration array or JSON-encoded configuration array |
|
244 | - * |
|
245 | - * @return bool|WP_Error[] true: Initialization succeeded; array of WP_Error objects if there are any issues. |
|
246 | - */ |
|
247 | - protected function parse_settings($config) |
|
248 | - { |
|
249 | - if (is_string($config)) { |
|
250 | - $config = json_decode($config, true); |
|
251 | - } |
|
252 | - |
|
253 | - if (!is_array($config) || empty($config)) { |
|
254 | - return [new WP_Error('empty_configuration', 'Configuration array cannot be empty. See https://www.trustedlogin.com/configuration/ for more information.')]; |
|
255 | - } |
|
256 | - |
|
257 | - $defaults = $this->get_default_settings(); |
|
258 | - |
|
259 | - $filtered_config = array_filter($config, [$this, 'is_not_null']); |
|
260 | - |
|
261 | - return shortcode_atts($defaults, $filtered_config); |
|
262 | - } |
|
263 | - |
|
264 | - /** |
|
265 | - * Filter out null input values. |
|
266 | - * |
|
267 | - * @internal Used for parsing settings |
|
268 | - * |
|
269 | - * @param mixed $input Input to test against. |
|
270 | - * |
|
271 | - * @return bool True: not null. False: null |
|
272 | - */ |
|
273 | - public function is_not_null($input) |
|
274 | - { |
|
275 | - return !is_null($input); |
|
276 | - } |
|
277 | - |
|
278 | - /** |
|
279 | - * Gets the default settings for the Client and define dynamic defaults (like paths/css and paths/js). |
|
280 | - * |
|
281 | - * @since 1.0.0 |
|
282 | - * |
|
283 | - * @return array Array of default settings. |
|
284 | - */ |
|
285 | - public function get_default_settings() |
|
286 | - { |
|
287 | - $default_settings = $this->default_settings; |
|
288 | - |
|
289 | - $default_settings['paths']['css'] = plugin_dir_url(__FILE__).'assets/trustedlogin.css'; |
|
290 | - $default_settings['paths']['js'] = plugin_dir_url(__FILE__).'assets/trustedlogin.js'; |
|
291 | - |
|
292 | - return $default_settings; |
|
293 | - } |
|
294 | - |
|
295 | - /** |
|
296 | - * @return string Vendor namespace, sanitized with dashes |
|
297 | - */ |
|
298 | - public function ns() |
|
299 | - { |
|
300 | - static $namespace; |
|
301 | - |
|
302 | - if (!$namespace) { |
|
303 | - $ns = $this->get_setting('vendor/namespace'); |
|
304 | - |
|
305 | - $namespace = sanitize_title_with_dashes($ns); |
|
306 | - } |
|
307 | - |
|
308 | - return $namespace; |
|
309 | - } |
|
310 | - |
|
311 | - /** |
|
312 | - * Helper Function: Get a specific setting or return a default value. |
|
313 | - * |
|
314 | - * @since 1.0.0 |
|
315 | - * |
|
316 | - * @param string $key The setting to fetch, nested results are delimited with forward slashes (eg vendor/name => settings['vendor']['name']) |
|
317 | - * @param mixed $default - if no setting found or settings not init, return this value. |
|
318 | - * @param array $settings Pass an array to fetch value for instead of using the default settings array |
|
319 | - * |
|
320 | - * @return string|array |
|
321 | - */ |
|
322 | - public function get_setting($key, $default = null, $settings = []) |
|
323 | - { |
|
324 | - if (empty($settings)) { |
|
325 | - $settings = $this->settings; |
|
326 | - } |
|
327 | - |
|
328 | - if (is_null($default)) { |
|
329 | - $default = $this->get_multi_array_value($this->get_default_settings(), $key); |
|
330 | - } |
|
331 | - |
|
332 | - if (empty($settings) || !is_array($settings)) { |
|
333 | - return $default; |
|
334 | - } |
|
335 | - |
|
336 | - return $this->get_multi_array_value($settings, $key, $default); |
|
337 | - } |
|
338 | - |
|
339 | - /** |
|
340 | - * Gets a specific property value within a multidimensional array. |
|
341 | - * |
|
342 | - * @param array $array The array to search in. |
|
343 | - * @param string $name The name of the property to find. |
|
344 | - * @param string $default Optional. Value that should be returned if the property is not set or empty. Defaults to null. |
|
345 | - * |
|
346 | - * @return null|string|mixed The value |
|
347 | - */ |
|
348 | - private function get_multi_array_value($array, $name, $default = null) |
|
349 | - { |
|
350 | - if (!is_array($array) && !(is_object($array) && $array instanceof ArrayAccess)) { |
|
351 | - return $default; |
|
352 | - } |
|
353 | - |
|
354 | - $names = explode('/', $name); |
|
355 | - $val = $array; |
|
356 | - foreach ($names as $current_name) { |
|
357 | - $val = $this->get_array_value($val, $current_name, $default); |
|
358 | - } |
|
359 | - |
|
360 | - return $val; |
|
361 | - } |
|
362 | - |
|
363 | - /** |
|
364 | - * Get a specific property of an array without needing to check if that property exists. |
|
365 | - * |
|
366 | - * Provide a default value if you want to return a specific value if the property is not set. |
|
367 | - * |
|
368 | - * @param array $array Array from which the property's value should be retrieved. |
|
369 | - * @param string $prop Name of the property to be retrieved. |
|
370 | - * @param string $default Optional. Value that should be returned if the property is not set or empty. Defaults to null. |
|
371 | - * |
|
372 | - * @return null|string|mixed The value |
|
373 | - */ |
|
374 | - private function get_array_value($array, $prop, $default = null) |
|
375 | - { |
|
376 | - if (!is_array($array) && !(is_object($array) && $array instanceof ArrayAccess)) { |
|
377 | - return $default; |
|
378 | - } |
|
379 | - |
|
380 | - if (isset($array[$prop])) { |
|
381 | - $value = $array[$prop]; |
|
382 | - } else { |
|
383 | - $value = $default; |
|
384 | - } |
|
385 | - |
|
386 | - $value_is_zero = 0 === $value; |
|
387 | - |
|
388 | - return (empty($value) && !$value_is_zero) && $default !== null ? $default : $value; |
|
389 | - } |
|
390 | - |
|
391 | - /** |
|
392 | - * Checks whether SSL requirements are met. |
|
393 | - * |
|
394 | - * @since 1.0.0 |
|
395 | - * |
|
396 | - * @return bool Whether the vendor-defined SSL requirements are met. |
|
397 | - */ |
|
398 | - public function meets_ssl_requirement() |
|
399 | - { |
|
400 | - $return = true; |
|
401 | - |
|
402 | - if ($this->get_setting('require_ssl', true) && !is_ssl()) { |
|
403 | - $return = false; |
|
404 | - } |
|
405 | - |
|
406 | - /** |
|
407 | - * @internal Do not rely on this!!!! |
|
408 | - * |
|
409 | - * @todo Remove this |
|
410 | - * |
|
411 | - * @param bool $return Does this site meet the SSL requirement? |
|
412 | - */ |
|
413 | - return apply_filters('trustedlogin/'.$this->ns().'/meets_ssl_requirement', $return); |
|
414 | - } |
|
26 | + /** |
|
27 | + * @var string[] These namespaces cannot be used, lest they result in confusion. |
|
28 | + */ |
|
29 | + private static $reserved_namespaces = ['trustedlogin', 'client', 'vendor', 'admin', 'wordpress']; |
|
30 | + |
|
31 | + /** |
|
32 | + * @var array Default settings values |
|
33 | + * |
|
34 | + * @link https://www.trustedlogin.com/configuration/ Read the configuration settings documentation |
|
35 | + * @since 1.0.0 |
|
36 | + */ |
|
37 | + private $default_settings = [ |
|
38 | + 'auth' => [ |
|
39 | + 'api_key' => null, |
|
40 | + 'license_key' => null, |
|
41 | + ], |
|
42 | + 'caps' => [ |
|
43 | + 'add' => [], |
|
44 | + 'remove' => [], |
|
45 | + ], |
|
46 | + 'decay' => WEEK_IN_SECONDS, |
|
47 | + 'logging' => [ |
|
48 | + 'enabled' => false, |
|
49 | + 'directory' => null, |
|
50 | + 'threshold' => 'notice', |
|
51 | + 'options' => [ |
|
52 | + 'extension' => 'log', |
|
53 | + 'dateFormat' => 'Y-m-d G:i:s.u', |
|
54 | + 'filename' => null, // Overridden in Logging.php |
|
55 | + 'flushFrequency' => false, |
|
56 | + 'logFormat' => false, |
|
57 | + 'appendContext' => true, |
|
58 | + ], |
|
59 | + ], |
|
60 | + 'menu' => [ |
|
61 | + 'slug' => null, |
|
62 | + 'title' => null, |
|
63 | + 'priority' => null, |
|
64 | + 'icon_url' => '', |
|
65 | + 'position' => null, |
|
66 | + ], |
|
67 | + 'paths' => [ |
|
68 | + 'css' => null, |
|
69 | + 'js' => null, // Default is defined in get_default_settings() |
|
70 | + ], |
|
71 | + 'reassign_posts' => true, |
|
72 | + 'require_ssl' => true, |
|
73 | + 'role' => 'editor', |
|
74 | + 'vendor' => [ |
|
75 | + 'namespace' => null, |
|
76 | + 'title' => null, |
|
77 | + 'email' => null, |
|
78 | + 'website' => null, |
|
79 | + 'support_url' => null, |
|
80 | + 'display_name' => null, |
|
81 | + 'logo_url' => null, |
|
82 | + 'about_live_access_url' => null, |
|
83 | + ], |
|
84 | + 'webhook_url' => null, |
|
85 | + ]; |
|
86 | + |
|
87 | + /** |
|
88 | + * @var array Configuration array after parsed and validated |
|
89 | + * |
|
90 | + * @since 1.0.0 |
|
91 | + */ |
|
92 | + private $settings = []; |
|
93 | + |
|
94 | + /** |
|
95 | + * Config constructor. |
|
96 | + * |
|
97 | + * @param array $settings |
|
98 | + * |
|
99 | + * @throws \Exception |
|
100 | + */ |
|
101 | + public function __construct(array $settings = []) |
|
102 | + { |
|
103 | + if (empty($settings)) { |
|
104 | + throw new Exception('Developer: TrustedLogin requires a configuration array. See https://trustedlogin.com/configuration/ for more information.', 400); |
|
105 | + } |
|
106 | + |
|
107 | + $this->settings = $settings; |
|
108 | + } |
|
109 | + |
|
110 | + /** |
|
111 | + * @throws \Exception |
|
112 | + * |
|
113 | + * @return true|\WP_Error[] |
|
114 | + */ |
|
115 | + public function validate() |
|
116 | + { |
|
117 | + if (in_array(__NAMESPACE__, ['ReplaceMe', 'ReplaceMe\GravityView\GravityView\TrustedLogin']) && !defined('TL_DOING_TESTS')) { |
|
118 | + throw new Exception('Developer: make sure to change the namespace for the TrustedLogin class. See https://trustedlogin.com/configuration/ for more information.', 501); |
|
119 | + } |
|
120 | + |
|
121 | + $errors = []; |
|
122 | + |
|
123 | + if (!isset($this->settings['auth']['api_key'])) { |
|
124 | + $errors[] = new WP_Error('missing_configuration', 'You need to set an API key. Get yours at https://app.trustedlogin.com'); |
|
125 | + } |
|
126 | + |
|
127 | + if (isset($this->settings['vendor']['website']) && 'https://www.example.com' === $this->settings['vendor']['website'] && !defined('TL_DOING_TESTS')) { |
|
128 | + $errors[] = new WP_Error('missing_configuration', 'You need to configure the "website" URL to point to the URL where the Vendor plugin is installed.'); |
|
129 | + } |
|
130 | + |
|
131 | + foreach (['namespace', 'title', 'website', 'support_url', 'email'] as $required_vendor_field) { |
|
132 | + if (!isset($this->settings['vendor'][$required_vendor_field])) { |
|
133 | + $errors[] = new WP_Error('missing_configuration', sprintf('Missing required configuration: `vendor/%s`', $required_vendor_field)); |
|
134 | + } |
|
135 | + } |
|
136 | + |
|
137 | + if (isset($this->settings['decay'])) { |
|
138 | + if (!is_int($this->settings['decay'])) { |
|
139 | + $errors[] = new WP_Error('invalid_configuration', 'Decay must be an integer (number of seconds).'); |
|
140 | + } elseif ($this->settings['decay'] > MONTH_IN_SECONDS) { |
|
141 | + $errors[] = new WP_Error('invalid_configuration', 'Decay must be less than or equal to 30 days.'); |
|
142 | + } elseif ($this->settings['decay'] < DAY_IN_SECONDS) { |
|
143 | + $errors[] = new WP_Error('invalid_configuration', 'Decay must be greater than 1 day.'); |
|
144 | + } |
|
145 | + } |
|
146 | + |
|
147 | + if (isset($this->settings['vendor']['namespace'])) { |
|
148 | + |
|
149 | + // This seems like a reasonable max limit on namespace length. |
|
150 | + // @see https://developer.wordpress.org/reference/functions/set_transient/#more-information |
|
151 | + if (strlen($this->settings['vendor']['namespace']) > 96) { |
|
152 | + $errors[] = new WP_Error('invalid_configuration', 'Namespace length must be shorter than 96 characters.'); |
|
153 | + } |
|
154 | + |
|
155 | + if (in_array(strtolower($this->settings['vendor']['namespace']), self::$reserved_namespaces, true)) { |
|
156 | + $errors[] = new WP_Error('invalid_configuration', 'The defined namespace is reserved.'); |
|
157 | + } |
|
158 | + } |
|
159 | + |
|
160 | + if (isset($this->settings['vendor']['email']) && !filter_var($this->settings['vendor']['email'], FILTER_VALIDATE_EMAIL)) { |
|
161 | + $errors[] = new WP_Error('invalid_configuration', 'An invalid `vendor/email` setting was passed to the TrustedLogin Client.'); |
|
162 | + } |
|
163 | + |
|
164 | + // TODO: Add namespace collision check? |
|
165 | + foreach (['webhook_url', 'vendor/support_url', 'vendor/website'] as $settings_key) { |
|
166 | + $value = $this->get_setting($settings_key, null, $this->settings); |
|
167 | + $url = wp_kses_bad_protocol($value, ['http', 'https']); |
|
168 | + if ($value && !filter_var($url, FILTER_VALIDATE_URL)) { |
|
169 | + $errors[] = new WP_Error( |
|
170 | + 'invalid_configuration', |
|
171 | + sprintf( |
|
172 | + 'An invalid `%s` setting was passed to the TrustedLogin Client: %s', |
|
173 | + $settings_key, |
|
174 | + print_r($this->get_setting($settings_key, null, $this->settings), true) |
|
175 | + ) |
|
176 | + ); |
|
177 | + } |
|
178 | + } |
|
179 | + |
|
180 | + $added_caps = $this->get_setting('caps/add', [], $this->settings); |
|
181 | + |
|
182 | + foreach (SupportRole::$prevented_caps as $invalid_cap) { |
|
183 | + if (array_key_exists($invalid_cap, $added_caps)) { |
|
184 | + $errors[] = new WP_Error('invalid_configuration', 'TrustedLogin users cannot be allowed to: '.$invalid_cap); |
|
185 | + } |
|
186 | + } |
|
187 | + |
|
188 | + if ($errors) { |
|
189 | + $error_text = []; |
|
190 | + foreach ($errors as $error) { |
|
191 | + if (is_wp_error($error)) { |
|
192 | + $error_text[] = $error->get_error_message(); |
|
193 | + } |
|
194 | + } |
|
195 | + |
|
196 | + $exception_text = 'Invalid TrustedLogin Configuration. Learn more at https://www.trustedlogin.com/configuration/'; |
|
197 | + $exception_text .= "\n- ".implode("\n- ", $error_text); |
|
198 | + |
|
199 | + throw new Exception($exception_text, 406); |
|
200 | + } |
|
201 | + |
|
202 | + return true; |
|
203 | + } |
|
204 | + |
|
205 | + /** |
|
206 | + * Returns a timestamp that is the current time + decay time setting. |
|
207 | + * |
|
208 | + * Note: This is a server timestamp, not a WordPress timestamp |
|
209 | + * |
|
210 | + * @param int $decay_time If passed, override the `decay` setting |
|
211 | + * @param bool $gmt Whether to use server time (false) or GMT time (true). Default: false. |
|
212 | + * |
|
213 | + * @return int|false Timestamp in seconds. Default is WEEK_IN_SECONDS from creation (`time()` + 604800). False if no expiration. |
|
214 | + */ |
|
215 | + public function get_expiration_timestamp($decay_time = null, $gmt = false) |
|
216 | + { |
|
217 | + if (is_null($decay_time)) { |
|
218 | + $decay_time = $this->get_setting('decay'); |
|
219 | + } |
|
220 | + |
|
221 | + if (0 === $decay_time) { |
|
222 | + return false; |
|
223 | + } |
|
224 | + |
|
225 | + $time = current_time('timestamp', $gmt); |
|
226 | + |
|
227 | + return $time + (int) $decay_time; |
|
228 | + } |
|
229 | + |
|
230 | + /** |
|
231 | + * Returns the display name for the vendor; otherwise, the title. |
|
232 | + * |
|
233 | + * @return string |
|
234 | + */ |
|
235 | + public function get_display_name() |
|
236 | + { |
|
237 | + return $this->get_setting('vendor/display_name', $this->get_setting('vendor/title', '')); |
|
238 | + } |
|
239 | + |
|
240 | + /** |
|
241 | + * Validate and initialize settings array passed to the Client contructor. |
|
242 | + * |
|
243 | + * @param array|string $config Configuration array or JSON-encoded configuration array |
|
244 | + * |
|
245 | + * @return bool|WP_Error[] true: Initialization succeeded; array of WP_Error objects if there are any issues. |
|
246 | + */ |
|
247 | + protected function parse_settings($config) |
|
248 | + { |
|
249 | + if (is_string($config)) { |
|
250 | + $config = json_decode($config, true); |
|
251 | + } |
|
252 | + |
|
253 | + if (!is_array($config) || empty($config)) { |
|
254 | + return [new WP_Error('empty_configuration', 'Configuration array cannot be empty. See https://www.trustedlogin.com/configuration/ for more information.')]; |
|
255 | + } |
|
256 | + |
|
257 | + $defaults = $this->get_default_settings(); |
|
258 | + |
|
259 | + $filtered_config = array_filter($config, [$this, 'is_not_null']); |
|
260 | + |
|
261 | + return shortcode_atts($defaults, $filtered_config); |
|
262 | + } |
|
263 | + |
|
264 | + /** |
|
265 | + * Filter out null input values. |
|
266 | + * |
|
267 | + * @internal Used for parsing settings |
|
268 | + * |
|
269 | + * @param mixed $input Input to test against. |
|
270 | + * |
|
271 | + * @return bool True: not null. False: null |
|
272 | + */ |
|
273 | + public function is_not_null($input) |
|
274 | + { |
|
275 | + return !is_null($input); |
|
276 | + } |
|
277 | + |
|
278 | + /** |
|
279 | + * Gets the default settings for the Client and define dynamic defaults (like paths/css and paths/js). |
|
280 | + * |
|
281 | + * @since 1.0.0 |
|
282 | + * |
|
283 | + * @return array Array of default settings. |
|
284 | + */ |
|
285 | + public function get_default_settings() |
|
286 | + { |
|
287 | + $default_settings = $this->default_settings; |
|
288 | + |
|
289 | + $default_settings['paths']['css'] = plugin_dir_url(__FILE__).'assets/trustedlogin.css'; |
|
290 | + $default_settings['paths']['js'] = plugin_dir_url(__FILE__).'assets/trustedlogin.js'; |
|
291 | + |
|
292 | + return $default_settings; |
|
293 | + } |
|
294 | + |
|
295 | + /** |
|
296 | + * @return string Vendor namespace, sanitized with dashes |
|
297 | + */ |
|
298 | + public function ns() |
|
299 | + { |
|
300 | + static $namespace; |
|
301 | + |
|
302 | + if (!$namespace) { |
|
303 | + $ns = $this->get_setting('vendor/namespace'); |
|
304 | + |
|
305 | + $namespace = sanitize_title_with_dashes($ns); |
|
306 | + } |
|
307 | + |
|
308 | + return $namespace; |
|
309 | + } |
|
310 | + |
|
311 | + /** |
|
312 | + * Helper Function: Get a specific setting or return a default value. |
|
313 | + * |
|
314 | + * @since 1.0.0 |
|
315 | + * |
|
316 | + * @param string $key The setting to fetch, nested results are delimited with forward slashes (eg vendor/name => settings['vendor']['name']) |
|
317 | + * @param mixed $default - if no setting found or settings not init, return this value. |
|
318 | + * @param array $settings Pass an array to fetch value for instead of using the default settings array |
|
319 | + * |
|
320 | + * @return string|array |
|
321 | + */ |
|
322 | + public function get_setting($key, $default = null, $settings = []) |
|
323 | + { |
|
324 | + if (empty($settings)) { |
|
325 | + $settings = $this->settings; |
|
326 | + } |
|
327 | + |
|
328 | + if (is_null($default)) { |
|
329 | + $default = $this->get_multi_array_value($this->get_default_settings(), $key); |
|
330 | + } |
|
331 | + |
|
332 | + if (empty($settings) || !is_array($settings)) { |
|
333 | + return $default; |
|
334 | + } |
|
335 | + |
|
336 | + return $this->get_multi_array_value($settings, $key, $default); |
|
337 | + } |
|
338 | + |
|
339 | + /** |
|
340 | + * Gets a specific property value within a multidimensional array. |
|
341 | + * |
|
342 | + * @param array $array The array to search in. |
|
343 | + * @param string $name The name of the property to find. |
|
344 | + * @param string $default Optional. Value that should be returned if the property is not set or empty. Defaults to null. |
|
345 | + * |
|
346 | + * @return null|string|mixed The value |
|
347 | + */ |
|
348 | + private function get_multi_array_value($array, $name, $default = null) |
|
349 | + { |
|
350 | + if (!is_array($array) && !(is_object($array) && $array instanceof ArrayAccess)) { |
|
351 | + return $default; |
|
352 | + } |
|
353 | + |
|
354 | + $names = explode('/', $name); |
|
355 | + $val = $array; |
|
356 | + foreach ($names as $current_name) { |
|
357 | + $val = $this->get_array_value($val, $current_name, $default); |
|
358 | + } |
|
359 | + |
|
360 | + return $val; |
|
361 | + } |
|
362 | + |
|
363 | + /** |
|
364 | + * Get a specific property of an array without needing to check if that property exists. |
|
365 | + * |
|
366 | + * Provide a default value if you want to return a specific value if the property is not set. |
|
367 | + * |
|
368 | + * @param array $array Array from which the property's value should be retrieved. |
|
369 | + * @param string $prop Name of the property to be retrieved. |
|
370 | + * @param string $default Optional. Value that should be returned if the property is not set or empty. Defaults to null. |
|
371 | + * |
|
372 | + * @return null|string|mixed The value |
|
373 | + */ |
|
374 | + private function get_array_value($array, $prop, $default = null) |
|
375 | + { |
|
376 | + if (!is_array($array) && !(is_object($array) && $array instanceof ArrayAccess)) { |
|
377 | + return $default; |
|
378 | + } |
|
379 | + |
|
380 | + if (isset($array[$prop])) { |
|
381 | + $value = $array[$prop]; |
|
382 | + } else { |
|
383 | + $value = $default; |
|
384 | + } |
|
385 | + |
|
386 | + $value_is_zero = 0 === $value; |
|
387 | + |
|
388 | + return (empty($value) && !$value_is_zero) && $default !== null ? $default : $value; |
|
389 | + } |
|
390 | + |
|
391 | + /** |
|
392 | + * Checks whether SSL requirements are met. |
|
393 | + * |
|
394 | + * @since 1.0.0 |
|
395 | + * |
|
396 | + * @return bool Whether the vendor-defined SSL requirements are met. |
|
397 | + */ |
|
398 | + public function meets_ssl_requirement() |
|
399 | + { |
|
400 | + $return = true; |
|
401 | + |
|
402 | + if ($this->get_setting('require_ssl', true) && !is_ssl()) { |
|
403 | + $return = false; |
|
404 | + } |
|
405 | + |
|
406 | + /** |
|
407 | + * @internal Do not rely on this!!!! |
|
408 | + * |
|
409 | + * @todo Remove this |
|
410 | + * |
|
411 | + * @param bool $return Does this site meet the SSL requirement? |
|
412 | + */ |
|
413 | + return apply_filters('trustedlogin/'.$this->ns().'/meets_ssl_requirement', $return); |
|
414 | + } |
|
415 | 415 | } |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | namespace GravityView\TrustedLogin; |
14 | 14 | |
15 | 15 | // Exit if accessed directly |
16 | -if (!defined('ABSPATH')) { |
|
16 | +if ( ! defined( 'ABSPATH' ) ) { |
|
17 | 17 | exit; |
18 | 18 | } |
19 | 19 | |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | /** |
27 | 27 | * @var string[] These namespaces cannot be used, lest they result in confusion. |
28 | 28 | */ |
29 | - private static $reserved_namespaces = ['trustedlogin', 'client', 'vendor', 'admin', 'wordpress']; |
|
29 | + private static $reserved_namespaces = [ 'trustedlogin', 'client', 'vendor', 'admin', 'wordpress' ]; |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * @var array Default settings values |
@@ -40,8 +40,8 @@ discard block |
||
40 | 40 | 'license_key' => null, |
41 | 41 | ], |
42 | 42 | 'caps' => [ |
43 | - 'add' => [], |
|
44 | - 'remove' => [], |
|
43 | + 'add' => [ ], |
|
44 | + 'remove' => [ ], |
|
45 | 45 | ], |
46 | 46 | 'decay' => WEEK_IN_SECONDS, |
47 | 47 | 'logging' => [ |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | * |
90 | 90 | * @since 1.0.0 |
91 | 91 | */ |
92 | - private $settings = []; |
|
92 | + private $settings = [ ]; |
|
93 | 93 | |
94 | 94 | /** |
95 | 95 | * Config constructor. |
@@ -98,10 +98,10 @@ discard block |
||
98 | 98 | * |
99 | 99 | * @throws \Exception |
100 | 100 | */ |
101 | - public function __construct(array $settings = []) |
|
101 | + public function __construct( array $settings = [ ] ) |
|
102 | 102 | { |
103 | - if (empty($settings)) { |
|
104 | - throw new Exception('Developer: TrustedLogin requires a configuration array. See https://trustedlogin.com/configuration/ for more information.', 400); |
|
103 | + if ( empty( $settings ) ) { |
|
104 | + throw new Exception( 'Developer: TrustedLogin requires a configuration array. See https://trustedlogin.com/configuration/ for more information.', 400 ); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | $this->settings = $settings; |
@@ -114,89 +114,89 @@ discard block |
||
114 | 114 | */ |
115 | 115 | public function validate() |
116 | 116 | { |
117 | - if (in_array(__NAMESPACE__, ['ReplaceMe', 'ReplaceMe\GravityView\GravityView\TrustedLogin']) && !defined('TL_DOING_TESTS')) { |
|
118 | - throw new Exception('Developer: make sure to change the namespace for the TrustedLogin class. See https://trustedlogin.com/configuration/ for more information.', 501); |
|
117 | + if ( in_array( __NAMESPACE__, [ 'ReplaceMe', 'ReplaceMe\GravityView\GravityView\TrustedLogin' ] ) && ! defined( 'TL_DOING_TESTS' ) ) { |
|
118 | + throw new Exception( 'Developer: make sure to change the namespace for the TrustedLogin class. See https://trustedlogin.com/configuration/ for more information.', 501 ); |
|
119 | 119 | } |
120 | 120 | |
121 | - $errors = []; |
|
121 | + $errors = [ ]; |
|
122 | 122 | |
123 | - if (!isset($this->settings['auth']['api_key'])) { |
|
124 | - $errors[] = new WP_Error('missing_configuration', 'You need to set an API key. Get yours at https://app.trustedlogin.com'); |
|
123 | + if ( ! isset( $this->settings[ 'auth' ][ 'api_key' ] ) ) { |
|
124 | + $errors[ ] = new WP_Error( 'missing_configuration', 'You need to set an API key. Get yours at https://app.trustedlogin.com' ); |
|
125 | 125 | } |
126 | 126 | |
127 | - if (isset($this->settings['vendor']['website']) && 'https://www.example.com' === $this->settings['vendor']['website'] && !defined('TL_DOING_TESTS')) { |
|
128 | - $errors[] = new WP_Error('missing_configuration', 'You need to configure the "website" URL to point to the URL where the Vendor plugin is installed.'); |
|
127 | + if ( isset( $this->settings[ 'vendor' ][ 'website' ] ) && 'https://www.example.com' === $this->settings[ 'vendor' ][ 'website' ] && ! defined( 'TL_DOING_TESTS' ) ) { |
|
128 | + $errors[ ] = new WP_Error( 'missing_configuration', 'You need to configure the "website" URL to point to the URL where the Vendor plugin is installed.' ); |
|
129 | 129 | } |
130 | 130 | |
131 | - foreach (['namespace', 'title', 'website', 'support_url', 'email'] as $required_vendor_field) { |
|
132 | - if (!isset($this->settings['vendor'][$required_vendor_field])) { |
|
133 | - $errors[] = new WP_Error('missing_configuration', sprintf('Missing required configuration: `vendor/%s`', $required_vendor_field)); |
|
131 | + foreach ( [ 'namespace', 'title', 'website', 'support_url', 'email' ] as $required_vendor_field ) { |
|
132 | + if ( ! isset( $this->settings[ 'vendor' ][ $required_vendor_field ] ) ) { |
|
133 | + $errors[ ] = new WP_Error( 'missing_configuration', sprintf( 'Missing required configuration: `vendor/%s`', $required_vendor_field ) ); |
|
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
137 | - if (isset($this->settings['decay'])) { |
|
138 | - if (!is_int($this->settings['decay'])) { |
|
139 | - $errors[] = new WP_Error('invalid_configuration', 'Decay must be an integer (number of seconds).'); |
|
140 | - } elseif ($this->settings['decay'] > MONTH_IN_SECONDS) { |
|
141 | - $errors[] = new WP_Error('invalid_configuration', 'Decay must be less than or equal to 30 days.'); |
|
142 | - } elseif ($this->settings['decay'] < DAY_IN_SECONDS) { |
|
143 | - $errors[] = new WP_Error('invalid_configuration', 'Decay must be greater than 1 day.'); |
|
137 | + if ( isset( $this->settings[ 'decay' ] ) ) { |
|
138 | + if ( ! is_int( $this->settings[ 'decay' ] ) ) { |
|
139 | + $errors[ ] = new WP_Error( 'invalid_configuration', 'Decay must be an integer (number of seconds).' ); |
|
140 | + } elseif ( $this->settings[ 'decay' ] > MONTH_IN_SECONDS ) { |
|
141 | + $errors[ ] = new WP_Error( 'invalid_configuration', 'Decay must be less than or equal to 30 days.' ); |
|
142 | + } elseif ( $this->settings[ 'decay' ] < DAY_IN_SECONDS ) { |
|
143 | + $errors[ ] = new WP_Error( 'invalid_configuration', 'Decay must be greater than 1 day.' ); |
|
144 | 144 | } |
145 | 145 | } |
146 | 146 | |
147 | - if (isset($this->settings['vendor']['namespace'])) { |
|
147 | + if ( isset( $this->settings[ 'vendor' ][ 'namespace' ] ) ) { |
|
148 | 148 | |
149 | 149 | // This seems like a reasonable max limit on namespace length. |
150 | 150 | // @see https://developer.wordpress.org/reference/functions/set_transient/#more-information |
151 | - if (strlen($this->settings['vendor']['namespace']) > 96) { |
|
152 | - $errors[] = new WP_Error('invalid_configuration', 'Namespace length must be shorter than 96 characters.'); |
|
151 | + if ( strlen( $this->settings[ 'vendor' ][ 'namespace' ] ) > 96 ) { |
|
152 | + $errors[ ] = new WP_Error( 'invalid_configuration', 'Namespace length must be shorter than 96 characters.' ); |
|
153 | 153 | } |
154 | 154 | |
155 | - if (in_array(strtolower($this->settings['vendor']['namespace']), self::$reserved_namespaces, true)) { |
|
156 | - $errors[] = new WP_Error('invalid_configuration', 'The defined namespace is reserved.'); |
|
155 | + if ( in_array( strtolower( $this->settings[ 'vendor' ][ 'namespace' ] ), self::$reserved_namespaces, true ) ) { |
|
156 | + $errors[ ] = new WP_Error( 'invalid_configuration', 'The defined namespace is reserved.' ); |
|
157 | 157 | } |
158 | 158 | } |
159 | 159 | |
160 | - if (isset($this->settings['vendor']['email']) && !filter_var($this->settings['vendor']['email'], FILTER_VALIDATE_EMAIL)) { |
|
161 | - $errors[] = new WP_Error('invalid_configuration', 'An invalid `vendor/email` setting was passed to the TrustedLogin Client.'); |
|
160 | + if ( isset( $this->settings[ 'vendor' ][ 'email' ] ) && ! filter_var( $this->settings[ 'vendor' ][ 'email' ], FILTER_VALIDATE_EMAIL ) ) { |
|
161 | + $errors[ ] = new WP_Error( 'invalid_configuration', 'An invalid `vendor/email` setting was passed to the TrustedLogin Client.' ); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | // TODO: Add namespace collision check? |
165 | - foreach (['webhook_url', 'vendor/support_url', 'vendor/website'] as $settings_key) { |
|
166 | - $value = $this->get_setting($settings_key, null, $this->settings); |
|
167 | - $url = wp_kses_bad_protocol($value, ['http', 'https']); |
|
168 | - if ($value && !filter_var($url, FILTER_VALIDATE_URL)) { |
|
169 | - $errors[] = new WP_Error( |
|
165 | + foreach ( [ 'webhook_url', 'vendor/support_url', 'vendor/website' ] as $settings_key ) { |
|
166 | + $value = $this->get_setting( $settings_key, null, $this->settings ); |
|
167 | + $url = wp_kses_bad_protocol( $value, [ 'http', 'https' ] ); |
|
168 | + if ( $value && ! filter_var( $url, FILTER_VALIDATE_URL ) ) { |
|
169 | + $errors[ ] = new WP_Error( |
|
170 | 170 | 'invalid_configuration', |
171 | 171 | sprintf( |
172 | 172 | 'An invalid `%s` setting was passed to the TrustedLogin Client: %s', |
173 | 173 | $settings_key, |
174 | - print_r($this->get_setting($settings_key, null, $this->settings), true) |
|
174 | + print_r( $this->get_setting( $settings_key, null, $this->settings ), true ) |
|
175 | 175 | ) |
176 | 176 | ); |
177 | 177 | } |
178 | 178 | } |
179 | 179 | |
180 | - $added_caps = $this->get_setting('caps/add', [], $this->settings); |
|
180 | + $added_caps = $this->get_setting( 'caps/add', [ ], $this->settings ); |
|
181 | 181 | |
182 | - foreach (SupportRole::$prevented_caps as $invalid_cap) { |
|
183 | - if (array_key_exists($invalid_cap, $added_caps)) { |
|
184 | - $errors[] = new WP_Error('invalid_configuration', 'TrustedLogin users cannot be allowed to: '.$invalid_cap); |
|
182 | + foreach ( SupportRole::$prevented_caps as $invalid_cap ) { |
|
183 | + if ( array_key_exists( $invalid_cap, $added_caps ) ) { |
|
184 | + $errors[ ] = new WP_Error( 'invalid_configuration', 'TrustedLogin users cannot be allowed to: ' . $invalid_cap ); |
|
185 | 185 | } |
186 | 186 | } |
187 | 187 | |
188 | - if ($errors) { |
|
189 | - $error_text = []; |
|
190 | - foreach ($errors as $error) { |
|
191 | - if (is_wp_error($error)) { |
|
192 | - $error_text[] = $error->get_error_message(); |
|
188 | + if ( $errors ) { |
|
189 | + $error_text = [ ]; |
|
190 | + foreach ( $errors as $error ) { |
|
191 | + if ( is_wp_error( $error ) ) { |
|
192 | + $error_text[ ] = $error->get_error_message(); |
|
193 | 193 | } |
194 | 194 | } |
195 | 195 | |
196 | 196 | $exception_text = 'Invalid TrustedLogin Configuration. Learn more at https://www.trustedlogin.com/configuration/'; |
197 | - $exception_text .= "\n- ".implode("\n- ", $error_text); |
|
197 | + $exception_text .= "\n- " . implode( "\n- ", $error_text ); |
|
198 | 198 | |
199 | - throw new Exception($exception_text, 406); |
|
199 | + throw new Exception( $exception_text, 406 ); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | return true; |
@@ -212,19 +212,19 @@ discard block |
||
212 | 212 | * |
213 | 213 | * @return int|false Timestamp in seconds. Default is WEEK_IN_SECONDS from creation (`time()` + 604800). False if no expiration. |
214 | 214 | */ |
215 | - public function get_expiration_timestamp($decay_time = null, $gmt = false) |
|
215 | + public function get_expiration_timestamp( $decay_time = null, $gmt = false ) |
|
216 | 216 | { |
217 | - if (is_null($decay_time)) { |
|
218 | - $decay_time = $this->get_setting('decay'); |
|
217 | + if ( is_null( $decay_time ) ) { |
|
218 | + $decay_time = $this->get_setting( 'decay' ); |
|
219 | 219 | } |
220 | 220 | |
221 | - if (0 === $decay_time) { |
|
221 | + if ( 0 === $decay_time ) { |
|
222 | 222 | return false; |
223 | 223 | } |
224 | 224 | |
225 | - $time = current_time('timestamp', $gmt); |
|
225 | + $time = current_time( 'timestamp', $gmt ); |
|
226 | 226 | |
227 | - return $time + (int) $decay_time; |
|
227 | + return $time + (int)$decay_time; |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | /** |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | */ |
235 | 235 | public function get_display_name() |
236 | 236 | { |
237 | - return $this->get_setting('vendor/display_name', $this->get_setting('vendor/title', '')); |
|
237 | + return $this->get_setting( 'vendor/display_name', $this->get_setting( 'vendor/title', '' ) ); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | /** |
@@ -244,21 +244,21 @@ discard block |
||
244 | 244 | * |
245 | 245 | * @return bool|WP_Error[] true: Initialization succeeded; array of WP_Error objects if there are any issues. |
246 | 246 | */ |
247 | - protected function parse_settings($config) |
|
247 | + protected function parse_settings( $config ) |
|
248 | 248 | { |
249 | - if (is_string($config)) { |
|
250 | - $config = json_decode($config, true); |
|
249 | + if ( is_string( $config ) ) { |
|
250 | + $config = json_decode( $config, true ); |
|
251 | 251 | } |
252 | 252 | |
253 | - if (!is_array($config) || empty($config)) { |
|
254 | - return [new WP_Error('empty_configuration', 'Configuration array cannot be empty. See https://www.trustedlogin.com/configuration/ for more information.')]; |
|
253 | + if ( ! is_array( $config ) || empty( $config ) ) { |
|
254 | + return [ new WP_Error( 'empty_configuration', 'Configuration array cannot be empty. See https://www.trustedlogin.com/configuration/ for more information.' ) ]; |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | $defaults = $this->get_default_settings(); |
258 | 258 | |
259 | - $filtered_config = array_filter($config, [$this, 'is_not_null']); |
|
259 | + $filtered_config = array_filter( $config, [ $this, 'is_not_null' ] ); |
|
260 | 260 | |
261 | - return shortcode_atts($defaults, $filtered_config); |
|
261 | + return shortcode_atts( $defaults, $filtered_config ); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | /** |
@@ -270,9 +270,9 @@ discard block |
||
270 | 270 | * |
271 | 271 | * @return bool True: not null. False: null |
272 | 272 | */ |
273 | - public function is_not_null($input) |
|
273 | + public function is_not_null( $input ) |
|
274 | 274 | { |
275 | - return !is_null($input); |
|
275 | + return ! is_null( $input ); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | /** |
@@ -286,8 +286,8 @@ discard block |
||
286 | 286 | { |
287 | 287 | $default_settings = $this->default_settings; |
288 | 288 | |
289 | - $default_settings['paths']['css'] = plugin_dir_url(__FILE__).'assets/trustedlogin.css'; |
|
290 | - $default_settings['paths']['js'] = plugin_dir_url(__FILE__).'assets/trustedlogin.js'; |
|
289 | + $default_settings[ 'paths' ][ 'css' ] = plugin_dir_url( __FILE__ ) . 'assets/trustedlogin.css'; |
|
290 | + $default_settings[ 'paths' ][ 'js' ] = plugin_dir_url( __FILE__ ) . 'assets/trustedlogin.js'; |
|
291 | 291 | |
292 | 292 | return $default_settings; |
293 | 293 | } |
@@ -299,10 +299,10 @@ discard block |
||
299 | 299 | { |
300 | 300 | static $namespace; |
301 | 301 | |
302 | - if (!$namespace) { |
|
303 | - $ns = $this->get_setting('vendor/namespace'); |
|
302 | + if ( ! $namespace ) { |
|
303 | + $ns = $this->get_setting( 'vendor/namespace' ); |
|
304 | 304 | |
305 | - $namespace = sanitize_title_with_dashes($ns); |
|
305 | + $namespace = sanitize_title_with_dashes( $ns ); |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | return $namespace; |
@@ -319,21 +319,21 @@ discard block |
||
319 | 319 | * |
320 | 320 | * @return string|array |
321 | 321 | */ |
322 | - public function get_setting($key, $default = null, $settings = []) |
|
322 | + public function get_setting( $key, $default = null, $settings = [ ] ) |
|
323 | 323 | { |
324 | - if (empty($settings)) { |
|
324 | + if ( empty( $settings ) ) { |
|
325 | 325 | $settings = $this->settings; |
326 | 326 | } |
327 | 327 | |
328 | - if (is_null($default)) { |
|
329 | - $default = $this->get_multi_array_value($this->get_default_settings(), $key); |
|
328 | + if ( is_null( $default ) ) { |
|
329 | + $default = $this->get_multi_array_value( $this->get_default_settings(), $key ); |
|
330 | 330 | } |
331 | 331 | |
332 | - if (empty($settings) || !is_array($settings)) { |
|
332 | + if ( empty( $settings ) || ! is_array( $settings ) ) { |
|
333 | 333 | return $default; |
334 | 334 | } |
335 | 335 | |
336 | - return $this->get_multi_array_value($settings, $key, $default); |
|
336 | + return $this->get_multi_array_value( $settings, $key, $default ); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | /** |
@@ -345,16 +345,16 @@ discard block |
||
345 | 345 | * |
346 | 346 | * @return null|string|mixed The value |
347 | 347 | */ |
348 | - private function get_multi_array_value($array, $name, $default = null) |
|
348 | + private function get_multi_array_value( $array, $name, $default = null ) |
|
349 | 349 | { |
350 | - if (!is_array($array) && !(is_object($array) && $array instanceof ArrayAccess)) { |
|
350 | + if ( ! is_array( $array ) && ! ( is_object( $array ) && $array instanceof ArrayAccess ) ) { |
|
351 | 351 | return $default; |
352 | 352 | } |
353 | 353 | |
354 | - $names = explode('/', $name); |
|
354 | + $names = explode( '/', $name ); |
|
355 | 355 | $val = $array; |
356 | - foreach ($names as $current_name) { |
|
357 | - $val = $this->get_array_value($val, $current_name, $default); |
|
356 | + foreach ( $names as $current_name ) { |
|
357 | + $val = $this->get_array_value( $val, $current_name, $default ); |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | return $val; |
@@ -371,21 +371,21 @@ discard block |
||
371 | 371 | * |
372 | 372 | * @return null|string|mixed The value |
373 | 373 | */ |
374 | - private function get_array_value($array, $prop, $default = null) |
|
374 | + private function get_array_value( $array, $prop, $default = null ) |
|
375 | 375 | { |
376 | - if (!is_array($array) && !(is_object($array) && $array instanceof ArrayAccess)) { |
|
376 | + if ( ! is_array( $array ) && ! ( is_object( $array ) && $array instanceof ArrayAccess ) ) { |
|
377 | 377 | return $default; |
378 | 378 | } |
379 | 379 | |
380 | - if (isset($array[$prop])) { |
|
381 | - $value = $array[$prop]; |
|
380 | + if ( isset( $array[ $prop ] ) ) { |
|
381 | + $value = $array[ $prop ]; |
|
382 | 382 | } else { |
383 | 383 | $value = $default; |
384 | 384 | } |
385 | 385 | |
386 | 386 | $value_is_zero = 0 === $value; |
387 | 387 | |
388 | - return (empty($value) && !$value_is_zero) && $default !== null ? $default : $value; |
|
388 | + return ( empty( $value ) && ! $value_is_zero ) && $default !== null ? $default : $value; |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | /** |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | { |
400 | 400 | $return = true; |
401 | 401 | |
402 | - if ($this->get_setting('require_ssl', true) && !is_ssl()) { |
|
402 | + if ( $this->get_setting( 'require_ssl', true ) && ! is_ssl() ) { |
|
403 | 403 | $return = false; |
404 | 404 | } |
405 | 405 | |
@@ -410,6 +410,6 @@ discard block |
||
410 | 410 | * |
411 | 411 | * @param bool $return Does this site meet the SSL requirement? |
412 | 412 | */ |
413 | - return apply_filters('trustedlogin/'.$this->ns().'/meets_ssl_requirement', $return); |
|
413 | + return apply_filters( 'trustedlogin/' . $this->ns() . '/meets_ssl_requirement', $return ); |
|
414 | 414 | } |
415 | 415 | } |
@@ -21,8 +21,7 @@ discard block |
||
21 | 21 | use Exception; |
22 | 22 | use WP_Error; |
23 | 23 | |
24 | -final class Config |
|
25 | -{ |
|
24 | +final class Config { |
|
26 | 25 | /** |
27 | 26 | * @var string[] These namespaces cannot be used, lest they result in confusion. |
28 | 27 | */ |
@@ -98,8 +97,7 @@ discard block |
||
98 | 97 | * |
99 | 98 | * @throws \Exception |
100 | 99 | */ |
101 | - public function __construct(array $settings = []) |
|
102 | - { |
|
100 | + public function __construct(array $settings = []) { |
|
103 | 101 | if (empty($settings)) { |
104 | 102 | throw new Exception('Developer: TrustedLogin requires a configuration array. See https://trustedlogin.com/configuration/ for more information.', 400); |
105 | 103 | } |
@@ -112,8 +110,7 @@ discard block |
||
112 | 110 | * |
113 | 111 | * @return true|\WP_Error[] |
114 | 112 | */ |
115 | - public function validate() |
|
116 | - { |
|
113 | + public function validate() { |
|
117 | 114 | if (in_array(__NAMESPACE__, ['ReplaceMe', 'ReplaceMe\GravityView\GravityView\TrustedLogin']) && !defined('TL_DOING_TESTS')) { |
118 | 115 | throw new Exception('Developer: make sure to change the namespace for the TrustedLogin class. See https://trustedlogin.com/configuration/ for more information.', 501); |
119 | 116 | } |
@@ -212,8 +209,7 @@ discard block |
||
212 | 209 | * |
213 | 210 | * @return int|false Timestamp in seconds. Default is WEEK_IN_SECONDS from creation (`time()` + 604800). False if no expiration. |
214 | 211 | */ |
215 | - public function get_expiration_timestamp($decay_time = null, $gmt = false) |
|
216 | - { |
|
212 | + public function get_expiration_timestamp($decay_time = null, $gmt = false) { |
|
217 | 213 | if (is_null($decay_time)) { |
218 | 214 | $decay_time = $this->get_setting('decay'); |
219 | 215 | } |
@@ -232,8 +228,7 @@ discard block |
||
232 | 228 | * |
233 | 229 | * @return string |
234 | 230 | */ |
235 | - public function get_display_name() |
|
236 | - { |
|
231 | + public function get_display_name() { |
|
237 | 232 | return $this->get_setting('vendor/display_name', $this->get_setting('vendor/title', '')); |
238 | 233 | } |
239 | 234 | |
@@ -244,8 +239,7 @@ discard block |
||
244 | 239 | * |
245 | 240 | * @return bool|WP_Error[] true: Initialization succeeded; array of WP_Error objects if there are any issues. |
246 | 241 | */ |
247 | - protected function parse_settings($config) |
|
248 | - { |
|
242 | + protected function parse_settings($config) { |
|
249 | 243 | if (is_string($config)) { |
250 | 244 | $config = json_decode($config, true); |
251 | 245 | } |
@@ -270,8 +264,7 @@ discard block |
||
270 | 264 | * |
271 | 265 | * @return bool True: not null. False: null |
272 | 266 | */ |
273 | - public function is_not_null($input) |
|
274 | - { |
|
267 | + public function is_not_null($input) { |
|
275 | 268 | return !is_null($input); |
276 | 269 | } |
277 | 270 | |
@@ -282,8 +275,7 @@ discard block |
||
282 | 275 | * |
283 | 276 | * @return array Array of default settings. |
284 | 277 | */ |
285 | - public function get_default_settings() |
|
286 | - { |
|
278 | + public function get_default_settings() { |
|
287 | 279 | $default_settings = $this->default_settings; |
288 | 280 | |
289 | 281 | $default_settings['paths']['css'] = plugin_dir_url(__FILE__).'assets/trustedlogin.css'; |
@@ -295,8 +287,7 @@ discard block |
||
295 | 287 | /** |
296 | 288 | * @return string Vendor namespace, sanitized with dashes |
297 | 289 | */ |
298 | - public function ns() |
|
299 | - { |
|
290 | + public function ns() { |
|
300 | 291 | static $namespace; |
301 | 292 | |
302 | 293 | if (!$namespace) { |
@@ -319,8 +310,7 @@ discard block |
||
319 | 310 | * |
320 | 311 | * @return string|array |
321 | 312 | */ |
322 | - public function get_setting($key, $default = null, $settings = []) |
|
323 | - { |
|
313 | + public function get_setting($key, $default = null, $settings = []) { |
|
324 | 314 | if (empty($settings)) { |
325 | 315 | $settings = $this->settings; |
326 | 316 | } |
@@ -345,8 +335,7 @@ discard block |
||
345 | 335 | * |
346 | 336 | * @return null|string|mixed The value |
347 | 337 | */ |
348 | - private function get_multi_array_value($array, $name, $default = null) |
|
349 | - { |
|
338 | + private function get_multi_array_value($array, $name, $default = null) { |
|
350 | 339 | if (!is_array($array) && !(is_object($array) && $array instanceof ArrayAccess)) { |
351 | 340 | return $default; |
352 | 341 | } |
@@ -371,8 +360,7 @@ discard block |
||
371 | 360 | * |
372 | 361 | * @return null|string|mixed The value |
373 | 362 | */ |
374 | - private function get_array_value($array, $prop, $default = null) |
|
375 | - { |
|
363 | + private function get_array_value($array, $prop, $default = null) { |
|
376 | 364 | if (!is_array($array) && !(is_object($array) && $array instanceof ArrayAccess)) { |
377 | 365 | return $default; |
378 | 366 | } |
@@ -395,8 +383,7 @@ discard block |
||
395 | 383 | * |
396 | 384 | * @return bool Whether the vendor-defined SSL requirements are met. |
397 | 385 | */ |
398 | - public function meets_ssl_requirement() |
|
399 | - { |
|
386 | + public function meets_ssl_requirement() { |
|
400 | 387 | $return = true; |
401 | 388 | |
402 | 389 | if ($this->get_setting('require_ssl', true) && !is_ssl()) { |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | |
26 | 26 | // Exit if accessed directly |
27 | 27 | if (!defined('ABSPATH')) { |
28 | - exit; |
|
28 | + exit; |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | use Exception; |
@@ -36,524 +36,524 @@ discard block |
||
36 | 36 | */ |
37 | 37 | final class Client |
38 | 38 | { |
39 | - /** |
|
40 | - * @var string The current drop-in file version |
|
41 | - * |
|
42 | - * @since 1.0.0 |
|
43 | - */ |
|
44 | - const VERSION = '1.2'; |
|
45 | - |
|
46 | - /** |
|
47 | - * @var Config |
|
48 | - */ |
|
49 | - private $config; |
|
50 | - |
|
51 | - /** |
|
52 | - * @var bool |
|
53 | - */ |
|
54 | - public static $valid_config; |
|
55 | - |
|
56 | - /** |
|
57 | - * @var null|Logging |
|
58 | - */ |
|
59 | - private $logging; |
|
60 | - |
|
61 | - /** |
|
62 | - * @var SupportUser |
|
63 | - */ |
|
64 | - private $support_user; |
|
65 | - |
|
66 | - /** |
|
67 | - * @var Remote |
|
68 | - */ |
|
69 | - private $remote; |
|
70 | - |
|
71 | - /** |
|
72 | - * @var Cron |
|
73 | - */ |
|
74 | - private $cron; |
|
75 | - |
|
76 | - /** |
|
77 | - * @var Endpoint |
|
78 | - */ |
|
79 | - private $endpoint; |
|
80 | - |
|
81 | - /** |
|
82 | - * @var Admin |
|
83 | - */ |
|
84 | - private $admin; |
|
85 | - |
|
86 | - /** |
|
87 | - * @var Ajax |
|
88 | - */ |
|
89 | - private $ajax; |
|
90 | - |
|
91 | - /** |
|
92 | - * @var SiteAccess |
|
93 | - */ |
|
94 | - private $site_access; |
|
95 | - |
|
96 | - /** |
|
97 | - * TrustedLogin constructor. |
|
98 | - * |
|
99 | - * @see https://docs.trustedlogin.com/ for more information |
|
100 | - * |
|
101 | - * @param Config $config |
|
102 | - * @param bool $init Whether to initialize everything on instantiation |
|
103 | - * |
|
104 | - * @throws Exception If initializing is prevented via constants or the configuration isn't valid, throws exception. |
|
105 | - * |
|
106 | - * @returns void If no errors, returns void. Otherwise, throws exceptions. |
|
107 | - */ |
|
108 | - public function __construct(Config $config, $init = true) |
|
109 | - { |
|
110 | - $should_initialize = $this->should_init($config); |
|
111 | - |
|
112 | - if (!$should_initialize) { |
|
113 | - throw new \Exception('TrustedLogin was prevented from loading by constants defined on the site.', 403); |
|
114 | - } |
|
115 | - |
|
116 | - try { |
|
117 | - self::$valid_config = $config->validate(); |
|
118 | - } catch (\Exception $exception) { |
|
119 | - self::$valid_config = false; |
|
120 | - |
|
121 | - throw $exception; |
|
122 | - } |
|
123 | - |
|
124 | - $this->config = $config; |
|
125 | - |
|
126 | - $this->logging = new Logging($config); |
|
127 | - |
|
128 | - $this->endpoint = new Endpoint($this->config, $this->logging); |
|
129 | - |
|
130 | - $this->cron = new Cron($this->config, $this->logging); |
|
131 | - |
|
132 | - $this->support_user = new SupportUser($this->config, $this->logging); |
|
133 | - |
|
134 | - $this->admin = new Admin($this->config, $this->logging); |
|
135 | - |
|
136 | - $this->ajax = new Ajax($this->config, $this->logging); |
|
137 | - |
|
138 | - $this->remote = new Remote($this->config, $this->logging); |
|
139 | - |
|
140 | - $this->site_access = new SiteAccess($this->config, $this->logging); |
|
141 | - |
|
142 | - if ($init) { |
|
143 | - $this->init(); |
|
144 | - } |
|
145 | - } |
|
146 | - |
|
147 | - /** |
|
148 | - * Should the Client fully initialize? |
|
149 | - * |
|
150 | - * @param Config $config |
|
151 | - * |
|
152 | - * @return bool |
|
153 | - */ |
|
154 | - private function should_init(Config $config) |
|
155 | - { |
|
156 | - |
|
157 | - // Disables all TL clients. |
|
158 | - if (defined('TRUSTEDLOGIN_DISABLE') && TRUSTEDLOGIN_DISABLE) { |
|
159 | - return false; |
|
160 | - } |
|
161 | - |
|
162 | - $ns = $config->ns(); |
|
163 | - |
|
164 | - // Namespace isn't set; allow Config |
|
165 | - if (empty($ns)) { |
|
166 | - return true; |
|
167 | - } |
|
168 | - |
|
169 | - // Disables namespaced client if `TRUSTEDLOGIN_DISABLE_{NS}` is defined and truthy. |
|
170 | - if (defined('TRUSTEDLOGIN_DISABLE_'.strtoupper($ns)) && constant('TRUSTEDLOGIN_DISABLE_'.strtoupper($ns))) { |
|
171 | - return false; |
|
172 | - } |
|
173 | - |
|
174 | - return true; |
|
175 | - } |
|
176 | - |
|
177 | - /** |
|
178 | - * Initialize all the things! |
|
179 | - */ |
|
180 | - public function init() |
|
181 | - { |
|
182 | - $this->admin->init(); |
|
183 | - $this->endpoint->init(); |
|
184 | - $this->remote->init(); |
|
185 | - $this->cron->init(); |
|
186 | - $this->ajax->init(); |
|
187 | - } |
|
39 | + /** |
|
40 | + * @var string The current drop-in file version |
|
41 | + * |
|
42 | + * @since 1.0.0 |
|
43 | + */ |
|
44 | + const VERSION = '1.2'; |
|
45 | + |
|
46 | + /** |
|
47 | + * @var Config |
|
48 | + */ |
|
49 | + private $config; |
|
50 | + |
|
51 | + /** |
|
52 | + * @var bool |
|
53 | + */ |
|
54 | + public static $valid_config; |
|
55 | + |
|
56 | + /** |
|
57 | + * @var null|Logging |
|
58 | + */ |
|
59 | + private $logging; |
|
60 | + |
|
61 | + /** |
|
62 | + * @var SupportUser |
|
63 | + */ |
|
64 | + private $support_user; |
|
65 | + |
|
66 | + /** |
|
67 | + * @var Remote |
|
68 | + */ |
|
69 | + private $remote; |
|
70 | + |
|
71 | + /** |
|
72 | + * @var Cron |
|
73 | + */ |
|
74 | + private $cron; |
|
75 | + |
|
76 | + /** |
|
77 | + * @var Endpoint |
|
78 | + */ |
|
79 | + private $endpoint; |
|
80 | + |
|
81 | + /** |
|
82 | + * @var Admin |
|
83 | + */ |
|
84 | + private $admin; |
|
85 | + |
|
86 | + /** |
|
87 | + * @var Ajax |
|
88 | + */ |
|
89 | + private $ajax; |
|
90 | + |
|
91 | + /** |
|
92 | + * @var SiteAccess |
|
93 | + */ |
|
94 | + private $site_access; |
|
95 | + |
|
96 | + /** |
|
97 | + * TrustedLogin constructor. |
|
98 | + * |
|
99 | + * @see https://docs.trustedlogin.com/ for more information |
|
100 | + * |
|
101 | + * @param Config $config |
|
102 | + * @param bool $init Whether to initialize everything on instantiation |
|
103 | + * |
|
104 | + * @throws Exception If initializing is prevented via constants or the configuration isn't valid, throws exception. |
|
105 | + * |
|
106 | + * @returns void If no errors, returns void. Otherwise, throws exceptions. |
|
107 | + */ |
|
108 | + public function __construct(Config $config, $init = true) |
|
109 | + { |
|
110 | + $should_initialize = $this->should_init($config); |
|
111 | + |
|
112 | + if (!$should_initialize) { |
|
113 | + throw new \Exception('TrustedLogin was prevented from loading by constants defined on the site.', 403); |
|
114 | + } |
|
115 | + |
|
116 | + try { |
|
117 | + self::$valid_config = $config->validate(); |
|
118 | + } catch (\Exception $exception) { |
|
119 | + self::$valid_config = false; |
|
120 | + |
|
121 | + throw $exception; |
|
122 | + } |
|
123 | + |
|
124 | + $this->config = $config; |
|
125 | + |
|
126 | + $this->logging = new Logging($config); |
|
127 | + |
|
128 | + $this->endpoint = new Endpoint($this->config, $this->logging); |
|
129 | + |
|
130 | + $this->cron = new Cron($this->config, $this->logging); |
|
131 | + |
|
132 | + $this->support_user = new SupportUser($this->config, $this->logging); |
|
133 | + |
|
134 | + $this->admin = new Admin($this->config, $this->logging); |
|
135 | + |
|
136 | + $this->ajax = new Ajax($this->config, $this->logging); |
|
137 | + |
|
138 | + $this->remote = new Remote($this->config, $this->logging); |
|
139 | + |
|
140 | + $this->site_access = new SiteAccess($this->config, $this->logging); |
|
141 | + |
|
142 | + if ($init) { |
|
143 | + $this->init(); |
|
144 | + } |
|
145 | + } |
|
146 | + |
|
147 | + /** |
|
148 | + * Should the Client fully initialize? |
|
149 | + * |
|
150 | + * @param Config $config |
|
151 | + * |
|
152 | + * @return bool |
|
153 | + */ |
|
154 | + private function should_init(Config $config) |
|
155 | + { |
|
156 | + |
|
157 | + // Disables all TL clients. |
|
158 | + if (defined('TRUSTEDLOGIN_DISABLE') && TRUSTEDLOGIN_DISABLE) { |
|
159 | + return false; |
|
160 | + } |
|
161 | + |
|
162 | + $ns = $config->ns(); |
|
163 | + |
|
164 | + // Namespace isn't set; allow Config |
|
165 | + if (empty($ns)) { |
|
166 | + return true; |
|
167 | + } |
|
168 | + |
|
169 | + // Disables namespaced client if `TRUSTEDLOGIN_DISABLE_{NS}` is defined and truthy. |
|
170 | + if (defined('TRUSTEDLOGIN_DISABLE_'.strtoupper($ns)) && constant('TRUSTEDLOGIN_DISABLE_'.strtoupper($ns))) { |
|
171 | + return false; |
|
172 | + } |
|
173 | + |
|
174 | + return true; |
|
175 | + } |
|
176 | + |
|
177 | + /** |
|
178 | + * Initialize all the things! |
|
179 | + */ |
|
180 | + public function init() |
|
181 | + { |
|
182 | + $this->admin->init(); |
|
183 | + $this->endpoint->init(); |
|
184 | + $this->remote->init(); |
|
185 | + $this->cron->init(); |
|
186 | + $this->ajax->init(); |
|
187 | + } |
|
188 | 188 | |
189 | - /** |
|
190 | - * Returns the current access key (hashed license key or generated access key. |
|
191 | - * |
|
192 | - * @see SiteAccess::get_access_key() |
|
193 | - * |
|
194 | - * @return string|null|WP_Error |
|
195 | - */ |
|
196 | - public function get_access_key() |
|
197 | - { |
|
198 | - if (!self::$valid_config) { |
|
199 | - return new WP_Error('invalid_configuration', 'TrustedLogin has not been properly configured or instantiated.', ['error_code' => 424]); |
|
200 | - } |
|
189 | + /** |
|
190 | + * Returns the current access key (hashed license key or generated access key. |
|
191 | + * |
|
192 | + * @see SiteAccess::get_access_key() |
|
193 | + * |
|
194 | + * @return string|null|WP_Error |
|
195 | + */ |
|
196 | + public function get_access_key() |
|
197 | + { |
|
198 | + if (!self::$valid_config) { |
|
199 | + return new WP_Error('invalid_configuration', 'TrustedLogin has not been properly configured or instantiated.', ['error_code' => 424]); |
|
200 | + } |
|
201 | 201 | |
202 | - return $this->site_access->get_access_key(); |
|
203 | - } |
|
202 | + return $this->site_access->get_access_key(); |
|
203 | + } |
|
204 | 204 | |
205 | - /** |
|
206 | - * This creates a TrustedLogin user ✨. |
|
207 | - * |
|
208 | - * @return array|WP_Error |
|
209 | - */ |
|
210 | - public function grant_access() |
|
211 | - { |
|
212 | - if (!self::$valid_config) { |
|
213 | - return new WP_Error('invalid_configuration', 'TrustedLogin has not been properly configured or instantiated.', ['error_code' => 424]); |
|
214 | - } |
|
205 | + /** |
|
206 | + * This creates a TrustedLogin user ✨. |
|
207 | + * |
|
208 | + * @return array|WP_Error |
|
209 | + */ |
|
210 | + public function grant_access() |
|
211 | + { |
|
212 | + if (!self::$valid_config) { |
|
213 | + return new WP_Error('invalid_configuration', 'TrustedLogin has not been properly configured or instantiated.', ['error_code' => 424]); |
|
214 | + } |
|
215 | 215 | |
216 | - if (!current_user_can('create_users')) { |
|
217 | - return new WP_Error('no_cap_create_users', 'Permissions issue: You do not have the ability to create users.', ['error_code' => 403]); |
|
218 | - } |
|
216 | + if (!current_user_can('create_users')) { |
|
217 | + return new WP_Error('no_cap_create_users', 'Permissions issue: You do not have the ability to create users.', ['error_code' => 403]); |
|
218 | + } |
|
219 | 219 | |
220 | - // If the user exists already, extend access |
|
221 | - if ($user_id = $this->support_user->exists()) { |
|
222 | - return $this->extend_access($user_id); |
|
223 | - } |
|
220 | + // If the user exists already, extend access |
|
221 | + if ($user_id = $this->support_user->exists()) { |
|
222 | + return $this->extend_access($user_id); |
|
223 | + } |
|
224 | 224 | |
225 | - timer_start(); |
|
225 | + timer_start(); |
|
226 | 226 | |
227 | - try { |
|
228 | - $support_user_id = $this->support_user->create(); |
|
229 | - } catch (Exception $exception) { |
|
230 | - $this->logging->log('An exception occurred trying to create a support user.', __METHOD__, 'critical', $exception); |
|
227 | + try { |
|
228 | + $support_user_id = $this->support_user->create(); |
|
229 | + } catch (Exception $exception) { |
|
230 | + $this->logging->log('An exception occurred trying to create a support user.', __METHOD__, 'critical', $exception); |
|
231 | 231 | |
232 | - return new WP_Error('support_user_exception', $exception->getMessage(), ['error_code' => 500]); |
|
233 | - } |
|
232 | + return new WP_Error('support_user_exception', $exception->getMessage(), ['error_code' => 500]); |
|
233 | + } |
|
234 | 234 | |
235 | - if (is_wp_error($support_user_id)) { |
|
236 | - $this->logging->log(sprintf('Support user not created: %s (%s)', $support_user_id->get_error_message(), $support_user_id->get_error_code()), __METHOD__, 'error'); |
|
235 | + if (is_wp_error($support_user_id)) { |
|
236 | + $this->logging->log(sprintf('Support user not created: %s (%s)', $support_user_id->get_error_message(), $support_user_id->get_error_code()), __METHOD__, 'error'); |
|
237 | 237 | |
238 | - $support_user_id->add_data(['error_code' => 409]); |
|
238 | + $support_user_id->add_data(['error_code' => 409]); |
|
239 | 239 | |
240 | - return $support_user_id; |
|
241 | - } |
|
240 | + return $support_user_id; |
|
241 | + } |
|
242 | 242 | |
243 | - $site_identifier_hash = Encryption::get_random_hash($this->logging); |
|
243 | + $site_identifier_hash = Encryption::get_random_hash($this->logging); |
|
244 | 244 | |
245 | - if (is_wp_error($site_identifier_hash)) { |
|
246 | - wp_delete_user($support_user_id); |
|
245 | + if (is_wp_error($site_identifier_hash)) { |
|
246 | + wp_delete_user($support_user_id); |
|
247 | 247 | |
248 | - $this->logging->log('Could not generate a secure secret.', __METHOD__, 'error'); |
|
248 | + $this->logging->log('Could not generate a secure secret.', __METHOD__, 'error'); |
|
249 | 249 | |
250 | - return new WP_Error('secure_secret_failed', 'Could not generate a secure secret.', ['error_code' => 501]); |
|
251 | - } |
|
250 | + return new WP_Error('secure_secret_failed', 'Could not generate a secure secret.', ['error_code' => 501]); |
|
251 | + } |
|
252 | 252 | |
253 | - $endpoint_hash = $this->endpoint->get_hash($site_identifier_hash); |
|
253 | + $endpoint_hash = $this->endpoint->get_hash($site_identifier_hash); |
|
254 | 254 | |
255 | - $updated = $this->endpoint->update($endpoint_hash); |
|
255 | + $updated = $this->endpoint->update($endpoint_hash); |
|
256 | 256 | |
257 | - if (!$updated) { |
|
258 | - $this->logging->log('Endpoint hash did not save or didn\'t update.', __METHOD__, 'info'); |
|
259 | - } |
|
257 | + if (!$updated) { |
|
258 | + $this->logging->log('Endpoint hash did not save or didn\'t update.', __METHOD__, 'info'); |
|
259 | + } |
|
260 | 260 | |
261 | - $expiration_timestamp = $this->config->get_expiration_timestamp(); |
|
261 | + $expiration_timestamp = $this->config->get_expiration_timestamp(); |
|
262 | 262 | |
263 | - // Add user meta, configure decay |
|
264 | - $did_setup = $this->support_user->setup($support_user_id, $site_identifier_hash, $expiration_timestamp, $this->cron); |
|
263 | + // Add user meta, configure decay |
|
264 | + $did_setup = $this->support_user->setup($support_user_id, $site_identifier_hash, $expiration_timestamp, $this->cron); |
|
265 | 265 | |
266 | - if (is_wp_error($did_setup)) { |
|
267 | - wp_delete_user($support_user_id); |
|
266 | + if (is_wp_error($did_setup)) { |
|
267 | + wp_delete_user($support_user_id); |
|
268 | 268 | |
269 | - $did_setup->add_data(['error_code' => 503]); |
|
269 | + $did_setup->add_data(['error_code' => 503]); |
|
270 | 270 | |
271 | - return $did_setup; |
|
272 | - } |
|
271 | + return $did_setup; |
|
272 | + } |
|
273 | 273 | |
274 | - if (empty($did_setup)) { |
|
275 | - return new WP_Error('support_user_setup_failed', 'Error updating user with identifier.', ['error_code' => 503]); |
|
276 | - } |
|
274 | + if (empty($did_setup)) { |
|
275 | + return new WP_Error('support_user_setup_failed', 'Error updating user with identifier.', ['error_code' => 503]); |
|
276 | + } |
|
277 | 277 | |
278 | - $secret_id = $this->endpoint->generate_secret_id($site_identifier_hash, $endpoint_hash); |
|
278 | + $secret_id = $this->endpoint->generate_secret_id($site_identifier_hash, $endpoint_hash); |
|
279 | 279 | |
280 | - if (is_wp_error($secret_id)) { |
|
281 | - wp_delete_user($support_user_id); |
|
280 | + if (is_wp_error($secret_id)) { |
|
281 | + wp_delete_user($support_user_id); |
|
282 | 282 | |
283 | - $secret_id->add_data(['error_code' => 500]); |
|
283 | + $secret_id->add_data(['error_code' => 500]); |
|
284 | 284 | |
285 | - return $secret_id; |
|
286 | - } |
|
285 | + return $secret_id; |
|
286 | + } |
|
287 | 287 | |
288 | - $reference_id = self::get_reference_id(); |
|
288 | + $reference_id = self::get_reference_id(); |
|
289 | 289 | |
290 | - $timing_local = timer_stop(0, 5); |
|
290 | + $timing_local = timer_stop(0, 5); |
|
291 | 291 | |
292 | - $return_data = [ |
|
293 | - 'type' => 'new', |
|
294 | - 'site_url' => get_site_url(), |
|
295 | - 'endpoint' => $endpoint_hash, |
|
296 | - 'identifier' => $site_identifier_hash, |
|
297 | - 'user_id' => $support_user_id, |
|
298 | - 'expiry' => $expiration_timestamp, |
|
299 | - 'reference_id' => $reference_id, |
|
300 | - 'timing' => [ |
|
301 | - 'local' => $timing_local, |
|
302 | - 'remote' => null, // Updated later |
|
303 | - ], |
|
304 | - ]; |
|
292 | + $return_data = [ |
|
293 | + 'type' => 'new', |
|
294 | + 'site_url' => get_site_url(), |
|
295 | + 'endpoint' => $endpoint_hash, |
|
296 | + 'identifier' => $site_identifier_hash, |
|
297 | + 'user_id' => $support_user_id, |
|
298 | + 'expiry' => $expiration_timestamp, |
|
299 | + 'reference_id' => $reference_id, |
|
300 | + 'timing' => [ |
|
301 | + 'local' => $timing_local, |
|
302 | + 'remote' => null, // Updated later |
|
303 | + ], |
|
304 | + ]; |
|
305 | 305 | |
306 | - if (!$this->config->meets_ssl_requirement()) { |
|
307 | - return new WP_Error('fails_ssl_requirement', esc_html__('TrustedLogin requires a secure connection using HTTPS.', 'gravityview')); |
|
308 | - } |
|
306 | + if (!$this->config->meets_ssl_requirement()) { |
|
307 | + return new WP_Error('fails_ssl_requirement', esc_html__('TrustedLogin requires a secure connection using HTTPS.', 'gravityview')); |
|
308 | + } |
|
309 | 309 | |
310 | - timer_start(); |
|
310 | + timer_start(); |
|
311 | 311 | |
312 | - try { |
|
313 | - add_filter('trustedlogin/'.$this->config->ns().'/envelope/meta', [$this, 'add_meta_to_envelope']); |
|
312 | + try { |
|
313 | + add_filter('trustedlogin/'.$this->config->ns().'/envelope/meta', [$this, 'add_meta_to_envelope']); |
|
314 | 314 | |
315 | - $created = $this->site_access->sync_secret($secret_id, $site_identifier_hash, 'create'); |
|
315 | + $created = $this->site_access->sync_secret($secret_id, $site_identifier_hash, 'create'); |
|
316 | 316 | |
317 | - remove_filter('trustedlogin/'.$this->config->ns().'/envelope/meta', [$this, 'add_meta_to_envelope']); |
|
318 | - } catch (Exception $e) { |
|
319 | - $exception_error = new WP_Error($e->getCode(), $e->getMessage(), ['status_code' => 500]); |
|
317 | + remove_filter('trustedlogin/'.$this->config->ns().'/envelope/meta', [$this, 'add_meta_to_envelope']); |
|
318 | + } catch (Exception $e) { |
|
319 | + $exception_error = new WP_Error($e->getCode(), $e->getMessage(), ['status_code' => 500]); |
|
320 | 320 | |
321 | - $this->logging->log('There was an error creating a secret.', __METHOD__, 'error', $e); |
|
321 | + $this->logging->log('There was an error creating a secret.', __METHOD__, 'error', $e); |
|
322 | 322 | |
323 | - wp_delete_user($support_user_id); |
|
323 | + wp_delete_user($support_user_id); |
|
324 | 324 | |
325 | - return $exception_error; |
|
326 | - } |
|
325 | + return $exception_error; |
|
326 | + } |
|
327 | 327 | |
328 | - if (is_wp_error($created)) { |
|
329 | - $this->logging->log(sprintf('There was an issue creating access (%s): %s', $created->get_error_code(), $created->get_error_message()), __METHOD__, 'error'); |
|
328 | + if (is_wp_error($created)) { |
|
329 | + $this->logging->log(sprintf('There was an issue creating access (%s): %s', $created->get_error_code(), $created->get_error_message()), __METHOD__, 'error'); |
|
330 | 330 | |
331 | - $created->add_data(['status_code' => 503]); |
|
331 | + $created->add_data(['status_code' => 503]); |
|
332 | 332 | |
333 | - wp_delete_user($support_user_id); |
|
333 | + wp_delete_user($support_user_id); |
|
334 | 334 | |
335 | - return $created; |
|
336 | - } |
|
335 | + return $created; |
|
336 | + } |
|
337 | 337 | |
338 | - $return_data['timing']['remote'] = timer_stop(0, 5); |
|
338 | + $return_data['timing']['remote'] = timer_stop(0, 5); |
|
339 | 339 | |
340 | - do_action('trustedlogin/'.$this->config->ns().'/access/created', [ |
|
341 | - 'url' => get_site_url(), |
|
342 | - 'ns' => $this->config->ns(), |
|
343 | - 'action' => 'created', |
|
344 | - 'ref' => $reference_id, |
|
345 | - ]); |
|
340 | + do_action('trustedlogin/'.$this->config->ns().'/access/created', [ |
|
341 | + 'url' => get_site_url(), |
|
342 | + 'ns' => $this->config->ns(), |
|
343 | + 'action' => 'created', |
|
344 | + 'ref' => $reference_id, |
|
345 | + ]); |
|
346 | 346 | |
347 | - return $return_data; |
|
348 | - } |
|
347 | + return $return_data; |
|
348 | + } |
|
349 | 349 | |
350 | - /** |
|
351 | - * Extends the access duration for an existing Support User. |
|
352 | - * |
|
353 | - * @since 1.0.0 |
|
354 | - * |
|
355 | - * @param int $user_id The existing Support User ID |
|
356 | - * |
|
357 | - * @return array|WP_Error |
|
358 | - */ |
|
359 | - private function extend_access($user_id) |
|
360 | - { |
|
361 | - timer_start(); |
|
350 | + /** |
|
351 | + * Extends the access duration for an existing Support User. |
|
352 | + * |
|
353 | + * @since 1.0.0 |
|
354 | + * |
|
355 | + * @param int $user_id The existing Support User ID |
|
356 | + * |
|
357 | + * @return array|WP_Error |
|
358 | + */ |
|
359 | + private function extend_access($user_id) |
|
360 | + { |
|
361 | + timer_start(); |
|
362 | 362 | |
363 | - $expiration_timestamp = $this->config->get_expiration_timestamp(); |
|
363 | + $expiration_timestamp = $this->config->get_expiration_timestamp(); |
|
364 | 364 | |
365 | - $site_identifier_hash = $this->support_user->get_site_hash($user_id); |
|
365 | + $site_identifier_hash = $this->support_user->get_site_hash($user_id); |
|
366 | 366 | |
367 | - if (is_wp_error($site_identifier_hash)) { |
|
368 | - $this->logging->log(sprintf('Could not get identifier hash for existing support user account. %s (%s)', $site_identifier_hash->get_error_message(), $site_identifier_hash->get_error_code()), __METHOD__, 'critical'); |
|
367 | + if (is_wp_error($site_identifier_hash)) { |
|
368 | + $this->logging->log(sprintf('Could not get identifier hash for existing support user account. %s (%s)', $site_identifier_hash->get_error_message(), $site_identifier_hash->get_error_code()), __METHOD__, 'critical'); |
|
369 | 369 | |
370 | - return $site_identifier_hash; |
|
371 | - } |
|
370 | + return $site_identifier_hash; |
|
371 | + } |
|
372 | 372 | |
373 | - $extended = $this->support_user->extend($user_id, $site_identifier_hash, $expiration_timestamp, $this->cron); |
|
373 | + $extended = $this->support_user->extend($user_id, $site_identifier_hash, $expiration_timestamp, $this->cron); |
|
374 | 374 | |
375 | - if (is_wp_error($extended)) { |
|
376 | - return $extended; |
|
377 | - } |
|
375 | + if (is_wp_error($extended)) { |
|
376 | + return $extended; |
|
377 | + } |
|
378 | 378 | |
379 | - $secret_id = $this->endpoint->generate_secret_id($site_identifier_hash); |
|
379 | + $secret_id = $this->endpoint->generate_secret_id($site_identifier_hash); |
|
380 | 380 | |
381 | - if (is_wp_error($secret_id)) { |
|
382 | - wp_delete_user($user_id); |
|
381 | + if (is_wp_error($secret_id)) { |
|
382 | + wp_delete_user($user_id); |
|
383 | 383 | |
384 | - $secret_id->add_data(['error_code' => 500]); |
|
384 | + $secret_id->add_data(['error_code' => 500]); |
|
385 | 385 | |
386 | - return $secret_id; |
|
387 | - } |
|
386 | + return $secret_id; |
|
387 | + } |
|
388 | 388 | |
389 | - $timing_local = timer_stop(0, 5); |
|
389 | + $timing_local = timer_stop(0, 5); |
|
390 | 390 | |
391 | - $return_data = [ |
|
392 | - 'type' => 'extend', |
|
393 | - 'site_url' => get_site_url(), |
|
394 | - 'identifier' => $site_identifier_hash, |
|
395 | - 'user_id' => $user_id, |
|
396 | - 'expiry' => $expiration_timestamp, |
|
397 | - 'timing' => [ |
|
398 | - 'local' => $timing_local, |
|
399 | - 'remote' => null, // Updated later |
|
400 | - ], |
|
401 | - ]; |
|
391 | + $return_data = [ |
|
392 | + 'type' => 'extend', |
|
393 | + 'site_url' => get_site_url(), |
|
394 | + 'identifier' => $site_identifier_hash, |
|
395 | + 'user_id' => $user_id, |
|
396 | + 'expiry' => $expiration_timestamp, |
|
397 | + 'timing' => [ |
|
398 | + 'local' => $timing_local, |
|
399 | + 'remote' => null, // Updated later |
|
400 | + ], |
|
401 | + ]; |
|
402 | 402 | |
403 | - if (!$this->config->meets_ssl_requirement()) { |
|
404 | - return new WP_Error('fails_ssl_requirement', esc_html__('TrustedLogin requires a secure connection using HTTPS.', 'gravityview')); |
|
405 | - } |
|
403 | + if (!$this->config->meets_ssl_requirement()) { |
|
404 | + return new WP_Error('fails_ssl_requirement', esc_html__('TrustedLogin requires a secure connection using HTTPS.', 'gravityview')); |
|
405 | + } |
|
406 | 406 | |
407 | - timer_start(); |
|
407 | + timer_start(); |
|
408 | 408 | |
409 | - try { |
|
410 | - add_filter('trustedlogin/'.$this->config->ns().'/envelope/meta', [$this, 'add_meta_to_envelope']); |
|
409 | + try { |
|
410 | + add_filter('trustedlogin/'.$this->config->ns().'/envelope/meta', [$this, 'add_meta_to_envelope']); |
|
411 | 411 | |
412 | - $updated = $this->site_access->sync_secret($secret_id, $site_identifier_hash, 'extend'); |
|
412 | + $updated = $this->site_access->sync_secret($secret_id, $site_identifier_hash, 'extend'); |
|
413 | 413 | |
414 | - remove_filter('trustedlogin/'.$this->config->ns().'/envelope/meta', [$this, 'add_meta_to_envelope']); |
|
415 | - } catch (Exception $e) { |
|
416 | - $exception_error = new WP_Error($e->getCode(), $e->getMessage(), ['status_code' => 500]); |
|
414 | + remove_filter('trustedlogin/'.$this->config->ns().'/envelope/meta', [$this, 'add_meta_to_envelope']); |
|
415 | + } catch (Exception $e) { |
|
416 | + $exception_error = new WP_Error($e->getCode(), $e->getMessage(), ['status_code' => 500]); |
|
417 | 417 | |
418 | - $this->logging->log('There was an error updating TrustedLogin servers.', __METHOD__, 'error', $e); |
|
418 | + $this->logging->log('There was an error updating TrustedLogin servers.', __METHOD__, 'error', $e); |
|
419 | 419 | |
420 | - wp_delete_user($user_id); |
|
420 | + wp_delete_user($user_id); |
|
421 | 421 | |
422 | - return $exception_error; |
|
423 | - } |
|
422 | + return $exception_error; |
|
423 | + } |
|
424 | 424 | |
425 | - if (is_wp_error($updated)) { |
|
426 | - $this->logging->log(sprintf('There was an issue creating access (%s): %s', $updated->get_error_code(), $updated->get_error_message()), __METHOD__, 'error'); |
|
425 | + if (is_wp_error($updated)) { |
|
426 | + $this->logging->log(sprintf('There was an issue creating access (%s): %s', $updated->get_error_code(), $updated->get_error_message()), __METHOD__, 'error'); |
|
427 | 427 | |
428 | - $updated->add_data(['status_code' => 503]); |
|
428 | + $updated->add_data(['status_code' => 503]); |
|
429 | 429 | |
430 | - wp_delete_user($user_id); |
|
430 | + wp_delete_user($user_id); |
|
431 | 431 | |
432 | - return $updated; |
|
433 | - } |
|
432 | + return $updated; |
|
433 | + } |
|
434 | 434 | |
435 | - $return_data['timing']['remote'] = timer_stop(0, 5); |
|
435 | + $return_data['timing']['remote'] = timer_stop(0, 5); |
|
436 | 436 | |
437 | - do_action('trustedlogin/'.$this->config->ns().'/access/extended', [ |
|
438 | - 'url' => get_site_url(), |
|
439 | - 'ns' => $this->config->ns(), |
|
440 | - 'action' => 'extended', |
|
441 | - 'ref' => self::get_reference_id(), |
|
442 | - ]); |
|
437 | + do_action('trustedlogin/'.$this->config->ns().'/access/extended', [ |
|
438 | + 'url' => get_site_url(), |
|
439 | + 'ns' => $this->config->ns(), |
|
440 | + 'action' => 'extended', |
|
441 | + 'ref' => self::get_reference_id(), |
|
442 | + ]); |
|
443 | 443 | |
444 | - return $return_data; |
|
445 | - } |
|
444 | + return $return_data; |
|
445 | + } |
|
446 | 446 | |
447 | - /** |
|
448 | - * Revoke access to a site. |
|
449 | - * |
|
450 | - * @param string $identifier Unique ID or "all" |
|
451 | - * |
|
452 | - * @return bool|WP_Error True: Synced to SaaS and user(s) deleted. False: empty identifier. WP_Error: failed to revoke site in SaaS or failed to delete user. |
|
453 | - */ |
|
454 | - public function revoke_access($identifier = '') |
|
455 | - { |
|
456 | - if (empty($identifier)) { |
|
457 | - $this->logging->log('Missing the revoke access identifier.', __METHOD__, 'error'); |
|
447 | + /** |
|
448 | + * Revoke access to a site. |
|
449 | + * |
|
450 | + * @param string $identifier Unique ID or "all" |
|
451 | + * |
|
452 | + * @return bool|WP_Error True: Synced to SaaS and user(s) deleted. False: empty identifier. WP_Error: failed to revoke site in SaaS or failed to delete user. |
|
453 | + */ |
|
454 | + public function revoke_access($identifier = '') |
|
455 | + { |
|
456 | + if (empty($identifier)) { |
|
457 | + $this->logging->log('Missing the revoke access identifier.', __METHOD__, 'error'); |
|
458 | 458 | |
459 | - return false; |
|
460 | - } |
|
459 | + return false; |
|
460 | + } |
|
461 | 461 | |
462 | - if ('all' === $identifier) { |
|
463 | - $users = $this->support_user->get_all(); |
|
462 | + if ('all' === $identifier) { |
|
463 | + $users = $this->support_user->get_all(); |
|
464 | 464 | |
465 | - foreach ($users as $user) { |
|
466 | - $this->revoke_access($this->support_user->get_user_identifier($user)); |
|
467 | - } |
|
468 | - } |
|
465 | + foreach ($users as $user) { |
|
466 | + $this->revoke_access($this->support_user->get_user_identifier($user)); |
|
467 | + } |
|
468 | + } |
|
469 | 469 | |
470 | - $user = $this->support_user->get($identifier); |
|
470 | + $user = $this->support_user->get($identifier); |
|
471 | 471 | |
472 | - if (null === $user) { |
|
473 | - $this->logging->log('User does not exist; access may have already been revoked.', __METHOD__, 'error'); |
|
472 | + if (null === $user) { |
|
473 | + $this->logging->log('User does not exist; access may have already been revoked.', __METHOD__, 'error'); |
|
474 | 474 | |
475 | - return false; |
|
476 | - } |
|
475 | + return false; |
|
476 | + } |
|
477 | 477 | |
478 | - $site_identifier_hash = $this->support_user->get_site_hash($user); |
|
479 | - $endpoint_hash = $this->endpoint->get_hash($site_identifier_hash); |
|
480 | - $secret_id = $this->endpoint->generate_secret_id($site_identifier_hash, $endpoint_hash); |
|
478 | + $site_identifier_hash = $this->support_user->get_site_hash($user); |
|
479 | + $endpoint_hash = $this->endpoint->get_hash($site_identifier_hash); |
|
480 | + $secret_id = $this->endpoint->generate_secret_id($site_identifier_hash, $endpoint_hash); |
|
481 | 481 | |
482 | - // Revoke site in SaaS |
|
483 | - $site_revoked = $this->site_access->revoke($secret_id, $this->remote); |
|
482 | + // Revoke site in SaaS |
|
483 | + $site_revoked = $this->site_access->revoke($secret_id, $this->remote); |
|
484 | 484 | |
485 | - if (is_wp_error($site_revoked)) { |
|
486 | - |
|
487 | - // Couldn't sync to SaaS, this should/could be extended to add a cron-task to delayed update of SaaS DB |
|
488 | - // TODO: extend to add a cron-task to delayed update of SaaS DB |
|
489 | - $this->logging->log('There was an issue syncing to SaaS. Failing silently.', __METHOD__, 'error'); |
|
490 | - } |
|
491 | - |
|
492 | - $deleted_user = $this->support_user->delete($identifier, true, true); |
|
493 | - |
|
494 | - if (is_wp_error($deleted_user)) { |
|
495 | - $this->logging->log('Removing user failed: '.$deleted_user->get_error_message(), __METHOD__, 'error'); |
|
485 | + if (is_wp_error($site_revoked)) { |
|
486 | + |
|
487 | + // Couldn't sync to SaaS, this should/could be extended to add a cron-task to delayed update of SaaS DB |
|
488 | + // TODO: extend to add a cron-task to delayed update of SaaS DB |
|
489 | + $this->logging->log('There was an issue syncing to SaaS. Failing silently.', __METHOD__, 'error'); |
|
490 | + } |
|
491 | + |
|
492 | + $deleted_user = $this->support_user->delete($identifier, true, true); |
|
493 | + |
|
494 | + if (is_wp_error($deleted_user)) { |
|
495 | + $this->logging->log('Removing user failed: '.$deleted_user->get_error_message(), __METHOD__, 'error'); |
|
496 | 496 | |
497 | - return $deleted_user; |
|
498 | - } |
|
497 | + return $deleted_user; |
|
498 | + } |
|
499 | 499 | |
500 | - $should_be_deleted = $this->support_user->get($identifier); |
|
500 | + $should_be_deleted = $this->support_user->get($identifier); |
|
501 | 501 | |
502 | - if (!empty($should_be_deleted)) { |
|
503 | - $this->logging->log('User #'.$should_be_deleted->ID.' was not removed', __METHOD__, 'error'); |
|
502 | + if (!empty($should_be_deleted)) { |
|
503 | + $this->logging->log('User #'.$should_be_deleted->ID.' was not removed', __METHOD__, 'error'); |
|
504 | 504 | |
505 | - return new WP_Error('support_user_not_deleted', esc_html__('The support user was not deleted.', 'gravityview')); |
|
506 | - } |
|
505 | + return new WP_Error('support_user_not_deleted', esc_html__('The support user was not deleted.', 'gravityview')); |
|
506 | + } |
|
507 | 507 | |
508 | - /** |
|
509 | - * Site was removed in SaaS, user was deleted. |
|
510 | - */ |
|
511 | - do_action('trustedlogin/'.$this->config->ns().'/access/revoked', [ |
|
512 | - 'url' => get_site_url(), |
|
513 | - 'ns' => $this->config->ns(), |
|
514 | - 'action' => 'revoked', |
|
515 | - ]); |
|
508 | + /** |
|
509 | + * Site was removed in SaaS, user was deleted. |
|
510 | + */ |
|
511 | + do_action('trustedlogin/'.$this->config->ns().'/access/revoked', [ |
|
512 | + 'url' => get_site_url(), |
|
513 | + 'ns' => $this->config->ns(), |
|
514 | + 'action' => 'revoked', |
|
515 | + ]); |
|
516 | 516 | |
517 | - return $site_revoked; |
|
518 | - } |
|
519 | - |
|
520 | - /** |
|
521 | - * Adds PLAINTEXT metadata to the envelope, including reference ID. |
|
522 | - * |
|
523 | - * @since 1.0.0 |
|
524 | - * |
|
525 | - * @param array $metadata |
|
526 | - * |
|
527 | - * @return array Array of metadata that will be sent with the Envelope. |
|
528 | - */ |
|
529 | - public function add_meta_to_envelope($metadata = []) |
|
530 | - { |
|
531 | - $reference_id = self::get_reference_id(); |
|
532 | - |
|
533 | - if ($reference_id) { |
|
534 | - $metadata['reference_id'] = $reference_id; |
|
535 | - } |
|
536 | - |
|
537 | - return $metadata; |
|
538 | - } |
|
539 | - |
|
540 | - /** |
|
541 | - * Gets the reference ID passed to the $_REQUEST using `reference_id` or `ref` keys. |
|
542 | - * |
|
543 | - * @since 1.0.0 |
|
544 | - * |
|
545 | - * @return string|null Sanitized reference ID (escaped with esc_html) if exists. NULL if not. |
|
546 | - */ |
|
547 | - public static function get_reference_id() |
|
548 | - { |
|
549 | - if (isset($_REQUEST['reference_id'])) { |
|
550 | - return esc_html($_REQUEST['reference_id']); |
|
551 | - } |
|
552 | - |
|
553 | - if (isset($_REQUEST['ref'])) { |
|
554 | - return esc_html($_REQUEST['ref']); |
|
555 | - } |
|
556 | - |
|
557 | - return null; |
|
558 | - } |
|
517 | + return $site_revoked; |
|
518 | + } |
|
519 | + |
|
520 | + /** |
|
521 | + * Adds PLAINTEXT metadata to the envelope, including reference ID. |
|
522 | + * |
|
523 | + * @since 1.0.0 |
|
524 | + * |
|
525 | + * @param array $metadata |
|
526 | + * |
|
527 | + * @return array Array of metadata that will be sent with the Envelope. |
|
528 | + */ |
|
529 | + public function add_meta_to_envelope($metadata = []) |
|
530 | + { |
|
531 | + $reference_id = self::get_reference_id(); |
|
532 | + |
|
533 | + if ($reference_id) { |
|
534 | + $metadata['reference_id'] = $reference_id; |
|
535 | + } |
|
536 | + |
|
537 | + return $metadata; |
|
538 | + } |
|
539 | + |
|
540 | + /** |
|
541 | + * Gets the reference ID passed to the $_REQUEST using `reference_id` or `ref` keys. |
|
542 | + * |
|
543 | + * @since 1.0.0 |
|
544 | + * |
|
545 | + * @return string|null Sanitized reference ID (escaped with esc_html) if exists. NULL if not. |
|
546 | + */ |
|
547 | + public static function get_reference_id() |
|
548 | + { |
|
549 | + if (isset($_REQUEST['reference_id'])) { |
|
550 | + return esc_html($_REQUEST['reference_id']); |
|
551 | + } |
|
552 | + |
|
553 | + if (isset($_REQUEST['ref'])) { |
|
554 | + return esc_html($_REQUEST['ref']); |
|
555 | + } |
|
556 | + |
|
557 | + return null; |
|
558 | + } |
|
559 | 559 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | namespace GravityView\TrustedLogin; |
25 | 25 | |
26 | 26 | // Exit if accessed directly |
27 | -if (!defined('ABSPATH')) { |
|
27 | +if ( ! defined( 'ABSPATH' ) ) { |
|
28 | 28 | exit; |
29 | 29 | } |
30 | 30 | |
@@ -105,17 +105,17 @@ discard block |
||
105 | 105 | * |
106 | 106 | * @returns void If no errors, returns void. Otherwise, throws exceptions. |
107 | 107 | */ |
108 | - public function __construct(Config $config, $init = true) |
|
108 | + public function __construct( Config $config, $init = true ) |
|
109 | 109 | { |
110 | - $should_initialize = $this->should_init($config); |
|
110 | + $should_initialize = $this->should_init( $config ); |
|
111 | 111 | |
112 | - if (!$should_initialize) { |
|
113 | - throw new \Exception('TrustedLogin was prevented from loading by constants defined on the site.', 403); |
|
112 | + if ( ! $should_initialize ) { |
|
113 | + throw new \Exception( 'TrustedLogin was prevented from loading by constants defined on the site.', 403 ); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | try { |
117 | 117 | self::$valid_config = $config->validate(); |
118 | - } catch (\Exception $exception) { |
|
118 | + } catch ( \Exception $exception ) { |
|
119 | 119 | self::$valid_config = false; |
120 | 120 | |
121 | 121 | throw $exception; |
@@ -123,23 +123,23 @@ discard block |
||
123 | 123 | |
124 | 124 | $this->config = $config; |
125 | 125 | |
126 | - $this->logging = new Logging($config); |
|
126 | + $this->logging = new Logging( $config ); |
|
127 | 127 | |
128 | - $this->endpoint = new Endpoint($this->config, $this->logging); |
|
128 | + $this->endpoint = new Endpoint( $this->config, $this->logging ); |
|
129 | 129 | |
130 | - $this->cron = new Cron($this->config, $this->logging); |
|
130 | + $this->cron = new Cron( $this->config, $this->logging ); |
|
131 | 131 | |
132 | - $this->support_user = new SupportUser($this->config, $this->logging); |
|
132 | + $this->support_user = new SupportUser( $this->config, $this->logging ); |
|
133 | 133 | |
134 | - $this->admin = new Admin($this->config, $this->logging); |
|
134 | + $this->admin = new Admin( $this->config, $this->logging ); |
|
135 | 135 | |
136 | - $this->ajax = new Ajax($this->config, $this->logging); |
|
136 | + $this->ajax = new Ajax( $this->config, $this->logging ); |
|
137 | 137 | |
138 | - $this->remote = new Remote($this->config, $this->logging); |
|
138 | + $this->remote = new Remote( $this->config, $this->logging ); |
|
139 | 139 | |
140 | - $this->site_access = new SiteAccess($this->config, $this->logging); |
|
140 | + $this->site_access = new SiteAccess( $this->config, $this->logging ); |
|
141 | 141 | |
142 | - if ($init) { |
|
142 | + if ( $init ) { |
|
143 | 143 | $this->init(); |
144 | 144 | } |
145 | 145 | } |
@@ -151,23 +151,23 @@ discard block |
||
151 | 151 | * |
152 | 152 | * @return bool |
153 | 153 | */ |
154 | - private function should_init(Config $config) |
|
154 | + private function should_init( Config $config ) |
|
155 | 155 | { |
156 | 156 | |
157 | 157 | // Disables all TL clients. |
158 | - if (defined('TRUSTEDLOGIN_DISABLE') && TRUSTEDLOGIN_DISABLE) { |
|
158 | + if ( defined( 'TRUSTEDLOGIN_DISABLE' ) && TRUSTEDLOGIN_DISABLE ) { |
|
159 | 159 | return false; |
160 | 160 | } |
161 | 161 | |
162 | 162 | $ns = $config->ns(); |
163 | 163 | |
164 | 164 | // Namespace isn't set; allow Config |
165 | - if (empty($ns)) { |
|
165 | + if ( empty( $ns ) ) { |
|
166 | 166 | return true; |
167 | 167 | } |
168 | 168 | |
169 | 169 | // Disables namespaced client if `TRUSTEDLOGIN_DISABLE_{NS}` is defined and truthy. |
170 | - if (defined('TRUSTEDLOGIN_DISABLE_'.strtoupper($ns)) && constant('TRUSTEDLOGIN_DISABLE_'.strtoupper($ns))) { |
|
170 | + if ( defined( 'TRUSTEDLOGIN_DISABLE_' . strtoupper( $ns ) ) && constant( 'TRUSTEDLOGIN_DISABLE_' . strtoupper( $ns ) ) ) { |
|
171 | 171 | return false; |
172 | 172 | } |
173 | 173 | |
@@ -195,8 +195,8 @@ discard block |
||
195 | 195 | */ |
196 | 196 | public function get_access_key() |
197 | 197 | { |
198 | - if (!self::$valid_config) { |
|
199 | - return new WP_Error('invalid_configuration', 'TrustedLogin has not been properly configured or instantiated.', ['error_code' => 424]); |
|
198 | + if ( ! self::$valid_config ) { |
|
199 | + return new WP_Error( 'invalid_configuration', 'TrustedLogin has not been properly configured or instantiated.', [ 'error_code' => 424 ] ); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | return $this->site_access->get_access_key(); |
@@ -209,85 +209,85 @@ discard block |
||
209 | 209 | */ |
210 | 210 | public function grant_access() |
211 | 211 | { |
212 | - if (!self::$valid_config) { |
|
213 | - return new WP_Error('invalid_configuration', 'TrustedLogin has not been properly configured or instantiated.', ['error_code' => 424]); |
|
212 | + if ( ! self::$valid_config ) { |
|
213 | + return new WP_Error( 'invalid_configuration', 'TrustedLogin has not been properly configured or instantiated.', [ 'error_code' => 424 ] ); |
|
214 | 214 | } |
215 | 215 | |
216 | - if (!current_user_can('create_users')) { |
|
217 | - return new WP_Error('no_cap_create_users', 'Permissions issue: You do not have the ability to create users.', ['error_code' => 403]); |
|
216 | + if ( ! current_user_can( 'create_users' ) ) { |
|
217 | + return new WP_Error( 'no_cap_create_users', 'Permissions issue: You do not have the ability to create users.', [ 'error_code' => 403 ] ); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | // If the user exists already, extend access |
221 | - if ($user_id = $this->support_user->exists()) { |
|
222 | - return $this->extend_access($user_id); |
|
221 | + if ( $user_id = $this->support_user->exists() ) { |
|
222 | + return $this->extend_access( $user_id ); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | timer_start(); |
226 | 226 | |
227 | 227 | try { |
228 | 228 | $support_user_id = $this->support_user->create(); |
229 | - } catch (Exception $exception) { |
|
230 | - $this->logging->log('An exception occurred trying to create a support user.', __METHOD__, 'critical', $exception); |
|
229 | + } catch ( Exception $exception ) { |
|
230 | + $this->logging->log( 'An exception occurred trying to create a support user.', __METHOD__, 'critical', $exception ); |
|
231 | 231 | |
232 | - return new WP_Error('support_user_exception', $exception->getMessage(), ['error_code' => 500]); |
|
232 | + return new WP_Error( 'support_user_exception', $exception->getMessage(), [ 'error_code' => 500 ] ); |
|
233 | 233 | } |
234 | 234 | |
235 | - if (is_wp_error($support_user_id)) { |
|
236 | - $this->logging->log(sprintf('Support user not created: %s (%s)', $support_user_id->get_error_message(), $support_user_id->get_error_code()), __METHOD__, 'error'); |
|
235 | + if ( is_wp_error( $support_user_id ) ) { |
|
236 | + $this->logging->log( sprintf( 'Support user not created: %s (%s)', $support_user_id->get_error_message(), $support_user_id->get_error_code() ), __METHOD__, 'error' ); |
|
237 | 237 | |
238 | - $support_user_id->add_data(['error_code' => 409]); |
|
238 | + $support_user_id->add_data( [ 'error_code' => 409 ] ); |
|
239 | 239 | |
240 | 240 | return $support_user_id; |
241 | 241 | } |
242 | 242 | |
243 | - $site_identifier_hash = Encryption::get_random_hash($this->logging); |
|
243 | + $site_identifier_hash = Encryption::get_random_hash( $this->logging ); |
|
244 | 244 | |
245 | - if (is_wp_error($site_identifier_hash)) { |
|
246 | - wp_delete_user($support_user_id); |
|
245 | + if ( is_wp_error( $site_identifier_hash ) ) { |
|
246 | + wp_delete_user( $support_user_id ); |
|
247 | 247 | |
248 | - $this->logging->log('Could not generate a secure secret.', __METHOD__, 'error'); |
|
248 | + $this->logging->log( 'Could not generate a secure secret.', __METHOD__, 'error' ); |
|
249 | 249 | |
250 | - return new WP_Error('secure_secret_failed', 'Could not generate a secure secret.', ['error_code' => 501]); |
|
250 | + return new WP_Error( 'secure_secret_failed', 'Could not generate a secure secret.', [ 'error_code' => 501 ] ); |
|
251 | 251 | } |
252 | 252 | |
253 | - $endpoint_hash = $this->endpoint->get_hash($site_identifier_hash); |
|
253 | + $endpoint_hash = $this->endpoint->get_hash( $site_identifier_hash ); |
|
254 | 254 | |
255 | - $updated = $this->endpoint->update($endpoint_hash); |
|
255 | + $updated = $this->endpoint->update( $endpoint_hash ); |
|
256 | 256 | |
257 | - if (!$updated) { |
|
258 | - $this->logging->log('Endpoint hash did not save or didn\'t update.', __METHOD__, 'info'); |
|
257 | + if ( ! $updated ) { |
|
258 | + $this->logging->log( 'Endpoint hash did not save or didn\'t update.', __METHOD__, 'info' ); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | $expiration_timestamp = $this->config->get_expiration_timestamp(); |
262 | 262 | |
263 | 263 | // Add user meta, configure decay |
264 | - $did_setup = $this->support_user->setup($support_user_id, $site_identifier_hash, $expiration_timestamp, $this->cron); |
|
264 | + $did_setup = $this->support_user->setup( $support_user_id, $site_identifier_hash, $expiration_timestamp, $this->cron ); |
|
265 | 265 | |
266 | - if (is_wp_error($did_setup)) { |
|
267 | - wp_delete_user($support_user_id); |
|
266 | + if ( is_wp_error( $did_setup ) ) { |
|
267 | + wp_delete_user( $support_user_id ); |
|
268 | 268 | |
269 | - $did_setup->add_data(['error_code' => 503]); |
|
269 | + $did_setup->add_data( [ 'error_code' => 503 ] ); |
|
270 | 270 | |
271 | 271 | return $did_setup; |
272 | 272 | } |
273 | 273 | |
274 | - if (empty($did_setup)) { |
|
275 | - return new WP_Error('support_user_setup_failed', 'Error updating user with identifier.', ['error_code' => 503]); |
|
274 | + if ( empty( $did_setup ) ) { |
|
275 | + return new WP_Error( 'support_user_setup_failed', 'Error updating user with identifier.', [ 'error_code' => 503 ] ); |
|
276 | 276 | } |
277 | 277 | |
278 | - $secret_id = $this->endpoint->generate_secret_id($site_identifier_hash, $endpoint_hash); |
|
278 | + $secret_id = $this->endpoint->generate_secret_id( $site_identifier_hash, $endpoint_hash ); |
|
279 | 279 | |
280 | - if (is_wp_error($secret_id)) { |
|
281 | - wp_delete_user($support_user_id); |
|
280 | + if ( is_wp_error( $secret_id ) ) { |
|
281 | + wp_delete_user( $support_user_id ); |
|
282 | 282 | |
283 | - $secret_id->add_data(['error_code' => 500]); |
|
283 | + $secret_id->add_data( [ 'error_code' => 500 ] ); |
|
284 | 284 | |
285 | 285 | return $secret_id; |
286 | 286 | } |
287 | 287 | |
288 | 288 | $reference_id = self::get_reference_id(); |
289 | 289 | |
290 | - $timing_local = timer_stop(0, 5); |
|
290 | + $timing_local = timer_stop( 0, 5 ); |
|
291 | 291 | |
292 | 292 | $return_data = [ |
293 | 293 | 'type' => 'new', |
@@ -303,46 +303,46 @@ discard block |
||
303 | 303 | ], |
304 | 304 | ]; |
305 | 305 | |
306 | - if (!$this->config->meets_ssl_requirement()) { |
|
307 | - return new WP_Error('fails_ssl_requirement', esc_html__('TrustedLogin requires a secure connection using HTTPS.', 'gravityview')); |
|
306 | + if ( ! $this->config->meets_ssl_requirement() ) { |
|
307 | + return new WP_Error( 'fails_ssl_requirement', esc_html__( 'TrustedLogin requires a secure connection using HTTPS.', 'gravityview' ) ); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | timer_start(); |
311 | 311 | |
312 | 312 | try { |
313 | - add_filter('trustedlogin/'.$this->config->ns().'/envelope/meta', [$this, 'add_meta_to_envelope']); |
|
313 | + add_filter( 'trustedlogin/' . $this->config->ns() . '/envelope/meta', [ $this, 'add_meta_to_envelope' ] ); |
|
314 | 314 | |
315 | - $created = $this->site_access->sync_secret($secret_id, $site_identifier_hash, 'create'); |
|
315 | + $created = $this->site_access->sync_secret( $secret_id, $site_identifier_hash, 'create' ); |
|
316 | 316 | |
317 | - remove_filter('trustedlogin/'.$this->config->ns().'/envelope/meta', [$this, 'add_meta_to_envelope']); |
|
318 | - } catch (Exception $e) { |
|
319 | - $exception_error = new WP_Error($e->getCode(), $e->getMessage(), ['status_code' => 500]); |
|
317 | + remove_filter( 'trustedlogin/' . $this->config->ns() . '/envelope/meta', [ $this, 'add_meta_to_envelope' ] ); |
|
318 | + } catch ( Exception $e ) { |
|
319 | + $exception_error = new WP_Error( $e->getCode(), $e->getMessage(), [ 'status_code' => 500 ] ); |
|
320 | 320 | |
321 | - $this->logging->log('There was an error creating a secret.', __METHOD__, 'error', $e); |
|
321 | + $this->logging->log( 'There was an error creating a secret.', __METHOD__, 'error', $e ); |
|
322 | 322 | |
323 | - wp_delete_user($support_user_id); |
|
323 | + wp_delete_user( $support_user_id ); |
|
324 | 324 | |
325 | 325 | return $exception_error; |
326 | 326 | } |
327 | 327 | |
328 | - if (is_wp_error($created)) { |
|
329 | - $this->logging->log(sprintf('There was an issue creating access (%s): %s', $created->get_error_code(), $created->get_error_message()), __METHOD__, 'error'); |
|
328 | + if ( is_wp_error( $created ) ) { |
|
329 | + $this->logging->log( sprintf( 'There was an issue creating access (%s): %s', $created->get_error_code(), $created->get_error_message() ), __METHOD__, 'error' ); |
|
330 | 330 | |
331 | - $created->add_data(['status_code' => 503]); |
|
331 | + $created->add_data( [ 'status_code' => 503 ] ); |
|
332 | 332 | |
333 | - wp_delete_user($support_user_id); |
|
333 | + wp_delete_user( $support_user_id ); |
|
334 | 334 | |
335 | 335 | return $created; |
336 | 336 | } |
337 | 337 | |
338 | - $return_data['timing']['remote'] = timer_stop(0, 5); |
|
338 | + $return_data[ 'timing' ][ 'remote' ] = timer_stop( 0, 5 ); |
|
339 | 339 | |
340 | - do_action('trustedlogin/'.$this->config->ns().'/access/created', [ |
|
340 | + do_action( 'trustedlogin/' . $this->config->ns() . '/access/created', [ |
|
341 | 341 | 'url' => get_site_url(), |
342 | 342 | 'ns' => $this->config->ns(), |
343 | 343 | 'action' => 'created', |
344 | 344 | 'ref' => $reference_id, |
345 | - ]); |
|
345 | + ] ); |
|
346 | 346 | |
347 | 347 | return $return_data; |
348 | 348 | } |
@@ -356,37 +356,37 @@ discard block |
||
356 | 356 | * |
357 | 357 | * @return array|WP_Error |
358 | 358 | */ |
359 | - private function extend_access($user_id) |
|
359 | + private function extend_access( $user_id ) |
|
360 | 360 | { |
361 | 361 | timer_start(); |
362 | 362 | |
363 | 363 | $expiration_timestamp = $this->config->get_expiration_timestamp(); |
364 | 364 | |
365 | - $site_identifier_hash = $this->support_user->get_site_hash($user_id); |
|
365 | + $site_identifier_hash = $this->support_user->get_site_hash( $user_id ); |
|
366 | 366 | |
367 | - if (is_wp_error($site_identifier_hash)) { |
|
368 | - $this->logging->log(sprintf('Could not get identifier hash for existing support user account. %s (%s)', $site_identifier_hash->get_error_message(), $site_identifier_hash->get_error_code()), __METHOD__, 'critical'); |
|
367 | + if ( is_wp_error( $site_identifier_hash ) ) { |
|
368 | + $this->logging->log( sprintf( 'Could not get identifier hash for existing support user account. %s (%s)', $site_identifier_hash->get_error_message(), $site_identifier_hash->get_error_code() ), __METHOD__, 'critical' ); |
|
369 | 369 | |
370 | 370 | return $site_identifier_hash; |
371 | 371 | } |
372 | 372 | |
373 | - $extended = $this->support_user->extend($user_id, $site_identifier_hash, $expiration_timestamp, $this->cron); |
|
373 | + $extended = $this->support_user->extend( $user_id, $site_identifier_hash, $expiration_timestamp, $this->cron ); |
|
374 | 374 | |
375 | - if (is_wp_error($extended)) { |
|
375 | + if ( is_wp_error( $extended ) ) { |
|
376 | 376 | return $extended; |
377 | 377 | } |
378 | 378 | |
379 | - $secret_id = $this->endpoint->generate_secret_id($site_identifier_hash); |
|
379 | + $secret_id = $this->endpoint->generate_secret_id( $site_identifier_hash ); |
|
380 | 380 | |
381 | - if (is_wp_error($secret_id)) { |
|
382 | - wp_delete_user($user_id); |
|
381 | + if ( is_wp_error( $secret_id ) ) { |
|
382 | + wp_delete_user( $user_id ); |
|
383 | 383 | |
384 | - $secret_id->add_data(['error_code' => 500]); |
|
384 | + $secret_id->add_data( [ 'error_code' => 500 ] ); |
|
385 | 385 | |
386 | 386 | return $secret_id; |
387 | 387 | } |
388 | 388 | |
389 | - $timing_local = timer_stop(0, 5); |
|
389 | + $timing_local = timer_stop( 0, 5 ); |
|
390 | 390 | |
391 | 391 | $return_data = [ |
392 | 392 | 'type' => 'extend', |
@@ -400,46 +400,46 @@ discard block |
||
400 | 400 | ], |
401 | 401 | ]; |
402 | 402 | |
403 | - if (!$this->config->meets_ssl_requirement()) { |
|
404 | - return new WP_Error('fails_ssl_requirement', esc_html__('TrustedLogin requires a secure connection using HTTPS.', 'gravityview')); |
|
403 | + if ( ! $this->config->meets_ssl_requirement() ) { |
|
404 | + return new WP_Error( 'fails_ssl_requirement', esc_html__( 'TrustedLogin requires a secure connection using HTTPS.', 'gravityview' ) ); |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | timer_start(); |
408 | 408 | |
409 | 409 | try { |
410 | - add_filter('trustedlogin/'.$this->config->ns().'/envelope/meta', [$this, 'add_meta_to_envelope']); |
|
410 | + add_filter( 'trustedlogin/' . $this->config->ns() . '/envelope/meta', [ $this, 'add_meta_to_envelope' ] ); |
|
411 | 411 | |
412 | - $updated = $this->site_access->sync_secret($secret_id, $site_identifier_hash, 'extend'); |
|
412 | + $updated = $this->site_access->sync_secret( $secret_id, $site_identifier_hash, 'extend' ); |
|
413 | 413 | |
414 | - remove_filter('trustedlogin/'.$this->config->ns().'/envelope/meta', [$this, 'add_meta_to_envelope']); |
|
415 | - } catch (Exception $e) { |
|
416 | - $exception_error = new WP_Error($e->getCode(), $e->getMessage(), ['status_code' => 500]); |
|
414 | + remove_filter( 'trustedlogin/' . $this->config->ns() . '/envelope/meta', [ $this, 'add_meta_to_envelope' ] ); |
|
415 | + } catch ( Exception $e ) { |
|
416 | + $exception_error = new WP_Error( $e->getCode(), $e->getMessage(), [ 'status_code' => 500 ] ); |
|
417 | 417 | |
418 | - $this->logging->log('There was an error updating TrustedLogin servers.', __METHOD__, 'error', $e); |
|
418 | + $this->logging->log( 'There was an error updating TrustedLogin servers.', __METHOD__, 'error', $e ); |
|
419 | 419 | |
420 | - wp_delete_user($user_id); |
|
420 | + wp_delete_user( $user_id ); |
|
421 | 421 | |
422 | 422 | return $exception_error; |
423 | 423 | } |
424 | 424 | |
425 | - if (is_wp_error($updated)) { |
|
426 | - $this->logging->log(sprintf('There was an issue creating access (%s): %s', $updated->get_error_code(), $updated->get_error_message()), __METHOD__, 'error'); |
|
425 | + if ( is_wp_error( $updated ) ) { |
|
426 | + $this->logging->log( sprintf( 'There was an issue creating access (%s): %s', $updated->get_error_code(), $updated->get_error_message() ), __METHOD__, 'error' ); |
|
427 | 427 | |
428 | - $updated->add_data(['status_code' => 503]); |
|
428 | + $updated->add_data( [ 'status_code' => 503 ] ); |
|
429 | 429 | |
430 | - wp_delete_user($user_id); |
|
430 | + wp_delete_user( $user_id ); |
|
431 | 431 | |
432 | 432 | return $updated; |
433 | 433 | } |
434 | 434 | |
435 | - $return_data['timing']['remote'] = timer_stop(0, 5); |
|
435 | + $return_data[ 'timing' ][ 'remote' ] = timer_stop( 0, 5 ); |
|
436 | 436 | |
437 | - do_action('trustedlogin/'.$this->config->ns().'/access/extended', [ |
|
437 | + do_action( 'trustedlogin/' . $this->config->ns() . '/access/extended', [ |
|
438 | 438 | 'url' => get_site_url(), |
439 | 439 | 'ns' => $this->config->ns(), |
440 | 440 | 'action' => 'extended', |
441 | 441 | 'ref' => self::get_reference_id(), |
442 | - ]); |
|
442 | + ] ); |
|
443 | 443 | |
444 | 444 | return $return_data; |
445 | 445 | } |
@@ -451,68 +451,68 @@ discard block |
||
451 | 451 | * |
452 | 452 | * @return bool|WP_Error True: Synced to SaaS and user(s) deleted. False: empty identifier. WP_Error: failed to revoke site in SaaS or failed to delete user. |
453 | 453 | */ |
454 | - public function revoke_access($identifier = '') |
|
454 | + public function revoke_access( $identifier = '' ) |
|
455 | 455 | { |
456 | - if (empty($identifier)) { |
|
457 | - $this->logging->log('Missing the revoke access identifier.', __METHOD__, 'error'); |
|
456 | + if ( empty( $identifier ) ) { |
|
457 | + $this->logging->log( 'Missing the revoke access identifier.', __METHOD__, 'error' ); |
|
458 | 458 | |
459 | 459 | return false; |
460 | 460 | } |
461 | 461 | |
462 | - if ('all' === $identifier) { |
|
462 | + if ( 'all' === $identifier ) { |
|
463 | 463 | $users = $this->support_user->get_all(); |
464 | 464 | |
465 | - foreach ($users as $user) { |
|
466 | - $this->revoke_access($this->support_user->get_user_identifier($user)); |
|
465 | + foreach ( $users as $user ) { |
|
466 | + $this->revoke_access( $this->support_user->get_user_identifier( $user ) ); |
|
467 | 467 | } |
468 | 468 | } |
469 | 469 | |
470 | - $user = $this->support_user->get($identifier); |
|
470 | + $user = $this->support_user->get( $identifier ); |
|
471 | 471 | |
472 | - if (null === $user) { |
|
473 | - $this->logging->log('User does not exist; access may have already been revoked.', __METHOD__, 'error'); |
|
472 | + if ( null === $user ) { |
|
473 | + $this->logging->log( 'User does not exist; access may have already been revoked.', __METHOD__, 'error' ); |
|
474 | 474 | |
475 | 475 | return false; |
476 | 476 | } |
477 | 477 | |
478 | - $site_identifier_hash = $this->support_user->get_site_hash($user); |
|
479 | - $endpoint_hash = $this->endpoint->get_hash($site_identifier_hash); |
|
480 | - $secret_id = $this->endpoint->generate_secret_id($site_identifier_hash, $endpoint_hash); |
|
478 | + $site_identifier_hash = $this->support_user->get_site_hash( $user ); |
|
479 | + $endpoint_hash = $this->endpoint->get_hash( $site_identifier_hash ); |
|
480 | + $secret_id = $this->endpoint->generate_secret_id( $site_identifier_hash, $endpoint_hash ); |
|
481 | 481 | |
482 | 482 | // Revoke site in SaaS |
483 | - $site_revoked = $this->site_access->revoke($secret_id, $this->remote); |
|
483 | + $site_revoked = $this->site_access->revoke( $secret_id, $this->remote ); |
|
484 | 484 | |
485 | - if (is_wp_error($site_revoked)) { |
|
485 | + if ( is_wp_error( $site_revoked ) ) { |
|
486 | 486 | |
487 | 487 | // Couldn't sync to SaaS, this should/could be extended to add a cron-task to delayed update of SaaS DB |
488 | 488 | // TODO: extend to add a cron-task to delayed update of SaaS DB |
489 | - $this->logging->log('There was an issue syncing to SaaS. Failing silently.', __METHOD__, 'error'); |
|
489 | + $this->logging->log( 'There was an issue syncing to SaaS. Failing silently.', __METHOD__, 'error' ); |
|
490 | 490 | } |
491 | 491 | |
492 | - $deleted_user = $this->support_user->delete($identifier, true, true); |
|
492 | + $deleted_user = $this->support_user->delete( $identifier, true, true ); |
|
493 | 493 | |
494 | - if (is_wp_error($deleted_user)) { |
|
495 | - $this->logging->log('Removing user failed: '.$deleted_user->get_error_message(), __METHOD__, 'error'); |
|
494 | + if ( is_wp_error( $deleted_user ) ) { |
|
495 | + $this->logging->log( 'Removing user failed: ' . $deleted_user->get_error_message(), __METHOD__, 'error' ); |
|
496 | 496 | |
497 | 497 | return $deleted_user; |
498 | 498 | } |
499 | 499 | |
500 | - $should_be_deleted = $this->support_user->get($identifier); |
|
500 | + $should_be_deleted = $this->support_user->get( $identifier ); |
|
501 | 501 | |
502 | - if (!empty($should_be_deleted)) { |
|
503 | - $this->logging->log('User #'.$should_be_deleted->ID.' was not removed', __METHOD__, 'error'); |
|
502 | + if ( ! empty( $should_be_deleted ) ) { |
|
503 | + $this->logging->log( 'User #' . $should_be_deleted->ID . ' was not removed', __METHOD__, 'error' ); |
|
504 | 504 | |
505 | - return new WP_Error('support_user_not_deleted', esc_html__('The support user was not deleted.', 'gravityview')); |
|
505 | + return new WP_Error( 'support_user_not_deleted', esc_html__( 'The support user was not deleted.', 'gravityview' ) ); |
|
506 | 506 | } |
507 | 507 | |
508 | 508 | /** |
509 | 509 | * Site was removed in SaaS, user was deleted. |
510 | 510 | */ |
511 | - do_action('trustedlogin/'.$this->config->ns().'/access/revoked', [ |
|
511 | + do_action( 'trustedlogin/' . $this->config->ns() . '/access/revoked', [ |
|
512 | 512 | 'url' => get_site_url(), |
513 | 513 | 'ns' => $this->config->ns(), |
514 | 514 | 'action' => 'revoked', |
515 | - ]); |
|
515 | + ] ); |
|
516 | 516 | |
517 | 517 | return $site_revoked; |
518 | 518 | } |
@@ -526,12 +526,12 @@ discard block |
||
526 | 526 | * |
527 | 527 | * @return array Array of metadata that will be sent with the Envelope. |
528 | 528 | */ |
529 | - public function add_meta_to_envelope($metadata = []) |
|
529 | + public function add_meta_to_envelope( $metadata = [ ] ) |
|
530 | 530 | { |
531 | 531 | $reference_id = self::get_reference_id(); |
532 | 532 | |
533 | - if ($reference_id) { |
|
534 | - $metadata['reference_id'] = $reference_id; |
|
533 | + if ( $reference_id ) { |
|
534 | + $metadata[ 'reference_id' ] = $reference_id; |
|
535 | 535 | } |
536 | 536 | |
537 | 537 | return $metadata; |
@@ -546,12 +546,12 @@ discard block |
||
546 | 546 | */ |
547 | 547 | public static function get_reference_id() |
548 | 548 | { |
549 | - if (isset($_REQUEST['reference_id'])) { |
|
550 | - return esc_html($_REQUEST['reference_id']); |
|
549 | + if ( isset( $_REQUEST[ 'reference_id' ] ) ) { |
|
550 | + return esc_html( $_REQUEST[ 'reference_id' ] ); |
|
551 | 551 | } |
552 | 552 | |
553 | - if (isset($_REQUEST['ref'])) { |
|
554 | - return esc_html($_REQUEST['ref']); |
|
553 | + if ( isset( $_REQUEST[ 'ref' ] ) ) { |
|
554 | + return esc_html( $_REQUEST[ 'ref' ] ); |
|
555 | 555 | } |
556 | 556 | |
557 | 557 | return null; |
@@ -34,8 +34,7 @@ discard block |
||
34 | 34 | /** |
35 | 35 | * The TrustedLogin all-in-one drop-in class. |
36 | 36 | */ |
37 | -final class Client |
|
38 | -{ |
|
37 | +final class Client { |
|
39 | 38 | /** |
40 | 39 | * @var string The current drop-in file version |
41 | 40 | * |
@@ -105,8 +104,7 @@ discard block |
||
105 | 104 | * |
106 | 105 | * @returns void If no errors, returns void. Otherwise, throws exceptions. |
107 | 106 | */ |
108 | - public function __construct(Config $config, $init = true) |
|
109 | - { |
|
107 | + public function __construct(Config $config, $init = true) { |
|
110 | 108 | $should_initialize = $this->should_init($config); |
111 | 109 | |
112 | 110 | if (!$should_initialize) { |
@@ -151,8 +149,7 @@ discard block |
||
151 | 149 | * |
152 | 150 | * @return bool |
153 | 151 | */ |
154 | - private function should_init(Config $config) |
|
155 | - { |
|
152 | + private function should_init(Config $config) { |
|
156 | 153 | |
157 | 154 | // Disables all TL clients. |
158 | 155 | if (defined('TRUSTEDLOGIN_DISABLE') && TRUSTEDLOGIN_DISABLE) { |
@@ -177,8 +174,7 @@ discard block |
||
177 | 174 | /** |
178 | 175 | * Initialize all the things! |
179 | 176 | */ |
180 | - public function init() |
|
181 | - { |
|
177 | + public function init() { |
|
182 | 178 | $this->admin->init(); |
183 | 179 | $this->endpoint->init(); |
184 | 180 | $this->remote->init(); |
@@ -193,8 +189,7 @@ discard block |
||
193 | 189 | * |
194 | 190 | * @return string|null|WP_Error |
195 | 191 | */ |
196 | - public function get_access_key() |
|
197 | - { |
|
192 | + public function get_access_key() { |
|
198 | 193 | if (!self::$valid_config) { |
199 | 194 | return new WP_Error('invalid_configuration', 'TrustedLogin has not been properly configured or instantiated.', ['error_code' => 424]); |
200 | 195 | } |
@@ -207,8 +202,7 @@ discard block |
||
207 | 202 | * |
208 | 203 | * @return array|WP_Error |
209 | 204 | */ |
210 | - public function grant_access() |
|
211 | - { |
|
205 | + public function grant_access() { |
|
212 | 206 | if (!self::$valid_config) { |
213 | 207 | return new WP_Error('invalid_configuration', 'TrustedLogin has not been properly configured or instantiated.', ['error_code' => 424]); |
214 | 208 | } |
@@ -356,8 +350,7 @@ discard block |
||
356 | 350 | * |
357 | 351 | * @return array|WP_Error |
358 | 352 | */ |
359 | - private function extend_access($user_id) |
|
360 | - { |
|
353 | + private function extend_access($user_id) { |
|
361 | 354 | timer_start(); |
362 | 355 | |
363 | 356 | $expiration_timestamp = $this->config->get_expiration_timestamp(); |
@@ -451,8 +444,7 @@ discard block |
||
451 | 444 | * |
452 | 445 | * @return bool|WP_Error True: Synced to SaaS and user(s) deleted. False: empty identifier. WP_Error: failed to revoke site in SaaS or failed to delete user. |
453 | 446 | */ |
454 | - public function revoke_access($identifier = '') |
|
455 | - { |
|
447 | + public function revoke_access($identifier = '') { |
|
456 | 448 | if (empty($identifier)) { |
457 | 449 | $this->logging->log('Missing the revoke access identifier.', __METHOD__, 'error'); |
458 | 450 | |
@@ -526,8 +518,7 @@ discard block |
||
526 | 518 | * |
527 | 519 | * @return array Array of metadata that will be sent with the Envelope. |
528 | 520 | */ |
529 | - public function add_meta_to_envelope($metadata = []) |
|
530 | - { |
|
521 | + public function add_meta_to_envelope($metadata = []) { |
|
531 | 522 | $reference_id = self::get_reference_id(); |
532 | 523 | |
533 | 524 | if ($reference_id) { |
@@ -544,8 +535,7 @@ discard block |
||
544 | 535 | * |
545 | 536 | * @return string|null Sanitized reference ID (escaped with esc_html) if exists. NULL if not. |
546 | 537 | */ |
547 | - public static function get_reference_id() |
|
548 | - { |
|
538 | + public static function get_reference_id() { |
|
549 | 539 | if (isset($_REQUEST['reference_id'])) { |
550 | 540 | return esc_html($_REQUEST['reference_id']); |
551 | 541 | } |
@@ -16,390 +16,390 @@ |
||
16 | 16 | |
17 | 17 | class Endpoint |
18 | 18 | { |
19 | - /** |
|
20 | - * @var string The query string parameter used to revoke users |
|
21 | - */ |
|
22 | - const REVOKE_SUPPORT_QUERY_PARAM = 'revoke-tl'; |
|
23 | - |
|
24 | - /** |
|
25 | - * @var string Site option used to track whether permalinks have been flushed. |
|
26 | - */ |
|
27 | - const PERMALINK_FLUSH_OPTION_NAME = 'tl_permalinks_flushed'; |
|
28 | - |
|
29 | - /** |
|
30 | - * @var string Expected value of $_POST['action'] before adding the endpoint and starting a login flow. |
|
31 | - */ |
|
32 | - const POST_ACTION_VALUE = 'trustedlogin'; |
|
33 | - |
|
34 | - /** @var string The $_POST key in the TrustedLogin request related to the action being performed. */ |
|
35 | - const POST_ACTION_KEY = 'action'; |
|
36 | - |
|
37 | - /** @var string The $_POST key in the TrustedLogin request that contains the value of the expected endpoint. */ |
|
38 | - const POST_ENDPOINT_KEY = 'endpoint'; |
|
39 | - |
|
40 | - /** @var string The $_POST key in the TrustedLogin request related to the action being performed. */ |
|
41 | - const POST_IDENTIFIER_KEY = 'identifier'; |
|
42 | - |
|
43 | - /** |
|
44 | - * @var Config |
|
45 | - */ |
|
46 | - private $config; |
|
47 | - |
|
48 | - /** |
|
49 | - * The namespaced setting name for storing part of the auto-login endpoint. |
|
50 | - * |
|
51 | - * @var string Example: `tl_{vendor/namespace}_endpoint` |
|
52 | - */ |
|
53 | - private $option_name; |
|
54 | - |
|
55 | - /** |
|
56 | - * @var SupportUser |
|
57 | - * |
|
58 | - * @todo decouple |
|
59 | - */ |
|
60 | - private $support_user; |
|
61 | - |
|
62 | - /** |
|
63 | - * @var Logging |
|
64 | - */ |
|
65 | - private $logging; |
|
66 | - |
|
67 | - /** |
|
68 | - * Logger constructor. |
|
69 | - */ |
|
70 | - public function __construct(Config $config, Logging $logging) |
|
71 | - { |
|
72 | - $this->config = $config; |
|
73 | - $this->logging = $logging; |
|
74 | - $this->support_user = new SupportUser($config, $logging); |
|
75 | - |
|
76 | - /** |
|
77 | - * Filter: Set endpoint setting name. |
|
78 | - * |
|
79 | - * @since 1.0.0 |
|
80 | - * |
|
81 | - * @param string |
|
82 | - * @param Config $config |
|
83 | - */ |
|
84 | - $this->option_name = apply_filters( |
|
85 | - 'trustedlogin/'.$config->ns().'/options/endpoint', |
|
86 | - 'tl_'.$config->ns().'_endpoint', |
|
87 | - $config |
|
88 | - ); |
|
89 | - } |
|
90 | - |
|
91 | - public function init() |
|
92 | - { |
|
93 | - if (did_action('init')) { |
|
94 | - $this->add(); |
|
95 | - } else { |
|
96 | - add_action('init', [$this, 'add']); |
|
97 | - } |
|
98 | - |
|
99 | - add_action('template_redirect', [$this, 'maybe_login_support'], 99); |
|
100 | - add_action('init', [$this, 'maybe_revoke_support'], 100); |
|
101 | - add_action('admin_init', [$this, 'maybe_revoke_support'], 100); |
|
102 | - } |
|
103 | - |
|
104 | - /** |
|
105 | - * Check if the endpoint is hit and has a valid identifier before automatically logging in support agent. |
|
106 | - * |
|
107 | - * @since 1.0.0 |
|
108 | - * |
|
109 | - * @return void |
|
110 | - */ |
|
111 | - public function maybe_login_support() |
|
112 | - { |
|
113 | - |
|
114 | - // The user's already logged-in; don't override that login. |
|
115 | - if (is_user_logged_in()) { |
|
116 | - return; |
|
117 | - } |
|
118 | - |
|
119 | - $request = $this->get_trustedlogin_request(); |
|
120 | - |
|
121 | - // Not a TrustedLogin request. |
|
122 | - if (!$request) { |
|
123 | - return; |
|
124 | - } |
|
125 | - |
|
126 | - $endpoint = $this->get(); |
|
127 | - |
|
128 | - // The expected endpoint doesn't match the one in the request. |
|
129 | - if ($endpoint !== $request[self::POST_ENDPOINT_KEY]) { |
|
130 | - return; |
|
131 | - } |
|
132 | - |
|
133 | - // The sanitized, unhashed identifier for the support user. |
|
134 | - $user_identifier = $request[self::POST_IDENTIFIER_KEY]; |
|
135 | - |
|
136 | - if (empty($user_identifier)) { |
|
137 | - return; |
|
138 | - } |
|
139 | - |
|
140 | - /** |
|
141 | - * Runs before the support user is (maybe) logged-in. |
|
142 | - * |
|
143 | - * @param string $user_identifier Unique identifier for support user. |
|
144 | - */ |
|
145 | - do_action('trustedlogin/'.$this->config->ns().'/login/before', $user_identifier); |
|
146 | - |
|
147 | - $security_checks = new SecurityChecks($this->config, $this->logging); |
|
148 | - |
|
149 | - // Before logging-in support, let's make sure the site isn't locked-down or that this request is flagged |
|
150 | - $is_verified = $security_checks->verify($user_identifier); |
|
151 | - |
|
152 | - if (!$is_verified || is_wp_error($is_verified)) { |
|
153 | - |
|
154 | - /** |
|
155 | - * Runs after the identifier fails security checks. |
|
156 | - * |
|
157 | - * @param string $user_identifier Unique identifier for support user. |
|
158 | - * @param WP_Error $is_verified The error encountered when verifying the identifier. |
|
159 | - */ |
|
160 | - do_action('trustedlogin/'.$this->config->ns().'/login/refused', $user_identifier, $is_verified); |
|
161 | - |
|
162 | - return; |
|
163 | - } |
|
164 | - |
|
165 | - $is_logged_in = $this->support_user->maybe_login($user_identifier); |
|
166 | - |
|
167 | - if (is_wp_error($is_logged_in)) { |
|
168 | - |
|
169 | - /** |
|
170 | - * Runs after the support user fails to log in. |
|
171 | - * |
|
172 | - * @param string $user_identifier Unique Identifier for support user. |
|
173 | - * @param WP_Error $is_logged_in The error encountered when logging-in. |
|
174 | - */ |
|
175 | - do_action('trustedlogin/'.$this->config->ns().'/login/error', $user_identifier, $is_logged_in); |
|
176 | - |
|
177 | - return; |
|
178 | - } |
|
179 | - |
|
180 | - /** |
|
181 | - * Runs after the support user is logged-in. |
|
182 | - * |
|
183 | - * @param string $user_identifier Unique Identifier for support user. |
|
184 | - */ |
|
185 | - do_action('trustedlogin/'.$this->config->ns().'/login/after', $user_identifier); |
|
186 | - |
|
187 | - wp_safe_redirect(admin_url()); |
|
188 | - |
|
189 | - exit(); |
|
190 | - } |
|
191 | - |
|
192 | - /** |
|
193 | - * Hooked Action to maybe revoke support if $_REQUEST[ SupportUser::ID_QUERY_PARAM ] == {namespace} |
|
194 | - * Can optionally check for $_REQUEST[ SupportUser::ID_QUERY_PARAM ] for revoking a specific user by their identifier. |
|
195 | - * |
|
196 | - * @since 1.0.0 |
|
197 | - */ |
|
198 | - public function maybe_revoke_support() |
|
199 | - { |
|
200 | - if (!isset($_REQUEST[self::REVOKE_SUPPORT_QUERY_PARAM])) { |
|
201 | - return; |
|
202 | - } |
|
203 | - |
|
204 | - if ($this->config->ns() !== $_REQUEST[self::REVOKE_SUPPORT_QUERY_PARAM]) { |
|
205 | - return; |
|
206 | - } |
|
207 | - |
|
208 | - if (!isset($_REQUEST['_wpnonce'])) { |
|
209 | - return; |
|
210 | - } |
|
211 | - |
|
212 | - $verify_nonce = wp_verify_nonce($_REQUEST['_wpnonce'], self::REVOKE_SUPPORT_QUERY_PARAM); |
|
213 | - |
|
214 | - if (!$verify_nonce) { |
|
215 | - $this->logging->log('Removing user failed: Nonce expired (Nonce value: '.$verify_nonce.')', __METHOD__, 'error'); |
|
216 | - |
|
217 | - return; |
|
218 | - } |
|
219 | - |
|
220 | - // Allow namespaced support team to revoke their own users |
|
221 | - $support_team = current_user_can($this->support_user->role->get_name()); |
|
222 | - |
|
223 | - // As well as existing users who can delete other users |
|
224 | - $can_delete_users = current_user_can('delete_users'); |
|
225 | - |
|
226 | - if (!$support_team && !$can_delete_users) { |
|
227 | - wp_safe_redirect(home_url()); |
|
228 | - |
|
229 | - return; |
|
230 | - } |
|
231 | - |
|
232 | - $user_identifier = isset($_REQUEST[SupportUser::ID_QUERY_PARAM]) ? esc_attr($_REQUEST[SupportUser::ID_QUERY_PARAM]) : 'all'; |
|
233 | - |
|
234 | - /** |
|
235 | - * Trigger action to revoke access based on Support User identifier. |
|
236 | - * |
|
237 | - * Hooked into by Cron::revoke |
|
238 | - * |
|
239 | - * @param string $user_identifier Unique ID for TrustedLogin support user or "all". |
|
240 | - */ |
|
241 | - do_action('trustedlogin/'.$this->config->ns().'/access/revoke', $user_identifier); |
|
242 | - |
|
243 | - $should_be_deleted = $this->support_user->get($user_identifier); |
|
244 | - |
|
245 | - if (!empty($should_be_deleted)) { |
|
246 | - $this->logging->log('User #'.$should_be_deleted->ID.' was not removed', __METHOD__, 'error'); |
|
247 | - |
|
248 | - return; // Don't trigger `access_revoked` if anything fails. |
|
249 | - } |
|
250 | - |
|
251 | - /** |
|
252 | - * Only triggered when all access has been successfully revoked and no users exist with identifier $identifer. |
|
253 | - * |
|
254 | - * @param string $user_identifier Unique TrustedLogin ID for the Support User or "all" |
|
255 | - */ |
|
256 | - do_action('trustedlogin/'.$this->config->ns().'/admin/access_revoked', $user_identifier); |
|
257 | - } |
|
258 | - |
|
259 | - /** |
|
260 | - * Hooked Action: Add a unique endpoint to WP if a support agent exists. |
|
261 | - * |
|
262 | - * @since 1.0.0 |
|
263 | - * @see Endpoint::init() Called via `init` hook |
|
264 | - */ |
|
265 | - public function add() |
|
266 | - { |
|
267 | - |
|
268 | - // Only add the endpoint if a TrustedLogin request is being made. |
|
269 | - if (!$this->get_trustedlogin_request()) { |
|
270 | - return; |
|
271 | - } |
|
272 | - |
|
273 | - $endpoint = $this->get(); |
|
274 | - |
|
275 | - if (!$endpoint) { |
|
276 | - return; |
|
277 | - } |
|
278 | - |
|
279 | - add_rewrite_endpoint($endpoint, EP_ROOT); |
|
280 | - |
|
281 | - $this->logging->log("Endpoint {$endpoint} added.", __METHOD__, 'debug'); |
|
282 | - |
|
283 | - if (get_site_option(self::PERMALINK_FLUSH_OPTION_NAME)) { |
|
284 | - return; |
|
285 | - } |
|
286 | - |
|
287 | - flush_rewrite_rules(false); |
|
288 | - |
|
289 | - $this->logging->log('Rewrite rules flushed.', __METHOD__, 'info'); |
|
290 | - |
|
291 | - $updated_option = update_site_option(self::PERMALINK_FLUSH_OPTION_NAME, 1); |
|
292 | - |
|
293 | - if (false === $updated_option) { |
|
294 | - $this->logging->log('Permalink flush option was not properly set.', 'warning'); |
|
295 | - } |
|
296 | - } |
|
297 | - |
|
298 | - /** |
|
299 | - * Get the site option value at {@see option_name}. |
|
300 | - * |
|
301 | - * @return string |
|
302 | - */ |
|
303 | - public function get() |
|
304 | - { |
|
305 | - return (string) get_site_option($this->option_name); |
|
306 | - } |
|
307 | - |
|
308 | - /** |
|
309 | - * Returns sanitized data from a TrustedLogin login $_POST request. |
|
310 | - * |
|
311 | - * Note: This is not a security check. It is only used to determine whether the request contains the expected keys. |
|
312 | - * |
|
313 | - * @since 1.1 |
|
314 | - * |
|
315 | - * @return false|array{action:string, endpoint:string, identifier: string} If false, the request is not from TrustedLogin. If the request is from TrustedLogin, an array with the posted keys, santiized. |
|
316 | - */ |
|
317 | - private function get_trustedlogin_request() |
|
318 | - { |
|
319 | - if (!isset($_POST[self::POST_ACTION_KEY], $_POST[self::POST_ENDPOINT_KEY], $_POST[self::POST_IDENTIFIER_KEY])) { |
|
320 | - return false; |
|
321 | - } |
|
322 | - |
|
323 | - if (self::POST_ACTION_VALUE !== $_POST[self::POST_ACTION_KEY]) { |
|
324 | - return false; |
|
325 | - } |
|
326 | - |
|
327 | - $_sanitized_post_data = array_map('sanitize_text_field', $_POST); |
|
328 | - |
|
329 | - // Return only the expected keys. |
|
330 | - return [ |
|
331 | - self::POST_ACTION_KEY => $_sanitized_post_data[self::POST_ACTION_KEY], |
|
332 | - self::POST_ENDPOINT_KEY => $_sanitized_post_data[self::POST_ENDPOINT_KEY], |
|
333 | - self::POST_IDENTIFIER_KEY => $_sanitized_post_data[self::POST_IDENTIFIER_KEY], |
|
334 | - ]; |
|
335 | - } |
|
336 | - |
|
337 | - /** |
|
338 | - * Generate the secret_id parameter as a hash of the endpoint with the identifier. |
|
339 | - * |
|
340 | - * @param string $site_identifier_hash |
|
341 | - * @param string $endpoint_hash |
|
342 | - * |
|
343 | - * @return string|WP_Error This hash will be used as an identifier in TrustedLogin SaaS. Or something went wrong. |
|
344 | - */ |
|
345 | - public function generate_secret_id($site_identifier_hash, $endpoint_hash = '') |
|
346 | - { |
|
347 | - if (empty($endpoint_hash)) { |
|
348 | - $endpoint_hash = $this->get_hash($site_identifier_hash); |
|
349 | - } |
|
350 | - |
|
351 | - if (is_wp_error($endpoint_hash)) { |
|
352 | - return $endpoint_hash; |
|
353 | - } |
|
354 | - |
|
355 | - return Encryption::hash($endpoint_hash.$site_identifier_hash); |
|
356 | - } |
|
357 | - |
|
358 | - /** |
|
359 | - * Generate the endpoint parameter as a hash of the site URL with the identifier. |
|
360 | - * |
|
361 | - * @param $site_identifier_hash |
|
362 | - * |
|
363 | - * @return string This hash will be used as the first part of the URL and also a part of $secret_id |
|
364 | - */ |
|
365 | - public function get_hash($site_identifier_hash) |
|
366 | - { |
|
367 | - return Encryption::hash(get_site_url().$site_identifier_hash); |
|
368 | - } |
|
369 | - |
|
370 | - /** |
|
371 | - * Updates the site's endpoint to listen for logins. Flushes rewrite rules after updating. |
|
372 | - * |
|
373 | - * @param string $endpoint |
|
374 | - * |
|
375 | - * @return bool True: updated; False: didn't change, or didn't update |
|
376 | - */ |
|
377 | - public function update($endpoint) |
|
378 | - { |
|
379 | - $updated = update_site_option($this->option_name, $endpoint); |
|
380 | - |
|
381 | - update_site_option(self::PERMALINK_FLUSH_OPTION_NAME, 0); |
|
382 | - |
|
383 | - return $updated; |
|
384 | - } |
|
385 | - |
|
386 | - /** |
|
387 | - * @return void |
|
388 | - */ |
|
389 | - public function delete() |
|
390 | - { |
|
391 | - if (!get_site_option($this->option_name)) { |
|
392 | - $this->logging->log('Endpoint not deleted because it does not exist.', __METHOD__, 'info'); |
|
393 | - |
|
394 | - return; |
|
395 | - } |
|
396 | - |
|
397 | - delete_site_option($this->option_name); |
|
398 | - |
|
399 | - flush_rewrite_rules(false); |
|
400 | - |
|
401 | - update_site_option(self::PERMALINK_FLUSH_OPTION_NAME, 0); |
|
402 | - |
|
403 | - $this->logging->log('Endpoint removed & rewrites flushed', __METHOD__, 'info'); |
|
404 | - } |
|
19 | + /** |
|
20 | + * @var string The query string parameter used to revoke users |
|
21 | + */ |
|
22 | + const REVOKE_SUPPORT_QUERY_PARAM = 'revoke-tl'; |
|
23 | + |
|
24 | + /** |
|
25 | + * @var string Site option used to track whether permalinks have been flushed. |
|
26 | + */ |
|
27 | + const PERMALINK_FLUSH_OPTION_NAME = 'tl_permalinks_flushed'; |
|
28 | + |
|
29 | + /** |
|
30 | + * @var string Expected value of $_POST['action'] before adding the endpoint and starting a login flow. |
|
31 | + */ |
|
32 | + const POST_ACTION_VALUE = 'trustedlogin'; |
|
33 | + |
|
34 | + /** @var string The $_POST key in the TrustedLogin request related to the action being performed. */ |
|
35 | + const POST_ACTION_KEY = 'action'; |
|
36 | + |
|
37 | + /** @var string The $_POST key in the TrustedLogin request that contains the value of the expected endpoint. */ |
|
38 | + const POST_ENDPOINT_KEY = 'endpoint'; |
|
39 | + |
|
40 | + /** @var string The $_POST key in the TrustedLogin request related to the action being performed. */ |
|
41 | + const POST_IDENTIFIER_KEY = 'identifier'; |
|
42 | + |
|
43 | + /** |
|
44 | + * @var Config |
|
45 | + */ |
|
46 | + private $config; |
|
47 | + |
|
48 | + /** |
|
49 | + * The namespaced setting name for storing part of the auto-login endpoint. |
|
50 | + * |
|
51 | + * @var string Example: `tl_{vendor/namespace}_endpoint` |
|
52 | + */ |
|
53 | + private $option_name; |
|
54 | + |
|
55 | + /** |
|
56 | + * @var SupportUser |
|
57 | + * |
|
58 | + * @todo decouple |
|
59 | + */ |
|
60 | + private $support_user; |
|
61 | + |
|
62 | + /** |
|
63 | + * @var Logging |
|
64 | + */ |
|
65 | + private $logging; |
|
66 | + |
|
67 | + /** |
|
68 | + * Logger constructor. |
|
69 | + */ |
|
70 | + public function __construct(Config $config, Logging $logging) |
|
71 | + { |
|
72 | + $this->config = $config; |
|
73 | + $this->logging = $logging; |
|
74 | + $this->support_user = new SupportUser($config, $logging); |
|
75 | + |
|
76 | + /** |
|
77 | + * Filter: Set endpoint setting name. |
|
78 | + * |
|
79 | + * @since 1.0.0 |
|
80 | + * |
|
81 | + * @param string |
|
82 | + * @param Config $config |
|
83 | + */ |
|
84 | + $this->option_name = apply_filters( |
|
85 | + 'trustedlogin/'.$config->ns().'/options/endpoint', |
|
86 | + 'tl_'.$config->ns().'_endpoint', |
|
87 | + $config |
|
88 | + ); |
|
89 | + } |
|
90 | + |
|
91 | + public function init() |
|
92 | + { |
|
93 | + if (did_action('init')) { |
|
94 | + $this->add(); |
|
95 | + } else { |
|
96 | + add_action('init', [$this, 'add']); |
|
97 | + } |
|
98 | + |
|
99 | + add_action('template_redirect', [$this, 'maybe_login_support'], 99); |
|
100 | + add_action('init', [$this, 'maybe_revoke_support'], 100); |
|
101 | + add_action('admin_init', [$this, 'maybe_revoke_support'], 100); |
|
102 | + } |
|
103 | + |
|
104 | + /** |
|
105 | + * Check if the endpoint is hit and has a valid identifier before automatically logging in support agent. |
|
106 | + * |
|
107 | + * @since 1.0.0 |
|
108 | + * |
|
109 | + * @return void |
|
110 | + */ |
|
111 | + public function maybe_login_support() |
|
112 | + { |
|
113 | + |
|
114 | + // The user's already logged-in; don't override that login. |
|
115 | + if (is_user_logged_in()) { |
|
116 | + return; |
|
117 | + } |
|
118 | + |
|
119 | + $request = $this->get_trustedlogin_request(); |
|
120 | + |
|
121 | + // Not a TrustedLogin request. |
|
122 | + if (!$request) { |
|
123 | + return; |
|
124 | + } |
|
125 | + |
|
126 | + $endpoint = $this->get(); |
|
127 | + |
|
128 | + // The expected endpoint doesn't match the one in the request. |
|
129 | + if ($endpoint !== $request[self::POST_ENDPOINT_KEY]) { |
|
130 | + return; |
|
131 | + } |
|
132 | + |
|
133 | + // The sanitized, unhashed identifier for the support user. |
|
134 | + $user_identifier = $request[self::POST_IDENTIFIER_KEY]; |
|
135 | + |
|
136 | + if (empty($user_identifier)) { |
|
137 | + return; |
|
138 | + } |
|
139 | + |
|
140 | + /** |
|
141 | + * Runs before the support user is (maybe) logged-in. |
|
142 | + * |
|
143 | + * @param string $user_identifier Unique identifier for support user. |
|
144 | + */ |
|
145 | + do_action('trustedlogin/'.$this->config->ns().'/login/before', $user_identifier); |
|
146 | + |
|
147 | + $security_checks = new SecurityChecks($this->config, $this->logging); |
|
148 | + |
|
149 | + // Before logging-in support, let's make sure the site isn't locked-down or that this request is flagged |
|
150 | + $is_verified = $security_checks->verify($user_identifier); |
|
151 | + |
|
152 | + if (!$is_verified || is_wp_error($is_verified)) { |
|
153 | + |
|
154 | + /** |
|
155 | + * Runs after the identifier fails security checks. |
|
156 | + * |
|
157 | + * @param string $user_identifier Unique identifier for support user. |
|
158 | + * @param WP_Error $is_verified The error encountered when verifying the identifier. |
|
159 | + */ |
|
160 | + do_action('trustedlogin/'.$this->config->ns().'/login/refused', $user_identifier, $is_verified); |
|
161 | + |
|
162 | + return; |
|
163 | + } |
|
164 | + |
|
165 | + $is_logged_in = $this->support_user->maybe_login($user_identifier); |
|
166 | + |
|
167 | + if (is_wp_error($is_logged_in)) { |
|
168 | + |
|
169 | + /** |
|
170 | + * Runs after the support user fails to log in. |
|
171 | + * |
|
172 | + * @param string $user_identifier Unique Identifier for support user. |
|
173 | + * @param WP_Error $is_logged_in The error encountered when logging-in. |
|
174 | + */ |
|
175 | + do_action('trustedlogin/'.$this->config->ns().'/login/error', $user_identifier, $is_logged_in); |
|
176 | + |
|
177 | + return; |
|
178 | + } |
|
179 | + |
|
180 | + /** |
|
181 | + * Runs after the support user is logged-in. |
|
182 | + * |
|
183 | + * @param string $user_identifier Unique Identifier for support user. |
|
184 | + */ |
|
185 | + do_action('trustedlogin/'.$this->config->ns().'/login/after', $user_identifier); |
|
186 | + |
|
187 | + wp_safe_redirect(admin_url()); |
|
188 | + |
|
189 | + exit(); |
|
190 | + } |
|
191 | + |
|
192 | + /** |
|
193 | + * Hooked Action to maybe revoke support if $_REQUEST[ SupportUser::ID_QUERY_PARAM ] == {namespace} |
|
194 | + * Can optionally check for $_REQUEST[ SupportUser::ID_QUERY_PARAM ] for revoking a specific user by their identifier. |
|
195 | + * |
|
196 | + * @since 1.0.0 |
|
197 | + */ |
|
198 | + public function maybe_revoke_support() |
|
199 | + { |
|
200 | + if (!isset($_REQUEST[self::REVOKE_SUPPORT_QUERY_PARAM])) { |
|
201 | + return; |
|
202 | + } |
|
203 | + |
|
204 | + if ($this->config->ns() !== $_REQUEST[self::REVOKE_SUPPORT_QUERY_PARAM]) { |
|
205 | + return; |
|
206 | + } |
|
207 | + |
|
208 | + if (!isset($_REQUEST['_wpnonce'])) { |
|
209 | + return; |
|
210 | + } |
|
211 | + |
|
212 | + $verify_nonce = wp_verify_nonce($_REQUEST['_wpnonce'], self::REVOKE_SUPPORT_QUERY_PARAM); |
|
213 | + |
|
214 | + if (!$verify_nonce) { |
|
215 | + $this->logging->log('Removing user failed: Nonce expired (Nonce value: '.$verify_nonce.')', __METHOD__, 'error'); |
|
216 | + |
|
217 | + return; |
|
218 | + } |
|
219 | + |
|
220 | + // Allow namespaced support team to revoke their own users |
|
221 | + $support_team = current_user_can($this->support_user->role->get_name()); |
|
222 | + |
|
223 | + // As well as existing users who can delete other users |
|
224 | + $can_delete_users = current_user_can('delete_users'); |
|
225 | + |
|
226 | + if (!$support_team && !$can_delete_users) { |
|
227 | + wp_safe_redirect(home_url()); |
|
228 | + |
|
229 | + return; |
|
230 | + } |
|
231 | + |
|
232 | + $user_identifier = isset($_REQUEST[SupportUser::ID_QUERY_PARAM]) ? esc_attr($_REQUEST[SupportUser::ID_QUERY_PARAM]) : 'all'; |
|
233 | + |
|
234 | + /** |
|
235 | + * Trigger action to revoke access based on Support User identifier. |
|
236 | + * |
|
237 | + * Hooked into by Cron::revoke |
|
238 | + * |
|
239 | + * @param string $user_identifier Unique ID for TrustedLogin support user or "all". |
|
240 | + */ |
|
241 | + do_action('trustedlogin/'.$this->config->ns().'/access/revoke', $user_identifier); |
|
242 | + |
|
243 | + $should_be_deleted = $this->support_user->get($user_identifier); |
|
244 | + |
|
245 | + if (!empty($should_be_deleted)) { |
|
246 | + $this->logging->log('User #'.$should_be_deleted->ID.' was not removed', __METHOD__, 'error'); |
|
247 | + |
|
248 | + return; // Don't trigger `access_revoked` if anything fails. |
|
249 | + } |
|
250 | + |
|
251 | + /** |
|
252 | + * Only triggered when all access has been successfully revoked and no users exist with identifier $identifer. |
|
253 | + * |
|
254 | + * @param string $user_identifier Unique TrustedLogin ID for the Support User or "all" |
|
255 | + */ |
|
256 | + do_action('trustedlogin/'.$this->config->ns().'/admin/access_revoked', $user_identifier); |
|
257 | + } |
|
258 | + |
|
259 | + /** |
|
260 | + * Hooked Action: Add a unique endpoint to WP if a support agent exists. |
|
261 | + * |
|
262 | + * @since 1.0.0 |
|
263 | + * @see Endpoint::init() Called via `init` hook |
|
264 | + */ |
|
265 | + public function add() |
|
266 | + { |
|
267 | + |
|
268 | + // Only add the endpoint if a TrustedLogin request is being made. |
|
269 | + if (!$this->get_trustedlogin_request()) { |
|
270 | + return; |
|
271 | + } |
|
272 | + |
|
273 | + $endpoint = $this->get(); |
|
274 | + |
|
275 | + if (!$endpoint) { |
|
276 | + return; |
|
277 | + } |
|
278 | + |
|
279 | + add_rewrite_endpoint($endpoint, EP_ROOT); |
|
280 | + |
|
281 | + $this->logging->log("Endpoint {$endpoint} added.", __METHOD__, 'debug'); |
|
282 | + |
|
283 | + if (get_site_option(self::PERMALINK_FLUSH_OPTION_NAME)) { |
|
284 | + return; |
|
285 | + } |
|
286 | + |
|
287 | + flush_rewrite_rules(false); |
|
288 | + |
|
289 | + $this->logging->log('Rewrite rules flushed.', __METHOD__, 'info'); |
|
290 | + |
|
291 | + $updated_option = update_site_option(self::PERMALINK_FLUSH_OPTION_NAME, 1); |
|
292 | + |
|
293 | + if (false === $updated_option) { |
|
294 | + $this->logging->log('Permalink flush option was not properly set.', 'warning'); |
|
295 | + } |
|
296 | + } |
|
297 | + |
|
298 | + /** |
|
299 | + * Get the site option value at {@see option_name}. |
|
300 | + * |
|
301 | + * @return string |
|
302 | + */ |
|
303 | + public function get() |
|
304 | + { |
|
305 | + return (string) get_site_option($this->option_name); |
|
306 | + } |
|
307 | + |
|
308 | + /** |
|
309 | + * Returns sanitized data from a TrustedLogin login $_POST request. |
|
310 | + * |
|
311 | + * Note: This is not a security check. It is only used to determine whether the request contains the expected keys. |
|
312 | + * |
|
313 | + * @since 1.1 |
|
314 | + * |
|
315 | + * @return false|array{action:string, endpoint:string, identifier: string} If false, the request is not from TrustedLogin. If the request is from TrustedLogin, an array with the posted keys, santiized. |
|
316 | + */ |
|
317 | + private function get_trustedlogin_request() |
|
318 | + { |
|
319 | + if (!isset($_POST[self::POST_ACTION_KEY], $_POST[self::POST_ENDPOINT_KEY], $_POST[self::POST_IDENTIFIER_KEY])) { |
|
320 | + return false; |
|
321 | + } |
|
322 | + |
|
323 | + if (self::POST_ACTION_VALUE !== $_POST[self::POST_ACTION_KEY]) { |
|
324 | + return false; |
|
325 | + } |
|
326 | + |
|
327 | + $_sanitized_post_data = array_map('sanitize_text_field', $_POST); |
|
328 | + |
|
329 | + // Return only the expected keys. |
|
330 | + return [ |
|
331 | + self::POST_ACTION_KEY => $_sanitized_post_data[self::POST_ACTION_KEY], |
|
332 | + self::POST_ENDPOINT_KEY => $_sanitized_post_data[self::POST_ENDPOINT_KEY], |
|
333 | + self::POST_IDENTIFIER_KEY => $_sanitized_post_data[self::POST_IDENTIFIER_KEY], |
|
334 | + ]; |
|
335 | + } |
|
336 | + |
|
337 | + /** |
|
338 | + * Generate the secret_id parameter as a hash of the endpoint with the identifier. |
|
339 | + * |
|
340 | + * @param string $site_identifier_hash |
|
341 | + * @param string $endpoint_hash |
|
342 | + * |
|
343 | + * @return string|WP_Error This hash will be used as an identifier in TrustedLogin SaaS. Or something went wrong. |
|
344 | + */ |
|
345 | + public function generate_secret_id($site_identifier_hash, $endpoint_hash = '') |
|
346 | + { |
|
347 | + if (empty($endpoint_hash)) { |
|
348 | + $endpoint_hash = $this->get_hash($site_identifier_hash); |
|
349 | + } |
|
350 | + |
|
351 | + if (is_wp_error($endpoint_hash)) { |
|
352 | + return $endpoint_hash; |
|
353 | + } |
|
354 | + |
|
355 | + return Encryption::hash($endpoint_hash.$site_identifier_hash); |
|
356 | + } |
|
357 | + |
|
358 | + /** |
|
359 | + * Generate the endpoint parameter as a hash of the site URL with the identifier. |
|
360 | + * |
|
361 | + * @param $site_identifier_hash |
|
362 | + * |
|
363 | + * @return string This hash will be used as the first part of the URL and also a part of $secret_id |
|
364 | + */ |
|
365 | + public function get_hash($site_identifier_hash) |
|
366 | + { |
|
367 | + return Encryption::hash(get_site_url().$site_identifier_hash); |
|
368 | + } |
|
369 | + |
|
370 | + /** |
|
371 | + * Updates the site's endpoint to listen for logins. Flushes rewrite rules after updating. |
|
372 | + * |
|
373 | + * @param string $endpoint |
|
374 | + * |
|
375 | + * @return bool True: updated; False: didn't change, or didn't update |
|
376 | + */ |
|
377 | + public function update($endpoint) |
|
378 | + { |
|
379 | + $updated = update_site_option($this->option_name, $endpoint); |
|
380 | + |
|
381 | + update_site_option(self::PERMALINK_FLUSH_OPTION_NAME, 0); |
|
382 | + |
|
383 | + return $updated; |
|
384 | + } |
|
385 | + |
|
386 | + /** |
|
387 | + * @return void |
|
388 | + */ |
|
389 | + public function delete() |
|
390 | + { |
|
391 | + if (!get_site_option($this->option_name)) { |
|
392 | + $this->logging->log('Endpoint not deleted because it does not exist.', __METHOD__, 'info'); |
|
393 | + |
|
394 | + return; |
|
395 | + } |
|
396 | + |
|
397 | + delete_site_option($this->option_name); |
|
398 | + |
|
399 | + flush_rewrite_rules(false); |
|
400 | + |
|
401 | + update_site_option(self::PERMALINK_FLUSH_OPTION_NAME, 0); |
|
402 | + |
|
403 | + $this->logging->log('Endpoint removed & rewrites flushed', __METHOD__, 'info'); |
|
404 | + } |
|
405 | 405 | } |
@@ -67,11 +67,11 @@ discard block |
||
67 | 67 | /** |
68 | 68 | * Logger constructor. |
69 | 69 | */ |
70 | - public function __construct(Config $config, Logging $logging) |
|
70 | + public function __construct( Config $config, Logging $logging ) |
|
71 | 71 | { |
72 | 72 | $this->config = $config; |
73 | 73 | $this->logging = $logging; |
74 | - $this->support_user = new SupportUser($config, $logging); |
|
74 | + $this->support_user = new SupportUser( $config, $logging ); |
|
75 | 75 | |
76 | 76 | /** |
77 | 77 | * Filter: Set endpoint setting name. |
@@ -82,23 +82,23 @@ discard block |
||
82 | 82 | * @param Config $config |
83 | 83 | */ |
84 | 84 | $this->option_name = apply_filters( |
85 | - 'trustedlogin/'.$config->ns().'/options/endpoint', |
|
86 | - 'tl_'.$config->ns().'_endpoint', |
|
85 | + 'trustedlogin/' . $config->ns() . '/options/endpoint', |
|
86 | + 'tl_' . $config->ns() . '_endpoint', |
|
87 | 87 | $config |
88 | 88 | ); |
89 | 89 | } |
90 | 90 | |
91 | 91 | public function init() |
92 | 92 | { |
93 | - if (did_action('init')) { |
|
93 | + if ( did_action( 'init' ) ) { |
|
94 | 94 | $this->add(); |
95 | 95 | } else { |
96 | - add_action('init', [$this, 'add']); |
|
96 | + add_action( 'init', [ $this, 'add' ] ); |
|
97 | 97 | } |
98 | 98 | |
99 | - add_action('template_redirect', [$this, 'maybe_login_support'], 99); |
|
100 | - add_action('init', [$this, 'maybe_revoke_support'], 100); |
|
101 | - add_action('admin_init', [$this, 'maybe_revoke_support'], 100); |
|
99 | + add_action( 'template_redirect', [ $this, 'maybe_login_support' ], 99 ); |
|
100 | + add_action( 'init', [ $this, 'maybe_revoke_support' ], 100 ); |
|
101 | + add_action( 'admin_init', [ $this, 'maybe_revoke_support' ], 100 ); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -112,28 +112,28 @@ discard block |
||
112 | 112 | { |
113 | 113 | |
114 | 114 | // The user's already logged-in; don't override that login. |
115 | - if (is_user_logged_in()) { |
|
115 | + if ( is_user_logged_in() ) { |
|
116 | 116 | return; |
117 | 117 | } |
118 | 118 | |
119 | 119 | $request = $this->get_trustedlogin_request(); |
120 | 120 | |
121 | 121 | // Not a TrustedLogin request. |
122 | - if (!$request) { |
|
122 | + if ( ! $request ) { |
|
123 | 123 | return; |
124 | 124 | } |
125 | 125 | |
126 | 126 | $endpoint = $this->get(); |
127 | 127 | |
128 | 128 | // The expected endpoint doesn't match the one in the request. |
129 | - if ($endpoint !== $request[self::POST_ENDPOINT_KEY]) { |
|
129 | + if ( $endpoint !== $request[ self::POST_ENDPOINT_KEY ] ) { |
|
130 | 130 | return; |
131 | 131 | } |
132 | 132 | |
133 | 133 | // The sanitized, unhashed identifier for the support user. |
134 | - $user_identifier = $request[self::POST_IDENTIFIER_KEY]; |
|
134 | + $user_identifier = $request[ self::POST_IDENTIFIER_KEY ]; |
|
135 | 135 | |
136 | - if (empty($user_identifier)) { |
|
136 | + if ( empty( $user_identifier ) ) { |
|
137 | 137 | return; |
138 | 138 | } |
139 | 139 | |
@@ -142,14 +142,14 @@ discard block |
||
142 | 142 | * |
143 | 143 | * @param string $user_identifier Unique identifier for support user. |
144 | 144 | */ |
145 | - do_action('trustedlogin/'.$this->config->ns().'/login/before', $user_identifier); |
|
145 | + do_action( 'trustedlogin/' . $this->config->ns() . '/login/before', $user_identifier ); |
|
146 | 146 | |
147 | - $security_checks = new SecurityChecks($this->config, $this->logging); |
|
147 | + $security_checks = new SecurityChecks( $this->config, $this->logging ); |
|
148 | 148 | |
149 | 149 | // Before logging-in support, let's make sure the site isn't locked-down or that this request is flagged |
150 | - $is_verified = $security_checks->verify($user_identifier); |
|
150 | + $is_verified = $security_checks->verify( $user_identifier ); |
|
151 | 151 | |
152 | - if (!$is_verified || is_wp_error($is_verified)) { |
|
152 | + if ( ! $is_verified || is_wp_error( $is_verified ) ) { |
|
153 | 153 | |
154 | 154 | /** |
155 | 155 | * Runs after the identifier fails security checks. |
@@ -157,14 +157,14 @@ discard block |
||
157 | 157 | * @param string $user_identifier Unique identifier for support user. |
158 | 158 | * @param WP_Error $is_verified The error encountered when verifying the identifier. |
159 | 159 | */ |
160 | - do_action('trustedlogin/'.$this->config->ns().'/login/refused', $user_identifier, $is_verified); |
|
160 | + do_action( 'trustedlogin/' . $this->config->ns() . '/login/refused', $user_identifier, $is_verified ); |
|
161 | 161 | |
162 | 162 | return; |
163 | 163 | } |
164 | 164 | |
165 | - $is_logged_in = $this->support_user->maybe_login($user_identifier); |
|
165 | + $is_logged_in = $this->support_user->maybe_login( $user_identifier ); |
|
166 | 166 | |
167 | - if (is_wp_error($is_logged_in)) { |
|
167 | + if ( is_wp_error( $is_logged_in ) ) { |
|
168 | 168 | |
169 | 169 | /** |
170 | 170 | * Runs after the support user fails to log in. |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * @param string $user_identifier Unique Identifier for support user. |
173 | 173 | * @param WP_Error $is_logged_in The error encountered when logging-in. |
174 | 174 | */ |
175 | - do_action('trustedlogin/'.$this->config->ns().'/login/error', $user_identifier, $is_logged_in); |
|
175 | + do_action( 'trustedlogin/' . $this->config->ns() . '/login/error', $user_identifier, $is_logged_in ); |
|
176 | 176 | |
177 | 177 | return; |
178 | 178 | } |
@@ -182,9 +182,9 @@ discard block |
||
182 | 182 | * |
183 | 183 | * @param string $user_identifier Unique Identifier for support user. |
184 | 184 | */ |
185 | - do_action('trustedlogin/'.$this->config->ns().'/login/after', $user_identifier); |
|
185 | + do_action( 'trustedlogin/' . $this->config->ns() . '/login/after', $user_identifier ); |
|
186 | 186 | |
187 | - wp_safe_redirect(admin_url()); |
|
187 | + wp_safe_redirect( admin_url() ); |
|
188 | 188 | |
189 | 189 | exit(); |
190 | 190 | } |
@@ -197,39 +197,39 @@ discard block |
||
197 | 197 | */ |
198 | 198 | public function maybe_revoke_support() |
199 | 199 | { |
200 | - if (!isset($_REQUEST[self::REVOKE_SUPPORT_QUERY_PARAM])) { |
|
200 | + if ( ! isset( $_REQUEST[ self::REVOKE_SUPPORT_QUERY_PARAM ] ) ) { |
|
201 | 201 | return; |
202 | 202 | } |
203 | 203 | |
204 | - if ($this->config->ns() !== $_REQUEST[self::REVOKE_SUPPORT_QUERY_PARAM]) { |
|
204 | + if ( $this->config->ns() !== $_REQUEST[ self::REVOKE_SUPPORT_QUERY_PARAM ] ) { |
|
205 | 205 | return; |
206 | 206 | } |
207 | 207 | |
208 | - if (!isset($_REQUEST['_wpnonce'])) { |
|
208 | + if ( ! isset( $_REQUEST[ '_wpnonce' ] ) ) { |
|
209 | 209 | return; |
210 | 210 | } |
211 | 211 | |
212 | - $verify_nonce = wp_verify_nonce($_REQUEST['_wpnonce'], self::REVOKE_SUPPORT_QUERY_PARAM); |
|
212 | + $verify_nonce = wp_verify_nonce( $_REQUEST[ '_wpnonce' ], self::REVOKE_SUPPORT_QUERY_PARAM ); |
|
213 | 213 | |
214 | - if (!$verify_nonce) { |
|
215 | - $this->logging->log('Removing user failed: Nonce expired (Nonce value: '.$verify_nonce.')', __METHOD__, 'error'); |
|
214 | + if ( ! $verify_nonce ) { |
|
215 | + $this->logging->log( 'Removing user failed: Nonce expired (Nonce value: ' . $verify_nonce . ')', __METHOD__, 'error' ); |
|
216 | 216 | |
217 | 217 | return; |
218 | 218 | } |
219 | 219 | |
220 | 220 | // Allow namespaced support team to revoke their own users |
221 | - $support_team = current_user_can($this->support_user->role->get_name()); |
|
221 | + $support_team = current_user_can( $this->support_user->role->get_name() ); |
|
222 | 222 | |
223 | 223 | // As well as existing users who can delete other users |
224 | - $can_delete_users = current_user_can('delete_users'); |
|
224 | + $can_delete_users = current_user_can( 'delete_users' ); |
|
225 | 225 | |
226 | - if (!$support_team && !$can_delete_users) { |
|
227 | - wp_safe_redirect(home_url()); |
|
226 | + if ( ! $support_team && ! $can_delete_users ) { |
|
227 | + wp_safe_redirect( home_url() ); |
|
228 | 228 | |
229 | 229 | return; |
230 | 230 | } |
231 | 231 | |
232 | - $user_identifier = isset($_REQUEST[SupportUser::ID_QUERY_PARAM]) ? esc_attr($_REQUEST[SupportUser::ID_QUERY_PARAM]) : 'all'; |
|
232 | + $user_identifier = isset( $_REQUEST[ SupportUser::ID_QUERY_PARAM ] ) ? esc_attr( $_REQUEST[ SupportUser::ID_QUERY_PARAM ] ) : 'all'; |
|
233 | 233 | |
234 | 234 | /** |
235 | 235 | * Trigger action to revoke access based on Support User identifier. |
@@ -238,12 +238,12 @@ discard block |
||
238 | 238 | * |
239 | 239 | * @param string $user_identifier Unique ID for TrustedLogin support user or "all". |
240 | 240 | */ |
241 | - do_action('trustedlogin/'.$this->config->ns().'/access/revoke', $user_identifier); |
|
241 | + do_action( 'trustedlogin/' . $this->config->ns() . '/access/revoke', $user_identifier ); |
|
242 | 242 | |
243 | - $should_be_deleted = $this->support_user->get($user_identifier); |
|
243 | + $should_be_deleted = $this->support_user->get( $user_identifier ); |
|
244 | 244 | |
245 | - if (!empty($should_be_deleted)) { |
|
246 | - $this->logging->log('User #'.$should_be_deleted->ID.' was not removed', __METHOD__, 'error'); |
|
245 | + if ( ! empty( $should_be_deleted ) ) { |
|
246 | + $this->logging->log( 'User #' . $should_be_deleted->ID . ' was not removed', __METHOD__, 'error' ); |
|
247 | 247 | |
248 | 248 | return; // Don't trigger `access_revoked` if anything fails. |
249 | 249 | } |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | * |
254 | 254 | * @param string $user_identifier Unique TrustedLogin ID for the Support User or "all" |
255 | 255 | */ |
256 | - do_action('trustedlogin/'.$this->config->ns().'/admin/access_revoked', $user_identifier); |
|
256 | + do_action( 'trustedlogin/' . $this->config->ns() . '/admin/access_revoked', $user_identifier ); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | /** |
@@ -266,32 +266,32 @@ discard block |
||
266 | 266 | { |
267 | 267 | |
268 | 268 | // Only add the endpoint if a TrustedLogin request is being made. |
269 | - if (!$this->get_trustedlogin_request()) { |
|
269 | + if ( ! $this->get_trustedlogin_request() ) { |
|
270 | 270 | return; |
271 | 271 | } |
272 | 272 | |
273 | 273 | $endpoint = $this->get(); |
274 | 274 | |
275 | - if (!$endpoint) { |
|
275 | + if ( ! $endpoint ) { |
|
276 | 276 | return; |
277 | 277 | } |
278 | 278 | |
279 | - add_rewrite_endpoint($endpoint, EP_ROOT); |
|
279 | + add_rewrite_endpoint( $endpoint, EP_ROOT ); |
|
280 | 280 | |
281 | - $this->logging->log("Endpoint {$endpoint} added.", __METHOD__, 'debug'); |
|
281 | + $this->logging->log( "Endpoint {$endpoint} added.", __METHOD__, 'debug' ); |
|
282 | 282 | |
283 | - if (get_site_option(self::PERMALINK_FLUSH_OPTION_NAME)) { |
|
283 | + if ( get_site_option( self::PERMALINK_FLUSH_OPTION_NAME ) ) { |
|
284 | 284 | return; |
285 | 285 | } |
286 | 286 | |
287 | - flush_rewrite_rules(false); |
|
287 | + flush_rewrite_rules( false ); |
|
288 | 288 | |
289 | - $this->logging->log('Rewrite rules flushed.', __METHOD__, 'info'); |
|
289 | + $this->logging->log( 'Rewrite rules flushed.', __METHOD__, 'info' ); |
|
290 | 290 | |
291 | - $updated_option = update_site_option(self::PERMALINK_FLUSH_OPTION_NAME, 1); |
|
291 | + $updated_option = update_site_option( self::PERMALINK_FLUSH_OPTION_NAME, 1 ); |
|
292 | 292 | |
293 | - if (false === $updated_option) { |
|
294 | - $this->logging->log('Permalink flush option was not properly set.', 'warning'); |
|
293 | + if ( false === $updated_option ) { |
|
294 | + $this->logging->log( 'Permalink flush option was not properly set.', 'warning' ); |
|
295 | 295 | } |
296 | 296 | } |
297 | 297 | |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | */ |
303 | 303 | public function get() |
304 | 304 | { |
305 | - return (string) get_site_option($this->option_name); |
|
305 | + return (string)get_site_option( $this->option_name ); |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | /** |
@@ -316,21 +316,21 @@ discard block |
||
316 | 316 | */ |
317 | 317 | private function get_trustedlogin_request() |
318 | 318 | { |
319 | - if (!isset($_POST[self::POST_ACTION_KEY], $_POST[self::POST_ENDPOINT_KEY], $_POST[self::POST_IDENTIFIER_KEY])) { |
|
319 | + if ( ! isset( $_POST[ self::POST_ACTION_KEY ], $_POST[ self::POST_ENDPOINT_KEY ], $_POST[ self::POST_IDENTIFIER_KEY ] ) ) { |
|
320 | 320 | return false; |
321 | 321 | } |
322 | 322 | |
323 | - if (self::POST_ACTION_VALUE !== $_POST[self::POST_ACTION_KEY]) { |
|
323 | + if ( self::POST_ACTION_VALUE !== $_POST[ self::POST_ACTION_KEY ] ) { |
|
324 | 324 | return false; |
325 | 325 | } |
326 | 326 | |
327 | - $_sanitized_post_data = array_map('sanitize_text_field', $_POST); |
|
327 | + $_sanitized_post_data = array_map( 'sanitize_text_field', $_POST ); |
|
328 | 328 | |
329 | 329 | // Return only the expected keys. |
330 | 330 | return [ |
331 | - self::POST_ACTION_KEY => $_sanitized_post_data[self::POST_ACTION_KEY], |
|
332 | - self::POST_ENDPOINT_KEY => $_sanitized_post_data[self::POST_ENDPOINT_KEY], |
|
333 | - self::POST_IDENTIFIER_KEY => $_sanitized_post_data[self::POST_IDENTIFIER_KEY], |
|
331 | + self::POST_ACTION_KEY => $_sanitized_post_data[ self::POST_ACTION_KEY ], |
|
332 | + self::POST_ENDPOINT_KEY => $_sanitized_post_data[ self::POST_ENDPOINT_KEY ], |
|
333 | + self::POST_IDENTIFIER_KEY => $_sanitized_post_data[ self::POST_IDENTIFIER_KEY ], |
|
334 | 334 | ]; |
335 | 335 | } |
336 | 336 | |
@@ -342,17 +342,17 @@ discard block |
||
342 | 342 | * |
343 | 343 | * @return string|WP_Error This hash will be used as an identifier in TrustedLogin SaaS. Or something went wrong. |
344 | 344 | */ |
345 | - public function generate_secret_id($site_identifier_hash, $endpoint_hash = '') |
|
345 | + public function generate_secret_id( $site_identifier_hash, $endpoint_hash = '' ) |
|
346 | 346 | { |
347 | - if (empty($endpoint_hash)) { |
|
348 | - $endpoint_hash = $this->get_hash($site_identifier_hash); |
|
347 | + if ( empty( $endpoint_hash ) ) { |
|
348 | + $endpoint_hash = $this->get_hash( $site_identifier_hash ); |
|
349 | 349 | } |
350 | 350 | |
351 | - if (is_wp_error($endpoint_hash)) { |
|
351 | + if ( is_wp_error( $endpoint_hash ) ) { |
|
352 | 352 | return $endpoint_hash; |
353 | 353 | } |
354 | 354 | |
355 | - return Encryption::hash($endpoint_hash.$site_identifier_hash); |
|
355 | + return Encryption::hash( $endpoint_hash . $site_identifier_hash ); |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | /** |
@@ -362,9 +362,9 @@ discard block |
||
362 | 362 | * |
363 | 363 | * @return string This hash will be used as the first part of the URL and also a part of $secret_id |
364 | 364 | */ |
365 | - public function get_hash($site_identifier_hash) |
|
365 | + public function get_hash( $site_identifier_hash ) |
|
366 | 366 | { |
367 | - return Encryption::hash(get_site_url().$site_identifier_hash); |
|
367 | + return Encryption::hash( get_site_url() . $site_identifier_hash ); |
|
368 | 368 | } |
369 | 369 | |
370 | 370 | /** |
@@ -374,11 +374,11 @@ discard block |
||
374 | 374 | * |
375 | 375 | * @return bool True: updated; False: didn't change, or didn't update |
376 | 376 | */ |
377 | - public function update($endpoint) |
|
377 | + public function update( $endpoint ) |
|
378 | 378 | { |
379 | - $updated = update_site_option($this->option_name, $endpoint); |
|
379 | + $updated = update_site_option( $this->option_name, $endpoint ); |
|
380 | 380 | |
381 | - update_site_option(self::PERMALINK_FLUSH_OPTION_NAME, 0); |
|
381 | + update_site_option( self::PERMALINK_FLUSH_OPTION_NAME, 0 ); |
|
382 | 382 | |
383 | 383 | return $updated; |
384 | 384 | } |
@@ -388,18 +388,18 @@ discard block |
||
388 | 388 | */ |
389 | 389 | public function delete() |
390 | 390 | { |
391 | - if (!get_site_option($this->option_name)) { |
|
392 | - $this->logging->log('Endpoint not deleted because it does not exist.', __METHOD__, 'info'); |
|
391 | + if ( ! get_site_option( $this->option_name ) ) { |
|
392 | + $this->logging->log( 'Endpoint not deleted because it does not exist.', __METHOD__, 'info' ); |
|
393 | 393 | |
394 | 394 | return; |
395 | 395 | } |
396 | 396 | |
397 | - delete_site_option($this->option_name); |
|
397 | + delete_site_option( $this->option_name ); |
|
398 | 398 | |
399 | - flush_rewrite_rules(false); |
|
399 | + flush_rewrite_rules( false ); |
|
400 | 400 | |
401 | - update_site_option(self::PERMALINK_FLUSH_OPTION_NAME, 0); |
|
401 | + update_site_option( self::PERMALINK_FLUSH_OPTION_NAME, 0 ); |
|
402 | 402 | |
403 | - $this->logging->log('Endpoint removed & rewrites flushed', __METHOD__, 'info'); |
|
403 | + $this->logging->log( 'Endpoint removed & rewrites flushed', __METHOD__, 'info' ); |
|
404 | 404 | } |
405 | 405 | } |
@@ -14,8 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | use WP_Error; |
16 | 16 | |
17 | -class Endpoint |
|
18 | -{ |
|
17 | +class Endpoint { |
|
19 | 18 | /** |
20 | 19 | * @var string The query string parameter used to revoke users |
21 | 20 | */ |
@@ -67,8 +66,7 @@ discard block |
||
67 | 66 | /** |
68 | 67 | * Logger constructor. |
69 | 68 | */ |
70 | - public function __construct(Config $config, Logging $logging) |
|
71 | - { |
|
69 | + public function __construct(Config $config, Logging $logging) { |
|
72 | 70 | $this->config = $config; |
73 | 71 | $this->logging = $logging; |
74 | 72 | $this->support_user = new SupportUser($config, $logging); |
@@ -88,8 +86,7 @@ discard block |
||
88 | 86 | ); |
89 | 87 | } |
90 | 88 | |
91 | - public function init() |
|
92 | - { |
|
89 | + public function init() { |
|
93 | 90 | if (did_action('init')) { |
94 | 91 | $this->add(); |
95 | 92 | } else { |
@@ -108,8 +105,7 @@ discard block |
||
108 | 105 | * |
109 | 106 | * @return void |
110 | 107 | */ |
111 | - public function maybe_login_support() |
|
112 | - { |
|
108 | + public function maybe_login_support() { |
|
113 | 109 | |
114 | 110 | // The user's already logged-in; don't override that login. |
115 | 111 | if (is_user_logged_in()) { |
@@ -195,8 +191,7 @@ discard block |
||
195 | 191 | * |
196 | 192 | * @since 1.0.0 |
197 | 193 | */ |
198 | - public function maybe_revoke_support() |
|
199 | - { |
|
194 | + public function maybe_revoke_support() { |
|
200 | 195 | if (!isset($_REQUEST[self::REVOKE_SUPPORT_QUERY_PARAM])) { |
201 | 196 | return; |
202 | 197 | } |
@@ -262,8 +257,7 @@ discard block |
||
262 | 257 | * @since 1.0.0 |
263 | 258 | * @see Endpoint::init() Called via `init` hook |
264 | 259 | */ |
265 | - public function add() |
|
266 | - { |
|
260 | + public function add() { |
|
267 | 261 | |
268 | 262 | // Only add the endpoint if a TrustedLogin request is being made. |
269 | 263 | if (!$this->get_trustedlogin_request()) { |
@@ -300,8 +294,7 @@ discard block |
||
300 | 294 | * |
301 | 295 | * @return string |
302 | 296 | */ |
303 | - public function get() |
|
304 | - { |
|
297 | + public function get() { |
|
305 | 298 | return (string) get_site_option($this->option_name); |
306 | 299 | } |
307 | 300 | |
@@ -314,8 +307,7 @@ discard block |
||
314 | 307 | * |
315 | 308 | * @return false|array{action:string, endpoint:string, identifier: string} If false, the request is not from TrustedLogin. If the request is from TrustedLogin, an array with the posted keys, santiized. |
316 | 309 | */ |
317 | - private function get_trustedlogin_request() |
|
318 | - { |
|
310 | + private function get_trustedlogin_request() { |
|
319 | 311 | if (!isset($_POST[self::POST_ACTION_KEY], $_POST[self::POST_ENDPOINT_KEY], $_POST[self::POST_IDENTIFIER_KEY])) { |
320 | 312 | return false; |
321 | 313 | } |
@@ -342,8 +334,7 @@ discard block |
||
342 | 334 | * |
343 | 335 | * @return string|WP_Error This hash will be used as an identifier in TrustedLogin SaaS. Or something went wrong. |
344 | 336 | */ |
345 | - public function generate_secret_id($site_identifier_hash, $endpoint_hash = '') |
|
346 | - { |
|
337 | + public function generate_secret_id($site_identifier_hash, $endpoint_hash = '') { |
|
347 | 338 | if (empty($endpoint_hash)) { |
348 | 339 | $endpoint_hash = $this->get_hash($site_identifier_hash); |
349 | 340 | } |
@@ -362,8 +353,7 @@ discard block |
||
362 | 353 | * |
363 | 354 | * @return string This hash will be used as the first part of the URL and also a part of $secret_id |
364 | 355 | */ |
365 | - public function get_hash($site_identifier_hash) |
|
366 | - { |
|
356 | + public function get_hash($site_identifier_hash) { |
|
367 | 357 | return Encryption::hash(get_site_url().$site_identifier_hash); |
368 | 358 | } |
369 | 359 | |
@@ -374,8 +364,7 @@ discard block |
||
374 | 364 | * |
375 | 365 | * @return bool True: updated; False: didn't change, or didn't update |
376 | 366 | */ |
377 | - public function update($endpoint) |
|
378 | - { |
|
367 | + public function update($endpoint) { |
|
379 | 368 | $updated = update_site_option($this->option_name, $endpoint); |
380 | 369 | |
381 | 370 | update_site_option(self::PERMALINK_FLUSH_OPTION_NAME, 0); |
@@ -386,8 +375,7 @@ discard block |
||
386 | 375 | /** |
387 | 376 | * @return void |
388 | 377 | */ |
389 | - public function delete() |
|
390 | - { |
|
378 | + public function delete() { |
|
391 | 379 | if (!get_site_option($this->option_name)) { |
392 | 380 | $this->logging->log('Endpoint not deleted because it does not exist.', __METHOD__, 'info'); |
393 | 381 |
@@ -278,7 +278,7 @@ |
||
278 | 278 | |
279 | 279 | add_rewrite_endpoint($endpoint, EP_ROOT); |
280 | 280 | |
281 | - $this->logging->log("Endpoint {$endpoint} added.", __METHOD__, 'debug'); |
|
281 | + $this->logging->log("endpoint {$endpoint} added.", __METHOD__, 'debug'); |
|
282 | 282 | |
283 | 283 | if (get_site_option(self::PERMALINK_FLUSH_OPTION_NAME)) { |
284 | 284 | return; |
@@ -14,207 +14,207 @@ |
||
14 | 14 | |
15 | 15 | // Exit if accessed directly |
16 | 16 | if (!defined('ABSPATH')) { |
17 | - exit; |
|
17 | + exit; |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | use WP_Error; |
21 | 21 | |
22 | 22 | final class SupportRole |
23 | 23 | { |
24 | - /** |
|
25 | - * @var Config |
|
26 | - */ |
|
27 | - private $config; |
|
28 | - |
|
29 | - /** |
|
30 | - * @var Logging |
|
31 | - */ |
|
32 | - private $logging; |
|
33 | - |
|
34 | - /** |
|
35 | - * @var string The namespaced name of the new Role to be created for Support Agents |
|
36 | - * |
|
37 | - * @example '{vendor/namespace}-support' |
|
38 | - */ |
|
39 | - private $role_name; |
|
40 | - |
|
41 | - /** |
|
42 | - * @var array These capabilities will never be allowed for users created by TrustedLogin |
|
43 | - * |
|
44 | - * @since 1.0.0 |
|
45 | - */ |
|
46 | - public static $prevented_caps = [ |
|
47 | - 'create_users', |
|
48 | - 'delete_users', |
|
49 | - 'edit_users', |
|
50 | - 'list_users', |
|
51 | - 'promote_users', |
|
52 | - 'delete_site', |
|
53 | - 'remove_users', |
|
54 | - ]; |
|
55 | - |
|
56 | - /** |
|
57 | - * SupportUser constructor. |
|
58 | - */ |
|
59 | - public function __construct(Config $config, Logging $logging) |
|
60 | - { |
|
61 | - $this->config = $config; |
|
62 | - $this->logging = $logging; |
|
63 | - $this->role_name = $this->set_name(); |
|
64 | - } |
|
65 | - |
|
66 | - /** |
|
67 | - * Get the name (slug) of the role that should be cloned for the TL support role. |
|
68 | - * |
|
69 | - * @return string |
|
70 | - */ |
|
71 | - public function get_cloned_name() |
|
72 | - { |
|
73 | - $roles = $this->config->get_setting('role', 'editor'); |
|
74 | - |
|
75 | - // TODO: Support multiple roles |
|
76 | - $role = is_array($roles) ? array_key_first($roles) : $roles; |
|
77 | - |
|
78 | - return (string) $role; |
|
79 | - } |
|
80 | - |
|
81 | - /** |
|
82 | - * @return string |
|
83 | - */ |
|
84 | - public function get_name() |
|
85 | - { |
|
86 | - return (string) $this->role_name; |
|
87 | - } |
|
88 | - |
|
89 | - /** |
|
90 | - * @return string Sanitized with {@uses sanitize_title_with_dashes} |
|
91 | - */ |
|
92 | - private function set_name() |
|
93 | - { |
|
94 | - $default = $this->config->ns().'-support'; |
|
95 | - |
|
96 | - $role_name = apply_filters( |
|
97 | - 'trustedlogin/'.$this->config->ns().'/support_role', |
|
98 | - $default, |
|
99 | - $this |
|
100 | - ); |
|
101 | - |
|
102 | - if (!is_string($role_name)) { |
|
103 | - $role_name = $default; |
|
104 | - } |
|
105 | - |
|
106 | - return sanitize_title_with_dashes($role_name); |
|
107 | - } |
|
108 | - |
|
109 | - /** |
|
110 | - * Creates the custom Support Role if it doesn't already exist. |
|
111 | - * |
|
112 | - * @since 1.0.0 |
|
113 | - * @since 1.0.0 removed excluded_caps from generated role |
|
114 | - * |
|
115 | - * @param string $new_role_slug The slug for the new role (optional). Default: {@see SupportRole::get_name()} |
|
116 | - * @param string $clone_role_slug The slug for the role to clone (optional). Default: {@see SupportRole::get_cloned_name()}. |
|
117 | - * |
|
118 | - * @return \WP_Role|\WP_Error Created/pre-existing role, if successful. WP_Error if failure. |
|
119 | - */ |
|
120 | - public function create($new_role_slug = '', $clone_role_slug = '') |
|
121 | - { |
|
122 | - if (empty($new_role_slug)) { |
|
123 | - $new_role_slug = $this->get_name(); |
|
124 | - } |
|
125 | - |
|
126 | - if (!is_string($new_role_slug)) { |
|
127 | - return new WP_Error('new_role_slug_not_string', 'The slug for the new support role must be a string.'); |
|
128 | - } |
|
129 | - |
|
130 | - if (empty($clone_role_slug)) { |
|
131 | - $clone_role_slug = $this->get_cloned_name(); |
|
132 | - } |
|
133 | - |
|
134 | - if (!is_string($clone_role_slug)) { |
|
135 | - return new WP_Error('cloned_role_slug_not_string', 'The slug for the cloned support role must be a string.'); |
|
136 | - } |
|
137 | - |
|
138 | - $role_exists = get_role($new_role_slug); |
|
139 | - |
|
140 | - if ($role_exists) { |
|
141 | - $this->logging->log('Not creating user role; it already exists', __METHOD__, 'notice'); |
|
142 | - |
|
143 | - return $role_exists; |
|
144 | - } |
|
145 | - |
|
146 | - $this->logging->log('New role slug: '.$new_role_slug.', Clone role slug: '.$clone_role_slug, __METHOD__, 'debug'); |
|
147 | - |
|
148 | - $old_role = get_role($clone_role_slug); |
|
149 | - |
|
150 | - if (empty($old_role)) { |
|
151 | - return new WP_Error('role_does_not_exist', 'Error: the role to clone does not exist: '.$clone_role_slug); |
|
152 | - } |
|
153 | - |
|
154 | - $capabilities = $old_role->capabilities; |
|
155 | - |
|
156 | - $add_caps = $this->config->get_setting('caps/add'); |
|
157 | - |
|
158 | - foreach ((array) $add_caps as $add_cap => $reason) { |
|
159 | - $capabilities[$add_cap] = true; |
|
160 | - } |
|
161 | - |
|
162 | - // These roles should never be assigned to TrustedLogin roles. |
|
163 | - foreach (self::$prevented_caps as $prevented_cap) { |
|
164 | - unset($capabilities[$prevented_cap]); |
|
165 | - } |
|
166 | - |
|
167 | - /** |
|
168 | - * @filter trustedlogin/{namespace}/support_role/display_name Modify the display name of the created support role |
|
169 | - */ |
|
170 | - $role_display_name = apply_filters('trustedlogin/'.$this->config->ns().'/support_role/display_name', sprintf(esc_html__('%s Support', 'gravityview'), $this->config->get_setting('vendor/title')), $this); |
|
171 | - |
|
172 | - $new_role = add_role($new_role_slug, $role_display_name, $capabilities); |
|
173 | - |
|
174 | - if (!$new_role) { |
|
175 | - return new WP_Error( |
|
176 | - 'add_role_failed', |
|
177 | - 'Error: the role was not created using add_role()', |
|
178 | - compact( |
|
179 | - 'new_role_slug', |
|
180 | - 'capabilities', |
|
181 | - 'role_display_name' |
|
182 | - ) |
|
183 | - ); |
|
184 | - } |
|
185 | - |
|
186 | - $remove_caps = $this->config->get_setting('caps/remove'); |
|
187 | - |
|
188 | - if (!empty($remove_caps)) { |
|
189 | - foreach ($remove_caps as $remove_cap => $description) { |
|
190 | - $new_role->remove_cap($remove_cap); |
|
191 | - $this->logging->log('Capability '.$remove_cap.' removed from role.', __METHOD__, 'info'); |
|
192 | - } |
|
193 | - } |
|
194 | - |
|
195 | - return $new_role; |
|
196 | - } |
|
197 | - |
|
198 | - /** |
|
199 | - * @return bool|null Null: Role wasn't found; True: Removing role succeeded; False: Role wasn't deleted successfully. |
|
200 | - */ |
|
201 | - public function delete() |
|
202 | - { |
|
203 | - if (!get_role($this->get_name())) { |
|
204 | - return null; |
|
205 | - } |
|
206 | - |
|
207 | - // Returns void; no way to tell if successful |
|
208 | - remove_role($this->get_name()); |
|
209 | - |
|
210 | - if (get_role($this->get_name())) { |
|
211 | - $this->logging->log('Role '.$this->get_name().' was not removed successfully.', __METHOD__, 'error'); |
|
212 | - |
|
213 | - return false; |
|
214 | - } |
|
215 | - |
|
216 | - $this->logging->log('Role '.$this->get_name().' removed.', __METHOD__, 'info'); |
|
24 | + /** |
|
25 | + * @var Config |
|
26 | + */ |
|
27 | + private $config; |
|
28 | + |
|
29 | + /** |
|
30 | + * @var Logging |
|
31 | + */ |
|
32 | + private $logging; |
|
33 | + |
|
34 | + /** |
|
35 | + * @var string The namespaced name of the new Role to be created for Support Agents |
|
36 | + * |
|
37 | + * @example '{vendor/namespace}-support' |
|
38 | + */ |
|
39 | + private $role_name; |
|
40 | + |
|
41 | + /** |
|
42 | + * @var array These capabilities will never be allowed for users created by TrustedLogin |
|
43 | + * |
|
44 | + * @since 1.0.0 |
|
45 | + */ |
|
46 | + public static $prevented_caps = [ |
|
47 | + 'create_users', |
|
48 | + 'delete_users', |
|
49 | + 'edit_users', |
|
50 | + 'list_users', |
|
51 | + 'promote_users', |
|
52 | + 'delete_site', |
|
53 | + 'remove_users', |
|
54 | + ]; |
|
55 | + |
|
56 | + /** |
|
57 | + * SupportUser constructor. |
|
58 | + */ |
|
59 | + public function __construct(Config $config, Logging $logging) |
|
60 | + { |
|
61 | + $this->config = $config; |
|
62 | + $this->logging = $logging; |
|
63 | + $this->role_name = $this->set_name(); |
|
64 | + } |
|
65 | + |
|
66 | + /** |
|
67 | + * Get the name (slug) of the role that should be cloned for the TL support role. |
|
68 | + * |
|
69 | + * @return string |
|
70 | + */ |
|
71 | + public function get_cloned_name() |
|
72 | + { |
|
73 | + $roles = $this->config->get_setting('role', 'editor'); |
|
74 | + |
|
75 | + // TODO: Support multiple roles |
|
76 | + $role = is_array($roles) ? array_key_first($roles) : $roles; |
|
77 | + |
|
78 | + return (string) $role; |
|
79 | + } |
|
80 | + |
|
81 | + /** |
|
82 | + * @return string |
|
83 | + */ |
|
84 | + public function get_name() |
|
85 | + { |
|
86 | + return (string) $this->role_name; |
|
87 | + } |
|
88 | + |
|
89 | + /** |
|
90 | + * @return string Sanitized with {@uses sanitize_title_with_dashes} |
|
91 | + */ |
|
92 | + private function set_name() |
|
93 | + { |
|
94 | + $default = $this->config->ns().'-support'; |
|
95 | + |
|
96 | + $role_name = apply_filters( |
|
97 | + 'trustedlogin/'.$this->config->ns().'/support_role', |
|
98 | + $default, |
|
99 | + $this |
|
100 | + ); |
|
101 | + |
|
102 | + if (!is_string($role_name)) { |
|
103 | + $role_name = $default; |
|
104 | + } |
|
105 | + |
|
106 | + return sanitize_title_with_dashes($role_name); |
|
107 | + } |
|
108 | + |
|
109 | + /** |
|
110 | + * Creates the custom Support Role if it doesn't already exist. |
|
111 | + * |
|
112 | + * @since 1.0.0 |
|
113 | + * @since 1.0.0 removed excluded_caps from generated role |
|
114 | + * |
|
115 | + * @param string $new_role_slug The slug for the new role (optional). Default: {@see SupportRole::get_name()} |
|
116 | + * @param string $clone_role_slug The slug for the role to clone (optional). Default: {@see SupportRole::get_cloned_name()}. |
|
117 | + * |
|
118 | + * @return \WP_Role|\WP_Error Created/pre-existing role, if successful. WP_Error if failure. |
|
119 | + */ |
|
120 | + public function create($new_role_slug = '', $clone_role_slug = '') |
|
121 | + { |
|
122 | + if (empty($new_role_slug)) { |
|
123 | + $new_role_slug = $this->get_name(); |
|
124 | + } |
|
125 | + |
|
126 | + if (!is_string($new_role_slug)) { |
|
127 | + return new WP_Error('new_role_slug_not_string', 'The slug for the new support role must be a string.'); |
|
128 | + } |
|
129 | + |
|
130 | + if (empty($clone_role_slug)) { |
|
131 | + $clone_role_slug = $this->get_cloned_name(); |
|
132 | + } |
|
133 | + |
|
134 | + if (!is_string($clone_role_slug)) { |
|
135 | + return new WP_Error('cloned_role_slug_not_string', 'The slug for the cloned support role must be a string.'); |
|
136 | + } |
|
137 | + |
|
138 | + $role_exists = get_role($new_role_slug); |
|
139 | + |
|
140 | + if ($role_exists) { |
|
141 | + $this->logging->log('Not creating user role; it already exists', __METHOD__, 'notice'); |
|
142 | + |
|
143 | + return $role_exists; |
|
144 | + } |
|
145 | + |
|
146 | + $this->logging->log('New role slug: '.$new_role_slug.', Clone role slug: '.$clone_role_slug, __METHOD__, 'debug'); |
|
147 | + |
|
148 | + $old_role = get_role($clone_role_slug); |
|
149 | + |
|
150 | + if (empty($old_role)) { |
|
151 | + return new WP_Error('role_does_not_exist', 'Error: the role to clone does not exist: '.$clone_role_slug); |
|
152 | + } |
|
153 | + |
|
154 | + $capabilities = $old_role->capabilities; |
|
155 | + |
|
156 | + $add_caps = $this->config->get_setting('caps/add'); |
|
157 | + |
|
158 | + foreach ((array) $add_caps as $add_cap => $reason) { |
|
159 | + $capabilities[$add_cap] = true; |
|
160 | + } |
|
161 | + |
|
162 | + // These roles should never be assigned to TrustedLogin roles. |
|
163 | + foreach (self::$prevented_caps as $prevented_cap) { |
|
164 | + unset($capabilities[$prevented_cap]); |
|
165 | + } |
|
166 | + |
|
167 | + /** |
|
168 | + * @filter trustedlogin/{namespace}/support_role/display_name Modify the display name of the created support role |
|
169 | + */ |
|
170 | + $role_display_name = apply_filters('trustedlogin/'.$this->config->ns().'/support_role/display_name', sprintf(esc_html__('%s Support', 'gravityview'), $this->config->get_setting('vendor/title')), $this); |
|
171 | + |
|
172 | + $new_role = add_role($new_role_slug, $role_display_name, $capabilities); |
|
173 | + |
|
174 | + if (!$new_role) { |
|
175 | + return new WP_Error( |
|
176 | + 'add_role_failed', |
|
177 | + 'Error: the role was not created using add_role()', |
|
178 | + compact( |
|
179 | + 'new_role_slug', |
|
180 | + 'capabilities', |
|
181 | + 'role_display_name' |
|
182 | + ) |
|
183 | + ); |
|
184 | + } |
|
185 | + |
|
186 | + $remove_caps = $this->config->get_setting('caps/remove'); |
|
187 | + |
|
188 | + if (!empty($remove_caps)) { |
|
189 | + foreach ($remove_caps as $remove_cap => $description) { |
|
190 | + $new_role->remove_cap($remove_cap); |
|
191 | + $this->logging->log('Capability '.$remove_cap.' removed from role.', __METHOD__, 'info'); |
|
192 | + } |
|
193 | + } |
|
194 | + |
|
195 | + return $new_role; |
|
196 | + } |
|
197 | + |
|
198 | + /** |
|
199 | + * @return bool|null Null: Role wasn't found; True: Removing role succeeded; False: Role wasn't deleted successfully. |
|
200 | + */ |
|
201 | + public function delete() |
|
202 | + { |
|
203 | + if (!get_role($this->get_name())) { |
|
204 | + return null; |
|
205 | + } |
|
206 | + |
|
207 | + // Returns void; no way to tell if successful |
|
208 | + remove_role($this->get_name()); |
|
209 | + |
|
210 | + if (get_role($this->get_name())) { |
|
211 | + $this->logging->log('Role '.$this->get_name().' was not removed successfully.', __METHOD__, 'error'); |
|
212 | + |
|
213 | + return false; |
|
214 | + } |
|
215 | + |
|
216 | + $this->logging->log('Role '.$this->get_name().' removed.', __METHOD__, 'info'); |
|
217 | 217 | |
218 | - return true; |
|
219 | - } |
|
218 | + return true; |
|
219 | + } |
|
220 | 220 | } |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | namespace GravityView\TrustedLogin; |
14 | 14 | |
15 | 15 | // Exit if accessed directly |
16 | -if (!defined('ABSPATH')) { |
|
16 | +if ( ! defined( 'ABSPATH' ) ) { |
|
17 | 17 | exit; |
18 | 18 | } |
19 | 19 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | /** |
57 | 57 | * SupportUser constructor. |
58 | 58 | */ |
59 | - public function __construct(Config $config, Logging $logging) |
|
59 | + public function __construct( Config $config, Logging $logging ) |
|
60 | 60 | { |
61 | 61 | $this->config = $config; |
62 | 62 | $this->logging = $logging; |
@@ -70,12 +70,12 @@ discard block |
||
70 | 70 | */ |
71 | 71 | public function get_cloned_name() |
72 | 72 | { |
73 | - $roles = $this->config->get_setting('role', 'editor'); |
|
73 | + $roles = $this->config->get_setting( 'role', 'editor' ); |
|
74 | 74 | |
75 | 75 | // TODO: Support multiple roles |
76 | - $role = is_array($roles) ? array_key_first($roles) : $roles; |
|
76 | + $role = is_array( $roles ) ? array_key_first( $roles ) : $roles; |
|
77 | 77 | |
78 | - return (string) $role; |
|
78 | + return (string)$role; |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | */ |
84 | 84 | public function get_name() |
85 | 85 | { |
86 | - return (string) $this->role_name; |
|
86 | + return (string)$this->role_name; |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -91,19 +91,19 @@ discard block |
||
91 | 91 | */ |
92 | 92 | private function set_name() |
93 | 93 | { |
94 | - $default = $this->config->ns().'-support'; |
|
94 | + $default = $this->config->ns() . '-support'; |
|
95 | 95 | |
96 | 96 | $role_name = apply_filters( |
97 | - 'trustedlogin/'.$this->config->ns().'/support_role', |
|
97 | + 'trustedlogin/' . $this->config->ns() . '/support_role', |
|
98 | 98 | $default, |
99 | 99 | $this |
100 | 100 | ); |
101 | 101 | |
102 | - if (!is_string($role_name)) { |
|
102 | + if ( ! is_string( $role_name ) ) { |
|
103 | 103 | $role_name = $default; |
104 | 104 | } |
105 | 105 | |
106 | - return sanitize_title_with_dashes($role_name); |
|
106 | + return sanitize_title_with_dashes( $role_name ); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -117,61 +117,61 @@ discard block |
||
117 | 117 | * |
118 | 118 | * @return \WP_Role|\WP_Error Created/pre-existing role, if successful. WP_Error if failure. |
119 | 119 | */ |
120 | - public function create($new_role_slug = '', $clone_role_slug = '') |
|
120 | + public function create( $new_role_slug = '', $clone_role_slug = '' ) |
|
121 | 121 | { |
122 | - if (empty($new_role_slug)) { |
|
122 | + if ( empty( $new_role_slug ) ) { |
|
123 | 123 | $new_role_slug = $this->get_name(); |
124 | 124 | } |
125 | 125 | |
126 | - if (!is_string($new_role_slug)) { |
|
127 | - return new WP_Error('new_role_slug_not_string', 'The slug for the new support role must be a string.'); |
|
126 | + if ( ! is_string( $new_role_slug ) ) { |
|
127 | + return new WP_Error( 'new_role_slug_not_string', 'The slug for the new support role must be a string.' ); |
|
128 | 128 | } |
129 | 129 | |
130 | - if (empty($clone_role_slug)) { |
|
130 | + if ( empty( $clone_role_slug ) ) { |
|
131 | 131 | $clone_role_slug = $this->get_cloned_name(); |
132 | 132 | } |
133 | 133 | |
134 | - if (!is_string($clone_role_slug)) { |
|
135 | - return new WP_Error('cloned_role_slug_not_string', 'The slug for the cloned support role must be a string.'); |
|
134 | + if ( ! is_string( $clone_role_slug ) ) { |
|
135 | + return new WP_Error( 'cloned_role_slug_not_string', 'The slug for the cloned support role must be a string.' ); |
|
136 | 136 | } |
137 | 137 | |
138 | - $role_exists = get_role($new_role_slug); |
|
138 | + $role_exists = get_role( $new_role_slug ); |
|
139 | 139 | |
140 | - if ($role_exists) { |
|
141 | - $this->logging->log('Not creating user role; it already exists', __METHOD__, 'notice'); |
|
140 | + if ( $role_exists ) { |
|
141 | + $this->logging->log( 'Not creating user role; it already exists', __METHOD__, 'notice' ); |
|
142 | 142 | |
143 | 143 | return $role_exists; |
144 | 144 | } |
145 | 145 | |
146 | - $this->logging->log('New role slug: '.$new_role_slug.', Clone role slug: '.$clone_role_slug, __METHOD__, 'debug'); |
|
146 | + $this->logging->log( 'New role slug: ' . $new_role_slug . ', Clone role slug: ' . $clone_role_slug, __METHOD__, 'debug' ); |
|
147 | 147 | |
148 | - $old_role = get_role($clone_role_slug); |
|
148 | + $old_role = get_role( $clone_role_slug ); |
|
149 | 149 | |
150 | - if (empty($old_role)) { |
|
151 | - return new WP_Error('role_does_not_exist', 'Error: the role to clone does not exist: '.$clone_role_slug); |
|
150 | + if ( empty( $old_role ) ) { |
|
151 | + return new WP_Error( 'role_does_not_exist', 'Error: the role to clone does not exist: ' . $clone_role_slug ); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | $capabilities = $old_role->capabilities; |
155 | 155 | |
156 | - $add_caps = $this->config->get_setting('caps/add'); |
|
156 | + $add_caps = $this->config->get_setting( 'caps/add' ); |
|
157 | 157 | |
158 | - foreach ((array) $add_caps as $add_cap => $reason) { |
|
159 | - $capabilities[$add_cap] = true; |
|
158 | + foreach ( (array)$add_caps as $add_cap => $reason ) { |
|
159 | + $capabilities[ $add_cap ] = true; |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | // These roles should never be assigned to TrustedLogin roles. |
163 | - foreach (self::$prevented_caps as $prevented_cap) { |
|
164 | - unset($capabilities[$prevented_cap]); |
|
163 | + foreach ( self::$prevented_caps as $prevented_cap ) { |
|
164 | + unset( $capabilities[ $prevented_cap ] ); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
168 | 168 | * @filter trustedlogin/{namespace}/support_role/display_name Modify the display name of the created support role |
169 | 169 | */ |
170 | - $role_display_name = apply_filters('trustedlogin/'.$this->config->ns().'/support_role/display_name', sprintf(esc_html__('%s Support', 'gravityview'), $this->config->get_setting('vendor/title')), $this); |
|
170 | + $role_display_name = apply_filters( 'trustedlogin/' . $this->config->ns() . '/support_role/display_name', sprintf( esc_html__( '%s Support', 'gravityview' ), $this->config->get_setting( 'vendor/title' ) ), $this ); |
|
171 | 171 | |
172 | - $new_role = add_role($new_role_slug, $role_display_name, $capabilities); |
|
172 | + $new_role = add_role( $new_role_slug, $role_display_name, $capabilities ); |
|
173 | 173 | |
174 | - if (!$new_role) { |
|
174 | + if ( ! $new_role ) { |
|
175 | 175 | return new WP_Error( |
176 | 176 | 'add_role_failed', |
177 | 177 | 'Error: the role was not created using add_role()', |
@@ -183,12 +183,12 @@ discard block |
||
183 | 183 | ); |
184 | 184 | } |
185 | 185 | |
186 | - $remove_caps = $this->config->get_setting('caps/remove'); |
|
186 | + $remove_caps = $this->config->get_setting( 'caps/remove' ); |
|
187 | 187 | |
188 | - if (!empty($remove_caps)) { |
|
189 | - foreach ($remove_caps as $remove_cap => $description) { |
|
190 | - $new_role->remove_cap($remove_cap); |
|
191 | - $this->logging->log('Capability '.$remove_cap.' removed from role.', __METHOD__, 'info'); |
|
188 | + if ( ! empty( $remove_caps ) ) { |
|
189 | + foreach ( $remove_caps as $remove_cap => $description ) { |
|
190 | + $new_role->remove_cap( $remove_cap ); |
|
191 | + $this->logging->log( 'Capability ' . $remove_cap . ' removed from role.', __METHOD__, 'info' ); |
|
192 | 192 | } |
193 | 193 | } |
194 | 194 | |
@@ -200,20 +200,20 @@ discard block |
||
200 | 200 | */ |
201 | 201 | public function delete() |
202 | 202 | { |
203 | - if (!get_role($this->get_name())) { |
|
203 | + if ( ! get_role( $this->get_name() ) ) { |
|
204 | 204 | return null; |
205 | 205 | } |
206 | 206 | |
207 | 207 | // Returns void; no way to tell if successful |
208 | - remove_role($this->get_name()); |
|
208 | + remove_role( $this->get_name() ); |
|
209 | 209 | |
210 | - if (get_role($this->get_name())) { |
|
211 | - $this->logging->log('Role '.$this->get_name().' was not removed successfully.', __METHOD__, 'error'); |
|
210 | + if ( get_role( $this->get_name() ) ) { |
|
211 | + $this->logging->log( 'Role ' . $this->get_name() . ' was not removed successfully.', __METHOD__, 'error' ); |
|
212 | 212 | |
213 | 213 | return false; |
214 | 214 | } |
215 | 215 | |
216 | - $this->logging->log('Role '.$this->get_name().' removed.', __METHOD__, 'info'); |
|
216 | + $this->logging->log( 'Role ' . $this->get_name() . ' removed.', __METHOD__, 'info' ); |
|
217 | 217 | |
218 | 218 | return true; |
219 | 219 | } |
@@ -19,8 +19,7 @@ discard block |
||
19 | 19 | |
20 | 20 | use WP_Error; |
21 | 21 | |
22 | -final class SupportRole |
|
23 | -{ |
|
22 | +final class SupportRole { |
|
24 | 23 | /** |
25 | 24 | * @var Config |
26 | 25 | */ |
@@ -56,8 +55,7 @@ discard block |
||
56 | 55 | /** |
57 | 56 | * SupportUser constructor. |
58 | 57 | */ |
59 | - public function __construct(Config $config, Logging $logging) |
|
60 | - { |
|
58 | + public function __construct(Config $config, Logging $logging) { |
|
61 | 59 | $this->config = $config; |
62 | 60 | $this->logging = $logging; |
63 | 61 | $this->role_name = $this->set_name(); |
@@ -68,8 +66,7 @@ discard block |
||
68 | 66 | * |
69 | 67 | * @return string |
70 | 68 | */ |
71 | - public function get_cloned_name() |
|
72 | - { |
|
69 | + public function get_cloned_name() { |
|
73 | 70 | $roles = $this->config->get_setting('role', 'editor'); |
74 | 71 | |
75 | 72 | // TODO: Support multiple roles |
@@ -81,16 +78,14 @@ discard block |
||
81 | 78 | /** |
82 | 79 | * @return string |
83 | 80 | */ |
84 | - public function get_name() |
|
85 | - { |
|
81 | + public function get_name() { |
|
86 | 82 | return (string) $this->role_name; |
87 | 83 | } |
88 | 84 | |
89 | 85 | /** |
90 | 86 | * @return string Sanitized with {@uses sanitize_title_with_dashes} |
91 | 87 | */ |
92 | - private function set_name() |
|
93 | - { |
|
88 | + private function set_name() { |
|
94 | 89 | $default = $this->config->ns().'-support'; |
95 | 90 | |
96 | 91 | $role_name = apply_filters( |
@@ -117,8 +112,7 @@ discard block |
||
117 | 112 | * |
118 | 113 | * @return \WP_Role|\WP_Error Created/pre-existing role, if successful. WP_Error if failure. |
119 | 114 | */ |
120 | - public function create($new_role_slug = '', $clone_role_slug = '') |
|
121 | - { |
|
115 | + public function create($new_role_slug = '', $clone_role_slug = '') { |
|
122 | 116 | if (empty($new_role_slug)) { |
123 | 117 | $new_role_slug = $this->get_name(); |
124 | 118 | } |
@@ -198,8 +192,7 @@ discard block |
||
198 | 192 | /** |
199 | 193 | * @return bool|null Null: Role wasn't found; True: Removing role succeeded; False: Role wasn't deleted successfully. |
200 | 194 | */ |
201 | - public function delete() |
|
202 | - { |
|
195 | + public function delete() { |
|
203 | 196 | if (!get_role($this->get_name())) { |
204 | 197 | return null; |
205 | 198 | } |