WP htaccess Control - Version 3.0

Version Description

(26/04/2012) = * Feature: base slug and archive creation for any taxonomy; * Major rewrite of core methods.

Download this release

Release Info

Developer antonioandra.de
Plugin Icon wp plugin WP htaccess Control
Version 3.0
Comparing to
See all releases

Code changes from version 2.7.2.1 to 3.0

readme.txt CHANGED
@@ -6,25 +6,25 @@ 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&currency_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: 2.7
9
- Tested up to: 3.3.1
10
- Stable tag: 2.7.2.1
11
 
12
  Interface to customize the permalinks (author, category, archives and pagination) and htaccess file generated by Wordpress.
13
 
14
  == Description ==
15
 
16
- **WP htaccess Control** provides an interface to customize permalinks (author, category, archives and pagination) and the htaccess file generated by Wordpress. Take a look at the screenshot for a clearer exemplification.
17
- Despite the name, many of the options now present on this plugin do not use the htaccess file but the wordpress internal rewrite.
18
 
19
  **Features:**
20
 
21
  * Customizing the htaccess file generated by Wordpress;
 
22
  * Removing the category base from permalinks;
23
  * Removing the author base from permalinks;
24
  * Customizing the Author Permalink Base;
25
  * Customizing Paginated Permalinks (translate the "page" word on permalinks to your own language);
26
  * Customization (and canonization) of the Search Permalink Base;
27
- * Category, Author and Tag based archives (ex: *"http://your-site.com/category/stories/2010/12"*, *"http://your-site.com/author/admin/2010/12/page/2"* and *"http://your-site.com/tag/wordpress/2010/12"*), this will also work if you've removed the category base;
28
  * Maintenance mode;
29
  * wp-login.php redirection.
30
 
@@ -76,6 +76,10 @@ Search redirection is based on Mark Jaquith's **Nice Search** but extended so th
76
 
77
  == Changelog ==
78
 
 
 
 
 
79
  = 2.7.2.1 (03/04/2012) =
80
  * Images and donators list included (no longer remotely loaded).
81
 
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&currency_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: 2.7
9
+ Tested up to: 3.3.2
10
+ Stable tag: 3.0
11
 
12
  Interface to customize the permalinks (author, category, archives and pagination) and htaccess file generated by Wordpress.
13
 
14
  == Description ==
15
 
16
+ **WP htaccess Control** should now really be called WP htacess *and Rewrite* Control. It provides an interface to customize the htaccess file generated by Wordpress but also its permalinks (author, category, archives, pagination and custom taxonomies). Take a look at the screenshot for a clearer exemplification.
 
17
 
18
  **Features:**
19
 
20
  * Customizing the htaccess file generated by Wordpress;
21
+ * Removing any custom taxonomy's slug base from permalinks;
22
  * Removing the category base from permalinks;
23
  * Removing the author base from permalinks;
24
  * Customizing the Author Permalink Base;
25
  * Customizing Paginated Permalinks (translate the "page" word on permalinks to your own language);
26
  * Customization (and canonization) of the Search Permalink Base;
27
+ * Creation of Category, Author, Tag and Custom Taxonomy based archives (ex: *"http://your-site.com/category/stories/2010/12"*, *"http://your-site.com/author/admin/2010/12/page/2"* and *"http://your-site.com/tag/wordpress/2010/12"*), this will also work if you've removed the base slug;
28
  * Maintenance mode;
29
  * wp-login.php redirection.
30
 
76
 
77
  == Changelog ==
78
 
79
+ = 3.0 (26/04/2012) =
80
+ * Feature: base slug and archive creation for any taxonomy;
81
+ * Major rewrite of core methods.
82
+
83
  = 2.7.2.1 (03/04/2012) =
84
  * Images and donators list included (no longer remotely loaded).
85
 
