Version Description
- Initial release.
=
Download this release
Release Info
Developer | nsp-code |
Plugin | WP Hide & Security Enhancer |
Version | 1.0 |
Comparing to | |
See all releases |
Version 1.0
- css/wph.css +52 -0
- images/admin-icon-settings.gif +0 -0
- images/sprite.png +0 -0
- include/admin-interface.class.php +162 -0
- include/functions.class.php +365 -0
- include/module.class.php +26 -0
- include/wph.class.php +474 -0
- languages/wp-hide.mo +0 -0
- languages/wp-hide.po +99 -0
- modules/module-admin.php +357 -0
- modules/module-general.php +234 -0
- modules/module-rewrite.php +685 -0
- readme.txt +83 -0
- screenshot-1.png +0 -0
- screenshot-2.png +0 -0
- wp-hide.php +53 -0
css/wph.css
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#wph h2.nav-tab-wrapper{padding-left: 10px}
|
2 |
+
#wph h2 .nav-tab {font-size: 12px; font-weight: bold; padding: 2px 10px 3px; margin-right: 0;}
|
3 |
+
#wph .ajax_loading {display: none}
|
4 |
+
#wph .postbox .inside { margin: 0; padding: 0;}
|
5 |
+
#wph h3.handle {border-bottom: 1px solid #e1e1e1; font-size: 14px; line-height: 1.4; margin: 0; padding: 8px 12px;}
|
6 |
+
#wph .postbox {margin-bottom: 0px}
|
7 |
+
#wph .wph_input fieldset label {padding-bottom: 5px; display: block;}
|
8 |
+
|
9 |
+
|
10 |
+
table.wph_input { border: 0 none; background: #fff;}
|
11 |
+
table.wph_input tbody tr td { padding: 10px 12px; border-top: 1px solid #f5f5f5; border-bottom: 0 none; width: 100%;box-sizing: border-box;}
|
12 |
+
table.wph_input tbody tr td.np {padding: 0px}
|
13 |
+
table.wph_input tbody tr:first-child td,
|
14 |
+
table.wph_input tbody tr:first-child td.label { border-top: 0 none;}
|
15 |
+
table.wph_input tbody tr td.data { padding-bottom: 20px;}
|
16 |
+
table.wph_input tbody tr td.data p.description {font-size: 14px}
|
17 |
+
|
18 |
+
table.inner_table tbody tr td {padding-bottom: 12px}
|
19 |
+
.inner_table .description {margin-bottom: 3px; font-style: normal;}
|
20 |
+
table .submit .submitdelete {line-height: 25px; text-align: left; vertical-align: middle;border-bottom-color: red; color: red; border-bottom-style: solid; border-bottom-width: 1px;padding: 1px 2px; text-decoration: none; margin-right: 20px}
|
21 |
+
table .submit .submitdelete:hover {color:#FFF; background-color: red; border-color: red}
|
22 |
+
table.wph_input tbody tr td.label { width: 25%; vertical-align: top; background: #F9F9F9; border-top: 1px solid #f0f0f0; border-right: none}
|
23 |
+
table.apto_rules tbody tr td{border-top: 0 none;}
|
24 |
+
table.wph_input img {vertical-align: middle;}
|
25 |
+
table.even_table tr td {background-color:#FCFCFC}
|
26 |
+
table.wph_input hr {border:1px dotted #E1E1E1; float: left; margin-left: 15px; width: 90%; border-style:none none dotted; color:#FFF; background:#FFF;}
|
27 |
+
table table.wph_input tr td{}
|
28 |
+
table.wph_input tbody tr td.param {width: 50%}
|
29 |
+
.conditional_rules table.wph_input td.param{width: 40%}
|
30 |
+
.conditional_rules table.wph_input td.comparison{width: 12%}
|
31 |
+
|
32 |
+
table .select.multiple {height: 82px}
|
33 |
+
table.wph_input tbody tr td h4 {margin: 0px; padding-bottom: 6px}
|
34 |
+
table.wph_input tbody tr td h5 {font-size: 12px; font-weight: normal; margin: 0; padding-bottom: 6px; padding-top: 10px;}
|
35 |
+
table.wph_input tbody tr td.label label{ display: block; font-size: 13px; font-weight: bold; padding: 0; margin: 0; color: #333; }
|
36 |
+
table.wph_input tbody tr td.label p{ display: block; font-size: 12px; padding: 6px 0 !important; margin: 0 !important; font-style: normal; line-height: 16px; color: #AAA;}
|
37 |
+
table.wph_input tbody tr td.label p .important {color: red}
|
38 |
+
table.wph_input tbody tr.submit td {background-color: #F9F9F9; text-align: right}
|
39 |
+
table.wph_input tbody tr.submit td.label {border-right: 1px solid #F9F9F9}
|
40 |
+
table.wph_input input[type=text],table.wph_input textarea,table.wph_input select{ width: 99.95%; outline: none;}
|
41 |
+
table.wph_input select { padding: 2px;}
|
42 |
+
table.wph_input input[type=text]:focus,table.wph_input textarea:focus,table.wph_input select:focus { border-color:#98B6CB;}
|
43 |
+
|
44 |
+
.postbox h3 span {display: inline-block; vertical-align: middle}
|
45 |
+
|
46 |
+
.postbox .icon {width: 20px; height: 18px; background-image:url("../images/sprite.png");background-repeat:no-repeat; margin-right: 10px}
|
47 |
+
.postbox .icon.settings {background-position: -10px -44px;}
|
48 |
+
|
49 |
+
|
50 |
+
#icon-settings {background-image:url("../images/admin-icon-settings.gif");background-repeat:no-repeat;}
|
51 |
+
h2.subtitle {font-size: 15px; font-style: italic; font-weight: bold}
|
52 |
+
.wrap .example { color: #666666; font-size: 11px; font-weight: bold}
|
images/admin-icon-settings.gif
ADDED
Binary file
|
images/sprite.png
ADDED
Binary file
|
include/admin-interface.class.php
ADDED
@@ -0,0 +1,162 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class WPH_interface
|
5 |
+
{
|
6 |
+
var $screen_slug;
|
7 |
+
var $module;
|
8 |
+
var $module_settings;
|
9 |
+
var $interface_data;
|
10 |
+
|
11 |
+
var $wph;
|
12 |
+
var $functions;
|
13 |
+
|
14 |
+
function __construct()
|
15 |
+
{
|
16 |
+
global $wph;
|
17 |
+
$this->wph = &$wph;
|
18 |
+
|
19 |
+
$this->functions = new WPH_functions();
|
20 |
+
|
21 |
+
}
|
22 |
+
|
23 |
+
function __destruct()
|
24 |
+
{
|
25 |
+
|
26 |
+
}
|
27 |
+
|
28 |
+
function _render($interface_name)
|
29 |
+
{
|
30 |
+
|
31 |
+
$this->screen_slug = $_GET['page'];
|
32 |
+
|
33 |
+
//identify the module by slug
|
34 |
+
$this->module = $this->functions->get_module_by_slug($this->screen_slug);
|
35 |
+
|
36 |
+
$this->_load_interface_data();
|
37 |
+
|
38 |
+
$this->_generate_interface_html();
|
39 |
+
|
40 |
+
}
|
41 |
+
|
42 |
+
function _load_interface_data()
|
43 |
+
{
|
44 |
+
$this->module_settings = $this->functions->filter_settings( $this->module->get_module_settings() );
|
45 |
+
$this->interface_data = $this->module->get_interface_data();
|
46 |
+
}
|
47 |
+
|
48 |
+
function _generate_interface_html()
|
49 |
+
{
|
50 |
+
|
51 |
+
?>
|
52 |
+
<div id="wph" class="wrap">
|
53 |
+
<h1><?php echo $this->interface_data['title'] ?></h1>
|
54 |
+
|
55 |
+
<div id="poststuff">
|
56 |
+
<div class="postbox">
|
57 |
+
<h3 class="handle"><?php echo $this->interface_data['handle_title'] ?></h3>
|
58 |
+
</div>
|
59 |
+
|
60 |
+
<div class="inside">
|
61 |
+
|
62 |
+
<form method="post" action="">
|
63 |
+
<?php wp_nonce_field( 'wph/interface_fields', 'wph-interface-nonce' ); ?>
|
64 |
+
|
65 |
+
<?php
|
66 |
+
|
67 |
+
$module_id = $this->module->get_module_id();
|
68 |
+
foreach($this->module_settings as $module_setting)
|
69 |
+
{
|
70 |
+
if(isset($module_setting['type']) && $module_setting['type'] == 'split')
|
71 |
+
{
|
72 |
+
?>
|
73 |
+
<p> </p>
|
74 |
+
<?php
|
75 |
+
|
76 |
+
continue;
|
77 |
+
}
|
78 |
+
|
79 |
+
?>
|
80 |
+
<div class="postbox">
|
81 |
+
<table class="wph_input widefat">
|
82 |
+
<tbody>
|
83 |
+
|
84 |
+
<tr>
|
85 |
+
<td class="label">
|
86 |
+
<label for=""><?php echo $module_setting['label'] ?></label>
|
87 |
+
<p class="description"><?php echo nl2br($module_setting['description']) ?></p>
|
88 |
+
</td>
|
89 |
+
</tr>
|
90 |
+
<tr>
|
91 |
+
<td class="data">
|
92 |
+
<?php if(!empty($module_setting['value_description'])) { ?><p class="description"><?php echo $module_setting['value_description'] ?></p><?php } ?>
|
93 |
+
<?php
|
94 |
+
|
95 |
+
$option_name = $this->module->get_module_id() . '_' . $module_setting['id'];
|
96 |
+
$value = $this->wph->get_setting_value( $option_name, $module_setting['default_value']);
|
97 |
+
|
98 |
+
switch($module_setting['input_type'])
|
99 |
+
{
|
100 |
+
case 'text' :
|
101 |
+
$class = 'text';
|
102 |
+
|
103 |
+
?><input name="<?php echo $module_setting['id'] ?>" class="<?php echo $class ?>" value="<?php echo $value ?>" placeholder="<?php echo $module_setting['placeholder'] ?>" type="text"><?php
|
104 |
+
|
105 |
+
break;
|
106 |
+
|
107 |
+
case 'radio' :
|
108 |
+
$class = 'radio';
|
109 |
+
|
110 |
+
?>
|
111 |
+
<fieldset>
|
112 |
+
<?php
|
113 |
+
|
114 |
+
foreach($module_setting['options'] as $option_value => $option_title)
|
115 |
+
{
|
116 |
+
?><label><input type="radio" class="<?php echo $class ?>" <?php checked($value, $option_value) ?> value="<?php echo $option_value ?>" name="<?php echo $module_setting['id'] ?>"> <span><?php echo $option_title ?></span></label><?php
|
117 |
+
}
|
118 |
+
|
119 |
+
?>
|
120 |
+
</fieldset>
|
121 |
+
<?php
|
122 |
+
|
123 |
+
break;
|
124 |
+
}
|
125 |
+
|
126 |
+
?>
|
127 |
+
</td>
|
128 |
+
</tr>
|
129 |
+
</tbody>
|
130 |
+
</table>
|
131 |
+
</div>
|
132 |
+
|
133 |
+
<?php
|
134 |
+
}
|
135 |
+
|
136 |
+
|
137 |
+
?>
|
138 |
+
|
139 |
+
<table class="wph_input widefat">
|
140 |
+
<tbody>
|
141 |
+
<tr class="submit">
|
142 |
+
<td class="label"> </td>
|
143 |
+
<td>
|
144 |
+
<input type="submit" value="Save" class="button-primary alignright">
|
145 |
+
</td>
|
146 |
+
</tr>
|
147 |
+
|
148 |
+
</tbody>
|
149 |
+
</table>
|
150 |
+
</form>
|
151 |
+
</div>
|
152 |
+
|
153 |
+
</div>
|
154 |
+
</div>
|
155 |
+
|
156 |
+
<?php
|
157 |
+
|
158 |
+
}
|
159 |
+
}
|
160 |
+
|
161 |
+
|
162 |
+
?>
|
include/functions.class.php
ADDED
@@ -0,0 +1,365 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class WPH_functions
|
5 |
+
{
|
6 |
+
var $wph;
|
7 |
+
|
8 |
+
function __construct()
|
9 |
+
{
|
10 |
+
global $wph;
|
11 |
+
$this->wph = &$wph;
|
12 |
+
}
|
13 |
+
|
14 |
+
function __destruct()
|
15 |
+
{
|
16 |
+
|
17 |
+
}
|
18 |
+
|
19 |
+
function filter_settings($module_settings)
|
20 |
+
{
|
21 |
+
if(!is_array($module_settings) || count($module_settings) < 1)
|
22 |
+
return $module_settings;
|
23 |
+
|
24 |
+
$defaults = array (
|
25 |
+
'id' => '',
|
26 |
+
'label' => '',
|
27 |
+
'description' => '',
|
28 |
+
'value_description' => '',
|
29 |
+
'input_type' => 'text',
|
30 |
+
'default_value' => '',
|
31 |
+
'sanitize_type' => array('sanitize_title')
|
32 |
+
);
|
33 |
+
|
34 |
+
foreach($module_settings as $key => $module_setting)
|
35 |
+
{
|
36 |
+
$module_setting = wp_parse_args( $module_setting, $defaults );
|
37 |
+
|
38 |
+
switch($module_setting['input_type'])
|
39 |
+
{
|
40 |
+
case 'text' :
|
41 |
+
$defaults_type = array (
|
42 |
+
'placeholder' => '',
|
43 |
+
);
|
44 |
+
$module_setting = wp_parse_args( $module_setting, $defaults_type );
|
45 |
+
|
46 |
+
break;
|
47 |
+
|
48 |
+
|
49 |
+
}
|
50 |
+
|
51 |
+
$module_settings[$key] = $module_setting;
|
52 |
+
}
|
53 |
+
|
54 |
+
return $module_settings;
|
55 |
+
|
56 |
+
}
|
57 |
+
|
58 |
+
|
59 |
+
function process_interface_save()
|
60 |
+
{
|
61 |
+
$nonce = $_POST['wph-interface-nonce'];
|
62 |
+
if ( ! wp_verify_nonce( $nonce, 'wph/interface_fields' ) )
|
63 |
+
return FALSE;
|
64 |
+
|
65 |
+
$screen_slug = $_GET['page'];
|
66 |
+
if(empty($screen_slug))
|
67 |
+
return FALSE;
|
68 |
+
|
69 |
+
$module = $this->get_module_by_slug($screen_slug);
|
70 |
+
if(!is_object($module))
|
71 |
+
return FALSE;
|
72 |
+
|
73 |
+
global $wph;
|
74 |
+
|
75 |
+
$module_id = $module->get_module_id();
|
76 |
+
|
77 |
+
//proces the fields
|
78 |
+
$module_settings = $this->filter_settings( $module->get_module_settings() );
|
79 |
+
|
80 |
+
foreach($module_settings as $module_setting)
|
81 |
+
{
|
82 |
+
$field_name = $module_setting['id'];
|
83 |
+
|
84 |
+
$value = isset($_POST[$field_name]) ? $_POST[$field_name] : '';
|
85 |
+
|
86 |
+
//sanitize value
|
87 |
+
foreach($module_setting['sanitize_type'] as $sanitize)
|
88 |
+
{
|
89 |
+
$value = call_user_func_array($sanitize, array($value));
|
90 |
+
}
|
91 |
+
|
92 |
+
//save the value
|
93 |
+
$wph->settings['module_settings'][$module_id .'_' . $field_name] = $value;
|
94 |
+
}
|
95 |
+
|
96 |
+
//update the settings
|
97 |
+
$this->update_settings($wph->settings);
|
98 |
+
|
99 |
+
//trigger the settings changed action
|
100 |
+
do_action('wph/settings_changed');
|
101 |
+
|
102 |
+
//redirect
|
103 |
+
$new_admin_url = $this->get_module_item_setting('admin_url' , 'admin');
|
104 |
+
if(!empty($new_admin_url))
|
105 |
+
$new_location = trailingslashit( site_url() ) . $new_admin_url . "/admin.php?page=" . $screen_slug;
|
106 |
+
else
|
107 |
+
$new_location = trailingslashit( site_url() ) . "wp-admin/admin.php?page=" . $screen_slug;
|
108 |
+
|
109 |
+
$new_location .= '&settings_updated=true';
|
110 |
+
|
111 |
+
wp_redirect($new_location);
|
112 |
+
}
|
113 |
+
|
114 |
+
|
115 |
+
/**
|
116 |
+
* Return the module class by it's slug
|
117 |
+
*
|
118 |
+
* @param mixed $module_slug
|
119 |
+
*/
|
120 |
+
function get_module_by_slug($module_slug)
|
121 |
+
{
|
122 |
+
global $wph;
|
123 |
+
|
124 |
+
$found_module = FALSE;
|
125 |
+
|
126 |
+
foreach($wph->modules as $module)
|
127 |
+
{
|
128 |
+
$interface_menu_data = $module->get_module_slug();
|
129 |
+
|
130 |
+
if($interface_menu_data == $module_slug)
|
131 |
+
{
|
132 |
+
$found_module = $module;
|
133 |
+
break;
|
134 |
+
}
|
135 |
+
}
|
136 |
+
|
137 |
+
return $found_module;
|
138 |
+
}
|
139 |
+
|
140 |
+
|
141 |
+
function is_permalink_enabled()
|
142 |
+
{
|
143 |
+
|
144 |
+
$permalink_structure = get_option('permalink_structure');
|
145 |
+
|
146 |
+
if ( empty($permalink_structure) )
|
147 |
+
return FALSE;
|
148 |
+
|
149 |
+
return TRUE;
|
150 |
+
|
151 |
+
}
|
152 |
+
|
153 |
+
|
154 |
+
function is_theme_customize()
|
155 |
+
{
|
156 |
+
|
157 |
+
if ( strpos($_SERVER['REQUEST_URI'] ,'customize.php') !== FALSE )
|
158 |
+
return TRUE;
|
159 |
+
|
160 |
+
if ( isset($_POST['wp_customize']) && $_POST['wp_customize'] == "on" )
|
161 |
+
return TRUE;
|
162 |
+
|
163 |
+
return FALSE;
|
164 |
+
|
165 |
+
}
|
166 |
+
|
167 |
+
|
168 |
+
/**
|
169 |
+
* return settings
|
170 |
+
*
|
171 |
+
*/
|
172 |
+
function get_settings()
|
173 |
+
{
|
174 |
+
$settings = get_option('wph_settings');
|
175 |
+
|
176 |
+
$defaults = array (
|
177 |
+
'module_settings' => array()
|
178 |
+
);
|
179 |
+
|
180 |
+
$settings = wp_parse_args( $settings, $defaults );
|
181 |
+
|
182 |
+
return $settings;
|
183 |
+
|
184 |
+
}
|
185 |
+
|
186 |
+
|
187 |
+
function get_module_item_setting($item_id, $module_id)
|
188 |
+
{
|
189 |
+
|
190 |
+
$settings = $this->get_settings();
|
191 |
+
|
192 |
+
$value = isset($settings['module_settings'][ $module_id . '_' . $item_id]) ? $settings['module_settings'][ $module_id . '_' . $item_id] : '';
|
193 |
+
|
194 |
+
return $value;
|
195 |
+
|
196 |
+
}
|
197 |
+
|
198 |
+
|
199 |
+
/**
|
200 |
+
* Save the settings
|
201 |
+
*
|
202 |
+
* @param mixed $settings
|
203 |
+
*/
|
204 |
+
function update_settings($settings)
|
205 |
+
{
|
206 |
+
update_option('wph_settings', $settings);
|
207 |
+
}
|
208 |
+
|
209 |
+
|
210 |
+
function get_url_path($url, $is_file_path = FALSE)
|
211 |
+
{
|
212 |
+
if(!$is_file_path)
|
213 |
+
$url = trailingslashit( $url );
|
214 |
+
|
215 |
+
$url_parse = parse_url( $url );
|
216 |
+
|
217 |
+
/*
|
218 |
+
$root = isset($url_parse['scheme']) ? $url_parse['scheme'] . '://' : '';
|
219 |
+
$root .= isset($url_parse['host']) ? $url_parse['host'] : '';
|
220 |
+
*/
|
221 |
+
|
222 |
+
$path = $url_parse['path'];
|
223 |
+
|
224 |
+
if(!$is_file_path)
|
225 |
+
$path = trailingslashit( $path );
|
226 |
+
|
227 |
+
if($path != '/' && strlen($path) > 1)
|
228 |
+
{
|
229 |
+
$path = ltrim($path, '/');
|
230 |
+
$path = '/' . $path;
|
231 |
+
}
|
232 |
+
|
233 |
+
if(isset($url_parse['query']))
|
234 |
+
$path .= '?' . $url_parse['query'];
|
235 |
+
|
236 |
+
return $path;
|
237 |
+
|
238 |
+
}
|
239 |
+
|
240 |
+
function untrailingslashit_all($value)
|
241 |
+
{
|
242 |
+
$value = ltrim(rtrim($value, "/"), "/");
|
243 |
+
|
244 |
+
return $value;
|
245 |
+
}
|
246 |
+
|
247 |
+
function sanitize_file_path_name($value)
|
248 |
+
{
|
249 |
+
$value = trim($value);
|
250 |
+
|
251 |
+
if(empty($value))
|
252 |
+
return $value;
|
253 |
+
|
254 |
+
$parts = explode("/", $value);
|
255 |
+
$parts = array_filter($parts);
|
256 |
+
|
257 |
+
foreach($parts as $key => $part_item)
|
258 |
+
{
|
259 |
+
$parts[$key] = sanitize_file_name($part_item);
|
260 |
+
}
|
261 |
+
|
262 |
+
$value = implode("/", $parts);
|
263 |
+
|
264 |
+
$value = strtolower($value);
|
265 |
+
|
266 |
+
return $value;
|
267 |
+
}
|
268 |
+
|
269 |
+
|
270 |
+
function get_current_url()
|
271 |
+
{
|
272 |
+
|
273 |
+
$current_url = 'http' . (isset($_SERVER['HTTPS']) ? 's' : '') . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
|
274 |
+
|
275 |
+
return $current_url;
|
276 |
+
|
277 |
+
}
|
278 |
+
|
279 |
+
|
280 |
+
function text_urls_replacement($text, $replacements)
|
281 |
+
{
|
282 |
+
//process the replacements
|
283 |
+
if( count($replacements) < 1)
|
284 |
+
return $text;
|
285 |
+
|
286 |
+
//exclude scheme to match urls without it
|
287 |
+
$_replacements = array();
|
288 |
+
foreach($replacements as $old_url => $new_url)
|
289 |
+
{
|
290 |
+
$old_url = str_ireplace( array('http://', 'https://'), "", $old_url);
|
291 |
+
$new_url = str_ireplace( array('http://', 'https://'), "", $new_url);
|
292 |
+
|
293 |
+
$_replacements[$old_url] = $new_url;
|
294 |
+
}
|
295 |
+
|
296 |
+
$replacements = $_replacements;
|
297 |
+
unset($_replacements);
|
298 |
+
|
299 |
+
$text = str_ireplace( array_keys($replacements), array_values($replacements) ,$text );
|
300 |
+
|
301 |
+
//check for json encode
|
302 |
+
foreach($replacements as $old_url => $new_url)
|
303 |
+
{
|
304 |
+
$old_url = trim(json_encode($old_url), '"');
|
305 |
+
$new_url = trim(json_encode($new_url), '"');
|
306 |
+
|
307 |
+
$text = str_ireplace( $old_url, $new_url ,$text );
|
308 |
+
}
|
309 |
+
|
310 |
+
return $text;
|
311 |
+
}
|
312 |
+
|
313 |
+
|
314 |
+
function default_scripts_styles_replace($object, $replacements)
|
315 |
+
{
|
316 |
+
//update default dirs
|
317 |
+
if(isset($object->default_dirs))
|
318 |
+
{
|
319 |
+
foreach($object->default_dirs as $key => $value)
|
320 |
+
{
|
321 |
+
$object->default_dirs[$key] = str_replace(array_keys($replacements), array_values($replacements), $value);
|
322 |
+
}
|
323 |
+
}
|
324 |
+
|
325 |
+
foreach($object->registered as $script_name => $script_data)
|
326 |
+
{
|
327 |
+
$script_data->src = str_replace(array_keys($replacements), array_values($replacements), $script_data->src);
|
328 |
+
|
329 |
+
$object->registered[$script_name] = $script_data;
|
330 |
+
}
|
331 |
+
|
332 |
+
return $object;
|
333 |
+
}
|
334 |
+
|
335 |
+
|
336 |
+
function check_headers_content_type($header_name, $header_value)
|
337 |
+
{
|
338 |
+
|
339 |
+
$headers = headers_list();
|
340 |
+
|
341 |
+
foreach($headers as $header)
|
342 |
+
{
|
343 |
+
if(stripos($header, $header_name) !== FALSE)
|
344 |
+
{
|
345 |
+
if(stripos($header, $header_value) !== FALSE)
|
346 |
+
return TRUE;
|
347 |
+
}
|
348 |
+
}
|
349 |
+
|
350 |
+
|
351 |
+
return FALSE;
|
352 |
+
|
353 |
+
}
|
354 |
+
|
355 |
+
function is_other_template($template)
|
356 |
+
{
|
357 |
+
if($this->wph->templates_data['main']['folder_name'] == $template || $this->wph->templates_data['child']['folder_name'] == $template)
|
358 |
+
return FALSE;
|
359 |
+
|
360 |
+
return TRUE;
|
361 |
+
}
|
362 |
+
|
363 |
+
}
|
364 |
+
|
365 |
+
?>
|
include/module.class.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class WPH_module
|
5 |
+
{
|
6 |
+
var $functions;
|
7 |
+
var $wph;
|
8 |
+
|
9 |
+
function __construct()
|
10 |
+
{
|
11 |
+
$this->functions = new WPH_functions();
|
12 |
+
|
13 |
+
global $wph;
|
14 |
+
$this->wph = &$wph;
|
15 |
+
}
|
16 |
+
|
17 |
+
function __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+
class WPH
|
5 |
+
{
|
6 |
+
var $default_variables = array();
|
7 |
+
var $templates_data = array();
|
8 |
+
var $urls_replacement = array();
|
9 |
+
|
10 |
+
var $modules = array();
|
11 |
+
|
12 |
+
var $settings;
|
13 |
+
|
14 |
+
var $functions;
|
15 |
+
|
16 |
+
var $disable_filters = FALSE;
|
17 |
+
var $doing_interface_save = FALSE;
|
18 |
+
var $uninstall = FALSE;
|
19 |
+
|
20 |
+
var $is_initialised = FALSE;
|
21 |
+
|
22 |
+
function __construct()
|
23 |
+
{
|
24 |
+
|
25 |
+
}
|
26 |
+
|
27 |
+
function __destruct()
|
28 |
+
{
|
29 |
+
|
30 |
+
}
|
31 |
+
|
32 |
+
|
33 |
+
function init()
|
34 |
+
{
|
35 |
+
$this->functions = new WPH_functions();
|
36 |
+
|
37 |
+
$this->settings = $this->functions->get_settings();
|
38 |
+
|
39 |
+
//check for interface submit
|
40 |
+
if(is_admin() && isset($_POST['wph-interface-nonce']))
|
41 |
+
{
|
42 |
+
$this->doing_interface_save = TRUE;
|
43 |
+
$this->disable_filters = TRUE;
|
44 |
+
}
|
45 |
+
|
46 |
+
$this->get_default_variables();
|
47 |
+
|
48 |
+
$this->_load_modules();
|
49 |
+
|
50 |
+
add_action('plugins_loaded', array($this, 'session_ob_start') , -1);
|
51 |
+
|
52 |
+
//process redirects
|
53 |
+
add_action('wp_redirect', array($this, 'wp_redirect') , 999, 2);
|
54 |
+
//hijack a redirect on permalink change
|
55 |
+
add_action('admin_head', array($this, 'permalink_change_redirect') , 999, 2);
|
56 |
+
|
57 |
+
add_action('logout_redirect', array($this, 'logout_redirect') , 999, 3);
|
58 |
+
|
59 |
+
//wp_default_styles
|
60 |
+
//add_filter('style_loader_src', array( $this, 'style_loader_src' ), 999, 2);
|
61 |
+
|
62 |
+
add_action('wp', array($this, '_action_wp'));
|
63 |
+
|
64 |
+
add_action('admin_menu', array($this, 'admin_menus'));
|
65 |
+
add_action('admin_init', array($this, 'admin_init'), 11);
|
66 |
+
|
67 |
+
add_action('admin_print_styles' , array($this, 'admin_print_styles'));
|
68 |
+
|
69 |
+
//rebuild and change uppon settings modified
|
70 |
+
add_action('wph/settings_changed', array($this, 'settings_changed'));
|
71 |
+
add_filter('mod_rewrite_rules', array($this, 'mod_rewrite_rules'));
|
72 |
+
|
73 |
+
//on switch theme
|
74 |
+
add_action('switch_theme', array($this, 'switch_theme'));
|
75 |
+
|
76 |
+
//admin notices
|
77 |
+
add_action( 'admin_notices', array(&$this, 'admin_notices'));
|
78 |
+
|
79 |
+
$this->is_initialised = TRUE;
|
80 |
+
}
|
81 |
+
|
82 |
+
function _load_modules()
|
83 |
+
{
|
84 |
+
$module_files = glob(WPH_PATH . "/modules/module-*.php");
|
85 |
+
|
86 |
+
foreach ($module_files as $filename)
|
87 |
+
{
|
88 |
+
$path_parts = pathinfo($filename);
|
89 |
+
|
90 |
+
include_once(WPH_PATH . '/modules/' . $path_parts['basename']);
|
91 |
+
|
92 |
+
$module_name = str_replace('module-' , '', $path_parts['filename']);
|
93 |
+
$module_class_name = 'WPH_module_' . $module_name;
|
94 |
+
$module = new $module_class_name;
|
95 |
+
|
96 |
+
//action available for MU
|
97 |
+
do_action('wp-hide/loaded_module', $module);
|
98 |
+
|
99 |
+
$interface_menu_data = $module->get_interface_menu_data();
|
100 |
+
$menu_position = $interface_menu_data['menu_position'];
|
101 |
+
|
102 |
+
$this->modules[$menu_position] = $module;
|
103 |
+
|
104 |
+
//process the module fields
|
105 |
+
$module_settings = $this->functions->filter_settings( $module->get_module_settings() );
|
106 |
+
$module_id = $module->get_module_id();
|
107 |
+
|
108 |
+
if(!$this->disable_filters && is_array($module_settings) && count($module_settings) > 0)
|
109 |
+
foreach($module_settings as $module_setting)
|
110 |
+
{
|
111 |
+
$field_id = $module_setting['id'];
|
112 |
+
$saved_field_value = $this->settings['module_settings'][$module_id . '_' . $field_id];
|
113 |
+
|
114 |
+
//ignore callbacks if permalink is turned OFF
|
115 |
+
if($this->functions->is_permalink_enabled())
|
116 |
+
{
|
117 |
+
$_callback = isset($module_setting['callback']) ? $module_setting['callback'] : '';
|
118 |
+
if(empty($_callback))
|
119 |
+
$_callback = '_callback_' . $field_id;
|
120 |
+
|
121 |
+
if (method_exists($module, $_callback) && is_callable(array($module, $_callback)))
|
122 |
+
$processing_data[] = call_user_func(array($module, $_callback), $saved_field_value);
|
123 |
+
}
|
124 |
+
|
125 |
+
//action available for MU
|
126 |
+
do_action('wp-hide/module_settings_process', $field_id, $saved_field_value, $module);
|
127 |
+
}
|
128 |
+
|
129 |
+
}
|
130 |
+
|
131 |
+
//sort the modules array
|
132 |
+
arsort($this->modules);
|
133 |
+
|
134 |
+
//sort the replacement urls
|
135 |
+
//$keys = array_map('strlen', array_keys($arr));
|
136 |
+
//array_multisort($keys, SORT_DESC, $arr);
|
137 |
+
|
138 |
+
}
|
139 |
+
|
140 |
+
/**
|
141 |
+
* run on admin_init action
|
142 |
+
*
|
143 |
+
*/
|
144 |
+
function admin_init()
|
145 |
+
{
|
146 |
+
//check for interface submit
|
147 |
+
if($this->doing_interface_save === TRUE)
|
148 |
+
$this->functions->process_interface_save();
|
149 |
+
}
|
150 |
+
|
151 |
+
|
152 |
+
function admin_print_styles()
|
153 |
+
{
|
154 |
+
|
155 |
+
wp_register_style('WPHStyle', WPH_URL . '/css/wph.css');
|
156 |
+
wp_enqueue_style( 'WPHStyle');
|
157 |
+
|
158 |
+
}
|
159 |
+
|
160 |
+
function admin_menus()
|
161 |
+
{
|
162 |
+
include_once(WPH_PATH . '/include/admin-interface.class.php');
|
163 |
+
|
164 |
+
$this->admin_interface = new WPH_interface();
|
165 |
+
|
166 |
+
add_menu_page('WP Hide', 'WP Hide', 'manage_options', 'wp-hide');
|
167 |
+
|
168 |
+
foreach($this->modules as $module)
|
169 |
+
{
|
170 |
+
$interface_menu_data = $module->get_interface_menu_data();
|
171 |
+
|
172 |
+
add_submenu_page( 'wp-hide', 'WP Hide', $interface_menu_data['menu_title'], 'manage_options', $interface_menu_data['menu_slug'], array($this->admin_interface,'_render'));
|
173 |
+
}
|
174 |
+
|
175 |
+
}
|
176 |
+
|
177 |
+
|
178 |
+
function admin_notices()
|
179 |
+
{
|
180 |
+
global $wp_rewrite;
|
181 |
+
|
182 |
+
//help nottice
|
183 |
+
if(isset($_GET['page']) && $_GET['page'] == 'wp-hide')
|
184 |
+
echo "<div class='updated'><p>". __('Help us to improve this plugin by reporting any issues at ', 'wp-hide') .'<a target="_blank" href="http://www.nsp-code.com/">www.nsp-code.com</a></p></div>';
|
185 |
+
|
186 |
+
//check for permalinks enabled
|
187 |
+
if (!$this->functions->is_permalink_enabled())
|
188 |
+
{
|
189 |
+
echo "<div class='error'><p>". __('Permalink is required to be turned ON for WP Hide & Security Enhancer to work', 'wp-hide') ."</p></div>";
|
190 |
+
}
|
191 |
+
|
192 |
+
if(isset($_GET['settings_updated']))
|
193 |
+
{
|
194 |
+
echo "<div class='updated'><p>". __('Settings saved', 'wp-hide') ."</p></div>";
|
195 |
+
|
196 |
+
$active_plugins = (array) get_option( 'active_plugins', array() );
|
197 |
+
|
198 |
+
//cache plugin nottice
|
199 |
+
if(array_search('w3-total-cache/w3-total-cache.php', $active_plugins) !== FALSE)
|
200 |
+
{
|
201 |
+
echo "<div class='error'><p>". __('W3 Total Cache Plugin is active, make sure you clear the cache for new changes to apply', 'wp-hide') ."</p></div>";
|
202 |
+
}
|
203 |
+
if(array_search('wp-super-cache/wp-cache.php', $active_plugins) !== FALSE)
|
204 |
+
{
|
205 |
+
echo "<div class='error'><p>". __('WP Super Cache Plugin is active, make sure you clear the cache for new changes to apply', 'wp-hide') ."</p></div>";
|
206 |
+
}
|
207 |
+
}
|
208 |
+
|
209 |
+
|
210 |
+
|
211 |
+
|
212 |
+
}
|
213 |
+
|
214 |
+
/**
|
215 |
+
* Turn ON buffering to allow a callback
|
216 |
+
*
|
217 |
+
*/
|
218 |
+
function session_ob_start()
|
219 |
+
{
|
220 |
+
|
221 |
+
ob_start(array($this, 'ob_start_callback'));
|
222 |
+
|
223 |
+
}
|
224 |
+
|
225 |
+
//callback processing
|
226 |
+
function ob_start_callback( $buffer )
|
227 |
+
{
|
228 |
+
|
229 |
+
$buffer = $this->functions->text_urls_replacement($buffer, $this->urls_replacement);
|
230 |
+
|
231 |
+
|
232 |
+
return $buffer;
|
233 |
+
|
234 |
+
}
|
235 |
+
|
236 |
+
/**
|
237 |
+
* check for any query and headers change
|
238 |
+
*
|
239 |
+
*/
|
240 |
+
function _action_wp()
|
241 |
+
{
|
242 |
+
if(!isset($_GET['throw_404']))
|
243 |
+
return;
|
244 |
+
|
245 |
+
global $wp_query;
|
246 |
+
|
247 |
+
$wp_query->set_404();
|
248 |
+
status_header(404);
|
249 |
+
|
250 |
+
remove_action( 'template_redirect', 'wp_redirect_admin_locations', 1000 );
|
251 |
+
|
252 |
+
}
|
253 |
+
|
254 |
+
/**
|
255 |
+
* The plugin always need to load first to ensure filters are loading before anything else
|
256 |
+
*
|
257 |
+
*/
|
258 |
+
function activated_plugin($plugin, $network_wide)
|
259 |
+
{
|
260 |
+
if($network_wide)
|
261 |
+
{
|
262 |
+
$active_plugins = get_site_option( 'active_sitewide_plugins', array() );
|
263 |
+
|
264 |
+
|
265 |
+
|
266 |
+
$active_plugins = get_site_option( 'active_sitewide_plugins', array() );
|
267 |
+
|
268 |
+
return;
|
269 |
+
}
|
270 |
+
|
271 |
+
|
272 |
+
$active_plugins = (array) get_option( 'active_plugins', array() );
|
273 |
+
|
274 |
+
if(count($active_plugins) < 2)
|
275 |
+
return;
|
276 |
+
|
277 |
+
$plugin_path = 'wp-hide/wp-hide.php';
|
278 |
+
|
279 |
+
$key = array_search( $plugin_path, $active_plugins );
|
280 |
+
if($key === FALSE || $key < 1)
|
281 |
+
return;
|
282 |
+
|
283 |
+
array_splice ( $active_plugins, $key, 1 );
|
284 |
+
array_unshift ( $active_plugins, $plugin_path );
|
285 |
+
|
286 |
+
update_option( 'active_plugins', $active_plugins );
|
287 |
+
|
288 |
+
}
|
289 |
+
|
290 |
+
|
291 |
+
function wp_redirect($location, $status)
|
292 |
+
{
|
293 |
+
if($this->uninstall === TRUE)
|
294 |
+
return $location;
|
295 |
+
|
296 |
+
$location = $this->functions->text_urls_replacement($location, $this->urls_replacement);
|
297 |
+
|
298 |
+
return $location;
|
299 |
+
}
|
300 |
+
|
301 |
+
function logout_redirect($redirect_to, $requested_redirect_to, $user)
|
302 |
+
{
|
303 |
+
$new_wp_login_php = $this->functions->get_module_item_setting('new_wp_login_php' , 'admin');
|
304 |
+
if (empty( $new_wp_login_php ))
|
305 |
+
return $redirect_to;
|
306 |
+
|
307 |
+
$redirect_to = str_replace('wp-login.php', $new_wp_login_php, $redirect_to);
|
308 |
+
|
309 |
+
return $redirect_to;
|
310 |
+
}
|
311 |
+
|
312 |
+
function generic_string_replacement($text)
|
313 |
+
{
|
314 |
+
$text = $this->functions->text_urls_replacement($text, $this->urls_replacement);
|
315 |
+
|
316 |
+
return $text;
|
317 |
+
|
318 |
+
}
|
319 |
+
|
320 |
+
function get_setting_value($setting_name, $default_value = '')
|
321 |
+
{
|
322 |
+
$setting_value = isset($this->settings['module_settings'][$setting_name]) ? $this->settings['module_settings'][$setting_name] : $default_value;
|
323 |
+
|
324 |
+
return $setting_value;
|
325 |
+
}
|
326 |
+
|
327 |
+
|
328 |
+
function settings_changed()
|
329 |
+
{
|
330 |
+
//allow rewrite
|
331 |
+
flush_rewrite_rules();
|
332 |
+
}
|
333 |
+
|
334 |
+
function mod_rewrite_rules( $rules )
|
335 |
+
{
|
336 |
+
if($this->uninstall === TRUE)
|
337 |
+
return $rules;
|
338 |
+
|
339 |
+
$processing_data = array();
|
340 |
+
|
341 |
+
//loop all module settings and run the callback functions
|
342 |
+
foreach($this->modules as $module)
|
343 |
+
{
|
344 |
+
$module_settings = $this->functions->filter_settings( $module->get_module_settings() );
|
345 |
+
$module_id = $module->get_module_id();
|
346 |
+
|
347 |
+
if(is_array($module_settings) && count($module_settings) > 0)
|
348 |
+
foreach($module_settings as $module_setting)
|
349 |
+
{
|
350 |
+
$field_id = $module_setting['id'];
|
351 |
+
$saved_field_value = $this->settings['module_settings'][$module_id . '_' . $field_id];
|
352 |
+
|
353 |
+
$_callback = isset($module_setting['callback_saved']) ? $module_setting['callback_saved'] : '';
|
354 |
+
if(empty($_callback))
|
355 |
+
$_callback = '_callback_saved_' . $field_id;
|
356 |
+
|
357 |
+
if (method_exists($module, $_callback) && is_callable(array($module, $_callback)))
|
358 |
+
$processing_data[] = call_user_func(array($module, $_callback), $saved_field_value);
|
359 |
+
}
|
360 |
+
}
|
361 |
+
|
362 |
+
//post-process the htaccess data
|
363 |
+
$_htaccess_data = array();
|
364 |
+
$_page_refresh = FALSE;
|
365 |
+
foreach($processing_data as $response)
|
366 |
+
{
|
367 |
+
if(isset($response['htaccess']))
|
368 |
+
{
|
369 |
+
//$_htaccess_line = trim($response['htaccess']);
|
370 |
+
//$_htaccess_data[] = trim($response['htaccess']);
|
371 |
+
|
372 |
+
$_htaccess_data[] = $response['htaccess'];
|
373 |
+
}
|
374 |
+
|
375 |
+
if(isset($response['page_refresh']) && $response['page_refresh'] === TRUE)
|
376 |
+
$_page_refresh = TRUE;
|
377 |
+
}
|
378 |
+
|
379 |
+
if(count($_htaccess_data) > 0)
|
380 |
+
{
|
381 |
+
$new_rules = "RewriteRule ^index\.php$ - [L]";
|
382 |
+
foreach($_htaccess_data as $_htaccess_data_line)
|
383 |
+
{
|
384 |
+
$new_rules .= "\n" . $_htaccess_data_line;
|
385 |
+
}
|
386 |
+
|
387 |
+
$new_rules .= "\n";
|
388 |
+
|
389 |
+
//update the main rule variable
|
390 |
+
$rules = str_replace('RewriteRule ^index\\.php$ - [L]', $new_rules, $rules);
|
391 |
+
}
|
392 |
+
|
393 |
+
return $rules;
|
394 |
+
|
395 |
+
}
|
396 |
+
|
397 |
+
|
398 |
+
function get_default_variables()
|
399 |
+
{
|
400 |
+
$this->default_variables['include_url'] = trailingslashit( site_url() ) . WPINC;
|
401 |
+
|
402 |
+
$this->default_variables['template_url'] = get_bloginfo('template_url');
|
403 |
+
$this->default_variables['stylesheet_uri'] = get_stylesheet_uri();
|
404 |
+
|
405 |
+
$this->default_variables['plugins_url'] = plugins_url();
|
406 |
+
|
407 |
+
$wp_upload_dir = wp_upload_dir();
|
408 |
+
$this->default_variables['upload_url'] = $wp_upload_dir['baseurl'];
|
409 |
+
|
410 |
+
$template = get_template();
|
411 |
+
|
412 |
+
$this->templates_data['is_child_theme'] = (get_option( 'stylesheet' ) != get_option( 'template' )) ? TRUE : FALSE;
|
413 |
+
$this->templates_data['themes_url'] = trailingslashit( str_replace($template, "", get_bloginfo('template_url')) );
|
414 |
+
|
415 |
+
$this->templates_data['main'] = array();
|
416 |
+
$this->templates_data['main']['folder_name'] = $template;
|
417 |
+
$this->templates_data['_template_' . $template] = 'main';
|
418 |
+
|
419 |
+
if($this->templates_data['is_child_theme'])
|
420 |
+
{
|
421 |
+
$this->templates_data['child'] = array();
|
422 |
+
|
423 |
+
$child_template = get_stylesheet();
|
424 |
+
$this->templates_data['child']['folder_name'] = $child_template;
|
425 |
+
$this->templates_data['_template_' . $child_template] = 'child';
|
426 |
+
}
|
427 |
+
|
428 |
+
}
|
429 |
+
|
430 |
+
function switch_theme()
|
431 |
+
{
|
432 |
+
$this->disable_filters = TRUE;
|
433 |
+
$this->get_default_variables();
|
434 |
+
|
435 |
+
//allow rewrite
|
436 |
+
flush_rewrite_rules();
|
437 |
+
|
438 |
+
$this->disable_filters = FALSE;
|
439 |
+
}
|
440 |
+
|
441 |
+
function permalink_change_redirect()
|
442 |
+
{
|
443 |
+
$screen = get_current_screen();
|
444 |
+
|
445 |
+
if($screen->base != "options-permalink" || !isset($_GET['settings-updated']))
|
446 |
+
return;
|
447 |
+
|
448 |
+
$new_location = trailingslashit( site_url() ) . "wp-admin/options-permalink.php";
|
449 |
+
|
450 |
+
if($this->functions->is_permalink_enabled())
|
451 |
+
{
|
452 |
+
$new_admin_url = $this->functions->get_module_item_setting('admin_url' , 'admin');
|
453 |
+
if(!empty($new_admin_url))
|
454 |
+
$new_location = trailingslashit( site_url() ) . $new_admin_url . "/options-permalink.php";
|
455 |
+
}
|
456 |
+
|
457 |
+
$new_location .= '?settings-updated=true';
|
458 |
+
|
459 |
+
//no need to redirect if it's on the same path
|
460 |
+
$request_uri = $_SERVER['REQUEST_URI'];
|
461 |
+
|
462 |
+
$new_location_uri = $this->functions->get_url_path($new_location, TRUE);
|
463 |
+
if($request_uri == $new_location_uri)
|
464 |
+
return;
|
465 |
+
|
466 |
+
wp_redirect( $new_location );
|
467 |
+
die();
|
468 |
+
}
|
469 |
+
|
470 |
+
|
471 |
+
}
|
472 |
+
|
473 |
+
|
474 |
+
?>
|
languages/wp-hide.mo
ADDED
Binary file
|
languages/wp-hide.po
ADDED
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
msgid ""
|
2 |
+
msgstr ""
|
3 |
+
"Project-Id-Version: Post Types Order\n"
|
4 |
+
"POT-Creation-Date: 2015-12-08 20:49+0200\n"
|
5 |
+
"PO-Revision-Date: 2015-12-08 20:49+0200\n"
|
6 |
+
"Last-Translator: Nsp Code <contact@nsp-code.com>\n"
|
7 |
+
"Language-Team: \n"
|
8 |
+
"MIME-Version: 1.0\n"
|
9 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
10 |
+
"Content-Transfer-Encoding: 8bit\n"
|
11 |
+
"X-Generator: Poedit 1.5.5\n"
|
12 |
+
"X-Poedit-KeywordsList: _;gettext;gettext_noop;__;_e\n"
|
13 |
+
"X-Poedit-Basepath: ../\n"
|
14 |
+
"X-Poedit-SearchPath-0: .\n"
|
15 |
+
|
16 |
+
#: include/wph.class.php:184
|
17 |
+
msgid ""
|
18 |
+
"Help us to improve this plugin by reporting any issues at <a target=\"_blank"
|
19 |
+
"\" href=\"http://www.nsp-code.com/\">www.nsp-code.com</a>"
|
20 |
+
msgstr ""
|
21 |
+
|
22 |
+
#: include/wph.class.php:189
|
23 |
+
msgid ""
|
24 |
+
"Permalink is required to be turned ON for WP Hide & Security Enhancer to work"
|
25 |
+
msgstr ""
|
26 |
+
|
27 |
+
#: include/wph.class.php:194
|
28 |
+
msgid "Settings saved"
|
29 |
+
msgstr ""
|
30 |
+
|
31 |
+
#: include/wph.class.php:201
|
32 |
+
msgid ""
|
33 |
+
"W3 Total Cache Plugin is active, make sure you clear the cache for new "
|
34 |
+
"changes to apply"
|
35 |
+
msgstr ""
|
36 |
+
|
37 |
+
#: include/wph.class.php:205
|
38 |
+
msgid ""
|
39 |
+
"WP Super Cache Plugin is active, make sure you clear the cache for new "
|
40 |
+
"changes to apply"
|
41 |
+
msgstr ""
|
42 |
+
|
43 |
+
#: modules/module-admin.php:56
|
44 |
+
msgid "Create a new admin url instead default /wp-admin and /login."
|
45 |
+
msgstr ""
|
46 |
+
|
47 |
+
#: modules/module-admin.php:67
|
48 |
+
msgid "Block default admin url and files from being accesible."
|
49 |
+
msgstr ""
|
50 |
+
|
51 |
+
#: modules/module-admin.php:71 modules/module-admin.php:103
|
52 |
+
#: modules/module-general.php:58 modules/module-general.php:78
|
53 |
+
#: modules/module-general.php:94 modules/module-general.php:111
|
54 |
+
#: modules/module-general.php:127 modules/module-general.php:145
|
55 |
+
#: modules/module-rewrite.php:138 modules/module-rewrite.php:172
|
56 |
+
#: modules/module-rewrite.php:205
|
57 |
+
msgid "Yes"
|
58 |
+
msgstr ""
|
59 |
+
|
60 |
+
#: modules/module-admin.php:72 modules/module-admin.php:104
|
61 |
+
#: modules/module-general.php:59 modules/module-general.php:79
|
62 |
+
#: modules/module-general.php:95 modules/module-general.php:112
|
63 |
+
#: modules/module-general.php:128 modules/module-general.php:146
|
64 |
+
#: modules/module-rewrite.php:139 modules/module-rewrite.php:173
|
65 |
+
#: modules/module-rewrite.php:206
|
66 |
+
msgid "No"
|
67 |
+
msgstr ""
|
68 |
+
|
69 |
+
#: modules/module-admin.php:88
|
70 |
+
msgid "Map a new wp-login.php instead default."
|
71 |
+
msgstr ""
|
72 |
+
|
73 |
+
#: modules/module-admin.php:99
|
74 |
+
msgid "Block default wp-login.php file from being accesible."
|
75 |
+
msgstr ""
|
76 |
+
|
77 |
+
#: modules/module-general.php:54
|
78 |
+
msgid "Remove version number from enqueued style and script files."
|
79 |
+
msgstr ""
|
80 |
+
|
81 |
+
#: modules/module-general.php:74
|
82 |
+
msgid "Remove the autogenerated meta generator tag within head."
|
83 |
+
msgstr ""
|
84 |
+
|
85 |
+
#: modules/module-general.php:90
|
86 |
+
msgid "Remove the wlwmanifest tag within head."
|
87 |
+
msgstr ""
|
88 |
+
|
89 |
+
#: modules/module-general.php:107
|
90 |
+
msgid "Remove the feed_links tag within head."
|
91 |
+
msgstr ""
|
92 |
+
|
93 |
+
#: modules/module-general.php:123
|
94 |
+
msgid "Remove the rsd_link tag within head."
|
95 |
+
msgstr ""
|
96 |
+
|
97 |
+
#: modules/module-general.php:141
|
98 |
+
msgid "Remove the adjacent_posts_rel tag within head."
|
99 |
+
msgstr ""
|
modules/module-admin.php
ADDED
@@ -0,0 +1,357 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class WPH_module_admin extends WPH_module
|
5 |
+
{
|
6 |
+
|
7 |
+
static function get_module_id()
|
8 |
+
{
|
9 |
+
|
10 |
+
return 'admin';
|
11 |
+
}
|
12 |
+
|
13 |
+
static function get_module_slug()
|
14 |
+
{
|
15 |
+
|
16 |
+
return 'wp-hide-admin';
|
17 |
+
}
|
18 |
+
|
19 |
+
function get_interface_menu_data()
|
20 |
+
{
|
21 |
+
$interface_data = array();
|
22 |
+
|
23 |
+
$interface_data['menu_title'] = 'Admin';
|
24 |
+
$interface_data['menu_slug'] = self::get_module_slug();
|
25 |
+
$interface_data['menu_position'] = 30;
|
26 |
+
|
27 |
+
return $interface_data;
|
28 |
+
}
|
29 |
+
|
30 |
+
function get_interface_data()
|
31 |
+
{
|
32 |
+
|
33 |
+
$interface_data = array();
|
34 |
+
|
35 |
+
$interface_data['title'] = 'WP Hide & Security Enhancer - Admin';
|
36 |
+
$interface_data['description'] = '';
|
37 |
+
$interface_data['handle_title'] = '<span class="icon settings"> </span><span>Admin Settings</span>';
|
38 |
+
|
39 |
+
return $interface_data;
|
40 |
+
|
41 |
+
}
|
42 |
+
|
43 |
+
|
44 |
+
function get_module_settings()
|
45 |
+
{
|
46 |
+
global $wph;
|
47 |
+
|
48 |
+
$module_settings = array();
|
49 |
+
|
50 |
+
|
51 |
+
|
52 |
+
|
53 |
+
$module_settings[] = array(
|
54 |
+
'id' => 'admin_url',
|
55 |
+
'label' => 'New Admin Url',
|
56 |
+
'description' => __('Create a new admin url instead default /wp-admin and /login.', 'wp-hide'),
|
57 |
+
|
58 |
+
'input_type' => 'text',
|
59 |
+
|
60 |
+
'sanitize_type' => array(array($this->functions, 'sanitize_file_path_name'))
|
61 |
+
|
62 |
+
);
|
63 |
+
|
64 |
+
$module_settings[] = array(
|
65 |
+
'id' => 'block_default_admin_url',
|
66 |
+
'label' => 'Block default Admin Url',
|
67 |
+
'description' => __('Block default admin url and files from being accesible.', 'wp-hide') . '<br /><span class="important">' . __('Warning: Write down your new admin url, or if lost, will not be able to log-in .', 'wp-hide') . '</span>',
|
68 |
+
|
69 |
+
'input_type' => 'radio',
|
70 |
+
'options' => array(
|
71 |
+
'yes' => __('Yes', 'wp-hide'),
|
72 |
+
'no' => __('No', 'wp-hide'),
|
73 |
+
),
|
74 |
+
'default_value' => 'no',
|
75 |
+
|
76 |
+
'sanitize_type' => array('sanitize_title', 'strtolower')
|
77 |
+
|
78 |
+
);
|
79 |
+
|
80 |
+
$module_settings[] = array(
|
81 |
+
'type' => 'split',
|
82 |
+
);
|
83 |
+
|
84 |
+
|
85 |
+
$module_settings[] = array(
|
86 |
+
'id' => 'new_wp_login_php',
|
87 |
+
'label' => 'New wp-login.php',
|
88 |
+
'description' => __('Map a new wp-login.php instead default.', 'wp-hide'),
|
89 |
+
|
90 |
+
'input_type' => 'text',
|
91 |
+
|
92 |
+
'sanitize_type' => array(array($this->functions, 'sanitize_file_path_name'))
|
93 |
+
|
94 |
+
);
|
95 |
+
|
96 |
+
$module_settings[] = array(
|
97 |
+
'id' => 'block_default_wp_login_php',
|
98 |
+
'label' => 'Block default wp-login.php',
|
99 |
+
'description' => __('Block default wp-login.php file from being accesible.', 'wp-hide'),
|
100 |
+
|
101 |
+
'input_type' => 'radio',
|
102 |
+
'options' => array(
|
103 |
+
'yes' => __('Yes', 'wp-hide'),
|
104 |
+
'no' => __('No', 'wp-hide'),
|
105 |
+
),
|
106 |
+
'default_value' => 'no',
|
107 |
+
|
108 |
+
'sanitize_type' => array('sanitize_title', 'strtolower')
|
109 |
+
|
110 |
+
);
|
111 |
+
|
112 |
+
|
113 |
+
$module_settings = apply_filters('wp-hide/module_settings', $module_settings, $this);
|
114 |
+
|
115 |
+
return $module_settings;
|
116 |
+
|
117 |
+
}
|
118 |
+
|
119 |
+
function _callback_admin_url($saved_field_data)
|
120 |
+
{
|
121 |
+
if(empty($saved_field_data) || $saved_field_data == 'no')
|
122 |
+
return FALSE;
|
123 |
+
|
124 |
+
$default_url = $this->functions->get_url_path( trailingslashit( site_url() ) . 'wp-admin' );
|
125 |
+
$new_url = $this->functions->get_url_path( trailingslashit( site_url() ) . $saved_field_data );
|
126 |
+
//add replacement
|
127 |
+
if(!isset($this->wph->urls_replacement[$default_url]))
|
128 |
+
{
|
129 |
+
$this->wph->urls_replacement[$default_url] = $new_url;
|
130 |
+
}
|
131 |
+
|
132 |
+
add_filter('admin_url', array($this,'admin_url'), 999, 3 );
|
133 |
+
add_action('set_auth_cookie', array($this,'set_auth_cookie'), 999, 5);
|
134 |
+
add_action('clear_auth_cookie', array($this,'clear_auth_cookie'));
|
135 |
+
add_filter('style_loader_src', array($this->wph, 'generic_string_replacement' ), 999);
|
136 |
+
|
137 |
+
add_filter('wp_default_scripts', array($this, 'wp_default_scripts' ), 999);
|
138 |
+
}
|
139 |
+
|
140 |
+
function _callback_saved_admin_url($saved_field_data)
|
141 |
+
{
|
142 |
+
$processing_response = array();
|
143 |
+
|
144 |
+
//check if the field is noe empty
|
145 |
+
if(empty($saved_field_data))
|
146 |
+
return $processing_response;
|
147 |
+
|
148 |
+
$admin_url = $this->functions->get_url_path( trailingslashit( site_url() ) . 'wp-admin' );
|
149 |
+
|
150 |
+
$text = "\nRewriteCond %{REQUEST_URI} ". $saved_field_data ."$";
|
151 |
+
$text .= "\nRewriteRule ^(.*)$ ". $saved_field_data ."/ [R=301,L]";
|
152 |
+
$text .= "\nRewriteRule ^" . $saved_field_data . '(.*) '. $admin_url .'$1 [L,QSA]';
|
153 |
+
|
154 |
+
$processing_response['htaccess'] = $text;
|
155 |
+
$processing_response['page_refresh'] = TRUE;
|
156 |
+
|
157 |
+
return $processing_response;
|
158 |
+
}
|
159 |
+
|
160 |
+
|
161 |
+
function admin_url($url, $path, $blog_id)
|
162 |
+
{
|
163 |
+
if($this->wph->uninstall === TRUE)
|
164 |
+
return $url;
|
165 |
+
|
166 |
+
$new_admin_url = $this->functions->get_module_item_setting('admin_url' , $this->get_module_id());
|
167 |
+
|
168 |
+
$admin_dir_uri = trailingslashit( site_url() ) . trim($new_admin_url, "/");
|
169 |
+
$new_url = trailingslashit( $admin_dir_uri ) . $path;
|
170 |
+
|
171 |
+
//add replacement
|
172 |
+
if(!isset($this->wph->urls_replacement[$url]))
|
173 |
+
{
|
174 |
+
$this->wph->urls_replacement[$url] = $new_url;
|
175 |
+
}
|
176 |
+
|
177 |
+
return $new_url;
|
178 |
+
|
179 |
+
}
|
180 |
+
|
181 |
+
function set_auth_cookie($auth_cookie, $expire, $expiration, $user_id, $scheme)
|
182 |
+
{
|
183 |
+
|
184 |
+
$new_admin_url = $this->functions->get_module_item_setting('admin_url' , $this->get_module_id());
|
185 |
+
|
186 |
+
if ( $scheme == 'secure_auth' )
|
187 |
+
{
|
188 |
+
$auth_cookie_name = SECURE_AUTH_COOKIE;
|
189 |
+
$secure = TRUE;
|
190 |
+
}
|
191 |
+
else
|
192 |
+
{
|
193 |
+
$auth_cookie_name = AUTH_COOKIE;
|
194 |
+
$secure = FALSE;
|
195 |
+
}
|
196 |
+
|
197 |
+
setcookie($auth_cookie_name, $auth_cookie, $expire, SITECOOKIEPATH . $new_admin_url, COOKIE_DOMAIN, $secure, true);
|
198 |
+
|
199 |
+
$manager = WP_Session_Tokens::get_instance( $user_id );
|
200 |
+
$token = $manager->create( $expiration );
|
201 |
+
|
202 |
+
$logged_in_cookie = wp_generate_auth_cookie( $user_id, $expiration, 'logged_in', $token );
|
203 |
+
|
204 |
+
}
|
205 |
+
|
206 |
+
function clear_auth_cookie()
|
207 |
+
{
|
208 |
+
|
209 |
+
$new_admin_url = $this->functions->get_module_item_setting('admin_url' , $this->get_module_id());
|
210 |
+
|
211 |
+
$secure = is_ssl();
|
212 |
+
$secure = apply_filters( 'secure_auth_cookie', $secure, $user_id );
|
213 |
+
if ( $secure )
|
214 |
+
{
|
215 |
+
$auth_cookie_name = SECURE_AUTH_COOKIE;
|
216 |
+
$scheme = 'secure_auth';
|
217 |
+
}
|
218 |
+
else
|
219 |
+
{
|
220 |
+
$auth_cookie_name = AUTH_COOKIE;
|
221 |
+
$scheme = 'auth';
|
222 |
+
}
|
223 |
+
|
224 |
+
setcookie($auth_cookie_name,'', time() - YEAR_IN_SECONDS, SITECOOKIEPATH . $new_admin_url, COOKIE_DOMAIN );
|
225 |
+
}
|
226 |
+
|
227 |
+
|
228 |
+
function wp_default_scripts($scripts)
|
229 |
+
{
|
230 |
+
//check if custom admin url is set
|
231 |
+
$admin_url = $this->functions->get_module_item_setting('admin_url' , $this->get_module_id());
|
232 |
+
if (empty( $admin_url ))
|
233 |
+
return;
|
234 |
+
|
235 |
+
//update default dirs
|
236 |
+
if(isset($scripts->default_dirs))
|
237 |
+
{
|
238 |
+
foreach($scripts->default_dirs as $key => $value)
|
239 |
+
{
|
240 |
+
$scripts->default_dirs[$key] = str_replace('wp-admin', $admin_url, $value);
|
241 |
+
}
|
242 |
+
}
|
243 |
+
|
244 |
+
foreach($scripts->registered as $script_name => $script_data)
|
245 |
+
{
|
246 |
+
$script_data->src = str_replace('wp-admin', $admin_url, $script_data->src);
|
247 |
+
|
248 |
+
$scripts->registered[$script_name] = $script_data;
|
249 |
+
}
|
250 |
+
}
|
251 |
+
|
252 |
+
|
253 |
+
function _callback_block_default_admin_url($saved_field_data)
|
254 |
+
{
|
255 |
+
if(empty($saved_field_data) || $saved_field_data == 'no')
|
256 |
+
return FALSE;
|
257 |
+
|
258 |
+
}
|
259 |
+
|
260 |
+
function _callback_saved_block_default_admin_url($saved_field_data)
|
261 |
+
{
|
262 |
+
$processing_response = array();
|
263 |
+
|
264 |
+
//check if the field is noe empty
|
265 |
+
if(empty($saved_field_data) || $saved_field_data == 'no')
|
266 |
+
return $processing_response;
|
267 |
+
|
268 |
+
//prevent from blocking if the admin_url is empty
|
269 |
+
$admin_url = $this->functions->get_module_item_setting('admin_url' , $this->get_module_id());
|
270 |
+
if (empty( $admin_url ))
|
271 |
+
return FALSE;
|
272 |
+
|
273 |
+
$site_index = $this->functions->get_url_path ( trailingslashit( site_url() ) . 'index.php', TRUE );
|
274 |
+
|
275 |
+
$text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
|
276 |
+
$text .= "RewriteRule ^wp-admin(.*) $site_index?throw_404 [L]\n";
|
277 |
+
$text .= "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
|
278 |
+
|
279 |
+
//theme my login usage
|
280 |
+
//$text .= "RewriteRule ^login(.*) $site_index?throw_404 [L]\n";
|
281 |
+
//$text .= "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
|
282 |
+
|
283 |
+
$text .= "RewriteRule ^dashboard(.*) $site_index?throw_404 [L]\n";
|
284 |
+
$text .= "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
|
285 |
+
$text .= "RewriteRule ^admin(.*) $site_index?throw_404 [L]";
|
286 |
+
|
287 |
+
$processing_response['htaccess'] = $text;
|
288 |
+
|
289 |
+
return $processing_response;
|
290 |
+
}
|
291 |
+
|
292 |
+
|
293 |
+
function _callback_new_wp_login_php($saved_field_data)
|
294 |
+
{
|
295 |
+
if(empty($saved_field_data) || $saved_field_data == 'no')
|
296 |
+
return FALSE;
|
297 |
+
|
298 |
+
|
299 |
+
//add replacement
|
300 |
+
if(!isset($this->wph->urls_replacement[$url]))
|
301 |
+
{
|
302 |
+
$this->wph->urls_replacement[ trailingslashit( site_url() ) . 'wp-login.php' ] = trailingslashit( site_url() ) . $saved_field_data;
|
303 |
+
}
|
304 |
+
}
|
305 |
+
|
306 |
+
function _callback_saved_new_wp_login_php($saved_field_data)
|
307 |
+
{
|
308 |
+
$processing_response = array();
|
309 |
+
|
310 |
+
//check if the field is noe empty
|
311 |
+
if(empty($saved_field_data))
|
312 |
+
return $processing_response;
|
313 |
+
|
314 |
+
$new_wp_login_php = untrailingslashit ( $this->functions->get_url_path( trailingslashit( site_url() ) . 'wp-login.php' ) );
|
315 |
+
|
316 |
+
$processing_response['htaccess'] = "\nRewriteRule ^" . $saved_field_data . '(.*) '. $new_wp_login_php .'$1 [L,QSA]';
|
317 |
+
|
318 |
+
return $processing_response;
|
319 |
+
}
|
320 |
+
|
321 |
+
|
322 |
+
function _callback_block_default_wp_login_php($saved_field_data)
|
323 |
+
{
|
324 |
+
if(empty($saved_field_data) || $saved_field_data == 'no')
|
325 |
+
return FALSE;
|
326 |
+
|
327 |
+
|
328 |
+
}
|
329 |
+
|
330 |
+
function _callback_saved_block_default_wp_login_php($saved_field_data)
|
331 |
+
{
|
332 |
+
$processing_response = array();
|
333 |
+
|
334 |
+
//check if the field is noe empty
|
335 |
+
if(empty($saved_field_data) || $saved_field_data == 'no')
|
336 |
+
return $processing_response;
|
337 |
+
|
338 |
+
//prevent from blocking if the new_wp_login_php is empty
|
339 |
+
$new_wp_login_php = $this->functions->get_module_item_setting('new_wp_login_php' , $this->get_module_id());
|
340 |
+
if (empty( $new_wp_login_php ))
|
341 |
+
return FALSE;
|
342 |
+
|
343 |
+
$site_index = $this->functions->get_url_path ( trailingslashit( site_url() ) . 'index.php', TRUE );
|
344 |
+
|
345 |
+
$text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
|
346 |
+
$text .= "RewriteRule ^wp-login.php $site_index?throw_404 [L]";
|
347 |
+
|
348 |
+
$processing_response['htaccess'] = $text;
|
349 |
+
|
350 |
+
return $processing_response;
|
351 |
+
}
|
352 |
+
|
353 |
+
|
354 |
+
}
|
355 |
+
|
356 |
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general extends WPH_module
|
5 |
+
{
|
6 |
+
|
7 |
+
static function get_module_id()
|
8 |
+
{
|
9 |
+
|
10 |
+
return 'general';
|
11 |
+
}
|
12 |
+
|
13 |
+
static function get_module_slug()
|
14 |
+
{
|
15 |
+
|
16 |
+
return 'wp-hide-general';
|
17 |
+
}
|
18 |
+
|
19 |
+
function get_interface_menu_data()
|
20 |
+
{
|
21 |
+
$interface_data = array();
|
22 |
+
|
23 |
+
$interface_data['menu_title'] = 'General';
|
24 |
+
$interface_data['menu_slug'] = self::get_module_slug();
|
25 |
+
$interface_data['menu_position'] = 20;
|
26 |
+
|
27 |
+
return $interface_data;
|
28 |
+
}
|
29 |
+
|
30 |
+
function get_interface_data()
|
31 |
+
{
|
32 |
+
|
33 |
+
$interface_data = array();
|
34 |
+
|
35 |
+
$interface_data['title'] = 'WP Hide & Security Enhancer - General';
|
36 |
+
$interface_data['description'] = '';
|
37 |
+
$interface_data['handle_title'] = '<span class="icon settings"> </span><span>General Settings</span>';
|
38 |
+
|
39 |
+
return $interface_data;
|
40 |
+
|
41 |
+
}
|
42 |
+
|
43 |
+
|
44 |
+
function get_module_settings()
|
45 |
+
{
|
46 |
+
global $wph;
|
47 |
+
|
48 |
+
$module_settings = array();
|
49 |
+
|
50 |
+
|
51 |
+
$module_settings[] = array(
|
52 |
+
'id' => 'remove_version',
|
53 |
+
'label' => 'Remove Version',
|
54 |
+
'description' => __('Remove version number from enqueued style and script files.', 'wp-hide'),
|
55 |
+
|
56 |
+
'input_type' => 'radio',
|
57 |
+
'options' => array(
|
58 |
+
'yes' => __('Yes', 'wp-hide'),
|
59 |
+
'no' => __('No', 'wp-hide'),
|
60 |
+
),
|
61 |
+
'default_value' => 'no',
|
62 |
+
|
63 |
+
'sanitize_type' => array('sanitize_title', 'strtolower')
|
64 |
+
|
65 |
+
);
|
66 |
+
|
67 |
+
$module_settings[] = array(
|
68 |
+
'type' => 'split',
|
69 |
+
);
|
70 |
+
|
71 |
+
$module_settings[] = array(
|
72 |
+
'id' => 'remove_generator_meta',
|
73 |
+
'label' => 'Remove Generator Meta',
|
74 |
+
'description' => __('Remove the autogenerated meta generator tag within head.', 'wp-hide'),
|
75 |
+
|
76 |
+
'input_type' => 'radio',
|
77 |
+
'options' => array(
|
78 |
+
'yes' => __('Yes', 'wp-hide'),
|
79 |
+
'no' => __('No', 'wp-hide'),
|
80 |
+
),
|
81 |
+
'default_value' => 'no',
|
82 |
+
|
83 |
+
'sanitize_type' => array('sanitize_title', 'strtolower')
|
84 |
+
|
85 |
+
);
|
86 |
+
|
87 |
+
$module_settings[] = array(
|
88 |
+
'id' => 'remove_wlwmanifest',
|
89 |
+
'label' => 'Remove wlwmanifest Meta',
|
90 |
+
'description' => __('Remove the wlwmanifest tag within head.', 'wp-hide'),
|
91 |
+
|
92 |
+
'input_type' => 'radio',
|
93 |
+
'options' => array(
|
94 |
+
'yes' => __('Yes', 'wp-hide'),
|
95 |
+
'no' => __('No', 'wp-hide'),
|
96 |
+
),
|
97 |
+
'default_value' => 'no',
|
98 |
+
|
99 |
+
'sanitize_type' => array('sanitize_title', 'strtolower')
|
100 |
+
|
101 |
+
);
|
102 |
+
|
103 |
+
|
104 |
+
$module_settings[] = array(
|
105 |
+
'id' => 'remove_feed_links',
|
106 |
+
'label' => 'Remove feed_links Meta',
|
107 |
+
'description' => __('Remove the feed_links tag within head.', 'wp-hide'),
|
108 |
+
|
109 |
+
'input_type' => 'radio',
|
110 |
+
'options' => array(
|
111 |
+
'yes' => __('Yes', 'wp-hide'),
|
112 |
+
'no' => __('No', 'wp-hide'),
|
113 |
+
),
|
114 |
+
'default_value' => 'no',
|
115 |
+
|
116 |
+
'sanitize_type' => array('sanitize_title', 'strtolower')
|
117 |
+
|
118 |
+
);
|
119 |
+
|
120 |
+
$module_settings[] = array(
|
121 |
+
'id' => 'remove_rsd_link',
|
122 |
+
'label' => 'Remove rsd_link Meta',
|
123 |
+
'description' => __('Remove the rsd_link tag within head.', 'wp-hide'),
|
124 |
+
|
125 |
+
'input_type' => 'radio',
|
126 |
+
'options' => array(
|
127 |
+
'yes' => __('Yes', 'wp-hide'),
|
128 |
+
'no' => __('No', 'wp-hide'),
|
129 |
+
),
|
130 |
+
'default_value' => 'no',
|
131 |
+
|
132 |
+
'sanitize_type' => array('sanitize_title', 'strtolower')
|
133 |
+
|
134 |
+
);
|
135 |
+
|
136 |
+
|
137 |
+
|
138 |
+
$module_settings[] = array(
|
139 |
+
'id' => 'remove_adjacent_posts_rel',
|
140 |
+
'label' => 'Remove adjacent_posts_rel Meta',
|
141 |
+
'description' => __('Remove the adjacent_posts_rel tag within head.', 'wp-hide'),
|
142 |
+
|
143 |
+
'input_type' => 'radio',
|
144 |
+
'options' => array(
|
145 |
+
'yes' => __('Yes', 'wp-hide'),
|
146 |
+
'no' => __('No', 'wp-hide'),
|
147 |
+
),
|
148 |
+
'default_value' => 'no',
|
149 |
+
|
150 |
+
'sanitize_type' => array('sanitize_title', 'strtolower')
|
151 |
+
|
152 |
+
);
|
153 |
+
|
154 |
+
$module_settings = apply_filters('wp-hide/module_settings', $module_settings, $this);
|
155 |
+
|
156 |
+
return $module_settings;
|
157 |
+
|
158 |
+
}
|
159 |
+
|
160 |
+
function _callback_remove_version($saved_field_data)
|
161 |
+
{
|
162 |
+
if(empty($saved_field_data) || $saved_field_data == 'no')
|
163 |
+
return FALSE;
|
164 |
+
|
165 |
+
add_filter( 'style_loader_src', array(&$this, 'remove_file_version'), 999 );
|
166 |
+
add_filter( 'script_loader_src', array(&$this, 'remove_file_version'), 999 );
|
167 |
+
|
168 |
+
}
|
169 |
+
|
170 |
+
|
171 |
+
function remove_file_version($src)
|
172 |
+
{
|
173 |
+
|
174 |
+
$src = remove_query_arg( 'ver', $src );
|
175 |
+
|
176 |
+
return $src;
|
177 |
+
|
178 |
+
}
|
179 |
+
|
180 |
+
|
181 |
+
function _callback_remove_generator_meta($saved_field_data)
|
182 |
+
{
|
183 |
+
if(empty($saved_field_data) || $saved_field_data == 'no')
|
184 |
+
return FALSE;
|
185 |
+
|
186 |
+
add_filter('the_generator', create_function('', 'return "";'));
|
187 |
+
remove_action( 'wp_head', 'wp_generator' );
|
188 |
+
}
|
189 |
+
|
190 |
+
|
191 |
+
function _callback_remove_wlwmanifest($saved_field_data)
|
192 |
+
{
|
193 |
+
if(empty($saved_field_data) || $saved_field_data == 'no')
|
194 |
+
return FALSE;
|
195 |
+
|
196 |
+
remove_action( 'wp_head', 'wlwmanifest_link' );
|
197 |
+
|
198 |
+
}
|
199 |
+
|
200 |
+
|
201 |
+
function _callback_remove_feed_links($saved_field_data)
|
202 |
+
{
|
203 |
+
if(empty($saved_field_data) || $saved_field_data == 'no')
|
204 |
+
return FALSE;
|
205 |
+
|
206 |
+
remove_action('wp_head', 'feed_links', 2);
|
207 |
+
remove_action('wp_head', 'feed_links_extra', 3);
|
208 |
+
|
209 |
+
}
|
210 |
+
|
211 |
+
function _callback_remove_rsd_link($saved_field_data)
|
212 |
+
{
|
213 |
+
if(empty($saved_field_data) || $saved_field_data == 'no')
|
214 |
+
return FALSE;
|
215 |
+
|
216 |
+
remove_action('wp_head', 'rsd_link');
|
217 |
+
|
218 |
+
}
|
219 |
+
|
220 |
+
|
221 |
+
function _callback_adjacent_posts_rel($saved_field_data)
|
222 |
+
{
|
223 |
+
if(empty($saved_field_data) || $saved_field_data == 'no')
|
224 |
+
return FALSE;
|
225 |
+
|
226 |
+
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);
|
227 |
+
|
228 |
+
}
|
229 |
+
|
230 |
+
|
231 |
+
}
|
232 |
+
|
233 |
+
|
234 |
+
?>
|
modules/module-rewrite.php
ADDED
@@ -0,0 +1,685 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class WPH_module_rewrite extends WPH_module
|
5 |
+
{
|
6 |
+
|
7 |
+
function get_module_id()
|
8 |
+
{
|
9 |
+
return 'rewrite';
|
10 |
+
}
|
11 |
+
|
12 |
+
function get_module_slug()
|
13 |
+
{
|
14 |
+
return 'wp-hide';
|
15 |
+
}
|
16 |
+
|
17 |
+
function get_interface_menu_data()
|
18 |
+
{
|
19 |
+
$interface_data = array();
|
20 |
+
|
21 |
+
$interface_data['menu_title'] = 'Rewrite';
|
22 |
+
$interface_data['menu_slug'] = self::get_module_slug();
|
23 |
+
$interface_data['menu_position'] = 1;
|
24 |
+
|
25 |
+
return $interface_data;
|
26 |
+
}
|
27 |
+
|
28 |
+
function get_interface_data()
|
29 |
+
{
|
30 |
+
$interface_data = array();
|
31 |
+
|
32 |
+
$interface_data['title'] = 'WP Hide & Security Enhancer - Rewrite';
|
33 |
+
$interface_data['description'] = '';
|
34 |
+
$interface_data['handle_title'] = '<span class="icon settings"> </span><span>Rewrite Settings</span>';
|
35 |
+
|
36 |
+
return $interface_data;
|
37 |
+
}
|
38 |
+
|
39 |
+
function get_module_settings()
|
40 |
+
{
|
41 |
+
|
42 |
+
$module_settings = array();
|
43 |
+
|
44 |
+
$module_settings[] = array(
|
45 |
+
'id' => 'new_theme_path',
|
46 |
+
'label' => 'New Theme Path',
|
47 |
+
'description' => 'The default theme path is set to <strong>'. str_replace(get_bloginfo('wpurl'), '' ,$this->wph->default_variables['template_url']) .'</strong>
|
48 |
+
More details can be found at <a href="#">Link</a>',
|
49 |
+
|
50 |
+
'value_description' => 'e.g. my_template',
|
51 |
+
'input_type' => 'text',
|
52 |
+
|
53 |
+
'sanitize_type' => array(array($this->functions, 'sanitize_file_path_name'))
|
54 |
+
);
|
55 |
+
|
56 |
+
if($this->wph->templates_data['is_child_theme'])
|
57 |
+
{
|
58 |
+
$module_settings[] = array(
|
59 |
+
'id' => 'new_theme_child_path',
|
60 |
+
'label' => 'New Theme Child Path',
|
61 |
+
'description' => 'The default theme path is set to <strong>'. str_replace(get_bloginfo('wpurl'), '' , trailingslashit($this->wph->templates_data['themes_url']) . $this->wph->templates_data['child']['folder_name']) .'</strong>
|
62 |
+
More details can be found at <a href="#">Link</a>',
|
63 |
+
|
64 |
+
'value_description' => 'e.g. my_child_template',
|
65 |
+
'input_type' => 'text',
|
66 |
+
|
67 |
+
'sanitize_type' => array(array($this->functions, 'sanitize_file_path_name'))
|
68 |
+
);
|
69 |
+
}
|
70 |
+
|
71 |
+
$module_settings[] = array(
|
72 |
+
'id' => 'new_style_file_path',
|
73 |
+
'label' => 'New Style File Path',
|
74 |
+
'description' => 'The default theme style file style.css path is set to <strong>'. str_replace(get_bloginfo('wpurl'), '' , $this->wph->default_variables['template_url']) .'/style.css</strong>',
|
75 |
+
|
76 |
+
'value_description' => 'e.g. custom-style-file.css',
|
77 |
+
'input_type' => 'text',
|
78 |
+
|
79 |
+
'sanitize_type' => array(array($this->functions, 'sanitize_file_path_name'))
|
80 |
+
);
|
81 |
+
|
82 |
+
/*
|
83 |
+
$module_settings[] = array(
|
84 |
+
'id' => 'new_style_path',
|
85 |
+
'label' => 'New Style Path',
|
86 |
+
'description' => 'The default theme style path is set to <strong>'. str_replace(get_bloginfo('wpurl'), '' , $this->wph->default_variables['template_url']) .'/css</strong>',
|
87 |
+
|
88 |
+
'value_description' => 'e.g. styling',
|
89 |
+
'input_type' => 'text',
|
90 |
+
|
91 |
+
'sanitize_type' => array(array($this->functions, 'sanitize_file_path_name'))
|
92 |
+
);
|
93 |
+
*/
|
94 |
+
|
95 |
+
$module_settings[] = array(
|
96 |
+
'type' => 'split',
|
97 |
+
);
|
98 |
+
|
99 |
+
/*
|
100 |
+
$module_settings[] = array(
|
101 |
+
'id' => 'block_wpcontent_themes_url',
|
102 |
+
'label' => 'Block wp-content/themes URL',
|
103 |
+
'description' => 'Block themes files from being accesible through default urls. Apply only if <b>New Theme Path</b> is not empty.',
|
104 |
+
|
105 |
+
'input_type' => 'radio',
|
106 |
+
'options' => array(
|
107 |
+
'yes' => __('Yes', 'wp-hide'),
|
108 |
+
'no' => __('No', 'wp-hide'),
|
109 |
+
),
|
110 |
+
'default_value' => 'no',
|
111 |
+
|
112 |
+
'sanitize_type' => array('sanitize_title', 'strtolower')
|
113 |
+
|
114 |
+
);
|
115 |
+
*/
|
116 |
+
|
117 |
+
|
118 |
+
|
119 |
+
$module_settings[] = array(
|
120 |
+
'id' => 'new_include_path',
|
121 |
+
'label' => 'New Include Path',
|
122 |
+
'description' => 'The default theme path is set to <strong>wp-include</strong>
|
123 |
+
More details can be found at <a href="#">Link</a>',
|
124 |
+
|
125 |
+
'value_description' => 'e.g. my_include',
|
126 |
+
'input_type' => 'text',
|
127 |
+
|
128 |
+
'sanitize_type' => array(array($this->functions, 'sanitize_file_path_name'))
|
129 |
+
);
|
130 |
+
|
131 |
+
$module_settings[] = array(
|
132 |
+
'id' => 'block_wpinclude_url',
|
133 |
+
'label' => 'Block wp-include URL',
|
134 |
+
'description' => 'Block wp-include files from being accesible through default urls. <br />Apply only if <b>New Include Path</b> is not empty.',
|
135 |
+
|
136 |
+
'input_type' => 'radio',
|
137 |
+
'options' => array(
|
138 |
+
'yes' => __('Yes', 'wp-hide'),
|
139 |
+
'no' => __('No', 'wp-hide'),
|
140 |
+
),
|
141 |
+
'default_value' => 'no',
|
142 |
+
|
143 |
+
'sanitize_type' => array('sanitize_title', 'strtolower')
|
144 |
+
|
145 |
+
);
|
146 |
+
|
147 |
+
|
148 |
+
$module_settings[] = array(
|
149 |
+
'type' => 'split',
|
150 |
+
);
|
151 |
+
|
152 |
+
|
153 |
+
$module_settings[] = array(
|
154 |
+
'id' => 'new_plugin_path',
|
155 |
+
'label' => 'New Plugin Path',
|
156 |
+
'description' => 'The default theme path is set to <strong>'. str_replace(get_bloginfo('wpurl'), '' ,$this->wph->default_variables['plugins_url']) .'</strong>
|
157 |
+
More details can be found at <a href="#">Link</a>',
|
158 |
+
|
159 |
+
'value_description' => 'e.g. my_plugin',
|
160 |
+
'input_type' => 'text',
|
161 |
+
|
162 |
+
'sanitize_type' => array(array($this->functions, 'sanitize_file_path_name'))
|
163 |
+
);
|
164 |
+
|
165 |
+
$module_settings[] = array(
|
166 |
+
'id' => 'block_plugins_url',
|
167 |
+
'label' => 'Block plugins URL',
|
168 |
+
'description' => 'Block plugins files from being accesible through default urls.<br />Apply only if <b>New Plugin Path</b> is not empty.',
|
169 |
+
|
170 |
+
'input_type' => 'radio',
|
171 |
+
'options' => array(
|
172 |
+
'yes' => __('Yes', 'wp-hide'),
|
173 |
+
'no' => __('No', 'wp-hide'),
|
174 |
+
),
|
175 |
+
'default_value' => 'no',
|
176 |
+
|
177 |
+
'sanitize_type' => array('sanitize_title', 'strtolower')
|
178 |
+
|
179 |
+
);
|
180 |
+
|
181 |
+
$module_settings[] = array(
|
182 |
+
'type' => 'split',
|
183 |
+
);
|
184 |
+
|
185 |
+
|
186 |
+
$module_settings[] = array(
|
187 |
+
'id' => 'new_upload_path',
|
188 |
+
'label' => 'New Upload Path',
|
189 |
+
'description' => 'The default upload path is set to <strong>'. str_replace(get_bloginfo('wpurl'), '' ,$this->wph->default_variables['upload_url']) .'</strong>
|
190 |
+
More details can be found at <a href="#">Link</a>',
|
191 |
+
|
192 |
+
'value_description' => 'e.g. my_uploads',
|
193 |
+
'input_type' => 'text',
|
194 |
+
|
195 |
+
'sanitize_type' => array(array($this->functions, 'sanitize_file_path_name'))
|
196 |
+
);
|
197 |
+
|
198 |
+
$module_settings[] = array(
|
199 |
+
'id' => 'block_upload_url',
|
200 |
+
'label' => 'Block upload URL',
|
201 |
+
'description' => 'Block upload files from being accesible through default urls. <br />If set to Yes, all new images inserted into posts will use the new Upload Url, as old url become blocked. Using the No, new images inesrted will use old url, which however are being updated on front side. This may be helpfull on plugin disable, so image urls can be accessible as before.<br />Apply only if <b>New Upload Path</b> is not empty.',
|
202 |
+
|
203 |
+
'input_type' => 'radio',
|
204 |
+
'options' => array(
|
205 |
+
'yes' => __('Yes', 'wp-hide'),
|
206 |
+
'no' => __('No', 'wp-hide'),
|
207 |
+
),
|
208 |
+
'default_value' => 'no',
|
209 |
+
|
210 |
+
'sanitize_type' => array('sanitize_title', 'strtolower')
|
211 |
+
|
212 |
+
);
|
213 |
+
|
214 |
+
$module_settings = apply_filters('wp-hide/module_settings', $module_settings, $this);
|
215 |
+
|
216 |
+
|
217 |
+
return $module_settings;
|
218 |
+
|
219 |
+
}
|
220 |
+
|
221 |
+
|
222 |
+
function _callback_new_theme_path($saved_field_data)
|
223 |
+
{
|
224 |
+
if(empty($saved_field_data))
|
225 |
+
return FALSE;
|
226 |
+
|
227 |
+
//applay when not admin and not customize.php
|
228 |
+
/*
|
229 |
+
if(is_admin() || $this->functions->is_theme_customize())
|
230 |
+
return;
|
231 |
+
*/
|
232 |
+
|
233 |
+
add_filter('stylesheet_directory_uri', array(&$this, 'stylesheet_directory_uri'), 999, 1);
|
234 |
+
add_filter('template_directory_uri', array(&$this, 'template_directory_uri'), 999, 3);
|
235 |
+
//add_filter('theme_root_uri', array(&$this, 'theme_root_uri'), 999, 3);
|
236 |
+
|
237 |
+
}
|
238 |
+
|
239 |
+
function _callback_saved_new_theme_path($saved_field_data)
|
240 |
+
{
|
241 |
+
$processing_response = array();
|
242 |
+
|
243 |
+
//check if the field is noe empty
|
244 |
+
if(empty($saved_field_data))
|
245 |
+
return $processing_response;
|
246 |
+
|
247 |
+
$theme_path = $this->functions->get_url_path( $this->wph->templates_data['themes_url'] . $this->wph->templates_data['main']['folder_name'] );
|
248 |
+
|
249 |
+
$processing_response['htaccess'] = "\nRewriteRule ^" . trailingslashit( $saved_field_data ) . '(.*) '. $theme_path .'$1 [L,QSA]';
|
250 |
+
|
251 |
+
return $processing_response;
|
252 |
+
}
|
253 |
+
|
254 |
+
|
255 |
+
|
256 |
+
function stylesheet_directory_uri($url)
|
257 |
+
{
|
258 |
+
if ( $this->wph->disable_filters )
|
259 |
+
return $url;
|
260 |
+
|
261 |
+
$template = str_replace($this->wph->templates_data['themes_url'], "", $url);
|
262 |
+
|
263 |
+
if($this->functions->is_other_template($template))
|
264 |
+
return $url;
|
265 |
+
|
266 |
+
if($this->wph->templates_data['_template_' . $template] == 'main')
|
267 |
+
$new_theme_path = $this->functions->get_module_item_setting('new_theme_path' , $this->get_module_id());
|
268 |
+
else
|
269 |
+
$new_theme_path = $this->functions->get_module_item_setting('new_theme_child_path' , $this->get_module_id());
|
270 |
+
|
271 |
+
$template_dir_uri = trailingslashit( site_url() ) . ltrim(rtrim($new_theme_path, "/"), "/");
|
272 |
+
|
273 |
+
//add replacement
|
274 |
+
if(!isset($this->wph->urls_replacement[$url]))
|
275 |
+
{
|
276 |
+
$this->wph->urls_replacement[$url] = $template_dir_uri;
|
277 |
+
}
|
278 |
+
|
279 |
+
return $template_dir_uri;
|
280 |
+
}
|
281 |
+
|
282 |
+
|
283 |
+
function template_directory_uri($template_dir_uri, $template, $theme_root_uri)
|
284 |
+
{
|
285 |
+
if ( $this->wph->disable_filters )
|
286 |
+
return $template_dir_uri;
|
287 |
+
|
288 |
+
if($this->functions->is_other_template($template))
|
289 |
+
return $template_dir_uri;
|
290 |
+
|
291 |
+
if($this->wph->templates_data['_template_' . $template] == 'main')
|
292 |
+
$new_theme_path = $this->functions->get_module_item_setting('new_theme_path' , $this->get_module_id());
|
293 |
+
else
|
294 |
+
$new_theme_path = $this->functions->get_module_item_setting('new_theme_child_path' , $this->get_module_id());
|
295 |
+
|
296 |
+
$new_template_dir_uri = trailingslashit( site_url() ) . trim($new_theme_path, "/") ;
|
297 |
+
|
298 |
+
//add replacement
|
299 |
+
if(!isset($this->wph->urls_replacement[$template_dir_uri]))
|
300 |
+
{
|
301 |
+
$this->wph->urls_replacement[$template_dir_uri] = $new_template_dir_uri;
|
302 |
+
}
|
303 |
+
|
304 |
+
return $new_template_dir_uri;
|
305 |
+
}
|
306 |
+
|
307 |
+
|
308 |
+
function theme_root_uri($theme_root_uri, $siteurl, $stylesheet_or_template)
|
309 |
+
{
|
310 |
+
if ( $this->wph->disable_filters )
|
311 |
+
return $theme_root_uri;
|
312 |
+
|
313 |
+
//only for current theme
|
314 |
+
$current_theme = get_stylesheet();
|
315 |
+
if($current_theme != $stylesheet_or_template)
|
316 |
+
return $theme_root_uri;
|
317 |
+
|
318 |
+
$theme_root_uri = untrailingslashit( site_url() ) ;
|
319 |
+
|
320 |
+
return $theme_root_uri;
|
321 |
+
}
|
322 |
+
|
323 |
+
|
324 |
+
function _callback_saved_new_theme_child_path($saved_field_data)
|
325 |
+
{
|
326 |
+
$processing_response = array();
|
327 |
+
|
328 |
+
//check if the field is noe empty
|
329 |
+
if(empty($saved_field_data))
|
330 |
+
return $processing_response;
|
331 |
+
|
332 |
+
$theme_path = $this->functions->get_url_path( $this->wph->templates_data['themes_url'] . $this->wph->templates_data['child']['folder_name'] );
|
333 |
+
|
334 |
+
$processing_response['htaccess'] = "\nRewriteRule ^" . trailingslashit( $saved_field_data ) . '(.*) '. $theme_path .'$1 [L,QSA]';
|
335 |
+
|
336 |
+
return $processing_response;
|
337 |
+
}
|
338 |
+
|
339 |
+
|
340 |
+
function _callback_new_style_file_path($saved_field_data)
|
341 |
+
{
|
342 |
+
if(empty($saved_field_data))
|
343 |
+
return FALSE;
|
344 |
+
|
345 |
+
if($this->functions->is_theme_customize())
|
346 |
+
return;
|
347 |
+
|
348 |
+
add_filter('stylesheet_uri', array(&$this, 'stylesheet_uri'), 999, 2);
|
349 |
+
}
|
350 |
+
|
351 |
+
function _callback_saved_new_style_file_path($saved_field_data)
|
352 |
+
{
|
353 |
+
$processing_response = array();
|
354 |
+
|
355 |
+
//check if the field is noe empty
|
356 |
+
if(empty($saved_field_data))
|
357 |
+
return $processing_response;
|
358 |
+
|
359 |
+
$current_stylesheet_uri = $this->wph->default_variables['stylesheet_uri'];
|
360 |
+
|
361 |
+
$current_stylesheet_uri = $this->functions->get_url_path( $current_stylesheet_uri, TRUE );
|
362 |
+
|
363 |
+
$processing_response['htaccess'] = "\nRewriteRule ^" . ( $saved_field_data ) . ' '. $current_stylesheet_uri .' [L,QSA]';
|
364 |
+
|
365 |
+
return $processing_response;
|
366 |
+
}
|
367 |
+
|
368 |
+
function stylesheet_uri($stylesheet_uri, $stylesheet_dir_uri)
|
369 |
+
{
|
370 |
+
if ( $this->wph->disable_filters )
|
371 |
+
return $stylesheet_uri;
|
372 |
+
|
373 |
+
$new_style_file_path = $this->functions->get_module_item_setting('new_style_file_path' , $this->get_module_id());
|
374 |
+
|
375 |
+
$new_style_file_path = trailingslashit( site_url() ) . $new_style_file_path;
|
376 |
+
|
377 |
+
return $new_style_file_path;
|
378 |
+
}
|
379 |
+
|
380 |
+
|
381 |
+
function _callback_saved_block_wpcontent_themes_url($saved_field_data)
|
382 |
+
{
|
383 |
+
$processing_response = array();
|
384 |
+
|
385 |
+
if(empty($saved_field_data) || $saved_field_data == 'no')
|
386 |
+
return FALSE;
|
387 |
+
|
388 |
+
//prevent from blocking if the wp-include is not modified
|
389 |
+
$new_theme_path = ltrim(rtrim($this->functions->get_module_item_setting('new_theme_path' , $this->get_module_id()), "/"), "/");
|
390 |
+
if (empty( $new_theme_path ))
|
391 |
+
return FALSE;
|
392 |
+
|
393 |
+
$default_content_url = untrailingslashit ( WP_CONTENT_URL );
|
394 |
+
$default_content_url = str_replace( site_url(), "", $default_content_url);
|
395 |
+
$default_content_url = ltrim(rtrim($default_content_url, "/"), "/");
|
396 |
+
|
397 |
+
$theme_roots = ltrim(rtrim(get_theme_roots(), "/"), "/");
|
398 |
+
|
399 |
+
$text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
|
400 |
+
$text .= "RewriteRule ^". trailingslashit ( $default_content_url ) . $theme_roots ."(.*) /404 [L]";
|
401 |
+
|
402 |
+
$processing_response['htaccess'] = $text;
|
403 |
+
|
404 |
+
return $processing_response;
|
405 |
+
|
406 |
+
|
407 |
+
}
|
408 |
+
|
409 |
+
function _callback_new_include_path($saved_field_data)
|
410 |
+
{
|
411 |
+
if(empty($saved_field_data))
|
412 |
+
return FALSE;
|
413 |
+
|
414 |
+
|
415 |
+
add_filter('includes_url', array( $this, 'includes_url' ), 999, 2);
|
416 |
+
add_filter('script_loader_src', array( $this, 'script_loader_src' ), 999, 2);
|
417 |
+
add_filter('style_loader_src', array( $this, 'style_loader_src' ), 999, 2);
|
418 |
+
|
419 |
+
add_filter('wp_default_scripts', array($this, 'wp_default_scripts' ), 999);
|
420 |
+
}
|
421 |
+
|
422 |
+
function _callback_saved_new_include_path($saved_field_data)
|
423 |
+
{
|
424 |
+
$processing_response = array();
|
425 |
+
|
426 |
+
//check if the field is noe empty
|
427 |
+
if(empty($saved_field_data))
|
428 |
+
return $processing_response;
|
429 |
+
|
430 |
+
|
431 |
+
$include_path = $this->functions->get_url_path( trailingslashit(site_url()) . WPINC );
|
432 |
+
|
433 |
+
$processing_response['htaccess'] = "\nRewriteRule ^" . trailingslashit( $saved_field_data ) . '(.*) '. $include_path .'$1 [L,QSA]';
|
434 |
+
|
435 |
+
return $processing_response;
|
436 |
+
}
|
437 |
+
|
438 |
+
|
439 |
+
|
440 |
+
function includes_url($url, $path)
|
441 |
+
{
|
442 |
+
if ( $this->wph->disable_filters )
|
443 |
+
return $url;
|
444 |
+
|
445 |
+
$new_include_path = $this->functions->get_module_item_setting('new_include_path' , $this->get_module_id());
|
446 |
+
|
447 |
+
$new_url = str_replace('/wp-includes/', '/' . $new_include_path . '/', $url);
|
448 |
+
|
449 |
+
return $new_url;
|
450 |
+
|
451 |
+
/*
|
452 |
+
$current_include = trailingslashit( $this->wph->default_variables['include_url'] );
|
453 |
+
|
454 |
+
$new_include_url = str_replace( $current_include , '' , $include_url);
|
455 |
+
$new_include_url = ltrim($new_include_url, "/");
|
456 |
+
|
457 |
+
$new_include_url = trailingslashit( site_url() ) . trailingslashit( ltrim(rtrim($new_include_path, "/"), "/") ) . $new_include_url;
|
458 |
+
*/
|
459 |
+
|
460 |
+
return $new_include_url;
|
461 |
+
}
|
462 |
+
|
463 |
+
function script_loader_src($src, $handle)
|
464 |
+
{
|
465 |
+
if ( $this->wph->disable_filters )
|
466 |
+
return $src;
|
467 |
+
|
468 |
+
$new_include_path = ltrim(rtrim($this->functions->get_module_item_setting('new_include_path' , $this->get_module_id()), "/"), "/");
|
469 |
+
|
470 |
+
$current_include_url = trailingslashit( $this->wph->default_variables['include_url'] );
|
471 |
+
$new_include_url = trailingslashit( trailingslashit( site_url() ) . $new_include_path );
|
472 |
+
$src = str_replace( $current_include_url , $new_include_url , $src);
|
473 |
+
|
474 |
+
return $src;
|
475 |
+
}
|
476 |
+
|
477 |
+
|
478 |
+
function style_loader_src($src, $handle)
|
479 |
+
{
|
480 |
+
if ( $this->wph->disable_filters )
|
481 |
+
return $src;
|
482 |
+
|
483 |
+
$new_include_path = ltrim(rtrim($this->functions->get_module_item_setting('new_include_path' , $this->get_module_id()), "/"), "/");
|
484 |
+
|
485 |
+
$current_include_url = trailingslashit( $this->wph->default_variables['include_url'] );
|
486 |
+
$new_include_url = trailingslashit( trailingslashit( site_url() ) . $new_include_path );
|
487 |
+
$src = str_replace( $current_include_url , $new_include_url , $src);
|
488 |
+
|
489 |
+
return $src;
|
490 |
+
}
|
491 |
+
|
492 |
+
function wp_default_scripts($scripts)
|
493 |
+
{
|
494 |
+
//check if custom admin url is set
|
495 |
+
$include_path = $this->functions->get_module_item_setting('new_include_path' , $this->get_module_id());
|
496 |
+
if (empty( $include_path ))
|
497 |
+
return;
|
498 |
+
|
499 |
+
$scripts = $this->functions->default_scripts_styles_replace($scripts, array('wp-includes' => $include_path));
|
500 |
+
}
|
501 |
+
|
502 |
+
|
503 |
+
function _callback_saved_block_wpinclude_url($saved_field_data)
|
504 |
+
{
|
505 |
+
$processing_response = array();
|
506 |
+
|
507 |
+
if(empty($saved_field_data) || $saved_field_data == 'no')
|
508 |
+
return FALSE;
|
509 |
+
|
510 |
+
//prevent from blocking if the wp-include is not modified
|
511 |
+
$new_include_path = ltrim(rtrim($this->functions->get_module_item_setting('new_include_path' , $this->get_module_id()), "/"), "/");
|
512 |
+
if (empty( $new_include_path ))
|
513 |
+
return FALSE;
|
514 |
+
|
515 |
+
$theme_roots = ltrim(rtrim(get_theme_roots(), "/"), "/");
|
516 |
+
|
517 |
+
$text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
|
518 |
+
$text .= "RewriteRule ^wp-includes(.*) /404 [L]";
|
519 |
+
|
520 |
+
$processing_response['htaccess'] = $text;
|
521 |
+
|
522 |
+
return $processing_response;
|
523 |
+
|
524 |
+
|
525 |
+
}
|
526 |
+
|
527 |
+
|
528 |
+
function _callback_new_plugin_path($saved_field_data)
|
529 |
+
{
|
530 |
+
if(empty($saved_field_data))
|
531 |
+
return FALSE;
|
532 |
+
|
533 |
+
|
534 |
+
add_filter('plugins_url',array( $this, 'plugins_url' ), 10, 3);
|
535 |
+
}
|
536 |
+
|
537 |
+
function _callback_saved_new_plugin_path($saved_field_data)
|
538 |
+
{
|
539 |
+
$processing_response = array();
|
540 |
+
|
541 |
+
//check if the field is noe empty
|
542 |
+
if(empty($saved_field_data))
|
543 |
+
return $processing_response;
|
544 |
+
|
545 |
+
$plugin_path = $this->functions->get_url_path( WP_PLUGIN_URL );
|
546 |
+
|
547 |
+
$processing_response['htaccess'] = "\nRewriteRule ^" . trailingslashit( $saved_field_data ) . '(.*) '. $plugin_path .'$1 [L,QSA]';
|
548 |
+
|
549 |
+
return $processing_response;
|
550 |
+
}
|
551 |
+
|
552 |
+
|
553 |
+
function plugins_url($url, $path, $plugin)
|
554 |
+
{
|
555 |
+
$new_url = str_replace(WP_PLUGIN_URL, "", $url);
|
556 |
+
$new_url = $this->functions->untrailingslashit_all( $new_url );
|
557 |
+
|
558 |
+
$new_plugin_path = $this->functions->untrailingslashit_all( $this->functions->get_module_item_setting('new_plugin_path' , $this->get_module_id()) );
|
559 |
+
|
560 |
+
$new_url = trailingslashit( site_url() ) . trailingslashit( $new_plugin_path ) . $new_url;
|
561 |
+
|
562 |
+
return $new_url;
|
563 |
+
}
|
564 |
+
|
565 |
+
|
566 |
+
function _callback_saved_block_plugins_url($saved_field_data)
|
567 |
+
{
|
568 |
+
$processing_response = array();
|
569 |
+
|
570 |
+
if(empty($saved_field_data) || $saved_field_data == 'no')
|
571 |
+
return FALSE;
|
572 |
+
|
573 |
+
//prevent from blocking if the wp-include is not modified
|
574 |
+
$new_theme_path = ltrim(rtrim($this->functions->get_module_item_setting('new_plugin_path' , $this->get_module_id()), "/"), "/");
|
575 |
+
if (empty( $new_theme_path ))
|
576 |
+
return FALSE;
|
577 |
+
|
578 |
+
$default_plugin_url = untrailingslashit ( WP_PLUGIN_URL );
|
579 |
+
$default_plugin_url = str_replace( site_url(), "", $default_plugin_url);
|
580 |
+
$default_plugin_url = ltrim(rtrim($default_plugin_url, "/"), "/");
|
581 |
+
|
582 |
+
$text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
|
583 |
+
$text .= "RewriteRule ^". $default_plugin_url ."(.*) /404 [L]";
|
584 |
+
|
585 |
+
$processing_response['htaccess'] = $text;
|
586 |
+
|
587 |
+
return $processing_response;
|
588 |
+
|
589 |
+
|
590 |
+
}
|
591 |
+
|
592 |
+
function _callback_new_upload_path($saved_field_data)
|
593 |
+
{
|
594 |
+
if(empty($saved_field_data))
|
595 |
+
return FALSE;
|
596 |
+
|
597 |
+
|
598 |
+
add_filter('upload_dir', array( $this, 'upload_dir' ), 999);
|
599 |
+
//add_filter('wp_get_attachment_url', array( $this, 'wp_get_attachment_url' ), 999, 2);
|
600 |
+
}
|
601 |
+
|
602 |
+
function _callback_saved_new_upload_path($saved_field_data)
|
603 |
+
{
|
604 |
+
$processing_response = array();
|
605 |
+
|
606 |
+
//check if the field is noe empty
|
607 |
+
if(empty($saved_field_data))
|
608 |
+
return $processing_response;
|
609 |
+
|
610 |
+
$uploads_path = $this->functions->get_url_path( WP_CONTENT_URL . '/uploads' );
|
611 |
+
|
612 |
+
$processing_response['htaccess'] = "\nRewriteRule ^" . trailingslashit( $saved_field_data ) . '(.*) '. $uploads_path .'$1 [L,QSA]';
|
613 |
+
|
614 |
+
return $processing_response;
|
615 |
+
}
|
616 |
+
|
617 |
+
|
618 |
+
function upload_dir($data)
|
619 |
+
{
|
620 |
+
|
621 |
+
$new_upload_path = $this->functions->untrailingslashit_all( $this->functions->get_module_item_setting('new_upload_path' , $this->get_module_id()) );
|
622 |
+
|
623 |
+
$new_url = trailingslashit( site_url() ) . $new_upload_path;
|
624 |
+
|
625 |
+
//$data['baseurl'] = $new_url;
|
626 |
+
|
627 |
+
//add replacement
|
628 |
+
if(!isset($this->wph->urls_replacement[ $this->wph->default_variables['upload_url'] ]))
|
629 |
+
{
|
630 |
+
//prevent media images from being replaced on admin, as when plugin disable the links will not work anymore
|
631 |
+
$block_upload_url = $this->functions->get_module_item_setting('block_upload_url' , $this->get_module_id());
|
632 |
+
if(!is_admin() || (is_admin() && !empty($block_upload_url) && $block_upload_url != 'no'))
|
633 |
+
{
|
634 |
+
$this->wph->urls_replacement[$this->wph->default_variables['upload_url']] = $new_url;
|
635 |
+
}
|
636 |
+
}
|
637 |
+
|
638 |
+
return $data;
|
639 |
+
}
|
640 |
+
|
641 |
+
/*
|
642 |
+
function wp_get_attachment_url($url, $post_ID)
|
643 |
+
{
|
644 |
+
$new_upload_path = $this->functions->untrailingslashit_all( $this->functions->get_module_item_setting('new_upload_path' , $this->get_module_id()) );
|
645 |
+
$new_url = trailingslashit( site_url() ) . $new_upload_path;
|
646 |
+
|
647 |
+
$url = str_replace($this->wph->default_variables['upload_url'], $new_url, $url);
|
648 |
+
|
649 |
+
return $url;
|
650 |
+
}
|
651 |
+
*/
|
652 |
+
|
653 |
+
function _callback_saved_block_upload_url($saved_field_data)
|
654 |
+
{
|
655 |
+
$processing_response = array();
|
656 |
+
|
657 |
+
if(empty($saved_field_data) || $saved_field_data == 'no')
|
658 |
+
return FALSE;
|
659 |
+
|
660 |
+
//prevent from blocking if the wp-include is not modified
|
661 |
+
$new_upload_path = $this->functions->get_module_item_setting('new_upload_path' , $this->get_module_id());
|
662 |
+
if (empty( $new_upload_path ))
|
663 |
+
return FALSE;
|
664 |
+
|
665 |
+
$wp_upload_dir = wp_upload_dir();
|
666 |
+
|
667 |
+
$default_upload_url = untrailingslashit ( $wp_upload_dir['baseurl'] );
|
668 |
+
$default_upload_url = str_replace( site_url(), "", $default_upload_url);
|
669 |
+
$default_upload_url = ltrim(rtrim($default_upload_url, "/"), "/");
|
670 |
+
|
671 |
+
$text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
|
672 |
+
$text .= "RewriteRule ^". $default_upload_url ."(.*) /404 [L]";
|
673 |
+
|
674 |
+
$processing_response['htaccess'] = $text;
|
675 |
+
|
676 |
+
return $processing_response;
|
677 |
+
|
678 |
+
|
679 |
+
}
|
680 |
+
|
681 |
+
|
682 |
+
}
|
683 |
+
|
684 |
+
|
685 |
+
?>
|
readme.txt
ADDED
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Plugin Name ===
|
2 |
+
Contributors: nsp-code
|
3 |
+
Donate link: http://www.nsp-code.com/donate.php
|
4 |
+
Tags: hide, security, improve security, hacking
|
5 |
+
Requires at least: 2.8
|
6 |
+
Tested up to: 4.4
|
7 |
+
Stable tag: 1.0
|
8 |
+
|
9 |
+
Hide and increase Security for your WordPress website instance using smart techniques. No files are changed on your server.
|
10 |
+
|
11 |
+
== Description ==
|
12 |
+
|
13 |
+
The easy way to completely hide your WordPress core files path from being show on front side. This is a huge improvement over Site Security. Provide a simple way to clean up html by removing WordPress fingerprints.
|
14 |
+
|
15 |
+
Being the best content management system, widely used, WordPress is susceptible to a large range of hacking attacks including brute-force, SQL injections, XSS, XSRF etc. Despite the fact the WordPress core is a very secure code maintained by a team of professional enthusiast, the additional plugins and themes makes the vulnerable spot of every website. In many cases, those are created by pseudo-developers who do not follow the best coding practices or simply do not own the experience to create a secure plugin.
|
16 |
+
Statistics reveal that every day new vulnerabilities are discovered, many affecting hundreds of thousands of WordPress websites.
|
17 |
+
Over 99,9% of hacked WordPress websites are target of automated malware scripts, who search for certain WordPress fingerprints. This plugin hide or replace those traces, making the hacking boots attacks useless.
|
18 |
+
|
19 |
+
Main plugin functionality:
|
20 |
+
|
21 |
+
* Custom admin Url
|
22 |
+
* Block default urls
|
23 |
+
* Custom wp-login.php filename
|
24 |
+
* Block default wo-login.php
|
25 |
+
* Adjustable theme url
|
26 |
+
* New child theme url
|
27 |
+
* Change theme style file name
|
28 |
+
* Custom wp-include
|
29 |
+
* Block default wp-include paths
|
30 |
+
* Custom plugins urls
|
31 |
+
* Block default plugins paths
|
32 |
+
* New upload url
|
33 |
+
* Block default upload urls
|
34 |
+
* Remove wordpress version
|
35 |
+
* Meta Generator block
|
36 |
+
* Remove wlwmanifest Meta
|
37 |
+
* Remove rsd_link Meta
|
38 |
+
|
39 |
+
and many more.
|
40 |
+
|
41 |
+
|
42 |
+
<br />Something is wrong with this plugin on your site? Just use the forum or get in touch with us at <a target="_blank" href="http://www.nsp-code.com">Contact</a> and we'll check it out.
|
43 |
+
|
44 |
+
<br />A website example can be found at <a target="_blank" href="http://nsp-code.com/demo/wp-hide/">http://nsp-code.com/demo/wp-hide/</a>
|
45 |
+
|
46 |
+
<br />
|
47 |
+
<br />This plugin is developed by <a target="_blank" href="http://www.nsp-code.com">Nsp-Code</a>
|
48 |
+
|
49 |
+
== Installation ==
|
50 |
+
|
51 |
+
1. Upload the plugin files to the `/wp-content/plugins/wp-hide` directory, or install the plugin through the WordPress plugins screen directly.
|
52 |
+
2. Activate the plugin through the 'Plugins' screen in WordPress.
|
53 |
+
3. Use the WP Hide screen to configure the plugin.
|
54 |
+
|
55 |
+
== Frequently Asked Questions ==
|
56 |
+
|
57 |
+
Feel free to contact us at electronice_delphi@yahoo.com
|
58 |
+
|
59 |
+
= I have no PHP knowledge at all, is this plugin for me? =
|
60 |
+
|
61 |
+
There's no requirements on php knowledge. All plugin features and functionality are applied automatically, controlled through a descriptive admin interface.
|
62 |
+
|
63 |
+
= I can't find a functionality that i feel i need =
|
64 |
+
|
65 |
+
Please get in touch with us and we'll do our best to include it for a later version.
|
66 |
+
|
67 |
+
== Screenshots ==
|
68 |
+
|
69 |
+
1. Admin Interface.
|
70 |
+
2. Sample front html code.
|
71 |
+
|
72 |
+
== Changelog ==
|
73 |
+
|
74 |
+
= 1.0 =
|
75 |
+
* Initial release.
|
76 |
+
|
77 |
+
== Upgrade Notice ==
|
78 |
+
|
79 |
+
Always keep plugin up to date.
|
80 |
+
|
81 |
+
|
82 |
+
== Localization ==
|
83 |
+
Available in English.
|
screenshot-1.png
ADDED
Binary file
|
screenshot-2.png
ADDED
Binary file
|
wp-hide.php
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: WP Hide & Security Enhancer
|
4 |
+
Plugin URI: http://www.nsp-code.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.0
|
9 |
+
Text Domain: wp-hide
|
10 |
+
Domain Path: /languages/
|
11 |
+
*/
|
12 |
+
|
13 |
+
|
14 |
+
define('WPH_PATH', plugin_dir_path(__FILE__));
|
15 |
+
|
16 |
+
//load language files
|
17 |
+
add_action( 'plugins_loaded', 'WPH_load_textdomain');
|
18 |
+
function WPH_load_textdomain()
|
19 |
+
{
|
20 |
+
load_plugin_textdomain('wp-hide', FALSE, dirname( plugin_basename( __FILE__ ) ) . '/languages');
|
21 |
+
}
|
22 |
+
|
23 |
+
include_once(WPH_PATH . '/include/wph.class.php');
|
24 |
+
include_once(WPH_PATH . '/include/functions.class.php');
|
25 |
+
include_once(WPH_PATH . '/include/module.class.php');
|
26 |
+
|
27 |
+
register_deactivation_hook(__FILE__, 'WPH_deactivated');
|
28 |
+
register_activation_hook(__FILE__, 'WPH_activated');
|
29 |
+
|
30 |
+
function WPH_activated($network_wide)
|
31 |
+
{
|
32 |
+
flush_rewrite_rules();
|
33 |
+
}
|
34 |
+
|
35 |
+
function WPH_deactivated()
|
36 |
+
{
|
37 |
+
global $wph;
|
38 |
+
|
39 |
+
$wph->uninstall = TRUE;
|
40 |
+
flush_rewrite_rules();
|
41 |
+
|
42 |
+
//redirect to old url
|
43 |
+
}
|
44 |
+
|
45 |
+
global $wph;
|
46 |
+
$wph = new WPH();
|
47 |
+
$wph->init();
|
48 |
+
|
49 |
+
define('WPH_URL', plugins_url('', __FILE__));
|
50 |
+
|
51 |
+
add_action( 'activated_plugin', array($wph, 'activated_plugin'), 999, 2 );
|
52 |
+
|
53 |
+
?>
|