您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 

87 行
2.7 KiB

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