-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Frontend email nag for custom domain (#33390)
* add plugin to show email nag on the frontend * show frontend domain email nag * add changelog * fix doc * Update domain-email-nag.php Add slash to do class look-up in global namespace instead of relative to package (it was causing an error on the frontend for me) * Rework logic to use Domain_Management class; change backround to red * Use the correct URL --------- Co-authored-by: Michael Kelly <mike.kelly@a8c.com> Co-authored-by: mpkelly <kikemelly@gmail.com> Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/6376528204
- Loading branch information
Showing
7 changed files
with
137 additions
and
10 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
vendor/automattic/jetpack-mu-wpcom/src/features/domain-email-nag/domain-email-nag.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
/** | ||
* Frontend Domain Email Nag | ||
* | ||
* @package A8C\Domain\Frontend_Email_Nag | ||
*/ | ||
|
||
namespace A8C\Domain\Frontend_Email_Nag; | ||
|
||
use Automattic\Jetpack\Jetpack_Mu_Wpcom; | ||
|
||
/** | ||
* Determines whether the email nag should be shown. | ||
* | ||
* @return boolean | ||
*/ | ||
function should_show_domain_frontend_email_nag() { | ||
if ( ! is_front_page() || ( is_front_page() && ! is_user_logged_in() ) ) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
/** | ||
* Returns the domain url for site that has a domain with an | ||
* univerified email address. | ||
* | ||
* @return string account url | ||
*/ | ||
function get_account_url() { | ||
return 'https://wordpress.com/domains/manage/' . wpcom_get_site_slug(); | ||
} | ||
|
||
/** | ||
* Find the domain, if any, that has an unverified email address. | ||
*/ | ||
function get_domain_with_unverified_email() { | ||
if ( ! class_exists( 'Domain_Management' ) ) { | ||
return false; | ||
} | ||
|
||
$domains = \Domain_Management::get_paid_domains_with_icann_verification_status(); | ||
|
||
foreach ( $domains as $domain ) { | ||
if ( $domain['is_pending_icann_verification'] === true ) { | ||
return $domain['domain']; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
/** | ||
* Decides whether to render to the email nag. | ||
*/ | ||
function domain_email_nag() { | ||
if ( ! should_show_domain_frontend_email_nag() ) { | ||
return; | ||
} | ||
|
||
$domain = get_domain_with_unverified_email(); | ||
|
||
if ( ! $domain ) { | ||
return; | ||
} | ||
|
||
wp_enqueue_style( 'wpcom-domain-email-nag-style', plugins_url( 'domain-nag.style.css', __FILE__ ), array(), Jetpack_Mu_Wpcom::PACKAGE_VERSION ); | ||
|
||
$notice = sprintf( | ||
/* translators: %1 User's email address, %2 current domain */ | ||
__( 'You need to confirm your domain email address to avoid having your domain <strong>%1$s</strong> suspended. Please check your inbox.', 'jetpack-mu-wpcom' ), | ||
$domain | ||
); | ||
|
||
?> | ||
<div class="wp-domain-nag-sticky-message"> | ||
<div class="wp-domain-nag-inner"> | ||
<p class="wp-domain-nag-text"><?php echo wp_kses( $notice, array( 'strong' => array() ) ); ?></p> | ||
<a class="button" href="<?php echo esc_url( get_account_url() ); ?>"><?php esc_html_e( 'Fix', 'jetpack-mu-wpcom' ); ?></a> | ||
</div> | ||
</div> | ||
<?php | ||
} | ||
add_action( 'wp_footer', __NAMESPACE__ . '\domain_email_nag' ); | ||
|
35 changes: 35 additions & 0 deletions
35
vendor/automattic/jetpack-mu-wpcom/src/features/domain-email-nag/domain-nag.style.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
.wp-domain-nag-sticky-message { | ||
position: sticky; | ||
bottom: 10px; | ||
width: 50%; | ||
margin: auto; | ||
background-color: #d9534f; | ||
border-radius: 2px; | ||
color: #fff; | ||
padding: 10px; | ||
} | ||
|
||
.wp-domain-nag-inner { | ||
display: inline-block; | ||
} | ||
|
||
.wp-domain-nag-text { | ||
display: inline; | ||
} | ||
|
||
.wp-domain-nag-sticky-message .button { | ||
background: #fff; | ||
border-radius: 2px; | ||
border: 1px solid #fff; | ||
box-sizing: border-box; | ||
display: inline-block; | ||
line-height: 21px; | ||
padding: 8px; | ||
text-align: center; | ||
text-overflow: ellipsis; | ||
text-decoration: none; | ||
transition: opacity .15s ease-out; | ||
white-space: nowrap; | ||
width: 120px; | ||
margin-left: 16px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters