PluginProbe
Loginizer / 2.0.2
Loginizer v2.0.2
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 +535 -16 1.2.02.0.2 View file →
@@ -1,8 +1,14 @@
1 1 <?php
2 2
3 +if(!defined('ABSPATH')){
4 + die('HACKING ATTEMPT!');
5 +}
6 +
7 +include_once(LOGINIZER_DIR.'/lib/IPv6/IPv6.php');
8 +
3 9 // Get the client IP
4 -function lz_getip(){
10 +function _lz_getip(){
5 11 if(isset($_SERVER["REMOTE_ADDR"])){
6 12 return $_SERVER["REMOTE_ADDR"];
7 13 }elseif(isset($_SERVER["HTTP_X_FORWARDED_FOR"])){
8 14 return $_SERVER["HTTP_X_FORWARDED_FOR"];
@@ -10,8 +16,48 @@
10 16 return $_SERVER["HTTP_CLIENT_IP"];
11 17 }
12 18 }
13 19
20 +// Get the client IP
21 +function lz_getip(){
22 +
23 + global $loginizer;
24 +
25 + // Just so that we have something
26 + $ip = _lz_getip();
27 +
28 + $loginizer['ip_method'] = (int) @$loginizer['ip_method'];
29 +
30 + if(isset($_SERVER["REMOTE_ADDR"])){
31 + $ip = $_SERVER["REMOTE_ADDR"];
32 + }
33 +
34 + if(isset($_SERVER["HTTP_X_FORWARDED_FOR"]) && @$loginizer['ip_method'] == 1){
35 + if(strpos($_SERVER["HTTP_X_FORWARDED_FOR"], ',')){
36 + $temp_ip = explode(',', $_SERVER["HTTP_X_FORWARDED_FOR"]);
37 + $ip = trim($temp_ip[0]);
38 + }else{
39 + $ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
40 + }
41 + }
42 +
43 + if(isset($_SERVER["HTTP_CLIENT_IP"]) && @$loginizer['ip_method'] == 2){
44 + $ip = $_SERVER["HTTP_CLIENT_IP"];
45 + }
46 +
47 + if(@$loginizer['ip_method'] == 3 && isset($_SERVER[@$loginizer['custom_ip_method']])){
48 + $ip = $_SERVER[@$loginizer['custom_ip_method']];
49 + }
50 +
51 + // Hacking fix for X-Forwarded-For
52 + if(!lz_valid_ip($ip)){
53 + return '';
54 + }
55 +
56 + return $ip;
57 +
58 +}
59 +
14 60 // Execute a select query and return an array
15 61 function lz_selectquery($query, $array = 0){
16 62 global $wpdb;
17 63
@@ -26,14 +72,55 @@
26 72
27 73 // Check if an IP is valid
28 74 function lz_valid_ip($ip){
29 75
30 - if(!ip2long($ip)){
76 + if(empty($ip)){
31 77 return false;
32 - }
78 + }
79 +
80 + // IPv6
81 + if(lz_valid_ipv6($ip)){
82 + return true;
83 + }
84 +
85 + // IPv4
86 + if(!ip2long($ip) || !lz_valid_ipv4($ip)){
87 + return false;
88 + }
89 +
33 90 return true;
34 91 }
35 92
93 +function lz_valid_ipv4($ip){
94 + if(!preg_match('/^(\d){1,3}\.(\d){1,3}\.(\d){1,3}\.(\d){1,3}$/is', $ip) || substr_count($ip, '.') != 3){
95 + return false;
96 + }
97 +
98 + $r = explode('.', $ip);
99 +
100 + foreach($r as $v){
101 + $v = (int) $v;
102 + if($v > 255 || $v < 0){
103 + return false;
104 + }
105 + }
106 +
107 + return true;
108 +
109 +}
110 +
111 +function lz_valid_ipv6($ip){
112 +
113 + $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}:))$/';
114 +
115 + if(!preg_match($pattern, $ip)){
116 + return false;
117 + }
118 +
119 + return true;
120 +
121 +}
122 +
36 123 // Check if a field is posted via POST else return default value
37 124 function lz_optpost($name, $default = ''){
38 125
39 126 if(!empty($_POST[$name])){
@@ -65,15 +152,21 @@
65 152
66 153 // For filling in posted values
67 154 function lz_POSTval($name, $default = ''){
68 155
69 - return (!empty($_POST) ? (!isset($_POST[$name]) ? '' : $_POST[$name]) : $default);
156 + return (!empty($_POST) ? (!isset($_POST[$name]) ? '' : esc_html($_POST[$name])) : $default);
70 157
71 158 }
72 159
73 -function lz_POSTchecked($name, $default = false){
160 +function lz_POSTchecked($name, $default = false, $submit_name = ''){
74 161
75 - return (!empty($_POST) ? (isset($_POST[$name]) ? 'checked="checked"' : '') : (!empty($default) ? 'checked="checked"' : ''));
162 + if(!empty($submit_name)){
163 + $post_to_check = isset($_POST[$submit_name]) ? $_POST[$submit_name] : '';
164 + }else{
165 + $post_to_check = $_POST;
166 + }
167 +
168 + return (!empty($post_to_check) ? (isset($_POST[$name]) ? 'checked="checked"' : '') : (!empty($default) ? 'checked="checked"' : ''));
76 169
77 170 }
78 171
79 172 function lz_POSTselect($name, $value, $default = false){
@@ -91,21 +184,18 @@
91 184 }
92 185
93 186 }
94 187
188 +function lz_POSTradio($name, $val, $default = null){
189 +
190 + return (!empty($_POST) ? (@$_POST[$name] == $val ? 'checked="checked"' : '') : (!is_null($default) && $default == $val ? 'checked="checked"' : ''));
191 +
192 +}
193 +
95 194 function lz_inputsec($string){
96 195
97 - if(!get_magic_quotes_gpc()){
196 + $string = addslashes($string);
98 197
99 - $string = addslashes($string);
100 -
101 - }else{
102 -
103 - $string = stripslashes($string);
104 - $string = addslashes($string);
105 -
106 - }
107 -
108 198 // This is to replace ` which can cause the command to be executed in exec()
109 199 $string = str_replace('`', '\`', $string);
110 200
111 201 return $string;
@@ -244,5 +334,434 @@
244 334 }
245 335 return $randomString;
246 336 }
247 337
338 +function lz_print($array){
248 339
340 + echo '<pre>';
341 + print_r($array);
342 + echo '</pre>';
343 +
344 +}
345 +
346 +function lz_cleanpath($path){
347 + $path = str_replace('\\\\', '/', $path);
348 + $path = str_replace('\\', '/', $path);
349 + $path = str_replace('//', '/', $path);
350 + return rtrim($path, '/');
351 +}
352 +
353 +// Returns the Numeric Value of results Per Page
354 +function lz_get_page($get = 'page', $resperpage = 50){
355 +
356 + $resperpage = (!empty($_REQUEST['reslen']) && is_numeric($_REQUEST['reslen']) ? (int) lz_optreq('reslen') : $resperpage);
357 +
358 + if(lz_optget($get)){
359 + $pg = (int) lz_optget($get);
360 + $pg = $pg - 1;
361 + $page = ($pg * $resperpage);
362 + $page = ($page <= 0 ? 0 : $page);
363 + }else{
364 + $page = 0;
365 + }
366 + return $page;
367 +}
368 +
369 +// Replaces the Variables with the supplied ones
370 +function lz_lang_vars_name($str, $array){
371 +
372 + foreach($array as $k => $v){
373 +
374 + $str = str_replace('$'.$k, $v, $str);
375 +
376 + }
377 +
378 + return $str;
379 +
380 +}
381 +
382 +// Check if Loginizer is premium
383 +function loginizer_is_premium(){
384 + return defined('LOGINIZER_PREMIUM');
385 +}
386 +
387 +function loginizer_feature_available($feature = '', $return = 0){
388 +
389 + if(loginizer_is_premium()){
390 + return true;
391 + }
392 +
393 + $msg = '';
394 +
395 + if(!empty($feature)){
396 + $msg .= '<b>'.$feature.'</b> is available in the Pro version of Loginizer. ';
397 + }
398 +
399 + $msg .= '<a href="'.LOGINIZER_PRICING_URL.'" target="_blank" style="text-decoration:none; color:green;"><b>Upgrade to Pro</b></a>';
400 +
401 + if(!empty($return)){
402 + return $msg;
403 + }else{
404 + 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>';
405 + }
406 +
407 +}
408 +
409 +// Checks if the email is valid
410 +function lz_valid_email($email){
411 +
412 + return filter_var($email, FILTER_VALIDATE_EMAIL);
413 +
414 +}
415 +
416 +function loginizer_blocked_page($lz_error){
417 +
418 + // We are checking if this is a login page or not
419 + if(false === stripos(wp_login_url(), $_SERVER['REQUEST_URI'])){
420 + return;
421 + }
422 +
423 + echo '<!DOCTYPE html><html><head>
424 + <meta name="robots" content="noindex, noarchive">
425 + <meta name="referrer" content="strict-origin-when-cross-origin">
426 + <meta name="viewport" content="width=device-width, initial-scale=1.0">
427 + <title>'.__('You can not access this page', 'loginizer').'</title>
428 + <style>html,body{height:100%}
429 + .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>
430 + </head>
431 + <body style="font-family:sans-serif; font-size:calc(15px + 0.390625vw);margin:0;">
432 + <div class="loginizer-blocked-wrapper">
433 + <div style="margin-top:10em;">
434 + <h1 align="center">'.__('You can not access this page', 'loginizer').'</h1>
435 + <p align="center">'.wp_kses_post(implode('', $lz_error)).'</p>
436 + </div>
437 + <footer>';
438 + if(!defined('LOGINIZER_PREMIUM')){
439 + echo '<p>Powered by Loginizer</p>';
440 + } else {
441 + echo '<p>Powered by ' . esc_html(get_bloginfo('name')) . '</p>';
442 + }
443 +
444 + echo '</footer></div></body></html>';
445 + die();
446 +}
447 +
448 +function loginizer_social_css($position = 'below'){
449 + global $loginizer;
450 +
451 + // Starting the CSS
452 + $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}';
453 +
454 + // CSS for the divider with the text OR in the middle
455 + if(!empty($loginizer['social_settings']) && ($position === 'below' || $position === 'above')){
456 + $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}';
457 + }
458 +
459 + wp_register_style('loginizer-social', '', [], LOGINIZER_VERSION);
460 + wp_enqueue_style('loginizer-social');
461 + wp_add_inline_style('loginizer-social', $css);
462 +}
463 +
464 +// Echos the HTML of the Social button
465 +function loginizer_social_btn($return = false, $page_type = 'login', $short_atts = []){
466 + global $loginizer, $loginizer_login_providers;
467 +
468 + // We don't want to give social login option to blacklisted IP's
469 + if(loginizer_is_blacklisted() || !loginizer_can_login()){
470 + return;
471 + }
472 +
473 + $provider_settings = get_option('loginizer_provider_settings', []);
474 + $provider_order = get_option('loginizer_social_order', []); // in what order the icons are to be shown
475 +
476 + $providers = [];
477 +
478 + // Sorting according to the saved order of the providers.
479 + if(!empty($provider_order)){
480 + foreach($provider_order as $key => $num){
481 + if(!empty($provider_settings[$key])){
482 + $providers[$key] = $provider_settings[$key];
483 + }
484 + }
485 + } else {
486 + $providers = $provider_settings;
487 + }
488 +
489 + if(empty($providers)){
490 + return;
491 + }
492 +
493 + // ------ HTML STARTS HERE -------- //
494 +
495 + $style = 'icon';
496 + $shape = 'square';
497 + $position = 'below';
498 + if(!empty($loginizer['social_settings'])){
499 + $social_settings = $loginizer['social_settings'];
500 +
501 + // Setting Button Style
502 + if(!empty($social_settings[$page_type]['button_style']) && $social_settings[$page_type]['button_style'] === 'full'){
503 + $style = 'full';
504 + }
505 +
506 + // Setting Button Shape
507 + if(!empty($social_settings[$page_type]['button_shape']) && $social_settings[$page_type]['button_shape'] !== 'square'){
508 + $shape = $social_settings[$page_type]['button_shape'];
509 + }
510 +
511 + // Setting position
512 + if(!empty($social_settings[$page_type]['button_position']) && $social_settings[$page_type]['button_position'] !== 'below'){
513 + $position = $social_settings[$page_type]['button_position'];
514 + }
515 + }
516 +
517 + $container_alignment = isset($loginizer['social_settings'][$page_type]['alignment']) ? $loginizer['social_settings'][$page_type]['alignment'] : 'auto';
518 + $button_alignment = isset($loginizer['social_settings'][$page_type]['button_alignment']) ? $loginizer['social_settings'][$page_type]['button_alignment'] : 'center';
519 +
520 + // Shortcode style
521 + if(!empty($short_atts['type'])){
522 + $style = esc_html($short_atts['type']);
523 + }
524 +
525 + // Shortcode Shape square or circle
526 + if(!empty($short_atts['shape'])){
527 + $shape = esc_html($short_atts['shape']);
528 + }
529 +
530 + // Shortcode for Container alignment
531 + if(!empty($short_atts['container_alignment'])){
532 + $container_alignment = esc_html($short_atts['container_alignment']);
533 + }
534 +
535 + // Shortcode for Button alignment
536 + if(!empty($short_atts['button_alignment'])){
537 + $button_alignment = esc_html($short_atts['button_alignment']);
538 + }
539 +
540 + // Setting divider position
541 + $divider_pos = '';
542 + if(!empty($short_atts['divider']) && $short_atts['divider'] == 'above'){
543 + $divider_pos = 'above';
544 + }elseif(empty($short_atts) && !empty($loginizer['social_settings']) && $position === 'below_plus'){
545 + $divider_pos = 'above';
546 + }elseif(!empty($short_atts['divider']) && $short_atts['divider'] == 'below'){
547 + $divider_pos = 'below';
548 + }elseif(empty($short_atts) && !empty($loginizer['social_settings']) && $position === 'above_plus'){
549 + $divider_pos = 'below';
550 + }
551 +
552 + loginizer_social_css($divider_pos);
553 +
554 + $padding = [
555 + 'above' => 'bottom',
556 + 'below' => 'top'
557 + ];
558 +
559 + $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).';">';
560 +
561 + // HTML of the divider in case the buttons are below the login fields
562 + if(!empty($divider_pos) && $divider_pos == 'above'){
563 + $social_buttons .= '<div class="loginizer-social-divider">OR</div><br>';
564 + }
565 +
566 + include_once LOGINIZER_DIR . '/main/login-providers.php';
567 +
568 + foreach($providers as $provider => $settings){
569 + if(empty($settings['enabled']) || empty($settings['tested'])){
570 + continue;
571 + }
572 +
573 + // Filters Pro Only Auth
574 + if(!empty($loginizer_login_providers[$provider]['premium']) && !defined('LOGINIZER_PREMIUM')){
575 + continue;
576 + }
577 +
578 + $name = $loginizer_login_providers[$provider]['name'];
579 + $color = $loginizer_login_providers[$provider]['color'];
580 +
581 + $btn_style = 'default';
582 + if(!empty($provider_settings[$provider]['button_style'])){
583 + $btn_style = $provider_settings[$provider]['button_style'];
584 + }
585 +
586 + // TODO:: Improve the comment here
587 + // The image is named based on button style as Facebook has different images for different style
588 + // And if some more social options are added they could have the same behaviour too.
589 + $img_url = LOGINIZER_URL .'/assets/images/social/'.$provider.'.png';
590 + if('default' !== $btn_style){
591 + if(file_exists(LOGINIZER_DIR .'/assets/images/social/'.$provider.'-'.$btn_style.'.png')){
592 + $img_url = LOGINIZER_URL .'/assets/images/social/'.$provider.'-'.$btn_style.'.png';
593 + }
594 + }
595 +
596 + $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;') .'">
597 + <div class="loginizer-social-btn-logo">
598 + <img src="'.esc_url($img_url).'" height="24" alt="'.esc_attr($name).' Icon"/>
599 + </div>';
600 +
601 + // Button text in case of full button
602 + if(!empty($loginizer['social_settings']) && $style === 'full'){
603 + $social_buttons .= '<div class="loginizer-social-btn-text">'.esc_html__('Login With', 'loginizer').' <strong>'.esc_html($name).'</strong>
604 + </div>';
605 + }
606 +
607 + $social_buttons .= '</div>';
608 + }
609 +
610 + if(empty($social_buttons)){
611 + $social_buttons .= esc_html__('No Auth Provider configured', 'loginizer');
612 + }
613 +
614 + // HTML of the divider in case the buttons are above the login fields
615 + if(!empty($divider_pos) && $divider_pos == 'below'){
616 + $social_buttons .= '<br><div class="loginizer-social-divider">OR</div>';
617 + }
618 +
619 + $social_buttons .= '</div>';
620 + loginizer_add_social_js($page_type);
621 +
622 + if($return){
623 + return $social_buttons;
624 + }
625 +
626 + echo wp_kses($social_buttons, [
627 + 'div' => ['class' => true, 'id' => true, 'style' => true, 'onclick' => true],
628 + 'img' => ['src' => true, 'height' => true, 'alt' => true, 'width' => true],
629 + 'strong' => true,
630 + ]);
631 +}
632 +
633 +function loginizer_add_social_js($page_type){
634 + global $loginizer;
635 +
636 + if(wp_script_is('loginizer-social-js') || loginizer_is_blacklisted() || !empty($loginizer['social_script_added'])){
637 + return;
638 + }
639 +
640 + $loginizer['social_script_added'] = false;
641 + $func = 'append';
642 + if(!empty($loginizer['social_settings']) && !empty($loginizer['social_settings'][$page_type]['button_position']) && strpos($loginizer['social_settings'][$page_type]['button_position'], 'above') !== FALSE){
643 + $func = 'prepend';
644 + }
645 +
646 + $target_window = 'same';
647 + if(isset($_GET['interim-login']) && $_GET['interim-login'] == 1){
648 + $target_window = 'popup';
649 + } elseif(!empty($loginizer['social_settings']['general']['target_window'])){
650 + $target_window = $loginizer['social_settings']['general']['target_window'];
651 + }
652 +
653 + $social_nonce = wp_create_nonce('loginizer_social_check');
654 +
655 + wp_register_script('loginizer-social-js', '', ['jquery'], LOGINIZER_VERSION, ['strategy' => false, 'in_footer' => true]);
656 + wp_enqueue_script('loginizer-social-js');
657 + wp_add_inline_script('loginizer-social-js', '
658 +
659 +
660 +
661 + let lz_form = document.querySelectorAll("#loginform, #registerform, .woocommerce-form-login, .woocommerce-form-register, #front-login-form, #setupform"),
662 + lz_social_btns = document.querySelectorAll("#lz-social-login-btns"),
663 + lz_target_window = "'.esc_html($target_window).'",
664 + lz_is_interim = "'.(!empty($_GET['interim-login']) ? '&interim-login=0' : '').'"; // as for interim it should only open a popup
665 +
666 + if(lz_target_window == "same"){
667 + 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>";
668 + loader += "<div id=\"loginizer-social-loader-wrap\"><div class=\"loginizer-social-loader\"></div></div>";
669 +
670 + jQuery("body").append(loader);
671 + }
672 +
673 +
674 + lz_social_btns.forEach((btns) => {
675 + btns.style.display="flex";
676 + });
677 +
678 + if(lz_form.length > 0){
679 + lz_form.forEach((form, index) => {
680 + if (lz_social_btns[index]) {
681 + lz_social_btns[index].style.display="flex";
682 + form.'.esc_html($func).'(lz_social_btns[index]);
683 + }
684 + });
685 + }
686 +
687 + function loginizer_auth_popup(provider, isAPI) {
688 + let target_url = "'.esc_url(wp_login_url()).'?social_security='.esc_html($social_nonce).'&lz_social_provider=" + provider+lz_is_interim;
689 +
690 + if(isAPI){
691 + target_url += "&lz_api=1";
692 + }
693 +
694 + target_url += "&ref='.esc_url((is_ssl() ? 'https://' : 'http://').$_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']).'"
695 +
696 + if(lz_target_window == "same"){
697 + jQuery("#loginizer-social-loader-wrap").css("display", "flex");
698 +
699 + window.location.href = target_url;
700 +
701 + return;
702 + }
703 +
704 + let screen_x = window.screenX !== undefined ? window.screenX : window.screenLeft,
705 + screen_y = window.screenY !== undefined ? window.screenY : window.screenTop,
706 + outer_width = window.outerWidth !== undefined ? window.outerWidth : document.documentElement.clientWidth,
707 + outer_height = window.outerHeight !== undefined ? window.outerHeight : document.documentElement.clientHeight - 22,
708 + target_width = 600,
709 + target_height = 600,
710 + right = parseInt(screen_y + (outerHeight - target_height) / 2.5, 10),
711 + left = parseInt(screen_x + (outerWidth - target_width) / 2, 10),
712 + attributes = [];
713 +
714 + if(target_width !== null){
715 + attributes.push("width=" + target_width);
716 + }
717 + if(target_height !== null){
718 + attributes.push("height=" + target_height);
719 + }
720 + attributes.push("left=" + left);
721 + attributes.push("top=" + right);
722 + attributes.push("scrollbars=1");
723 +
724 + var auth_window = window.open(target_url, "authWindow", attributes.join(","));
725 +
726 + if(window.focus){
727 + auth_window.focus();
728 + }
729 + return false;
730 + }'
731 + );
732 +
733 + $loginizer['social_script_added'] = true;
734 +
735 +}
736 +
737 +function loginizer_social_btn_login($return = false, $id = ''){
738 + loginizer_social_btn($return, 'login');
739 +}
740 +
741 +function loginizer_get_social_error(){
742 + global $loginizer;
743 +
744 + // If we already have the error set
745 + if(!empty($loginizer['social_errors'])){
746 + return;
747 + }
748 +
749 + if(empty($_COOKIE) || empty($_COOKIE['lz_social_error'])){
750 + return;
751 + }
752 +
753 + $error_identifier = sanitize_text_field(wp_unslash($_COOKIE['lz_social_error']));
754 + $social_errors = get_site_transient($error_identifier);
755 +
756 + if(empty($social_errors['errors'])){
757 + return;
758 + }
759 +
760 + // Setting error data
761 + $loginizer['retries_left'] = $social_errors['retries_left'];
762 + $loginizer['social_errors'] = $social_errors['errors'];
763 +
764 + // Cleaning the error data
765 + delete_site_transient($error_identifier); // Deleting the data
766 + //setcookie('lz_social_error', '', time() - 300, COOKIEPATH, COOKIE_DOMAIN, is_ssl(), true); // have to delete
767 +}