7 */ |
7 */ |
8 |
8 |
9 /** Load WordPress Administration Bootstrap */ |
9 /** Load WordPress Administration Bootstrap */ |
10 require_once( dirname( __FILE__ ) . '/admin.php' ); |
10 require_once( dirname( __FILE__ ) . '/admin.php' ); |
11 |
11 |
|
12 /** |
|
13 * @global string $post_type |
|
14 * @global object $post_type_object |
|
15 * @global WP_Post $post |
|
16 */ |
12 global $post_type, $post_type_object, $post; |
17 global $post_type, $post_type_object, $post; |
13 |
18 |
14 if ( ! isset( $_GET['post_type'] ) ) { |
19 if ( ! isset( $_GET['post_type'] ) ) { |
15 $post_type = 'post'; |
20 $post_type = 'post'; |
16 } elseif ( in_array( $_GET['post_type'], get_post_types( array('show_ui' => true ) ) ) ) { |
21 } elseif ( in_array( $_GET['post_type'], get_post_types( array('show_ui' => true ) ) ) ) { |
17 $post_type = $_GET['post_type']; |
22 $post_type = $_GET['post_type']; |
18 } else { |
23 } else { |
19 wp_die( __('Invalid post type') ); |
24 wp_die( __( 'Invalid post type.' ) ); |
20 } |
25 } |
21 $post_type_object = get_post_type_object( $post_type ); |
26 $post_type_object = get_post_type_object( $post_type ); |
22 |
27 |
23 if ( 'post' == $post_type ) { |
28 if ( 'post' == $post_type ) { |
24 $parent_file = 'edit.php'; |
29 $parent_file = 'edit.php'; |
47 |
52 |
48 $title = $post_type_object->labels->add_new_item; |
53 $title = $post_type_object->labels->add_new_item; |
49 |
54 |
50 $editing = true; |
55 $editing = true; |
51 |
56 |
52 if ( ! current_user_can( $post_type_object->cap->edit_posts ) || ! current_user_can( $post_type_object->cap->create_posts ) ) |
57 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 ); |
58 wp_die( |
|
59 '<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' . |
|
60 '<p>' . __( 'Sorry, you are not allowed to create posts as this user.' ) . '</p>', |
|
61 403 |
|
62 ); |
|
63 } |
54 |
64 |
55 // Schedule auto-draft cleanup |
65 // Schedule auto-draft cleanup |
56 if ( ! wp_next_scheduled( 'wp_scheduled_auto_draft_delete' ) ) |
66 if ( ! wp_next_scheduled( 'wp_scheduled_auto_draft_delete' ) ) { |
57 wp_schedule_event( time(), 'daily', 'wp_scheduled_auto_draft_delete' ); |
67 wp_schedule_event( time(), 'daily', 'wp_scheduled_auto_draft_delete' ); |
58 |
|
59 wp_enqueue_script( 'autosave' ); |
|
60 |
|
61 if ( is_multisite() ) { |
|
62 add_action( 'admin_footer', '_admin_notice_post_locked' ); |
|
63 } else { |
|
64 $check_users = get_users( array( 'fields' => 'ID', 'number' => 2 ) ); |
|
65 |
|
66 if ( count( $check_users ) > 1 ) |
|
67 add_action( 'admin_footer', '_admin_notice_post_locked' ); |
|
68 |
|
69 unset( $check_users ); |
|
70 } |
68 } |
71 |
69 |
72 // Show post form. |
|
73 $post = get_default_post_to_edit( $post_type, true ); |
70 $post = get_default_post_to_edit( $post_type, true ); |
74 $post_ID = $post->ID; |
71 $post_ID = $post->ID; |
75 include( ABSPATH . 'wp-admin/edit-form-advanced.php' ); |
72 |
|
73 /** This filter is documented in wp-admin/post.php */ |
|
74 if ( apply_filters( 'replace_editor', false, $post ) !== true ) { |
|
75 wp_enqueue_script( 'autosave' ); |
|
76 include( ABSPATH . 'wp-admin/edit-form-advanced.php' ); |
|
77 } |
|
78 |
76 include( ABSPATH . 'wp-admin/admin-footer.php' ); |
79 include( ABSPATH . 'wp-admin/admin-footer.php' ); |