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'; } 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 3a6c0a2..bb69b7e 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.' ); } @@ -99,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.' ); } }