WordPress.org

Make WordPress Core

Opened 2 years ago

Last modified 2 years ago

#40870 new defect (bug)

Using underscore in meta box id field metabox is not working correctly

Reported by: stode Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.7.5
Component: General Keywords:
Focuses: Cc:
PR Number:

Description

To reproduce this issue: 1. Create a meta box with an id that has underscores(id_with_underscores). 2. Try to put the box after the title. Nothing happens. Replace the underscores with dashes and everything works as expected.

<?php
// Render metabox
function render_metabox(){
?>
<h2>Test</h2>
<?php
}
// Define meta box
add_meta_box(
                        'test_underscore_metabox',
                        __( 'Person Details', 'text-domain' ),
                        'render_metabox',
                        'post',
                        'advanced',
                        'high',
                        null
                );
function move_metabox_after_title() {
        
        global $post, $wp_meta_boxes;
        
        do_meta_boxes( get_current_screen(), 'advanced', $post );
        
        unset( $wp_meta_boxes[ get_post_type( $post ) ]['advanced'] );
}
add_action( 'edit_form_after_title', 'move_metabox_after_title' );

Change History (3)

#1 follow-up: @GregRoss
2 years ago

May be related to #35305.

#2 in reply to: ↑ 1 @stode
2 years ago

Replying to GregRoss:

May be related to #35305.

Thanks @GregRoss that could very well be related and your suggestion on #3505 to update docs sounds legit for this too. Unless this behavior could somehow be avoided.

#3 @GregRoss
2 years ago

@stode when I investigated #35305 I didn't find a solution that didn't break something else or have a significant trade off, hence the doc update recommendation.

Note: See TracTickets for help on using tickets.