1 | <?php |
||
15 | class Options extends Module { |
||
16 | /** |
||
17 | * Whitelist for options we want to sync. |
||
18 | * |
||
19 | * @access private |
||
20 | * |
||
21 | * @var array |
||
22 | */ |
||
23 | private $options_whitelist; |
||
24 | |||
25 | /** |
||
26 | * Contentless options we want to sync. |
||
27 | * |
||
28 | * @access private |
||
29 | * |
||
30 | * @var array |
||
31 | */ |
||
32 | private $options_contentless; |
||
33 | |||
34 | /** |
||
35 | * Sync module name. |
||
36 | * |
||
37 | * @access public |
||
38 | * |
||
39 | * @return string |
||
40 | */ |
||
41 | public function name() { |
||
44 | |||
45 | /** |
||
46 | * Initialize options action listeners. |
||
47 | * |
||
48 | * @access public |
||
49 | * |
||
50 | * @param callable $callable Action handler callable. |
||
51 | */ |
||
52 | public function init_listeners( $callable ) { |
||
68 | |||
69 | /** |
||
70 | * Initialize options action listeners for full sync. |
||
71 | * |
||
72 | * @access public |
||
73 | * |
||
74 | * @param callable $callable Action handler callable. |
||
75 | */ |
||
76 | public function init_full_sync_listeners( $callable ) { |
||
79 | |||
80 | /** |
||
81 | * Initialize the module in the sender. |
||
82 | * |
||
83 | * @access public |
||
84 | */ |
||
85 | public function init_before_send() { |
||
89 | |||
90 | /** |
||
91 | * Set module defaults. |
||
92 | * Define the options whitelist and contentless options. |
||
93 | * |
||
94 | * @access public |
||
95 | */ |
||
96 | public function set_defaults() { |
||
100 | |||
101 | /** |
||
102 | * Set module defaults at a later time. |
||
103 | * |
||
104 | * @access public |
||
105 | */ |
||
106 | public function set_late_default() { |
||
113 | |||
114 | /** |
||
115 | * Enqueue the options actions for full sync. |
||
116 | * |
||
117 | * @access public |
||
118 | * |
||
119 | * @param array $config Full sync configuration for this sync module. |
||
120 | * @param int $max_items_to_enqueue Maximum number of items to enqueue. |
||
121 | * @param boolean $state True if full sync has finished enqueueing this module, false otherwise. |
||
122 | * @return array Number of actions enqueued, and next module state. |
||
123 | */ |
||
124 | public function enqueue_full_sync_actions( $config, $max_items_to_enqueue, $state ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
||
137 | |||
138 | /** |
||
139 | * Send the options actions for full sync. |
||
140 | * |
||
141 | * @access public |
||
142 | * |
||
143 | * @param array $config Full sync configuration for this sync module. |
||
144 | * @param int $send_until The timestamp until the current request can send. |
||
145 | * @param array $state This module Full Sync status. |
||
146 | * |
||
147 | * @return array This module Full Sync status. |
||
148 | */ |
||
149 | public function send_full_sync_actions( $config, $send_until, $state ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
||
156 | |||
157 | /** |
||
158 | * Retrieve an estimated number of actions that will be enqueued. |
||
159 | * |
||
160 | * @access public |
||
161 | * |
||
162 | * @param array $config Full sync configuration for this sync module. |
||
163 | * @return int Number of items yet to be enqueued. |
||
164 | */ |
||
165 | public function estimate_full_sync_actions( $config ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
||
168 | |||
169 | /** |
||
170 | * Retrieve the actions that will be sent for this module during a full sync. |
||
171 | * |
||
172 | * @access public |
||
173 | * |
||
174 | * @return array Full sync actions of this module. |
||
175 | */ |
||
176 | public function get_full_sync_actions() { |
||
179 | |||
180 | /** |
||
181 | * Retrieve all options as per the current options whitelist. |
||
182 | * Public so that we don't have to store so much data all the options twice. |
||
183 | * |
||
184 | * @access public |
||
185 | * |
||
186 | * @return array All options. |
||
187 | */ |
||
188 | public function get_all_options() { |
||
208 | |||
209 | /** |
||
210 | * Update the options whitelist to the default one. |
||
211 | * |
||
212 | * @access public |
||
213 | */ |
||
214 | public function update_options_whitelist() { |
||
217 | |||
218 | /** |
||
219 | * Set the options whitelist. |
||
220 | * |
||
221 | * @access public |
||
222 | * |
||
223 | * @param array $options The new options whitelist. |
||
224 | */ |
||
225 | public function set_options_whitelist( $options ) { |
||
228 | |||
229 | /** |
||
230 | * Get the options whitelist. |
||
231 | * |
||
232 | * @access public |
||
233 | * |
||
234 | * @return array The options whitelist. |
||
235 | */ |
||
236 | public function get_options_whitelist() { |
||
239 | |||
240 | /** |
||
241 | * Update the contentless options to the defaults. |
||
242 | * |
||
243 | * @access public |
||
244 | */ |
||
245 | public function update_options_contentless() { |
||
248 | |||
249 | /** |
||
250 | * Get the contentless options. |
||
251 | * |
||
252 | * @access public |
||
253 | * |
||
254 | * @return array Array of the contentless options. |
||
255 | */ |
||
256 | public function get_options_contentless() { |
||
259 | |||
260 | /** |
||
261 | * Reject any options that aren't whitelisted or contentless. |
||
262 | * |
||
263 | * @access public |
||
264 | * |
||
265 | * @param array $args The hook parameters. |
||
266 | * @return array $args The hook parameters. |
||
267 | */ |
||
268 | public function whitelist_options( $args ) { |
||
292 | |||
293 | /** |
||
294 | * Whether a certain option is whitelisted for sync. |
||
295 | * |
||
296 | * @access public |
||
297 | * |
||
298 | * @param string $option Option name. |
||
299 | * @return boolean Whether the option is whitelisted. |
||
300 | */ |
||
301 | public function is_whitelisted_option( $option ) { |
||
304 | |||
305 | /** |
||
306 | * Whether a certain option is a contentless one. |
||
307 | * |
||
308 | * @access private |
||
309 | * |
||
310 | * @param string $option Option name. |
||
311 | * @return boolean Whether the option is contentless. |
||
312 | */ |
||
313 | private function is_contentless_option( $option ) { |
||
316 | |||
317 | /** |
||
318 | * Filters out falsy values from theme mod options. |
||
319 | * |
||
320 | * @access private |
||
321 | * |
||
322 | * @param array $value Option value. |
||
323 | */ |
||
324 | private function filter_theme_mods( &$value ) { |
||
329 | |||
330 | /** |
||
331 | * Handle changes in the core site icon and sync them. |
||
332 | * |
||
333 | * @access public |
||
334 | */ |
||
335 | public function jetpack_sync_core_icon() { |
||
347 | |||
348 | /** |
||
349 | * Expand all options within a hook before they are serialized and sent to the server. |
||
350 | * |
||
351 | * @access public |
||
352 | * |
||
353 | * @param array $args The hook parameters. |
||
354 | * @return array $args The hook parameters. |
||
355 | */ |
||
356 | public function expand_options( $args ) { |
||
363 | |||
364 | /** |
||
365 | * Return Total number of objects. |
||
366 | * |
||
367 | * @param array $config Full Sync config. |
||
368 | * |
||
369 | * @return int total |
||
370 | */ |
||
371 | public function total( $config ) { |
||
374 | |||
375 | } |
||
376 |