WordPress.org

Make WordPress Core


Ignore:
Timestamp:
01/04/2010 04:58:43 PM (10 years ago)
Author:
ryan
Message:

More custom post type support. Props scribu. see #9674

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/link-template.php

    r12590 r12597  
    679679
    680680    if ( 'display' == $context )
    681         $action = 'action=edit&';
     681        $action = '&action=edit';
    682682    else
    683         $action = 'action=edit&';
    684 
    685     switch ( $post->post_type ) :
    686     case 'page' :
    687         if ( !current_user_can( 'edit_page', $post->ID ) )
    688             return;
    689         $file = 'page';
    690         $var  = 'post';
    691         break;
    692     case 'attachment' :
    693         if ( !current_user_can( 'edit_post', $post->ID ) )
    694             return;
    695         $file = 'media';
    696         $var  = 'attachment_id';
    697         break;
    698     case 'revision' :
    699         if ( !current_user_can( 'edit_post', $post->ID ) )
    700             return;
    701         $file = 'revision';
    702         $var  = 'revision';
    703         $action = '';
    704         break;
    705     default :
    706         if ( !current_user_can( 'edit_post', $post->ID ) )
    707             return apply_filters( 'get_edit_post_link', '', $post->ID, $context );
    708         $file = 'post';
    709         $var  = 'post';
    710         break;
    711     endswitch;
    712 
    713     return apply_filters( 'get_edit_post_link', admin_url("$file.php?{$action}$var=$post->ID"), $post->ID, $context );
     683        $action = '&action=edit';
     684
     685    $post_type_object = get_post_type_object( $post->post_type );
     686    if ( !$post_type_object )
     687        return;
     688
     689    if ( !current_user_can( $post_type_object->edit_cap, $post->ID ) )
     690        return;
     691
     692    return apply_filters( 'get_edit_post_link', admin_url( sprintf($post_type_object->_edit_link . $action, $post->ID) ), $post->ID, $context );
    714693}
    715694
Note: See TracChangeset for help on using the changeset viewer.