| 1 |
<?php |
| 2 |
/** |
| 3 |
* Login & Register page wrapper for the Ultimate Store Kit builder. |
| 4 |
* |
| 5 |
* Loaded by Builder_Integration::setFrontendTemplate() when a logged-out |
| 6 |
* visitor lands on the My Account page and the site has an enabled |
| 7 |
* `account|login` template. A single template handles both authentication |
| 8 |
* flows because WooCommerce's own form-login.php renders the login and |
| 9 |
* registration forms on the same URL — there is no separate /register/ |
| 10 |
* endpoint in WooCommerce. |
| 11 |
* |
| 12 |
* @package UltimateStoreKit |
| 13 |
* @version 1.0.0 |
| 14 |
*/ |
| 15 |
|
| 16 |
defined('ABSPATH') || exit; |
| 17 |
|
| 18 |
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals -- usk_ / BDTUSK_ / ultimate-store-kit- are this plugin's established public prefixes. Ultimate Store Kit Pro calls into these names, as does third-party integration code, so renaming them is a breaking change. Plugin Check only recognises prefixes derived verbatim from the slug and so reports them as unprefixed. |
| 19 |
|
| 20 |
use UltimateStoreKit\Builder\Builder_Integration; |
| 21 |
|
| 22 |
get_header('shop'); |
| 23 |
|
| 24 |
/** |
| 25 |
* Hook: woocommerce_before_main_content. |
| 26 |
* |
| 27 |
* Standard WC layout hook — themes rely on this to open their wrappers |
| 28 |
* (woocommerce_output_content_wrapper). Keeping it lets the login page |
| 29 |
* inherit the theme's account-area layout instead of escaping it. |
| 30 |
*/ |
| 31 |
do_action('woocommerce_before_main_content'); |
| 32 |
|
| 33 |
// Display WooCommerce notices (login errors, password-reset success, etc.). |
| 34 |
if (function_exists('wc_print_notices')) { |
| 35 |
wc_print_notices(); |
| 36 |
} |
| 37 |
|
| 38 |
$usk_template_id = Builder_Integration::instance()->current_template_id; |
| 39 |
|
| 40 |
$usk_has_content = false; |
| 41 |
if ($usk_template_id && class_exists('Elementor\Plugin')) { |
| 42 |
$usk_elementor_data = get_post_meta($usk_template_id, '_elementor_data', true); |
| 43 |
|
| 44 |
if (is_string($usk_elementor_data)) { |
| 45 |
$decoded = json_decode($usk_elementor_data, true); |
| 46 |
$usk_has_content = is_array($decoded) && ! empty($decoded); |
| 47 |
} elseif (is_array($usk_elementor_data)) { |
| 48 |
$usk_has_content = ! empty($usk_elementor_data); |
| 49 |
} |
| 50 |
} |
| 51 |
|
| 52 |
do_action('woocommerce_before_customer_login_form'); |
| 53 |
|
| 54 |
if ($usk_has_content) { |
| 55 |
echo Elementor\Plugin::instance()->frontend->get_builder_content($usk_template_id, false); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Elementor renders and escapes the builder content itself. |
| 56 |
} else { |
| 57 |
// Fallback to WC's stock login/register form so the page is never empty. |
| 58 |
wc_get_template('myaccount/form-login.php'); |
| 59 |
} |
| 60 |
|
| 61 |
do_action('woocommerce_after_customer_login_form'); |
| 62 |
|
| 63 |
do_action('woocommerce_after_main_content'); |
| 64 |
|
| 65 |
get_footer('shop'); |
| 66 |
|