PluginProbe
King Addons for Elementor – 100+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce Builder, Mega Menu, Popup Builder / 51.1.63
King Addons for Elementor – 100+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce Builder, Mega Menu, Popup Builder v51.1.63
51.1.86 51.1.84 51.1.85 51.1.83 51.1.82 51.1.81 51.1.79 51.1.78 51.1.77 51.1.76 51.1.74 51.1.75 51.1.65 51.1.64 51.1.63 trunk 51.1.14 51.1.2 51.1.35 51.1.36 51.1.37 51.1.38 51.1.39 51.1.44 51.1.45 All 40 releases
king-addons / includes / helpers / Woo_Builder / Abstract_My_Account_Widget.php

Abstract_My_Account_Widget.php in King Addons for Elementor – 100+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce Builder, Mega Menu, Popup Builder 51.1.63, at includes/helpers/Woo_Builder/Abstract_My_Account_Widget.php

93 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Base class for My Account builder widgets.
4 *
5 * @package King_Addons
6 */
7
8 namespace King_Addons;
9
10 use Elementor\Widget_Base;
11 use King_Addons\Woo_Builder\Context as Woo_Context;
12
13 if (!defined('ABSPATH')) {
14 exit;
15 }
16
17 /**
18 * Provides my-account context utilities.
19 */
20 abstract class Abstract_My_Account_Widget extends Widget_Base
21 {
22 /**
23 * Check if we should render the widget.
24 * Returns true if in editor editing my_account template or on actual my account page.
25 *
26 * @return bool
27 */
28 protected function should_render(): bool
29 {
30 // In editor mode editing my_account template
31 if (class_exists('King_Addons\\Woo_Builder\\Context') && Woo_Context::is_editing_template_type('my_account')) {
32 return true;
33 }
34
35 // On actual my account page
36 if (function_exists('is_account_page') && is_account_page()) {
37 return true;
38 }
39
40 return false;
41 }
42
43 /**
44 * Render placeholder when my account context is missing.
45 *
46 * @return void
47 */
48 protected function render_missing_account_notice(): void
49 {
50 if (!class_exists('\Elementor\Plugin') || !\Elementor\Plugin::$instance->editor->is_edit_mode()) {
51 return;
52 }
53
54 // Check if we're editing a My Account template
55 if (class_exists('King_Addons\\Woo_Builder\\Context') && Woo_Context::is_editing_template_type('my_account')) {
56 // Don't show notice - we're in the right template type
57 return;
58 }
59
60 echo '<div class="king-addons-woo-builder-notice">' . esc_html__('This widget works only on the WooCommerce My Account page.', 'king-addons') . '</div>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
61 }
62
63 /**
64 * Render login form if user is not logged in.
65 * In editor mode, shows a placeholder instead.
66 *
67 * @return bool True when login form rendered.
68 */
69 protected function maybe_render_login_form(): bool
70 {
71 // In editor mode, don't show login form - show preview content
72 if (class_exists('King_Addons\\Woo_Builder\\Context') && Woo_Context::is_editor()) {
73 return false;
74 }
75
76 if (is_user_logged_in()) {
77 return false;
78 }
79
80 echo '<div class="king-addons-my-account-login">';
81 woocommerce_login_form(['redirect' => wc_get_page_permalink('myaccount')]);
82 echo '</div>';
83 return true;
84 }
85 }
86
87
88
89
90
91
92
93