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
login-settings.php
238 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WP_Social\App; |
| 4 | |
| 5 | use WP_Social\Traits\Singleton; |
| 6 | |
| 7 | defined('ABSPATH') || exit; |
| 8 | |
| 9 | class Login_Settings { |
| 10 | |
| 11 | use Singleton; |
| 12 | |
| 13 | const OK_GLOBAL = 'xs_global_setting_data'; |
| 14 | const OK_STYLES = 'xs_style_setting_data'; |
| 15 | const OK_PROVIDER = 'xs_provider_data'; |
| 16 | const OK_PROVIDER_ENABLED = 'xs_providers_enabled_login'; |
| 17 | |
| 18 | |
| 19 | private $global; |
| 20 | private $providers; |
| 21 | private $enabled; |
| 22 | private $styles; |
| 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 static function get_login_styles() { |
| 34 | |
| 35 | $free_styles = [ |
| 36 | 'style-1' => [ |
| 37 | 'image' => WSLU_LOGIN_PLUGIN_URL . 'assets/images/screenshort/login/style-1.png', |
| 38 | 'title' => __('Icon with providers label', 'wp-social'), |
| 39 | 'package' => 'free', |
| 40 | 'unlocked' => true, |
| 41 | ], |
| 42 | 'style-2' => [ |
| 43 | 'image' => WSLU_LOGIN_PLUGIN_URL . 'assets/images/screenshort/login/style-2.png', |
| 44 | 'title' => __('Only social icon', 'wp-social'), |
| 45 | 'package' => 'free', |
| 46 | 'unlocked' => true, |
| 47 | ], |
| 48 | 'style-3' => [ |
| 49 | 'image' => WSLU_LOGIN_PLUGIN_URL . 'assets/images/screenshort/login/style-3.png', |
| 50 | 'title' => __('Only providers label', 'wp-social'), |
| 51 | 'package' => 'free', |
| 52 | 'unlocked' => true, |
| 53 | ], |
| 54 | ]; |
| 55 | |
| 56 | if(\WP_Social::is_pro_active()) { |
| 57 | |
| 58 | return apply_filters('wp_social_pro/login/styles/pro_design', $free_styles); |
| 59 | } |
| 60 | |
| 61 | $pro_only = [ |
| 62 | 'style-4' => [ |
| 63 | 'image' => WSLU_LOGIN_PLUGIN_URL . 'assets/images/screenshort/login/style-4-pro.png', |
| 64 | 'title' => __('Icon Overlay', 'wp-social'), |
| 65 | 'package' => 'pro', |
| 66 | 'unlocked' => false, |
| 67 | ], |
| 68 | 'style-5' => [ |
| 69 | 'image' => WSLU_LOGIN_PLUGIN_URL . 'assets/images/screenshort/login/style-5-pro.png', |
| 70 | 'title' => __('Left Slide', 'wp-social'), |
| 71 | 'package' => 'pro', |
| 72 | 'unlocked' => false, |
| 73 | ], |
| 74 | 'style-6' => [ |
| 75 | 'image' => WSLU_LOGIN_PLUGIN_URL . 'assets/images/screenshort/login/style-6-pro.png', |
| 76 | 'title' => __('Circle Blow', 'wp-social'), |
| 77 | 'package' => 'pro', |
| 78 | 'unlocked' => false, |
| 79 | ], |
| 80 | |
| 81 | // 'style-7' => [ |
| 82 | // 'image' => WSLU_LOGIN_PLUGIN_URL . 'assets/images/screenshort/login/style-7-pro.png', |
| 83 | // 'title' => 'Left Slide Overlay', |
| 84 | // 'package' => 'pro', |
| 85 | // 'unlocked' => false, |
| 86 | // ], |
| 87 | // 'style-8' => [ |
| 88 | // 'image' => WSLU_LOGIN_PLUGIN_URL . 'assets/images/screenshort/login/style-8-pro.png', |
| 89 | // 'title' => 'Circle Line Icon', |
| 90 | // 'package' => 'pro', |
| 91 | // 'unlocked' => false, |
| 92 | // ], |
| 93 | // 'style-9' => [ |
| 94 | // 'image' => WSLU_LOGIN_PLUGIN_URL . 'assets/images/screenshort/login/style-9-pro.png', |
| 95 | // 'title' => 'Slide to arrow', |
| 96 | // 'package' => 'pro', |
| 97 | // 'unlocked' => false, |
| 98 | // ], |
| 99 | // 'style-10' => [ |
| 100 | // 'image' => WSLU_LOGIN_PLUGIN_URL . 'assets/images/screenshort/login/style-10-pro.png', |
| 101 | // 'title' => 'Stroke right radius', |
| 102 | // 'package' => 'pro', |
| 103 | // 'unlocked' => false, |
| 104 | // ], |
| 105 | // 'style-11' => [ |
| 106 | // 'image' => WSLU_LOGIN_PLUGIN_URL . 'assets/images/screenshort/login/style-11-pro.png', |
| 107 | // 'title' => 'Gradient Icon', |
| 108 | // 'package' => 'pro', |
| 109 | // 'unlocked' => false, |
| 110 | // ], |
| 111 | // 'style-12' => [ |
| 112 | // 'image' => WSLU_LOGIN_PLUGIN_URL . 'assets/images/screenshort/login/style-12-pro.png', |
| 113 | // 'title' => 'Box Style', |
| 114 | // 'package' => 'pro', |
| 115 | // 'unlocked' => false, |
| 116 | // ], |
| 117 | // 'style-13' => [ |
| 118 | // 'image' => WSLU_LOGIN_PLUGIN_URL . 'assets/images/screenshort/login/style-13-pro.png', |
| 119 | // 'title' => 'Drop icon', |
| 120 | // 'package' => 'pro', |
| 121 | // 'unlocked' => false, |
| 122 | // ], |
| 123 | ]; |
| 124 | |
| 125 | return array_merge($free_styles, $pro_only); |
| 126 | } |
| 127 | |
| 128 | |
| 129 | public function load() { |
| 130 | |
| 131 | if(empty($this->global)) { |
| 132 | $this->global = get_option(self::OK_GLOBAL, []); |
| 133 | } |
| 134 | |
| 135 | if(empty($this->enabled)) { |
| 136 | $this->enabled = get_option(self::OK_PROVIDER_ENABLED, []); |
| 137 | } |
| 138 | |
| 139 | if(empty($this->providers)) { |
| 140 | $this->providers = get_option(self::OK_PROVIDER, []); |
| 141 | } |
| 142 | |
| 143 | if(empty($this->styles)) { |
| 144 | $this->styles = get_option(self::OK_STYLES, []); |
| 145 | } |
| 146 | |
| 147 | return $this; |
| 148 | } |
| 149 | |
| 150 | |
| 151 | public function get_enabled_providers() { |
| 152 | |
| 153 | return $this->enabled; |
| 154 | } |
| 155 | |
| 156 | |
| 157 | public function update_enabled_providers($val) { |
| 158 | |
| 159 | $this->enabled = $val; |
| 160 | |
| 161 | update_option(self::OK_PROVIDER_ENABLED, $val, true); |
| 162 | |
| 163 | return $this; |
| 164 | } |
| 165 | |
| 166 | |
| 167 | public function get_provider_settings() { |
| 168 | |
| 169 | return $this->providers; |
| 170 | } |
| 171 | |
| 172 | |
| 173 | public function update_provider_settings($val) { |
| 174 | |
| 175 | $this->providers = $val; |
| 176 | |
| 177 | update_option(self::OK_PROVIDER, $val, true); |
| 178 | |
| 179 | return $this; |
| 180 | } |
| 181 | |
| 182 | |
| 183 | public function get_style_settings() { |
| 184 | |
| 185 | return $this->styles; |
| 186 | } |
| 187 | |
| 188 | |
| 189 | public function update_style_settings($val) { |
| 190 | |
| 191 | $this->styles = $val; |
| 192 | |
| 193 | update_option(self::OK_STYLES, $val, true); |
| 194 | |
| 195 | return $this; |
| 196 | } |
| 197 | |
| 198 | |
| 199 | public function get_global_settings() { |
| 200 | |
| 201 | return $this->global; |
| 202 | } |
| 203 | |
| 204 | |
| 205 | public function update_global_settings($val) { |
| 206 | |
| 207 | $this->global = $val; |
| 208 | |
| 209 | update_option(self::OK_GLOBAL, $val, true); |
| 210 | |
| 211 | return $this; |
| 212 | } |
| 213 | |
| 214 | |
| 215 | public function is_custom_url_enabled() { |
| 216 | |
| 217 | return !empty($this->global['custom_login_url']['enable']); |
| 218 | } |
| 219 | |
| 220 | |
| 221 | public function get_custom_url() { |
| 222 | |
| 223 | return empty($this->global['custom_login_url']['data']) ? '#' : $this->global['custom_login_url']['data']; |
| 224 | } |
| 225 | |
| 226 | |
| 227 | public function is_login_page_login_button_enabled() { |
| 228 | |
| 229 | return !empty($this->global['wp_login_page']['enable']); |
| 230 | } |
| 231 | |
| 232 | |
| 233 | public function get_selected_style() { |
| 234 | |
| 235 | return empty($this->styles['login_button_style']) ? 'style-1' : $this->styles['login_button_style']; |
| 236 | } |
| 237 | } |
| 238 |