diff --git a/src/wp-admin/edit-form-advanced.php b/src/wp-admin/edit-form-advanced.php index 1908f5c5e3..7411f6d5d2 100644 --- a/src/wp-admin/edit-form-advanced.php +++ b/src/wp-admin/edit-form-advanced.php @@ -243,167 +243,7 @@ $post_type_object = get_post_type_object( $post_type ); // All meta boxes should be defined and added before the first do_meta_boxes() call (or potentially during the do_meta_boxes action). require_once( ABSPATH . 'wp-admin/includes/meta-boxes.php' ); - -$publish_callback_args = array( '__back_compat_meta_box' => true ); -if ( post_type_supports( $post_type, 'revisions' ) && 'auto-draft' != $post->post_status ) { - $revisions = wp_get_post_revisions( $post_ID ); - - // We should aim to show the revisions meta box only when there are revisions. - if ( count( $revisions ) > 1 ) { - reset( $revisions ); // Reset pointer for key() - $publish_callback_args = array( - 'revisions_count' => count( $revisions ), - 'revision_id' => key( $revisions ), - '__back_compat_meta_box' => true, - ); - add_meta_box( 'revisionsdiv', __( 'Revisions' ), 'post_revisions_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) ); - } -} - -if ( 'attachment' == $post_type ) { - wp_enqueue_script( 'image-edit' ); - wp_enqueue_style( 'imgareaselect' ); - add_meta_box( 'submitdiv', __( 'Save' ), 'attachment_submit_meta_box', null, 'side', 'core', array( '__back_compat_meta_box' => true ) ); - add_action( 'edit_form_after_title', 'edit_form_image_editor' ); - - if ( wp_attachment_is( 'audio', $post ) ) { - add_meta_box( 'attachment-id3', __( 'Metadata' ), 'attachment_id3_data_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) ); - } -} else { - add_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', null, 'side', 'core', $publish_callback_args ); -} - -if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post_type, 'post-formats' ) ) { - add_meta_box( 'formatdiv', _x( 'Format', 'post format' ), 'post_format_meta_box', null, 'side', 'core', array( '__back_compat_meta_box' => true ) ); -} - -// all taxonomies -foreach ( get_object_taxonomies( $post ) as $tax_name ) { - $taxonomy = get_taxonomy( $tax_name ); - if ( ! $taxonomy->show_ui || false === $taxonomy->meta_box_cb ) { - continue; - } - - $label = $taxonomy->labels->name; - - if ( ! is_taxonomy_hierarchical( $tax_name ) ) { - $tax_meta_box_id = 'tagsdiv-' . $tax_name; - } else { - $tax_meta_box_id = $tax_name . 'div'; - } - - add_meta_box( - $tax_meta_box_id, - $label, - $taxonomy->meta_box_cb, - null, - 'side', - 'core', - array( - 'taxonomy' => $tax_name, - '__back_compat_meta_box' => true, - ) - ); -} - -if ( post_type_supports( $post_type, 'page-attributes' ) || count( get_page_templates( $post ) ) > 0 ) { - add_meta_box( 'pageparentdiv', $post_type_object->labels->attributes, 'page_attributes_meta_box', null, 'side', 'core', array( '__back_compat_meta_box' => true ) ); -} - -if ( $thumbnail_support && current_user_can( 'upload_files' ) ) { - 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 ) ); -} - -if ( post_type_supports( $post_type, 'excerpt' ) ) { - add_meta_box( 'postexcerpt', __( 'Excerpt' ), 'post_excerpt_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) ); -} - -if ( post_type_supports( $post_type, 'trackbacks' ) ) { - add_meta_box( 'trackbacksdiv', __( 'Send Trackbacks' ), 'post_trackback_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) ); -} - -if ( post_type_supports( $post_type, 'custom-fields' ) ) { - add_meta_box( 'postcustom', __( 'Custom Fields' ), 'post_custom_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) ); -} - -/** - * Fires in the middle of built-in meta box registration. - * - * @since 2.1.0 - * @deprecated 3.7.0 Use 'add_meta_boxes' instead. - * - * @param WP_Post $post Post object. - */ -do_action( 'dbx_post_advanced', $post ); - -// Allow the Discussion meta box to show up if the post type supports comments, -// or if comments or pings are open. -if ( comments_open( $post ) || pings_open( $post ) || post_type_supports( $post_type, 'comments' ) ) { - add_meta_box( 'commentstatusdiv', __( 'Discussion' ), 'post_comment_status_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) ); -} - -$stati = get_post_stati( array( 'public' => true ) ); -if ( empty( $stati ) ) { - $stati = array( 'publish' ); -} -$stati[] = 'private'; - -if ( in_array( get_post_status( $post ), $stati ) ) { - // If the post type support comments, or the post has comments, allow the - // Comments meta box. - if ( comments_open( $post ) || pings_open( $post ) || $post->comment_count > 0 || post_type_supports( $post_type, 'comments' ) ) { - add_meta_box( 'commentsdiv', __( 'Comments' ), 'post_comment_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) ); - } -} - -if ( ! ( 'pending' == get_post_status( $post ) && ! current_user_can( $post_type_object->cap->publish_posts ) ) ) { - add_meta_box( 'slugdiv', __( 'Slug' ), 'post_slug_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) ); -} - -if ( post_type_supports( $post_type, 'author' ) && current_user_can( $post_type_object->cap->edit_others_posts ) ) { - add_meta_box( 'authordiv', __( 'Author' ), 'post_author_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) ); -} - -/** - * Fires after all built-in meta boxes have been added. - * - * @since 3.0.0 - * - * @param string $post_type Post type for posts, 'comment' for comments, - * 'link' for links. - * @param WP_Post|WP_Comment|object $post Post, comment, or link object. - */ -do_action( 'add_meta_boxes', $post_type, $post ); - -/** - * Fires after all built-in meta boxes have been added, contextually for the given post type. - * - * The dynamic portion of the hook, `$post_type`, refers to the post type of the post. - * - * @since 3.0.0 - * - * @param WP_Post $post Post object. - */ -do_action( "add_meta_boxes_{$post_type}", $post ); - -/** - * Fires after meta boxes have been added. - * - * Fires once for each of the default meta box contexts: normal, advanced, and side. - * - * @since 3.0.0 - * - * @param string $post_type Post type for posts, 'dashboard' for dashboard widgets, - * 'link' for links. - * @param string $context Meta box context. Accepts 'normal', 'advanced', 'side'. - * @param WP_Post|string|object $post Post object for posts, empty string for dashboard widgets, - * link object for links. - */ -do_action( 'do_meta_boxes', $post_type, 'normal', $post ); -/** This action is documented in wp-admin/edit-form-advanced.php */ -do_action( 'do_meta_boxes', $post_type, 'advanced', $post ); -/** This action is documented in wp-admin/edit-form-advanced.php */ -do_action( 'do_meta_boxes', $post_type, 'side', $post ); +register_and_do_post_meta_boxes( $post ); add_screen_option( 'layout_columns', diff --git a/src/wp-admin/edit-form-blocks.php b/src/wp-admin/edit-form-blocks.php index b9c3d187d6..d61456e97b 100644 --- a/src/wp-admin/edit-form-blocks.php +++ b/src/wp-admin/edit-form-blocks.php @@ -363,6 +363,14 @@ wp_enqueue_style( 'wp-format-library' ); */ do_action( 'enqueue_block_editor_assets' ); +// In order to duplicate classic meta box behaviour, we need to run the classic meta box actions. +require_once( ABSPATH . 'wp-admin/includes/meta-boxes.php' ); +register_and_do_post_meta_boxes( $post ); + +// Some meta boxes hook into the 'edit_form_advanced' filter. +/** This action is documented in wp-admin/edit-form-advanced.php */ +do_action( 'edit_form_advanced', $post ); + require_once( ABSPATH . 'wp-admin/admin-header.php' ); ?> diff --git a/src/wp-admin/edit-form-comment.php b/src/wp-admin/edit-form-comment.php index 69dd6911ac..12849edcf7 100644 --- a/src/wp-admin/edit-form-comment.php +++ b/src/wp-admin/edit-form-comment.php @@ -195,7 +195,7 @@ endif;