Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 14
0.00% covered (danger)
0.00%
0 / 4
CRAP
n/a
0 / 0
jetpack_inspect_register_option
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
jetpack_inspect_option
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
jetpack_inspect_get_option
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
jetpack_inspect_update_option
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3use Automattic\Jetpack\Packages\Async_Option\Async_Option;
4use Automattic\Jetpack\Packages\Async_Option\Async_Options;
5use Automattic\Jetpack\Packages\Async_Option\Registry;
6use Automattic\Jetpack_Inspect\Options\Monitor_Status;
7use Automattic\Jetpack_Inspect\Options\Observer_Settings;
8
9/**
10 * Functions to make it easier to interface with Async Option:
11 */
12function jetpack_inspect_register_option( $name, $handler ) {
13    return Registry::get_instance( 'jetpack_inspect' )
14                    ->register( $name, $handler );
15}
16
17/**
18 * @param $name
19 *
20 * @return Async_Option
21 */
22function jetpack_inspect_option( $name ) {
23    return Registry::get_instance( 'jetpack_inspect' )->get_option( $name );
24}
25
26function jetpack_inspect_get_option( $option ) {
27    return jetpack_inspect_option( $option )->get();
28}
29
30function jetpack_inspect_update_option( $option, $value ) {
31    return jetpack_inspect_option( $option )->set( $value );
32}
33
34/**
35 * Ensure that Async Options are passed to the relevant scripts.
36 */
37add_action(
38    'admin_init',
39    function () {
40        Async_Options::setup( 'jetpack_inspect', 'jetpack-inspect-main' );
41    }
42);
43
44jetpack_inspect_register_option( 'monitor_status', new Monitor_Status() );
45jetpack_inspect_register_option( 'observer_incoming', new Observer_Settings() );
46jetpack_inspect_register_option( 'observer_outgoing', new Observer_Settings() );