1 | <?php |
||
30 | class WordPoints_Hooks extends WordPoints_App { |
||
31 | |||
32 | /** |
||
33 | * Whether network-wide mode is turned on. |
||
34 | * |
||
35 | * @since 1.0.0 |
||
36 | * |
||
37 | * @var bool |
||
38 | */ |
||
39 | protected $network_mode = null; |
||
40 | |||
41 | /** |
||
42 | * Register the sub apps when the app is constructed. |
||
43 | * |
||
44 | * @since 1.0.0 |
||
45 | */ |
||
46 | protected function init() { |
||
59 | |||
60 | /** |
||
61 | * Gets whether network-wide mode is on. |
||
62 | * |
||
63 | * @since 1.0.0 |
||
64 | * |
||
65 | * @return bool Whether network-wide mode is on. |
||
66 | */ |
||
67 | public function get_network_mode() { |
||
89 | |||
90 | /** |
||
91 | * Sets whether network-wide mode is on. |
||
92 | * |
||
93 | * This function should not be used, especially to turn network mode off when |
||
94 | * WordPoints has turned it on. I won't even say, "Unless you really know what |
||
95 | * you're doing," because trust me, if you're trying to do that, you don't. Here |
||
96 | * be dragons! |
||
97 | * |
||
98 | * For those of you that are specifically looking for something to break, here is |
||
99 | * how to do it. |
||
100 | * |
||
101 | * What network mode does is tell the hooks API that it is in the context of the |
||
102 | * network itself, and not of any particular site. This feature is what allows us |
||
103 | * to have network-wide reactions in addition to the standard, per-site |
||
104 | * reactions. When network mode is on, it means that we don't want to do anything |
||
105 | * with standard reactions at all, because even though there may be a "current |
||
106 | * site" that we could pull them from, we're actually supposed to be pretending |
||
107 | * that we aren't on a particular site on the network, but in network-wide |
||
108 | * context. So when network mode is turned on, you won't be able to do anything |
||
109 | * with standard reactions, only network-wide ones. |
||
110 | * |
||
111 | * This is why turning it off is so dangerous—it would allow you to accidentally |
||
112 | * do things with standard reactions when you probably aren't expected to. The |
||
113 | * user is in the context of the network, for example in the network admin, so |
||
114 | * they're only expecting network-wide reactions to be affected. If you did |
||
115 | * something with standard reactions, you'd end up affecting a particular site, |
||
116 | * when the user doesn't think he is. |
||
117 | * |
||
118 | * @since 1.0.0 |
||
119 | * |
||
120 | * @internal |
||
121 | * |
||
122 | * @param bool $on Whether network-wide mode should be on (or off). |
||
123 | */ |
||
124 | public function _set_network_mode( $on = true ) { |
||
127 | } |
||
128 | |||
130 |