wp-htaccess-control-ui.css CHANGED
@@ -21,4 +21,5 @@ div.updated p span{float:right;}
21
  textarea.readonly{background-color:#eee;}
22
  ul.description{margin-top:1em;}
23
  ul.description a{text-decoration:none;}
24
- #donations{list-style:square inside;}
 
21
  textarea.readonly{background-color:#eee;}
22
  ul.description{margin-top:1em;}
23
  ul.description a{text-decoration:none;}
24
+
25
+ .wphtc-inputs pre{margin:2.5%;width:95%;overflow:auto;}
wp-htaccess-control-ui.js CHANGED
@@ -2,7 +2,7 @@ jQuery(document).ready(function(){
2
  collapseSections();
3
  editWPhtaJM();
4
  function collapseSections(){
5
- jQuery("#wphtc-main .wphtc-inputs,.wphtc-section-title a").not(".wphtc-inputs:last").hide();
6
  jQuery(".handlediv").fadeOut(0);
7
  jQuery("#wphtc-main .wphtc-section").hover(
8
  function(){
@@ -12,7 +12,7 @@ jQuery(document).ready(function(){
12
  jQuery(this).find(".handlediv").fadeOut(150);
13
  }
14
  )
15
- jQuery("#wphtc-main .wphtc-section-title h3").click(
16
  function(){
17
  if(jQuery(this).parent().find("a")){
18
  jQuery(this).parent().find("a").toggle();
2
  collapseSections();
3
  editWPhtaJM();
4
  function collapseSections(){
5
+ jQuery("#wphtc-main .wphtc-inputs,.wphtc-section-title a").not(".wphtc-inputs.start-open").hide();
6
  jQuery(".handlediv").fadeOut(0);
7
  jQuery("#wphtc-main .wphtc-section").hover(
8
  function(){
12
  jQuery(this).find(".handlediv").fadeOut(150);
13
  }
14
  )
15
+ jQuery("#wphtc-main .wphtc-section:not(.permanently-open) .wphtc-section-title h3").click(
16
  function(){
17
  if(jQuery(this).parent().find("a")){
18
  jQuery(this).parent().find("a").toggle();
wp-htaccess-control-ui.php CHANGED
@@ -1,4 +1,6 @@
1
  <?php
 
 
2
  $plugin_path = WP_CONTENT_DIR.'/plugins/'.plugin_basename(dirname(__FILE__));
3
  $plugin_url = WP_CONTENT_URL.'/plugins/'.plugin_basename(dirname(__FILE__));
4
  $q=explode('&',$_SERVER['QUERY_STRING']);
@@ -6,10 +8,10 @@ $purl='http'.((!empty($_SERVER['HTTPS'])) ? 's' : '').'://'.$_SERVER['HTTP_HOST'
6
  global $WPhtc, $echo;
7
  $WPhtc->wphtc_page_action();
8
  $WPhtc_data=get_option('WPhtc_data');
9
- //global $wp_rewrite;print_r($wp_rewrite);
10
  ?>
11
  <div id="wphtc-page" class="wrap">
12
- <h2>Wp htaccess Control</h2>
13
  <?php
14
  if(!current_user_can("administrator")) {
15
  echo '<p>'.__('Please log in as admin','wp-htaccess-control').'</p>';
@@ -17,38 +19,6 @@ $WPhtc_data=get_option('WPhtc_data');
17
  }
18
  ?>
19
  <div id="wphtc-sidebar">
20
- <?php //$d = file_get_contents('http://antonioandra.de/wp-htaccess-control-donations');
21
- if($d){?>
22
- <div class="wphtc-section">
23
- <div class="wphtc-section-title stuffbox">
24
- <!--<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>-->
25
- <h3><?php _e('Latest donations', 'wp-htaccess-control'); ?></h3>
26
- </div>
27
- <div class="wphtc-inputs">
28
- <ul id="donations">
29
- <?php
30
- preg_match_all("'<ul>(.*?)</ul>'si",$d,$out);
31
- echo $out[1][0];
32
- ?>
33
- </ul>
34
- </div>
35
- </div>
36
- <?php } ?>
37
- <div class="wphtc-section">
38
- <div class="wphtc-section-title stuffbox">
39
- <h3><?php _e('Latest donations', 'wp-htaccess-control'); ?></h3>
40
- </div>
41
- <div class="wphtc-inputs">
42
- <ul id="donations">
43
- <li><a target="_blank" href="http://everydayseo.com">EverydaySEO</a></li>
44
- <li><a target="_blank" href="http://ait-pro.com">AITpro</a></li>
45
- <li>G------ P-------</li>
46
- <li><a target="_blank" href="http://anphicle.com">Anphicle</a></li>
47
- <li>G----- F----</li>
48
- <li><a target="_blank" href="http://www.hans-wurst.de">Tatron</a></li>
49
- </ul>
50
- </div>
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>-->
@@ -58,11 +28,18 @@ $WPhtc_data=get_option('WPhtc_data');
58
  <ul>
59
  <li><a href="http://antonioandra.de/wp-htaccess-control"><img width="16" height="16" src="<?php echo $plugin_url?>/images/antonioandra.de_favicon.png"> Plugin Homepage</a></li>
60
  <li><a href="http://wordpress.org/extend/plugins/wp-htaccess-control/"><img src="<?php echo $plugin_url?>/images/favicon.ico"> Plugin at Wordpress.org </a></li>
61
- <!--<li><a href="http://dardna.com/"><img src="http://dardna.com/favicon.ico"> Author Homepage</a></li>-->
62
  <li><a href="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&currency_code=EUR&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHostedGuest"><img width="16" height="16" src="<?php echo $plugin_url?>/images/pp_favicon_x.ico"> Donate with Paypal</a></li>
63
  </ul>
64
  </div>
65
  </div>
 
 
 
 
 
 
 
 
66
  <p id="foot">WP htaccess Control <?php _e('by', 'wp-htaccess-control'); ?> António Andrade</p>
67
  </div>
68
  <div id="wphtc-main">
@@ -81,6 +58,23 @@ $WPhtc_data=get_option('WPhtc_data');
81
  </div>
82
  <?php }?>
83
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  <!-- Custom Author Permalink -->
85
  <div class="wphtc-section">
86
  <div class="wphtc-section-title stuffbox">
@@ -156,33 +150,14 @@ $WPhtc_data=get_option('WPhtc_data');
156
  </tr>
157
  </table>
158
  </div>
159
- <!-- Remove Category Base -->
160
  <div class="wphtc-section">
161
  <div class="wphtc-section-title stuffbox">
162
  <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>
163
- <h3><?php _e('Remove Category Base', 'wp-htaccess-control');?></h3>
164
- </div>
165
- <table class="form-table wphtc-inputs">
166
- <tr valign="top">
167
- <th scope="row" style="width:18%;"><?php _e('Remove Category Base', 'wp-htaccess-control'); ?></th>
168
- <td >
169
- <input type="checkbox" name="WPhtc_remove_category_base" <?php if($WPhtc_data['remove_category_base']){echo "checked=checked";} ?> />
170
- </td>
171
- <td valign="middle">
172
- <p class="description"><?php _e('If active, the category base will be removed from permalinks:'); ?></p>
173
- <p class="description"><code><?php bloginfo('home')?>/<?php _e('your-category', 'wp-htaccess-control'); ?></code></p>
174
- <p class="description"><strong><?php _e('Beware:'); ?></strong> <?php _e('This could conflict with the removal of the author base on a situation where a category slug is the same as a user nicename.'); ?></p>
175
- </td>
176
- </tr>
177
- </table>
178
- </div>
179
- <!-- Remove Author Base -->
180
- <div class="wphtc-section">
181
- <div class="wphtc-section-title stuffbox">
182
- <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>
183
- <h3><?php _e('Remove Author Base', 'wp-htaccess-control');?></h3>
184
  </div>
185
  <table class="form-table wphtc-inputs">
 
186
  <tr valign="top">
187
  <th scope="row" style="width:18%;"><?php _e('Remove Author Base', 'wp-htaccess-control'); ?></th>
188
  <td >
@@ -192,9 +167,26 @@ $WPhtc_data=get_option('WPhtc_data');
192
  <p class="description"><?php _e('If active, the author base will be removed from permalinks:'); ?></p>
193
  <p class="description"><code><?php bloginfo('home')?>/<?php _e('the-author', 'wp-htaccess-control'); ?></code></p>
194
  <p class="description"><strong><?php _e('Beware:'); ?></strong> <?php _e('This could conflict with the removal of the category base on a situation where a category slug is the same as a user nicename.'); ?></p>
195
- <p class="description"><strong><?php _e('Beware:'); ?></strong> <?php _e('I have not evaluated the impact on performance when using this with dozens of users. Please tell me how it goes.'); ?></p>
196
  </td>
197
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
198
  </table>
199
  </div>
200
  <!-- Advanced Archives -->
@@ -204,40 +196,24 @@ $WPhtc_data=get_option('WPhtc_data');
204
  <h3><?php _e('Advanced Archives', 'wp-htaccess-control');?></h3>
205
  </div>
206
  <table class="form-table wphtc-inputs">
207
- <tr valign="top">
208
- <th scope="row" style="width:18%;"><?php _e('Category Archives', 'wp-htaccess-control'); ?></th>
209
- <td >
210
- <input type="checkbox" name="WPhtc_category_archives" <?php if($WPhtc_data['category_archives']){echo "checked=checked";} ?> />
211
- </td>
212
- <td valign="middle">
213
- <p class="description"><?php _e('If active, category-based archives will be accessible using the structure:', 'wp-htaccess-control'); ?></p>
214
- <p class="description"><code><?php bloginfo('home')?>/<?php _e('your-category-base', 'wp-htaccess-control'); ?>/<?php _e('your-category', 'wp-htaccess-control'); ?>/2010</code></p>
215
- <p class="description"><code><?php bloginfo('home')?>/<?php _e('your-category-base', 'wp-htaccess-control'); ?>/<?php _e('your-category', 'wp-htaccess-control'); ?>/2010/12</code></p>
216
- <p class="description"><?php _e("This will also work if you've removed the category base.", 'wp-htaccess-control'); ?></p>
217
- </td>
218
- </tr>
219
- <tr valign="top">
220
- <th scope="row" style="width:18%;"><?php _e('Author Archives', 'wp-htaccess-control'); ?></th>
221
- <td >
222
- <input type="checkbox" name="WPhtc_author_archives" <?php if($WPhtc_data['author_archives']){echo "checked=checked";} ?> />
223
- </td>
224
- <td valign="middle">
225
- <p class="description"><?php _e('If active, author-based archives will be accessible using the structure:', 'wp-htaccess-control'); ?></p>
226
- <p class="description"><code><?php bloginfo('home')?>/<?php _e('your-author-base', 'wp-htaccess-control'); ?>/<?php _e('your-author', 'wp-htaccess-control'); ?>/2010</code></p>
227
- <p class="description"><code><?php bloginfo('home')?>/<?php _e('your-author-base', 'wp-htaccess-control'); ?>/<?php _e('your-author', 'wp-htaccess-control'); ?>/2010/12</code></p>
228
- </td>
229
- </tr>
230
- <tr valign="top">
231
- <th scope="row" style="width:18%;"><?php _e('Tag Archives', 'wp-htaccess-control'); ?></th>
232
- <td >
233
- <input type="checkbox" name="WPhtc_tag_archives" <?php if($WPhtc_data['tag_archives']){echo "checked=checked";} ?> />
234
- </td>
235
- <td valign="middle">
236
- <p class="description"><?php _e('If active, tag-based archives will be accessible using the structure:', 'wp-htaccess-control'); ?></p>
237
- <p class="description"><code><?php bloginfo('home')?>/<?php _e('your-tag-base', 'wp-htaccess-control'); ?>/<?php _e('your-tag', 'wp-htaccess-control'); ?>/2010</code></p>
238
- <p class="description"><code><?php bloginfo('home')?>/<?php _e('your-tag-base', 'wp-htaccess-control'); ?>/<?php _e('your-tag', 'wp-htaccess-control'); ?>/2010/12</code></p>
239
- </td>
240
- </tr>
241
  </table>
242
  </div>
243
  <!-- Custom htaccess -->
@@ -537,11 +513,28 @@ $WPhtc_data=get_option('WPhtc_data');
537
  <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>
538
  <h3><?php _e('Current htaccess file as it is generated by Wordpress', 'wp-htaccess-control'); ?></h3>
539
  </div>
540
- <div class="wphtc-inputs">
541
  <p>
542
  <code><?php echo str_replace(array("&lt;br /&gt;","&lt;br/&gt;"),"<br/>",htmlspecialchars($WPhtc_data['cur_hta']));?></code>
543
  </p>
544
  </div>
545
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
546
  </div>
547
  </div>
1
  <?php
2
+ $debug=false;
3
+
4
  $plugin_path = WP_CONTENT_DIR.'/plugins/'.plugin_basename(dirname(__FILE__));
5
  $plugin_url = WP_CONTENT_URL.'/plugins/'.plugin_basename(dirname(__FILE__));
6
  $q=explode('&',$_SERVER['QUERY_STRING']);
8
  global $WPhtc, $echo;
9
  $WPhtc->wphtc_page_action();
10
  $WPhtc_data=get_option('WPhtc_data');
11
+
12
  ?>
13
  <div id="wphtc-page" class="wrap">
14
+ <h2>Wp htaccess Control 3.0</h2>
15
  <?php
16
  if(!current_user_can("administrator")) {
17
  echo '<p>'.__('Please log in as admin','wp-htaccess-control').'</p>';
19
  }
20
  ?>
21
  <div id="wphtc-sidebar">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  <div class="wphtc-section">
23
  <div class="wphtc-section-title stuffbox">
24
  <!--<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>-->
28
  <ul>
29
  <li><a href="http://antonioandra.de/wp-htaccess-control"><img width="16" height="16" src="<?php echo $plugin_url?>/images/antonioandra.de_favicon.png"> Plugin Homepage</a></li>
30
  <li><a href="http://wordpress.org/extend/plugins/wp-htaccess-control/"><img src="<?php echo $plugin_url?>/images/favicon.ico"> Plugin at Wordpress.org </a></li>
 
31
  <li><a href="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&currency_code=EUR&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHostedGuest"><img width="16" height="16" src="<?php echo $plugin_url?>/images/pp_favicon_x.ico"> Donate with Paypal</a></li>
32
  </ul>
33
  </div>
34
  </div>
35
+ <div class="wphtc-section">
36
+ <div class="wphtc-section-title stuffbox">
37
+ <h3><?php _e('Latest donations', 'wp-htaccess-control'); ?></h3>
38
+ </div>
39
+ <div class="wphtc-inputs">
40
+ <iframe width="220" src="http://antonioandra.de/wp-htaccess-control-donations"></iframe>
41
+ </div>
42
+ </div>
43
  <p id="foot">WP htaccess Control <?php _e('by', 'wp-htaccess-control'); ?> António Andrade</p>
44
  </div>
45
  <div id="wphtc-main">
58
  </div>
59
  <?php }?>
60
 
61
+ <!-- INSTRUCTIONS -->
62
+ <div class="wphtc-section permanently-open">
63
+ <div class="wphtc-section-title stuffbox">
64
+ <h3><?php _e('Introduction', 'wp-table-of-paginated-contents');?></h3>
65
+ </div>
66
+ <table class="form-table wphtc-inputs start-open">
67
+ <tr valign="top">
68
+ <th scope="row" style="width:18%;"></th>
69
+ <td >
70
+ <p class="description"><?php _e('This plugin has made such a long way that it should really now be called <strong>WP htaccess and Rewrite Control</strong>.', 'wp-htaccess-control');?></p>
71
+ <p class="description"><?php _e('Many core parts of WP htaccess Control have been almost completely re-done in version 3.0 with the goal of providing an universal solution. This means that you can now selectively remove base slugs and create full archives for any custom taxonomy in addiction to the previous Category and Post tags.', 'wp-htaccess-control');?></p>
72
+ <p class="description"><?php _e('This changes also mean that some unforeseen issues might arise. Please report them. If your setup seems to get out of control there are a few easy options to reverse all changes: 1) Click on "Reset all rules", at the bottom of this page; 2) rename/delete the plugin folder and re-submit your permalink settings under "Settings > Permalinks" and 3) if the previous did not solve your issue, remove the .htaccess file on your blog\'s root directory and repeat step 2.', 'wp-htaccess-control');?></p>
73
+ </td>
74
+ </tr>
75
+ </table>
76
+ </div>
77
+
78
  <!-- Custom Author Permalink -->
79
  <div class="wphtc-section">
80
  <div class="wphtc-section-title stuffbox">
150
  </tr>
151
  </table>
152
  </div>
153
+ <!-- Remove Taxonomies and Author Base -->
154
  <div class="wphtc-section">
155
  <div class="wphtc-section-title stuffbox">
156
  <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>
157
+ <h3><?php _e('Remove Taxonomies and Author Base', 'wp-htaccess-control');?></h3>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
158
  </div>
159
  <table class="form-table wphtc-inputs">
160
+ <!-- Remove Author Base -->
161
  <tr valign="top">
162
  <th scope="row" style="width:18%;"><?php _e('Remove Author Base', 'wp-htaccess-control'); ?></th>
163
  <td >
167
  <p class="description"><?php _e('If active, the author base will be removed from permalinks:'); ?></p>
168
  <p class="description"><code><?php bloginfo('home')?>/<?php _e('the-author', 'wp-htaccess-control'); ?></code></p>
169
  <p class="description"><strong><?php _e('Beware:'); ?></strong> <?php _e('This could conflict with the removal of the category base on a situation where a category slug is the same as a user nicename.'); ?></p>
 
170
  </td>
171
  </tr>
172
+ <!-- Remove Taxonomies Base -->
173
+ <?php foreach (get_taxonomies('','objects') as $taxonomy){
174
+ if(!$taxonomy->rewrite){continue;}
175
+ ?>
176
+ <tr valign="top">
177
+ <th scope="row" style="width:18%;"><?php _e('Remove', 'wp-htaccess-control'); echo " ".$taxonomy->labels->name." " ; _e('Base', 'wp-htaccess-control'); ?></th>
178
+ <td >
179
+ <input type="checkbox" name="WPhtc_remove_base[<?php echo $taxonomy->name; ?>]" <?php if($WPhtc_data['remove_taxonomy_base'][$taxonomy->name]){echo "checked=checked";} ?> />
180
+ </td>
181
+ <td valign="middle">
182
+ <p class="description"><?php _e('If active, the'); echo " ".$taxonomy->labels->name." "; _e('base will be removed from permalinks:'); ?></p>
183
+ <p class="description"><code><?php bloginfo('home')?>/<?php echo $taxonomy->name;?>_term</code></p>
184
+ <p class="description"><strong><?php _e('Beware:'); ?></strong> <?php _e('This could conflict with the removal of the other permalink bases on a situation where a term slug is the same.'); ?></p>
185
+ </td>
186
+ </tr>
187
+ <?php
188
+ }
189
+ ?>
190
  </table>
191
  </div>
192
  <!-- Advanced Archives -->
196
  <h3><?php _e('Advanced Archives', 'wp-htaccess-control');?></h3>
197
  </div>
198
  <table class="form-table wphtc-inputs">
199
+ <?php foreach (get_taxonomies('','objects') as $taxonomy){
200
+ if(!$taxonomy->rewrite){continue;}
201
+ ?>
202
+ <tr valign="top">
203
+ <th scope="row" style="width:18%;"><?php _e('Create', 'wp-htaccess-control'); echo " ".$taxonomy->labels->name." " ; _e('Archives', 'wp-htaccess-control'); ?></th>
204
+ <td >
205
+ <input type="checkbox" name="WPhtc_create_archive[<?php echo $taxonomy->name; ?>]" <?php if($WPhtc_data['create_archive'][$taxonomy->name]){echo "checked=checked";} ?> />
206
+ </td>
207
+ <td valign="middle">
208
+ <p class="description"><?php _e('If active, taxonomy-based archives will be accessible:', 'wp-htaccess-control'); ?></p>
209
+ <p class="description"><code><?php bloginfo('home')?>/<?php echo $taxonomy->name; ?>_base/<?php echo $taxonomy->name; ?>_term/2010</code></p>
210
+ <p class="description"><code><?php bloginfo('home')?>/<?php echo $taxonomy->name; ?>_base/<?php echo $taxonomy->name; ?>_term/2010/12</code></p>
211
+ <p class="description"><?php _e("This will also work if you've removed the", 'wp-htaccess-control'); ?> <?php echo $taxonomy->labels->name; ?> <?php _e("base.", 'wp-htaccess-control'); ?></p>
212
+ </td>
213
+ </tr>
214
+ <?php
215
+ }
216
+ ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
217
  </table>
218
  </div>
219
  <!-- Custom htaccess -->
513
  <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>
514
  <h3><?php _e('Current htaccess file as it is generated by Wordpress', 'wp-htaccess-control'); ?></h3>
515
  </div>
516
+ <div class="wphtc-inputs start-open">
517
  <p>
518
  <code><?php echo str_replace(array("&lt;br /&gt;","&lt;br/&gt;"),"<br/>",htmlspecialchars($WPhtc_data['cur_hta']));?></code>
519
  </p>
520
  </div>
521
  </div>
522
+ <?php if($debug){?>
523
+ <div class="wphtc-section start-open">
524
+ <div class="wphtc-section-title stuffbox">
525
+ <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>
526
+ <h3><?php _e('Debug Data', 'wp-htaccess-control'); ?></h3>
527
+ </div>
528
+ <div class="wphtc-inputs">
529
+ <pre>
530
+ <?php print_r($WPhtc_data);?>
531
+ </pre>
532
+
533
+ <pre>
534
+ <?php global $wp_rewrite; print_r($wp_rewrite);?>
535
+ </pre>
536
+ </div>
537
+ </div>
538
+ <?php } ?>
539
  </div>
540
  </div>
wp-htaccess-control.php CHANGED
@@ -3,11 +3,11 @@
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: 2.7.2.1
7
  Author: António Andrade
8
  Author URI: http://dardna.com
9
  */
10
- /* Copyright 2010-2011 António Andrade (email : dardna@dardna.com)
11
 
12
  This program is free software; you can redistribute it and/or modify
13
  it under the terms of the GNU General Public License as published by
@@ -45,9 +45,8 @@ if (!class_exists("WPhtc")) {
45
  if($_GET['s']){
46
  wp_redirect( home_url( $WPhtc_data['custom_search_permalink']. "/" . rawurlencode(get_query_var( 's' )) ) );
47
  }
 
48
  # rewrite query
49
-
50
-
51
  if(strpos($_SERVER["REQUEST_URI"], $WPhtc_data['custom_search_permalink'])){
52
  global $wp_query;
53
  if(strpos($_SERVER["REQUEST_URI"], '/feed')){
@@ -60,8 +59,8 @@ if (!class_exists("WPhtc")) {
60
  }
61
  }
62
  $page_base=($WPhtc_data['cpp']!='')?$WPhtc_data['cpp']:'page';
63
- # in need of better regex
64
 
 
65
  if(!strpos($_SERVER["REQUEST_URI"], '/feed')&&!strpos($_SERVER["REQUEST_URI"],$page_base)){
66
  $pattern="/\/".$WPhtc_data['custom_search_permalink']."\/(.+)/";
67
  }
@@ -105,8 +104,30 @@ if (!class_exists("WPhtc")) {
105
  return $link;
106
  }
107
  function wphtc_check_first_run(){
108
- # flush rules to get some data filled
109
  $WPhtc_data=get_option('WPhtc_data');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
  if(!isset($WPhtc_data['htaccess_original'])){
111
  $this->refresh_rewrite_rules();
112
  }
@@ -115,7 +136,9 @@ if (!class_exists("WPhtc")) {
115
  function refresh_rewrite_rules(){
116
  global $wp_rewrite;
117
  $wp_rewrite->flush_rules();
118
- //print_r($wp_rewrite);
 
 
119
  }
120
  # Filter pagination links generated by Wordpress
121
  function wphtc_filter_get_pagenum_link($result){
@@ -149,52 +172,60 @@ if (!class_exists("WPhtc")) {
149
  return $requested_url;
150
  }
151
  }
 
 
 
 
 
 
 
 
 
 
152
  # Rewrite Rules: Add Category + Tag + Author Archives; Custom Pagination; Custom Author Base
153
  function wphtc_filter_rewrite_rules($rewrite_rules){
154
  $WPhtc_data=get_option('WPhtc_data');
 
155
  $page_base=($WPhtc_data['cpp']!='')?$WPhtc_data['cpp']:'page';
156
- # Category Archives
157
- if($WPhtc_data['category_archives']){
158
- # If category base removed
159
- if($WPhtc_data['remove_category_base']){
160
- $categories=get_categories(array('hide_empty'=>false));
161
- foreach($categories as $category) {
162
- $category_nicename = urldecode($category->slug);
163
- if ( $category->parent == $category->cat_ID ){
164
- $category->parent = 0;
165
  }
166
- elseif ($category->parent != 0 ){
167
- $category_nicename = urldecode(get_category_parents( $category->parent, false, '/', true )) . $category_nicename;
168
  }
169
- $new_rules = array(
170
- '('.$category_nicename.')/([0-9]{4})/?$' => 'index.php?category_name=$matches[1]&year=$matches[2]',
171
- '('.$category_nicename.')/([0-9]{4})/'.$page_base.'/?([0-9]{1,})/?$' => 'index.php?category_name=$matches[1]&year=$matches[2]&paged=$matches[3]',
172
-
173
- '('.$category_nicename.')/([0-9]{4})/([0-9]{2})/?$' => 'index.php?category_name=$matches[1]&year=$matches[2]&monthnum=$matches[3]',
174
- '('.$category_nicename.')/([0-9]{4})/([0-9]{2})/'.$page_base.'/?([0-9]{1,})/?$' => 'index.php?category_name=$matches[1]&year=$matches[2]&monthnum=$matches[3]&paged=$matches[4]',
175
-
176
- '('.$category_nicename.')/([0-9]{4})/([0-9]{2})/([0-9]{2})/?$' => 'index.php?category_name=$matches[1]&year=$matches[2]&monthnum=$matches[3]&day=$matches[4]',
177
- '('.$category_nicename.')/([0-9]{4})/([0-9]{2})/([0-9]{2})/'.$page_base.'/?([0-9]{1,})/?$' => 'index.php?category_name=$matches[1]&year=$matches[2]&monthnum=$matches[3]&day=$matches[4]&paged=$matches[5]');
178
-
179
- $rewrite_rules = $new_rules + $rewrite_rules;
 
 
 
 
 
 
 
 
 
 
 
180
  }
181
  }
182
- # else
183
- else {
184
- $category_base = (get_option('category_base')!='')?get_option('category_base'):'category';
185
- $new_rules = array(
186
- $category_base.'/([^/]+)/([0-9]{4})/?$' => 'index.php?category_name=$matches[1]&year=$matches[2]',
187
- $category_base.'/([^/]+)/([0-9]{4})/'.$page_base.'/?([0-9]{1,})/?$' => 'index.php?category_name=$matches[1]&year=$matches[2]&paged=$matches[3]',
188
-
189
- $category_base.'/([^/]+)/([0-9]{4})/([0-9]{2})/?$' => 'index.php?category_name=$matches[1]&year=$matches[2]&monthnum=$matches[3]',
190
- $category_base.'/([^/]+)/([0-9]{4})/([0-9]{2})/'.$page_base.'/?([0-9]{1,})/?$' => 'index.php?category_name=$matches[1]&year=$matches[2]&monthnum=$matches[3]&paged=$matches[4]',
191
-
192
- $category_base.'/([^/]+)/([0-9]{4})/([0-9]{2})/([0-9]{2})/?$' => 'index.php?category_name=$matches[1]&year=$matches[2]&monthnum=$matches[3]&day=$matches[4]',
193
- $category_base.'/([^/]+)/([0-9]{4})/([0-9]{2})/([0-9]{2})/'.$page_base.'/?([0-9]{1,})/?$' => 'index.php?category_name=$matches[1]&year=$matches[2]&monthnum=$matches[3]&day=$matches[4]&paged=$matches[5]');
194
-
195
- $rewrite_rules = $new_rules + $rewrite_rules;
196
- }
197
  }
 
198
  # Author Archives
199
  if($WPhtc_data['remove_author_base']){
200
  $blogusers = get_users('who=authors');
@@ -227,20 +258,7 @@ if (!class_exists("WPhtc")) {
227
 
228
  $rewrite_rules = $new_rules + $rewrite_rules;
229
  }
230
- # Tag Archives
231
- if(isset($WPhtc_data['tag_archives'])){
232
- $new_rules = array(
233
- 'tag/([^/]+)/([0-9]{4})/?$' => 'index.php?tag=$matches[1]&year=$matches[2]',
234
- 'tag/([^/]+)/([0-9]{4})/'.$page_base.'/?([0-9]{1,})/?$' => 'index.php?tag=$matches[1]&year=$matches[2]&paged=$matches[3]',
235
-
236
- 'tag/([^/]+)/([0-9]{4})/([0-9]{2})/?$' => 'index.php?tag=$matches[1]&year=$matches[2]&monthnum=$matches[3]',
237
- 'tag/([^/]+)/([0-9]{4})/([0-9]{2})/'.$page_base.'/?([0-9]{1,})/?$' => 'index.php?tag=$matches[1]&year=$matches[2]&monthnum=$matches[3]&paged=$matches[4]',
238
-
239
- 'tag/([^/]+)/([0-9]{4})/([0-9]{2})/([0-9]{2})/?$' => 'index.php?tag=$matches[1]&year=$matches[2]&monthnum=$matches[3]&day=$matches[4]',
240
- 'tag/([^/]+)/([0-9]{4})/([0-9]{2})/([0-9]{2})/'.$page_base.'/?([0-9]{1,})/?$' => 'index.php?tag=$matches[1]&year=$matches[2]&monthnum=$matches[3]&monthnum=$matches[4]&paged=$matches[5]');
241
-
242
- $rewrite_rules = $new_rules + $rewrite_rules;
243
- }
244
  # Custom Pagination; Custom Author Permalink
245
  if((isset($WPhtc_data['cap'])&&$WPhtc_data['cap']!='')||(isset($WPhtc_data['cpp'])&&$WPhtc_data['cpp']!='')){
246
  $rewrite_rules=serialize($rewrite_rules);
@@ -256,10 +274,12 @@ if (!class_exists("WPhtc")) {
256
  if(isset($WPhtc_data['custom_search_permalink'])&&$WPhtc_data['custom_search_permalink']!=''){
257
  $rewrite_rules=str_replace('search/',$WPhtc_data['custom_search_permalink'].'/',$rewrite_rules);
258
  }
 
259
  $rewrite_rules=unserialize(preg_replace('!s:(\d+):"(.*?)";!se', "'s:'.strlen('$2').':\"$2\";'",$rewrite_rules));
260
  }
261
  return $rewrite_rules;
262
  }
 
263
  # Adding our Custom Author Base to the sitemap generated by Google XML Sitemaps
264
  # Adapted from sitemap-core.php (line ~2036)
265
  function set_sm(){
@@ -299,8 +319,6 @@ if (!class_exists("WPhtc")) {
299
  $WPhtc_data=get_option('WPhtc_data');
300
  # Keeping a copy of the generated htaccess in our option array for later reviewing
301
  $WPhtc_data['cur_hta']='# BEGIN Wordpress<br/>'.nl2br($wp_rewrite->mod_rewrite_rules())."# END Wordpress";
302
- # deprecating original_hta
303
- unset($WPhtc_data['original_hta']);
304
  update_option('WPhtc_data',$WPhtc_data);
305
  return $wp_rewrite;
306
  }
@@ -490,46 +508,22 @@ if (!class_exists("WPhtc")) {
490
  }
491
  return $new_rules;
492
  }
493
- # Category Base
494
- function filter_category_link($catlink, $category_id) {
495
- $WPhtc_data=get_option('WPhtc_data');
496
- if($WPhtc_data['remove_category_base']){
497
- $category = &get_category( $category_id );
498
- if ( is_wp_error( $category ) ){
499
- return $category;
500
- }
501
- $category_nicename = $category->slug;
502
- if ( $category->parent == $category_id ){
503
- $category->parent = 0;
504
- }
505
- elseif ($category->parent != 0 ){
506
- $category_nicename = get_category_parents( $category->parent, false, '/', true ) . $category_nicename;
507
- }
508
- $catlink = trailingslashit(get_option( 'home' )) . user_trailingslashit( $category_nicename, 'category' );
509
  }
510
- return $catlink;
511
  }
512
- # Filter Category Rewrite Rules
513
- function remove_category_base_from_rewrite_rules($category_rewrite) {
514
- $WPhtc_data=get_option('WPhtc_data');
515
- if($WPhtc_data['remove_category_base']){
516
- $category_rewrite=array();
517
- $categories=get_categories(array('hide_empty'=>false));
518
- foreach($categories as $category) {
519
- $category_nicename = urldecode($category->slug);
520
- if ( $category->parent == $category->cat_ID ){
521
- $category->parent = 0;
522
- }
523
- elseif ($category->parent != 0 ){
524
- $category_nicename = urldecode(get_category_parents( $category->parent, false, '/', true )) . $category_nicename;
525
- }
526
- $category_rewrite['('.$category_nicename.')/(?:feed/)?(feed|rdf|rss|rss2|atom)/?$'] = 'index.php?category_name=$matches[1]&feed=$matches[2]';
527
- $category_rewrite['('.$category_nicename.')/page/?([0-9]{1,})/?$'] = 'index.php?category_name=$matches[1]&paged=$matches[2]';
528
- $category_rewrite['('.$category_nicename.')/?$'] = 'index.php?category_name=$matches[1]';
529
- }
530
- }
531
- return $category_rewrite;
532
  }
 
533
  # Filter Author Rewrite Rules
534
  function remove_author_base_from_rewrite_rules($author_rewrite) {
535
  $WPhtc_data=get_option('WPhtc_data');
@@ -564,6 +558,15 @@ if (!class_exists("WPhtc")) {
564
  function wphtc_page_style(){
565
  wp_enqueue_style("htaccess-control-css", WP_PLUGIN_URL . '/wp-htaccess-control/wp-htaccess-control-ui.css');
566
  }
 
 
 
 
 
 
 
 
 
567
  # Options Page Actions
568
  function wphtc_page_action(){
569
  $this->wphtc_check_first_run();
@@ -626,8 +629,6 @@ if (!class_exists("WPhtc")) {
626
  $WPhtc_data['wp_hta'].="# else rewrite the request to WP\n";
627
  $WPhtc_data['wp_hta'].="RewriteRule . /index.php [L]\n";
628
  }
629
- # Remove Category Base
630
- $WPhtc_data['remove_category_base']=$_POST['WPhtc_remove_category_base'];
631
  # Remove Author Base
632
  $WPhtc_data['remove_author_base']=$_POST['WPhtc_remove_author_base'];
633
  # Advanced Archives
@@ -686,6 +687,23 @@ if (!class_exists("WPhtc")) {
686
  do_action("sm_rebuild");
687
  }
688
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
689
  # Update WP htaccess Control options
690
  update_option('WPhtc_data',$WPhtc_data);
691
  # Flush Rewrite Rules
@@ -713,14 +731,26 @@ if (isset($WPhtc)) {
713
  add_action('sm_buildmap',array($WPhtc,'set_sm'));
714
  add_action('init', array($WPhtc,'wphtc_init'));
715
  add_action('template_redirect', array($WPhtc,'wphtc_template_redirect') );
716
- add_filter('category_rewrite_rules', array($WPhtc,'remove_category_base_from_rewrite_rules'));
717
  add_filter('author_rewrite_rules', array($WPhtc,'remove_author_base_from_rewrite_rules'));
718
- add_filter('category_link', array($WPhtc,'filter_category_link'),1000,2);
719
- add_action('created_category',array($WPhtc,'refresh_rewrite_rules'));
720
- add_action('edited_category',array($WPhtc,'refresh_rewrite_rules'));
721
- add_action('delete_category',array($WPhtc,'refresh_rewrite_rules'));
722
- /* This refresh should maybe be conditional/author only, maybe not */
723
- add_action('user_register',array($WPhtc,'refresh_rewrite_rules'));
724
- add_action('delete_user',array($WPhtc,'refresh_rewrite_rules'));
 
 
 
 
 
 
 
 
 
 
 
 
 
725
  }
726
  ?>
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.0
7
  Author: António Andrade
8
  Author URI: http://dardna.com
9
  */
10
+ /* Copyright 2010-2012 António Andrade (email : antonio@antonioandra.de)
11
 
12
  This program is free software; you can redistribute it and/or modify
13
  it under the terms of the GNU General Public License as published by
45
  if($_GET['s']){
46
  wp_redirect( home_url( $WPhtc_data['custom_search_permalink']. "/" . rawurlencode(get_query_var( 's' )) ) );
47
  }
48
+
49
  # rewrite query
 
 
50
  if(strpos($_SERVER["REQUEST_URI"], $WPhtc_data['custom_search_permalink'])){
51
  global $wp_query;
52
  if(strpos($_SERVER["REQUEST_URI"], '/feed')){
59
  }
60
  }
61
  $page_base=($WPhtc_data['cpp']!='')?$WPhtc_data['cpp']:'page';
 
62
 
63
+ # in need of better regex
64
  if(!strpos($_SERVER["REQUEST_URI"], '/feed')&&!strpos($_SERVER["REQUEST_URI"],$page_base)){
65
  $pattern="/\/".$WPhtc_data['custom_search_permalink']."\/(.+)/";
66
  }
104
  return $link;
105
  }
106
  function wphtc_check_first_run(){
 
107
  $WPhtc_data=get_option('WPhtc_data');
108
+
109
+ # MIGRATE OPTIONS
110
+
111
+ // deprecating old category base removal
112
+ if($WPhtc_data['remove_category_base']){
113
+ unset($WPhtc_data['remove_category_base']);
114
+ $WPhtc_data['remove_taxonomy_base']['category']=true;
115
+ }
116
+ // deprecating old category archive
117
+ if($WPhtc_data['category_archives']){
118
+ unset($WPhtc_data['category_archives']);
119
+ $WPhtc_data['create_archive']['category']=true;
120
+ }
121
+ // deprecating old tag archive
122
+ if($WPhtc_data['tag_archives']){
123
+ unset($WPhtc_data['tag_archives']);
124
+ $WPhtc_data['create_archive']['post_tag']=true;
125
+ }
126
+ if($WPhtc_data['remove_category_base'] || $WPhtc_data['category_archives'] || $WPhtc_data['tag_archives']){
127
+ update_option('WPhtc_data',$WPhtc_data);
128
+ }
129
+
130
+ # flush rules to get some data filled on first usage
131
  if(!isset($WPhtc_data['htaccess_original'])){
132
  $this->refresh_rewrite_rules();
133
  }
136
  function refresh_rewrite_rules(){
137
  global $wp_rewrite;
138
  $wp_rewrite->flush_rules();
139
+ }
140
+ function refresh_rewrite_rules_later(){
141
+ wp_schedule_single_event(time(), 'flush_event');
142
  }
143
  # Filter pagination links generated by Wordpress
144
  function wphtc_filter_get_pagenum_link($result){
172
  return $requested_url;
173
  }
174
  }
175
+
176
+ # ancestors nesting method
177
+ function term_ancestors($tax,$id){
178
+ $term=get_term($id,$tax);
179
+ $ancestor=$term->slug;
180
+ if($term->parent!=0){
181
+ $ancestor=$this->term_ancestors($tax,$term->parent)."/".$ancestor;
182
+ }
183
+ return $ancestor;
184
+ }
185
  # Rewrite Rules: Add Category + Tag + Author Archives; Custom Pagination; Custom Author Base
186
  function wphtc_filter_rewrite_rules($rewrite_rules){
187
  $WPhtc_data=get_option('WPhtc_data');
188
+
189
  $page_base=($WPhtc_data['cpp']!='')?$WPhtc_data['cpp']:'page';
190
+
191
+ if($WPhtc_data['create_archive'] || $WPhtc_data['remove_taxonomy_base']){
192
+ foreach (get_taxonomies('','objects') as $taxonomy){
193
+ if(!$taxonomy->rewrite || !$WPhtc_data['remove_taxonomy_base'][$taxonomy->name] || !$WPhtc_data['create_archive'][$taxonomy->name]){continue;}
194
+ $terms=get_terms($taxonomy->name);
195
+ foreach($terms as $term){
196
+ $base=$WPhtc_data['remove_taxonomy_base'][$taxonomy->name]?"":$taxonomy->rewrite->slug."/";
197
+ if($term->parent!=0){
198
+ $ancestors=$this->term_ancestors($taxonomy->name,$term->parent)."/";
199
  }
200
+ else{
201
+ $ancestors="";
202
  }
203
+ // category hack
204
+ $tax_name=($taxonomy->name=="category")?"category_name":$taxonomy->name;
205
+
206
+ # create archives
207
+ if($WPhtc_data['create_archive'][$tax_name]){
208
+ #year
209
+ $new_rules[$base.$ancestors.'('.$term->slug.')/([0-9]{4})/?$'] = 'index.php?'.$tax_name.'=$matches[1]&year=$matches[2]';
210
+ $new_rules[$base.$ancestors.'('.$term->slug.')/([0-9]{4})/'.$page_base.'/?([0-9]{1,})/?$'] = 'index.php?'.$tax_name.'=$matches[1]&year=$matches[2]&paged=$matches[3]';
211
+ #year/month
212
+ $new_rules[$base.$ancestors.'('.$term->slug.')/([0-9]{4})/([0-9]{2})/?$'] = 'index.php?'.$tax_name.'=$matches[1]&year=$matches[2]&monthnum=$matches[3]';
213
+ $new_rules[$base.$ancestors.'('.$term->slug.')/([0-9]{4})/([0-9]{2})/'.$page_base.'/?([0-9]{1,})/?$'] = 'index.php?'.$tax_name.'=$matches[1]&year=$matches[2]&monthnum=$matches[3]&paged=$matches[4]';
214
+ #year/month/day
215
+ $new_rules[$base.$ancestors.'('.$term->slug.')/([0-9]{4})/([0-9]{2})/([0-9]{2})/?$'] = 'index.php?'.$tax_name.'=$matches[1]&year=$matches[2]&monthnum=$matches[3]&day=$matches[4]';
216
+ $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]';
217
+ }
218
+ # create rewrite rules with tax base
219
+ if(!$base){
220
+ $new_rules[$ancestors.'('.$term->slug.')/(?:feed/)?(feed|rdf|rss|rss2|atom)/?$'] = 'index.php?'.$tax_name.'=$matches[1]&feed=$matches[2]';
221
+ $new_rules[$ancestors.'('.$term->slug.')/page/?([0-9]{1,})/?$'] = 'index.php?'.$tax_name.'=$matches[1]&paged=$matches[2]';
222
+ $new_rules[$ancestors.'('.$term->slug.')/?$'] = 'index.php?'.$tax_name.'=$matches[1]';
223
+ }
224
+ $rewrite_rules = $new_rules + $rewrite_rules;
225
  }
226
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
227
  }
228
+
229
  # Author Archives
230
  if($WPhtc_data['remove_author_base']){
231
  $blogusers = get_users('who=authors');
258
 
259
  $rewrite_rules = $new_rules + $rewrite_rules;
260
  }
261
+
 
 
 
 
 
 
 
 
 
 
 
 
 
262
  # Custom Pagination; Custom Author Permalink
263
  if((isset($WPhtc_data['cap'])&&$WPhtc_data['cap']!='')||(isset($WPhtc_data['cpp'])&&$WPhtc_data['cpp']!='')){
264
  $rewrite_rules=serialize($rewrite_rules);
274
  if(isset($WPhtc_data['custom_search_permalink'])&&$WPhtc_data['custom_search_permalink']!=''){
275
  $rewrite_rules=str_replace('search/',$WPhtc_data['custom_search_permalink'].'/',$rewrite_rules);
276
  }
277
+
278
  $rewrite_rules=unserialize(preg_replace('!s:(\d+):"(.*?)";!se', "'s:'.strlen('$2').':\"$2\";'",$rewrite_rules));
279
  }
280
  return $rewrite_rules;
281
  }
282
+
283
  # Adding our Custom Author Base to the sitemap generated by Google XML Sitemaps
284
  # Adapted from sitemap-core.php (line ~2036)
285
  function set_sm(){
319
  $WPhtc_data=get_option('WPhtc_data');
320
  # Keeping a copy of the generated htaccess in our option array for later reviewing
321
  $WPhtc_data['cur_hta']='# BEGIN Wordpress<br/>'.nl2br($wp_rewrite->mod_rewrite_rules())."# END Wordpress";
 
 
322
  update_option('WPhtc_data',$WPhtc_data);
323
  return $wp_rewrite;
324
  }
508
  }
509
  return $new_rules;
510
  }
511
+
512
+ # Filter Term Link
513
+ function filter_term_link($termlink, $term, $taxonomy){
514
+ $txs=get_taxonomies(array('name'=>$taxonomy),"object");
515
+ foreach($txs as $t){
516
+ return str_replace($t->rewrite['slug']."/","",$termlink);
 
 
 
 
 
 
 
 
 
 
517
  }
 
518
  }
519
+
520
+ # Filter Taxonomy Base
521
+ function remove_taxonomy_base_from_rewrite_rules($rules){
522
+ # Let's remove every taxonomy rule here, we'll reacreate them at wphtc_filter_rewrite_rules()
523
+ return array();
524
+ //return $rules;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
525
  }
526
+
527
  # Filter Author Rewrite Rules
528
  function remove_author_base_from_rewrite_rules($author_rewrite) {
529
  $WPhtc_data=get_option('WPhtc_data');
558
  function wphtc_page_style(){
559
  wp_enqueue_style("htaccess-control-css", WP_PLUGIN_URL . '/wp-htaccess-control/wp-htaccess-control-ui.css');
560
  }
561
+
562
+ # Filter "View" Link on Administration
563
+ function filter_tax_table_actions( $actions, $tag){
564
+ if($tag->parent!=0){
565
+ $actions['view']='<a href="'.get_bloginfo('home').'/'.$this->term_ancestors($tag->taxonomy,$tag->parent).'/'.$tag->slug.'">View</a>';
566
+ }
567
+ return $actions;
568
+ }
569
+
570
  # Options Page Actions
571
  function wphtc_page_action(){
572
  $this->wphtc_check_first_run();
629
  $WPhtc_data['wp_hta'].="# else rewrite the request to WP\n";
630
  $WPhtc_data['wp_hta'].="RewriteRule . /index.php [L]\n";
631
  }
 
 
632
  # Remove Author Base
633
  $WPhtc_data['remove_author_base']=$_POST['WPhtc_remove_author_base'];
634
  # Advanced Archives
687
  do_action("sm_rebuild");
688
  }
689
  }
690
+
691
+ # Taxonomy Base removal options
692
+ unset($WPhtc_data['remove_taxonomy_base']);
693
+ if($_POST['WPhtc_remove_base']){
694
+ foreach($_POST['WPhtc_remove_base'] as $tax_key=>$remove){
695
+ $WPhtc_data['remove_taxonomy_base'][$tax_key]=$remove;
696
+ }
697
+ }
698
+
699
+ # Advanced archives
700
+ unset($WPhtc_data['create_archive']);
701
+ if($_POST['WPhtc_create_archive']){
702
+ foreach($_POST['WPhtc_create_archive'] as $tax_key=>$create_archive){
703
+ $WPhtc_data['create_archive'][$tax_key]=$create_archive;
704
+ }
705
+ }
706
+
707
  # Update WP htaccess Control options
708
  update_option('WPhtc_data',$WPhtc_data);
709
  # Flush Rewrite Rules
731
  add_action('sm_buildmap',array($WPhtc,'set_sm'));
732
  add_action('init', array($WPhtc,'wphtc_init'));
733
  add_action('template_redirect', array($WPhtc,'wphtc_template_redirect') );
 
734
  add_filter('author_rewrite_rules', array($WPhtc,'remove_author_base_from_rewrite_rules'));
735
+ add_filter('term_link',array($WPhtc,'filter_term_link'),10,3);
736
+
737
+ /* Taxonomy Base Removal*/
738
+ $WPhtc_data=get_option('WPhtc_data');
739
+ if($WPhtc_data['remove_taxonomy_base']){
740
+ foreach($WPhtc_data['remove_taxonomy_base'] as $tax=>$v){
741
+ if($v) {
742
+ add_filter($tax.'_rewrite_rules', array($WPhtc,'remove_taxonomy_base_from_rewrite_rules'));
743
+ add_filter($tax."_row_actions",array($WPhtc,'filter_tax_table_actions'), 10,2 );
744
+ }
745
+ }
746
+ }
747
+
748
+ add_action('flush_event',array($WPhtc,'refresh_rewrite_rules'));
749
+ add_action('created_term',array($WPhtc,'refresh_rewrite_rules_later'));
750
+ add_action('edited_term',array($WPhtc,'refresh_rewrite_rules_later'));
751
+ add_action('delete_term',array($WPhtc,'refresh_rewrite_rules_later'));
752
+ /* This flush should maybe be conditional to content authors only, maybe not */
753
+ add_action('user_register',array($WPhtc,'refresh_rewrite_rules_later'));
754
+ add_action('delete_user',array($WPhtc,'refresh_rewrite_rules_later'));
755
  }
756
  ?>