Make WordPress Core

Changeset 13865


Ignore:
Timestamp:
03/28/2010 05:23:49 AM (13 years ago)
Author:
dd32
Message:

Fix the Permalink editor for custom post_types. Fixes #12742

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/post.php

    r13769 r13865  
    10121012function get_sample_permalink($id, $title = null, $name = null) {
    10131013    $post = &get_post($id);
    1014     if ( !$post->ID ) {
     1014    if ( !$post->ID )
    10151015        return array('', '');
    1016     }
     1016
     1017    $ptype = get_post_type_object($post->post_type);
     1018
    10171019    $original_status = $post->post_status;
    10181020    $original_date = $post->post_date;
     
    10301032    // If the user wants to set a new name -- override the current one
    10311033    // Note: if empty name is supplied -- use the title instead, see #6072
    1032     if ( !is_null($name) ) {
     1034    if ( !is_null($name) )
    10331035        $post->post_name = sanitize_title($name ? $name : $title, $post->ID);
    1034     }
    10351036
    10361037    $post->filter = 'sample';
     
    10381039    $permalink = get_permalink($post, true);
    10391040
     1041    if ( $ptype->query_var ) // Replace custom post_type Token with generic pagename token for ease of use.
     1042        $permalink = str_replace('%' . $ptype->query_var . '%', '%pagename%', $permalink);
     1043
    10401044    // Handle page hierarchy
    1041     if ( 'page' == $post->post_type ) {
     1045    if ( $ptype->hierarchical ) {
    10421046        $uri = get_page_uri($post->ID);
    10431047        $uri = untrailingslashit($uri);
     
    10451049        $uri = untrailingslashit($uri);
    10461050        if ( !empty($uri) )
    1047             $uri .='/';
     1051            $uri .= '/';
    10481052        $permalink = str_replace('%pagename%', "${uri}%pagename%", $permalink);
    10491053    }
     
    10751079
    10761080    if ( 'publish' == $post->post_status ) {
    1077         $view_post = 'post' == $post->post_type ? __('View Post') : __('View Page');
     1081        if ( 'post' == $post->post_type ) {
     1082            $view_post = __('View Post');
     1083        } elseif ( 'page' == $post->post_type ) {
     1084            $view_post = __('View Page');
     1085        } else {
     1086            $ptype = get_post_type_object($post->post_type);
     1087            $view_post = sprintf(__('View %s'), $ptype->singular_label);
     1088        }
    10781089        $title = __('Click to edit this part of the permalink');
    10791090    } else {
  • trunk/wp-includes/link-template.php

    r13831 r13865  
    109109        return get_attachment_link($post->ID);
    110110    elseif ( in_array($post->post_type, get_post_types( array('_builtin' => false) ) ) )
    111         return get_post_permalink($post);
     111        return get_post_permalink($post, $leavename);
    112112
    113113    $permalink = get_option('permalink_structure');
Note: See TracChangeset for help on using the changeset viewer.