| 1 |
<?php |
| 2 |
/** |
| 3 |
* Store Checkout — WooCommerce required view |
| 4 |
* |
| 5 |
* Store Checkout replaces the WooCommerce checkout, so the screen is useless |
| 6 |
* without WooCommerce. Instead of rendering an empty listing we render the |
| 7 |
* dashboard shell with a blocking modal that installs or activates |
| 8 |
* WooCommerce in place. |
| 9 |
* |
| 10 |
* @package WPFunnels |
| 11 |
* @since 3.13.1 |
| 12 |
*/ |
| 13 |
|
| 14 |
use WPFunnels\Wpfnl_functions; |
| 15 |
|
| 16 |
if ( ! defined( 'ABSPATH' ) ) { |
| 17 |
exit; |
| 18 |
} |
| 19 |
|
| 20 |
if ( ! function_exists( 'get_plugins' ) ) { |
| 21 |
require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 22 |
} |
| 23 |
|
| 24 |
$wpfnl_wc_plugin = 'woocommerce/woocommerce.php'; |
| 25 |
$wpfnl_wc_status = Wpfnl_functions::is_plugin_installed( $wpfnl_wc_plugin ) ? 'inactive' : 'not-installed'; |
| 26 |
|
| 27 |
// Installing and activating need different capabilities — only offer the |
| 28 |
// action the current user is actually allowed to perform. |
| 29 |
if ( 'not-installed' === $wpfnl_wc_status ) { |
| 30 |
$wpfnl_can_act = current_user_can( 'install_plugins' ); |
| 31 |
$wpfnl_button_label = __( 'Install WooCommerce', 'wpfnl' ); |
| 32 |
} else { |
| 33 |
$wpfnl_can_act = current_user_can( 'activate_plugins' ); |
| 34 |
$wpfnl_button_label = __( 'Activate WooCommerce', 'wpfnl' ); |
| 35 |
} |
| 36 |
|
| 37 |
$wpfnl_dashboard_url = add_query_arg( array( 'page' => WPFNL_MAIN_PAGE_SLUG ), admin_url( 'admin.php' ) ); |
| 38 |
?> |
| 39 |
|
| 40 |
<div class="wpfnl wpfnl-store-checkout-page wpfnl-wc-required-page"> |
| 41 |
<div class="wpfnl-dashboard"> |
| 42 |
<nav class="wpfnl-dashboard__nav"> |
| 43 |
<?php require_once WPFNL_DIR . '/admin/partials/dashboard-nav.php'; ?> |
| 44 |
</nav> |
| 45 |
|
| 46 |
<div class="dashboard-nav__content"></div> |
| 47 |
<!-- /.dashboard-nav__content --> |
| 48 |
</div> |
| 49 |
|
| 50 |
<div class="wpfnl-wc-required-modal" role="dialog" aria-modal="true" aria-labelledby="wpfnl-wc-required-title"> |
| 51 |
<div class="wpfnl-wc-required-modal__backdrop"></div> |
| 52 |
|
| 53 |
<div class="wpfnl-wc-required-modal__panel"> |
| 54 |
<div class="wpfnl-wc-required-modal__body"> |
| 55 |
<span class="wpfnl-wc-required-modal__icon" aria-hidden="true"> |
| 56 |
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> |
| 57 |
<path d="M12 9v4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/> |
| 58 |
<path d="M12 16.5h.01" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/> |
| 59 |
<path d="M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/> |
| 60 |
</svg> |
| 61 |
</span> |
| 62 |
|
| 63 |
<div class="wpfnl-wc-required-modal__content"> |
| 64 |
<h2 id="wpfnl-wc-required-title" class="wpfnl-wc-required-modal__title"> |
| 65 |
<?php esc_html_e( 'Plugin Required', 'wpfnl' ); ?> |
| 66 |
</h2> |
| 67 |
<p class="wpfnl-wc-required-modal__text"> |
| 68 |
<?php esc_html_e( 'You need WooCommerce plugin installed and activated to access this page.', 'wpfnl' ); ?> |
| 69 |
</p> |
| 70 |
<?php if ( ! $wpfnl_can_act ) : ?> |
| 71 |
<p class="wpfnl-wc-required-modal__text"> |
| 72 |
<?php esc_html_e( 'You do not have permission to do this. Please contact your site administrator.', 'wpfnl' ); ?> |
| 73 |
</p> |
| 74 |
<?php endif; ?> |
| 75 |
<p class="wpfnl-wc-required-modal__error" style="display: none;"></p> |
| 76 |
</div> |
| 77 |
</div> |
| 78 |
|
| 79 |
<div class="wpfnl-wc-required-modal__footer"> |
| 80 |
<a href="<?php echo esc_url( $wpfnl_dashboard_url ); ?>" class="wpfnl-wc-required-modal__btn wpfnl-wc-required-modal__btn--secondary"> |
| 81 |
<?php esc_html_e( 'Go Back', 'wpfnl' ); ?> |
| 82 |
</a> |
| 83 |
|
| 84 |
<?php if ( $wpfnl_can_act ) : ?> |
| 85 |
<button type="button" id="wpfnl-wc-required-action" class="wpfnl-wc-required-modal__btn wpfnl-wc-required-modal__btn--primary"> |
| 86 |
<span class="wpfnl-wc-required-modal__spinner" aria-hidden="true"></span> |
| 87 |
<span class="wpfnl-wc-required-modal__label"><?php echo esc_html( $wpfnl_button_label ); ?></span> |
| 88 |
</button> |
| 89 |
<?php endif; ?> |
| 90 |
</div> |
| 91 |
</div> |
| 92 |
</div> |
| 93 |
</div> |
| 94 |
|
| 95 |
<?php |
| 96 |
// Core prints the filesystem credentials form here; wp.updates needs it when |
| 97 |
// the install cannot be written directly. |
| 98 |
if ( function_exists( 'wp_print_request_filesystem_credentials_modal' ) ) { |
| 99 |
wp_print_request_filesystem_credentials_modal(); |
| 100 |
} |
| 101 |
?> |
| 102 |
|
| 103 |
<style> |
| 104 |
.wpfnl-wc-required-page .dashboard-nav__content { |
| 105 |
min-height: 420px; |
| 106 |
} |
| 107 |
|
| 108 |
.wpfnl-wc-required-modal { |
| 109 |
position: fixed; |
| 110 |
inset: 0; |
| 111 |
z-index: 100000; |
| 112 |
display: flex; |
| 113 |
align-items: center; |
| 114 |
justify-content: center; |
| 115 |
padding: 20px; |
| 116 |
} |
| 117 |
|
| 118 |
.wpfnl-wc-required-modal__backdrop { |
| 119 |
position: absolute; |
| 120 |
inset: 0; |
| 121 |
background: rgba(54, 59, 78, 0.6); |
| 122 |
} |
| 123 |
|
| 124 |
.wpfnl-wc-required-modal__panel { |
| 125 |
position: relative; |
| 126 |
width: 100%; |
| 127 |
max-width: 512px; |
| 128 |
background: #fff; |
| 129 |
border-radius: 12px; |
| 130 |
box-shadow: 0 24px 48px -12px rgba(16, 24, 40, 0.25); |
| 131 |
overflow: hidden; |
| 132 |
} |
| 133 |
|
| 134 |
.wpfnl-wc-required-modal__body { |
| 135 |
display: flex; |
| 136 |
align-items: flex-start; |
| 137 |
gap: 16px; |
| 138 |
padding: 28px 28px 20px; |
| 139 |
} |
| 140 |
|
| 141 |
.wpfnl-wc-required-modal__icon { |
| 142 |
flex: 0 0 40px; |
| 143 |
width: 40px; |
| 144 |
height: 40px; |
| 145 |
display: inline-flex; |
| 146 |
align-items: center; |
| 147 |
justify-content: center; |
| 148 |
border-radius: 50%; |
| 149 |
background: rgba(220, 53, 69, 0.1); |
| 150 |
color: #DC3545; |
| 151 |
} |
| 152 |
|
| 153 |
.wpfnl-wc-required-modal__content { |
| 154 |
min-width: 0; |
| 155 |
} |
| 156 |
|
| 157 |
.wpfnl-wc-required-modal__title { |
| 158 |
margin: 0 0 8px; |
| 159 |
padding: 0; |
| 160 |
font-size: 18px; |
| 161 |
font-weight: 600; |
| 162 |
line-height: 1.4; |
| 163 |
color: #363B4E; |
| 164 |
} |
| 165 |
|
| 166 |
.wpfnl-wc-required-modal__text { |
| 167 |
margin: 0; |
| 168 |
font-size: 14px; |
| 169 |
line-height: 1.5; |
| 170 |
color: #7A8B9A; |
| 171 |
} |
| 172 |
|
| 173 |
.wpfnl-wc-required-modal__text + .wpfnl-wc-required-modal__text { |
| 174 |
margin-top: 8px; |
| 175 |
} |
| 176 |
|
| 177 |
.wpfnl-wc-required-modal__error { |
| 178 |
margin: 12px 0 0; |
| 179 |
font-size: 13px; |
| 180 |
line-height: 1.5; |
| 181 |
color: #DC3545; |
| 182 |
} |
| 183 |
|
| 184 |
.wpfnl-wc-required-modal__footer { |
| 185 |
display: flex; |
| 186 |
align-items: center; |
| 187 |
justify-content: flex-end; |
| 188 |
gap: 10px; |
| 189 |
padding: 4px 28px 24px; |
| 190 |
} |
| 191 |
|
| 192 |
/* Buttons are styled from scratch rather than reusing .btn-default so the |
| 193 |
dashboard's global button rules cannot bleed in (capitalize, letter-spacing, |
| 194 |
130px min-width, washed-out label colour). */ |
| 195 |
.wpfnl-wc-required-page .wpfnl-wc-required-modal__btn { |
| 196 |
display: inline-flex; |
| 197 |
align-items: center; |
| 198 |
justify-content: center; |
| 199 |
gap: 8px; |
| 200 |
box-sizing: border-box; |
| 201 |
height: 42px; |
| 202 |
min-width: 0; |
| 203 |
margin: 0; |
| 204 |
padding: 0 20px; |
| 205 |
border: 1px solid transparent; |
| 206 |
border-radius: 8px; |
| 207 |
background: none; |
| 208 |
box-shadow: none; |
| 209 |
font-family: inherit; |
| 210 |
font-size: 14px; |
| 211 |
font-weight: 500; |
| 212 |
line-height: 1; |
| 213 |
letter-spacing: 0; |
| 214 |
text-align: center; |
| 215 |
text-transform: none; |
| 216 |
text-decoration: none; |
| 217 |
white-space: nowrap; |
| 218 |
cursor: pointer; |
| 219 |
transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease; |
| 220 |
} |
| 221 |
|
| 222 |
.wpfnl-wc-required-page .wpfnl-wc-required-modal__btn > span { |
| 223 |
color: inherit; |
| 224 |
} |
| 225 |
|
| 226 |
.wpfnl-wc-required-page .wpfnl-wc-required-modal__btn:focus { |
| 227 |
outline: none; |
| 228 |
} |
| 229 |
|
| 230 |
.wpfnl-wc-required-page .wpfnl-wc-required-modal__btn:focus-visible { |
| 231 |
box-shadow: 0 0 0 3px rgba(110, 66, 211, 0.25); |
| 232 |
} |
| 233 |
|
| 234 |
/* Secondary — quiet escape hatch. */ |
| 235 |
.wpfnl-wc-required-page .wpfnl-wc-required-modal__btn--secondary, |
| 236 |
.wpfnl-wc-required-page .wpfnl-wc-required-modal__btn--secondary:visited { |
| 237 |
border-color: #E4E6EB; |
| 238 |
background: #fff; |
| 239 |
color: #3C3F47; |
| 240 |
} |
| 241 |
|
| 242 |
.wpfnl-wc-required-page .wpfnl-wc-required-modal__btn--secondary:hover, |
| 243 |
.wpfnl-wc-required-page .wpfnl-wc-required-modal__btn--secondary:focus { |
| 244 |
border-color: #D5D8E0; |
| 245 |
background: #F5F6FA; |
| 246 |
color: #3C3F47; |
| 247 |
} |
| 248 |
|
| 249 |
/* Primary — the action we actually want taken. */ |
| 250 |
.wpfnl-wc-required-page .wpfnl-wc-required-modal__btn--primary { |
| 251 |
background-color: #6E42D3; |
| 252 |
color: #fff; |
| 253 |
box-shadow: 0 6px 14px -4px rgba(110, 66, 211, 0.45); |
| 254 |
} |
| 255 |
|
| 256 |
.wpfnl-wc-required-page .wpfnl-wc-required-modal__btn--primary:hover, |
| 257 |
.wpfnl-wc-required-page .wpfnl-wc-required-modal__btn--primary:focus { |
| 258 |
background-color: #4C25A5; |
| 259 |
color: #fff; |
| 260 |
} |
| 261 |
|
| 262 |
.wpfnl-wc-required-page .wpfnl-wc-required-modal__btn--primary:active { |
| 263 |
box-shadow: none; |
| 264 |
} |
| 265 |
|
| 266 |
.wpfnl-wc-required-page .wpfnl-wc-required-modal__btn--primary.is-busy { |
| 267 |
pointer-events: none; |
| 268 |
background-color: #6E42D3; |
| 269 |
box-shadow: none; |
| 270 |
opacity: 0.75; |
| 271 |
} |
| 272 |
|
| 273 |
.wpfnl-wc-required-modal__spinner { |
| 274 |
display: none; |
| 275 |
flex: 0 0 14px; |
| 276 |
width: 14px; |
| 277 |
height: 14px; |
| 278 |
border: 2px solid rgba(255, 255, 255, 0.45); |
| 279 |
border-top-color: #fff; |
| 280 |
border-radius: 50%; |
| 281 |
animation: wpfnl-wc-required-spin 0.7s linear infinite; |
| 282 |
} |
| 283 |
|
| 284 |
.wpfnl-wc-required-page .wpfnl-wc-required-modal__btn--primary.is-busy .wpfnl-wc-required-modal__spinner { |
| 285 |
display: block; |
| 286 |
} |
| 287 |
|
| 288 |
@keyframes wpfnl-wc-required-spin { |
| 289 |
0% { transform: rotate(0deg); } |
| 290 |
100% { transform: rotate(360deg); } |
| 291 |
} |
| 292 |
</style> |
| 293 |
|