Version Description
- Fixed wp-login url issue
- Fixed wp-admin url issue
Download this release
Release Info
Developer | india-web-developer |
Plugin | Protect Your Admin |
Version | 1.5 |
Comparing to | |
See all releases |
Code changes from version 1.4 to 1.5
- protect-wp-admin.php +30 -3
- pwa-class.php +170 -198
- readme.txt +7 -3
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)
|
@@ -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/
|
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>
|
@@ -145,7 +145,11 @@ function init_pwa_admin_option_page(){
|
|
145 |
}
|
146 |
|
147 |
/** add js into admin footer */
|
148 |
-
|
|
|
|
|
|
|
|
|
149 |
function init_pwa_admin_scripts()
|
150 |
{
|
151 |
wp_register_style( 'pwa_admin_style', plugins_url( 'css/pwa-admin-min.css',__FILE__ ) );
|
@@ -256,4 +260,27 @@ function init_uninstall_pwa_plugins(){
|
|
256 |
}
|
257 |
require dirname(__FILE__).'/pwa-class.php';
|
258 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
259 |
?>
|
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.5
|
9 |
*/
|
10 |
|
11 |
/*** Copyright 2014 Raghunath (email : raghunath.0087@gmail.com)
|
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">Simple Testimonial Rutator</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>
|
145 |
}
|
146 |
|
147 |
/** add js into admin footer */
|
148 |
+
// better use get_current_screen(); or the global $current_screen
|
149 |
+
if (isset($_GET['page']) && $_GET['page'] == 'pwa-settings') {
|
150 |
+
add_action('admin_footer','init_pwa_admin_scripts');
|
151 |
+
}
|
152 |
+
|
153 |
function init_pwa_admin_scripts()
|
154 |
{
|
155 |
wp_register_style( 'pwa_admin_style', plugins_url( 'css/pwa-admin-min.css',__FILE__ ) );
|
260 |
}
|
261 |
require dirname(__FILE__).'/pwa-class.php';
|
262 |
|
263 |
+
/** register_deactivation_hook */
|
264 |
+
/** Delete exits options during deactivation the plugins */
|
265 |
+
if( function_exists('register_deactivation_hook') ){
|
266 |
+
register_deactivation_hook(__FILE__,'init_deactivation_pwa_plugins');
|
267 |
+
}
|
268 |
+
|
269 |
+
//Delete all options after uninstall the plugin
|
270 |
+
function init_deactivation_pwa_plugins(){
|
271 |
+
delete_option('pwa_active');
|
272 |
+
delete_option('pwa_rewrite_text');
|
273 |
+
flush_rewrite_rules();
|
274 |
+
}
|
275 |
+
|
276 |
+
/** register_activation_hook */
|
277 |
+
/** Delete exits options during disable the plugins */
|
278 |
+
if( function_exists('register_activation_hook') ){
|
279 |
+
register_activation_hook(__FILE__,'init_activation_pwa_plugins');
|
280 |
+
}
|
281 |
+
|
282 |
+
//Delete all options after uninstall the plugin
|
283 |
+
function init_activation_pwa_plugins(){
|
284 |
+
flush_rewrite_rules();
|
285 |
+
}
|
286 |
?>
|
pwa-class.php
CHANGED
@@ -1,198 +1,170 @@
|
|
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 |
-
if(
|
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 |
-
|
171 |
-
}
|
172 |
-
function pwa_get_current_page_url($s, $use_forwarded_host=false)
|
173 |
-
{
|
174 |
-
return pwa_current_path_protocol($s, $use_forwarded_host) . $s['REQUEST_URI'];
|
175 |
-
}
|
176 |
-
|
177 |
-
|
178 |
-
//if(isset($getPwaOptions['pwa_logo_path'])):
|
179 |
-
|
180 |
-
/* Change Wordpress Default Logo */
|
181 |
-
function pwa_update_login_page_logo() {
|
182 |
-
$getPwaOptions=get_pwa_setting_options();
|
183 |
-
|
184 |
-
echo '<style type="text/css"> /* Protect WP-Admin Style*/';
|
185 |
-
|
186 |
-
if(isset($getPwaOptions['pwa_logo_path']) && $getPwaOptions['pwa_logo_path']!='')
|
187 |
-
echo ' h1 a { background-image:url('.$getPwaOptions['pwa_logo_path'].') !important; }';
|
188 |
-
|
189 |
-
if(isset($getPwaOptions['pwa_login_page_bg_color']) && $getPwaOptions['pwa_login_page_bg_color']!='')
|
190 |
-
echo ' body.login-action-login,html{ background:'.$getPwaOptions['pwa_login_page_bg_color'].' !important; height: 100% !important;}';
|
191 |
-
|
192 |
-
echo '</style>';
|
193 |
-
|
194 |
-
}
|
195 |
-
add_action('login_head', 'pwa_update_login_page_logo');
|
196 |
-
|
197 |
-
|
198 |
-
?>
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Protect WP-Admin (C)
|
4 |
+
* @register_install_hook()
|
5 |
+
* @register_uninstall_hook()
|
6 |
+
* */
|
7 |
+
?>
|
8 |
+
<?php
|
9 |
+
/** Get all options value */
|
10 |
+
function get_pwa_setting_options() {
|
11 |
+
global $wpdb;
|
12 |
+
$pwaOptions = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options WHERE option_name LIKE 'pwa_%'");
|
13 |
+
|
14 |
+
foreach ($pwaOptions as $option) {
|
15 |
+
$pwaOptions[$option->option_name] = $option->option_value;
|
16 |
+
}
|
17 |
+
return $pwaOptions;
|
18 |
+
}
|
19 |
+
$getPwaOptions=get_pwa_setting_options();
|
20 |
+
if(isset($getPwaOptions['pwa_active']) && '1'==$getPwaOptions['pwa_active'])
|
21 |
+
{
|
22 |
+
add_action('init', 'init_pwa_admin_rewrite_rules' );
|
23 |
+
add_action('init', 'pwa_admin_url_redirect_conditions' );
|
24 |
+
}
|
25 |
+
if(isset($getPwaOptions['pwa_logout']))
|
26 |
+
{
|
27 |
+
add_action('admin_init', 'pwa_logout_user_after_settings_save');
|
28 |
+
add_action('admin_init', 'pwa_logout_user_after_settings_save');
|
29 |
+
}
|
30 |
+
function pwa_logout_user_after_settings_save()
|
31 |
+
{
|
32 |
+
$getPwaOptions=get_pwa_setting_options();
|
33 |
+
if(isset($_GET['settings-updated']) && $_GET['settings-updated'] && isset($_GET['page']) && $_GET['page']=='pwa-settings')
|
34 |
+
{
|
35 |
+
flush_rewrite_rules();
|
36 |
+
}
|
37 |
+
|
38 |
+
if(isset($_GET['settings-updated']) && $_GET['settings-updated'] && isset($_GET['page']) && $_GET['page']=='pwa-settings' && isset($getPwaOptions['pwa_logout']) && $getPwaOptions['pwa_logout']==1)
|
39 |
+
{
|
40 |
+
$URL=str_replace('&','&',wp_logout_url());
|
41 |
+
if(isset($getPwaOptions['pwa_rewrite_text']) && isset($getPwaOptions['pwa_logout']) && $getPwaOptions['pwa_logout']==1 && $getPwaOptions['pwa_rewrite_text']!=''){
|
42 |
+
wp_redirect(home_url('/'.$getPwaOptions['pwa_rewrite_text']));
|
43 |
+
}else
|
44 |
+
{
|
45 |
+
//silent
|
46 |
+
}
|
47 |
+
//wp_redirect($URL);
|
48 |
+
}
|
49 |
+
}
|
50 |
+
/** Create a new rewrite rule for change to wp-admin url */
|
51 |
+
function init_pwa_admin_rewrite_rules() {
|
52 |
+
$getPwaOptions=get_pwa_setting_options();
|
53 |
+
if(isset($getPwaOptions['pwa_active']) && ''!=$getPwaOptions['pwa_rewrite_text']){
|
54 |
+
$newurl=strip_tags($getPwaOptions['pwa_rewrite_text']);
|
55 |
+
add_rewrite_rule( $newurl.'/?$', 'wp-login.php', 'top' );
|
56 |
+
add_rewrite_rule( $newurl.'/register/?$', 'wp-login.php?action=register', 'top' );
|
57 |
+
add_rewrite_rule( $newurl.'/lostpassword/?$', 'wp-login.php?action=lostpassword', 'top' );
|
58 |
+
}
|
59 |
+
}
|
60 |
+
/**
|
61 |
+
* Update Login, Register & Forgot password link as per new admin url
|
62 |
+
* */
|
63 |
+
add_action('login_head','csbwfs_custom_script');
|
64 |
+
function csbwfs_custom_script()
|
65 |
+
{
|
66 |
+
$getPwaOptions=get_pwa_setting_options();
|
67 |
+
if(isset($getPwaOptions['pwa_active']) && ''!=$getPwaOptions['pwa_rewrite_text']){
|
68 |
+
echo '<script>jQuery(window).load(function(){var formId= jQuery("#login form").attr("id");
|
69 |
+
if(formId=="loginform"){
|
70 |
+
jQuery("#"+formId).attr("action","'.home_url($getPwaOptions["pwa_rewrite_text"]).'");
|
71 |
+
}else if("lostpasswordform"==formId){
|
72 |
+
jQuery("#"+formId).attr("action","'.home_url($getPwaOptions["pwa_rewrite_text"].'/lostpassword').'");
|
73 |
+
}else if("registerform"==formId){
|
74 |
+
jQuery("#"+formId).attr("action","'.home_url($getPwaOptions["pwa_rewrite_text"].'/register').'");
|
75 |
+
}else
|
76 |
+
{
|
77 |
+
//silent
|
78 |
+
}
|
79 |
+
jQuery("#nav a").each(function(){
|
80 |
+
var linkText=jQuery(this).text();
|
81 |
+
if(linkText=="Log in"){jQuery(this).attr("href","'.home_url($getPwaOptions["pwa_rewrite_text"]).'");}
|
82 |
+
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 {
|
83 |
+
//silent
|
84 |
+
}
|
85 |
+
});});</script>';
|
86 |
+
}
|
87 |
+
}
|
88 |
+
function pwa_admin_url_redirect_conditions()
|
89 |
+
{
|
90 |
+
$getPwaOptions=get_pwa_setting_options();
|
91 |
+
$pwaActualURLAry =array
|
92 |
+
(
|
93 |
+
str_replace('www.','',home_url('/wp-login.php')),
|
94 |
+
str_replace('www.','',home_url('/wp-login.php/')),
|
95 |
+
str_replace('www.','',home_url('/wp-login')),
|
96 |
+
str_replace('www.','',home_url('/wp-login/')),
|
97 |
+
str_replace('www.','',home_url('/wp-admin')),
|
98 |
+
str_replace('www.','',home_url('/wp-admin/')),
|
99 |
+
);
|
100 |
+
$request_url = pwa_get_current_page_url($_SERVER);
|
101 |
+
$newUrl = explode('?',$request_url);
|
102 |
+
// print_r($pwaActualURLAry); echo str_replace('www.','',$newUrl[0]);exit;
|
103 |
+
$pwa_requestUrl=str_replace('www.','',$newUrl[0]);
|
104 |
+
if(! is_user_logged_in() && in_array($pwa_requestUrl,$pwaActualURLAry) )
|
105 |
+
{
|
106 |
+
wp_redirect(home_url('/'),301);
|
107 |
+
//exit;
|
108 |
+
}
|
109 |
+
else if(isset($getPwaOptions['pwa_restrict']) && $getPwaOptions['pwa_restrict']==1 && is_user_logged_in())
|
110 |
+
{
|
111 |
+
global $current_user;
|
112 |
+
$user_roles = $current_user->roles;
|
113 |
+
$user_ID = $current_user->ID;
|
114 |
+
$user_role = array_shift($user_roles);
|
115 |
+
if(isset($getPwaOptions['pwa_allow_custom_users']) && $getPwaOptions['pwa_allow_custom_users']!='')
|
116 |
+
{
|
117 |
+
$userids=explode(',' ,$getPwaOptions['pwa_allow_custom_users']);
|
118 |
+
if(is_array($userids))
|
119 |
+
{
|
120 |
+
$userids=explode(',' ,$getPwaOptions['pwa_allow_custom_users']);
|
121 |
+
}else
|
122 |
+
{
|
123 |
+
$userids[]=$getPwaOptions['pwa_allow_custom_users'];
|
124 |
+
}
|
125 |
+
}else
|
126 |
+
{
|
127 |
+
$userids=array();
|
128 |
+
}
|
129 |
+
|
130 |
+
if($user_role=='administrator' || in_array($user_ID,$userids))
|
131 |
+
{
|
132 |
+
//silent is gold
|
133 |
+
}else
|
134 |
+
{
|
135 |
+
wp_redirect(home_url('/'));
|
136 |
+
}
|
137 |
+
}else
|
138 |
+
{
|
139 |
+
//silent is gold
|
140 |
+
}
|
141 |
+
}
|
142 |
+
/** Get the current url*/
|
143 |
+
function pwa_current_path_protocol($s, $use_forwarded_host=false)
|
144 |
+
{
|
145 |
+
$pwahttp = (!empty($s['HTTPS']) && $s['HTTPS'] == 'on') ? true:false;
|
146 |
+
$pwasprotocal = strtolower($s['SERVER_PROTOCOL']);
|
147 |
+
$pwa_protocol = substr($pwasprotocal, 0, strpos($pwasprotocal, '/')) . (($pwahttp) ? 's' : '');
|
148 |
+
$port = $s['SERVER_PORT'];
|
149 |
+
$port = ((!$pwahttp && $port=='80') || ($pwahttp && $port=='443')) ? '' : ':'.$port;
|
150 |
+
$host = ($use_forwarded_host && isset($s['HTTP_X_FORWARDED_HOST'])) ? $s['HTTP_X_FORWARDED_HOST'] : (isset($s['HTTP_HOST']) ? $s['HTTP_HOST'] : null);
|
151 |
+
$host = isset($host) ? $host : $s['SERVER_NAME'] . $port;
|
152 |
+
return $pwa_protocol . '://' . $host;
|
153 |
+
}
|
154 |
+
function pwa_get_current_page_url($s, $use_forwarded_host=false)
|
155 |
+
{
|
156 |
+
return pwa_current_path_protocol($s, $use_forwarded_host) . $s['REQUEST_URI'];
|
157 |
+
}
|
158 |
+
//if(isset($getPwaOptions['pwa_logo_path'])):
|
159 |
+
/* Change Wordpress Default Logo */
|
160 |
+
function pwa_update_login_page_logo() {
|
161 |
+
$getPwaOptions=get_pwa_setting_options();
|
162 |
+
echo '<style type="text/css"> /* Protect WP-Admin Style*/';
|
163 |
+
if(isset($getPwaOptions['pwa_logo_path']) && $getPwaOptions['pwa_logo_path']!='')
|
164 |
+
echo ' h1 a { background-image:url('.$getPwaOptions['pwa_logo_path'].') !important; }';
|
165 |
+
if(isset($getPwaOptions['pwa_login_page_bg_color']) && $getPwaOptions['pwa_login_page_bg_color']!='')
|
166 |
+
echo ' body.login-action-login,html{ background:'.$getPwaOptions['pwa_login_page_bg_color'].' !important; height: 100% !important;}';
|
167 |
+
echo '</style>';
|
168 |
+
}
|
169 |
+
add_action('login_head', 'pwa_update_login_page_logo');
|
170 |
+
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
readme.txt
CHANGED
@@ -2,9 +2,9 @@
|
|
2 |
Contributors:india-web-developer
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=WN785E5V492L4
|
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.
|
6 |
-
Tested up to: 4.
|
7 |
-
Stable tag: 1.
|
8 |
|
9 |
Protect Your Website Admin Against Hackers and Modify Login Page Style
|
10 |
|
@@ -83,6 +83,10 @@ Don not forgot to update the "newadmin" slug with your new admin slug (that you
|
|
83 |
|
84 |
== Changelog ==
|
85 |
|
|
|
|
|
|
|
|
|
86 |
= 1.4 =
|
87 |
* Fixed links issue on "Register", "Login" & "Lost Password" As Per New Admin Url
|
88 |
* Fixed the "Register", "Login" & "Lost Password" Form Action URL As Per New Admin Url
|
2 |
Contributors:india-web-developer
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=WN785E5V492L4
|
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.2
|
7 |
+
Stable tag: 1.5
|
8 |
|
9 |
Protect Your Website Admin Against Hackers and Modify Login Page Style
|
10 |
|
83 |
|
84 |
== Changelog ==
|
85 |
|
86 |
+
= 1.5 =
|
87 |
+
* Fixed wp-login url issue
|
88 |
+
* Fixed wp-admin url issue
|
89 |
+
|
90 |
= 1.4 =
|
91 |
* Fixed links issue on "Register", "Login" & "Lost Password" As Per New Admin Url
|
92 |
* Fixed the "Register", "Login" & "Lost Password" Form Action URL As Per New Admin Url
|