1 | <?php |
||
13 | class autoptimizeOptionWrapper { |
||
14 | /** |
||
15 | * Constructor, add filter on saving options. |
||
16 | */ |
||
17 | public function __construct() { |
||
19 | |||
20 | /** |
||
21 | * Ensure that is_plugin_active_for_network function is declared. |
||
22 | */ |
||
23 | public static function maybe_include_plugin_functions() { |
||
28 | |||
29 | /** |
||
30 | * Retrieves the option in standalone and multisite instances. |
||
31 | * |
||
32 | * @param string $option Name of option to retrieve. Expected to not be SQL-escaped. |
||
33 | * @param mixed $default Optional. Default value to return if the option does not exist. |
||
34 | * @return mixed Value set for the option. |
||
35 | */ |
||
36 | public static function get_option( $option, $default = false ) { |
||
50 | |||
51 | /** |
||
52 | * Saves the option in standalone and multisite instances. |
||
53 | * |
||
54 | * @param string $option Option name. Expected to not be SQL-escaped. |
||
55 | * @param mixed $value Option value. Must be serializable if non-scalar. Expected to not be SQL-escaped. |
||
56 | * @param string|bool $autoload Optional. Whether to load the option when WordPress starts up. For existing options, |
||
57 | * `$autoload` can only be updated using `update_option()` if `$value` is also changed. |
||
58 | * Accepts 'yes'|true to enable or 'no'|false to disable. For non-existent options, |
||
59 | * the default value is 'yes'. Default null. |
||
60 | * @return bool False if value was not updated and true if value was updated. |
||
61 | */ |
||
62 | public static function update_option( $option, $value, $autoload = null ) { |
||
69 | |||
70 | /** |
||
71 | * Use the pre_update_option filter to check if the option to be saved if from autoptimize and |
||
72 | * in that case, take care of multisite case. |
||
73 | */ |
||
74 | public static function check_multisite_on_saving_options() { |
||
79 | |||
80 | /** |
||
81 | * The actual magic to differentiate between network options and per-site options. |
||
82 | * |
||
83 | * @param mixed $value Option value. |
||
84 | * @param string $option Option name. |
||
85 | * @param string $old_value Old value. |
||
86 | */ |
||
87 | public static function update_autoptimize_option_on_network( $value, $option, $old_value ) { |
||
101 | |||
102 | /** |
||
103 | * As options are POST-ed to wp-admin/options.php checking is_network_admin() does not |
||
104 | * work (yet). Instead we compare the network_admin_url with the _wp_http_referer |
||
105 | * (which should always be available as part of a hidden form field). |
||
106 | */ |
||
107 | public static function is_options_from_network_admin() { |
||
120 | |||
121 | /** |
||
122 | * Function to check if AO (including beta) is active for network. |
||
123 | */ |
||
124 | public static function is_ao_active_for_network() { |
||
136 | } |
||
137 | new autoptimizeOptionWrapper(); |
||
138 |