Skip to content

Commit

Permalink
Update Sales form template
Browse files Browse the repository at this point in the history
  • Loading branch information
gocemitevski committed Jul 31, 2024
1 parent 006abbf commit bd683e1
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion template-snippets/sales-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,16 @@ function keitaro_sales_form_check_spam( $content ) {
if ( ( isset( $_GET['salesFormSubmitted'] ) ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ), 'keitaroSalesForm' ) ) :

try {
// Check if phone number is invalid.
if ( ! is_email( $sender_email ) ) :
throw new Exception( esc_html__( 'Seems like your email address is invalid. Please try again.', 'keitaro' ) );
endif;

// Check if phone number is invalid.
if ( ! preg_match( '/\+[0-9]{7,15}/', $phone ) ) :
throw new Exception( esc_html__( 'Seems like the phone number does not have a valid format. Please try again.', 'keitaro' ) );
endif;

// Check email content with Akismet before sending.
if ( 'true' === keitaro_sales_form_check_spam( $spam_check ) ) :
throw new Exception( esc_html__( "Seems like you are trying to submit spam. Sorry, that's not allowed.", 'keitaro' ) );
Expand Down Expand Up @@ -178,7 +188,7 @@ function keitaro_sales_form_check_spam( $content ) {
<div class="col-md-6">
<div class="form-group">
<label for="salesFormPhone">Phone</label>
<input class="form-control" minlength="11" type="tel" placeholder="+1-123-456-7890" pattern="+[0-9]{11}" name="salesFormPhone" id="salesFormPhone" />
<input class="form-control" minlength="7" type="tel" required placeholder="+1234567890" pattern="\+[0-9]{7,15}" name="salesFormPhone" id="salesFormPhone" />
</div>
</div>
</div>
Expand Down

0 comments on commit bd683e1

Please sign in to comment.