Version Description
Download this release
Release Info
Developer | Toro_Unit |
Plugin | Custom Post Type Permalinks |
Version | 0.7.8 |
Comparing to | |
See all releases |
Code changes from version 0.7.6 to 0.7.8
- custom-post-type-permalinks.php +27 -6
- readme.txt +3 -1
custom-post-type-permalinks.php
CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://www.torounit.com
|
|
5 |
Description: Add post archives of custom post type and customizable permalinks.
|
6 |
Author: Toro-Unit
|
7 |
Author URI: http://www.torounit.com/plugins/custom-post-type-permalinks/
|
8 |
-
Version: 0.7.
|
9 |
Text Domain: cptp
|
10 |
Domain Path: /
|
11 |
*/
|
@@ -45,7 +45,7 @@ class Custom_Post_Type_Permalinks {
|
|
45 |
add_filter('post_type_link', array(&$this,'set_permalink'),10,3);
|
46 |
|
47 |
add_filter('getarchives_where', array(&$this,'get_archives_where'), 10, 2);
|
48 |
-
add_filter('get_archives_link', array(&$this,'get_archives_link'));
|
49 |
add_filter('term_link', array(&$this,'set_term_link'),10,3);
|
50 |
}
|
51 |
}
|
@@ -143,6 +143,10 @@ class Custom_Post_Type_Permalinks {
|
|
143 |
$wp_rewrite->add_rewrite_tag( '%post_type%', '([^/]+)', 'post_type=' );
|
144 |
$wp_rewrite->add_rewrite_tag( '%'.$post_type.'_id%', '([0-9]{1,})','post_type='.$post_type.'&p=' );
|
145 |
$wp_rewrite->add_rewrite_tag( '%'.$post_type.'_page%', '/?([0-9]{1,}?)/?',"page=" );
|
|
|
|
|
|
|
|
|
146 |
$wp_rewrite->add_permastruct( $post_type, $permalink, false );
|
147 |
|
148 |
endforeach;
|
@@ -240,21 +244,38 @@ class Custom_Post_Type_Permalinks {
|
|
240 |
return $where;
|
241 |
}
|
242 |
|
243 |
-
function get_archives_link( $
|
244 |
//$slug = get_post_type_object($this->get_archives_where_r['post_type'])->rewrite['slug'];
|
245 |
if (isset($this->get_archives_where_r['post_type']) and $this->get_archives_where_r['type'] != 'postbypost'){
|
246 |
$blog_url = get_bloginfo("url");
|
|
|
|
|
|
|
247 |
if($str = rtrim( preg_replace("/%[a-z,_]*%/","",get_option("permalink_structure")) ,'/')) {
|
248 |
-
$
|
249 |
}else{
|
250 |
$blog_url = rtrim($blog_url,"/");
|
251 |
-
$
|
252 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
253 |
}
|
254 |
|
255 |
-
return $
|
|
|
|
|
256 |
}
|
257 |
|
|
|
|
|
258 |
/**
|
259 |
* fix permalink custom taxonomy
|
260 |
*/
|
5 |
Description: Add post archives of custom post type and customizable permalinks.
|
6 |
Author: Toro-Unit
|
7 |
Author URI: http://www.torounit.com/plugins/custom-post-type-permalinks/
|
8 |
+
Version: 0.7.8
|
9 |
Text Domain: cptp
|
10 |
Domain Path: /
|
11 |
*/
|
45 |
add_filter('post_type_link', array(&$this,'set_permalink'),10,3);
|
46 |
|
47 |
add_filter('getarchives_where', array(&$this,'get_archives_where'), 10, 2);
|
48 |
+
add_filter('get_archives_link', array(&$this,'get_archives_link'),20,1);
|
49 |
add_filter('term_link', array(&$this,'set_term_link'),10,3);
|
50 |
}
|
51 |
}
|
143 |
$wp_rewrite->add_rewrite_tag( '%post_type%', '([^/]+)', 'post_type=' );
|
144 |
$wp_rewrite->add_rewrite_tag( '%'.$post_type.'_id%', '([0-9]{1,})','post_type='.$post_type.'&p=' );
|
145 |
$wp_rewrite->add_rewrite_tag( '%'.$post_type.'_page%', '/?([0-9]{1,}?)/?',"page=" );
|
146 |
+
//test
|
147 |
+
if(is_post_type_hierarchical($post_type)) {
|
148 |
+
$wp_rewrite->add_rewrite_tag( '%'.$post_type.'%', '(?:[^/]+/){1}([^/]+)/?','name=' );
|
149 |
+
}
|
150 |
$wp_rewrite->add_permastruct( $post_type, $permalink, false );
|
151 |
|
152 |
endforeach;
|
244 |
return $where;
|
245 |
}
|
246 |
|
247 |
+
public function get_archives_link( $link ) {
|
248 |
//$slug = get_post_type_object($this->get_archives_where_r['post_type'])->rewrite['slug'];
|
249 |
if (isset($this->get_archives_where_r['post_type']) and $this->get_archives_where_r['type'] != 'postbypost'){
|
250 |
$blog_url = get_bloginfo("url");
|
251 |
+
|
252 |
+
|
253 |
+
// /archive/%post_id%
|
254 |
if($str = rtrim( preg_replace("/%[a-z,_]*%/","",get_option("permalink_structure")) ,'/')) {
|
255 |
+
$ret_link = str_replace($str, '/'.'%link_dir%', $link);
|
256 |
}else{
|
257 |
$blog_url = rtrim($blog_url,"/");
|
258 |
+
$ret_link = str_replace($blog_url,$blog_url.'/'.'%link_dir%',$link);
|
259 |
}
|
260 |
+
$link_dir = $this->get_archives_where_r['post_type'];
|
261 |
+
|
262 |
+
if(!strstr($link,'/date/')){
|
263 |
+
$link_dir = $link_dir .'/date';
|
264 |
+
}
|
265 |
+
|
266 |
+
$ret_link = str_replace('%link_dir%',$link_dir,$ret_link);
|
267 |
+
|
268 |
+
return $ret_link;
|
269 |
+
|
270 |
}
|
271 |
|
272 |
+
return $link;
|
273 |
+
|
274 |
+
|
275 |
}
|
276 |
|
277 |
+
|
278 |
+
|
279 |
/**
|
280 |
* fix permalink custom taxonomy
|
281 |
*/
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: Toro_Unit
|
|
3 |
Tags: custom post type,permalink
|
4 |
Requires at least: 3.2
|
5 |
Tested up to: 3.3
|
6 |
-
Stable tag: 0.7.
|
7 |
|
8 |
Lets you edit the permalink of custom post type.
|
9 |
|
@@ -32,6 +32,8 @@ That's it. You can access the permalinks setting by going to *Settings -> Permal
|
|
32 |
|
33 |
== Changelog ==
|
34 |
|
|
|
|
|
35 |
|
36 |
= 0.7.6 =
|
37 |
* Add parent's slug to hierarchical post type.
|
3 |
Tags: custom post type,permalink
|
4 |
Requires at least: 3.2
|
5 |
Tested up to: 3.3
|
6 |
+
Stable tag: 0.7.8
|
7 |
|
8 |
Lets you edit the permalink of custom post type.
|
9 |
|
32 |
|
33 |
== Changelog ==
|
34 |
|
35 |
+
= 0.7.7 =
|
36 |
+
* Bug fix
|
37 |
|
38 |
= 0.7.6 =
|
39 |
* Add parent's slug to hierarchical post type.
|