- wp_enqueue_script('post');
- if ( user_can_richedit() )
- wp_enqueue_script('editor');
- wp_enqueue_script('thickbox');
- wp_enqueue_script('media-upload');
-
- if ( current_user_can('edit_post', $post_ID) ) {
- if ( $last = wp_check_post_lock( $post->ID ) ) {
- $last_user = get_userdata( $last );
- $last_user_name = $last_user ? $last_user->display_name : __('Somebody');
- $message = sprintf( __( 'Warning: %s is currently editing this post' ), wp_specialchars( $last_user_name ) );
- $message = str_replace( "'", "\'", "<div class='error'><p>$message</p></div>" );
- add_action('admin_notices', create_function( '', "echo '$message';" ) );
- } else {
- wp_set_post_lock( $post->ID );
- wp_enqueue_script('autosave');
- }
+ if ( !current_user_can($post_type_object->cap->edit_post, $post_id) )
+ wp_die( __('You are not allowed to edit this item.') );
+
+ if ( 'trash' == $post->post_status )
+ wp_die( __('You can’t edit this item because it is in the Trash. Please restore it and try again.') );
+
+ if ( null == $post_type_object )
+ wp_die( __('Unknown post type.') );
+
+ $post_type = $post->post_type;
+ if ( 'post' == $post_type ) {
+ $parent_file = "edit.php";
+ $submenu_file = "edit.php";
+ } else {
+ $parent_file = "edit.php?post_type=$post_type";
+ $submenu_file = "edit.php?post_type=$post_type";