Version Description
- Fixed wp-login.php issue for www url
Download this release
Release Info
Developer | india-web-developer |
Plugin | Protect Your Admin |
Version | 1.6 |
Comparing to | |
See all releases |
Code changes from version 1.5 to 1.6
- protect-wp-admin.php +4 -4
- pwa-class.php +198 -170
- readme.txt +6 -4
protect-wp-admin.php
CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://www.mrwebsolution.in/
|
|
5 |
Description: "protect-wp-admin" is a very help full plugin to make wordpress admin more secure. Protect WP-Admin plugin is provide the options for change the wp-admin url and make the login page private(directly user can't access the login page).
|
6 |
Author: Raghunath
|
7 |
Author URI: http://www.mrwebsolution.in/
|
8 |
-
Version: 1.
|
9 |
*/
|
10 |
|
11 |
/*** Copyright 2014 Raghunath (email : raghunath.0087@gmail.com)
|
@@ -84,7 +84,7 @@ function init_pwa_admin_option_page(){
|
|
84 |
<!-- Start Options Form -->
|
85 |
<form action="options.php" method="post" id="pwa-settings-form-admin">
|
86 |
<input type="hidden" id="check_permalink" value="<?php echo count($tt);?>">
|
87 |
-
<div id="pwa-tab-menu"><a id="pwa-general" class="pwa-tab-links active" >General</a> <a id="pwa-admin-style" class="pwa-tab-links">
|
88 |
|
89 |
<div class="pwa-setting">
|
90 |
<!-- General Setting -->
|
@@ -96,7 +96,7 @@ function init_pwa_admin_option_page(){
|
|
96 |
|
97 |
<!-- Admin Style -->
|
98 |
<div class="last author pwa-tab" id="div-pwa-admin-style">
|
99 |
-
<h2>Admin Style Settings</h2>
|
100 |
<p id="adminurl"><label>Define Logo Path: </label><input type="text" id="pwa_logo_path" name="pwa_logo_path" value="<?php echo esc_attr(get_option('pwa_logo_path')); ?>" placeholder="Add Custom Logo Image Path" size="30">(<i>Change WordPress Default Login Logo </i>)</p>
|
101 |
<p id="adminurl"><label>Body Background Color: </label><input type="text" id="pwa_login_page_bg_color" name="pwa_login_page_bg_color" value="<?php echo esc_attr(get_option('pwa_login_page_bg_color')); ?>" placeholder="#444444" size="30"></p>
|
102 |
</div>
|
@@ -123,7 +123,7 @@ function init_pwa_admin_option_page(){
|
|
123 |
<p><strong>My Other Plugins:</strong><br>
|
124 |
<ul>
|
125 |
<li><a href="https://wordpress.org/plugins/custom-share-buttons-with-floating-sidebar" target="_blank">Custom Share Buttons with Floating Sidebar</a></li>
|
126 |
-
<li><a href="https://wordpress.org/plugins/wp-testimonial" target="_blank">
|
127 |
<li><a href="https://wordpress.org/plugins/wp-easy-recipe/" target="_blank">WP Easy Recipe</a></li>
|
128 |
<li><a href="https://wordpress.org/plugins/wp-social-buttons/" target="_blank">WP Social Buttons</a></li>
|
129 |
<li><a href="https://wordpress.org/plugins/wp-youtube-gallery/" target="_blank">WP Youtube Gallery</a></li>
|
5 |
Description: "protect-wp-admin" is a very help full plugin to make wordpress admin more secure. Protect WP-Admin plugin is provide the options for change the wp-admin url and make the login page private(directly user can't access the login page).
|
6 |
Author: Raghunath
|
7 |
Author URI: http://www.mrwebsolution.in/
|
8 |
+
Version: 1.6
|
9 |
*/
|
10 |
|
11 |
/*** Copyright 2014 Raghunath (email : raghunath.0087@gmail.com)
|
84 |
<!-- Start Options Form -->
|
85 |
<form action="options.php" method="post" id="pwa-settings-form-admin">
|
86 |
<input type="hidden" id="check_permalink" value="<?php echo count($tt);?>">
|
87 |
+
<div id="pwa-tab-menu"><a id="pwa-general" class="pwa-tab-links active" >General</a> <a id="pwa-admin-style" class="pwa-tab-links">LoginPage Style</a> <a id="pwa-advance" class="pwa-tab-links">Advance Settings</a> <a id="pwa-support" class="pwa-tab-links">Support</a> </div>
|
88 |
|
89 |
<div class="pwa-setting">
|
90 |
<!-- General Setting -->
|
96 |
|
97 |
<!-- Admin Style -->
|
98 |
<div class="last author pwa-tab" id="div-pwa-admin-style">
|
99 |
+
<h2>Admin Login Page Style Settings</h2>
|
100 |
<p id="adminurl"><label>Define Logo Path: </label><input type="text" id="pwa_logo_path" name="pwa_logo_path" value="<?php echo esc_attr(get_option('pwa_logo_path')); ?>" placeholder="Add Custom Logo Image Path" size="30">(<i>Change WordPress Default Login Logo </i>)</p>
|
101 |
<p id="adminurl"><label>Body Background Color: </label><input type="text" id="pwa_login_page_bg_color" name="pwa_login_page_bg_color" value="<?php echo esc_attr(get_option('pwa_login_page_bg_color')); ?>" placeholder="#444444" size="30"></p>
|
102 |
</div>
|
123 |
<p><strong>My Other Plugins:</strong><br>
|
124 |
<ul>
|
125 |
<li><a href="https://wordpress.org/plugins/custom-share-buttons-with-floating-sidebar" target="_blank">Custom Share Buttons with Floating Sidebar</a></li>
|
126 |
+
<li><a href="https://wordpress.org/plugins/wp-testimonial" target="_blank">WP Testimonial</a></li>
|
127 |
<li><a href="https://wordpress.org/plugins/wp-easy-recipe/" target="_blank">WP Easy Recipe</a></li>
|
128 |
<li><a href="https://wordpress.org/plugins/wp-social-buttons/" target="_blank">WP Social Buttons</a></li>
|
129 |
<li><a href="https://wordpress.org/plugins/wp-youtube-gallery/" target="_blank">WP Youtube Gallery</a></li>
|
pwa-class.php
CHANGED
@@ -1,170 +1,198 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
* Protect WP-Admin (C)
|
4 |
-
* @register_install_hook()
|
5 |
-
* @register_uninstall_hook()
|
6 |
-
* */
|
7 |
-
?>
|
8 |
-
<?php
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
$
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
if(isset($getPwaOptions['
|
26 |
-
{
|
27 |
-
|
28 |
-
add_action('
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
$
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
}
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
{
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Protect WP-Admin (C)
|
4 |
+
* @register_install_hook()
|
5 |
+
* @register_uninstall_hook()
|
6 |
+
* */
|
7 |
+
?>
|
8 |
+
<?php
|
9 |
+
|
10 |
+
/** Get all options value */
|
11 |
+
function get_pwa_setting_options() {
|
12 |
+
global $wpdb;
|
13 |
+
$pwaOptions = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options WHERE option_name LIKE 'pwa_%'");
|
14 |
+
|
15 |
+
foreach ($pwaOptions as $option) {
|
16 |
+
$pwaOptions[$option->option_name] = $option->option_value;
|
17 |
+
}
|
18 |
+
|
19 |
+
return $pwaOptions;
|
20 |
+
}
|
21 |
+
|
22 |
+
|
23 |
+
$getPwaOptions=get_pwa_setting_options();
|
24 |
+
|
25 |
+
if(isset($getPwaOptions['pwa_active']) && '1'==$getPwaOptions['pwa_active'])
|
26 |
+
{
|
27 |
+
|
28 |
+
add_action('init', 'init_pwa_admin_rewrite_rules' );
|
29 |
+
add_action('init', 'pwa_admin_url_redirect_conditions' );
|
30 |
+
|
31 |
+
}
|
32 |
+
|
33 |
+
|
34 |
+
if(isset($getPwaOptions['pwa_logout']))
|
35 |
+
{
|
36 |
+
add_action('admin_init', 'pwa_logout_user_after_settings_save');
|
37 |
+
add_action('admin_init', 'pwa_logout_user_after_settings_save');
|
38 |
+
}
|
39 |
+
|
40 |
+
function pwa_logout_user_after_settings_save()
|
41 |
+
{
|
42 |
+
$getPwaOptions=get_pwa_setting_options();
|
43 |
+
if(isset($_GET['settings-updated']) && $_GET['settings-updated'] && isset($_GET['page']) && $_GET['page']=='pwa-settings')
|
44 |
+
{
|
45 |
+
flush_rewrite_rules();
|
46 |
+
}
|
47 |
+
|
48 |
+
if(isset($_GET['settings-updated']) && $_GET['settings-updated'] && isset($_GET['page']) && $_GET['page']=='pwa-settings' && isset($getPwaOptions['pwa_logout']) && $getPwaOptions['pwa_logout']==1)
|
49 |
+
{
|
50 |
+
$URL=str_replace('&','&',wp_logout_url());
|
51 |
+
if(isset($getPwaOptions['pwa_rewrite_text']) && isset($getPwaOptions['pwa_logout']) && $getPwaOptions['pwa_logout']==1 && $getPwaOptions['pwa_rewrite_text']!=''){
|
52 |
+
wp_redirect(home_url('/'.$getPwaOptions['pwa_rewrite_text']));
|
53 |
+
}else
|
54 |
+
{
|
55 |
+
//silent
|
56 |
+
}
|
57 |
+
//wp_redirect($URL);
|
58 |
+
}
|
59 |
+
|
60 |
+
}
|
61 |
+
/** Create a new rewrite rule for change to wp-admin url */
|
62 |
+
function init_pwa_admin_rewrite_rules() {
|
63 |
+
$getPwaOptions=get_pwa_setting_options();
|
64 |
+
if(isset($getPwaOptions['pwa_active']) && ''!=$getPwaOptions['pwa_rewrite_text']){
|
65 |
+
$newurl=strip_tags($getPwaOptions['pwa_rewrite_text']);
|
66 |
+
add_rewrite_rule( $newurl.'/?$', 'wp-login.php', 'top' );
|
67 |
+
add_rewrite_rule( $newurl.'/register/?$', 'wp-login.php?action=register', 'top' );
|
68 |
+
add_rewrite_rule( $newurl.'/lostpassword/?$', 'wp-login.php?action=lostpassword', 'top' );
|
69 |
+
|
70 |
+
}
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Update Login, Register & Forgot password link as per new admin url
|
75 |
+
* */
|
76 |
+
add_action('login_head','csbwfs_custom_script');
|
77 |
+
function csbwfs_custom_script()
|
78 |
+
{
|
79 |
+
$getPwaOptions=get_pwa_setting_options();
|
80 |
+
if(isset($getPwaOptions['pwa_active']) && ''!=$getPwaOptions['pwa_rewrite_text']){
|
81 |
+
echo '<script>jQuery(window).load(function(){
|
82 |
+
jQuery("#login #login_error a").attr("href","'.home_url($getPwaOptions["pwa_rewrite_text"].'/lostpassword').'");
|
83 |
+
var formId= jQuery("#login form").attr("id");
|
84 |
+
if(formId=="loginform"){
|
85 |
+
jQuery("#"+formId).attr("action","'.home_url($getPwaOptions["pwa_rewrite_text"]).'");
|
86 |
+
}else if("lostpasswordform"==formId){
|
87 |
+
jQuery("#"+formId).attr("action","'.home_url($getPwaOptions["pwa_rewrite_text"].'/lostpassword').'");
|
88 |
+
}else if("registerform"==formId){
|
89 |
+
jQuery("#"+formId).attr("action","'.home_url($getPwaOptions["pwa_rewrite_text"].'/register').'");
|
90 |
+
}else
|
91 |
+
{
|
92 |
+
//silent
|
93 |
+
}
|
94 |
+
jQuery("#nav a").each(function(){
|
95 |
+
var linkText=jQuery(this).text();
|
96 |
+
if(linkText=="Log in"){jQuery(this).attr("href","'.home_url($getPwaOptions["pwa_rewrite_text"]).'");}
|
97 |
+
else if(linkText=="Register"){jQuery(this).attr("href","'.home_url($getPwaOptions["pwa_rewrite_text"].'/register').'");}else if(linkText=="Lost your password?"){jQuery(this).attr("href","'.home_url($getPwaOptions["pwa_rewrite_text"].'/lostpassword').'");}else {
|
98 |
+
//silent
|
99 |
+
}
|
100 |
+
});});</script>';
|
101 |
+
}
|
102 |
+
|
103 |
+
}
|
104 |
+
|
105 |
+
function pwa_admin_url_redirect_conditions()
|
106 |
+
{
|
107 |
+
$getPwaOptions=get_pwa_setting_options();
|
108 |
+
$pwaActualURLAry =array
|
109 |
+
(
|
110 |
+
home_url('/wp-login.php'),
|
111 |
+
home_url('/wp-login.php/'),
|
112 |
+
home_url('/wp-login'),
|
113 |
+
home_url('/wp-login/'),
|
114 |
+
home_url('/wp-admin'),
|
115 |
+
home_url('/wp-admin/'),
|
116 |
+
);
|
117 |
+
$request_url = pwa_get_current_page_url($_SERVER);
|
118 |
+
$newUrl = explode('?',$request_url);
|
119 |
+
//print_r($pwaActualURLAry); echo $newUrl[0];exit;
|
120 |
+
if(! is_user_logged_in() && in_array($newUrl[0],$pwaActualURLAry) )
|
121 |
+
{
|
122 |
+
wp_redirect(home_url('/'),301);
|
123 |
+
//exit;
|
124 |
+
}
|
125 |
+
else if(isset($getPwaOptions['pwa_restrict']) && $getPwaOptions['pwa_restrict']==1 && is_user_logged_in())
|
126 |
+
{
|
127 |
+
global $current_user;
|
128 |
+
$user_roles = $current_user->roles;
|
129 |
+
$user_ID = $current_user->ID;
|
130 |
+
$user_role = array_shift($user_roles);
|
131 |
+
|
132 |
+
if(isset($getPwaOptions['pwa_allow_custom_users']) && $getPwaOptions['pwa_allow_custom_users']!='')
|
133 |
+
{
|
134 |
+
$userids=explode(',' ,$getPwaOptions['pwa_allow_custom_users']);
|
135 |
+
|
136 |
+
if(is_array($userids))
|
137 |
+
{
|
138 |
+
$userids=explode(',' ,$getPwaOptions['pwa_allow_custom_users']);
|
139 |
+
}else
|
140 |
+
{
|
141 |
+
$userids[]=$getPwaOptions['pwa_allow_custom_users'];
|
142 |
+
}
|
143 |
+
}else
|
144 |
+
{
|
145 |
+
$userids=array();
|
146 |
+
}
|
147 |
+
|
148 |
+
if($user_role=='administrator' || in_array($user_ID,$userids))
|
149 |
+
{
|
150 |
+
//silent is gold
|
151 |
+
}else
|
152 |
+
{
|
153 |
+
wp_redirect(home_url('/'));
|
154 |
+
}
|
155 |
+
}else
|
156 |
+
{
|
157 |
+
//silent is gold
|
158 |
+
}
|
159 |
+
|
160 |
+
}
|
161 |
+
|
162 |
+
/** Get the current url*/
|
163 |
+
function pwa_current_path_protocol($s, $use_forwarded_host=false)
|
164 |
+
{
|
165 |
+
$pwahttp = (!empty($s['HTTPS']) && $s['HTTPS'] == 'on') ? true:false;
|
166 |
+
$pwasprotocal = strtolower($s['SERVER_PROTOCOL']);
|
167 |
+
$pwa_protocol = substr($pwasprotocal, 0, strpos($pwasprotocal, '/')) . (($pwahttp) ? 's' : '');
|
168 |
+
$port = $s['SERVER_PORT'];
|
169 |
+
$port = ((!$pwahttp && $port=='80') || ($pwahttp && $port=='443')) ? '' : ':'.$port;
|
170 |
+
$host = ($use_forwarded_host && isset($s['HTTP_X_FORWARDED_HOST'])) ? $s['HTTP_X_FORWARDED_HOST'] : (isset($s['HTTP_HOST']) ? $s['HTTP_HOST'] : null);
|
171 |
+
$host = isset($host) ? $host : $s['SERVER_NAME'] . $port;
|
172 |
+
return $pwa_protocol . '://' . $host;
|
173 |
+
}
|
174 |
+
function pwa_get_current_page_url($s, $use_forwarded_host=false)
|
175 |
+
{
|
176 |
+
return pwa_current_path_protocol($s, $use_forwarded_host) . $s['REQUEST_URI'];
|
177 |
+
}
|
178 |
+
|
179 |
+
|
180 |
+
//if(isset($getPwaOptions['pwa_logo_path'])):
|
181 |
+
|
182 |
+
/* Change Wordpress Default Logo */
|
183 |
+
function pwa_update_login_page_logo() {
|
184 |
+
$getPwaOptions=get_pwa_setting_options();
|
185 |
+
|
186 |
+
echo '<style type="text/css"> /* Protect WP-Admin Style*/';
|
187 |
+
|
188 |
+
if(isset($getPwaOptions['pwa_logo_path']) && $getPwaOptions['pwa_logo_path']!='')
|
189 |
+
echo ' h1 a { background-image:url('.$getPwaOptions['pwa_logo_path'].') !important; }';
|
190 |
+
|
191 |
+
if(isset($getPwaOptions['pwa_login_page_bg_color']) && $getPwaOptions['pwa_login_page_bg_color']!='')
|
192 |
+
echo ' body.login-action-login,html{ background:'.$getPwaOptions['pwa_login_page_bg_color'].' !important; height: 100% !important;}';
|
193 |
+
|
194 |
+
echo '</style>';
|
195 |
+
|
196 |
+
}
|
197 |
+
add_action('login_head', 'pwa_update_login_page_logo');
|
198 |
+
?>
|
readme.txt
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
=== Protect Your Admin ===
|
2 |
Contributors:india-web-developer
|
3 |
-
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=
|
4 |
Tags: Protect WP-Admin,wp-admin,Protect wordpress admin,Secure Admin,Admin,Scure Wordpress Admin,Rename Admin URL, Rename Wordpress Admin URL,Change wp-admin url,Change Admin URL,Change Admin Path,Restrict wp-admin
|
5 |
Requires at least: 3.3
|
6 |
-
Tested up to: 4.
|
7 |
-
Stable tag: 1.
|
8 |
|
9 |
Protect Your Website Admin Against Hackers and Modify Login Page Style
|
10 |
|
@@ -82,7 +82,9 @@ Don not forgot to update the "newadmin" slug with your new admin slug (that you
|
|
82 |
|
83 |
|
84 |
== Changelog ==
|
85 |
-
|
|
|
|
|
86 |
= 1.5 =
|
87 |
* Fixed wp-login url issue
|
88 |
* Fixed wp-admin url issue
|
1 |
=== Protect Your Admin ===
|
2 |
Contributors:india-web-developer
|
3 |
+
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=ZEMSYQUZRUK6A
|
4 |
Tags: Protect WP-Admin,wp-admin,Protect wordpress admin,Secure Admin,Admin,Scure Wordpress Admin,Rename Admin URL, Rename Wordpress Admin URL,Change wp-admin url,Change Admin URL,Change Admin Path,Restrict wp-admin
|
5 |
Requires at least: 3.3
|
6 |
+
Tested up to: 4.3
|
7 |
+
Stable tag: 1.6
|
8 |
|
9 |
Protect Your Website Admin Against Hackers and Modify Login Page Style
|
10 |
|
82 |
|
83 |
|
84 |
== Changelog ==
|
85 |
+
= 1.6 =
|
86 |
+
* Fixed wp-login.php issue for www url
|
87 |
+
|
88 |
= 1.5 =
|
89 |
* Fixed wp-login url issue
|
90 |
* Fixed wp-admin url issue
|