Version Description
(01/07/2012) =
- Added option to force removal of taxonomy hierarchy from permalinks;
- Only supporting WordPress > 3.4 from now on;
- Fix tax link filter;
- Fix rules reset;
- Smaller fixes;
- Tested under 3.4.1.
Download this release
Release Info
Developer | antonioandra.de |
Plugin | WP htaccess Control |
Version | 3.3 |
Comparing to | |
See all releases |
Code changes from version 3.2.1 to 3.3
- readme.txt +17 -2
- wp-htaccess-control-ui.php +27 -0
- wp-htaccess-control.php +44 -49
readme.txt
CHANGED
@@ -5,8 +5,8 @@ Plugin URI: http://antonioandra.de/wp-htaccess-control
|
|
5 |
Contributors: antonioandra.de
|
6 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=s4mancha%40gmail%2ecom&lc=US&item_name=WP%20htaccess%20Control%20%28Antonio%20Andrade%29&no_note=0¤cy_code=EUR&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHostedGuest
|
7 |
Tags: permalinks, permalink, author, htaccess, rewrite, redirect, admin, maintenance, pagination, category, category base, archive, archives
|
8 |
-
Requires at least:
|
9 |
-
Tested up to: 3.
|
10 |
Stable tag: 3.2.1
|
11 |
|
12 |
Interface to customize the permalinks (author, category, archives and pagination) and htaccess file generated by Wordpress.
|
@@ -74,8 +74,23 @@ I still haven't tested this under **Wordpress multisite**, issues have however b
|
|
74 |
Removal of the category base is based on iDope's **WP No Category Base** but extended so that it works with category archives (ie.: *"http://example.com/my-category/2010/12"*).
|
75 |
Search redirection is based on Mark Jaquith's **Nice Search** but extended so that it works with custom search base (ie.: *"http://example.com/search-base/search-term"*).
|
76 |
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
== Changelog ==
|
78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
= 3.2.1 (29/04/2012) =
|
80 |
* Forcing 3.2.1.
|
81 |
|
5 |
Contributors: antonioandra.de
|
6 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=s4mancha%40gmail%2ecom&lc=US&item_name=WP%20htaccess%20Control%20%28Antonio%20Andrade%29&no_note=0¤cy_code=EUR&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHostedGuest
|
7 |
Tags: permalinks, permalink, author, htaccess, rewrite, redirect, admin, maintenance, pagination, category, category base, archive, archives
|
8 |
+
Requires at least: 3.4
|
9 |
+
Tested up to: 3.4.1
|
10 |
Stable tag: 3.2.1
|
11 |
|
12 |
Interface to customize the permalinks (author, category, archives and pagination) and htaccess file generated by Wordpress.
|
74 |
Removal of the category base is based on iDope's **WP No Category Base** but extended so that it works with category archives (ie.: *"http://example.com/my-category/2010/12"*).
|
75 |
Search redirection is based on Mark Jaquith's **Nice Search** but extended so that it works with custom search base (ie.: *"http://example.com/search-base/search-term"*).
|
76 |
|
77 |
+
== Stable Versions ==
|
78 |
+
|
79 |
+
For WordPress versions above 3.4 use the plugin version 3.3.
|
80 |
+
For WordPress versions prior to 3.4 use the plugin version 2.7.2.
|
81 |
+
|
82 |
+
|
83 |
== Changelog ==
|
84 |
|
85 |
+
= 3.3 (01/07/2012) =
|
86 |
+
|
87 |
+
* Added option to force removal of taxonomy hierarchy from permalinks;
|
88 |
+
* Only supporting WordPress > 3.4 from now on;
|
89 |
+
* Fix tax link filter;
|
90 |
+
* Fix rules reset;
|
91 |
+
* Smaller fixes;
|
92 |
+
* Tested under 3.4.1.
|
93 |
+
|
94 |
= 3.2.1 (29/04/2012) =
|
95 |
* Forcing 3.2.1.
|
96 |
|
wp-htaccess-control-ui.php
CHANGED
@@ -215,6 +215,33 @@ $WPhtc->page_action();
|
|
215 |
?>
|
216 |
</table>
|
217 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
218 |
<!-- Custom htaccess -->
|
219 |
<div class="wphtc-section">
|
220 |
<div class="wphtc-section-title stuffbox">
|
215 |
?>
|
216 |
</table>
|
217 |
</div>
|
218 |
+
<!-- More Rewrite Settings -->
|
219 |
+
<div class="wphtc-section">
|
220 |
+
<div class="wphtc-section-title stuffbox">
|
221 |
+
<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>
|
222 |
+
<h3><?php _e('More Rewrite Settings', 'wp-htaccess-control');?></h3>
|
223 |
+
</div>
|
224 |
+
<table class="form-table wphtc-inputs">
|
225 |
+
<tr valign="top">
|
226 |
+
<th scope="row" style="width:18%;"><?php _e("Remove hierarchy", 'wp-htaccess-control'); ?></th>
|
227 |
+
<td style="width:3%;" valign="middle">
|
228 |
+
<input type="checkbox" name="WPhtc_remove_hierarchy" value="true" <?php if($WPhtc->data['remove_hierarchy']){ echo "checked";}?>/>
|
229 |
+
</td>
|
230 |
+
<td valign="middle">
|
231 |
+
<p class="description"><?php _e("Remove hierarchy from taxonomy permalinks (this might be interesting when removing the category base).", 'wp-htaccess-control'); ?></p>
|
232 |
+
</td>
|
233 |
+
</tr>
|
234 |
+
<!--<tr valign="top">
|
235 |
+
<th scope="row" style="width:18%;"><?php _e(".html suffix", 'wp-htaccess-control'); ?></th>
|
236 |
+
<td style="width:3%;" valign="middle">
|
237 |
+
<input type="checkbox" name="WPhtc_suffix_html" value="true" <?php if($WPhtc->data['suffix_html']){ echo "checked";}?>/>
|
238 |
+
</td>
|
239 |
+
<td valign="middle">
|
240 |
+
<p class="description"><?php _e("Add '.html' at the end of taxonomy permalinks.", 'wp-htaccess-control'); ?></p>
|
241 |
+
</td>
|
242 |
+
</tr>-->
|
243 |
+
</table>
|
244 |
+
</div>
|
245 |
<!-- Custom htaccess -->
|
246 |
<div class="wphtc-section">
|
247 |
<div class="wphtc-section-title stuffbox">
|
wp-htaccess-control.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: WP htaccess Control
|
4 |
Plugin URI: http://dardna.com/wp-htaccess-control
|
5 |
Description: Interface to customize the permalinks (author, category, archives and pagination) and htaccess file generated by Wordpress.
|
6 |
-
Version: 3.
|
7 |
Author: António Andrade
|
8 |
Author URI: http://antonioandra.de
|
9 |
*/
|
@@ -173,7 +173,8 @@ if (!class_exists("WPhtc")) {
|
|
173 |
function term_ancestors($tax,$id){
|
174 |
$term=get_term($id,$tax);
|
175 |
$ancestor=$term->slug;
|
176 |
-
|
|
|
177 |
$ancestor=$this->term_ancestors($tax,$term->parent)."/".$ancestor;
|
178 |
}
|
179 |
return $ancestor;
|
@@ -181,6 +182,7 @@ if (!class_exists("WPhtc")) {
|
|
181 |
# Rewrite Rules: Add Category + Tag + Author Archives; Custom Pagination; Custom Author Base
|
182 |
function filter_rewrite_rules($rewrite_rules){
|
183 |
|
|
|
184 |
|
185 |
$page_base=($this->data['cpp']!='')?$this->data['cpp']:'page';
|
186 |
|
@@ -190,14 +192,24 @@ if (!class_exists("WPhtc")) {
|
|
190 |
$terms=get_terms($taxonomy->name);
|
191 |
foreach($terms as $term){
|
192 |
$base=$this->data['remove_taxonomy_base'][$taxonomy->name]?"":$taxonomy->rewrite->slug."/";
|
193 |
-
if($term->parent!=0){
|
194 |
$ancestors=$this->term_ancestors($taxonomy->name,$term->parent)."/";
|
195 |
}
|
196 |
else{
|
197 |
$ancestors="";
|
198 |
}
|
199 |
-
|
200 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
201 |
|
202 |
# create archives
|
203 |
if($this->data['create_archive'][$tax_name]){
|
@@ -212,10 +224,14 @@ if (!class_exists("WPhtc")) {
|
|
212 |
$new_rules[$base.$ancestors.'('.$term->slug.')/([0-9]{4})/([0-9]{2})/([0-9]{2})/'.$page_base.'/?([0-9]{1,})/?$'] = 'index.php?'.$tax_name.'=$matches[1]&year=$matches[2]&monthnum=$matches[3]&day=$matches[4]&paged=$matches[5]';
|
213 |
}
|
214 |
# create rewrite rules with tax base
|
|
|
|
|
|
|
|
|
215 |
if(!$base){
|
216 |
$new_rules[$ancestors.'('.$term->slug.')/(?:feed/)?(feed|rdf|rss|rss2|atom)/?$'] = 'index.php?'.$tax_name.'=$matches[1]&feed=$matches[2]';
|
217 |
$new_rules[$ancestors.'('.$term->slug.')/page/?([0-9]{1,})/?$'] = 'index.php?'.$tax_name.'=$matches[1]&paged=$matches[2]';
|
218 |
-
$new_rules[$ancestors.'('.$term->slug.')/?$'] = 'index.php?'.$tax_name.'=$matches[1]';
|
219 |
}
|
220 |
$rewrite_rules = $new_rules + $rewrite_rules;
|
221 |
}
|
@@ -507,16 +523,21 @@ if (!class_exists("WPhtc")) {
|
|
507 |
|
508 |
# Filter Term Link
|
509 |
function filter_term_link($termlink, $term, $taxonomy){
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
return
|
515 |
-
|
516 |
-
|
517 |
-
|
|
|
|
|
|
|
518 |
}
|
519 |
}
|
|
|
|
|
520 |
}
|
521 |
|
522 |
# Filter Taxonomy Base
|
@@ -588,7 +609,9 @@ if (!class_exists("WPhtc")) {
|
|
588 |
if(!check_admin_referer( 'WPhtc_reset_settings')){
|
589 |
die("You have no permission to do this.");
|
590 |
}
|
|
|
591 |
delete_option('WPhtc_data');
|
|
|
592 |
$echo.=__('All rules reset.', 'wp-htaccess-control');
|
593 |
$this->refresh_rewrite_rules();
|
594 |
break;
|
@@ -602,17 +625,14 @@ if (!class_exists("WPhtc")) {
|
|
602 |
if(!check_admin_referer( 'WPhtc_settings')){
|
603 |
die("You have no permission to do this.");
|
604 |
}
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
# get Custom Search Permalink
|
612 |
-
$this->data['custom_search_permalink']=$_POST['WPhtc_custom_search_permalink'];
|
613 |
# wordpress htaccess and jim morgan's htaccess
|
614 |
$this->data['wp_hta']=$_POST['WPhtc_wp_hta']."\n";
|
615 |
-
$this->data['jim_morgan_hta']=$_POST['WPhtc_jim_morgan_hta'];
|
616 |
if($this->data['jim_morgan_hta']){
|
617 |
$this->data['wp_hta'] ="\nRewriteEngine on\n";
|
618 |
$this->data['wp_hta'].="# Unless you have set a different RewriteBase preceding this point,\n";
|
@@ -631,30 +651,10 @@ if (!class_exists("WPhtc")) {
|
|
631 |
$this->data['wp_hta'].="# else rewrite the request to WP\n";
|
632 |
$this->data['wp_hta'].="RewriteRule . /index.php [L]\n";
|
633 |
}
|
634 |
-
|
635 |
-
$this->data['remove_author_base']=$_POST['WPhtc_remove_author_base'];
|
636 |
-
# Advanced Archives
|
637 |
-
$this->data['category_archives']=$_POST['WPhtc_category_archives'];
|
638 |
-
$this->data['author_archives']=$_POST['WPhtc_author_archives'];
|
639 |
-
$this->data['tag_archives']=$_POST['WPhtc_tag_archives'];
|
640 |
# get htaccess Suggestions
|
641 |
-
$this->data['disable_serversignature']=$_POST['WPhtc_disable_serversignature'];
|
642 |
-
$this->data['disable_indexes']=$_POST['WPhtc_disable_indexes'];
|
643 |
$this->data['up_limit']=(is_numeric($_POST['WPhtc_up_limit'])&&$_POST['WPhtc_up_limit']>0)?$_POST['WPhtc_up_limit']:'';
|
644 |
-
$this->data['protect_wp_config']=$_POST['WPhtc_protect_wp_config'];
|
645 |
-
$this->data['protect_htaccess']=$_POST['WPhtc_protect_htaccess'];
|
646 |
-
$this->data['protect_comments']=$_POST['WPhtc_protect_comments'];
|
647 |
-
$this->data['disable_hotlink']=trim($_POST['WPhtc_disable_hotlink']);
|
648 |
-
$this->data['disable_file_hotlink_ext']=trim($_POST['WPhtc_disable_file_hotlink_ext']);
|
649 |
-
$this->data['disable_file_hotlink_redir']=trim($_POST['WPhtc_disable_file_hotlink_redir']);
|
650 |
-
$this->data['redirect_500']=trim($_POST['WPhtc_redirect_500']);
|
651 |
-
$this->data['redirect_403']=trim($_POST['WPhtc_redirect_403']);
|
652 |
-
$this->data['canon']=$_POST['WPhtc_canon'];
|
653 |
-
$this->data['admin_email']=trim($_POST['WPhtc_admin_email']);
|
654 |
-
$this->data['deflate']=trim($_POST['WPhtc_deflate']);
|
655 |
-
$this->data['gzip']=trim($_POST['WPhtc_gzip']);
|
656 |
# get maintenance
|
657 |
-
$this->data['maintenance_active']=$_POST['WPhtc_maintenance_active'];
|
658 |
$lines=preg_split("/\n|,/",$_POST['WPhtc_maintenance_ips']);
|
659 |
$this->data['maintenance_ips']=array();
|
660 |
foreach($lines as $line){
|
@@ -663,11 +663,7 @@ if (!class_exists("WPhtc")) {
|
|
663 |
$this->data['maintenance_ips'][]=$line;
|
664 |
}
|
665 |
}
|
666 |
-
$this->data['maintenance_redirection']=trim($_POST['WPhtc_maintenance_redirection']);
|
667 |
# get login control data
|
668 |
-
$this->data['login_disabled']=$_POST['WPhtc_login_disabled'];
|
669 |
-
$this->data['login_half_mode']=$_POST['WPhtc_login_half_mode'];
|
670 |
-
$this->data['login_redirection']=trim($_POST['WPhtc_login_redirection']);
|
671 |
$lines=preg_split("/\n|,/",$_POST['WPhtc_login_ips']);
|
672 |
$this->data['login_ips']=array();
|
673 |
foreach($lines as $line){
|
@@ -678,7 +674,6 @@ if (!class_exists("WPhtc")) {
|
|
678 |
}
|
679 |
|
680 |
# Unsetting inclusion of Author pages on Google XML Sitemap options, we'll add those links to the sitemap later with our Custom Author Permalink
|
681 |
-
$this->data['sm_enabled']=$_POST['WPhtc_sm_enabled'];
|
682 |
if($this->data['sm_enabled']==true){
|
683 |
$SMoptions=get_option("sm_options");
|
684 |
if($SMoptions&&is_array($SMoptions)){
|
3 |
Plugin Name: WP htaccess Control
|
4 |
Plugin URI: http://dardna.com/wp-htaccess-control
|
5 |
Description: Interface to customize the permalinks (author, category, archives and pagination) and htaccess file generated by Wordpress.
|
6 |
+
Version: 3.3
|
7 |
Author: António Andrade
|
8 |
Author URI: http://antonioandra.de
|
9 |
*/
|
173 |
function term_ancestors($tax,$id){
|
174 |
$term=get_term($id,$tax);
|
175 |
$ancestor=$term->slug;
|
176 |
+
|
177 |
+
if($term->parent!=0 && !$this->data['remove_hierarchy']){
|
178 |
$ancestor=$this->term_ancestors($tax,$term->parent)."/".$ancestor;
|
179 |
}
|
180 |
return $ancestor;
|
182 |
# Rewrite Rules: Add Category + Tag + Author Archives; Custom Pagination; Custom Author Base
|
183 |
function filter_rewrite_rules($rewrite_rules){
|
184 |
|
185 |
+
$new_rules=array();
|
186 |
|
187 |
$page_base=($this->data['cpp']!='')?$this->data['cpp']:'page';
|
188 |
|
192 |
$terms=get_terms($taxonomy->name);
|
193 |
foreach($terms as $term){
|
194 |
$base=$this->data['remove_taxonomy_base'][$taxonomy->name]?"":$taxonomy->rewrite->slug."/";
|
195 |
+
if($term->parent!=0 && !$this->data['remove_hierarchy']){
|
196 |
$ancestors=$this->term_ancestors($taxonomy->name,$term->parent)."/";
|
197 |
}
|
198 |
else{
|
199 |
$ancestors="";
|
200 |
}
|
201 |
+
|
202 |
+
# some query vars differ from tax name
|
203 |
+
switch($taxonomy->name){
|
204 |
+
case "post_tag":
|
205 |
+
$tax_name="tag";
|
206 |
+
break;
|
207 |
+
case "category":
|
208 |
+
$tax_name="category_name";
|
209 |
+
break;
|
210 |
+
default:
|
211 |
+
$tax_name=$taxonomy->name;
|
212 |
+
}
|
213 |
|
214 |
# create archives
|
215 |
if($this->data['create_archive'][$tax_name]){
|
224 |
$new_rules[$base.$ancestors.'('.$term->slug.')/([0-9]{4})/([0-9]{2})/([0-9]{2})/'.$page_base.'/?([0-9]{1,})/?$'] = 'index.php?'.$tax_name.'=$matches[1]&year=$matches[2]&monthnum=$matches[3]&day=$matches[4]&paged=$matches[5]';
|
225 |
}
|
226 |
# create rewrite rules with tax base
|
227 |
+
|
228 |
+
# appending ".html" to taxonomy permalinks
|
229 |
+
$suffix=$this->data['suffix_html']?".html":"";
|
230 |
+
|
231 |
if(!$base){
|
232 |
$new_rules[$ancestors.'('.$term->slug.')/(?:feed/)?(feed|rdf|rss|rss2|atom)/?$'] = 'index.php?'.$tax_name.'=$matches[1]&feed=$matches[2]';
|
233 |
$new_rules[$ancestors.'('.$term->slug.')/page/?([0-9]{1,})/?$'] = 'index.php?'.$tax_name.'=$matches[1]&paged=$matches[2]';
|
234 |
+
$new_rules[$ancestors.'('.$term->slug.')'.$suffix.'/?$'] = 'index.php?'.$tax_name.'=$matches[1]';
|
235 |
}
|
236 |
$rewrite_rules = $new_rules + $rewrite_rules;
|
237 |
}
|
523 |
|
524 |
# Filter Term Link
|
525 |
function filter_term_link($termlink, $term, $taxonomy){
|
526 |
+
// WPhtc -> this
|
527 |
+
if($this->data['remove_taxonomy_base'][$taxonomy]){
|
528 |
+
$txs=get_taxonomies(array('name'=>$taxonomy),"object");
|
529 |
+
foreach($txs as $t){
|
530 |
+
//return str_replace($t->rewrite['slug']."/","",$termlink);
|
531 |
+
if($term->parent!=0 && !$this->data['remove_hierarchy']){
|
532 |
+
return get_bloginfo('home')."/".$this->term_ancestors($taxonomy,$term->parent)."/".$term->slug;
|
533 |
+
}
|
534 |
+
else{
|
535 |
+
return get_bloginfo('home')."/".$term->slug;
|
536 |
+
}
|
537 |
}
|
538 |
}
|
539 |
+
else
|
540 |
+
return $termlink;
|
541 |
}
|
542 |
|
543 |
# Filter Taxonomy Base
|
609 |
if(!check_admin_referer( 'WPhtc_reset_settings')){
|
610 |
die("You have no permission to do this.");
|
611 |
}
|
612 |
+
$this->data=array();
|
613 |
delete_option('WPhtc_data');
|
614 |
+
//update_option('WPhtc_data',$this->data);
|
615 |
$echo.=__('All rules reset.', 'wp-htaccess-control');
|
616 |
$this->refresh_rewrite_rules();
|
617 |
break;
|
625 |
if(!check_admin_referer( 'WPhtc_settings')){
|
626 |
die("You have no permission to do this.");
|
627 |
}
|
628 |
+
|
629 |
+
foreach(array("hta", "cap", "cpp", "custom_search_permalink", "remove_author_base", "category_archives", "author_archives", "tag_archives", "disable_serversignature", "disable_indexes", "protect_wp_config", "protect_htaccess", "protect_comments", "disable_hotlink", "disable_file_hotlink_ext", "disable_file_hotlink_redir", "redirect_500", "redirect_403", "canon", "admin_email", "deflate", "gzip", "maintenance_active", "maintenance_redirection", "login_disabled", "login_half_mode", "login_redirection", "sm_enabled", "jim_morgan_hta", "remove_hierarchy", "suffix_html")
|
630 |
+
as $k){
|
631 |
+
$this->data[$k]=$_POST['WPhtc_'.$k];
|
632 |
+
}
|
633 |
+
|
|
|
|
|
634 |
# wordpress htaccess and jim morgan's htaccess
|
635 |
$this->data['wp_hta']=$_POST['WPhtc_wp_hta']."\n";
|
|
|
636 |
if($this->data['jim_morgan_hta']){
|
637 |
$this->data['wp_hta'] ="\nRewriteEngine on\n";
|
638 |
$this->data['wp_hta'].="# Unless you have set a different RewriteBase preceding this point,\n";
|
651 |
$this->data['wp_hta'].="# else rewrite the request to WP\n";
|
652 |
$this->data['wp_hta'].="RewriteRule . /index.php [L]\n";
|
653 |
}
|
654 |
+
|
|
|
|
|
|
|
|
|
|
|
655 |
# get htaccess Suggestions
|
|
|
|
|
656 |
$this->data['up_limit']=(is_numeric($_POST['WPhtc_up_limit'])&&$_POST['WPhtc_up_limit']>0)?$_POST['WPhtc_up_limit']:'';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
657 |
# get maintenance
|
|
|
658 |
$lines=preg_split("/\n|,/",$_POST['WPhtc_maintenance_ips']);
|
659 |
$this->data['maintenance_ips']=array();
|
660 |
foreach($lines as $line){
|
663 |
$this->data['maintenance_ips'][]=$line;
|
664 |
}
|
665 |
}
|
|
|
666 |
# get login control data
|
|
|
|
|
|
|
667 |
$lines=preg_split("/\n|,/",$_POST['WPhtc_login_ips']);
|
668 |
$this->data['login_ips']=array();
|
669 |
foreach($lines as $line){
|
674 |
}
|
675 |
|
676 |
# Unsetting inclusion of Author pages on Google XML Sitemap options, we'll add those links to the sitemap later with our Custom Author Permalink
|
|
|
677 |
if($this->data['sm_enabled']==true){
|
678 |
$SMoptions=get_option("sm_options");
|
679 |
if($SMoptions&&is_array($SMoptions)){
|