PluginProbe
King Addons for Elementor – 80+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce, Mega Menu, Popup Builder / 51.1.65
King Addons for Elementor – 80+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce, Mega Menu, Popup Builder v51.1.65
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 / Table_Builder / Table_Builder.php

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

174 lines 4.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace King_Addons;
4
5 use Elementor\Widget_Base;
6 use Elementor\Controls_Manager;
7
8 if (!defined('ABSPATH')) {
9 exit;
10 }
11
12 class Table_Builder extends Widget_Base
13 {
14 public function get_name()
15 {
16 return 'king-addons-table-builder';
17 }
18
19 public function get_title()
20 {
21 return esc_html__('KNG Table', 'king-addons');
22 }
23
24 public function get_icon()
25 {
26 return 'king-addons-icon king-addons-data-table';
27 }
28
29 public function get_categories()
30 {
31 return ['king-addons'];
32 }
33
34 public function get_keywords()
35 {
36 return ['table', 'data table', 'builder', 'kng table', 'interactive table'];
37 }
38
39 public function get_custom_help_url()
40 {
41 return 'mailto:bug@kingaddons.com?subject=Bug Report - King Addons&body=Please describe the issue';
42 }
43
44 protected function register_controls(): void
45 {
46 $this->start_controls_section(
47 'section_content',
48 [
49 'label' => esc_html__('Table', 'king-addons'),
50 ]
51 );
52
53 $this->add_control(
54 'table_id',
55 [
56 'label' => esc_html__('Select Table', 'king-addons'),
57 'type' => Controls_Manager::SELECT,
58 'options' => $this->get_table_options(),
59 'default' => '',
60 ]
61 );
62
63 $this->add_control(
64 'theme_override',
65 [
66 'label' => esc_html__('Theme Override', 'king-addons'),
67 'type' => Controls_Manager::SELECT,
68 'options' => [
69 '' => esc_html__('Default', 'king-addons'),
70 'dark' => esc_html__('Dark', 'king-addons'),
71 'light' => esc_html__('Light', 'king-addons'),
72 ],
73 'default' => '',
74 ]
75 );
76
77 $this->add_control(
78 'show_search',
79 [
80 'label' => esc_html__('Show Search', 'king-addons'),
81 'type' => Controls_Manager::SWITCHER,
82 'default' => 'yes',
83 ]
84 );
85
86 $this->add_control(
87 'show_pagination',
88 [
89 'label' => esc_html__('Show Pagination', 'king-addons'),
90 'type' => Controls_Manager::SWITCHER,
91 'default' => 'yes',
92 ]
93 );
94
95 $this->add_control(
96 'enable_sort',
97 [
98 'label' => esc_html__('Enable Sorting', 'king-addons'),
99 'type' => Controls_Manager::SWITCHER,
100 'default' => 'yes',
101 ]
102 );
103
104 $this->end_controls_section();
105
106 Core::renderProFeaturesSection($this, '', Controls_Manager::RAW_HTML, 'table-builder', [
107 'Advanced filters and column types',
108 'Conditional formatting and badges',
109 'Inline charts and expandable rows',
110 'Google Sheets sync and JSON/PDF export',
111 'Analytics and role-based access'
112 ]);
113 }
114
115 private function get_table_options(): array
116 {
117 $post_type = class_exists('King_Addons\Data_Table_Builder') ? Data_Table_Builder::POST_TYPE : 'kng_table';
118 $tables = get_posts([
119 'post_type' => $post_type,
120 'post_status' => 'publish',
121 'posts_per_page' => 50,
122 'orderby' => 'title',
123 'order' => 'ASC',
124 ]);
125
126 $options = [
127 '' => esc_html__('Select a table', 'king-addons'),
128 ];
129
130 foreach ($tables as $table) {
131 $options[$table->ID] = $table->post_title;
132 }
133
134 return $options;
135 }
136
137 protected function render(): void
138 {
139 $settings = $this->get_settings_for_display();
140 $table_id = isset($settings['table_id']) ? absint($settings['table_id']) : 0;
141
142 if ($table_id === 0) {
143 $link = admin_url('admin.php?page=king-addons-table-builder&view=add');
144 echo '<div class="kng-table-empty">';
145 echo esc_html__('Select a table in the widget settings or create one in Table Builder.', 'king-addons');
146 echo ' <a href="' . esc_url($link) . '" target="_blank" rel="noopener">' . esc_html__('Create Table', 'king-addons') . '</a>';
147 echo '</div>';
148 return;
149 }
150
151 $shortcode = '[kng_table id="' . $table_id . '"';
152
153 if (!empty($settings['theme_override'])) {
154 $shortcode .= ' theme="' . esc_attr($settings['theme_override']) . '"';
155 }
156
157 if ($settings['show_search'] !== 'yes') {
158 $shortcode .= ' search="false"';
159 }
160
161 if ($settings['show_pagination'] !== 'yes') {
162 $shortcode .= ' pagination="false"';
163 }
164
165 if ($settings['enable_sort'] !== 'yes') {
166 $shortcode .= ' sort="false"';
167 }
168
169 $shortcode .= ']';
170
171 echo do_shortcode($shortcode);
172 }
173 }
174