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 | functions.php +446 -81 1.3.3 → trunk View file →
@@ -1,44 +1,12 @@
1 1 <?php
2 2
3 -include_once(LOGINIZER_DIR.'/IPv6/IPv6.php');
4 -
5 -// Get the client IP
6 -function _lz_getip(){
7 - if(isset($_SERVER["REMOTE_ADDR"])){
8 - return $_SERVER["REMOTE_ADDR"];
9 - }elseif(isset($_SERVER["HTTP_X_FORWARDED_FOR"])){
10 - return $_SERVER["HTTP_X_FORWARDED_FOR"];
11 - }elseif(isset($_SERVER["HTTP_CLIENT_IP"])){
12 - return $_SERVER["HTTP_CLIENT_IP"];
13 - }
3 +if(!defined('ABSPATH')){
4 + die('HACKING ATTEMPT!');
14 5 }
15 6
16 -// Get the client IP
17 -function lz_getip(){
18 -
19 - global $loginizer;
20 -
21 - // Just so that we have something
22 - $ip = _lz_getip();
23 -
24 - $loginizer['ip_method'] = (int) @$loginizer['ip_method'];
25 -
26 - if(isset($_SERVER["REMOTE_ADDR"])){
27 - $ip = $_SERVER["REMOTE_ADDR"];
28 - }
29 -
30 - if(isset($_SERVER["HTTP_X_FORWARDED_FOR"]) && @$loginizer['ip_method'] == 1){
31 - $ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
32 - }
33 -
34 - if(isset($_SERVER["HTTP_CLIENT_IP"]) && @$loginizer['ip_method'] == 2){
35 - $ip = $_SERVER["HTTP_CLIENT_IP"];
36 - }
37 -
38 - return $ip;
39 -
40 -}
7 +include_once(LOGINIZER_DIR.'/lib/IPv6/IPv6.php');
8 +include_once(LOGINIZER_DIR .'/common.php');
41 9
42 10 // Execute a select query and return an array
43 11 function lz_selectquery($query, $array = 0){
44 12 global $wpdb;
@@ -51,36 +19,8 @@
51 19 return $result;
52 20 }
53 21 }
54 22
55 -// Check if an IP is valid
56 -function lz_valid_ip($ip){
57 -
58 - // IPv6
59 - if(lz_valid_ipv6($ip)){
60 - return true;
61 - }
62 -
63 - // IPv4
64 - if(!ip2long($ip)){
65 - return false;
66 - }
67 -
68 - return true;
69 -}
70 -
71 -function lz_valid_ipv6($ip){
72 -
73 - $pattern = '/^((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))$/';
74 -
75 - if(!preg_match($pattern, $ip)){
76 - return false;
77 - }
78 -
79 - return true;
80 -
81 -}
82 -
83 23 // Check if a field is posted via POST else return default value
84 24 function lz_optpost($name, $default = ''){
85 25
86 26 if(!empty($_POST[$name])){
@@ -112,15 +52,21 @@
112 52
113 53 // For filling in posted values
114 54 function lz_POSTval($name, $default = ''){
115 55
116 - return (!empty($_POST) ? (!isset($_POST[$name]) ? '' : $_POST[$name]) : $default);
56 + return (!empty($_POST) ? (!isset($_POST[$name]) ? '' : esc_html($_POST[$name])) : $default);
117 57
118 58 }
119 59
120 -function lz_POSTchecked($name, $default = false){
60 +function lz_POSTchecked($name, $default = false, $submit_name = ''){
121 61
122 - return (!empty($_POST) ? (isset($_POST[$name]) ? 'checked="checked"' : '') : (!empty($default) ? 'checked="checked"' : ''));
62 + if(!empty($submit_name)){
63 + $post_to_check = isset($_POST[$submit_name]) ? $_POST[$submit_name] : '';
64 + }else{
65 + $post_to_check = $_POST;
66 + }
67 +
68 + return (!empty($post_to_check) ? (isset($_POST[$name]) ? 'checked="checked"' : '') : (!empty($default) ? 'checked="checked"' : ''));
123 69
124 70 }
125 71
126 72 function lz_POSTselect($name, $value, $default = false){
@@ -138,21 +84,18 @@
138 84 }
139 85
140 86 }
141 87
88 +function lz_POSTradio($name, $val, $default = null){
89 +
90 + return (!empty($_POST) ? (@$_POST[$name] == $val ? 'checked="checked"' : '') : (!is_null($default) && $default == $val ? 'checked="checked"' : ''));
91 +
92 +}
93 +
142 94 function lz_inputsec($string){
143 95
144 - if(!get_magic_quotes_gpc()){
96 + $string = addslashes($string);
145 97
146 - $string = addslashes($string);
147 -
148 - }else{
149 -
150 - $string = stripslashes($string);
151 - $string = addslashes($string);
152 -
153 - }
154 -
155 98 // This is to replace ` which can cause the command to be executed in exec()
156 99 $string = str_replace('`', '\`', $string);
157 100
158 101 return $string;
@@ -201,9 +144,9 @@
201 144 if(empty($error)){
202 145 return true;
203 146 }
204 147
205 - $error_string = '<b>Please fix the below error(s) :</b> <br />';
148 + $error_string = '<b>'.__('Please fix the below error(s)', 'loginizer').' :</b> <br />';
206 149
207 150 foreach($error as $ek => $ev){
208 151 $error_string .= '* '.$ev.'<br />';
209 152 }
@@ -208,9 +151,9 @@
208 151 $error_string .= '* '.$ev.'<br />';
209 152 }
210 153
211 154 echo '<div id="message" class="error"><p>'
212 - . __($error_string, 'loginizer')
155 + . $error_string
213 156 . '</p></div>';
214 157 }
215 158
216 159 // Report a notice
@@ -228,9 +171,9 @@
228 171 }else{
229 172 $notice_class = 'updated';
230 173 }
231 174
232 - $notice_string = '<b>Please check the below notice(s) :</b> <br />';
175 + $notice_string = '<b>'.__('Please check the below notice(s)', 'loginizer').' :</b> <br />';
233 176
234 177 foreach($notice as $ek => $ev){
235 178 $notice_string .= '* '.$ev.'<br />';
236 179 }
@@ -235,9 +178,9 @@
235 178 $notice_string .= '* '.$ev.'<br />';
236 179 }
237 180
238 181 echo '<div id="message" class="'.$notice_class.'"><p>'
239 - . __($notice_string, 'loginizer')
182 + . $notice_string
240 183 . '</p></div>';
241 184 }
242 185
243 186 // Convert an objext to array
@@ -322,4 +265,426 @@
322 265 }
323 266 return $page;
324 267 }
325 268
269 +// Replaces the Variables with the supplied ones
270 +function lz_lang_vars_name($str, $array){
271 +
272 + foreach($array as $k => $v){
273 +
274 + $str = str_replace('$'.$k, $v, $str);
275 +
276 + }
277 +
278 + return $str;
279 +
280 +}
281 +
282 +// Check if Loginizer is premium
283 +function loginizer_is_premium(){
284 + return defined('LOGINIZER_PREMIUM');
285 +}
286 +
287 +function loginizer_feature_available($feature = '', $return = 0){
288 +
289 + if(loginizer_is_premium()){
290 + return true;
291 + }
292 +
293 + $msg = '';
294 +
295 + if(!empty($feature)){
296 + $msg .= '<b>'.$feature.'</b> is available in the Pro version of Loginizer. ';
297 + }
298 +
299 + $msg .= '<a href="'.LOGINIZER_PRICING_URL.'" target="_blank" style="text-decoration:none; color:green;"><b>Upgrade to Pro</b></a>';
300 +
301 + if(!empty($return)){
302 + return $msg;
303 + }else{
304 + echo '<div style="color:#a94442; background-color:#f2dede; border-color:#ebccd1; padding:15px; margin-bottom:20px; border:1px solid transparent; border-radius:4px;">'.$msg.'</div>';
305 + }
306 +
307 +}
308 +
309 +// Checks if the email is valid
310 +function lz_valid_email($email){
311 +
312 + return filter_var($email, FILTER_VALIDATE_EMAIL);
313 +
314 +}
315 +
316 +function loginizer_blocked_page($lz_error){
317 +
318 + // We are checking if this is a login page or not
319 + if(false === stripos(wp_login_url(), $_SERVER['REQUEST_URI'])){
320 + return;
321 + }
322 +
323 + echo '<!DOCTYPE html><html><head>
324 + <meta name="robots" content="noindex, noarchive">
325 + <meta name="referrer" content="strict-origin-when-cross-origin">
326 + <meta name="viewport" content="width=device-width, initial-scale=1.0">
327 + <title>'.__('You can not access this page', 'loginizer').'</title>
328 + <style>html,body{height:100%}
329 + .loginizer-blocked-wrapper{display:flex; align-items:center; justify-content:space-between; flex-direction:column; height:100%;} footer{border-top:1px solid #dadada; width:40vh; text-align:center;}</style>
330 + </head>
331 + <body style="font-family:sans-serif; font-size:calc(15px + 0.390625vw);margin:0;">
332 + <div class="loginizer-blocked-wrapper">
333 + <div style="margin-top:10em;">
334 + <h1 align="center">'.__('You can not access this page', 'loginizer').'</h1>
335 + <p align="center">'.wp_kses_post(implode('', $lz_error)).'</p>
336 + </div>
337 + <footer>';
338 + if(!defined('LOGINIZER_PREMIUM')){
339 + echo '<p>Powered by Loginizer</p>';
340 + } else {
341 + echo '<p>Powered by ' . esc_html(get_bloginfo('name')) . '</p>';
342 + }
343 +
344 + echo '</footer></div></body></html>';
345 + die();
346 +}
347 +
348 +function loginizer_social_css($position = 'below'){
349 + global $loginizer;
350 +
351 + // Starting the CSS
352 + $css = '#lz-social-login-btns{display:none;max-width:350px;width:100%;box-sizing:border-box}.lz-social-login-btns-icon{flex-direction:row;flex-wrap:wrap;gap:8px}.lz-social-login-btns-full{flex-wrap:wrap;}.lz-social-top-padding{padding-top:20px}.lz-social-bottom-padding{padding-bottom:20px}.loginizer-social-button{display:flex;align-items:center;cursor:pointer;margin-bottom:10px;box-sizing:border-box;text-align:center;line-height:1;border:none;outline:none}.lz-social-button-icon{padding:0;width:40px;height:40px}.lz-social-button-icon-circle{border-radius:20px}.lz-social-button-icon-square{border-radius:3px}.lz-social-button-btn{padding:0 12px;width:100%;max-width:400px}.loginizer-social-button img{border-radius:2px;max-width:24px !important;}.loginizer-social-btn-logo{display:flex;padding:8px;align-items:center}.loginizer-social-btn-text{text-align:center;margin-left:15px;padding:10px 0;font-size:16px}';
353 +
354 + // CSS for the divider with the text OR in the middle
355 + if(!empty($loginizer['social_settings']) && ($position === 'below' || $position === 'above')){
356 + $css .= '.loginizer-social-divider{flex: 1 0 100%; font-size:17px; font-weight:700; margin-bottom:10px; display:flex;align-items:center}.loginizer-social-divider::after,.loginizer-social-divider::before{flex:1;content:"";padding:1px;background-color:#ececec;margin:5px}';
357 + }
358 +
359 + wp_register_style('loginizer-social', '', [], LOGINIZER_VERSION);
360 + wp_enqueue_style('loginizer-social');
361 + wp_add_inline_style('loginizer-social', $css);
362 +}
363 +
364 +// Echos the HTML of the Social button
365 +function loginizer_social_btn($return = false, $page_type = 'login', $short_atts = []){
366 + global $loginizer, $loginizer_login_providers;
367 +
368 + // We don't want to give social login option to blacklisted IP's
369 + if(loginizer_is_blacklisted() || !loginizer_can_login()){
370 + return;
371 + }
372 +
373 + $provider_settings = get_option('loginizer_provider_settings', []);
374 + $provider_order = get_option('loginizer_social_order', []); // in what order the icons are to be shown
375 +
376 + $providers = [];
377 +
378 + // Sorting according to the saved order of the providers.
379 + if(!empty($provider_order)){
380 + foreach($provider_order as $key => $num){
381 + if(!empty($provider_settings[$key])){
382 + $providers[$key] = $provider_settings[$key];
383 + }
384 + }
385 + } else {
386 + $providers = $provider_settings;
387 + }
388 +
389 + if(empty($providers)){
390 + return;
391 + }
392 +
393 + // ------ HTML STARTS HERE -------- //
394 +
395 + $style = 'icon';
396 + $shape = 'square';
397 + $position = 'below';
398 + if(!empty($loginizer['social_settings'])){
399 + $social_settings = $loginizer['social_settings'];
400 +
401 + // Setting Button Style
402 + if(!empty($social_settings[$page_type]['button_style']) && $social_settings[$page_type]['button_style'] === 'full'){
403 + $style = 'full';
404 + }
405 +
406 + // Setting Button Shape
407 + if(!empty($social_settings[$page_type]['button_shape']) && $social_settings[$page_type]['button_shape'] !== 'square'){
408 + $shape = $social_settings[$page_type]['button_shape'];
409 + }
410 +
411 + // Setting position
412 + if(!empty($social_settings[$page_type]['button_position']) && $social_settings[$page_type]['button_position'] !== 'below'){
413 + $position = $social_settings[$page_type]['button_position'];
414 + }
415 + }
416 +
417 + $container_alignment = isset($loginizer['social_settings'][$page_type]['alignment']) ? $loginizer['social_settings'][$page_type]['alignment'] : 'auto';
418 + $button_alignment = isset($loginizer['social_settings'][$page_type]['button_alignment']) ? $loginizer['social_settings'][$page_type]['button_alignment'] : 'center';
419 +
420 + // Shortcode style
421 + if(!empty($short_atts['type'])){
422 + $style = esc_html($short_atts['type']);
423 + }
424 +
425 + // Shortcode Shape square or circle
426 + if(!empty($short_atts['shape'])){
427 + $shape = esc_html($short_atts['shape']);
428 + }
429 +
430 + // Shortcode for Container alignment
431 + if(!empty($short_atts['container_alignment'])){
432 + $container_alignment = esc_html($short_atts['container_alignment']);
433 + }
434 +
435 + // Shortcode for Button alignment
436 + if(!empty($short_atts['button_alignment'])){
437 + $button_alignment = esc_html($short_atts['button_alignment']);
438 + }
439 +
440 + // Setting divider position
441 + $divider_pos = '';
442 + if(!empty($short_atts['divider']) && $short_atts['divider'] == 'above'){
443 + $divider_pos = 'above';
444 + }elseif(empty($short_atts) && !empty($loginizer['social_settings']) && $position === 'below_plus'){
445 + $divider_pos = 'above';
446 + }elseif(!empty($short_atts['divider']) && $short_atts['divider'] == 'below'){
447 + $divider_pos = 'below';
448 + }elseif(empty($short_atts) && !empty($loginizer['social_settings']) && $position === 'above_plus'){
449 + $divider_pos = 'below';
450 + }
451 +
452 + loginizer_social_css($divider_pos);
453 +
454 + $padding = [
455 + 'above' => 'bottom',
456 + 'below' => 'top'
457 + ];
458 +
459 + $social_buttons = '<div id="lz-social-login-btns" class="'.($style == 'icon' ? 'lz-social-login-btns-icon' : 'lz-social-login-btns-full').' '.($position == 'above' || $position == 'below' ? 'lz-social-'.$padding[$position].'-padding' : '').'" style="justify-self:'.esc_attr($container_alignment).'; justify-content:'.esc_attr($button_alignment).';">';
460 +
461 + /* translators: %s: This OR is used as a separator for Either login through username OR use social login */
462 + $or_translated = __('OR', 'loginizer');
463 +
464 + // HTML of the divider in case the buttons are below the login fields
465 + if(!empty($divider_pos) && $divider_pos == 'above'){
466 + $social_buttons .= '<div class="loginizer-social-divider">'.esc_html($or_translated).'</div><br>';
467 + }
468 +
469 + include_once LOGINIZER_DIR . '/main/login-providers.php';
470 +
471 + // This is used to decide weather we will use Login with or Register with
472 + $current_hook = current_action();
473 + $register_hooks = ['register_form', 'woocommerce_register_form'];
474 +
475 + foreach($providers as $provider => $settings){
476 + if(empty($settings['enabled']) || empty($settings['tested'])){
477 + continue;
478 + }
479 +
480 + // Filters Pro Only Auth
481 + if(!empty($loginizer_login_providers[$provider]['premium']) && !defined('LOGINIZER_PREMIUM')){
482 + continue;
483 + }
484 +
485 + $name = $loginizer_login_providers[$provider]['name'];
486 + $color = $loginizer_login_providers[$provider]['color'];
487 +
488 + $btn_style = 'default';
489 + if(!empty($provider_settings[$provider]['button_style'])){
490 + $btn_style = $provider_settings[$provider]['button_style'];
491 + }
492 +
493 + // TODO:: Improve the comment here
494 + // The image is named based on button style as Facebook has different images for different style
495 + // And if some more social options are added they could have the same behaviour too.
496 + $img_url = LOGINIZER_URL .'/assets/images/social/'.$provider.'.png';
497 + if('default' !== $btn_style){
498 + if(file_exists(LOGINIZER_DIR .'/assets/images/social/'.$provider.'-'.$btn_style.'.png')){
499 + $img_url = LOGINIZER_URL .'/assets/images/social/'.$provider.'-'.$btn_style.'.png';
500 + }
501 + }
502 +
503 + $social_buttons .= '<div class="loginizer-social-button '.($style == 'icon' ? 'lz-social-button-icon' : 'lz-social-button-btn').' '.($shape == 'circle' ? 'lz-social-button-icon-circle' : 'lz-social-button-icon-square').'" onclick="loginizer_auth_popup(\''.esc_js($provider).'\', '.esc_js(!empty($settings['loginizer_social_key']) ? true : 0).')" style="'.((!empty($loginizer_login_providers[$provider]['styles']) && !empty($loginizer_login_providers[$provider]['styles'][$btn_style])) ? esc_attr($loginizer_login_providers[$provider]['styles'][$btn_style]) : esc_attr('background-color:'. esc_attr($color)). '; color:#FFF;') .'">
504 + <div class="loginizer-social-btn-logo">
505 + <img src="'.esc_url($img_url).'" height="24" alt="'.esc_attr($name).' Icon"/>
506 + </div>';
507 +
508 + if(in_array($current_hook, $register_hooks)){
509 + /* translators: %s: This is for social login so the complete text would be Register With [Brand Name], eg Register With Google */
510 + $button_text = esc_html__('Register With', 'loginizer');
511 + } else {
512 + /* translators: %s: This is for social login so the complete text would be Login With [Brand Name], eg Login With Google */
513 + $button_text = esc_html__('Login With', 'loginizer');
514 + }
515 +
516 + // Button text in case of full button
517 + if(!empty($loginizer['social_settings']) && $style === 'full'){
518 + $social_buttons .= '<div class="loginizer-social-btn-text">'.esc_html($button_text).' <strong>'.esc_html($name).'</strong>
519 + </div>';
520 + }
521 +
522 + $social_buttons .= '</div>';
523 + }
524 +
525 + if(empty($social_buttons)){
526 + $social_buttons .= esc_html__('No Auth Provider configured', 'loginizer');
527 + }
528 +
529 + // HTML of the divider in case the buttons are above the login fields
530 + if(!empty($divider_pos) && $divider_pos == 'below'){
531 + $social_buttons .= '<br><div class="loginizer-social-divider">'.esc_html($or_translated).'</div>';
532 + }
533 +
534 + $social_buttons .= '</div>';
535 + loginizer_add_social_js($page_type);
536 +
537 + if($return){
538 + return $social_buttons;
539 + }
540 +
541 + echo wp_kses($social_buttons, [
542 + 'div' => ['class' => true, 'id' => true, 'style' => true, 'onclick' => true],
543 + 'img' => ['src' => true, 'height' => true, 'alt' => true, 'width' => true],
544 + 'strong' => true,
545 + ]);
546 +}
547 +
548 +function loginizer_add_social_js($page_type){
549 + global $loginizer;
550 +
551 + if(wp_script_is('loginizer-social-js') || loginizer_is_blacklisted() || !empty($loginizer['social_script_added'])){
552 + return;
553 + }
554 +
555 + $loginizer['social_script_added'] = false;
556 + $func = 'append';
557 + if(!empty($loginizer['social_settings']) && !empty($loginizer['social_settings'][$page_type]['button_position']) && strpos($loginizer['social_settings'][$page_type]['button_position'], 'above') !== FALSE){
558 + $func = 'prepend';
559 + }
560 +
561 + $target_window = 'same';
562 + if(isset($_GET['interim-login']) && $_GET['interim-login'] == 1){
563 + $target_window = 'popup';
564 + } elseif(!empty($loginizer['social_settings']['general']['target_window'])){
565 + $target_window = $loginizer['social_settings']['general']['target_window'];
566 + }
567 +
568 + $social_nonce = wp_create_nonce('loginizer_social_check');
569 +
570 + wp_register_script('loginizer-social-js', '', ['jquery'], LOGINIZER_VERSION, ['strategy' => false, 'in_footer' => true]);
571 + wp_enqueue_script('loginizer-social-js');
572 + wp_add_inline_script('loginizer-social-js', '
573 +
574 +
575 +
576 + let lz_form = document.querySelectorAll("#loginform, #registerform, .woocommerce-form-login, .woocommerce-form-register, #front-login-form, #setupform"),
577 + lz_social_btns = document.querySelectorAll("#lz-social-login-btns"),
578 + lz_target_window = "'.esc_html($target_window).'",
579 + lz_is_interim = "'.(!empty($_GET['interim-login']) ? '&interim-login=0' : '').'"; // as for interim it should only open a popup
580 +
581 + if(lz_target_window == "same"){
582 + let loader = "<style>#loginizer-social-loader-wrap{display:none; align-items:center; justify-content:center; position:fixed; top:0; left:0; width:100%; height:100vh; background-color:rgba(0, 0, 0, 0.2);} .loginizer-social-loader{width:48px;height:48px;border:5px solid #fff;border-bottom-color:transparent;border-radius:50%;display:inline-block;box-sizing:border-box;animation:1s linear infinite rotation}@keyframes rotation{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}</style>";
583 + loader += "<div id=\"loginizer-social-loader-wrap\"><div class=\"loginizer-social-loader\"></div></div>";
584 +
585 + jQuery("body").append(loader);
586 + }
587 +
588 +
589 + lz_social_btns.forEach((btns) => {
590 + btns.style.display="flex";
591 + });
592 +
593 + if(lz_form.length > 0){
594 + lz_form.forEach((form, index) => {
595 + if (lz_social_btns[index]) {
596 + lz_social_btns[index].style.display="flex";
597 + form.'.esc_html($func).'(lz_social_btns[index]);
598 + }
599 + });
600 + }
601 +
602 + function loginizer_auth_popup(provider, isAPI) {
603 + let target_url = "'.esc_url(wp_login_url()).'?social_security='.esc_html($social_nonce).'&lz_social_provider=" + provider+lz_is_interim;
604 +
605 + if(isAPI){
606 + target_url += "&lz_api=1";
607 + }
608 +
609 + let redirect_to = "'.(!empty($_GET['redirect_to']) ? wp_validate_redirect(esc_url($_GET['redirect_to'])) : '') .'";
610 +
611 + if(redirect_to.length){
612 + target_url += "&ref="+redirect_to;
613 + } else {
614 + target_url += "&ref='.esc_url((is_ssl() ? 'https://' : 'http://').$_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']).'"
615 + }
616 +
617 + if(lz_target_window == "same"){
618 + jQuery("#loginizer-social-loader-wrap").css("display", "flex");
619 +
620 + window.location.href = target_url;
621 +
622 + return;
623 + }
624 +
625 + let screen_x = window.screenX !== undefined ? window.screenX : window.screenLeft,
626 + screen_y = window.screenY !== undefined ? window.screenY : window.screenTop,
627 + outer_width = window.outerWidth !== undefined ? window.outerWidth : document.documentElement.clientWidth,
628 + outer_height = window.outerHeight !== undefined ? window.outerHeight : document.documentElement.clientHeight - 22,
629 + target_width = 600,
630 + target_height = 600,
631 + right = parseInt(screen_y + (outerHeight - target_height) / 2.5, 10),
632 + left = parseInt(screen_x + (outerWidth - target_width) / 2, 10),
633 + attributes = [];
634 +
635 + if(target_width !== null){
636 + attributes.push("width=" + target_width);
637 + }
638 + if(target_height !== null){
639 + attributes.push("height=" + target_height);
640 + }
641 + attributes.push("left=" + left);
642 + attributes.push("top=" + right);
643 + attributes.push("scrollbars=1");
644 +
645 + var auth_window = window.open(target_url, "authWindow", attributes.join(","));
646 +
647 + if(window.focus){
648 + auth_window.focus();
649 + }
650 + return false;
651 + }'
652 + );
653 +
654 + $loginizer['social_script_added'] = true;
655 +
656 +}
657 +
658 +function loginizer_social_btn_login($return = false, $id = ''){
659 + if(!loginizer_is_blacklisted()){
660 + loginizer_social_btn($return, 'login');
661 + }
662 +}
663 +
664 +function loginizer_get_social_error(){
665 + global $loginizer;
666 +
667 + // If we already have the error set
668 + if(!empty($loginizer['social_errors'])){
669 + return;
670 + }
671 +
672 + if(empty($_COOKIE) || empty($_COOKIE['lz_social_error'])){
673 + return;
674 + }
675 +
676 + $error_identifier = sanitize_text_field(wp_unslash($_COOKIE['lz_social_error']));
677 + $social_errors = get_site_transient($error_identifier);
678 +
679 + if(empty($social_errors['errors'])){
680 + return;
681 + }
682 +
683 + // Setting error data
684 + $loginizer['retries_left'] = $social_errors['retries_left'];
685 + $loginizer['social_errors'] = $social_errors['errors'];
686 +
687 + // Cleaning the error data
688 + delete_site_transient($error_identifier); // Deleting the data
689 + //setcookie('lz_social_error', '', time() - 300, COOKIEPATH, COOKIE_DOMAIN, is_ssl(), true); // have to delete
690 +}