home *** CD-ROM | disk | FTP | other *** search
/ HTML Examples / WP.iso / wordpress / wp-admin / post-new.php < prev    next >
Encoding:
PHP Script  |  2017-10-11  |  2.5 KB  |  80 lines

  1. <?php
  2. /**
  3.  * New Post Administration Screen.
  4.  *
  5.  * @package WordPress
  6.  * @subpackage Administration
  7.  */
  8.  
  9. /** Load WordPress Administration Bootstrap */
  10. require_once( dirname( __FILE__ ) . '/admin.php' );
  11.  
  12. /**
  13.  * @global string  $post_type
  14.  * @global object  $post_type_object
  15.  * @global WP_Post $post
  16.  */
  17. global $post_type, $post_type_object, $post;
  18.  
  19. if ( ! isset( $_GET['post_type'] ) ) {
  20.     $post_type = 'post';
  21. } elseif ( in_array( $_GET['post_type'], get_post_types( array('show_ui' => true ) ) ) ) {
  22.     $post_type = $_GET['post_type'];
  23. } else {
  24.     wp_die( __( 'Invalid post type.' ) );
  25. }
  26. $post_type_object = get_post_type_object( $post_type );
  27.  
  28. if ( 'post' == $post_type ) {
  29.     $parent_file = 'edit.php';
  30.     $submenu_file = 'post-new.php';
  31. } elseif ( 'attachment' == $post_type ) {
  32.     if ( wp_redirect( admin_url( 'media-new.php' ) ) )
  33.         exit;
  34. } else {
  35.     $submenu_file = "post-new.php?post_type=$post_type";
  36.     if ( isset( $post_type_object ) && $post_type_object->show_in_menu && $post_type_object->show_in_menu !== true ) {
  37.         $parent_file = $post_type_object->show_in_menu;
  38.         // What if there isn't a post-new.php item for this post type?
  39.         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( "edit.php?post_type=$post_type", $post_type_object->show_in_menu ) ] ) ) {
  41.                 // Fall back to edit.php for that post type, if it exists
  42.                 $submenu_file = "edit.php?post_type=$post_type";
  43.             } else {
  44.                 // Otherwise, give up and highlight the parent
  45.                 $submenu_file = $parent_file;
  46.             }
  47.         }
  48.     } else {
  49.         $parent_file = "edit.php?post_type=$post_type";
  50.     }
  51. }
  52.  
  53. $title = $post_type_object->labels->add_new_item;
  54.  
  55. $editing = true;
  56.  
  57. if ( ! current_user_can( $post_type_object->cap->edit_posts ) || ! current_user_can( $post_type_object->cap->create_posts ) ) {
  58.     wp_die(
  59.         '<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' .
  60.         '<p>' . __( 'Sorry, you are not allowed to create posts as this user.' ) . '</p>',
  61.         403
  62.     );
  63. }
  64.  
  65. // Schedule auto-draft cleanup
  66. if ( ! wp_next_scheduled( 'wp_scheduled_auto_draft_delete' ) ) {
  67.     wp_schedule_event( time(), 'daily', 'wp_scheduled_auto_draft_delete' );
  68. }
  69.  
  70. $post = get_default_post_to_edit( $post_type, true );
  71. $post_ID = $post->ID;
  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.  
  79. include( ABSPATH . 'wp-admin/admin-footer.php' );
  80.