Plugin Directory

Changeset 1431045


Ignore:
Timestamp:
06/06/2016 01:06:59 AM (10 years ago)
Author:
michaeltyson
Message:

Tagged 0.7.25: Fixed draft preview issues

Location:
custom-permalinks
Files:
4 added
2 edited

Legend:

Unmodified
Added
Removed
  • custom-permalinks/trunk/custom-permalinks.php

    r1402771 r1431045  
    55Donate link: http://atastypixel.com/blog/wordpress/plugins/custom-permalinks/
    66Description: Set custom permalinks on a per-post basis
    7 Version: 0.7.23
     7Version: 0.7.25
    88Author: Michael Tyson
    99Author URI: http://atastypixel.com/blog
     
    162162 
    163163  // Queries are now WP3.9 compatible (by Steve from Sowmedia.nl)
    164     $sql = $wpdb->prepare("SELECT $wpdb->posts.ID, $wpdb->postmeta.meta_value, $wpdb->posts.post_type FROM $wpdb->posts  ".
    165               "LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) WHERE ".
    166               "  meta_key = 'custom_permalink' AND ".
    167               "  meta_value != '' AND ".
    168               "  ( LOWER(meta_value) = LEFT(LOWER('%s'), LENGTH(meta_value)) OR ".
    169               "    LOWER(meta_value) = LEFT(LOWER('%s'), LENGTH(meta_value)) ) ".
    170               "  AND post_status != 'trash' AND post_type != 'nav_menu_item'".
    171               " ORDER BY LENGTH(meta_value) DESC, ".
    172               " FIELD(post_status,'publish','private','draft','auto-draft','inherit'),".
    173               " FIELD(post_type,'post','page'),".
    174               "$wpdb->posts.ID ASC  LIMIT 1",
    175       $request_noslash,
    176       $request_noslash."/"
    177         );
     164  $sql = $wpdb->prepare("SELECT $wpdb->posts.ID, $wpdb->postmeta.meta_value, $wpdb->posts.post_type, $wpdb->posts.post_status FROM $wpdb->posts  ".
     165            "LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) WHERE ".
     166            "  meta_key = 'custom_permalink' AND ".
     167            "  meta_value != '' AND ".
     168            "  ( LOWER(meta_value) = LEFT(LOWER('%s'), LENGTH(meta_value)) OR ".
     169            "    LOWER(meta_value) = LEFT(LOWER('%s'), LENGTH(meta_value)) ) ".
     170            "  AND post_status != 'trash' AND post_type != 'nav_menu_item'".
     171            " ORDER BY LENGTH(meta_value) DESC, ".
     172            " FIELD(post_status,'publish','private','draft','auto-draft','inherit'),".
     173            " FIELD(post_type,'post','page'),".
     174            "$wpdb->posts.ID ASC  LIMIT 1",
     175    $request_noslash,
     176    $request_noslash."/");
    178177
    179178  $posts = $wpdb->get_results($sql);
     
    185184    if ( $request_noslash == trim($posts[0]->meta_value,'/') )
    186185      $_CPRegisteredURL = $request;
    187        
    188     $originalUrl =  preg_replace( '@/+@', '/', str_replace( trim( strtolower($posts[0]->meta_value),'/' ),
    189                   ( $posts[0]->post_type == 'page' ?
    190                       custom_permalinks_original_page_link($posts[0]->ID)
    191                       : custom_permalinks_original_post_link($posts[0]->ID) ),
    192                    strtolower($request_noslash) ) );
     186   
     187    if ( $posts[0]->post_status == 'draft' ) {
     188      $originalUrl = "?p=" . $posts[0]->ID;
     189    } else {
     190      $originalUrl =  preg_replace( '@/+@', '/', str_replace( trim( strtolower($posts[0]->meta_value),'/' ),
     191                    ( $posts[0]->post_type == 'page' ?
     192                        custom_permalinks_original_page_link($posts[0]->ID)
     193                        : custom_permalinks_original_post_link($posts[0]->ID) ),
     194                     strtolower($request_noslash) ) );
     195    }
    193196  }
    194197
  • custom-permalinks/trunk/readme.txt

    r1402771 r1431045  
    44Tags: permalink, url, link, address, custom, redirect
    55Requires at least: 2.6
    6 Tested up to: 4.5
    7 Stable tag: 0.7.24
     6Tested up to: 4.5.2
     7Stable tag: 0.7.25
    88
    99Set custom permalinks on a per-post, per-tag or per-category basis.
     
    2929
    3030== Changelog ==
     31
     32= 0.7.25 =
     33
     34 * Fixed draft preview issue
    3135
    3236= 0.7.24 =
Note: See TracChangeset for help on using the changeset viewer.