WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/24/2011 06:34:08 PM (9 years ago)
Author:
nacin
Message:

Move WP_Screen to a full registry. Have convert_to_screen() return a WP_Screen object. Improve and verify values for post_type and taxonomy. see #18785. also fixes #14886.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/post.php

    r18796 r19052  
    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;
    25 $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     }
     19if ( isset( $_GET['post'] ) )
     20    $post_id = $post_ID = (int) $_GET['post'];
     21elseif ( isset( $_POST['post_ID'] ) )
     22    $post_id = $post_ID = (int) $_POST['post_ID'];
     23 else
     24    $post_id = $post_ID = 0;
     25
     26$post = $post_type = $post_type_object = null;
     27
     28if ( $post_id )
     29    $post = get_post( $post_id );
     30
     31if ( $post ) {
     32    $post_type = $post->post_type;
     33    $post_type_object = get_post_type_object( $post_type );
    4634}
    4735
Note: See TracChangeset for help on using the changeset viewer.