diff --git a/app/Gateways/AbstractGateway.php b/app/Gateways/AbstractGateway.php index 8f43891..b82cb37 100644 --- a/app/Gateways/AbstractGateway.php +++ b/app/Gateways/AbstractGateway.php @@ -475,6 +475,10 @@ public function get_field_content($value, $forceFrontendLabel, $form): string return $this->theme ?? 'light'; }); + Hook::addFilter('theme', function () { + return $this->theme ?? 'light'; + }); + $tx = $this->get_tx_with_user_and_form_id(strval($formId)); $status = $this->is_this_form_needs_payment($form, $tx); diff --git a/app/Gateways/Gateway.php b/app/Gateways/Gateway.php new file mode 100644 index 0000000..10e1333 --- /dev/null +++ b/app/Gateways/Gateway.php @@ -0,0 +1,52 @@ + $properties + */ + public function __construct(array $properties = []) + { + parent::__construct($properties); + } + + /** + * @return string + */ + public function get_form_editor_field_title(): string + { + return esc_attr__('CryptoPay', 'gf-cryptopay'); + } + + /** + * @return string + */ + public function get_form_editor_field_description(): string + { + return esc_attr__('Adds cryptocurrency payments to your form.', 'gf-cryptopay'); + } + + /** + * @param int $formId + * @return string + */ + public function run(int $formId): string + { + return (new Payment('gravityforms'))->html(); + } +} diff --git a/app/Gateways/CryptoPayLite.php b/app/Gateways/GatewayLite.php similarity index 95% rename from app/Gateways/CryptoPayLite.php rename to app/Gateways/GatewayLite.php index 0d7b198..238e91d 100644 --- a/app/Gateways/CryptoPayLite.php +++ b/app/Gateways/GatewayLite.php @@ -9,7 +9,7 @@ use BeycanPress\CryptoPayLite\Payment; -class CryptoPayLite extends AbstractGateway +class GatewayLite extends AbstractGateway { /** * @var string diff --git a/app/Loader.php b/app/Loader.php index e1ff7e2..75d8d42 100644 --- a/app/Loader.php +++ b/app/Loader.php @@ -23,6 +23,10 @@ public function __construct() 10, [ 'orderId' => function ($tx) { + if (!isset($tx->orderId)) { + return esc_html__('Pending...', 'gf-cryptopay'); + } + return Helpers::run('view', 'components/link', [ 'url' => sprintf(admin_url('admin.php?page=gf_entries&view=entry&id=%d&lid=%d&order=ASC&filter&paged=1&pos=0&field_id&operator'), $tx->params->formId, $tx->orderId), // @phpcs:ignore 'text' => sprintf(esc_html__('View entry #%d', 'gf-cryptopay'), $tx->orderId) @@ -55,9 +59,9 @@ public function paymentRedirectUrls(object $data): array public function register(): void { if (Helpers::exists()) { - \GF_Fields::register(new Gateways\CryptoPayLite()); + \GF_Fields::register(new Gateways\Gateway()); } else { - \GF_Fields::register(new Gateways\CryptoPayLite()); + \GF_Fields::register(new Gateways\GatewayLite()); } } }