| 1 |
<?php |
| 2 |
|
| 3 |
namespace WP_Social\App; |
| 4 |
|
| 5 |
|
| 6 |
class Settings { |
| 7 |
|
| 8 |
public static $ok_counter_cached_data = 'xs_counter_options'; |
| 9 |
public static $ok_global_counter_setting = 'xs_counter_global_setting_data'; |
| 10 |
public static $ok_counter_provider_setting = 'xs_counter_providers_data'; |
| 11 |
public static $ok_enabled_providers_counter = 'xs_providers_enabled_counter'; |
| 12 |
public static $ok_enabled_providers_share = 'xs_providers_enabled_share'; |
| 13 |
|
| 14 |
|
| 15 |
/** |
| 16 |
* todo - we will finish it later |
| 17 |
* |
| 18 |
*/ |
| 19 |
public function load() { |
| 20 |
|
| 21 |
$global = get_option(self::$ok_global_counter_setting, []); |
| 22 |
$provider = get_option(self::$ok_counter_provider_setting, []); |
| 23 |
} |
| 24 |
|
| 25 |
|
| 26 |
/** |
| 27 |
* Return caching time in seconds as set in global counter settings |
| 28 |
* |
| 29 |
* @return int |
| 30 |
*/ |
| 31 |
public static function get_counter_cache_time() { |
| 32 |
|
| 33 |
$opt = get_option(self::$ok_global_counter_setting, []); |
| 34 |
|
| 35 |
return empty($opt['global']['cache']) ? 12 * 3600 : intval(floatval($opt['global']['cache']) * 3600); |
| 36 |
} |
| 37 |
|
| 38 |
|
| 39 |
public static function get_counter_provider_settings() { |
| 40 |
|
| 41 |
$opt = get_option(self::$ok_counter_provider_setting, []); |
| 42 |
|
| 43 |
return empty($opt['social']) ? [] : $opt['social']; |
| 44 |
} |
| 45 |
|
| 46 |
public static function get_counter_provider_conf() { |
| 47 |
|
| 48 |
$opt = get_option(self::$ok_counter_provider_setting, []); |
| 49 |
|
| 50 |
return $opt; |
| 51 |
} |
| 52 |
|
| 53 |
public static function update_counter_provider_conf($val) { |
| 54 |
|
| 55 |
return update_option(self::$ok_counter_provider_setting, $val); |
| 56 |
} |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
public static function get_enabled_provider_conf_counter() { |
| 61 |
|
| 62 |
$opt = get_option(self::$ok_enabled_providers_counter, []); |
| 63 |
|
| 64 |
return $opt; |
| 65 |
} |
| 66 |
|
| 67 |
public static function update_enabled_provider_conf_counter($val) { |
| 68 |
|
| 69 |
return update_option(self::$ok_enabled_providers_counter, $val); |
| 70 |
} |
| 71 |
|
| 72 |
|
| 73 |
public static function get_enabled_provider_conf_share() { |
| 74 |
|
| 75 |
$opt = get_option(self::$ok_enabled_providers_share, []); |
| 76 |
|
| 77 |
return $opt; |
| 78 |
} |
| 79 |
|
| 80 |
public static function update_enabled_provider_conf_share($val) { |
| 81 |
|
| 82 |
return update_option(self::$ok_enabled_providers_share, $val); |
| 83 |
} |
| 84 |
|
| 85 |
public static function get_counter_cached_data() { |
| 86 |
|
| 87 |
$opt = get_option(self::$ok_counter_cached_data, []); |
| 88 |
|
| 89 |
return empty($opt['data']) ? [] : $opt['data']; |
| 90 |
} |
| 91 |
} |
| 92 |
|