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
← All changes | elementor-elements/classes/wdk-locations-list.php +88 -9 1.2.7 → 1.5.9 View file →
@@ -29,8 +29,9 @@
29 29 \Elementor\Controls_Manager::add_tab(
30 30 'tab_conf',
31 31 esc_html__('Settings', 'wpdirectorykit')
32 32 );
33 +
33 34
34 35 \Elementor\Controls_Manager::add_tab(
35 36 'tab_layout',
36 37 esc_html__('Layout', 'wpdirectorykit')
@@ -130,9 +131,9 @@
130 131
131 132 $locations_ids = array();
132 133 foreach($this->data['settings']['conf_custom_results'] as $location) {
133 134 if(isset($location['location_id']) && !empty($location['location_id'])) {
134 - $locations_ids [] = $location['location_id'];
135 + $locations_ids [] = (int)$location['location_id'];
135 136 }
136 137 }
137 138
138 139 /* where in */
@@ -149,15 +150,41 @@
149 150
150 151 } else {
151 152 $order_by = NULL;
152 153 if(!empty($this->data['settings']['conf_order_by']))
153 - $order_by = $this->data['settings']['conf_order_by'].' '.$this->data['settings']['conf_order'];
154 + $order_by = wdk_esc_sql_order_by($this->data['settings']['conf_order_by'].' '.$this->data['settings']['conf_order'], $this->WMVC->{$controller.'_m'}->getAllowedOrderBy());
154 155
155 156 $where = array();
156 157 if (!empty($this->data['settings']['only_root_enable']) && $this->data['settings']['only_root_enable'] == 'yes') {
157 158 $where['('.$this->WMVC->{$controller.'_m'}->_table_name.'.level = 0)'] = NULL;
158 159 }
159 - $this->data['results'] = $this->WMVC->{$controller.'_m'}->get_pagination($this->data['settings']['conf_limit'], NULL, $where, $order_by);
160 +
161 + static $results = array();
162 + $key = $order_by.http_build_query($where).$this->data['settings']['conf_limit'];
163 +
164 + if(!isset($results[$key])) {
165 + $this->data['results'] = $results[$key] = $this->WMVC->{$controller.'_m'}->get_pagination((!empty($this->data['settings']['conf_limit'])) ? $this->data['settings']['conf_limit'] : NULL, NULL, $where, $order_by);
166 + } else {
167 + $this->data['results'] = $results[$key];
168 + }
169 +
170 + if(wmvc_show_data('conf_query_params', $this->data['settings'], false) && !empty($this->data['settings']['conf_query_params'])) {
171 + $custom_parameters = array();
172 + $qr_string = trim($this->data['settings']['conf_query_params'],'?');
173 + $string_par = array();
174 + parse_str($qr_string, $string_par);
175 + $custom_parameters += array_map('trim', $string_par);
176 +
177 + $columns = array('ID', 'location_id', 'category_id', 'post_title', 'post_date', 'search', 'order_by','is_featured', 'address');
178 + $external_columns = array('location_id', 'category_id', 'post_title');
179 +
180 + foreach ($this->data['results'] as $key => $item) {
181 + $custom_parameters['search_location'] = wmvc_show_data('idlocation', $item, false);
182 + wdk_prepare_search_query_GET($columns, $controller.'_m', $external_columns, $custom_parameters, TRUE);
183 + $this->data['results'][$key]->listings_counter = $this->WMVC->listing_m->total(array('is_activated' => 1,'is_approved'=>1));
184 + }
185 +
186 + }
160 187 }
161 188
162 189 $this->data['is_edit_mode']= false;
163 190 if(Plugin::$instance->editor->is_edit_mode())
@@ -162,9 +189,9 @@
162 189 $this->data['is_edit_mode']= false;
163 190 if(Plugin::$instance->editor->is_edit_mode())
164 191 $this->data['is_edit_mode']= true;
165 192
166 - echo $this->view('wdk-locations-list', $this->data);
193 + $this->view('wdk-locations-list', $this->data, true);
167 194 }
168 195
169 196
170 197 private function generate_controls_conf() {
@@ -174,8 +201,21 @@
174 201 'label' => esc_html__('Main', 'wpdirectorykit'),
175 202 'tab' => '1',
176 203 ]
177 204 );
205 +
206 + $this->add_control(
207 + 'enable_search_sensitive',
208 + [
209 + 'label' => __( 'Enable Search Sensitive', 'wpdirectorykit' ),
210 + 'type' => \Elementor\Controls_Manager::SWITCHER,
211 + 'label_on' => __( 'On', 'wpdirectorykit' ),
212 + 'label_off' => __( 'Off', 'wpdirectorykit' ),
213 + 'return_value' => 'true',
214 + 'default' => '',
215 + 'separator' => 'after',
216 + ]
217 + );
178 218
179 219 $pages = array('' => __('Not Selected', 'wpdirectorykit'));
180 220 foreach(get_pages(array('sort_column' => 'post_title')) as $page)
181 221 {
@@ -185,9 +225,9 @@
185 225 $this->add_control(
186 226 'conf_link',
187 227 [
188 228 'label' => __( 'Open results on page', 'wpdirectorykit' ),
189 - 'type' => \Elementor\Controls_Manager::SELECT,
229 + 'type' => \Elementor\Controls_Manager::SELECT2,
190 230 'default' => '',
191 231 'options' => $pages
192 232 ]
193 233 );
@@ -203,10 +243,47 @@
203 243 'custom_locations' => __( 'Specific', 'wpdirectorykit' ),
204 244 ],
205 245 ]
206 246 );
207 -
247 +
208 248 $this->add_control(
249 + 'conf_query_params',
250 + [
251 + 'label' => __( 'Query params', 'wpdirectorykit' ),
252 + 'description' => __( 'Put addition query params for locations (counting required memory)', 'wpdirectorykit' ),
253 + 'type' => \Elementor\Controls_Manager::TEXTAREA,
254 + 'default' => '',
255 + 'conditions' => [
256 + 'terms' => [
257 + [
258 + 'name' => 'conf_results_type',
259 + 'operator' => '==',
260 + 'value' => 'results_locations',
261 + ]
262 + ],
263 + ],
264 + ]
265 + );
266 +
267 + $this->add_control(
268 + 'suffix',
269 + [
270 + 'label' => __( 'Title Suffix', 'wpdirectorykit' ),
271 + 'type' => \Elementor\Controls_Manager::TEXT,
272 + 'default' => '',
273 + ]
274 + );
275 +
276 + $this->add_control(
277 + 'prefix',
278 + [
279 + 'label' => __( 'Title Prefix', 'wpdirectorykit' ),
280 + 'type' => \Elementor\Controls_Manager::TEXT,
281 + 'default' => '',
282 + ]
283 + );
284 +
285 + $this->add_control(
209 286 'show_icon',
210 287 [
211 288 'label' => __( 'Enable Location Icons', 'wpdirectorykit' ),
212 289 'type' => \Elementor\Controls_Manager::SWITCHER,
@@ -222,8 +299,9 @@
222 299 'important_note',
223 300 [
224 301 'label' => '',
225 302 'type' => \Elementor\Controls_Manager::RAW_HTML,
303 + /* translators: 1: URL. */
226 304 'raw' => wdk_sprintf(__( 'Edit Locations <a href="%1$s" target="_blank"> open </a>', 'wpdirectorykit' ), admin_url('admin.php?page=wdk_location')),
227 305 'content_classes' => 'wdk_elementor_hint',
228 306 ]
229 307 );
@@ -242,11 +320,12 @@
242 320 $this->add_control(
243 321 'conf_limit',
244 322 [
245 323 'label' => __( 'Limit Locations', 'wpdirectorykit' ),
324 + 'description' => __( 'Set 0 for unlimit', 'wpdirectorykit' ),
246 325 'type' => \Elementor\Controls_Manager::NUMBER,
247 - 'min' => 1,
248 - 'max' => 50,
326 + 'min' => 0,
327 + 'max' => 500,
249 328 'step' => 1,
250 329 'default' => 6,
251 330 'separator' => 'before',
252 331 'conditions' => [
@@ -507,9 +586,9 @@
507 586 $item['key'].'_size',
508 587 [
509 588 'label' => __( 'Size', 'wpdirectorykit' ),
510 589 'type' => Controls_Manager::SLIDER,
511 - 'size_units' => [ 'px'],
590 + 'size_units' => [ 'px','em', 'vw', '%', 'custom' ],
512 591 'range' => [
513 592 'px' => [
514 593 'min' => 1,
515 594 'max' => 60,