WordPress.org

Make WordPress Core

Changeset 12708


Ignore:
Timestamp:
01/12/2010 04:50:37 PM (11 years ago)
Author:
ryan
Message:

Merge page.php into post.php. see #9674

Location:
trunk
Files:
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/edit-form-advanced.php

    r12695 r12708  
    4141    __('Custom field updated.'),
    4242    __('Custom field deleted.'),
     43    __('Page updated.'),
     44    isset($_GET['revision']) ? sprintf( __('Page restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
    4345    sprintf( __('Page published. <a href="%s">View page</a>'), get_permalink($post_ID) ),
    44     isset($_GET['revision']) ? sprintf( __('Page restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
    4546    sprintf( __('Page submitted. <a target="_blank" href="%s">Preview page</a>'), add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ),
    4647    // translators: Publish box date format, see http://php.net/date - Same as in meta-boxes.php
  • trunk/wp-admin/post.php

    r12597 r12708  
    1717wp_reset_vars(array('action', 'safe_mode', 'withcomments', 'posts', 'content', 'edited_post_title', 'comment_error', 'profile', 'trackback_url', 'excerpt', 'showcomments', 'commentstart', 'commentend', 'commentorder'));
    1818
     19if ( isset($_GET['post']) )
     20    $post_id = (int) $_GET['post'];
     21elseif ( isset($_POST['post_ID']) )
     22    $post_id = (int) $_POST['post_ID'];
     23else
     24    $post_id = 0;
     25$post_ID = $post_id;
     26
     27$post = null;
     28$post_type_object = null;
     29$post_type_cap = null;
     30if ( $post_id ) {
     31    $post = get_post($post_id);
     32    if ( $post ) {
     33        $post_type_object = get_post_type_object($post->post_type);
     34        if ( $post_type_object )
     35            $post_type_cap = $post_type_object->capability_type;
     36    }
     37}
     38
    1939/**
    2040 * Redirect to previous page.
    2141 *
    22  * @param int $post_ID Optional. Post ID.
     42 * @param int $post_id Optional. Post ID.
    2343 */
    24 function redirect_post($post_ID = '') {
     44function redirect_post($post_id = '') {
    2545    global $action;
    2646
     
    3858            $location = 'sidebar.php?a=b';
    3959    } elseif ( isset($_POST['save']) || isset($_POST['publish']) ) {
    40         $status = get_post_status( $post_ID );
     60        $status = get_post_status( $post_id );
    4161
    4262        if ( isset( $_POST['publish'] ) ) {
     
    5575        }
    5676
    57         $location = add_query_arg( 'message', $message, get_edit_post_link( $post_ID, 'url' ) );
     77        $location = add_query_arg( 'message', $message, get_edit_post_link( $post_id, 'url' ) );
    5878    } elseif ( isset($_POST['addmeta']) && $_POST['addmeta'] ) {
    5979        $location = add_query_arg( 'message', 2, wp_get_referer() );
     
    6585        $location = $location[0] . '#postcustom';
    6686    } elseif ( 'post-quickpress-save-cont' == $_POST['action'] ) {
    67         $location = "post.php?action=edit&post=$post_ID&message=7";
    68     } else {
    69         $location = add_query_arg( 'message', 4, get_edit_post_link( $post_ID, 'url' ) );
    70     }
    71 
    72     wp_redirect( apply_filters( 'redirect_post_location', $location, $post_ID ) );
     87        $location = "post.php?action=edit&post=$post_id&message=7";
     88    } else {
     89        $location = add_query_arg( 'message', 4, get_edit_post_link( $post_id, 'url' ) );
     90    }
     91
     92    wp_redirect( apply_filters( 'redirect_post_location', $location, $post_id ) );
    7393}
    7494
     
    101121    if ( !empty( $_POST['quickpress_post_ID'] ) ) {
    102122        $_POST['post_ID'] = (int) $_POST['quickpress_post_ID'];
    103         $post_ID = edit_post();
    104     } else {
    105         $post_ID = 'postajaxpost' == $action ? edit_post() : write_post();
     123        $post_id = edit_post();
     124    } else {
     125        $post_id = 'postajaxpost' == $action ? edit_post() : write_post();
    106126    }
    107127
    108128    if ( 0 === strpos( $action, 'post-quickpress' ) ) {
    109         $_POST['post_ID'] = $post_ID;
     129        $_POST['post_ID'] = $post_id;
    110130        // output the quickpress dashboard widget
    111131        require_once(ABSPATH . 'wp-admin/includes/dashboard.php');
     
    114134    }
    115135
    116     redirect_post($post_ID);
     136    redirect_post($post_id);
    117137    exit();
    118138    break;
     
    121141    $editing = true;
    122142
    123     if ( empty( $_GET['post'] ) ) {
     143    if ( empty( $post_id ) ) {
    124144        wp_redirect("post.php");
    125145        exit();
    126146    }
    127     $post_ID = $p = (int) $_GET['post'];
    128     $post = get_post($post_ID);
    129     $post_type_object = get_post_type_object($post->post_type);
     147
     148    $p = $post_id;
    130149
    131150    if ( empty($post->ID) )
    132         wp_die( __('You attempted to edit a post that doesn&#8217;t exist. Perhaps it was deleted?') );
    133 
    134     if ( !current_user_can('edit_post', $post_ID) )
    135         wp_die( __('You are not allowed to edit this post.') );
     151        wp_die( __('You attempted to edit an item that doesn&#8217;t exist. Perhaps it was deleted?') );
     152
     153    if ( !current_user_can($post_type_object->edit_cap, $post_id) )
     154        wp_die( __('You are not allowed to edit this item.') );
    136155
    137156    if ( 'trash' == $post->post_status )
    138         wp_die( __('You can&#8217;t edit this post because it is in the Trash. Please restore it and try again.') );
     157        wp_die( __('You can&#8217;t edit this item because it is in the Trash. Please restore it and try again.') );
    139158
    140159    if ( null == $post_type_object )
    141160        wp_die( __('Unknown post type.') );
    142161
    143     if ( 'post' != $post->post_type && $post_type_object->_builtin ) {
    144         wp_redirect( get_edit_post_link( $post->ID, 'url' ) );
    145         exit();
    146     }
    147 
    148162    $post_type = $post->post_type;
    149     if ( 'post' != $post_type ) {
    150         $parent_file = "edit.php?post_type=$post_type";
    151         $submenu_file = "edit.php?post_type=$post_type";
     163    if ( 'post' == $post_type ) {
     164        $parent_file = "edit.php";
     165        $submenu_file = "edit.php";
     166    } elseif ( 'page' == $post_type ) {
     167        $parent_file = "edit-pages.php";
     168        $submenu_file = "edit-pages.php";
     169    } else {
     170        if ( $post_type_object->hierarchical ) {
     171            $parent_file = "edit-pages.php?post_type=$post_type";
     172            $submenu_file = "edit-pages.php?post_type=$post_type";
     173        } else {
     174            $parent_file = "edit.php?post_type=$post_type";
     175            $submenu_file = "edit.php?post_type=$post_type";
     176        }
    152177    }
    153178
     
    169194
    170195    $title = sprintf(__('Edit %s'), $post_type_object->label);
    171     $post = get_post_to_edit($post_ID);
     196    $post = get_post_to_edit($post_id);
    172197
    173198    include('edit-form-advanced.php');
     
    176201
    177202case 'editattachment':
    178     $post_id = (int) $_POST['post_ID'];
    179 
    180203    check_admin_referer('update-attachment_' . $post_id);
    181204
     
    191214
    192215case 'editpost':
    193     $post_ID = (int) $_POST['post_ID'];
    194     check_admin_referer('update-post_' . $post_ID);
    195 
    196     $post_ID = edit_post();
    197 
    198     redirect_post($post_ID); // Send user on their way while we keep working
     216    check_admin_referer('update-' . $post->post_type . '_' . $post_id);
     217
     218    $post_id = edit_post();
     219
     220    redirect_post($post_id); // Send user on their way while we keep working
    199221
    200222    exit();
     
    202224
    203225case 'trash':
    204     $post_id = isset($_GET['post']) ? intval($_GET['post']) : intval($_POST['post_ID']);
    205226    check_admin_referer('trash-post_' . $post_id);
    206227
    207228    $post = & get_post($post_id);
    208229
    209     if ( !current_user_can('delete_post', $post_id) )
    210         wp_die( __('You are not allowed to move this post to the trash.') );
     230    if ( !current_user_can('delete_' . $post_type_cap, $post_id) )
     231        wp_die( __('You are not allowed to move this item to the trash.') );
    211232
    212233    if ( ! wp_trash_post($post_id) )
     
    218239
    219240case 'untrash':
    220     $post_id = isset($_GET['post']) ? intval($_GET['post']) : intval($_POST['post_ID']);
    221241    check_admin_referer('untrash-post_' . $post_id);
    222242
    223     $post = & get_post($post_id);
    224 
    225     if ( !current_user_can('delete_post', $post_id) )
    226         wp_die( __('You are not allowed to move this post out of the trash.') );
     243    if ( !current_user_can('delete_' . $post_type_cap, $post_id) )
     244        wp_die( __('You are not allowed to move this item out of the trash.') );
    227245
    228246    if ( ! wp_untrash_post($post_id) )
     
    234252
    235253case 'delete':
    236     $post_id = (isset($_GET['post']))  ? intval($_GET['post']) : intval($_POST['post_ID']);
    237254    check_admin_referer('delete-post_' . $post_id);
    238255
    239     $post = & get_post($post_id);
    240 
    241     if ( !current_user_can('delete_post', $post_id) )
    242         wp_die( __('You are not allowed to delete this post.') );
     256    if ( !current_user_can('delete_' . $post_type_cap, $post_id) )
     257        wp_die( __('You are not allowed to delete this item.') );
    243258
    244259    $force = !EMPTY_TRASH_DAYS;
     
    266281
    267282default:
    268     wp_redirect('edit.php');
     283    if ( $post_type_object->hierarchical )
     284        wp_redirect('edit-pages.php');
     285    else
     286        wp_redirect('edit.php');
    269287    exit();
    270288    break;
  • trunk/wp-includes/post.php

    r12697 r12708  
    1717function create_initial_post_types() {
    1818    register_post_type( 'post', array('label' => __('Posts'), 'exclude_from_search' => false, '_builtin' => true, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'hierarchical' => false) );
    19     register_post_type( 'page', array('label' => __('Pages'),'exclude_from_search' => false, '_builtin' => true, '_edit_link' => 'page.php?post=%d', 'capability_type' => 'page', 'hierarchical' => true) );
     19    register_post_type( 'page', array('label' => __('Pages'),'exclude_from_search' => false, '_builtin' => true, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'page', 'hierarchical' => true) );
    2020    register_post_type( 'attachment', array('label' => __('Media'), 'exclude_from_search' => false, '_builtin' => true, '_edit_link' => 'media.php?attachment_id=%d', 'capability_type' => 'post', 'hierarchical' => false) );
    2121    register_post_type( 'revision', array('label' => __('Revisions'),'exclude_from_search' => true, '_builtin' => true, '_edit_link' => 'revision.php?revision=%d', 'capability_type' => 'post', 'hierarchical' => false) );
Note: See TracChangeset for help on using the changeset viewer.