Custom Permalinks - Version 0.7.16

Version Description

  • Security and compatibility fixes by Hans-Michael Varbaek of Sense of Security
Download this release

Release Info

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

Code changes from version 0.7.15 to 0.7.16

Files changed (3) hide show
  1. custom-permalinks.php +44 -37
  2. index.html +0 -0
  3. readme.txt +5 -1
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.15
8
  Author: Michael Tyson
9
  Author URI: http://atastypixel.com/blog
10
  */
@@ -164,8 +164,8 @@ function custom_permalinks_request($query) {
164
  "LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) WHERE ".
165
  " meta_key = 'custom_permalink' AND ".
166
  " meta_value != '' AND ".
167
- " ( LOWER(meta_value) = LEFT(LOWER('".mysql_escape_string($request_noslash)."'), LENGTH(meta_value)) OR ".
168
- " LOWER(meta_value) = LEFT(LOWER('".mysql_escape_string($request_noslash."/")."'), LENGTH(meta_value)) ) ".
169
  "ORDER BY LENGTH(meta_value) DESC LIMIT 1";
170
 
171
  $posts = $wpdb->get_results($sql);
@@ -507,7 +507,7 @@ function custom_permalinks_save_term($term, $permalink) {
507
  */
508
  function custom_permalinks_delete_permalink( $id ){
509
  global $wpdb;
510
- $wpdb->query("DELETE FROM $wpdb->postmeta WHERE `meta_key` = 'custom_permalink' AND `post_id` = '".mysql_escape_string($id)."'");
511
  }
512
 
513
  /**
@@ -559,9 +559,9 @@ function custom_permalinks_options_page() {
559
  $redirectUrl = $_SERVER['REQUEST_URI'];
560
  ?>
561
  <script type="text/javascript">
562
- document.location = '<?php echo $redirectUrl ?>';
563
  </script>
564
- <?php
565
  }
566
 
567
  ?>
@@ -630,7 +630,7 @@ function custom_permalinks_admin_rows() {
630
  $row['permalink'] = get_home_url()."/".$permalink;
631
  $row['type'] = ucwords($info['kind']);
632
  $row['title'] = $term->name;
633
- $row['editlink'] = ( $info['kind'] == 'tag' ? 'edit-tags.php?action=edit&tag_ID='.$info['id'] : 'categories.php?action=edit&cat_ID='.$info['id'] );
634
  $rows[] = $row;
635
  }
636
  }
@@ -750,36 +750,43 @@ if ( !function_exists("get_home_url") ) {
750
  }
751
  }
752
 
753
- $v = explode('.', get_bloginfo('version'));
754
-
755
- add_action( 'template_redirect', 'custom_permalinks_redirect', 5 );
756
- add_filter( 'post_link', 'custom_permalinks_post_link', 10, 2 );
757
- add_filter( 'post_type_link', 'custom_permalinks_post_link', 10, 2 );
758
- add_filter( 'page_link', 'custom_permalinks_page_link', 10, 2 );
759
- add_filter( 'tag_link', 'custom_permalinks_term_link', 10, 2 );
760
- add_filter( 'category_link', 'custom_permalinks_term_link', 10, 2 );
761
- add_filter( 'request', 'custom_permalinks_request', 10, 1 );
762
- add_filter( 'user_trailingslashit', 'custom_permalinks_trailingslash', 10, 2 );
763
-
764
- if ( $v[0] >= 2 ) {
765
- add_filter( 'get_sample_permalink_html', 'custom_permalink_get_sample_permalink_html', 10, 4 );
766
- } else {
767
- add_action( 'edit_form_advanced', 'custom_permalinks_post_options' );
768
- add_action( 'edit_page_form', 'custom_permalinks_page_options' );
769
- }
770
 
771
- add_action( 'edit_tag_form', 'custom_permalinks_term_options' );
772
- add_action( 'add_tag_form', 'custom_permalinks_term_options' );
773
- add_action( 'edit_category_form', 'custom_permalinks_term_options' );
774
- add_action( 'save_post', 'custom_permalinks_save_post' );
775
- add_action( 'save_page', 'custom_permalinks_save_post' );
776
- add_action( 'edited_post_tag', 'custom_permalinks_save_tag' );
777
- add_action( 'edited_category', 'custom_permalinks_save_category' );
778
- add_action( 'create_post_tag', 'custom_permalinks_save_tag' );
779
- add_action( 'create_category', 'custom_permalinks_save_category' );
780
- add_action( 'delete_post', 'custom_permalinks_delete_permalink', 10);
781
- add_action( 'delete_post_tag', 'custom_permalinks_delete_term' );
782
- add_action( 'delete_post_category', 'custom_permalinks_delete_term' );
783
- add_action( 'admin_menu', 'custom_permalinks_setup_admin' );
784
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
785
  ?>
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.16
8
  Author: Michael Tyson
9
  Author URI: http://atastypixel.com/blog
10
  */
164
  "LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) WHERE ".
165
  " meta_key = 'custom_permalink' AND ".
166
  " meta_value != '' AND ".
167
+ " ( LOWER(meta_value) = LEFT(LOWER('".mysql_real_escape_string($request_noslash)."'), LENGTH(meta_value)) OR ".
168
+ " LOWER(meta_value) = LEFT(LOWER('".mysql_real_escape_string($request_noslash."/")."'), LENGTH(meta_value)) ) ".
169
  "ORDER BY LENGTH(meta_value) DESC LIMIT 1";
170
 
171
  $posts = $wpdb->get_results($sql);
507
  */
508
  function custom_permalinks_delete_permalink( $id ){
509
  global $wpdb;
510
+ $wpdb->query("DELETE FROM $wpdb->postmeta WHERE `meta_key` = 'custom_permalink' AND `post_id` = '".mysql_real_escape_string($id)."'");
511
  }
512
 
513
  /**
559
  $redirectUrl = $_SERVER['REQUEST_URI'];
560
  ?>
561
  <script type="text/javascript">
562
+ document.location = '<?php echo $redirectUrl ?>'
563
  </script>
564
+ <?php ;
565
  }
566
 
567
  ?>
630
  $row['permalink'] = get_home_url()."/".$permalink;
631
  $row['type'] = ucwords($info['kind']);
632
  $row['title'] = $term->name;
633
+ $row['editlink'] = ( $info['kind'] == 'tag' ? 'edit-tags.php?action=edit&taxonomy=post_tag&tag_ID='.$info['id'] : 'edit-tags.php?action=edit&taxonomy=category&tag_ID='.$info['id'] );
634
  $rows[] = $row;
635
  }
636
  }
750
  }
751
  }
752
 
753
+ # Check whether we're running within the WP environment, to avoid showing errors like
754
+ # "Fatal error: Call to undefined function get_bloginfo() in C:\xampp\htdocs\custom-permalinks\custom-permalinks.php on line 753"
755
+ # and similar errors that occurs when the script is called directly to e.g. find out the full path.
756
+
757
+ if (function_exists("add_action") && function_exists("add_filter")) {
758
+ add_action( 'template_redirect', 'custom_permalinks_redirect', 5 );
759
+ add_filter( 'post_link', 'custom_permalinks_post_link', 10, 2 );
760
+ add_filter( 'post_type_link', 'custom_permalinks_post_link', 10, 2 );
761
+ add_filter( 'page_link', 'custom_permalinks_page_link', 10, 2 );
762
+ add_filter( 'tag_link', 'custom_permalinks_term_link', 10, 2 );
763
+ add_filter( 'category_link', 'custom_permalinks_term_link', 10, 2 );
764
+ add_filter( 'request', 'custom_permalinks_request', 10, 1 );
765
+ add_filter( 'user_trailingslashit', 'custom_permalinks_trailingslash', 10, 2 );
766
+
767
+ if (function_exists("get_bloginfo")) {
768
+ $v = explode('.', get_bloginfo('version'));
769
+ }
770
 
771
+ if ( $v[0] >= 2 ) {
772
+ add_filter( 'get_sample_permalink_html', 'custom_permalink_get_sample_permalink_html', 10, 4 );
773
+ } else {
774
+ add_action( 'edit_form_advanced', 'custom_permalinks_post_options' );
775
+ add_action( 'edit_page_form', 'custom_permalinks_page_options' );
776
+ }
 
 
 
 
 
 
 
777
 
778
+ add_action( 'edit_tag_form', 'custom_permalinks_term_options' );
779
+ add_action( 'add_tag_form', 'custom_permalinks_term_options' );
780
+ add_action( 'edit_category_form', 'custom_permalinks_term_options' );
781
+ add_action( 'save_post', 'custom_permalinks_save_post' );
782
+ add_action( 'save_page', 'custom_permalinks_save_post' );
783
+ add_action( 'edited_post_tag', 'custom_permalinks_save_tag' );
784
+ add_action( 'edited_category', 'custom_permalinks_save_category' );
785
+ add_action( 'create_post_tag', 'custom_permalinks_save_tag' );
786
+ add_action( 'create_category', 'custom_permalinks_save_category' );
787
+ add_action( 'delete_post', 'custom_permalinks_delete_permalink', 10);
788
+ add_action( 'delete_post_tag', 'custom_permalinks_delete_term' );
789
+ add_action( 'delete_post_category', 'custom_permalinks_delete_term' );
790
+ add_action( 'admin_menu', 'custom_permalinks_setup_admin' );
791
+ }
792
  ?>
index.html ADDED
File without changes
readme.txt CHANGED
@@ -4,7 +4,7 @@ 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.3.1
7
- Stable tag: 0.7.15
8
 
9
  Set custom permalinks on a per-post, per-tag or per-category basis.
10
 
@@ -29,6 +29,10 @@ within that category.
29
 
30
  == Changelog ==
31
 
 
 
 
 
32
  = 0.7.15 =
33
 
34
  * Permalinks are now case-insensitive (thanks to @ericmann)
4
  Tags: permalink, url, link, address, custom, redirect
5
  Requires at least: 2.6
6
  Tested up to: 3.3.1
7
+ Stable tag: 0.7.16
8
 
9
  Set custom permalinks on a per-post, per-tag or per-category basis.
10
 
29
 
30
  == Changelog ==
31
 
32
+ = 0.7.16 =
33
+
34
+ * Security and compatibility fixes by Hans-Michael Varbaek of Sense of Security
35
+
36
  = 0.7.15 =
37
 
38
  * Permalinks are now case-insensitive (thanks to @ericmann)