WP Hide & Security Enhancer - Version 1.5.5.4

Version Description

  • Fix Wp Rocket cache when using Minify and Concatenation
  • New functionality - Remove Admin Bar for specified roles
  • Module block structure extend to support 'callback_arguments' to passThrough additional data to processing function
  • Redirect the default non-pretty-url search url to customized one
Download this release

Release Info

Developer nsp-code
Plugin Icon 128x128 WP Hide & Security Enhancer
Version 1.5.5.4
Comparing to
See all releases

Code changes from version 1.5.5 to 1.5.5.4

compatibility/wp-rocket.php CHANGED
@@ -9,7 +9,10 @@
9
  if( ! self::is_plugin_active())
10
  return FALSE;
11
 
12
- add_action('wp', array('WPH_conflict_handle_wp_rocket', 'wpcache') , -1);
 
 
 
13
  }
14
 
15
  static function is_plugin_active()
@@ -22,128 +25,28 @@
22
  else
23
  return FALSE;
24
  }
25
-
26
- static public function wpcache()
27
- {
28
-
29
- //only on front side
30
- if(is_admin() && ! defined( 'DOING_AJAX' ) )
31
- return;
32
-
33
- if( defined( 'DOING_AJAX' ) && DOING_AJAX )
34
- return;
35
-
36
- if ( ! isset( $_SERVER['REQUEST_METHOD'] ) || $_SERVER['REQUEST_METHOD'] != 'GET' )
37
- return;
38
-
39
-
40
- global $wph;
41
-
42
- //if loged in and not using 'cache_logged_user' leave the default plugin ob callback
43
- $wp_rocket_options = get_option( WP_ROCKET_SLUG );
44
- $cache_logged_user = isset($wp_rocket_options['cache_logged_user']) ? $wp_rocket_options['cache_logged_user'] : '';
45
- if (is_user_logged_in() && empty( $cache_logged_user ) )
46
- return;
47
-
48
- $request_uri = explode( '?', $_SERVER['REQUEST_URI'] );
49
- $request_uri = reset(( $request_uri ));
50
-
51
- // Don't cache disallowed extensions
52
- if ( strtolower( $_SERVER['REQUEST_URI'] ) != '/index.php' && in_array( pathinfo( $request_uri, PATHINFO_EXTENSION ), array( 'php', 'xml', 'xsl' ) ) )
53
- return;
54
-
55
- //query GET
56
- if ( ! empty( $_GET )
57
- && ( ! isset( $_GET['utm_source'], $_GET['utm_medium'], $_GET['utm_campaign'] ) )
58
- && ( ! isset( $_GET['utm_expid'] ) )
59
- && ( ! isset( $_GET['fb_action_ids'], $_GET['fb_action_types'], $_GET['fb_source'] ) )
60
- && ( ! isset( $_GET['gclid'] ) )
61
- && ( ! isset( $_GET['permalink_name'] ) )
62
- && ( ! isset( $_GET['lp-variation-id'] ) )
63
- && ( ! isset( $_GET['lang'] ) )
64
- && ( ! isset( $_GET['s'] ) )
65
- && ( ! isset( $_GET['age-verified'] ) )
66
- && ( ! isset( $rocket_cache_query_strings ) || ! array_intersect( array_keys( $_GET ), $rocket_cache_query_strings ) )
67
- )
68
- {
69
- return;
70
- }
71
-
72
-
73
-
74
- $rocket_cache_search = apply_filters( 'rocket_cache_search', false );
75
-
76
- if ( function_exists( 'is_404' ) && is_404() )
77
- return;
78
-
79
- if ( function_exists( 'is_search' ) && is_search() || $rocket_cache_search) // Don't cache search results
80
- return;
81
-
82
- if ( defined( 'DONOTCACHEPAGE' ) )
83
- return;
84
-
85
-
86
- add_filter( 'rocket_buffer', array( 'WPH_conflict_handle_wp_rocket', 'set_cache_possible_write_marker'), 999 );
87
-
88
 
89
-
90
  }
