wp/wp-admin/post-new.php
changeset 7 cf61fcea0001
parent 5 5e2f62d02dcd
child 9 177826044cd9
--- a/wp/wp-admin/post-new.php	Tue Jun 09 11:14:17 2015 +0000
+++ b/wp/wp-admin/post-new.php	Mon Oct 14 17:39:30 2019 +0200
@@ -9,6 +9,11 @@
 /** Load WordPress Administration Bootstrap */
 require_once( dirname( __FILE__ ) . '/admin.php' );
 
+/**
+ * @global string  $post_type
+ * @global object  $post_type_object
+ * @global WP_Post $post
+ */
 global $post_type, $post_type_object, $post;
 
 if ( ! isset( $_GET['post_type'] ) ) {
@@ -16,7 +21,7 @@
 } elseif ( in_array( $_GET['post_type'], get_post_types( array('show_ui' => true ) ) ) ) {
 	$post_type = $_GET['post_type'];
 } else {
-	wp_die( __('Invalid post type') );
+	wp_die( __( 'Invalid post type.' ) );
 }
 $post_type_object = get_post_type_object( $post_type );
 
@@ -49,28 +54,26 @@
 
 $editing = true;
 
-if ( ! current_user_can( $post_type_object->cap->edit_posts ) || ! current_user_can( $post_type_object->cap->create_posts ) )
-	wp_die( __( 'Cheatin’ uh?' ), 403 );
+if ( ! current_user_can( $post_type_object->cap->edit_posts ) || ! current_user_can( $post_type_object->cap->create_posts ) ) {
+	wp_die(
+		'<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' .
+		'<p>' . __( 'Sorry, you are not allowed to create posts as this user.' ) . '</p>',
+		403
+	);
+}
 
 // Schedule auto-draft cleanup
-if ( ! wp_next_scheduled( 'wp_scheduled_auto_draft_delete' ) )
+if ( ! wp_next_scheduled( 'wp_scheduled_auto_draft_delete' ) ) {
 	wp_schedule_event( time(), 'daily', 'wp_scheduled_auto_draft_delete' );
-
-wp_enqueue_script( 'autosave' );
-
-if ( is_multisite() ) {
-	add_action( 'admin_footer', '_admin_notice_post_locked' );
-} else {
-	$check_users = get_users( array( 'fields' => 'ID', 'number' => 2 ) );
-
-	if ( count( $check_users ) > 1 )
-		add_action( 'admin_footer', '_admin_notice_post_locked' );
-
-	unset( $check_users );
 }
 
-// Show post form.
 $post = get_default_post_to_edit( $post_type, true );
 $post_ID = $post->ID;
-include( ABSPATH . 'wp-admin/edit-form-advanced.php' );
+
+/** This filter is documented in wp-admin/post.php */
+if ( apply_filters( 'replace_editor', false, $post ) !== true ) {
+	wp_enqueue_script( 'autosave' );
+	include( ABSPATH . 'wp-admin/edit-form-advanced.php' );
+}
+
 include( ABSPATH . 'wp-admin/admin-footer.php' );