Make WordPress Core


Ignore:
Timestamp:
01/18/2010 11:44:51 AM (15 years ago)
Author:
dd32
Message:

Introduce Revisioning for custom Post Types, Introduce 'supports' argument to register_post_type() to wrap add_post_type_support(), Whitespace additions to create_initial_post_types(). See #9674. Fixes #11703

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/revision.php

    r12500 r12751  
    1313
    1414wp_reset_vars(array('revision', 'left', 'right', 'diff', 'action'));
     15
    1516$revision_id = absint($revision);
    1617$diff        = absint($diff);
     
    1819$right       = absint($right);
    1920
    20 $parent_file = $redirect = 'edit.php';
     21$redirect = 'edit.php';
    2122
    2223switch ( $action ) :
    23 case 'delete' : // stubs
    24 case 'edit' :
    25     if ( constant('WP_POST_REVISIONS') ) // stub
    26         $redirect = remove_query_arg( 'action' );
    27     else // Revisions disabled
    28         $redirect = 'edit.php';
    29     break;
    3024case 'restore' :
    3125    if ( !$revision = wp_get_post_revision( $revision_id ) )
     
    116110        break;
    117111
     112    $post_type_object = get_post_type_object($post->post_type);
     113
    118114    $post_title = '<a href="' . get_edit_post_link() . '">' . get_the_title() . '</a>';
    119115    $revision_title = wp_post_revision_title( $revision, false );
    120     $h2 = sprintf( __( 'Post Revision for &#8220;%1$s&#8221; created on %2$s' ), $post_title, $revision_title );
     116    $h2 = sprintf( __( 'Revision for &#8220;%1$s&#8221; created on %2$s' ), $post_title, $revision_title );
     117    $title = __( 'Revisions' );
    121118
    122119    // Sets up the diff radio buttons
     
    128125endswitch;
    129126
    130 if ( !$redirect && !in_array( $post->post_type, array( 'post', 'page' ) ) )
    131     $redirect = 'edit.php';
    132 
    133 if ( $redirect ) {
     127if ( !$redirect ) {
     128    if ( empty($post->post_type) ) // Empty post_type means either malformed object found, or no valid parent was found.
     129        $redirect = 'edit.php';
     130    elseif ( !post_type_supports($post->post_type, 'revisions') )
     131        $redirect = 'edit.php?post_type=' . $post->post_type;
     132}
     133
     134if ( !empty($redirect) ) {
    134135    wp_redirect( $redirect );
    135136    exit;
    136137}
    137138
    138 if ( 'page' == $post->post_type ) {
    139     $submenu_file = 'edit-pages.php';
    140     $title = __( 'Page Revisions' );
    141 } else {
    142     $submenu_file = 'edit.php';
    143     $title = __( 'Post Revisions' );
    144 }
     139// This is so that the correct "Edit" menu item is selected.
     140if ( !empty($post->post_type) && 'post' != $post->post_type )
     141    $parent_file = $submenu_file = 'edit.php?post_type=' . $post->post_type;
     142else
     143    $parent_file = $submenu_file = 'edit.php';
    145144
    146145require_once( 'admin-header.php' );
Note: See TracChangeset for help on using the changeset viewer.