Version Description
- Test for WordPress 4.9.
- PHPCS fix.
Download this release
Release Info
Developer | Toro_Unit |
Plugin | Custom Post Type Permalinks |
Version | 3.1.4 |
Comparing to | |
See all releases |
Code changes from version 3.1.3 to 3.1.4
- .svnignore +25 -10
- CPTP.php +24 -12
- CPTP/Module.php +19 -2
- CPTP/Module/Admin.php +63 -27
- CPTP/Module/FlushRules.php +11 -16
- CPTP/Module/GetArchives.php +35 -31
- CPTP/Module/Option.php +30 -24
- CPTP/Module/Permalink.php +58 -48
- CPTP/Module/Rewrite.php +36 -29
- CPTP/Module/Setting.php +14 -10
- CPTP/Util.php +49 -30
- circle.yml +2 -1
- codesniffer.ruleset.xml +1 -3
- composer.json +3 -3
- custom-post-type-permalinks.php +4 -2
- readme.md +1 -1
- readme.txt +8 -4
.svnignore
CHANGED
@@ -1,18 +1,33 @@
|
|
1 |
-
.
|
|
|
|
|
2 |
.git
|
3 |
-
.github
|
4 |
.gitignore
|
|
|
5 |
.travis.yml
|
6 |
-
.
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
README.md
|
11 |
-
_site
|
12 |
bin
|
|
|
|
|
13 |
composer.lock
|
14 |
-
|
15 |
-
|
|
|
16 |
phpunit.xml
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
tests
|
18 |
vendor
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# A set of files you probably don't want in your WordPress.org distribution
|
2 |
+
.svnignore
|
3 |
+
.editorconfig
|
4 |
.git
|
|
|
5 |
.gitignore
|
6 |
+
.gitlab-ci.yml
|
7 |
.travis.yml
|
8 |
+
.vscode
|
9 |
+
.DS_Store
|
10 |
+
Thumbs.db
|
11 |
+
behat.yml
|
|
|
|
|
12 |
bin
|
13 |
+
circle.yml
|
14 |
+
composer.json
|
15 |
composer.lock
|
16 |
+
Gruntfile.js
|
17 |
+
package.json
|
18 |
+
package-lock.json
|
19 |
phpunit.xml
|
20 |
+
phpunit.xml.dist
|
21 |
+
multisite.xml
|
22 |
+
multisite.xml.dist
|
23 |
+
phpcs.ruleset.xml
|
24 |
+
README.md
|
25 |
+
wp-cli.local.yml
|
26 |
tests
|
27 |
vendor
|
28 |
+
node_modules
|
29 |
+
*.sql
|
30 |
+
*.tar.gz
|
31 |
+
*.zip
|
32 |
+
.release-it.json
|
33 |
+
.env
|
CPTP.php
CHANGED
@@ -1,20 +1,34 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
/**
|
4 |
* CPTP
|
5 |
*
|
6 |
-
* Facade.
|
7 |
-
*
|
8 |
-
* @package Custom_Post_Type_Permalinks
|
9 |
* @since 0.9.4
|
10 |
* */
|
11 |
class CPTP {
|
12 |
|
|
|
|
|
|
|
|
|
|
|
13 |
private static $_instance;
|
14 |
|
15 |
-
/**
|
|
|
|
|
|
|
|
|
16 |
public $modules;
|
17 |
|
|
|
|
|
|
|
18 |
private function __construct() {
|
19 |
$this->load_modules();
|
20 |
}
|
@@ -39,7 +53,7 @@ class CPTP {
|
|
39 |
}
|
40 |
|
41 |
/**
|
42 |
-
*
|
43 |
*
|
44 |
* @since 2.0.0
|
45 |
*/
|
@@ -52,12 +66,12 @@ class CPTP {
|
|
52 |
}
|
53 |
|
54 |
/**
|
55 |
-
*
|
56 |
*
|
57 |
* @since 1.5.0
|
58 |
*
|
59 |
-
* @param $name
|
60 |
-
* @param CPTP_Module $module
|
61 |
*/
|
62 |
public function set_module( $name, CPTP_Module $module ) {
|
63 |
|
@@ -65,7 +79,7 @@ class CPTP {
|
|
65 |
}
|
66 |
|
67 |
/**
|
68 |
-
*
|
69 |
*
|
70 |
* Fire Module::add_hook
|
71 |
*
|
@@ -84,7 +98,7 @@ class CPTP {
|
|
84 |
public static function get_instance() {
|
85 |
|
86 |
if ( ! isset( self::$_instance ) ) {
|
87 |
-
self::$_instance = new CPTP;
|
88 |
}
|
89 |
|
90 |
return self::$_instance;
|
@@ -92,7 +106,6 @@ class CPTP {
|
|
92 |
|
93 |
|
94 |
/**
|
95 |
-
*
|
96 |
* Activation Hooks
|
97 |
* This function will browse initialized modules and execute their activation_hook methods.
|
98 |
* It will also set the uninstall_hook to the cptp_uninstall function which behaves the same way as this one.
|
@@ -108,7 +121,6 @@ class CPTP {
|
|
108 |
}
|
109 |
|
110 |
/**
|
111 |
-
*
|
112 |
* Uninstall Hooks
|
113 |
* This function will browse initialized modules and execute their uninstall_hook methods.
|
114 |
*
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* CPTP core.
|
4 |
+
*
|
5 |
+
* @package Custom_Post_Type_Permalinks
|
6 |
+
*/
|
7 |
|
8 |
/**
|
9 |
* CPTP
|
10 |
*
|
|
|
|
|
|
|
11 |
* @since 0.9.4
|
12 |
* */
|
13 |
class CPTP {
|
14 |
|
15 |
+
/**
|
16 |
+
* CPTP instance.
|
17 |
+
*
|
18 |
+
* @var CPTP
|
19 |
+
*/
|
20 |
private static $_instance;
|
21 |
|
22 |
+
/**
|
23 |
+
* Module instances.
|
24 |
+
*
|
25 |
+
* @var CPTP_Module[]
|
26 |
+
*/
|
27 |
public $modules;
|
28 |
|
29 |
+
/**
|
30 |
+
* CPTP constructor.
|
31 |
+
*/
|
32 |
private function __construct() {
|
33 |
$this->load_modules();
|
34 |
}
|
53 |
}
|
54 |
|
55 |
/**
|
56 |
+
* Initialize modules.
|
57 |
*
|
58 |
* @since 2.0.0
|
59 |
*/
|
66 |
}
|
67 |
|
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 |
|
79 |
}
|
80 |
|
81 |
/**
|
82 |
+
* Init
|
83 |
*
|
84 |
* Fire Module::add_hook
|
85 |
*
|
98 |
public static function get_instance() {
|
99 |
|
100 |
if ( ! isset( self::$_instance ) ) {
|
101 |
+
self::$_instance = new CPTP();
|
102 |
}
|
103 |
|
104 |
return self::$_instance;
|
106 |
|
107 |
|
108 |
/**
|
|
|
109 |
* Activation Hooks
|
110 |
* This function will browse initialized modules and execute their activation_hook methods.
|
111 |
* It will also set the uninstall_hook to the cptp_uninstall function which behaves the same way as this one.
|
121 |
}
|
122 |
|
123 |
/**
|
|
|
124 |
* Uninstall Hooks
|
125 |
* This function will browse initialized modules and execute their uninstall_hook methods.
|
126 |
*
|
CPTP/Module.php
CHANGED
@@ -1,19 +1,36 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
2 |
|
|
|
|
|
|
|
3 |
abstract class CPTP_Module {
|
4 |
|
|
|
|
|
|
|
5 |
final public function init() {
|
6 |
$this->register();
|
7 |
}
|
8 |
|
|
|
|
|
|
|
9 |
public function register() {
|
10 |
add_action( 'CPTP_init', array( $this, 'add_hook' ) );
|
11 |
}
|
12 |
|
|
|
|
|
|
|
13 |
abstract function add_hook();
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
*
|
18 |
* @static
|
19 |
*/
|
@@ -21,7 +38,7 @@ abstract class CPTP_Module {
|
|
21 |
}
|
22 |
|
23 |
/**
|
24 |
-
*
|
25 |
*/
|
26 |
public function activation_hook() {
|
27 |
}
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* Abstract Module.
|
4 |
+
*
|
5 |
+
* @package Custom_Post_Type_Permalinks
|
6 |
+
*/
|
7 |
|
8 |
+
/**
|
9 |
+
* Class CPTP_Module
|
10 |
+
*/
|
11 |
abstract class CPTP_Module {
|
12 |
|
13 |
+
/**
|
14 |
+
* Entry point.
|
15 |
+
*/
|
16 |
final public function init() {
|
17 |
$this->register();
|
18 |
}
|
19 |
|
20 |
+
/**
|
21 |
+
* Register hook on CPTP_init.
|
22 |
+
*/
|
23 |
public function register() {
|
24 |
add_action( 'CPTP_init', array( $this, 'add_hook' ) );
|
25 |
}
|
26 |
|
27 |
+
/**
|
28 |
+
* Module hook point.
|
29 |
+
*/
|
30 |
abstract function add_hook();
|
31 |
|
32 |
/**
|
33 |
+
* Uninstall hooks
|
34 |
*
|
35 |
* @static
|
36 |
*/
|
38 |
}
|
39 |
|
40 |
/**
|
41 |
+
* Fire on activate
|
42 |
*/
|
43 |
public function activation_hook() {
|
44 |
}
|
CPTP/Module/Admin.php
CHANGED
@@ -1,24 +1,28 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
|
4 |
/**
|
5 |
-
*
|
6 |
* Admin Page View.
|
7 |
*
|
8 |
* @package Custom_Post_Type_Permalinks
|
9 |
* @since 0.9.4
|
10 |
* */
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
class CPTP_Module_Admin extends CPTP_Module {
|
12 |
|
|
|
|
|
|
|
13 |
public function add_hook() {
|
14 |
add_action( 'admin_init', array( $this, 'settings_api_init' ), 30 );
|
15 |
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_css_js' ) );
|
16 |
add_action( 'admin_notices', array( $this, 'admin_notices' ) );
|
17 |
}
|
18 |
|
19 |
-
|
20 |
/**
|
21 |
-
*
|
22 |
* Setting Init
|
23 |
*
|
24 |
* @since 0.7
|
@@ -40,7 +44,10 @@ class CPTP_Module_Admin extends CPTP_Module {
|
|
40 |
array( $this, 'setting_structure_callback_function' ),
|
41 |
'permalink',
|
42 |
'cptp_setting_section',
|
43 |
-
array(
|
|
|
|
|
|
|
44 |
);
|
45 |
register_setting( 'permalink', $post_type . '_structure' );
|
46 |
}
|
@@ -51,7 +58,9 @@ class CPTP_Module_Admin extends CPTP_Module {
|
|
51 |
array( $this, 'setting_no_tax_structure_callback_function' ),
|
52 |
'permalink',
|
53 |
'cptp_setting_section',
|
54 |
-
array(
|
|
|
|
|
55 |
);
|
56 |
|
57 |
register_setting( 'permalink', 'no_taxonomy_structure' );
|
@@ -62,30 +71,58 @@ class CPTP_Module_Admin extends CPTP_Module {
|
|
62 |
array( $this, 'add_post_type_for_tax_callback_function' ),
|
63 |
'permalink',
|
64 |
'cptp_setting_section',
|
65 |
-
array(
|
|
|
|
|
66 |
);
|
67 |
|
68 |
register_setting( 'permalink', 'no_taxonomy_structure' );
|
69 |
-
|
70 |
}
|
71 |
|
|
|
|
|
|
|
72 |
public function setting_section_callback_function() {
|
73 |
-
$sptp_link
|
|
|
74 |
$sptp_template = __( 'If you need post type permalink only, you should use <a href="%s">Simple Post Type Permalinks</a>.', 'custom-post-type-permalinks' );
|
75 |
?>
|
76 |
<p>
|
77 |
-
<strong
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
</p>
|
|
|
|
|
|
|
|
|
|
|
79 |
|
80 |
-
<p><?php echo wp_kses( __( 'The tags you can use are WordPress Structure Tags and <code>%"custom_taxonomy_slug"%</code> (e.g. <code>%actors%</code> or <code>%movie_actors%</code>).', 'custom-post-type-permalinks' ),
|
81 |
-
<?php echo wp_kses( __( '<code>%"custom_taxonomy_slug"%</code> is replaced by the term of taxonomy.', 'custom-post-type-permalinks' ),
|
82 |
|
83 |
<p><?php esc_html_e( "Presence of the trailing '/' is unified into a standard permalink structure setting.", 'custom-post-type-permalinks' ); ?>
|
84 |
-
<p><?php echo wp_kses( __( 'If <code>has_archive</code> is true, add permalinks for custom post type archive.', 'custom-post-type-permalinks' ),
|
85 |
|
86 |
<?php
|
87 |
}
|
88 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
public function setting_structure_callback_function( $option ) {
|
90 |
|
91 |
$post_type = $option['post_type'];
|
@@ -97,7 +134,7 @@ class CPTP_Module_Admin extends CPTP_Module {
|
|
97 |
$value = CPTP_Util::get_permalink_structure( $post_type );
|
98 |
|
99 |
$disabled = false;
|
100 |
-
if ( isset( $pt_object->cptp_permalink_structure )
|
101 |
$disabled = true;
|
102 |
}
|
103 |
|
@@ -107,22 +144,22 @@ class CPTP_Module_Admin extends CPTP_Module {
|
|
107 |
|
108 |
global $wp_rewrite;
|
109 |
$front = substr( $wp_rewrite->front, 1 );
|
110 |
-
if ( $front
|
111 |
$slug = $front . $slug;
|
112 |
}
|
113 |
?>
|
114 |
<p>
|
115 |
<code><?php echo esc_html( home_url() . ( $slug ? '/' : '' ) . $slug ); ?></code>
|
116 |
-
<input name="<?php echo esc_attr( $name ); ?>" id="<?php echo esc_attr( $name ); ?>" type="text"
|
117 |
-
class="regular-text code "
|
118 |
-
value="<?php echo esc_attr( $value ); ?>" <?php disabled( $disabled, true, true ); ?> />
|
119 |
</p>
|
120 |
<p>has_archive: <code><?php echo esc_html( $pt_object->has_archive ? 'true' : 'false' ); ?></code> / with_front:
|
121 |
<code><?php echo esc_html( $pt_object->rewrite['with_front'] ? 'true' : 'false' ); ?></code></p>
|
122 |
<?php
|
123 |
}
|
124 |
|
125 |
-
|
|
|
|
|
126 |
public function setting_no_tax_structure_callback_function() {
|
127 |
$no_taxonomy_structure = CPTP_Util::get_no_taxonomy_structure();
|
128 |
echo '<input name="no_taxonomy_structure" id="no_taxonomy_structure" type="checkbox" value="1" class="code" ' . checked( false, $no_taxonomy_structure, false ) . ' /> ';
|
@@ -130,7 +167,9 @@ class CPTP_Module_Admin extends CPTP_Module {
|
|
130 |
echo sprintf( wp_kses( $txt, array( 'code' => array() ) ), esc_html( home_url() ) );
|
131 |
}
|
132 |
|
133 |
-
|
|
|
|
|
134 |
public function add_post_type_for_tax_callback_function() {
|
135 |
echo '<input name="add_post_type_for_tax" id="add_post_type_for_tax" type="checkbox" value="1" class="code" ' . checked( true, get_option( 'add_post_type_for_tax' ), false ) . ' /> ';
|
136 |
esc_html_e( 'Custom taxonomy archive also works as post type archive. ', 'custom-post-type-permalinks' );
|
@@ -139,8 +178,7 @@ class CPTP_Module_Admin extends CPTP_Module {
|
|
139 |
|
140 |
|
141 |
/**
|
142 |
-
*
|
143 |
-
* enqueue CSS and JS
|
144 |
*
|
145 |
* @since 0.8.5
|
146 |
*/
|
@@ -148,7 +186,7 @@ class CPTP_Module_Admin extends CPTP_Module {
|
|
148 |
$pointer_name = 'custom-post-type-permalinks-settings';
|
149 |
if ( ! is_network_admin() ) {
|
150 |
$dismissed = explode( ',', get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
|
151 |
-
if ( false === array_search( $pointer_name, $dismissed ) ) {
|
152 |
$content = '';
|
153 |
$content .= '<h3>' . __( 'Custom Post Type Permalinks', 'custom-post-type-permalinks' ) . '</h3>';
|
154 |
$content .= '<p>' . __( 'You can setting permalink for post type in <a href="options-permalink.php">Permalinks</a>.', 'custom-post-type-permalinks' ) . '</p>';
|
@@ -165,18 +203,16 @@ class CPTP_Module_Admin extends CPTP_Module {
|
|
165 |
}
|
166 |
}
|
167 |
|
168 |
-
|
169 |
/**
|
170 |
* Admin notice for update permalink settings!
|
171 |
*/
|
172 |
public function admin_notices() {
|
173 |
if ( version_compare( get_option( 'cptp_permalink_checked' ), '3.0.0', '<' ) ) {
|
|
|
174 |
$format = __( '[Custom Post Type Permalinks] <a href="%s"><strong>Please check your permalink settings!</strong></a>', 'custom-post-type-permalinks' );
|
175 |
$message = sprintf( $format, admin_url( 'options-permalink.php' ) );
|
176 |
echo sprintf( '<div class="notice notice-warning"><p>%s</p></div>', wp_kses( $message, wp_kses_allowed_html( 'post' ) ) );
|
177 |
}
|
178 |
-
|
179 |
}
|
180 |
-
|
181 |
}
|
182 |
|
1 |
<?php
|
|
|
|
|
2 |
/**
|
|
|
3 |
* Admin Page View.
|
4 |
*
|
5 |
* @package Custom_Post_Type_Permalinks
|
6 |
* @since 0.9.4
|
7 |
* */
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Admin Page Class.
|
11 |
+
*
|
12 |
+
* @since 0.9.4
|
13 |
+
* */
|
14 |
class CPTP_Module_Admin extends CPTP_Module {
|
15 |
|
16 |
+
/**
|
17 |
+
* Add actions.
|
18 |
+
*/
|
19 |
public function add_hook() {
|
20 |
add_action( 'admin_init', array( $this, 'settings_api_init' ), 30 );
|
21 |
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_css_js' ) );
|
22 |
add_action( 'admin_notices', array( $this, 'admin_notices' ) );
|
23 |
}
|
24 |
|
|
|
25 |
/**
|
|
|
26 |
* Setting Init
|
27 |
*
|
28 |
* @since 0.7
|
44 |
array( $this, 'setting_structure_callback_function' ),
|
45 |
'permalink',
|
46 |
'cptp_setting_section',
|
47 |
+
array(
|
48 |
+
'label_for' => $post_type . '_structure',
|
49 |
+
'post_type' => $post_type,
|
50 |
+
)
|
51 |
);
|
52 |
register_setting( 'permalink', $post_type . '_structure' );
|
53 |
}
|
58 |
array( $this, 'setting_no_tax_structure_callback_function' ),
|
59 |
'permalink',
|
60 |
'cptp_setting_section',
|
61 |
+
array(
|
62 |
+
'label_for' => 'no_taxonomy_structure',
|
63 |
+
)
|
64 |
);
|
65 |
|
66 |
register_setting( 'permalink', 'no_taxonomy_structure' );
|
71 |
array( $this, 'add_post_type_for_tax_callback_function' ),
|
72 |
'permalink',
|
73 |
'cptp_setting_section',
|
74 |
+
array(
|
75 |
+
'label_for' => 'add_post_type_for_tax',
|
76 |
+
)
|
77 |
);
|
78 |
|
79 |
register_setting( 'permalink', 'no_taxonomy_structure' );
|
|
|
80 |
}
|
81 |
|
82 |
+
/**
|
83 |
+
* Setting section view.
|
84 |
+
*/
|
85 |
public function setting_section_callback_function() {
|
86 |
+
$sptp_link = admin_url( 'plugin-install.php?s=simple-post-type-permalinks&tab=search&type=term' );
|
87 |
+
// translators: %s simple post type permalinks install page.
|
88 |
$sptp_template = __( 'If you need post type permalink only, you should use <a href="%s">Simple Post Type Permalinks</a>.', 'custom-post-type-permalinks' );
|
89 |
?>
|
90 |
<p>
|
91 |
+
<strong>
|
92 |
+
<?php
|
93 |
+
$allowed_html = array(
|
94 |
+
'a' => array(
|
95 |
+
'href' => true,
|
96 |
+
),
|
97 |
+
);
|
98 |
+
echo wp_kses( sprintf( $sptp_template, esc_url( $sptp_link ) ), $allowed_html );
|
99 |
+
?>
|
100 |
+
</strong>
|
101 |
</p>
|
102 |
+
<?php
|
103 |
+
$allowed_html_code_tag = array(
|
104 |
+
'code' => array(),
|
105 |
+
);
|
106 |
+
?>
|
107 |
|
108 |
+
<p><?php echo wp_kses( __( 'The tags you can use are WordPress Structure Tags and <code>%"custom_taxonomy_slug"%</code> (e.g. <code>%actors%</code> or <code>%movie_actors%</code>).', 'custom-post-type-permalinks' ), $allowed_html_code_tag ); ?>
|
109 |
+
<?php echo wp_kses( __( '<code>%"custom_taxonomy_slug"%</code> is replaced by the term of taxonomy.', 'custom-post-type-permalinks' ), $allowed_html_code_tag ); ?></p>
|
110 |
|
111 |
<p><?php esc_html_e( "Presence of the trailing '/' is unified into a standard permalink structure setting.", 'custom-post-type-permalinks' ); ?>
|
112 |
+
<p><?php echo wp_kses( __( 'If <code>has_archive</code> is true, add permalinks for custom post type archive.', 'custom-post-type-permalinks' ), $allowed_html_code_tag ); ?></p>
|
113 |
|
114 |
<?php
|
115 |
}
|
116 |
|
117 |
+
/**
|
118 |
+
* Show setting structure input.
|
119 |
+
*
|
120 |
+
* @param array $option {
|
121 |
+
* Callback option.
|
122 |
+
* @type string 'post_type' post type name.
|
123 |
+
* @type string 'label_for' post type label.
|
124 |
+
* }
|
125 |
+
*/
|
126 |
public function setting_structure_callback_function( $option ) {
|
127 |
|
128 |
$post_type = $option['post_type'];
|
134 |
$value = CPTP_Util::get_permalink_structure( $post_type );
|
135 |
|
136 |
$disabled = false;
|
137 |
+
if ( isset( $pt_object->cptp_permalink_structure ) && $pt_object->cptp_permalink_structure ) {
|
138 |
$disabled = true;
|
139 |
}
|
140 |
|
144 |
|
145 |
global $wp_rewrite;
|
146 |
$front = substr( $wp_rewrite->front, 1 );
|
147 |
+
if ( $front && $with_front ) {
|
148 |
$slug = $front . $slug;
|
149 |
}
|
150 |
?>
|
151 |
<p>
|
152 |
<code><?php echo esc_html( home_url() . ( $slug ? '/' : '' ) . $slug ); ?></code>
|
153 |
+
<input name="<?php echo esc_attr( $name ); ?>" id="<?php echo esc_attr( $name ); ?>" type="text" class="regular-text code " value="<?php echo esc_attr( $value ); ?>" <?php disabled( $disabled, true, true ); ?> />
|
|
|
|
|
154 |
</p>
|
155 |
<p>has_archive: <code><?php echo esc_html( $pt_object->has_archive ? 'true' : 'false' ); ?></code> / with_front:
|
156 |
<code><?php echo esc_html( $pt_object->rewrite['with_front'] ? 'true' : 'false' ); ?></code></p>
|
157 |
<?php
|
158 |
}
|
159 |
|
160 |
+
/**
|
161 |
+
* Show checkbox no tax.
|
162 |
+
*/
|
163 |
public function setting_no_tax_structure_callback_function() {
|
164 |
$no_taxonomy_structure = CPTP_Util::get_no_taxonomy_structure();
|
165 |
echo '<input name="no_taxonomy_structure" id="no_taxonomy_structure" type="checkbox" value="1" class="code" ' . checked( false, $no_taxonomy_structure, false ) . ' /> ';
|
167 |
echo sprintf( wp_kses( $txt, array( 'code' => array() ) ), esc_html( home_url() ) );
|
168 |
}
|
169 |
|
170 |
+
/**
|
171 |
+
* Show checkbox for post type query.
|
172 |
+
*/
|
173 |
public function add_post_type_for_tax_callback_function() {
|
174 |
echo '<input name="add_post_type_for_tax" id="add_post_type_for_tax" type="checkbox" value="1" class="code" ' . checked( true, get_option( 'add_post_type_for_tax' ), false ) . ' /> ';
|
175 |
esc_html_e( 'Custom taxonomy archive also works as post type archive. ', 'custom-post-type-permalinks' );
|
178 |
|
179 |
|
180 |
/**
|
181 |
+
* Enqueue css and js
|
|
|
182 |
*
|
183 |
* @since 0.8.5
|
184 |
*/
|
186 |
$pointer_name = 'custom-post-type-permalinks-settings';
|
187 |
if ( ! is_network_admin() ) {
|
188 |
$dismissed = explode( ',', get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
|
189 |
+
if ( false === array_search( $pointer_name, $dismissed, true ) ) {
|
190 |
$content = '';
|
191 |
$content .= '<h3>' . __( 'Custom Post Type Permalinks', 'custom-post-type-permalinks' ) . '</h3>';
|
192 |
$content .= '<p>' . __( 'You can setting permalink for post type in <a href="options-permalink.php">Permalinks</a>.', 'custom-post-type-permalinks' ) . '</p>';
|
203 |
}
|
204 |
}
|
205 |
|
|
|
206 |
/**
|
207 |
* Admin notice for update permalink settings!
|
208 |
*/
|
209 |
public function admin_notices() {
|
210 |
if ( version_compare( get_option( 'cptp_permalink_checked' ), '3.0.0', '<' ) ) {
|
211 |
+
// translators: %s URL.
|
212 |
$format = __( '[Custom Post Type Permalinks] <a href="%s"><strong>Please check your permalink settings!</strong></a>', 'custom-post-type-permalinks' );
|
213 |
$message = sprintf( $format, admin_url( 'options-permalink.php' ) );
|
214 |
echo sprintf( '<div class="notice notice-warning"><p>%s</p></div>', wp_kses( $message, wp_kses_allowed_html( 'post' ) ) );
|
215 |
}
|
|
|
216 |
}
|
|
|
217 |
}
|
218 |
|
CPTP/Module/FlushRules.php
CHANGED
@@ -1,16 +1,21 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
/**
|
4 |
*
|
5 |
* Reflush Rewrite Rules
|
6 |
*
|
7 |
-
* @package Custom_Post_Type_Permalinks
|
8 |
* @since 0.9.4
|
9 |
* */
|
10 |
-
|
11 |
class CPTP_Module_FlushRules extends CPTP_Module {
|
12 |
|
13 |
-
|
|
|
|
|
14 |
public function add_hook() {
|
15 |
add_action( 'init', array( $this, 'update_rules' ) );
|
16 |
add_action( 'add_option_cptp_version', array( $this, 'update_rules' ) );
|
@@ -18,16 +23,12 @@ class CPTP_Module_FlushRules extends CPTP_Module {
|
|
18 |
add_action( 'wp_loaded', array( __CLASS__, 'dequeue_flush_rules' ), 200 );
|
19 |
}
|
20 |
|
21 |
-
|
22 |
-
|
23 |
/**
|
24 |
-
*
|
25 |
* Add hook flush_rules
|
26 |
*
|
27 |
* @since 0.7.9
|
28 |
*/
|
29 |
public function update_rules() {
|
30 |
-
|
31 |
$post_types = CPTP_Util::get_post_types();
|
32 |
foreach ( $post_types as $post_type ) {
|
33 |
add_action( 'update_option_' . $post_type . '_structure', array( __CLASS__, 'queue_flush_rules' ), 10, 2 );
|
@@ -35,35 +36,29 @@ class CPTP_Module_FlushRules extends CPTP_Module {
|
|
35 |
add_action( 'update_option_no_taxonomy_structure', array( __CLASS__, 'queue_flush_rules' ), 10, 2 );
|
36 |
}
|
37 |
|
38 |
-
|
39 |
/**
|
40 |
-
*
|
41 |
-
* dequeue flush rules
|
42 |
*
|
43 |
* @since 0.9
|
44 |
*/
|
45 |
-
|
46 |
public static function dequeue_flush_rules() {
|
47 |
if ( get_option( 'queue_flush_rules' ) ) {
|
48 |
flush_rewrite_rules();
|
49 |
update_option( 'queue_flush_rules', 0 );
|
50 |
-
|
51 |
}
|
52 |
}
|
53 |
|
54 |
-
|
55 |
/**
|
56 |
* Flush rules
|
57 |
*
|
58 |
* @since 0.7.9
|
59 |
*/
|
60 |
-
|
61 |
public static function queue_flush_rules() {
|
62 |
update_option( 'queue_flush_rules', 1 );
|
63 |
}
|
64 |
|
65 |
/**
|
66 |
-
*
|
67 |
*
|
68 |
* @staitc
|
69 |
*/
|
@@ -72,7 +67,7 @@ class CPTP_Module_FlushRules extends CPTP_Module {
|
|
72 |
}
|
73 |
|
74 |
/**
|
75 |
-
*
|
76 |
*/
|
77 |
public function activation_hook() {
|
78 |
CPTP_Module_FlushRules::queue_flush_rules();
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* Refresh Rewrite Rules.
|
4 |
+
*
|
5 |
+
* @package Custom_Post_Type_Permalinks
|
6 |
+
*/
|
7 |
|
8 |
/**
|
9 |
*
|
10 |
* Reflush Rewrite Rules
|
11 |
*
|
|
|
12 |
* @since 0.9.4
|
13 |
* */
|
|
|
14 |
class CPTP_Module_FlushRules extends CPTP_Module {
|
15 |
|
16 |
+
/**
|
17 |
+
* Add actions.
|
18 |
+
*/
|
19 |
public function add_hook() {
|
20 |
add_action( 'init', array( $this, 'update_rules' ) );
|
21 |
add_action( 'add_option_cptp_version', array( $this, 'update_rules' ) );
|
23 |
add_action( 'wp_loaded', array( __CLASS__, 'dequeue_flush_rules' ), 200 );
|
24 |
}
|
25 |
|
|
|
|
|
26 |
/**
|
|
|
27 |
* Add hook flush_rules
|
28 |
*
|
29 |
* @since 0.7.9
|
30 |
*/
|
31 |
public function update_rules() {
|
|
|
32 |
$post_types = CPTP_Util::get_post_types();
|
33 |
foreach ( $post_types as $post_type ) {
|
34 |
add_action( 'update_option_' . $post_type . '_structure', array( __CLASS__, 'queue_flush_rules' ), 10, 2 );
|
36 |
add_action( 'update_option_no_taxonomy_structure', array( __CLASS__, 'queue_flush_rules' ), 10, 2 );
|
37 |
}
|
38 |
|
|
|
39 |
/**
|
40 |
+
* Dequeue flush rules
|
|
|
41 |
*
|
42 |
* @since 0.9
|
43 |
*/
|
|
|
44 |
public static function dequeue_flush_rules() {
|
45 |
if ( get_option( 'queue_flush_rules' ) ) {
|
46 |
flush_rewrite_rules();
|
47 |
update_option( 'queue_flush_rules', 0 );
|
|
|
48 |
}
|
49 |
}
|
50 |
|
|
|
51 |
/**
|
52 |
* Flush rules
|
53 |
*
|
54 |
* @since 0.7.9
|
55 |
*/
|
|
|
56 |
public static function queue_flush_rules() {
|
57 |
update_option( 'queue_flush_rules', 1 );
|
58 |
}
|
59 |
|
60 |
/**
|
61 |
+
* Uninstall hooks
|
62 |
*
|
63 |
* @staitc
|
64 |
*/
|
67 |
}
|
68 |
|
69 |
/**
|
70 |
+
* Fire on activate
|
71 |
*/
|
72 |
public function activation_hook() {
|
73 |
CPTP_Module_FlushRules::queue_flush_rules();
|
CPTP/Module/GetArchives.php
CHANGED
@@ -1,36 +1,45 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
|
4 |
/**
|
5 |
-
*
|
6 |
-
*
|
7 |
*
|
8 |
* @package Custom_Post_Type_Permalinks
|
|
|
|
|
|
|
|
|
|
|
9 |
* @since 0.9.4
|
10 |
* */
|
11 |
-
|
12 |
class CPTP_Module_GetArchives extends CPTP_Module {
|
13 |
|
|
|
|
|
|
|
14 |
public function add_hook() {
|
15 |
-
if ( get_option( 'permalink_structure' )
|
16 |
-
add_filter( 'getarchives_join', array( $this, 'getarchives_join' ), 10, 2 );
|
17 |
add_filter( 'getarchives_where', array( $this, 'getarchives_where' ), 10 , 2 );
|
18 |
add_filter( 'get_archives_link', array( $this, 'get_archives_link' ), 20, 1 );
|
19 |
}
|
20 |
-
|
21 |
}
|
22 |
|
23 |
/**
|
|
|
24 |
*
|
25 |
-
*
|
26 |
-
* Ex:wp_get_archives('&post_type='.get_query_var( 'post_type' ));
|
27 |
-
*
|
28 |
-
* @version 2.0
|
29 |
*/
|
30 |
-
|
31 |
public $get_archives_where_r;
|
32 |
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
public function getarchives_where( $where, $r ) {
|
35 |
$this->get_archives_where_r = $r;
|
36 |
if ( isset( $r['post_type'] ) ) {
|
@@ -45,19 +54,15 @@ class CPTP_Module_GetArchives extends CPTP_Module {
|
|
45 |
return $where;
|
46 |
}
|
47 |
|
48 |
-
|
49 |
-
|
50 |
-
// function added by [steve]
|
51 |
/**
|
52 |
-
*
|
53 |
-
* get_archive_join
|
54 |
*
|
55 |
* @author Steve
|
56 |
* @since 0.8
|
57 |
* @version 1.0
|
58 |
*
|
59 |
-
* @param string $join
|
60 |
-
* @param array $r
|
61 |
*
|
62 |
* @return string
|
63 |
*/
|
@@ -73,8 +78,7 @@ class CPTP_Module_GetArchives extends CPTP_Module {
|
|
73 |
|
74 |
|
75 |
/**
|
76 |
-
*
|
77 |
-
* get_arcihves_link
|
78 |
*
|
79 |
* @version 2.2 03/27/14
|
80 |
*
|
@@ -89,19 +93,19 @@ class CPTP_Module_GetArchives extends CPTP_Module {
|
|
89 |
return $html;
|
90 |
}
|
91 |
|
92 |
-
if ( 'post'
|
93 |
return $html;
|
94 |
}
|
95 |
|
96 |
-
$c = isset( $this->get_archives_where_r['taxonomy'] ) && is_array( $this->get_archives_where_r['taxonomy'] ) ? $this->get_archives_where_r['taxonomy'] : '';
|
97 |
$t = $this->get_archives_where_r['post_type'];
|
98 |
|
99 |
$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]
|
100 |
|
101 |
-
if ( isset( $this->get_archives_where_r['post_type'] )
|
102 |
$blog_url = rtrim( home_url() ,'/' );
|
103 |
|
104 |
-
// remove front
|
105 |
$front = substr( $wp_rewrite->front, 1 );
|
106 |
$html = str_replace( $front, '', $html );
|
107 |
|
@@ -109,14 +113,14 @@ class CPTP_Module_GetArchives extends CPTP_Module {
|
|
109 |
$ret_link = str_replace( $blog_url, $blog_url . '/%link_dir%', $html );
|
110 |
|
111 |
$post_type = get_post_type_object( $this->get_archives_where_r['post_type'] );
|
112 |
-
if ( empty( $c ) ) {
|
113 |
if ( isset( $post_type->rewrite['slug'] ) ) {
|
114 |
$link_dir = $post_type->rewrite['slug'];
|
115 |
} else {
|
116 |
$link_dir = $this->get_archives_where_r['post_type'];
|
117 |
}
|
118 |
-
} else {
|
119 |
-
$c['name'] = ( 'category'
|
120 |
$link_dir = $post_type->rewrite['slug'] . '/' . $c['name'] . '/' . $c['termslug'];
|
121 |
}
|
122 |
|
@@ -132,7 +136,7 @@ class CPTP_Module_GetArchives extends CPTP_Module {
|
|
132 |
} else {
|
133 |
$ret_link = $html;
|
134 |
}
|
135 |
-
$this->get_archives_where_r['post_type'] = $t;
|
136 |
return $ret_link;
|
137 |
}
|
138 |
}
|
1 |
<?php
|
|
|
|
|
2 |
/**
|
3 |
+
* Fix: wp_get_archives fix for custom post
|
4 |
+
* Ex:wp_get_archives('&post_type='.get_query_var( 'post_type' ));
|
5 |
*
|
6 |
* @package Custom_Post_Type_Permalinks
|
7 |
+
*/
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Get Archives fix.
|
11 |
+
*
|
12 |
* @since 0.9.4
|
13 |
* */
|
|
|
14 |
class CPTP_Module_GetArchives extends CPTP_Module {
|
15 |
|
16 |
+
/**
|
17 |
+
* Register hooks.
|
18 |
+
*/
|
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 |
}
|
26 |
|
27 |
/**
|
28 |
+
* Argument in wp_get_archives.
|
29 |
*
|
30 |
+
* @var array
|
|
|
|
|
|
|
31 |
*/
|
|
|
32 |
public $get_archives_where_r;
|
33 |
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Get archive where.
|
37 |
+
*
|
38 |
+
* @param string $where SQL where.
|
39 |
+
* @param array $r Argument in wp_get_archives.
|
40 |
+
*
|
41 |
+
* @return mixed|string
|
42 |
+
*/
|
43 |
public function getarchives_where( $where, $r ) {
|
44 |
$this->get_archives_where_r = $r;
|
45 |
if ( isset( $r['post_type'] ) ) {
|
54 |
return $where;
|
55 |
}
|
56 |
|
|
|
|
|
|
|
57 |
/**
|
58 |
+
* Get_archive_join
|
|
|
59 |
*
|
60 |
* @author Steve
|
61 |
* @since 0.8
|
62 |
* @version 1.0
|
63 |
*
|
64 |
+
* @param string $join SQL JOIN.
|
65 |
+
* @param array $r Argument in wp_get_archives.
|
66 |
*
|
67 |
* @return string
|
68 |
*/
|
78 |
|
79 |
|
80 |
/**
|
81 |
+
* Filter: get_arcihves_link
|
|
|
82 |
*
|
83 |
* @version 2.2 03/27/14
|
84 |
*
|
93 |
return $html;
|
94 |
}
|
95 |
|
96 |
+
if ( 'post' === $this->get_archives_where_r['post_type'] ) {
|
97 |
return $html;
|
98 |
}
|
99 |
|
100 |
+
$c = isset( $this->get_archives_where_r['taxonomy'] ) && is_array( $this->get_archives_where_r['taxonomy'] ) ? $this->get_archives_where_r['taxonomy'] : '';
|
101 |
$t = $this->get_archives_where_r['post_type'];
|
102 |
|
103 |
$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]
|
104 |
|
105 |
+
if ( isset( $this->get_archives_where_r['post_type'] ) && 'postbypost' !== $this->get_archives_where_r['type'] ) {
|
106 |
$blog_url = rtrim( home_url() ,'/' );
|
107 |
|
108 |
+
// remove front.
|
109 |
$front = substr( $wp_rewrite->front, 1 );
|
110 |
$html = str_replace( $front, '', $html );
|
111 |
|
113 |
$ret_link = str_replace( $blog_url, $blog_url . '/%link_dir%', $html );
|
114 |
|
115 |
$post_type = get_post_type_object( $this->get_archives_where_r['post_type'] );
|
116 |
+
if ( empty( $c ) ) {
|
117 |
if ( isset( $post_type->rewrite['slug'] ) ) {
|
118 |
$link_dir = $post_type->rewrite['slug'];
|
119 |
} else {
|
120 |
$link_dir = $this->get_archives_where_r['post_type'];
|
121 |
}
|
122 |
+
} else {
|
123 |
+
$c['name'] = ( 'category' === $c['name'] && get_option( 'category_base' ) ) ? get_option( 'category_base' ) : $c['name'];
|
124 |
$link_dir = $post_type->rewrite['slug'] . '/' . $c['name'] . '/' . $c['termslug'];
|
125 |
}
|
126 |
|
136 |
} else {
|
137 |
$ret_link = $html;
|
138 |
}
|
139 |
+
$this->get_archives_where_r['post_type'] = $t;
|
140 |
return $ret_link;
|
141 |
}
|
142 |
}
|
CPTP/Module/Option.php
CHANGED
@@ -1,46 +1,50 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
|
4 |
/**
|
5 |
-
*
|
6 |
* Options.
|
7 |
*
|
8 |
* Save Options.
|
9 |
*
|
10 |
* @package Custom_Post_Type_Permalinks
|
11 |
-
* @since 0.9.6
|
12 |
* */
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
class CPTP_Module_Option extends CPTP_Module {
|
14 |
|
|
|
|
|
|
|
15 |
public function add_hook() {
|
16 |
add_action( 'init', array( $this, 'set_default_option' ), 1 );
|
17 |
add_action( 'admin_init', array( $this, 'save_options' ), 30 );
|
18 |
}
|
19 |
|
|
|
|
|
|
|
20 |
public function set_default_option() {
|
21 |
add_option( 'no_taxonomy_structure', true );
|
22 |
add_option( 'add_post_type_for_tax', false );
|
23 |
}
|
24 |
|
|
|
|
|
|
|
|
|
|
|
25 |
public function save_options() {
|
26 |
-
|
27 |
-
if ( empty( $_POST['submit'] ) ) {
|
28 |
-
return false;
|
29 |
-
}
|
30 |
-
|
31 |
-
if ( empty( $_POST['_wpnonce'] ) ) {
|
32 |
-
return false;
|
33 |
-
}
|
34 |
-
|
35 |
-
if ( ! wp_verify_nonce( $_POST['_wpnonce'], 'update-permalink' ) ) {
|
36 |
return false;
|
37 |
}
|
38 |
|
39 |
-
if (
|
40 |
return false;
|
41 |
}
|
42 |
|
43 |
-
if ( false === strpos(
|
44 |
return false;
|
45 |
}
|
46 |
|
@@ -48,32 +52,34 @@ class CPTP_Module_Option extends CPTP_Module {
|
|
48 |
|
49 |
foreach ( $post_types as $post_type ) :
|
50 |
|
51 |
-
$structure = trim( esc_attr(
|
52 |
|
53 |
-
// default permalink structure
|
54 |
if ( ! $structure ) {
|
55 |
$structure = CPTP_DEFAULT_PERMALINK;
|
56 |
}
|
57 |
|
58 |
$structure = str_replace( '//', '/', '/' . $structure );// first "/"
|
59 |
-
// last "/"
|
60 |
-
$lastString = substr( trim( esc_attr(
|
61 |
$structure = rtrim( $structure, '/' );
|
62 |
|
63 |
-
if ( '/'
|
64 |
$structure = $structure . '/';
|
65 |
}
|
66 |
|
67 |
update_option( $post_type . '_structure', $structure );
|
68 |
endforeach;
|
|
|
|
|
69 |
|
70 |
-
update_option( 'no_taxonomy_structure',
|
71 |
-
update_option( 'add_post_type_for_tax',
|
72 |
update_option( 'cptp_permalink_checked', CPTP_VERSION );
|
73 |
}
|
74 |
|
75 |
/**
|
76 |
-
*
|
77 |
*
|
78 |
* @static
|
79 |
*/
|
1 |
<?php
|
|
|
|
|
2 |
/**
|
|
|
3 |
* Options.
|
4 |
*
|
5 |
* Save Options.
|
6 |
*
|
7 |
* @package Custom_Post_Type_Permalinks
|
|
|
8 |
* */
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Class CPTP_Module_Option
|
12 |
+
*
|
13 |
+
* @since 0.9.6
|
14 |
+
*/
|
15 |
class CPTP_Module_Option extends CPTP_Module {
|
16 |
|
17 |
+
/**
|
18 |
+
* Add Actions.
|
19 |
+
*/
|
20 |
public function add_hook() {
|
21 |
add_action( 'init', array( $this, 'set_default_option' ), 1 );
|
22 |
add_action( 'admin_init', array( $this, 'save_options' ), 30 );
|
23 |
}
|
24 |
|
25 |
+
/**
|
26 |
+
* Set default option values.
|
27 |
+
*/
|
28 |
public function set_default_option() {
|
29 |
add_option( 'no_taxonomy_structure', true );
|
30 |
add_option( 'add_post_type_for_tax', false );
|
31 |
}
|
32 |
|
33 |
+
/**
|
34 |
+
* Save Options.
|
35 |
+
*
|
36 |
+
* @return bool
|
37 |
+
*/
|
38 |
public function save_options() {
|
39 |
+
if ( ! filter_input( INPUT_POST, 'submit' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
return false;
|
41 |
}
|
42 |
|
43 |
+
if ( ! wp_verify_nonce( filter_input( INPUT_POST, '_wpnonce' ), 'update-permalink' ) ) {
|
44 |
return false;
|
45 |
}
|
46 |
|
47 |
+
if ( false === strpos( filter_input( INPUT_POST, '_wp_http_referer' ), 'options-permalink.php' ) ) {
|
48 |
return false;
|
49 |
}
|
50 |
|
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.
|
58 |
if ( ! $structure ) {
|
59 |
$structure = CPTP_DEFAULT_PERMALINK;
|
60 |
}
|
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 ) {
|
68 |
$structure = $structure . '/';
|
69 |
}
|
70 |
|
71 |
update_option( $post_type . '_structure', $structure );
|
72 |
endforeach;
|
73 |
+
$no_taxonomy_structure = ! filter_input( INPUT_POST, 'no_taxonomy_structure' );
|
74 |
+
$add_post_type_for_tax = filter_input( INPUT_POST, 'add_post_type_for_tax' );
|
75 |
|
76 |
+
update_option( 'no_taxonomy_structure', $no_taxonomy_structure );
|
77 |
+
update_option( 'add_post_type_for_tax', $add_post_type_for_tax );
|
78 |
update_option( 'cptp_permalink_checked', CPTP_VERSION );
|
79 |
}
|
80 |
|
81 |
/**
|
82 |
+
* Fire on uninstall. delete options.
|
83 |
*
|
84 |
* @static
|
85 |
*/
|
CPTP/Module/Permalink.php
CHANGED
@@ -1,13 +1,13 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
|
4 |
/**
|
5 |
-
*
|
6 |
-
* CPTP_Permalink
|
7 |
-
*
|
8 |
-
* Override Permalinks
|
9 |
*
|
10 |
* @package Custom_Post_Type_Permalinks
|
|
|
|
|
|
|
|
|
|
|
11 |
* @since 0.9.4
|
12 |
* */
|
13 |
class CPTP_Module_Permalink extends CPTP_Module {
|
@@ -45,28 +45,32 @@ class CPTP_Module_Permalink extends CPTP_Module {
|
|
45 |
*
|
46 |
* Fix permalinks output.
|
47 |
*
|
48 |
-
* @param String $post_link
|
49 |
-
* @param WP_Post $post
|
50 |
-
* @param String $leavename for edit.php
|
51 |
*
|
52 |
* @version 2.0
|
53 |
*
|
54 |
* @return string
|
55 |
*/
|
56 |
public function post_type_link( $post_link, $post, $leavename ) {
|
57 |
-
|
58 |
-
|
|
|
|
|
|
|
|
|
59 |
|
60 |
if ( ! $wp_rewrite->permalink_structure ) {
|
61 |
return $post_link;
|
62 |
}
|
63 |
|
64 |
$draft_or_pending = isset( $post->post_status ) && in_array( $post->post_status, array(
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
) );
|
69 |
-
if ( $draft_or_pending
|
70 |
return $post_link;
|
71 |
}
|
72 |
|
@@ -101,7 +105,8 @@ class CPTP_Module_Permalink extends CPTP_Module {
|
|
101 |
}
|
102 |
|
103 |
// %post_id%/attachment/%attachement_name%;
|
104 |
-
|
|
|
105 |
$parent_structure = trim( CPTP_Util::get_permalink_structure( $post->post_type ), '/' );
|
106 |
$parent_dirs = explode( '/', $parent_structure );
|
107 |
if ( is_array( $parent_dirs ) ) {
|
@@ -110,7 +115,7 @@ class CPTP_Module_Permalink extends CPTP_Module {
|
|
110 |
$last_dir = $parent_dirs;
|
111 |
}
|
112 |
|
113 |
-
if ( '%post_id%'
|
114 |
$permalink = $permalink . '/attachment/';
|
115 |
}
|
116 |
}
|
@@ -132,12 +137,13 @@ class CPTP_Module_Permalink extends CPTP_Module {
|
|
132 |
$category_object = apply_filters( 'post_link_category', $categories[0], $categories, $post );
|
133 |
$category_object = get_term( $category_object, 'category' );
|
134 |
$category = $category_object->slug;
|
135 |
-
if ( $
|
|
|
136 |
$category = get_category_parents( $parent, false, '/', true ) . $category;
|
137 |
}
|
138 |
}
|
139 |
// show default category in permalinks, without
|
140 |
-
// having to assign it explicitly
|
141 |
if ( empty( $category ) ) {
|
142 |
$default_category = get_term( get_option( 'default_category' ), 'category' );
|
143 |
$category = is_wp_error( $default_category ) ? '' : $default_category->slug;
|
@@ -181,11 +187,10 @@ class CPTP_Module_Permalink extends CPTP_Module {
|
|
181 |
|
182 |
|
183 |
/**
|
|
|
184 |
*
|
185 |
-
*
|
186 |
-
*
|
187 |
-
* @param int $post_id
|
188 |
-
* @param string $permalink
|
189 |
*
|
190 |
* @return array
|
191 |
*/
|
@@ -196,26 +201,24 @@ class CPTP_Module_Permalink extends CPTP_Module {
|
|
196 |
$taxonomies = CPTP_Util::get_taxonomies( true );
|
197 |
|
198 |
// %taxnomomy% -> parent/child
|
199 |
-
// 運用でケアすべきかも。
|
200 |
foreach ( $taxonomies as $taxonomy => $objects ) {
|
201 |
|
202 |
if ( false !== strpos( $permalink, '%' . $taxonomy . '%' ) ) {
|
203 |
$terms = get_the_terms( $post_id, $taxonomy );
|
204 |
|
205 |
-
if ( $terms
|
206 |
-
$parents = array_map( array( __CLASS__, 'get_term_parent' ), $terms );
|
207 |
$newTerms = array();
|
208 |
foreach ( $terms as $key => $term ) {
|
209 |
-
if ( ! in_array( $term->term_id, $parents ) ) {
|
210 |
$newTerms[] = $term;
|
211 |
}
|
212 |
}
|
213 |
|
214 |
-
|
215 |
-
$term_obj = reset( $newTerms ); // 最初のOBjectのみを対象。
|
216 |
$term_slug = $term_obj->slug;
|
217 |
|
218 |
-
if ( isset( $term_obj->parent )
|
219 |
$term_slug = CPTP_Util::get_taxonomy_parents_slug( $term_obj->parent, $taxonomy, '/', true ) . $term_slug;
|
220 |
}
|
221 |
}
|
@@ -227,39 +230,43 @@ class CPTP_Module_Permalink extends CPTP_Module {
|
|
227 |
}
|
228 |
}
|
229 |
|
230 |
-
return array(
|
|
|
|
|
|
|
231 |
}
|
232 |
|
233 |
/**
|
|
|
234 |
*
|
235 |
-
*
|
236 |
-
*
|
237 |
-
* @param WP_Term|stdClass $term
|
238 |
*
|
239 |
* @return mixed
|
240 |
*/
|
241 |
private static function get_term_parent( $term ) {
|
242 |
-
if ( isset( $term->parent )
|
243 |
return $term->parent;
|
244 |
}
|
245 |
}
|
246 |
|
247 |
|
248 |
/**
|
249 |
-
*
|
250 |
-
* fix attachment output
|
251 |
*
|
252 |
* @version 1.0
|
253 |
* @since 0.8.2
|
254 |
*
|
255 |
-
* @param string $link
|
256 |
-
* @param int $post_id
|
257 |
*
|
258 |
* @return string
|
259 |
*/
|
260 |
-
|
261 |
public function attachment_link( $link, $post_id ) {
|
262 |
-
/**
|
|
|
|
|
|
|
|
|
263 |
global $wp_rewrite;
|
264 |
|
265 |
if ( ! $wp_rewrite->permalink_structure ) {
|
@@ -296,20 +303,23 @@ class CPTP_Module_Permalink extends CPTP_Module {
|
|
296 |
}
|
297 |
|
298 |
/**
|
299 |
-
*
|
300 |
* Fix taxonomy link outputs.
|
301 |
*
|
302 |
* @since 0.6
|
303 |
* @version 1.0
|
304 |
*
|
305 |
-
* @param string $termlink
|
306 |
-
* @param Object $term
|
307 |
-
* @param Object $taxonomy
|
308 |
*
|
309 |
* @return string
|
310 |
*/
|
311 |
public function term_link( $termlink, $term, $taxonomy ) {
|
312 |
-
/**
|
|
|
|
|
|
|
|
|
313 |
global $wp_rewrite;
|
314 |
|
315 |
if ( ! $wp_rewrite->permalink_structure ) {
|
@@ -331,7 +341,7 @@ class CPTP_Module_Permalink extends CPTP_Module {
|
|
331 |
|
332 |
$wp_home = rtrim( home_url(), '/' );
|
333 |
|
334 |
-
if ( in_array( get_post_type(), $taxonomy->object_type ) ) {
|
335 |
$post_type = get_post_type();
|
336 |
} else {
|
337 |
$post_type = $taxonomy->object_type[0];
|
1 |
<?php
|
|
|
|
|
2 |
/**
|
3 |
+
* Override Output Permalinks
|
|
|
|
|
|
|
4 |
*
|
5 |
* @package Custom_Post_Type_Permalinks
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* CPTP_Module_Permalink
|
10 |
+
*
|
11 |
* @since 0.9.4
|
12 |
* */
|
13 |
class CPTP_Module_Permalink extends CPTP_Module {
|
45 |
*
|
46 |
* Fix permalinks output.
|
47 |
*
|
48 |
+
* @param String $post_link link url.
|
49 |
+
* @param WP_Post $post post object.
|
50 |
+
* @param String $leavename for edit.php.
|
51 |
*
|
52 |
* @version 2.0
|
53 |
*
|
54 |
* @return string
|
55 |
*/
|
56 |
public function post_type_link( $post_link, $post, $leavename ) {
|
57 |
+
/**
|
58 |
+
* WP_Rewrite.
|
59 |
+
*
|
60 |
+
* @var WP_Rewrite $wp_rewrite
|
61 |
+
*/
|
62 |
+
global $wp_rewrite;
|
63 |
|
64 |
if ( ! $wp_rewrite->permalink_structure ) {
|
65 |
return $post_link;
|
66 |
}
|
67 |
|
68 |
$draft_or_pending = isset( $post->post_status ) && in_array( $post->post_status, array(
|
69 |
+
'draft',
|
70 |
+
'pending',
|
71 |
+
'auto-draft',
|
72 |
+
), true );
|
73 |
+
if ( $draft_or_pending && ! $leavename ) {
|
74 |
return $post_link;
|
75 |
}
|
76 |
|
105 |
}
|
106 |
|
107 |
// %post_id%/attachment/%attachement_name%;
|
108 |
+
$id = filter_input( INPUT_GET, 'post' );
|
109 |
+
if ( null !== $id && $post->ID !== $id ) {
|
110 |
$parent_structure = trim( CPTP_Util::get_permalink_structure( $post->post_type ), '/' );
|
111 |
$parent_dirs = explode( '/', $parent_structure );
|
112 |
if ( is_array( $parent_dirs ) ) {
|
115 |
$last_dir = $parent_dirs;
|
116 |
}
|
117 |
|
118 |
+
if ( '%post_id%' === $parent_structure || '%post_id%' === $last_dir ) {
|
119 |
$permalink = $permalink . '/attachment/';
|
120 |
}
|
121 |
}
|
137 |
$category_object = apply_filters( 'post_link_category', $categories[0], $categories, $post );
|
138 |
$category_object = get_term( $category_object, 'category' );
|
139 |
$category = $category_object->slug;
|
140 |
+
if ( $category_object->parent ) {
|
141 |
+
$parent = $category_object->parent;
|
142 |
$category = get_category_parents( $parent, false, '/', true ) . $category;
|
143 |
}
|
144 |
}
|
145 |
// show default category in permalinks, without
|
146 |
+
// having to assign it explicitly.
|
147 |
if ( empty( $category ) ) {
|
148 |
$default_category = get_term( get_option( 'default_category' ), 'category' );
|
149 |
$category = is_wp_error( $default_category ) ? '' : $default_category->slug;
|
187 |
|
188 |
|
189 |
/**
|
190 |
+
* Create %tax% -> term
|
191 |
*
|
192 |
+
* @param int $post_id post id.
|
193 |
+
* @param string $permalink permalink uri.
|
|
|
|
|
194 |
*
|
195 |
* @return array
|
196 |
*/
|
201 |
$taxonomies = CPTP_Util::get_taxonomies( true );
|
202 |
|
203 |
// %taxnomomy% -> parent/child
|
|
|
204 |
foreach ( $taxonomies as $taxonomy => $objects ) {
|
205 |
|
206 |
if ( false !== strpos( $permalink, '%' . $taxonomy . '%' ) ) {
|
207 |
$terms = get_the_terms( $post_id, $taxonomy );
|
208 |
|
209 |
+
if ( $terms && ! is_wp_error( $terms ) ) {
|
210 |
+
$parents = array_map( array( __CLASS__, 'get_term_parent' ), $terms );
|
211 |
$newTerms = array();
|
212 |
foreach ( $terms as $key => $term ) {
|
213 |
+
if ( ! in_array( $term->term_id, $parents , true ) ) {
|
214 |
$newTerms[] = $term;
|
215 |
}
|
216 |
}
|
217 |
|
218 |
+
$term_obj = reset( $newTerms );
|
|
|
219 |
$term_slug = $term_obj->slug;
|
220 |
|
221 |
+
if ( isset( $term_obj->parent ) && $term_obj->parent ) {
|
222 |
$term_slug = CPTP_Util::get_taxonomy_parents_slug( $term_obj->parent, $taxonomy, '/', true ) . $term_slug;
|
223 |
}
|
224 |
}
|
230 |
}
|
231 |
}
|
232 |
|
233 |
+
return array(
|
234 |
+
'search' => $search,
|
235 |
+
'replace' => $replace,
|
236 |
+
);
|
237 |
}
|
238 |
|
239 |
/**
|
240 |
+
* Get parent from term Object
|
241 |
*
|
242 |
+
* @param WP_Term $term Term Object.
|
|
|
|
|
243 |
*
|
244 |
* @return mixed
|
245 |
*/
|
246 |
private static function get_term_parent( $term ) {
|
247 |
+
if ( isset( $term->parent ) && $term->parent > 0 ) {
|
248 |
return $term->parent;
|
249 |
}
|
250 |
}
|
251 |
|
252 |
|
253 |
/**
|
254 |
+
* Fix attachment output
|
|
|
255 |
*
|
256 |
* @version 1.0
|
257 |
* @since 0.8.2
|
258 |
*
|
259 |
+
* @param string $link permalink URI.
|
260 |
+
* @param int $post_id Post ID.
|
261 |
*
|
262 |
* @return string
|
263 |
*/
|
|
|
264 |
public function attachment_link( $link, $post_id ) {
|
265 |
+
/**
|
266 |
+
* WP_Rewrite.
|
267 |
+
*
|
268 |
+
* @var WP_Rewrite $wp_rewrite
|
269 |
+
*/
|
270 |
global $wp_rewrite;
|
271 |
|
272 |
if ( ! $wp_rewrite->permalink_structure ) {
|
303 |
}
|
304 |
|
305 |
/**
|
|
|
306 |
* Fix taxonomy link outputs.
|
307 |
*
|
308 |
* @since 0.6
|
309 |
* @version 1.0
|
310 |
*
|
311 |
+
* @param string $termlink link URI.
|
312 |
+
* @param Object $term Term Object.
|
313 |
+
* @param Object $taxonomy Taxonomy Object.
|
314 |
*
|
315 |
* @return string
|
316 |
*/
|
317 |
public function term_link( $termlink, $term, $taxonomy ) {
|
318 |
+
/**
|
319 |
+
* WP_Rewrite.
|
320 |
+
*
|
321 |
+
* @var WP_Rewrite $wp_rewrite
|
322 |
+
*/
|
323 |
global $wp_rewrite;
|
324 |
|
325 |
if ( ! $wp_rewrite->permalink_structure ) {
|
341 |
|
342 |
$wp_home = rtrim( home_url(), '/' );
|
343 |
|
344 |
+
if ( in_array( get_post_type(), $taxonomy->object_type, true ) ) {
|
345 |
$post_type = get_post_type();
|
346 |
} else {
|
347 |
$post_type = $taxonomy->object_type[0];
|
CPTP/Module/Rewrite.php
CHANGED
@@ -1,42 +1,47 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
|
4 |
/**
|
5 |
-
*
|
6 |
* Add Rewrite Rules
|
7 |
*
|
8 |
* @package Custom_Post_Type_Permalinks
|
|
|
|
|
|
|
|
|
|
|
9 |
* @version 1.0.3
|
10 |
* @since 0.9.4
|
11 |
* */
|
12 |
class CPTP_Module_Rewrite extends CPTP_Module {
|
13 |
|
14 |
-
|
|
|
|
|
15 |
public function add_hook() {
|
16 |
add_action( 'parse_request', array( $this, 'parse_request' ) );
|
17 |
add_action( 'registered_post_type', array( $this, 'register_post_type_rules' ), 10, 2 );
|
18 |
add_action( 'registered_taxonomy', array( $this, 'register_taxonomy_rules' ), 10, 3 );
|
19 |
}
|
20 |
|
21 |
-
|
22 |
/**
|
23 |
-
*
|
24 |
-
*
|
25 |
-
* ** add rewrite tag for Custom Post Type.
|
26 |
*
|
27 |
* @version 1.1
|
28 |
* @since 0.9
|
29 |
*
|
30 |
-
* @param string
|
31 |
-
* @param
|
32 |
*/
|
33 |
-
|
34 |
public function register_post_type_rules( $post_type, $args ) {
|
35 |
|
36 |
-
/**
|
|
|
|
|
|
|
|
|
37 |
global $wp_rewrite;
|
38 |
|
39 |
-
if ( $args->_builtin
|
40 |
return;
|
41 |
}
|
42 |
|
@@ -62,7 +67,9 @@ class CPTP_Module_Rewrite extends CPTP_Module {
|
|
62 |
|
63 |
$rewrite_args = $args->rewrite;
|
64 |
if ( ! is_array( $rewrite_args ) ) {
|
65 |
-
$rewrite_args = array(
|
|
|
|
|
66 |
}
|
67 |
|
68 |
$slug = $args->rewrite['slug'];
|
@@ -92,7 +99,7 @@ class CPTP_Module_Rewrite extends CPTP_Module {
|
|
92 |
add_rewrite_rule( $slug . '/author/([^/]+)/page/?([0-9]{1,})/?$', 'index.php?author_name=$matches[1]&paged=$matches[2]&post_type=' . $post_type, 'top' );
|
93 |
add_rewrite_rule( $slug . '/author/([^/]+)/?$', 'index.php?author_name=$matches[1]&post_type=' . $post_type, 'top' );
|
94 |
|
95 |
-
if ( in_array( 'category', $args->taxonomies ) ) {
|
96 |
|
97 |
$category_base = get_option( 'category_base' );
|
98 |
if ( ! $category_base ) {
|
@@ -114,12 +121,11 @@ class CPTP_Module_Rewrite extends CPTP_Module {
|
|
114 |
|
115 |
|
116 |
/**
|
|
|
117 |
*
|
118 |
-
*
|
119 |
-
*
|
120 |
-
* @param
|
121 |
-
* @param array|string $object_type
|
122 |
-
* @param array|WP_Taxonomy $args
|
123 |
*
|
124 |
* @return void
|
125 |
*/
|
@@ -158,11 +164,12 @@ class CPTP_Module_Rewrite extends CPTP_Module {
|
|
158 |
$slug = substr( $wp_rewrite->front, 1 ) . $slug;
|
159 |
}
|
160 |
|
161 |
-
if ( 'category'
|
162 |
-
$
|
|
|
163 |
$taxonomy_key = 'category_name';
|
164 |
} else {
|
165 |
-
// Edit by [Xiphe]
|
166 |
if ( isset( $args['rewrite']['slug'] ) ) {
|
167 |
$taxonomy_slug = $args['rewrite']['slug'];
|
168 |
} else {
|
@@ -182,7 +189,7 @@ class CPTP_Module_Rewrite extends CPTP_Module {
|
|
182 |
'regex' => '%s/(.+?)/(feed|rdf|rss|rss2|atom)/?$',
|
183 |
'redirect' => "index.php?{$taxonomy_key}=\$matches[1]&feed=\$matches[2]",
|
184 |
),
|
185 |
-
// year
|
186 |
array(
|
187 |
'regex' => '%s/(.+?)/date/([0-9]{4})/?$',
|
188 |
'redirect' => "index.php?{$taxonomy_key}=\$matches[1]&year=\$matches[2]",
|
@@ -191,7 +198,7 @@ class CPTP_Module_Rewrite extends CPTP_Module {
|
|
191 |
'regex' => '%s/(.+?)/date/([0-9]{4})/page/?([0-9]{1,})/?$',
|
192 |
'redirect' => "index.php?{$taxonomy_key}=\$matches[1]&year=\$matches[2]&paged=\$matches[3]",
|
193 |
),
|
194 |
-
// monthnum
|
195 |
array(
|
196 |
'regex' => '%s/(.+?)/date/([0-9]{4})/([0-9]{1,2})/?$',
|
197 |
'redirect' => "index.php?{$taxonomy_key}=\$matches[1]&year=\$matches[2]&monthnum=\$matches[3]",
|
@@ -200,7 +207,7 @@ class CPTP_Module_Rewrite extends CPTP_Module {
|
|
200 |
'regex' => '%s/(.+?)/date/([0-9]{4})/([0-9]{1,2})/page/?([0-9]{1,})/?$',
|
201 |
'redirect' => "index.php?{$taxonomy_key}=\$matches[1]&year=\$matches[2]&monthnum=\$matches[3]&paged=\$matches[4]",
|
202 |
),
|
203 |
-
// day
|
204 |
array(
|
205 |
'regex' => '%s/(.+?)/date/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?$',
|
206 |
'redirect' => "index.php?{$taxonomy_key}=\$matches[1]&year=\$matches[2]&monthnum=\$matches[3]&day=\$matches[4]",
|
@@ -209,7 +216,7 @@ class CPTP_Module_Rewrite extends CPTP_Module {
|
|
209 |
'regex' => '%s/(.+?)/date/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/page/?([0-9]{1,})/?$',
|
210 |
'redirect' => "index.php?{$taxonomy_key}=\$matches[1]&year=\$matches[2]&monthnum=\$matches[3]&day=\$matches[4]&paged=\$matches[5]",
|
211 |
),
|
212 |
-
// paging
|
213 |
array(
|
214 |
'regex' => '%s/(.+?)/page/?([0-9]{1,})/?$',
|
215 |
'redirect' => "index.php?{$taxonomy_key}=\$matches[1]&paged=\$matches[2]",
|
@@ -254,12 +261,12 @@ class CPTP_Module_Rewrite extends CPTP_Module {
|
|
254 |
*
|
255 |
* @since 0.9.3
|
256 |
*
|
257 |
-
* @param WP $obj
|
258 |
*/
|
259 |
public function parse_request( $obj ) {
|
260 |
$taxes = CPTP_Util::get_taxonomies();
|
261 |
foreach ( $taxes as $key => $tax ) {
|
262 |
-
if ( isset( $obj->query_vars[ $tax ] )
|
263 |
if ( false !== strpos( $obj->query_vars[ $tax ], '/' ) ) {
|
264 |
$query_vars = explode( '/', $obj->query_vars[ $tax ] );
|
265 |
if ( is_array( $query_vars ) ) {
|
1 |
<?php
|
|
|
|
|
2 |
/**
|
|
|
3 |
* Add Rewrite Rules
|
4 |
*
|
5 |
* @package Custom_Post_Type_Permalinks
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Add CPTP_Module_Rewrite Rules
|
10 |
+
*
|
11 |
* @version 1.0.3
|
12 |
* @since 0.9.4
|
13 |
* */
|
14 |
class CPTP_Module_Rewrite extends CPTP_Module {
|
15 |
|
16 |
+
/**
|
17 |
+
* Add Actions.
|
18 |
+
*/
|
19 |
public function add_hook() {
|
20 |
add_action( 'parse_request', array( $this, 'parse_request' ) );
|
21 |
add_action( 'registered_post_type', array( $this, 'register_post_type_rules' ), 10, 2 );
|
22 |
add_action( 'registered_taxonomy', array( $this, 'register_taxonomy_rules' ), 10, 3 );
|
23 |
}
|
24 |
|
|
|
25 |
/**
|
26 |
+
* Register_post_type_rules
|
27 |
+
* add rewrite tag for Custom Post Type.
|
|
|
28 |
*
|
29 |
* @version 1.1
|
30 |
* @since 0.9
|
31 |
*
|
32 |
+
* @param string $post_type Post type.
|
33 |
+
* @param WP_Post_Type $args Arguments used to register the post type.
|
34 |
*/
|
|
|
35 |
public function register_post_type_rules( $post_type, $args ) {
|
36 |
|
37 |
+
/**
|
38 |
+
* WP_Rewrite.
|
39 |
+
*
|
40 |
+
* @var WP_Rewrite $wp_rewrite
|
41 |
+
*/
|
42 |
global $wp_rewrite;
|
43 |
|
44 |
+
if ( $args->_builtin || ! $args->publicly_queryable ) {
|
45 |
return;
|
46 |
}
|
47 |
|
67 |
|
68 |
$rewrite_args = $args->rewrite;
|
69 |
if ( ! is_array( $rewrite_args ) ) {
|
70 |
+
$rewrite_args = array(
|
71 |
+
'with_front' => $args->rewrite,
|
72 |
+
);
|
73 |
}
|
74 |
|
75 |
$slug = $args->rewrite['slug'];
|
99 |
add_rewrite_rule( $slug . '/author/([^/]+)/page/?([0-9]{1,})/?$', 'index.php?author_name=$matches[1]&paged=$matches[2]&post_type=' . $post_type, 'top' );
|
100 |
add_rewrite_rule( $slug . '/author/([^/]+)/?$', 'index.php?author_name=$matches[1]&post_type=' . $post_type, 'top' );
|
101 |
|
102 |
+
if ( in_array( 'category', $args->taxonomies, true ) ) {
|
103 |
|
104 |
$category_base = get_option( 'category_base' );
|
105 |
if ( ! $category_base ) {
|
121 |
|
122 |
|
123 |
/**
|
124 |
+
* Register_taxonomy_rules
|
125 |
*
|
126 |
+
* @param string $taxonomy Taxonomy slug.
|
127 |
+
* @param array|string $object_type Object type or array of object types.
|
128 |
+
* @param array $args Array of taxonomy registration arguments.
|
|
|
|
|
129 |
*
|
130 |
* @return void
|
131 |
*/
|
164 |
$slug = substr( $wp_rewrite->front, 1 ) . $slug;
|
165 |
}
|
166 |
|
167 |
+
if ( 'category' === $taxonomy ) {
|
168 |
+
$cb = get_option( 'category_base' );
|
169 |
+
$taxonomy_slug = ( $cb ) ? $cb : $taxonomy;
|
170 |
$taxonomy_key = 'category_name';
|
171 |
} else {
|
172 |
+
// Edit by [Xiphe].
|
173 |
if ( isset( $args['rewrite']['slug'] ) ) {
|
174 |
$taxonomy_slug = $args['rewrite']['slug'];
|
175 |
} else {
|
189 |
'regex' => '%s/(.+?)/(feed|rdf|rss|rss2|atom)/?$',
|
190 |
'redirect' => "index.php?{$taxonomy_key}=\$matches[1]&feed=\$matches[2]",
|
191 |
),
|
192 |
+
// year.
|
193 |
array(
|
194 |
'regex' => '%s/(.+?)/date/([0-9]{4})/?$',
|
195 |
'redirect' => "index.php?{$taxonomy_key}=\$matches[1]&year=\$matches[2]",
|
198 |
'regex' => '%s/(.+?)/date/([0-9]{4})/page/?([0-9]{1,})/?$',
|
199 |
'redirect' => "index.php?{$taxonomy_key}=\$matches[1]&year=\$matches[2]&paged=\$matches[3]",
|
200 |
),
|
201 |
+
// monthnum.
|
202 |
array(
|
203 |
'regex' => '%s/(.+?)/date/([0-9]{4})/([0-9]{1,2})/?$',
|
204 |
'redirect' => "index.php?{$taxonomy_key}=\$matches[1]&year=\$matches[2]&monthnum=\$matches[3]",
|
207 |
'regex' => '%s/(.+?)/date/([0-9]{4})/([0-9]{1,2})/page/?([0-9]{1,})/?$',
|
208 |
'redirect' => "index.php?{$taxonomy_key}=\$matches[1]&year=\$matches[2]&monthnum=\$matches[3]&paged=\$matches[4]",
|
209 |
),
|
210 |
+
// day.
|
211 |
array(
|
212 |
'regex' => '%s/(.+?)/date/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?$',
|
213 |
'redirect' => "index.php?{$taxonomy_key}=\$matches[1]&year=\$matches[2]&monthnum=\$matches[3]&day=\$matches[4]",
|
216 |
'regex' => '%s/(.+?)/date/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/page/?([0-9]{1,})/?$',
|
217 |
'redirect' => "index.php?{$taxonomy_key}=\$matches[1]&year=\$matches[2]&monthnum=\$matches[3]&day=\$matches[4]&paged=\$matches[5]",
|
218 |
),
|
219 |
+
// paging.
|
220 |
array(
|
221 |
'regex' => '%s/(.+?)/page/?([0-9]{1,})/?$',
|
222 |
'redirect' => "index.php?{$taxonomy_key}=\$matches[1]&paged=\$matches[2]",
|
261 |
*
|
262 |
* @since 0.9.3
|
263 |
*
|
264 |
+
* @param WP $obj WP instance.
|
265 |
*/
|
266 |
public function parse_request( $obj ) {
|
267 |
$taxes = CPTP_Util::get_taxonomies();
|
268 |
foreach ( $taxes as $key => $tax ) {
|
269 |
+
if ( isset( $obj->query_vars[ $tax ] ) && is_string( $obj->query_vars[ $tax ] ) ) {
|
270 |
if ( false !== strpos( $obj->query_vars[ $tax ], '/' ) ) {
|
271 |
$query_vars = explode( '/', $obj->query_vars[ $tax ] );
|
272 |
if ( is_array( $query_vars ) ) {
|
CPTP/Module/Setting.php
CHANGED
@@ -1,15 +1,20 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
|
4 |
/**
|
|
|
5 |
*
|
|
|
|
|
|
|
|
|
6 |
* For load plugin.
|
7 |
*
|
8 |
-
* @package Custom_Post_Type_Permalinks
|
9 |
* @since 0.9.4
|
10 |
* */
|
11 |
class CPTP_Module_Setting extends CPTP_Module {
|
12 |
|
|
|
|
|
|
|
13 |
public function add_hook() {
|
14 |
$this->update_version();
|
15 |
add_action( 'init', array( $this, 'load_textdomain' ) );
|
@@ -17,11 +22,10 @@ class CPTP_Module_Setting extends CPTP_Module {
|
|
17 |
}
|
18 |
|
19 |
/**
|
20 |
-
*
|
21 |
*
|
22 |
* @since 0.8.6
|
23 |
*/
|
24 |
-
|
25 |
public function update_version() {
|
26 |
update_option( 'cptp_version', CPTP_VERSION );
|
27 |
}
|
@@ -32,7 +36,7 @@ class CPTP_Module_Setting extends CPTP_Module {
|
|
32 |
* @since 3.0.0
|
33 |
*
|
34 |
* @param object $wp_upgrader WP_Upgrader instance.
|
35 |
-
* @param array
|
36 |
*/
|
37 |
public function upgrader_process_complete( $wp_upgrader, $options ) {
|
38 |
|
@@ -44,17 +48,17 @@ class CPTP_Module_Setting extends CPTP_Module {
|
|
44 |
return;
|
45 |
}
|
46 |
|
47 |
-
if ( 'update'
|
48 |
$plugin_path = plugin_basename( CPTP_PLUGIN_FILE );
|
49 |
-
if ( in_array( $plugin_path, $options['plugins'] ) ) {
|
50 |
-
//for update code.
|
51 |
add_option( 'no_taxonomy_structure', false );
|
52 |
}
|
53 |
}
|
54 |
}
|
55 |
|
56 |
/**
|
57 |
-
*
|
58 |
*
|
59 |
* @since 0.6.2
|
60 |
*/
|
1 |
<?php
|
|
|
|
|
2 |
/**
|
3 |
+
* Management Setting.
|
4 |
*
|
5 |
+
* @package Custom_Post_Type_Permalinks
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
* For load plugin.
|
10 |
*
|
|
|
11 |
* @since 0.9.4
|
12 |
* */
|
13 |
class CPTP_Module_Setting extends CPTP_Module {
|
14 |
|
15 |
+
/**
|
16 |
+
* Module hooks.
|
17 |
+
*/
|
18 |
public function add_hook() {
|
19 |
$this->update_version();
|
20 |
add_action( 'init', array( $this, 'load_textdomain' ) );
|
22 |
}
|
23 |
|
24 |
/**
|
25 |
+
* Save CPTP version.
|
26 |
*
|
27 |
* @since 0.8.6
|
28 |
*/
|
|
|
29 |
public function update_version() {
|
30 |
update_option( 'cptp_version', CPTP_VERSION );
|
31 |
}
|
36 |
* @since 3.0.0
|
37 |
*
|
38 |
* @param object $wp_upgrader WP_Upgrader instance.
|
39 |
+
* @param array $options Extra information about performed upgrade.
|
40 |
*/
|
41 |
public function upgrader_process_complete( $wp_upgrader, $options ) {
|
42 |
|
48 |
return;
|
49 |
}
|
50 |
|
51 |
+
if ( 'update' === $options['action'] && 'plugin' === $options['type'] ) {
|
52 |
$plugin_path = plugin_basename( CPTP_PLUGIN_FILE );
|
53 |
+
if ( in_array( $plugin_path, $options['plugins'], true ) ) {
|
54 |
+
// for update code.
|
55 |
add_option( 'no_taxonomy_structure', false );
|
56 |
}
|
57 |
}
|
58 |
}
|
59 |
|
60 |
/**
|
61 |
+
* Load textdomain
|
62 |
*
|
63 |
* @since 0.6.2
|
64 |
*/
|
CPTP/Util.php
CHANGED
@@ -1,29 +1,46 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
*
|
5 |
-
* Utilty Class
|
6 |
*
|
7 |
* @package Custom_Post_Type_Permalinks
|
|
|
|
|
|
|
|
|
|
|
8 |
* @since 0.9.4
|
9 |
* */
|
10 |
class CPTP_Util {
|
11 |
|
|
|
|
|
|
|
|
|
|
|
12 |
private function __construct() {
|
13 |
}
|
14 |
|
15 |
/**
|
|
|
|
|
16 |
* @return array
|
17 |
*/
|
18 |
public static function get_post_types() {
|
19 |
-
$
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
return array_filter( $post_type, array( __CLASS__, 'is_post_type_support_rewrite' ) );
|
22 |
|
23 |
}
|
24 |
|
25 |
/**
|
26 |
-
*
|
|
|
|
|
27 |
*
|
28 |
* @return bool
|
29 |
*/
|
@@ -37,7 +54,9 @@ class CPTP_Util {
|
|
37 |
}
|
38 |
|
39 |
/**
|
40 |
-
*
|
|
|
|
|
41 |
*
|
42 |
* @return array
|
43 |
*/
|
@@ -48,21 +67,22 @@ class CPTP_Util {
|
|
48 |
$output = 'names';
|
49 |
}
|
50 |
|
51 |
-
return get_taxonomies( array(
|
|
|
|
|
|
|
52 |
}
|
53 |
|
54 |
-
|
55 |
/**
|
56 |
-
*
|
57 |
* Get Custom Taxonomies parents slug.
|
58 |
*
|
59 |
* @version 1.0
|
60 |
*
|
61 |
-
* @param int|WP_Term|object $term
|
62 |
-
* @param string
|
63 |
-
* @param string
|
64 |
-
* @param bool
|
65 |
-
* @param array
|
66 |
*
|
67 |
* @return string
|
68 |
*/
|
@@ -79,9 +99,9 @@ class CPTP_Util {
|
|
79 |
$name = $parent->name;
|
80 |
}
|
81 |
|
82 |
-
if ( $parent->parent && ( $parent->parent
|
83 |
$visited[] = $parent->parent;
|
84 |
-
$chain
|
85 |
}
|
86 |
$chain .= $name . $separator;
|
87 |
|
@@ -89,17 +109,16 @@ class CPTP_Util {
|
|
89 |
}
|
90 |
|
91 |
/**
|
92 |
-
*
|
93 |
* Get Custom Taxonomies parents.
|
94 |
*
|
95 |
* @deprecated
|
96 |
*
|
97 |
-
* @param int|WP_Term|object $term
|
98 |
-
* @param string
|
99 |
-
* @param bool
|
100 |
-
* @param string
|
101 |
-
* @param bool
|
102 |
-
* @param array
|
103 |
*
|
104 |
* @return string
|
105 |
*/
|
@@ -118,7 +137,7 @@ class CPTP_Util {
|
|
118 |
|
119 |
if ( $parent->parent && ( $parent->parent != $parent->term_id ) && ! in_array( $parent->parent, $visited ) ) {
|
120 |
$visited[] = $parent->parent;
|
121 |
-
$chain
|
122 |
}
|
123 |
if ( $link ) {
|
124 |
$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 );
|
@@ -173,7 +192,7 @@ class CPTP_Util {
|
|
173 |
preg_match_all( '/%.+?%/', $structure, $tokens );
|
174 |
$tok_index = 1;
|
175 |
foreach ( (array) $tokens[0] as $token ) {
|
176 |
-
if ( '%post_id%'
|
177 |
$front = '/date';
|
178 |
break;
|
179 |
}
|
@@ -198,9 +217,9 @@ class CPTP_Util {
|
|
198 |
*
|
199 |
* @since 3.1.0
|
200 |
*
|
201 |
-
* @param WP_Term[]
|
202 |
-
* @param string|array $orderby
|
203 |
-
* @param string
|
204 |
*
|
205 |
* @return WP_Term[]
|
206 |
*/
|
@@ -210,13 +229,13 @@ class CPTP_Util {
|
|
210 |
$terms = wp_list_sort( $terms, 'term_id', 'ASC' );
|
211 |
} else {
|
212 |
|
213 |
-
if ( 'name'
|
214 |
usort( $terms, '_usort_terms_by_name' );
|
215 |
} else {
|
216 |
usort( $terms, '_usort_terms_by_ID' );
|
217 |
}
|
218 |
|
219 |
-
if ( 'DESC'
|
220 |
$terms = array_reverse( $terms );
|
221 |
}
|
222 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* Utility
|
|
|
4 |
*
|
5 |
* @package Custom_Post_Type_Permalinks
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Utility methods.
|
10 |
+
*
|
11 |
* @since 0.9.4
|
12 |
* */
|
13 |
class CPTP_Util {
|
14 |
|
15 |
+
/**
|
16 |
+
* CPTP_Util constructor.
|
17 |
+
*
|
18 |
+
* @private
|
19 |
+
*/
|
20 |
private function __construct() {
|
21 |
}
|
22 |
|
23 |
/**
|
24 |
+
* Get filtered post type.
|
25 |
+
*
|
26 |
* @return array
|
27 |
*/
|
28 |
public static function get_post_types() {
|
29 |
+
$param = array(
|
30 |
+
'_builtin' => false,
|
31 |
+
'publicly_queryable' => true,
|
32 |
+
'show_ui' => true,
|
33 |
+
);
|
34 |
+
$post_type = get_post_types( $param );
|
35 |
|
36 |
return array_filter( $post_type, array( __CLASS__, 'is_post_type_support_rewrite' ) );
|
37 |
|
38 |
}
|
39 |
|
40 |
/**
|
41 |
+
* Check post type support rewrite.
|
42 |
+
*
|
43 |
+
* @param string $post_type post_type name.
|
44 |
*
|
45 |
* @return bool
|
46 |
*/
|
54 |
}
|
55 |
|
56 |
/**
|
57 |
+
* Get taxonomies.
|
58 |
+
*
|
59 |
+
* @param bool $objects object or name.
|
60 |
*
|
61 |
* @return array
|
62 |
*/
|
67 |
$output = 'names';
|
68 |
}
|
69 |
|
70 |
+
return get_taxonomies( array(
|
71 |
+
'show_ui' => true,
|
72 |
+
'_builtin' => false,
|
73 |
+
), $output );
|
74 |
}
|
75 |
|
|
|
76 |
/**
|
|
|
77 |
* Get Custom Taxonomies parents slug.
|
78 |
*
|
79 |
* @version 1.0
|
80 |
*
|
81 |
+
* @param int|WP_Term|object $term Target term.
|
82 |
+
* @param string $taxonomy Taxonomy name.
|
83 |
+
* @param string $separator separater string.
|
84 |
+
* @param bool $nicename use slug or name.
|
85 |
+
* @param array $visited visited parent slug.
|
86 |
*
|
87 |
* @return string
|
88 |
*/
|
99 |
$name = $parent->name;
|
100 |
}
|
101 |
|
102 |
+
if ( $parent->parent && ( $parent->parent !== $parent->term_id ) && ! in_array( $parent->parent, $visited, true ) ) {
|
103 |
$visited[] = $parent->parent;
|
104 |
+
$chain .= CPTP_Util::get_taxonomy_parents_slug( $parent->parent, $taxonomy, $separator, $nicename, $visited );
|
105 |
}
|
106 |
$chain .= $name . $separator;
|
107 |
|
109 |
}
|
110 |
|
111 |
/**
|
|
|
112 |
* Get Custom Taxonomies parents.
|
113 |
*
|
114 |
* @deprecated
|
115 |
*
|
116 |
+
* @param int|WP_Term|object $term term.
|
117 |
+
* @param string $taxonomy taxonomy.
|
118 |
+
* @param bool $link show link html.
|
119 |
+
* @param string $separator separator string.
|
120 |
+
* @param bool $nicename use slug or name.
|
121 |
+
* @param array $visited visited term.
|
122 |
*
|
123 |
* @return string
|
124 |
*/
|
137 |
|
138 |
if ( $parent->parent && ( $parent->parent != $parent->term_id ) && ! in_array( $parent->parent, $visited ) ) {
|
139 |
$visited[] = $parent->parent;
|
140 |
+
$chain .= CPTP_Util::get_taxonomy_parents( $parent->parent, $taxonomy, $link, $separator, $nicename, $visited );
|
141 |
}
|
142 |
if ( $link ) {
|
143 |
$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 );
|
192 |
preg_match_all( '/%.+?%/', $structure, $tokens );
|
193 |
$tok_index = 1;
|
194 |
foreach ( (array) $tokens[0] as $token ) {
|
195 |
+
if ( '%post_id%' === $token && ( $tok_index <= 3 ) ) {
|
196 |
$front = '/date';
|
197 |
break;
|
198 |
}
|
217 |
*
|
218 |
* @since 3.1.0
|
219 |
*
|
220 |
+
* @param WP_Term[] $terms Terms array.
|
221 |
+
* @param string|array $orderby term object key.
|
222 |
+
* @param string $order ASC or DESC.
|
223 |
*
|
224 |
* @return WP_Term[]
|
225 |
*/
|
229 |
$terms = wp_list_sort( $terms, 'term_id', 'ASC' );
|
230 |
} else {
|
231 |
|
232 |
+
if ( 'name' === $orderby ) {
|
233 |
usort( $terms, '_usort_terms_by_name' );
|
234 |
} else {
|
235 |
usort( $terms, '_usort_terms_by_ID' );
|
236 |
}
|
237 |
|
238 |
+
if ( 'DESC' === $order ) {
|
239 |
$terms = array_reverse( $terms );
|
240 |
}
|
241 |
}
|
circle.yml
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
## Customize the test machine
|
2 |
machine:
|
3 |
-
|
|
|
4 |
# Override /etc/hosts
|
5 |
|
6 |
# Add some environment variables
|
1 |
## Customize the test machine
|
2 |
machine:
|
3 |
+
php:
|
4 |
+
version: 7.0.0
|
5 |
# Override /etc/hosts
|
6 |
|
7 |
# Add some environment variables
|
codesniffer.ruleset.xml
CHANGED
@@ -6,9 +6,7 @@
|
|
6 |
<rule ref="WordPress">
|
7 |
<exclude name="Generic.WhiteSpace.ScopeIndent.IncorrectExact" />
|
8 |
<exclude name="Generic.WhiteSpace.ScopeIndent.Incorrect" />
|
9 |
-
<exclude name="WordPress.VIP" />
|
10 |
-
<exclude name="Squiz.Commenting" />
|
11 |
-
<exclude name="Generic.Commenting" />
|
12 |
<exclude name="Generic.Files.LowercasedFilename" />
|
13 |
<exclude name="WordPress.NamingConventions" />
|
14 |
</rule>
|
6 |
<rule ref="WordPress">
|
7 |
<exclude name="Generic.WhiteSpace.ScopeIndent.IncorrectExact" />
|
8 |
<exclude name="Generic.WhiteSpace.ScopeIndent.Incorrect" />
|
9 |
+
<exclude name="WordPress.VIP.RestrictedFunctions" />
|
|
|
|
|
10 |
<exclude name="Generic.Files.LowercasedFilename" />
|
11 |
<exclude name="WordPress.NamingConventions" />
|
12 |
</rule>
|
composer.json
CHANGED
@@ -16,13 +16,13 @@
|
|
16 |
},
|
17 |
"scripts": {
|
18 |
"post-install-cmd": [
|
19 |
-
"php vendor/bin/phpcs --config-set installed_paths vendor/wp-coding-standards/wpcs/"
|
20 |
],
|
21 |
"post-update-cmd": [
|
22 |
-
"php vendor/bin/phpcs --config-set installed_paths vendor/wp-coding-standards/wpcs/"
|
23 |
],
|
24 |
"phpcs": [
|
25 |
-
"php vendor/bin/phpcs -p -s -v -n . --standard=./codesniffer.ruleset.xml --extensions=php"
|
26 |
]
|
27 |
}
|
28 |
}
|
16 |
},
|
17 |
"scripts": {
|
18 |
"post-install-cmd": [
|
19 |
+
"@php vendor/bin/phpcs --config-set installed_paths vendor/wp-coding-standards/wpcs/"
|
20 |
],
|
21 |
"post-update-cmd": [
|
22 |
+
"@php vendor/bin/phpcs --config-set installed_paths vendor/wp-coding-standards/wpcs/"
|
23 |
],
|
24 |
"phpcs": [
|
25 |
+
"@php vendor/bin/phpcs -p -s -v -n . --standard=./codesniffer.ruleset.xml --extensions=php"
|
26 |
]
|
27 |
}
|
28 |
}
|
custom-post-type-permalinks.php
CHANGED
@@ -5,13 +5,13 @@
|
|
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.1.
|
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.1.
|
15 |
*/
|
16 |
|
17 |
define( 'CPTP_PLUGIN_FILE', __FILE__ );
|
@@ -38,6 +38,8 @@ define( 'CPTP_TEXT_DOMAIN', $cptp_data['TextDomain'] );
|
|
38 |
* Autoloader for CPTP.
|
39 |
*
|
40 |
* @since 1.0.0
|
|
|
|
|
41 |
*/
|
42 |
function cptp_class_loader( $class_name ) {
|
43 |
$dir = dirname( __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: 3.1.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.1.4
|
15 |
*/
|
16 |
|
17 |
define( 'CPTP_PLUGIN_FILE', __FILE__ );
|
38 |
* Autoloader for CPTP.
|
39 |
*
|
40 |
* @since 1.0.0
|
41 |
+
*
|
42 |
+
* @param string $class_name class name.
|
43 |
*/
|
44 |
function cptp_class_loader( $class_name ) {
|
45 |
$dir = dirname( __FILE__ );
|
readme.md
CHANGED
@@ -12,7 +12,7 @@ Edit the permalink of custom post type.
|
|
12 |
[![Build Status](https://travis-ci.org/torounit/custom-post-type-permalinks.svg)](https://travis-ci.org/torounit/custom-post-type-permalinks)
|
13 |
[![Donation](https://img.shields.io/badge/bitcoin-donate-yellow.svg)](https://blockchain.info/ja/address/3HwkojX2pd9wc5kPFdXnDXMTNbgBmPRygX)
|
14 |
[![Gratipay](https://img.shields.io/gratipay/team/custom-post-type-permalinks.svg)](https://gratipay.com/Custom-Post-Type-Permalinks/)
|
15 |
-
[![](https://
|
16 |
|
17 |
## Description
|
18 |
|
12 |
[![Build Status](https://travis-ci.org/torounit/custom-post-type-permalinks.svg)](https://travis-ci.org/torounit/custom-post-type-permalinks)
|
13 |
[![Donation](https://img.shields.io/badge/bitcoin-donate-yellow.svg)](https://blockchain.info/ja/address/3HwkojX2pd9wc5kPFdXnDXMTNbgBmPRygX)
|
14 |
[![Gratipay](https://img.shields.io/gratipay/team/custom-post-type-permalinks.svg)](https://gratipay.com/Custom-Post-Type-Permalinks/)
|
15 |
+
[![](https://ps.w.org/custom-post-type-permalinks/assets/banner-1544x500.png?rev=1044335)](https://wordpress.org/plugins/custom-post-type-permalinks/)
|
16 |
|
17 |
## Description
|
18 |
|
readme.txt
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
=== Custom Post Type Permalinks ===
|
2 |
Contributors: Toro_Unit,inc2734,ixkaito,keita_kobayashi
|
3 |
-
Donate link: https://
|
4 |
Tags: permalink,permalinks,custom post type,custom taxonomy,cms
|
5 |
Requires at least: 4.3
|
6 |
-
Tested up to: 4.
|
7 |
-
Stable tag:
|
8 |
License: GPLv2 or Later
|
9 |
|
10 |
Edit the permalink of custom post type.
|
@@ -19,7 +19,7 @@ And support wp_get_archives( "post_type=foo" ).
|
|
19 |
|
20 |
[This Plugin published on GitHub.](https://github.com/torounit/custom-post-type-permalinks)
|
21 |
|
22 |
-
Donation: Please send [bitcoin](https://blockchain.info/ja/address/3HwkojX2pd9wc5kPFdXnDXMTNbgBmPRygX) or [My Wishlist](
|
23 |
|
24 |
|
25 |
= Translators =
|
@@ -67,6 +67,10 @@ That's it. You can access the permalinks setting by going to *Settings -> Permal
|
|
67 |
|
68 |
== Changelog ==
|
69 |
|
|
|
|
|
|
|
|
|
70 |
= 3.1.3 =
|
71 |
* Test for WordPress 4.8.
|
72 |
* Bug fix for attachment link.
|
1 |
=== Custom Post Type Permalinks ===
|
2 |
Contributors: Toro_Unit,inc2734,ixkaito,keita_kobayashi
|
3 |
+
Donate link: https://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.9
|
7 |
+
Stable tag: 3.1.4
|
8 |
License: GPLv2 or Later
|
9 |
|
10 |
Edit the permalink of custom post type.
|
19 |
|
20 |
[This Plugin published on GitHub.](https://github.com/torounit/custom-post-type-permalinks)
|
21 |
|
22 |
+
Donation: Please send [bitcoin](https://blockchain.info/ja/address/3HwkojX2pd9wc5kPFdXnDXMTNbgBmPRygX) or [My Wishlist](https://www.amazon.co.jp/registry/wishlist/COKSXS25MVQV)
|
23 |
|
24 |
|
25 |
= Translators =
|
67 |
|
68 |
== Changelog ==
|
69 |
|
70 |
+
= 3.1.4 =
|
71 |
+
* Test for WordPress 4.9.
|
72 |
+
* PHPCS fix.
|
73 |
+
|
74 |
= 3.1.3 =
|
75 |
* Test for WordPress 4.8.
|
76 |
* Bug fix for attachment link.
|