PluginProbe
WP Directory Kit / 1.2.3
WP Directory Kit v1.2.3
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 1.4.0 1.4.1 All 35 releases
wpdirectorykit / elementor-elements / classes / wdk-field-files-list.php

wdk-field-files-list.php in WP Directory Kit 1.2.3, at elementor-elements/classes/wdk-field-files-list.php

358 lines 11.3 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 WdkFieldFilesList 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 \Elementor\Controls_Manager::add_tab(
35 'tab_layout',
36 esc_html__('Layout', 'wpdirectorykit')
37 );
38
39 \Elementor\Controls_Manager::add_tab(
40 'tab_content',
41 esc_html__('Main', 'wpdirectorykit')
42 );
43
44 if ($this->is_edit_mode_load()) {
45 $this->enqueue_styles_scripts();
46 }
47
48 parent::__construct($data, $args);
49
50 }
51
52 /**
53 * Retrieve the list of categories the widget belongs to.
54 *
55 * Used to determine where to display the widget in the editor.
56 *
57 * Note that currently Elementor supports only one category.
58 * When multiple categories passed, Elementor uses the first one.
59 *
60 * @since 1.1.0
61 *
62 * @access public
63 *
64 * @return array Widget categories.
65 */
66 public function get_categories() {
67 return [ 'wdk-elementor-listing-preview' ];
68 }
69
70 /**
71 * Retrieve the widget name.
72 *
73 * @since 1.1.0
74 *
75 * @access public
76 *
77 * @return string Widget name.
78 */
79 public function get_name() {
80 return 'wdk-field-files-list';
81 }
82
83 /**
84 * Retrieve the widget title.
85 *
86 * @since 1.1.0
87 *
88 * @access public
89 *
90 * @return string Widget title.
91 */
92 public function get_title() {
93 return esc_html__('Wdk Listing Plans And Documents List', 'wpdirectorykit');
94 }
95
96 /**
97 * Retrieve the widget icon.
98 *
99 * @since 1.1.0
100 *
101 * @access public
102 *
103 * @return string Widget icon.
104 */
105 public function get_icon() {
106 return 'eicon-editor-list-ul';
107 }
108
109 /**
110 * Register the widget controls.
111 *
112 * Adds different input fields to allow the user to change and customize the widget settings.
113 *
114 * @since 1.1.0
115 *
116 * @access protected
117 */
118 protected function register_controls() {
119 $this->generate_controls_conf();
120 $this->generate_controls_layout();
121 $this->generate_controls_styles();
122 $this->generate_controls_content();
123
124 $this->insert_pro_message('1');
125 parent::register_controls();
126 }
127
128 /**
129 * Render the widget output on the frontend.
130 *
131 * Written in PHP and used to generate the final HTML.
132 *
133 * @since 1.1.0
134 *
135 * @access protected
136 */
137 protected function render() {
138 parent::render();
139 global $wdk_listing_id;
140 /* test data */
141 $this->data['id_element'] = $this->get_id();
142 $this->data['settings'] = $this->get_settings();
143
144 $this->data['images'] = array();
145
146 if(!Plugin::$instance->editor->is_edit_mode()) {
147 $this->data['images'] = wdk_listing_images_data (wdk_field_value('listing_plans_documents', $wdk_listing_id), 'full', '', $this->data['settings']['extension_list']);
148 $this->data['images'] = array_slice($this->data['images'], ($this->data['settings']['offset_images']-1), $this->data['settings']['limit_images']);
149 } else {
150 $this->data['images'] = array_fill(0, $this->data['settings']['limit_images'], wdk_placeholder_image_src());
151 }
152
153 $this->data['is_edit_mode']= false;
154 if(Plugin::$instance->editor->is_edit_mode()) {
155 $this->data['is_edit_mode']= true;
156 } else {
157 /* return false if no content */
158 }
159
160 echo $this->view('wdk-field-files-list', $this->data);
161 }
162
163
164 private function generate_controls_conf() {
165 $this->start_controls_section(
166 'tab_conf_main_section',
167 [
168 'label' => esc_html__('Main', 'wpdirectorykit'),
169 'tab' => '1',
170 ]
171 );
172
173 $this->add_control(
174 'extension_list',
175 [
176 'label' => __( 'Show Only Files By Extension', 'wpdirectorykit' ),
177 'description' => __( 'Put file`s extension, if you want show only these files, separate like bmp,xml,pdf,jpg. Responsive only on live version', 'wpdirectorykit' ),
178 'type' => \Elementor\Controls_Manager::TEXTAREA,
179 ]
180 );
181
182 $this->add_control(
183 'limit_images',
184 [
185 'label' => __( 'Limit Files', 'wpdirectorykit' ),
186 'type' => \Elementor\Controls_Manager::NUMBER,
187 'min' => 1,
188 'max' => 100,
189 'step' => 1,
190 'default' => 50,
191 ]
192 );
193
194 $this->add_control(
195 'offset_images',
196 [
197 'label' => __( 'Offset File', 'wpdirectorykit' ),
198 'type' => \Elementor\Controls_Manager::NUMBER,
199 'min' => 1,
200 'max' => 100,
201 'step' => 1,
202 'default' => 1,
203 ]
204 );
205
206 $this->end_controls_section();
207
208 }
209
210 private function generate_controls_layout() {
211 }
212
213 private function generate_controls_styles() {
214 /* files */
215 if(true) {
216
217 $this->start_controls_section(
218 'files_section',
219 [
220 'label' => esc_html__('Files List', 'wpdirectorykit'),
221 'tab' => Controls_Manager::TAB_STYLE,
222 ]
223 );
224
225 $this->add_control(
226 'files_section_box_header',
227 [
228 'label' => __('Container', 'wpdirectorykit'),
229 'type' => \Elementor\Controls_Manager::HEADING,
230 ]
231 );
232
233 $selectors = array(
234 'normal' => '{{WRAPPER}} .wdk-field-files-list .files-row ul.files',
235 );
236
237 $this->generate_renders_tabs($selectors, 'files_section_bo_dynamic', ['background','border','border_radius','padding','margin','shadow','transition' ]);
238
239 $this->add_control(
240 'files_section_li',
241 [
242 'label' => __('List Items', 'wpdirectorykit'),
243 'type' => \Elementor\Controls_Manager::HEADING,
244 ]
245 );
246
247 $this->add_control(
248 'files_section_li_hr',
249 [
250 'type' => \Elementor\Controls_Manager::DIVIDER,
251 ]
252 );
253
254 $this->add_control(
255 'files_section_space',
256 [
257 'label' => __('Vertical Space', 'wpdirectorykit'),
258 'type' => Controls_Manager::SLIDER,
259 'size_units' => ['px'],
260 'range' => [
261 'px' => [
262 'min' => 0,
263 'max' => 250,
264 'step' => 1,
265 ],
266 ],
267 'selectors' => [
268 '{{WRAPPER}} .wdk-field-files-list .files-row ul.files li:not(:last-child)' => 'margin-bottom: {{SIZE}}{{UNIT}};',
269 ],
270 ]
271 );
272
273 $selectors = array(
274 'normal' => '{{WRAPPER}} .wdk-field-files-list .files-row ul.files li',
275 );
276
277 $this->generate_renders_tabs($selectors, 'files_section_item_dynamic', ['align','background','border','border_radius','padding','shadow','transition' ]);
278
279 $this->add_control(
280 'files_section_hr',
281 [
282 'type' => \Elementor\Controls_Manager::DIVIDER,
283 ]
284 );
285
286 $this->add_control(
287 'files_section_items',
288 [
289 'label' => __('More Styles', 'wpdirectorykit'),
290 'type' => \Elementor\Controls_Manager::HEADING,
291 ]
292 );
293
294 $items = [
295 [
296 'key'=>'files_icon',
297 'label'=> esc_html__('Icon', 'wpdirectorykit'),
298 'selector'=>'{{WRAPPER}} .wdk-field-files-list .files-row .list-item a .wdk-listing-file-icon',
299 'selector_hover'=>'{{WRAPPER}} .wdk-field-files-list .files-row .list-item%1$s a .wdk-listing-file-icon',
300 'options'=> ['margin','background','border','border_radius','padding','shadow','transition','image_size_control','css_filters','hover_animation'],
301 ],
302 [
303 'key'=>'files_caption',
304 'label'=> esc_html__('Caption', 'wpdirectorykit'),
305 'selector'=>'{{WRAPPER}} .wdk-field-files-list .files-row .list-item a',
306 'selector_hover'=>'{{WRAPPER}} .wdk-field-files-list .files-row .list-item a%1$s',
307 'options'=> ['margin','align','typo','color','background','border','border_radius','padding','shadow','transition'],
308 ],
309 ];
310
311 foreach ($items as $item) {
312 $this->add_control(
313 $item['key'].'_header',
314 [
315 'label' => $item['label'],
316 'type' => \Elementor\Controls_Manager::HEADING,
317 ]
318 );
319
320 if($item['key'] == 'files_icon')
321 $this->add_responsive_control(
322 $item['key'].'_hide',
323 [
324 'label' => esc_html__( 'Hide Element', 'wpdirectorykit' ),
325 'type' => Controls_Manager::SWITCHER,
326 'none' => esc_html__( 'Hide', 'wpdirectorykit' ),
327 'block' => esc_html__( 'Show', 'wpdirectorykit' ),
328 'return_value' => 'none',
329 'default' => '',
330 'selectors' => [
331 $item['selector'] => 'display: {{VALUE}};',
332 ],
333 ]
334 );
335
336 $selectors = array(
337 'normal' => $item['selector'],
338 'hover'=>$item['selector_hover'],
339 );
340 $this->generate_renders_tabs($selectors, $item['key'].'_dynamic', $item['options']);
341 }
342
343 $this->end_controls_section();
344 }
345 }
346
347 private function generate_controls_content() {
348
349 }
350
351 public function enqueue_styles_scripts() {
352 wp_enqueue_style('wdk-field-files-list');
353 wp_enqueue_style('blueimp-gallery');
354 wp_enqueue_script('blueimp-gallery');
355 wp_enqueue_script('wdk-blueimp-gallery');
356 }
357 }
358