Custom Post Type Permalinks - Version 1.0.2

Version Description

  • category slug bug fix.
Download this release

Release Info

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

Code changes from version 1.0.1 to 1.0.2

CPTP/Module/Rewrite.php CHANGED
@@ -6,7 +6,7 @@
6
  * Add Rewrite Rules
7
  *
8
  * @package Custom_Post_Type_Permalinks
9
- * @version 1.0.1
10
  * @since 0.9.4
11
  *
12
  * */
@@ -108,10 +108,6 @@ class CPTP_Module_Rewrite extends CPTP_Module {
108
  $rewrite_args = array( 'with_front' => $args->rewrite );
109
  }
110
 
111
- $rewrite_args['walk_dirs'] = false;
112
- add_permastruct( $post_type, $permalink, $rewrite_args );
113
-
114
-
115
  $slug = $args->rewrite['slug'];
116
  if ( $args->has_archive ) {
117
  if ( is_string( $args->has_archive ) ) {
@@ -124,6 +120,10 @@ class CPTP_Module_Rewrite extends CPTP_Module {
124
 
125
  $date_front = CPTP_Util::get_date_front( $post_type );
126
 
 
 
 
 
127
  add_rewrite_rule( $slug . $date_front . '/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$', 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&feed=$matches[4]&post_type=' . $post_type, 'top' );
128
  add_rewrite_rule( $slug . $date_front . '/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$', 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&feed=$matches[4]&post_type=' . $post_type, 'top' );
129
  add_rewrite_rule( $slug . $date_front . '/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/page/?([0-9]{1,})/?$', 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&paged=$matches[4]&post_type=' . $post_type, 'top' );
@@ -138,11 +138,15 @@ class CPTP_Module_Rewrite extends CPTP_Module {
138
  add_rewrite_rule( $slug . $date_front . '/([0-9]{4})/?$', 'index.php?year=$matches[1]&post_type=' . $post_type, 'top' );
139
  add_rewrite_rule( $slug . '/author/([^/]+)/page/?([0-9]{1,})/?$', 'index.php?author_name=$matches[1]&paged=$matches[2]&post_type=' . $post_type, 'top' );
140
  add_rewrite_rule( $slug . '/author/([^/]+)/?$', 'index.php?author_name=$matches[1]&post_type=' . $post_type, 'top' );
141
- add_rewrite_rule( $slug . get_option( 'category_base' ) . '/([^/]+)/page/?([0-9]{1,})/?$', 'index.php?category_name=$matches[1]&paged=$matches[2]&post_type=' . $post_type, 'top' );
142
- add_rewrite_rule( $slug . get_option( 'category_base' ) . '/([^/]+)/?$', 'index.php?category_name=$matches[1]&post_type=' . $post_type, 'top' );
143
 
144
  do_action( 'CPTP_registered_' . $post_type . '_rules', $args, $slug );
145
  }
 
 
 
 
146
  }
147
 
148
 
6
  * Add Rewrite Rules
7
  *
8
  * @package Custom_Post_Type_Permalinks
9
+ * @version 1.0.2
10
  * @since 0.9.4
11
  *
12
  * */
108
  $rewrite_args = array( 'with_front' => $args->rewrite );
109
  }
110
 
 
 
 
 
111
  $slug = $args->rewrite['slug'];
112
  if ( $args->has_archive ) {
113
  if ( is_string( $args->has_archive ) ) {
120
 
121
  $date_front = CPTP_Util::get_date_front( $post_type );
122
 
123
+ $category_base = get_option( 'category_base' );
124
+ if( !$category_base ) {
125
+ $category_base = 'category';
126
+ }
127
  add_rewrite_rule( $slug . $date_front . '/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$', 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&feed=$matches[4]&post_type=' . $post_type, 'top' );
128
  add_rewrite_rule( $slug . $date_front . '/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$', 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&feed=$matches[4]&post_type=' . $post_type, 'top' );
129
  add_rewrite_rule( $slug . $date_front . '/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/page/?([0-9]{1,})/?$', 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&paged=$matches[4]&post_type=' . $post_type, 'top' );
138
  add_rewrite_rule( $slug . $date_front . '/([0-9]{4})/?$', 'index.php?year=$matches[1]&post_type=' . $post_type, 'top' );
139
  add_rewrite_rule( $slug . '/author/([^/]+)/page/?([0-9]{1,})/?$', 'index.php?author_name=$matches[1]&paged=$matches[2]&post_type=' . $post_type, 'top' );
140
  add_rewrite_rule( $slug . '/author/([^/]+)/?$', 'index.php?author_name=$matches[1]&post_type=' . $post_type, 'top' );
141
+ add_rewrite_rule( $slug . '/'. $category_base . '/([^/]+)/page/?([0-9]{1,})/?$', 'index.php?category_name=$matches[1]&paged=$matches[2]&post_type=' . $post_type, 'top' );
142
+ add_rewrite_rule( $slug . '/'. $category_base . '/([^/]+)/?$', 'index.php?category_name=$matches[1]&post_type=' . $post_type, 'top' );
143
 
144
  do_action( 'CPTP_registered_' . $post_type . '_rules', $args, $slug );
145
  }
146
+
147
+ $rewrite_args['walk_dirs'] = false;
148
+ add_permastruct( $post_type, $permalink, $rewrite_args );
149
+
150
  }
151
 
152
 
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: 1.0.1
9
  Text Domain: cptp
10
  License: GPL2 or later
11
  Domain Path: /language/
@@ -22,7 +22,7 @@ Domain Path: /language/
22
  */
23
 
24
  define( 'CPTP_PLUGIN_FILE', __FILE__ );
25
- define( 'CPTP_VERSION', '1.0.1' );
26
  define( 'CPTP_DEFAULT_PERMALINK', '/%postname%/' );
27
 
28
 
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: 1.0.2
9
  Text Domain: cptp
10
  License: GPL2 or later
11
  Domain Path: /language/
22
  */
23
 
24
  define( 'CPTP_PLUGIN_FILE', __FILE__ );
25
+ define( 'CPTP_VERSION', '1.0.2' );
26
  define( 'CPTP_DEFAULT_PERMALINK', '/%postname%/' );
27
 
28
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.amazon.co.jp/registry/wishlist/COKSXS25MVQV
4
  Tags: permalink,permalinks,custom post type,custom taxonomy,cms
5
  Requires at least: 4.1
6
  Tested up to: 4.2
7
- Stable tag: 1.0.1
8
  License: GPLv2 or Later
9
 
10
  Lets you edit the permalink of custom post type.
@@ -61,6 +61,9 @@ That's it. You can access the permalinks setting by going to *Settings -> Permal
61
 
62
  == Changelog ==
63
 
 
 
 
64
  = 1.0.0 =
65
  * Set Permalink enable register_post_type.
66
  * Enable add post type query to taxonomy archives.
4
  Tags: permalink,permalinks,custom post type,custom taxonomy,cms
5
  Requires at least: 4.1
6
  Tested up to: 4.2
7
+ Stable tag: 1.0.2
8
  License: GPLv2 or Later
9
 
10
  Lets you edit the permalink of custom post type.
61
 
62
  == Changelog ==
63
 
64
+ = 1.0.2 =
65
+ * category slug bug fix.
66
+
67
  = 1.0.0 =
68
  * Set Permalink enable register_post_type.
69
  * Enable add post type query to taxonomy archives.