Custom Permalinks - Version 0.6.1

Version Description

  • Fix bug causing incorrect link from "View Post"/"View Page" button in post/page editor
Download this release

Release Info

Developer michaeltyson
Plugin Icon Custom Permalinks
Version 0.6.1
Comparing to
See all releases

Code changes from version 0.6 to 0.6.1

Files changed (2) hide show
  1. custom-permalinks.php +14 -6
  2. readme.txt +10 -2
custom-permalinks.php CHANGED
@@ -1,12 +1,12 @@
1
  <?php
2
  /*
3
  Plugin Name: Custom Permalinks
4
- Plugin URI: http://michael.tyson.id.au/wordpress/plugins/custom-permalinks
5
- Donate link: http://michael.tyson.id.au/wordpress/plugins/custom-permalinks
6
  Description: Set custom permalinks on a per-post basis
7
- Version: 0.6
8
  Author: Michael Tyson
9
- Author URI: http://michael.tyson.id.au
10
  */
11
 
12
  /* Copyright 2008 Michael Tyson <mike@tyson.id.au>
@@ -267,7 +267,7 @@ function custom_permalinks_trailingslash($string, $type) {
267
  * @since 0.6
268
  */
269
  function custom_permalink_get_sample_permalink_html($html, $id, $new_title, $new_slug) {
270
- $permalink = get_post_meta( $id, 'custom_permalink', true );
271
  $post = &get_post($id);
272
 
273
  ob_start();
@@ -281,7 +281,15 @@ function custom_permalink_get_sample_permalink_html($html, $id, $new_title, $new
281
  $view_post = 'post' == $post->post_type ? __('View Post') : __('View Page');
282
  }
283
 
284
- list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug);
 
 
 
 
 
 
 
 
285
  return '<strong>' . __('Permalink:') . "</strong>\n" . $content .
286
  ( isset($view_post) ? "<span id='view-post-btn'><a href='$permalink' class='button' target='_blank'>$view_post</a></span>\n" : "" );
287
  }
1
  <?php
2
  /*
3
  Plugin Name: Custom Permalinks
4
+ Plugin URI: http://atastypixel.com/blog/wordpress/plugins/custom-permalinks/
5
+ Donate link: http://atastypixel.com/blog/wordpress/plugins/custom-permalinks/
6
  Description: Set custom permalinks on a per-post basis
7
+ Version: 0.6.1
8
  Author: Michael Tyson
9
+ Author URI: http://atastypixel.com/blog
10
  */
11
 
12
  /* Copyright 2008 Michael Tyson <mike@tyson.id.au>
267
  * @since 0.6
268
  */
269
  function custom_permalink_get_sample_permalink_html($html, $id, $new_title, $new_slug) {
270
+ $permalink = get_post_meta( $id, 'custom_permalink', true );
271
  $post = &get_post($id);
272
 
273
  ob_start();
281
  $view_post = 'post' == $post->post_type ? __('View Post') : __('View Page');
282
  }
283
 
284
+ if ( preg_match("@view-post-btn.*?href='([^']+)'@s", $html, $matches) ) {
285
+ $permalink = $matches[1];
286
+ } else {
287
+ list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug);
288
+ if ( false !== strpos($permalink, '%postname%') || false !== strpos($permalink, '%pagename%') ) {
289
+ $permalink = str_replace(array('%pagename%','%postname%'), $post_name, $permalink);
290
+ }
291
+ }
292
+
293
  return '<strong>' . __('Permalink:') . "</strong>\n" . $content .
294
  ( isset($view_post) ? "<span id='view-post-btn'><a href='$permalink' class='button' target='_blank'>$view_post</a></span>\n" : "" );
295
  }
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Custom Permalinks ===
2
 
3
- Donate link: http://michael.tyson.id.au/wordpress/plugins/custom-permalinks
4
  Tags: permalink, url, link, address, custom, redirect
5
  Requires at least: 2.6
6
  Tested up to: 2.9.2
7
- Stable tag: 0.6
8
 
9
  Set custom permalinks on a per-post, per-tag or per-category basis.
10
 
@@ -23,6 +23,10 @@ over your site structure.
23
 
24
  == Changelog ==
25
 
 
 
 
 
26
  = 0.6 =
27
 
28
  * Fix infinite redirect for permalinks ending in a / (critical fix)
@@ -81,6 +85,10 @@ over your site structure.
81
 
82
  == Changelog ==
83
 
 
 
 
 
84
  = 0.6 =
85
 
86
  In the process of fixing one issue, version 0.5.3 broke permalinks ending with a "/". Update now to fix this, and sorry for the inconvenience!
1
  === Custom Permalinks ===
2
 
3
+ Donate link: http://atastypixel.com/blog/wordpress/plugins/custom-permalinks/
4
  Tags: permalink, url, link, address, custom, redirect
5
  Requires at least: 2.6
6
  Tested up to: 2.9.2
7
+ Stable tag: 0.6.1
8
 
9
  Set custom permalinks on a per-post, per-tag or per-category basis.
10
 
23
 
24
  == Changelog ==
25
 
26
+ = 0.6.1 =
27
+
28
+ * Fix bug causing incorrect link from "View Post"/"View Page" button in post/page editor
29
+
30
  = 0.6 =
31
 
32
  * Fix infinite redirect for permalinks ending in a / (critical fix)
85
 
86
  == Changelog ==
87
 
88
+ = 0.6.1 =
89
+
90
+ * This release fixes a bug causing incorrect link from the "View Post"/"View Page" button in the editor
91
+
92
  = 0.6 =
93
 
94
  In the process of fixing one issue, version 0.5.3 broke permalinks ending with a "/". Update now to fix this, and sorry for the inconvenience!