PageRenderTime 55ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 1ms

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

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