diff --git a/wp-admin/revision.php b/wp-admin/revision.php
index b1590ee6d7..d7410b2ac3 100644
a
|
b
|
switch ( $action ) { |
42 | 42 | break; |
43 | 43 | } |
44 | 44 | |
45 | | $post = get_post( $revision->post_parent ); |
46 | | if ( ! $post ) { |
| 45 | $parent = get_post( $revision->post_parent ); |
| 46 | if ( ! $parent ) { |
47 | 47 | break; |
48 | 48 | } |
49 | 49 | |
50 | | // Restore if revisions are enabled or this is an autosave. |
51 | | if ( ! wp_revisions_enabled( $post ) && ! wp_is_post_autosave( $revision ) ) { |
52 | | $redirect = 'edit.php?post_type=' . $post->post_type; |
| 50 | // Don't restore if revisions are disabled and this is not an autosave. |
| 51 | if ( ! wp_revisions_enabled( $parent ) && ! wp_is_post_autosave( $revision ) ) { |
| 52 | $redirect = 'edit.php?post_type=' . $parent->post_type; |
53 | 53 | break; |
54 | 54 | } |
55 | 55 | |
56 | 56 | // Don't allow revision restore when post is locked. |
57 | | if ( wp_check_post_lock( $post->ID ) ) { |
| 57 | if ( wp_check_post_lock( $parent->ID ) ) { |
58 | 58 | break; |
59 | 59 | } |
60 | 60 | |
| 61 | /** |
| 62 | * @global WP_Query $wp_query |
| 63 | */ |
| 64 | global $wp_query; |
| 65 | |
| 66 | // Set up global post variables for the use of any functions hooked into restore process. |
| 67 | $post = clone $parent; |
| 68 | $wp_query->posts = array( $post ); |
| 69 | $wp_query->post = $post; |
| 70 | setup_postdata( $post ); |
| 71 | |
61 | 72 | check_admin_referer( "restore-post_{$revision->ID}" ); |
62 | 73 | |
63 | 74 | wp_restore_post_revision( $revision->ID ); |
… |
… |
switch ( $action ) { |
66 | 77 | 'message' => 5, |
67 | 78 | 'revision' => $revision->ID, |
68 | 79 | ), |
69 | | get_edit_post_link( $post->ID, 'url' ) |
| 80 | get_edit_post_link( $parent->ID, 'url' ) |
70 | 81 | ); |
71 | 82 | break; |
72 | 83 | case 'view': |
… |
… |
switch ( $action ) { |
77 | 88 | break; |
78 | 89 | } |
79 | 90 | |
80 | | $post = get_post( $revision->post_parent ); |
81 | | if ( ! $post ) { |
| 91 | $parent = get_post( $revision->post_parent ); |
| 92 | if ( ! $parent ) { |
82 | 93 | break; |
83 | 94 | } |
84 | 95 | |
… |
… |
switch ( $action ) { |
87 | 98 | } |
88 | 99 | |
89 | 100 | // Revisions disabled and we're not looking at an autosave. |
90 | | if ( ! wp_revisions_enabled( $post ) && ! wp_is_post_autosave( $revision ) ) { |
91 | | $redirect = 'edit.php?post_type=' . $post->post_type; |
| 101 | if ( ! wp_revisions_enabled( $parent ) && ! wp_is_post_autosave( $revision ) ) { |
| 102 | $redirect = 'edit.php?post_type=' . $parent->post_type; |
92 | 103 | break; |
93 | 104 | } |
94 | 105 | |
… |
… |
switch ( $action ) { |
104 | 115 | } |
105 | 116 | |
106 | 117 | // Empty post_type means either malformed object found, or no valid parent was found. |
107 | | if ( ! $redirect && empty( $post->post_type ) ) { |
| 118 | if ( ! $redirect && empty( $parent->post_type ) ) { |
108 | 119 | $redirect = 'edit.php'; |
109 | 120 | } |
110 | 121 | |
… |
… |
if ( ! empty( $redirect ) ) { |
114 | 125 | } |
115 | 126 | |
116 | 127 | // This is so that the correct "Edit" menu item is selected. |
117 | | if ( ! empty( $post->post_type ) && 'post' != $post->post_type ) { |
118 | | $parent_file = 'edit.php?post_type=' . $post->post_type; |
| 128 | if ( ! empty( $parent->post_type ) && 'post' != $parent->post_type ) { |
| 129 | $parent_file = 'edit.php?post_type=' . $parent->post_type; |
119 | 130 | } else { |
120 | 131 | $parent_file = 'edit.php'; |
121 | 132 | } |
122 | 133 | $submenu_file = $parent_file; |
123 | 134 | |
124 | 135 | wp_enqueue_script( 'revisions' ); |
125 | | wp_localize_script( 'revisions', '_wpRevisionsSettings', wp_prepare_revisions_for_js( $post, $revision_id, $from ) ); |
| 136 | wp_localize_script( 'revisions', '_wpRevisionsSettings', wp_prepare_revisions_for_js( $parent, $revision_id, $from ) ); |
126 | 137 | |
127 | 138 | /* Revisions Help Tab */ |
128 | 139 | |