home *** CD-ROM | disk | FTP | other *** search
/ HTML Examples / WP.iso / wordpress / wp-admin / includes / meta-boxes.php < prev    next >
Encoding:
PHP Script  |  2017-11-23  |  51.0 KB  |  1,285 lines

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