WordPress.org

Make WordPress Core

Ticket #14886: garyc40.14886.2.diff

File garyc40.14886.2.diff, 2.9 KB (added by garyc40, 7 years ago)

change the logic a bit to be more consistent with previous behavior

  • wp-admin/admin.php

    diff --git wp-admin/admin.php wp-admin/admin.php
    index ce7edfb..0449c0b 100644
    if ( isset($_GET['page']) ) { 
    8888        $plugin_page = plugin_basename($plugin_page);
    8989}
    9090
    91 if ( isset($_GET['post_type']) )
     91if ( isset($_REQUEST['post_type']) )
    9292        $typenow = sanitize_key($_GET['post_type']);
    9393else
    9494        $typenow = '';
  • wp-admin/includes/template.php

    diff --git wp-admin/includes/template.php wp-admin/includes/template.php
    index a788b8f..c96b43c 100644
    function set_current_screen( $id = '' ) { 
    20772077                $current_screen->id .= '-' . $typenow;
    20782078                $current_screen->post_type = $typenow;
    20792079        } elseif ( 'post' == $current_screen->id ) {
    2080                 if ( empty($typenow) )
     2080                if ( isset($_GET['post']) )
     2081                        $post_id = (int) $_GET['post'];
     2082                elseif ( isset($_POST['post_ID']) )
     2083                        $post_id = (int) $_POST['post_ID'];
     2084                else
     2085                        $post_id = 0;
     2086                       
     2087                $GLOBALS['post_id'] = $post_id;
     2088               
     2089                $post_type_object = null;
     2090               
     2091                if ( $post_id ) {
     2092                        $post = get_post( $post_id );
     2093                        $typenow = $post->post_type;
     2094                }
     2095               
     2096                if ( empty( $typenow ) || ! get_post_type_object( $typenow ) )
    20812097                        $typenow = 'post';
    2082                 $current_screen->id = $typenow;
    2083                 $current_screen->post_type = $typenow;
     2098               
     2099                $current_screen->id = $current_screen->post_type = $typenow;
    20842100        } elseif ( 'edit-tags' == $current_screen->id ) {
    20852101                if ( empty($taxnow) )
    20862102                        $taxnow = 'post_tag';
     2103                if ( empty( $typenow ) )
     2104                        $typenow = 'post';
    20872105                $current_screen->id = 'edit-' . $taxnow;
    20882106                $current_screen->taxonomy = $taxnow;
    20892107        }
  • wp-admin/post.php

    diff --git wp-admin/post.php wp-admin/post.php
    index 0dae46d..19e3272 100644
    $submenu_file = 'edit.php'; 
    1616
    1717wp_reset_vars(array('action', 'safe_mode', 'withcomments', 'posts', 'content', 'edited_post_title', 'comment_error', 'profile', 'trackback_url', 'excerpt', 'showcomments', 'commentstart', 'commentend', 'commentorder'));
    1818
    19 if ( isset($_GET['post']) )
    20         $post_id = (int) $_GET['post'];
    21 elseif ( isset($_POST['post_ID']) )
    22         $post_id = (int) $_POST['post_ID'];
    23 else
    24         $post_id = 0;
    2519$post_ID = $post_id;
    26 $post = null;
    27 $post_type_object = null;
    28 $post_type = null;
    29 if ( $post_id ) {
    30         $post = get_post($post_id);
    31         if ( $post ) {
    32                 $post_type_object = get_post_type_object($post->post_type);
    33                 if ( $post_type_object ) {
    34                         $post_type = $post->post_type;
    35                         $current_screen->post_type = $post->post_type;
    36                         $current_screen->id = $current_screen->post_type;
    37                 }
    38         }
    39 } elseif ( isset($_POST['post_type']) ) {
    40         $post_type_object = get_post_type_object($_POST['post_type']);
    41         if ( $post_type_object ) {
    42                 $post_type = $post_type_object->name;
    43                 $current_screen->post_type = $post_type;
    44                 $current_screen->id = $current_screen->post_type;
    45         }
    46 }
     20$post = get_post( $post_id );
     21$post_type_object = get_post_type_object( $typenow );
     22$post_type = $typenow;
    4723
    4824/**
    4925 * Redirect to previous page.