web/wp-admin/post-new.php
changeset 194 32102edaa81b
parent 136 bde1974c263b
child 204 09a1c134465b
equal deleted inserted replaced
193:2f6f6f7551ca 194:32102edaa81b
     1 <?php
     1 <?php
     2 /**
     2 /**
     3  * New Post Administration Panel.
     3  * New Post Administration Screen.
     4  *
     4  *
     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('admin.php');
    10 require_once('./admin.php');
    11 $title = __('Add New Post');
       
    12 $parent_file = 'edit.php';
       
    13 $editing = true;
       
    14 wp_enqueue_script('autosave');
       
    15 wp_enqueue_script('post');
       
    16 if ( user_can_richedit() )
       
    17 	wp_enqueue_script('editor');
       
    18 add_thickbox();
       
    19 wp_enqueue_script('media-upload');
       
    20 wp_enqueue_script('word-count');
       
    21 
    11 
    22 if ( ! current_user_can('edit_posts') ) {
    12 if ( !isset($_GET['post_type']) )
    23 	require_once ('./admin-header.php'); ?>
    13 	$post_type = 'post';
    24 <div class="wrap">
    14 elseif ( in_array( $_GET['post_type'], get_post_types( array('show_ui' => true ) ) ) )
    25 <p><?php printf(__('Since you&#8217;re a newcomer, you&#8217;ll have to wait for an admin to add the <code>edit_posts</code> capability to your user, in order to be authorized to post.<br />
    15 	$post_type = $_GET['post_type'];
    26 You can also <a href="mailto:%s?subject=Promotion?">e-mail the admin</a> to ask for a promotion.<br />
    16 else
    27 When you&#8217;re promoted, just reload this page and you&#8217;ll be able to blog. :)'), get_option('admin_email')); ?>
    17 	wp_die( __('Invalid post type') );
    28 </p>
    18 
    29 </div>
    19 $post_type_object = get_post_type_object( $post_type );
    30 <?php
    20 
    31 	include('admin-footer.php');
    21 if ( 'post' == $post_type ) {
    32 	exit();
    22 	$parent_file = 'edit.php';
       
    23 	$submenu_file = 'post-new.php';
       
    24 } else {
       
    25 	$submenu_file = "post-new.php?post_type=$post_type";
       
    26 	if ( isset( $post_type_object ) && $post_type_object->show_in_menu && $post_type_object->show_in_menu !== true ) {
       
    27 		$parent_file = $post_type_object->show_in_menu;
       
    28 		if ( ! isset( $_registered_pages[ get_plugin_page_hookname( "post-new.php?post_type=$post_type", $post_type_object->show_in_menu ) ] ) )
       
    29 			$submenu_file = $parent_file;
       
    30 	} else {
       
    31 		$parent_file = "edit.php?post_type=$post_type";
       
    32 	}
    33 }
    33 }
    34 
    34 
       
    35 $title = $post_type_object->labels->add_new_item;
       
    36 
       
    37 $editing = true;
       
    38 
       
    39 if ( ! current_user_can( $post_type_object->cap->edit_posts ) )
       
    40 	wp_die( __( 'Cheatin&#8217; uh?' ) );
       
    41 
       
    42 // Schedule auto-draft cleanup
       
    43 if ( ! wp_next_scheduled( 'wp_scheduled_auto_draft_delete' ) )
       
    44 	wp_schedule_event( time(), 'daily', 'wp_scheduled_auto_draft_delete' );
       
    45 
       
    46 wp_enqueue_script('autosave');
       
    47 
    35 // Show post form.
    48 // Show post form.
    36 $post = get_default_post_to_edit();
    49 $post = get_default_post_to_edit( $post_type, true );
       
    50 $post_ID = $post->ID;
    37 include('edit-form-advanced.php');
    51 include('edit-form-advanced.php');
    38 
    52 include('./admin-footer.php');
    39 include('admin-footer.php');
       
    40 ?>