Version Description
Download this release
Release Info
Developer | michaeltyson |
Plugin | Custom Permalinks |
Version | 0.5.2 |
Comparing to | |
See all releases |
Code changes from version 0.5.1 to 0.5.2
- custom-permalinks.php +10 -7
- readme.txt +4 -2
custom-permalinks.php
CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Custom Permalinks
|
|
4 |
Plugin URI: http://michael.tyson.id.au/wordpress/plugins/custom-permalinks
|
5 |
Donate link: http://michael.tyson.id.au/wordpress/plugins/custom-permalinks
|
6 |
Description: Set custom permalinks on a per-post basis
|
7 |
-
Version: 0.5.
|
8 |
Author: Michael Tyson
|
9 |
Author URI: http://michael.tyson.id.au
|
10 |
*/
|
@@ -158,17 +158,19 @@ function custom_permalinks_request($query) {
|
|
158 |
" meta_key = 'custom_permalink' AND ".
|
159 |
" meta_value != '' AND ".
|
160 |
" ( meta_value = LEFT('".mysql_escape_string($request)."', LENGTH(meta_value)) OR ".
|
161 |
-
" meta_value = LEFT('".mysql_escape_string($request."/")."', LENGTH(meta_value)) )"
|
|
|
162 |
|
163 |
$posts = $wpdb->get_results($sql);
|
|
|
164 |
if ( $posts ) {
|
165 |
// A post matches our request
|
166 |
|
167 |
// Preserve this url for later if it's the same as the permalink (no extra stuff)
|
168 |
if ( trim($request,'/') == trim($posts[0]->meta_value,'/') )
|
169 |
$_CPRegisteredURL = $request;
|
170 |
-
|
171 |
-
$originalUrl = preg_replace('@/+@', '/', str_replace( trim($posts[0]->meta_value,'/'
|
172 |
( $posts[0]->post_type == 'post' ?
|
173 |
custom_permalinks_original_post_link($posts[0]->ID)
|
174 |
: custom_permalinks_original_page_link($posts[0]->ID) ),
|
@@ -200,7 +202,7 @@ function custom_permalinks_request($query) {
|
|
200 |
}
|
201 |
}
|
202 |
}
|
203 |
-
|
204 |
if ( $originalUrl ) {
|
205 |
|
206 |
if ( ($pos=strpos($_SERVER['REQUEST_URI'], '?')) !== false ) {
|
@@ -211,7 +213,7 @@ function custom_permalinks_request($query) {
|
|
211 |
// Now we have the original URL, run this back through WP->parse_request, in order to
|
212 |
// parse parameters properly. We set $_SERVER variables to fool the function.
|
213 |
$oldPathInfo = $_SERVER['PATH_INFO']; $oldRequestUri = $_SERVER['REQUEST_URI']; $oldQueryString = $_SERVER['QUERY_STRING'];
|
214 |
-
$_SERVER['
|
215 |
$_SERVER['QUERY_STRING'] = (($pos=strpos($originalUrl, '?')) !== false ? substr($originalUrl, $pos+1) : '');
|
216 |
parse_str($_SERVER['QUERY_STRING'], $queryArray);
|
217 |
$oldValues = array();
|
@@ -220,7 +222,7 @@ function custom_permalinks_request($query) {
|
|
220 |
$oldValues[$key] = $_REQUEST[$key];
|
221 |
$_REQUEST[$key] = $_GET[$key] = $value;
|
222 |
}
|
223 |
-
|
224 |
// Re-run the filter, now with original environment in place
|
225 |
remove_filter( 'request', 'custom_permalinks_request', 10, 1 );
|
226 |
global $wp;
|
@@ -234,6 +236,7 @@ function custom_permalinks_request($query) {
|
|
234 |
$_REQUEST[$key] = $value;
|
235 |
}
|
236 |
}
|
|
|
237 |
return $query;
|
238 |
}
|
239 |
|
4 |
Plugin URI: http://michael.tyson.id.au/wordpress/plugins/custom-permalinks
|
5 |
Donate link: http://michael.tyson.id.au/wordpress/plugins/custom-permalinks
|
6 |
Description: Set custom permalinks on a per-post basis
|
7 |
+
Version: 0.5.2
|
8 |
Author: Michael Tyson
|
9 |
Author URI: http://michael.tyson.id.au
|
10 |
*/
|
158 |
" meta_key = 'custom_permalink' AND ".
|
159 |
" meta_value != '' AND ".
|
160 |
" ( meta_value = LEFT('".mysql_escape_string($request)."', LENGTH(meta_value)) OR ".
|
161 |
+
" meta_value = LEFT('".mysql_escape_string($request."/")."', LENGTH(meta_value)) ) ".
|
162 |
+
" ORDER BY LENGTH(meta_value) DESC";
|
163 |
|
164 |
$posts = $wpdb->get_results($sql);
|
165 |
+
|
166 |
if ( $posts ) {
|
167 |
// A post matches our request
|
168 |
|
169 |
// Preserve this url for later if it's the same as the permalink (no extra stuff)
|
170 |
if ( trim($request,'/') == trim($posts[0]->meta_value,'/') )
|
171 |
$_CPRegisteredURL = $request;
|
172 |
+
|
173 |
+
$originalUrl = preg_replace('@/+@', '/', str_replace( trim($posts[0]->meta_value,'/'),
|
174 |
( $posts[0]->post_type == 'post' ?
|
175 |
custom_permalinks_original_post_link($posts[0]->ID)
|
176 |
: custom_permalinks_original_page_link($posts[0]->ID) ),
|
202 |
}
|
203 |
}
|
204 |
}
|
205 |
+
|
206 |
if ( $originalUrl ) {
|
207 |
|
208 |
if ( ($pos=strpos($_SERVER['REQUEST_URI'], '?')) !== false ) {
|
213 |
// Now we have the original URL, run this back through WP->parse_request, in order to
|
214 |
// parse parameters properly. We set $_SERVER variables to fool the function.
|
215 |
$oldPathInfo = $_SERVER['PATH_INFO']; $oldRequestUri = $_SERVER['REQUEST_URI']; $oldQueryString = $_SERVER['QUERY_STRING'];
|
216 |
+
$_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO'] = '/'.ltrim($originalUrl,'/');
|
217 |
$_SERVER['QUERY_STRING'] = (($pos=strpos($originalUrl, '?')) !== false ? substr($originalUrl, $pos+1) : '');
|
218 |
parse_str($_SERVER['QUERY_STRING'], $queryArray);
|
219 |
$oldValues = array();
|
222 |
$oldValues[$key] = $_REQUEST[$key];
|
223 |
$_REQUEST[$key] = $_GET[$key] = $value;
|
224 |
}
|
225 |
+
|
226 |
// Re-run the filter, now with original environment in place
|
227 |
remove_filter( 'request', 'custom_permalinks_request', 10, 1 );
|
228 |
global $wp;
|
236 |
$_REQUEST[$key] = $value;
|
237 |
}
|
238 |
}
|
239 |
+
|
240 |
return $query;
|
241 |
}
|
242 |
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
Donate link: http://michael.tyson.id.au/wordpress/plugins/custom-permalinks
|
4 |
Tags: permalink, url, link, address, custom, redirect
|
5 |
Requires at least: 2.6
|
6 |
-
Tested up to: 2.
|
7 |
-
Stable tag: 0.5.
|
8 |
|
9 |
Set custom permalinks on a per-post, per-tag or per-category basis.
|
10 |
|
@@ -23,6 +23,8 @@ over your site structure.
|
|
23 |
|
24 |
== Changelog ==
|
25 |
|
|
|
|
|
26 |
0.5.1: Compatibility fix for WP 2.7's tag/category pages
|
27 |
|
28 |
0.5: Support for Wordpress sites in subdirectories (i.e., not located at the webroot)
|
3 |
Donate link: http://michael.tyson.id.au/wordpress/plugins/custom-permalinks
|
4 |
Tags: permalink, url, link, address, custom, redirect
|
5 |
Requires at least: 2.6
|
6 |
+
Tested up to: 2.8.4
|
7 |
+
Stable tag: 0.5.2
|
8 |
|
9 |
Set custom permalinks on a per-post, per-tag or per-category basis.
|
10 |
|
23 |
|
24 |
== Changelog ==
|
25 |
|
26 |
+
0.5.2: Bugfix for matching posts when there are multiple posts that match parts of the query
|
27 |
+
|
28 |
0.5.1: Compatibility fix for WP 2.7's tag/category pages
|
29 |
|
30 |
0.5: Support for Wordpress sites in subdirectories (i.e., not located at the webroot)
|