wp/wp-admin/post-new.php
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 21 48c4eec2b7e6
equal deleted inserted replaced
15:3d4e9c994f10 16:a86126ab1dd4
     5  * @package WordPress
     5  * @package WordPress
     6  * @subpackage Administration
     6  * @subpackage Administration
     7  */
     7  */
     8 
     8 
     9 /** Load WordPress Administration Bootstrap */
     9 /** Load WordPress Administration Bootstrap */
    10 require_once( dirname( __FILE__ ) . '/admin.php' );
    10 require_once __DIR__ . '/admin.php';
    11 
    11 
    12 /**
    12 /**
    13  * @global string  $post_type
    13  * @global string  $post_type
    14  * @global object  $post_type_object
    14  * @global object  $post_type_object
    15  * @global WP_Post $post
    15  * @global WP_Post $post             Global post object.
    16  */
    16  */
    17 global $post_type, $post_type_object, $post;
    17 global $post_type, $post_type_object, $post;
    18 
    18 
    19 if ( ! isset( $_GET['post_type'] ) ) {
    19 if ( ! isset( $_GET['post_type'] ) ) {
    20 	$post_type = 'post';
    20 	$post_type = 'post';
    21 } 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 ) ), true ) ) {
    22 	$post_type = $_GET['post_type'];
    22 	$post_type = $_GET['post_type'];
    23 } else {
    23 } else {
    24 	wp_die( __( 'Invalid post type.' ) );
    24 	wp_die( __( 'Invalid post type.' ) );
    25 }
    25 }
    26 $post_type_object = get_post_type_object( $post_type );
    26 $post_type_object = get_post_type_object( $post_type );
    27 
    27 
    28 if ( 'post' == $post_type ) {
    28 if ( 'post' === $post_type ) {
    29 	$parent_file  = 'edit.php';
    29 	$parent_file  = 'edit.php';
    30 	$submenu_file = 'post-new.php';
    30 	$submenu_file = 'post-new.php';
    31 } elseif ( 'attachment' == $post_type ) {
    31 } elseif ( 'attachment' === $post_type ) {
    32 	if ( wp_redirect( admin_url( 'media-new.php' ) ) ) {
    32 	if ( wp_redirect( admin_url( 'media-new.php' ) ) ) {
    33 		exit;
    33 		exit;
    34 	}
    34 	}
    35 } else {
    35 } else {
    36 	$submenu_file = "post-new.php?post_type=$post_type";
    36 	$submenu_file = "post-new.php?post_type=$post_type";
    37 	if ( isset( $post_type_object ) && $post_type_object->show_in_menu && $post_type_object->show_in_menu !== true ) {
    37 	if ( isset( $post_type_object ) && $post_type_object->show_in_menu && true !== $post_type_object->show_in_menu ) {
    38 		$parent_file = $post_type_object->show_in_menu;
    38 		$parent_file = $post_type_object->show_in_menu;
    39 		// What if there isn't a post-new.php item for this post type?
    39 		// What if there isn't a post-new.php item for this post type?
    40 		if ( ! isset( $_registered_pages[ get_plugin_page_hookname( "post-new.php?post_type=$post_type", $post_type_object->show_in_menu ) ] ) ) {
    40 		if ( ! isset( $_registered_pages[ get_plugin_page_hookname( "post-new.php?post_type=$post_type", $post_type_object->show_in_menu ) ] ) ) {
    41 			if ( isset( $_registered_pages[ get_plugin_page_hookname( "edit.php?post_type=$post_type", $post_type_object->show_in_menu ) ] ) ) {
    41 			if ( isset( $_registered_pages[ get_plugin_page_hookname( "edit.php?post_type=$post_type", $post_type_object->show_in_menu ) ] ) ) {
    42 				// Fall back to edit.php for that post type, if it exists
    42 				// Fall back to edit.php for that post type, if it exists.
    43 				$submenu_file = "edit.php?post_type=$post_type";
    43 				$submenu_file = "edit.php?post_type=$post_type";
    44 			} else {
    44 			} else {
    45 				// Otherwise, give up and highlight the parent
    45 				// Otherwise, give up and highlight the parent.
    46 				$submenu_file = $parent_file;
    46 				$submenu_file = $parent_file;
    47 			}
    47 			}
    48 		}
    48 		}
    49 	} else {
    49 	} else {
    50 		$parent_file = "edit.php?post_type=$post_type";
    50 		$parent_file = "edit.php?post_type=$post_type";
    67 $post_ID = $post->ID;
    67 $post_ID = $post->ID;
    68 
    68 
    69 /** This filter is documented in wp-admin/post.php */
    69 /** This filter is documented in wp-admin/post.php */
    70 if ( apply_filters( 'replace_editor', false, $post ) !== true ) {
    70 if ( apply_filters( 'replace_editor', false, $post ) !== true ) {
    71 	if ( use_block_editor_for_post( $post ) ) {
    71 	if ( use_block_editor_for_post( $post ) ) {
    72 		include( ABSPATH . 'wp-admin/edit-form-blocks.php' );
    72 		require ABSPATH . 'wp-admin/edit-form-blocks.php';
    73 	} else {
    73 	} else {
    74 		wp_enqueue_script( 'autosave' );
    74 		wp_enqueue_script( 'autosave' );
    75 		include( ABSPATH . 'wp-admin/edit-form-advanced.php' );
    75 		require ABSPATH . 'wp-admin/edit-form-advanced.php';
    76 	}
    76 	}
    77 } else {
    77 } else {
    78 	// Flag that we're not loading the block editor.
    78 	// Flag that we're not loading the block editor.
    79 	$current_screen = get_current_screen();
    79 	$current_screen = get_current_screen();
    80 	$current_screen->is_block_editor( false );
    80 	$current_screen->is_block_editor( false );
    81 }
    81 }
    82 
    82 
    83 include( ABSPATH . 'wp-admin/admin-footer.php' );
    83 require_once ABSPATH . 'wp-admin/admin-footer.php';