Custom Post Type Permalinks - Version 0.7.1

Version Description

  • Bug fix.
Download this release

Release Info

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

Code changes from version 0.7 to 0.7.1

Files changed (3) hide show
  1. custom-post-type-permalinks.php +14 -13
  2. readme.txt +5 -2
  3. screenshot-1.png +0 -0
custom-post-type-permalinks.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://www.torounit.com
5
  Description: Add post archives of custom post type and customizable permalinks.
6
  Author: Toro-Unit
7
  Author URI: http://www.torounit.com/plugins/custom-post-type-permalinks/
8
- Version: 0.7
9
  */
10
 
11
 
@@ -59,8 +59,6 @@ function get_taxonomy_parents( $id, $taxonomy = 'category', $link = false, $sepa
59
 
60
 
61
 
62
-
63
-
64
  class Custom_Post_Type_Permalinks {
65
 
66
  function add_hooks(){
@@ -159,10 +157,6 @@ class Custom_Post_Type_Permalinks {
159
  $wp_rewrite->add_rewrite_tag('%post_type%', '([^/]+)','post_type=');
160
  $wp_rewrite->add_permastruct($post_type,$permalink, false);
161
 
162
- if(!$slug or $slug != $post_type){
163
- $wp_rewrite->add_rewrite_tag('%$slug%', '([^/]+)',"post_type=$post_type&slug=");
164
- $wp_rewrite->add_permastruct($post_type,str_replace("%post_type%","%$slug%",$permalink), false);
165
- }
166
 
167
 
168
  endforeach;
@@ -193,14 +187,14 @@ class Custom_Post_Type_Permalinks {
193
  global $wp_rewrite;
194
 
195
  $newlink = $wp_rewrite->get_extra_permastruct($post->post_type);
196
- $slug = get_post_type_object($post->post_type)->rewrite["slug"];
197
- $newlink = str_replace("%$slug%", $slug, $newlink);
198
 
199
  $newlink = str_replace("%post_type%", $post->post_type, $newlink);
200
  $newlink = str_replace("%post_id%", $post->ID, $newlink);
201
  if(!$leavename){
202
  $newlink = str_replace("%$post->post_type%", $post->post_name, $newlink);
203
  }
 
 
204
 
205
 
206
  //カスタム分類の対応
@@ -345,15 +339,16 @@ class Custom_Post_Type_Permalinks_Admin {
345
 
346
  function add_hooks(){
347
  add_action('init', array(&$this,'load_textdomain'));
348
- add_action('admin_init', array(&$this,'settings_api_init'));
 
349
 
350
  }
 
351
  function load_textdomain(){
352
  load_plugin_textdomain('cptp',false,'custom-post-type-permalinks');
353
  }
354
 
355
-
356
- function settings_api_init() {
357
  add_settings_section('setting_section',
358
  __("Permalink Setting for custom post type","cptp"),
359
  array(&$this,'setting_section_callback_function'),
@@ -364,7 +359,8 @@ class Custom_Post_Type_Permalinks_Admin {
364
  $post_types = get_post_types(array("_builtin"=>false,"publicly_queryable"=>true));
365
  foreach ($post_types as $post_type):
366
  if(isset($_POST["submit"])){
367
- update_option($post_type."_structure",esc_attr($_POST[$post_type."_structure"]));
 
368
  }
369
 
370
  add_settings_field($post_type."_structure",
@@ -378,6 +374,11 @@ class Custom_Post_Type_Permalinks_Admin {
378
  endforeach;
379
 
380
  }
 
 
 
 
 
381
 
382
 
383
 
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.7.1
9
  */
10
 
11
 
59
 
60
 
61
 
 
 
62
  class Custom_Post_Type_Permalinks {
63
 
64
  function add_hooks(){
157
  $wp_rewrite->add_rewrite_tag('%post_type%', '([^/]+)','post_type=');
158
  $wp_rewrite->add_permastruct($post_type,$permalink, false);
159
 
 
 
 
 
160
 
161
 
162
  endforeach;
187
  global $wp_rewrite;
188
 
189
  $newlink = $wp_rewrite->get_extra_permastruct($post->post_type);
 
 
190
 
191
  $newlink = str_replace("%post_type%", $post->post_type, $newlink);
192
  $newlink = str_replace("%post_id%", $post->ID, $newlink);
193
  if(!$leavename){
194
  $newlink = str_replace("%$post->post_type%", $post->post_name, $newlink);
195
  }
196
+
197
+ $newlink = str_replace("%postname%", $post->post_name, $newlink);
198
 
199
 
200
  //カスタム分類の対応
339
 
340
  function add_hooks(){
341
  add_action('init', array(&$this,'load_textdomain'));
342
+ add_action('admin_init', array(&$this,'settings_api_init'),10);
343
+ add_action('admin_init', array(&$this,'set_rules'),50);
344
 
345
  }
346
+
347
  function load_textdomain(){
348
  load_plugin_textdomain('cptp',false,'custom-post-type-permalinks');
349
  }
350
 
351
+ function settings_api_init(){
 
352
  add_settings_section('setting_section',
353
  __("Permalink Setting for custom post type","cptp"),
354
  array(&$this,'setting_section_callback_function'),
359
  $post_types = get_post_types(array("_builtin"=>false,"publicly_queryable"=>true));
360
  foreach ($post_types as $post_type):
361
  if(isset($_POST["submit"])){
362
+ if( strpos($_POST["_wp_http_referer"],"options-permalink.php") !== FALSE )
363
+ update_option($post_type."_structure",esc_attr($_POST[$post_type."_structure"]));
364
  }
365
 
366
  add_settings_field($post_type."_structure",
374
  endforeach;
375
 
376
  }
377
+
378
+ function set_rules(){
379
+ global $wp_rewrite;
380
+ $wp_rewrite->flush_rules();
381
+ }
382
 
383
 
384
 
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: Toro_Unit
3
  Tags: custom post type,permalink
4
  Requires at least: 3.2
5
  Tested up to: 3.3
6
- Stable tag: 0.7
7
 
8
  Lets you edit the permalink of custom post type.
9
 
@@ -28,7 +28,10 @@ That's it. You can access the permalinks setting by going to *Settings -> Permal
28
 
29
  == Changelog ==
30
 
31
- =0.7=
 
 
 
32
  * Add %{taxonomy}% tag.
33
  * A large number of Bug Fix.
34
  * Change Setting Page. Use Setting API.
3
  Tags: custom post type,permalink
4
  Requires at least: 3.2
5
  Tested up to: 3.3
6
+ Stable tag: 0.7.1
7
 
8
  Lets you edit the permalink of custom post type.
9
 
28
 
29
  == Changelog ==
30
 
31
+ = 0.7.1 =
32
+ * Bug fix.
33
+
34
+ = 0.7 =
35
  * Add %{taxonomy}% tag.
36
  * A large number of Bug Fix.
37
  * Change Setting Page. Use Setting API.
screenshot-1.png CHANGED
Binary file