Plugin Directory

Changeset 428746


Ignore:
Timestamp:
08/25/2011 05:33:41 PM (15 years ago)
Author:
dardna
Message:
  • *Feature:* added option to remove author base.
Location:
wp-htaccess-control/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • wp-htaccess-control/trunk/readme.txt

    r427640 r428746  
    77Requires at least: 2.7
    88Tested up to: 3.2.1
    9 Stable tag: 2.5.8
     9Stable tag: 2.6
    1010
    1111Interface to customize the permalinks (author, category, archives and pagination) and htaccess file generated by Wordpress.
     
    1919
    2020* Customizing the htaccess file generated by Wordpress;
    21 * Removing the category base;
     21* Removing the category base from permalinks;
     22* Removing the author base from permalinks;
    2223* Customizing the Author Permalink Base;
    2324* Customizing Paginated Permalinks (translate the "page" word on permalinks to your own language);
     
    7374== Changelog ==
    7475
     76= 2.6 (23/08/2011) =
     77* *Feature:* added option to remove author base.
     78
    7579= 2.5.8 (23/08/2011) =
    7680* *Fix:* fixed file encoding introduced on 2.5.7 (which should always by UTF-8 without BOM).
  • wp-htaccess-control/trunk/wp-htaccess-control-ui.php

    r402270 r428746  
    157157                            <p class="description"><?php _e('If active, the category base will be removed from permalinks:'); ?></p>
    158158                            <p class="description"><code><?php bloginfo('home')?>/<?php _e('your-category', 'wp-htaccess-control'); ?></code></p>
     159                            <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>
     160                        </td>
     161                    </tr>
     162                </table>
     163            </div>
     164            <!-- Remove Author Base -->
     165            <div class="wphtc-section">
     166                <div class="wphtc-section-title stuffbox">
     167                    <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>
     168                    <h3><?php _e('Remove Author Base', 'wp-htaccess-control');?></h3>
     169                </div>
     170                <table class="form-table wphtc-inputs">
     171                    <tr valign="top">
     172                        <th scope="row" style="width:18%;"><?php _e('Remove Author Base', 'wp-htaccess-control'); ?></th>
     173                        <td >
     174                            <input type="checkbox" name="WPhtc_remove_author_base" <?php if($WPhtc_data['remove_author_base']){echo "checked=checked";} ?> />
     175                        </td>
     176                        <td valign="middle">
     177                            <p class="description"><?php _e('If active, the author base will be removed from permalinks:'); ?></p>
     178                            <p class="description"><code><?php bloginfo('home')?>/<?php _e('the-author', 'wp-htaccess-control'); ?></code></p>
     179                            <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>
     180                            <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>
    159181                        </td>
    160182                    </tr>
  • wp-htaccess-control/trunk/wp-htaccess-control.php

    r427627 r428746  
    44Plugin URI: http://dardna.com/wp-htaccess-control
    55Description: Interface to customize the permalinks (author, category, archives and pagination) and htaccess file generated by Wordpress.
    6 Version: 2.5.8
     6Version: 2.6
    77Author: António Andrade
    88Author URI: http://dardna.com
     
    130130        function wphtc_filter_author_link($link){
    131131            $WPhtc_data=get_option('WPhtc_data');
    132             if(isset($WPhtc_data['cap']) && $WPhtc_data['cap']!=''){
     132            if($WPhtc_data['remove_author_base']){
     133                $link=str_replace("author/","",$link);
     134                }
     135            else if(isset($WPhtc_data['cap']) && $WPhtc_data['cap']!=''){
    133136                $link=str_replace("author",urlencode($WPhtc_data['cap']),$link);
    134137                }
     
    194197                }
    195198            # Author Archives
    196             if(isset($WPhtc_data['author_archives'])){
     199            if($WPhtc_data['remove_author_base']){
     200                $blogusers = get_users('who=authors');
     201                    foreach ($blogusers as $user) {
     202                       
     203                        $new_rules = array(
     204                                    '('.$user->user_nicename.')/([^/]+)/([0-9]{4})/?$' => 'index.php?author_name=$matches[1]&year=$matches[2]',
     205                                    '('.$user->user_nicename.')/([^/]+)/([0-9]{4})/'.$page_base.'/?([0-9]{1,})/?$' => 'index.php?author_name=$matches[1]&year=$matches[2]&paged=$matches[3]',
     206                                   
     207                                    '('.$user->user_nicename.')/([^/]+)/([0-9]{4})/([0-9]{2})/?$' => 'index.php?author_name=$matches[1]&year=$matches[2]&monthnum=$matches[3]',
     208                                    '('.$user->user_nicename.')/([^/]+)/([0-9]{4})/([0-9]{2})/'.$page_base.'/?([0-9]{1,})/?$' => 'index.php?author_name=$matches[1]&year=$matches[2]&monthnum=$matches[3]&paged=$matches[4]',
     209                                   
     210                                    '('.$user->user_nicename.')/([^/]+)/([0-9]{4})/([0-9]{2})/([0-9]{2})/?$' => 'index.php?author_name=$matches[1]&year=$matches[2]&monthnum=$matches[3]&day=$matches[4]',
     211                                    '('.$user->user_nicename.')/([^/]+)/([0-9]{4})/([0-9]{2})/([0-9]{2})/'.$page_base.'/?([0-9]{1,})/?$' => 'index.php?author_name=$matches[1]&year=$matches[2]&monthnum=$matches[3]&day=$matches[4]&paged=$matches[5]');
     212                                   
     213                                    $rewrite_rules = $new_rules + $rewrite_rules;
     214                    }
     215                }
     216            else if(isset($WPhtc_data['author_archives'])){
    197217                $author_base = ($WPhtc_data['cap']!='')?$WPhtc_data['cap']:'author';
    198218                $new_rules = array(
     
    480500                }
    481501            return $category_rewrite;
     502            }
     503        # Filter Author Rewrite Rules
     504        function remove_author_base_from_rewrite_rules($author_rewrite) {
     505            $WPhtc_data=get_option('WPhtc_data');
     506            if($WPhtc_data['remove_author_base']){
     507                $author_rewrite=array();
     508                $blogusers = get_users('who=authors');
     509                foreach($blogusers as $user) {
     510                    $author_rewrite['('.$user->user_nicename.')/(?:feed/)?(feed|rdf|rss|rss2|atom)/?$'] = 'index.php?author_name=$matches[1]&feed=$matches[2]';
     511                    $author_rewrite['('.$user->user_nicename.')/page/?([0-9]{1,})/?$'] = 'index.php?author_name=$matches[1]&paged=$matches[2]';
     512                    $author_rewrite['('.$user->user_nicename.')/?$'] = 'index.php?author_name=$matches[1]';
     513                    }
     514                }
     515            return $author_rewrite;
    482516            }
    483517        # WP-htaccess Control options page interface
     
    565599                        # Remove Category Base
    566600                        $WPhtc_data['remove_category_base']=$_POST['WPhtc_remove_category_base'];
     601                        # Remove Author Base
     602                        $WPhtc_data['remove_author_base']=$_POST['WPhtc_remove_author_base'];
    567603                        # Advanced Archives
    568604                        $WPhtc_data['category_archives']=$_POST['WPhtc_category_archives'];
     
    635671    add_action('template_redirect', array($WPhtc,'wphtc_template_redirect') );
    636672    add_filter('category_rewrite_rules', array($WPhtc,'remove_category_base_from_rewrite_rules'));
     673    add_filter('author_rewrite_rules', array($WPhtc,'remove_author_base_from_rewrite_rules'));
    637674    add_filter('category_link', array($WPhtc,'filter_category_link'),1000,2);
    638675    add_action('created_category',array($WPhtc,'refresh_rewrite_rules'));
Note: See TracChangeset for help on using the changeset viewer.