PluginProbe
Loginizer / trunk
Loginizer vtrunk
2.1.0 2.0.9 2.0.8 1.9.8 1.9.9 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 trunk 1.0 1.0.1 1.0.2 1.1.0 1.1.1 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 All 74 releases
loginizer / main / settings / social_login.php

social_login.php in Loginizer trunk, at main/settings/social_login.php

678 lines 41.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if(!defined('ABSPATH')){
4 die('HACKING ATTEMPT!');
5 }
6
7 function loginizer_social_login(){
8
9 if(!current_user_can('manage_options')){
10 wp_die('Sorry, but you do not have permissions to change settings.');
11 }
12
13 if(defined('LOGINIZER_PREMIUM') && file_exists(LOGINIZER_PRO_DIR . '/main/settings/social_login.php')){
14 include_once LOGINIZER_PRO_DIR . '/main/settings/social_login.php';
15 }
16
17 $script_data = [
18 'nonce' => wp_create_nonce('loginizer_social_nonce'),
19 'ajax_url' => admin_url('admin-ajax.php')
20 ];
21
22 wp_localize_script('loginizer_social_script', 'loginizer_social', $script_data);
23
24 loginizer_page_header('Social Login Settings');
25
26 do_action('loginizer_pro_social_auth_notice');
27
28 echo '<div class="tabs-wrapper" style="margin-bottom:10px; width:100%;">
29 <nav class="nav-tab-wrapper">
30 <a href="?page=loginizer_social_login" class="nav-tab '.(isset($_GET['settings']) ? '' : 'nav-tab-active').'">Provider</a>
31 <a href="?page=loginizer_social_login&settings=global" class="nav-tab '.(isset($_GET['settings']) ? 'nav-tab-active' : '').'">Settings</a>
32 </nav>
33 </div>';
34
35 // Handling Settings Page
36 if(!empty($_GET['settings'])){
37 loginizer_general_settings();
38
39 return;
40 }
41
42 // Contains the list of all the providers
43 include_once LOGINIZER_DIR . '/main/login-providers.php';
44
45 if(empty($loginizer_login_providers)){
46 echo '<p>' . esc_html__('Something went wrong can\'t load social App details', 'loginizer') . '</p>';
47 return;
48 }
49
50 // Handling Provider settings.
51 if(!empty($_GET['provider'])){
52 $provider_page = sanitize_text_field($_GET['provider']);
53 loginizer_provider_settings($provider_page, $loginizer_login_providers);
54
55 return;
56 }
57
58 $provider_settings = get_option('loginizer_provider_settings', []);
59 $provider_order = get_option('loginizer_social_order', []);
60
61 $providers = [];
62
63 // Sorting according to the saved order of the providers.
64 if(!empty($provider_order)){
65 foreach($provider_order as $key => $num){
66 if(!empty($loginizer_login_providers[$key])){
67 $providers[$key] = $loginizer_login_providers[$key];
68 }
69 }
70
71 // TODO:: There is some issue here.
72 // To check if something new was added and will be added at the last.
73 $remaining = array_diff(array_keys($loginizer_login_providers), array_keys($providers));
74
75 if(!empty($remaining)){
76 foreach($remaining as $new_social){
77 $providers[$new_social] = $loginizer_login_providers[$new_social];
78 }
79 }
80
81 } else {
82 $providers = $loginizer_login_providers;
83 }
84
85 // ------ HTML STARTS HERE -------- //
86
87 echo '<div class="loginizer-social-wrapper">';
88
89 // Image used here is supposed to be same as the key in png format.
90 foreach($providers as $key => $provider){
91
92 $action_class = '';
93 $action_text = __('Get Started', 'loginizer');
94 if(array_key_exists($key, $provider_settings)){
95 $action_text = __('Settings', 'loginizer');
96 }
97
98 $action_to = admin_url('admin.php?page=loginizer_social_login&provider='.$key);
99 if(!empty($provider['premium']) && !defined('LOGINIZER_PREMIUM')){
100 $action_text = __('Upgrade to Pro');
101 $action_class = ' button-primary'; // Have added space here at the start of the string
102 $action_to = 'https://loginizer.com/pricing';
103 }
104
105 echo '<div class="loginizer-social-provider" data-provider="'.esc_attr($key).'">
106 <div class="loginizer-social-logo" style="background-color:'.esc_attr($provider['color']).';">
107 <div class="loginizer-social-grip">
108 <svg version="1.2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 100" fill="#d3d3d3" width="12" height="25"><path d="m12.5 27c-4.7 0-8.5-3.8-8.5-8.5 0-4.7 3.8-8.5 8.5-8.5 4.7 0 8.5 3.8 8.5 8.5 0 4.7-3.8 8.5-8.5 8.5zm0 25c-4.7 0-8.5-3.8-8.5-8.5 0-4.7 3.8-8.5 8.5-8.5 4.7 0 8.5 3.8 8.5 8.5 0 4.7-3.8 8.5-8.5 8.5zm0 28c-4.7 0-8.5-3.8-8.5-8.5 0-4.7 3.8-8.5 8.5-8.5 4.7 0 8.5 3.8 8.5 8.5 0 4.7-3.8 8.5-8.5 8.5zm25-53c-4.7 0-8.5-3.8-8.5-8.5 0-4.7 3.8-8.5 8.5-8.5 4.7 0 8.5 3.8 8.5 8.5 0 4.7-3.8 8.5-8.5 8.5zm0 25c-4.7 0-8.5-3.8-8.5-8.5 0-4.7 3.8-8.5 8.5-8.5 4.7 0 8.5 3.8 8.5 8.5 0 4.7-3.8 8.5-8.5 8.5zm0 28c-4.7 0-8.5-3.8-8.5-8.5 0-4.7 3.8-8.5 8.5-8.5 4.7 0 8.5 3.8 8.5 8.5 0 4.7-3.8 8.5-8.5 8.5z"/></svg>
109 </div>';
110 if(array_key_exists($key, $provider_settings) && loginizer_show_social_status($loginizer_login_providers[$key])){
111 if(!empty($provider_settings[$key]['enabled']) && !empty($provider_settings[$key]['tested'])){
112 echo '<div class="loginizer-social-provider-state loginizer-social-provider-state-enabled">Enabled</div>';
113 } elseif(!empty($provider_settings[$key]['enabled']) && empty($provider_settings[$key]['tested'])){
114 echo '<div class="loginizer-social-provider-state loginizer-social-provider-state-pending">Pending</div>';
115 } else {
116 echo '<div class="loginizer-social-provider-state loginizer-social-provider-state-disabled">Disabled</div>';
117 }
118 }
119
120 echo '<div class="loginizer-social-saving-order">'.esc_html__('Saving Order', 'loginizer').'...</div>
121 <img src="'.esc_url(LOGINIZER_URL . '/assets/images/social/'.$key.'.png').'" height="60" alt="'.esc_attr($provider['name']).'" style="'.(($provider['name'] === 'Google') ? 'background-color:white; padding:3px;' : '').'"/>
122 </div>
123 <div class="loginizer-social-provider-action"><h2>'.esc_html($provider['name']).'</h2>
124 <a href="'.esc_url($action_to).'" class="button'.esc_attr($action_class).'">'.esc_html($action_text).'</a></div>
125 </div>';
126 }
127
128 echo '</div>';
129
130 loginizer_page_footer();
131 }
132
133 // Settings page for every Social Provider.
134 function loginizer_provider_settings($provider, $provider_defaults){
135
136 $provider_settings = get_option('loginizer_provider_settings', []);
137
138 if(empty($provider_settings)){
139 update_option('loginizer_social_login_url', wp_login_url());
140 }
141
142 if(!empty($_GET['test'])){
143 $provider_settings[$provider]['tested'] = true;
144 update_option('loginizer_provider_settings', $provider_settings);
145 }
146
147 // Checking for the Pro version for the specific Provider
148 if(!defined('LOGINIZER_PREMIUM') && (empty($provider_defaults[$provider]) || !empty($provider_defaults[$provider]['premium']))){
149 loginizer_feature_available($provider_defaults[$provider]['name'] . ' Social Login Provider');
150 loginizer_page_footer();
151 return;
152 }
153
154 if(!empty($_POST['lz_save_social_provider'])){
155 if(!check_admin_referer('loginizer_social_nonce', 'security')){
156 $error[] = __('Security Check failed', 'loginizer');
157 } else {
158 if(empty($provider_settings[$provider])){
159 $provider_settings[$provider] = []; // initializing
160 $provider_settings[$provider]['tested'] = false;
161 }
162
163 // Need to make the user to test the login again if the key gets changed, if keys gets dirty
164 if(
165 (isset($provider_settings[$provider]['client_id']) && $provider_settings[$provider]['client_id'] != sanitize_text_field(wp_unslash($_POST['client_id']))) ||
166 (isset($provider_settings[$provider]['client_secret']) && $provider_settings[$provider]['client_secret'] != sanitize_text_field(wp_unslash($_POST['client_secret'])))
167 ){
168 $provider_settings[$provider]['tested'] = false;
169 }
170
171 $provider_settings[$provider]['client_id'] = !empty($_POST['client_id']) ? sanitize_text_field(wp_unslash($_POST['client_id'])) : '';
172 $provider_settings[$provider]['client_secret'] = !empty($_POST['client_secret']) ? sanitize_text_field(wp_unslash($_POST['client_secret'])) : '';
173 $provider_settings[$provider]['enabled'] = !empty($_POST['provider_enabled']) ? true : false;
174
175 if(defined('LOGINIZER_PREMIUM')){
176 $provider_settings = apply_filters('loginizer_pro_save_provider_settings', $provider_settings, $provider);
177 }
178
179 $provider_settings[$provider]['button_style'] = !empty($_POST['button_style']) ? lz_optpost('button_style') : 'default';
180
181 // Making sure we save enable only when required settings are there
182 if(!empty($provider_settings[$provider]['enabled'])){
183 if(
184 (empty($provider_settings[$provider]['client_secret']) ||
185 empty($provider_settings[$provider]['client_id'])) &&
186 empty($provider_settings[$provider]['loginizer_social_key'])
187 ){
188 $provider_settings[$provider]['tested'] = false;
189 $provider_settings[$provider]['enabled'] = false;
190 }
191 }
192
193 update_option('loginizer_provider_settings', $provider_settings);
194
195 $saved = true;
196 }
197
198 if(!empty($error)){
199 lz_report_error($error);
200 }
201
202 if(!empty($saved)){
203 echo '<div id="message" class="updated"><p>'
204 . esc_html__('The settings were saved successfully', 'loginizer')
205 . '</p></div><br />';
206 }
207 }
208
209 if(!empty($provider_settings[$provider]) && !empty($provider_settings[$provider]['enabled']) && empty($provider_settings[$provider]['tested'])){
210 $social_nonce = wp_create_nonce('loginizer_social_check');
211
212 wp_register_script('loginizer-social-test', '', ['jquery'], LOGINIZER_VERSION, ['strategy' => false, 'in_footer' => true]);
213 wp_enqueue_script('loginizer-social-test');
214 wp_add_inline_script('loginizer-social-test', '
215 function loginizer_auth_test_popup() {
216 let screenX = window.screenX !== undefined ? window.screenX : window.screenLeft,
217 screenY = window.screenY !== undefined ? window.screenY : window.screenTop,
218 outer_width = window.outerWidth !== undefined ? window.outerWidth : document.documentElement.clientWidth,
219 outer_height = window.outerHeight !== undefined ? window.outerHeight : document.documentElement.clientHeight - 22,
220 target_width = 600,
221 target_height = 600,
222 right = parseInt(screenY + (outer_height - target_height) / 2.5, 10),
223 left = parseInt(screenX + (outer_width - target_width) / 2, 10),
224 attributes = [];
225
226 if (target_width !== null) {
227 attributes.push("width=" + target_width);
228 }
229 if (target_height !== null) {
230 attributes.push("height=" + target_height);
231 }
232 attributes.push("left=" + left);
233 attributes.push("top=" + right);
234 attributes.push("scrollbars=1");
235
236 var social_window = window.open("'.esc_url(wp_login_url()).'?lz_social_provider='.esc_html($provider).'&test=true&social_security='.esc_html($social_nonce).'&ref='.esc_url($_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']).'", "socialWindow", attributes.join(","));
237
238 if(window.focus){
239 social_window.focus();
240 }
241 return false;
242 }'
243 );
244 }
245
246 echo '<a href="'.esc_url(admin_url('admin.php?page=loginizer_social_login')).'">&#8592; '.esc_html__('Go Back', 'loginizer').'</a>';
247
248 if(!empty($provider_settings[$provider]) && !empty($provider_settings[$provider]['enabled']) && empty($provider_settings[$provider]['tested']) && empty($provider_settings[$provider]['loginizer_social_key'])){
249 echo '<div class="loginizer-social-test-alert">
250 <h3>'.sprintf(esc_html__('Test %s to be able to use it', 'loginizer'), esc_html($provider_defaults[$provider]['name'])).'</h3>
251 <p>'.esc_html__('You have added/updated the keys of this provider so you will need to test it to be able to use it.', 'loginizer').'</p>
252 <p>'.esc_html__('Please use the same email with which you have created this account.', 'loginizer').'</p>
253 <button class="button button-primary" id="loginizer-test-provider-btn" onclick="loginizer_auth_test_popup()">'.esc_html__('Test Now', 'loginizer').'</button>
254 </div>';
255 }
256
257 echo '<div style="display:flex; justify-content:space-between;">
258 <div style="width:"50%;">
259 <h3>'.esc_html($provider_defaults[$provider]['name']).' Settings</h3>
260
261 <form method="POST">
262 <table class="form-table">
263 <tr>
264 <th scope="row"><label for="provider_enabled">Enable</label></th>
265 <td><input type="checkbox" name="provider_enabled" id="provider_enabled" '.(!empty($provider_settings[$provider]['enabled']) ? 'checked' : '').' value="1"/></td>
266 </tr>';
267
268 $display_keys = '';
269 // Loginizer Social Auth Input
270 $lz_social_key_providers = function_exists('loginizer_pro_social_auth_providers') ? loginizer_pro_social_auth_providers() : [];
271
272 if(in_array($provider, $lz_social_key_providers)){
273 if(empty($provider_settings[$provider])){
274 $provider_settings[$provider] = [];
275 }
276
277 do_action('loginizer_pro_social_api_settings', $provider_settings[$provider], $provider);
278
279 if(!empty($provider_settings[$provider]['loginizer_social_key'])){
280 $display_keys = 'display:none;';
281 }
282 }
283
284 echo '<tr style="'.esc_attr($display_keys).'">
285 <th scope="row"><label for="loginizer_social_client_id">Client ID</label></th>
286 <td><input type="text" name="client_id" id="loginizer_social_client_id" value="'.(!empty($provider_settings[$provider]['client_id']) ? esc_attr($provider_settings[$provider]['client_id']) : '').'"/></td>
287 </tr>
288 <tr style="'.esc_attr($display_keys).'">
289 <th scope="row"><label for="loginizer_social_client_secret">Client Secret</label></th>
290 <td><input type="text" name="client_secret" id="loginizer_social_client_secret" value="'.(!empty($provider_settings[$provider]['client_secret']) ? esc_attr($provider_settings[$provider]['client_secret']) : '').'"/></td>
291 </tr>
292 <tr>
293 <th scope="row"><label for="button_style_default">Button Style</label></th>
294 <td>';
295 $styles = $provider_defaults[$provider]['styles'];
296
297 foreach($styles as $style => $style_css){
298 echo '<label style="padding:20px 20px 20px 0"><input type="radio" name="button_style" id="button_style_'.esc_attr($style).'" value="'.esc_attr($style).'" '.((empty($provider_settings[$provider]['button_style'])) ? 'checked' : checked($provider_settings[$provider]['button_style'], $style, false)).'/>'.esc_attr(ucfirst($style)).'</label>';
299 }
300 echo '</td>
301 </tr>';
302
303 if($provider == 'MicrosoftGraph'){
304 echo '<tr style="'.esc_attr($display_keys).'">
305 <th scope="row"><label for="loginizer_social_ms_account_type">'.esc_html__('Account Type', 'loginizer').'</label>
306 <p class="description">'.esc_html__('Which type of accounts you want to allow to be able to signin', 'loginizer').'</p></th>
307 <td style="display:block;"><label><input type="radio" name="account_type" value="organizations" '.(!empty($provider_settings[$provider]['account_type']) ? checked($provider_settings[$provider]['account_type'], 'organizations', false) : '').'/>'.esc_html__('Accounts in any Organizational directory', 'loginizer').'</label></td>
308 <td style="display:block;"><label><input type="radio" name="account_type" value="common" '.(!empty($provider_settings[$provider]['account_type']) ? checked($provider_settings[$provider]['account_type'], 'common', false) : '').'/>'.esc_html__('Accounts in any Organizational directory and Personal Microsoft accounts', 'loginizer').'</label></td>
309 <td style="display:block;"><label><input type="radio" name="account_type" value="consumers" id="loginizer_social_ms_account_type" '.(!empty($provider_settings[$provider]['account_type']) ? checked($provider_settings[$provider]['account_type'], 'consumers', false) : '').'/>'.esc_html__('Personal Microsoft accounts only', 'loginizer').'</label></td>
310 </tr>';
311 }
312
313 echo '</table>';
314 wp_nonce_field('loginizer_social_nonce', 'security');
315 echo '<input type="submit" name="lz_save_social_provider" value="Save Settings" class="button button-primary"/>
316 </form>
317 </div>
318 <div class="loginizer-provider-docs" style="width:46%;">';
319 if(function_exists('loginizer_how_to_'.$provider)){
320 call_user_func('loginizer_how_to_'.$provider);
321 } else {
322 echo '<p>No Documentation Present</p>';
323 }
324 echo '</div>
325 </div>
326 ';
327
328 loginizer_page_footer();
329 }
330
331 // General Settings Page
332 function loginizer_general_settings(){
333
334 $social_settings = get_option('loginizer_social_settings', []);
335
336 if(!empty($_POST['security'])){
337 if(!check_admin_referer('loginizer_social_nonce', 'security')){
338 $error[] = __('Security Check failed', 'loginizer');
339 } else if(isset($_POST['general_settings'])){
340 $social_settings['general']['target_window'] = !empty($_POST['target_window']) ? lz_optpost('target_window') : false;
341
342 } else if(isset($_POST['login_settings'])){
343 $social_settings['login']['login_form'] = lz_optpost('login_form');
344 $social_settings['login']['button_style'] = lz_optpost('button_style');
345 $social_settings['login']['button_shape'] = lz_optpost('button_shape');
346 $social_settings['login']['button_position'] = lz_optpost('button_position');
347 $social_settings['login']['alignment'] = lz_optpost('alignment');
348 $social_settings['login']['button_alignment'] = lz_optpost('button_alignment');
349 }
350
351 $social_settings = apply_filters('loginizer_social_general_settings', $social_settings);
352 $social_settings = map_deep($social_settings, 'sanitize_text_field');
353
354 update_option('loginizer_social_settings', $social_settings);
355 }
356
357 // NOTE:: The tab switching is done purly through CSS so, if you add any other tab in here then use css, just look for the class of already present tabs in the CSS and you will know.
358 echo '
359 <div class="loginizer-social-login-settings">
360 <div class="loginizer-v-tab">
361 <label><input type="radio" name="lz-social-setting-type" value="general" checked/>'.esc_html__('General', 'loginizer').'</label>
362 <label><input type="radio" name="lz-social-setting-type" value="login"/>'.esc_html__('Login Form', 'loginizer').'</label>
363 <label><input type="radio" name="lz-social-setting-type" value="woocommerce"/>'.esc_html__('WooCommerce', 'loginizer').(!defined('LOGINIZER_PREMIUM') ? '<span class="dashicons dashicons-lock" style="color:#f69d2e;" title="Available in Premium version"></span>' : ''). '</label>
364 <label><input type="radio" name="lz-social-setting-type" value="comment"/>'.esc_html__('Comment', 'loginizer').(!defined('LOGINIZER_PREMIUM') ? '<span class="dashicons dashicons-lock" style="color:#f69d2e;" title="Available in Premium version"></span>' : '').'</label>';
365
366 if(is_plugin_active('ultimate-member/ultimate-member.php')){
367 echo '<label><input type="radio" name="lz-social-setting-type" value="ultimate-member"/>'.esc_html__('Ultimate Member', 'loginizer').(!defined('LOGINIZER_PREMIUM') ? '<span class="dashicons dashicons-lock" style="color:#f69d2e;" title="Available in Premium version"></span>' : '').'</label>';
368 }
369
370 echo '</div>
371
372 <div class="lz-v-tab-content">
373 <div id="lz-social-general-settings">
374 <h2>General Settings</h2>
375 <form method="POST">
376 <table class="form-table">
377 <tr>
378 <th scope="row"><label for="save_avatar">Target Window</label></th>
379 <td class="loginizer-general-settings">
380 <label><input type="radio" name="target_window" id="target_window" value="same" '.(!empty($social_settings['general']['target_window']) && $social_settings['general']['target_window'] == 'same' ? 'checked' : (empty($social_settings['general']['target_window']) ? 'checked' : '')).'/>'.esc_html__('Prefer Same window', 'loginizer').'</label>
381 <label><input type="radio" name="target_window" id="target_window" value="popup" '.(!empty($social_settings['general']['target_window']) && $social_settings['general']['target_window'] == 'popup' ? 'checked' : '').'/>'.esc_html__('Prefer Popup', 'loginizer').'</label>
382 <p class="description">'.esc_html__('Where you want the App Authentication to be visible in', 'loginizer').'</p>
383 </td>
384 </tr>';
385
386 if(defined('LOGINIZER_PREMIUM')){
387 echo '<tr>
388 <th scope="row"><label for="save_avatar">Save Avatar</label></th>
389 <td class="loginizer-general-settings">
390 <input type="checkbox" name="save_avatar" id="save_avatar" '.(!empty($social_settings['general']['save_avatar']) ? 'checked' : '').'/>
391 <p class="description">'.esc_html__('On registration save and update user avatar, if possible', 'loginizer').'</p>
392 </td>
393 </tr>
394 <tr>
395 <th scope="row"><label for="register_new">Create User</label></th>
396 <td class="loginizer-general-settings">
397 <input type="checkbox" name="register_new" id="register_new" '.(!empty($social_settings['general']['register_new']) ? 'checked' : '').'/>
398 <p>'.esc_html__('If the user is not present then should loginizer create new user?', 'loginizer').'</p>
399 </td>
400 </tr>
401 <tr>
402 <th scope="row"><label for="default_role">New User Role</label></th>
403 <td class="loginizer-general-settings">
404 <select name="default_role" id="default_role">';
405 wp_dropdown_roles(!empty($social_settings['general']['default_role']) ? $social_settings['general']['default_role'] : 'subscriber');
406 echo '</select>
407 <p>'.esc_html__('What role you want to assign to the user created through social login?', 'loginizer').'</p>
408 </td>
409 </tr>
410 <tr>
411 <th scope="row"><label for="admin_bar">'.esc_html__('Hide Admin Bar', 'loginizer').'</label></th>
412 <td class="loginizer-general-settings">
413 <input type="checkbox" name="admin_bar" id="admin_bar" '.(!empty($social_settings['general']['admin_bar']) ? 'checked' : '').'/>
414 <p>'.esc_html__('Do you want the new user to see the Admin Bar in the Front end? Checked means you want to hide it.', 'loginizer'). '</p>
415 </td>
416 </tr>';
417 } else {
418 echo '<tr>
419 <th scope="row"><label>Save Avatar <span class="dashicons dashicons-lock" style="color:#f69d2e;" title="Available in Premium version"></span></label></th>
420 <td class="loginizer-general-settings">
421 <input type="checkbox" disabled/>
422 <p class="description">'.esc_html__('On registration save and update user avatar, if possible', 'loginizer').'</p>
423 </td>
424 </tr>
425 <tr>
426 <th scope="row"><label>Create User <span class="dashicons dashicons-lock" style="color:#f69d2e;" title="Available in Premium version"></span></label></th>
427 <td class="loginizer-general-settings">
428 <input type="checkbox" disabled>
429 <p>'.esc_html__('If the user is not present then should loginizer create new user?', 'loginizer').'</p>
430 </td>
431 </tr>
432 <tr>
433 <th scope="row"><label>New User Role <span class="dashicons dashicons-lock" style="color:#f69d2e;" title="Available in Premium version"></span></label></th>
434 <td class="loginizer-general-settings">
435 <select disabled>
436 <option>Subscriber</option>
437 </select>
438 <p>'.esc_html__('What role you want to assign to the user created through social login?', 'loginizer').'</p>
439 </td>
440 </tr>
441 <tr>
442 <th scope="row"><label>'.esc_html__('Hide Admin Bar', 'loginizer').' <span class="dashicons dashicons-lock" style="color:#f69d2e;" title="Available in Premium version"></span></label></th>
443 <td class="loginizer-general-settings">
444 <input type="checkbox" disabled/>
445 <p>'.esc_html__('Do you want the new user to see the Admin Bar in the Front end? Checked means you want to hide it.', 'loginizer'). '</p>
446 </td>
447 </tr>';
448
449 }
450 echo '</table>';
451 wp_nonce_field('loginizer_social_nonce', 'security');
452 echo '<input type="submit" class="button button-primary" name="general_settings" value="Save Settings"/>
453 </form>
454 </div>
455 <div id="lz-social-login-settings">
456 <h2>Login Form</h2>
457 <form method="POST">
458 <table class="form-table">
459 <tr>
460 <th scope="row"><label for="button_style_full">'.esc_html__('Login Form', 'loginizer').'</label></th>
461 <td class="loginizer-general-settings">
462 <label><input type="checkbox" name="login_form" id="login_form" value="yes" '.(!empty($social_settings['login']['login_form']) ? 'checked' : '').'/></label>
463 <p>'.esc_html__('Do you want to show social buttons on WordPress login form.', 'loginizer'). '</p>
464 </td>
465 </tr>';
466
467 if(defined('LOGINIZER_PREMIUM')){
468 echo '<tr>
469 <th scope="row"><label for="registration_form">'.esc_html__('Registration Form', 'loginizer').'</label></th>
470 <td class="loginizer-general-settings">
471 <label><input type="checkbox" name="registration_form" id="registration_form" value="yes" '.(!empty($social_settings['login']['registration_form']) ? 'checked' : '').'/></label>
472 <p>'.esc_html__('Do you want to show social login on the WordPress registration form.', 'loginizer'). '</p>
473 </td>
474 </tr>';
475 } else {
476 echo '<tr>
477 <th scope="row"><label>'.esc_html__('Registration Form', 'loginizer').'<span class="dashicons dashicons-lock" style="color:#f69d2e;" title="Available in Premium version"></span></label></th>
478 <td class="loginizer-general-settings">
479 <label><input type="checkbox" disabled/></label>
480 <p class="disabled">'.esc_html__('Do you want to show social login on the WordPress registration form.', 'loginizer'). '</p>
481 </td>
482 </tr>';
483 }
484
485 echo '<tr>
486 <th scope="row"><label for="button_style_full">'.esc_html__('Button Style', 'loginizer').'</label></th>
487 <td class="loginizer-general-settings">
488 <label><input type="radio" name="button_style" id="button_style_full" value="full" '.(empty($social_settings['login']['button_style']) ? 'checked' : checked($social_settings['login']['button_style'], 'full', false)).'/>Full Length</label>
489 <label><input type="radio" name="button_style" value="icon" '.(!empty($social_settings['login']['button_style']) ? checked($social_settings['login']['button_style'], 'icon', false) : '').'/>Icon</label>
490 </td>
491 </tr>
492 <tr>
493 <th scope="row"><label for="button_shape_square">'.esc_html__('Button Shape', 'loginizer').'</label></th>
494 <td class="loginizer-general-settings">
495 <label><input type="radio" name="button_shape" id="button_shape_square" value="square" '.(empty($social_settings['login']['button_shape']) ? 'checked' : checked($social_settings['login']['button_shape'], 'square', false)).'>'.esc_html__('Square', 'loginizer').'</label>
496 <label><input type="radio" name="button_shape" value="circle" '.(!empty($social_settings['login']['button_shape']) ? checked($social_settings['login']['button_shape'], 'circle', false) : '').'>'.esc_html__('Pill/Circle', 'loginizer').'</label>
497 </td>
498 </tr>
499 <tr>
500 <th scope="row"><label for="button_position">Button Position</label></th>
501 <td class="loginizer-general-settings">
502 <label><input type="radio" name="button_position" id="button_position" value="below" '.(empty($social_settings['login']['button_position']) ? 'checked' : checked($social_settings['login']['button_position'], 'below', false)).'>Below</label>
503 <label><input type="radio" name="button_position" value="below_plus" '.(!empty($social_settings['login']['button_position']) ? checked($social_settings['login']['button_position'], 'below_plus', false) : '').'>'.esc_html__('Below with Seperator', 'loginizer').'</label>
504 <label><input type="radio" name="button_position" value="above" '.(!empty($social_settings['login']['button_position']) ? checked($social_settings['login']['button_position'], 'above', false) : '').'>'.esc_html__('Above', 'loginizer').'</label>
505 <label><input type="radio" name="button_position" value="above_plus" '.(!empty($social_settings['login']['button_position']) ? checked($social_settings['login']['button_position'], 'above_plus', false) : '').'>'.esc_html__('Above with Seperator', 'loginizer').'</label>
506 </td>
507 </tr>
508 <tr>
509 <th scope="row"><label for="social-alignment">'.esc_html__('Container Alignment', 'loginizer').'</label></th>
510 <td class="loginizer-general-settings">
511 <label><input type="radio" name="alignment" id="social-alignment" value="left" '.(empty($social_settings['login']['alignment']) ? 'checked' : checked($social_settings['login']['alignment'], 'left', false)).'>Left</label>
512 <label><input type="radio" name="alignment" value="center" '.(!empty($social_settings['login']['alignment']) ? checked($social_settings['login']['alignment'], 'center', false) : '').'>'.esc_html__('Center', 'loginizer').'</label>
513 <label><input type="radio" name="alignment" value="right" '.(!empty($social_settings['login']['alignment']) ? checked($social_settings['login']['alignment'], 'right', false) : '').'>'.esc_html__('Right', 'loginizer').'</label>
514 </td>
515 </tr>
516 <tr>
517 <th scope="row"><label for="social-alignment">'.esc_html__('Button Alignment', 'loginizer').'</label></th>
518 <td class="loginizer-general-settings">
519 <label><input type="radio" name="button_alignment" id="social-alignment" value="left" '.(empty($social_settings['login']['button_alignment']) ? 'checked' : checked($social_settings['login']['button_alignment'], 'left', false)).'>Left</label>
520 <label><input type="radio" name="button_alignment" value="center" '.(!empty($social_settings['login']['button_alignment']) ? checked($social_settings['login']['button_alignment'], 'center', false) : '').'>'.esc_html__('Center', 'loginizer').'</label>
521 <label><input type="radio" name="button_alignment" value="right" '.(!empty($social_settings['login']['button_alignment']) ? checked($social_settings['login']['button_alignment'], 'right', false) : '').'>'.esc_html__('Right', 'loginizer').'</label>
522 </td>
523 </tr>
524 </table>';
525 wp_nonce_field('loginizer_social_nonce', 'security');
526 echo '<input type="submit" class="button button-primary" name="login_settings" value="'.esc_html__('Save Settings', 'loginizer').'">
527 </form>
528 </div>
529 <div id="lz-social-woocommerce-settings">
530 <h2>WooCommerce Settings</h2>';
531 loginizer_feature_available('Social login for WooCommerce');
532 echo '<form method="POST" loginizer-premium-only="1">
533 <table class="form-table">
534 <tr>
535 <th scope="row"><label for="button_style_full">'.esc_html__('Login Form', 'loginizer').'</label></th>
536 <td class="loginizer-general-settings">
537 <label><input type="checkbox" name="login_form" id="login_form" value="login" '.(!empty($social_settings['woocommerce']['login_form']) ? 'checked' : '').'/></label>
538 <p>'.esc_html__('Do you want to show social buttons on WooCommerce login form.', 'loginizer'). '</p>
539 </td>
540 </tr>
541 <tr>
542 <th scope="row"><label for="button_style_full">'.esc_html__('Registration Form', 'loginizer').'</label></th>
543 <td class="loginizer-general-settings">
544 <label><input type="checkbox" name="registration_form" id="registration_form" value="reg" '.(!empty($social_settings['woocommerce']['registration_form']) ? 'checked' : '').'/></label>
545 <p>'.esc_html__('Do you want to show social login on the WooCommerce registration form.', 'loginizer'). '</p>
546 </td>
547 </tr>
548 <tr>
549 <th scope="row"><label for="button_style_full">'.esc_html__('Button Style', 'loginizer').'</label></th>
550 <td class="loginizer-general-settings">
551 <label><input type="radio" name="button_style" id="button_style_full" value="full" '.(empty($social_settings['woocommerce']['button_style']) ? 'checked' : checked($social_settings['woocommerce']['button_style'], 'full', false)).'/>'.esc_html__('Full Length', 'loginizer').'</label>
552 <label><input type="radio" name="button_style" value="icon" '.(!empty($social_settings['woocommerce']['button_style']) ? checked($social_settings['woocommerce']['button_style'], 'icon', false) : '').'/>'.esc_html__('Icon', 'loginizer').'</label>
553 </td>
554 </tr>
555 <tr>
556 <th scope="row"><label for="button_shape_square">'.esc_html__('Button Shape', 'loginizer').'</label></th>
557 <td class="loginizer-general-settings">
558 <label><input type="radio" name="button_shape" id="button_shape_square" value="square" '.(empty($social_settings['woocommerce']['button_shape']) ? 'checked' : checked($social_settings['woocommerce']['button_shape'], 'square', false)).'>'.esc_html__('Square', 'loginizer').'</label>
559 <label><input type="radio" name="button_shape" value="circle" '.(!empty($social_settings['woocommerce']['button_shape']) ? checked($social_settings['woocommerce']['button_shape'], 'circle', false) : '').'>'.esc_html__('Pill/Circle', 'loginizer').'</label>
560 </td>
561 </tr>
562 <tr>
563 <th scope="row"><label for="button_position">'.esc_html__('Button Position', 'loginizer').'</label></th>
564 <td class="loginizer-general-settings">
565 <label><input type="radio" name="button_position" id="button_position" value="below" '.(empty($social_settings['woocommerce']['button_position']) ? 'checked' : checked($social_settings['woocommerce']['button_position'], 'below', false)).'>'.esc_html__('Below', 'loginizer').'</label>
566 <label><input type="radio" name="button_position" value="below_plus" '.(!empty($social_settings['woocommerce']['button_position']) ? checked($social_settings['woocommerce']['button_position'], 'below_plus', false) : '').'>'.esc_html__('Below with Seperator', 'loginizer').'</label>
567 <label><input type="radio" name="button_position" value="above" '.(!empty($social_settings['woocommerce']['button_position']) ? checked($social_settings['woocommerce']['button_position'], 'above', false) : '').'>'.esc_html__('Above', 'loginizer').'</label>
568 <label><input type="radio" name="button_position" value="above_plus" '.(!empty($social_settings['woocommerce']['button_position']) ? checked($social_settings['woocommerce']['button_position'], 'above_plus', false) : '').'>'.esc_html__('Above with Seperator', 'loginizer').'</label>
569 </td>
570 </tr>
571 <tr>
572 <th scope="row"><label for="social-alignment">'.esc_html__('Container Alignment', 'loginizer').'</label></th>
573 <td class="loginizer-general-settings">
574 <label><input type="radio" name="alignment" id="social-alignment" value="left" '.(empty($social_settings['woocommerce']['alignment']) ? 'checked' : checked($social_settings['woocommerce']['alignment'], 'left', false)).'>Left</label>
575 <label><input type="radio" name="alignment" value="center" '.(!empty($social_settings['woocommerce']['alignment']) ? checked($social_settings['woocommerce']['alignment'], 'center', false) : '').'>'.esc_html__('Center', 'loginizer').'</label>
576 <label><input type="radio" name="alignment" value="right" '.(!empty($social_settings['woocommerce']['alignment']) ? checked($social_settings['woocommerce']['alignment'], 'right', false) : '').'>'.esc_html__('Right', 'loginizer').'</label>
577 </td>
578 </tr>
579 <tr>
580 <th scope="row"><label for="social-alignment">'.esc_html__('Button Alignment', 'loginizer').'</label></th>
581 <td class="loginizer-general-settings">
582 <label><input type="radio" name="button_alignment" id="social-alignment" value="left" '.(empty($social_settings['woocommerce']['button_alignment']) ? 'checked' : checked($social_settings['woocommerce']['button_alignment'], 'left', false)).'>Left</label>
583 <label><input type="radio" name="button_alignment" value="center" '.(!empty($social_settings['woocommerce']['button_alignment']) ? checked($social_settings['woocommerce']['button_alignment'], 'center', false) : '').'>'.esc_html__('Center', 'loginizer').'</label>
584 <label><input type="radio" name="button_alignment" value="right" '.(!empty($social_settings['woocommerce']['button_alignment']) ? checked($social_settings['woocommerce']['button_alignment'], 'right', false) : '').'>'.esc_html__('Right', 'loginizer').'</label>
585 </td>
586 </tr>
587 </table>';
588 wp_nonce_field('loginizer_social_nonce', 'security');
589 echo '<input type="submit" class="button button-primary" name="woocommerce_settings" value="'.esc_html__('Save Settings', 'loginizer').'">
590 </form>
591 </div>
592 <div id="lz-social-comment-settings">
593 <h2>Comment Settings</h2>';
594 loginizer_feature_available('Social Login for comment');
595 echo '<form method="POST" loginizer-premium-only="1">
596 <table class="form-table">
597 <tr>
598 <th scope="row"><label for="button_style_full">'.esc_html__('Show buttons', 'loginizer').'</label></th>
599 <td class="loginizer-general-settings">
600 <label><input type="checkbox" name="enable_buttons" id="enable_buttons" value="yes" '.(!empty($social_settings['comment']['enable_buttons']) ? 'checked' : '').'/></label>
601 <p>'.esc_html__('Do you want to show social buttons on Comments.', 'loginizer'). '</p>
602 </td>
603 </tr>
604 <tr>
605 <th scope="row"><label for="button_style_full">'.esc_html__('Button Style', 'loginizer').'</label></th>
606 <td class="loginizer-general-settings">
607 <label><input type="radio" name="button_style" id="button_style_full" value="full" '.(empty($social_settings['comment']['button_style']) ? 'checked' : checked($social_settings['comment']['button_style'], 'full', false)).'/>'.esc_html__('Full Length', 'loginizer').'</label>
608 <label><input type="radio" name="button_style" value="icon" '.(!empty($social_settings['comment']['button_style']) ? checked($social_settings['comment']['button_style'], 'icon', false) : '').'/>'.esc_html__('Icon', 'loginizer').'</label>
609 </td>
610 </tr>
611 <tr>
612 <th scope="row"><label for="button_shape_square">'.esc_html__('Button Shape', 'loginizer').'</label></th>
613 <td class="loginizer-general-settings">
614 <label><input type="radio" name="button_shape" id="button_shape_square" value="square" '.(empty($social_settings['comment']['button_shape']) ? 'checked' : checked($social_settings['comment']['button_shape'], 'square', false)).'>'.esc_html__('Square', 'loginizer').'</label>
615 <label><input type="radio" name="button_shape" value="circle" '.(!empty($social_settings['comment']['button_shape']) ? checked($social_settings['comment']['button_shape'], 'circle', false) : '').'>'.esc_html__('Pill/Circle', 'loginizer').'</label>
616 </td>
617 </tr>
618 <tr>
619 <th scope="row"><label for="social-alignment">'.esc_html__('Container Alignment', 'loginizer').'</label></th>
620 <td class="loginizer-general-settings">
621 <label><input type="radio" name="alignment" id="social-alignment" value="left" '.(empty($social_settings['comment']['alignment']) ? 'checked' : checked($social_settings['comment']['alignment'], 'left', false)).'>Left</label>
622 <label><input type="radio" name="alignment" value="center" '.(!empty($social_settings['comment']['alignment']) ? checked($social_settings['comment']['alignment'], 'center', false) : '').'>'.esc_html__('Center', 'loginizer-security').'</label>
623 <label><input type="radio" name="alignment" value="right" '.(!empty($social_settings['comment']['alignment']) ? checked($social_settings['comment']['alignment'], 'right', false) : '').'>'.esc_html__('Right', 'loginizer-security').'</label>
624 </td>
625 </tr>
626 <tr>
627 <th scope="row"><label for="social-alignment">'.esc_html__('Button Alignment', 'loginizer').'</label></th>
628 <td class="loginizer-general-settings">
629 <label><input type="radio" name="button_alignment" id="social-alignment" value="left" '.(empty($social_settings['comment']['button_alignment']) ? 'checked' : checked($social_settings['comment']['button_alignment'], 'left', false)).'>Left</label>
630 <label><input type="radio" name="button_alignment" value="center" '.(!empty($social_settings['comment']['button_alignment']) ? checked($social_settings['comment']['button_alignment'], 'center', false) : '').'>'.esc_html__('Center', 'loginizer').'</label>
631 <label><input type="radio" name="button_alignment" value="right" '.(!empty($social_settings['comment']['button_alignment']) ? checked($social_settings['comment']['button_alignment'], 'right', false) : '').'>'.esc_html__('Right', 'loginizer').'</label>
632 </td>
633 </tr>
634 </table>';
635 wp_nonce_field('loginizer_social_nonce', 'security');
636 echo '<input type="submit" class="button button-primary" name="comment_settings" value="'.esc_html__('Save Settings', 'loginizer').'"/>
637 </form>
638 </div>
639 <div id="lz-social-ultimate-member-settings">
640 <h2>'.esc_html__('Ultimate Member Settings', 'loginizer').'</h2>';
641 loginizer_feature_available('Social Login for Ultimate Member');
642 do_action('loginizer_pro_social_um_settings');
643 echo '</div>
644 </div>';
645
646 loginizer_page_footer();
647 }
648
649 // Checks if we can show the Status of the Social App.
650 // As if Premium verison is disabled then the status should not be visible.
651 function loginizer_show_social_status($provider){
652 if(!empty($provider['premium']) && !defined('LOGINIZER_PREMIUM')){
653 return false;
654 }
655
656 return true;
657 }
658
659 function loginizer_how_to_linkedinopenid(){
660
661 // NOTE: update the date of last updated of this doc if you make any change.
662 echo '<div>
663 <h2>'.esc_html__('Create LinkedIn App', 'loginizer').'</h2>
664 <span><b>'.esc_html__('Last Updated','loginizer').':</b> 24th June 2024</span>
665 <p>'.esc_html__('To allow your users to be able to login through their LinkedIn Account, you first need to create a LinkedIn App. For that follow the Project creation steps below.', 'loginizer').'</p>
666 <ol>
667 <li>'.esc_html__('Go to LinkedIn Apps page for that','loginizer').' <a href="https://www.linkedin.com/developers/apps" target="_blank">Navigate to https://www.linkedin.com/developers/apps</a></li>
668 <li>'.esc_html__('Once you open the Apps page, click on Create App button, which will take you to fill a form.', 'loginizer').'</li>
669 <li>'.esc_html__('On that form fill the App Name and LinkedIn page, if you dont have a linked in page then create once as its required to create a App.','loginizer').' <a href="https://www.linkedin.com/company/setup/new/" target="_blank">https://www.linkedin.com/company/setup/new/</a></li>
670 <li>'.esc_html__('After you have filled the LinkedIn page details, upload your logo and read terms and conditions and check the field which say I have read and agreed to these terms and then click on Create App','loginizer').'</li>
671 <li>'.esc_html__('You will be redirect to your App page in Product Tab, there look for "Sign In with LinkedIn using OpenID Connect" and click on Request Access, now go to the Auth tab as we need to access Oauth 2.0','loginizer').'</li>
672 <li>'.esc_html__('On the Auth tab copy the Client ID and Client Secret and place those keys in Client ID and CLient Secret of the Loginizer LinkedIn Social provider respectively and enable it and save it','loginizer').'</li>
673 <li>'.esc_html__('Now on LinkedIn Auth page you will need to add Redirect URL, for that add this URL there', 'loginizer').'<code>'.esc_url(wp_login_url()).'?lz_social_provider=LinkedInOpenID</code></li>
674 <li>'.esc_html__('After that you can test in the Loginizer dashboard to see if it is working without any issue', 'loginizer').'</li>
675 </ol>
676 </div>';
677 }
678