PageRenderTime 56ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 1ms

/msw/dev/wp-admin/includes/meta-boxes.php

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