PluginProbe
WP Directory Kit / 1.3.1
WP Directory Kit v1.3.1
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-icon.php

wdk-field-icon.php in WP Directory Kit 1.3.1, at elementor-elements/classes/wdk-field-icon.php

304 lines 9.4 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 WdkFieldIcon extends WdkElementorBase {
26
27 public $field_id = NULL;
28 public $fields_list = array();
29
30 public function __construct($data = array(), $args = null) {
31
32 \Elementor\Controls_Manager::add_tab(
33 'tab_conf',
34 esc_html__('Settings', 'wpdirectorykit')
35 );
36
37 \Elementor\Controls_Manager::add_tab(
38 'tab_layout',
39 esc_html__('Layout', 'wpdirectorykit')
40 );
41
42 \Elementor\Controls_Manager::add_tab(
43 'tab_content',
44 esc_html__('Main', 'wpdirectorykit')
45 );
46
47 add_action( 'elementor/editor/after_enqueue_styles', function()
48 {
49 wp_add_inline_style( 'elementor-editor', '.elementor-control-content select option[value*="section"]{color:#fff;background:#000}');
50 } );
51
52 if ($this->is_edit_mode_load()) {
53 $this->enqueue_styles_scripts();
54 }
55
56 parent::__construct($data, $args);
57
58 }
59
60 /**
61 * Retrieve the list of categories the widget belongs to.
62 *
63 * Used to determine where to display the widget in the editor.
64 *
65 * Note that currently Elementor supports only one category.
66 * When multiple categories passed, Elementor uses the first one.
67 *
68 * @since 1.1.0
69 *
70 * @access public
71 *
72 * @return array Widget categories.
73 */
74 public function get_categories() {
75 return [ 'wdk-elementor-listing-preview' ];
76 }
77
78 /**
79 * Retrieve the widget name.
80 *
81 * @since 1.1.0
82 *
83 * @access public
84 *
85 * @return string Widget name.
86 */
87 public function get_name() {
88 return 'wdk-field-icon';
89 }
90
91 /**
92 * Retrieve the widget title.
93 *
94 * @since 1.1.0
95 *
96 * @access public
97 *
98 * @return string Widget title.
99 */
100 public function get_title() {
101 return esc_html__('Wdk Field Icon', 'wpdirectorykit');
102 }
103
104 /**
105 * Retrieve the widget icon.
106 *
107 * @since 1.1.0
108 *
109 * @access public
110 *
111 * @return string Widget icon.
112 */
113 public function get_icon() {
114 return 'eicon-image-bold';
115 }
116
117 /**
118 * Register the widget controls.
119 *
120 * Adds different input fields to allow the user to change and customize the widget settings.
121 *
122 * @since 1.1.0
123 *
124 * @access protected
125 */
126 protected function register_controls() {
127 $this->generate_controls_conf();
128 $this->generate_controls_layout();
129 $this->generate_controls_styles();
130 $this->generate_controls_content();
131
132 $this->insert_pro_message('1');
133 parent::register_controls();
134 }
135
136 /**
137 * Render the widget output on the frontend.
138 *
139 * Written in PHP and used to generate the final HTML.
140 *
141 * @since 1.1.0
142 *
143 * @access protected
144 */
145 protected function render() {
146 parent::render();
147 global $wdk_listing_id;
148
149 $this->data['id_element'] = $this->get_id();
150 $this->data['settings'] = $this->get_settings();
151
152 $this->data['field_icon'] = '';
153 if(!empty($this->data['settings']['field_id'])) {
154 if(strpos($this->data['settings']['field_id'],'__') !== FALSE){
155 $this->data['settings']['field_id'] = substr($this->data['settings']['field_id'], strpos($this->data['settings']['field_id'],'__')+2);
156 }
157 if(wdk_field_option ($this->data['settings']['field_id'], 'icon_id'))
158 $this->data['field_icon'] = wdk_field_option ($this->data['settings']['field_id'], 'icon_id');
159 }
160
161 $this->data['is_edit_mode']= false;
162 if(Plugin::$instance->editor->is_edit_mode()){
163 $this->data['is_edit_mode']= true;
164 } else {
165 /* return false if no content */
166 if(wdk_field_option ($this->data['settings']['field_id'], 'icon_id') == '')
167 return false;
168 }
169
170 echo $this->view('wdk-field-icon', $this->data);
171 }
172
173
174 private function generate_controls_conf() {
175 $this->start_controls_section(
176 'tab_conf_main_section',
177 [
178 'label' => esc_html__('Main', 'wpdirectorykit'),
179 'tab' => '1',
180 ]
181 );
182
183 $fields_data = wdk_cached_field_get();
184 $fields_list = array('' => esc_html__('Not Selected', 'wpdirectorykit'));
185 $order_i = 0;
186
187 $fields_list [(++$order_i).'__section'] = esc_html__('-- Section Custom fields --', 'wpdirectorykit');
188 $fields_list [(++$order_i).'__post_title'] = esc_html__('WP Title', 'wpdirectorykit');
189 $fields_list [(++$order_i).'__post_content'] = esc_html__('WP Content', 'wpdirectorykit');
190 $fields_list [(++$order_i).'__address'] = esc_html__('Address', 'wpdirectorykit');
191 $fields_list [(++$order_i).'__category_id'] = esc_html__('Category', 'wpdirectorykit');
192 $fields_list [(++$order_i).'__location_id'] = esc_html__('Location', 'wpdirectorykit');
193
194 foreach($fields_data as $field)
195 {
196 if(wmvc_show_data('field_type', $field) == 'SECTION') {
197 $fields_list [(++$order_i).'section__'.wmvc_show_data('idfield', $field)] = '-- '.esc_html__('Section', 'wpdirectorykit').' '.wmvc_show_data('field_label', $field).' --';
198 } else {
199 $fields_list[(++$order_i).'__'.wmvc_show_data('idfield', $field)] = '#'.wmvc_show_data('idfield', $field).' '.wmvc_show_data('field_label', $field).'['.wmvc_show_data('field_type', $field).']';
200 }
201 }
202 $this->add_control(
203 'field_id',
204 [
205 'label' => __( 'Field id', 'wpdirectorykit' ),
206 'type' => \Elementor\Controls_Manager::SELECT2,
207 'default' => '',
208 'options' => $fields_list,
209 'separator' => 'after',
210 ]
211 );
212
213 $this->end_controls_section();
214
215 }
216
217 private function generate_controls_layout() {
218 }
219
220
221 private function generate_controls_styles() {
222 $this->start_controls_section(
223 'field_group',
224 [
225 'label' => esc_html__('Field icon', 'wpdirectorykit'),
226 'tab' => Controls_Manager::TAB_STYLE,
227 ]
228 );
229
230 $this->add_responsive_control (
231 'field_group_icon_max_heigth',
232 [
233 'label' => esc_html__('Max Height', 'wpdirectorykit'),
234 'type' => Controls_Manager::SLIDER,
235 'range' => [
236 'px' => [
237 'min' => 10,
238 'max' => 1500,
239 ],
240 'vw' => [
241 'min' => 0,
242 'max' => 100,
243 ],
244 '%' => [
245 'min' => 0,
246 'max' => 100,
247 ],
248 ],
249 'size_units' => [ 'px', 'vw','%' ],
250 'default' => [
251 'unit' => 'px',
252 'size' => 18,
253 ],
254 'selectors' => [
255 '{{WRAPPER}} .wdk-field-icon' => 'max-width: {{SIZE}}{{UNIT}}',
256 ],
257 ]
258 );
259
260
261 $this->add_responsive_control (
262 'field_group_icon_max_width',
263 [
264 'label' => esc_html__('Max Width', 'wpdirectorykit'),
265 'type' => Controls_Manager::SLIDER,
266 'range' => [
267 'px' => [
268 'min' => 10,
269 'max' => 1500,
270 ],
271 'vw' => [
272 'min' => 0,
273 'max' => 100,
274 ],
275 '%' => [
276 'min' => 0,
277 'max' => 100,
278 ],
279 ],
280 'size_units' => [ 'px', 'vw','%' ],
281 'default' => [
282 'unit' => 'px',
283 'size' => 18,
284 ],
285 'selectors' => [
286 '{{WRAPPER}} .wdk-field-icon' => 'max-width: {{SIZE}}{{UNIT}}',
287 ],
288 ]
289 );
290
291 $this->end_controls_section();
292 /* END special for some elements */
293 }
294
295
296 private function generate_controls_content() {
297
298 }
299
300 public function enqueue_styles_scripts() {
301
302 }
303 }
304