Create an interface for classes that need to register hooks

This commit is contained in:
Jeremy Pry 2023-08-14 18:25:25 -04:00 committed by Justin Palmer
parent fa0c4782a7
commit f03821904b
No known key found for this signature in database
GPG Key ID: ACAB7C35AA2577AF
2 changed files with 24 additions and 2 deletions

View File

@ -1,6 +1,8 @@
<?php
/**
* Renders order edit page, works with both post and order object.
*
* phpcs:disable Generic.Commenting.DocComment.MissingShort
*/
namespace Automattic\WooCommerce\Internal\Admin\Orders;
@ -232,7 +234,7 @@ class Edit {
/* Translators: %s order type name. */
sprintf( __( '%s information', 'woocommerce' ), $title ),
function( $post_or_order ) use ( $source_attribution_meta_box ) {
$order = $post_or_order instanceof WC_Order ?: wc_get_order( $post_or_order );
$order = $post_or_order instanceof WC_Order ? $post_or_order : wc_get_order( $post_or_order );
$source_attribution_meta_box->output( $order );
},
$screen_id,
@ -247,7 +249,7 @@ class Edit {
'woocommerce-customer-history',
__( 'Customer History', 'woocommerce' ),
function( $post_or_order ) use ( $customer_history_meta_box ) {
$order = $post_or_order instanceof WC_Order ?: wc_get_order( $post_or_order );
$order = $post_or_order instanceof WC_Order ? $post_or_order : wc_get_order( $post_or_order );
$customer_history_meta_box->output( $order );
},
$screen_id,

View File

@ -0,0 +1,20 @@
<?php
declare( strict_types=1 );
namespace Automattic\WooCommerce\Internal;
/**
* Interface RegisterHooksInterface
*
* @since x.x.x
*/
interface RegisterHooksInterface {
/**
* Register this class instance to the appropriate hooks.
*
* @since x.x.x
* @return void
*/
public function register();
}