Skip to content

Offer different email frequency in onboarding signup #317

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

Draft
wants to merge 14 commits into
base: develop
Choose a base branch
from
Draft
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
14 changes: 10 additions & 4 deletions assets/css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ button.prpl-info-icon {

label {
display: grid;
grid-template-columns: 1fr 3fr;
grid-template-columns: 2fr 8fr;
margin-bottom: 0.5em;
gap: var(--prpl-padding);
}
Expand Down Expand Up @@ -467,9 +467,15 @@ button.prpl-info-icon {
margin-inline-start: 0.25em;
vertical-align: middle;

svg {
width: 1em;
height: 1em;
label {
display: grid;
grid-template-columns: 2fr 8fr;
margin-bottom: 0.5em;
gap: var(--prpl-padding);
}

.prpl-onboard-form-radio-select {
margin-bottom: 1em;
}
}

Expand Down
38 changes: 32 additions & 6 deletions assets/js/onboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,22 @@ if ( document.getElementById( 'prpl-onboarding-form' ) ) {
.forEach( ( inputField ) => {
inputField.required = false;
} );

// Hide the form fields and the primary button.
document
.getElementById( 'prpl-onboarding-form' )
.querySelectorAll(
'.prpl-form-fields, .prpl-button-primary'
)
.forEach( ( el ) => el.classList.add( 'prpl-hidden' ) );

// Show the secondary button.
document
.getElementById( 'prpl-onboarding-form' )
.querySelectorAll( '.prpl-button-secondary--no-email' )
.forEach( ( el ) =>
el.classList.remove( 'prpl-hidden' )
);
} else {
document
.getElementById( 'prpl-onboarding-form' )
Expand All @@ -115,13 +131,23 @@ if ( document.getElementById( 'prpl-onboarding-form' ) ) {
inputField.required = true;
}
} );

// Show the form fields and the primary button.
document
.getElementById( 'prpl-onboarding-form' )
.querySelectorAll(
'.prpl-form-fields, .prpl-button-primary'
)
.forEach( ( el ) =>
el.classList.remove( 'prpl-hidden' )
);

// Hide the secondary button.
document
.getElementById( 'prpl-onboarding-form' )
.querySelectorAll( '.prpl-button-secondary--no-email' )
.forEach( ( el ) => el.classList.add( 'prpl-hidden' ) );
}
document
.getElementById( 'prpl-onboarding-form' )
.querySelectorAll(
'.prpl-form-fields, .prpl-form-fields, .prpl-button-primary, .prpl-button-secondary--no-email'
)
.forEach( ( el ) => el.classList.toggle( 'prpl-hidden' ) );
} );
} );

Expand Down
93 changes: 58 additions & 35 deletions views/popovers/subscribe-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,45 +26,68 @@
?>
</p>
<div class="prpl-form-fields">
<label>
<span class="prpl-label-content">
<?php \esc_html_e( 'First name', 'progress-planner' ); ?>
</span>
<div class="prpl-onboard-form-radio-select">
<label>
<input type="radio" name="with-email" value="weekly" checked>
<span class="prpl-label-content">
<?php \esc_html_e( 'Yes, send me weekly updates!', 'progress-planner' ); ?>
</span>
</label>
<label>
<input type="radio" name="with-email" value="monthly">
<span class="prpl-label-content">
<?php \esc_html_e( 'Monthly, tell me what to do next month!', 'progress-planner' ); ?>
</span>
</label>
<label>
<input type="radio" name="with-email" value="quarterly">
<span class="prpl-label-content">
<?php \esc_html_e( 'Quarterly, just keep me posted on your plugin updates.', 'progress-planner' ); ?>
</span>
</label>
<label>
<input type="radio" name="with-email" value="no">
<span class="prpl-label-content">
<?php \esc_html_e( 'No, I don’t want emails right now.', 'progress-planner' ); ?>
</span>
</label>
</div>
<div class="prpl-form-fields">
<label>
<span class="prpl-label-content">
<?php \esc_html_e( 'First name', 'progress-planner' ); ?>
</span>
<input
type="text"
name="name"
class="prpl-input"
required
value="<?php echo \esc_attr( \get_user_meta( $prpl_current_user->ID, 'first_name', true ) ); ?>"
>
</label>
<label>
<span class="prpl-label-content">
<?php \esc_html_e( 'Email', 'progress-planner' ); ?>
</span>
<input
type="email"
name="email"
class="prpl-input"
required
value="<?php echo \esc_attr( $prpl_current_user->user_email ); ?>"
>
</label>
<input
type="text"
name="name"
class="prpl-input"
required
value="<?php echo \esc_attr( \get_user_meta( $prpl_current_user->ID, 'first_name', true ) ); ?>"
type="hidden"
name="site"
value="<?php echo \esc_attr( \set_url_scheme( \site_url() ) ); ?>"
>
</label>
<label>
<span class="prpl-label-content">
<?php \esc_html_e( 'Email', 'progress-planner' ); ?>
</span>
<input
type="email"
name="email"
class="prpl-input"
required
value="<?php echo \esc_attr( $prpl_current_user->user_email ); ?>"
type="hidden"
name="timezone_offset"
value="<?php echo (float) ( \wp_timezone()->getOffset( new \DateTime( 'midnight' ) ) / 3600 ); ?>"
>
</label>
<input
type="hidden"
name="site"
value="<?php echo \esc_attr( \set_url_scheme( \site_url() ) ); ?>"
>
<input
type="hidden"
name="timezone_offset"
value="<?php echo (float) ( \wp_timezone()->getOffset( new \DateTime( 'midnight' ) ) / 3600 ); ?>"
>
<input
type="hidden"
name="with-email"
value="yes"
>
</div>
</div>
<button id="submit-license-key" class="button button-primary"><?php \esc_html_e( 'Subscribe', 'progress-planner' ); ?></button>
</form>
16 changes: 14 additions & 2 deletions views/welcome.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,23 @@
<strong><?php \esc_html_e( 'Choose your preference:', 'progress-planner' ); ?></strong>
<div class="prpl-onboard-form-radio-select">
<label>
<input type="radio" name="with-email" value="yes" checked>
<input type="radio" name="with-email" value="weekly" checked>
<span class="prpl-label-content">
<?php \esc_html_e( 'Yes, send me weekly updates!', 'progress-planner' ); ?>
</span>
</label>
<label>
<input type="radio" name="with-email" value="monthly">
<span class="prpl-label-content">
<?php \esc_html_e( 'Monthly, tell me what to do next month!', 'progress-planner' ); ?>
</span>
</label>
<label>
<input type="radio" name="with-email" value="quarterly">
<span class="prpl-label-content">
<?php \esc_html_e( 'Quarterly, just keep me posted on your plugin updates.', 'progress-planner' ); ?>
</span>
</label>
<label>
<input type="radio" name="with-email" value="no">
<span class="prpl-label-content">
Expand Down Expand Up @@ -142,7 +154,7 @@ class="prpl-input"
<span>
<input
type="submit"
value="<?php \esc_attr_e( 'Get going and send me weekly emails', 'progress-planner' ); ?>"
value="<?php \esc_attr_e( 'Get going and send me emails', 'progress-planner' ); ?>"
class="prpl-button-primary"
>
</span>
Expand Down
Loading