Protect Your Admin - Version 3.7

Version Description

  • fixed url issue
  • optimized code
Download this release

Release Info

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

Code changes from version 3.6.2 to 3.7

Files changed (4) hide show
  1. js/pwa-login.js +6 -6
  2. protect-wp-admin.php +22 -78
  3. pwa-class.php +1 -1
  4. readme.txt +5 -1
js/pwa-login.js CHANGED
@@ -9,7 +9,7 @@ jQuery(document).ready(function(){
9
  let c = pwaawp_object.c;
10
 
11
  if( l != '') {
12
- jQuery("#login h1 a").css('background', 'url(' + l + ')');
13
  }
14
 
15
  if( b != '') {
@@ -26,10 +26,10 @@ jQuery(document).ready(function(){
26
  if(formId=="loginform"){
27
  jQuery("#"+formId).attr("action",su);
28
  }else if("lostpasswordform"==formId){
29
- jQuery("#"+formId).attr("action",pwaawp_object.u+'/lostpassword');
30
- jQuery("#"+formId+" input:hidden[name=redirect_to]").val(pwaawp_object.u+'/?checkemail=confirm');
31
  }else if("registerform"==formId){
32
- jQuery("#"+formId).attr("action",pwaawp_object.u+'/register');
33
  }
34
  else
35
  {
@@ -37,8 +37,8 @@ if(formId=="loginform"){
37
  }
38
  jQuery("#nav a").each(function(){
39
  var linkText = jQuery(this).attr("href").match(/[^/]*(?=(\/)?$)/)[0];
40
- if(linkText=="wp-login.php"){jQuery(this).attr("href",pwaawp_object.u);}
41
- else if(linkText=="wp-login.php?action=register"){jQuery(this).attr("href",pwaawp_object.u+'/register');}else if(linkText=="wp-login.php?action=lostpassword"){jQuery(this).attr("href",pwaawp_object.u+'/lostpassword');}else {
42
  //silent
43
  }
44
  });
9
  let c = pwaawp_object.c;
10
 
11
  if( l != '') {
12
+ jQuery("#login h1 a").css('background', 'url(' + l + ')').css('background-repeat', 'no-repeat').css('background-size', 'contain');
13
  }
14
 
15
  if( b != '') {
26
  if(formId=="loginform"){
27
  jQuery("#"+formId).attr("action",su);
28
  }else if("lostpasswordform"==formId){
29
+ jQuery("#"+formId).attr("action",su+'/lostpassword');
30
+ jQuery("#"+formId+" input:hidden[name=redirect_to]").val(su+'/?checkemail=confirm');
31
  }else if("registerform"==formId){
32
+ jQuery("#"+formId).attr("action",su+'/register');
33
  }
34
  else
35
  {
37
  }
38
  jQuery("#nav a").each(function(){
39
  var linkText = jQuery(this).attr("href").match(/[^/]*(?=(\/)?$)/)[0];
40
+ if(linkText=="wp-login.php"){jQuery(this).attr("href",su);}
41
+ else if(linkText=="wp-login.php?action=register"){jQuery(this).attr("href",su+'/register');}else if(linkText=="wp-login.php?action=lostpassword"){jQuery(this).attr("href",su+'/lostpassword');}else {
42
  //silent
43
  }
44
  });
protect-wp-admin.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: https://www.wp-experts.in/
5
  Description: Give extra protection to your site admin and make secure your website against hackers!!
6
  Author: WP Experts Team
7
  Author URI: https://www.wp-experts.in/
8
- Version: 3.6.2
9
  */
10
 
11
  /*** WP Experts Team Copyright 2017-2020 (email : raghunath.0087@gmail.com)
@@ -87,21 +87,12 @@ function pwa_sanitization_newslug_escaping_text($val)
87
  return $val;
88
  }
89
  endif;
90
- if(!function_exists('add_pwa_admin_style_script')):
91
- function add_pwa_admin_style_script()
92
- {
93
- wp_register_script('pwa-image-upload', plugins_url('/js/pwa.js',__FILE__ ), array('jquery','media-upload','thickbox','wp-color-picker'));
94
- wp_enqueue_script('pwa-image-upload');
95
- wp_enqueue_style( 'wp-color-picker' );
96
- wp_enqueue_style('thickbox');
97
- }
98
- endif;
99
  /** Add settings link to plugin list page in admin */
100
  add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'pwa_action_links' );
101
  if(!function_exists('pwa_action_links')):
102
  function pwa_action_links( $links ) {
103
  $links[] = '<a href="'. get_admin_url(null, 'options-general.php?page=pwa-settings') .'">Settings</a> | <a href="http://www.wp-experts.in/products/protect-wp-admin-pro">GO PRO</a>';
104
- return $links;
105
  }
106
  endif;
107
  /** Options Form HTML for "Protect WP-Admin" plugin */
@@ -117,7 +108,7 @@ function init_pwa_admin_option_page(){
117
  <h1>Protect WP-Admin Settings</h1>
118
  <!-- Start Options Form -->
119
  <form action="options.php" method="post" id="pwa-settings-form-admin">
120
- <input type="hidden" id="check_permalink" value="<?php echo $permalink_structure_val;?>">
121
  <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">Login Page Style</a><a id="pwa-support" class="pwa-tab-links">Support & Our other plugin</a> </div>
122
  <hr>
123
  <div class="pwa-setting">
@@ -128,12 +119,12 @@ function init_pwa_admin_option_page(){
128
  <tr>
129
  <td valign="top" width="50%">
130
 
131
- <p><input type="checkbox" id="pwa_active" name="pwa_active" value='1' <?php if(get_option('pwa_active')!=''){ echo ' checked="checked"'; }?>/> <label><strong>Enable</strong></label></p>
132
  <p id="adminurl"><label><strong>New Admin Slug:</strong></label><br><input onkeyup="this.value=this.value.replace(/[^a-z]/g,'');" type="text" id="pwa_rewrite_text" size="20" name="pwa_rewrite_text" value="<?php echo esc_attr(get_option('pwa_rewrite_text')); ?>" placeholder="myadmin" size="30"><br><i>Don't use any special character.</i></p>
133
  <?php
134
  $getPwaOptions=get_pwa_setting_options();
135
  if((isset($getPwaOptions['pwa_active']) && '1'==$getPwaOptions['pwa_active']) && (isset($getPwaOptions['pwa_rewrite_text']) && $getPwaOptions['pwa_rewrite_text']!='')){
136
- echo '<p><a href="'.site_url($getPwaOptions['pwa_rewrite_text'].'?preview=1').'" target="_blank" style="border: 1px solid #ff0000;text-decoration: none;color: #ff0000;font-size: 18px;vertical-align: middle;padding: 10px 20px;" target="_blank">Preview Of New Admin URL</a></blink></strong></p><em><strong>Note:</strong>Please check new admin url before logout.</em><br>';
137
 
138
  }
139
  ?>
@@ -141,7 +132,7 @@ function init_pwa_admin_option_page(){
141
 
142
  <h2>Advance Settings</h2>
143
 
144
- <p><input type="checkbox" id="pwa_restrict" name="pwa_restrict" value='1' <?php if(get_option('pwa_restrict')!=''){ echo ' checked="checked"'; }?>/> <label>Restrict registered non-admin users from wp-admin :</label></p>
145
  <p><label>Allow access to non-admin users:<br></label><input type="text" id="pwa_allow_custom_users" name="pwa_allow_custom_users" value="<?php echo esc_attr(get_option('pwa_allow_custom_users')); ?>" placeholder="1,2,3"> <br>(<i>Add comma seprated ids</i>)</p>
146
 
147
  </td>
@@ -231,8 +222,7 @@ endif;
231
  /** add js into admin footer */
232
  // better use get_current_screen(); or the global $current_screen
233
  if (isset($_GET['page']) && $_GET['page'] == 'pwa-settings') {
234
- add_action('admin_footer','init_pwa_admin_scripts');
235
- add_action('admin_head','add_pwa_admin_style_script');
236
  }
237
  if(!function_exists('init_pwa_admin_scripts')):
238
  function init_pwa_admin_scripts()
@@ -240,6 +230,11 @@ function init_pwa_admin_scripts()
240
  wp_register_style( 'pwa_admin_style', plugins_url( 'css/pwa-admin-min.css',__FILE__ ) );
241
  wp_enqueue_style( 'pwa_admin_style' );
242
 
 
 
 
 
 
243
  /* check .htaccess file writeable or not*/
244
  $csbwfsHtaccessfilePath = getcwd()."/.htaccess";
245
  $csbwfsHtaccessfilePath = str_replace('/wp-admin/','/',$csbwfsHtaccessfilePath);
@@ -255,67 +250,16 @@ if(file_exists($csbwfsHtaccessfilePath)){
255
  }
256
  $localHostIP=$_SERVER['REMOTE_ADDR'];
257
  $pwaActive=get_option('pwa_active');
258
- //$pwaNewSlug=get_option('pwa_rewrite_text');
259
- //print_r($_SERVER); exit;
260
- echo $script='<script type="text/javascript">
261
- /* Protect WP-Admin js for admin */
262
- jQuery(document).ready(function(){
263
- jQuery(".pwa-tab").hide();
264
- jQuery("#div-pwa-general").show();
265
- jQuery(".pwa-tab-links").click(function(){
266
- var divid=jQuery(this).attr("id");
267
- jQuery(".pwa-tab-links").removeClass("active");
268
- jQuery(".pwa-tab").hide();
269
- jQuery("#"+divid).addClass("active");
270
- jQuery("#div-"+divid).fadeIn();
271
- });
272
-
273
- jQuery("#pwa-settings-form-admin .button-primary").click(function(){
274
- var $el = jQuery("#pwa_active");
275
- var $vlue = jQuery("#pwa_rewrite_text").val();
276
- var pwaActive ="'.$pwaActive.'";
277
- /*if((!$el[0].checked) && $vlue=="")
278
- {
279
- alert("Please enable plugin");
280
- return false;
281
- }*/
282
-
283
- if(($el[0].checked) && $vlue=="")
284
- {
285
- jQuery("#pwa_rewrite_text").css("border","1px solid red");
286
- jQuery("#adminurl").append(" <span style=\'color:red;display:block;\'>Please enter new admin slug</span>");
287
- return false;
288
- }
289
-
290
- /*if(($el[0].checked) && pwaActive==""){
291
- //alert(pwaActive);
292
- if (confirm("1. Have you updated permalink settings to SEO friendly URL\n\nIf your answer is YES then Click OK to continue")){
293
- return true;
294
- }else
295
- {
296
- location.href="'.admin_url('options-permalink.php').'";
297
- return false;
298
- }
299
- }*/
300
- var seoUrlVal=jQuery("#check_permalink").val();
301
- var htaccessWriteable ="'.$htaccessWriteable.'";
302
- var hostIP ="'.$localHostIP.'";
303
- // alert(hostIP);
304
- if(seoUrlVal=="no")
305
- {
306
- alert("Please update permalinks before activate the plugin. permalinks option should not be default!.");
307
- window.open("'.admin_url('options-permalink.php').'","_blank");
308
- return false;
309
- }
310
- else
311
- {
312
- return true;
313
- }
314
- });
315
-
316
- })
317
- </script>';
318
 
 
 
 
 
 
 
 
 
319
  }
320
  endif;
321
 
@@ -330,7 +274,7 @@ function is_permalink_activate() {
330
  endif;
331
  if(!function_exists('permalink_structure_admin_notice')):
332
  function permalink_structure_admin_notice(){
333
- echo '<div id="message" class="error"><p>Please Make sure to enable <a href="options-permalink.php">Permalinks</a>.</p></div>';
334
  }
335
  endif;
336
  /** register_install_hook */
5
  Description: Give extra protection to your site admin and make secure your website against hackers!!
6
  Author: WP Experts Team
7
  Author URI: https://www.wp-experts.in/
8
+ Version: 3.7
9
  */
10
 
11
  /*** WP Experts Team Copyright 2017-2020 (email : raghunath.0087@gmail.com)
87
  return $val;
88
  }
89
  endif;
 
 
 
 
 
 
 
 
 
90
  /** Add settings link to plugin list page in admin */
91
  add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'pwa_action_links' );
92
  if(!function_exists('pwa_action_links')):
93
  function pwa_action_links( $links ) {
94
  $links[] = '<a href="'. get_admin_url(null, 'options-general.php?page=pwa-settings') .'">Settings</a> | <a href="http://www.wp-experts.in/products/protect-wp-admin-pro">GO PRO</a>';
95
+ return ($links);
96
  }
97
  endif;
98
  /** Options Form HTML for "Protect WP-Admin" plugin */
108
  <h1>Protect WP-Admin Settings</h1>
109
  <!-- Start Options Form -->
110
  <form action="options.php" method="post" id="pwa-settings-form-admin">
111
+ <input type="hidden" id="check_permalink" value="<?php echo esc_attr($permalink_structure_val);?>">
112
  <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">Login Page Style</a><a id="pwa-support" class="pwa-tab-links">Support & Our other plugin</a> </div>
113
  <hr>
114
  <div class="pwa-setting">
119
  <tr>
120
  <td valign="top" width="50%">
121
 
122
+ <p><input type="checkbox" id="pwa_active" name="pwa_active" value='1' <?php if(get_option('pwa_active')!=''){ echo esc_attr(' checked="checked"'); }?>/> <label><strong>Enable</strong></label></p>
123
  <p id="adminurl"><label><strong>New Admin Slug:</strong></label><br><input onkeyup="this.value=this.value.replace(/[^a-z]/g,'');" type="text" id="pwa_rewrite_text" size="20" name="pwa_rewrite_text" value="<?php echo esc_attr(get_option('pwa_rewrite_text')); ?>" placeholder="myadmin" size="30"><br><i>Don't use any special character.</i></p>
124
  <?php
125
  $getPwaOptions=get_pwa_setting_options();
126
  if((isset($getPwaOptions['pwa_active']) && '1'==$getPwaOptions['pwa_active']) && (isset($getPwaOptions['pwa_rewrite_text']) && $getPwaOptions['pwa_rewrite_text']!='')){
127
+ echo ('<p><a href="'.site_url($getPwaOptions['pwa_rewrite_text'].'?preview=1').'" target="_blank" style="border: 1px solid #ff0000;text-decoration: none;color: #ff0000;font-size: 18px;vertical-align: middle;padding: 10px 20px;" target="_blank">Preview Of New Admin URL</a></blink></strong></p><em><strong>Note:</strong>Please check new admin url before logout.</em><br>');
128
 
129
  }
130
  ?>
132
 
133
  <h2>Advance Settings</h2>
134
 
135
+ <p><input type="checkbox" id="pwa_restrict" name="pwa_restrict" value='1' <?php if(get_option('pwa_restrict')!=''){ echo esc_attr(' checked="checked"'); }?>/> <label>Restrict registered non-admin users from wp-admin :</label></p>
136
  <p><label>Allow access to non-admin users:<br></label><input type="text" id="pwa_allow_custom_users" name="pwa_allow_custom_users" value="<?php echo esc_attr(get_option('pwa_allow_custom_users')); ?>" placeholder="1,2,3"> <br>(<i>Add comma seprated ids</i>)</p>
137
 
138
  </td>
222
  /** add js into admin footer */
223
  // better use get_current_screen(); or the global $current_screen
224
  if (isset($_GET['page']) && $_GET['page'] == 'pwa-settings') {
225
+ add_action('admin_enqueue_scripts','init_pwa_admin_scripts');
 
226
  }
227
  if(!function_exists('init_pwa_admin_scripts')):
228
  function init_pwa_admin_scripts()
230
  wp_register_style( 'pwa_admin_style', plugins_url( 'css/pwa-admin-min.css',__FILE__ ) );
231
  wp_enqueue_style( 'pwa_admin_style' );
232
 
233
+ wp_register_script('pwa-script', plugins_url('/js/pwa.js',__FILE__ ), array('jquery','media-upload','thickbox','wp-color-picker'));
234
+ wp_enqueue_script('pwa-script');
235
+ wp_enqueue_style( 'wp-color-picker' );
236
+ wp_enqueue_style('thickbox');
237
+
238
  /* check .htaccess file writeable or not*/
239
  $csbwfsHtaccessfilePath = getcwd()."/.htaccess";
240
  $csbwfsHtaccessfilePath = str_replace('/wp-admin/','/',$csbwfsHtaccessfilePath);
250
  }
251
  $localHostIP=$_SERVER['REMOTE_ADDR'];
252
  $pwaActive=get_option('pwa_active');
253
+ $url = admin_url('options-permalink.php');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
254
 
255
+ wp_localize_script( 'pwa-script', 'pwa_admin_object',
256
+ array(
257
+ 'st' => $pwaActive,
258
+ 'ip' => $localHostIP,
259
+ 'ht' => $htaccessWriteable,
260
+ 'ur' => $url,
261
+ )
262
+ );
263
  }
264
  endif;
265
 
274
  endif;
275
  if(!function_exists('permalink_structure_admin_notice')):
276
  function permalink_structure_admin_notice(){
277
+ echo ('<div id="message" class="error"><p>Please Make sure to enable <a href="options-permalink.php">Permalinks</a>.</p></div>');
278
  }
279
  endif;
280
  /** register_install_hook */
pwa-class.php CHANGED
@@ -224,7 +224,7 @@ add_action( 'login_enqueue_scripts', 'pwa_update_login_page_logo' );
224
  if(!function_exists('pwa_update_login_page_logo')):
225
  function pwa_update_login_page_logo()
226
  {
227
- wp_enqueue_script( 'pwa-login', plugin_dir_url( __FILE__ ) . 'js/pwa-login.js' );
228
  $newadmin = 'nwp'.get_option("pwa_rewrite_text");
229
  $bg = get_option("pwa_login_page_bg_color");
230
  $color = get_option("pwa_login_page_color");
224
  if(!function_exists('pwa_update_login_page_logo')):
225
  function pwa_update_login_page_logo()
226
  {
227
+ wp_enqueue_script( 'pwa-login', plugin_dir_url( __FILE__ ) . 'js/pwa-login.js?v=1' );
228
  $newadmin = 'nwp'.get_option("pwa_rewrite_text");
229
  $bg = get_option("pwa_login_page_bg_color");
230
  $color = get_option("pwa_login_page_color");
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
  Tags: secure website, secure wordpress, protect wp admin, protection,security, wordpress protection, wordpress security, prevent hacking, hack, secure login, website security, change username, rename username, admin url, secure admin, username, protect admin, login, secure wordpress admin, admin login, admin, rename admin url
5
  Requires at least: 5.0
6
  Tested up to: 5.8.2
7
- Stable tag: 3.6.2
8
 
9
  == Description ==
10
 
@@ -126,6 +126,10 @@ Here we are using new admin slug as "myadmin" so as per your new admin slug you
126
 
127
  == Changelog ==
128
 
 
 
 
 
129
  = 3.6 =
130
   * Optimized the code and security things
131
   * Tested with wordpress version 5.8.2
4
  Tags: secure website, secure wordpress, protect wp admin, protection,security, wordpress protection, wordpress security, prevent hacking, hack, secure login, website security, change username, rename username, admin url, secure admin, username, protect admin, login, secure wordpress admin, admin login, admin, rename admin url
5
  Requires at least: 5.0
6
  Tested up to: 5.8.2
7
+ Stable tag: 3.7
8
 
9
  == Description ==
10
 
126
 
127
  == Changelog ==
128
 
129
+ = 3.7 =
130
+  * fixed url issue
131
+  * optimized code
132
+  
133
  = 3.6 =
134
   * Optimized the code and security things
135
   * Tested with wordpress version 5.8.2