PluginProbe
King Addons for Elementor – 80+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce, Mega Menu, Popup Builder / 51.1.49
King Addons for Elementor – 80+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce, Mega Menu, Popup Builder v51.1.49
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 51.1.46 51.1.47 51.1.49 All 37 releases
king-addons / includes / widgets / Global_Section_Container / Global_Section_Container.php

Global_Section_Container.php in King Addons for Elementor – 80+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce, Mega Menu, Popup Builder 51.1.49, at includes/widgets/Global_Section_Container/Global_Section_Container.php

139 lines 4.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php /** @noinspection PhpUnused, DuplicatedCode, SpellCheckingInspection */
2
3 namespace King_Addons;
4
5 use DOMDocument;
6 use Elementor\Controls_Manager;
7 use Elementor\Plugin;
8 use Elementor\Widget_Base;
9
10 if (!defined('ABSPATH')) {
11 exit; // Exit if accessed directly.
12 }
13
14
15
16 class Global_Section_Container extends Widget_Base
17 {
18
19
20 public function get_name(): string
21 {
22 return 'king-addons-global-section-container';
23 }
24
25 public function get_title(): string
26 {
27 return esc_html__('Global Section & Container', 'king-addons');
28 }
29
30 public function get_icon(): string
31 {
32 return 'king-addons-icon king-addons-global-section-container';
33 }
34
35 public function get_categories(): array
36 {
37 return ['king-addons'];
38 }
39
40 public function get_keywords(): array
41 {
42 return ['content', 'template', 'templates', 'container', 'section', 'column', 'widget', 'module', 'connect',
43 'global widget', 'global', 'reusable', 'across', 'multiple', 'multi', 'page', 'pages',
44 'king', 'addons', 'kingaddons', 'king-addons', 'off canvas', 'embed'];
45 }
46
47 public function get_custom_help_url()
48 {
49 return 'mailto:bug@kingaddons.com?subject=Bug Report - King Addons&body=Please describe the issue';
50 }
51
52 protected function register_controls(): void
53 {
54 $this->start_controls_section(
55 'kng_global_section_container_general',
56 [
57 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('General', 'king-addons'),
58 ]
59 );
60
61 $this->add_control(
62 'kng_global_section_container_template',
63 [
64 'label' => esc_html__('Select Template', 'king-addons'),
65 'type' => 'king-addons-ajax-select2',
66 'options' => 'ajaxselect2/getElementorTemplates',
67 'label_block' => true,
68 ]
69 );
70
71 $this->add_control(
72 'kng_global_section_container_alert_info',
73 [
74 'type' => Controls_Manager::ALERT,
75 'alert_type' => 'info',
76 'heading' => esc_html__('Note for Entrance Animations in Editor mode', 'king-addons'),
77 'content' => esc_html__('If any content within the global template has Entrance Animations configured in the Advanced -> Motion Effects tab, it may not be displayed after selecting the template in Editor mode (Elementor editor). This occurs because the Entrance Animations are triggered immediately after the page loads. To address this issue, try saving your changes and reloading this editor page; following this, the global template should fully appear in most cases. The problem does not affect the appearance of the live website and is only present in the editor.', 'king-addons'),
78 ]
79 );
80
81
82
83
84 $this->end_controls_section();
85
86
87 }
88
89 public function getOffCanvasTemplate($template_id): ?string
90 {
91 if (empty($template_id)) {
92 return null;
93 }
94
95 $type = get_post_meta(get_the_ID(), '_king_addons_template_type', true);
96 $has_css = 'internal' === get_option('elementor_css_print_method') || '' !== $type;
97
98 return Plugin::instance()->frontend->get_builder_content_for_display($template_id, $has_css);
99 }
100
101 protected function render(): void
102 {
103 $settings = $this->get_settings_for_display();
104 if (!empty($settings['kng_global_section_container_template'])) {
105 $html = $this->getOffCanvasTemplate(esc_html($settings['kng_global_section_container_template']));
106 $dom = new DOMDocument;
107 libxml_use_internal_errors(true); // Disable libxml errors
108 $dom->loadHTML($html);
109 libxml_clear_errors();
110
111 $tags = [];
112 $this->getTagsAndAttributes($dom->documentElement, $tags);
113
114 echo wp_kses($html, $tags);
115 } else {
116 echo '<p>' . esc_html__('Please select a template', 'king-addons') . '</p>';
117 }
118 }
119
120 public function getTagsAndAttributes($node, &$tags): void
121 {
122 if ($node->nodeType == XML_ELEMENT_NODE) {
123 $tagName = $node->nodeName;
124 if (!isset($tags[$tagName])) {
125 $tags[$tagName] = [];
126 }
127
128 foreach ($node->attributes as $attr) {
129 if (!isset($tags[$tagName][$attr->nodeName])) {
130 $tags[$tagName][$attr->nodeName] = true;
131 }
132 }
133 }
134
135 foreach ($node->childNodes as $child) {
136 $this->getTagsAndAttributes($child, $tags);
137 }
138 }
139 }