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
← All changes | main/settings/social_login.php +132 -22 1.9.9 → trunk View file →
@@ -22,8 +22,10 @@
22 22 wp_localize_script('loginizer_social_script', 'loginizer_social', $script_data);
23 23
24 24 loginizer_page_header('Social Login Settings');
25 25
26 + do_action('loginizer_pro_social_auth_notice');
27 +
26 28 echo '<div class="tabs-wrapper" style="margin-bottom:10px; width:100%;">
27 29 <nav class="nav-tab-wrapper">
28 30 <a href="?page=loginizer_social_login" class="nav-tab '.(isset($_GET['settings']) ? '' : 'nav-tab-active').'">Provider</a>
29 31 <a href="?page=loginizer_social_login&settings=global" class="nav-tab '.(isset($_GET['settings']) ? 'nav-tab-active' : '').'">Settings</a>
@@ -87,11 +89,11 @@
87 89 // Image used here is supposed to be same as the key in png format.
88 90 foreach($providers as $key => $provider){
89 91
90 92 $action_class = '';
91 - $action_text = __('Get Started');
93 + $action_text = __('Get Started', 'loginizer');
92 94 if(array_key_exists($key, $provider_settings)){
93 - $action_text = __('Settings');
95 + $action_text = __('Settings', 'loginizer');
94 96 }
95 97
96 98 $action_to = admin_url('admin.php?page=loginizer_social_login&provider='.$key);
97 99 if(!empty($provider['premium']) && !defined('LOGINIZER_PREMIUM')){
@@ -117,9 +119,10 @@
117 119
118 120 echo '<div class="loginizer-social-saving-order">'.esc_html__('Saving Order', 'loginizer').'...</div>
119 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;' : '').'"/>
120 122 </div>
121 - <div class="loginizer-social-provider-action"><h2>'.esc_html($provider['name']).'</h2><a href="'.esc_url($action_to).'" class="button'.esc_attr($action_class).'">'.esc_html($action_text).'</a></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>
122 125 </div>';
123 126 }
124 127
125 128 echo '</div>';
@@ -147,13 +150,12 @@
147 150 loginizer_page_footer();
148 151 return;
149 152 }
150 153
151 - if(!empty($_POST['client_id'])){
154 + if(!empty($_POST['lz_save_social_provider'])){
152 155 if(!check_admin_referer('loginizer_social_nonce', 'security')){
153 156 $error[] = __('Security Check failed', 'loginizer');
154 157 } else {
155 -
156 158 if(empty($provider_settings[$provider])){
157 159 $provider_settings[$provider] = []; // initializing
158 160 $provider_settings[$provider]['tested'] = false;
159 161 }
@@ -158,10 +160,12 @@
158 160 $provider_settings[$provider]['tested'] = false;
159 161 }
160 162
161 163 // Need to make the user to test the login again if the key gets changed, if keys gets dirty
162 - if((isset($provider_settings[$provider]['client_id']) && $provider_settings[$provider]['client_id'] != sanitize_text_field(wp_unslash($_POST['client_id'])))
163 - || (isset($provider_settings[$provider]['client_secret']) && $provider_settings[$provider]['client_secret'] != sanitize_text_field(wp_unslash($_POST['client_secret'])))){
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 + ){
164 168 $provider_settings[$provider]['tested'] = false;
165 169 }
166 170
167 171 $provider_settings[$provider]['client_id'] = !empty($_POST['client_id']) ? sanitize_text_field(wp_unslash($_POST['client_id'])) : '';
@@ -166,9 +170,26 @@
166 170
167 171 $provider_settings[$provider]['client_id'] = !empty($_POST['client_id']) ? sanitize_text_field(wp_unslash($_POST['client_id'])) : '';
168 172 $provider_settings[$provider]['client_secret'] = !empty($_POST['client_secret']) ? sanitize_text_field(wp_unslash($_POST['client_secret'])) : '';
169 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 +
170 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 + }
171 192
172 193 update_option('loginizer_provider_settings', $provider_settings);
173 194
174 195 $saved = true;
@@ -223,14 +244,14 @@
223 244 }
224 245
225 246 echo '<a href="'.esc_url(admin_url('admin.php?page=loginizer_social_login')).'">&#8592; '.esc_html__('Go Back', 'loginizer').'</a>';
226 247
227 - if(!empty($provider_settings[$provider]) && !empty($provider_settings[$provider]['enabled']) && empty($provider_settings[$provider]['tested'])){
248 + if(!empty($provider_settings[$provider]) && !empty($provider_settings[$provider]['enabled']) && empty($provider_settings[$provider]['tested']) && empty($provider_settings[$provider]['loginizer_social_key'])){
228 249 echo '<div class="loginizer-social-test-alert">
229 250 <h3>'.sprintf(esc_html__('Test %s to be able to use it', 'loginizer'), esc_html($provider_defaults[$provider]['name'])).'</h3>
230 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>
231 252 <p>'.esc_html__('Please use the same email with which you have created this account.', 'loginizer').'</p>
232 - <button class="button button-primary" id="loginizer-test-provider-btn" onClick="loginizer_auth_test_popup()">'.esc_html__('Test Now', 'loginizer').'</button>
253 + <button class="button button-primary" id="loginizer-test-provider-btn" onclick="loginizer_auth_test_popup()">'.esc_html__('Test Now', 'loginizer').'</button>
233 254 </div>';
234 255 }
235 256
236 257 echo '<div style="display:flex; justify-content:space-between;">
@@ -241,18 +262,35 @@
241 262 <table class="form-table">
242 263 <tr>
243 264 <th scope="row"><label for="provider_enabled">Enable</label></th>
244 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>
245 287 </tr>
246 - <tr>
247 - <th scope="row"><label for="client_id">Client ID</label></th>
248 - <td><input type="text" name="client_id" id="client_id" value="'.(!empty($provider_settings[$provider]['client_id']) ? esc_attr($provider_settings[$provider]['client_id']) : '').'"/></td>
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>
249 291 </tr>
250 292 <tr>
251 - <th scope="row"><label for="client_secret">Client Secret</label></th>
252 - <td><input type="text" name="client_secret" id="client_secret" value="'.(!empty($provider_settings[$provider]['client_secret']) ? esc_attr($provider_settings[$provider]['client_secret']) : '').'"/></td>
253 - </tr>
254 - <tr>
255 293 <th scope="row"><label for="button_style_default">Button Style</label></th>
256 294 <td>';
257 295 $styles = $provider_defaults[$provider]['styles'];
258 296
@@ -259,12 +297,23 @@
259 297 foreach($styles as $style => $style_css){
260 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>';
261 299 }
262 300 echo '</td>
263 - </tr>
264 - </table>';
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>';
265 314 wp_nonce_field('loginizer_social_nonce', 'security');
266 - echo '<button class="button button-primary">Save Settings</button>
315 + echo '<input type="submit" name="lz_save_social_provider" value="Save Settings" class="button button-primary"/>
267 316 </form>
268 317 </div>
269 318 <div class="loginizer-provider-docs" style="width:46%;">';
270 319 if(function_exists('loginizer_how_to_'.$provider)){
@@ -294,8 +343,10 @@
294 343 $social_settings['login']['login_form'] = lz_optpost('login_form');
295 344 $social_settings['login']['button_style'] = lz_optpost('button_style');
296 345 $social_settings['login']['button_shape'] = lz_optpost('button_shape');
297 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');
298 349 }
299 350
300 351 $social_settings = apply_filters('loginizer_social_general_settings', $social_settings);
301 352 $social_settings = map_deep($social_settings, 'sanitize_text_field');
@@ -301,9 +352,10 @@
301 352 $social_settings = map_deep($social_settings, 'sanitize_text_field');
302 353
303 354 update_option('loginizer_social_settings', $social_settings);
304 355 }
305 -
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.
306 358 echo '
307 359 <div class="loginizer-social-login-settings">
308 360 <div class="loginizer-v-tab">
309 361 <label><input type="radio" name="lz-social-setting-type" value="general" checked/>'.esc_html__('General', 'loginizer').'</label>
@@ -308,11 +360,16 @@
308 360 <div class="loginizer-v-tab">
309 361 <label><input type="radio" name="lz-social-setting-type" value="general" checked/>'.esc_html__('General', 'loginizer').'</label>
310 362 <label><input type="radio" name="lz-social-setting-type" value="login"/>'.esc_html__('Login Form', 'loginizer').'</label>
311 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>
312 - <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>
313 - </div>
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 + }
314 369
370 + echo '</div>
371 +
315 372 <div class="lz-v-tab-content">
316 373 <div id="lz-social-general-settings">
317 374 <h2>General Settings</h2>
318 375 <form method="POST">
@@ -447,8 +504,24 @@
447 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>
448 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>
449 506 </td>
450 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>
451 524 </table>';
452 525 wp_nonce_field('loginizer_social_nonce', 'security');
453 526 echo '<input type="submit" class="button button-primary" name="login_settings" value="'.esc_html__('Save Settings', 'loginizer').'">
454 527 </form>
@@ -494,8 +567,24 @@
494 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>
495 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>
496 569 </td>
497 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>
498 587 </table>';
499 588 wp_nonce_field('loginizer_social_nonce', 'security');
500 589 echo '<input type="submit" class="button button-primary" name="woocommerce_settings" value="'.esc_html__('Save Settings', 'loginizer').'">
501 590 </form>
@@ -525,13 +614,34 @@
525 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>
526 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>
527 616 </td>
528 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>
529 634 </table>';
530 635 wp_nonce_field('loginizer_social_nonce', 'security');
531 636 echo '<input type="submit" class="button button-primary" name="comment_settings" value="'.esc_html__('Save Settings', 'loginizer').'"/>
532 637 </form>
533 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>
534 644 </div>';
535 645
536 646 loginizer_page_footer();
537 647 }