Version Description
-
rewirte => false
post type support.
Download this release
Release Info
Developer | Toro_Unit |
Plugin | Custom Post Type Permalinks |
Version | 2.1.2 |
Comparing to | |
See all releases |
Code changes from version 2.1.1 to 2.1.2
- CPTP/Module/Permalink.php +13 -1
- CPTP/Module/Rewrite.php +5 -0
- CPTP/Util.php +16 -1
- custom-post-type-permalinks.php +2 -2
- readme.txt +5 -1
CPTP/Module/Permalink.php
CHANGED
@@ -71,9 +71,14 @@ class CPTP_Module_Permalink extends CPTP_Module {
|
|
71 |
}
|
72 |
|
73 |
$post_type = $post->post_type;
|
74 |
-
$permalink = $wp_rewrite->get_extra_permastruct( $post_type );
|
75 |
$pt_object = get_post_type_object( $post_type );
|
76 |
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
$permalink = str_replace( '%post_id%', $post->ID, $permalink );
|
78 |
$permalink = str_replace( '%' . $post_type . '_slug%', $pt_object->rewrite['slug'], $permalink );
|
79 |
|
@@ -269,6 +274,13 @@ class CPTP_Module_Permalink extends CPTP_Module {
|
|
269 |
if ( ! $post_parent ) {
|
270 |
return $link;
|
271 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
272 |
$permalink = CPTP_Util::get_permalink_structure( $post_parent->post_type );
|
273 |
$post_type = get_post_type_object( $post_parent->post_type );
|
274 |
|
71 |
}
|
72 |
|
73 |
$post_type = $post->post_type;
|
|
|
74 |
$pt_object = get_post_type_object( $post_type );
|
75 |
|
76 |
+
if ( false === $pt_object->rewrite ) {
|
77 |
+
return $post_link;
|
78 |
+
}
|
79 |
+
|
80 |
+
$permalink = $wp_rewrite->get_extra_permastruct( $post_type );
|
81 |
+
|
82 |
$permalink = str_replace( '%post_id%', $post->ID, $permalink );
|
83 |
$permalink = str_replace( '%' . $post_type . '_slug%', $pt_object->rewrite['slug'], $permalink );
|
84 |
|
274 |
if ( ! $post_parent ) {
|
275 |
return $link;
|
276 |
}
|
277 |
+
|
278 |
+
$pt_object = get_post_type_object( $post_parent->post_type );
|
279 |
+
|
280 |
+
if ( false === $pt_object->rewrite ) {
|
281 |
+
return $link;
|
282 |
+
}
|
283 |
+
|
284 |
$permalink = CPTP_Util::get_permalink_structure( $post_parent->post_type );
|
285 |
$post_type = get_post_type_object( $post_parent->post_type );
|
286 |
|
CPTP/Module/Rewrite.php
CHANGED
@@ -39,6 +39,11 @@ class CPTP_Module_Rewrite extends CPTP_Module {
|
|
39 |
if ( $args->_builtin or ! $args->publicly_queryable ) {
|
40 |
return;
|
41 |
}
|
|
|
|
|
|
|
|
|
|
|
42 |
$permalink = CPTP_Util::get_permalink_structure( $post_type );
|
43 |
|
44 |
if ( ! $permalink ) {
|
39 |
if ( $args->_builtin or ! $args->publicly_queryable ) {
|
40 |
return;
|
41 |
}
|
42 |
+
|
43 |
+
if ( false === $args->rewrite ) {
|
44 |
+
return;
|
45 |
+
}
|
46 |
+
|
47 |
$permalink = CPTP_Util::get_permalink_structure( $post_type );
|
48 |
|
49 |
if ( ! $permalink ) {
|
CPTP/Util.php
CHANGED
@@ -17,7 +17,22 @@ class CPTP_Util {
|
|
17 |
* @return array
|
18 |
*/
|
19 |
public static function get_post_types() {
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
}
|
22 |
|
23 |
/**
|
17 |
* @return array
|
18 |
*/
|
19 |
public static function get_post_types() {
|
20 |
+
$post_type = get_post_types( array( '_builtin' => false, 'publicly_queryable' => true, 'show_ui' => true ) );
|
21 |
+
return array_filter( $post_type, array( __CLASS__, 'is_post_type_support_rewrite' ) );
|
22 |
+
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* @param string $post_type
|
27 |
+
*
|
28 |
+
* @return bool
|
29 |
+
*/
|
30 |
+
private static function is_post_type_support_rewrite( $post_type ) {
|
31 |
+
$post_type_object = get_post_type_object( $post_type );
|
32 |
+
if ( false === $post_type_object->rewrite ) {
|
33 |
+
return false;
|
34 |
+
}
|
35 |
+
return true;
|
36 |
}
|
37 |
|
38 |
/**
|
custom-post-type-permalinks.php
CHANGED
@@ -5,7 +5,7 @@ Plugin URI: https://github.com/torounit/custom-post-type-permalinks
|
|
5 |
Description: Add post archives of custom post type and customizable permalinks.
|
6 |
Author: Toro_Unit
|
7 |
Author URI: https://torounit.com/
|
8 |
-
Version: 2.1.
|
9 |
Text Domain: custom-post-type-permalinks
|
10 |
License: GPL2 or later
|
11 |
Domain Path: /language/
|
@@ -17,7 +17,7 @@ Domain Path: /language/
|
|
17 |
* Custom Post Type Permalinks
|
18 |
*
|
19 |
* @package Custom_Post_Type_Permalinks
|
20 |
-
* @version 2.1.
|
21 |
*/
|
22 |
|
23 |
define( 'CPTP_PLUGIN_FILE', __FILE__ );
|
5 |
Description: Add post archives of custom post type and customizable permalinks.
|
6 |
Author: Toro_Unit
|
7 |
Author URI: https://torounit.com/
|
8 |
+
Version: 2.1.2
|
9 |
Text Domain: custom-post-type-permalinks
|
10 |
License: GPL2 or later
|
11 |
Domain Path: /language/
|
17 |
* Custom Post Type Permalinks
|
18 |
*
|
19 |
* @package Custom_Post_Type_Permalinks
|
20 |
+
* @version 2.1.2
|
21 |
*/
|
22 |
|
23 |
define( 'CPTP_PLUGIN_FILE', __FILE__ );
|
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.3
|
6 |
Tested up to: 4.6
|
7 |
-
Stable tag: 2.1.
|
8 |
License: GPLv2 or Later
|
9 |
|
10 |
Edit the permalink of custom post type.
|
@@ -67,6 +67,10 @@ That's it. You can access the permalinks setting by going to *Settings -> Permal
|
|
67 |
|
68 |
== Changelog ==
|
69 |
|
|
|
|
|
|
|
|
|
70 |
= 2.1.0 =
|
71 |
|
72 |
* Create rewrite rule on `registered_post_type` and `registered_taxonomy` action.
|
4 |
Tags: permalink,permalinks,custom post type,custom taxonomy,cms
|
5 |
Requires at least: 4.3
|
6 |
Tested up to: 4.6
|
7 |
+
Stable tag: 2.1.2
|
8 |
License: GPLv2 or Later
|
9 |
|
10 |
Edit the permalink of custom post type.
|
67 |
|
68 |
== Changelog ==
|
69 |
|
70 |
+
= 2.1.2 =
|
71 |
+
|
72 |
+
* `rewirte => false` post type support.
|
73 |
+
|
74 |
= 2.1.0 =
|
75 |
|
76 |
* Create rewrite rule on `registered_post_type` and `registered_taxonomy` action.
|