From f8bfaafde9d5f227affb9c34ef24ffad3027619c Mon Sep 17 00:00:00 2001 From: Jon Waldstein Date: Mon, 9 Oct 2023 14:09:30 -0400 Subject: [PATCH] Refactor: make `designId` nullable on confirmation receipt (#7000) Co-authored-by: Jon Waldstein --- .../ViewModels/DonationConfirmationReceiptViewModel.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/DonationForms/ViewModels/DonationConfirmationReceiptViewModel.php b/src/DonationForms/ViewModels/DonationConfirmationReceiptViewModel.php index ee2bbe3173..507a4211d6 100644 --- a/src/DonationForms/ViewModels/DonationConfirmationReceiptViewModel.php +++ b/src/DonationForms/ViewModels/DonationConfirmationReceiptViewModel.php @@ -102,10 +102,7 @@ public function render(): string $this->enqueueGlobalStyles($primaryColor, $secondaryColor); - $this->enqueueFormScripts( - $this->donation->formId, - $formDesignId - ); + $this->enqueueFormScripts($formDesignId); ob_start(); wp_print_styles(); @@ -166,7 +163,7 @@ public function enqueueGlobalStyles(string $primaryColor, string $secondaryColor * * @return void */ - private function enqueueFormScripts(int $formId, string $formDesignId) + private function enqueueFormScripts(?string $formDesignId) { $handle = 'givewp-donation-form-registrars'; wp_enqueue_script( @@ -196,7 +193,7 @@ private function enqueueFormScripts(int $formId, string $formDesignId) $formDesignRegistrar = give(FormDesignRegistrar::class); // silently fail if design is missing for some reason - if ($formDesignRegistrar->hasDesign($formDesignId)) { + if (!empty($formDesignId) && $formDesignRegistrar->hasDesign($formDesignId)) { $design = $formDesignRegistrar->getDesign($formDesignId); if ($design->css()) {