Adds `add_meta_boxes_<SCREEN_ID>` hook to the HPOS order editor. (#35999)

Co-authored-by: Néstor Soriano <konamiman@konamiman.com>
This commit is contained in:
Barry Hughes 2023-01-02 03:10:14 -08:00 committed by GitHub
parent a633ff8abf
commit c2b2eb5bed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: tweak
Makes it possible to use an `add_meta_boxes_<SCREEN_ID>` style hook in the HPOS editor, for parity with the traditional post editor.

View File

@ -89,6 +89,7 @@ class Edit {
*/
public function setup( \WC_Order $order ) {
$this->order = $order;
$wc_screen_id = wc_get_page_screen_id( 'shop-order' );
$current_screen = get_current_screen();
$current_screen->is_block_editor( false );
$this->screen_id = $current_screen->id;
@ -107,7 +108,18 @@ class Edit {
*
* @since 3.8.0.
*/
do_action( 'add_meta_boxes', wc_get_page_screen_id( 'shop-order' ), $this->order );
do_action( 'add_meta_boxes', $wc_screen_id, $this->order );
/**
* Provides an opportunity to inject custom meta boxes into the order editor screen. This
* hook is an analog of `add_meta_boxes_<POST_TYPE>` as provided by WordPress core.
*
* @since 7.4.0
*
* @oaram WC_Order $order The order being edited.
*/
do_action( 'add_meta_boxes_' . $wc_screen_id, $this->order );
$this->enqueue_scripts();
}