From f28ce36b958a98ee3e47dec1e2d82834cff0a192 Mon Sep 17 00:00:00 2001 From: "Alex P." Date: Thu, 7 Nov 2024 09:44:00 +0200 Subject: [PATCH 1/2] Add new settings containers --- .../src/Data/GeneralSettings.php | 191 ++++++++++++++++++ .../src/Data/PaymentSettings.php | 34 ++++ .../src/Data/StylingSettings.php | 34 ++++ 3 files changed, 259 insertions(+) create mode 100644 modules/ppcp-settings/src/Data/GeneralSettings.php create mode 100644 modules/ppcp-settings/src/Data/PaymentSettings.php create mode 100644 modules/ppcp-settings/src/Data/StylingSettings.php diff --git a/modules/ppcp-settings/src/Data/GeneralSettings.php b/modules/ppcp-settings/src/Data/GeneralSettings.php new file mode 100644 index 000000000..2020035a9 --- /dev/null +++ b/modules/ppcp-settings/src/Data/GeneralSettings.php @@ -0,0 +1,191 @@ + false, + 'live_client_id' => '', + 'live_client_secret' => '', + 'live_merchant_id' => '', + 'live_merchant_email' => '', + 'sandbox_client_id' => '', + 'sandbox_client_secret' => '', + 'sandbox_merchant_id' => '', + 'sandbox_merchant_email' => '', + ); + } + + // ----- + + /** + * Gets the 'is_sandbox' flag. + */ + public function is_sandbox() : bool { + return (bool) $this->data['is_sandbox']; + } + + /** + * Sets the 'is_sandbox' flag. + * + * @param bool $value The value to set. + */ + public function set_is_sandbox( bool $value ) : void { + $this->data['is_sandbox'] = $value; + } + + /** + * Gets the live client ID. + */ + public function live_client_id() : string { + return $this->data['live_client_id']; + } + + /** + * Sets the live client ID. + * + * @param string $value The value to set. + */ + public function set_live_client_id( string $value ) : void { + $this->data['live_client_id'] = sanitize_text_field( $value ); + } + + /** + * Gets the live client secret. + */ + public function live_client_secret() : string { + return $this->data['live_client_secret']; + } + + /** + * Sets the live client secret. + * + * @param string $value The value to set. + */ + public function set_live_client_secret( string $value ) : void { + $this->data['live_client_secret'] = sanitize_text_field( $value ); + } + + /** + * Gets the live merchant ID. + */ + public function live_merchant_id() : string { + return $this->data['live_merchant_id']; + } + + /** + * Sets the live merchant ID. + * + * @param string $value The value to set. + */ + public function set_live_merchant_id( string $value ) : void { + $this->data['live_merchant_id'] = sanitize_text_field( $value ); + } + + /** + * Gets the live merchant email. + */ + public function live_merchant_email() : string { + return $this->data['live_merchant_email']; + } + + /** + * Sets the live merchant email. + * + * @param string $value The value to set. + */ + public function set_live_merchant_email( string $value ) : void { + $this->data['live_merchant_email'] = sanitize_text_field( $value ); + } + + /** + * Gets the sandbox client ID. + */ + public function sandbox_client_id() : string { + return $this->data['sandbox_client_id']; + } + + /** + * Sets the sandbox client ID. + * + * @param string $value The value to set. + */ + public function set_sandbox_client_id( string $value ) : void { + $this->data['sandbox_client_id'] = sanitize_text_field( $value ); + } + + /** + * Gets the sandbox client secret. + */ + public function sandbox_client_secret() : string { + return $this->data['sandbox_client_secret']; + } + + /** + * Sets the sandbox client secret. + * + * @param string $value The value to set. + */ + public function set_sandbox_client_secret( string $value ) : void { + $this->data['sandbox_client_secret'] = sanitize_text_field( $value ); + } + + /** + * Gets the sandbox merchant ID. + */ + public function sandbox_merchant_id() : string { + return $this->data['sandbox_merchant_id']; + } + + /** + * Sets the sandbox merchant ID. + * + * @param string $value The value to set. + */ + public function set_sandbox_merchant_id( string $value ) : void { + $this->data['sandbox_merchant_id'] = sanitize_text_field( $value ); + } + + /** + * Gets the sandbox merchant email. + */ + public function sandbox_merchant_email() : string { + return $this->data['sandbox_merchant_email']; + } + + /** + * Sets the sandbox merchant email. + * + * @param string $value The value to set. + */ + public function set_sandbox_merchant_email( string $value ) : void { + $this->data['sandbox_merchant_email'] = sanitize_text_field( $value ); + } +} diff --git a/modules/ppcp-settings/src/Data/PaymentSettings.php b/modules/ppcp-settings/src/Data/PaymentSettings.php new file mode 100644 index 000000000..0180150a2 --- /dev/null +++ b/modules/ppcp-settings/src/Data/PaymentSettings.php @@ -0,0 +1,34 @@ + Date: Fri, 8 Nov 2024 08:04:26 +0200 Subject: [PATCH 2/2] Use sanitize_email Co-authored-by: Matic Luznar <139765838+inpsyde-maticluznar@users.noreply.github.com> --- modules/ppcp-settings/src/Data/GeneralSettings.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/ppcp-settings/src/Data/GeneralSettings.php b/modules/ppcp-settings/src/Data/GeneralSettings.php index 2020035a9..8fe7ee872 100644 --- a/modules/ppcp-settings/src/Data/GeneralSettings.php +++ b/modules/ppcp-settings/src/Data/GeneralSettings.php @@ -122,7 +122,7 @@ class GeneralSettings extends AbstractDataModel { * @param string $value The value to set. */ public function set_live_merchant_email( string $value ) : void { - $this->data['live_merchant_email'] = sanitize_text_field( $value ); + $this->data['live_merchant_email'] = sanitize_email( $value ); } /** @@ -186,6 +186,6 @@ class GeneralSettings extends AbstractDataModel { * @param string $value The value to set. */ public function set_sandbox_merchant_email( string $value ) : void { - $this->data['sandbox_merchant_email'] = sanitize_text_field( $value ); + $this->data['sandbox_merchant_email'] = sanitize_email( $value ); } }