diff --git a/modules/ppcp-fraud-protection/src/Recaptcha/Recaptcha.php b/modules/ppcp-fraud-protection/src/Recaptcha/Recaptcha.php index d1f0c72a6..3bbbba8e3 100644 --- a/modules/ppcp-fraud-protection/src/Recaptcha/Recaptcha.php +++ b/modules/ppcp-fraud-protection/src/Recaptcha/Recaptcha.php @@ -8,6 +8,7 @@ use Psr\Log\LoggerInterface; use WC_Order; use WP_Error; +use WP_Post; class Recaptcha { private const V2_CONTAINER_ID = 'ppcp-recaptcha-v2-container'; @@ -355,7 +356,16 @@ public function add_metabox(): void { add_meta_box( 'ppcp_recaptcha_status', __( 'reCAPTCHA Status', 'woocommerce-paypal-payments' ), - function ( WC_Order $order ): void { + /** + * @param $order WC_Order|WP_Post + * @psalm-suppress MissingClosureParamType + */ + function ( $order ): void { + $order = $order instanceof WC_Order ? $order : wc_get_order( $order ); + if ( ! $order instanceof WC_Order ) { + return; + } + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo $this->render_metabox( $order ); },