meta-boxes.php 61 KB

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