api-routes.php
5 years ago
avatar.php
4 years ago
counter-settings.php
5 years ago
legacy.php
5 years ago
login-settings.php
3 years ago
providers.php
3 years ago
route.php
4 years ago
settings.php
5 years ago
share-settings.php
4 years ago
share.php
3 years ago
counter-settings.php
96 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WP_Social\App; |
| 4 | |
| 5 | use WP_Social\Traits\Singleton; |
| 6 | |
| 7 | defined('ABSPATH') || exit; |
| 8 | |
| 9 | class Counter_Settings { |
| 10 | |
| 11 | use Singleton; |
| 12 | |
| 13 | const OK_GLOBAL = 'xs_counter_global_setting_data'; |
| 14 | const OK_STYLES = 'xs_style_setting_data_counter'; |
| 15 | const OK_PROVIDER = 'xs_counter_providers_data'; |
| 16 | const OK_PROVIDER_ENABLED = 'xs_providers_enabled_counter'; |
| 17 | |
| 18 | private $global; |
| 19 | private $providers; |
| 20 | private $enabled; |
| 21 | private $styles; |
| 22 | |
| 23 | |
| 24 | public function __construct() { |
| 25 | |
| 26 | $this->global = get_option(self::OK_GLOBAL, []); |
| 27 | $this->enabled = get_option(self::OK_PROVIDER_ENABLED, []); |
| 28 | $this->providers = get_option(self::OK_PROVIDER, []); |
| 29 | $this->styles = get_option(self::OK_STYLES, []); |
| 30 | } |
| 31 | |
| 32 | |
| 33 | public function get_enabled_providers() { |
| 34 | |
| 35 | return $this->enabled; |
| 36 | } |
| 37 | |
| 38 | |
| 39 | public function update_enabled_providers($val) { |
| 40 | |
| 41 | $this->enabled = $val; |
| 42 | |
| 43 | update_option(self::OK_PROVIDER_ENABLED, $val, true); |
| 44 | |
| 45 | return $this; |
| 46 | } |
| 47 | |
| 48 | |
| 49 | public function get_provider_settings() { |
| 50 | |
| 51 | return $this->providers; |
| 52 | } |
| 53 | |
| 54 | |
| 55 | public function update_provider_settings($val) { |
| 56 | |
| 57 | $this->providers = $val; |
| 58 | |
| 59 | update_option(self::OK_PROVIDER, $val, true); |
| 60 | |
| 61 | return $this; |
| 62 | } |
| 63 | |
| 64 | |
| 65 | public function get_style_settings() { |
| 66 | |
| 67 | return $this->styles; |
| 68 | } |
| 69 | |
| 70 | |
| 71 | public function update_style_settings($val) { |
| 72 | |
| 73 | $this->styles = $val; |
| 74 | |
| 75 | update_option(self::OK_STYLES, $val, true); |
| 76 | |
| 77 | return $this; |
| 78 | } |
| 79 | |
| 80 | |
| 81 | public function get_global_settings() { |
| 82 | |
| 83 | return $this->global; |
| 84 | } |
| 85 | |
| 86 | |
| 87 | public function update_global_settings($val) { |
| 88 | |
| 89 | $this->global = $val; |
| 90 | |
| 91 | update_option(self::OK_GLOBAL, $val, true); |
| 92 | |
| 93 | return $this; |
| 94 | } |
| 95 | } |
| 96 |