Version Description
(25/03/2010) = * Feature: customization of the pagination permalinks; * Feature: "mod_gzip" and "mod_deflate".
Download this release
Release Info
Developer | andrad |
Plugin | WP htaccess Control |
Version | 1.5 |
Comparing to | |
See all releases |
Code changes from version 1.4.3 to 1.5
- readme.txt +45 -51
- screenshot-1.jpg +0 -0
- wp-htaccess-control-ui.php +36 -0
- wp-htaccess-control.php +99 -29
readme.txt
CHANGED
@@ -6,18 +6,19 @@ Donate link:
|
|
6 |
Tags: permalinks, permalink, author, htaccess, rewrite, redirect
|
7 |
Requires at least: 2.7
|
8 |
Tested up to: 2.9.2
|
9 |
-
Stable tag: 1.
|
10 |
|
11 |
-
Provides an interface to add custom htaccess rules to the htaccess file generated by Wordpress and customisation of the Author Permalink Base.
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
-
**WP htaccess Control** provides an interface to add custom htaccess rules to the htaccess file generated by Wordpress and customisation of the Author Permalink Base. (Take a look at the screenshot...)
|
16 |
|
17 |
**Features:**
|
18 |
|
19 |
* Adding custom rules to the htaccess file generated by Wordpress;
|
20 |
* Customizing the Author Permalink Base (if Google XML Sitemap is found installed, you'll be able to use your Custom Author Permalink on the sitemap generated);
|
|
|
21 |
|
22 |
**Easy to use "Suggested htaccess" rules:**
|
23 |
|
@@ -28,6 +29,8 @@ Provides an interface to add custom htaccess rules to the htaccess file generate
|
|
28 |
* Protect wp-config.php file from access;
|
29 |
* Protect .htaccess file from access;
|
30 |
* Set 500 error page;
|
|
|
|
|
31 |
* Set admin email on server generated error pages;
|
32 |
* Disable ServerSignature on server generated error pages.
|
33 |
|
@@ -46,75 +49,66 @@ Suggestions are of course very welcome and please report any bugs found!
|
|
46 |
|
47 |
== Screenshots ==
|
48 |
|
49 |
-
1. Administration page (as of v.1.
|
50 |
|
51 |
== Changelog ==
|
|
|
|
|
|
|
|
|
52 |
= 1.4.3 (22/03/2010) =
|
53 |
-
* Custom Author Permalink now working when using wp_list_authors (thank you HW for the report);
|
54 |
-
*
|
55 |
-
*
|
56 |
|
57 |
= 1.4.2 (12/03/2010) =
|
58 |
-
*
|
59 |
|
60 |
= 1.4.1 (12/03/2010) =
|
61 |
-
*
|
62 |
|
63 |
= 1.4 (12/03/2010) =
|
64 |
-
*
|
65 |
-
*
|
66 |
|
67 |
-
= 1.3 =
|
68 |
-
*
|
69 |
-
*
|
70 |
|
71 |
-
= 1.2.1 =
|
72 |
-
*
|
73 |
-
*
|
74 |
-
*
|
75 |
|
76 |
-
= 1.2 =
|
77 |
-
*
|
78 |
|
79 |
-
= 1.1.4 =
|
80 |
-
*
|
81 |
-
*
|
82 |
-
*
|
83 |
|
84 |
-
= 1.1.3 =
|
85 |
-
*
|
86 |
-
*
|
87 |
|
88 |
-
= 1.1.2 =
|
89 |
-
*
|
90 |
-
* Confirmed compatibility with WP 2.8
|
91 |
-
* Still some work to do on the interface.
|
92 |
|
93 |
-
= 1.1.1 =
|
94 |
-
*
|
95 |
|
96 |
-
= 1.1 =
|
97 |
-
*
|
98 |
-
*
|
99 |
|
100 |
-
= 1.0.1 =
|
101 |
* Added GNU license.
|
102 |
|
103 |
-
= 1.0 =
|
104 |
-
* Initial release (poor interface
|
105 |
|
106 |
== Upgrade Notice ==
|
107 |
= 1.4.1 =
|
108 |
* Clean up on debug left over from 1.4 for url canonization.
|
109 |
-
|
110 |
-
= 1.4 =
|
111 |
-
* Features added.
|
112 |
-
|
113 |
-
= 1.3 =
|
114 |
-
* Integrated the Custom Author Permalink with the Google XML Sitemap plugin.
|
115 |
-
|
116 |
-
= 1.2.1 =
|
117 |
-
* Fixed critical bugs inserted on 1.2, you should update.
|
118 |
-
|
119 |
-
= 1.2 =
|
120 |
-
* You should try the new htaccess customization possibilities.
|
6 |
Tags: permalinks, permalink, author, htaccess, rewrite, redirect
|
7 |
Requires at least: 2.7
|
8 |
Tested up to: 2.9.2
|
9 |
+
Stable tag: 1.5
|
10 |
|
11 |
+
Provides an interface to add custom htaccess rules to the htaccess file generated by Wordpress and customisation of the Author Permalink Base and of Paginated Permalinks.
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
+
**WP htaccess Control** provides an interface to add custom htaccess rules to the htaccess file generated by Wordpress and customisation of the Author Permalink Base and of Paginated Permalinks. (Take a look at the screenshot...)
|
16 |
|
17 |
**Features:**
|
18 |
|
19 |
* Adding custom rules to the htaccess file generated by Wordpress;
|
20 |
* Customizing the Author Permalink Base (if Google XML Sitemap is found installed, you'll be able to use your Custom Author Permalink on the sitemap generated);
|
21 |
+
* Customizing Paginated Permalinks (translate the "page" word on permalinks to your own language);
|
22 |
|
23 |
**Easy to use "Suggested htaccess" rules:**
|
24 |
|
29 |
* Protect wp-config.php file from access;
|
30 |
* Protect .htaccess file from access;
|
31 |
* Set 500 error page;
|
32 |
+
* Use mod_gzip if available;
|
33 |
+
* Use mod_deflate if available;
|
34 |
* Set admin email on server generated error pages;
|
35 |
* Disable ServerSignature on server generated error pages.
|
36 |
|
49 |
|
50 |
== Screenshots ==
|
51 |
|
52 |
+
1. Administration page (as of v.1.5)
|
53 |
|
54 |
== Changelog ==
|
55 |
+
= 1.5 (25/03/2010) =
|
56 |
+
* Feature: customization of the pagination permalinks;
|
57 |
+
* Feature: "mod_gzip" and "mod_deflate".
|
58 |
+
|
59 |
= 1.4.3 (22/03/2010) =
|
60 |
+
* Fix: Custom Author Permalink now working when using wp_list_authors (thank you HW for the report);
|
61 |
+
* Change: options page should now only be seen by admins;
|
62 |
+
* Change: prepared l10n.
|
63 |
|
64 |
= 1.4.2 (12/03/2010) =
|
65 |
+
* Change: minor documentation fix (readme).
|
66 |
|
67 |
= 1.4.1 (12/03/2010) =
|
68 |
+
* Fix: debug left over on 1.4 for url canonization.
|
69 |
|
70 |
= 1.4 (12/03/2010) =
|
71 |
+
* Feature: added "Suggested htaccess";
|
72 |
+
* Change: improved ui.
|
73 |
|
74 |
+
= 1.3 (10/03/2010) =
|
75 |
+
* Feature: integrated the Custom Author Permalink with the Google XML Sitemap plugin;
|
76 |
+
* Change: two fields to customize the htaccess were being used when only one was needed, for the sake of simplicity.
|
77 |
|
78 |
+
= 1.2.1 (15/02/2010) =
|
79 |
+
* Fix: bug on resetting all rules;
|
80 |
+
* Fix: critical bug on empty htaccess custom rules;
|
81 |
+
* Confirmed compatibility with WP 2.9.2.
|
82 |
|
83 |
+
= 1.2 (15/02/2010) =
|
84 |
+
* Change: improved htaccess customization giving now much more freedom.
|
85 |
|
86 |
+
= 1.1.4 (05/02/2010) =
|
87 |
+
* Fix: "Current htaccess file as it is generated by Wordpress" was not being printed;
|
88 |
+
* Change: minor ui changes;
|
89 |
+
* Confirmed compatibility with WP 2.9.1.
|
90 |
|
91 |
+
= 1.1.3 (06/07/2009) =
|
92 |
+
* Fix: mistake on wphtc_cap()'s preg_replace commited on 1.1.2 (thank you mattcav for the report);
|
93 |
+
* Fix: php warning on updating options without htaccess rules.
|
94 |
|
95 |
+
= 1.1.2 (01/07/2009) =
|
96 |
+
* Change: better options handling (no longer creating empty option array on install or reset);
|
97 |
+
* Confirmed compatibility with WP 2.8.
|
|
|
98 |
|
99 |
+
= 1.1.1 (09/04/2009) =
|
100 |
+
* Change: minor documentation fix (screenshot).
|
101 |
|
102 |
+
= 1.1 (09/04/2009) =
|
103 |
+
* Change: separated ui file;
|
104 |
+
* Change: improved management and ui.
|
105 |
|
106 |
+
= 1.0.1 (08/04/2009) =
|
107 |
* Added GNU license.
|
108 |
|
109 |
+
= 1.0 (08/04/2009) =
|
110 |
+
* Initial public release (poor interface).
|
111 |
|
112 |
== Upgrade Notice ==
|
113 |
= 1.4.1 =
|
114 |
* Clean up on debug left over from 1.4 for url canonization.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
screenshot-1.jpg
CHANGED
Binary file
|
wp-htaccess-control-ui.php
CHANGED
@@ -49,6 +49,26 @@ $WPhtc_data=get_option('WPhtc_data');
|
|
49 |
<?php } ?>
|
50 |
</table>
|
51 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
<div class="wphtc-section">
|
53 |
<div class="wphtc-section-title stuffbox">
|
54 |
<div title="Click to toggle" class="handlediv" style="background:url('<?php bloginfo("wpurl")?>/wp-admin/images/menu-bits.gif') no-repeat scroll left -111px transparent"><br></div>
|
@@ -104,6 +124,22 @@ $WPhtc_data=get_option('WPhtc_data');
|
|
104 |
</td>
|
105 |
<td valign="middle"><?php _e('Deny access to .htaccess file.', 'wp-htaccess-control'); ?></td>
|
106 |
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
<tr valign="top">
|
108 |
<th scope="row"><?php _e('Limit Upload Size', 'wp-htaccess-control'); ?></th>
|
109 |
<td style="width:3%;" valign="middle">
|
49 |
<?php } ?>
|
50 |
</table>
|
51 |
</div>
|
52 |
+
<div class="wphtc-section">
|
53 |
+
<div class="wphtc-section-title stuffbox">
|
54 |
+
<div title="Click to toggle" class="handlediv" style="background:url('<?php bloginfo("wpurl")?>/wp-admin/images/menu-bits.gif') no-repeat scroll left -111px transparent"><br></div>
|
55 |
+
<h3><?php _e('Custom Pagination Permalink', 'wp-htaccess-control');?></h3>
|
56 |
+
</div>
|
57 |
+
<table class="form-table wphtc-inputs">
|
58 |
+
<tr valign="top">
|
59 |
+
<th scope="row" style="width:18%;"><?php _e('Page Base', 'wp-htaccess-control'); ?></th>
|
60 |
+
<td >
|
61 |
+
<input type="text" name="WPhtc_cpp" value="<?php echo $WPhtc_data['cpp']; ?>" />
|
62 |
+
<p><code><?php bloginfo('home')?>/<em><?php _e('(your-base)', 'wp-htaccess-control');?></em>/2</code></p>
|
63 |
+
</td>
|
64 |
+
<td valign="middle">
|
65 |
+
<p class="description"><?php _e('Permalink settings must be set and not Default (/?p=123).', 'wp-htaccess-control'); ?></p>
|
66 |
+
<p class="description"><?php _e('If set, the page base will be used as shown next to the form field in every post listing (category, tag, archive, etc).', 'wp-htaccess-control'); ?></p>
|
67 |
+
<p class="description"><?php _e('If you do not want to use a custom Pagination Permalink base just leave the field empty.', 'wp-htaccess-control'); ?></p>
|
68 |
+
</td>
|
69 |
+
</tr>
|
70 |
+
</table>
|
71 |
+
</div>
|
72 |
<div class="wphtc-section">
|
73 |
<div class="wphtc-section-title stuffbox">
|
74 |
<div title="Click to toggle" class="handlediv" style="background:url('<?php bloginfo("wpurl")?>/wp-admin/images/menu-bits.gif') no-repeat scroll left -111px transparent"><br></div>
|
124 |
</td>
|
125 |
<td valign="middle"><?php _e('Deny access to .htaccess file.', 'wp-htaccess-control'); ?></td>
|
126 |
</tr>
|
127 |
+
<tr valign="top">
|
128 |
+
<th scope="row"><?php _e('mod_gzip', 'wp-htaccess-control'); ?></th>
|
129 |
+
<td style="width:3%;" valign="middle">
|
130 |
+
<input type="checkbox" name="WPhtc_gzip" value="true" <?php if($WPhtc_data['gzip']){ echo "checked";}?>/>
|
131 |
+
</td>
|
132 |
+
<td valign="middle"><?php _e('Use mod_gzip if available.', 'wp-htaccess-control'); ?></td>
|
133 |
+
</tr>
|
134 |
+
<tr valign="top">
|
135 |
+
<th scope="row"><?php _e('mod_deflate', 'wp-htaccess-control'); ?></th>
|
136 |
+
<td style="width:3%;" valign="middle">
|
137 |
+
<input type="checkbox" name="WPhtc_deflate" value="true" <?php if($WPhtc_data['deflate']){ echo "checked";}?>/>
|
138 |
+
</td>
|
139 |
+
<td valign="middle"><?php _e('Use mod_deflate if available.', 'wp-htaccess-control'); ?></td>
|
140 |
+
</tr>
|
141 |
+
|
142 |
+
|
143 |
<tr valign="top">
|
144 |
<th scope="row"><?php _e('Limit Upload Size', 'wp-htaccess-control'); ?></th>
|
145 |
<td style="width:3%;" valign="middle">
|
wp-htaccess-control.php
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
/*
|
3 |
Plugin Name: WP htaccess Control
|
4 |
Plugin URI: http://dardna.com/wp-htaccess-control
|
5 |
-
Description: Provides an interface to add custom htaccess rules to the htaccess file generated by wordpress. Also provides customisation of the Author Permalink Base.
|
6 |
-
Version: 1.
|
7 |
Author: António Andrade
|
8 |
Author URI: http://dardna.com
|
9 |
*/
|
@@ -34,13 +34,14 @@ if (!class_exists("WPhtc")) {
|
|
34 |
if(@file_exists($moFile) && is_readable($moFile)) load_textdomain('wp-htaccess-control', $moFile);
|
35 |
}
|
36 |
}
|
37 |
-
#
|
38 |
-
function
|
39 |
$WPhtc_data=get_option('WPhtc_data');
|
40 |
-
if(isset($WPhtc_data['
|
41 |
-
$
|
|
|
42 |
}
|
43 |
-
return $
|
44 |
}
|
45 |
# Filter link generated by get_author_posts_url() to use the Custom Author Permalink
|
46 |
function wphtc_filter_author_link($link){
|
@@ -50,6 +51,31 @@ if (!class_exists("WPhtc")) {
|
|
50 |
}
|
51 |
return $link;
|
52 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
# Adding our Custom Author Base to the sitemap generated by Google XML Sitemaps
|
54 |
# Adapted from sitemap-core.php line 2036
|
55 |
function set_sm(){
|
@@ -104,80 +130,103 @@ if (!class_exists("WPhtc")) {
|
|
104 |
if($WPhtc_data['hta']){
|
105 |
$new_rules.="\n# WPhtc: Begin Custom htaccess\n";
|
106 |
$new_rules.=$WPhtc_data['hta']."\n";
|
107 |
-
$new_rules.="# WPhtc: End Custom htaccess\n
|
108 |
}
|
109 |
# htaccess suggestions
|
110 |
if($WPhtc_data['disable_serversignature']){
|
111 |
-
$new_rules.="# WPhtC: Disable ServerSignature on generated error pages\n";
|
112 |
-
$new_rules.="ServerSignature Off\n
|
113 |
}
|
114 |
if($WPhtc_data['admin_email']){
|
115 |
-
$new_rules.="# WPhtC: Set admin email\n";
|
116 |
$new_rules.="SetEnv SERVER_ADMIN ".$WPhtc_data['admin_email']."\n\n";
|
117 |
}
|
118 |
if($WPhtc_data['disable_indexes']){
|
119 |
-
$new_rules.="# WPhtC: Disable directory browsing\n";
|
120 |
-
$new_rules.="Options All -Indexes\n
|
121 |
}
|
122 |
if($WPhtc_data['up_limit']){
|
123 |
-
$new_rules.="# WPhtC: Limit upload size to ".$WPhtc_data['up_limit']." MB\n";
|
124 |
-
$new_rules.="LimitRequestBody ".($WPhtc_data['up_limit']*1024*1024)." \n
|
125 |
}
|
126 |
if($WPhtc_data['redirect_500']){
|
127 |
-
$new_rules.="# WPhtC: Setting 500 Error page\n";
|
128 |
-
$new_rules.="ErrorDocument 500 ".$WPhtc_data['redirect_500']."\n
|
129 |
}
|
130 |
if($WPhtc_data['protect_wp_config']){
|
131 |
-
$new_rules.="# WPhtC: Protect WP-config.php\n";
|
132 |
$new_rules.="<files wp-config.php>\n";
|
133 |
$new_rules.="order allow,deny\n";
|
134 |
$new_rules.="deny from all\n";
|
135 |
-
$new_rules.="</files>\n
|
136 |
}
|
137 |
if($WPhtc_data['protect_htaccess']){
|
138 |
-
$new_rules.="# WPhtC: Protect .htaccess file\n";
|
139 |
$new_rules.="<files ~ \"^.*\.([Hh][Tt][Aa])\">\n";
|
140 |
$new_rules.="order allow,deny\n";
|
141 |
$new_rules.="deny from all\n";
|
142 |
-
$new_rules.="</files>\n
|
143 |
}
|
144 |
if($WPhtc_data['disable_hotlink']){
|
145 |
-
$new_rules.="# WPhtC: Disable image hotlinking\n";
|
146 |
$new_rules.="<IfModule mod_rewrite.c>\n";
|
147 |
$new_rules.="RewriteEngine On\n";
|
148 |
$new_rules.="RewriteCond %{HTTP_REFERER} !^$\n";
|
149 |
$new_rules.="RewriteCond %{HTTP_REFERER} !^http://(www\.)?".str_ireplace(array("http://","www."),"",get_bloginfo("url"))."/.*$ [NC]\n";
|
150 |
$new_rules.="RewriteRule \.(jpg|jpeg|png|gif)$ ".$WPhtc_data['disable_hotlink']." [NC,R,L]\n";
|
151 |
-
$new_rules.="</IfModule>\n
|
152 |
}
|
153 |
if($WPhtc_data['canon']){
|
154 |
$url=str_ireplace(array("http://","www."),"",get_bloginfo("url"));
|
155 |
$domain=explode("/",$url);
|
156 |
$escaped_domain=str_ireplace(".","\.",$domain[0]);
|
157 |
if($WPhtc_data['canon']=='www'){
|
158 |
-
$new_rules.="# WPhtC: Setting WWW canon\n";
|
159 |
$new_rules.="<IfModule mod_rewrite.c>\n";
|
160 |
$new_rules.="RewriteEngine On\n";
|
161 |
$new_rules.="RewriteCond %{HTTP_HOST} ^".$escaped_domain." [NC] \n";
|
162 |
$new_rules.="RewriteRule (.*) http://www.".$domain[0]."/$1 [R=301,L]\n";
|
163 |
-
$new_rules.="</IfModule>\n
|
164 |
}
|
165 |
else if($WPhtc_data['canon']=='simple'){
|
166 |
-
$new_rules.="# WPhtC: Setting canon to non-WWW\n";
|
167 |
$new_rules.="<IfModule mod_rewrite.c>\n";
|
168 |
$new_rules.="RewriteEngine On\n";
|
169 |
$new_rules.="RewriteCond %{HTTP_HOST} ^www\.".$escaped_domain." [NC] \n";
|
170 |
$new_rules.="RewriteRule (.*) http://".$domain[0]."/$1 [R=301,L]\n";
|
171 |
-
$new_rules.="</IfModule>\n
|
172 |
}
|
173 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
174 |
// DEPRECATE LATER (mod_rewrite)
|
175 |
if($WPhtc_data['hta_mr']!=''){
|
176 |
$insert="\n\n# WPhtc: Begin Custom htaccess\n".$WPhtc_data['hta_mr']."\n# WPhtc: End Custom htaccess\n";
|
177 |
$new_rules.=str_replace("RewriteEngine On","RewriteEngine On".$insert,$rules);
|
178 |
}
|
179 |
else{
|
180 |
-
$new_rules
|
181 |
}
|
182 |
return $new_rules;
|
183 |
}
|
@@ -238,6 +287,8 @@ if (!class_exists("WPhtc")) {
|
|
238 |
unset($WPhtc_data['hta_mr']);
|
239 |
# get Custom Author Permalink
|
240 |
$WPhtc_data['cap']=$_POST['WPhtc_cap'];
|
|
|
|
|
241 |
# get htaccess Suggestions
|
242 |
$WPhtc_data['disable_serversignature']=$_POST['WPhtc_disable_serversignature'];
|
243 |
$WPhtc_data['disable_indexes']=$_POST['WPhtc_disable_indexes'];
|
@@ -248,6 +299,8 @@ if (!class_exists("WPhtc")) {
|
|
248 |
$WPhtc_data['redirect_500']=trim($_POST['WPhtc_redirect_500']);
|
249 |
$WPhtc_data['canon']=$_POST['WPhtc_canon'];
|
250 |
$WPhtc_data['admin_email']=trim($_POST['WPhtc_admin_email']);
|
|
|
|
|
251 |
|
252 |
# Unsetting inclusion of Author pages on Google XML Sitemap options, we'll add those links to the sitemap later with our Custom Author Permalink
|
253 |
$WPhtc_data['sm_enabled']=$_POST['WPhtc_sm_enabled'];
|
@@ -290,6 +343,21 @@ if (!class_exists("WPhtc")) {
|
|
290 |
}
|
291 |
}
|
292 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
293 |
}
|
294 |
}
|
295 |
if (class_exists("WPhtc")) {
|
@@ -298,8 +366,10 @@ if (class_exists("WPhtc")) {
|
|
298 |
if (isset($WPhtc)) {
|
299 |
add_filter('mod_rewrite_rules', array($WPhtc,'wphtc_hta_rules'));
|
300 |
add_filter('generate_rewrite_rules', array($WPhtc,'wphtc_wp_rewrite_rules'));
|
301 |
-
add_filter('rewrite_rules_array',array($WPhtc,'
|
302 |
add_filter('author_link',array($WPhtc,'wphtc_filter_author_link'));
|
|
|
|
|
303 |
add_action('admin_menu', array($WPhtc,'configure_menu'));
|
304 |
add_action('sm_buildmap',array($WPhtc,'set_sm'));
|
305 |
add_action('init', array($WPhtc,'wphtc_init'));
|
2 |
/*
|
3 |
Plugin Name: WP htaccess Control
|
4 |
Plugin URI: http://dardna.com/wp-htaccess-control
|
5 |
+
Description: Provides an interface to add custom htaccess rules to the htaccess file generated by wordpress. Also provides customisation of the Author Permalink Base and of Paginated Permalinks.
|
6 |
+
Version: 1.5
|
7 |
Author: António Andrade
|
8 |
Author URI: http://dardna.com
|
9 |
*/
|
34 |
if(@file_exists($moFile) && is_readable($moFile)) load_textdomain('wp-htaccess-control', $moFile);
|
35 |
}
|
36 |
}
|
37 |
+
# Filter pagination links generated by Wordpress
|
38 |
+
function wphtc_filter_get_pagenum_link($result){
|
39 |
$WPhtc_data=get_option('WPhtc_data');
|
40 |
+
if(isset($WPhtc_data['cpp'])&&$WPhtc_data['cpp']!=''){
|
41 |
+
$result=preg_replace("/".$WPhtc_data['cpp']."\/[0-9]+\//","",$result);
|
42 |
+
$result=str_replace("page",$WPhtc_data['cpp'],$result);
|
43 |
}
|
44 |
+
return $result;
|
45 |
}
|
46 |
# Filter link generated by get_author_posts_url() to use the Custom Author Permalink
|
47 |
function wphtc_filter_author_link($link){
|
51 |
}
|
52 |
return $link;
|
53 |
}
|
54 |
+
# Disable canonical redirection on urls using custom pagination permalink
|
55 |
+
function wphtc_filter_redirect_canonical($redirect_url,$requested_url){
|
56 |
+
$WPhtc_data=get_option('WPhtc_data');
|
57 |
+
if(isset($WPhtc_data['cpp'])&&$WPhtc_data['cpp']!=''&&get_query_var('paged') > 1&&strpos($requested_url,$WPhtc_data['cpp'])){
|
58 |
+
return false;
|
59 |
+
}
|
60 |
+
else{
|
61 |
+
return $redirect_url;
|
62 |
+
}
|
63 |
+
}
|
64 |
+
# Replacing the Wordpress Author Permalink by rewriting its rules if we have a Custom Author Permalink, everytime the rules are flush
|
65 |
+
function wphtc_filter_rewrite_rules($rules){
|
66 |
+
$WPhtc_data=get_option('WPhtc_data');
|
67 |
+
if((isset($WPhtc_data['cap'])&&$WPhtc_data['cap']!='')||(isset($WPhtc_data['cpp'])&&$WPhtc_data['cpp']!='')){
|
68 |
+
$rules=serialize($rules);
|
69 |
+
if(isset($WPhtc_data['cap'])&&$WPhtc_data['cap']!=''){
|
70 |
+
$rules=str_replace('author/',$WPhtc_data['cap'].'/',$rules);
|
71 |
+
}
|
72 |
+
if(isset($WPhtc_data['cpp'])&&$WPhtc_data['cpp']!=''){
|
73 |
+
$rules=str_replace('page/',$WPhtc_data['cpp'].'/',$rules);
|
74 |
+
}
|
75 |
+
$rules=unserialize(preg_replace('!s:(\d+):"(.*?)";!se', "'s:'.strlen('$2').':\"$2\";'",$rules));
|
76 |
+
}
|
77 |
+
return $rules;
|
78 |
+
}
|
79 |
# Adding our Custom Author Base to the sitemap generated by Google XML Sitemaps
|
80 |
# Adapted from sitemap-core.php line 2036
|
81 |
function set_sm(){
|
130 |
if($WPhtc_data['hta']){
|
131 |
$new_rules.="\n# WPhtc: Begin Custom htaccess\n";
|
132 |
$new_rules.=$WPhtc_data['hta']."\n";
|
133 |
+
$new_rules.="# WPhtc: End Custom htaccess\n";
|
134 |
}
|
135 |
# htaccess suggestions
|
136 |
if($WPhtc_data['disable_serversignature']){
|
137 |
+
$new_rules.="\n# WPhtC: Disable ServerSignature on generated error pages\n";
|
138 |
+
$new_rules.="ServerSignature Off\n";
|
139 |
}
|
140 |
if($WPhtc_data['admin_email']){
|
141 |
+
$new_rules.="\n# WPhtC: Set admin email\n";
|
142 |
$new_rules.="SetEnv SERVER_ADMIN ".$WPhtc_data['admin_email']."\n\n";
|
143 |
}
|
144 |
if($WPhtc_data['disable_indexes']){
|
145 |
+
$new_rules.="\n# WPhtC: Disable directory browsing\n";
|
146 |
+
$new_rules.="Options All -Indexes\n";
|
147 |
}
|
148 |
if($WPhtc_data['up_limit']){
|
149 |
+
$new_rules.="\n# WPhtC: Limit upload size to ".$WPhtc_data['up_limit']." MB\n";
|
150 |
+
$new_rules.="LimitRequestBody ".($WPhtc_data['up_limit']*1024*1024)." \n";
|
151 |
}
|
152 |
if($WPhtc_data['redirect_500']){
|
153 |
+
$new_rules.="\n# WPhtC: Setting 500 Error page\n";
|
154 |
+
$new_rules.="ErrorDocument 500 ".$WPhtc_data['redirect_500']."\n";
|
155 |
}
|
156 |
if($WPhtc_data['protect_wp_config']){
|
157 |
+
$new_rules.="\n# WPhtC: Protect WP-config.php\n";
|
158 |
$new_rules.="<files wp-config.php>\n";
|
159 |
$new_rules.="order allow,deny\n";
|
160 |
$new_rules.="deny from all\n";
|
161 |
+
$new_rules.="</files>\n";
|
162 |
}
|
163 |
if($WPhtc_data['protect_htaccess']){
|
164 |
+
$new_rules.="\n# WPhtC: Protect .htaccess file\n";
|
165 |
$new_rules.="<files ~ \"^.*\.([Hh][Tt][Aa])\">\n";
|
166 |
$new_rules.="order allow,deny\n";
|
167 |
$new_rules.="deny from all\n";
|
168 |
+
$new_rules.="</files>\n";
|
169 |
}
|
170 |
if($WPhtc_data['disable_hotlink']){
|
171 |
+
$new_rules.="\n# WPhtC: Disable image hotlinking\n";
|
172 |
$new_rules.="<IfModule mod_rewrite.c>\n";
|
173 |
$new_rules.="RewriteEngine On\n";
|
174 |
$new_rules.="RewriteCond %{HTTP_REFERER} !^$\n";
|
175 |
$new_rules.="RewriteCond %{HTTP_REFERER} !^http://(www\.)?".str_ireplace(array("http://","www."),"",get_bloginfo("url"))."/.*$ [NC]\n";
|
176 |
$new_rules.="RewriteRule \.(jpg|jpeg|png|gif)$ ".$WPhtc_data['disable_hotlink']." [NC,R,L]\n";
|
177 |
+
$new_rules.="</IfModule>\n";
|
178 |
}
|
179 |
if($WPhtc_data['canon']){
|
180 |
$url=str_ireplace(array("http://","www."),"",get_bloginfo("url"));
|
181 |
$domain=explode("/",$url);
|
182 |
$escaped_domain=str_ireplace(".","\.",$domain[0]);
|
183 |
if($WPhtc_data['canon']=='www'){
|
184 |
+
$new_rules.="\n# WPhtC: Setting WWW canon\n";
|
185 |
$new_rules.="<IfModule mod_rewrite.c>\n";
|
186 |
$new_rules.="RewriteEngine On\n";
|
187 |
$new_rules.="RewriteCond %{HTTP_HOST} ^".$escaped_domain." [NC] \n";
|
188 |
$new_rules.="RewriteRule (.*) http://www.".$domain[0]."/$1 [R=301,L]\n";
|
189 |
+
$new_rules.="</IfModule>\n";
|
190 |
}
|
191 |
else if($WPhtc_data['canon']=='simple'){
|
192 |
+
$new_rules.="\n# WPhtC: Setting canon to non-WWW\n";
|
193 |
$new_rules.="<IfModule mod_rewrite.c>\n";
|
194 |
$new_rules.="RewriteEngine On\n";
|
195 |
$new_rules.="RewriteCond %{HTTP_HOST} ^www\.".$escaped_domain." [NC] \n";
|
196 |
$new_rules.="RewriteRule (.*) http://".$domain[0]."/$1 [R=301,L]\n";
|
197 |
+
$new_rules.="</IfModule>\n";
|
198 |
}
|
199 |
}
|
200 |
+
if($WPhtc_data['gzip']){
|
201 |
+
$new_rules.="\n# WPhtC: Setting mod_gzip\n";
|
202 |
+
$new_rules.="<ifModule mod_gzip.c>\n";
|
203 |
+
$new_rules.="mod_gzip_on Yes\n";
|
204 |
+
$new_rules.="mod_gzip_dechunk Yes\n";
|
205 |
+
$new_rules.="mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$\n";
|
206 |
+
$new_rules.="mod_gzip_item_include handler ^cgi-script$\n";
|
207 |
+
$new_rules.="mod_gzip_item_include mime ^text/.*\n";
|
208 |
+
$new_rules.="mod_gzip_item_include mime ^application/x-javascript.*\n";
|
209 |
+
$new_rules.="mod_gzip_item_exclude mime ^image/.*\n";
|
210 |
+
$new_rules.="mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*\n";
|
211 |
+
$new_rules.="</ifModule>\n";
|
212 |
+
}
|
213 |
+
if($WPhtc_data['deflate']){
|
214 |
+
$new_rules.="\n# WPhtC: Setting mod_deflate\n";
|
215 |
+
$new_rules.="<IfModule mod_deflate.c>\n";
|
216 |
+
$new_rules.="AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/javascript text/css application/x-javascript\n";
|
217 |
+
$new_rules.="BrowserMatch ^Mozilla/4 gzip-only-text/html\n";
|
218 |
+
$new_rules.="BrowserMatch ^Mozilla/4.0[678] no-gzip\n";
|
219 |
+
$new_rules.="BrowserMatch bMSIE !no-gzip !gzip-only-text/html\n";
|
220 |
+
$new_rules.="Header append Vary User-Agent env=!dont-vary\n";
|
221 |
+
$new_rules.="</IfModule>\n";
|
222 |
+
}
|
223 |
// DEPRECATE LATER (mod_rewrite)
|
224 |
if($WPhtc_data['hta_mr']!=''){
|
225 |
$insert="\n\n# WPhtc: Begin Custom htaccess\n".$WPhtc_data['hta_mr']."\n# WPhtc: End Custom htaccess\n";
|
226 |
$new_rules.=str_replace("RewriteEngine On","RewriteEngine On".$insert,$rules);
|
227 |
}
|
228 |
else{
|
229 |
+
$new_rules.="\n".$rules;
|
230 |
}
|
231 |
return $new_rules;
|
232 |
}
|
287 |
unset($WPhtc_data['hta_mr']);
|
288 |
# get Custom Author Permalink
|
289 |
$WPhtc_data['cap']=$_POST['WPhtc_cap'];
|
290 |
+
# get Custom Pagination Permalink
|
291 |
+
$WPhtc_data['cpp']=$_POST['WPhtc_cpp'];
|
292 |
# get htaccess Suggestions
|
293 |
$WPhtc_data['disable_serversignature']=$_POST['WPhtc_disable_serversignature'];
|
294 |
$WPhtc_data['disable_indexes']=$_POST['WPhtc_disable_indexes'];
|
299 |
$WPhtc_data['redirect_500']=trim($_POST['WPhtc_redirect_500']);
|
300 |
$WPhtc_data['canon']=$_POST['WPhtc_canon'];
|
301 |
$WPhtc_data['admin_email']=trim($_POST['WPhtc_admin_email']);
|
302 |
+
$WPhtc_data['deflate']=trim($_POST['WPhtc_deflate']);
|
303 |
+
$WPhtc_data['gzip']=trim($_POST['WPhtc_gzip']);
|
304 |
|
305 |
# Unsetting inclusion of Author pages on Google XML Sitemap options, we'll add those links to the sitemap later with our Custom Author Permalink
|
306 |
$WPhtc_data['sm_enabled']=$_POST['WPhtc_sm_enabled'];
|
343 |
}
|
344 |
}
|
345 |
}
|
346 |
+
function formatted_print_r($data) {
|
347 |
+
if(is_array($data)) { //If the given variable is an array, print using the print_r function.
|
348 |
+
print "<pre>-----------------------\n";
|
349 |
+
print_r($data);
|
350 |
+
print "-----------------------</pre>";
|
351 |
+
} elseif (is_object($data)) {
|
352 |
+
print "<pre>==========================\n";
|
353 |
+
var_dump($data);
|
354 |
+
print "===========================</pre>";
|
355 |
+
} else {
|
356 |
+
print "=========> ";
|
357 |
+
var_dump($data);
|
358 |
+
print " <=========";
|
359 |
+
}
|
360 |
+
}
|
361 |
}
|
362 |
}
|
363 |
if (class_exists("WPhtc")) {
|
366 |
if (isset($WPhtc)) {
|
367 |
add_filter('mod_rewrite_rules', array($WPhtc,'wphtc_hta_rules'));
|
368 |
add_filter('generate_rewrite_rules', array($WPhtc,'wphtc_wp_rewrite_rules'));
|
369 |
+
add_filter('rewrite_rules_array',array($WPhtc,'wphtc_filter_rewrite_rules'));
|
370 |
add_filter('author_link',array($WPhtc,'wphtc_filter_author_link'));
|
371 |
+
add_filter('get_pagenum_link',array($WPhtc,'wphtc_filter_get_pagenum_link'));
|
372 |
+
add_filter('redirect_canonical',array($WPhtc,'wphtc_filter_redirect_canonical'),10,4);
|
373 |
add_action('admin_menu', array($WPhtc,'configure_menu'));
|
374 |
add_action('sm_buildmap',array($WPhtc,'set_sm'));
|
375 |
add_action('init', array($WPhtc,'wphtc_init'));
|