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

  1. <?php 
  2.  
  3. // -- Post related Meta Boxes 
  4.  
  5. /** 
  6. * Displays post submit form fields. 
  7. * 
  8. * @since 2.7.0 
  9. * 
  10. * @global string $action 
  11. * 
  12. * @param WP_Post $post Current post object. 
  13. * @param array $args { 
  14. * Array of arguments for building the post submit meta box. 
  15. * 
  16. * @type string $id Meta box 'id' attribute. 
  17. * @type string $title Meta box title. 
  18. * @type callable $callback Meta box display callback. 
  19. * @type array $args Extra meta box arguments. 
  20. * } 
  21. */ 
  22. function post_submit_meta_box( $post, $args = array() ) { 
  23. global $action; 
  24.  
  25. $post_type = $post->post_type; 
  26. $post_type_object = get_post_type_object($post_type); 
  27. $can_publish = current_user_can($post_type_object->cap->publish_posts); 
  28. ?> 
  29. <div class="submitbox" id="submitpost"> 
  30.  
  31. <div id="minor-publishing"> 
  32.  
  33. <?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key ?> 
  34. <div style="display:none;"> 
  35. <?php submit_button( __( 'Save' ), '', 'save' ); ?> 
  36. </div> 
  37.  
  38. <div id="minor-publishing-actions"> 
  39. <div id="save-action"> 
  40. <?php if ( 'publish' != $post->post_status && 'future' != $post->post_status && 'pending' != $post->post_status ) { ?> 
  41. <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'); ?>" class="button" /> 
  42. <span class="spinner"></span> 
  43. <?php } elseif ( 'pending' == $post->post_status && $can_publish ) { ?> 
  44. <input type="submit" name="save" id="save-post" value="<?php esc_attr_e('Save as Pending'); ?>" class="button" /> 
  45. <span class="spinner"></span> 
  46. <?php } ?> 
  47. </div> 
  48. <?php if ( is_post_type_viewable( $post_type_object ) ) : ?> 
  49. <div id="preview-action"> 
  50. <?php 
  51. $preview_link = esc_url( get_preview_post_link( $post ) ); 
  52. if ( 'publish' == $post->post_status ) { 
  53. $preview_button = __( 'Preview Changes' ); 
  54. } else { 
  55. $preview_button = __( 'Preview' ); 
  56. ?> 
  57. <a class="preview button" href="<?php echo $preview_link; ?>" target="wp-preview-<?php echo (int) $post->ID; ?>" id="post-preview"><?php echo $preview_button; ?></a> 
  58. <input type="hidden" name="wp-preview" id="wp-preview" value="" /> 
  59. </div> 
  60. <?php endif; // public post type ?> 
  61. <?php 
  62. /** 
  63. * Fires before the post time/date setting in the Publish meta box. 
  64. * 
  65. * @since 4.4.0 
  66. * 
  67. * @param WP_Post $post WP_Post object for the current post. 
  68. */ 
  69. do_action( 'post_submitbox_minor_actions', $post ); 
  70. ?> 
  71. <div class="clear"></div> 
  72. </div><!-- #minor-publishing-actions --> 
  73.  
  74. <div id="misc-publishing-actions"> 
  75.  
  76. <div class="misc-pub-section misc-pub-post-status"> 
  77. <?php _e( 'Status:' ) ?> <span id="post-status-display"><?php 
  78.  
  79. switch ( $post->post_status ) { 
  80. case 'private': 
  81. _e('Privately Published'); 
  82. break; 
  83. case 'publish': 
  84. _e('Published'); 
  85. break; 
  86. case 'future': 
  87. _e('Scheduled'); 
  88. break; 
  89. case 'pending': 
  90. _e('Pending Review'); 
  91. break; 
  92. case 'draft': 
  93. case 'auto-draft': 
  94. _e('Draft'); 
  95. break; 
  96. ?> 
  97. </span> 
  98. <?php if ( 'publish' == $post->post_status || 'private' == $post->post_status || $can_publish ) { ?> 
  99. <a href="#post_status" <?php if ( 'private' == $post->post_status ) { ?>style="display:none;" <?php } ?>class="edit-post-status hide-if-no-js" role="button"><span aria-hidden="true"><?php _e( 'Edit' ); ?></span> <span class="screen-reader-text"><?php _e( 'Edit status' ); ?></span></a> 
  100.  
  101. <div id="post-status-select" class="hide-if-js"> 
  102. <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); ?>" /> 
  103. <label for="post_status" class="screen-reader-text"><?php _e( 'Set status' ) ?></label> 
  104. <select name="post_status" id="post_status"> 
  105. <?php if ( 'publish' == $post->post_status ) : ?> 
  106. <option<?php selected( $post->post_status, 'publish' ); ?> value='publish'><?php _e('Published') ?></option> 
  107. <?php elseif ( 'private' == $post->post_status ) : ?> 
  108. <option<?php selected( $post->post_status, 'private' ); ?> value='publish'><?php _e('Privately Published') ?></option> 
  109. <?php elseif ( 'future' == $post->post_status ) : ?> 
  110. <option<?php selected( $post->post_status, 'future' ); ?> value='future'><?php _e('Scheduled') ?></option> 
  111. <?php endif; ?> 
  112. <option<?php selected( $post->post_status, 'pending' ); ?> value='pending'><?php _e('Pending Review') ?></option> 
  113. <?php if ( 'auto-draft' == $post->post_status ) : ?> 
  114. <option<?php selected( $post->post_status, 'auto-draft' ); ?> value='draft'><?php _e('Draft') ?></option> 
  115. <?php else : ?> 
  116. <option<?php selected( $post->post_status, 'draft' ); ?> value='draft'><?php _e('Draft') ?></option> 
  117. <?php endif; ?> 
  118. </select> 
  119. <a href="#post_status" class="save-post-status hide-if-no-js button"><?php _e('OK'); ?></a> 
  120. <a href="#post_status" class="cancel-post-status hide-if-no-js button-cancel"><?php _e('Cancel'); ?></a> 
  121. </div> 
  122.  
  123. <?php } ?> 
  124. </div><!-- .misc-pub-section --> 
  125.  
  126. <div class="misc-pub-section misc-pub-visibility" id="visibility"> 
  127. <?php _e('Visibility:'); ?> <span id="post-visibility-display"><?php 
  128.  
  129. if ( 'private' == $post->post_status ) { 
  130. $post->post_password = ''; 
  131. $visibility = 'private'; 
  132. $visibility_trans = __('Private'); 
  133. } elseif ( !empty( $post->post_password ) ) { 
  134. $visibility = 'password'; 
  135. $visibility_trans = __('Password protected'); 
  136. } elseif ( $post_type == 'post' && is_sticky( $post->ID ) ) { 
  137. $visibility = 'public'; 
  138. $visibility_trans = __('Public, Sticky'); 
  139. } else { 
  140. $visibility = 'public'; 
  141. $visibility_trans = __('Public'); 
  142.  
  143. echo esc_html( $visibility_trans ); ?></span> 
  144. <?php if ( $can_publish ) { ?> 
  145. <a href="#visibility" class="edit-visibility hide-if-no-js" role="button"><span aria-hidden="true"><?php _e( 'Edit' ); ?></span> <span class="screen-reader-text"><?php _e( 'Edit visibility' ); ?></span></a> 
  146.  
  147. <div id="post-visibility-select" class="hide-if-js"> 
  148. <input type="hidden" name="hidden_post_password" id="hidden-post-password" value="<?php echo esc_attr($post->post_password); ?>" /> 
  149. <?php if ($post_type == 'post'): ?> 
  150. <input type="checkbox" style="display:none" name="hidden_post_sticky" id="hidden-post-sticky" value="sticky" <?php checked(is_sticky($post->ID)); ?> /> 
  151. <?php endif; ?> 
  152. <input type="hidden" name="hidden_post_visibility" id="hidden-post-visibility" value="<?php echo esc_attr( $visibility ); ?>" /> 
  153. <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 /> 
  154. <?php if ( $post_type == 'post' && current_user_can( 'edit_others_posts' ) ) : ?> 
  155. <span id="sticky-span"><input id="sticky" name="sticky" type="checkbox" value="sticky" <?php checked( is_sticky( $post->ID ) ); ?> /> <label for="sticky" class="selectit"><?php _e( 'Stick this post to the front page' ); ?></label><br /></span> 
  156. <?php endif; ?> 
  157. <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 /> 
  158. <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); ?>" maxlength="255" /><br /></span> 
  159. <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 /> 
  160.  
  161. <p> 
  162. <a href="#visibility" class="save-post-visibility hide-if-no-js button"><?php _e('OK'); ?></a> 
  163. <a href="#visibility" class="cancel-post-visibility hide-if-no-js button-cancel"><?php _e('Cancel'); ?></a> 
  164. </p> 
  165. </div> 
  166. <?php } ?> 
  167.  
  168. </div><!-- .misc-pub-section --> 
  169.  
  170. <?php 
  171. /** translators: Publish box date format, see https://secure.php.net/date */ 
  172. $datef = __( 'M j, Y @ H:i' ); 
  173. if ( 0 != $post->ID ) { 
  174. if ( 'future' == $post->post_status ) { // scheduled for publishing at a future date 
  175. /** translators: Post date information. 1: Date on which the post is currently scheduled to be published */ 
  176. $stamp = __('Scheduled for: <b>%1$s</b>'); 
  177. } elseif ( 'publish' == $post->post_status || 'private' == $post->post_status ) { // already published 
  178. /** translators: Post date information. 1: Date on which the post was published */ 
  179. $stamp = __('Published on: <b>%1$s</b>'); 
  180. } elseif ( '0000-00-00 00:00:00' == $post->post_date_gmt ) { // draft, 1 or more saves, no date specified 
  181. $stamp = __('Publish <b>immediately</b>'); 
  182. } elseif ( time() < strtotime( $post->post_date_gmt . ' +0000' ) ) { // draft, 1 or more saves, future date specified 
  183. /** translators: Post date information. 1: Date on which the post is to be published */ 
  184. $stamp = __('Schedule for: <b>%1$s</b>'); 
  185. } else { // draft, 1 or more saves, date specified 
  186. /** translators: Post date information. 1: Date on which the post is to be published */ 
  187. $stamp = __('Publish on: <b>%1$s</b>'); 
  188. $date = date_i18n( $datef, strtotime( $post->post_date ) ); 
  189. } else { // draft (no saves, and thus no date specified) 
  190. $stamp = __('Publish <b>immediately</b>'); 
  191. $date = date_i18n( $datef, strtotime( current_time('mysql') ) ); 
  192.  
  193. if ( ! empty( $args['args']['revisions_count'] ) ) : ?> 
  194. <div class="misc-pub-section misc-pub-revisions"> 
  195. <?php 
  196. /** translators: Post revisions heading. 1: The number of available revisions */ 
  197. printf( __( 'Revisions: %s' ), '<b>' . number_format_i18n( $args['args']['revisions_count'] ) . '</b>' ); 
  198. ?> 
  199. <a class="hide-if-no-js" href="<?php echo esc_url( get_edit_post_link( $args['args']['revision_id'] ) ); ?>"><span aria-hidden="true"><?php _ex( 'Browse', 'revisions' ); ?></span> <span class="screen-reader-text"><?php _e( 'Browse revisions' ); ?></span></a> 
  200. </div> 
  201. <?php endif; 
  202.  
  203. if ( $can_publish ) : // Contributors don't get to choose the date of publish ?> 
  204. <div class="misc-pub-section curtime misc-pub-curtime"> 
  205. <span id="timestamp"> 
  206. <?php printf($stamp, $date); ?></span> 
  207. <a href="#edit_timestamp" class="edit-timestamp hide-if-no-js" role="button"><span aria-hidden="true"><?php _e( 'Edit' ); ?></span> <span class="screen-reader-text"><?php _e( 'Edit date and time' ); ?></span></a> 
  208. <fieldset id="timestampdiv" class="hide-if-js"> 
  209. <legend class="screen-reader-text"><?php _e( 'Date and time' ); ?></legend> 
  210. <?php touch_time( ( $action === 'edit' ), 1 ); ?> 
  211. </fieldset> 
  212. </div><?php // /misc-pub-section ?> 
  213. <?php endif; ?> 
  214.  
  215. <?php 
  216. /** 
  217. * Fires after the post time/date setting in the Publish meta box. 
  218. * 
  219. * @since 2.9.0 
  220. * @since 4.4.0 Added the `$post` parameter. 
  221. * 
  222. * @param WP_Post $post WP_Post object for the current post. 
  223. */ 
  224. do_action( 'post_submitbox_misc_actions', $post ); 
  225. ?> 
  226. </div> 
  227. <div class="clear"></div> 
  228. </div> 
  229.  
  230. <div id="major-publishing-actions"> 
  231. <?php 
  232. /** 
  233. * Fires at the beginning of the publishing actions section of the Publish meta box. 
  234. * 
  235. * @since 2.7.0 
  236. */ 
  237. do_action( 'post_submitbox_start' ); 
  238. ?> 
  239. <div id="delete-action"> 
  240. <?php 
  241. if ( current_user_can( "delete_post", $post->ID ) ) { 
  242. if ( !EMPTY_TRASH_DAYS ) 
  243. $delete_text = __('Delete Permanently'); 
  244. else 
  245. $delete_text = __('Move to Trash'); 
  246. ?> 
  247. <a class="submitdelete deletion" href="<?php echo get_delete_post_link($post->ID); ?>"><?php echo $delete_text; ?></a><?php 
  248. } ?> 
  249. </div> 
  250.  
  251. <div id="publishing-action"> 
  252. <span class="spinner"></span> 
  253. <?php 
  254. if ( !in_array( $post->post_status, array('publish', 'future', 'private') ) || 0 == $post->ID ) { 
  255. if ( $can_publish ) : 
  256. if ( !empty($post->post_date_gmt) && time() < strtotime( $post->post_date_gmt . ' +0000' ) ) : ?> 
  257. <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Schedule') ?>" /> 
  258. <?php submit_button( __( 'Schedule' ), 'primary large', 'publish', false ); ?> 
  259. <?php else : ?> 
  260. <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Publish') ?>" /> 
  261. <?php submit_button( __( 'Publish' ), 'primary large', 'publish', false ); ?> 
  262. <?php endif; 
  263. else : ?> 
  264. <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Submit for Review') ?>" /> 
  265. <?php submit_button( __( 'Submit for Review' ), 'primary large', 'publish', false ); ?> 
  266. <?php 
  267. endif; 
  268. } else { ?> 
  269. <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Update') ?>" /> 
  270. <input name="save" type="submit" class="button button-primary button-large" id="publish" value="<?php esc_attr_e( 'Update' ) ?>" /> 
  271. <?php 
  272. } ?> 
  273. </div> 
  274. <div class="clear"></div> 
  275. </div> 
  276. </div> 
  277.  
  278. <?php 
  279.  
  280. /** 
  281. * Display attachment submit form fields. 
  282. * 
  283. * @since 3.5.0 
  284. * 
  285. * @param object $post 
  286. */ 
  287. function attachment_submit_meta_box( $post ) { 
  288. ?> 
  289. <div class="submitbox" id="submitpost"> 
  290.  
  291. <div id="minor-publishing"> 
  292.  
  293. <?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key ?> 
  294. <div style="display:none;"> 
  295. <?php submit_button( __( 'Save' ), '', 'save' ); ?> 
  296. </div> 
  297.  
  298.  
  299. <div id="misc-publishing-actions"> 
  300. <?php 
  301. /** translators: Publish box date format, see https://secure.php.net/date */ 
  302. $datef = __( 'M j, Y @ H:i' ); 
  303. /** translators: Attachment information. 1: Date the attachment was uploaded */ 
  304. $stamp = __('Uploaded on: <b>%1$s</b>'); 
  305. $date = date_i18n( $datef, strtotime( $post->post_date ) ); 
  306. ?> 
  307. <div class="misc-pub-section curtime misc-pub-curtime"> 
  308. <span id="timestamp"><?php printf($stamp, $date); ?></span> 
  309. </div><!-- .misc-pub-section --> 
  310.  
  311. <?php 
  312. /** 
  313. * Fires after the 'Uploaded on' section of the Save meta box 
  314. * in the attachment editing screen. 
  315. * 
  316. * @since 3.5.0 
  317. */ 
  318. do_action( 'attachment_submitbox_misc_actions' ); 
  319. ?> 
  320. </div><!-- #misc-publishing-actions --> 
  321. <div class="clear"></div> 
  322. </div><!-- #minor-publishing --> 
  323.  
  324. <div id="major-publishing-actions"> 
  325. <div id="delete-action"> 
  326. <?php 
  327. if ( current_user_can( 'delete_post', $post->ID ) ) 
  328. if ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) { 
  329. echo "<a class='submitdelete deletion' href='" . get_delete_post_link( $post->ID ) . "'>" . _x( 'Trash', 'verb' ) . "</a>"; 
  330. } else { 
  331. $delete_ays = ! MEDIA_TRASH ? " onclick='return showNotice.warn();'" : ''; 
  332. echo "<a class='submitdelete deletion'$delete_ays href='" . get_delete_post_link( $post->ID, null, true ) . "'>" . __( 'Delete Permanently' ) . "</a>"; 
  333. ?> 
  334. </div> 
  335.  
  336. <div id="publishing-action"> 
  337. <span class="spinner"></span> 
  338. <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Update') ?>" /> 
  339. <input name="save" type="submit" class="button button-primary button-large" id="publish" value="<?php esc_attr_e( 'Update' ) ?>" /> 
  340. </div> 
  341. <div class="clear"></div> 
  342. </div><!-- #major-publishing-actions --> 
  343.  
  344. </div> 
  345.  
  346. <?php 
  347.  
  348. /** 
  349. * Display post format form elements. 
  350. * 
  351. * @since 3.1.0 
  352. * 
  353. * @param WP_Post $post Post object. 
  354. * @param array $box { 
  355. * Post formats meta box arguments. 
  356. * 
  357. * @type string $id Meta box 'id' attribute. 
  358. * @type string $title Meta box title. 
  359. * @type callable $callback Meta box display callback. 
  360. * @type array $args Extra meta box arguments. 
  361. * } 
  362. */ 
  363. function post_format_meta_box( $post, $box ) { 
  364. if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) ) : 
  365. $post_formats = get_theme_support( 'post-formats' ); 
  366.  
  367. if ( is_array( $post_formats[0] ) ) : 
  368. $post_format = get_post_format( $post->ID ); 
  369. if ( !$post_format ) 
  370. $post_format = '0'; 
  371. // Add in the current one if it isn't there yet, in case the current theme doesn't support it 
  372. if ( $post_format && !in_array( $post_format, $post_formats[0] ) ) 
  373. $post_formats[0][] = $post_format; 
  374. ?> 
  375. <div id="post-formats-select"> 
  376. <fieldset> 
  377. <legend class="screen-reader-text"><?php _e( 'Post Formats' ); ?></legend> 
  378. <input type="radio" name="post_format" class="post-format" id="post-format-0" value="0" <?php checked( $post_format, '0' ); ?> /> <label for="post-format-0" class="post-format-icon post-format-standard"><?php echo get_post_format_string( 'standard' ); ?></label> 
  379. <?php foreach ( $post_formats[0] as $format ) : ?> 
  380. <br /><input type="radio" name="post_format" class="post-format" id="post-format-<?php echo esc_attr( $format ); ?>" value="<?php echo esc_attr( $format ); ?>" <?php checked( $post_format, $format ); ?> /> <label for="post-format-<?php echo esc_attr( $format ); ?>" class="post-format-icon post-format-<?php echo esc_attr( $format ); ?>"><?php echo esc_html( get_post_format_string( $format ) ); ?></label> 
  381. <?php endforeach; ?> 
  382. </fieldset> 
  383. </div> 
  384. <?php endif; endif; 
  385.  
  386. /** 
  387. * Display post tags form fields. 
  388. * 
  389. * @since 2.6.0 
  390. * 
  391. * @todo Create taxonomy-agnostic wrapper for this. 
  392. * 
  393. * @param WP_Post $post Post object. 
  394. * @param array $box { 
  395. * Tags meta box arguments. 
  396. * 
  397. * @type string $id Meta box 'id' attribute. 
  398. * @type string $title Meta box title. 
  399. * @type callable $callback Meta box display callback. 
  400. * @type array $args { 
  401. * Extra meta box arguments. 
  402. * 
  403. * @type string $taxonomy Taxonomy. Default 'post_tag'. 
  404. * } 
  405. * } 
  406. */ 
  407. function post_tags_meta_box( $post, $box ) { 
  408. $defaults = array( 'taxonomy' => 'post_tag' ); 
  409. if ( ! isset( $box['args'] ) || ! is_array( $box['args'] ) ) { 
  410. $args = array(); 
  411. } else { 
  412. $args = $box['args']; 
  413. $r = wp_parse_args( $args, $defaults ); 
  414. $tax_name = esc_attr( $r['taxonomy'] ); 
  415. $taxonomy = get_taxonomy( $r['taxonomy'] ); 
  416. $user_can_assign_terms = current_user_can( $taxonomy->cap->assign_terms ); 
  417. $comma = _x( ', ', 'tag delimiter' ); 
  418. $terms_to_edit = get_terms_to_edit( $post->ID, $tax_name ); 
  419. if ( ! is_string( $terms_to_edit ) ) { 
  420. $terms_to_edit = ''; 
  421. ?> 
  422. <div class="tagsdiv" id="<?php echo $tax_name; ?>"> 
  423. <div class="jaxtag"> 
  424. <div class="nojs-tags hide-if-js"> 
  425. <label for="tax-input-<?php echo $tax_name; ?>"><?php echo $taxonomy->labels->add_or_remove_items; ?></label> 
  426. <p><textarea name="<?php echo "tax_input[$tax_name]"; ?>" rows="3" cols="20" class="the-tags" id="tax-input-<?php echo $tax_name; ?>" <?php disabled( ! $user_can_assign_terms ); ?> aria-describedby="new-tag-<?php echo $tax_name; ?>-desc"><?php echo str_replace( ', ', $comma . ' ', $terms_to_edit ); // textarea_escaped by esc_attr() ?></textarea></p> 
  427. </div> 
  428. <?php if ( $user_can_assign_terms ) : ?> 
  429. <div class="ajaxtag hide-if-no-js"> 
  430. <label class="screen-reader-text" for="new-tag-<?php echo $tax_name; ?>"><?php echo $taxonomy->labels->add_new_item; ?></label> 
  431. <p><input data-wp-taxonomy="<?php echo $tax_name; ?>" type="text" id="new-tag-<?php echo $tax_name; ?>" name="newtag[<?php echo $tax_name; ?>]" class="newtag form-input-tip" size="16" autocomplete="off" aria-describedby="new-tag-<?php echo $tax_name; ?>-desc" value="" /> 
  432. <input type="button" class="button tagadd" value="<?php esc_attr_e('Add'); ?>" /></p> 
  433. </div> 
  434. <p class="howto" id="new-tag-<?php echo $tax_name; ?>-desc"><?php echo $taxonomy->labels->separate_items_with_commas; ?></p> 
  435. <?php elseif ( empty( $terms_to_edit ) ): ?> 
  436. <p><?php echo $taxonomy->labels->no_terms; ?></p> 
  437. <?php endif; ?> 
  438. </div> 
  439. <div class="tagchecklist"></div> 
  440. </div> 
  441. <?php if ( $user_can_assign_terms ) : ?> 
  442. <p class="hide-if-no-js"><button type="button" class="button-link tagcloud-link" id="link-<?php echo $tax_name; ?>" aria-expanded="false"><?php echo $taxonomy->labels->choose_from_most_used; ?></button></p> 
  443. <?php endif; ?> 
  444. <?php 
  445.  
  446. /** 
  447. * Display post categories form fields. 
  448. * 
  449. * @since 2.6.0 
  450. * 
  451. * @todo Create taxonomy-agnostic wrapper for this. 
  452. * 
  453. * @param WP_Post $post Post object. 
  454. * @param array $box { 
  455. * Categories meta box arguments. 
  456. * 
  457. * @type string $id Meta box 'id' attribute. 
  458. * @type string $title Meta box title. 
  459. * @type callable $callback Meta box display callback. 
  460. * @type array $args { 
  461. * Extra meta box arguments. 
  462. * 
  463. * @type string $taxonomy Taxonomy. Default 'category'. 
  464. * } 
  465. * } 
  466. */ 
  467. function post_categories_meta_box( $post, $box ) { 
  468. $defaults = array( 'taxonomy' => 'category' ); 
  469. if ( ! isset( $box['args'] ) || ! is_array( $box['args'] ) ) { 
  470. $args = array(); 
  471. } else { 
  472. $args = $box['args']; 
  473. $r = wp_parse_args( $args, $defaults ); 
  474. $tax_name = esc_attr( $r['taxonomy'] ); 
  475. $taxonomy = get_taxonomy( $r['taxonomy'] ); 
  476. ?> 
  477. <div id="taxonomy-<?php echo $tax_name; ?>" class="categorydiv"> 
  478. <ul id="<?php echo $tax_name; ?>-tabs" class="category-tabs"> 
  479. <li class="tabs"><a href="#<?php echo $tax_name; ?>-all"><?php echo $taxonomy->labels->all_items; ?></a></li> 
  480. <li class="hide-if-no-js"><a href="#<?php echo $tax_name; ?>-pop"><?php _e( 'Most Used' ); ?></a></li> 
  481. </ul> 
  482.  
  483. <div id="<?php echo $tax_name; ?>-pop" class="tabs-panel" style="display: none;"> 
  484. <ul id="<?php echo $tax_name; ?>checklist-pop" class="categorychecklist form-no-clear" > 
  485. <?php $popular_ids = wp_popular_terms_checklist( $tax_name ); ?> 
  486. </ul> 
  487. </div> 
  488.  
  489. <div id="<?php echo $tax_name; ?>-all" class="tabs-panel"> 
  490. <?php 
  491. $name = ( $tax_name == 'category' ) ? 'post_category' : 'tax_input[' . $tax_name . ']'; 
  492. 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. 
  493. ?> 
  494. <ul id="<?php echo $tax_name; ?>checklist" data-wp-lists="list:<?php echo $tax_name; ?>" class="categorychecklist form-no-clear"> 
  495. <?php wp_terms_checklist( $post->ID, array( 'taxonomy' => $tax_name, 'popular_cats' => $popular_ids ) ); ?> 
  496. </ul> 
  497. </div> 
  498. <?php if ( current_user_can( $taxonomy->cap->edit_terms ) ) : ?> 
  499. <div id="<?php echo $tax_name; ?>-adder" class="wp-hidden-children"> 
  500. <a id="<?php echo $tax_name; ?>-add-toggle" href="#<?php echo $tax_name; ?>-add" class="hide-if-no-js taxonomy-add-new"> 
  501. <?php 
  502. /** translators: %s: add new taxonomy label */ 
  503. printf( __( '+ %s' ), $taxonomy->labels->add_new_item ); 
  504. ?> 
  505. </a> 
  506. <p id="<?php echo $tax_name; ?>-add" class="category-add wp-hidden-child"> 
  507. <label class="screen-reader-text" for="new<?php echo $tax_name; ?>"><?php echo $taxonomy->labels->add_new_item; ?></label> 
  508. <input type="text" name="new<?php echo $tax_name; ?>" id="new<?php echo $tax_name; ?>" class="form-required form-input-tip" value="<?php echo esc_attr( $taxonomy->labels->new_item_name ); ?>" aria-required="true"/> 
  509. <label class="screen-reader-text" for="new<?php echo $tax_name; ?>_parent"> 
  510. <?php echo $taxonomy->labels->parent_item_colon; ?> 
  511. </label> 
  512. <?php 
  513. $parent_dropdown_args = array( 
  514. 'taxonomy' => $tax_name,  
  515. 'hide_empty' => 0,  
  516. 'name' => 'new' . $tax_name . '_parent',  
  517. 'orderby' => 'name',  
  518. 'hierarchical' => 1,  
  519. 'show_option_none' => '— ' . $taxonomy->labels->parent_item . ' —',  
  520. ); 
  521.  
  522. /** 
  523. * Filters the arguments for the taxonomy parent dropdown on the Post Edit page. 
  524. * 
  525. * @since 4.4.0 
  526. * 
  527. * @param array $parent_dropdown_args { 
  528. * Optional. Array of arguments to generate parent dropdown. 
  529. * 
  530. * @type string $taxonomy Name of the taxonomy to retrieve. 
  531. * @type bool $hide_if_empty True to skip generating markup if no 
  532. * categories are found. Default 0. 
  533. * @type string $name Value for the 'name' attribute 
  534. * of the select element. 
  535. * Default "new{$tax_name}_parent". 
  536. * @type string $orderby Which column to use for ordering 
  537. * terms. Default 'name'. 
  538. * @type bool|int $hierarchical Whether to traverse the taxonomy 
  539. * hierarchy. Default 1. 
  540. * @type string $show_option_none Text to display for the "none" option. 
  541. * Default "— {$parent} —",  
  542. * where `$parent` is 'parent_item' 
  543. * taxonomy label. 
  544. * } 
  545. */ 
  546. $parent_dropdown_args = apply_filters( 'post_edit_category_parent_dropdown_args', $parent_dropdown_args ); 
  547.  
  548. wp_dropdown_categories( $parent_dropdown_args ); 
  549. ?> 
  550. <input type="button" id="<?php echo $tax_name; ?>-add-submit" data-wp-lists="add:<?php echo $tax_name; ?>checklist:<?php echo $tax_name; ?>-add" class="button category-add-submit" value="<?php echo esc_attr( $taxonomy->labels->add_new_item ); ?>" /> 
  551. <?php wp_nonce_field( 'add-' . $tax_name, '_ajax_nonce-add-' . $tax_name, false ); ?> 
  552. <span id="<?php echo $tax_name; ?>-ajax-response"></span> 
  553. </p> 
  554. </div> 
  555. <?php endif; ?> 
  556. </div> 
  557. <?php 
  558.  
  559. /** 
  560. * Display post excerpt form fields. 
  561. * 
  562. * @since 2.6.0 
  563. * 
  564. * @param object $post 
  565. */ 
  566. function post_excerpt_meta_box($post) { 
  567. ?> 
  568. <label class="screen-reader-text" for="excerpt"><?php _e('Excerpt') ?></label><textarea rows="1" cols="40" name="excerpt" id="excerpt"><?php echo $post->post_excerpt; // textarea_escaped ?></textarea> 
  569. <p><?php 
  570. printf( 
  571. /** translators: %s: Codex URL */ 
  572. __( 'Excerpts are optional hand-crafted summaries of your content that can be used in your theme. <a href="%s">Learn more about manual excerpts</a>.' ),  
  573. __( 'https://codex.wordpress.org/Excerpt' ) 
  574. ); 
  575. ?></p> 
  576. <?php 
  577.  
  578. /** 
  579. * Display trackback links form fields. 
  580. * 
  581. * @since 2.6.0 
  582. * 
  583. * @param object $post 
  584. */ 
  585. function post_trackback_meta_box($post) { 
  586. $form_trackback = '<input type="text" name="trackback_url" id="trackback_url" class="code" value="' . 
  587. esc_attr( str_replace( "\n", ' ', $post->to_ping ) ) . '" aria-describedby="trackback-url-desc" />'; 
  588. if ('' != $post->pinged) { 
  589. $pings = '<p>'. __('Already pinged:') . '</p><ul>'; 
  590. $already_pinged = explode("\n", trim($post->pinged)); 
  591. foreach ($already_pinged as $pinged_url) { 
  592. $pings .= "\n\t<li>" . esc_html($pinged_url) . "</li>"; 
  593. $pings .= '</ul>'; 
  594.  
  595. ?> 
  596. <p> 
  597. <label for="trackback_url"><?php _e( 'Send trackbacks to:' ); ?></label> 
  598. <?php echo $form_trackback; ?> 
  599. </p> 
  600. <p id="trackback-url-desc" class="howto"><?php _e( 'Separate multiple URLs with spaces' ); ?></p> 
  601. <p><?php 
  602. printf( 
  603. /** translators: %s: Codex URL */ 
  604. __( 'Trackbacks are a way to notify legacy blog systems that you’ve linked to them. If you link other WordPress sites, they’ll be notified automatically using <a href="%s">pingbacks</a>, no other action necessary.' ),  
  605. __( 'https://codex.wordpress.org/Introduction_to_Blogging#Managing_Comments' ) 
  606. ); 
  607. ?></p> 
  608. <?php 
  609. if ( ! empty($pings) ) 
  610. echo $pings; 
  611.  
  612. /** 
  613. * Display custom fields form fields. 
  614. * 
  615. * @since 2.6.0 
  616. * 
  617. * @param object $post 
  618. */ 
  619. function post_custom_meta_box($post) { 
  620. ?> 
  621. <div id="postcustomstuff"> 
  622. <div id="ajax-response"></div> 
  623. <?php 
  624. $metadata = has_meta($post->ID); 
  625. foreach ( $metadata as $key => $value ) { 
  626. if ( is_protected_meta( $metadata[ $key ][ 'meta_key' ], 'post' ) || ! current_user_can( 'edit_post_meta', $post->ID, $metadata[ $key ][ 'meta_key' ] ) ) 
  627. unset( $metadata[ $key ] ); 
  628. list_meta( $metadata ); 
  629. meta_form( $post ); ?> 
  630. </div> 
  631. <p><?php 
  632. printf( 
  633. /** translators: %s: Codex URL */ 
  634. __( 'Custom fields can be used to add extra metadata to a post that you can <a href="%s">use in your theme</a>.' ),  
  635. __( 'https://codex.wordpress.org/Using_Custom_Fields' ) 
  636. ); 
  637. ?></p> 
  638. <?php 
  639.  
  640. /** 
  641. * Display comments status form fields. 
  642. * 
  643. * @since 2.6.0 
  644. * 
  645. * @param object $post 
  646. */ 
  647. function post_comment_status_meta_box($post) { 
  648. ?> 
  649. <input name="advanced_view" type="hidden" value="1" /> 
  650. <p class="meta-options"> 
  651. <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 /> 
  652. <label for="ping_status" class="selectit"><input name="ping_status" type="checkbox" id="ping_status" value="open" <?php checked($post->ping_status, 'open'); ?> /> <?php 
  653. printf( 
  654. /** translators: %s: Codex URL */ 
  655. __( 'Allow <a href="%s">trackbacks and pingbacks</a> on this page.' ),  
  656. __( 'https://codex.wordpress.org/Introduction_to_Blogging#Managing_Comments' ) ); 
  657. ?></label> 
  658. <?php 
  659. /** 
  660. * Fires at the end of the Discussion meta box on the post editing screen. 
  661. * 
  662. * @since 3.1.0 
  663. * 
  664. * @param WP_Post $post WP_Post object of the current post. 
  665. */ 
  666. do_action( 'post_comment_status_meta_box-options', $post ); 
  667. ?> 
  668. </p> 
  669. <?php 
  670.  
  671. /** 
  672. * Display comments for post table header 
  673. * 
  674. * @since 3.0.0 
  675. * 
  676. * @param array $result table header rows 
  677. * @return array 
  678. */ 
  679. function post_comment_meta_box_thead($result) { 
  680. unset($result['cb'], $result['response']); 
  681. return $result; 
  682.  
  683. /** 
  684. * Display comments for post. 
  685. * 
  686. * @since 2.8.0 
  687. * 
  688. * @param object $post 
  689. */ 
  690. function post_comment_meta_box( $post ) { 
  691. wp_nonce_field( 'get-comments', 'add_comment_nonce', false ); 
  692. ?> 
  693. <p class="hide-if-no-js" id="add-new-comment"><a class="button" href="#commentstatusdiv" onclick="window.commentReply && commentReply.addcomment(<?php echo $post->ID; ?>);return false;"><?php _e('Add comment'); ?></a></p> 
  694. <?php 
  695.  
  696. $total = get_comments( array( 'post_id' => $post->ID, 'number' => 1, 'count' => true ) ); 
  697. $wp_list_table = _get_list_table('WP_Post_Comments_List_Table'); 
  698. $wp_list_table->display( true ); 
  699.  
  700. if ( 1 > $total ) { 
  701. echo '<p id="no-comments">' . __('No comments yet.') . '</p>'; 
  702. } else { 
  703. $hidden = get_hidden_meta_boxes( get_current_screen() ); 
  704. if ( ! in_array('commentsdiv', $hidden) ) { 
  705. ?> 
  706. <script type="text/javascript">jQuery(document).ready(function() {commentsBox.get(<?php echo $total; ?>, 10);});</script> 
  707. <?php 
  708.  
  709. ?> 
  710. <p class="hide-if-no-js" id="show-comments"><a href="#commentstatusdiv" onclick="commentsBox.load(<?php echo $total; ?>);return false;"><?php _e('Show comments'); ?></a> <span class="spinner"></span></p> 
  711. <?php 
  712.  
  713. wp_comment_trashnotice(); 
  714.  
  715. /** 
  716. * Display slug form fields. 
  717. * 
  718. * @since 2.6.0 
  719. * 
  720. * @param object $post 
  721. */ 
  722. function post_slug_meta_box($post) { 
  723. /** This filter is documented in wp-admin/edit-tag-form.php */ 
  724. $editable_slug = apply_filters( 'editable_slug', $post->post_name, $post ); 
  725. ?> 
  726. <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( $editable_slug ); ?>" /> 
  727. <?php 
  728.  
  729. /** 
  730. * Display form field with list of authors. 
  731. * 
  732. * @since 2.6.0 
  733. * 
  734. * @global int $user_ID 
  735. * 
  736. * @param object $post 
  737. */ 
  738. function post_author_meta_box($post) { 
  739. global $user_ID; 
  740. ?> 
  741. <label class="screen-reader-text" for="post_author_override"><?php _e('Author'); ?></label> 
  742. <?php 
  743. wp_dropdown_users( array( 
  744. 'who' => 'authors',  
  745. 'name' => 'post_author_override',  
  746. 'selected' => empty($post->ID) ? $user_ID : $post->post_author,  
  747. 'include_selected' => true,  
  748. 'show' => 'display_name_with_login',  
  749. ) ); 
  750.  
  751. /** 
  752. * Display list of revisions. 
  753. * 
  754. * @since 2.6.0 
  755. * 
  756. * @param object $post 
  757. */ 
  758. function post_revisions_meta_box( $post ) { 
  759. wp_list_post_revisions( $post ); 
  760.  
  761. // -- Page related Meta Boxes 
  762.  
  763. /** 
  764. * Display page attributes form fields. 
  765. * 
  766. * @since 2.7.0 
  767. * 
  768. * @param object $post 
  769. */ 
  770. function page_attributes_meta_box($post) { 
  771. if ( is_post_type_hierarchical( $post->post_type ) ) : 
  772. $dropdown_args = array( 
  773. 'post_type' => $post->post_type,  
  774. 'exclude_tree' => $post->ID,  
  775. 'selected' => $post->post_parent,  
  776. 'name' => 'parent_id',  
  777. 'show_option_none' => __('(no parent)'),  
  778. 'sort_column' => 'menu_order, post_title',  
  779. 'echo' => 0,  
  780. ); 
  781.  
  782. /** 
  783. * Filters the arguments used to generate a Pages drop-down element. 
  784. * 
  785. * @since 3.3.0 
  786. * 
  787. * @see wp_dropdown_pages() 
  788. * 
  789. * @param array $dropdown_args Array of arguments used to generate the pages drop-down. 
  790. * @param WP_Post $post The current WP_Post object. 
  791. */ 
  792. $dropdown_args = apply_filters( 'page_attributes_dropdown_pages_args', $dropdown_args, $post ); 
  793. $pages = wp_dropdown_pages( $dropdown_args ); 
  794. if ( ! empty($pages) ) : 
  795. ?> 
  796. <p class="post-attributes-label-wrapper"><label class="post-attributes-label" for="parent_id"><?php _e( 'Parent' ); ?></label></p> 
  797. <?php echo $pages; ?> 
  798. <?php 
  799. endif; // end empty pages check 
  800. endif; // end hierarchical check. 
  801.  
  802. if ( count( get_page_templates( $post ) ) > 0 && get_option( 'page_for_posts' ) != $post->ID ) : 
  803. $template = ! empty( $post->page_template ) ? $post->page_template : false; 
  804. ?> 
  805. <p class="post-attributes-label-wrapper"><label class="post-attributes-label" for="page_template"><?php _e( 'Template' ); ?></label><?php 
  806. /** 
  807. * Fires immediately after the label inside the 'Template' section 
  808. * of the 'Page Attributes' meta box. 
  809. * 
  810. * @since 4.4.0 
  811. * 
  812. * @param string $template The template used for the current post. 
  813. * @param WP_Post $post The current post. 
  814. */ 
  815. do_action( 'page_attributes_meta_box_template', $template, $post ); 
  816. ?></p> 
  817. <select name="page_template" id="page_template"> 
  818. <?php 
  819. /** 
  820. * Filters the title of the default page template displayed in the drop-down. 
  821. * 
  822. * @since 4.1.0 
  823. * 
  824. * @param string $label The display value for the default page template title. 
  825. * @param string $context Where the option label is displayed. Possible values 
  826. * include 'meta-box' or 'quick-edit'. 
  827. */ 
  828. $default_title = apply_filters( 'default_page_template_title', __( 'Default Template' ), 'meta-box' ); 
  829. ?> 
  830. <option value="default"><?php echo esc_html( $default_title ); ?></option> 
  831. <?php page_template_dropdown( $template, $post->post_type ); ?> 
  832. </select> 
  833. <?php endif; ?> 
  834. <?php if ( post_type_supports( $post->post_type, 'page-attributes' ) ) : ?> 
  835. <p class="post-attributes-label-wrapper"><label class="post-attributes-label" for="menu_order"><?php _e( 'Order' ); ?></label></p> 
  836. <input name="menu_order" type="text" size="4" id="menu_order" value="<?php echo esc_attr( $post->menu_order ); ?>" /> 
  837. <?php if ( 'page' == $post->post_type && get_current_screen()->get_help_tabs() ) : ?> 
  838. <p><?php _e( 'Need help? Use the Help tab above the screen title.' ); ?></p> 
  839. <?php endif; 
  840. endif; 
  841.  
  842. // -- Link related Meta Boxes 
  843.  
  844. /** 
  845. * Display link create form fields. 
  846. * 
  847. * @since 2.7.0 
  848. * 
  849. * @param object $link 
  850. */ 
  851. function link_submit_meta_box($link) { 
  852. ?> 
  853. <div class="submitbox" id="submitlink"> 
  854.  
  855. <div id="minor-publishing"> 
  856.  
  857. <?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key ?> 
  858. <div style="display:none;"> 
  859. <?php submit_button( __( 'Save' ), '', 'save', false ); ?> 
  860. </div> 
  861.  
  862. <div id="minor-publishing-actions"> 
  863. <div id="preview-action"> 
  864. <?php if ( !empty($link->link_id) ) { ?> 
  865. <a class="preview button" href="<?php echo $link->link_url; ?>" target="_blank"><?php _e('Visit Link'); ?></a> 
  866. <?php } ?> 
  867. </div> 
  868. <div class="clear"></div> 
  869. </div> 
  870.  
  871. <div id="misc-publishing-actions"> 
  872. <div class="misc-pub-section misc-pub-private"> 
  873. <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> 
  874. </div> 
  875. </div> 
  876.  
  877. </div> 
  878.  
  879. <div id="major-publishing-actions"> 
  880. <?php 
  881. /** This action is documented in wp-admin/includes/meta-boxes.php */ 
  882. do_action( 'post_submitbox_start' ); 
  883. ?> 
  884. <div id="delete-action"> 
  885. <?php 
  886. if ( !empty($_GET['action']) && 'edit' == $_GET['action'] && current_user_can('manage_links') ) { ?> 
  887. <a class="submitdelete deletion" href="<?php echo wp_nonce_url("link.php?action=delete&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> 
  888. <?php } ?> 
  889. </div> 
  890.  
  891. <div id="publishing-action"> 
  892. <?php if ( !empty($link->link_id) ) { ?> 
  893. <input name="save" type="submit" class="button button-primary button-large" id="publish" value="<?php esc_attr_e( 'Update Link' ) ?>" /> 
  894. <?php } else { ?> 
  895. <input name="save" type="submit" class="button button-primary button-large" id="publish" value="<?php esc_attr_e( 'Add Link' ) ?>" /> 
  896. <?php } ?> 
  897. </div> 
  898. <div class="clear"></div> 
  899. </div> 
  900. <?php 
  901. /** 
  902. * Fires at the end of the Publish box in the Link editing screen. 
  903. * 
  904. * @since 2.5.0 
  905. */ 
  906. do_action( 'submitlink_box' ); 
  907. ?> 
  908. <div class="clear"></div> 
  909. </div> 
  910. <?php 
  911.  
  912. /** 
  913. * Display link categories form fields. 
  914. * 
  915. * @since 2.6.0 
  916. * 
  917. * @param object $link 
  918. */ 
  919. function link_categories_meta_box($link) { 
  920. ?> 
  921. <div id="taxonomy-linkcategory" class="categorydiv"> 
  922. <ul id="category-tabs" class="category-tabs"> 
  923. <li class="tabs"><a href="#categories-all"><?php _e( 'All Categories' ); ?></a></li> 
  924. <li class="hide-if-no-js"><a href="#categories-pop"><?php _e( 'Most Used' ); ?></a></li> 
  925. </ul> 
  926.  
  927. <div id="categories-all" class="tabs-panel"> 
  928. <ul id="categorychecklist" data-wp-lists="list:category" class="categorychecklist form-no-clear"> 
  929. <?php 
  930. if ( isset($link->link_id) ) 
  931. wp_link_category_checklist($link->link_id); 
  932. else 
  933. wp_link_category_checklist(); 
  934. ?> 
  935. </ul> 
  936. </div> 
  937.  
  938. <div id="categories-pop" class="tabs-panel" style="display: none;"> 
  939. <ul id="categorychecklist-pop" class="categorychecklist form-no-clear"> 
  940. <?php wp_popular_terms_checklist('link_category'); ?> 
  941. </ul> 
  942. </div> 
  943.  
  944. <div id="category-adder" class="wp-hidden-children"> 
  945. <a id="category-add-toggle" href="#category-add" class="taxonomy-add-new"><?php _e( '+ Add New Category' ); ?></a> 
  946. <p id="link-category-add" class="wp-hidden-child"> 
  947. <label class="screen-reader-text" for="newcat"><?php _e( '+ Add New Category' ); ?></label> 
  948. <input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php esc_attr_e( 'New category name' ); ?>" aria-required="true" /> 
  949. <input type="button" id="link-category-add-submit" data-wp-lists="add:categorychecklist:link-category-add" class="button" value="<?php esc_attr_e( 'Add' ); ?>" /> 
  950. <?php wp_nonce_field( 'add-link-category', '_ajax_nonce', false ); ?> 
  951. <span id="category-ajax-response"></span> 
  952. </p> 
  953. </div> 
  954. </div> 
  955. <?php 
  956.  
  957. /** 
  958. * Display form fields for changing link target. 
  959. * 
  960. * @since 2.6.0 
  961. * 
  962. * @param object $link 
  963. */ 
  964. function link_target_meta_box($link) { ?> 
  965. <fieldset><legend class="screen-reader-text"><span><?php _e('Target') ?></span></legend> 
  966. <p><label for="link_target_blank" class="selectit"> 
  967. <input id="link_target_blank" type="radio" name="link_target" value="_blank" <?php echo ( isset( $link->link_target ) && ($link->link_target == '_blank') ? 'checked="checked"' : ''); ?> /> 
  968. <?php _e('<code>_blank</code> — new window or tab.'); ?></label></p> 
  969. <p><label for="link_target_top" class="selectit"> 
  970. <input id="link_target_top" type="radio" name="link_target" value="_top" <?php echo ( isset( $link->link_target ) && ($link->link_target == '_top') ? 'checked="checked"' : ''); ?> /> 
  971. <?php _e('<code>_top</code> — current window or tab, with no frames.'); ?></label></p> 
  972. <p><label for="link_target_none" class="selectit"> 
  973. <input id="link_target_none" type="radio" name="link_target" value="" <?php echo ( isset( $link->link_target ) && ($link->link_target == '') ? 'checked="checked"' : ''); ?> /> 
  974. <?php _e('<code>_none</code> — same window or tab.'); ?></label></p> 
  975. </fieldset> 
  976. <p><?php _e('Choose the target frame for your link.'); ?></p> 
  977. <?php 
  978.  
  979. /** 
  980. * Display checked checkboxes attribute for xfn microformat options. 
  981. * 
  982. * @since 1.0.1 
  983. * 
  984. * @global object $link 
  985. * 
  986. * @param string $class 
  987. * @param string $value 
  988. * @param mixed $deprecated Never used. 
  989. */ 
  990. function xfn_check( $class, $value = '', $deprecated = '' ) { 
  991. global $link; 
  992.  
  993. if ( !empty( $deprecated ) ) 
  994. _deprecated_argument( __FUNCTION__, '0.0.0' ); // Never implemented 
  995.  
  996. $link_rel = isset( $link->link_rel ) ? $link->link_rel : ''; // In PHP 5.3: $link_rel = $link->link_rel ?: ''; 
  997. $rels = preg_split('/\s+/', $link_rel); 
  998.  
  999. if ('' != $value && in_array($value, $rels) ) { 
  1000. echo ' checked="checked"'; 
  1001.  
  1002. if ('' == $value) { 
  1003. 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"'; 
  1004. if ('friendship' == $class && strpos($link_rel, 'friend') === false && strpos($link_rel, 'acquaintance') === false && strpos($link_rel, 'contact') === false) echo ' checked="checked"'; 
  1005. if ('geographical' == $class && strpos($link_rel, 'co-resident') === false && strpos($link_rel, 'neighbor') === false) echo ' checked="checked"'; 
  1006. if ('identity' == $class && in_array('me', $rels) ) echo ' checked="checked"'; 
  1007.  
  1008. /** 
  1009. * Display xfn form fields. 
  1010. * 
  1011. * @since 2.6.0 
  1012. * 
  1013. * @param object $link 
  1014. */ 
  1015. function link_xfn_meta_box($link) { 
  1016. ?> 
  1017. <table class="links-table"> 
  1018. <tr> 
  1019. <th scope="row"><label for="link_rel"><?php /** translators: xfn: http://gmpg.org/xfn/ */ _e('rel:') ?></label></th> 
  1020. <td><input type="text" name="link_rel" id="link_rel" value="<?php echo ( isset( $link->link_rel ) ? esc_attr($link->link_rel) : ''); ?>" /></td> 
  1021. </tr> 
  1022. <tr> 
  1023. <th scope="row"><?php /** translators: xfn: http://gmpg.org/xfn/ */ _e('identity') ?></th> 
  1024. <td><fieldset><legend class="screen-reader-text"><span><?php /** translators: xfn: http://gmpg.org/xfn/ */ _e('identity') ?></span></legend> 
  1025. <label for="me"> 
  1026. <input type="checkbox" name="identity" value="me" id="me" <?php xfn_check('identity', 'me'); ?> /> 
  1027. <?php _e('another web address of mine') ?></label> 
  1028. </fieldset></td> 
  1029. </tr> 
  1030. <tr> 
  1031. <th scope="row"><?php /** translators: xfn: http://gmpg.org/xfn/ */ _e('friendship') ?></th> 
  1032. <td><fieldset><legend class="screen-reader-text"><span><?php /** translators: xfn: http://gmpg.org/xfn/ */ _e('friendship') ?></span></legend> 
  1033. <label for="contact"> 
  1034. <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') ?> 
  1035. </label> 
  1036. <label for="acquaintance"> 
  1037. <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') ?> 
  1038. </label> 
  1039. <label for="friend"> 
  1040. <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') ?> 
  1041. </label> 
  1042. <label for="friendship"> 
  1043. <input name="friendship" type="radio" class="valinp" value="" id="friendship" <?php xfn_check('friendship'); ?> /> <?php /** translators: xfn: http://gmpg.org/xfn/ */ _e('none') ?> 
  1044. </label> 
  1045. </fieldset></td> 
  1046. </tr> 
  1047. <tr> 
  1048. <th scope="row"> <?php /** translators: xfn: http://gmpg.org/xfn/ */ _e('physical') ?> </th> 
  1049. <td><fieldset><legend class="screen-reader-text"><span><?php /** translators: xfn: http://gmpg.org/xfn/ */ _e('physical') ?></span></legend> 
  1050. <label for="met"> 
  1051. <input class="valinp" type="checkbox" name="physical" value="met" id="met" <?php xfn_check('physical', 'met'); ?> /> <?php /** translators: xfn: http://gmpg.org/xfn/ */ _e('met') ?> 
  1052. </label> 
  1053. </fieldset></td> 
  1054. </tr> 
  1055. <tr> 
  1056. <th scope="row"> <?php /** translators: xfn: http://gmpg.org/xfn/ */ _e('professional') ?> </th> 
  1057. <td><fieldset><legend class="screen-reader-text"><span><?php /** translators: xfn: http://gmpg.org/xfn/ */ _e('professional') ?></span></legend> 
  1058. <label for="co-worker"> 
  1059. <input class="valinp" type="checkbox" name="professional" value="co-worker" id="co-worker" <?php xfn_check('professional', 'co-worker'); ?> /> <?php /** translators: xfn: http://gmpg.org/xfn/ */ _e('co-worker') ?> 
  1060. </label> 
  1061. <label for="colleague"> 
  1062. <input class="valinp" type="checkbox" name="professional" value="colleague" id="colleague" <?php xfn_check('professional', 'colleague'); ?> /> <?php /** translators: xfn: http://gmpg.org/xfn/ */ _e('colleague') ?> 
  1063. </label> 
  1064. </fieldset></td> 
  1065. </tr> 
  1066. <tr> 
  1067. <th scope="row"><?php /** translators: xfn: http://gmpg.org/xfn/ */ _e('geographical') ?></th> 
  1068. <td><fieldset><legend class="screen-reader-text"><span> <?php /** translators: xfn: http://gmpg.org/xfn/ */ _e('geographical') ?> </span></legend> 
  1069. <label for="co-resident"> 
  1070. <input class="valinp" type="radio" name="geographical" value="co-resident" id="co-resident" <?php xfn_check('geographical', 'co-resident'); ?> /> <?php /** translators: xfn: http://gmpg.org/xfn/ */ _e('co-resident') ?> 
  1071. </label> 
  1072. <label for="neighbor"> 
  1073. <input class="valinp" type="radio" name="geographical" value="neighbor" id="neighbor" <?php xfn_check('geographical', 'neighbor'); ?> /> <?php /** translators: xfn: http://gmpg.org/xfn/ */ _e('neighbor') ?> 
  1074. </label> 
  1075. <label for="geographical"> 
  1076. <input class="valinp" type="radio" name="geographical" value="" id="geographical" <?php xfn_check('geographical'); ?> /> <?php /** translators: xfn: http://gmpg.org/xfn/ */ _e('none') ?> 
  1077. </label> 
  1078. </fieldset></td> 
  1079. </tr> 
  1080. <tr> 
  1081. <th scope="row"><?php /** translators: xfn: http://gmpg.org/xfn/ */ _e('family') ?></th> 
  1082. <td><fieldset><legend class="screen-reader-text"><span> <?php /** translators: xfn: http://gmpg.org/xfn/ */ _e('family') ?> </span></legend> 
  1083. <label for="child"> 
  1084. <input class="valinp" type="radio" name="family" value="child" id="child" <?php xfn_check('family', 'child'); ?> /> <?php /** translators: xfn: http://gmpg.org/xfn/ */ _e('child') ?> 
  1085. </label> 
  1086. <label for="kin"> 
  1087. <input class="valinp" type="radio" name="family" value="kin" id="kin" <?php xfn_check('family', 'kin'); ?> /> <?php /** translators: xfn: http://gmpg.org/xfn/ */ _e('kin') ?> 
  1088. </label> 
  1089. <label for="parent"> 
  1090. <input class="valinp" type="radio" name="family" value="parent" id="parent" <?php xfn_check('family', 'parent'); ?> /> <?php /** translators: xfn: http://gmpg.org/xfn/ */ _e('parent') ?> 
  1091. </label> 
  1092. <label for="sibling"> 
  1093. <input class="valinp" type="radio" name="family" value="sibling" id="sibling" <?php xfn_check('family', 'sibling'); ?> /> <?php /** translators: xfn: http://gmpg.org/xfn/ */ _e('sibling') ?> 
  1094. </label> 
  1095. <label for="spouse"> 
  1096. <input class="valinp" type="radio" name="family" value="spouse" id="spouse" <?php xfn_check('family', 'spouse'); ?> /> <?php /** translators: xfn: http://gmpg.org/xfn/ */ _e('spouse') ?> 
  1097. </label> 
  1098. <label for="family"> 
  1099. <input class="valinp" type="radio" name="family" value="" id="family" <?php xfn_check('family'); ?> /> <?php /** translators: xfn: http://gmpg.org/xfn/ */ _e('none') ?> 
  1100. </label> 
  1101. </fieldset></td> 
  1102. </tr> 
  1103. <tr> 
  1104. <th scope="row"><?php /** translators: xfn: http://gmpg.org/xfn/ */ _e('romantic') ?></th> 
  1105. <td><fieldset><legend class="screen-reader-text"><span> <?php /** translators: xfn: http://gmpg.org/xfn/ */ _e('romantic') ?> </span></legend> 
  1106. <label for="muse"> 
  1107. <input class="valinp" type="checkbox" name="romantic" value="muse" id="muse" <?php xfn_check('romantic', 'muse'); ?> /> <?php /** translators: xfn: http://gmpg.org/xfn/ */ _e('muse') ?> 
  1108. </label> 
  1109. <label for="crush"> 
  1110. <input class="valinp" type="checkbox" name="romantic" value="crush" id="crush" <?php xfn_check('romantic', 'crush'); ?> /> <?php /** translators: xfn: http://gmpg.org/xfn/ */ _e('crush') ?> 
  1111. </label> 
  1112. <label for="date"> 
  1113. <input class="valinp" type="checkbox" name="romantic" value="date" id="date" <?php xfn_check('romantic', 'date'); ?> /> <?php /** translators: xfn: http://gmpg.org/xfn/ */ _e('date') ?> 
  1114. </label> 
  1115. <label for="romantic"> 
  1116. <input class="valinp" type="checkbox" name="romantic" value="sweetheart" id="romantic" <?php xfn_check('romantic', 'sweetheart'); ?> /> <?php /** translators: xfn: http://gmpg.org/xfn/ */ _e('sweetheart') ?> 
  1117. </label> 
  1118. </fieldset></td> 
  1119. </tr> 
  1120.  
  1121. </table> 
  1122. <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> 
  1123. <?php 
  1124.  
  1125. /** 
  1126. * Display advanced link options form fields. 
  1127. * 
  1128. * @since 2.6.0 
  1129. * 
  1130. * @param object $link 
  1131. */ 
  1132. function link_advanced_meta_box($link) { 
  1133. ?> 
  1134. <table class="links-table" cellpadding="0"> 
  1135. <tr> 
  1136. <th scope="row"><label for="link_image"><?php _e('Image Address') ?></label></th> 
  1137. <td><input type="text" name="link_image" class="code" id="link_image" maxlength="255" value="<?php echo ( isset( $link->link_image ) ? esc_attr($link->link_image) : ''); ?>" /></td> 
  1138. </tr> 
  1139. <tr> 
  1140. <th scope="row"><label for="rss_uri"><?php _e('RSS Address') ?></label></th> 
  1141. <td><input name="link_rss" class="code" type="text" id="rss_uri" maxlength="255" value="<?php echo ( isset( $link->link_rss ) ? esc_attr($link->link_rss) : ''); ?>" /></td> 
  1142. </tr> 
  1143. <tr> 
  1144. <th scope="row"><label for="link_notes"><?php _e('Notes') ?></label></th> 
  1145. <td><textarea name="link_notes" id="link_notes" rows="10"><?php echo ( isset( $link->link_notes ) ? $link->link_notes : ''); // textarea_escaped ?></textarea></td> 
  1146. </tr> 
  1147. <tr> 
  1148. <th scope="row"><label for="link_rating"><?php _e('Rating') ?></label></th> 
  1149. <td><select name="link_rating" id="link_rating" size="1"> 
  1150. <?php 
  1151. for ( $r = 0; $r <= 10; $r++ ) { 
  1152. echo '<option value="' . $r . '"'; 
  1153. if ( isset($link->link_rating) && $link->link_rating == $r ) 
  1154. echo ' selected="selected"'; 
  1155. echo('>' . $r . '</option>'); 
  1156. ?></select> <?php _e('(Leave at 0 for no rating.)') ?> 
  1157. </td> 
  1158. </tr> 
  1159. </table> 
  1160. <?php 
  1161.  
  1162. /** 
  1163. * Display post thumbnail meta box. 
  1164. * 
  1165. * @since 2.9.0 
  1166. * 
  1167. * @param WP_Post $post A post object. 
  1168. */ 
  1169. function post_thumbnail_meta_box( $post ) { 
  1170. $thumbnail_id = get_post_meta( $post->ID, '_thumbnail_id', true ); 
  1171. echo _wp_post_thumbnail_html( $thumbnail_id, $post->ID ); 
  1172.  
  1173. /** 
  1174. * Display fields for ID3 data 
  1175. * 
  1176. * @since 3.9.0 
  1177. * 
  1178. * @param WP_Post $post A post object. 
  1179. */ 
  1180. function attachment_id3_data_meta_box( $post ) { 
  1181. $meta = array(); 
  1182. if ( ! empty( $post->ID ) ) { 
  1183. $meta = wp_get_attachment_metadata( $post->ID ); 
  1184.  
  1185. foreach ( wp_get_attachment_id3_keys( $post, 'edit' ) as $key => $label ) : ?> 
  1186. <p> 
  1187. <label for="title"><?php echo $label ?></label><br /> 
  1188. <input type="text" name="id3_<?php echo esc_attr( $key ) ?>" id="id3_<?php echo esc_attr( $key ) ?>" class="large-text" value="<?php 
  1189. if ( ! empty( $meta[ $key ] ) ) { 
  1190. echo esc_attr( $meta[ $key ] ); 
  1191. ?>" /> 
  1192. </p> 
  1193. <?php 
  1194. endforeach; 
.