From 4fbc47f1cf5326aaa0f4c382d103ef102ae9713c Mon Sep 17 00:00:00 2001
From: Pedro Silva
Date: Thu, 26 Oct 2023 12:18:07 +0100
Subject: [PATCH] Revert rendering of GooglePay button to wp action.
---
.../src/Assets/DataToAppleButtonScripts.php | 2 +-
modules/ppcp-googlepay/src/GooglepayModule.php | 12 +++++++++---
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/modules/ppcp-applepay/src/Assets/DataToAppleButtonScripts.php b/modules/ppcp-applepay/src/Assets/DataToAppleButtonScripts.php
index 6558ac472..ae0056c58 100644
--- a/modules/ppcp-applepay/src/Assets/DataToAppleButtonScripts.php
+++ b/modules/ppcp-applepay/src/Assets/DataToAppleButtonScripts.php
@@ -199,7 +199,7 @@ class DataToAppleButtonScripts {
'totalLabel' => $total_label,
),
'ajax_url' => admin_url( 'admin-ajax.php' ),
- 'buttonMarkup' => $button_markup,
+ 'buttonMarkup' => $button_markup, // Is this being used?
);
}
}
diff --git a/modules/ppcp-googlepay/src/GooglepayModule.php b/modules/ppcp-googlepay/src/GooglepayModule.php
index 4a9ab5644..94f70ea09 100644
--- a/modules/ppcp-googlepay/src/GooglepayModule.php
+++ b/modules/ppcp-googlepay/src/GooglepayModule.php
@@ -76,9 +76,15 @@ class GooglepayModule implements ModuleInterface {
}
// Initializes button rendering.
- if ( ! is_admin() ) {
- $button->render();
- }
+ add_action(
+ 'wp',
+ static function () use ( $c, $button ) {
+ if ( is_admin() ) {
+ return;
+ }
+ $button->render();
+ }
+ );
// Enqueue frontend scripts.
add_action(