| @@ -3,122 +3,14 @@ | ||
| 3 | 3 | if(!defined('ABSPATH')){ |
| 4 | 4 | die('Hacking Attempt!'); |
| 5 | 5 | } |
| 6 | 6 | |
| 7 | -function loginizer_admin_hooks(){ | |
| 8 | - add_action('admin_menu', 'loginizer_admin_menu'); | |
| 9 | - add_action('admin_notices', 'loginizer_social_login_url_alert'); | |
| 10 | - add_action('admin_footer', 'loginizer_social_interim_js'); | |
| 11 | - add_action('admin_init', 'loginizer_admin_actions'); | |
| 12 | - // add_filter("plugin_action_links_plugin_loginizer", 'loginizer_plugin_action_links'); | |
| 13 | - | |
| 14 | - loginizer_admin_promo_hooks(); | |
| 15 | -} | |
| 16 | 7 | |
| 17 | -function loginizer_admin_promo_hooks(){ | |
| 18 | - global $loginizer; | |
| 19 | - | |
| 20 | - if(!current_user_can('activate_plugins') || defined('SITEPAD')){ | |
| 21 | - return; | |
| 22 | - } | |
| 8 | +// HOOKS | |
| 9 | +add_action('admin_menu', 'loginizer_admin_menu'); | |
| 10 | +//add_filter("plugin_action_links_plugin_loginizer", 'loginizer_plugin_action_links'); | |
| 23 | 11 | |
| 24 | - // Is the premium features there ? | |
| 25 | - if(!defined('LOGINIZER_PREMIUM')){ | |
| 26 | - // The promo time | |
| 27 | - $loginizer['promo_time'] = get_option('loginizer_promo_time'); | |
| 28 | - if(empty($loginizer['promo_time'])){ | |
| 29 | - $loginizer['promo_time'] = time(); | |
| 30 | - update_option('loginizer_promo_time', $loginizer['promo_time']); | |
| 31 | - } | |
| 32 | 12 | |
| 33 | - // Are we to show the loginizer promo | |
| 34 | - if(!empty($loginizer['promo_time']) && $loginizer['promo_time'] > 0 && $loginizer['promo_time'] < (time() - (30*24*3600))){ | |
| 35 | - add_action('admin_notices', 'loginizer_promo'); | |
| 36 | - } | |
| 37 | - | |
| 38 | - if(!empty($loginizer['csrf_promo']) && $loginizer['csrf_promo'] > 0 && $loginizer['csrf_promo'] < (time() - 86400)){ | |
| 39 | - add_action('admin_notices', 'loginizer_csrf_promo'); | |
| 40 | - } | |
| 41 | - | |
| 42 | - // Are we to disable the promo | |
| 43 | - if(isset($_GET['loginizer_promo']) && (int)$_GET['loginizer_promo'] == 0){ | |
| 44 | - update_option('loginizer_promo_time', (0 - time()) ); | |
| 45 | - die('DONE'); | |
| 46 | - } | |
| 47 | - | |
| 48 | - $loginizer['backuply_promo'] = get_option('loginizer_backuply_promo_time'); | |
| 49 | - if(empty($loginizer['backuply_promo'])){ | |
| 50 | - $loginizer['backuply_promo'] = abs($loginizer['promo_time']); | |
| 51 | - update_option('loginizer_backuply_promo_time', $loginizer['backuply_promo']); | |
| 52 | - } | |
| 53 | - | |
| 54 | - // Setting CSRF Promo time | |
| 55 | - $loginizer['csrf_promo'] = get_option('loginizer_csrf_promo_time'); | |
| 56 | - | |
| 57 | - if(empty($loginizer['csrf_promo'])){ | |
| 58 | - $loginizer['csrf_promo'] = abs($loginizer['promo_time']); | |
| 59 | - update_option('loginizer_csrf_promo_time', $loginizer['csrf_promo']); | |
| 60 | - } | |
| 61 | - } | |
| 62 | - | |
| 63 | - // === Plugin Update Notice === // | |
| 64 | - $plugin_update_notice = get_option('softaculous_plugin_update_notice', []); | |
| 65 | - $available_update_list = get_site_transient('update_plugins'); | |
| 66 | - | |
| 67 | - if( | |
| 68 | - !empty($available_update_list) && | |
| 69 | - is_object($available_update_list) && | |
| 70 | - !empty($available_update_list->response) && | |
| 71 | - !empty($available_update_list->response['loginizer/loginizer.php']) && | |
| 72 | - (empty($plugin_update_notice) || empty($plugin_update_notice['loginizer/loginizer.php']) || (!empty($plugin_update_notice['loginizer/loginizer.php']) && | |
| 73 | - version_compare($plugin_update_notice['loginizer/loginizer.php'], $available_update_list->response['loginizer/loginizer.php']->new_version, '<'))) | |
| 74 | - ){ | |
| 75 | - add_action('admin_notices', 'loginizer_plugin_update_notice'); | |
| 76 | - add_filter('softaculous_plugin_update_notice', 'loginizer_update_notice_filter'); | |
| 77 | - } | |
| 78 | - // === Plugin Update Notice === // | |
| 79 | -} | |
| 80 | - | |
| 81 | -function loginizer_admin_actions(){ | |
| 82 | - global $loginizer; | |
| 83 | - | |
| 84 | - if(defined('LOGINIZER_PREMIUM') && !defined('SITEPAD') && current_user_can('activate_plugins') && isset($_GET['page']) && strpos($_GET['page'], 'loginizer') !== FALSE){ | |
| 85 | - | |
| 86 | - $license_notice = get_option('loginizer_license_notice', 0); | |
| 87 | - if(empty($license_notice)){ | |
| 88 | - $license_notice = time(); | |
| 89 | - update_option('loginizer_license_notice', $license_notice); | |
| 90 | - } | |
| 91 | - | |
| 92 | - $license = get_option('loginizer_license', []); | |
| 93 | - | |
| 94 | - // Here we are making sure that we have a license and it has expiry time and has not been dismissed for 2 months | |
| 95 | - if(!empty($license) && !empty($license['expires']) && ($license_notice > 0 || (abs($license_notice) + MONTH_IN_SECONDS * 2) < time())){ | |
| 96 | - $current_timestamp = time(); | |
| 97 | - $expiration_timestamp = strtotime($license['expires']); | |
| 98 | - $timediff = $expiration_timestamp - $current_timestamp; | |
| 99 | - | |
| 100 | - if($timediff <= WEEK_IN_SECONDS){ | |
| 101 | - add_action('admin_notices', 'loginizer_check_expires'); | |
| 102 | - } | |
| 103 | - } | |
| 104 | - } | |
| 105 | - | |
| 106 | - // Notice to let user know about SoftWP. | |
| 107 | - if( | |
| 108 | - !defined('LOGINIZER_PREMIUM') && | |
| 109 | - !defined('BACKUPLY_PRO') && | |
| 110 | - !defined('SPEEDYCACHE_PRO') && | |
| 111 | - !defined('PAGELAYER_PREMIUM') && | |
| 112 | - !defined('GOSMTP_PREMIUM') && | |
| 113 | - !defined('SITESEO_PREMIUM') | |
| 114 | - ){ | |
| 115 | - add_action('admin_notices', 'loginizer_softwp_upgrader_notice'); | |
| 116 | - } | |
| 117 | -} | |
| 118 | - | |
| 119 | - | |
| 120 | - | |
| 121 | 13 | // Add settings link on plugin page |
| 122 | 14 | function loginizer_plugin_action_links($links) { |
| 123 | 15 | |
| 124 | 16 | if(!defined('LOGINIZER_PREMIUM')){ |
| @@ -431,8 +323,31 @@ | ||
| 431 | 323 | </ul> |
| 432 | 324 | <center><a class="button button-primary" target="_blank" href="https://wordpress.org/plugins/pagelayer/">'.__('Visit Pagelayer','loginizer').'</a></center> |
| 433 | 325 | </div> |
| 434 | 326 | </div>'; |
| 327 | + | |
| 328 | + echo ' | |
| 329 | + <div class="postbox" style="min-width:0px !important;"> | |
| 330 | + <div class="postbox-header"> | |
| 331 | + <h2 class="hndle ui-sortable-handle"> | |
| 332 | + <span><a target="_blank" href="https://wpcentral.co/?from=loginizer-plugin"><img src="'.LOGINIZER_URL.'/assets/images/wpcentral_product.png" width="100%" /></a></span> | |
| 333 | + </h2> | |
| 334 | + </div> | |
| 335 | + <div class="inside"> | |
| 336 | + <i>'.__('Manage all your WordPress sites from <b>1 dashboard</b> ','loginizer').'</i>:<br> | |
| 337 | + <ul class="lz-right-ul"> | |
| 338 | + <li>'.__('1-click Admin Access','loginizer').'</li> | |
| 339 | + <li>'.__('Update WordPress','loginizer').'</li> | |
| 340 | + <li>'.__('Update Themes','loginizer').'</li> | |
| 341 | + <li>'.__('Update Plugins','loginizer').'</li> | |
| 342 | + <li>'.__('Backup your WordPress Site','loginizer').'</li> | |
| 343 | + <li>'.__('Plugins & Theme Management','loginizer').'</li> | |
| 344 | + <li>'.__('Post Management','loginizer').'</li> | |
| 345 | + <li>'.__('And many more ...','loginizer').'</li> | |
| 346 | + </ul> | |
| 347 | + <center><a class="button button-primary" target="_blank" href="https://wpcentral.co/?from=loginizer-plugin">'.__('Visit wpCentral','loginizer').'</a></center> | |
| 348 | + </div> | |
| 349 | + </div>'; | |
| 435 | 350 | |
| 436 | 351 | } |
| 437 | 352 | |
| 438 | 353 | echo '</td> |
| @@ -459,9 +374,9 @@ | ||
| 459 | 374 | } |
| 460 | 375 | </script> |
| 461 | 376 | |
| 462 | 377 | <hr /> |
| 463 | - <a href="http://loginizer.com" target="_blank">Loginizer</a> v'.LOGINIZER_VERSION.'. '.__('You can report any bugs ','loginizer').'<a href="http://wordpress.org/support/plugin/loginizer" target="_blank">'.__('here','loginizer').'</a>.'; | |
| 378 | + <a href="http://loginizer.com" target="_blank">Loginizer</a> '.__('v'.LOGINIZER_VERSION.'. You can report any bugs ','loginizer').'<a href="http://wordpress.org/support/plugin/loginizer" target="_blank">'.__('here','loginizer').'</a>.'; | |
| 464 | 379 | |
| 465 | 380 | } |
| 466 | 381 | |
| 467 | 382 | echo ' |
| @@ -515,9 +430,9 @@ | ||
| 515 | 430 | <table cellpadding="8" cellspacing="1" width="100%" class="fixed"> |
| 516 | 431 | <tr> |
| 517 | 432 | <td valign="top">'; |
| 518 | 433 | |
| 519 | - if(defined('LOGINIZER_PREMIUM') && !empty($loginizer['enable_csrf_protection']) && !loginizer_is_csrf_prot_mod_set()){ | |
| 434 | + if(file_exists(LOGINIZER_DIR.'/premium.php') && !empty($loginizer['enable_csrf_protection']) && !loginizer_is_csrf_prot_mod_set()){ | |
| 520 | 435 | |
| 521 | 436 | $lz_error['csrf_mod'] = esc_html__('You have enabled CSRF protection but the .htaccess file has not been updated', 'loginizer'); |
| 522 | 437 | |
| 523 | 438 | if(!empty($lz_error)){ |
| @@ -548,19 +463,11 @@ | ||
| 548 | 463 | // Rename Login |
| 549 | 464 | add_submenu_page('loginizer', __('Security Settings', 'loginizer'), __('Rename Login', 'loginizer'), 'activate_plugins', 'loginizer', 'loginizer_security_settings'); |
| 550 | 465 | |
| 551 | 466 | } |
| 552 | - | |
| 467 | + | |
| 553 | 468 | // Brute Force |
| 554 | 469 | add_submenu_page('loginizer', __('Brute Force Settings', 'loginizer'), __('Brute Force', 'loginizer'), 'activate_plugins', 'loginizer_brute_force', 'loginizer_brute_force_settings'); |
| 555 | - | |
| 556 | - if(defined('LOGINIZER_PREMIUM')){ | |
| 557 | - // WAF Security Firewall | |
| 558 | - $expiry_date = strtotime('2026-03-01'); | |
| 559 | - $tag_new = time() < $expiry_date ? '<span style="display: inline-block; margin-left: 10px; padding: 0px 5px; color: #fff; background-color: #d63638; border-radius: 2px;">'.__('New', 'loginizer').'</span>' : ''; | |
| 560 | - | |
| 561 | - add_submenu_page('loginizer', __('Country Block', 'loginizer'), __('Country Block', 'loginizer').' '.$tag_new, 'activate_plugins', 'loginizer_firewall', 'loginizer_firewall_settings'); | |
| 562 | - } | |
| 563 | 470 | |
| 564 | 471 | // PasswordLess |
| 565 | 472 | add_submenu_page('loginizer', __($loginizer['prefix'].'PasswordLess Settings', 'loginizer'), __('PasswordLess', 'loginizer'), 'activate_plugins', 'loginizer_passwordless', 'loginizer_passwordless_settings'); |
| 566 | 473 | |
| @@ -572,21 +479,18 @@ | ||
| 572 | 479 | |
| 573 | 480 | } |
| 574 | 481 | |
| 575 | 482 | // reCaptcha |
| 576 | - add_submenu_page('loginizer', $loginizer['prefix'].__('reCAPTCHA Settings', 'loginizer'), __('reCAPTCHA', 'loginizer'), 'activate_plugins', 'loginizer_recaptcha', 'loginizer_recaptcha_settings'); | |
| 483 | + add_submenu_page('loginizer', __($loginizer['prefix'].'reCAPTCHA Settings', 'loginizer'), __('reCAPTCHA', 'loginizer'), 'activate_plugins', 'loginizer_recaptcha', 'loginizer_recaptcha_settings'); | |
| 577 | 484 | |
| 578 | 485 | // Temporary Login |
| 579 | - add_submenu_page('loginizer', $loginizer['prefix'].__('SSO', 'loginizer'), __('Single Sign On', 'loginizer'). ((time() < strtotime('30 November 2023')) ? ' <span style="color:yellow;">Update</span>' : ''), 'activate_plugins', 'loginizer_sso', 'loginizer_sso_settings'); | |
| 486 | + add_submenu_page('loginizer', __($loginizer['prefix'].'SSO', 'loginizer'), __('Single Sign On', 'loginizer'). ((time() < strtotime('30 November 2023')) ? ' <span style="color:yellow;">Update</span>' : ''), 'activate_plugins', 'loginizer_sso', 'loginizer_sso_settings'); | |
| 580 | 487 | |
| 581 | - // Social Login | |
| 582 | - $hook_name = add_submenu_page('loginizer', $loginizer['prefix']. __('Social Login', 'loginizer'), __('Social Login', 'loginizer') . (defined('LOGINIZER_PREMIUM') && (time() < strtotime('30 June 2025')) ? ' <span style="color:yellow;font-size:12px;">Updated</span>' : ''), 'activate_plugins', 'loginizer_social_login', 'loginizer_social_login_settings'); | |
| 583 | - | |
| 584 | 488 | // Security Settings |
| 585 | 489 | if(!defined('SITEPAD')){ |
| 586 | 490 | |
| 587 | 491 | // Security Settings |
| 588 | - add_submenu_page('loginizer', $loginizer['prefix'].__('Security Settings', 'loginizer'), __('Security Settings', 'loginizer'), 'activate_plugins', 'loginizer_security', 'loginizer_security_settings'); | |
| 492 | + add_submenu_page('loginizer', __($loginizer['prefix'].'Security Settings', 'loginizer'), __('Security Settings', 'loginizer'), 'activate_plugins', 'loginizer_security', 'loginizer_security_settings'); | |
| 589 | 493 | |
| 590 | 494 | // File Checksums |
| 591 | 495 | add_submenu_page('loginizer', __('Loginizer File Checksums', 'loginizer'), __('File Checksums', 'loginizer'), 'activate_plugins', 'loginizer_checksums', 'loginizer_checksums_settings'); |
| 592 | 496 | |
| @@ -597,79 +501,76 @@ | ||
| 597 | 501 | // Go Pro link |
| 598 | 502 | add_submenu_page('loginizer', __('Loginizer Go Pro', 'loginizer'), __('Go Pro', 'loginizer'), 'activate_plugins', LOGINIZER_PRO_URL); |
| 599 | 503 | |
| 600 | 504 | } |
| 601 | - | |
| 602 | - // NOTE: This hook is just for Social Login for now, | |
| 603 | - // will need to change if we make different CSS files for every Menu page | |
| 604 | - // INFO:: Using this action helps is loading the CSS beforehand preventing any layout change on load. | |
| 605 | - add_action('load-'.$hook_name, 'loginizer_load_admin_assets'); | |
| 606 | 505 | |
| 607 | 506 | } |
| 608 | 507 | |
| 609 | -// Loads assets like CSS and JS for admin Pages. | |
| 610 | -function loginizer_load_admin_assets(){ | |
| 611 | - wp_enqueue_style('loginizer_social_style', LOGINIZER_URL . '/assets/css/social-admin.css', [], LOGINIZER_VERSION); | |
| 612 | - wp_enqueue_script('loginizer_social_script', LOGINIZER_URL . '/assets/js/social-admin.js', ['jquery', 'jquery-ui-sortable'], LOGINIZER_VERSION, true); | |
| 613 | -} | |
| 614 | - | |
| 615 | 508 | // Show the promo |
| 616 | 509 | function loginizer_promo(){ |
| 617 | 510 | |
| 618 | 511 | echo ' |
| 619 | 512 | <style> |
| 620 | -.wp-core-ui .lz_button1 { | |
| 513 | +.lz_button { | |
| 514 | +background-color: #4CAF50; /* Green */ | |
| 515 | +border: none; | |
| 516 | +color: white; | |
| 517 | +padding: 8px 16px; | |
| 518 | +text-align: center; | |
| 519 | +text-decoration: none; | |
| 520 | +display: inline-block; | |
| 521 | +font-size: 16px; | |
| 522 | +margin: 4px 2px; | |
| 523 | +-webkit-transition-duration: 0.4s; /* Safari */ | |
| 524 | +transition-duration: 0.4s; | |
| 525 | +cursor: pointer; | |
| 526 | +} | |
| 527 | + | |
| 528 | +.lz_button:focus{ | |
| 529 | +border: none; | |
| 530 | +color: white; | |
| 531 | +} | |
| 532 | + | |
| 533 | +.lz_button1 { | |
| 534 | +color: white; | |
| 621 | 535 | background-color: #4CAF50; |
| 622 | -border-color: transparent; | |
| 623 | -border-radius: 2px; | |
| 624 | -color: #fff; | |
| 536 | +border:3px solid #4CAF50; | |
| 625 | 537 | } |
| 626 | 538 | |
| 627 | -.wp-core-ui .lz_button1:hover { | |
| 628 | -background-color:#3b963f; | |
| 629 | -border-color: transparent; | |
| 630 | -border-radius: 2px; | |
| 631 | -color: #fff; | |
| 539 | +.lz_button1:hover { | |
| 540 | +box-shadow: 0 6px 8px 0 rgba(0,0,0,0.24), 0 9px 25px 0 rgba(0,0,0,0.19); | |
| 541 | +color: white; | |
| 542 | +border:3px solid #4CAF50; | |
| 632 | 543 | } |
| 633 | 544 | |
| 634 | -.wp-core-ui .lz_button2 { | |
| 545 | +.lz_button2 { | |
| 546 | +color: white; | |
| 635 | 547 | background-color: #0085ba; |
| 636 | -border-color: transparent; | |
| 637 | -border-radius: 2px; | |
| 638 | -color: #fff; | |
| 639 | 548 | } |
| 640 | 549 | |
| 641 | -.wp-core-ui .lz_button2:hover { | |
| 642 | -background-color: #0175a3; | |
| 643 | -border-color: transparent; | |
| 644 | -border-radius: 2px; | |
| 645 | -color: #fff; | |
| 550 | +.lz_button2:hover { | |
| 551 | +box-shadow: 0 6px 8px 0 rgba(0,0,0,0.24), 0 9px 25px 0 rgba(0,0,0,0.19); | |
| 552 | +color: white; | |
| 646 | 553 | } |
| 647 | 554 | |
| 648 | -.wp-core-ui .lz_button3 { | |
| 555 | +.lz_button3 { | |
| 556 | +color: white; | |
| 649 | 557 | background-color: #365899; |
| 650 | -border-color: transparent; | |
| 651 | -border-radius: 2px; | |
| 652 | -color: #fff; | |
| 653 | 558 | } |
| 654 | 559 | |
| 655 | -.wp-core-ui .lz_button3:hover { | |
| 656 | -border-color: transparent; | |
| 657 | -background-color: #274785; | |
| 658 | -color:#fff; | |
| 560 | +.lz_button3:hover { | |
| 561 | +box-shadow: 0 6px 8px 0 rgba(0,0,0,0.24), 0 9px 25px 0 rgba(0,0,0,0.19); | |
| 562 | +color: white; | |
| 659 | 563 | } |
| 660 | 564 | |
| 661 | -.wp-core-ui .lz_button4 { | |
| 662 | -background-color: #14171A; | |
| 663 | -border-color: transparent; | |
| 664 | -border-radius: 2px; | |
| 665 | -color: #fff; | |
| 565 | +.lz_button4 { | |
| 566 | +color: white; | |
| 567 | +background-color: rgb(66, 184, 221); | |
| 666 | 568 | } |
| 667 | 569 | |
| 668 | -.wp-core-ui .lz_button4:hover { | |
| 669 | -background-color: #24292E; | |
| 670 | -color: #fff; | |
| 671 | -border-color: transparent; | |
| 570 | +.lz_button4:hover { | |
| 571 | +box-shadow: 0 6px 8px 0 rgba(0,0,0,0.24), 0 9px 25px 0 rgba(0,0,0,0.19); | |
| 572 | +color: white; | |
| 672 | 573 | } |
| 673 | 574 | |
| 674 | 575 | .loginizer_promo-close{ |
| 675 | 576 | float:right; |
| @@ -706,12 +607,12 @@ | ||
| 706 | 607 | </a> |
| 707 | 608 | <img src="'.LOGINIZER_URL.'/assets/images/loginizer-200.png" style="float:left; margin:10px 20px 10px 10px" width="100" /> |
| 708 | 609 | <p style="font-size:16px">We are glad you like Loginizer and have been using it since the past few days. It is time to take the next step </p> |
| 709 | 610 | <p> |
| 710 | - <a class="button lz_button1" target="_blank" href="https://loginizer.com/features">'.esc_html__('Upgrade to Pro', 'loginizer').'</a> | |
| 711 | - <a class="button lz_button2" target="_blank" href="https://wordpress.org/support/view/plugin-reviews/loginizer">Rate it 5★\'s</a> | |
| 712 | - <a class="button lz_button3" target="_blank" href="https://www.facebook.com/Loginizer-815504798591884/">'.esc_html__('Like Us on Facebook', 'loginizer').'</a> | |
| 713 | - <a class="button lz_button4" target="_blank" href="https://x.com/intent/tweet?text='.rawurlencode('I use @loginizer to secure my #WordPress site - https://loginizer.com').'">'.esc_html__('Post on X about Loginizer', 'loginizer').'</a> | |
| 611 | + <a class="lz_button lz_button1" target="_blank" href="https://loginizer.com/features">Upgrade to Pro</a> | |
| 612 | + <a class="lz_button lz_button2" target="_blank" href="https://wordpress.org/support/view/plugin-reviews/loginizer">Rate it 5★\'s</a> | |
| 613 | + <a class="lz_button lz_button3" target="_blank" href="https://www.facebook.com/Loginizer-815504798591884/">Like Us on Facebook</a> | |
| 614 | + <a class="lz_button lz_button4" target="_blank" href="https://twitter.com/home?status='.rawurlencode('I use @loginizer to secure my #WordPress site - https://loginizer.com').'">Tweet about Loginizer</a> | |
| 714 | 615 | </p> |
| 715 | 616 | </div>'; |
| 716 | 617 | |
| 717 | 618 | } |
| @@ -748,257 +649,25 @@ | ||
| 748 | 649 | } |
| 749 | 650 | |
| 750 | 651 | function loginizer_dashboard(){ |
| 751 | 652 | include_once LOGINIZER_DIR . '/main/settings/dashboard.php'; |
| 653 | + | |
| 752 | 654 | loginizer_page_dashboard(); |
| 753 | 655 | } |
| 754 | 656 | |
| 755 | 657 | function loginizer_sso_settings(){ |
| 658 | + loginizer_enqueue_admin_script(); | |
| 756 | 659 | include_once LOGINIZER_DIR . '/main/settings/sso.php'; |
| 757 | 660 | |
| 758 | 661 | loginizer_sso(); |
| 759 | 662 | } |
| 760 | 663 | |
| 761 | -function loginizer_social_login_settings(){ | |
| 762 | - include_once LOGINIZER_DIR . '/main/settings/social_login.php'; | |
| 664 | +function loginizer_enqueue_admin_script(){ | |
| 665 | + wp_enqueue_script('loginizer-admin', LOGINIZER_URL . '/assets/js/loginizer-admin.js', LOGINIZER_VERSION, true); | |
| 763 | 666 | |
| 764 | - loginizer_social_login(); | |
| 765 | -} | |
| 766 | - | |
| 767 | -function loginizer_firewall_settings(){ | |
| 768 | - include_once LOGINIZER_PRO_DIR . 'main/settings/waf.php'; | |
| 769 | - loginizer_pro_firewall(); | |
| 770 | -} | |
| 771 | - | |
| 772 | -// Hides the interim login poup after successful login. | |
| 773 | -function loginizer_social_interim_js(){ | |
| 774 | - | |
| 775 | - if(isset($_GET['interim_login']) && $_GET['interim_login'] === 'lz' && is_user_logged_in()){ | |
| 776 | - echo '<script> | |
| 777 | - document.addEventListener("DOMContentLoaded", () => { | |
| 778 | - parent.document.querySelector("#wp-auth-check-wrap")?.classList.add("hidden"); | |
| 779 | - }); | |
| 780 | - </script>'; | |
| 781 | - } | |
| 782 | -} | |
| 783 | - | |
| 784 | -// Show alert when the login url gets changes from when the Loginizer social settings were setup. | |
| 785 | -function loginizer_social_login_url_alert(){ | |
| 786 | - | |
| 787 | - // We want to show this error to user which has sufficient privilage | |
| 788 | - if(!current_user_can('activate_plugins')){ | |
| 789 | - return; | |
| 790 | - } | |
| 667 | + $loginizer_script_data = array( | |
| 668 | + 'nonce' => wp_create_nonce('loginizer_nonce'), | |
| 669 | + 'ajax_url' => admin_url('admin-ajax.php'), | |
| 670 | + ); | |
| 791 | 671 | |
| 792 | - $set_login_url = get_option('loginizer_social_login_url', ''); | |
| 793 | - if(empty($set_login_url) || $set_login_url === wp_login_url()){ | |
| 794 | - return; | |
| 795 | - } | |
| 796 | - | |
| 797 | - $provider_settings = get_option('loginizer_provider_settings', []); | |
| 798 | - | |
| 799 | - // If we dont have any settings then it dosent matter what URL is set. | |
| 800 | - // As it will be updated once user saves the settings. | |
| 801 | - if(empty($provider_settings)){ | |
| 802 | - return; | |
| 803 | - } | |
| 804 | - | |
| 805 | - $has_enabled = false; | |
| 806 | - $has_non_login_auth = false; | |
| 807 | - foreach($provider_settings as $provider){ | |
| 808 | - if(empty($provider['loginizer_social_key']) && !empty($provider['enabled'])){ | |
| 809 | - $has_non_login_auth = true; | |
| 810 | - } | |
| 811 | - | |
| 812 | - if(!empty($provider['enabled'])){ | |
| 813 | - $has_enabled = true; | |
| 814 | - } | |
| 815 | - } | |
| 816 | - | |
| 817 | - // We will only show this error if the user is using key based config | |
| 818 | - if(empty($has_non_login_auth)){ | |
| 819 | - return; | |
| 820 | - } | |
| 821 | - | |
| 822 | - // If we have no Provider enabled then just show the warning on the social login page. | |
| 823 | - if(empty($has_enabled) && (empty($_GET['page']) || $_GET['page'] !== 'loginizer_social_login')){ | |
| 824 | - return; | |
| 825 | - } | |
| 826 | - | |
| 827 | - echo '<div class="notice notice-error"> | |
| 828 | - <h4>'.esc_html__('You changed login slug!', 'loginizer').'</h4> | |
| 829 | - <p>'.esc_html__('You changed the login slug and have some social login apps enabled. These social login apps use the login URL as the redirect URI. This means that since the login URL has changed, the social login will now break.', 'loginizer').'</p> | |
| 830 | - | |
| 831 | - <h4>'.esc_html__('How to fix:', 'loginizer').'</h4> | |
| 832 | - <p>'.esc_html__('When you created secret keys for the social apps, you also provided a Redirect URI. To fix this issue, you need to update that Redirect URI.', 'loginizer').'<br/> | |
| 833 | - You just need to update the <code>/wp-login.php</code> to the new slug you have.</p> | |
| 834 | - <p><button class="button button-primary" id="loginizer-social-login-alert">'.esc_html__('I have fixed this issue', 'loginizer').'</button></p> | |
| 835 | - </div>'; | |
| 836 | - | |
| 837 | - | |
| 838 | - wp_register_script('loginizer_social_alert', '', ['jquery'], LOGINIZER_VERSION, true); | |
| 839 | - wp_enqueue_script('loginizer_social_alert'); | |
| 840 | - wp_add_inline_script('loginizer_social_alert', ' | |
| 841 | - jQuery("#loginizer-social-login-alert").on("click", function(){ | |
| 842 | - jQuery(this).closest(".notice").slideToggle(); | |
| 843 | - | |
| 844 | - var data = new Object(); | |
| 845 | - data["action"] = "loginizer_dismiss_social_alert"; | |
| 846 | - data["nonce"] = "'.wp_create_nonce('loginizer_admin_ajax').'"; | |
| 847 | - | |
| 848 | - var admin_url = "'.admin_url().'"+"admin-ajax.php"; | |
| 849 | - jQuery.post(admin_url, data, function(response){ | |
| 850 | - }); | |
| 851 | - });'); | |
| 672 | + wp_localize_script('loginizer-admin', 'lz_obj', $loginizer_script_data); | |
| 852 | 673 | } |
| 853 | - | |
| 854 | -function loginizer_softwp_upgrader_notice(){ | |
| 855 | - | |
| 856 | - // We want to show this error to user which has sufficient privilage | |
| 857 | - if(!current_user_can('activate_plugins')){ | |
| 858 | - return; | |
| 859 | - } | |
| 860 | - | |
| 861 | - /*$notice_end_time = strtotime('31 March 2025'); | |
| 862 | - if(!empty($notice_end_time) && time() > $notice_end_time){ | |
| 863 | - return; | |
| 864 | - }*/ | |
| 865 | - | |
| 866 | - $softwp_upgrade = get_option('loginizer_softwp_upgrade', 0); | |
| 867 | - | |
| 868 | - if(empty($softwp_upgrade) || $softwp_upgrade < 0){ | |
| 869 | - return; | |
| 870 | - } | |
| 871 | - | |
| 872 | - if(empty($_GET['page']) || !preg_match('/loginizer/is', $_GET['page'])){ | |
| 873 | - return; | |
| 874 | - } | |
| 875 | - | |
| 876 | - echo '<style>.loginizer_promo-close{float:right;text-decoration:none;margin: 5px 10px 0px 0px;}.loginizer_promo-close:hover{color: red;}</style> | |
| 877 | - <div class="notice notice-warning" id="loginizer_softwp_notice"> | |
| 878 | - <a class="loginizer_promo-close" id="loginizer-softwp-promo-close" href="javascript:" aria-label="Dismiss Forever"> | |
| 879 | - <span class="dashicons dashicons-dismiss"></span> '.esc_html__('Dismiss Forever', 'loginizer').' | |
| 880 | - </a> | |
| 881 | - <p>' . esc_html__('Hey, you might be eligible to access Premium plugins provided by Softaculous for Free ! Please refer to these documents for details on how to avail them.', 'loginizer').' | |
| 882 | - <a href="https://softwp.net/docs/admin/generate-softwp-license" target="_blank">' . esc_html__('Generate SoftWP License', 'loginizer') . '</a> | <a href="https://softwp.net/docs/admin/installing-plugins" target="_blank">' . esc_html__('How to Install the Pro plugins', 'loginizer') . '</a></p> | |
| 883 | - </div>'; | |
| 884 | - | |
| 885 | - wp_register_script('loginizer_softwp_alert', '', ['jquery'], LOGINIZER_VERSION, true); | |
| 886 | - wp_enqueue_script('loginizer_softwp_alert'); | |
| 887 | - wp_add_inline_script('loginizer_softwp_alert', ' | |
| 888 | - jQuery("#loginizer-softwp-promo-close").on("click", function(){ | |
| 889 | - jQuery(this).closest("#loginizer_softwp_notice").slideToggle(); | |
| 890 | - | |
| 891 | - var data = new Object(); | |
| 892 | - data["action"] = "loginizer_dismiss_softwp_alert"; | |
| 893 | - data["security"] = "'.wp_create_nonce('loginizer_softwp_notice').'"; | |
| 894 | - | |
| 895 | - var admin_url = "'.admin_url().'"+"admin-ajax.php"; | |
| 896 | - jQuery.post(admin_url, data, function(response){ | |
| 897 | - }); | |
| 898 | - });'); | |
| 899 | -} | |
| 900 | - | |
| 901 | -function loginizer_check_expires(){ | |
| 902 | - global $loginizer; | |
| 903 | - | |
| 904 | - // We do not want to show the expiry notice if the license is by SoftWP. | |
| 905 | - if(!empty($loginizer['license']) && !empty($loginizer['license']['has_plid'])){ | |
| 906 | - return; | |
| 907 | - } | |
| 908 | - | |
| 909 | - $current_timestamp = time(); | |
| 910 | - $expiration_timestamp = strtotime($loginizer['license']['expires']); | |
| 911 | - $time_diff = $expiration_timestamp - $current_timestamp; | |
| 912 | - | |
| 913 | - // Renew link | |
| 914 | - $loginizer_user_license = $loginizer['license']['license']; | |
| 915 | - $loginizer_user_plan = $loginizer['license']['plan']; | |
| 916 | - $loginizer_renew_url = 'https://www.softaculous.com/clients?ca=loginizer_buy&plan=' . $loginizer_user_plan . '&license=' . $loginizer_user_license; | |
| 917 | - | |
| 918 | - if($time_diff > 0 && $time_diff <= WEEK_IN_SECONDS){ | |
| 919 | - $human_time = human_time_diff($current_timestamp, $expiration_timestamp); | |
| 920 | - | |
| 921 | - echo '<style>.loginizer_promo-close{float:right;text-decoration:none;margin: 5px 10px 0px 0px;}.loginizer_promo-close:hover{color: red;}</style> | |
| 922 | - <div class="notice notice-error" id="loginizer_license_notice"> | |
| 923 | - <a class="loginizer_promo-close" id="loginizer-license-promo-close" href="javascript:" aria-label="Dismiss this Notice"> | |
| 924 | - <span class="dashicons dashicons-dismiss"></span> '.esc_html__('Dismiss for 60 days', 'loginizer').' | |
| 925 | - </a> | |
| 926 | - <p>' . sprintf(esc_html__('Alert : Your Loginizer Premium license will expire in %s. Renew to keep getting updates!', 'loginizer'), esc_html($human_time)).' | |
| 927 | - <a href="' . esc_url($loginizer_renew_url) . '" target="_blank">' . esc_html__('Click here to renew', 'loginizer') . '</a> | |
| 928 | - </p> | |
| 929 | - </div>'; | |
| 930 | - | |
| 931 | - } else if($time_diff <= 0){ | |
| 932 | - echo '<style>.loginizer_promo-close{float:right;text-decoration:none;margin: 5px 10px 0px 0px;}.loginizer_promo-close:hover{color: red;}</style> | |
| 933 | - <div class="notice notice-error" id="loginizer_license_notice"> | |
| 934 | - <a class="loginizer_promo-close" id="loginizer-license-promo-close" href="javascript:" aria-label="Dismiss this Notice"> | |
| 935 | - <span class="dashicons dashicons-dismiss"></span> '.esc_html__('Dismiss for 60 days', 'loginizer').' | |
| 936 | - </a> | |
| 937 | - <p>' . esc_html__('Alert: Your Loginizer Premium license has expired. Please renew immediately to keep getting updates ', 'loginizer').' | |
| 938 | - <a href="' . esc_url($loginizer_renew_url) . '" target="_blank">' . esc_html__('Click here to renew', 'loginizer') . '</a></p> | |
| 939 | - </div>'; | |
| 940 | - } | |
| 941 | - | |
| 942 | - wp_register_script('loginizer_license_alert', '', ['jquery'], LOGINIZER_VERSION, true); | |
| 943 | - wp_enqueue_script('loginizer_license_alert'); | |
| 944 | - wp_add_inline_script('loginizer_license_alert', ' | |
| 945 | - jQuery("#loginizer-license-promo-close").on("click", function(){ | |
| 946 | - jQuery(this).closest("#loginizer_license_notice").slideToggle(); | |
| 947 | - | |
| 948 | - var data = new Object(); | |
| 949 | - data["action"] = "loginizer_dismiss_license_alert"; | |
| 950 | - data["security"] = "'.wp_create_nonce('loginizer_license_notice').'"; | |
| 951 | - | |
| 952 | - var admin_url = "'.admin_url().'"+"admin-ajax.php"; | |
| 953 | - jQuery.post(admin_url, data, function(response){ | |
| 954 | - }); | |
| 955 | - });'); | |
| 956 | -} | |
| 957 | - | |
| 958 | -function loginizer_update_notice_filter($plugins = []){ | |
| 959 | - $plugins['loginizer/loginizer.php'] = 'Loginizer'; | |
| 960 | - | |
| 961 | - return $plugins; | |
| 962 | -} | |
| 963 | - | |
| 964 | -function loginizer_plugin_update_notice(){ | |
| 965 | - if(defined('SOFTACULOUS_PLUGIN_UPDATE_NOTICE')){ | |
| 966 | - return; | |
| 967 | - } | |
| 968 | - | |
| 969 | - $to_update_plugins = apply_filters('softaculous_plugin_update_notice', []); | |
| 970 | - | |
| 971 | - if(empty($to_update_plugins)){ | |
| 972 | - return; | |
| 973 | - } | |
| 974 | - | |
| 975 | - /* translators: %1$s is replaced with a "string" of name of plugins, and %2$s is replaced with "string" which can be "is" or "are" based on the count of the plugin */ | |
| 976 | - $msg = sprintf(__('New versions of %1$s %2$s available. Updating ensures better performance, security, and access to the latest features.', 'loginizer'), '<b>'.esc_html(implode(', ', $to_update_plugins)).'</b>', (count($to_update_plugins) > 1 ? 'are' : 'is')) . ' <a class="button button-primary" href='.esc_url(admin_url('plugins.php?plugin_status=upgrade')).'>Update Now</a>'; | |
| 977 | - | |
| 978 | - define('SOFTACULOUS_PLUGIN_UPDATE_NOTICE', true); // To make sure other plugins don't return a Notice | |
| 979 | - echo '<div class="notice notice-info is-dismissible" id="loginizer-plugin-update-notice"> | |
| 980 | - <p>'.$msg. '</p> | |
| 981 | - </div>'; | |
| 982 | - | |
| 983 | - wp_register_script('loginizer-update-notice', '', ['jquery'], '', true); | |
| 984 | - wp_enqueue_script('loginizer-update-notice'); | |
| 985 | - wp_add_inline_script('loginizer-update-notice', 'jQuery("#loginizer-plugin-update-notice").on("click", function(e){ | |
| 986 | - let target = jQuery(e.target); | |
| 987 | - | |
| 988 | - if(!target.hasClass("notice-dismiss")){ | |
| 989 | - return; | |
| 990 | - } | |
| 991 | - | |
| 992 | - var data; | |
| 993 | - | |
| 994 | - // Hide it | |
| 995 | - jQuery("#loginizer-plugin-update-notice").hide(); | |
| 996 | - | |
| 997 | - // Save this preference | |
| 998 | - jQuery.post("'.admin_url('admin-ajax.php?action=loginizer_close_update_notice').'&security='.wp_create_nonce('loginizer_promo_nonce').'", data, function(response) { | |
| 999 | - //alert(response); | |
| 1000 | - }); | |
| 1001 | - });'); | |
| 1002 | -} | |
| 1003 | - | |
| 1004 | -loginizer_admin_hooks(); | |