From 3b66f11e95490e977f2f2f3abef7afffc3f80fc1 Mon Sep 17 00:00:00 2001 From: Halil Beycan <50718965+BeycanDeveloper@users.noreply.github.com> Date: Sat, 27 Apr 2024 11:08:00 +0800 Subject: [PATCH] configuration for wp.org --- app/Gateways/AbstractGateway.php | 24 +++++++++++++++++++++--- readme.txt | 2 +- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/app/Gateways/AbstractGateway.php b/app/Gateways/AbstractGateway.php index ec3e10b..6c47f5d 100644 --- a/app/Gateways/AbstractGateway.php +++ b/app/Gateways/AbstractGateway.php @@ -80,6 +80,7 @@ public function tagHandler(\WPCF7_FormTag $tag): string $itemCurrency = get_post_meta($form->id(), "cf7_cp_item_currency", true); if (!$activate) { + /* translators: %s: plugin name */ return sprintf(esc_html__('%s is not activated.', 'cf7-cryptopay'), $this->name); } @@ -103,7 +104,7 @@ public function tagHandler(\WPCF7_FormTag $tag): string if (Session::has('cf7_transaction_hash')) { $transaction = $this->getModel()->findOneBy([ 'hash' => Session::get('cf7_transaction_hash'), - 'params' => json_encode($params), + 'params' => wp_json_encode($params), ]); if ($transaction) { return $this->alreadyPaid($transaction); @@ -154,6 +155,10 @@ private function alreadyPaid(object $transaction): string */ public function save(\WPCF7_ContactForm $form): void { + if (!isset($_POST['cf7_cp_nonce']) || !wp_verify_nonce($_POST['cf7_cp_nonce'], 'cf7_cp_nonce')) { + return; + } + $activate = isset($_POST['cf7_cp_activate']) ? 1 : 0; $itemId = isset($_POST['cf7_cp_item_id']) ? absint($_POST['cf7_cp_item_id']) : 0; $itemPrice = isset($_POST['cf7_cp_item_price']) ? absint($_POST['cf7_cp_item_price']) : 0; @@ -186,6 +191,8 @@ public function addPanel(array $panels): array */ public function panelContent(): void { + /* phpcs:disable WordPress.Security.NonceVerification.Recommended */ + if (class_exists(Constants::class)) { $currencies = Constants::getCountryCurrencies(); } else { @@ -205,11 +212,14 @@ public function panelContent(): void $options .= ''; } + wp_nonce_field('cf7_cp_nonce', 'cf7_cp_nonce', false, true); + echo '
' . esc_html__('Add cryptocurrency payment gateway to your form.', 'cf7-cryptopay') . '
'; echo '' . sprintf( + /* translators: %s: tag name */ esc_html__( - 'You need add "%s" tag to form for start %s and need delete submit button.', + 'You need add "%1$s" tag to form for start %2$s and need delete submit button.', 'cf7-cryptopay' ), '[' . esc_html($this->key) . ']', @@ -219,7 +229,13 @@ public function panelContent(): void
- + | @@ -270,6 +286,8 @@ public function panelContent(): void |