From c2b2eb5bed872f2f38df404545ca4b5b5086fe06 Mon Sep 17 00:00:00 2001 From: Barry Hughes <3594411+barryhughes@users.noreply.github.com> Date: Mon, 2 Jan 2023 03:10:14 -0800 Subject: [PATCH] Adds `add_meta_boxes_` hook to the HPOS order editor. (#35999) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: NĂ©stor Soriano --- .../changelog/fix-35647-hpos-meta-boxes | 4 ++++ .../woocommerce/src/Internal/Admin/Orders/Edit.php | 14 +++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 plugins/woocommerce/changelog/fix-35647-hpos-meta-boxes diff --git a/plugins/woocommerce/changelog/fix-35647-hpos-meta-boxes b/plugins/woocommerce/changelog/fix-35647-hpos-meta-boxes new file mode 100644 index 00000000000..391f689ee59 --- /dev/null +++ b/plugins/woocommerce/changelog/fix-35647-hpos-meta-boxes @@ -0,0 +1,4 @@ +Significance: patch +Type: tweak + +Makes it possible to use an `add_meta_boxes_` style hook in the HPOS editor, for parity with the traditional post editor. diff --git a/plugins/woocommerce/src/Internal/Admin/Orders/Edit.php b/plugins/woocommerce/src/Internal/Admin/Orders/Edit.php index b268779a2e1..9dc6553ca1e 100644 --- a/plugins/woocommerce/src/Internal/Admin/Orders/Edit.php +++ b/plugins/woocommerce/src/Internal/Admin/Orders/Edit.php @@ -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_` 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(); }