3 * New Post Administration Screen.
6 * @subpackage Administration
9 /** Load WordPress Administration Bootstrap */
10 require_once( dirname( __FILE__ ) . '/admin.php' );
12 global $post_type, $post_type_object, $post;
14 if ( ! isset( $_GET['post_type'] ) ) {
16 } elseif ( in_array( $_GET['post_type'], get_post_types( array('show_ui' => true ) ) ) ) {
17 $post_type = $_GET['post_type'];
19 wp_die( __('Invalid post type') );
21 $post_type_object = get_post_type_object( $post_type );
23 if ( 'post' == $post_type ) {
24 $parent_file = 'edit.php';
25 $submenu_file = 'post-new.php';
26 } elseif ( 'attachment' == $post_type ) {
27 if ( wp_redirect( admin_url( 'media-new.php' ) ) )
30 $submenu_file = "post-new.php?post_type=$post_type";
31 if ( isset( $post_type_object ) && $post_type_object->show_in_menu && $post_type_object->show_in_menu !== true ) {
32 $parent_file = $post_type_object->show_in_menu;
33 // What if there isn't a post-new.php item for this post type?
34 if ( ! isset( $_registered_pages[ get_plugin_page_hookname( "post-new.php?post_type=$post_type", $post_type_object->show_in_menu ) ] ) ) {
35 if ( isset( $_registered_pages[ get_plugin_page_hookname( "edit.php?post_type=$post_type", $post_type_object->show_in_menu ) ] ) ) {
36 // Fall back to edit.php for that post type, if it exists
37 $submenu_file = "edit.php?post_type=$post_type";
39 // Otherwise, give up and highlight the parent
40 $submenu_file = $parent_file;
44 $parent_file = "edit.php?post_type=$post_type";
48 $title = $post_type_object->labels->add_new_item;
52 if ( ! current_user_can( $post_type_object->cap->edit_posts ) || ! current_user_can( $post_type_object->cap->create_posts ) )
53 wp_die( __( 'Cheatin’ uh?' ), 403 );
55 // Schedule auto-draft cleanup
56 if ( ! wp_next_scheduled( 'wp_scheduled_auto_draft_delete' ) )
57 wp_schedule_event( time(), 'daily', 'wp_scheduled_auto_draft_delete' );
59 wp_enqueue_script( 'autosave' );
61 if ( is_multisite() ) {
62 add_action( 'admin_footer', '_admin_notice_post_locked' );
64 $check_users = get_users( array( 'fields' => 'ID', 'number' => 2 ) );
66 if ( count( $check_users ) > 1 )
67 add_action( 'admin_footer', '_admin_notice_post_locked' );
69 unset( $check_users );
73 $post = get_default_post_to_edit( $post_type, true );
75 include( ABSPATH . 'wp-admin/edit-form-advanced.php' );
76 include( ABSPATH . 'wp-admin/admin-footer.php' );