Plugin Directory

Changeset 588769


Ignore:
Timestamp:
08/22/2012 10:17:30 AM (14 years ago)
Author:
michaeltyson
Message:

Permalinks are now case insensitive, thanks to @ericmann; Tagged v0.7.15

Location:
custom-permalinks
Files:
3 added
2 edited

Legend:

Unmodified
Added
Removed
  • custom-permalinks/trunk/custom-permalinks.php

    r550239 r588769  
    55Donate link: http://atastypixel.com/blog/wordpress/plugins/custom-permalinks/
    66Description: Set custom permalinks on a per-post basis
    7 Version: 0.7.14
     7Version: 0.7.15
    88Author: Michael Tyson
    99Author URI: http://atastypixel.com/blog
     
    9494   
    9595    // Get request URI, strip parameters
    96     $url = parse_url(get_bloginfo('url')); $url = $url['path'];
     96    $url = parse_url(get_bloginfo('url'));
     97    $url = isset($url['path']) ? $url['path'] : '';
    9798    $request = ltrim(substr($_SERVER['REQUEST_URI'], strlen($url)),'/');
    9899    if ( ($pos=strpos($request, "?")) ) $request = substr($request, 0, $pos);
     
    114115                                          custom_permalinks_original_category_link($theTerm->term_id));
    115116    }
    116    
     117
    117118    if ( $custom_permalink &&
    118119            (substr($request, 0, strlen($custom_permalink)) != $custom_permalink ||
     
    152153   
    153154    // Get request URI, strip parameters and /'s
    154     $url = parse_url(get_bloginfo('url')); $url = $url['path'];
     155    $url = parse_url(get_bloginfo('url'));
     156    $url = isset($url['path']) ? $url['path'] : '';
    155157    $request = ltrim(substr($_SERVER['REQUEST_URI'], strlen($url)),'/');
    156158    $request = (($pos=strpos($request, '?')) ? substr($request, 0, $pos) : $request);
    157159    $request_noslash = preg_replace('@/+@','/', trim($request, '/'));
    158    
     160
    159161    if ( !$request ) return $query;
    160162   
     
    163165                "  meta_key = 'custom_permalink' AND ".
    164166                "  meta_value != '' AND ".
    165                 "  ( meta_value = LEFT('".mysql_escape_string($request_noslash)."', LENGTH(meta_value)) OR ".
    166                 "    meta_value = LEFT('".mysql_escape_string($request_noslash."/")."', LENGTH(meta_value)) ) ".
     167                "  ( LOWER(meta_value) = LEFT(LOWER('".mysql_escape_string($request_noslash)."'), LENGTH(meta_value)) OR ".
     168                "    LOWER(meta_value) = LEFT(LOWER('".mysql_escape_string($request_noslash."/")."'), LENGTH(meta_value)) ) ".
    167169                "ORDER BY LENGTH(meta_value) DESC LIMIT 1";
    168170
    169171    $posts = $wpdb->get_results($sql);
    170    
     172
    171173    if ( $posts ) {
    172174        // A post matches our request
     
    176178            $_CPRegisteredURL = $request;
    177179               
    178         $originalUrl =  preg_replace( '@/+@', '/', str_replace( trim( $posts[0]->meta_value,'/' ),
     180        $originalUrl =  preg_replace( '@/+@', '/', str_replace( trim( strtolower($posts[0]->meta_value),'/' ),
    179181                                    ( $posts[0]->post_type == 'page' ?
    180182                                            custom_permalinks_original_page_link($posts[0]->ID)
    181183                                            : custom_permalinks_original_post_link($posts[0]->ID) ),
    182                                    $request_noslash ) );
    183     }
    184    
     184                                   strtolower($request_noslash) ) );
     185    }
     186
    185187    if ( $originalUrl === NULL ) {
    186188        // See if any terms have a matching permalink
     
    231233            $_REQUEST[$key] = $_GET[$key] = $value;
    232234        }
    233                
     235
    234236        // Re-run the filter, now with original environment in place
    235237        remove_filter( 'request', 'custom_permalinks_request', 10, 1 );
  • custom-permalinks/trunk/readme.txt

    r550239 r588769  
    55Requires at least: 2.6
    66Tested up to: 3.3.1
    7 Stable tag: 0.7.14
     7Stable tag: 0.7.15
    88
    99Set custom permalinks on a per-post, per-tag or per-category basis.
     
    2929
    3030== Changelog ==
     31
     32= 0.7.15 =
     33
     34 * Permalinks are now case-insensitive (thanks to @ericmann)
    3135
    3236= 0.7.14 =
Note: See TracChangeset for help on using the changeset viewer.