Ticket #46671: 46671.3.diff
| File 46671.3.diff, 3.7 KB (added by , 5 years ago) |
|---|
-
src/wp-admin/revision.php
42 42 break; 43 43 } 44 44 45 $p ost = get_post( $revision->post_parent );46 if ( ! $p ost ) {45 $parent = get_post( $revision->post_parent ); 46 if ( ! $parent ) { 47 47 break; 48 48 } 49 49 50 50 // Don't restore if revisions are disabled and this is not an autosave. 51 if ( ! wp_revisions_enabled( $p ost ) && ! wp_is_post_autosave( $revision ) ) {52 $redirect = 'edit.php?post_type=' . $p ost->post_type;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 restore if the post is locked. 57 if ( wp_check_post_lock( $p ost->ID ) ) {57 if ( wp_check_post_lock( $parent->ID ) ) { 58 58 break; 59 59 } 60 60 61 61 check_admin_referer( "restore-post_{$revision->ID}" ); 62 62 63 // Set up global post variable for the use of any functions hooked into restore process. 64 $post = clone $parent; 65 $wp_query->post = $post; 66 63 67 wp_restore_post_revision( $revision->ID ); 64 68 65 69 $redirect = add_query_arg( … … 67 71 'message' => 5, 68 72 'revision' => $revision->ID, 69 73 ), 70 get_edit_post_link( $p ost->ID, 'url' )74 get_edit_post_link( $parent->ID, 'url' ) 71 75 ); 72 76 break; 73 77 case 'view': … … 78 82 break; 79 83 } 80 84 81 $p ost = get_post( $revision->post_parent );82 if ( ! $p ost ) {85 $parent = get_post( $revision->post_parent ); 86 if ( ! $parent ) { 83 87 break; 84 88 } 85 89 … … 88 92 } 89 93 90 94 // Bail if revisions are disabled and this is not an autosave. 91 if ( ! wp_revisions_enabled( $p ost ) && ! wp_is_post_autosave( $revision ) ) {92 $redirect = 'edit.php?post_type=' . $p ost->post_type;95 if ( ! wp_revisions_enabled( $parent ) && ! wp_is_post_autosave( $revision ) ) { 96 $redirect = 'edit.php?post_type=' . $parent->post_type; 93 97 break; 94 98 } 95 99 96 $post_edit_link = get_edit_post_link( );97 $post_title = '<a href="' . $post_edit_link . '">' . _draft_or_post_title( ) . '</a>';100 $post_edit_link = get_edit_post_link( $parent ); 101 $post_title = '<a href="' . $post_edit_link . '">' . _draft_or_post_title( $parent ) . '</a>'; 98 102 /* translators: %s: Post title. */ 99 103 $h1 = sprintf( __( 'Compare Revisions of “%s”' ), $post_title ); 100 104 $return_to_post = '<a href="' . $post_edit_link . '">' . __( '← Return to editor' ) . '</a>'; … … 105 109 } 106 110 107 111 // Empty post_type means either malformed object found, or no valid parent was found. 108 if ( ! $redirect && empty( $p ost->post_type ) ) {112 if ( ! $redirect && empty( $parent->post_type ) ) { 109 113 $redirect = 'edit.php'; 110 114 } 111 115 … … 115 119 } 116 120 117 121 // This is so that the correct "Edit" menu item is selected. 118 if ( ! empty( $p ost->post_type ) && 'post' != $post->post_type ) {119 $parent_file = 'edit.php?post_type=' . $p ost->post_type;122 if ( ! empty( $parent->post_type ) && 'post' != $parent->post_type ) { 123 $parent_file = 'edit.php?post_type=' . $parent->post_type; 120 124 } else { 121 125 $parent_file = 'edit.php'; 122 126 } … … 123 127 $submenu_file = $parent_file; 124 128 125 129 wp_enqueue_script( 'revisions' ); 126 wp_localize_script( 'revisions', '_wpRevisionsSettings', wp_prepare_revisions_for_js( $p ost, $revision_id, $from ) );130 wp_localize_script( 'revisions', '_wpRevisionsSettings', wp_prepare_revisions_for_js( $parent, $revision_id, $from ) ); 127 131 128 132 /* Revisions Help Tab */ 129 133 … … 157 161 <?php echo $return_to_post; ?> 158 162 </div> 159 163 <?php 164 // Set up global post variable for wp_print_revision_templates(). 165 $post = clone $parent; 166 160 167 wp_print_revision_templates(); 161 168 162 169 require_once ABSPATH . 'wp-admin/admin-footer.php';