1 | <?php |
||
5 | class Jetpack_Sync_Settings { |
||
6 | const SETTINGS_OPTION_PREFIX = 'jetpack_sync_settings_'; |
||
7 | |||
8 | static $valid_settings = array( |
||
|
|||
9 | 'dequeue_max_bytes' => true, |
||
10 | 'upload_max_bytes' => true, |
||
11 | 'upload_max_rows' => true, |
||
12 | 'sync_wait_time' => true, |
||
13 | 'max_queue_size' => true, |
||
14 | 'max_queue_lag' => true, |
||
15 | ); |
||
16 | |||
17 | static function get_settings() { |
||
24 | |||
25 | // Fetches the setting. It saves it if the setting doesn't exist, so that it gets |
||
26 | // autoloaded on page load rather than re-queried every time. |
||
27 | static function get_setting( $setting ) { |
||
28 | if ( ! isset( self::$valid_settings[ $setting ] ) ) { |
||
29 | return false; |
||
30 | } |
||
31 | |||
32 | $value = get_option( self::SETTINGS_OPTION_PREFIX.$setting ); |
||
33 | |||
34 | if ( $value === false ) { |
||
35 | $default_name = "default_$setting"; // e.g. default_dequeue_max_bytes |
||
36 | $value = Jetpack_Sync_Defaults::$$default_name; |
||
37 | update_option( self::SETTINGS_OPTION_PREFIX.$setting, $value, null, true ); |
||
38 | } |
||
39 | |||
40 | return (int) $value; |
||
41 | } |
||
42 | |||
43 | static function update_settings( $new_settings ) { |
||
49 | |||
50 | static function reset_data() { |
||
57 | } |
||
58 |
The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using
the property is implicitly global.
To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.