Protect Your Admin - Version 1.0

Version Description

Download this release

Release Info

Developer india-web-developer
Plugin Icon 128x128 Protect Your Admin
Version 1.0
Comparing to
See all releases

Version 1.0

Files changed (5) hide show
  1. css/pwa-admin-min.css +5 -0
  2. images/raghu.jpg +0 -0
  3. protect-wp-admin.php +152 -0
  4. pwa-class.php +73 -0
  5. readme.txt +40 -0
css/pwa-admin-min.css ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ /**
2
+ * Protect WP-Admin (C)
3
+ * @Raghunath Gurjar
4
+ * */
5
+ #pwa-tab-menu {width:50%; padding:1%;background: none repeat scroll 0 0 #ccc;}#pwa-tab-menu a {background: none repeat scroll 0 0 #DCA808; border: 0 none;color: #FFFFFF;display: inline-block;font-size: 16px;font-weight: bold;padding: 12px 20px;opacity:0.5;}#pwa-tab-menu a:hover{cursor:pointer;background: none repeat scroll 0 0 #DCA808;opacity:1;}#pwa-tab-menu a.active{ background: none repeat scroll 0 0 #DCA808;opacity:1;}#pwa-settings-form-admin .submit-btn {width: 100%; display: inline-block; padding-top: 10px; margin-top: 10px; border-top: 1px dashed #DCA808;}#pwa-settings-form-admin .submit-btn .button-primary{cursor:pointer;height:35px;}#pwa-settings-form-admin .csbwfs-setting p label {min-width:75px;display:inline-block;}#div-pwa-support img {width:auto; height:auto;}#pwa-settings-form-admin ul {list-style:inside}#pwa-settings-form-admin #div-pwa-support .contact-author{ background: none repeat scroll 0 0 #DC22FF;border: 0 none;color: #FFFFFF;display: inline-block;font-size: 12px; font-weight: bold;padding: 2px 5px;text-decoration: none;}
images/raghu.jpg ADDED
Binary file
protect-wp-admin.php ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ Plugin Name: Protect WP-Admin
4
+ 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.0
9
+ */
10
+
11
+ /*** Copyright 2014 Raghunath (email : raghunath.0087@gmail.com)
12
+
13
+ This program is free software; you can redistribute it and/or modify
14
+ it under the terms of the GNU General Public License, version 2, as
15
+ published by the Free Software Foundation.
16
+
17
+ This program is distributed in the hope that it will be useful,
18
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
+ GNU General Public License for more details.
21
+
22
+ You should have received a copy of the GNU General Public License
23
+ along with this program; if not, write to the Free Software
24
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
+ ***/
26
+
27
+
28
+ /**
29
+ * Initialize "Protect WP-Admin" plugin admin menu
30
+ * @create new menu
31
+ * @create plugin settings page
32
+ */
33
+ add_action('admin_menu','init_pwa_admin_menu');
34
+
35
+ function init_pwa_admin_menu(){
36
+
37
+ add_options_page('Protect WP-Admin','Protect WP-Admin','manage_options','pwa-settings','init_pwa_admin_option_page');
38
+
39
+ }
40
+
41
+ /** Define Action to register "Protect WP-Admin" Options */
42
+ add_action('admin_init','init_pwa_options_fields');
43
+ /** Register "Protect WP-Admin" options */
44
+ function init_pwa_options_fields(){
45
+ register_setting('pwa_setting_options','pwa_active');
46
+ register_setting('pwa_setting_options','pwa_rewrite_text');
47
+ }
48
+
49
+
50
+ /** Add settings link to plugin list page in admin */
51
+ add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'pwa_action_links' );
52
+ function pwa_action_links( $links ) {
53
+ $links[] = '<a href="'. get_admin_url(null, 'options-general.php?page=pwa-settings') .'">Settings</a>';
54
+ return $links;
55
+ }
56
+
57
+ /** Options Form HTML for "Protect WP-Admin" plugin */
58
+ function init_pwa_admin_option_page(){ ?>
59
+ <div style="width: 80%; padding: 10px; margin: 10px;">
60
+ <h1>Protect WP-Admin Settings</h1>
61
+ <!-- Start Options Form -->
62
+ <form action="options.php" method="post" id="pwa-settings-form-admin">
63
+
64
+ <div id="pwa-tab-menu"><a id="pwa-general" class="pwa-tab-links active" >General</a> <a id="pwa-support" class="pwa-tab-links">Support</a> </div>
65
+
66
+ <div class="pwa-setting">
67
+ <!-- General Setting -->
68
+ <div class="first pwa-tab" id="div-pwa-general">
69
+ <h2>General Settings</h2>
70
+ <p><strong>Note!:</strong> After update the new admin url,you have need to update the site permalink!</p>
71
+ <p><label>Enable:</label><input type="checkbox" id="pwa_active" name="pwa_active" value='1' <?php if(get_option('pwa_active')!=''){ echo ' checked="checked"'; }?>/></p>
72
+ <p><label>New Admin URL:</label><input type="text" id="pwa_rewrite_text" name="pwa_rewrite_text" value="<?php echo esc_attr(get_option('pwa_rewrite_text')); ?>" placeholder="wp-admin"></p>
73
+ </div>
74
+
75
+ <!-- Support -->
76
+ <div class="last author pwa-tab" id="div-pwa-support">
77
+ <h2>Plugin Support</h2>
78
+
79
+ <p><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=WN785E5V492L4" target="_blank" style="font-size: 17px; font-weight: bold;"><img src="https://www.paypal.com/en_US/i/btn/btn_donate_LG.gif" title="Donate for this plugin"></a></p>
80
+
81
+ <p><strong>Plugin Author:</strong><br><img src="<?php echo plugins_url( 'images/raghu.jpg' , __FILE__ );?>" width="75" height="75"><br><a href="http://raghunathgurjar.wordpress.com" target="_blank">Raghunath Gurjar</a></p>
82
+ <p><a href="mailto:raghunath.0087@gmail.com" target="_blank" class="contact-author">Contact Author</a></p>
83
+ <p><strong>My Other Plugins:</strong><br>
84
+ <ul>
85
+ <li><a href="https://wordpress.org/plugins/custom-share-buttons-with-floating-sidebar" target="_blank">Simple Testimonial Rutator</a></li>
86
+ <li><a href="https://wordpress.org/plugins/simple-testimonial-rutator/" target="_blank">Simple Testimonial Rutator</a></li>
87
+ <li><a href="https://wordpress.org/plugins/wp-easy-recipe/" target="_blank">WP Easy Recipe</a></li>
88
+ <li><a href="https://wordpress.org/plugins/wp-social-buttons/" target="_blank">WP Social Buttons</a></li>
89
+ <li><a href="https://wordpress.org/plugins/wp-youtube-gallery/" target="_blank">WP Youtube Gallery</a></li>
90
+ </ul></p>
91
+ </div>
92
+
93
+ </div>
94
+ <span class="submit-btn"><?php echo get_submit_button('Save Settings','button-primary','submit','','');?></span>
95
+
96
+ <?php settings_fields('pwa_setting_options'); ?>
97
+
98
+ </form>
99
+
100
+ <!-- End Options Form -->
101
+ </div>
102
+
103
+ <?php
104
+ }
105
+
106
+ /** add js into admin footer */
107
+ add_action('admin_footer','init_pwa_admin_scripts');
108
+ function init_pwa_admin_scripts()
109
+ {
110
+ wp_register_style( 'pwa_admin_style', plugins_url( 'css/pwa-admin-min.css',__FILE__ ) );
111
+ wp_enqueue_style( 'pwa_admin_style' );
112
+
113
+ echo $script='<script type="text/javascript">
114
+ /* Protect WP-Admin js for admin */
115
+ jQuery(document).ready(function(){
116
+ jQuery(".pwa-tab").hide();
117
+ jQuery("#div-pwa-general").show();
118
+ jQuery(".pwa-tab-links").click(function(){
119
+ var divid=jQuery(this).attr("id");
120
+ jQuery(".pwa-tab-links").removeClass("active");
121
+ jQuery(".pwa-tab").hide();
122
+ jQuery("#"+divid).addClass("active");
123
+ jQuery("#div-"+divid).fadeIn();
124
+ })
125
+ })
126
+ </script>';
127
+
128
+ }
129
+
130
+
131
+ /** register_install_hook */
132
+ if( function_exists('register_install_hook') ){
133
+ register_uninstall_hook(__FILE__,'init_install_pwa_plugins');
134
+ }
135
+ //flush the rewrite
136
+ function init_install_pwa_plugins(){
137
+ flush_rewrite_rules();
138
+ }
139
+ /** register_uninstall_hook */
140
+ /** Delete exits options during disable the plugins */
141
+ if( function_exists('register_uninstall_hook') ){
142
+ register_uninstall_hook(__FILE__,'init_uninstall_pwa_plugins');
143
+ }
144
+
145
+ //Delete all options after uninstall the plugin
146
+ function init_uninstall_pwa_plugins(){
147
+ delete_option('pwa_active');
148
+ delete_option('pwa_rewrite_text');
149
+ }
150
+ require dirname(__FILE__).'/pwa-class.php';
151
+
152
+ ?>
pwa-class.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
18
+ return $pwaOptions;
19
+ }
20
+ $getPwaOptions=get_pwa_setting_options();
21
+ if(isset($getPwaOptions['pwa_active']) && '1'==$getPwaOptions['pwa_active'])
22
+ {
23
+ add_action('init', 'pwa_flush_rewrite');
24
+ add_action( 'init', 'init_pwa_admin_rewrite_rules' );
25
+ add_action( 'init', 'pwa_admin_url_redirect_conditions' );
26
+ }
27
+ /** Flush rewrite rules after update the permalink */
28
+ function pwa_flush_rewrite() {
29
+ global $wp_rewrite;
30
+ $wp_rewrite->flush_rules();
31
+ }
32
+ /** Create a new rewrite rule for change to wp-admin url */
33
+ function init_pwa_admin_rewrite_rules() {
34
+ $getPwaOptions=get_pwa_setting_options();
35
+ if(isset($getPwaOptions['pwa_active']) && ''!=$getPwaOptions['pwa_rewrite_text']){
36
+ $newurl=strip_tags($getPwaOptions['pwa_rewrite_text']);
37
+ add_rewrite_rule( $newurl.'/?$', 'wp-login.php', 'top' );
38
+ }
39
+ }
40
+
41
+ function pwa_admin_url_redirect_conditions()
42
+ {
43
+ $wordpresActualURL =home_url('/wp-login.php');
44
+ $request_url = pwa_get_current_page_url($_SERVER);
45
+ $newUrl = explode('?',$request_url);
46
+
47
+ if(! is_user_logged_in() && $wordpresActualURL==$newUrl[0] )
48
+ {
49
+ //echo "{False}";
50
+ wp_redirect(home_url('/'));
51
+ }else
52
+ {
53
+ //echo "{Ture}";
54
+ }
55
+ }
56
+
57
+ /** Get the current url*/
58
+ function pwa_current_path_protocol($s, $use_forwarded_host=false)
59
+ {
60
+ $pwahttp = (!empty($s['HTTPS']) && $s['HTTPS'] == 'on') ? true:false;
61
+ $pwasprotocal = strtolower($s['SERVER_PROTOCOL']);
62
+ $pwa_protocol = substr($pwasprotocal, 0, strpos($pwasprotocal, '/')) . (($pwahttp) ? 's' : '');
63
+ $port = $s['SERVER_PORT'];
64
+ $port = ((!$pwahttp && $port=='80') || ($pwahttp && $port=='443')) ? '' : ':'.$port;
65
+ $host = ($use_forwarded_host && isset($s['HTTP_X_FORWARDED_HOST'])) ? $s['HTTP_X_FORWARDED_HOST'] : (isset($s['HTTP_HOST']) ? $s['HTTP_HOST'] : null);
66
+ $host = isset($host) ? $host : $s['SERVER_NAME'] . $port;
67
+ return $pwa_protocol . '://' . $host;
68
+ }
69
+ function pwa_get_current_page_url($s, $use_forwarded_host=false)
70
+ {
71
+ return pwa_current_path_protocol($s, $use_forwarded_host) . $s['REQUEST_URI'];
72
+ }
73
+ ?>
readme.txt ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Protect WP-Admin ===
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, Wordpress Admin
5
+ Requires at least: 3.0
6
+ Tested up to: 4.0
7
+ Stable tag: 1.0
8
+
9
+ Protect Your WordPress Site Admin Against Hackers
10
+
11
+ == Description ==
12
+
13
+ "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 admin login page private(spam user can't access the admin login page).
14
+
15
+ * Note : You have must need to update the site permalink after add/update the new admin url.
16
+
17
+ == Installation ==
18
+
19
+ Step 1. Upload "protect-wp-admin" folder to the `/wp-content/plugins/` directory
20
+
21
+ Step 2. Activate the plugin through the Plugins menu in WordPress
22
+
23
+ Step 3. Go to Settings "Protect WP-Admin" and configure the plugin settings.
24
+
25
+ == Frequently Asked Questions ==
26
+
27
+ 1.Nothing happen after enable and add the new wordpress admin url?
28
+
29
+ Don't worry, Just update the site permalink ("Settings" >> "Permalinks") and re-check,Now this time it will be work fine
30
+ == Screenshots ==
31
+
32
+ 1. screenshot-1.png
33
+
34
+ 2. screenshot-2.png
35
+
36
+
37
+ == Changelog ==
38
+
39
+ = 1.0 =
40
+ * First stable release