Custom Permalinks - Version 0.4.1

Version Description

Download this release

Release Info

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

Code changes from version 0.4 to 0.4.1

Files changed (2) hide show
  1. custom-permalinks.php +9 -7
  2. readme.txt +3 -1
custom-permalinks.php CHANGED
@@ -4,7 +4,7 @@ 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.4
8
  Author: Michael Tyson
9
  Author URI: http://michael.tyson.id.au
10
  */
@@ -165,11 +165,11 @@ function custom_permalinks_request($query) {
165
  if ( trim($request,'/') == trim($posts[0]->meta_value,'/') )
166
  $_CPRegisteredURL = $request;
167
 
168
- $originalUrl = str_replace( trim($posts[0]->meta_value,'/' ),
169
  ( $posts[0]->post_type == 'post' ?
170
  custom_permalinks_original_post_link($posts[0]->ID)
171
  : custom_permalinks_original_page_link($posts[0]->ID) ),
172
- trim( $request,'/' ) );
173
  }
174
 
175
  if ( !$originalUrl ) {
@@ -300,7 +300,7 @@ function custom_permalinks_page_options() {
300
  <div class="postbox closed">
301
  <h3><?php _e('Custom Permalink', 'custom-permalink') ?></h3>
302
  <div class="inside">
303
- <?php custom_permalinks_form($permalink, custom_permalinks_original_post_link($post_id)); ?>
304
  </div>
305
  </div>
306
  <?php
@@ -344,15 +344,17 @@ function custom_permalinks_term_options($object) {
344
  function custom_permalinks_form($permalink, $original="") {
345
  ?>
346
  <input value="true" type="hidden" name="custom_permalinks_edit" />
 
 
347
  <table class="form-table" id="custom_permalink_form">
348
  <tr>
349
  <th scope="row"><?php _e('Custom Permalink', 'custom-permalink') ?></th>
350
  <td>
351
  <?php echo get_option('home') ?>/
352
- <input type="text" name="custom_permalink" class="text" value="<?php echo htmlspecialchars($permalink ? $permalink : $original) ?>"
353
- style="width: 300px; <?php if ( !$permalink ) echo 'color: #ddd;' ?>"
354
  onfocus="if ( this.value == '<?php echo htmlspecialchars($original) ?>' ) { this.value = ''; this.style.color = '#000'; }"
355
- onblur="if ( this.value == '' ) { this.value = '<?php echo htmlspecialchars($original) ?>'; this.style.color = '#ddd'; }"/><br />
356
  <small><?php _e('Leave blank to disable', 'custom-permalink') ?></small>
357
  </td>
358
  </tr>
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.4.1
8
  Author: Michael Tyson
9
  Author URI: http://michael.tyson.id.au
10
  */
165
  if ( trim($request,'/') == trim($posts[0]->meta_value,'/') )
166
  $_CPRegisteredURL = $request;
167
 
168
+ $originalUrl = preg_replace('@/+@', '/', str_replace( trim($posts[0]->meta_value,'/' ),
169
  ( $posts[0]->post_type == 'post' ?
170
  custom_permalinks_original_post_link($posts[0]->ID)
171
  : custom_permalinks_original_page_link($posts[0]->ID) ),
172
+ trim( $request,'/' ) ));
173
  }
174
 
175
  if ( !$originalUrl ) {
300
  <div class="postbox closed">
301
  <h3><?php _e('Custom Permalink', 'custom-permalink') ?></h3>
302
  <div class="inside">
303
+ <?php custom_permalinks_form($permalink, custom_permalinks_original_page_link($post_id)); ?>
304
  </div>
305
  </div>
306
  <?php
344
  function custom_permalinks_form($permalink, $original="") {
345
  ?>
346
  <input value="true" type="hidden" name="custom_permalinks_edit" />
347
+ <input value="<?php echo htmlspecialchars($permalink) ?>" type="hidden" name="custom_permalink" id="custom_permalink" />
348
+
349
  <table class="form-table" id="custom_permalink_form">
350
  <tr>
351
  <th scope="row"><?php _e('Custom Permalink', 'custom-permalink') ?></th>
352
  <td>
353
  <?php echo get_option('home') ?>/
354
+ <input type="text" class="text" value="<?php echo htmlspecialchars($permalink ? $permalink : $original) ?>"
355
+ style="width: 250px; <?php if ( !$permalink ) echo 'color: #ddd;' ?>"
356
  onfocus="if ( this.value == '<?php echo htmlspecialchars($original) ?>' ) { this.value = ''; this.style.color = '#000'; }"
357
+ onblur="document.getElementById('custom_permalink').value = this.value; if ( this.value == '' ) { this.value = '<?php echo htmlspecialchars($original) ?>'; this.style.color = '#ddd'; }"/><br />
358
  <small><?php _e('Leave blank to disable', 'custom-permalink') ?></small>
359
  </td>
360
  </tr>
readme.txt CHANGED
@@ -4,7 +4,7 @@ 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.6.2
7
- Stable tag: 0.4
8
 
9
  Set custom permalinks on a per-post, per-tag or per-category basis.
10
 
@@ -23,6 +23,8 @@ over your site structure.
23
 
24
  == Changelog ==
25
 
 
 
26
  0.4: Support for pages, and a fix for draft posts/pages
27
 
28
  0.3.1: Discovered a typo that broke categories
4
  Tags: permalink, url, link, address, custom, redirect
5
  Requires at least: 2.6
6
  Tested up to: 2.6.2
7
+ Stable tag: 0.4.1
8
 
9
  Set custom permalinks on a per-post, per-tag or per-category basis.
10
 
23
 
24
  == Changelog ==
25
 
26
+ 0.4.1: WP 2.7 compatability fixes; fix for bug encountered when publishing a draft, or reverting to draft status, and fix for placeholder permalink value for pages
27
+
28
  0.4: Support for pages, and a fix for draft posts/pages
29
 
30
  0.3.1: Discovered a typo that broke categories