PluginProbe
WP Directory Kit / 1.5.9
WP Directory Kit v1.5.9
1.5.9 1.5.7 1.5.6 1.5.5 1.5.4 1.5.3 trunk 1.1.0 1.1.6 1.1.8 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.8 All 37 releases
wpdirectorykit / elementor-elements / classes / wdk-tabs.php

wdk-tabs.php in WP Directory Kit 1.5.9, at elementor-elements/classes/wdk-tabs.php

314 lines 9.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Wdk\Elementor\Widgets;
4
5 use Wdk\Elementor\Widgets\WdkElementorBase;
6 use Elementor\Widget_Base;
7 use Elementor\Controls_Manager;
8 use Elementor\Utils;
9 use Elementor\Typography;
10 use Elementor\Editor;
11 use Elementor\Plugin;
12 use Elementor\Repeater;
13 use Elementor\Core\Schemes;
14 use Elementor\Icons_Manager;
15 use Elementor\Group_Control_Typography;
16 use Elementor\Group_Control_Border;
17 use Elementor\Group_Control_Box_Shadow;
18
19 if (!defined('ABSPATH'))
20 exit; // Exit if accessed directly
21
22 /**
23 * @since 1.1.0
24 */
25 class WdkTabs extends WdkElementorBase {
26
27 public function __construct($data = array(), $args = null) {
28
29 \Elementor\Controls_Manager::add_tab(
30 'tab_conf',
31 esc_html__('Settings', 'wpdirectorykit')
32 );
33
34
35 \Elementor\Controls_Manager::add_tab(
36 'tab_layout',
37 esc_html__('Layout', 'wpdirectorykit')
38 );
39
40 \Elementor\Controls_Manager::add_tab(
41 'tab_content',
42 esc_html__('Main', 'wpdirectorykit')
43 );
44
45 if ($this->is_edit_mode_load()) {
46 $this->enqueue_styles_scripts();
47 }
48
49 parent::__construct($data, $args);
50 }
51
52 /**
53 * Retrieve the widget name.
54 *
55 * @since 1.1.0
56 *
57 * @access public
58 *
59 * @return string Widget name.
60 */
61 public function get_name() {
62 return 'wdk-tabs';
63 }
64
65 /**
66 * Retrieve the widget title.
67 *
68 * @since 1.1.0
69 *
70 * @access public
71 *
72 * @return string Widget title.
73 */
74 public function get_title() {
75 return esc_html__('Wdk Switcher', 'wpdirectorykit');
76 }
77
78 /**
79 * Retrieve the widget icon.
80 *
81 * @since 1.1.0
82 *
83 * @access public
84 *
85 * @return string Widget icon.
86 */
87 public function get_icon() {
88 return 'eicon-tabs';
89 }
90
91 /**
92 * Register the widget controls.
93 *
94 * Adds different input fields to allow the user to change and customize the widget settings.
95 *
96 * @since 1.1.0
97 *
98 * @access protected
99 */
100 protected function register_controls() {
101 $this->generate_controls_conf();
102 $this->generate_controls_layout();
103 $this->generate_controls_styles();
104 $this->generate_controls_content();
105
106 $this->insert_pro_message('1');
107 parent::register_controls();
108 }
109
110 /**
111 * Render the widget output on the frontend.
112 *
113 * Written in PHP and used to generate the final HTML.
114 *
115 * @since 1.1.0
116 *
117 * @access protected
118 */
119 protected function render() {
120 parent::render();
121 $this->data['id_element'] = $this->get_id();
122 $this->data['settings'] = $this->get_settings();
123
124
125 $this->data['is_edit_mode'] = false;
126 if(Plugin::$instance->editor->is_edit_mode()) {
127 $this->data['is_edit_mode'] = true;
128 }
129
130 $this->view('wdk-tabs', $this->data, true);
131 }
132
133
134 private function generate_controls_conf() {
135 $this->start_controls_section(
136 'section_config',
137 [
138 'label' => __( 'Configuration', 'wpdirectorykit' ),
139 ]
140 );
141
142
143 $this->add_control(
144 'important_note',
145 [
146 'label' => '',
147 'type' => \Elementor\Controls_Manager::RAW_HTML,
148 /* translators: 1: URL. */
149 'raw' => wdk_sprintf(__( '<a href="%1$s" target="_blank">Have a question how to configure? Check our Guide</a>', 'wpdirectorykit' ), '//wpdirectorykit.com/wp/wpdirectorykit-elementor-element-wdk-tabs'),
150 'content_classes' => 'wdk_elementor_hint',
151 ]
152 );
153
154 $this->add_control(
155 'important_note_2',
156 [
157 'label' => 'Guide:',
158 'type' => \Elementor\Controls_Manager::RAW_HTML,
159 'raw' => '<span style="word-break: break-all;">'.
160 '<br> 1. '.__( 'Create Tabs and set Tab Target', 'wpdirectorykit' ).''.
161 '<br> 2. '.__( 'Tab Target, set in CSS Classes of tabs and also class "wdk_tab_mobile"', 'wpdirectorykit' ).''.
162 '<br> 3. '.__( 'For choose first active tab, add for tab class "active"', 'wpdirectorykit' ).''.
163 '</span>',
164 'content_classes' => 'wdk_elementor_hint',
165 ]
166 );
167
168
169 $repeater = new Repeater();
170 $repeater->start_controls_tabs( 'custom_fields_repeat' );
171
172 $repeater->add_control(
173 'tab_name',
174 [
175 'label' => __( 'Tab Name', 'wpdirectorykit' ),
176 'type' => \Elementor\Controls_Manager::TEXT,
177 'default' => '',
178 ]
179 );
180
181 $repeater->add_control(
182 'tab_target',
183 [
184 'description' => __( 'put name for css of css class, then set this class for tab', 'wpdirectorykit' ),
185 'label' => __( 'Tab Target', 'wpdirectorykit' ),
186 'type' => \Elementor\Controls_Manager::TEXT,
187 'default' => '',
188 ]
189 );
190
191 $repeater->add_control(
192 'tab_css_class',
193 [
194 'label' => __( 'Special Class for Tab', 'wpdirectorykit' ),
195 'type' => \Elementor\Controls_Manager::TEXT,
196 'default' => '',
197 ]
198 );
199
200 $repeater->add_control(
201 'tab_icon',
202 [
203 'label' => esc_html__('Icon', 'wpdirectorykit'),
204 'type' => Controls_Manager::ICONS,
205 'label_block' => true,
206 ]
207 );
208
209 $repeater->end_controls_tabs();
210
211
212 $this->add_control(
213 'tabs',
214 [
215 'type' => Controls_Manager::REPEATER,
216 'fields' => $repeater->get_controls(),
217 'label' => __( 'Field id', 'wpdirectorykit' ),
218 'default' => [
219 [
220 'tab_name' => esc_html__('Tab 1', 'wpdirectorykit'),
221 'tab_target' => 'tab_1',
222 'tab_css_class' => '',
223 'tab_icon' => 'fas fa-list',
224 ],
225 [
226 'tab_name' => esc_html__('Tab 1', 'wpdirectorykit'),
227 'tab_target' => 'tab_1',
228 'tab_css_class' => '',
229 'tab_icon' => 'fas fa-list',
230 ],
231 ],
232 'title_field' => "{{{ tab_name }}}",
233 ]
234 );
235
236 $this->end_controls_section();
237 }
238
239 private function generate_controls_layout() {
240
241 }
242
243 private function generate_controls_styles() {
244
245 $items = [
246 [
247 'key'=>'wrapper',
248 'label'=> esc_html__('Styles Wrapper', 'wpdirectorykit'),
249 'selector'=>'{{WRAPPER}} .wdk-tabs',
250 'options'=> ['margin','border','border_radius','padding','shadow','transition','background_group'],
251 ],
252 [
253 'key'=>'btns',
254 'label'=> esc_html__('Styles Buttons', 'wpdirectorykit'),
255 'selector'=>'{{WRAPPER}} .wdk-tabs .tab',
256 'selector_hover'=>'{{WRAPPER}} .wdk-tabs .tab%1$s',
257 'options'=>['typo','color','border','border_radius','padding','shadow','transition','background_group'],
258 ],
259 ];
260
261 foreach ($items as $item) {
262 $this->start_controls_section(
263 $item['key'].'_section',
264 [
265 'label' => $item['label'],
266 'tab' => 'tab_form_styles',
267 ]
268 );
269
270 if(!empty($item['selector_hide'])) {
271 $this->add_responsive_control(
272 $item['key'].'_hide',
273 [
274 'label' => esc_html__( 'Hide Element', 'wpdirectorykit' ),
275 'type' => Controls_Manager::SWITCHER,
276 'none' => esc_html__( 'Hide', 'wpdirectorykit' ),
277 'block' => esc_html__( 'Show', 'wpdirectorykit' ),
278 'return_value' => 'none',
279 'default' => ($item['key'] == 'field_button_reset' ) ? 'none':'',
280 'selectors' => [
281 $item['selector_hide'] => 'display: {{VALUE}};',
282 ],
283 ]
284 );
285 }
286
287 $selectors = array();
288 if(!empty($item['selector']))
289 $selectors['normal'] = $item['selector'];
290
291 if(!empty($item['selector_hover']))
292 $selectors['hover'] = $item['selector_hover'];
293
294 if(!empty($item['selector_focus']))
295 $selectors['focus'] = $item['selector_focus'];
296
297 $this->generate_renders_tabs($selectors, $item['key'].'_dynamic', $item['options']);
298
299 $this->end_controls_section();
300 /* END special for some elements */
301 }
302
303 }
304
305 private function generate_controls_content() {
306
307 }
308
309 public function enqueue_styles_scripts() {
310 wp_enqueue_style( 'wdk-tabs');
311 wp_enqueue_script( 'wdk-tabs');
312 }
313 }
314