From 81839e0c57120ab5bf07501d022e86fabce938b6 Mon Sep 17 00:00:00 2001 From: Nerijus Zaniauskas Date: Fri, 2 Feb 2024 14:46:05 +0200 Subject: [PATCH 1/3] Show connection form --- omnisend/includes/Internal/class-connection.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/omnisend/includes/Internal/class-connection.php b/omnisend/includes/Internal/class-connection.php index ff20016..b37d792 100644 --- a/omnisend/includes/Internal/class-connection.php +++ b/omnisend/includes/Internal/class-connection.php @@ -38,6 +38,11 @@ public static function display(): void { } } + if ( ! $connected ) { + require_once __DIR__ . '/../../view/connection-form.html'; + return; + } + require_once __DIR__ . '/../../view/connection-success.html'; } From 78f25df918c3a6d6f270f363090917e87be61741 Mon Sep 17 00:00:00 2001 From: Nerijus Zaniauskas Date: Fri, 2 Feb 2024 15:00:06 +0200 Subject: [PATCH 2/3] Remove phone validation --- omnisend/includes/Public/V1/class-contact.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/omnisend/includes/Public/V1/class-contact.php b/omnisend/includes/Public/V1/class-contact.php index 3a6c0a2..ea43a4c 100644 --- a/omnisend/includes/Public/V1/class-contact.php +++ b/omnisend/includes/Public/V1/class-contact.php @@ -73,7 +73,7 @@ public function validate(): WP_Error { } } - if ( $this->email != null && ! is_email( $this->email ) && $error['email'] == null ) { + if ( $this->email != null && ! is_email( $this->email ) ) { $error->add( 'email', 'Not a email.' ); } @@ -81,10 +81,6 @@ public function validate(): WP_Error { $error->add( 'send_welcome_email', 'Not a valid boolean.' ); } - if ( $this->phone != null && ! is_numeric( $this->phone ) && $error['phone'] == null ) { - $error->add( 'phone', 'Not a valid phone number.' ); - } - if ( $this->phone == null && $this->email == null ) { $error->add( 'identifier', 'Phone or email must be set.' ); } From 1378f71c1f91991f04fa145d75ee3c278217cc57 Mon Sep 17 00:00:00 2001 From: Nerijus Zaniauskas Date: Fri, 2 Feb 2024 16:12:13 +0200 Subject: [PATCH 3/3] Improve validation --- omnisend/includes/Internal/class-utils.php | 4 ++-- omnisend/includes/Public/V1/class-contact.php | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/omnisend/includes/Internal/class-utils.php b/omnisend/includes/Internal/class-utils.php index 591c883..6de2f94 100644 --- a/omnisend/includes/Internal/class-utils.php +++ b/omnisend/includes/Internal/class-utils.php @@ -19,7 +19,7 @@ class Utils { * @return bool */ public static function is_valid_custom_property_name( $name ): bool { - return preg_match( '/^[a-zA-Z0-9_]{1,128}$/', $name ); + return is_string( $name ) && preg_match( '/^[a-zA-Z0-9_]{1,128}$/', $name ); } /** @@ -30,7 +30,7 @@ public static function is_valid_custom_property_name( $name ): bool { * @return bool */ public static function is_valid_tag( $tag ): bool { - return preg_match( '/^[a-zA-Z0-9_\- ]{1,128}$/', $tag ); + return is_string( $tag ) && preg_match( '/^[a-zA-Z0-9_\- ]{1,128}$/', $tag ); } /** diff --git a/omnisend/includes/Public/V1/class-contact.php b/omnisend/includes/Public/V1/class-contact.php index ea43a4c..bb69b7e 100644 --- a/omnisend/includes/Public/V1/class-contact.php +++ b/omnisend/includes/Public/V1/class-contact.php @@ -95,9 +95,9 @@ public function validate(): WP_Error { } } - foreach ( $this->custom_properties as $custom_property ) { - if ( ! Utils::is_valid_custom_property_name( $custom_property ) ) { - $error->add( 'custom_properties', 'Custom property "' . $custom_property . '" is not valid. Please cleanup it before setting it.' ); + foreach ( $this->custom_properties as $custom_property_name => $custom_property_value ) { + if ( ! Utils::is_valid_custom_property_name( $custom_property_name ) ) { + $error->add( 'custom_properties', 'Custom property "' . $custom_property_name . '" is not valid. Please cleanup it before setting it.' ); } }