Version Description
- Translate Bug Fix.
Download this release
Release Info
Developer | Toro_Unit |
Plugin | Custom Post Type Permalinks |
Version | 0.8.7 |
Comparing to | |
See all releases |
Code changes from version 0.8.6 to 0.8.7
- cptp-ja.mo +0 -0
- cptp-ja.po +23 -11
- custom-post-type-permalinks.php +99 -64
- readme.txt +3 -1
cptp-ja.mo
CHANGED
Binary file
|
cptp-ja.po
CHANGED
@@ -2,8 +2,8 @@ msgid ""
|
|
2 |
msgstr ""
|
3 |
"Project-Id-Version: Custom Post Type Permalinks\n"
|
4 |
"Report-Msgid-Bugs-To: \n"
|
5 |
-
"POT-Creation-Date: 2012-11-
|
6 |
-
"PO-Revision-Date: 2012-11-
|
7 |
"Last-Translator: Toro_Unit <mail@torounit.com>\n"
|
8 |
"Language-Team: Toro_Unit <mail@torounit.com>\n"
|
9 |
"Language: ja_JP\n"
|
@@ -16,24 +16,24 @@ msgstr ""
|
|
16 |
"X-Generator: Poedit 1.5.4\n"
|
17 |
"X-Poedit-SearchPath-0: custom-post-type-permalinks\n"
|
18 |
|
19 |
-
#: custom-post-type-permalinks/custom-post-type-permalinks.php:
|
20 |
#, php-format
|
21 |
msgid "View all posts in %s"
|
22 |
msgstr "%s のすべての投稿を見る"
|
23 |
|
24 |
-
#: custom-post-type-permalinks/custom-post-type-permalinks.php:
|
25 |
msgid "Permalink Setting for custom post type"
|
26 |
msgstr "カスタム投稿タイプのパーマリンクの設定"
|
27 |
|
28 |
-
#: custom-post-type-permalinks/custom-post-type-permalinks.php:
|
29 |
msgid "Use custom permalink of custom taxonomy archive."
|
30 |
msgstr "カスタム分類のアーカイブのパーマリンクを変更する。"
|
31 |
|
32 |
-
#: custom-post-type-permalinks/custom-post-type-permalinks.php:
|
33 |
msgid "Setting permalinks of custom post type."
|
34 |
msgstr "カスタム投稿タイプごとのパーマリンク構造を設定できます。"
|
35 |
|
36 |
-
#: custom-post-type-permalinks/custom-post-type-permalinks.php:
|
37 |
msgid ""
|
38 |
"The tags you can use is WordPress Structure Tags and '%\"custom_taxonomy_slug"
|
39 |
"\"%'. (e.g. %actors%)"
|
@@ -41,23 +41,23 @@ msgstr ""
|
|
41 |
"使用できるタグは、WordPress標準のタグと '%\"カスタム分類名\"%' です。 (例: "
|
42 |
"%actors%)"
|
43 |
|
44 |
-
#: custom-post-type-permalinks/custom-post-type-permalinks.php:
|
45 |
msgid "%\"custom_taxonomy_slug\"% is replaced the taxonomy's term.'."
|
46 |
msgstr "'%\"カスタム分類名\"%' は、そのカスタム分類のタームに置換されます。"
|
47 |
|
48 |
-
#: custom-post-type-permalinks/custom-post-type-permalinks.php:
|
49 |
msgid ""
|
50 |
"Presence of the trailing '/' is unified into a standard permalink structure "
|
51 |
"setting."
|
52 |
msgstr "末尾の '/' の有無は、標準のパーマリンク構造の設定に統一されます。"
|
53 |
|
54 |
-
#: custom-post-type-permalinks/custom-post-type-permalinks.php:
|
55 |
msgid ""
|
56 |
"If you don't entered permalink structure, permalink is configured /%postname"
|
57 |
"%/'."
|
58 |
msgstr "未入力のときは、/%postname%/ に設定されます。"
|
59 |
|
60 |
-
#: custom-post-type-permalinks/custom-post-type-permalinks.php:
|
61 |
#, php-format
|
62 |
msgid ""
|
63 |
"If you check,The custom taxonomy's permalinks is <code>%s/post_type/taxonomy/"
|
@@ -65,3 +65,15 @@ msgid ""
|
|
65 |
msgstr ""
|
66 |
"チェックした場合、カスタム分類のアーカイブのパーマリンクは <code>%s/"
|
67 |
"post_type/taxonomy/term</code>. に変更されます。"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
msgstr ""
|
3 |
"Project-Id-Version: Custom Post Type Permalinks\n"
|
4 |
"Report-Msgid-Bugs-To: \n"
|
5 |
+
"POT-Creation-Date: 2012-11-28 18:45+0900\n"
|
6 |
+
"PO-Revision-Date: 2012-11-28 18:45+0900\n"
|
7 |
"Last-Translator: Toro_Unit <mail@torounit.com>\n"
|
8 |
"Language-Team: Toro_Unit <mail@torounit.com>\n"
|
9 |
"Language: ja_JP\n"
|
16 |
"X-Generator: Poedit 1.5.4\n"
|
17 |
"X-Poedit-SearchPath-0: custom-post-type-permalinks\n"
|
18 |
|
19 |
+
#: custom-post-type-permalinks/custom-post-type-permalinks.php:108
|
20 |
#, php-format
|
21 |
msgid "View all posts in %s"
|
22 |
msgstr "%s のすべての投稿を見る"
|
23 |
|
24 |
+
#: custom-post-type-permalinks/custom-post-type-permalinks.php:552
|
25 |
msgid "Permalink Setting for custom post type"
|
26 |
msgstr "カスタム投稿タイプのパーマリンクの設定"
|
27 |
|
28 |
+
#: custom-post-type-permalinks/custom-post-type-permalinks.php:594
|
29 |
msgid "Use custom permalink of custom taxonomy archive."
|
30 |
msgstr "カスタム分類のアーカイブのパーマリンクを変更する。"
|
31 |
|
32 |
+
#: custom-post-type-permalinks/custom-post-type-permalinks.php:615
|
33 |
msgid "Setting permalinks of custom post type."
|
34 |
msgstr "カスタム投稿タイプごとのパーマリンク構造を設定できます。"
|
35 |
|
36 |
+
#: custom-post-type-permalinks/custom-post-type-permalinks.php:616
|
37 |
msgid ""
|
38 |
"The tags you can use is WordPress Structure Tags and '%\"custom_taxonomy_slug"
|
39 |
"\"%'. (e.g. %actors%)"
|
41 |
"使用できるタグは、WordPress標準のタグと '%\"カスタム分類名\"%' です。 (例: "
|
42 |
"%actors%)"
|
43 |
|
44 |
+
#: custom-post-type-permalinks/custom-post-type-permalinks.php:617
|
45 |
msgid "%\"custom_taxonomy_slug\"% is replaced the taxonomy's term.'."
|
46 |
msgstr "'%\"カスタム分類名\"%' は、そのカスタム分類のタームに置換されます。"
|
47 |
|
48 |
+
#: custom-post-type-permalinks/custom-post-type-permalinks.php:619
|
49 |
msgid ""
|
50 |
"Presence of the trailing '/' is unified into a standard permalink structure "
|
51 |
"setting."
|
52 |
msgstr "末尾の '/' の有無は、標準のパーマリンク構造の設定に統一されます。"
|
53 |
|
54 |
+
#: custom-post-type-permalinks/custom-post-type-permalinks.php:620
|
55 |
msgid ""
|
56 |
"If you don't entered permalink structure, permalink is configured /%postname"
|
57 |
"%/'."
|
58 |
msgstr "未入力のときは、/%postname%/ に設定されます。"
|
59 |
|
60 |
+
#: custom-post-type-permalinks/custom-post-type-permalinks.php:640
|
61 |
#, php-format
|
62 |
msgid ""
|
63 |
"If you check,The custom taxonomy's permalinks is <code>%s/post_type/taxonomy/"
|
65 |
msgstr ""
|
66 |
"チェックした場合、カスタム分類のアーカイブのパーマリンクは <code>%s/"
|
67 |
"post_type/taxonomy/term</code>. に変更されます。"
|
68 |
+
|
69 |
+
#: custom-post-type-permalinks/custom-post-type-permalinks.php:668
|
70 |
+
msgid ""
|
71 |
+
"<h3>Custom Post Type Permalinks</h3><p>From <a href='options-permalink."
|
72 |
+
"php'>Permalinks</a>, set a custom permalink for each post type.</p>"
|
73 |
+
msgstr ""
|
74 |
+
"<h3>Custom Post Type Permalinks</h3><p><a href='options-permalink.php'>パーマ"
|
75 |
+
"リンク設定</a>より、カスタム投稿タイプごとのパーマリンクを設定できます。</p>"
|
76 |
+
|
77 |
+
#~ msgid "From Permalinks, set a custom permalink for each post type."
|
78 |
+
#~ msgstr ""
|
79 |
+
#~ "パーマリンク設定より、カスタム投稿タイプごとのパーマリンクを設定できます。"
|
custom-post-type-permalinks.php
CHANGED
@@ -3,9 +3,9 @@
|
|
3 |
Plugin Name: Custom Post Type Permalinks
|
4 |
Plugin URI: http://www.torounit.com
|
5 |
Description: Add post archives of custom post type and customizable permalinks.
|
6 |
-
Author:
|
7 |
Author URI: http://www.torounit.com/plugins/custom-post-type-permalinks/
|
8 |
-
Version: 0.8.
|
9 |
Text Domain: cptp
|
10 |
Domain Path: /
|
11 |
*/
|
@@ -38,26 +38,45 @@ Domain Path: /
|
|
38 |
*/
|
39 |
class Custom_Post_Type_Permalinks {
|
40 |
|
41 |
-
|
|
|
42 |
|
43 |
/**
|
44 |
*
|
45 |
-
* Constructor
|
46 |
* Add Action & filter hooks.
|
47 |
* @version 2.0
|
48 |
*/
|
|
|
49 |
|
50 |
-
|
51 |
-
add_action('
|
52 |
-
|
53 |
-
add_action('wp_loaded', array(&$this,'
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
add_filter('
|
59 |
-
add_filter('
|
60 |
-
add_filter('
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
}
|
62 |
}
|
63 |
|
@@ -93,6 +112,8 @@ class Custom_Post_Type_Permalinks {
|
|
93 |
return $chain;
|
94 |
}
|
95 |
|
|
|
|
|
96 |
/**
|
97 |
*
|
98 |
* Add rewrite rules for archives.
|
@@ -130,12 +151,11 @@ class Custom_Post_Type_Permalinks {
|
|
130 |
add_rewrite_rule( $slug.'/author/([^/]+)/?$', 'index.php?author_name=$matches[1]&post_type='.$post_type, 'top' );
|
131 |
add_rewrite_rule( $slug.'/page/?([0-9]{1,})/?$', 'index.php?paged=$matches[1]&post_type='.$post_type, 'top' );
|
132 |
add_rewrite_rule( $slug.'/?$', 'index.php?post_type='.$post_type, 'top' );
|
133 |
-
|
134 |
-
|
135 |
endforeach;
|
136 |
}
|
137 |
|
138 |
|
|
|
139 |
/**
|
140 |
*
|
141 |
* Add Rewrite rule for single posts.
|
@@ -150,16 +170,18 @@ class Custom_Post_Type_Permalinks {
|
|
150 |
foreach ( $post_types as $post_type ):
|
151 |
$permalink = get_option( $post_type.'_structure' );
|
152 |
|
153 |
-
if( !$permalink )
|
154 |
-
$permalink =
|
|
|
155 |
|
156 |
$permalink = str_replace( '%postname%', '%'.$post_type.'%', $permalink );
|
157 |
$permalink = str_replace( '%post_id%', '%'.$post_type.'_id%', $permalink );
|
158 |
|
159 |
$slug = get_post_type_object($post_type)->rewrite['slug'];
|
160 |
|
161 |
-
if( !$slug )
|
162 |
-
$slug = $post_type;
|
|
|
163 |
|
164 |
$permalink = '/'.$slug.'/'.$permalink;
|
165 |
|
@@ -195,12 +217,14 @@ class Custom_Post_Type_Permalinks {
|
|
195 |
$wp_rewrite->use_verbose_page_rules = true;
|
196 |
}
|
197 |
|
|
|
|
|
198 |
/**
|
199 |
*
|
200 |
* Fix permalinks output.
|
201 |
*
|
202 |
-
* @param String $post_link
|
203 |
-
* @param Object $post
|
204 |
* @param String $leavename 記事編集画面でのみ渡される
|
205 |
*
|
206 |
* @version 1.2
|
@@ -245,8 +269,10 @@ class Custom_Post_Type_Permalinks {
|
|
245 |
usort($terms, '_usort_terms_by_ID'); // order by ID
|
246 |
$term = $terms[0]->slug;
|
247 |
|
248 |
-
if ( $parent = $terms[0]->parent )
|
249 |
-
$term = $this->get_taxonomy_parents( $parent,$taxonomy, false, '/', true ) . $term;
|
|
|
|
|
250 |
}
|
251 |
|
252 |
if( isset($term) ) {
|
@@ -274,6 +300,8 @@ class Custom_Post_Type_Permalinks {
|
|
274 |
|
275 |
}
|
276 |
|
|
|
|
|
277 |
/**
|
278 |
*
|
279 |
* wp_get_archives fix for custom post
|
@@ -287,17 +315,20 @@ class Custom_Post_Type_Permalinks {
|
|
287 |
// function modified by [steve]
|
288 |
public function get_archives_where( $where, $r ) {
|
289 |
$this->get_archives_where_r = $r;
|
290 |
-
if ( isset($r['post_type']) )
|
291 |
-
$where = str_replace( '\'post\'', '\'' . $r['post_type'] . '\'', $where );
|
|
|
292 |
|
293 |
if(isset($r['taxonomy']) && is_array($r['taxonomy']) ){
|
294 |
-
|
295 |
$where = $where . " AND $wpdb->term_taxonomy.taxonomy = '".$r['taxonomy']['name']."' AND $wpdb->term_taxonomy.term_id = '".$r['taxonomy']['termid']."'";
|
296 |
}
|
297 |
|
298 |
return $where;
|
299 |
}
|
300 |
|
|
|
|
|
301 |
//function added by [steve]
|
302 |
/**
|
303 |
*
|
@@ -317,6 +348,8 @@ class Custom_Post_Type_Permalinks {
|
|
317 |
return $join;
|
318 |
}
|
319 |
|
|
|
|
|
320 |
/**
|
321 |
*
|
322 |
* get_arcihves_link
|
@@ -362,6 +395,8 @@ class Custom_Post_Type_Permalinks {
|
|
362 |
return $link;
|
363 |
}
|
364 |
|
|
|
|
|
365 |
/**
|
366 |
*
|
367 |
* Add rewrite rules for custom taxonomies.
|
@@ -370,14 +405,18 @@ class Custom_Post_Type_Permalinks {
|
|
370 |
*
|
371 |
*/
|
372 |
public function add_tax_rewrite() {
|
373 |
-
if(get_option('no_taxonomy_structure'))
|
374 |
-
return false;
|
|
|
|
|
375 |
|
376 |
global $wp_rewrite;
|
377 |
$taxonomies = get_taxonomies(array( '_builtin' => false));
|
378 |
$taxonomies['category'] = 'category';
|
379 |
-
|
380 |
-
|
|
|
|
|
381 |
|
382 |
foreach ($taxonomies as $taxonomy) :
|
383 |
$post_types = get_taxonomy($taxonomy)->object_type;
|
@@ -389,7 +428,7 @@ class Custom_Post_Type_Permalinks {
|
|
389 |
$slug = $post_type;
|
390 |
}
|
391 |
|
392 |
-
if(is_string($post_type_obj->has_archive)){
|
393 |
$slug = $post_type_obj->has_archive;
|
394 |
};
|
395 |
|
@@ -419,6 +458,8 @@ class Custom_Post_Type_Permalinks {
|
|
419 |
}
|
420 |
|
421 |
|
|
|
|
|
422 |
/**
|
423 |
*
|
424 |
* Fix taxonomy link outputs.
|
@@ -427,8 +468,9 @@ class Custom_Post_Type_Permalinks {
|
|
427 |
*
|
428 |
*/
|
429 |
public function set_term_link( $termlink, $term, $taxonomy ) {
|
430 |
-
if( get_option('no_taxonomy_structure') )
|
431 |
-
return $termlink;
|
|
|
432 |
|
433 |
$taxonomy = get_taxonomy($taxonomy);
|
434 |
if( $taxonomy->_builtin )
|
@@ -449,28 +491,21 @@ class Custom_Post_Type_Permalinks {
|
|
449 |
return str_replace($str, "", $termlink );
|
450 |
|
451 |
}
|
452 |
-
}
|
453 |
-
|
454 |
-
/**
|
455 |
-
*
|
456 |
-
* Admin Page Class
|
457 |
-
*
|
458 |
-
*/
|
459 |
|
460 |
-
class Custom_Post_Type_Permalinks_Admin {
|
461 |
|
462 |
-
public function add_hook () {
|
463 |
-
add_action('init', array(&$this,'load_textdomain'));
|
464 |
-
add_action('init', array(&$this, 'update_rules'));
|
465 |
-
add_action('admin_init', array(&$this,'settings_api_init'),30);
|
466 |
-
add_action('admin_enqueue_scripts', array(&$this,'enqueue_css_js'));
|
467 |
-
add_action('admin_footer',array(&$this,'pointer_js'));
|
468 |
-
}
|
469 |
|
|
|
|
|
|
|
|
|
|
|
|
|
470 |
public function load_textdomain() {
|
471 |
load_plugin_textdomain('cptp',false,'custom-post-type-permalinks');
|
472 |
}
|
473 |
|
|
|
|
|
474 |
/**
|
475 |
*
|
476 |
* Add hook flush_rules
|
@@ -486,9 +521,9 @@ class Custom_Post_Type_Permalinks_Admin {
|
|
486 |
add_action('update_option_'.$post_type.'_structure',array(&$this,'flush_rules'),10,2);
|
487 |
endforeach;
|
488 |
add_action('update_option_no_taxonomy_structure',array(&$this,'flush_rules'),10,2);
|
|
|
489 |
|
490 |
|
491 |
-
}
|
492 |
|
493 |
/**
|
494 |
* Flush rules
|
@@ -498,13 +533,14 @@ class Custom_Post_Type_Permalinks_Admin {
|
|
498 |
*/
|
499 |
|
500 |
public function flush_rules(){
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
flush_rewrite_rules();
|
505 |
}
|
506 |
|
507 |
|
|
|
508 |
/**
|
509 |
*
|
510 |
* Setting Init
|
@@ -527,7 +563,7 @@ class Custom_Post_Type_Permalinks_Admin {
|
|
527 |
|
528 |
#default permalink structure
|
529 |
if( !$structure )
|
530 |
-
$structure =
|
531 |
|
532 |
$structure = str_replace('//','/','/'.$structure);# first "/"
|
533 |
|
@@ -594,18 +630,19 @@ class Custom_Post_Type_Permalinks_Admin {
|
|
594 |
|
595 |
$value = get_option($option);
|
596 |
if( !$value )
|
597 |
-
$value =
|
598 |
|
599 |
echo '<code>'.home_url().'/'.$slug.'</code> <input name="'.$option.'" id="'.$option.'" type="text" class="regular-text code" value="' . $value .'" />';
|
600 |
}
|
601 |
|
602 |
public function setting_no_tax_structure_callback_function(){
|
603 |
-
echo '<input name="no_taxonomy_structure" id="no_taxonomy_structure" type="checkbox" value="1" class="code" ' . checked( false, get_option('no_taxonomy_structure'),false) . ' />
|
604 |
$txt = __("If you check,The custom taxonomy's permalinks is <code>%s/post_type/taxonomy/term</code>.","cptp");
|
605 |
printf($txt , home_url());
|
606 |
}
|
607 |
|
608 |
|
|
|
609 |
/**
|
610 |
*
|
611 |
* enqueue CSS and JS
|
@@ -618,6 +655,7 @@ class Custom_Post_Type_Permalinks_Admin {
|
|
618 |
}
|
619 |
|
620 |
|
|
|
621 |
/**
|
622 |
*
|
623 |
* add js for pointer
|
@@ -626,18 +664,19 @@ class Custom_Post_Type_Permalinks_Admin {
|
|
626 |
public function pointer_js() {
|
627 |
if(!is_network_admin()) {
|
628 |
$dismissed = explode(',', get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ));
|
629 |
-
if(array_search('
|
|
|
630 |
?>
|
631 |
<script type="text/javascript">
|
632 |
jQuery(function($) {
|
633 |
|
634 |
$("#menu-settings .wp-has-submenu").pointer({
|
635 |
-
content: "
|
636 |
position: {"edge":"left","align":"center"},
|
637 |
close: function() {
|
638 |
$.post('admin-ajax.php', {
|
639 |
action:'dismiss-wp-pointer',
|
640 |
-
pointer: '
|
641 |
})
|
642 |
|
643 |
}
|
@@ -653,8 +692,4 @@ class Custom_Post_Type_Permalinks_Admin {
|
|
653 |
$custom_post_type_permalinks = new Custom_Post_Type_Permalinks;
|
654 |
$custom_post_type_permalinks = apply_filters('custom_post_type_permalinks', $custom_post_type_permalinks);
|
655 |
$custom_post_type_permalinks->add_hook();
|
656 |
-
|
657 |
-
$custom_post_type_permalinks_admin = new Custom_Post_Type_Permalinks_Admin;
|
658 |
-
$custom_post_type_permalinks_admin = apply_filters('custom_post_type_permalinks_admin', $custom_post_type_permalinks_admin);
|
659 |
-
$custom_post_type_permalinks_admin->add_hook();
|
660 |
?>
|
3 |
Plugin Name: Custom Post Type Permalinks
|
4 |
Plugin URI: http://www.torounit.com
|
5 |
Description: Add post archives of custom post type and customizable permalinks.
|
6 |
+
Author: Toro_Unit
|
7 |
Author URI: http://www.torounit.com/plugins/custom-post-type-permalinks/
|
8 |
+
Version: 0.8.7
|
9 |
Text Domain: cptp
|
10 |
Domain Path: /
|
11 |
*/
|
38 |
*/
|
39 |
class Custom_Post_Type_Permalinks {
|
40 |
|
41 |
+
public $version = "0.8.7";
|
42 |
+
public $default_structure = '/%postname%/';
|
43 |
|
44 |
/**
|
45 |
*
|
|
|
46 |
* Add Action & filter hooks.
|
47 |
* @version 2.0
|
48 |
*/
|
49 |
+
public function add_hook () {
|
50 |
|
51 |
+
add_action( 'update_option_cptp_version', array(&$this, 'update_rules') );
|
52 |
+
add_action( 'plugins_loaded', array(&$this,'check_version') );
|
53 |
+
|
54 |
+
add_action( 'wp_loaded', array(&$this,'set_archive_rewrite'), 99 );
|
55 |
+
add_action( 'wp_loaded', array(&$this,'set_rewrite'), 100 );
|
56 |
+
add_action( 'wp_loaded', array(&$this,'add_tax_rewrite') );
|
57 |
+
|
58 |
+
if(get_option( "permalink_structure") != "") {
|
59 |
+
add_filter( 'post_type_link', array(&$this,'set_permalink'), 10, 3 );
|
60 |
+
add_filter( 'getarchives_join', array(&$this,'get_archives_join'), 10, 2 ); // [steve]
|
61 |
+
add_filter( 'getarchives_where', array(&$this,'get_archives_where'), 10 , 2 );
|
62 |
+
add_filter( 'get_archives_link', array(&$this,'get_archives_link'), 20, 1 );
|
63 |
+
add_filter( 'term_link', array(&$this,'set_term_link'), 10, 3 );
|
64 |
+
}
|
65 |
+
|
66 |
+
add_action( 'init', array(&$this,'load_textdomain') );
|
67 |
+
add_action( 'init', array(&$this, 'update_rules') );
|
68 |
+
add_action( 'admin_init', array(&$this,'settings_api_init'), 30 );
|
69 |
+
add_action( 'admin_enqueue_scripts', array(&$this,'enqueue_css_js') );
|
70 |
+
add_action( 'admin_footer', array(&$this,'pointer_js') );
|
71 |
+
|
72 |
+
|
73 |
+
}
|
74 |
+
|
75 |
+
|
76 |
+
public function check_version() {
|
77 |
+
$version = get_option('cptp_version', 0);
|
78 |
+
if($version != $this->version) {
|
79 |
+
update_option('cptp_version', $this->version);
|
80 |
}
|
81 |
}
|
82 |
|
112 |
return $chain;
|
113 |
}
|
114 |
|
115 |
+
|
116 |
+
|
117 |
/**
|
118 |
*
|
119 |
* Add rewrite rules for archives.
|
151 |
add_rewrite_rule( $slug.'/author/([^/]+)/?$', 'index.php?author_name=$matches[1]&post_type='.$post_type, 'top' );
|
152 |
add_rewrite_rule( $slug.'/page/?([0-9]{1,})/?$', 'index.php?paged=$matches[1]&post_type='.$post_type, 'top' );
|
153 |
add_rewrite_rule( $slug.'/?$', 'index.php?post_type='.$post_type, 'top' );
|
|
|
|
|
154 |
endforeach;
|
155 |
}
|
156 |
|
157 |
|
158 |
+
|
159 |
/**
|
160 |
*
|
161 |
* Add Rewrite rule for single posts.
|
170 |
foreach ( $post_types as $post_type ):
|
171 |
$permalink = get_option( $post_type.'_structure' );
|
172 |
|
173 |
+
if( !$permalink ) {
|
174 |
+
$permalink = $this->default_structure;
|
175 |
+
}
|
176 |
|
177 |
$permalink = str_replace( '%postname%', '%'.$post_type.'%', $permalink );
|
178 |
$permalink = str_replace( '%post_id%', '%'.$post_type.'_id%', $permalink );
|
179 |
|
180 |
$slug = get_post_type_object($post_type)->rewrite['slug'];
|
181 |
|
182 |
+
if( !$slug ) {
|
183 |
+
$slug = $post_type;
|
184 |
+
}
|
185 |
|
186 |
$permalink = '/'.$slug.'/'.$permalink;
|
187 |
|
217 |
$wp_rewrite->use_verbose_page_rules = true;
|
218 |
}
|
219 |
|
220 |
+
|
221 |
+
|
222 |
/**
|
223 |
*
|
224 |
* Fix permalinks output.
|
225 |
*
|
226 |
+
* @param String $post_link
|
227 |
+
* @param Object $post 投稿情報
|
228 |
* @param String $leavename 記事編集画面でのみ渡される
|
229 |
*
|
230 |
* @version 1.2
|
269 |
usort($terms, '_usort_terms_by_ID'); // order by ID
|
270 |
$term = $terms[0]->slug;
|
271 |
|
272 |
+
if ( $parent = $terms[0]->parent ) {
|
273 |
+
$term = $this->get_taxonomy_parents( $parent,$taxonomy, false, '/', true ) . $term;
|
274 |
+
}
|
275 |
+
|
276 |
}
|
277 |
|
278 |
if( isset($term) ) {
|
300 |
|
301 |
}
|
302 |
|
303 |
+
|
304 |
+
|
305 |
/**
|
306 |
*
|
307 |
* wp_get_archives fix for custom post
|
315 |
// function modified by [steve]
|
316 |
public function get_archives_where( $where, $r ) {
|
317 |
$this->get_archives_where_r = $r;
|
318 |
+
if ( isset($r['post_type']) ) {
|
319 |
+
$where = str_replace( '\'post\'', '\'' . $r['post_type'] . '\'', $where );
|
320 |
+
}
|
321 |
|
322 |
if(isset($r['taxonomy']) && is_array($r['taxonomy']) ){
|
323 |
+
global $wpdb;
|
324 |
$where = $where . " AND $wpdb->term_taxonomy.taxonomy = '".$r['taxonomy']['name']."' AND $wpdb->term_taxonomy.term_id = '".$r['taxonomy']['termid']."'";
|
325 |
}
|
326 |
|
327 |
return $where;
|
328 |
}
|
329 |
|
330 |
+
|
331 |
+
|
332 |
//function added by [steve]
|
333 |
/**
|
334 |
*
|
348 |
return $join;
|
349 |
}
|
350 |
|
351 |
+
|
352 |
+
|
353 |
/**
|
354 |
*
|
355 |
* get_arcihves_link
|
395 |
return $link;
|
396 |
}
|
397 |
|
398 |
+
|
399 |
+
|
400 |
/**
|
401 |
*
|
402 |
* Add rewrite rules for custom taxonomies.
|
405 |
*
|
406 |
*/
|
407 |
public function add_tax_rewrite() {
|
408 |
+
if(get_option('no_taxonomy_structure')) {
|
409 |
+
return false;
|
410 |
+
}
|
411 |
+
|
412 |
|
413 |
global $wp_rewrite;
|
414 |
$taxonomies = get_taxonomies(array( '_builtin' => false));
|
415 |
$taxonomies['category'] = 'category';
|
416 |
+
|
417 |
+
if(empty($taxonomies)) {
|
418 |
+
return false;
|
419 |
+
}
|
420 |
|
421 |
foreach ($taxonomies as $taxonomy) :
|
422 |
$post_types = get_taxonomy($taxonomy)->object_type;
|
428 |
$slug = $post_type;
|
429 |
}
|
430 |
|
431 |
+
if(is_string($post_type_obj->has_archive)) {
|
432 |
$slug = $post_type_obj->has_archive;
|
433 |
};
|
434 |
|
458 |
}
|
459 |
|
460 |
|
461 |
+
|
462 |
+
|
463 |
/**
|
464 |
*
|
465 |
* Fix taxonomy link outputs.
|
468 |
*
|
469 |
*/
|
470 |
public function set_term_link( $termlink, $term, $taxonomy ) {
|
471 |
+
if( get_option('no_taxonomy_structure') ) {
|
472 |
+
return $termlink;
|
473 |
+
}
|
474 |
|
475 |
$taxonomy = get_taxonomy($taxonomy);
|
476 |
if( $taxonomy->_builtin )
|
491 |
return str_replace($str, "", $termlink );
|
492 |
|
493 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
494 |
|
|
|
495 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
496 |
|
497 |
+
/**
|
498 |
+
*
|
499 |
+
* load textdomain
|
500 |
+
* @since 0.6.2
|
501 |
+
*
|
502 |
+
*/
|
503 |
public function load_textdomain() {
|
504 |
load_plugin_textdomain('cptp',false,'custom-post-type-permalinks');
|
505 |
}
|
506 |
|
507 |
+
|
508 |
+
|
509 |
/**
|
510 |
*
|
511 |
* Add hook flush_rules
|
521 |
add_action('update_option_'.$post_type.'_structure',array(&$this,'flush_rules'),10,2);
|
522 |
endforeach;
|
523 |
add_action('update_option_no_taxonomy_structure',array(&$this,'flush_rules'),10,2);
|
524 |
+
}
|
525 |
|
526 |
|
|
|
527 |
|
528 |
/**
|
529 |
* Flush rules
|
533 |
*/
|
534 |
|
535 |
public function flush_rules(){
|
536 |
+
$this->add_tax_rewrite();
|
537 |
+
$this->set_archive_rewrite();
|
538 |
+
$this->set_rewrite();
|
539 |
flush_rewrite_rules();
|
540 |
}
|
541 |
|
542 |
|
543 |
+
|
544 |
/**
|
545 |
*
|
546 |
* Setting Init
|
563 |
|
564 |
#default permalink structure
|
565 |
if( !$structure )
|
566 |
+
$structure = $this->default_structure;
|
567 |
|
568 |
$structure = str_replace('//','/','/'.$structure);# first "/"
|
569 |
|
630 |
|
631 |
$value = get_option($option);
|
632 |
if( !$value )
|
633 |
+
$value = $this->default_structure;
|
634 |
|
635 |
echo '<code>'.home_url().'/'.$slug.'</code> <input name="'.$option.'" id="'.$option.'" type="text" class="regular-text code" value="' . $value .'" />';
|
636 |
}
|
637 |
|
638 |
public function setting_no_tax_structure_callback_function(){
|
639 |
+
echo '<input name="no_taxonomy_structure" id="no_taxonomy_structure" type="checkbox" value="1" class="code" ' . checked( false, get_option('no_taxonomy_structure'),false) . ' /> ';
|
640 |
$txt = __("If you check,The custom taxonomy's permalinks is <code>%s/post_type/taxonomy/term</code>.","cptp");
|
641 |
printf($txt , home_url());
|
642 |
}
|
643 |
|
644 |
|
645 |
+
|
646 |
/**
|
647 |
*
|
648 |
* enqueue CSS and JS
|
655 |
}
|
656 |
|
657 |
|
658 |
+
|
659 |
/**
|
660 |
*
|
661 |
* add js for pointer
|
664 |
public function pointer_js() {
|
665 |
if(!is_network_admin()) {
|
666 |
$dismissed = explode(',', get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ));
|
667 |
+
if(array_search('cptp_pointer.0.8.7', $dismissed) === false){
|
668 |
+
$content = __("<h3>Custom Post Type Permalinks</h3><p>From <a href='options-permalink.php'>Permalinks</a>, set a custom permalink for each post type.</p>", "cptp");
|
669 |
?>
|
670 |
<script type="text/javascript">
|
671 |
jQuery(function($) {
|
672 |
|
673 |
$("#menu-settings .wp-has-submenu").pointer({
|
674 |
+
content: "<?php echo $content;?>",
|
675 |
position: {"edge":"left","align":"center"},
|
676 |
close: function() {
|
677 |
$.post('admin-ajax.php', {
|
678 |
action:'dismiss-wp-pointer',
|
679 |
+
pointer: 'cptp_pointer.0.8.7'
|
680 |
})
|
681 |
|
682 |
}
|
692 |
$custom_post_type_permalinks = new Custom_Post_Type_Permalinks;
|
693 |
$custom_post_type_permalinks = apply_filters('custom_post_type_permalinks', $custom_post_type_permalinks);
|
694 |
$custom_post_type_permalinks->add_hook();
|
|
|
|
|
|
|
|
|
695 |
?>
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: Toro_Unit
|
|
3 |
Tags: custom post type,permalink
|
4 |
Requires at least: 3.4
|
5 |
Tested up to: 3.5
|
6 |
-
Stable tag: 0.8.
|
7 |
|
8 |
Lets you edit the permalink of custom post type.
|
9 |
|
@@ -32,6 +32,8 @@ That's it. You can access the permalinks setting by going to *Settings -> Permal
|
|
32 |
|
33 |
== Changelog ==
|
34 |
|
|
|
|
|
35 |
|
36 |
= 0.8.6 =
|
37 |
* Paging Bug Fix.
|
3 |
Tags: custom post type,permalink
|
4 |
Requires at least: 3.4
|
5 |
Tested up to: 3.5
|
6 |
+
Stable tag: 0.8.7
|
7 |
|
8 |
Lets you edit the permalink of custom post type.
|
9 |
|
32 |
|
33 |
== Changelog ==
|
34 |
|
35 |
+
= 0.8.7 =
|
36 |
+
* Translate Bug Fix.
|
37 |
|
38 |
= 0.8.6 =
|
39 |
* Paging Bug Fix.
|