What’s the usage of action do_meta_boxes?

/**
 * 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 of the post.
 * @param string  $context   string  Meta box context.
 * @param WP_Post $post      Post object.
 */
do_action( 'do_meta_boxes', $post_type, 'normal', $post );

I found these in wp-admin/edit-form-advanced.php and I can’t figure out purpose of these actions ( checked for add_action( ‘do_meta_boxes’ … ) there is no such actions ).

Documentation says

Fires after meta boxes have been added.

Fires once for each of the default meta box contexts: normal,
advanced, and side.

But what’s purpose is for these action? When should I use these actions?

NOTE: it’s not the same as do_meta_boxes() function and has nothing common with it!

1 Answer
1

As explained here:

[The] do_meta_boxes [action] is designed to let people manipulate the registered meta boxes once they are registered but before they are rendered.

So the do_meta_boxes hook is not for doing (that is: displaying) the meta boxes. This is because:

When the do_meta_boxes actions was moved out of do_meta_boxes() it should have had its name changed. add_meta_boxes was added in 3.0 to be the hook that we should have renamed do_meta_boxes to be.

Leave a Comment