PluginProbe
WP Directory Kit / 1.2.7
WP Directory Kit v1.2.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 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.2.7, at elementor-elements/classes/wdk-field-icon.php

306 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 $WMVC = &wdk_get_instance();
184 $WMVC->model('field_m');
185 $fields_data = $WMVC->field_m->get();
186 $fields_list = array('' => esc_html__('Not Selected', 'wpdirectorykit'));
187 $order_i = 0;
188
189 $fields_list [(++$order_i).'__section'] = esc_html__('-- Section Custom fields --', 'wpdirectorykit');
190 $fields_list [(++$order_i).'__post_title'] = esc_html__('WP Title', 'wpdirectorykit');
191 $fields_list [(++$order_i).'__post_content'] = esc_html__('WP Content', 'wpdirectorykit');
192 $fields_list [(++$order_i).'__address'] = esc_html__('Address', 'wpdirectorykit');
193 $fields_list [(++$order_i).'__category_id'] = esc_html__('Category', 'wpdirectorykit');
194 $fields_list [(++$order_i).'__location_id'] = esc_html__('Location', 'wpdirectorykit');
195
196 foreach($fields_data as $field)
197 {
198 if(wmvc_show_data('field_type', $field) == 'SECTION') {
199 $fields_list [(++$order_i).'section__'.wmvc_show_data('idfield', $field)] = '-- '.esc_html__('Section', 'wpdirectorykit').' '.wmvc_show_data('field_label', $field).' --';
200 } else {
201 $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).']';
202 }
203 }
204 $this->add_control(
205 'field_id',
206 [
207 'label' => __( 'Field id', 'wpdirectorykit' ),
208 'type' => \Elementor\Controls_Manager::SELECT,
209 'default' => '',
210 'options' => $fields_list,
211 'separator' => 'after',
212 ]
213 );
214
215 $this->end_controls_section();
216
217 }
218
219 private function generate_controls_layout() {
220 }
221
222
223 private function generate_controls_styles() {
224 $this->start_controls_section(
225 'field_group',
226 [
227 'label' => esc_html__('Field icon', 'wpdirectorykit'),
228 'tab' => Controls_Manager::TAB_STYLE,
229 ]
230 );
231
232 $this->add_responsive_control (
233 'field_group_icon_max_heigth',
234 [
235 'label' => esc_html__('Max Height', 'wpdirectorykit'),
236 'type' => Controls_Manager::SLIDER,
237 'range' => [
238 'px' => [
239 'min' => 10,
240 'max' => 1500,
241 ],
242 'vw' => [
243 'min' => 0,
244 'max' => 100,
245 ],
246 '%' => [
247 'min' => 0,
248 'max' => 100,
249 ],
250 ],
251 'size_units' => [ 'px', 'vw','%' ],
252 'default' => [
253 'unit' => 'px',
254 'size' => 18,
255 ],
256 'selectors' => [
257 '{{WRAPPER}} .wdk-field-icon' => 'max-width: {{SIZE}}{{UNIT}}',
258 ],
259 ]
260 );
261
262
263 $this->add_responsive_control (
264 'field_group_icon_max_width',
265 [
266 'label' => esc_html__('Max Width', 'wpdirectorykit'),
267 'type' => Controls_Manager::SLIDER,
268 'range' => [
269 'px' => [
270 'min' => 10,
271 'max' => 1500,
272 ],
273 'vw' => [
274 'min' => 0,
275 'max' => 100,
276 ],
277 '%' => [
278 'min' => 0,
279 'max' => 100,
280 ],
281 ],
282 'size_units' => [ 'px', 'vw','%' ],
283 'default' => [
284 'unit' => 'px',
285 'size' => 18,
286 ],
287 'selectors' => [
288 '{{WRAPPER}} .wdk-field-icon' => 'max-width: {{SIZE}}{{UNIT}}',
289 ],
290 ]
291 );
292
293 $this->end_controls_section();
294 /* END special for some elements */
295 }
296
297
298 private function generate_controls_content() {
299
300 }
301
302 public function enqueue_styles_scripts() {
303
304 }
305 }
306