Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show connection form #16

Merged
merged 3 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions omnisend/includes/Internal/class-connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}

Expand Down
4 changes: 2 additions & 2 deletions omnisend/includes/Internal/class-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}

/**
Expand All @@ -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 );
}

/**
Expand Down
12 changes: 4 additions & 8 deletions omnisend/includes/Public/V1/class-contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,14 @@ 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.' );
}

if ( $this->send_welcome_email != null && ! is_bool( $this->send_welcome_email ) ) {
$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.' );
}
Expand All @@ -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.' );
}
}

Expand Down
Loading