PluginProbe
Extendify / 3.2.2
Extendify v3.2.2
3.2.2 3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 All 128 releases
extendify / app / Mcp / Availability.php

Availability.php in Extendify 3.2.2, at app/Mcp/Availability.php

65 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Whether connections work on this site at all.
5 */
6
7 namespace Extendify\Mcp;
8
9 defined('ABSPATH') || die('No direct access.');
10
11 use Extendify\PartnerData;
12
13 /**
14 * An administrator can undo their own switch, never the partner's.
15 */
16 class Availability
17 {
18 // phpcs:ignore PSR12.Properties.ConstantVisibility.NotFound
19 const OPTION = 'extendify_mcp_turned_off';
20
21 /**
22 * @return boolean
23 */
24 public static function offered()
25 {
26 // A blocked partner's last mcpConfig would otherwise keep every token working.
27 return PartnerData::setting('license') === 'active' && Allowed::reads() !== Allowed::NONE;
28 }
29
30 /**
31 * @return boolean
32 */
33 public static function live()
34 {
35 return self::offered() && !self::turnedOff();
36 }
37
38 /**
39 * @return array|null
40 */
41 public static function turnedOff()
42 {
43 $off = \get_option(self::OPTION);
44
45 return is_array($off) ? $off : null;
46 }
47
48 /**
49 * @param integer $userId - The administrator turning connections off.
50 * @return void
51 */
52 public static function turnOff($userId)
53 {
54 \update_option(self::OPTION, ['by' => (int) $userId, 'at' => time()], false);
55 }
56
57 /**
58 * @return void
59 */
60 public static function turnOn()
61 {
62 \delete_option(self::OPTION);
63 }
64 }
65