PluginProbe
Loginizer / 2.0.3
Loginizer v2.0.3
2.1.0 2.0.9 2.0.8 1.9.8 1.9.9 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 trunk 1.0 1.0.1 1.0.2 1.1.0 1.1.1 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 All 74 releases
← All changes | main/admin.php +138 -14 2.0.02.0.3 View file →
@@ -3,15 +3,82 @@
3 3 if(!defined('ABSPATH')){
4 4 die('Hacking Attempt!');
5 5 }
6 6
7 -// 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');
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 +}
13 16
17 +function loginizer_admin_promo_hooks(){
18 + global $loginizer;
19 +
20 + if(!current_user_can('activate_plugins') || defined('SITEPAD')){
21 + return;
22 + }
23 +
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 +
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 +
14 81 function loginizer_admin_actions(){
15 82 global $loginizer;
16 83
17 84 if(defined('LOGINIZER_PREMIUM') && !defined('SITEPAD') && current_user_can('activate_plugins') && isset($_GET['page']) && strpos($_GET['page'], 'loginizer') !== FALSE){
@@ -503,9 +570,9 @@
503 570 // Temporary Login
504 571 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');
505 572
506 573 // Social Login
507 - $hook_name = add_submenu_page('loginizer', __($loginizer['prefix'].'social_login', 'loginizer'), __('Social Login', 'loginizer') . ((time() < strtotime('30 July 2024')) ? ' <span style="color:red;">New</span>' : ''), 'activate_plugins', 'loginizer_social_login', 'loginizer_social_login_settings');
574 + $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');
508 575
509 576 // Security Settings
510 577 if(!defined('SITEPAD')){
511 578
@@ -681,9 +748,8 @@
681 748 }
682 749
683 750 function loginizer_dashboard(){
684 751 include_once LOGINIZER_DIR . '/main/settings/dashboard.php';
685 -
686 752 loginizer_page_dashboard();
687 753 }
688 754
689 755 function loginizer_sso_settings(){
@@ -716,10 +782,11 @@
716 782 // We want to show this error to user which has sufficient privilage
717 783 if(!current_user_can('activate_plugins')){
718 784 return;
719 785 }
720 -
721 - if(get_option('loginizer_social_login_url', '') === wp_login_url()){
786 +
787 + $set_login_url = get_option('loginizer_social_login_url', '');
788 + if(empty($set_login_url) || $set_login_url === wp_login_url()){
722 789 return;
723 790 }
724 791
725 792 $provider_settings = get_option('loginizer_provider_settings', []);
@@ -730,14 +797,23 @@
730 797 return;
731 798 }
732 799
733 800 $has_enabled = false;
801 + $has_non_login_auth = false;
734 802 foreach($provider_settings as $provider){
735 - if($provider['enabled']){
803 + if(empty($provider['loginizer_social_key']) && !empty($provider['enabled'])){
804 + $has_non_login_auth = true;
805 + }
806 +
807 + if(!empty($provider['enabled'])){
736 808 $has_enabled = true;
737 - break;
738 809 }
739 810 }
811 +
812 + // We will only show this error if the user is using key based config
813 + if(empty($has_non_login_auth)){
814 + return;
815 + }
740 816
741 817 // If we have no Provider enabled then just show the warning on the social login page.
742 818 if(empty($has_enabled) && (empty($_GET['page']) || $_GET['page'] !== 'loginizer_social_login')){
743 819 return;
@@ -743,9 +819,9 @@
743 819 return;
744 820 }
745 821
746 822 echo '<div class="notice notice-error">
747 - <h4>'.esc_html__('Your changed login slug!', 'loginizer').'</h4>
823 + <h4>'.esc_html__('You changed login slug!', 'loginizer').'</h4>
748 824 <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>
749 825
750 826 <h4>'.esc_html__('How to fix:', 'loginizer').'</h4>
751 827 <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/>
@@ -871,5 +947,53 @@
871 947 var admin_url = "'.admin_url().'"+"admin-ajax.php";
872 948 jQuery.post(admin_url, data, function(response){
873 949 });
874 950 });');
875 -}
951 +}
952 +
953 +function loginizer_update_notice_filter($plugins = []){
954 + $plugins['loginizer/loginizer.php'] = 'Loginizer';
955 +
956 + return $plugins;
957 +}
958 +
959 +function loginizer_plugin_update_notice(){
960 + if(defined('SOFTACULOUS_PLUGIN_UPDATE_NOTICE')){
961 + return;
962 + }
963 +
964 + $to_update_plugins = apply_filters('softaculous_plugin_update_notice', []);
965 +
966 + if(empty($to_update_plugins)){
967 + return;
968 + }
969 +
970 + /* 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 */
971 + $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>';
972 +
973 + define('SOFTACULOUS_PLUGIN_UPDATE_NOTICE', true); // To make sure other plugins don't return a Notice
974 + echo '<div class="notice notice-info is-dismissible" id="loginizer-plugin-update-notice">
975 + <p>'.$msg. '</p>
976 + </div>';
977 +
978 + wp_register_script('loginizer-update-notice', '', ['jquery'], '', true);
979 + wp_enqueue_script('loginizer-update-notice');
980 + wp_add_inline_script('loginizer-update-notice', 'jQuery("#loginizer-plugin-update-notice").on("click", function(e){
981 + let target = jQuery(e.target);
982 +
983 + if(!target.hasClass("notice-dismiss")){
984 + return;
985 + }
986 +
987 + var data;
988 +
989 + // Hide it
990 + jQuery("#loginizer-plugin-update-notice").hide();
991 +
992 + // Save this preference
993 + jQuery.post("'.admin_url('admin-ajax.php?action=loginizer_close_update_notice').'&security='.wp_create_nonce('loginizer_promo_nonce').'", data, function(response) {
994 + //alert(response);
995 + });
996 + });');
997 +}
998 +
999 +loginizer_admin_hooks();