Make WordPress Core


Ignore:
Timestamp:
05/29/2008 10:21:36 PM (17 years ago)
Author:
ryan
Message:

Post revisions API cleanup from mdawaffe. see #6775

File:
1 edited

Legend:

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

    r7913 r8011  
    22
    33require_once('admin.php');
    4 
    5 if ( !constant('WP_POST_REVISIONS') ) {
    6     wp_redirect( 'edit.php' );
    7     exit;
    8 }
    94
    105wp_reset_vars(array('revision', 'left', 'right', 'action'));
     
    1914case 'delete' : // stubs
    2015case 'edit' :
    21     $redirect = remove_query_arg( 'action' );
     16    if ( constant('WP_POST_REVISIONS') ) // stub
     17        $redirect = remove_query_arg( 'action' );
     18    else // Revisions disabled
     19        $redirect = 'edit.php';
    2220    break;
    2321case 'restore' :
     22    if ( !$revision = wp_get_post_revision( $revision_id ) )
     23        break;
    2424    if ( !current_user_can( 'edit_post', $revision->post_parent ) )
    2525        break;
    26     if ( !$revision = wp_get_revision( $revision_id ) )
    27         break;
    2826    if ( !$post = get_post( $revision->post_parent ) )
    2927        break;
    3028
     29    if ( !constant('WP_POST_REVISIONS') && !wp_is_post_autosave( $revision ) ) // Revisions disabled and we're not looking at an autosave
     30        break;
     31
    3132    check_admin_referer( "restore-post_$post->ID|$revision->ID" );
    3233
    33     wp_restore_revision( $revision->ID );
     34    wp_restore_post_revision( $revision->ID );
    3435    $redirect = add_query_arg( array( 'message' => 5, 'revision' => $revision->ID ), get_edit_post_link( $post->ID, 'url' ) );
    3536    break;
     
    5859        break; // Don't diff two unrelated revisions
    5960
     61    if ( !constant('WP_POST_REVISIONS') ) { // Revisions disabled
     62        if (
     63            // we're not looking at an autosave
     64            ( !wp_is_post_autosave( $left_revision ) && !wp_is_post_autosave( $right_revision ) )
     65        ||
     66            // we're not comparing an autosave to the current post
     67            ( $post->ID !== $left_revision->ID && $post->ID !== $right_revision->ID )
     68        )
     69            break;
     70    }
     71
    6072    if (
    6173        // They're the same
     
    6375    ||
    6476        // Neither is a revision
    65         ( !wp_get_revision( $left_revision->ID ) && !wp_get_revision( $right_revision->ID ) )
     77        ( !wp_get_post_revision( $left_revision->ID ) && !wp_get_post_revision( $right_revision->ID ) )
    6678    )
    6779        break;
     
    7789case 'view' :
    7890default :
    79     if ( !$revision = wp_get_revision( $revision_id ) )
     91    if ( !$revision = wp_get_post_revision( $revision_id ) )
    8092        break;
    8193    if ( !$post = get_post( $revision->post_parent ) )
     
    8395
    8496    if ( !current_user_can( 'read_post', $revision->ID ) || !current_user_can( 'read_post', $post->ID ) )
     97        break;
     98
     99    if ( !constant('WP_POST_REVISIONS') && !wp_is_post_autosave( $revision ) ) // Revisions disabled and we're not looking at an autosave
    85100        break;
    86101
     
    114129
    115130// Converts post_author ID# into name
    116 add_filter( '_wp_revision_field_post_author', 'get_author_name' );
     131add_filter( '_wp_post_revision_field_post_author', 'get_author_name' );
    117132
    118133require_once( 'admin-header.php' );
     
    138153// use get_post_to_edit filters?
    139154$identical = true;
    140 foreach ( _wp_revision_fields() as $field => $field_title ) :
     155foreach ( _wp_post_revision_fields() as $field => $field_title ) :
    141156    if ( 'diff' == $action ) {
    142         $left_content = apply_filters( "_wp_revision_field_$field", $left_revision->$field, $field );
    143         $right_content = apply_filters( "_wp_revision_field_$field", $right_revision->$field, $field );
     157        $left_content = apply_filters( "_wp_post_revision_field_$field", $left_revision->$field, $field );
     158        $right_content = apply_filters( "_wp_post_revision_field_$field", $right_revision->$field, $field );
    144159        if ( !$content = wp_text_diff( $left_content, $right_content ) )
    145160            continue; // There is no difference between left and right
    146161        $identical = false;
    147162    } else {
    148         add_filter( "_wp_revision_field_$field", 'htmlspecialchars' );
    149         $content = apply_filters( "_wp_revision_field_$field", $revision->$field, $field );
     163        add_filter( "_wp_post_revision_field_$field", 'htmlspecialchars' );
     164        $content = apply_filters( "_wp_post_revision_field_$field", $revision->$field, $field );
    150165    }
    151166    ?>
     
    180195<?php
    181196
    182 wp_list_post_revisions( $post, array( 'format' => 'form-table', 'parent' => true, 'right' => $right, 'left' => $left ) );
     197$args = array( 'format' => 'form-table', 'parent' => true, 'right' => $right, 'left' => $left );
     198if ( !constant( 'WP_POST_REVISIONS' ) )
     199    $args['type'] = 'autosave';
     200
     201wp_list_post_revisions( $post, $args );
    183202
    184203require_once( 'admin-footer.php' );
Note: See TracChangeset for help on using the changeset viewer.