Custom Permalinks - Version 0.7

Version Description

  • Added support for SSL sites, thanks to Dan from todaywasawesome.com
Download this release

Release Info

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

Code changes from version 0.6.1 to 0.7

Files changed (2) hide show
  1. custom-permalinks.php +11 -11
  2. readme.txt +6 -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.6.1
8
  Author: Michael Tyson
9
  Author URI: http://atastypixel.com/blog
10
  */
@@ -41,7 +41,7 @@ Author URI: http://atastypixel.com/blog
41
  function custom_permalinks_post_link($permalink, $post) {
42
  $custom_permalink = get_post_meta( $post->ID, 'custom_permalink', true );
43
  if ( $custom_permalink ) {
44
- return get_option('home')."/".$custom_permalink;
45
  }
46
 
47
  return $permalink;
@@ -57,7 +57,7 @@ function custom_permalinks_post_link($permalink, $post) {
57
  function custom_permalinks_page_link($permalink, $page) {
58
  $custom_permalink = get_post_meta( $page, 'custom_permalink', true );
59
  if ( $custom_permalink ) {
60
- return get_option('home')."/".$custom_permalink;
61
  }
62
 
63
  return $permalink;
@@ -77,7 +77,7 @@ function custom_permalinks_term_link($permalink, $term) {
77
  $custom_permalink = custom_permalinks_permalink_for_term($term);
78
 
79
  if ( $custom_permalink ) {
80
- return get_option('home')."/".$custom_permalink;
81
  }
82
 
83
  return $permalink;
@@ -126,7 +126,7 @@ function custom_permalinks_redirect() {
126
  $url = preg_replace('@//*@', '/', str_replace(trim($original_permalink,'/'), trim($custom_permalink,'/'), $request));
127
  $url = preg_replace('@([^?]*)&@', '\1?', $url);
128
  }
129
- wp_redirect( get_option('home')."/".$url, 301 );
130
  exit();
131
  }
132
  }
@@ -394,7 +394,7 @@ function custom_permalinks_form($permalink, $original="", $renderContainers=true
394
  <th scope="row"><?php _e('Custom Permalink', 'custom-permalink') ?></th>
395
  <td>
396
  <?php endif; ?>
397
- <?php echo get_option('home') ?>/
398
  <input type="text" class="text" value="<?php echo htmlspecialchars($permalink ? $permalink : $original) ?>"
399
  style="width: 250px; <?php if ( !$permalink ) echo 'color: #ddd;' ?>"
400
  onfocus="if ( this.value == '<?php echo htmlspecialchars($original) ?>' ) { this.value = ''; this.style.color = '#000'; }"
@@ -597,7 +597,7 @@ function custom_permalinks_admin_rows() {
597
  $row = array();
598
  $term = get_term($info['id'], ($info['kind'] == 'tag' ? 'post_tag' : 'category'));
599
  $row['id'] = $info['kind'].'.'.$info['id'];
600
- $row['permalink'] = get_option('home')."/".$permalink;
601
  $row['type'] = ucwords($info['kind']);
602
  $row['title'] = $term->name;
603
  $row['editlink'] = ( $info['kind'] == 'tag' ? 'edit-tags.php?action=edit&tag_ID='.$info['id'] : 'categories.php?action=edit&cat_ID='.$info['id'] );
@@ -632,7 +632,7 @@ function custom_permalinks_admin_rows() {
632
  */
633
  function custom_permalinks_original_post_link($post_id) {
634
  remove_filter( 'post_link', 'custom_permalinks_post_link', 10, 2 );
635
- $originalPermalink = ltrim(str_replace(get_option('home'), '', get_permalink( $post_id )), '/');
636
  add_filter( 'post_link', 'custom_permalinks_post_link', 10, 2 );
637
  return $originalPermalink;
638
  }
@@ -645,7 +645,7 @@ function custom_permalinks_original_post_link($post_id) {
645
  */
646
  function custom_permalinks_original_page_link($post_id) {
647
  remove_filter( 'page_link', 'custom_permalinks_page_link', 10, 2 );
648
- $originalPermalink = ltrim(str_replace(get_option('home'), '', get_permalink( $post_id )), '/');
649
  add_filter( 'page_link', 'custom_permalinks_page_link', 10, 2 );
650
  return $originalPermalink;
651
  }
@@ -659,7 +659,7 @@ function custom_permalinks_original_page_link($post_id) {
659
  */
660
  function custom_permalinks_original_tag_link($tag_id) {
661
  remove_filter( 'tag_link', 'custom_permalinks_term_link', 10, 2 );
662
- $originalPermalink = ltrim(str_replace(get_option('home'), '', get_tag_link($tag_id)), '/');
663
  add_filter( 'tag_link', 'custom_permalinks_term_link', 10, 2 );
664
  return $originalPermalink;
665
  }
@@ -672,7 +672,7 @@ function custom_permalinks_original_tag_link($tag_id) {
672
  */
673
  function custom_permalinks_original_category_link($category_id) {
674
  remove_filter( 'category_link', 'custom_permalinks_term_link', 10, 2 );
675
- $originalPermalink = ltrim(str_replace(get_option('home'), '', get_category_link($category_id)), '/');
676
  add_filter( 'category_link', 'custom_permalinks_term_link', 10, 2 );
677
  return $originalPermalink;
678
  }
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
8
  Author: Michael Tyson
9
  Author URI: http://atastypixel.com/blog
10
  */
41
  function custom_permalinks_post_link($permalink, $post) {
42
  $custom_permalink = get_post_meta( $post->ID, 'custom_permalink', true );
43
  if ( $custom_permalink ) {
44
+ return get_site_url()."/".$custom_permalink;
45
  }
46
 
47
  return $permalink;
57
  function custom_permalinks_page_link($permalink, $page) {
58
  $custom_permalink = get_post_meta( $page, 'custom_permalink', true );
59
  if ( $custom_permalink ) {
60
+ return get_site_url()."/".$custom_permalink;
61
  }
62
 
63
  return $permalink;
77
  $custom_permalink = custom_permalinks_permalink_for_term($term);
78
 
79
  if ( $custom_permalink ) {
80
+ return get_site_url()."/".$custom_permalink;
81
  }
82
 
83
  return $permalink;
126
  $url = preg_replace('@//*@', '/', str_replace(trim($original_permalink,'/'), trim($custom_permalink,'/'), $request));
127
  $url = preg_replace('@([^?]*)&@', '\1?', $url);
128
  }
129
+ wp_redirect( get_site_url()."/".$url, 301 );
130
  exit();
131
  }
132
  }
394
  <th scope="row"><?php _e('Custom Permalink', 'custom-permalink') ?></th>
395
  <td>
396
  <?php endif; ?>
397
+ <?php echo get_site_url() ?>/
398
  <input type="text" class="text" value="<?php echo htmlspecialchars($permalink ? $permalink : $original) ?>"
399
  style="width: 250px; <?php if ( !$permalink ) echo 'color: #ddd;' ?>"
400
  onfocus="if ( this.value == '<?php echo htmlspecialchars($original) ?>' ) { this.value = ''; this.style.color = '#000'; }"
597
  $row = array();
598
  $term = get_term($info['id'], ($info['kind'] == 'tag' ? 'post_tag' : 'category'));
599
  $row['id'] = $info['kind'].'.'.$info['id'];
600
+ $row['permalink'] = get_site_url()."/".$permalink;
601
  $row['type'] = ucwords($info['kind']);
602
  $row['title'] = $term->name;
603
  $row['editlink'] = ( $info['kind'] == 'tag' ? 'edit-tags.php?action=edit&tag_ID='.$info['id'] : 'categories.php?action=edit&cat_ID='.$info['id'] );
632
  */
633
  function custom_permalinks_original_post_link($post_id) {
634
  remove_filter( 'post_link', 'custom_permalinks_post_link', 10, 2 );
635
+ $originalPermalink = ltrim(str_replace(get_site_url(), '', get_permalink( $post_id )), '/');
636
  add_filter( 'post_link', 'custom_permalinks_post_link', 10, 2 );
637
  return $originalPermalink;
638
  }
645
  */
646
  function custom_permalinks_original_page_link($post_id) {
647
  remove_filter( 'page_link', 'custom_permalinks_page_link', 10, 2 );
648
+ $originalPermalink = ltrim(str_replace(get_site_url(), '', get_permalink( $post_id )), '/');
649
  add_filter( 'page_link', 'custom_permalinks_page_link', 10, 2 );
650
  return $originalPermalink;
651
  }
659
  */
660
  function custom_permalinks_original_tag_link($tag_id) {
661
  remove_filter( 'tag_link', 'custom_permalinks_term_link', 10, 2 );
662
+ $originalPermalink = ltrim(str_replace(get_site_url(), '', get_tag_link($tag_id)), '/');
663
  add_filter( 'tag_link', 'custom_permalinks_term_link', 10, 2 );
664
  return $originalPermalink;
665
  }
672
  */
673
  function custom_permalinks_original_category_link($category_id) {
674
  remove_filter( 'category_link', 'custom_permalinks_term_link', 10, 2 );
675
+ $originalPermalink = ltrim(str_replace(get_site_url(), '', get_category_link($category_id)), '/');
676
  add_filter( 'category_link', 'custom_permalinks_term_link', 10, 2 );
677
  return $originalPermalink;
678
  }
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: 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,6 +23,10 @@ over your site structure.
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
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: 3.1.2
7
+ Stable tag: 0.7
8
 
9
  Set custom permalinks on a per-post, per-tag or per-category basis.
10
 
23
 
24
  == Changelog ==
25
 
26
+ = 0.7 =
27
+
28
+ * Added support for SSL sites, thanks to Dan from todaywasawesome.com
29
+
30
  = 0.6.1 =
31
 
32
  * Fix bug causing incorrect link from "View Post"/"View Page" button in post/page editor