Make WordPress Core

Ticket #46671: 46671.diff

File 46671.diff, 2.7 KB (added by markparnell, 4 years ago)

Renamed $post variable to $parent to avoid conflicts with global variable

  • wp-admin/revision.php

    diff --git a/wp-admin/revision.php b/wp-admin/revision.php
    index b1590ee6d7..5cbf5cd408 100644
    a b switch ( $action ) { 
    4242                        break;
    4343                }
    4444
    45                 $post = get_post( $revision->post_parent );
    46                 if ( ! $post ) {
     45                $parent = get_post( $revision->post_parent );
     46                if ( ! $parent ) {
    4747                        break;
    4848                }
    4949
    5050                // 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;
     51                if ( ! wp_revisions_enabled( $parent ) && ! wp_is_post_autosave( $revision ) ) {
     52                        $redirect = 'edit.php?post_type=' . $parent->post_type;
    5353                        break;
    5454                }
    5555
    5656                // 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 ) ) {
    5858                        break;
    5959                }
    6060
    switch ( $action ) { 
    6666                                'message'  => 5,
    6767                                'revision' => $revision->ID,
    6868                        ),
    69                         get_edit_post_link( $post->ID, 'url' )
     69                        get_edit_post_link( $parent->ID, 'url' )
    7070                );
    7171                break;
    7272        case 'view':
    switch ( $action ) { 
    7777                        break;
    7878                }
    7979
    80                 $post = get_post( $revision->post_parent );
    81                 if ( ! $post ) {
     80                $parent = get_post( $revision->post_parent );
     81                if ( ! $parent ) {
    8282                        break;
    8383                }
    8484
    switch ( $action ) { 
    8787                }
    8888
    8989                // 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;
     90                if ( ! wp_revisions_enabled( $parent ) && ! wp_is_post_autosave( $revision ) ) {
     91                        $redirect = 'edit.php?post_type=' . $parent->post_type;
    9292                        break;
    9393                }
    9494
    switch ( $action ) { 
    104104}
    105105
    106106// Empty post_type means either malformed object found, or no valid parent was found.
    107 if ( ! $redirect && empty( $post->post_type ) ) {
     107if ( ! $redirect && empty( $parent->post_type ) ) {
    108108        $redirect = 'edit.php';
    109109}
    110110
    if ( ! empty( $redirect ) ) { 
    114114}
    115115
    116116// 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;
     117if ( ! empty( $parent->post_type ) && 'post' != $parent->post_type ) {
     118        $parent_file = 'edit.php?post_type=' . $parent->post_type;
    119119} else {
    120120        $parent_file = 'edit.php';
    121121}
    122122$submenu_file = $parent_file;
    123123
    124124wp_enqueue_script( 'revisions' );
    125 wp_localize_script( 'revisions', '_wpRevisionsSettings', wp_prepare_revisions_for_js( $post, $revision_id, $from ) );
     125wp_localize_script( 'revisions', '_wpRevisionsSettings', wp_prepare_revisions_for_js( $parent, $revision_id, $from ) );
    126126
    127127/* Revisions Help Tab */
    128128