Custom Permalinks - Version 0.7.22

Version Description

  • Fixed PHP warning
    • Fixed initial permalink display for new posts/pages
Download this release

Release Info

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

Code changes from version 0.7.21 to 0.7.22

Files changed (2) hide show
  1. custom-permalinks.php +7 -14
  2. readme.txt +7 -2
custom-permalinks.php CHANGED
@@ -4,7 +4,7 @@ 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.7.21
8
  Author: Michael Tyson
9
  Author URI: http://atastypixel.com/blog
10
  Text Domain: custom-permalinks
@@ -105,7 +105,7 @@ function custom_permalinks_redirect() {
105
  $original_permalink = '';
106
 
107
  // If the post/tag/category we're on has a custom permalink, get it and check against the request
108
- if ( is_single() || is_page() ) {
109
  $post = $wp_query->post;
110
  $custom_permalink = get_post_meta( $post->ID, 'custom_permalink', true );
111
  $original_permalink = ( $post->post_type == 'page' ? custom_permalinks_original_page_link( $post->ID ) : custom_permalinks_original_post_link( $post->ID ) );
@@ -673,12 +673,10 @@ function custom_permalinks_admin_rows() {
673
  * @since 0.1
674
  */
675
  function custom_permalinks_original_post_link($post_id) {
676
- remove_filter( 'post_link', 'custom_permalinks_post_link', 'edit_files', 2 ); // original hook
677
- remove_filter( 'post_type_link', 'custom_permalinks_post_link', 'edit_files', 2 );
678
- $originalPermalink = ltrim(str_replace(home_url(), '', get_permalink( $post_id )), '/');
679
- add_filter( 'post_link', 'custom_permalinks_post_link', 'edit_files', 2 ); // original hook
680
- add_filter( 'post_type_link', 'custom_permalinks_post_link', 'edit_files', 2 );
681
- return $originalPermalink;
682
  }
683
 
684
  /**
@@ -688,12 +686,7 @@ function custom_permalinks_original_post_link($post_id) {
688
  * @since 0.4
689
  */
690
  function custom_permalinks_original_page_link($post_id) {
691
- remove_filter( 'page_link', 'custom_permalinks_page_link', 'edit_files', 2 );
692
- remove_filter( 'user_trailingslashit', 'custom_permalinks_trailingslash', 'edit_files', 2 );
693
- $originalPermalink = ltrim(str_replace(home_url(), '', get_permalink( $post_id )), '/');
694
- add_filter( 'user_trailingslashit', 'custom_permalinks_trailingslash', 'edit_files', 2 );
695
- add_filter( 'page_link', 'custom_permalinks_page_link', 'edit_files', 2 );
696
- return $originalPermalink;
697
  }
698
 
699
 
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.7.22
8
  Author: Michael Tyson
9
  Author URI: http://atastypixel.com/blog
10
  Text Domain: custom-permalinks
105
  $original_permalink = '';
106
 
107
  // If the post/tag/category we're on has a custom permalink, get it and check against the request
108
+ if ( (is_single() || is_page()) && !empty($wp_query->post) ) {
109
  $post = $wp_query->post;
110
  $custom_permalink = get_post_meta( $post->ID, 'custom_permalink', true );
111
  $original_permalink = ( $post->post_type == 'page' ? custom_permalinks_original_page_link( $post->ID ) : custom_permalinks_original_post_link( $post->ID ) );
673
  * @since 0.1
674
  */
675
  function custom_permalinks_original_post_link($post_id) {
676
+ list( $permalink, $post_name ) = get_sample_permalink( $post_id );
677
+ $permalink = str_replace(array('%pagename%','%postname%'), $post_name, $permalink);
678
+ $permalink = ltrim(str_replace(home_url(), '', $permalink), '/');
679
+ return $permalink;
 
 
680
  }
681
 
682
  /**
686
  * @since 0.4
687
  */
688
  function custom_permalinks_original_page_link($post_id) {
689
+ return custom_permalinks_original_post_link($post_id);
 
 
 
 
 
690
  }
691
 
692
 
readme.txt CHANGED
@@ -3,8 +3,8 @@
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: 4.1
7
- Stable tag: 0.7.21
8
 
9
  Set custom permalinks on a per-post, per-tag or per-category basis.
10
 
@@ -29,6 +29,11 @@ within that category.
29
 
30
  == Changelog ==
31
 
 
 
 
 
 
32
  = 0.7.21 =
33
 
34
  * Minor internationalization fixes
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: 4.5
7
+ Stable tag: 0.7.22
8
 
9
  Set custom permalinks on a per-post, per-tag or per-category basis.
10
 
29
 
30
  == Changelog ==
31
 
32
+ = 0.7.22 =
33
+
34
+ * Fixed PHP warning
35
+ * Fixed initial permalink display for new posts/pages
36
+
37
  = 0.7.21 =
38
 
39
  * Minor internationalization fixes