elementor
3 years ago
admin-create-shortcode.php
7 years ago
admin-create-user.php
3 years ago
admin-custom-function.php
3 years ago
admin-rest-api.php
4 years ago
admin-settings.php
3 years ago
admin-social-button.php
3 years ago
admin-social-enque-script.php
5 years ago
counter-widget.php
3 years ago
counter.php
3 years ago
custom-function.php
4 years ago
login-widget.php
3 years ago
login.php
5 years ago
share-widget.php
3 years ago
share.php
3 years ago
admin-settings.php
950 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WP_Social\Inc; |
| 4 | |
| 5 | defined('ABSPATH') || exit; |
| 6 | |
| 7 | use WP_Social\App\Counter_Settings; |
| 8 | use WP_Social\App\Login_Settings; |
| 9 | use WP_Social\App\Providers; |
| 10 | use WP_Social\App\Settings; |
| 11 | use WP_Social\Helper\User_Helper; |
| 12 | use WP_Social\Lib\Onboard\Onboard; |
| 13 | use WP_Social\Xs_Migration\Migration; |
| 14 | use WP_User_Query; |
| 15 | |
| 16 | /** |
| 17 | * Class Name : XS_Social_Login_Settings; |
| 18 | * Class Details : Added menu and sub menu in wordpress main admin menu |
| 19 | * |
| 20 | * @params : void |
| 21 | * @return : added new page link |
| 22 | * |
| 23 | * @since : 1.0 |
| 24 | */ |
| 25 | class Admin_Settings { |
| 26 | |
| 27 | public static $counter_style = ['wslu-counter-box-shaped wslu-counter-fill-colored' => 'Block', 'wslu-counter-line-shaped wslu-counter-fill-colored' => 'Line', 'wslu-counter-line-shaped wslu-counter-fill-colored wslu-counter-rounded' => 'Line with Round']; |
| 28 | |
| 29 | /** |
| 30 | * @var array |
| 31 | */ |
| 32 | public static $horizontal_style = [ |
| 33 | |
| 34 | 'horizontal' => [ |
| 35 | 'class' => 'wslu-share-horizontal', |
| 36 | 'name' => 'Horizontal', |
| 37 | ], |
| 38 | |
| 39 | 'vertical' => [ |
| 40 | 'class' => 'wslu-share-vertical', |
| 41 | 'name' => 'Vertical', |
| 42 | ], |
| 43 | ]; |
| 44 | |
| 45 | |
| 46 | public function __construct($load = true) { |
| 47 | |
| 48 | add_action('wp_ajax_export_users_content_csv', [$this, 'export_users_content_csv']); |
| 49 | |
| 50 | add_action('wp_ajax_sort_providers_login', [$this, 'sort_providers_login']); |
| 51 | |
| 52 | add_action('wp_ajax_sort_providers_share', [$this, 'sort_providers_share']); |
| 53 | |
| 54 | add_action('wp_ajax_sort_providers_counter', [$this, 'sort_providers_counter']); |
| 55 | |
| 56 | if($load) { |
| 57 | // added admin menu |
| 58 | add_action('admin_menu', [$this, 'wp_social_admin_menu']); |
| 59 | } |
| 60 | |
| 61 | if(!did_action('wslu_social_pro/plugin_loaded')) { |
| 62 | add_filter('wslu/share/style_settins', [$this, 'share_style_settings']); |
| 63 | add_filter('wslu/counter/style_settings', [$this, 'counter_style_settings']); |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | |
| 68 | public static function share_styles() { |
| 69 | |
| 70 | $share_style = [ |
| 71 | 'style-1' => [ |
| 72 | 'name' => __('Icon with fill color', 'wp-social'), |
| 73 | 'class' => 'wslu-share-box-shaped wslu-fill-colored', |
| 74 | 'design' => 'img-1', |
| 75 | 'package' => 'free', |
| 76 | ], |
| 77 | 'style-2' => [ |
| 78 | 'name' => __('Icon with fill color and space', 'wp-social'), |
| 79 | 'class' => 'wslu-share-box-shaped wslu-fill-colored wslu-share-m-5', |
| 80 | 'design' => 'img-2', |
| 81 | 'package' => 'free', |
| 82 | ], |
| 83 | 'style-3' => [ |
| 84 | 'name' => __('Icon with hover fill color and space', 'wp-social'), |
| 85 | 'class' => 'wslu-share-box-shaped wslu-fill-brand-hover-colored wslu-share-m-5', |
| 86 | 'design' => 'img-3', |
| 87 | 'package' => 'free', |
| 88 | ], |
| 89 | ]; |
| 90 | |
| 91 | return apply_filters('wslu/share/style_settins', $share_style); |
| 92 | } |
| 93 | |
| 94 | public function share_style_settings($share) { |
| 95 | |
| 96 | $array = [ |
| 97 | 'style-4' => [ |
| 98 | 'name' => __('Icon with text', 'wp-social'), |
| 99 | 'class' => 'wslu-go-pro', |
| 100 | 'design' => 'img-4', |
| 101 | 'package' => 'pro', |
| 102 | ], |
| 103 | 'style-5' => [ |
| 104 | 'name' => __('Icon with text & slightly rounded', 'wp-social'), |
| 105 | 'class' => 'wslu-go-pro', |
| 106 | 'design' => 'img-5', |
| 107 | 'package' => 'pro', |
| 108 | ], |
| 109 | 'style-6' => [ |
| 110 | 'name' => __('Circled Icon with fill color', 'wp-social'), |
| 111 | 'class' => 'wslu-go-pro', |
| 112 | 'design' => 'img-6', |
| 113 | 'package' => 'pro', |
| 114 | ], |
| 115 | 'style-7' => [ |
| 116 | 'name' => __('Circled Icon with hover fill color', 'wp-social'), |
| 117 | 'class' => 'wslu-go-pro', |
| 118 | 'design' => 'img-7', |
| 119 | 'package' => 'pro', |
| 120 | ], |
| 121 | 'style-8' => [ |
| 122 | 'name' => __('Icon with colored border', 'wp-social'), |
| 123 | 'class' => 'wslu-go-pro', |
| 124 | 'design' => 'img-8', |
| 125 | 'package' => 'pro', |
| 126 | ], |
| 127 | 'style-9' => [ |
| 128 | 'name' => __('Icon with hover colored border', 'wp-social'), |
| 129 | 'class' => 'wslu-go-pro', |
| 130 | 'design' => 'img-9', |
| 131 | 'package' => 'pro', |
| 132 | ], |
| 133 | 'style-10' => [ |
| 134 | 'name' => __('Icon with colored rounded border', 'wp-social'), |
| 135 | 'class' => 'wslu-go-pro', |
| 136 | 'design' => 'img-10', |
| 137 | 'package' => 'pro', |
| 138 | ], |
| 139 | 'style-11' => [ |
| 140 | 'name' => __('Icon with hover colored rounded border', 'wp-social'), |
| 141 | 'class' => 'wslu-go-pro', |
| 142 | 'design' => 'img-11', |
| 143 | 'package' => 'pro', |
| 144 | ], |
| 145 | 'style-12' => [ |
| 146 | 'name' => __('Icon with hover fill color border', 'wp-social'), |
| 147 | 'class' => 'wslu-go-pro', |
| 148 | 'design' => 'img-12', |
| 149 | 'package' => 'pro', |
| 150 | ], |
| 151 | 'style-13' => [ |
| 152 | 'name' => __('Slightly rounded icon with fill color', 'wp-social'), |
| 153 | 'class' => 'wslu-go-pro', |
| 154 | 'design' => 'img-13', |
| 155 | 'package' => 'pro', |
| 156 | ], |
| 157 | 'style-14' => [ |
| 158 | 'name' => __('Icon with follower count', 'wp-social'), |
| 159 | 'class' => 'wslu-go-pro', |
| 160 | 'design' => 'img-14', |
| 161 | 'package' => 'pro', |
| 162 | ], |
| 163 | 'style-15' => [ |
| 164 | 'name' => __('Rounded filled icon with text', 'wp-social'), |
| 165 | 'class' => 'wslu-go-pro', |
| 166 | 'design' => 'img-15', |
| 167 | 'package' => 'pro', |
| 168 | ], |
| 169 | 'style-16' => [ |
| 170 | 'name' => __('Semi-rounded icon with fill color', 'wp-social'), |
| 171 | 'class' => 'wslu-go-pro', |
| 172 | 'design' => 'img-16', |
| 173 | 'package' => 'pro', |
| 174 | ], |
| 175 | 'style-17' => [ |
| 176 | 'name' => __('Semi-rounded icon and border color', 'wp-social'), |
| 177 | 'class' => 'wslu-go-pro', |
| 178 | 'design' => 'img-17', |
| 179 | 'package' => 'pro', |
| 180 | ], |
| 181 | 'style-18' => [ |
| 182 | 'name' => __('Icon with text and follower count', 'wp-social'), |
| 183 | 'class' => 'wslu-go-pro', |
| 184 | 'design' => 'img-18', |
| 185 | 'package' => 'pro', |
| 186 | ], |
| 187 | ]; |
| 188 | |
| 189 | return array_merge($share, $array); |
| 190 | } |
| 191 | |
| 192 | |
| 193 | /** |
| 194 | * |
| 195 | * @return mixed |
| 196 | */ |
| 197 | public static function counter_styles() { |
| 198 | |
| 199 | $counterStyles = [ |
| 200 | |
| 201 | 'style-1' => [ |
| 202 | 'name' => __('Flat style with fill color', 'wp-social'), |
| 203 | 'class' => 'wslu-counter-box-shaped wslu-counter-fill-colored wslu-counter-space', |
| 204 | 'design' => 'img-1', |
| 205 | 'package' => 'free', |
| 206 | ], |
| 207 | |
| 208 | 'style-2' => [ |
| 209 | 'name' => __('Line style with fill color', 'wp-social'), |
| 210 | 'class' => 'wslu-counter-line-shaped wslu-counter-fill-colored wslu-counter-space', |
| 211 | 'design' => 'img-2', |
| 212 | 'package' => 'free', |
| 213 | ], |
| 214 | |
| 215 | 'style-3' => [ |
| 216 | 'name' => __('Line slightly rounded style with fill color', 'wp-social'), |
| 217 | 'class' => 'wslu-counter-line-shaped wslu-counter-fill-colored wslu-counter-rounded wslu-counter-space', |
| 218 | 'design' => 'img-3', |
| 219 | 'package' => 'free', |
| 220 | ], |
| 221 | ]; |
| 222 | |
| 223 | |
| 224 | return apply_filters('wslu/counter/style_settings', $counterStyles); |
| 225 | } |
| 226 | |
| 227 | public function counter_style_settings($counter) { |
| 228 | $array = [ |
| 229 | 'style-4' => [ |
| 230 | 'name' => __('Flat style with hover fill color', 'wp-social'), |
| 231 | 'class' => 'wslu-counter-go-pro', |
| 232 | 'design' => 'img-4', |
| 233 | 'package' => 'pro', |
| 234 | ], |
| 235 | 'style-5' => [ |
| 236 | 'name' => __('Metro style with fill color', 'wp-social'), |
| 237 | 'class' => 'wslu-counter-go-pro', |
| 238 | 'design' => 'img-5', |
| 239 | 'package' => 'pro', |
| 240 | ], |
| 241 | 'style-6' => [ |
| 242 | 'name' => __('Flat style with hover icon color', 'wp-social'), |
| 243 | 'class' => 'wslu-counter-go-pro', |
| 244 | 'design' => 'img-6', |
| 245 | 'package' => 'pro', |
| 246 | ], |
| 247 | 'style-7' => [ |
| 248 | 'name' => __('Flat style with icon color', 'wp-social'), |
| 249 | 'class' => 'wslu-counter-go-pro', |
| 250 | 'design' => 'img-7', |
| 251 | 'package' => 'pro', |
| 252 | ], |
| 253 | 'style-8' => [ |
| 254 | 'name' => __('Flat style with icon fill color', 'wp-social'), |
| 255 | 'class' => 'wslu-counter-go-pro', |
| 256 | 'design' => 'img-8', |
| 257 | 'package' => 'pro', |
| 258 | ], |
| 259 | 'style-9' => [ |
| 260 | 'name' => __('Flat style with fill color & rounded icon', 'wp-social'), |
| 261 | 'class' => 'wslu-counter-go-pro', |
| 262 | 'design' => 'img-9', |
| 263 | 'package' => 'pro', |
| 264 | ], |
| 265 | 'style-10' => [ |
| 266 | 'name' => __('Vertical line style with icon color', 'wp-social'), |
| 267 | 'class' => 'wslu-counter-go-pro', |
| 268 | 'design' => 'img-10', |
| 269 | 'package' => 'pro', |
| 270 | ], |
| 271 | 'style-11' => [ |
| 272 | 'name' => __('Vertical line style with icon fill color', 'wp-social'), |
| 273 | 'class' => 'wslu-counter-go-pro', |
| 274 | 'design' => 'img-11', |
| 275 | 'package' => 'pro', |
| 276 | ], |
| 277 | 'style-12' => [ |
| 278 | 'name' => __('Vertical line style with fill color & rounded icon', 'wp-social'), |
| 279 | 'class' => 'wslu-counter-go-pro', |
| 280 | 'design' => 'img-12', |
| 281 | 'package' => 'pro', |
| 282 | ], |
| 283 | 'style-13' => [ |
| 284 | 'name' => __('Rounded icon style with fill color', 'wp-social'), |
| 285 | 'class' => 'wslu-counter-go-pro', |
| 286 | 'design' => 'img-13', |
| 287 | 'package' => 'pro', |
| 288 | ], |
| 289 | 'style-14' => [ |
| 290 | 'name' => __('Rounded icon style with hover fill color', 'wp-social'), |
| 291 | 'class' => 'wslu-counter-go-pro', |
| 292 | 'design' => 'img-14', |
| 293 | 'package' => 'pro', |
| 294 | ], |
| 295 | 'style-15' => [ |
| 296 | 'name' => __('Slightly Rounded icon style with fill color', 'wp-social'), |
| 297 | 'class' => 'wslu-counter-go-pro', |
| 298 | 'design' => 'img-15', |
| 299 | 'package' => 'pro', |
| 300 | ], |
| 301 | 'style-16' => [ |
| 302 | 'name' => __('Slightly Rounded icon style with hover fill color', 'wp-social'), |
| 303 | 'class' => 'wslu-counter-go-pro', |
| 304 | 'design' => 'img-16', |
| 305 | 'package' => 'pro', |
| 306 | ], |
| 307 | 'style-17' => [ |
| 308 | 'name' => __('Metro style with hover fill color', 'wp-social'), |
| 309 | 'class' => 'wslu-counter-go-pro', |
| 310 | 'design' => 'img-17', |
| 311 | 'package' => 'pro', |
| 312 | ], |
| 313 | 'style-18' => [ |
| 314 | 'name' => __('Line style with hover fill color', 'wp-social'), |
| 315 | 'class' => 'wslu-counter-go-pro', |
| 316 | 'design' => 'img-18', |
| 317 | 'package' => 'pro', |
| 318 | ], |
| 319 | ]; |
| 320 | |
| 321 | return array_merge($counter, $array); |
| 322 | } |
| 323 | |
| 324 | |
| 325 | /** |
| 326 | * Method Name : wp_social_admin_menu |
| 327 | * Method Details : add menu for social login plugin |
| 328 | * |
| 329 | * @params : void |
| 330 | * @return : void |
| 331 | * |
| 332 | * @since : 1.0 |
| 333 | */ |
| 334 | public function wp_social_admin_menu() { |
| 335 | add_menu_page( __('WP Social Login Ultimate', 'wp-social'), __('WP Social', 'wp-social'), 'manage_options', 'wslu_global_setting', [$this, 'content_xs_global_setting'], WSLU_LOGIN_PLUGIN_URL . 'assets/images/icon-menu.png'); |
| 336 | add_submenu_page('wslu_global_setting', __('Social Login', 'wp-social'), __('Social Login', 'wp-social'), 'manage_options', 'wslu_global_setting', [$this, 'content_xs_global_setting']); |
| 337 | add_submenu_page('wslu_global_setting', __('Social Share', 'wp-social'), __('Social Share', 'wp-social'), 'manage_options', 'wslu_share_setting', [$this, 'content_xs_share_setting']); |
| 338 | add_submenu_page('wslu_global_setting', __('Social Counter', 'wp-social'), __('Social Counter', 'wp-social'), 'manage_options', 'wslu_counter_setting', [$this, 'content_xs_counter_setting']); |
| 339 | add_submenu_page('wslu_global_setting', __('Settings', 'wp-social'), __('Settings', 'wp-social'), 'manage_options', 'wslu_settings', [$this, 'content_xs_settings']); |
| 340 | //add_submenu_page('wslu_global_setting', 'Test123', 'Data conversion', 'manage_options', 'wslu_data_migration', [$this, 'content_xs_data_migration']); |
| 341 | } |
| 342 | |
| 343 | /** |
| 344 | * Method Name : content_xs_global_setting |
| 345 | * Method Details : content for global setting page |
| 346 | * |
| 347 | * @params : void |
| 348 | * @return : void |
| 349 | * |
| 350 | * @since : 1.0 |
| 351 | */ |
| 352 | public function content_xs_global_setting() { |
| 353 | |
| 354 | if(isset($_GET['wp-social-met-onboard-steps']) && sanitize_text_field($_GET['wp-social-met-onboard-steps']) == 'loaded') { |
| 355 | Onboard::instance()->views(); |
| 356 | } else { |
| 357 | $global_optionKey = 'xs_global_setting_data'; |
| 358 | $message_global = 'hide'; |
| 359 | |
| 360 | if(isset($_POST['global_setting_submit_form'])) { |
| 361 | |
| 362 | if( !isset( $_POST['nonce'] ) || !wp_verify_nonce( $_POST['nonce'], 'global_setting_submit_form_nonce' ) ) { |
| 363 | return; |
| 364 | } |
| 365 | |
| 366 | $option_value_global = isset($_POST['xs_global']) ? Self::sanitize($_POST['xs_global']) : []; |
| 367 | |
| 368 | if(update_option($global_optionKey, $option_value_global, 'Yes')) { |
| 369 | $message_global = 'show'; |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | // get returned global setting data from db |
| 374 | $return_data = get_option($global_optionKey); |
| 375 | |
| 376 | $membership = get_option('users_can_register', 0); |
| 377 | $wpUserRole = get_option('default_role', 'subscriber'); |
| 378 | |
| 379 | |
| 380 | // wordpress role options |
| 381 | $active_tab = isset($_GET["tab"]) ? sanitize_text_field($_GET["tab"]) : 'wslu_global_setting'; |
| 382 | |
| 383 | if($active_tab == 'wslu_providers') { |
| 384 | |
| 385 | $this->content_xs_providers(); |
| 386 | |
| 387 | } elseif($active_tab == 'wslu_style_setting') { |
| 388 | |
| 389 | $this->content_xs_style_setting(); |
| 390 | |
| 391 | } else { |
| 392 | |
| 393 | require_once(WSLU_LOGIN_PLUGIN . '/template/admin/global-setting.php'); |
| 394 | } |
| 395 | } |
| 396 | } |
| 397 | |
| 398 | |
| 399 | /** |
| 400 | * Method Name : content_xs_providers |
| 401 | * Method Details : content for social provider page |
| 402 | * |
| 403 | * |
| 404 | * @params : void |
| 405 | * @return : void |
| 406 | * |
| 407 | * @since : 1.0 |
| 408 | */ |
| 409 | public function content_xs_providers() { |
| 410 | $option_key = 'xs_provider_data'; |
| 411 | $message_provider = 'hide'; |
| 412 | |
| 413 | $enabled_providers = \WP_Social\App\Settings::get_enabled_provider_conf_login(); |
| 414 | |
| 415 | /** |
| 416 | * Legacy version support |
| 417 | * After 3/4 version we can hopefully delete the below if block |
| 418 | */ |
| 419 | if(empty($enabled_providers)) { |
| 420 | |
| 421 | $old_settings = \WP_Social\App\Settings::get_login_settings_data(); |
| 422 | |
| 423 | if(!empty($old_settings)) { |
| 424 | |
| 425 | $tmp = []; |
| 426 | |
| 427 | foreach($old_settings as $key => $info) { |
| 428 | |
| 429 | $tmp[$key]['enable'] = empty($info['enable']) ? '' : 1; |
| 430 | } |
| 431 | |
| 432 | \WP_Social\App\Settings::update_enabled_provider_conf_login($tmp); |
| 433 | |
| 434 | $enabled_providers = $tmp; |
| 435 | } |
| 436 | } |
| 437 | |
| 438 | |
| 439 | // save prodivers data in db |
| 440 | if(isset($_POST['xs_provider_submit_form'])) { |
| 441 | |
| 442 | $option_value = isset($_POST['xs_social']) ? self::sanitize($_POST['xs_social']) : []; |
| 443 | |
| 444 | if(update_option($option_key, $option_value, 'Yes')) { |
| 445 | $message_provider = 'show'; |
| 446 | } |
| 447 | } |
| 448 | |
| 449 | $saved_settings = \WP_Social\App\Settings::get_login_settings_data(); |
| 450 | $core_provider = \WP_Social\App\Providers::get_core_providers_login(); |
| 451 | |
| 452 | require_once(WSLU_LOGIN_PLUGIN . '/template/admin/providers-setting.php'); |
| 453 | } |
| 454 | |
| 455 | |
| 456 | /** |
| 457 | * Method Name : content_xs_style_setting |
| 458 | * Method Details : content for social provider style settings |
| 459 | * |
| 460 | */ |
| 461 | public function content_xs_style_setting() { |
| 462 | |
| 463 | $message_provider = 'hide'; |
| 464 | |
| 465 | if(isset($_POST['style_setting_submit_form'])) { |
| 466 | |
| 467 | if( !isset( $_POST['nonce'] ) || !wp_verify_nonce( $_POST['nonce'], 'style_setting_submit_form_nonce' ) ) { |
| 468 | return; |
| 469 | } |
| 470 | |
| 471 | $option_value = isset($_POST['xs_style']) ? self::sanitize($_POST['xs_style']) : []; |
| 472 | |
| 473 | if(update_option(Login_Settings::OK_STYLES, $option_value, 'yes')) { |
| 474 | $message_provider = 'show'; |
| 475 | } |
| 476 | } |
| 477 | |
| 478 | $saved_style = Login_Settings::instance()->get_style_settings(); |
| 479 | |
| 480 | |
| 481 | require_once(WSLU_LOGIN_PLUGIN . '/template/admin/style-setting.php'); |
| 482 | } |
| 483 | |
| 484 | |
| 485 | /** |
| 486 | * Method Name : content_xs_counter_setting |
| 487 | * Method Details : content for social provider style settings |
| 488 | * |
| 489 | * |
| 490 | */ |
| 491 | public function content_xs_counter_setting() { |
| 492 | $global_optionKey = 'xs_counter_global_setting_data'; |
| 493 | $message_global = 'hide'; |
| 494 | |
| 495 | if(isset($_POST['counter_settings_submit_form_global'])) { |
| 496 | |
| 497 | if( !isset( $_POST['nonce'] ) || !wp_verify_nonce( $_POST['nonce'], 'counter_settings_submit_form_global_nonce' ) ) { |
| 498 | return; |
| 499 | } |
| 500 | |
| 501 | $option_value_global = isset($_POST['xs_counter']) ? self::sanitize($_POST['xs_counter']) : []; |
| 502 | if(update_option($global_optionKey, $option_value_global, 'Yes')) { |
| 503 | $message_global = 'show'; |
| 504 | } |
| 505 | } |
| 506 | |
| 507 | // get returned global setting data from db |
| 508 | $return_data = get_option($global_optionKey); |
| 509 | |
| 510 | // wordpress role options |
| 511 | $active_tab = isset($_GET["tab"]) ? sanitize_text_field($_GET["tab"]) : 'wslu_global_setting'; |
| 512 | |
| 513 | if($active_tab == 'wslu_providers') { |
| 514 | $this->content_xs_providers_counter(); |
| 515 | } else { |
| 516 | if($active_tab == 'wslu_style_setting') { |
| 517 | $this->content_xs_style_setting_counter(); |
| 518 | } else { |
| 519 | require_once(WSLU_LOGIN_PLUGIN . '/template/admin/counter/counter-setting.php'); |
| 520 | } |
| 521 | } |
| 522 | } |
| 523 | |
| 524 | |
| 525 | public function export_users_content_csv() { |
| 526 | if(current_user_can('manage_options') && isset($_POST['wslu_export_users_list_nonce']) && wp_verify_nonce($_POST['wslu_export_users_list_nonce'],'wslu_export_users_list_nonce') && isset($_POST['provider'])) { |
| 527 | User_Helper::export_users_content_csv(sanitize_text_field($_POST['provider'])); |
| 528 | } |
| 529 | } |
| 530 | |
| 531 | /** |
| 532 | * Method Name : content_xs_settings |
| 533 | * Method Details : |
| 534 | * |
| 535 | * |
| 536 | * @params : void |
| 537 | * @return : void |
| 538 | * |
| 539 | * @since : 1.0 |
| 540 | */ |
| 541 | public function content_xs_settings() { |
| 542 | |
| 543 | $message_global = ''; |
| 544 | |
| 545 | if(!empty($_POST['sycn_setting'])) { |
| 546 | |
| 547 | if( !isset( $_POST['nonce'] ) || !wp_verify_nonce( $_POST['nonce'], 'sycn_setting_nonce' ) ) { |
| 548 | return; |
| 549 | } |
| 550 | |
| 551 | if(isset($_POST['sync'])) { |
| 552 | update_option('wp_social_login_sync', sanitize_key($_POST['sync'])); |
| 553 | } else { |
| 554 | update_option('wp_social_login_sync', 'no'); |
| 555 | } |
| 556 | |
| 557 | if(isset($_POST['sync_image'])) { |
| 558 | update_option('wp_social_login_sync_image_too', sanitize_key($_POST['sync_image'])); |
| 559 | } else { |
| 560 | update_option('wp_social_login_sync_image_too', 'no'); |
| 561 | } |
| 562 | $message_global = 'show'; |
| 563 | } |
| 564 | require_once(WSLU_LOGIN_PLUGIN . '/template/admin/settings.php'); |
| 565 | } |
| 566 | |
| 567 | /** |
| 568 | * Method Name : content_xs_providers_counter |
| 569 | * Method Details : content for social provider counter settings |
| 570 | * |
| 571 | * |
| 572 | * @params : void |
| 573 | * @return : void |
| 574 | * |
| 575 | * @since : 1.0 |
| 576 | */ |
| 577 | public function content_xs_providers_counter() { |
| 578 | |
| 579 | $counter = new Counter(false); |
| 580 | $counter_social_items = $counter->xs_counter_providers(); |
| 581 | $counter_provider = \WP_Social\App\Settings::get_counter_provider_settings(); |
| 582 | |
| 583 | $option_key = 'xs_counter_providers_data'; |
| 584 | $message_provider = 'hide'; |
| 585 | |
| 586 | $enabled_providers = get_option(Settings::$ok_enabled_providers_counter, []); |
| 587 | |
| 588 | /** |
| 589 | * Legacy version support |
| 590 | * After 3/4 version we can hopefully delete the below if block |
| 591 | */ |
| 592 | if(empty($enabled_providers)) { |
| 593 | |
| 594 | $old_settings = get_option($option_key, []); |
| 595 | |
| 596 | if(!empty($old_settings['social'])) { |
| 597 | |
| 598 | $tmp = []; |
| 599 | |
| 600 | foreach($old_settings['social'] as $key => $info) { |
| 601 | |
| 602 | $tmp[$key]['enable'] = empty($info['enable']) ? '' : 1; |
| 603 | } |
| 604 | |
| 605 | update_option(Settings::$ok_enabled_providers_counter, $tmp); |
| 606 | |
| 607 | $enabled_providers = $tmp; |
| 608 | } |
| 609 | } |
| 610 | |
| 611 | |
| 612 | /** |
| 613 | * Here saves all the counter providers updated settings |
| 614 | * |
| 615 | */ |
| 616 | if(isset($_POST['counter_settings_submit_form'])) { |
| 617 | |
| 618 | $option_value = isset($_POST['xs_counter']) ? self::sanitize($_POST['xs_counter']) : []; |
| 619 | |
| 620 | if(update_option($option_key, $option_value, 'yes')) { |
| 621 | |
| 622 | $message_provider = 'show'; |
| 623 | } |
| 624 | } |
| 625 | |
| 626 | |
| 627 | $xsc_options = get_option($option_key, []); |
| 628 | |
| 629 | $counter_provider = isset($xsc_options['social']) ? $xsc_options['social'] : $counter_social_items; |
| 630 | |
| 631 | $saved_settings = get_option($option_key, []); |
| 632 | |
| 633 | $core_provider = \WP_Social\App\Providers::get_core_providers_count(); |
| 634 | |
| 635 | $getType = isset($_GET['xs_access']) ? self::sanitize($_GET['xs_access']) : ''; |
| 636 | |
| 637 | require_once(WSLU_LOGIN_PLUGIN . '/template/admin/counter/providers-counter.php'); |
| 638 | } |
| 639 | |
| 640 | |
| 641 | /** |
| 642 | * Method Name : content_xs_style_setting |
| 643 | * Method Details : content for social provider style settings |
| 644 | * |
| 645 | * @params : void |
| 646 | * @return : void |
| 647 | * |
| 648 | * @since : 1.0 |
| 649 | */ |
| 650 | public function content_xs_style_setting_counter() { |
| 651 | |
| 652 | $option_key = 'xs_style_setting_data_counter'; |
| 653 | $message_provider = 'hide'; |
| 654 | |
| 655 | //save providers data in db |
| 656 | if(isset($_POST['style_setting_submit_form'])) { |
| 657 | |
| 658 | if( !isset( $_POST['nonce'] ) || !wp_verify_nonce( $_POST['nonce'], 'style_setting_submit_form_counter_nonce' ) ) { |
| 659 | return; |
| 660 | } |
| 661 | |
| 662 | $option_value = isset($_POST['xs_style']) ? self::sanitize($_POST['xs_style']) : []; |
| 663 | if(update_option($option_key, $option_value, 'Yes')) { |
| 664 | $message_provider = 'show'; |
| 665 | } |
| 666 | } |
| 667 | |
| 668 | |
| 669 | $return_data = Counter_Settings::instance()->get_style_settings(); |
| 670 | |
| 671 | // style type settings |
| 672 | $styleArr = self::counter_styles(); |
| 673 | |
| 674 | // prodiver settings data |
| 675 | $return_data_prodivers = Settings::get_login_settings_data(); |
| 676 | |
| 677 | if(empty($return_data['login_button_style']['style'])) { |
| 678 | $return_data = []; |
| 679 | $return_data['login_button_style']['style'] = 'style-1:top-tooltip'; |
| 680 | } |
| 681 | |
| 682 | $styleAndEffect = explode(':', $return_data['login_button_style']['style']); |
| 683 | $selectedStyle = $styleAndEffect[0]; |
| 684 | $selectedEffect = empty($styleAndEffect[1]) ? 'top-tooltip' : $styleAndEffect[1]; |
| 685 | |
| 686 | |
| 687 | if(did_action('wslu_social_pro/plugin_loaded')) { |
| 688 | |
| 689 | // Counter Hover effect list |
| 690 | if( method_exists( \WP_Social_Pro\Inc\Admin_Settings::class, 'counter_hover_effects' ) ){ |
| 691 | |
| 692 | $share_hover_effects = \WP_Social_Pro\Inc\Admin_Settings::counter_hover_effects(); |
| 693 | |
| 694 | }else{ |
| 695 | |
| 696 | $share_hover_effects = \WP_Social_Pro\Inc\Admin_Settings::$counter_hover_effects; |
| 697 | |
| 698 | } |
| 699 | } |
| 700 | |
| 701 | require_once(WSLU_LOGIN_PLUGIN . '/template/admin/counter/style-setting.php'); |
| 702 | } |
| 703 | |
| 704 | |
| 705 | /** |
| 706 | * Method Name : content_xs_share_setting |
| 707 | * Method Details : content for social provider style settings for share |
| 708 | * |
| 709 | * @params : void |
| 710 | * @return : void |
| 711 | * |
| 712 | * @since : 1.0 |
| 713 | */ |
| 714 | public function content_xs_share_setting() { |
| 715 | |
| 716 | $global_optionKey = 'xs_share_global_setting_data'; |
| 717 | $message_global = 'hide'; |
| 718 | |
| 719 | if(isset($_POST['share_global_setting_submit_form'])) { |
| 720 | |
| 721 | if( !isset( $_POST['nonce'] ) || !wp_verify_nonce( $_POST['nonce'], 'share_global_setting_submit_form_nonce' ) ) { |
| 722 | return; |
| 723 | } |
| 724 | |
| 725 | $option_value_global = isset($_POST['xs_share']) ? self::sanitize($_POST['xs_share']) : []; |
| 726 | if(update_option($global_optionKey, $option_value_global, 'Yes')) { |
| 727 | $message_global = 'show'; |
| 728 | } |
| 729 | } |
| 730 | |
| 731 | // get returned global setting data from db |
| 732 | $return_data = get_option($global_optionKey); |
| 733 | |
| 734 | // wordpress role options |
| 735 | $active_tab = isset($_GET["tab"]) ? sanitize_text_field($_GET["tab"]) : 'wslu_global_setting'; |
| 736 | |
| 737 | if($active_tab == 'wslu_providers') { |
| 738 | $this->content_xs_share_provider(); |
| 739 | |
| 740 | } elseif($active_tab == 'wslu_style_setting') { |
| 741 | $this->content_xs_style_setting_share(); |
| 742 | |
| 743 | } else { |
| 744 | require_once(WSLU_LOGIN_PLUGIN . '/template/admin/share/share-setting.php'); |
| 745 | } |
| 746 | } |
| 747 | |
| 748 | |
| 749 | /** |
| 750 | * Social share providers |
| 751 | * |
| 752 | * |
| 753 | */ |
| 754 | public function content_xs_share_provider() { |
| 755 | $share = new Share(false); |
| 756 | $counter_social_items = $share->social_share_link(); |
| 757 | |
| 758 | $option_key = 'xs_share_providers_data'; |
| 759 | $message_provider = 'hide'; |
| 760 | $saved_settings = get_option($option_key, []); |
| 761 | $enabled_providers = get_option(Settings::$ok_enabled_providers_share, []); |
| 762 | |
| 763 | /** |
| 764 | * Legacy version support |
| 765 | * After 3/4 version we can hopefully delete the below if block |
| 766 | */ |
| 767 | if(empty($enabled_providers)) { |
| 768 | |
| 769 | $old_settings = get_option($option_key, []); |
| 770 | |
| 771 | if(!empty($old_settings['social'])) { |
| 772 | |
| 773 | $tmp = []; |
| 774 | |
| 775 | foreach($old_settings['social'] as $key => $info) { |
| 776 | |
| 777 | $tmp[$key]['enable'] = empty($info['enable']) ? '' : 1; |
| 778 | } |
| 779 | |
| 780 | update_option(Settings::$ok_enabled_providers_share, $tmp); |
| 781 | |
| 782 | $enabled_providers = $tmp; |
| 783 | } |
| 784 | } |
| 785 | |
| 786 | if(isset($_POST['share_settings_submit_form'])) { |
| 787 | |
| 788 | $option_value = isset($_POST['xs_share']) ? self::sanitize($_POST['xs_share']) : []; |
| 789 | |
| 790 | if(update_option($option_key, $option_value, true)) { |
| 791 | $message_provider = 'show'; |
| 792 | $saved_settings = $option_value; |
| 793 | } |
| 794 | } |
| 795 | |
| 796 | // get returned data from db |
| 797 | $xsc_options = get_option($option_key) ? get_option($option_key) : []; |
| 798 | $share_provider = isset($xsc_options['social']) ? $xsc_options['social'] : $counter_social_items; |
| 799 | $core_provider = \WP_Social\App\Providers::get_core_providers_share(); |
| 800 | |
| 801 | $getType = isset($_GET['xs_access']) ? self::sanitize($_GET['xs_access']) : ''; |
| 802 | |
| 803 | require_once(WSLU_LOGIN_PLUGIN . '/template/admin/share/share-providers.php'); |
| 804 | } |
| 805 | |
| 806 | /** |
| 807 | * Method Name : content_xs_style_setting |
| 808 | * Method Details : content for social provider style settings |
| 809 | * |
| 810 | * @params : void |
| 811 | * @return : void |
| 812 | * |
| 813 | * @since : 1.0 |
| 814 | */ |
| 815 | public function content_xs_style_setting_share() { |
| 816 | |
| 817 | $option_key = 'xs_style_setting_data_share'; |
| 818 | $message_provider = 'hide'; |
| 819 | |
| 820 | // save providers data in db |
| 821 | if(isset($_POST['style_setting_submit_form'])) { |
| 822 | |
| 823 | if( !isset( $_POST['nonce'] ) || !wp_verify_nonce( $_POST['nonce'], 'style_setting_submit_form_share_nonce' ) ) { |
| 824 | return; |
| 825 | } |
| 826 | |
| 827 | $option_value = isset($_POST['xs_style']) ? self::sanitize($_POST['xs_style']) : []; |
| 828 | if(update_option($option_key, $option_value, 'Yes')) { |
| 829 | $message_provider = 'show'; |
| 830 | } |
| 831 | } |
| 832 | |
| 833 | // get returned data from db |
| 834 | $return_data = get_option($option_key); |
| 835 | |
| 836 | // style type settings |
| 837 | $styleArr = self::share_styles(); |
| 838 | |
| 839 | // prodiver settings data |
| 840 | $return_data_prodivers = Settings::get_login_settings_data(); |
| 841 | |
| 842 | if(did_action('wslu_social_pro/plugin_loaded')) { |
| 843 | |
| 844 | // Share Hover effect list |
| 845 | if( method_exists( \WP_Social_Pro\Inc\Admin_Settings::class, 'share_hover_effects' ) ){ |
| 846 | |
| 847 | $share_hover_effects = \WP_Social_Pro\Inc\Admin_Settings::share_hover_effects(); |
| 848 | |
| 849 | }else{ |
| 850 | |
| 851 | $share_hover_effects = \WP_Social_Pro\Inc\Admin_Settings::$share_hover_effects; |
| 852 | |
| 853 | } |
| 854 | |
| 855 | } |
| 856 | |
| 857 | if(empty($return_data['main_content']['style'])) { |
| 858 | $return_data['main_content']['style'] = 'style-1:none-none:horizontal'; |
| 859 | } |
| 860 | if(empty($return_data['fixed_display']['style'])) { |
| 861 | $return_data['fixed_display']['style'] = 'style-1:none-none:vertical'; |
| 862 | } |
| 863 | |
| 864 | |
| 865 | $styleAndEffect = explode(':', $return_data['main_content']['style']); |
| 866 | $mainEffect = empty($styleAndEffect[1]) ? 'none-none' : $styleAndEffect[1]; |
| 867 | |
| 868 | require_once(WSLU_LOGIN_PLUGIN . '/template/admin/share/style-setting.php'); |
| 869 | } |
| 870 | |
| 871 | |
| 872 | public static function sanitize($value, $senitize_func = 'sanitize_text_field') { |
| 873 | $senitize_func = (in_array($senitize_func, [ |
| 874 | 'sanitize_email', |
| 875 | 'sanitize_file_name', |
| 876 | 'sanitize_hex_color', |
| 877 | 'sanitize_hex_color_no_hash', |
| 878 | 'sanitize_html_class', |
| 879 | 'sanitize_key', |
| 880 | 'sanitize_meta', |
| 881 | 'sanitize_mime_type', |
| 882 | 'sanitize_sql_orderby', |
| 883 | 'sanitize_option', |
| 884 | 'sanitize_text_field', |
| 885 | 'sanitize_title', |
| 886 | 'sanitize_title_for_query', |
| 887 | 'sanitize_title_with_dashes', |
| 888 | 'sanitize_user', |
| 889 | 'esc_url_raw', |
| 890 | 'wp_filter_nohtml_kses', |
| 891 | ])) ? $senitize_func : 'sanitize_text_field'; |
| 892 | |
| 893 | if(!is_array($value)) { |
| 894 | return $senitize_func($value); |
| 895 | } else { |
| 896 | return array_map(function ($inner_value) use ($senitize_func) { |
| 897 | return self::sanitize($inner_value, $senitize_func); |
| 898 | }, $value); |
| 899 | } |
| 900 | } |
| 901 | |
| 902 | |
| 903 | public function content_xs_data_migration() { |
| 904 | |
| 905 | $migration = new Migration(); |
| 906 | |
| 907 | $ret = $migration->input('wp-social', '1.3.3', '1.3.5'); |
| 908 | |
| 909 | require_once(WSLU_LOGIN_PLUGIN . '/xs_migration/markup/data-conversion.php'); |
| 910 | |
| 911 | } |
| 912 | |
| 913 | public function sort_providers_login() { |
| 914 | |
| 915 | if ( ! isset($_POST['wslu_provider_nonce'] ) || ( isset($_POST['wslu_provider_nonce']) && ! wp_verify_nonce( $_POST['wslu_provider_nonce'], 'wp_rest' )) || ! current_user_can( 'manage_options' ) ) { |
| 916 | return; |
| 917 | } |
| 918 | |
| 919 | $providers = array_map('sanitize_key', $_POST['providers']); |
| 920 | |
| 921 | return update_option(Providers::ORDER_LIST_PROVIDER_LOGIN, $providers); |
| 922 | } |
| 923 | |
| 924 | public function sort_providers_share() { |
| 925 | |
| 926 | if ( ! isset($_POST['wslu_provider_nonce'] ) || ( isset($_POST['wslu_provider_nonce']) && ! wp_verify_nonce( $_POST['wslu_provider_nonce'], 'wp_rest' )) || ! current_user_can( 'manage_options' )) { |
| 927 | return; |
| 928 | } |
| 929 | |
| 930 | $providers = array_map('sanitize_key', $_POST['providers']); |
| 931 | |
| 932 | return update_option(Providers::ORDER_LIST_PROVIDER_SHARE, $providers); |
| 933 | } |
| 934 | |
| 935 | public function sort_providers_counter() { |
| 936 | |
| 937 | if ( ! isset($_POST['wslu_provider_nonce'] ) || ( isset($_POST['wslu_provider_nonce']) && ! wp_verify_nonce( $_POST['wslu_provider_nonce'], 'wp_rest' )) || ! current_user_can( 'manage_options' ) ) { |
| 938 | return; |
| 939 | } |
| 940 | |
| 941 | $providers = array_map('sanitize_key', $_POST['providers']); |
| 942 | |
| 943 | update_option(Counter::ORDER_LIST_PROVIDER_COUNTER, $providers); // frontend sort |
| 944 | |
| 945 | return update_option(Providers::ORDER_LIST_PROVIDER_COUNTER, $providers); // backend sort |
| 946 | } |
| 947 | |
| 948 | } |
| 949 | |
| 950 |