Custom Post Type Permalinks - Version 0.9.5.6

Version Description

  • Strict Standard Error Fix.
Download this release

Release Info

Developer Toro_Unit
Plugin Icon 128x128 Custom Post Type Permalinks
Version 0.9.5.6
Comparing to
See all releases

Code changes from version 0.9.5.4 to 0.9.5.6

CPTP.php CHANGED
@@ -11,7 +11,7 @@
11
  * */
12
 
13
 
14
- define( "CPTP_VERSION", "0.9.3" );
15
  define( "CPTP_DEFAULT_PERMALINK", "/%postname%/" );
16
  define( "CPTP_DIR", dirname( __FILE__ ) );
17
 
11
  * */
12
 
13
 
14
+ define( "CPTP_VERSION", "0.9.5.6" );
15
  define( "CPTP_DEFAULT_PERMALINK", "/%postname%/" );
16
  define( "CPTP_DIR", dirname( __FILE__ ) );
17
 
CPTP/Module/GetArchives.php CHANGED
@@ -90,8 +90,7 @@ class CPTP_Module_GetArchives extends CPTP_Module {
90
  $this->get_archives_where_r['post_type'] = isset($this->get_archives_where_r['post_type_slug']) ? $this->get_archives_where_r['post_type_slug'] : $t; // [steve] [*** bug fixing]
91
 
92
  if (isset($this->get_archives_where_r['post_type']) and $this->get_archives_where_r['type'] != 'postbypost'){
93
- $blog_url = rtrim( get_bloginfo("url") ,'/');
94
-
95
 
96
  //remove front
97
  $front = substr( $wp_rewrite->front, 1 );
90
  $this->get_archives_where_r['post_type'] = isset($this->get_archives_where_r['post_type_slug']) ? $this->get_archives_where_r['post_type_slug'] : $t; // [steve] [*** bug fixing]
91
 
92
  if (isset($this->get_archives_where_r['post_type']) and $this->get_archives_where_r['type'] != 'postbypost'){
93
+ $blog_url = rtrim( home_url() ,'/');
 
94
 
95
  //remove front
96
  $front = substr( $wp_rewrite->front, 1 );
CPTP/Module/Permalink.php CHANGED
@@ -72,7 +72,15 @@ class CPTP_Module_Permalink extends CPTP_Module {
72
  //画像の編集ページでのリンク
73
  if( isset($_GET["post"]) && $_GET["post"] != $post->ID ) {
74
  $parent_structure = trim(get_option( $post->post_type.'_structure' ), "/");
75
- if( "%post_id%" == $parent_structure or "%post_id%" == array_pop( explode( "/", $parent_structure ) ) ) {
 
 
 
 
 
 
 
 
76
  $permalink = $permalink."/attachment/";
77
  };
78
  }
@@ -205,6 +213,8 @@ class CPTP_Module_Permalink extends CPTP_Module {
205
  *
206
  */
207
  public function term_link( $termlink, $term, $taxonomy ) {
 
 
208
  if( get_option('no_taxonomy_structure') ) {
209
  return $termlink;
210
  }
@@ -227,21 +237,15 @@ class CPTP_Module_Permalink extends CPTP_Module {
227
  $post_type_obj = get_post_type_object($post_type);
228
  $slug = $post_type_obj->rewrite['slug'];
229
  $with_front = $post_type_obj->rewrite['with_front'];
 
 
230
 
231
-
232
- //拡張子を削除
233
- $str = explode(".", get_option("permalink_structure"));
234
- $str = array_shift($str);
235
- $str = rtrim( preg_replace( "/%[a-z_]*%/", "" ,$str) ,'/' );//remove with front
236
- $termlink = str_replace($str."/", "/", $termlink );
237
-
238
-
239
- if( $with_front === false ) {
240
- $str = "";
241
  }
242
- $slug = $str."/".$slug;
243
 
244
- $termlink = str_replace( $wp_home, $wp_home.$slug, $termlink );
 
245
  if ( ! $taxonomy->rewrite['hierarchical'] ) {
246
  $termlink = str_replace( $term->slug.'/', CPTP_Util::get_taxonomy_parents( $term->term_id,$taxonomy->name, false, '/', true ), $termlink );
247
  }
72
  //画像の編集ページでのリンク
73
  if( isset($_GET["post"]) && $_GET["post"] != $post->ID ) {
74
  $parent_structure = trim(get_option( $post->post_type.'_structure' ), "/");
75
+ $parent_dirs = explode( "/", $parent_structure );
76
+ if(is_array($parent_dirs)) {
77
+ $last_dir = array_pop( $parent_dirs );
78
+ }
79
+ else {
80
+ $last_dir = $parent_dirs;
81
+ }
82
+
83
+ if( "%post_id%" == $parent_structure or "%post_id%" == $last_dir ) {
84
  $permalink = $permalink."/attachment/";
85
  };
86
  }
213
  *
214
  */
215
  public function term_link( $termlink, $term, $taxonomy ) {
216
+ global $wp_rewrite;
217
+
218
  if( get_option('no_taxonomy_structure') ) {
219
  return $termlink;
220
  }
237
  $post_type_obj = get_post_type_object($post_type);
238
  $slug = $post_type_obj->rewrite['slug'];
239
  $with_front = $post_type_obj->rewrite['with_front'];
240
+ $front = substr( $wp_rewrite->front, 1 );
241
+ $termlink = str_replace($front,"",$termlink);
242
 
243
+ if( $with_front ) {
244
+ $slug = $front.$slug;
 
 
 
 
 
 
 
 
245
  }
 
246
 
247
+ $termlink = str_replace( $wp_home, $wp_home."/".$slug, $termlink );
248
+
249
  if ( ! $taxonomy->rewrite['hierarchical'] ) {
250
  $termlink = str_replace( $term->slug.'/', CPTP_Util::get_taxonomy_parents( $term->term_id,$taxonomy->name, false, '/', true ), $termlink );
251
  }
CPTP/Module/Rewrite.php CHANGED
@@ -167,7 +167,10 @@ class CPTP_Module_Rewrite extends CPTP_Module {
167
  foreach ($taxes as $key => $tax) {
168
  if(isset($obj->query_vars[$tax])) {
169
  if(strpos( $obj->query_vars[$tax] ,"/") !== false ) {
170
- $obj->query_vars[$tax] = array_pop(explode("/", $obj->query_vars[$tax]));
 
 
 
171
  }
172
  }
173
  }
167
  foreach ($taxes as $key => $tax) {
168
  if(isset($obj->query_vars[$tax])) {
169
  if(strpos( $obj->query_vars[$tax] ,"/") !== false ) {
170
+ $query_vars = explode("/", $obj->query_vars[$tax]);
171
+ if(is_array($query_vars)) {
172
+ $obj->query_vars[$tax] = array_pop($query_vars);
173
+ }
174
  }
175
  }
176
  }
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.9.5.4
9
  Text Domain: cptp
10
  License: GPL2 or later
11
  Domain Path: /language/
@@ -24,6 +24,9 @@ Domain Path: /language/
24
 
25
  require_once dirname(__FILE__).'/CPTP.php';
26
 
27
- CPTP::get_instance();
 
 
 
28
 
29
 
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.9.5.6
9
  Text Domain: cptp
10
  License: GPL2 or later
11
  Domain Path: /language/
24
 
25
  require_once dirname(__FILE__).'/CPTP.php';
26
 
27
+ add_action( 'plugins_loaded', 'cptp_init_instance' );
28
+ function cptp_init_instance() {
29
+ CPTP::get_instance();
30
+ }
31
 
32
 
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: Toro_Unit
3
  Tags: permalink,permalinks,custom post type,custom taxonomy,cms
4
  Requires at least: 3.7
5
  Tested up to: 3.9
6
- Stable tag: 0.9.5.4
7
 
8
  Lets you edit the permalink of custom post type.
9
 
@@ -41,6 +41,9 @@ That's it. You can access the permalinks setting by going to *Settings -> Permal
41
 
42
  == Changelog ==
43
 
 
 
 
44
  = 0.9.5.4 =
45
  * archive link bug fix.
46
  * Tested Up 3.9
3
  Tags: permalink,permalinks,custom post type,custom taxonomy,cms
4
  Requires at least: 3.7
5
  Tested up to: 3.9
6
+ Stable tag: 0.9.5.6
7
 
8
  Lets you edit the permalink of custom post type.
9
 
41
 
42
  == Changelog ==
43
 
44
+ = 0.9.5.6 =
45
+ * Strict Standard Error Fix.
46
+
47
  = 0.9.5.4 =
48
  * archive link bug fix.
49
  * Tested Up 3.9