meta-boxes.php 51 KB

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