Version Description
Download this release
Release Info
Developer | Toro_Unit |
Plugin | Custom Post Type Permalinks |
Version | 3.3.4 |
Comparing to | |
See all releases |
Code changes from version 3.3.1 to 3.3.4
- .rsyncignore +36 -0
- CPTP.php +6 -6
- CPTP/Module/Admin.php +10 -7
- CPTP/Module/GetArchives.php +2 -3
- CPTP/Module/Option.php +1 -2
- CPTP/Module/Permalink.php +14 -13
- CPTP/Module/Rewrite.php +0 -5
- CPTP/Module/Setting.php +0 -1
- CPTP/Util.php +8 -8
- custom-post-type-permalinks.php +16 -13
- docker-compose.yml +54 -0
- readme.txt +3 -3
.rsyncignore
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
- .svnignore
|
2 |
+
- .idea
|
3 |
+
- .rsyncignore
|
4 |
+
- .editorconfig
|
5 |
+
- .git
|
6 |
+
- .gitignore
|
7 |
+
- .gitlab-ci.yml
|
8 |
+
- .travis.yml
|
9 |
+
- .vscode
|
10 |
+
- .DS_Store
|
11 |
+
- Thumbs.db
|
12 |
+
- behat.yml
|
13 |
+
- bin
|
14 |
+
- circle.yml
|
15 |
+
- composer.json
|
16 |
+
- composer.lock
|
17 |
+
- Gruntfile.js
|
18 |
+
- package.json
|
19 |
+
- package-lock.json
|
20 |
+
- phpunit.xml
|
21 |
+
- phpunit.xml.dist
|
22 |
+
- multisite.xml
|
23 |
+
- multisite.xml.dist
|
24 |
+
- phpcs.ruleset.xml
|
25 |
+
- codesniffer.ruleset.xml
|
26 |
+
- README.md
|
27 |
+
- wp-cli.local.yml
|
28 |
+
- tests
|
29 |
+
- vendor
|
30 |
+
- node_modules
|
31 |
+
- *.sql
|
32 |
+
- *.tar.gz
|
33 |
+
- *.zip
|
34 |
+
- .release-it.json
|
35 |
+
- .env
|
36 |
+
- docker-compose.yml
|
CPTP.php
CHANGED
@@ -49,7 +49,6 @@ class CPTP {
|
|
49 |
$this->set_module( 'flush_rules', new CPTP_Module_FlushRules() );
|
50 |
|
51 |
do_action( 'CPTP_load_modules', $this );
|
52 |
-
|
53 |
}
|
54 |
|
55 |
/**
|
@@ -68,14 +67,16 @@ class CPTP {
|
|
68 |
/**
|
69 |
* Set module instance.
|
70 |
*
|
71 |
-
* @since 1.5.0
|
72 |
-
*
|
73 |
* @param String $name Module Name.
|
74 |
* @param CPTP_Module $module Module instance.
|
|
|
|
|
75 |
*/
|
76 |
public function set_module( $name, CPTP_Module $module ) {
|
77 |
-
|
78 |
-
|
|
|
|
|
79 |
}
|
80 |
|
81 |
/**
|
@@ -96,7 +97,6 @@ class CPTP {
|
|
96 |
* @static
|
97 |
*/
|
98 |
public static function get_instance() {
|
99 |
-
|
100 |
if ( ! isset( self::$_instance ) ) {
|
101 |
self::$_instance = new CPTP();
|
102 |
}
|
49 |
$this->set_module( 'flush_rules', new CPTP_Module_FlushRules() );
|
50 |
|
51 |
do_action( 'CPTP_load_modules', $this );
|
|
|
52 |
}
|
53 |
|
54 |
/**
|
67 |
/**
|
68 |
* Set module instance.
|
69 |
*
|
|
|
|
|
70 |
* @param String $name Module Name.
|
71 |
* @param CPTP_Module $module Module instance.
|
72 |
+
*
|
73 |
+
* @since 1.5.0
|
74 |
*/
|
75 |
public function set_module( $name, CPTP_Module $module ) {
|
76 |
+
$module = apply_filters( "CPTP_set_{$name}_module", $module );
|
77 |
+
if ( $module instanceof CPTP_Module ) {
|
78 |
+
$this->modules[ $name ] = $module;
|
79 |
+
}
|
80 |
}
|
81 |
|
82 |
/**
|
97 |
* @static
|
98 |
*/
|
99 |
public static function get_instance() {
|
|
|
100 |
if ( ! isset( self::$_instance ) ) {
|
101 |
self::$_instance = new CPTP();
|
102 |
}
|
CPTP/Module/Admin.php
CHANGED
@@ -28,7 +28,8 @@ class CPTP_Module_Admin extends CPTP_Module {
|
|
28 |
* @since 0.7
|
29 |
*/
|
30 |
public function settings_api_init() {
|
31 |
-
add_settings_section(
|
|
|
32 |
__( 'Permalink Settings for Custom Post Types', 'custom-post-type-permalinks' ),
|
33 |
array( $this, 'setting_section_callback_function' ),
|
34 |
'permalink'
|
@@ -37,7 +38,6 @@ class CPTP_Module_Admin extends CPTP_Module {
|
|
37 |
$post_types = CPTP_Util::get_post_types();
|
38 |
|
39 |
foreach ( $post_types as $post_type ) {
|
40 |
-
|
41 |
add_settings_field(
|
42 |
$post_type . '_structure',
|
43 |
$post_type,
|
@@ -124,7 +124,6 @@ class CPTP_Module_Admin extends CPTP_Module {
|
|
124 |
* }
|
125 |
*/
|
126 |
public function setting_structure_callback_function( $option ) {
|
127 |
-
|
128 |
$post_type = $option['post_type'];
|
129 |
$name = $option['label_for'];
|
130 |
$pt_object = get_post_type_object( $post_type );
|
@@ -195,10 +194,14 @@ class CPTP_Module_Admin extends CPTP_Module {
|
|
195 |
wp_enqueue_script( 'wp-pointer' );
|
196 |
wp_enqueue_script( 'custom-post-type-permalinks-pointer', plugins_url( 'assets/settings-pointer.js', CPTP_PLUGIN_FILE ), array( 'wp-pointer' ), CPTP_VERSION );
|
197 |
|
198 |
-
wp_localize_script(
|
199 |
-
'
|
200 |
-
'
|
201 |
-
|
|
|
|
|
|
|
|
|
202 |
}
|
203 |
}
|
204 |
}
|
28 |
* @since 0.7
|
29 |
*/
|
30 |
public function settings_api_init() {
|
31 |
+
add_settings_section(
|
32 |
+
'cptp_setting_section',
|
33 |
__( 'Permalink Settings for Custom Post Types', 'custom-post-type-permalinks' ),
|
34 |
array( $this, 'setting_section_callback_function' ),
|
35 |
'permalink'
|
38 |
$post_types = CPTP_Util::get_post_types();
|
39 |
|
40 |
foreach ( $post_types as $post_type ) {
|
|
|
41 |
add_settings_field(
|
42 |
$post_type . '_structure',
|
43 |
$post_type,
|
124 |
* }
|
125 |
*/
|
126 |
public function setting_structure_callback_function( $option ) {
|
|
|
127 |
$post_type = $option['post_type'];
|
128 |
$name = $option['label_for'];
|
129 |
$pt_object = get_post_type_object( $post_type );
|
194 |
wp_enqueue_script( 'wp-pointer' );
|
195 |
wp_enqueue_script( 'custom-post-type-permalinks-pointer', plugins_url( 'assets/settings-pointer.js', CPTP_PLUGIN_FILE ), array( 'wp-pointer' ), CPTP_VERSION );
|
196 |
|
197 |
+
wp_localize_script(
|
198 |
+
'custom-post-type-permalinks-pointer',
|
199 |
+
'CPTP_Settings_Pointer',
|
200 |
+
array(
|
201 |
+
'content' => $content,
|
202 |
+
'name' => $pointer_name,
|
203 |
+
)
|
204 |
+
);
|
205 |
}
|
206 |
}
|
207 |
}
|
CPTP/Module/GetArchives.php
CHANGED
@@ -19,7 +19,7 @@ class CPTP_Module_GetArchives extends CPTP_Module {
|
|
19 |
public function add_hook() {
|
20 |
if ( get_option( 'permalink_structure', '' ) !== '' ) {
|
21 |
add_filter( 'getarchives_join', array( $this, 'getarchives_join' ), 10, 2 );
|
22 |
-
add_filter( 'getarchives_where', array( $this, 'getarchives_where' ), 10
|
23 |
add_filter( 'get_archives_link', array( $this, 'get_archives_link' ), 20, 1 );
|
24 |
}
|
25 |
}
|
@@ -43,7 +43,6 @@ class CPTP_Module_GetArchives extends CPTP_Module {
|
|
43 |
public function getarchives_where( $where, $r ) {
|
44 |
$this->get_archives_where_r = $r;
|
45 |
if ( isset( $r['post_type'] ) ) {
|
46 |
-
|
47 |
if ( ! in_array( $r['post_type'], CPTP_Util::get_post_types(), true ) ) {
|
48 |
return $where;
|
49 |
}
|
@@ -130,7 +129,7 @@ class CPTP_Module_GetArchives extends CPTP_Module {
|
|
130 |
$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]
|
131 |
|
132 |
if ( isset( $this->get_archives_where_r['post_type'] ) && 'postbypost' !== $this->get_archives_where_r['type'] ) {
|
133 |
-
$blog_url = rtrim( home_url()
|
134 |
|
135 |
// remove front.
|
136 |
$front = substr( $wp_rewrite->front, 1 );
|
19 |
public function add_hook() {
|
20 |
if ( get_option( 'permalink_structure', '' ) !== '' ) {
|
21 |
add_filter( 'getarchives_join', array( $this, 'getarchives_join' ), 10, 2 );
|
22 |
+
add_filter( 'getarchives_where', array( $this, 'getarchives_where' ), 10, 2 );
|
23 |
add_filter( 'get_archives_link', array( $this, 'get_archives_link' ), 20, 1 );
|
24 |
}
|
25 |
}
|
43 |
public function getarchives_where( $where, $r ) {
|
44 |
$this->get_archives_where_r = $r;
|
45 |
if ( isset( $r['post_type'] ) ) {
|
|
|
46 |
if ( ! in_array( $r['post_type'], CPTP_Util::get_post_types(), true ) ) {
|
47 |
return $where;
|
48 |
}
|
129 |
$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]
|
130 |
|
131 |
if ( isset( $this->get_archives_where_r['post_type'] ) && 'postbypost' !== $this->get_archives_where_r['type'] ) {
|
132 |
+
$blog_url = rtrim( home_url(), '/' );
|
133 |
|
134 |
// remove front.
|
135 |
$front = substr( $wp_rewrite->front, 1 );
|
CPTP/Module/Option.php
CHANGED
@@ -51,7 +51,6 @@ class CPTP_Module_Option extends CPTP_Module {
|
|
51 |
$post_types = CPTP_Util::get_post_types();
|
52 |
|
53 |
foreach ( $post_types as $post_type ) :
|
54 |
-
|
55 |
$structure = trim( esc_attr( filter_input( INPUT_POST, $post_type . '_structure' ) ) ); // get setting.
|
56 |
|
57 |
// default permalink structure.
|
@@ -61,7 +60,7 @@ class CPTP_Module_Option extends CPTP_Module {
|
|
61 |
|
62 |
$structure = str_replace( '//', '/', '/' . $structure );// first "/"
|
63 |
// last "/".
|
64 |
-
$lastString = substr( trim( esc_attr( filter_input( INPUT_POST,'permalink_structure' ) ) ), - 1 );
|
65 |
$structure = rtrim( $structure, '/' );
|
66 |
|
67 |
if ( '/' === $lastString ) {
|
51 |
$post_types = CPTP_Util::get_post_types();
|
52 |
|
53 |
foreach ( $post_types as $post_type ) :
|
|
|
54 |
$structure = trim( esc_attr( filter_input( INPUT_POST, $post_type . '_structure' ) ) ); // get setting.
|
55 |
|
56 |
// default permalink structure.
|
60 |
|
61 |
$structure = str_replace( '//', '/', '/' . $structure );// first "/"
|
62 |
// last "/".
|
63 |
+
$lastString = substr( trim( esc_attr( filter_input( INPUT_POST, 'permalink_structure' ) ) ), - 1 );
|
64 |
$structure = rtrim( $structure, '/' );
|
65 |
|
66 |
if ( '/' === $lastString ) {
|
CPTP/Module/Permalink.php
CHANGED
@@ -17,7 +17,6 @@ class CPTP_Module_Permalink extends CPTP_Module {
|
|
17 |
* Add Filter Hooks.
|
18 |
*/
|
19 |
public function add_hook() {
|
20 |
-
|
21 |
add_filter(
|
22 |
'post_type_link',
|
23 |
array( $this, 'post_type_link' ),
|
@@ -61,15 +60,19 @@ class CPTP_Module_Permalink extends CPTP_Module {
|
|
61 |
*/
|
62 |
global $wp_rewrite;
|
63 |
|
64 |
-
if ( ! $wp_rewrite->
|
65 |
return $post_link;
|
66 |
}
|
67 |
|
68 |
-
$draft_or_pending = isset( $post->post_status ) && in_array(
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
|
|
|
|
|
|
|
|
73 |
if ( $draft_or_pending && ! $leavename ) {
|
74 |
return $post_link;
|
75 |
}
|
@@ -137,7 +140,7 @@ class CPTP_Module_Permalink extends CPTP_Module {
|
|
137 |
$categories = get_the_category( $post->ID );
|
138 |
if ( $categories ) {
|
139 |
$categories = CPTP_Util::sort_terms( $categories );
|
140 |
-
|
141 |
$category_object = apply_filters( 'post_link_category', $categories[0], $categories, $post );
|
142 |
$category_object = get_term( $category_object, 'category' );
|
143 |
$category = $category_object->slug;
|
@@ -206,7 +209,6 @@ class CPTP_Module_Permalink extends CPTP_Module {
|
|
206 |
|
207 |
// %taxnomomy% -> parent/child
|
208 |
foreach ( $taxonomies as $taxonomy => $objects ) {
|
209 |
-
|
210 |
if ( false !== strpos( $permalink, '%' . $taxonomy . '%' ) ) {
|
211 |
$terms = get_the_terms( $post_id, $taxonomy );
|
212 |
|
@@ -214,7 +216,7 @@ class CPTP_Module_Permalink extends CPTP_Module {
|
|
214 |
$parents = array_map( array( __CLASS__, 'get_term_parent' ), $terms );
|
215 |
$newTerms = array();
|
216 |
foreach ( $terms as $key => $term ) {
|
217 |
-
if ( ! in_array( $term->term_id, $parents
|
218 |
$newTerms[] = $term;
|
219 |
}
|
220 |
}
|
@@ -273,7 +275,7 @@ class CPTP_Module_Permalink extends CPTP_Module {
|
|
273 |
*/
|
274 |
global $wp_rewrite;
|
275 |
|
276 |
-
if ( ! $wp_rewrite->
|
277 |
return $link;
|
278 |
}
|
279 |
|
@@ -302,7 +304,6 @@ class CPTP_Module_Permalink extends CPTP_Module {
|
|
302 |
|
303 |
if ( empty( $post_type->_builtin ) ) {
|
304 |
if ( strpos( $permalink, '%postname%' ) < strrpos( $permalink, '%post_id%' ) && false === strrpos( $link, 'attachment/' ) ) {
|
305 |
-
|
306 |
$link = str_replace( $post->post_name, 'attachment/' . $post->post_name, $link );
|
307 |
}
|
308 |
}
|
@@ -330,7 +331,7 @@ class CPTP_Module_Permalink extends CPTP_Module {
|
|
330 |
*/
|
331 |
global $wp_rewrite;
|
332 |
|
333 |
-
if ( ! $wp_rewrite->
|
334 |
return $termlink;
|
335 |
}
|
336 |
|
17 |
* Add Filter Hooks.
|
18 |
*/
|
19 |
public function add_hook() {
|
|
|
20 |
add_filter(
|
21 |
'post_type_link',
|
22 |
array( $this, 'post_type_link' ),
|
60 |
*/
|
61 |
global $wp_rewrite;
|
62 |
|
63 |
+
if ( ! $wp_rewrite->using_permalinks() ) {
|
64 |
return $post_link;
|
65 |
}
|
66 |
|
67 |
+
$draft_or_pending = isset( $post->post_status ) && in_array(
|
68 |
+
$post->post_status,
|
69 |
+
array(
|
70 |
+
'draft',
|
71 |
+
'pending',
|
72 |
+
'auto-draft',
|
73 |
+
),
|
74 |
+
true
|
75 |
+
);
|
76 |
if ( $draft_or_pending && ! $leavename ) {
|
77 |
return $post_link;
|
78 |
}
|
140 |
$categories = get_the_category( $post->ID );
|
141 |
if ( $categories ) {
|
142 |
$categories = CPTP_Util::sort_terms( $categories );
|
143 |
+
// phpcs:ignore
|
144 |
$category_object = apply_filters( 'post_link_category', $categories[0], $categories, $post );
|
145 |
$category_object = get_term( $category_object, 'category' );
|
146 |
$category = $category_object->slug;
|
209 |
|
210 |
// %taxnomomy% -> parent/child
|
211 |
foreach ( $taxonomies as $taxonomy => $objects ) {
|
|
|
212 |
if ( false !== strpos( $permalink, '%' . $taxonomy . '%' ) ) {
|
213 |
$terms = get_the_terms( $post_id, $taxonomy );
|
214 |
|
216 |
$parents = array_map( array( __CLASS__, 'get_term_parent' ), $terms );
|
217 |
$newTerms = array();
|
218 |
foreach ( $terms as $key => $term ) {
|
219 |
+
if ( ! in_array( $term->term_id, $parents, true ) ) {
|
220 |
$newTerms[] = $term;
|
221 |
}
|
222 |
}
|
275 |
*/
|
276 |
global $wp_rewrite;
|
277 |
|
278 |
+
if ( ! $wp_rewrite->using_permalinks() ) {
|
279 |
return $link;
|
280 |
}
|
281 |
|
304 |
|
305 |
if ( empty( $post_type->_builtin ) ) {
|
306 |
if ( strpos( $permalink, '%postname%' ) < strrpos( $permalink, '%post_id%' ) && false === strrpos( $link, 'attachment/' ) ) {
|
|
|
307 |
$link = str_replace( $post->post_name, 'attachment/' . $post->post_name, $link );
|
308 |
}
|
309 |
}
|
331 |
*/
|
332 |
global $wp_rewrite;
|
333 |
|
334 |
+
if ( ! $wp_rewrite->using_permalinks() ) {
|
335 |
return $termlink;
|
336 |
}
|
337 |
|
CPTP/Module/Rewrite.php
CHANGED
@@ -103,18 +103,15 @@ class CPTP_Module_Rewrite extends CPTP_Module {
|
|
103 |
}
|
104 |
|
105 |
if ( CPTP_Util::get_post_type_author_archive_support( $post_type ) ) {
|
106 |
-
|
107 |
add_rewrite_rule( $slug . '/author/([^/]+)/page/?([0-9]{1,})/?$', 'index.php?author_name=$matches[1]&paged=$matches[2]&post_type=' . $post_type, 'top' );
|
108 |
add_rewrite_rule( $slug . '/author/([^/]+)/?$', 'index.php?author_name=$matches[1]&post_type=' . $post_type, 'top' );
|
109 |
}
|
110 |
|
111 |
if ( in_array( 'category', $args->taxonomies, true ) ) {
|
112 |
-
|
113 |
$category_base = get_option( 'category_base', 'category' );
|
114 |
|
115 |
add_rewrite_rule( $slug . '/' . $category_base . '/([^/]+)/page/?([0-9]{1,})/?$', 'index.php?category_name=$matches[1]&paged=$matches[2]&post_type=' . $post_type, 'top' );
|
116 |
add_rewrite_rule( $slug . '/' . $category_base . '/([^/]+)/?$', 'index.php?category_name=$matches[1]&post_type=' . $post_type, 'top' );
|
117 |
-
|
118 |
}
|
119 |
|
120 |
do_action( 'CPTP_registered_' . $post_type . '_rules', $args, $slug );
|
@@ -122,7 +119,6 @@ class CPTP_Module_Rewrite extends CPTP_Module {
|
|
122 |
|
123 |
$rewrite_args['walk_dirs'] = false;
|
124 |
add_permastruct( $post_type, $permalink, $rewrite_args );
|
125 |
-
|
126 |
}
|
127 |
|
128 |
|
@@ -256,7 +252,6 @@ class CPTP_Module_Rewrite extends CPTP_Module {
|
|
256 |
}
|
257 |
|
258 |
do_action( 'CPTP_registered_' . $taxonomy . '_rules', $object_type, $args, $taxonomy_slug );
|
259 |
-
|
260 |
endforeach;
|
261 |
}
|
262 |
|
103 |
}
|
104 |
|
105 |
if ( CPTP_Util::get_post_type_author_archive_support( $post_type ) ) {
|
|
|
106 |
add_rewrite_rule( $slug . '/author/([^/]+)/page/?([0-9]{1,})/?$', 'index.php?author_name=$matches[1]&paged=$matches[2]&post_type=' . $post_type, 'top' );
|
107 |
add_rewrite_rule( $slug . '/author/([^/]+)/?$', 'index.php?author_name=$matches[1]&post_type=' . $post_type, 'top' );
|
108 |
}
|
109 |
|
110 |
if ( in_array( 'category', $args->taxonomies, true ) ) {
|
|
|
111 |
$category_base = get_option( 'category_base', 'category' );
|
112 |
|
113 |
add_rewrite_rule( $slug . '/' . $category_base . '/([^/]+)/page/?([0-9]{1,})/?$', 'index.php?category_name=$matches[1]&paged=$matches[2]&post_type=' . $post_type, 'top' );
|
114 |
add_rewrite_rule( $slug . '/' . $category_base . '/([^/]+)/?$', 'index.php?category_name=$matches[1]&post_type=' . $post_type, 'top' );
|
|
|
115 |
}
|
116 |
|
117 |
do_action( 'CPTP_registered_' . $post_type . '_rules', $args, $slug );
|
119 |
|
120 |
$rewrite_args['walk_dirs'] = false;
|
121 |
add_permastruct( $post_type, $permalink, $rewrite_args );
|
|
|
122 |
}
|
123 |
|
124 |
|
252 |
}
|
253 |
|
254 |
do_action( 'CPTP_registered_' . $taxonomy . '_rules', $object_type, $args, $taxonomy_slug );
|
|
|
255 |
endforeach;
|
256 |
}
|
257 |
|
CPTP/Module/Setting.php
CHANGED
@@ -39,7 +39,6 @@ class CPTP_Module_Setting extends CPTP_Module {
|
|
39 |
* @param array $options Extra information about performed upgrade.
|
40 |
*/
|
41 |
public function upgrader_process_complete( $wp_upgrader, $options ) {
|
42 |
-
|
43 |
if ( empty( $options['plugins'] ) ) {
|
44 |
return;
|
45 |
}
|
39 |
* @param array $options Extra information about performed upgrade.
|
40 |
*/
|
41 |
public function upgrader_process_complete( $wp_upgrader, $options ) {
|
|
|
42 |
if ( empty( $options['plugins'] ) ) {
|
43 |
return;
|
44 |
}
|
CPTP/Util.php
CHANGED
@@ -33,7 +33,6 @@ class CPTP_Util {
|
|
33 |
$post_type = get_post_types( $param );
|
34 |
|
35 |
return array_filter( $post_type, array( __CLASS__, 'is_rewrite_supported_by' ) );
|
36 |
-
|
37 |
}
|
38 |
|
39 |
/**
|
@@ -85,10 +84,13 @@ class CPTP_Util {
|
|
85 |
$output = 'names';
|
86 |
}
|
87 |
|
88 |
-
return get_taxonomies(
|
89 |
-
|
90 |
-
|
91 |
-
|
|
|
|
|
|
|
92 |
}
|
93 |
|
94 |
/**
|
@@ -158,6 +160,7 @@ class CPTP_Util {
|
|
158 |
$chain .= CPTP_Util::get_taxonomy_parents( $parent->parent, $taxonomy, $link, $separator, $nicename, $visited );
|
159 |
}
|
160 |
if ( $link ) {
|
|
|
161 |
$chain .= '<a href="' . get_term_link( $parent->term_id, $taxonomy ) . '" title="' . esc_attr( sprintf( __( 'View all posts in %s' ), $parent->name ) ) . '">' . esc_html( $name ) . '</a>' . esc_html( $separator );
|
162 |
} else {
|
163 |
$chain .= $name . $separator;
|
@@ -232,7 +235,6 @@ class CPTP_Util {
|
|
232 |
}
|
233 |
|
234 |
return true;
|
235 |
-
|
236 |
}
|
237 |
|
238 |
|
@@ -285,11 +287,9 @@ class CPTP_Util {
|
|
285 |
* @return WP_Term[]
|
286 |
*/
|
287 |
public static function sort_terms( $terms, $orderby = 'term_id', $order = 'ASC' ) {
|
288 |
-
|
289 |
if ( function_exists( 'wp_list_sort' ) ) {
|
290 |
$terms = wp_list_sort( $terms, 'term_id', 'ASC' );
|
291 |
} else {
|
292 |
-
|
293 |
if ( 'name' === $orderby ) {
|
294 |
usort( $terms, '_usort_terms_by_name' );
|
295 |
} else {
|
33 |
$post_type = get_post_types( $param );
|
34 |
|
35 |
return array_filter( $post_type, array( __CLASS__, 'is_rewrite_supported_by' ) );
|
|
|
36 |
}
|
37 |
|
38 |
/**
|
84 |
$output = 'names';
|
85 |
}
|
86 |
|
87 |
+
return get_taxonomies(
|
88 |
+
array(
|
89 |
+
'public' => true,
|
90 |
+
'_builtin' => false,
|
91 |
+
),
|
92 |
+
$output
|
93 |
+
);
|
94 |
}
|
95 |
|
96 |
/**
|
160 |
$chain .= CPTP_Util::get_taxonomy_parents( $parent->parent, $taxonomy, $link, $separator, $nicename, $visited );
|
161 |
}
|
162 |
if ( $link ) {
|
163 |
+
// phpcs:ignore
|
164 |
$chain .= '<a href="' . get_term_link( $parent->term_id, $taxonomy ) . '" title="' . esc_attr( sprintf( __( 'View all posts in %s' ), $parent->name ) ) . '">' . esc_html( $name ) . '</a>' . esc_html( $separator );
|
165 |
} else {
|
166 |
$chain .= $name . $separator;
|
235 |
}
|
236 |
|
237 |
return true;
|
|
|
238 |
}
|
239 |
|
240 |
|
287 |
* @return WP_Term[]
|
288 |
*/
|
289 |
public static function sort_terms( $terms, $orderby = 'term_id', $order = 'ASC' ) {
|
|
|
290 |
if ( function_exists( 'wp_list_sort' ) ) {
|
291 |
$terms = wp_list_sort( $terms, 'term_id', 'ASC' );
|
292 |
} else {
|
|
|
293 |
if ( 'name' === $orderby ) {
|
294 |
usort( $terms, '_usort_terms_by_name' );
|
295 |
} else {
|
custom-post-type-permalinks.php
CHANGED
@@ -5,29 +5,32 @@
|
|
5 |
* Description: Add post archives of custom post type and customizable permalinks.
|
6 |
* Author: Toro_Unit
|
7 |
* Author URI: https://torounit.com/
|
8 |
-
* Version: 3.3.
|
9 |
* Text Domain: custom-post-type-permalinks
|
10 |
* License: GPL2 or later
|
11 |
* Domain Path: /language/
|
12 |
*
|
13 |
* @package Custom_Post_Type_Permalinks
|
14 |
-
* @version 3.3.
|
15 |
*/
|
16 |
|
17 |
define( 'CPTP_PLUGIN_FILE', __FILE__ );
|
18 |
define( 'CPTP_DEFAULT_PERMALINK', '/%postname%/' );
|
19 |
|
20 |
-
$cptp_data = get_file_data(
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
|
|
|
|
|
|
31 |
|
32 |
define( 'CPTP_VERSION', $cptp_data['Version'] );
|
33 |
define( 'CPTP_DOMAIN_PATH', $cptp_data['DomainPath'] );
|
5 |
* Description: Add post archives of custom post type and customizable permalinks.
|
6 |
* Author: Toro_Unit
|
7 |
* Author URI: https://torounit.com/
|
8 |
+
* Version: 3.3.4
|
9 |
* Text Domain: custom-post-type-permalinks
|
10 |
* License: GPL2 or later
|
11 |
* Domain Path: /language/
|
12 |
*
|
13 |
* @package Custom_Post_Type_Permalinks
|
14 |
+
* @version 3.3.4
|
15 |
*/
|
16 |
|
17 |
define( 'CPTP_PLUGIN_FILE', __FILE__ );
|
18 |
define( 'CPTP_DEFAULT_PERMALINK', '/%postname%/' );
|
19 |
|
20 |
+
$cptp_data = get_file_data(
|
21 |
+
__FILE__,
|
22 |
+
array(
|
23 |
+
'Name' => 'Plugin Name',
|
24 |
+
'PluginURI' => 'Plugin URI',
|
25 |
+
'Version' => 'Version',
|
26 |
+
'Description' => 'Description',
|
27 |
+
'Author' => 'Author',
|
28 |
+
'AuthorURI' => 'Author URI',
|
29 |
+
'TextDomain' => 'Text Domain',
|
30 |
+
'DomainPath' => 'Domain Path',
|
31 |
+
'Network' => 'Network',
|
32 |
+
)
|
33 |
+
);
|
34 |
|
35 |
define( 'CPTP_VERSION', $cptp_data['Version'] );
|
36 |
define( 'CPTP_DOMAIN_PATH', $cptp_data['DomainPath'] );
|
docker-compose.yml
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
version: '3.1'
|
2 |
+
|
3 |
+
services:
|
4 |
+
|
5 |
+
wordpress:
|
6 |
+
image: wordpress
|
7 |
+
ports:
|
8 |
+
- 50080:80
|
9 |
+
environment:
|
10 |
+
WORDPRESS_DB_PASSWORD: example
|
11 |
+
ABSPATH: /usr/src/wordpress/
|
12 |
+
volumes:
|
13 |
+
- wordpress:/var/www/html
|
14 |
+
- .:/var/www/html/wp-content/plugins/custom-post-type-permalinks
|
15 |
+
depends_on:
|
16 |
+
- mysql
|
17 |
+
|
18 |
+
cli:
|
19 |
+
image: wordpress:cli
|
20 |
+
user: xfs
|
21 |
+
volumes:
|
22 |
+
- wordpress:/var/www/html
|
23 |
+
- ./bin:/opt/bin
|
24 |
+
- .:/var/www/html/wp-content/plugins/custom-post-type-permalinks
|
25 |
+
depends_on:
|
26 |
+
- mysql
|
27 |
+
- wordpress
|
28 |
+
command: >
|
29 |
+
sh /opt/bin/wait-for.sh mysql:3306 -t 60 -- sh /opt/bin/install.sh 50080
|
30 |
+
|
31 |
+
mysql:
|
32 |
+
image: mysql:5.7
|
33 |
+
environment:
|
34 |
+
MYSQL_ROOT_PASSWORD: example
|
35 |
+
MYSQL_DATABASE: wordpress_test
|
36 |
+
|
37 |
+
wordpress_phpunit:
|
38 |
+
image: chriszarate/wordpress-phpunit
|
39 |
+
environment:
|
40 |
+
PHPUNIT_DB_HOST: mysql
|
41 |
+
volumes:
|
42 |
+
- .:/app
|
43 |
+
- testsuite:/tmp
|
44 |
+
depends_on:
|
45 |
+
- mysql
|
46 |
+
|
47 |
+
composer:
|
48 |
+
image: composer
|
49 |
+
volumes:
|
50 |
+
- .:/app
|
51 |
+
|
52 |
+
volumes:
|
53 |
+
testsuite:
|
54 |
+
wordpress:
|
readme.txt
CHANGED
@@ -3,9 +3,9 @@ Contributors: Toro_Unit,inc2734,ixkaito,keita_kobayashi
|
|
3 |
Donate link: https://www.paypal.me/torounit
|
4 |
Tags: permalink,permalinks,custom post type,custom taxonomy,cms
|
5 |
Requires at least: 4.3
|
6 |
-
Tested up to: 5.
|
7 |
Requires PHP: 5.3
|
8 |
-
Stable tag: 3.3.
|
9 |
License: GPLv2 or Later
|
10 |
|
11 |
Edit the permalink of custom post type.
|
@@ -16,7 +16,7 @@ Custom Post Type Permalinks allow you edit the permalink structure of custom pos
|
|
16 |
|
17 |
Change custom taxonomy archive's permalink to "example.org/post_type/taxonomy_name/term_slug". Can disable this fix.
|
18 |
|
19 |
-
And support `wp_get_archives( 'post_type=foo' )
|
20 |
|
21 |
[This Plugin published on GitHub.](https://github.com/torounit/custom-post-type-permalinks)
|
22 |
|
3 |
Donate link: https://www.paypal.me/torounit
|
4 |
Tags: permalink,permalinks,custom post type,custom taxonomy,cms
|
5 |
Requires at least: 4.3
|
6 |
+
Tested up to: 5.3
|
7 |
Requires PHP: 5.3
|
8 |
+
Stable tag: 3.3.4
|
9 |
License: GPLv2 or Later
|
10 |
|
11 |
Edit the permalink of custom post type.
|
16 |
|
17 |
Change custom taxonomy archive's permalink to "example.org/post_type/taxonomy_name/term_slug". Can disable this fix.
|
18 |
|
19 |
+
And support `wp_get_archives( 'post_type=foo' )` and post type date archive (ex. `example.com/post_type_slug/date/2010/01/01` ).
|
20 |
|
21 |
[This Plugin published on GitHub.](https://github.com/torounit/custom-post-type-permalinks)
|
22 |
|