PluginProbe
WP Directory Kit / 1.3.3
WP Directory Kit v1.3.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-last-search.php

wdk-last-search.php in WP Directory Kit 1.3.3, at elementor-elements/classes/wdk-last-search.php

312 lines 9.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 WdkLastSearch 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 add_action( 'elementor/editor/after_enqueue_styles', function()
45 {
46 wp_add_inline_style( 'elementor-editor', '.elementor-control-content select option[value*="section"]{color:#fff;background:#000}');
47 } );
48
49 if ($this->is_edit_mode_load()) {
50 $this->enqueue_styles_scripts();
51 }
52
53 parent::__construct($data, $args);
54
55 }
56
57 /**
58 * Retrieve the list of categories the widget belongs to.
59 *
60 * Used to determine where to display the widget in the editor.
61 *
62 * Note that currently Elementor supports only one category.
63 * When multiple categories passed, Elementor uses the first one.
64 *
65 * @since 1.1.0
66 *
67 * @access public
68 *
69 * @return array Widget categories.
70 */
71 public function get_categories() {
72 return [ 'wdk-elementor-listing-preview' ];
73 }
74
75 /**
76 * Retrieve the widget name.
77 *
78 * @since 1.1.0
79 *
80 * @access public
81 *
82 * @return string Widget name.
83 */
84 public function get_name() {
85 return 'wdk-last-search';
86 }
87
88 /**
89 * Retrieve the widget title.
90 *
91 * @since 1.1.0
92 *
93 * @access public
94 *
95 * @return string Widget title.
96 */
97 public function get_title() {
98 return esc_html__('Wdk Last Search', 'wpdirectorykit');
99 }
100
101 /**
102 * Retrieve the widget icon.
103 *
104 * @since 1.1.0
105 *
106 * @access public
107 *
108 * @return string Widget icon.
109 */
110 public function get_icon() {
111 return 'eicon-post-title';
112 }
113
114 /**
115 * Register the widget controls.
116 *
117 * Adds different input fields to allow the user to change and customize the widget settings.
118 *
119 * @since 1.1.0
120 *
121 * @access protected
122 */
123 protected function register_controls() {
124 $this->generate_controls_conf();
125 $this->generate_controls_layout();
126 $this->generate_controls_styles();
127 $this->generate_controls_content();
128
129 $this->insert_pro_message('1');
130 parent::register_controls();
131 }
132
133 /**
134 * Render the widget output on the frontend.
135 *
136 * Written in PHP and used to generate the final HTML.
137 *
138 * @since 1.1.0
139 *
140 * @access protected
141 */
142 protected function render() {
143 parent::render();
144
145 $this->data['id_element'] = $this->get_id();
146 $this->data['settings'] = $this->get_settings();
147
148 $this->data['last_search'] = wmvc_show_data('text_default_search', $this->data['settings']);
149 if(empty($this->data['last_search'])) {
150 $this->data['last_search'] = esc_html__('Last Search', 'wpdirectorykit');
151 }
152
153 $this->data['last_search_url'] = wmvc_show_data('url_link_default_onempty', $this->data['settings'],'#');
154
155 if(isset($_COOKIE['wdk_last_search'])) {
156 $this->data['last_search_url'] = wdk_url_suffix(get_permalink(get_option('wdk_results_page')), $_COOKIE['wdk_last_search']);
157
158 $custom_parameters = array();
159 $qr_string = trim($_COOKIE['wdk_last_search']);
160
161 parse_str($qr_string, $custom_parameters);
162
163 if(isset($custom_parameters['search_location'])) {
164 if(is_array($custom_parameters['search_location'])) {
165 if(isset($custom_parameters['search_location'][0]) && !empty($custom_parameters['search_location'][0]))
166 $this->data['last_search'] = wdk_get_location_title($custom_parameters['search_location'][0], $this->data['last_search']);
167 } else {
168 $this->data['last_search'] = wdk_get_location_title($custom_parameters['search_location'], $this->data['last_search']);
169 }
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 } else {
178 if($this->data['last_search_url'] == '#' || empty($this->data['last_search_url']) ) {
179 return false;
180 }
181 }
182
183 echo $this->view('wdk-last-search', $this->data);
184 }
185
186
187 private function generate_controls_conf() {
188 $this->start_controls_section(
189 'tab_conf_main_section',
190 [
191 'label' => esc_html__('Main', 'wpdirectorykit'),
192 'tab' => '1',
193 ]
194 );
195
196 $this->add_control(
197 'text_before',
198 [
199 'label' => __( 'Text before', 'wpdirectorykit' ),
200 'type' => \Elementor\Controls_Manager::TEXT,
201 'default' => '',
202 'render_type' => 'template'
203 ]
204 );
205
206 $this->add_control(
207 'text_after',
208 [
209 'label' => __( 'Text after', 'wpdirectorykit' ),
210 'type' => \Elementor\Controls_Manager::TEXT,
211 'default' => '',
212 'render_type' => 'template'
213 ]
214 );
215
216 $this->add_control(
217 'text_default_search',
218 [
219 'label' => __( 'Text default', 'wpdirectorykit' ),
220 'default' => __( 'Last Search', 'wpdirectorykit' ),
221 'type' => \Elementor\Controls_Manager::TEXT,
222 'render_type' => 'template'
223 ]
224 );
225
226 $this->add_control(
227 'url_link_default_onempty',
228 [
229 'label' => __( 'Link if missing latest search', 'wpdirectorykit' ),
230 'default' =>'',
231 'type' => \Elementor\Controls_Manager::TEXT,
232 ]
233 );
234
235 $this->end_controls_section();
236
237 }
238
239 private function generate_controls_layout() {
240 }
241
242
243 private function generate_controls_styles() {
244 $items = [
245 [
246 'key'=>'text',
247 'label'=> esc_html__('Styles', 'wpdirectorykit'),
248 'selector'=>'{{WRAPPER}} .wdk-last-search',
249 'options'=>['align','typo','color'],
250 ],
251 [
252 'key'=>'text_search',
253 'label'=> esc_html__('Special For Link', 'wpdirectorykit'),
254 'selector'=>'{{WRAPPER}} .wdk-last-search a',
255 'selector_hover'=>'{{WRAPPER}} .wdk-last-search a%1$s',
256 'options'=>['align','typo','color'],
257 ],
258 ];
259
260 foreach ($items as $item) {
261 $this->start_controls_section(
262 $item['key'].'_section',
263 [
264 'label' => $item['label'],
265 'tab' => 'tab_form_styles',
266 ]
267 );
268
269 if(!empty($item['selector_hide'])) {
270 $this->add_responsive_control(
271 $item['key'].'_hide',
272 [
273 'label' => esc_html__( 'Hide Element', 'wdk-svg-map' ),
274 'type' => Controls_Manager::SWITCHER,
275 'none' => esc_html__( 'Hide', 'wdk-svg-map' ),
276 'block' => esc_html__( 'Show', 'wdk-svg-map' ),
277 'return_value' => 'none',
278 'default' => ($item['key'] == 'field_button_reset' ) ? 'none':'',
279 'selectors' => [
280 $item['selector_hide'] => 'display: {{VALUE}};',
281 ],
282 ]
283 );
284 }
285
286 $selectors = array();
287 if(!empty($item['selector']))
288 $selectors['normal'] = $item['selector'];
289
290 if(!empty($item['selector_hover']))
291 $selectors['hover'] = $item['selector_hover'];
292
293 if(!empty($item['selector_focus']))
294 $selectors['focus'] = $item['selector_hover'];
295
296 $this->generate_renders_tabs($selectors, $item['key'].'_dynamic', $item['options']);
297
298 $this->end_controls_section();
299 /* END special for some elements */
300 }
301 }
302
303
304 private function generate_controls_content() {
305
306 }
307
308 public function enqueue_styles_scripts() {
309
310 }
311 }
312