PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.6
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.6
1.6.6 1.6.5 1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 All 49 releases
← All changes | app/Hooks/Handlers/ShortCodes/CustomerProfileHandler.php +30 -2 1.6.4 → 1.6.6 View file →
@@ -6,8 +6,12 @@
6 6 use FluentCart\Api\PaymentMethods;
7 7 use FluentCart\Api\Resource\CustomerResource;
8 8 use FluentCart\Api\StoreSettings;
9 9 use FluentCart\App\App;
10 +use FluentCart\App\Services\CustomerIdentity\EmailClaimPortal;
11 +use FluentCart\App\Services\CustomerIdentity\CustomerRecoveryService;
12 +use FluentCart\App\Services\CustomerIdentity\EmailClaimService;
13 +use FluentCart\App\Services\CustomerIdentity\EmailVerificationService;
10 14 use FluentCart\App\Helpers\CurrenciesHelper;
11 15 use FluentCart\App\Helpers\Helper;
12 16 use FluentCart\App\Models\Subscription;
13 17 use FluentCart\App\Modules\Templating\AssetLoader;
@@ -12,8 +16,9 @@
12 16 use FluentCart\App\Models\Subscription;
13 17 use FluentCart\App\Modules\Templating\AssetLoader;
14 18 use FluentCart\App\Services\Renderer\CheckoutFieldsSchema;
15 19 use FluentCart\App\Services\TemplateService;
20 +use FluentCart\App\Services\DateTime\DayjsFormatter;
16 21 use FluentCart\App\Services\Translations\TransStrings;
17 22 use FluentCart\App\Vite;
18 23 use FluentCart\Framework\Support\Arr;
19 24 use FluentCart\Framework\Support\Str;
@@ -38,8 +43,18 @@
38 43 public static function register()
39 44 {
40 45 parent::register();
41 46
47 + add_action(CustomerRecoveryService::HOOK, [CustomerRecoveryService::class, 'run']);
48 +
49 + add_action('template_redirect', function () {
50 + $redirect = EmailClaimPortal::handleSubmission();
51 + if ($redirect) {
52 + wp_safe_redirect($redirect);
53 + exit;
54 + }
55 + });
56 +
42 57 // Add wildcard customer profile pages
43 58 // add a custom permalink endpoint
44 59 add_action('init', function () {
45 60 $pageSlug = (new StoreSettings())->getCustomerDashboardPageSlug();
@@ -64,8 +79,13 @@
64 79 $redirectUrl = $this->resolveLoginRedirectUrl(
65 80 (new StoreSettings())->getCustomerProfilePage()
66 81 );
67 82
83 + $claimToken = Arr::get($_GET, EmailClaimService::QUERY_TOKEN, '');
84 + if (is_string($claimToken) && $claimToken !== '') {
85 + $redirectUrl = add_query_arg(EmailClaimService::QUERY_TOKEN, sanitize_text_field(wp_unslash($claimToken)), (new StoreSettings())->getCustomerProfilePage());
86 + }
87 +
68 88 if (defined('FLUENT_AUTH_VERSION') && (new \FluentAuth\App\Hooks\Handlers\CustomAuthHandler())->isEnabled()) {
69 89 ?>
70 90 <div style="max-width: 600px; margin: 0 auto; padding: 20px; border: 1px solid #CBD5E0; border-radius: 8px;" class="fct_auth_wrap">
71 91 <h4><?php echo esc_html__('Please log in to access your customer portal.', 'fluent-cart'); ?></h4>
@@ -127,8 +147,15 @@
127 147 Vite::enqueueStyle( 'fluent-cart-customer-profile-global',
128 148 'public/customer-profile/style/customer-profile-global.scss',
129 149 );
130 150
151 + // Gate before custom endpoint callbacks or the dashboard load customer data.
152 + $verificationNotice = EmailClaimPortal::render();
153 + if (EmailVerificationService::isRequired(get_current_user_id())) {
154 + echo $verificationNotice; // @phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- escaped in the view
155 + return;
156 + }
157 +
131 158 $customEndpointContent = $this->maybeCustomEndpointContent();
132 159
133 160 if(!$customEndpointContent) {
134 161 (new static())->enqueueStyles();
@@ -135,9 +162,10 @@
135 162 }
136 163
137 164 $colors = self::generateCssColorVariables(Arr::get($this->shortCodeAttributes, 'colors', ''));
138 165 add_action('fluent_cart/customer_menu', array($this, 'renderCustomerMenu'));
139 - add_action('fluent_cart/customer_app', function () use ($customEndpointContent) {
166 + add_action('fluent_cart/customer_app', function () use ($customEndpointContent, $verificationNotice) {
167 + echo $verificationNotice; // @phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- escaped in the view
140 168 if($customEndpointContent) {
141 169 echo $customEndpointContent; // @phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
142 170 } else {
143 171 AssetLoader::loadCustomerDashboardAssets();
@@ -403,9 +431,9 @@
403 431 'first_name' => $currentCustomer ? $currentCustomer->first_name : '',
404 432 'last_name' => $currentCustomer ? $currentCustomer->last_name : '',
405 433 ],
406 434 'logout_url' => wp_logout_url(home_url()),
407 - 'datei18' => TransStrings::dateTimeStrings(),
435 + 'datei18' => DayjsFormatter::localizedStrings(),
408 436 'el_strings' => TransStrings::elStrings(),
409 437 'wp_locale' => get_locale(),
410 438 'is_company_name_enabled' => CheckoutFieldsSchema::isCompanyNameEnabled(),
411 439 'is_company_name_required' => CheckoutFieldsSchema::isCompanyNameRequired(),