post_parent ) ) break; if ( !$post = get_post( $revision->post_parent ) ) break; // Revisions disabled and we're not looking at an autosave if ( ( ! WP_POST_REVISIONS || !post_type_supports($post->post_type, 'revisions') ) && !wp_is_post_autosave( $revision ) ) { $redirect = 'edit.php?post_type=' . $post->post_type; break; } check_admin_referer( "restore-post_{$post->ID}|{$revision->ID}" ); wp_restore_post_revision( $revision->ID ); $redirect = add_query_arg( array( 'message' => 5, 'revision' => $revision->ID ), get_edit_post_link( $post->ID, 'url' ) ); break; case 'view' : case 'edit' : default : if ( !$revision = wp_get_post_revision( $revision_id ) ) break; if ( !$post = get_post( $revision->post_parent ) ) break; if ( !current_user_can( 'read_post', $revision->ID ) || !current_user_can( 'read_post', $post->ID ) ) break; // Revisions disabled and we're not looking at an autosave if ( ( ! WP_POST_REVISIONS || !post_type_supports($post->post_type, 'revisions') ) && !wp_is_post_autosave( $revision ) ) { $redirect = 'edit.php?post_type=' . $post->post_type; break; } $post_title = '' . get_the_title() . ''; $revision_title = wp_post_revision_title( $revision, false ); $h2 = sprintf( __( 'Compare Revisions of “%1$s”' ), $post_title ); $title = __( 'Revisions' ); $redirect = false; break; endswitch; // Empty post_type means either malformed object found, or no valid parent was found. if ( !$redirect && empty($post->post_type) ) $redirect = 'edit.php'; if ( !empty($redirect) ) { wp_redirect( $redirect ); exit; } // This is so that the correct "Edit" menu item is selected. if ( !empty($post->post_type) && 'post' != $post->post_type ) $parent_file = $submenu_file = 'edit.php?post_type=' . $post->post_type; else $parent_file = $submenu_file = 'edit.php'; wp_enqueue_style( 'wp-jquery-ui-slider' ); wp_enqueue_script( 'revisions' ); require_once( './admin-header.php' ); //TODO - Some of the translations below split things into multiple strings that are contextually related and this makes it pretty impossible for RTL translation. //TODO can we pass the context in a better way ?>