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-last-search.php

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

308 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'], esc_html__('Last Search', 'wpdirectorykit'));
149 $this->data['last_search_url'] = wmvc_show_data('url_link_default_onempty', $this->data['settings'],'#');
150
151 if(isset($_COOKIE['wdk_last_search'])) {
152 $this->data['last_search_url'] = wdk_url_suffix(get_permalink(get_option('wdk_results_page')), $_COOKIE['wdk_last_search']);
153
154 $custom_parameters = array();
155 $qr_string = trim($_COOKIE['wdk_last_search']);
156 $qr_string = 'search_location%5B%5D=221&search_location55=1&search_category%5B%5D=0&search_category=2&wmvc_view_type=grid&order_by=post_id%20DESC';
157 parse_str($qr_string, $custom_parameters);
158
159 if(isset($custom_parameters['search_location'])) {
160 if(is_array($custom_parameters['search_location'])) {
161 if(isset($custom_parameters['search_location'][0]) && !empty($custom_parameters['search_location'][0]))
162 $this->data['last_search'] = wdk_get_location_title($custom_parameters['search_location'][0], $this->data['last_search']);
163 } else {
164 $this->data['last_search'] = wdk_get_location_title($custom_parameters['search_location'], $this->data['last_search']);
165 }
166 }
167
168 }
169
170 $this->data['is_edit_mode']= false;
171 if(Plugin::$instance->editor->is_edit_mode()){
172 $this->data['is_edit_mode']= true;
173 } else {
174 if($this->data['last_search_url'] == '#' || empty($this->data['last_search_url']) ) {
175 return false;
176 }
177 }
178
179 echo $this->view('wdk-last-search', $this->data);
180 }
181
182
183 private function generate_controls_conf() {
184 $this->start_controls_section(
185 'tab_conf_main_section',
186 [
187 'label' => esc_html__('Main', 'wpdirectorykit'),
188 'tab' => '1',
189 ]
190 );
191
192 $this->add_control(
193 'text_before',
194 [
195 'label' => __( 'Text before', 'wpdirectorykit' ),
196 'type' => \Elementor\Controls_Manager::TEXT,
197 'default' => '',
198 'render_type' => 'template'
199 ]
200 );
201
202 $this->add_control(
203 'text_after',
204 [
205 'label' => __( 'Text after', 'wpdirectorykit' ),
206 'type' => \Elementor\Controls_Manager::TEXT,
207 'default' => '',
208 'render_type' => 'template'
209 ]
210 );
211
212 $this->add_control(
213 'text_default_search',
214 [
215 'label' => __( 'Text default', 'wpdirectorykit' ),
216 'default' => __( 'Last Search', 'wpdirectorykit' ),
217 'type' => \Elementor\Controls_Manager::TEXT,
218 'render_type' => 'template'
219 ]
220 );
221
222 $this->add_control(
223 'url_link_default_onempty',
224 [
225 'label' => __( 'Link if missing latest search', 'wpdirectorykit' ),
226 'default' =>'',
227 'type' => \Elementor\Controls_Manager::TEXT,
228 ]
229 );
230
231 $this->end_controls_section();
232
233 }
234
235 private function generate_controls_layout() {
236 }
237
238
239 private function generate_controls_styles() {
240 $items = [
241 [
242 'key'=>'text',
243 'label'=> esc_html__('Styles', 'wpdirectorykit'),
244 'selector'=>'{{WRAPPER}} .wdk-last-search',
245 'options'=>['align','typo','color'],
246 ],
247 [
248 'key'=>'text_search',
249 'label'=> esc_html__('Special For Link', 'wpdirectorykit'),
250 'selector'=>'{{WRAPPER}} .wdk-last-search a',
251 'selector_hover'=>'{{WRAPPER}} .wdk-last-search a%1$s',
252 'options'=>['align','typo','color'],
253 ],
254 ];
255
256 foreach ($items as $item) {
257 $this->start_controls_section(
258 $item['key'].'_section',
259 [
260 'label' => $item['label'],
261 'tab' => 'tab_form_styles',
262 ]
263 );
264
265 if(!empty($item['selector_hide'])) {
266 $this->add_responsive_control(
267 $item['key'].'_hide',
268 [
269 'label' => esc_html__( 'Hide Element', 'wdk-svg-map' ),
270 'type' => Controls_Manager::SWITCHER,
271 'none' => esc_html__( 'Hide', 'wdk-svg-map' ),
272 'block' => esc_html__( 'Show', 'wdk-svg-map' ),
273 'return_value' => 'none',
274 'default' => ($item['key'] == 'field_button_reset' ) ? 'none':'',
275 'selectors' => [
276 $item['selector_hide'] => 'display: {{VALUE}};',
277 ],
278 ]
279 );
280 }
281
282 $selectors = array();
283 if(!empty($item['selector']))
284 $selectors['normal'] = $item['selector'];
285
286 if(!empty($item['selector_hover']))
287 $selectors['hover'] = $item['selector_hover'];
288
289 if(!empty($item['selector_focus']))
290 $selectors['focus'] = $item['selector_hover'];
291
292 $this->generate_renders_tabs($selectors, $item['key'].'_dynamic', $item['options']);
293
294 $this->end_controls_section();
295 /* END special for some elements */
296 }
297 }
298
299
300 private function generate_controls_content() {
301
302 }
303
304 public function enqueue_styles_scripts() {
305
306 }
307 }
308