~canonical-sysadmins/wordpress/4.7.2

« back to all changes in this revision

Viewing changes to wp-admin/post-new.php

  • Committer: Jacek Nykis
  • Date: 2015-01-05 16:17:05 UTC
  • Revision ID: jacek.nykis@canonical.com-20150105161705-w544l1h5mcg7u4w9
Initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
if ( !isset($_GET['post_type']) )
 
13
        $post_type = 'post';
 
14
elseif ( in_array( $_GET['post_type'], get_post_types( array('show_ui' => true ) ) ) )
 
15
        $post_type = $_GET['post_type'];
 
16
else
 
17
        wp_die( __('Invalid post type') );
 
18
 
 
19
$post_type_object = get_post_type_object( $post_type );
 
20
 
 
21
if ( 'post' == $post_type ) {
 
22
        $parent_file = 'edit.php';
 
23
        $submenu_file = 'post-new.php';
 
24
} elseif ( 'attachment' == $post_type ) {
 
25
        if ( wp_redirect( admin_url( 'media-new.php' ) ) )
 
26
                exit;
 
27
} else {
 
28
        $submenu_file = "post-new.php?post_type=$post_type";
 
29
        if ( isset( $post_type_object ) && $post_type_object->show_in_menu && $post_type_object->show_in_menu !== true ) {
 
30
                $parent_file = $post_type_object->show_in_menu;
 
31
                // What if there isn't a post-new.php item for this post type?
 
32
                if ( ! isset( $_registered_pages[ get_plugin_page_hookname( "post-new.php?post_type=$post_type", $post_type_object->show_in_menu ) ] ) ) {
 
33
                        if (    isset( $_registered_pages[ get_plugin_page_hookname( "edit.php?post_type=$post_type", $post_type_object->show_in_menu ) ] ) ) {
 
34
                                // Fall back to edit.php for that post type, if it exists
 
35
                                $submenu_file = "edit.php?post_type=$post_type";
 
36
                        } else {
 
37
                                // Otherwise, give up and highlight the parent
 
38
                                $submenu_file = $parent_file;
 
39
                        }
 
40
                }
 
41
        } else {
 
42
                $parent_file = "edit.php?post_type=$post_type";
 
43
        }
 
44
}
 
45
 
 
46
$title = $post_type_object->labels->add_new_item;
 
47
 
 
48
$editing = true;
 
49
 
 
50
if ( ! current_user_can( $post_type_object->cap->edit_posts ) || ! current_user_can( $post_type_object->cap->create_posts ) )
 
51
        wp_die( __( 'Cheatin&#8217; uh?' ) );
 
52
 
 
53
// Schedule auto-draft cleanup
 
54
if ( ! wp_next_scheduled( 'wp_scheduled_auto_draft_delete' ) )
 
55
        wp_schedule_event( time(), 'daily', 'wp_scheduled_auto_draft_delete' );
 
56
 
 
57
wp_enqueue_script( 'autosave' );
 
58
 
 
59
if ( is_multisite() ) {
 
60
        add_action( 'admin_footer', '_admin_notice_post_locked' );
 
61
} else {
 
62
        $check_users = get_users( array( 'fields' => 'ID', 'number' => 2 ) );
 
63
 
 
64
        if ( count( $check_users ) > 1 )
 
65
                add_action( 'admin_footer', '_admin_notice_post_locked' );
 
66
 
 
67
        unset( $check_users );
 
68
}
 
69
 
 
70
// Show post form.
 
71
$post = get_default_post_to_edit( $post_type, true );
 
72
$post_ID = $post->ID;
 
73
include( ABSPATH . 'wp-admin/edit-form-advanced.php' );
 
74
include( ABSPATH . 'wp-admin/admin-footer.php' );