91
-
92
- /**
93
- * reenable the ob_start_Callback
94
- *
95
- */
96
- static public function set_cache_possible_write_marker( $buffer )
97
  {
98
 
 
 
 
99
  global $wph;
100
 
101
- if ( apply_filters( 'do_rocket_generate_caching_files', true ) )
102
- add_filter('wp-hide/ob_start_callback', array('WPH_conflict_handle_wp_rocket', 'save_correct_cache') , 999);
103
 
104
  return $buffer;
105
 
106
  }
107
-
108
-
109
- static public function save_correct_cache( $buffer )
110
- {
111
- global $request_uri_path, $rocket_cache_filepath, $is_nginx;
112
-
113
-
114
- // Create cache folders of the request uri.
115
- rocket_mkdir_p( $request_uri_path );
116
-
117
- $footprint = '';
118
-
119
- // Save the cache file.
120
- rocket_put_content( $rocket_cache_filepath, $buffer . $footprint );
121
-
122
- if ( get_rocket_option( 'do_caching_mobile_files' ) ) {
123
- if ( $is_nginx ) {
124
- // Create a hidden empty file for mobile detection on NGINX with the Rocket NGINX configuration.
125
- $nginx_mobile_detect_file = $request_uri_path . '/.mobile-active';
126
-
127
- if ( ! rocket_direct_filesystem()->exists( $nginx_mobile_detect_file ) ) {
128
- rocket_direct_filesystem()->touch( $nginx_mobile_detect_file );
129
- }
130
- }
131
- }
132
-
133
- if ( function_exists( 'gzencode' ) ) {
134
- rocket_put_content( $rocket_cache_filepath . '_gzip', gzencode( $buffer . $footprint, apply_filters( 'rocket_gzencode_level_compression', 3 ) ) );
135
- }
136
-
137
- // Send headers with the last modified time of the cache file.
138
- /*
139
- if ( file_exists( $rocket_cache_filepath ) ) {
140
- header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s', filemtime( $rocket_cache_filepath ) ) . ' GMT' );
141
- }
142
- */
143
-
144
- return $buffer;
145
-
146
- }
147
 
148
  }
149
 
9
  if( ! self::is_plugin_active())
10
  return FALSE;
11
 
12
+ //add_action('wp', array('WPH_conflict_handle_wp_rocket', 'wpcache') , -1);
13
+ add_filter( 'wp-hide/ignore_ob_start_callback', array( 'WPH_conflict_handle_wp_rocket', 'ignore_ob_start_callback'));
14
+ add_filter( 'rocket_buffer', array( 'WPH_conflict_handle_wp_rocket', 'rocket_buffer'), 999 );
15
+
16
  }
17
 
18
  static function is_plugin_active()
25
  else
26
  return FALSE;
27
  }
28
+
29
+
30
+ static function ignore_ob_start_callback( $do_ignore )
31
+ {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
 
33
+ return TRUE;
34
  }
35
+
36
+ static function rocket_buffer( $buffer )
 
 
 
 
37
  {
38
 
39
+ //remove the filter to allow the buffer processing
40
+ remove_filter( 'wp-hide/ignore_ob_start_callback', array( 'WPH_conflict_handle_wp_rocket', 'ignore_ob_start_callback'));
41
+
42
  global $wph;
43
 
44
+ $buffer = $wph->ob_start_callback( $buffer );
 
45
 
46
  return $buffer;
47
 
48
  }
49
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
 
51
  }
52
 
include/functions.class.php CHANGED
@@ -24,7 +24,13 @@
24
  'default_value' => '',
25
  'sanitize_type' => array('sanitize_title'),
26
 
27
- 'callback' => '',
 
 
 
 
 
 
28
  'processing_order' => 10,
29
  );
30
 
@@ -1563,7 +1569,7 @@
1563
  function do_recovery()
1564
  {
1565
  //prevent hammering
1566
- //sleep(5);
1567
 
1568
  //feetch a new set of settings
1569
  $settings = $this->get_settings();
24
  'default_value' => '',
25
  'sanitize_type' => array('sanitize_title'),
26
 
27
+ //callback function when components run. Default being set for _init_{$field_id}
28
+ 'callback' => '',
29
+ //callback function to return the rewrite code, Default being set for _callback_saved_{$field_id}
30
+ 'callback_saved' => '',
31
+ //PassThrough any additional arguments
32
+ 'callback_arguments' => array(),
33
+
34
  'processing_order' => 10,
35
  );
