Wordpress 2.9
[autoinstalls/wordpress.git] / wp-admin / includes / meta-boxes.php
1 <?php
2
3 // -- Post related Meta Boxes
4
5 /**
6  * Display post submit form fields.
7  *
8  * @since 2.7.0
9  *
10  * @param object $post
11  */
12 function post_submit_meta_box($post) {
13         global $action;
14
15         $post_type = $post->post_type;
16         $can_publish = current_user_can("publish_${post_type}s");
17 ?>
18 <div class="submitbox" id="submitpost">
19
20 <div id="minor-publishing">
21
22 <?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key ?>
23 <div style="display:none;">
24 <input type="submit" name="save" value="<?php esc_attr_e('Save'); ?>" />
25 </div>
26
27 <div id="minor-publishing-actions">
28 <div id="save-action">
29 <?php if ( 'publish' != $post->post_status && 'future' != $post->post_status && 'pending' != $post->post_status )  { ?>
30 <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" />
31 <?php } elseif ( 'pending' == $post->post_status && $can_publish ) { ?>
32 <input type="submit" name="save" id="save-post" value="<?php esc_attr_e('Save as Pending'); ?>" tabindex="4" class="button button-highlighted" />
33 <?php } ?>
34 </div>
35
36 <div id="preview-action">
37 <?php
38 if ( 'publish' == $post->post_status ) {
39         $preview_link = esc_url(get_permalink($post->ID));
40         $preview_button = __('Preview Changes');
41 } else {
42         $preview_link = esc_url(apply_filters('preview_post_link', add_query_arg('preview', 'true', get_permalink($post->ID))));
43         $preview_button = __('Preview');
44 }
45 ?>
46 <a class="preview button" href="<?php echo $preview_link; ?>" target="wp-preview" id="post-preview" tabindex="4"><?php echo $preview_button; ?></a>
47 <input type="hidden" name="wp-preview" id="wp-preview" value="" />
48 </div>
49
50 <div class="clear"></div>
51 </div><?php // /minor-publishing-actions ?>
52
53 <div id="misc-publishing-actions">
54
55 <div class="misc-pub-section<?php if ( !$can_publish ) { echo ' misc-pub-section-last'; } ?>"><label for="post_status"><?php _e('Status:') ?></label>
56 <span id="post-status-display">
57 <?php
58 switch ( $post->post_status ) {
59         case 'private':
60                 _e('Privately Published');
61                 break;
62         case 'publish':
63                 _e('Published');
64                 break;
65         case 'future':
66                 _e('Scheduled');
67                 break;
68         case 'pending':
69                 _e('Pending Review');
70                 break;
71         case 'draft':
72                 _e('Draft');
73                 break;
74 }
75 ?>
76 </span>
77 <?php if ( 'publish' == $post->post_status || 'private' == $post->post_status || $can_publish ) { ?>
78 <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>
79
80 <div id="post-status-select" class="hide-if-js">
81 <input type="hidden" name="hidden_post_status" id="hidden_post_status" value="<?php echo esc_attr($post->post_status); ?>" />
82 <select name='post_status' id='post_status' tabindex='4'>
83 <?php if ( 'publish' == $post->post_status ) : ?>
84 <option<?php selected( $post->post_status, 'publish' ); ?> value='publish'><?php _e('Published') ?></option>
85 <?php elseif ( 'private' == $post->post_status ) : ?>
86 <option<?php selected( $post->post_status, 'private' ); ?> value='publish'><?php _e('Privately Published') ?></option>
87 <?php elseif ( 'future' == $post->post_status ) : ?>
88 <option<?php selected( $post->post_status, 'future' ); ?> value='future'><?php _e('Scheduled') ?></option>
89 <?php endif; ?>
90 <option<?php selected( $post->post_status, 'pending' ); ?> value='pending'><?php _e('Pending Review') ?></option>
91 <option<?php selected( $post->post_status, 'draft' ); ?> value='draft'><?php _e('Draft') ?></option>
92 </select>
93  <a href="#post_status" class="save-post-status hide-if-no-js button"><?php _e('OK'); ?></a>
94  <a href="#post_status" class="cancel-post-status hide-if-no-js"><?php _e('Cancel'); ?></a>
95 </div>
96
97 <?php } ?>
98 </div><?php // /misc-pub-section ?>
99
100 <div class="misc-pub-section " id="visibility">
101 <?php _e('Visibility:'); ?> <span id="post-visibility-display"><?php
102
103 if ( 'private' == $post->post_status ) {
104         $post->post_password = '';
105         $visibility = 'private';
106         $visibility_trans = __('Private');
107 } elseif ( !empty( $post->post_password ) ) {
108         $visibility = 'password';
109         $visibility_trans = __('Password protected');
110 } elseif ( $post_type == 'post' && is_sticky( $post->ID ) ) {
111         $visibility = 'public';
112         $visibility_trans = __('Public, Sticky');
113 } else {
114         $visibility = 'public';
115         $visibility_trans = __('Public');
116 }
117
118 echo esc_html( $visibility_trans ); ?></span>
119 <?php if ( $can_publish ) { ?>
120 <a href="#visibility" class="edit-visibility hide-if-no-js"><?php _e('Edit'); ?></a>
121
122 <div id="post-visibility-select" class="hide-if-js">
123 <input type="hidden" name="hidden_post_password" id="hidden-post-password" value="<?php echo esc_attr($post->post_password); ?>" />
124 <?php if ($post_type == 'post'): ?>
125 <input type="checkbox" style="display:none" name="hidden_post_sticky" id="hidden-post-sticky" value="sticky" <?php checked(is_sticky($post->ID)); ?> />
126 <?php endif; ?>
127 <input type="hidden" name="hidden_post_visibility" id="hidden-post-visibility" value="<?php echo esc_attr( $visibility ); ?>" />
128
129
130 <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 />
131 <?php if ($post_type == 'post'): ?>
132 <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>
133 <?php endif; ?>
134 <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 />
135 <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>
136 <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 />
137
138 <p>
139  <a href="#visibility" class="save-post-visibility hide-if-no-js button"><?php _e('OK'); ?></a>
140  <a href="#visibility" class="cancel-post-visibility hide-if-no-js"><?php _e('Cancel'); ?></a>
141 </p>
142 </div>
143 <?php } ?>
144
145 </div><?php // /misc-pub-section ?>
146
147
148 <?php
149 // translators: Publish box date formt, see http://php.net/date
150 $datef = __( 'M j, Y @ G:i' );
151 if ( 0 != $post->ID ) {
152         if ( 'future' == $post->post_status ) { // scheduled for publishing at a future date
153                 $stamp = __('Scheduled for: <b>%1$s</b>');
154         } else if ( 'publish' == $post->post_status || 'private' == $post->post_status ) { // already published
155                 $stamp = __('Published on: <b>%1$s</b>');
156         } else if ( '0000-00-00 00:00:00' == $post->post_date_gmt ) { // draft, 1 or more saves, no date specified
157                 $stamp = __('Publish <b>immediately</b>');
158         } else if ( time() < strtotime( $post->post_date_gmt . ' +0000' ) ) { // draft, 1 or more saves, future date specified
159                 $stamp = __('Schedule for: <b>%1$s</b>');
160         } else { // draft, 1 or more saves, date specified
161                 $stamp = __('Publish on: <b>%1$s</b>');
162         }
163         $date = date_i18n( $datef, strtotime( $post->post_date ) );
164 } else { // draft (no saves, and thus no date specified)
165         $stamp = __('Publish <b>immediately</b>');
166         $date = date_i18n( $datef, strtotime( current_time('mysql') ) );
167 }
168
169 if ( $can_publish ) : // Contributors don't get to choose the date of publish ?>
170 <div class="misc-pub-section curtime misc-pub-section-last">
171         <span id="timestamp">
172         <?php printf($stamp, $date); ?></span>
173         <a href="#edit_timestamp" class="edit-timestamp hide-if-no-js" tabindex='4'><?php _e('Edit') ?></a>
174         <div id="timestampdiv" class="hide-if-js"><?php touch_time(($action == 'edit'),1,4); ?></div>
175 </div><?php // /misc-pub-section ?>
176 <?php endif; ?>
177
178 <?php do_action('post_submitbox_misc_actions'); ?>
179 </div>
180 <div class="clear"></div>
181 </div>
182
183 <div id="major-publishing-actions">
184 <?php do_action('post_submitbox_start'); ?>
185 <div id="delete-action">
186 <?php
187 if ( current_user_can( "delete_${post_type}", $post->ID ) ) {
188         if ( !EMPTY_TRASH_DAYS ) {
189                 $delete_url = wp_nonce_url( add_query_arg( array('action' => 'delete', 'post' => $post->ID) ), "delete-${post_type}_{$post->ID}" );
190                 $delete_text = __('Delete Permanently');
191         } else {
192                 $delete_url = wp_nonce_url( add_query_arg( array('action' => 'trash', 'post' => $post->ID) ), "trash-${post_type}_{$post->ID}" );
193                 $delete_text = __('Move to Trash');
194         } ?>
195 <a class="submitdelete deletion<?php if ( 'edit' != $action ) { echo " hidden"; } ?>" href="<?php echo $delete_url; ?>"><?php echo $delete_text; ?></a><?php
196 } ?>
197 </div>
198
199 <div id="publishing-action">
200 <img src="images/wpspin_light.gif" id="ajax-loading" style="visibility:hidden;" alt="" />
201 <?php
202 if ( !in_array( $post->post_status, array('publish', 'future', 'private') ) || 0 == $post->ID ) {
203         if ( $can_publish ) :
204                 if ( !empty($post->post_date_gmt) && time() < strtotime( $post->post_date_gmt . ' +0000' ) ) : ?>
205                 <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Schedule') ?>" />
206                 <input name="publish" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php esc_attr_e('Schedule') ?>" />
207 <?php   else : ?>
208                 <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Publish') ?>" />
209                 <input name="publish" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php esc_attr_e('Publish') ?>" />
210 <?php   endif;
211         else : ?>
212                 <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Submit for Review') ?>" />
213                 <input name="publish" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php esc_attr_e('Submit for Review') ?>" />
214 <?php
215         endif;
216 } else { ?>
217                 <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Update') ?>" />
218                 <input name="save" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php esc_attr_e('Update') ?>" />
219 <?php
220 } ?>
221 </div>
222 <div class="clear"></div>
223 </div>
224 </div>
225
226 <?php
227 }
228
229
230 /**
231  * Display post tags form fields.
232  *
233  * @since 2.6.0
234  *
235  * @param object $post
236  */
237 function post_tags_meta_box($post, $box) {
238         $tax_name = esc_attr(substr($box['id'], 8));
239         $taxonomy = get_taxonomy($tax_name);
240         $helps = isset($taxonomy->helps) ? esc_attr($taxonomy->helps) : __('Separate tags with commas.');
241 ?>
242 <div class="tagsdiv" id="<?php echo $tax_name; ?>">
243         <div class="jaxtag">
244         <div class="nojs-tags hide-if-js">
245         <p><?php _e('Add or remove tags'); ?></p>
246         <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>
247
248         <div class="ajaxtag hide-if-no-js">
249                 <label class="screen-reader-text" for="new-tag-<?php echo $tax_name; ?>"><?php echo $box['title']; ?></label>
250                 <div class="taghint"><?php _e('Add new tag'); ?></div>
251                 <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="" />
252                 <input type="button" class="button tagadd" value="<?php esc_attr_e('Add'); ?>" tabindex="3" />
253         </div></div>
254         <p class="howto"><?php echo $helps; ?></p>
255         <div class="tagchecklist"></div>
256 </div>
257 <p class="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>
258 <?php
259 }
260
261
262 /**
263  * Display post categories form fields.
264  *
265  * @since 2.6.0
266  *
267  * @param object $post
268  */
269 function post_categories_meta_box($post) {
270 ?>
271 <ul id="category-tabs">
272         <li class="tabs"><a href="#categories-all" tabindex="3"><?php _e( 'All Categories' ); ?></a></li>
273         <li class="hide-if-no-js"><a href="#categories-pop" tabindex="3"><?php _e( 'Most Used' ); ?></a></li>
274 </ul>
275
276 <div id="categories-pop" class="tabs-panel" style="display: none;">
277         <ul id="categorychecklist-pop" class="categorychecklist form-no-clear" >
278 <?php $popular_ids = wp_popular_terms_checklist('category'); ?>
279         </ul>
280 </div>
281
282 <div id="categories-all" class="tabs-panel">
283         <ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
284 <?php wp_category_checklist($post->ID, false, false, $popular_ids) ?>
285         </ul>
286 </div>
287
288 <?php if ( current_user_can('manage_categories') ) : ?>
289 <div id="category-adder" class="wp-hidden-children">
290         <h4><a id="category-add-toggle" href="#category-add" class="hide-if-no-js" tabindex="3"><?php _e( '+ Add New Category' ); ?></a></h4>
291         <p id="category-add" class="wp-hidden-child">
292         <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"/>
293         <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') ) ); ?>
294         <input type="button" id="category-add-sumbit" class="add:categorychecklist:category-add button" value="<?php esc_attr_e( 'Add' ); ?>" tabindex="3" />
295 <?php   wp_nonce_field( 'add-category', '_ajax_nonce', false ); ?>
296         <span id="category-ajax-response"></span></p>
297 </div>
298 <?php
299 endif;
300
301 }
302
303
304 /**
305  * Display post excerpt form fields.
306  *
307  * @since 2.6.0
308  *
309  * @param object $post
310  */
311 function post_excerpt_meta_box($post) {
312 ?>
313 <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>
314 <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>
315 <?php
316 }
317
318
319 /**
320  * Display trackback links form fields.
321  *
322  * @since 2.6.0
323  *
324  * @param object $post
325  */
326 function post_trackback_meta_box($post) {
327         $form_trackback = '<input type="text" name="trackback_url" id="trackback_url" class="code" tabindex="7" value="'. esc_attr( str_replace("\n", ' ', $post->to_ping) ) .'" />';
328         if ('' != $post->pinged) {
329                 $pings = '<p>'. __('Already pinged:') . '</p><ul>';
330                 $already_pinged = explode("\n", trim($post->pinged));
331                 foreach ($already_pinged as $pinged_url) {
332                         $pings .= "\n\t<li>" . esc_html($pinged_url) . "</li>";
333                 }
334                 $pings .= '</ul>';
335         }
336
337 ?>
338 <p><label for="trackback_url"><?php _e('Send trackbacks to:'); ?></label> <?php echo $form_trackback; ?><br /> (<?php _e('Separate multiple URLs with spaces'); ?>)</p>
339 <p><?php _e('Trackbacks are a way to notify legacy blog systems that you&#8217;ve linked to them. If you link other WordPress blogs they&#8217;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>
340 <?php
341 if ( ! empty($pings) )
342         echo $pings;
343 }
344
345
346 /**
347  * Display custom fields form fields.
348  *
349  * @since 2.6.0
350  *
351  * @param object $post
352  */
353 function post_custom_meta_box($post) {
354 ?>
355 <div id="postcustomstuff">
356 <div id="ajax-response"></div>
357 <?php
358 $metadata = has_meta($post->ID);
359 list_meta($metadata);
360 meta_form(); ?>
361 </div>
362 <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>
363 <?php
364 }
365
366
367 /**
368  * Display comments status form fields.
369  *
370  * @since 2.6.0
371  *
372  * @param object $post
373  */
374 function post_comment_status_meta_box($post) {
375 ?>
376 <input name="advanced_view" type="hidden" value="1" />
377 <p class="meta-options">
378         <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.') ?></label><br />
379         <label for="ping_status" class="selectit"><input name="ping_status" type="checkbox" id="ping_status" value="open" <?php checked($post->ping_status, 'open'); ?> /><?php printf( __('Allow <a href="%s" target="_blank">trackbacks and pingbacks</a> on this page.'),_x('http://codex.wordpress.org/Introduction_to_Blogging#Managing_Comments','Url to codex article on Managing Comments')); ?></label>
380 </p>
381 <?php
382 }
383
384
385 /**
386  * Display comments for post.
387  *
388  * @since 2.8.0
389  *
390  * @param object $post
391  */
392 function post_comment_meta_box($post) {
393         global $wpdb, $post_ID;
394
395         $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));
396
397         if ( 1 > $total ) {
398                 echo '<p>' . __('No comments yet.') . '</p>';
399                 return;
400         }
401
402         wp_nonce_field( 'get-comments', 'add_comment_nonce', false );
403 ?>
404
405 <table class="widefat comments-box fixed" cellspacing="0" style="display:none;">
406 <thead><tr>
407     <th scope="col" class="column-author"><?php _e('Author') ?></th>
408     <th scope="col" class="column-comment">
409 <?php /* translators: field name in comment form */ echo _x('Comment', 'noun'); ?></th>
410 </tr></thead>
411 <tbody id="the-comment-list" class="list:comment"></tbody>
412 </table>
413 <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>
414 <?php
415         $hidden = get_hidden_meta_boxes('post');
416         if ( ! in_array('commentsdiv', $hidden) ) { ?>
417                 <script type="text/javascript">jQuery(document).ready(function(){commentsBox.get(<?php echo $total; ?>, 10);});</script>
418 <?php
419         }
420         wp_comment_trashnotice();
421 }
422
423
424 /**
425  * Display slug form fields.
426  *
427  * @since 2.6.0
428  *
429  * @param object $post
430  */
431 function post_slug_meta_box($post) {
432 ?>
433 <label class="screen-reader-text" for="post_name"><?php _e('Slug') ?></label><input name="post_name" type="text" size="13" id="post_name" value="<?php echo esc_attr( $post->post_name ); ?>" />
434 <?php
435 }
436
437
438 /**
439  * Display form field with list of authors.
440  *
441  * @since 2.6.0
442  *
443  * @param object $post
444  */
445 function post_author_meta_box($post) {
446         global $current_user, $user_ID;
447         $authors = get_editable_user_ids( $current_user->id, true, $post->post_type ); // TODO: ROLE SYSTEM
448         if ( $post->post_author && !in_array($post->post_author, $authors) )
449                 $authors[] = $post->post_author;
450 ?>
451 <label class="screen-reader-text" for="post_author_override"><?php _e('Author'); ?></label><?php wp_dropdown_users( array('include' => $authors, 'name' => 'post_author_override', 'selected' => empty($post->ID) ? $user_ID : $post->post_author) ); ?>
452 <?php
453 }
454
455
456 /**
457  * Display list of revisions.
458  *
459  * @since 2.6.0
460  *
461  * @param object $post
462  */
463 function post_revisions_meta_box($post) {
464         wp_list_post_revisions();
465 }
466
467
468 // -- Page related Meta Boxes
469
470 /**
471  * Display page attributes form fields.
472  *
473  * @since 2.7.0
474  *
475  * @param object $post
476  */
477 function page_attributes_meta_box($post){
478 ?>
479 <h5><?php _e('Parent') ?></h5>
480 <label class="screen-reader-text" for="parent_id"><?php _e('Page Parent') ?></label>
481 <?php wp_dropdown_pages(array('exclude_tree' => $post->ID, 'selected' => $post->post_parent, 'name' => 'parent_id', 'show_option_none' => __('Main Page (no parent)'), 'sort_column'=> 'menu_order, post_title')); ?>
482 <p><?php _e('You can arrange your pages in hierarchies. For example, you could have an &#8220;About&#8221; page that has &#8220;Life Story&#8221; and &#8220;My Dog&#8221; pages under it. There are no limits to how deeply nested you can make pages.'); ?></p>
483 <?php
484         if ( 0 != count( get_page_templates() ) ) { ?>
485 <h5><?php _e('Template') ?></h5>
486 <label class="screen-reader-text" for="page_template"><?php _e('Page Template') ?></label><select name="page_template" id="page_template">
487 <option value='default'><?php _e('Default Template'); ?></option>
488 <?php page_template_dropdown($post->page_template); ?>
489 </select>
490 <p><?php _e('Some themes have custom templates you can use for certain pages that might have additional features or custom layouts. If so, you&#8217;ll see them above.'); ?></p>
491 <?php
492         } ?>
493 <h5><?php _e('Order') ?></h5>
494 <p><label class="screen-reader-text" for="menu_order"><?php _e('Page Order') ?></label><input name="menu_order" type="text" size="4" id="menu_order" value="<?php echo esc_attr($post->menu_order) ?>" /></p>
495 <p><?php _e('Pages are usually ordered alphabetically, but you can put a number above to change the order pages appear in.'); ?></p>
496 <?php
497 }
498
499
500 // -- Link related Meta Boxes
501
502 /**
503  * Display link create form fields.
504  *
505  * @since 2.7.0
506  *
507  * @param object $link
508  */
509 function link_submit_meta_box($link) {
510 ?>
511 <div class="submitbox" id="submitlink">
512
513 <div id="minor-publishing">
514
515 <?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key ?>
516 <div style="display:none;">
517 <input type="submit" name="save" value="<?php esc_attr_e('Save'); ?>" />
518 </div>
519
520 <div id="minor-publishing-actions">
521 <div id="preview-action">
522 <?php if ( !empty($link->link_id) ) { ?>
523         <a class="preview button" href="<?php echo $link->link_url; ?>" target="_blank" tabindex="4"><?php _e('Visit Link'); ?></a>
524 <?php } ?>
525 </div>
526 <div class="clear"></div>
527 </div>
528
529 <div id="misc-publishing-actions">
530 <div class="misc-pub-section misc-pub-section-last">
531         <label for="link_private" class="selectit"><input id="link_private" name="link_visible" type="checkbox" value="N" <?php checked($link->link_visible, 'N'); ?> /> <?php _e('Keep this link private') ?></label>
532 </div>
533 </div>
534
535 </div>
536
537 <div id="major-publishing-actions">
538 <?php do_action('post_submitbox_start'); ?>
539 <div id="delete-action">
540 <?php
541 if ( !empty($_GET['action']) && 'edit' == $_GET['action'] && current_user_can('manage_links') ) { ?>
542         <a class="submitdelete deletion" href="<?php echo wp_nonce_url("link.php?action=delete&amp;link_id=$link->link_id", 'delete-bookmark_' . $link->link_id); ?>" onclick="if ( confirm('<?php echo esc_js(sprintf(__("You are about to delete this link '%s'\n  'Cancel' to stop, 'OK' to delete."), $link->link_name )); ?>') ) {return true;}return false;"><?php _e('Delete'); ?></a>
543 <?php } ?>
544 </div>
545
546 <div id="publishing-action">
547 <?php if ( !empty($link->link_id) ) { ?>
548         <input name="save" type="submit" class="button-primary" id="publish" tabindex="4" accesskey="p" value="<?php esc_attr_e('Update Link') ?>" />
549 <?php } else { ?>
550         <input name="save" type="submit" class="button-primary" id="publish" tabindex="4" accesskey="p" value="<?php esc_attr_e('Add Link') ?>" />
551 <?php } ?>
552 </div>
553 <div class="clear"></div>
554 </div>
555 <?php do_action('submitlink_box'); ?>
556 <div class="clear"></div>
557 </div>
558 <?php
559 }
560
561
562 /**
563  * Display link categories form fields.
564  *
565  * @since 2.6.0
566  *
567  * @param object $link
568  */
569 function link_categories_meta_box($link) { ?>
570 <ul id="category-tabs">
571         <li class="tabs"><a href="#categories-all"><?php _e( 'All Categories' ); ?></a></li>
572         <li class="hide-if-no-js"><a href="#categories-pop"><?php _e( 'Most Used' ); ?></a></li>
573 </ul>
574
575 <div id="categories-all" class="tabs-panel">
576         <ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
577                 <?php
578                 if ( isset($link->link_id) )
579                         wp_link_category_checklist($link->link_id);
580                 else
581                         wp_link_category_checklist();
582                 ?>
583         </ul>
584 </div>
585
586 <div id="categories-pop" class="tabs-panel" style="display: none;">
587         <ul id="categorychecklist-pop" class="categorychecklist form-no-clear">
588                 <?php wp_popular_terms_checklist('link_category'); ?>
589         </ul>
590 </div>
591
592 <div id="category-adder" class="wp-hidden-children">
593         <h4><a id="category-add-toggle" href="#category-add"><?php _e( '+ Add New Category' ); ?></a></h4>
594         <p id="link-category-add" class="wp-hidden-child">
595                 <label class="screen-reader-text" for="newcat"><?php _e( '+ Add New Category' ); ?></label>
596                 <input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php esc_attr_e( 'New category name' ); ?>" aria-required="true" />
597                 <input type="button" id="category-add-submit" class="add:categorychecklist:linkcategorydiv button" value="<?php esc_attr_e( 'Add' ); ?>" />
598                 <?php wp_nonce_field( 'add-link-category', '_ajax_nonce', false ); ?>
599                 <span id="category-ajax-response"></span>
600         </p>
601 </div>
602 <?php
603 }
604
605
606 /**
607  * Display form fields for changing link target.
608  *
609  * @since 2.6.0
610  *
611  * @param object $link
612  */
613 function link_target_meta_box($link) { ?>
614 <fieldset><legend class="screen-reader-text"><span><?php _e('Target') ?></span></legend>
615 <p><label for="link_target_blank" class="selectit">
616 <input id="link_target_blank" type="radio" name="link_target" value="_blank" <?php echo ( isset( $link->link_target ) && ($link->link_target == '_blank') ? 'checked="checked"' : ''); ?> />
617 <?php _e('<code>_blank</code> - new window or tab.'); ?></label></p>
618 <p><label for="link_target_top" class="selectit">
619 <input id="link_target_top" type="radio" name="link_target" value="_top" <?php echo ( isset( $link->link_target ) && ($link->link_target == '_top') ? 'checked="checked"' : ''); ?> />
620 <?php _e('<code>_top</code> - current window or tab, with no frames.'); ?></label></p>
621 <p><label for="link_target_none" class="selectit">
622 <input id="link_target_none" type="radio" name="link_target" value="" <?php echo ( isset( $link->link_target ) && ($link->link_target == '') ? 'checked="checked"' : ''); ?> />
623 <?php _e('<code>_none</code> - same window or tab.'); ?></label></p>
624 </fieldset>
625 <p><?php _e('Choose the target frame for your link.'); ?></p>
626 <?php
627 }
628
629
630 /**
631  * Display checked checkboxes attribute for xfn microformat options.
632  *
633  * @since 1.0.1
634  *
635  * @param string $class
636  * @param string $value
637  * @param mixed $deprecated Not used.
638  */
639 function xfn_check($class, $value = '', $deprecated = '') {
640         global $link;
641
642         $link_rel = isset( $link->link_rel ) ? $link->link_rel : ''; // In PHP 5.3: $link_rel = $link->link_rel ?: '';
643         $rels = preg_split('/\s+/', $link_rel);
644
645         if ('' != $value && in_array($value, $rels) ) {
646                 echo ' checked="checked"';
647         }
648
649         if ('' == $value) {
650                 if ('family' == $class && strpos($link_rel, 'child') === false && strpos($link_rel, 'parent') === false && strpos($link_rel, 'sibling') === false && strpos($link_rel, 'spouse') === false && strpos($link_rel, 'kin') === false) echo ' checked="checked"';
651                 if ('friendship' == $class && strpos($link_rel, 'friend') === false && strpos($link_rel, 'acquaintance') === false && strpos($link_rel, 'contact') === false) echo ' checked="checked"';
652                 if ('geographical' == $class && strpos($link_rel, 'co-resident') === false && strpos($link_rel, 'neighbor') === false) echo ' checked="checked"';
653                 if ('identity' == $class && in_array('me', $rels) ) echo ' checked="checked"';
654         }
655 }
656
657
658 /**
659  * Display xfn form fields.
660  *
661  * @since 2.6.0
662  *
663  * @param object $link
664  */
665 function link_xfn_meta_box($link) {
666 ?>
667 <table class="editform" style="width: 100%;" cellspacing="2" cellpadding="5">
668         <tr>
669                 <th style="width: 20%;" scope="row"><label for="link_rel"><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('rel:') ?></label></th>
670                 <td style="width: 80%;"><input type="text" name="link_rel" id="link_rel" size="50" value="<?php echo ( isset( $link->link_rel ) ? esc_attr($link->link_rel) : ''); ?>" /></td>
671         </tr>
672         <tr>
673                 <td colspan="2">
674                         <table cellpadding="3" cellspacing="5" class="form-table">
675                                 <tr>
676                                         <th scope="row"> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('identity') ?> </th>
677                                         <td><fieldset><legend class="screen-reader-text"><span> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('identity') ?> </span></legend>
678                                                 <label for="me">
679                                                 <input type="checkbox" name="identity" value="me" id="me" <?php xfn_check('identity', 'me'); ?> />
680                                                 <?php _e('another web address of mine') ?></label>
681                                         </fieldset></td>
682                                 </tr>
683                                 <tr>
684                                         <th scope="row"> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('friendship') ?> </th>
685                                         <td><fieldset><legend class="screen-reader-text"><span> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('friendship') ?> </span></legend>
686                                                 <label for="contact">
687                                                 <input class="valinp" type="radio" name="friendship" value="contact" id="contact" <?php xfn_check('friendship', 'contact', 'radio'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('contact') ?></label>
688                                                 <label for="acquaintance">
689                                                 <input class="valinp" type="radio" name="friendship" value="acquaintance" id="acquaintance" <?php xfn_check('friendship', 'acquaintance', 'radio'); ?> />  <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('acquaintance') ?></label>
690                                                 <label for="friend">
691                                                 <input class="valinp" type="radio" name="friendship" value="friend" id="friend" <?php xfn_check('friendship', 'friend', 'radio'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('friend') ?></label>
692                                                 <label for="friendship">
693                                                 <input name="friendship" type="radio" class="valinp" value="" id="friendship" <?php xfn_check('friendship', '', 'radio'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('none') ?></label>
694                                         </fieldset></td>
695                                 </tr>
696                                 <tr>
697                                         <th scope="row"> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('physical') ?> </th>
698                                         <td><fieldset><legend class="screen-reader-text"><span> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('physical') ?> </span></legend>
699                                                 <label for="met">
700                                                 <input class="valinp" type="checkbox" name="physical" value="met" id="met" <?php xfn_check('physical', 'met'); ?> />
701                                                 <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('met') ?></label>
702                                         </fieldset></td>
703                                 </tr>
704                                 <tr>
705                                         <th scope="row"> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('professional') ?> </th>
706                                         <td><fieldset><legend class="screen-reader-text"><span> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('professional') ?> </span></legend>
707                                                 <label for="co-worker">
708                                                 <input class="valinp" type="checkbox" name="professional" value="co-worker" id="co-worker" <?php xfn_check('professional', 'co-worker'); ?> />
709                                                 <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('co-worker') ?></label>
710                                                 <label for="colleague">
711                                                 <input class="valinp" type="checkbox" name="professional" value="colleague" id="colleague" <?php xfn_check('professional', 'colleague'); ?> />
712                                                 <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('colleague') ?></label>
713                                         </fieldset></td>
714                                 </tr>
715                                 <tr>
716                                         <th scope="row"> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('geographical') ?> </th>
717                                         <td><fieldset><legend class="screen-reader-text"><span> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('geographical') ?> </span></legend>
718                                                 <label for="co-resident">
719                                                 <input class="valinp" type="radio" name="geographical" value="co-resident" id="co-resident" <?php xfn_check('geographical', 'co-resident', 'radio'); ?> />
720                                                 <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('co-resident') ?></label>
721                                                 <label for="neighbor">
722                                                 <input class="valinp" type="radio" name="geographical" value="neighbor" id="neighbor" <?php xfn_check('geographical', 'neighbor', 'radio'); ?> />
723                                                 <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('neighbor') ?></label>
724                                                 <label for="geographical">
725                                                 <input class="valinp" type="radio" name="geographical" value="" id="geographical" <?php xfn_check('geographical', '', 'radio'); ?> />
726                                                 <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('none') ?></label>
727                                         </fieldset></td>
728                                 </tr>
729                                 <tr>
730                                         <th scope="row"> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('family') ?> </th>
731                                         <td><fieldset><legend class="screen-reader-text"><span> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('family') ?> </span></legend>
732                                                 <label for="child">
733                                                 <input class="valinp" type="radio" name="family" value="child" id="child" <?php xfn_check('family', 'child', 'radio'); ?>  />
734                                                 <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('child') ?></label>
735                                                 <label for="kin">
736                                                 <input class="valinp" type="radio" name="family" value="kin" id="kin" <?php xfn_check('family', 'kin', 'radio'); ?>  />
737                                                 <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('kin') ?></label>
738                                                 <label for="parent">
739                                                 <input class="valinp" type="radio" name="family" value="parent" id="parent" <?php xfn_check('family', 'parent', 'radio'); ?> />
740                                                 <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('parent') ?></label>
741                                                 <label for="sibling">
742                                                 <input class="valinp" type="radio" name="family" value="sibling" id="sibling" <?php xfn_check('family', 'sibling', 'radio'); ?> />
743                                                 <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('sibling') ?></label>
744                                                 <label for="spouse">
745                                                 <input class="valinp" type="radio" name="family" value="spouse" id="spouse" <?php xfn_check('family', 'spouse', 'radio'); ?> />
746                                                 <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('spouse') ?></label>
747                                                 <label for="family">
748                                                 <input class="valinp" type="radio" name="family" value="" id="family" <?php xfn_check('family', '', 'radio'); ?> />
749                                                 <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('none') ?></label>
750                                         </fieldset></td>
751                                 </tr>
752                                 <tr>
753                                         <th scope="row"> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('romantic') ?> </th>
754                                         <td><fieldset><legend class="screen-reader-text"><span> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('romantic') ?> </span></legend>
755                                                 <label for="muse">
756                                                 <input class="valinp" type="checkbox" name="romantic" value="muse" id="muse" <?php xfn_check('romantic', 'muse'); ?> />
757                                                 <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('muse') ?></label>
758                                                 <label for="crush">
759                                                 <input class="valinp" type="checkbox" name="romantic" value="crush" id="crush" <?php xfn_check('romantic', 'crush'); ?> />
760                                                 <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('crush') ?></label>
761                                                 <label for="date">
762                                                 <input class="valinp" type="checkbox" name="romantic" value="date" id="date" <?php xfn_check('romantic', 'date'); ?> />
763                                                 <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('date') ?></label>
764                                                 <label for="romantic">
765                                                 <input class="valinp" type="checkbox" name="romantic" value="sweetheart" id="romantic" <?php xfn_check('romantic', 'sweetheart'); ?> />
766                                                 <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('sweetheart') ?></label>
767                                         </fieldset></td>
768                                 </tr>
769                         </table>
770                 </td>
771         </tr>
772 </table>
773 <p><?php _e('If the link is to a person, you can specify your relationship with them using the above form. If you would like to learn more about the idea check out <a href="http://gmpg.org/xfn/">XFN</a>.'); ?></p>
774 <?php
775 }
776
777
778 /**
779  * Display advanced link options form fields.
780  *
781  * @since 2.6.0
782  *
783  * @param object $link
784  */
785 function link_advanced_meta_box($link) {
786 ?>
787 <table class="form-table" style="width: 100%;" cellspacing="2" cellpadding="5">
788         <tr class="form-field">
789                 <th valign="top"  scope="row"><label for="link_image"><?php _e('Image Address') ?></label></th>
790                 <td><input type="text" name="link_image" class="code" id="link_image" size="50" value="<?php echo ( isset( $link->link_image ) ? esc_attr($link->link_image) : ''); ?>" style="width: 95%" /></td>
791         </tr>
792         <tr class="form-field">
793                 <th valign="top"  scope="row"><label for="rss_uri"><?php _e('RSS Address') ?></label></th>
794                 <td><input name="link_rss" class="code" type="text" id="rss_uri" value="<?php echo  ( isset( $link->link_rss ) ? esc_attr($link->link_rss) : ''); ?>" size="50" style="width: 95%" /></td>
795         </tr>
796         <tr class="form-field">
797                 <th valign="top"  scope="row"><label for="link_notes"><?php _e('Notes') ?></label></th>
798                 <td><textarea name="link_notes" id="link_notes" cols="50" rows="10" style="width: 95%"><?php echo  ( isset( $link->link_notes ) ? $link->link_notes : ''); ?></textarea></td>
799         </tr>
800         <tr class="form-field">
801                 <th valign="top"  scope="row"><label for="link_rating"><?php _e('Rating') ?></label></th>
802                 <td><select name="link_rating" id="link_rating" size="1">
803                 <?php
804                         for ($r = 0; $r <= 10; $r++) {
805                                 echo('            <option value="'. esc_attr($r) .'" ');
806                                 if ( isset($link->link_rating) && $link->link_rating == $r)
807                                         echo 'selected="selected"';
808                                 echo('>'.$r.'</option>');
809                         }
810                 ?></select>&nbsp;<?php _e('(Leave at 0 for no rating.)') ?>
811                 </td>
812         </tr>
813 </table>
814 <?php
815 }
816
817 /**
818  * Display post thumbnail meta box.
819  *
820  * @since 2.9.0
821  */
822 function post_thumbnail_meta_box() {
823         global $post;
824         $thumbnail_id = get_post_meta( $post->ID, '_thumbnail_id', true );
825         echo _wp_post_thumbnail_html( $thumbnail_id );
826 }