Sin descripción

meta-boxes.php 62KB

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