PluginProbe
Loginizer / 1.2.0
Loginizer v1.2.0
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 +16 -541 2.0.41.2.0 View file →
@@ -1,14 +1,8 @@
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 -
9 3 // Get the client IP
10 -function _lz_getip(){
4 +function lz_getip(){
11 5 if(isset($_SERVER["REMOTE_ADDR"])){
12 6 return $_SERVER["REMOTE_ADDR"];
13 7 }elseif(isset($_SERVER["HTTP_X_FORWARDED_FOR"])){
14 8 return $_SERVER["HTTP_X_FORWARDED_FOR"];
@@ -16,48 +10,8 @@
16 10 return $_SERVER["HTTP_CLIENT_IP"];
17 11 }
18 12 }
19 13
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 -
60 14 // Execute a select query and return an array
61 15 function lz_selectquery($query, $array = 0){
62 16 global $wpdb;
63 17
@@ -72,55 +26,14 @@
72 26
73 27 // Check if an IP is valid
74 28 function lz_valid_ip($ip){
75 29
76 - if(empty($ip)){
30 + if(!ip2long($ip)){
77 31 return false;
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 -
32 + }
90 33 return true;
91 34 }
92 35
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 -
123 36 // Check if a field is posted via POST else return default value
124 37 function lz_optpost($name, $default = ''){
125 38
126 39 if(!empty($_POST[$name])){
@@ -152,21 +65,15 @@
152 65
153 66 // For filling in posted values
154 67 function lz_POSTval($name, $default = ''){
155 68
156 - return (!empty($_POST) ? (!isset($_POST[$name]) ? '' : esc_html($_POST[$name])) : $default);
69 + return (!empty($_POST) ? (!isset($_POST[$name]) ? '' : $_POST[$name]) : $default);
157 70
158 71 }
159 72
160 -function lz_POSTchecked($name, $default = false, $submit_name = ''){
73 +function lz_POSTchecked($name, $default = false){
161 74
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"' : ''));
75 + return (!empty($_POST) ? (isset($_POST[$name]) ? 'checked="checked"' : '') : (!empty($default) ? 'checked="checked"' : ''));
169 76
170 77 }
171 78
172 79 function lz_POSTselect($name, $value, $default = false){
@@ -184,18 +91,21 @@
184 91 }
185 92
186 93 }
187 94
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 -
194 95 function lz_inputsec($string){
195 96
196 - $string = addslashes($string);
97 + if(!get_magic_quotes_gpc()){
197 98
99 + $string = addslashes($string);
100 +
101 + }else{
102 +
103 + $string = stripslashes($string);
104 + $string = addslashes($string);
105 +
106 + }
107 +
198 108 // This is to replace ` which can cause the command to be executed in exec()
199 109 $string = str_replace('`', '\`', $string);
200 110
201 111 return $string;
@@ -334,440 +244,5 @@
334 244 }
335 245 return $randomString;
336 246 }
337 247
338 -function lz_print($array){
339 248
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 - let redirect_to = "'.(!empty($_GET['redirect_to']) ? wp_validate_redirect(esc_url($_GET['redirect_to'])) : '') .'";
695 -
696 - if(redirect_to.length){
697 - target_url += "&ref="+redirect_to;
698 - } else {
699 - target_url += "&ref='.esc_url((is_ssl() ? 'https://' : 'http://').$_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']).'"
700 - }
701 -
702 - if(lz_target_window == "same"){
703 - jQuery("#loginizer-social-loader-wrap").css("display", "flex");
704 -
705 - window.location.href = target_url;
706 -
707 - return;
708 - }
709 -
710 - let screen_x = window.screenX !== undefined ? window.screenX : window.screenLeft,
711 - screen_y = window.screenY !== undefined ? window.screenY : window.screenTop,
712 - outer_width = window.outerWidth !== undefined ? window.outerWidth : document.documentElement.clientWidth,
713 - outer_height = window.outerHeight !== undefined ? window.outerHeight : document.documentElement.clientHeight - 22,
714 - target_width = 600,
715 - target_height = 600,
716 - right = parseInt(screen_y + (outerHeight - target_height) / 2.5, 10),
717 - left = parseInt(screen_x + (outerWidth - target_width) / 2, 10),
718 - attributes = [];
719 -
720 - if(target_width !== null){
721 - attributes.push("width=" + target_width);
722 - }
723 - if(target_height !== null){
724 - attributes.push("height=" + target_height);
725 - }
726 - attributes.push("left=" + left);
727 - attributes.push("top=" + right);
728 - attributes.push("scrollbars=1");
729 -
730 - var auth_window = window.open(target_url, "authWindow", attributes.join(","));
731 -
732 - if(window.focus){
733 - auth_window.focus();
734 - }
735 - return false;
736 - }'
737 - );
738 -
739 - $loginizer['social_script_added'] = true;
740 -
741 -}
742 -
743 -function loginizer_social_btn_login($return = false, $id = ''){
744 - loginizer_social_btn($return, 'login');
745 -}
746 -
747 -function loginizer_get_social_error(){
748 - global $loginizer;
749 -
750 - // If we already have the error set
751 - if(!empty($loginizer['social_errors'])){
752 - return;
753 - }
754 -
755 - if(empty($_COOKIE) || empty($_COOKIE['lz_social_error'])){
756 - return;
757 - }
758 -
759 - $error_identifier = sanitize_text_field(wp_unslash($_COOKIE['lz_social_error']));
760 - $social_errors = get_site_transient($error_identifier);
761 -
762 - if(empty($social_errors['errors'])){
763 - return;
764 - }
765 -
766 - // Setting error data
767 - $loginizer['retries_left'] = $social_errors['retries_left'];
768 - $loginizer['social_errors'] = $social_errors['errors'];
769 -
770 - // Cleaning the error data
771 - delete_site_transient($error_identifier); // Deleting the data
772 - //setcookie('lz_social_error', '', time() - 300, COOKIEPATH, COOKIE_DOMAIN, is_ssl(), true); // have to delete
773 -}