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-field-icon.php

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

276 lines 8.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 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($this->data['settings']['field_id'] == 'category_id') {
158 $this->WMVC->model('category_m');
159 $tree_data = $this->WMVC->category_m->get(wdk_field_value ($this->data['settings']['field_id'], $wdk_listing_id), TRUE);
160 $this->data['field_icon'] = wmvc_show_data('icon_id', $tree_data);
161 } else if($this->data['settings']['field_id'] == 'location_id') {
162 $this->WMVC->model('location_id');
163 $tree_data = $this->WMVC->location_id->get(wdk_field_value ($this->data['settings']['field_id'], $wdk_listing_id), TRUE);
164 $this->data['field_icon'] = wmvc_show_data('icon_id', $tree_data);
165 } else {
166 $this->data['field_icon'] = wdk_field_option ($this->data['settings']['field_id'], 'icon_id');
167 }
168 }
169
170
171 $this->data['is_edit_mode']= false;
172 if(Plugin::$instance->editor->is_edit_mode()){
173 $this->data['is_edit_mode']= true;
174 } else {
175
176 /* return false if no content */
177 if($this->data['settings']['hide_onempty'] == 'yes' && $this->data['field_icon'] == '')
178 return false;
179
180 /* return false if no content */
181 if($this->data['field_icon'] == '')
182 return false;
183 }
184
185 $this->view('wdk-field-icon', $this->data, true);
186 }
187
188
189 private function generate_controls_conf() {
190 $this->start_controls_section(
191 'tab_conf_main_section',
192 [
193 'label' => esc_html__('Main', 'wpdirectorykit'),
194 'tab' => '1',
195 ]
196 );
197
198 $fields_data = wdk_cached_field_get();
199 $fields_list = array('' => esc_html__('Not Selected', 'wpdirectorykit'));
200 $order_i = 0;
201
202 $fields_list [(++$order_i).'__section'] = esc_html__('-- Section Custom fields --', 'wpdirectorykit');
203 $fields_list [(++$order_i).'__post_title'] = esc_html__('WP Title', 'wpdirectorykit');
204 $fields_list [(++$order_i).'__post_content'] = esc_html__('WP Content', 'wpdirectorykit');
205 $fields_list [(++$order_i).'__address'] = esc_html__('Address', 'wpdirectorykit');
206 $fields_list [(++$order_i).'__category_id'] = esc_html__('Category', 'wpdirectorykit');
207 $fields_list [(++$order_i).'__location_id'] = esc_html__('Location', 'wpdirectorykit');
208
209 foreach($fields_data as $field)
210 {
211 if(wmvc_show_data('field_type', $field) == 'SECTION') {
212 $fields_list [(++$order_i).'section__'.wmvc_show_data('idfield', $field)] = '-- '.esc_html__('Section', 'wpdirectorykit').' '.wmvc_show_data('field_label', $field).' --';
213 } else {
214 $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).']';
215 }
216 }
217 $this->add_control(
218 'field_id',
219 [
220 'label' => __( 'Field id', 'wpdirectorykit' ),
221 'type' => \Elementor\Controls_Manager::SELECT2,
222 'default' => '',
223 'options' => $fields_list,
224 'separator' => 'after',
225 ]
226 );
227
228 $this->add_control(
229 'hide_onempty',
230 [
231 'label' => __( 'Hide if empty', 'wpdirectorykit' ),
232 'type' => \Elementor\Controls_Manager::SWITCHER,
233 'label_on' => __( 'True', 'wpdirectorykit' ),
234 'label_off' => __( 'False', 'wpdirectorykit' ),
235 'return_value' => 'yes',
236 'default' => '',
237 ]
238 );
239
240 $this->end_controls_section();
241
242 }
243
244 private function generate_controls_layout() {
245 }
246
247
248 private function generate_controls_styles() {
249 $this->start_controls_section(
250 'field_group',
251 [
252 'label' => esc_html__('Field icon', 'wpdirectorykit'),
253 'tab' => Controls_Manager::TAB_STYLE,
254 ]
255 );
256
257 $selectors = array(
258 'normal' => '{{WRAPPER}} .wdk-field-icon img',
259 );
260 $this->generate_renders_tabs($selectors, 'layout_image_dynamic', ['image_size_control','image_fit_control', 'height', 'width','css_filters']);
261
262
263 $this->end_controls_section();
264 /* END special for some elements */
265 }
266
267
268 private function generate_controls_content() {
269
270 }
271
272 public function enqueue_styles_scripts() {
273
274 }
275 }
276