PluginProbe
WP Directory Kit / 1.3.4
WP Directory Kit v1.3.4
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-label.php

wdk-field-label.php in WP Directory Kit 1.3.4, at elementor-elements/classes/wdk-field-label.php

321 lines 10.9 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 WdkFieldLabel 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-label';
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 Label', '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-post-title';
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_label'] = 'Example Label';
153 $this->data['field_prefix'] = $this->data['settings']['field_prefix'];
154 $this->data['field_suffix'] = $this->data['settings']['field_suffix'];
155 if(!empty($this->data['settings']['field_id'])) {
156 if(strpos($this->data['settings']['field_id'],'__') !== FALSE){
157 $this->data['settings']['field_id'] = substr($this->data['settings']['field_id'], strpos($this->data['settings']['field_id'],'__')+2);
158 }
159 $this->data['field_label'] = wdk_field_label($this->data['settings']['field_id']);
160
161 if(Plugin::$instance->editor->is_edit_mode()) {
162 if($this->data['settings']['field_id'] == 'post_title') {
163 $this->data['field_label'] = esc_html__('Field', 'wpdirectorykit') .' '.esc_html__('Title', 'wpdirectorykit');
164 } elseif($this->data['settings']['field_id'] == 'address') {
165 $this->data['field_label'] = esc_html__('Field', 'wpdirectorykit') .' '.esc_html__('Address', 'wpdirectorykit');
166 } elseif($this->data['settings']['field_id'] == 'post_content') {
167 $this->data['field_label'] = esc_html__('Field', 'wpdirectorykit') .' '.esc_html__('Content', 'wpdirectorykit');
168 } elseif($this->data['settings']['field_id'] == 'counter_views') {
169 $this->data['field_label'] = esc_html__('Field', 'wpdirectorykit') .' '.esc_html__('Views counter', 'wpdirectorykit');
170 }
171 }
172 }
173
174 $this->data['is_edit_mode']= false;
175 if(Plugin::$instance->editor->is_edit_mode()){
176 $this->data['is_edit_mode']= true;
177 if(is_intval($this->data['settings']['field_id']) && wdk_field_option($this->data['settings']['field_id'], 'is_visible_frontend') != 1) {
178 $this->data['field_label'] .= ' <span class="dashicons dashicons-hidden" style="color:red"></span>';
179 }
180 } else {
181 if(is_intval($this->data['settings']['field_id']) && wdk_field_option($this->data['settings']['field_id'], 'is_visible_frontend') != 1) {
182 return false;
183 }
184
185 if(wdk_field_value('category_id', $wdk_listing_id) && wdk_depend_is_hidden_field($this->data['settings']['field_id'], wdk_field_value('category_id', $wdk_listing_id))) {
186 return false;
187 }
188
189 /* return false if no content */
190 if($this->data['settings']['hide_onempty'] == 'yes' && wdk_field_value($this->data['settings']['field_id'], $wdk_listing_id) == '')
191 return false;
192 }
193
194 echo $this->view('wdk-field-label', $this->data);
195 }
196
197
198 private function generate_controls_conf() {
199 $this->start_controls_section(
200 'tab_conf_main_section',
201 [
202 'label' => esc_html__('Main', 'wpdirectorykit'),
203 'tab' => '1',
204 ]
205 );
206
207 $fields_data = wdk_cached_field_get();
208 $fields_list = array('' => esc_html__('Not Selected', 'wpdirectorykit'));
209 $order_i = 0;
210
211 $fields_list [(++$order_i).'__section'] = esc_html__('-- Section Custom fields --', 'wpdirectorykit');
212 $fields_list [(++$order_i).'__idlisting'] = esc_html__('Id listing', 'wpdirectorykit');
213 $fields_list [(++$order_i).'__post_id'] = esc_html__('Post Id', 'wpdirectorykit');
214 $fields_list [(++$order_i).'__counter_views'] = esc_html__('Views counter', 'wpdirectorykit');
215 $fields_list [(++$order_i).'__lat'] = esc_html__('Gps Lat', 'wpdirectorykit');
216 $fields_list [(++$order_i).'__lng'] = esc_html__('Gps Lng', 'wpdirectorykit');
217 $fields_list [(++$order_i).'__date'] = esc_html__('Date', 'wpdirectorykit');
218 $fields_list [(++$order_i).'__date_modified'] = esc_html__('Date Modified', 'wpdirectorykit');
219 $fields_list [(++$order_i).'__post_title'] = esc_html__('WP Title', 'wpdirectorykit');
220 $fields_list [(++$order_i).'__post_content'] = esc_html__('WP Content', 'wpdirectorykit');
221 $fields_list [(++$order_i).'__address'] = esc_html__('Address', 'wpdirectorykit');
222 $fields_list [(++$order_i).'__category_id'] = esc_html__('Category', 'wpdirectorykit');
223 $fields_list [(++$order_i).'__location_id'] = esc_html__('Location', 'wpdirectorykit');
224
225 foreach($fields_data as $field)
226 {
227 if(wmvc_show_data('field_type', $field) == 'SECTION') {
228 $fields_list [(++$order_i).'section__'.wmvc_show_data('idfield', $field)] = '-- '.esc_html__('Section', 'wpdirectorykit').' '.wmvc_show_data('field_label', $field).' --';
229 } else {
230 $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).']';
231 }
232 }
233 $this->add_control(
234 'field_id',
235 [
236 'label' => __( 'Field id', 'wpdirectorykit' ),
237 'type' => \Elementor\Controls_Manager::SELECT2,
238 'default' => '',
239 'options' => $fields_list,
240 'separator' => 'after',
241 ]
242 );
243
244 $this->add_control(
245 'field_suffix',
246 [
247 'label' => __( 'Label suffix', 'wpdirectorykit' ),
248 'type' => \Elementor\Controls_Manager::TEXT,
249 'default' => '',
250 ]
251 );
252
253 $this->add_control(
254 'field_prefix',
255 [
256 'label' => __( 'Label prefix', 'wpdirectorykit' ),
257 'type' => \Elementor\Controls_Manager::TEXT,
258 'default' => '',
259 ]
260 );
261
262 $this->add_control(
263 'hide_onempty',
264 [
265 'label' => __( 'Hide if empty', 'wpdirectorykit' ),
266 'type' => \Elementor\Controls_Manager::SWITCHER,
267 'label_on' => __( 'True', 'wpdirectorykit' ),
268 'label_off' => __( 'False', 'wpdirectorykit' ),
269 'return_value' => 'yes',
270 'default' => '',
271 ]
272 );
273
274 $this->end_controls_section();
275
276 }
277
278 private function generate_controls_layout() {
279 }
280
281
282 private function generate_controls_styles() {
283 $items = [
284 [
285 'key'=>'field_label',
286 'label'=> esc_html__('Field Label', 'wpdirectorykit'),
287 'selector'=>'.wdk-field-label',
288 'options'=>'full',
289 ]
290 ];
291
292 foreach ($items as $item) {
293 $this->start_controls_section(
294 $item['key'].'_section',
295 [
296 'label' => $item['label'],
297 'tab' => 'tab_layout'
298 ]
299 );
300
301 $selectors = array(
302 'normal' => '{{WRAPPER}} '.$item['selector'],
303 'hover'=>'{{WRAPPER}} '.$item['selector'].'%1$s'
304 );
305 $this->generate_renders_tabs($selectors, $item['key'].'_dynamic', $item['options']);
306
307 $this->end_controls_section();
308 /* END special for some elements */
309 }
310 }
311
312
313 private function generate_controls_content() {
314
315 }
316
317 public function enqueue_styles_scripts() {
318
319 }
320 }
321