* Displays post format form elements.
* @param WP_Post $post Current post object.
* Post formats meta box arguments.
* @type string $id Meta box 'id' attribute.
* @type string $title Meta box title.
* @type callable $callback Meta box display callback.
* @type array $args Extra meta box arguments.
function post_format_meta_box( $post, $box ) {
if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) ) :
$post_formats = get_theme_support( 'post-formats' );
if ( is_array( $post_formats[0] ) ) :
$post_format = get_post_format( $post->ID );
// Add in the current one if it isn't there yet, in case the active theme doesn't support it.
if ( $post_format && ! in_array( $post_format, $post_formats[0], true ) ) {
$post_formats[0][] = $post_format;
<div id="post-formats-select">
<legend class="screen-reader-text">
/* translators: Hidden accessibility text. */
<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>
<?php foreach ( $post_formats[0] as $format ) : ?>
<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>
* Displays post tags form fields.
* @todo Create taxonomy-agnostic wrapper for this.
* @param WP_Post $post Current post object.
* Tags meta box arguments.
* @type string $id Meta box 'id' attribute.
* @type string $title Meta box title.
* @type callable $callback Meta box display callback.
* Extra meta box arguments.
* @type string $taxonomy Taxonomy. Default 'post_tag'.
function post_tags_meta_box( $post, $box ) {
$defaults = array( 'taxonomy' => 'post_tag' );
if ( ! isset( $box['args'] ) || ! is_array( $box['args'] ) ) {
$parsed_args = wp_parse_args( $args, $defaults );
$tax_name = esc_attr( $parsed_args['taxonomy'] );
$taxonomy = get_taxonomy( $parsed_args['taxonomy'] );
$user_can_assign_terms = current_user_can( $taxonomy->cap->assign_terms );
$comma = _x( ',', 'tag delimiter' );
$terms_to_edit = get_terms_to_edit( $post->ID, $tax_name );
if ( ! is_string( $terms_to_edit ) ) {
<div class="tagsdiv" id="<?php echo $tax_name; ?>">
<div class="nojs-tags hide-if-js">
<label for="tax-input-<?php echo $tax_name; ?>"><?php echo $taxonomy->labels->add_or_remove_items; ?></label>
<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>
<?php if ( $user_can_assign_terms ) : ?>
<div class="ajaxtag hide-if-no-js">
<label class="screen-reader-text" for="new-tag-<?php echo $tax_name; ?>"><?php echo $taxonomy->labels->add_new_item; ?></label>
<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="" />
<input type="button" class="button tagadd" value="<?php esc_attr_e( 'Add' ); ?>" />
<p class="howto" id="new-tag-<?php echo $tax_name; ?>-desc"><?php echo $taxonomy->labels->separate_items_with_commas; ?></p>
<?php elseif ( empty( $terms_to_edit ) ) : ?>
<p><?php echo $taxonomy->labels->no_terms; ?></p>
<ul class="tagchecklist" role="list"></ul>
<?php if ( $user_can_assign_terms ) : ?>
<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>
* Displays post categories form fields.
* @todo Create taxonomy-agnostic wrapper for this.
* @param WP_Post $post Current post object.
* Categories meta box arguments.
* @type string $id Meta box 'id' attribute.
* @type string $title Meta box title.
* @type callable $callback Meta box display callback.
* Extra meta box arguments.
* @type string $taxonomy Taxonomy. Default 'category'.
function post_categories_meta_box( $post, $box ) {
$defaults = array( 'taxonomy' => 'category' );
if ( ! isset( $box['args'] ) || ! is_array( $box['args'] ) ) {
$parsed_args = wp_parse_args( $args, $defaults );
$tax_name = esc_attr( $parsed_args['taxonomy'] );
$taxonomy = get_taxonomy( $parsed_args['taxonomy'] );
<div id="taxonomy-<?php echo $tax_name; ?>" class="categorydiv">
<ul id="<?php echo $tax_name; ?>-tabs" class="category-tabs">
<li class="tabs"><a href="#<?php echo $tax_name; ?>-all"><?php echo $taxonomy->labels->all_items; ?></a></li>
<li class="hide-if-no-js"><a href="#<?php echo $tax_name; ?>-pop"><?php echo esc_html( $taxonomy->labels->most_used ); ?></a></li>
<div id="<?php echo $tax_name; ?>-pop" class="tabs-panel" style="display: none;">
<ul id="<?php echo $tax_name; ?>checklist-pop" class="categorychecklist form-no-clear" >
<?php $popular_ids = wp_popular_terms_checklist( $tax_name ); ?>
<div id="<?php echo $tax_name; ?>-all" class="tabs-panel">
$name = ( 'category' === $tax_name ) ? 'post_category' : 'tax_input[' . $tax_name . ']';
// Allows for an empty term set to be sent. 0 is an invalid term ID and will be ignored by empty() checks.
echo "<input type='hidden' name='{$name}[]' value='0' />";
<ul id="<?php echo $tax_name; ?>checklist" data-wp-lists="list:<?php echo $tax_name; ?>" class="categorychecklist form-no-clear">
'popular_cats' => $popular_ids,
<?php if ( current_user_can( $taxonomy->cap->edit_terms ) ) : ?>
<div id="<?php echo $tax_name; ?>-adder" class="wp-hidden-children">
<a id="<?php echo $tax_name; ?>-add-toggle" href="#<?php echo $tax_name; ?>-add" class="hide-if-no-js taxonomy-add-new">
/* translators: %s: Add New taxonomy label. */
printf( __( '+ %s' ), $taxonomy->labels->add_new_item );
<p id="<?php echo $tax_name; ?>-add" class="category-add wp-hidden-child">
<label class="screen-reader-text" for="new<?php echo $tax_name; ?>"><?php echo $taxonomy->labels->add_new_item; ?></label>
<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" />
<label class="screen-reader-text" for="new<?php echo $tax_name; ?>_parent">
<?php echo $taxonomy->labels->parent_item_colon; ?>
$parent_dropdown_args = array(
'name' => 'new' . $tax_name . '_parent',
'show_option_none' => '— ' . $taxonomy->labels->parent_item . ' —',
* Filters the arguments for the taxonomy parent dropdown on the Post Edit page.
* @param array $parent_dropdown_args {
* Optional. Array of arguments to generate parent dropdown.
* @type string $taxonomy Name of the taxonomy to retrieve.
* @type bool $hide_if_empty True to skip generating markup if no
* categories are found. Default 0.
* @type string $name Value for the 'name' attribute
* Default "new{$tax_name}_parent".
* @type string $orderby Which column to use for ordering
* @type bool|int $hierarchical Whether to traverse the taxonomy
* @type string $show_option_none Text to display for the "none" option.
* Default "— {$parent} —",
* where `$parent` is 'parent_item'
$parent_dropdown_args = apply_filters( 'post_edit_category_parent_dropdown_args', $parent_dropdown_args );
wp_dropdown_categories( $parent_dropdown_args );
<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 ); ?>" />
<?php wp_nonce_field( 'add-' . $tax_name, '_ajax_nonce-add-' . $tax_name, false ); ?>
<span id="<?php echo $tax_name; ?>-ajax-response"></span>
* Displays post excerpt form fields.
* @param WP_Post $post Current post object.
function post_excerpt_meta_box( $post ) {
<label class="screen-reader-text" for="excerpt">
/* translators: Hidden accessibility text. */
</label><textarea rows="1" cols="40" name="excerpt" id="excerpt"><?php echo $post->post_excerpt; // textarea_escaped ?></textarea>
/* translators: %s: Documentation URL. */
__( '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>.' ),
__( 'https://wordpress.org/documentation/article/what-is-an-excerpt-classic-editor/' )
* Displays trackback links form fields.
* @param WP_Post $post Current post object.
function post_trackback_meta_box( $post ) {
$form_trackback = '<input type="text" name="trackback_url" id="trackback_url" class="code" value="' .
esc_attr( str_replace( "\n", ' ', $post->to_ping ) ) . '" aria-describedby="trackback-url-desc" />';
if ( '' !== $post->pinged ) {
$pings = '<p>' . __( 'Already pinged:' ) . '</p><ul>';
$already_pinged = explode( "\n", trim( $post->pinged ) );
foreach ( $already_pinged as $pinged_url ) {
$pings .= "\n\t<li>" . esc_html( $pinged_url ) . '</li>';
<label for="trackback_url"><?php _e( 'Send trackbacks to:' ); ?></label>
<?php echo $form_trackback; ?>
<p id="trackback-url-desc" class="howto"><?php _e( 'Separate multiple URLs with spaces' ); ?></p>
/* translators: %s: Documentation URL. */
__( 'Trackbacks are a way to notify legacy blog systems that you’ve linked to them. If you link other WordPress sites, they’ll be notified automatically using <a href="%s">pingbacks</a>, no other action necessary.' ),
__( 'https://wordpress.org/documentation/article/introduction-to-blogging/#comments' )
if ( ! empty( $pings ) ) {
* Displays custom fields form fields.
* @param WP_Post $post Current post object.
function post_custom_meta_box( $post ) {
<div id="postcustomstuff">
<div id="ajax-response"></div>
$metadata = has_meta( $post->ID );
foreach ( $metadata as $key => $value ) {
if ( is_protected_meta( $metadata[ $key ]['meta_key'], 'post' ) || ! current_user_can( 'edit_post_meta', $post->ID, $metadata[ $key ]['meta_key'] ) ) {
unset( $metadata[ $key ] );
/* translators: %s: Documentation URL. */
__( 'Custom fields can be used to add extra metadata to a post that you can <a href="%s">use in your theme</a>.' ),
__( 'https://wordpress.org/documentation/article/assign-custom-fields/' )
* Displays comments status form fields.
* @param WP_Post $post Current post object.
function post_comment_status_meta_box( $post ) {
<input name="advanced_view" type="hidden" value="1" />
<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 />
<label for="ping_status" class="selectit"><input name="ping_status" type="checkbox" id="ping_status" value="open" <?php checked( $post->ping_status, 'open' ); ?> />
/* translators: %s: Documentation URL. */
__( 'Allow <a href="%s">trackbacks and pingbacks</a>' ),
__( 'https://wordpress.org/documentation/article/introduction-to-blogging/#managing-comments' )
* Fires at the end of the Discussion meta box on the post editing screen.
* @param WP_Post $post WP_Post object for the current post.
do_action( 'post_comment_status_meta_box-options', $post ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
* Displays comments for post table header
* @param array $result Table header rows.
function post_comment_meta_box_thead( $result ) {
unset( $result['cb'], $result['response'] );
* Displays comments for post.
* @param WP_Post $post Current post object.
function post_comment_meta_box( $post ) {
wp_nonce_field( 'get-comments', 'add_comment_nonce', false );
<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>
$wp_list_table = _get_list_table( 'WP_Post_Comments_List_Table' );
$wp_list_table->display( true );
echo '<p id="no-comments">' . __( 'No comments yet.' ) . '</p>';
$hidden = get_hidden_meta_boxes( get_current_screen() );
if ( ! in_array( 'commentsdiv', $hidden, true ) ) {
<script type="text/javascript">jQuery(function(){commentsBox.get(<?php echo $total; ?>, 10);});</script>
<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>
wp_comment_trashnotice();
* Displays slug form fields.
* @param WP_Post $post Current post object.
function post_slug_meta_box( $post ) {
/** This filter is documented in wp-admin/edit-tag-form.php */
$editable_slug = apply_filters( 'editable_slug', $post->post_name, $post );
<label class="screen-reader-text" for="post_name">
/* translators: Hidden accessibility text. */
</label><input name="post_name" type="text" class="large-text" id="post_name" value="<?php echo esc_attr( $editable_slug ); ?>" />
* Displays form field with list of authors.
* @param WP_Post $post Current post object.
function post_author_meta_box( $post ) {
$post_type_object = get_post_type_object( $post->post_type );
<label class="screen-reader-text" for="post_author_override">
/* translators: Hidden accessibility text. */
'capability' => array( $post_type_object->cap->edit_posts ),
'name' => 'post_author_override',
'selected' => empty( $post->ID ) ? $user_ID : $post->post_author,
'include_selected' => true,
'show' => 'display_name_with_login',
* Displays list of revisions.
* @param WP_Post $post Current post object.
function post_revisions_meta_box( $post ) {
wp_list_post_revisions( $post );
// Page-related Meta Boxes.
* Displays page attributes form fields.