login-btn-html.php
93 lines
| 1 | <?php |
| 2 | |
| 3 | use WP_Social\Lib\Login\Line_App; |
| 4 | |
| 5 | defined('ABSPATH') || exit; |
| 6 | |
| 7 | // $buttonStyle is the styles selected by user example: style-1 || style-2 || style-3 |
| 8 | $currentStyle = empty($force_style) ? (isset($style_data['login_button_style']) ? $style_data['login_button_style'] : 'style-1') : $force_style; |
| 9 | |
| 10 | // parent class of login button container |
| 11 | $className = 'xs-login xs-login--' . $currentStyle; |
| 12 | ?> |
| 13 | <div id="xs-social-login-container"> |
| 14 | <div class="<?php echo esc_attr($className); ?>"> |
| 15 | <?php |
| 16 | |
| 17 | if(!is_user_logged_in()) { |
| 18 | |
| 19 | $url_params = ''; |
| 20 | |
| 21 | if(empty($_GET['redirect_to'])) { |
| 22 | |
| 23 | $custom_url = xs_current_url_custom(); |
| 24 | |
| 25 | if(strlen($custom_url) > 2) { |
| 26 | if($typeCurrent == 'show') { |
| 27 | $url_params = '?XScurrentPage=' . $custom_url; |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | } else { |
| 32 | |
| 33 | $url_params = '?redirect_to=' . urlencode(urldecode($_GET['redirect_to'])); |
| 34 | } |
| 35 | |
| 36 | $core_provider = \WP_Social\App\Providers::get_core_providers_login(); |
| 37 | $enabled_providers = \WP_Social\App\Settings::get_enabled_provider_conf_login(); |
| 38 | |
| 39 | /** |
| 40 | * todo - below there are some bujruki code need to change it, style icon set info also should come from array |
| 41 | * |
| 42 | */ |
| 43 | |
| 44 | // loop through all the provides |
| 45 | foreach($core_provider AS $keyType => $valueType): |
| 46 | // check if the provider enable |
| 47 | if(!empty($enabled_providers[$keyType]['enable'])): |
| 48 | |
| 49 | if(in_array('all', $attr_provider) || in_array($keyType, $attr_provider)) { |
| 50 | |
| 51 | /* |
| 52 | ------------------------------------------ |
| 53 | arrange necessary info for all buttons |
| 54 | ---------------------------------------- |
| 55 | */ |
| 56 | $args = [ |
| 57 | 'label' => isset($provider_data[$keyType]['login_label']) ? $provider_data[$keyType]['login_label'] : 'Login with <b>' . $valueType . '</b>', |
| 58 | 'icon' => '<i class="met-social met-social-' . $keyType . '"></i>', |
| 59 | 'clrClass' => 'wslu-color-scheme--' . $keyType, |
| 60 | ]; |
| 61 | |
| 62 | |
| 63 | if($valueType == 'LineApp') { |
| 64 | $line = new Line_App(); |
| 65 | $args['url'] = $line->get_auth_url(get_site_url() . '/wp-json/wslu-social-login/type/' . $keyType); |
| 66 | |
| 67 | } else { |
| 68 | $args['url'] = get_site_url() . '/wp-json/wslu-social-login/type/' . $keyType . '' . $url_params; |
| 69 | } |
| 70 | |
| 71 | /* |
| 72 | ------------------------------------------------------- |
| 73 | -require a specific markup file that contain the style |
| 74 | -markup file name and style key must be same |
| 75 | ------------------------------------------------------ |
| 76 | */ |
| 77 | $style_file_path = WSLU_LOGIN_PLUGIN . '/template/login/screens/default.php'; |
| 78 | |
| 79 | require($style_file_path); |
| 80 | } |
| 81 | endif; |
| 82 | endforeach; |
| 83 | } else { |
| 84 | $correntUrlLogout = esc_url(xs_current_url_custom()); |
| 85 | ?> |
| 86 | <div><a class="wslu-logout-button" |
| 87 | rel="nofollow" |
| 88 | href="<?php echo esc_url(wp_logout_url($correntUrlLogout)); ?>"><?php echo esc_html__('Logout', 'wp-social'); ?></a> |
| 89 | </div> <?php |
| 90 | } ?> |
| 91 | </div> |
| 92 | </div> |
| 93 |