16 * @var int |
16 * @var int |
17 */ |
17 */ |
18 $post_ID = isset($post_ID) ? (int) $post_ID : 0; |
18 $post_ID = isset($post_ID) ? (int) $post_ID : 0; |
19 |
19 |
20 $action = isset($action) ? $action : ''; |
20 $action = isset($action) ? $action : ''; |
21 if ( isset($_GET['message']) ) |
21 |
|
22 $message = false; |
|
23 if ( isset($_GET['message']) ) { |
22 $_GET['message'] = absint( $_GET['message'] ); |
24 $_GET['message'] = absint( $_GET['message'] ); |
23 $messages[1] = sprintf(__('Post updated. <a href="%s">View post</a>'), get_permalink($post_ID)); |
25 |
24 $messages[2] = __('Custom field updated.'); |
26 switch ( $_GET['message'] ) { |
25 $messages[3] = __('Custom field deleted.'); |
27 case 1: |
26 $messages[4] = __('Post updated.'); |
28 $message = sprintf( __('Post updated. <a href="%s">View post</a>'), get_permalink($post_ID) ); |
27 $messages[6] = sprintf(__('Post published. <a href="%s">View post</a>'), get_permalink($post_ID)); |
29 break; |
28 $messages[7] = __('Post saved.'); |
30 case 2: |
29 $messages[8] = sprintf(__('Post submitted. <a href="%s">Preview post</a>'), add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ); |
31 $message = __('Custom field updated.'); |
30 |
32 break; |
31 if ( isset($_GET['revision']) ) |
33 case 3: |
32 $messages[5] = sprintf( __('Post restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) ); |
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 } |
33 |
61 |
34 $notice = false; |
62 $notice = false; |
35 $notices[1] = __( 'There is an autosave of this post that is more recent than the version below. <a href="%s">View the autosave</a>.' ); |
|
36 |
|
37 if ( 0 == $post_ID ) { |
63 if ( 0 == $post_ID ) { |
38 $form_action = 'post'; |
64 $form_action = 'post'; |
39 $temp_ID = -1 * time(); // don't change this formula without looking at wp_write_post() |
65 $temp_ID = -1 * time(); // don't change this formula without looking at wp_write_post() |
40 $form_extra = "<input type='hidden' id='post_ID' name='temp_ID' value='" . esc_attr($temp_ID) . "' />"; |
66 $form_extra = "<input type='hidden' id='post_ID' name='temp_ID' value='" . esc_attr($temp_ID) . "' />"; |
41 $autosave = false; |
67 $autosave = false; |
46 |
72 |
47 // Detect if there exists an autosave newer than the post and if that autosave is different than the post |
73 // Detect if there exists an autosave newer than the post and if that autosave is different than the post |
48 if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql2date( 'U', $post->post_modified_gmt, false ) ) { |
74 if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql2date( 'U', $post->post_modified_gmt, false ) ) { |
49 foreach ( _wp_post_revision_fields() as $autosave_field => $_autosave_field ) { |
75 foreach ( _wp_post_revision_fields() as $autosave_field => $_autosave_field ) { |
50 if ( normalize_whitespace( $autosave->$autosave_field ) != normalize_whitespace( $post->$autosave_field ) ) { |
76 if ( normalize_whitespace( $autosave->$autosave_field ) != normalize_whitespace( $post->$autosave_field ) ) { |
51 $notice = sprintf( $notices[1], get_edit_post_link( $autosave->ID ) ); |
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 ) ); |
52 break; |
78 break; |
53 } |
79 } |
54 } |
80 } |
55 unset($autosave_field, $_autosave_field); |
81 unset($autosave_field, $_autosave_field); |
56 } |
82 } |
57 } |
83 } |
58 |
84 |
59 // All meta boxes should be defined and added before the first do_meta_boxes() call (or potentially during the do_meta_boxes action). |
85 // All meta boxes should be defined and added before the first do_meta_boxes() call (or potentially during the do_meta_boxes action). |
60 |
86 require_once('includes/meta-boxes.php'); |
61 /** |
87 |
62 * Display post submit form fields. |
|
63 * |
|
64 * @since 2.7.0 |
|
65 * |
|
66 * @param object $post |
|
67 */ |
|
68 function post_submit_meta_box($post) { |
|
69 global $action; |
|
70 |
|
71 $can_publish = current_user_can('publish_posts'); |
|
72 ?> |
|
73 <div class="submitbox" id="submitpost"> |
|
74 |
|
75 <div id="minor-publishing"> |
|
76 |
|
77 <?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key ?> |
|
78 <div style="display:none;"> |
|
79 <input type="submit" name="save" value="<?php esc_attr_e('Save'); ?>" /> |
|
80 </div> |
|
81 |
|
82 <div id="minor-publishing-actions"> |
|
83 <div id="save-action"> |
|
84 <?php if ( 'publish' != $post->post_status && 'future' != $post->post_status && 'pending' != $post->post_status ) { ?> |
|
85 <input <?php if ( 'private' == $post->post_status ) { ?>style="display:none"<?php } ?> type="submit" name="save" id="save-post" value="<?php esc_attr_e('Save Draft'); ?>" tabindex="4" class="button button-highlighted" /> |
|
86 <?php } elseif ( 'pending' == $post->post_status && $can_publish ) { ?> |
|
87 <input type="submit" name="save" id="save-post" value="<?php esc_attr_e('Save as Pending'); ?>" tabindex="4" class="button button-highlighted" /> |
|
88 <?php } ?> |
|
89 </div> |
|
90 |
|
91 <div id="preview-action"> |
|
92 <?php |
|
93 if ( 'publish' == $post->post_status ) { |
|
94 $preview_link = esc_url(get_permalink($post->ID)); |
|
95 $preview_button = __('Preview Changes'); |
|
96 } else { |
|
97 $preview_link = esc_url(apply_filters('preview_post_link', add_query_arg('preview', 'true', get_permalink($post->ID)))); |
|
98 $preview_button = __('Preview'); |
|
99 } |
|
100 ?> |
|
101 <a class="preview button" href="<?php echo $preview_link; ?>" target="wp-preview" id="post-preview" tabindex="4"><?php echo $preview_button; ?></a> |
|
102 <input type="hidden" name="wp-preview" id="wp-preview" value="" /> |
|
103 </div> |
|
104 |
|
105 <div class="clear"></div> |
|
106 </div><?php // /minor-publishing-actions ?> |
|
107 |
|
108 <div id="misc-publishing-actions"> |
|
109 |
|
110 <div class="misc-pub-section<?php if ( !$can_publish ) { echo ' misc-pub-section-last'; } ?>"><label for="post_status"><?php _e('Status:') ?></label> |
|
111 <span id="post-status-display"> |
|
112 <?php |
|
113 switch ( $post->post_status ) { |
|
114 case 'private': |
|
115 _e('Privately Published'); |
|
116 break; |
|
117 case 'publish': |
|
118 _e('Published'); |
|
119 break; |
|
120 case 'future': |
|
121 _e('Scheduled'); |
|
122 break; |
|
123 case 'pending': |
|
124 _e('Pending Review'); |
|
125 break; |
|
126 case 'draft': |
|
127 _e('Draft'); |
|
128 break; |
|
129 } |
|
130 ?> |
|
131 </span> |
|
132 <?php if ( 'publish' == $post->post_status || 'private' == $post->post_status || $can_publish ) { ?> |
|
133 <a href="#post_status" <?php if ( 'private' == $post->post_status ) { ?>style="display:none;" <?php } ?>class="edit-post-status hide-if-no-js" tabindex='4'><?php _e('Edit') ?></a> |
|
134 |
|
135 <div id="post-status-select" class="hide-if-js"> |
|
136 <input type="hidden" name="hidden_post_status" id="hidden_post_status" value="<?php echo esc_attr($post->post_status); ?>" /> |
|
137 <select name='post_status' id='post_status' tabindex='4'> |
|
138 <?php if ( 'publish' == $post->post_status ) : ?> |
|
139 <option<?php selected( $post->post_status, 'publish' ); ?> value='publish'><?php _e('Published') ?></option> |
|
140 <?php elseif ( 'private' == $post->post_status ) : ?> |
|
141 <option<?php selected( $post->post_status, 'private' ); ?> value='publish'><?php _e('Privately Published') ?></option> |
|
142 <?php elseif ( 'future' == $post->post_status ) : ?> |
|
143 <option<?php selected( $post->post_status, 'future' ); ?> value='future'><?php _e('Scheduled') ?></option> |
|
144 <?php endif; ?> |
|
145 <option<?php selected( $post->post_status, 'pending' ); ?> value='pending'><?php _e('Pending Review') ?></option> |
|
146 <option<?php selected( $post->post_status, 'draft' ); ?> value='draft'><?php _e('Draft') ?></option> |
|
147 </select> |
|
148 <a href="#post_status" class="save-post-status hide-if-no-js button"><?php _e('OK'); ?></a> |
|
149 <a href="#post_status" class="cancel-post-status hide-if-no-js"><?php _e('Cancel'); ?></a> |
|
150 </div> |
|
151 |
|
152 <?php } ?> |
|
153 </div><?php // /misc-pub-section ?> |
|
154 |
|
155 <div class="misc-pub-section " id="visibility"> |
|
156 <?php _e('Visibility:'); ?> <span id="post-visibility-display"><?php |
|
157 |
|
158 if ( 'private' == $post->post_status ) { |
|
159 $post->post_password = ''; |
|
160 $visibility = 'private'; |
|
161 $visibility_trans = __('Private'); |
|
162 } elseif ( !empty( $post->post_password ) ) { |
|
163 $visibility = 'password'; |
|
164 $visibility_trans = __('Password protected'); |
|
165 } elseif ( is_sticky( $post->ID ) ) { |
|
166 $visibility = 'public'; |
|
167 $visibility_trans = __('Public, Sticky'); |
|
168 } else { |
|
169 $visibility = 'public'; |
|
170 $visibility_trans = __('Public'); |
|
171 } |
|
172 |
|
173 ?><?php echo esc_html( $visibility_trans ); ?></span> <?php if ( $can_publish ) { ?> <a href="#visibility" class="edit-visibility hide-if-no-js"><?php _e('Edit'); ?></a> |
|
174 |
|
175 <div id="post-visibility-select" class="hide-if-js"> |
|
176 <input type="hidden" name="hidden_post_password" id="hidden-post-password" value="<?php echo esc_attr($post->post_password); ?>" /> |
|
177 <input type="checkbox" style="display:none" name="hidden_post_sticky" id="hidden-post-sticky" value="sticky" <?php checked(is_sticky($post->ID)); ?> /> |
|
178 <input type="hidden" name="hidden_post_visibility" id="hidden-post-visibility" value="<?php echo esc_attr( $visibility ); ?>" /> |
|
179 |
|
180 |
|
181 <input type="radio" name="visibility" id="visibility-radio-public" value="public" <?php checked( $visibility, 'public' ); ?> /> <label for="visibility-radio-public" class="selectit"><?php _e('Public'); ?></label><br /> |
|
182 <span id="sticky-span"><input id="sticky" name="sticky" type="checkbox" value="sticky" <?php checked(is_sticky($post->ID)); ?> tabindex="4" /> <label for="sticky" class="selectit"><?php _e('Stick this post to the front page') ?></label><br /></span> |
|
183 <input type="radio" name="visibility" id="visibility-radio-password" value="password" <?php checked( $visibility, 'password' ); ?> /> <label for="visibility-radio-password" class="selectit"><?php _e('Password protected'); ?></label><br /> |
|
184 <span id="password-span"><label for="post_password"><?php _e('Password:'); ?></label> <input type="text" name="post_password" id="post_password" value="<?php echo esc_attr($post->post_password); ?>" /><br /></span> |
|
185 <input type="radio" name="visibility" id="visibility-radio-private" value="private" <?php checked( $visibility, 'private' ); ?> /> <label for="visibility-radio-private" class="selectit"><?php _e('Private'); ?></label><br /> |
|
186 |
|
187 <p> |
|
188 <a href="#visibility" class="save-post-visibility hide-if-no-js button"><?php _e('OK'); ?></a> |
|
189 <a href="#visibility" class="cancel-post-visibility hide-if-no-js"><?php _e('Cancel'); ?></a> |
|
190 </p> |
|
191 </div> |
|
192 <?php } ?> |
|
193 |
|
194 </div><?php // /misc-pub-section ?> |
|
195 |
|
196 |
|
197 <?php |
|
198 // translators: Publish box date formt, see http://php.net/date |
|
199 $datef = __( 'M j, Y @ G:i' ); |
|
200 if ( 0 != $post->ID ) { |
|
201 if ( 'future' == $post->post_status ) { // scheduled for publishing at a future date |
|
202 $stamp = __('Scheduled for: <b>%1$s</b>'); |
|
203 } else if ( 'publish' == $post->post_status || 'private' == $post->post_status ) { // already published |
|
204 $stamp = __('Published on: <b>%1$s</b>'); |
|
205 } else if ( '0000-00-00 00:00:00' == $post->post_date_gmt ) { // draft, 1 or more saves, no date specified |
|
206 $stamp = __('Publish <b>immediately</b>'); |
|
207 } else if ( time() < strtotime( $post->post_date_gmt . ' +0000' ) ) { // draft, 1 or more saves, future date specified |
|
208 $stamp = __('Schedule for: <b>%1$s</b>'); |
|
209 } else { // draft, 1 or more saves, date specified |
|
210 $stamp = __('Publish on: <b>%1$s</b>'); |
|
211 } |
|
212 $date = date_i18n( $datef, strtotime( $post->post_date ) ); |
|
213 } else { // draft (no saves, and thus no date specified) |
|
214 $stamp = __('Publish <b>immediately</b>'); |
|
215 $date = date_i18n( $datef, strtotime( current_time('mysql') ) ); |
|
216 } |
|
217 |
|
218 if ( $can_publish ) : // Contributors don't get to choose the date of publish ?> |
|
219 <div class="misc-pub-section curtime misc-pub-section-last"> |
|
220 <span id="timestamp"> |
|
221 <?php printf($stamp, $date); ?></span> |
|
222 <a href="#edit_timestamp" class="edit-timestamp hide-if-no-js" tabindex='4'><?php _e('Edit') ?></a> |
|
223 <div id="timestampdiv" class="hide-if-js"><?php touch_time(($action == 'edit'),1,4); ?></div> |
|
224 </div><?php // /misc-pub-section ?> |
|
225 <?php endif; ?> |
|
226 |
|
227 </div> |
|
228 <div class="clear"></div> |
|
229 </div> |
|
230 |
|
231 <div id="major-publishing-actions"> |
|
232 <?php do_action('post_submitbox_start'); ?> |
|
233 <div id="delete-action"> |
|
234 <?php |
|
235 if ( ( 'edit' == $action ) && current_user_can('delete_post', $post->ID) ) { ?> |
|
236 <a class="submitdelete deletion" href="<?php echo wp_nonce_url("post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID); ?>" onclick="if ( confirm('<?php echo esc_js(sprintf( ('draft' == $post->post_status) ? __("You are about to delete this draft '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this post '%s'\n 'Cancel' to stop, 'OK' to delete."), $post->post_title )); ?>') ) {return true;}return false;"><?php _e('Delete'); ?></a> |
|
237 <?php } ?> |
|
238 </div> |
|
239 |
|
240 <div id="publishing-action"> |
|
241 <?php |
|
242 if ( !in_array( $post->post_status, array('publish', 'future', 'private') ) || 0 == $post->ID ) { |
|
243 if ( current_user_can('publish_posts') ) : |
|
244 if ( !empty($post->post_date_gmt) && time() < strtotime( $post->post_date_gmt . ' +0000' ) ) : ?> |
|
245 <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Schedule') ?>" /> |
|
246 <input name="publish" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php esc_attr_e('Schedule') ?>" /> |
|
247 <?php else : ?> |
|
248 <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Publish') ?>" /> |
|
249 <input name="publish" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php esc_attr_e('Publish') ?>" /> |
|
250 <?php endif; |
|
251 else : ?> |
|
252 <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Submit for Review') ?>" /> |
|
253 <input name="publish" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php esc_attr_e('Submit for Review') ?>" /> |
|
254 <?php |
|
255 endif; |
|
256 } else { ?> |
|
257 <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Update Post') ?>" /> |
|
258 <input name="save" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php esc_attr_e('Update Post') ?>" /> |
|
259 <?php |
|
260 } ?> |
|
261 </div> |
|
262 <div class="clear"></div> |
|
263 </div> |
|
264 </div> |
|
265 |
|
266 <?php |
|
267 } |
|
268 add_meta_box('submitdiv', __('Publish'), 'post_submit_meta_box', 'post', 'side', 'core'); |
88 add_meta_box('submitdiv', __('Publish'), 'post_submit_meta_box', 'post', 'side', 'core'); |
269 |
|
270 /** |
|
271 * Display post tags form fields. |
|
272 * |
|
273 * @since 2.6.0 |
|
274 * |
|
275 * @param object $post |
|
276 */ |
|
277 function post_tags_meta_box($post, $box) { |
|
278 $tax_name = esc_attr(substr($box['id'], 8)); |
|
279 $taxonomy = get_taxonomy($tax_name); |
|
280 $helps = isset($taxonomy->helps) ? esc_attr($taxonomy->helps) : __('Separate tags with commas.'); |
|
281 ?> |
|
282 <div class="tagsdiv" id="<?php echo $tax_name; ?>"> |
|
283 <div class="jaxtag"> |
|
284 <div class="nojs-tags hide-if-js"> |
|
285 <p><?php _e('Add or remove tags'); ?></p> |
|
286 <textarea name="<?php echo "tax_input[$tax_name]"; ?>" class="the-tags" id="tax-input[<?php echo $tax_name; ?>]"><?php echo esc_attr(get_terms_to_edit( $post->ID, $tax_name )); ?></textarea></div> |
|
287 |
|
288 <span class="ajaxtag hide-if-no-js"> |
|
289 <label class="screen-reader-text" for="new-tag-<?php echo $tax_name; ?>"><?php echo $box['title']; ?></label> |
|
290 <input type="text" id="new-tag-<?php echo $tax_name; ?>" name="newtag[<?php echo $tax_name; ?>]" class="newtag form-input-tip" size="16" autocomplete="off" value="<?php esc_attr_e('Add new tag'); ?>" /> |
|
291 <input type="button" class="button tagadd" value="<?php esc_attr_e('Add'); ?>" tabindex="3" /> |
|
292 </span></div> |
|
293 <p class="howto"><?php echo $helps; ?></p> |
|
294 <div class="tagchecklist"></div> |
|
295 </div> |
|
296 <p class="tagcloud-link hide-if-no-js"><a href="#titlediv" class="tagcloud-link" id="link-<?php echo $tax_name; ?>"><?php printf( __('Choose from the most used tags in %s'), $box['title'] ); ?></a></p> |
|
297 <?php |
|
298 } |
|
299 |
89 |
300 // all tag-style post taxonomies |
90 // all tag-style post taxonomies |
301 foreach ( get_object_taxonomies('post') as $tax_name ) { |
91 foreach ( get_object_taxonomies('post') as $tax_name ) { |
302 if ( !is_taxonomy_hierarchical($tax_name) ) { |
92 if ( !is_taxonomy_hierarchical($tax_name) ) { |
303 $taxonomy = get_taxonomy($tax_name); |
93 $taxonomy = get_taxonomy($tax_name); |
305 |
95 |
306 add_meta_box('tagsdiv-' . $tax_name, $label, 'post_tags_meta_box', 'post', 'side', 'core'); |
96 add_meta_box('tagsdiv-' . $tax_name, $label, 'post_tags_meta_box', 'post', 'side', 'core'); |
307 } |
97 } |
308 } |
98 } |
309 |
99 |
310 /** |
|
311 * Display post categories form fields. |
|
312 * |
|
313 * @since 2.6.0 |
|
314 * |
|
315 * @param object $post |
|
316 */ |
|
317 function post_categories_meta_box($post) { |
|
318 ?> |
|
319 <ul id="category-tabs"> |
|
320 <li class="tabs"><a href="#categories-all" tabindex="3"><?php _e( 'All Categories' ); ?></a></li> |
|
321 <li class="hide-if-no-js"><a href="#categories-pop" tabindex="3"><?php _e( 'Most Used' ); ?></a></li> |
|
322 </ul> |
|
323 |
|
324 <div id="categories-pop" class="tabs-panel" style="display: none;"> |
|
325 <ul id="categorychecklist-pop" class="categorychecklist form-no-clear" > |
|
326 <?php $popular_ids = wp_popular_terms_checklist('category'); ?> |
|
327 </ul> |
|
328 </div> |
|
329 |
|
330 <div id="categories-all" class="tabs-panel"> |
|
331 <ul id="categorychecklist" class="list:category categorychecklist form-no-clear"> |
|
332 <?php wp_category_checklist($post->ID, false, false, $popular_ids) ?> |
|
333 </ul> |
|
334 </div> |
|
335 |
|
336 <?php if ( current_user_can('manage_categories') ) : ?> |
|
337 <div id="category-adder" class="wp-hidden-children"> |
|
338 <h4><a id="category-add-toggle" href="#category-add" class="hide-if-no-js" tabindex="3"><?php _e( '+ Add New Category' ); ?></a></h4> |
|
339 <p id="category-add" class="wp-hidden-child"> |
|
340 <label class="screen-reader-text" for="newcat"><?php _e( 'Add New Category' ); ?></label><input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php esc_attr_e( 'New category name' ); ?>" tabindex="3" aria-required="true"/> |
|
341 <label class="screen-reader-text" for="newcat_parent"><?php _e('Parent category'); ?>:</label><?php wp_dropdown_categories( array( 'hide_empty' => 0, 'name' => 'newcat_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => __('Parent category'), 'tab_index' => 3 ) ); ?> |
|
342 <input type="button" id="category-add-sumbit" class="add:categorychecklist:category-add button" value="<?php esc_attr_e( 'Add' ); ?>" tabindex="3" /> |
|
343 <?php wp_nonce_field( 'add-category', '_ajax_nonce', false ); ?> |
|
344 <span id="category-ajax-response"></span></p> |
|
345 </div> |
|
346 <?php |
|
347 endif; |
|
348 |
|
349 } |
|
350 add_meta_box('categorydiv', __('Categories'), 'post_categories_meta_box', 'post', 'side', 'core'); |
100 add_meta_box('categorydiv', __('Categories'), 'post_categories_meta_box', 'post', 'side', 'core'); |
351 |
101 if ( current_theme_supports( 'post-thumbnails', 'post' ) ) |
352 /** |
102 add_meta_box('postimagediv', __('Post Thumbnail'), 'post_thumbnail_meta_box', 'post', 'side', 'low'); |
353 * Display post password form fields. |
|
354 * |
|
355 * @since 2.6.0 |
|
356 * |
|
357 * @param object $post |
|
358 */ |
|
359 function post_password_meta_box($post) { |
|
360 ?> |
|
361 <p><label for="post_status_private" class="selectit"><input id="post_status_private" name="post_status" type="checkbox" value="private" <?php checked($post->post_status, 'private'); ?> tabindex="4" /> <?php _e('Keep this post private') ?></label></p> |
|
362 <h4><?php _e( 'Post Password' ); ?></h4> |
|
363 <p><label class="screen-reader-text" for="post_password"><?php _e('Password Protect This Post') ?></label><input name="post_password" type="text" size="25" id="post_password" value="<?php the_post_password(); ?>" /></p> |
|
364 <p><?php _e('Setting a password will require people who visit your blog to enter the above password to view this post and its comments.'); ?></p> |
|
365 <?php |
|
366 } |
|
367 // add_meta_box('passworddiv', __('Privacy Options'), 'post_password_meta_box', 'post', 'side', 'core'); |
|
368 |
|
369 /** |
|
370 * Display post excerpt form fields. |
|
371 * |
|
372 * @since 2.6.0 |
|
373 * |
|
374 * @param object $post |
|
375 */ |
|
376 function post_excerpt_meta_box($post) { |
|
377 ?> |
|
378 <label class="screen-reader-text" for="excerpt"><?php _e('Excerpt') ?></label><textarea rows="1" cols="40" name="excerpt" tabindex="6" id="excerpt"><?php echo $post->post_excerpt ?></textarea> |
|
379 <p><?php _e('Excerpts are optional hand-crafted summaries of your content that can be used in your theme. <a href="http://codex.wordpress.org/Excerpt" target="_blank">Learn more about manual excerpts.</a>'); ?></p> |
|
380 <?php |
|
381 } |
|
382 add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', 'post', 'normal', 'core'); |
103 add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', 'post', 'normal', 'core'); |
383 |
|
384 /** |
|
385 * Display trackback links form fields. |
|
386 * |
|
387 * @since 2.6.0 |
|
388 * |
|
389 * @param object $post |
|
390 */ |
|
391 function post_trackback_meta_box($post) { |
|
392 $form_trackback = '<input type="text" name="trackback_url" id="trackback_url" class="code" tabindex="7" value="'. esc_attr( str_replace("\n", ' ', $post->to_ping) ) .'" />'; |
|
393 if ('' != $post->pinged) { |
|
394 $pings = '<p>'. __('Already pinged:') . '</p><ul>'; |
|
395 $already_pinged = explode("\n", trim($post->pinged)); |
|
396 foreach ($already_pinged as $pinged_url) { |
|
397 $pings .= "\n\t<li>" . esc_html($pinged_url) . "</li>"; |
|
398 } |
|
399 $pings .= '</ul>'; |
|
400 } |
|
401 |
|
402 ?> |
|
403 <p><label for="trackback_url"><?php _e('Send trackbacks to:'); ?></label> <?php echo $form_trackback; ?><br /> (<?php _e('Separate multiple URLs with spaces'); ?>)</p> |
|
404 <p><?php _e('Trackbacks are a way to notify legacy blog systems that you’ve linked to them. If you link other WordPress blogs they’ll be notified automatically using <a href="http://codex.wordpress.org/Introduction_to_Blogging#Managing_Comments" target="_blank">pingbacks</a>, no other action necessary.'); ?></p> |
|
405 <?php |
|
406 if ( ! empty($pings) ) |
|
407 echo $pings; |
|
408 } |
|
409 add_meta_box('trackbacksdiv', __('Send Trackbacks'), 'post_trackback_meta_box', 'post', 'normal', 'core'); |
104 add_meta_box('trackbacksdiv', __('Send Trackbacks'), 'post_trackback_meta_box', 'post', 'normal', 'core'); |
410 |
|
411 /** |
|
412 * Display custom fields for the post form fields. |
|
413 * |
|
414 * @since 2.6.0 |
|
415 * |
|
416 * @param object $post |
|
417 */ |
|
418 function post_custom_meta_box($post) { |
|
419 ?> |
|
420 <div id="postcustomstuff"> |
|
421 <div id="ajax-response"></div> |
|
422 <?php |
|
423 $metadata = has_meta($post->ID); |
|
424 list_meta($metadata); |
|
425 meta_form(); ?> |
|
426 </div> |
|
427 <p><?php _e('Custom fields can be used to add extra metadata to a post that you can <a href="http://codex.wordpress.org/Using_Custom_Fields" target="_blank">use in your theme</a>.'); ?></p> |
|
428 <?php |
|
429 } |
|
430 add_meta_box('postcustom', __('Custom Fields'), 'post_custom_meta_box', 'post', 'normal', 'core'); |
105 add_meta_box('postcustom', __('Custom Fields'), 'post_custom_meta_box', 'post', 'normal', 'core'); |
431 |
|
432 do_action('dbx_post_advanced'); |
106 do_action('dbx_post_advanced'); |
433 |
|
434 /** |
|
435 * Display comment status for post form fields. |
|
436 * |
|
437 * @since 2.6.0 |
|
438 * |
|
439 * @param object $post |
|
440 */ |
|
441 function post_comment_status_meta_box($post) { |
|
442 ?> |
|
443 <input name="advanced_view" type="hidden" value="1" /> |
|
444 <p class="meta-options"> |
|
445 <label for="comment_status" class="selectit"> <input name="comment_status" type="checkbox" id="comment_status" value="open" <?php checked($post->comment_status, 'open'); ?> /> <?php _e('Allow comments on this post') ?></label><br /> |
|
446 <label for="ping_status" class="selectit"><input name="ping_status" type="checkbox" id="ping_status" value="open" <?php checked($post->ping_status, 'open'); ?> /> <?php _e('Allow <a href="http://codex.wordpress.org/Introduction_to_Blogging#Managing_Comments" target="_blank">trackbacks and pingbacks</a> on this post') ?></label></p> |
|
447 <?php |
|
448 } |
|
449 add_meta_box('commentstatusdiv', __('Discussion'), 'post_comment_status_meta_box', 'post', 'normal', 'core'); |
107 add_meta_box('commentstatusdiv', __('Discussion'), 'post_comment_status_meta_box', 'post', 'normal', 'core'); |
450 |
108 |
451 /** |
|
452 * Display comments for post. |
|
453 * |
|
454 * @since 2.8.0 |
|
455 * |
|
456 * @param object $post |
|
457 */ |
|
458 function post_comment_meta_box($post) { |
|
459 global $wpdb, $post_ID; |
|
460 |
|
461 $total = $wpdb->get_var($wpdb->prepare("SELECT count(1) FROM $wpdb->comments WHERE comment_post_ID = '%d' AND ( comment_approved = '0' OR comment_approved = '1')", $post_ID)); |
|
462 |
|
463 if ( 1 > $total ) { |
|
464 echo '<p>' . __('No comments yet.') . '</p>'; |
|
465 return; |
|
466 } |
|
467 |
|
468 wp_nonce_field( 'get-comments', 'add_comment_nonce', false ); |
|
469 ?> |
|
470 |
|
471 <table class="widefat comments-box fixed" cellspacing="0" style="display:none;"> |
|
472 <thead><tr> |
|
473 <th scope="col" class="column-author"><?php _e('Author') ?></th> |
|
474 <th scope="col" class="column-comment"> |
|
475 <?php /* translators: field name in comment form */ echo _x('Comment', 'noun'); ?></th> |
|
476 </tr></thead> |
|
477 <tbody id="the-comment-list" class="list:comment"></tbody> |
|
478 </table> |
|
479 <p class="hide-if-no-js"><a href="#commentstatusdiv" id="show-comments" onclick="commentsBox.get(<?php echo $total; ?>);return false;"><?php _e('Show comments'); ?></a> <img class="waiting" style="display:none;" src="images/wpspin_light.gif" alt="" /></p> |
|
480 <?php |
|
481 $hidden = get_hidden_meta_boxes('post'); |
|
482 if ( ! in_array('commentsdiv', $hidden) ) { ?> |
|
483 <script type="text/javascript">jQuery(document).ready(function(){commentsBox.get(<?php echo $total; ?>, 10);});</script> |
|
484 <?php |
|
485 } |
|
486 } |
|
487 if ( 'publish' == $post->post_status || 'private' == $post->post_status ) |
109 if ( 'publish' == $post->post_status || 'private' == $post->post_status ) |
488 add_meta_box('commentsdiv', __('Comments'), 'post_comment_meta_box', 'post', 'normal', 'core'); |
110 add_meta_box('commentsdiv', __('Comments'), 'post_comment_meta_box', 'post', 'normal', 'core'); |
489 |
111 |
490 /** |
|
491 * Display post slug form fields. |
|
492 * |
|
493 * @since 2.6.0 |
|
494 * |
|
495 * @param object $post |
|
496 */ |
|
497 function post_slug_meta_box($post) { |
|
498 ?> |
|
499 <label class="screen-reader-text" for="post_name"><?php _e('Post Slug') ?></label><input name="post_name" type="text" size="13" id="post_name" value="<?php echo esc_attr( $post->post_name ); ?>" /> |
|
500 <?php |
|
501 } |
|
502 if ( !( 'pending' == $post->post_status && !current_user_can( 'publish_posts' ) ) ) |
112 if ( !( 'pending' == $post->post_status && !current_user_can( 'publish_posts' ) ) ) |
503 add_meta_box('slugdiv', __('Post Slug'), 'post_slug_meta_box', 'post', 'normal', 'core'); |
113 add_meta_box('slugdiv', __('Post Slug'), 'post_slug_meta_box', 'post', 'normal', 'core'); |
504 |
114 |
505 $authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM |
115 $authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM |
506 if ( $post->post_author && !in_array($post->post_author, $authors) ) |
116 if ( $post->post_author && !in_array($post->post_author, $authors) ) |
507 $authors[] = $post->post_author; |
117 $authors[] = $post->post_author; |
508 if ( $authors && count( $authors ) > 1 ) : |
118 if ( $authors && count( $authors ) > 1 ) |
509 /** |
119 add_meta_box('authordiv', __('Post Author'), 'post_author_meta_box', 'post', 'normal', 'core'); |
510 * Display form field with list of authors. |
120 |
511 * |
121 if ( 0 < $post_ID && wp_get_post_revisions( $post_ID ) ) |
512 * @since 2.6.0 |
122 add_meta_box('revisionsdiv', __('Post Revisions'), 'post_revisions_meta_box', 'post', 'normal', 'core'); |
513 * |
|
514 * @param object $post |
|
515 */ |
|
516 function post_author_meta_box($post) { |
|
517 global $current_user, $user_ID; |
|
518 $authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM |
|
519 if ( $post->post_author && !in_array($post->post_author, $authors) ) |
|
520 $authors[] = $post->post_author; |
|
521 ?> |
|
522 <label class="screen-reader-text" for="post_author_override"><?php _e('Post Author'); ?></label><?php wp_dropdown_users( array('include' => $authors, 'name' => 'post_author_override', 'selected' => empty($post->ID) ? $user_ID : $post->post_author) ); ?> |
|
523 <?php |
|
524 } |
|
525 add_meta_box('authordiv', __('Post Author'), 'post_author_meta_box', 'post', 'normal', 'core'); |
|
526 endif; |
|
527 |
|
528 if ( 0 < $post_ID && wp_get_post_revisions( $post_ID ) ) : |
|
529 /** |
|
530 * Display list of post revisions. |
|
531 * |
|
532 * @since 2.6.0 |
|
533 * |
|
534 * @param object $post |
|
535 */ |
|
536 function post_revisions_meta_box($post) { |
|
537 wp_list_post_revisions(); |
|
538 } |
|
539 add_meta_box('revisionsdiv', __('Post Revisions'), 'post_revisions_meta_box', 'post', 'normal', 'core'); |
|
540 endif; |
|
541 |
123 |
542 do_action('do_meta_boxes', 'post', 'normal', $post); |
124 do_action('do_meta_boxes', 'post', 'normal', $post); |
543 do_action('do_meta_boxes', 'post', 'advanced', $post); |
125 do_action('do_meta_boxes', 'post', 'advanced', $post); |
544 do_action('do_meta_boxes', 'post', 'side', $post); |
126 do_action('do_meta_boxes', 'post', 'side', $post); |
545 |
127 |
546 require_once('admin-header.php'); |
128 require_once('admin-header.php'); |
547 |
129 |
548 ?> |
130 ?> |
549 |
|
550 <?php if ( (isset($mode) && 'bookmarklet' == $mode) || isset($_GET['popupurl']) ): ?> |
|
551 <input type="hidden" name="mode" value="bookmarklet" /> |
|
552 <?php endif; ?> |
|
553 |
131 |
554 <div class="wrap"> |
132 <div class="wrap"> |
555 <?php screen_icon(); ?> |
133 <?php screen_icon(); ?> |
556 <h2><?php echo esc_html( $title ); ?></h2> |
134 <h2><?php echo esc_html( $title ); ?></h2> |
557 <?php if ( $notice ) : ?> |
135 <?php if ( $notice ) : ?> |
558 <div id="notice" class="error"><p><?php echo $notice ?></p></div> |
136 <div id="notice" class="error"><p><?php echo $notice ?></p></div> |
559 <?php endif; ?> |
137 <?php endif; ?> |
560 <?php if (isset($_GET['message'])) : ?> |
138 <?php if ( $message ) : ?> |
561 <div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div> |
139 <div id="message" class="updated fade"><p><?php echo $message; ?></p></div> |
562 <?php endif; ?> |
140 <?php endif; ?> |
563 <form name="post" action="post.php" method="post" id="post"> |
141 <form name="post" action="post.php" method="post" id="post"> |
564 <?php |
142 <?php |
565 |
143 |
566 if ( 0 == $post_ID) |
144 if ( 0 == $post_ID) |