1 | <?php |
||
15 | class Network_Options extends Module { |
||
16 | /** |
||
17 | * Whitelist for network options we want to sync. |
||
18 | * |
||
19 | * @access private |
||
20 | * |
||
21 | * @var array |
||
22 | */ |
||
23 | private $network_options_whitelist; |
||
24 | |||
25 | /** |
||
26 | * Sync module name. |
||
27 | * |
||
28 | * @access public |
||
29 | * |
||
30 | * @return string |
||
31 | */ |
||
32 | public function name() { |
||
35 | |||
36 | /** |
||
37 | * Initialize network options action listeners when on multisite. |
||
38 | * |
||
39 | * @access public |
||
40 | * |
||
41 | * @param callable $callable Action handler callable. |
||
42 | */ |
||
43 | public function init_listeners( $callable ) { |
||
58 | |||
59 | /** |
||
60 | * Initialize network options action listeners for full sync. |
||
61 | * |
||
62 | * @access public |
||
63 | * |
||
64 | * @param callable $callable Action handler callable. |
||
65 | */ |
||
66 | public function init_full_sync_listeners( $callable ) { |
||
69 | |||
70 | /** |
||
71 | * Initialize the module in the sender. |
||
72 | * |
||
73 | * @access public |
||
74 | */ |
||
75 | public function init_before_send() { |
||
89 | |||
90 | /** |
||
91 | * Set module defaults. |
||
92 | * Define the network options whitelist based on the default one. |
||
93 | * |
||
94 | * @access public |
||
95 | */ |
||
96 | public function set_defaults() { |
||
99 | |||
100 | /** |
||
101 | * Enqueue the network options actions for full sync. |
||
102 | * |
||
103 | * @access public |
||
104 | * |
||
105 | * @param array $config Full sync configuration for this sync module. |
||
106 | * @param int $max_items_to_enqueue Maximum number of items to enqueue. |
||
107 | * @param boolean $state True if full sync has finished enqueueing this module, false otherwise. |
||
108 | * @return array Number of actions enqueued, and next module state. |
||
109 | */ |
||
110 | public function enqueue_full_sync_actions( $config, $max_items_to_enqueue, $state ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
||
127 | |||
128 | /** |
||
129 | * Send the network options actions for full sync. |
||
130 | * |
||
131 | * @access public |
||
132 | * |
||
133 | * @param array $config Full sync configuration for this sync module. |
||
134 | * @param int $send_until The timestamp until the current request can send. |
||
135 | * @param array $state This module Full Sync status. |
||
136 | * |
||
137 | * @return array This module Full Sync status. |
||
138 | */ |
||
139 | public function send_full_sync_actions( $config, $send_until, $state ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
||
150 | |||
151 | /** |
||
152 | * Retrieve an estimated number of actions that will be enqueued. |
||
153 | * |
||
154 | * @access public |
||
155 | * |
||
156 | * @param array $config Full sync configuration for this sync module. |
||
157 | * @return array Number of items yet to be enqueued. |
||
158 | */ |
||
159 | public function estimate_full_sync_actions( $config ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
||
166 | |||
167 | /** |
||
168 | * Retrieve the actions that will be sent for this module during a full sync. |
||
169 | * |
||
170 | * @access public |
||
171 | * |
||
172 | * @return array Full sync actions of this module. |
||
173 | */ |
||
174 | public function get_full_sync_actions() { |
||
177 | |||
178 | /** |
||
179 | * Retrieve all network options as per the current network options whitelist. |
||
180 | * |
||
181 | * @access public |
||
182 | * |
||
183 | * @return array All network options. |
||
184 | */ |
||
185 | public function get_all_network_options() { |
||
193 | |||
194 | /** |
||
195 | * Set the network options whitelist. |
||
196 | * |
||
197 | * @access public |
||
198 | * |
||
199 | * @param array $options The new network options whitelist. |
||
200 | */ |
||
201 | public function set_network_options_whitelist( $options ) { |
||
204 | |||
205 | /** |
||
206 | * Get the network options whitelist. |
||
207 | * |
||
208 | * @access public |
||
209 | * |
||
210 | * @return array The network options whitelist. |
||
211 | */ |
||
212 | public function get_network_options_whitelist() { |
||
215 | |||
216 | /** |
||
217 | * Reject non-whitelisted network options. |
||
218 | * |
||
219 | * @access public |
||
220 | * |
||
221 | * @param array $args The hook parameters. |
||
222 | * @return array|false $args The hook parameters, false if not a whitelisted network option. |
||
223 | */ |
||
224 | public function whitelist_network_options( $args ) { |
||
231 | |||
232 | /** |
||
233 | * Whether the option is a whitelisted network option in a multisite system. |
||
234 | * |
||
235 | * @access public |
||
236 | * |
||
237 | * @param string $option Option name. |
||
238 | * @return boolean True if this is a whitelisted network option. |
||
239 | */ |
||
240 | public function is_whitelisted_network_option( $option ) { |
||
243 | |||
244 | /** |
||
245 | * Expand the network options within a hook before they are serialized and sent to the server. |
||
246 | * |
||
247 | * @access public |
||
248 | * |
||
249 | * @param array $args The hook parameters. |
||
250 | * @return array $args The hook parameters. |
||
251 | */ |
||
252 | public function expand_network_options( $args ) { |
||
259 | |||
260 | /** |
||
261 | * Return Total number of objects. |
||
262 | * |
||
263 | * @param array $config Full Sync config. |
||
264 | * |
||
265 | * @return int total |
||
266 | */ |
||
267 | public function total( $config ) { |
||
270 | |||
271 | } |
||
272 |