|
1 <?php |
|
2 /** |
|
3 * Post advanced form for inclusion in the administration panels. |
|
4 * |
|
5 * @package WordPress |
|
6 * @subpackage Administration |
|
7 */ |
|
8 |
|
9 // don't load directly |
|
10 if ( !defined('ABSPATH') ) |
|
11 die('-1'); |
|
12 |
|
13 /** |
|
14 * Post ID global |
|
15 * @name $post_ID |
|
16 * @var int |
|
17 */ |
|
18 $post_ID = isset($post_ID) ? (int) $post_ID : 0; |
|
19 |
|
20 $action = isset($action) ? $action : ''; |
|
21 |
|
22 $message = false; |
|
23 if ( isset($_GET['message']) ) { |
|
24 $_GET['message'] = absint( $_GET['message'] ); |
|
25 |
|
26 switch ( $_GET['message'] ) { |
|
27 case 1: |
|
28 $message = sprintf( __('Post updated. <a href="%s">View post</a>'), get_permalink($post_ID) ); |
|
29 break; |
|
30 case 2: |
|
31 $message = __('Custom field updated.'); |
|
32 break; |
|
33 case 3: |
|
34 $message = __('Custom field deleted.'); |
|
35 break; |
|
36 case 4: |
|
37 $message = __('Post updated.'); |
|
38 break; |
|
39 case 5: |
|
40 if ( isset($_GET['revision']) ) |
|
41 $message = sprintf( __('Post restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) ); |
|
42 break; |
|
43 case 6: |
|
44 $message = sprintf( __('Post published. <a href="%s">View post</a>'), get_permalink($post_ID) ); |
|
45 break; |
|
46 case 7: |
|
47 $message = __('Post saved.'); |
|
48 break; |
|
49 case 8: |
|
50 $message = sprintf( __('Post submitted. <a target="_blank" href="%s">Preview post</a>'), add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ); |
|
51 break; |
|
52 case 9: |
|
53 // translators: Publish box date formt, see http://php.net/date - Same as in meta-boxes.php |
|
54 $message = sprintf( __('Post scheduled for: <b>%1$s</b>. <a target="_blank" href="%2$s">Preview post</a>'), date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), get_permalink($post_ID) ); |
|
55 break; |
|
56 case 10: |
|
57 $message = sprintf( __('Post draft updated. <a target="_blank" href="%s">Preview post</a>'), add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ); |
|
58 break; |
|
59 } |
|
60 } |
|
61 |
|
62 $notice = false; |
|
63 if ( 0 == $post_ID ) { |
|
64 $form_action = 'post'; |
|
65 $temp_ID = -1 * time(); // don't change this formula without looking at wp_write_post() |
|
66 $form_extra = "<input type='hidden' id='post_ID' name='temp_ID' value='" . esc_attr($temp_ID) . "' />"; |
|
67 $autosave = false; |
|
68 } else { |
|
69 $form_action = 'editpost'; |
|
70 $form_extra = "<input type='hidden' id='post_ID' name='post_ID' value='" . esc_attr($post_ID) . "' />"; |
|
71 $autosave = wp_get_post_autosave( $post_ID ); |
|
72 |
|
73 // Detect if there exists an autosave newer than the post and if that autosave is different than the post |
|
74 if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql2date( 'U', $post->post_modified_gmt, false ) ) { |
|
75 foreach ( _wp_post_revision_fields() as $autosave_field => $_autosave_field ) { |
|
76 if ( normalize_whitespace( $autosave->$autosave_field ) != normalize_whitespace( $post->$autosave_field ) ) { |
|
77 $notice = sprintf( __( 'There is an autosave of this post that is more recent than the version below. <a href="%s">View the autosave</a>.' ), get_edit_post_link( $autosave->ID ) ); |
|
78 break; |
|
79 } |
|
80 } |
|
81 unset($autosave_field, $_autosave_field); |
|
82 } |
|
83 } |
|
84 |
|
85 // All meta boxes should be defined and added before the first do_meta_boxes() call (or potentially during the do_meta_boxes action). |
|
86 require_once('includes/meta-boxes.php'); |
|
87 |
|
88 add_meta_box('submitdiv', __('Publish'), 'post_submit_meta_box', 'post', 'side', 'core'); |
|
89 |
|
90 // all tag-style post taxonomies |
|
91 foreach ( get_object_taxonomies('post') as $tax_name ) { |
|
92 if ( !is_taxonomy_hierarchical($tax_name) ) { |
|
93 $taxonomy = get_taxonomy($tax_name); |
|
94 $label = isset($taxonomy->label) ? esc_attr($taxonomy->label) : $tax_name; |
|
95 |
|
96 add_meta_box('tagsdiv-' . $tax_name, $label, 'post_tags_meta_box', 'post', 'side', 'core'); |
|
97 } |
|
98 } |
|
99 |
|
100 add_meta_box('categorydiv', __('Categories'), 'post_categories_meta_box', 'post', 'side', 'core'); |
|
101 if ( current_theme_supports( 'post-thumbnails', 'post' ) ) |
|
102 add_meta_box('postimagediv', __('Post Thumbnail'), 'post_thumbnail_meta_box', 'post', 'side', 'low'); |
|
103 add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', 'post', 'normal', 'core'); |
|
104 add_meta_box('trackbacksdiv', __('Send Trackbacks'), 'post_trackback_meta_box', 'post', 'normal', 'core'); |
|
105 add_meta_box('postcustom', __('Custom Fields'), 'post_custom_meta_box', 'post', 'normal', 'core'); |
|
106 do_action('dbx_post_advanced'); |
|
107 add_meta_box('commentstatusdiv', __('Discussion'), 'post_comment_status_meta_box', 'post', 'normal', 'core'); |
|
108 |
|
109 if ( 'publish' == $post->post_status || 'private' == $post->post_status ) |
|
110 add_meta_box('commentsdiv', __('Comments'), 'post_comment_meta_box', 'post', 'normal', 'core'); |
|
111 |
|
112 if ( !( 'pending' == $post->post_status && !current_user_can( 'publish_posts' ) ) ) |
|
113 add_meta_box('slugdiv', __('Post Slug'), 'post_slug_meta_box', 'post', 'normal', 'core'); |
|
114 |
|
115 $authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM |
|
116 if ( $post->post_author && !in_array($post->post_author, $authors) ) |
|
117 $authors[] = $post->post_author; |
|
118 if ( $authors && count( $authors ) > 1 ) |
|
119 add_meta_box('authordiv', __('Post Author'), 'post_author_meta_box', 'post', 'normal', 'core'); |
|
120 |
|
121 if ( 0 < $post_ID && wp_get_post_revisions( $post_ID ) ) |
|
122 add_meta_box('revisionsdiv', __('Post Revisions'), 'post_revisions_meta_box', 'post', 'normal', 'core'); |
|
123 |
|
124 do_action('do_meta_boxes', 'post', 'normal', $post); |
|
125 do_action('do_meta_boxes', 'post', 'advanced', $post); |
|
126 do_action('do_meta_boxes', 'post', 'side', $post); |
|
127 |
|
128 require_once('admin-header.php'); |
|
129 |
|
130 ?> |
|
131 |
|
132 <div class="wrap"> |
|
133 <?php screen_icon(); ?> |
|
134 <h2><?php echo esc_html( $title ); ?></h2> |
|
135 <?php if ( $notice ) : ?> |
|
136 <div id="notice" class="error"><p><?php echo $notice ?></p></div> |
|
137 <?php endif; ?> |
|
138 <?php if ( $message ) : ?> |
|
139 <div id="message" class="updated fade"><p><?php echo $message; ?></p></div> |
|
140 <?php endif; ?> |
|
141 <form name="post" action="post.php" method="post" id="post"> |
|
142 <?php |
|
143 |
|
144 if ( 0 == $post_ID) |
|
145 wp_nonce_field('add-post'); |
|
146 else |
|
147 wp_nonce_field('update-post_' . $post_ID); |
|
148 |
|
149 ?> |
|
150 |
|
151 <input type="hidden" id="user-id" name="user_ID" value="<?php echo (int) $user_ID ?>" /> |
|
152 <input type="hidden" id="hiddenaction" name="action" value="<?php echo esc_attr($form_action) ?>" /> |
|
153 <input type="hidden" id="originalaction" name="originalaction" value="<?php echo esc_attr($form_action) ?>" /> |
|
154 <input type="hidden" id="post_author" name="post_author" value="<?php echo esc_attr( $post->post_author ); ?>" /> |
|
155 <input type="hidden" id="post_type" name="post_type" value="<?php echo esc_attr($post->post_type) ?>" /> |
|
156 <input type="hidden" id="original_post_status" name="original_post_status" value="<?php echo esc_attr($post->post_status) ?>" /> |
|
157 <input name="referredby" type="hidden" id="referredby" value="<?php echo esc_url(stripslashes(wp_get_referer())); ?>" /> |
|
158 <?php |
|
159 if ( 'draft' != $post->post_status ) |
|
160 wp_original_referer_field(true, 'previous'); |
|
161 |
|
162 echo $form_extra ?> |
|
163 |
|
164 <div id="poststuff" class="metabox-holder<?php echo 2 == $screen_layout_columns ? ' has-right-sidebar' : ''; ?>"> |
|
165 <div id="side-info-column" class="inner-sidebar"> |
|
166 |
|
167 <?php do_action('submitpost_box'); ?> |
|
168 |
|
169 <?php $side_meta_boxes = do_meta_boxes('post', 'side', $post); ?> |
|
170 </div> |
|
171 |
|
172 <div id="post-body"> |
|
173 <div id="post-body-content"> |
|
174 <div id="titlediv"> |
|
175 <div id="titlewrap"> |
|
176 <label class="screen-reader-text" for="title"><?php _e('Title') ?></label> |
|
177 <input type="text" name="post_title" size="30" tabindex="1" value="<?php echo esc_attr( htmlspecialchars( $post->post_title ) ); ?>" id="title" autocomplete="off" /> |
|
178 </div> |
|
179 <div class="inside"> |
|
180 <?php |
|
181 $sample_permalink_html = get_sample_permalink_html($post->ID); |
|
182 if ( !( 'pending' == $post->post_status && !current_user_can( 'publish_posts' ) ) ) { ?> |
|
183 <div id="edit-slug-box"> |
|
184 <?php |
|
185 if ( ! empty($post->ID) && ! empty($sample_permalink_html) ) : |
|
186 echo $sample_permalink_html; |
|
187 endif; ?> |
|
188 </div> |
|
189 <?php |
|
190 } ?> |
|
191 </div> |
|
192 </div> |
|
193 |
|
194 <div id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>" class="postarea"> |
|
195 |
|
196 <?php the_editor($post->post_content); ?> |
|
197 |
|
198 <table id="post-status-info" cellspacing="0"><tbody><tr> |
|
199 <td id="wp-word-count"></td> |
|
200 <td class="autosave-info"> |
|
201 <span id="autosave"> </span> |
|
202 <?php |
|
203 if ( $post_ID ) { |
|
204 echo '<span id="last-edit">'; |
|
205 if ( $last_id = get_post_meta($post_ID, '_edit_last', true) ) { |
|
206 $last_user = get_userdata($last_id); |
|
207 printf(__('Last edited by %1$s on %2$s at %3$s'), esc_html( $last_user->display_name ), mysql2date(get_option('date_format'), $post->post_modified), mysql2date(get_option('time_format'), $post->post_modified)); |
|
208 } else { |
|
209 printf(__('Last edited on %1$s at %2$s'), mysql2date(get_option('date_format'), $post->post_modified), mysql2date(get_option('time_format'), $post->post_modified)); |
|
210 } |
|
211 echo '</span>'; |
|
212 } ?> |
|
213 </td> |
|
214 </tr></tbody></table> |
|
215 |
|
216 <?php |
|
217 wp_nonce_field( 'autosave', 'autosavenonce', false ); |
|
218 wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); |
|
219 wp_nonce_field( 'getpermalink', 'getpermalinknonce', false ); |
|
220 wp_nonce_field( 'samplepermalink', 'samplepermalinknonce', false ); |
|
221 wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?> |
|
222 </div> |
|
223 |
|
224 <?php |
|
225 |
|
226 do_meta_boxes('post', 'normal', $post); |
|
227 |
|
228 do_action('edit_form_advanced'); |
|
229 |
|
230 do_meta_boxes('post', 'advanced', $post); |
|
231 |
|
232 do_action('dbx_post_sidebar'); ?> |
|
233 |
|
234 </div> |
|
235 </div> |
|
236 <br class="clear" /> |
|
237 </div><!-- /poststuff --> |
|
238 </form> |
|
239 </div> |
|
240 |
|
241 <?php wp_comment_reply(); ?> |
|
242 |
|
243 <?php if ((isset($post->post_title) && '' == $post->post_title) || (isset($_GET['message']) && 2 > $_GET['message'])) : ?> |
|
244 <script type="text/javascript"> |
|
245 try{document.post.title.focus();}catch(e){} |
|
246 </script> |
|
247 <?php endif; ?> |