36
 
1569
  function do_recovery()
1570
  {
1571
  //prevent hammering
1572
+ sleep(5);
1573
 
1574
  //feetch a new set of settings
1575
  $settings = $this->get_settings();
include/wph.class.php CHANGED
@@ -246,12 +246,13 @@
246
  //ignore callbacks if permalink is turned OFF
247
  if($this->functions->is_permalink_enabled())
248
  {
249
- $_callback = isset($module_setting['callback']) ? $module_setting['callback'] : '';
 
250
  if(empty($_callback))
251
  $_callback = '_init_' . $field_id;
252
 
253
  if (method_exists($_class_instance, $_callback) && is_callable(array($_class_instance, $_callback)))
254
- $processing_data[] = call_user_func(array($_class_instance, $_callback), $saved_field_value);
255
  }
256
 
257
  //action available for mu-plugins
@@ -261,6 +262,24 @@
261
  }
262
 
263
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
264
 
265
 
266
 
@@ -490,6 +509,10 @@
490
  if($this->disable_ob_start_callback === TRUE)
491
  return $buffer;
492
 
 
 
 
 
493
  //check headers fir content-encoding
494
  if(function_exists('apache_response_headers'))
495
  {
246
  //ignore callbacks if permalink is turned OFF
247
  if($this->functions->is_permalink_enabled())
248
  {
249
+ $_callback = isset($module_setting['callback']) ? $module_setting['callback'] : '';
250
+ $_callback_arguments = isset($module_setting['callback_arguments']) ? $module_setting['callback_arguments'] : '';
251
  if(empty($_callback))
252
  $_callback = '_init_' . $field_id;
253
 
254
  if (method_exists($_class_instance, $_callback) && is_callable(array($_class_instance, $_callback)))
255
+ $processing_data[] = $this->_run_component_callback( $_callback, $_callback_arguments, $_class_instance, $saved_field_value );
256
  }
257
 
258
  //action available for mu-plugins
262
  }
263
 
264
  }
265
+
266
+
267
+
268
+ /**
269
+ * Retrieve the rewrite results from component
270
+ *
271
+ */
272
+ private function _run_component_callback( $_callback, $_callback_arguments, $_class_instance, $saved_field_value)
273
+ {
274
+
275
+ if ( ! empty($_callback_arguments) && is_array($_callback_arguments) && count($_callback_arguments) > 0 )
276
+ $module_processing_data = call_user_func_array( array($_class_instance, $_callback), array_merge( array( 'field_value' => $saved_field_value), $_callback_arguments));
277
+ else
278
+ $module_processing_data = call_user_func(array($_class_instance, $_callback), $saved_field_value);
279
+
280
+ return $module_processing_data;
281
+
282
+ }
283
 
284
 
285
 
509
  if($this->disable_ob_start_callback === TRUE)
510
  return $buffer;
511
 
512
+ //provide a filter to disable the replacements
513
+ if ( apply_filters('wp-hide/ignore_ob_start_callback', FALSE) === TRUE )
514
+ return $buffer;
515
+
516
  //check headers fir content-encoding
517
  if(function_exists('apache_response_headers'))
