Skip to content

Commit

Permalink
Merge pull request #1472 from sapayth/enhance/move_newsletter_subscri…
Browse files Browse the repository at this point in the history
…ption_to_wemail

enhance: move newsletter subscription to weMail
  • Loading branch information
sapayth authored Aug 16, 2024
2 parents 5048171 + fc21a6a commit 7121e70
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 122 deletions.
50 changes: 13 additions & 37 deletions assets/css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -1069,59 +1069,35 @@ span.pro-icon:hover .wpuf-pro-field-tooltip {
}
.wpuf-help-page .wpuf-subscribe-box {
display: flex;
justify-content: space-between;
border: 1px solid #e5e5e5;
background: #fff;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
margin-top: 15px;
}
.wpuf-help-page .wpuf-subscribe-box .text-wrap {
width: calc(100% - 530px);
.wpuf-help-page .wpuf-subscribe-box .wpuf-text-wrap {
padding: 10px 15px;
width: 60%;
}
.wpuf-help-page .wpuf-subscribe-box .text-wrap h3 {
.wpuf-help-page .wpuf-subscribe-box .wpuf-text-wrap h3 {
color: #ff5722;
margin: 4px 0 0 0;
}
.wpuf-help-page .wpuf-subscribe-box .text-wrap p {
margin-bottom: 5px;
}
.wpuf-help-page .wpuf-subscribe-box .form-wrap {
width: 530px;
display: flex;
padding: 10px 0;
.wpuf-help-page .wpuf-subscribe-box .wpuf-form-wrap {
background: #f7f7f7;
padding-left: 20px;
padding: 10px 15px;
width: 40%;
border-left: 1px solid #eee;
}
.wpuf-help-page .wpuf-subscribe-box .form-wrap .thank-you {
font-size: 16px;
color: green;
padding-top: 20px;
text-align: center;
width: 100%;
}
.wpuf-help-page .wpuf-subscribe-box .form-wrap label {
.wpuf-help-page .wpuf-subscribe-box .wpuf-form-wrap label {
color: #666;
}
.wpuf-help-page .wpuf-subscribe-box .form-wrap input {
max-width: 100%;
overflow: hidden;
}
.wpuf-help-page .wpuf-subscribe-box .form-wrap input[type="text"],
.wpuf-help-page .wpuf-subscribe-box .form-wrap input[type="email"] {
padding: 5px 8px;
}
.wpuf-help-page .wpuf-subscribe-box .form-wrap .fname {
width: 35%;
margin-right: 10px;
}
.wpuf-help-page .wpuf-subscribe-box .form-wrap .email {
width: 40%;
margin-right: 10px;
.wpuf-help-page .wpuf-subscribe-box .wpuf-form-wrap form {
display: flex;
align-items: flex-end;
}
.wpuf-help-page .wpuf-subscribe-box .form-wrap .submit-btn {
width: 20%;
padding-top: 22px;
.wpuf-help-page .wpuf-subscribe-box .wpuf-form-wrap form input {
margin-right: 15px;
}
.wpuf-help-page .help-blocks {
display: flex;
Expand Down
53 changes: 12 additions & 41 deletions assets/less/help.less
Original file line number Diff line number Diff line change
Expand Up @@ -151,68 +151,39 @@

.wpuf-subscribe-box {
display: flex;
justify-content: space-between;
border: 1px solid #e5e5e5;
background: #fff;
box-shadow: 0 1px 1px rgba(0,0,0,.04);
margin-top: 15px;

.text-wrap {
width: ~"calc(100% - 530px)";
.wpuf-text-wrap {
padding: 10px 15px;
width: 60%;

h3 {
color: #ff5722;
margin: 4px 0 0 0;
}

p {
margin-bottom: 5px;
}
}

.form-wrap {
width: 530px;
display: flex;
padding: 10px 0;
.wpuf-form-wrap {
background: #f7f7f7;
padding-left: 20px;
padding: 10px 15px;
width: 40%;
border-left: 1px solid #eee;

.thank-you {
font-size: 16px;
color: green;
padding-top: 20px;
text-align: center;
width: 100%;
}

label {
color: #666;
}

input {
max-width: 100%;
overflow: hidden;
}

input[type="text"],
input[type="email"] {
padding: 5px 8px;
}

.fname {
width: 35%;
margin-right: 10px;
}
form {
display: flex;
align-items: flex-end;

.email {
width: 40%;
margin-right: 10px;
}

.submit-btn {
width: 20%;
padding-top: 22px;
input {
margin-right: 15px;
}
}
}
}
Expand Down
109 changes: 65 additions & 44 deletions includes/Admin/views/support.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,32 +204,57 @@ function wpuf_help_related_articles( $articles ) {
<div class="wrap wpuf-help-page">
<h1><?php esc_html_e( 'General Help Questions', 'wp-user-frontend' ); ?> <a href="https://wedevs.com/docs/wp-user-frontend-pro/?utm_source=wpuf-help-page&utm_medium=button-primary&utm_campaign=view-all-docs" target="_blank" class="page-title-action"><span class="dashicons dashicons-external" style="margin-top: 8px;"></span> <?php esc_html_e( 'View all Documentations', 'wp-user-frontend' ); ?></a></h1>

<form class="wpuf-subscribe-box" id="wpuf-form-subscribe" action="https://wedevs.us16.list-manage.com/subscribe/post-json?u=66e606cfe0af264974258f030&id=0d176bb256&c=?" method="get">

<div class="text-wrap">
<div class="wpuf-subscribe-box">
<div class="wpuf-text-wrap">
<h3><?php esc_html_e( 'Subscribe to Our Newsletter', 'wp-user-frontend' ); ?></h3>
<p>
<?php echo wp_kses_post( __( 'Subscribe to our newsletter for regular <strong>tips</strong>, <strong>offers</strong> and <strong>news updates</strong>.', 'wp-user-frontend' ) ); ?>
<?php echo wp_kses_post(
__(
'Subscribe to our newsletter for regular <strong>tips</strong>, <strong>offers</strong> and <strong>news updates</strong>.',
'wp-user-frontend'
)
); ?>
</p>
</div>

<div class="form-wrap">
<div class="fname">
<label for="fname"><?php esc_html_e( 'First Name', 'wp-user-frontend' ); ?></label>
<input type="text" name="FNAME" id="fname" class="regular-text" value="<?php echo esc_attr( $current_user->first_name ); ?>" required>
</div>

<div class="email">
<label for="email"><?php esc_html_e( 'Email', 'wp-user-frontend' ); ?></label>
<input type="email" name="EMAIL" id="email" class="regular-text" value="<?php echo esc_attr( $current_user->user_email ); ?>" required>
</div>

<div class="submit-btn">
<input type="hidden" name="group[3555][1]" value="1">
<input type="submit" class="button button-primary" value="<?php echo esc_attr( __( 'Subscribe', 'wp-user-frontend' ) ); ?>">
</div>
<div class="wpuf-form-wrap">
<form id="wemail-embedded-subscriber-form" method="post"
action="https://api.getwemail.io/v1/embed/subscribe/8da67b42-c367-4ad3-ae70-5cf63635a832">
<div class="form-group">
<label for="wemail-first-name">First Name <span
class="required-indicator">*</span></label>
<div>
<input
type="text"
name="first_name"
id="wemail-first-name"
required="required"
placeholder="<?php echo esc_attr( "Enter first name" ); ?>"
value="<?php echo esc_attr( $current_user->first_name ); ?>"
class="form-control">
</div>
</div>
<div class="form-group">
<label for="wemail-email">Email <span
class="required-indicator">*</span></label>
<div>
<input
type="email"
name="email"
required="required"
id="wemail-email"
placeholder="<?php echo esc_attr( "Enter email" ); ?>"
value="<?php echo esc_attr( $current_user->user_email ); ?>"
class="form-control">
</div>
</div>
<input type="hidden" name="tag" value="698f5d31-4ef9-430a-a6f3-7f4bb24cdaf9">
<div>
<button class="button button-primary"><?php esc_html_e( 'Subscribe', 'wp-user-frontend' ); ?></button>
</div>

</form>
</div>
</form>
</div>

<div class="wpuf-help-tabbed">
<nav>
Expand Down Expand Up @@ -522,34 +547,30 @@ function wpuf_help_related_articles( $articles ) {
});
});

$('#wpuf-form-subscribe').submit(function(e) {
e.preventDefault();
const wemailForm = document.getElementById('wemail-embedded-subscriber-form');

var form = $(this);
if (wemailForm) {
wemailForm.addEventListener('submit', function(e) {
e.preventDefault();

form.find('input[type="submit"]').prop('disabled', true);
const formData = new FormData(wemailForm);
const email = formData.get('email');

$.ajax({
url: form.attr('action'),
data: form.serialize(),
type: 'GET',
dataType: 'json',
cache: false,
contentType: "application/json; charset=utf-8",
})
.done(function(data) {
// console.log(data);
if (!isValidEmail( email )) {
alert( 'Please enter a valid email address' );

if (data.result != "success") {
// do something
return;
}
})
.fail(function() {
// console.log("error");
})
.always(function(response) {
$('.form-wrap', form).html( '<div class="thank-you">' + response.msg + '</div>' );

wemailForm.submit();
});
});
}

function isValidEmail(email) {
// Regular expression for validating an Email
const regex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;

return regex.test(email);
}
});
</script>

0 comments on commit 7121e70

Please sign in to comment.