| 1 |
<?php |
| 2 |
defined( 'ABSPATH' ) || exit; |
| 3 |
|
| 4 |
/* |
| 5 |
* WooCommerce dependency gate. |
| 6 |
* |
| 7 |
* On the YayMail (WooCommerce) product the customizer app is only enqueued when |
| 8 |
* WooCommerce is active (Initialize::init_core runs solely in the WC branch of |
| 9 |
* the plugin bootstrap). Without WooCommerce the React app never mounts, so the |
| 10 |
* bare pre-loader below would spin forever. Render a dedicated requirement screen |
| 11 |
* instead of a blank, endlessly loading page. |
| 12 |
* |
| 13 |
* The Yay WP Email Customizer product (yaymagic-email-builder platform) is designed to run |
| 14 |
* without WooCommerce, so it must never see this screen — scope the check with the |
| 15 |
* platform provider, falling back to the YAYWP_VERSION signal when the platform |
| 16 |
* cannot be resolved from the current screen. |
| 17 |
*/ |
| 18 |
$yaymail_current_platform = class_exists( '\YayMail\Platform\PlatformRegistry' ) |
| 19 |
? \YayMail\Platform\PlatformRegistry::from_screen( get_current_screen() ) |
| 20 |
: null; |
| 21 |
|
| 22 |
$yaymail_needs_woocommerce = $yaymail_current_platform |
| 23 |
? ( $yaymail_current_platform->is_woo_product() && ! function_exists( 'WC' ) ) |
| 24 |
: ( ! defined( 'YAYWP_VERSION' ) && ! function_exists( 'WC' ) ); |
| 25 |
|
| 26 |
if ( $yaymail_needs_woocommerce ) { |
| 27 |
$yaymail_install_wc_url = esc_url( admin_url( 'plugin-install.php?s=woocommerce&tab=search&type=term' ) ); |
| 28 |
?> |
| 29 |
<style> |
| 30 |
#wpcontent #wpbody .notice, |
| 31 |
.error, .updated { display: none; } |
| 32 |
#wpfooter { display: none; } |
| 33 |
.yaymail-requirement-screen { |
| 34 |
display: flex; |
| 35 |
align-items: center; |
| 36 |
justify-content: center; |
| 37 |
min-height: calc(100vh - 160px); |
| 38 |
padding: 24px; |
| 39 |
box-sizing: border-box; |
| 40 |
} |
| 41 |
.yaymail-requirement-card { |
| 42 |
max-width: 460px; |
| 43 |
width: 100%; |
| 44 |
text-align: center; |
| 45 |
background: #ffffff; |
| 46 |
border: 1px solid #e4e4e7; |
| 47 |
border-radius: 12px; |
| 48 |
padding: 40px 32px; |
| 49 |
box-shadow: 0 1px 3px rgba( 0, 0, 0, 0.06 ); |
| 50 |
} |
| 51 |
.yaymail-requirement-card__icon { font-size: 44px; line-height: 1; margin-bottom: 16px; } |
| 52 |
.yaymail-requirement-card__title { font-size: 22px; font-weight: 600; color: #1e1e1e; margin: 0 0 12px; } |
| 53 |
.yaymail-requirement-card__text { font-size: 14px; line-height: 1.6; color: #50575e; margin: 0 0 24px; } |
| 54 |
.yaymail-requirement-card__button { |
| 55 |
display: inline-block; |
| 56 |
background: #873eff; |
| 57 |
color: #ffffff; |
| 58 |
font-size: 14px; |
| 59 |
font-weight: 600; |
| 60 |
text-decoration: none; |
| 61 |
padding: 10px 24px; |
| 62 |
border-radius: 6px; |
| 63 |
transition: background 0.15s ease; |
| 64 |
} |
| 65 |
.yaymail-requirement-card__button:hover, |
| 66 |
.yaymail-requirement-card__button:focus { background: #6f2fe0; color: #ffffff; } |
| 67 |
.yaymail-requirement-card__hint { font-size: 12px; color: #787c82; margin: 20px 0 0; } |
| 68 |
</style> |
| 69 |
<div class="yaymail-requirement-screen"> |
| 70 |
<div class="yaymail-requirement-card"> |
| 71 |
<div class="yaymail-requirement-card__icon" aria-hidden="true">🛒</div> |
| 72 |
<h1 class="yaymail-requirement-card__title"> |
| 73 |
<?php esc_html_e( 'WooCommerce is required', 'yaymail' ); ?> |
| 74 |
</h1> |
| 75 |
<p class="yaymail-requirement-card__text"> |
| 76 |
<?php esc_html_e( 'YayMail customizes your WooCommerce transactional emails, so it needs WooCommerce installed and activated. Install WooCommerce to start building your emails.', 'yaymail' ); ?> |
| 77 |
</p> |
| 78 |
<a class="yaymail-requirement-card__button" href="<?php echo esc_url( $yaymail_install_wc_url ); ?>"> |
| 79 |
<?php esc_html_e( 'Install WooCommerce', 'yaymail' ); ?> |
| 80 |
</a> |
| 81 |
<p class="yaymail-requirement-card__hint"> |
| 82 |
<?php esc_html_e( 'Already installed it? Activate WooCommerce, then reload this page.', 'yaymail' ); ?> |
| 83 |
</p> |
| 84 |
</div> |
| 85 |
</div> |
| 86 |
<?php |
| 87 |
return; |
| 88 |
} |
| 89 |
?> |
| 90 |
<style> |
| 91 |
#wpcontent #wpbody .notice, |
| 92 |
.error, .updated { |
| 93 |
display: none; |
| 94 |
} |
| 95 |
#wpfooter { |
| 96 |
display: none; |
| 97 |
} |
| 98 |
</style> |
| 99 |
<div style="display: none;"> |
| 100 |
<?php |
| 101 |
wp_editor( |
| 102 |
'', |
| 103 |
'yaymagic-email-builder-editor-placeholder', |
| 104 |
[ |
| 105 |
'quicktags' => false, |
| 106 |
'media_buttons' => true, |
| 107 |
'tinymce' => true, |
| 108 |
] |
| 109 |
); |
| 110 |
?> |
| 111 |
</div> |
| 112 |
<div id="yaymail-main-pages"> |
| 113 |
<div class="yaymail-pre-loading" style="width: 20px; height: 20px; background: url(images/spinner-2x.gif); background-size: contain; background-repeat: no-repeat; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);"> |
| 114 |
</div> |
| 115 |
</div> |
| 116 |
|
| 117 |
|