518
  {
modules/components/general-admin-bar.php ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
4
+
5
+ class WPH_module_general_admin_bar extends WPH_module_component
6
+ {
7
+
8
+ var $_initialized = FALSE;
9
+
10
+ function get_component_title()
11
+ {
12
+ return "Admin Bar";
13
+ }
14
+
15
+
16
+ function get_module_settings()
17
+ {
18
+
19
+ $wp_roles = wp_roles();
20
+
21
+ foreach ( $wp_roles->roles as $role_slug => $role )
22
+ {
23
+
24
+ $this->module_settings[] = $this->_prepare_modle_setting( $role_slug, $role['name'] );
25
+
26
+ }
27
+
28
+ return $this->module_settings;
29
+ }
30
+
31
+
32
+ function _prepare_modle_setting( $role_slug, $role_name )
33
+ {
34
+
35
+ $module_setting = array(
36
+ 'id' => 'remove_admin_bar_' . $role_slug,
37
+ 'label' => __('Remove Admin Bar for ', 'wp-hide-security-enhancer') . $role_name,
38
+ 'description' => __('Remove WordPress Admin Bar for ', 'wp-hide-security-enhancer') . $role_name . ' ' . __('role, which is being displayed by default on front side of your website.', 'wp-hide-security-enhancer'),
39
+
40
+ 'input_type' => 'radio',
41
+ 'options' => array(
42
+ 'yes' => __('Yes', 'wp-hide-security-enhancer'),
43
+ 'no' => __('No', 'wp-hide-security-enhancer'),
44
+ ),
45
+ 'default_value' => 'no',
46
+
47
+ 'sanitize_type' => array('sanitize_title', 'strtolower'),
48
+
49
+ 'callback' => '_init_remove_admin_bar',
50
+ 'callback_arguments' => array('role_slug' => $role_slug ),
51
+
52
+ );
53
+
54
+ return $module_setting;
55
+ }
56
+
57
+
58
+
59
+ function _init_remove_admin_bar( $saved_field_data, $role )
60
+ {
61
+ if(empty($saved_field_data) || $saved_field_data == 'no')
62
+ return FALSE;
63
+
64
+ //trigger once
65
+ if ( $this->_initialized )
66
+ return;
67
+
68
+ $this->_initialized = TRUE;
69
+
70
+ add_action('init', array($this, 'remove_admin_bar'));
71
+ }
72
+
73
+
74
+ function remove_admin_bar()
75
+ {
76
+ if ( is_user_logged_in() === FALSE )
77
+ return;
78
+
79
+ $current_user = wp_get_current_user();
80
+ $user_role = isset( $current_user->roles[0] ) ? $current_user->roles[0] : '';
81
+ if ( empty ( $user_role ))
82
+ return;
83
+
84
+ $role_hide_admin_bar = $this->wph->functions->get_module_item_setting('remove_admin_bar_' . $user_role );
85
+ if( $role_hide_admin_bar != 'yes')
86
+ return;
87
+
88
+ add_filter('show_admin_bar', '__return_false');
89
+
90
+ }
91
+
92
+
93
+
94
+
95
+ }
96
+
97
+ ?>
modules/components/rewrite-search.php CHANGED
@@ -52,6 +52,8 @@
52
 
53
  if(empty($saved_field_data))
54
  return FALSE;
 
 
55
 
56
  //add default plugin path replacement
57
  $url = trailingslashit( site_url() ) . 'search';
@@ -93,5 +95,21 @@
93
  }
94
 
95
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  }
97
  ?>
52
 
53
  if(empty($saved_field_data))
54
  return FALSE;
55
+
56
+ add_action( 'template_redirect', array( $this, 'template_redirect' ), -1);
57
 
58
  //add default plugin path replacement
59
  $url = trailingslashit( site_url() ) . 'search';
95
  }
96
 
97
 
98
+ /**
99
+ * Redirect to new slug url
100
+ *
101
+ */
102
+ function template_redirect()
103
+ {
104
+ if ( is_search() && ! empty( $_GET['s'] ) )
105
+ {
106
+ $new_search_path = $this->wph->functions->get_module_item_setting('search');
107
+
108
+ wp_redirect( home_url( "/" . $new_search_path . "/" ) . urlencode( get_query_var( 's' ) ) );
109
+ exit();
110
+ }
111
+ }
112
+
113
+
114
  }
115
  ?>
modules/module-general.php CHANGED
@@ -12,6 +12,9 @@
12
  include(WPH_PATH . "/modules/components/general-meta.php");
13
  $this->components[] = new WPH_module_general_meta();
14
 
 
 
 
15
  include(WPH_PATH . "/modules/components/general-feed.php");
16
  $this->components[] = new WPH_module_general_feed();
17
 
12
  include(WPH_PATH . "/modules/components/general-meta.php");
13
  $this->components[] = new WPH_module_general_meta();
14
 
15
+ include(WPH_PATH . "/modules/components/general-admin-bar.php");
16
+ $this->components[] = new WPH_module_general_admin_bar();
17
+
18
  include(WPH_PATH . "/modules/components/general-feed.php");
19
  $this->components[] = new WPH_module_general_feed();
20
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.nsp-code.com/
4
  Tags: wordpress hide, hide, security, improve security, hacking, wp hide, custom login, wp-loging.php, wp-admin, admin hide, login change,
5
  Requires at least: 2.8
6
  Tested up to: 5.0.3
7
- Stable tag: 1.5.5
8
  License: GPLv2 or later
9
 
10
  Hide and increase Security for your WordPress site instance using smart techniques. No files are changed on your server.
@@ -172,6 +172,10 @@ Since version 1.2 Change individual plugin urls which make them unrecognizable,
172
  * Remove profile link
173
  * Remove canonical link
174
 
 
 
 
 
175
  **General / Feed**
176
 
177
  * Remove feed|rdf|rss|rss2|atom links
@@ -281,6 +285,12 @@ Please get in touch with us and we'll do our best to include it for a next versi
281
 
282
  == Changelog ==
283
 
 
 
 
 
 
 
284
  = 1.5.5 =
285
  * New component: Rewrite Author
286
  * New component: Rewrite Search
4
  Tags: wordpress hide, hide, security, improve security, hacking, wp hide, custom login, wp-loging.php, wp-admin, admin hide, login change,
5
  Requires at least: 2.8
6
  Tested up to: 5.0.3
7
+ Stable tag: 1.5.5.4
8
  License: GPLv2 or later
9
 
10
  Hide and increase Security for your WordPress site instance using smart techniques. No files are changed on your server.
172
  * Remove profile link
173
  * Remove canonical link
174
 
175
+ **General / Html > Admin Bar**
176
+
177
+ * Remove WordPress Admin Bar for specified urser roles
178
+
179
  **General / Feed**
180
 
181
  * Remove feed|rdf|rss|rss2|atom links
285
 
286
  == Changelog ==
287
 
288
+ = 1.5.5.4 =
289
+ * Fix Wp Rocket cache when using Minify and Concatenation
290
+ * New functionality - Remove Admin Bar for specified roles
291
+ * Module block structure extend to support 'callback_arguments' to passThrough additional data to processing function
292
+ * Redirect the default non-pretty-url search url to customized one
293
+
294
  = 1.5.5 =
295
  * New component: Rewrite Author
296
  * New component: Rewrite Search
router/environment.php CHANGED
@@ -1,2 +1,2 @@
1
  <?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
- $environment_variable = '{"theme":{"folder_name":"twentysixteen","mapped_name":""},"allowed_paths":["F:\/htdocs\/wp-hide.dev\/wp-content\/themes"],"cache_path":"F:\/htdocs\/wp-hide.dev\/wp-content\/cache\/wph\/","wordpress_directory":"","site_relative_path":"\/"}' ?>
1
  <?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
+ $environment_variable = '{"theme":{"folder_name":"twentysixteen","mapped_name":"eereer"},"allowed_paths":["F:\/htdocs\/wp-hide.dev\/wp-content\/themes"],"cache_path":"F:\/htdocs\/wp-hide.dev\/wp-content\/cache\/wph\/","wordpress_directory":"","site_relative_path":"\/"}' ?>
wp-hide.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: https://www.wp-hide.com/
5
  Description: Hide and increase Security for your WordPress website instance using smart techniques. No files are changed on your server.
6
  Author: Nsp Code
7
  Author URI: http://www.nsp-code.com
8
- Version: 1.5.5
9
  Text Domain: wp-hide-security-enhancer
10
  Domain Path: /languages/
11
  */
5
  Description: Hide and increase Security for your WordPress website instance using smart techniques. No files are changed on your server.
6
  Author: Nsp Code
7
  Author URI: http://www.nsp-code.com
8
+ Version: 1.5.5.4
9
  Text Domain: wp-hide-security-enhancer
10
  Domain Path: /languages/
11
  */