PluginProbe
WP Directory Kit / 1.2.9
WP Directory Kit v1.2.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 / application / models / Settings_m.php

Settings_m.php in WP Directory Kit 1.2.9, at application/models/Settings_m.php

430 lines 23.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // If this file is called directly, abort.
4 if ( ! defined( 'WPINC' ) ) {
5 die;
6 }
7
8 class Settings_m extends Winter_MVC_Model {
9
10 public $_table_name = 'options';
11 public $_order_by = 'option_id';
12 public $_primary_key = 'option_id';
13 public $_own_columns = array();
14 public $_timestamps = TRUE;
15 protected $_primary_filter = 'intval';
16 public $fields_list = array();
17 public $fields_list_tabs = array();
18
19 public function __construct(){
20 parent::__construct();
21
22 $pages = array('' => __('Not Selected', 'wpdirectorykit'));
23 foreach(get_pages(array('sort_column' => 'post_title')) as $page)
24 {
25 $pages[$page->ID] = $page->post_title.' #'.$page->ID;
26 }
27
28 $WMVC = &wdk_get_instance();
29 $WMVC->model('field_m');
30 $fields_data = $WMVC->field_m->get();
31 $fields_list = array('' => esc_html__('Not Selected', 'wpdirectorykit'));
32 $fields_list_inputs = array('' => esc_html__('Not Selected', 'wpdirectorykit'));
33 $order_i = 0;
34
35 $fields_list ['section'] = esc_html__('-- Section Custom fields --', 'wpdirectorykit');
36 $fields_list ['post_title'] = esc_html__('WP Title', 'wpdirectorykit');
37 $fields_list ['post_content'] = esc_html__('WP Content', 'wpdirectorykit');
38
39 foreach($fields_data as $field)
40 {
41 if(wmvc_show_data('field_type', $field) == 'SECTION') {
42 $fields_list ['section__'.wmvc_show_data('idfield', $field)] = '-- '.esc_html__('Section', 'wpdirectorykit').' '.wmvc_show_data('field_label', $field).' --';
43 } else {
44 $fields_list[wmvc_show_data('idfield', $field)] = '#'.wmvc_show_data('idfield', $field).' '.wmvc_show_data('field_label', $field).'['.wmvc_show_data('field_type', $field).']';
45 }
46
47 if(wmvc_show_data('field_type', $field) == 'INPUTBOX') {
48 $fields_list_inputs [wmvc_show_data('idfield', $field)] = '#'.wmvc_show_data('idfield', $field).' '.wmvc_show_data('field_label', $field).'['.wmvc_show_data('field_type', $field).']';
49 }
50 }
51
52 /* General */
53
54 $this->fields_list_tabs['general'] = array(
55 array('field' => 'wdk_default_lat', 'field_label' => __('Default GPS Position', 'wpdirectorykit'), 'hint' => '', 'field_type' => 'MAP', 'rules' => ''),
56 array('field' => 'wdk_default_lng', 'field_label' => __('Default GPS Longitude', 'wpdirectorykit'), 'hint' => '', 'field_type' => 'INPUTBOX', 'rules' => '', 'class' => 'hidden'),
57 array('field' => 'wdk_fixed_map_results_position', 'field_label' => __('Fix map center on default location', 'wpdirectorykit'), 'hint' => '', 'field_type' => 'CHECKBOX', 'rules' => '', 'class' => ''),
58
59 array('field' => 'wdk_is_category_enabled', 'field_label' => __('Enable Categories', 'wpdirectorykit'), 'hint' => __('If you don\'t need categories features you can disable that here', 'wpdirectorykit'), 'field_type' => 'CHECKBOX', 'rules' => ''),
60 array('field' => 'wdk_is_location_enabled', 'field_label' => __('Enable Locations', 'wpdirectorykit'), 'hint' => __('If you don\'t need location features you can disable that here', 'wpdirectorykit'), 'field_type' => 'CHECKBOX', 'rules' => '', 'class' => ''),
61
62
63 array('field' => 'wdk_is_address_enabled', 'field_label' => __('Enable Address', 'wpdirectorykit'), 'hint' => __('Select regular page which ill be used for listing preview page on frontend, you can create new one also for this purpose', 'wpdirectorykit'), 'field_type' => 'CHECKBOX', 'rules' => ''),
64 array('field' => 'wdk_slug_listing_preview_page', 'field_label' => __('Custom Listing Preview Page Slug', 'wpdirectorykit'), 'hint' => __('Slug used for listing preview page, if empty, default will be used', 'wpdirectorykit'), 'field_type' => 'INPUTBOX', 'rules' => 'wdk_slug_format'),
65 array('field' => 'wdk_listing_page', 'field_label' => __('Listing Page', 'wpdirectorykit'), 'hint' => __('Select regular page which ill be used for listing preview page on frontend, you can create new one also for this purpose', 'wpdirectorykit'), 'field_type' => 'DROPDOWN', 'rules' => '', 'values' => $pages),
66 array('field' => 'wdk_results_page', 'field_label' => __('Results Page', 'wpdirectorykit'), 'hint' => __('Select regular page which ill be used for results page on frontend, you can create new one also for this purpose', 'wpdirectorykit'), 'field_type' => 'DROPDOWN', 'rules' => '', 'values' => $pages),
67 array('field' => 'wdk_is_results_page_require', 'field_label' => __('Always use results page', 'wpdirectorykit'), 'hint' => __('Always even if on current page you have results where can be showed', 'wpdirectorykit'), 'field_type' => 'CHECKBOX', 'rules' => ''),
68
69 array(
70 'field' => 'wdk_card_video_enable',
71 'field_label' => __('Card Video From gallery in result card enable', 'wpdirectorykit'),
72 'hint' => __('If you upload video on first place in listing, will become visible in result card', 'wpdirectorykit'),
73 'field_type' => 'CHECKBOX',
74 'rules' => '',
75 ),
76 array(
77 'field' => 'wdk_listing_category_required',
78 'field_label' => __('Category is required field', 'wpdirectorykit'),
79 'hint' => __('if this is enabled, listing required category field', 'wpdirectorykit'),
80 'field_type' => 'CHECKBOX',
81 'rules' => '',
82 ),
83 array(
84 'field' => 'wdk_listing_location_required',
85 'field_label' => __('Location is required field', 'wpdirectorykit'),
86 'hint' => __('if this is enabled, listing required location field', 'wpdirectorykit'),
87 'field_type' => 'CHECKBOX',
88 'rules' => '',
89 ),
90
91 array(
92 'field' => 'wdk_sub_listings_enable',
93 'field_label' => __('Related Listings', 'wpdirectorykit'),
94 'field_type' => 'CHECKBOX',
95 'rules' => '',
96 ),
97 array(
98 'field' => 'wdk_listings_images_required_enable',
99 'field_label' => __('Listing Images required', 'wpdirectorykit'),
100 'field_type' => 'CHECKBOX',
101 'rules' => '',
102 ),
103 array(
104 'field' => 'wdk_default_currency_symbol',
105 'field_label' => __('Default Currency Symbol1', 'wpdirectorykit'),
106 'hint' => __('Put default currency symbol like $', 'wpdirectorykit'),
107 'field_type' => 'INPUTBOX',
108 'rules' => '',
109 ),
110 );
111
112
113 /* Templates */
114 $this->fields_list_tabs['templates'] = array(
115 array(
116 'field' => 'wdk_placeholder',
117 'field_label' => __('Cooming soon listing image', 'wpdirectorykit'),
118 'hint' => '',
119 'field_type' => 'UPLOAD',
120 'rules' => '',
121 ),
122 array(
123 'field' => 'wdk_card_slider_enable',
124 'field_label' => __('Show slider in result card', 'wpdirectorykit'),
125 'hint' => '',
126 'field_type' => 'CHECKBOX',
127 'rules' => '',
128 ),
129 array(
130 'field' => 'wdk_card_video_field',
131 'field_label' => __('Card video field', 'wpdirectorykit'),
132 'hint' => '',
133 'field_type' => 'DROPDOWN',
134 'values' => $fields_list_inputs,
135 'rules' => '',
136 'hint' => '',
137 ),
138 array(
139 'field' => 'wdk_mobile_bottom_navbar_enable',
140 'field_label' => __('Mobile bottom navbar', 'wpdirectorykit'),
141 'field_type' => 'CHECKBOX',
142 'rules' => '',
143 ),
144 array(
145 'field' => 'wdk_field_search_suggestion_disable',
146 'field_label' => __('Smart Search Suggestion Disable', 'wpdirectorykit'),
147 'field_type' => 'CHECKBOX',
148 'rules' => '',
149 ),
150 );
151
152 /* Fields */
153 $this->fields_list_tabs['fields'] = array(
154 array('field' => 'wdk_seo_keywords', 'field_label' => __('SEO Listing Page Keywords', 'wpdirectorykit'), 'hint' => __('Set field for meta tag keywords', 'wpdirectorykit'), 'field_type' => 'DROPDOWN', 'values' => $fields_list, 'rules' => ''),
155 array('field' => 'wdk_seo_description', 'field_label' => __('SEO Listing Page Description', 'wpdirectorykit'), 'hint' => __('Set field for meta tag description', 'wpdirectorykit'), 'field_type' => 'DROPDOWN', 'values' => $fields_list, 'rules' => ''),
156
157 array(
158 'field' => 'wdk_multi_locations_search_field_type',
159 'field_label' => __('Location field Search', 'wpdirectorykit'),
160 'field_type' => 'RADIO',
161 'hint' => __('Visible on search form', 'wpdirectorykit'),
162 'rules' => '',
163 'values' => array(
164 '' => esc_html__('Single Tree Dropdown', 'wpdirectorykit'),
165 'select2' => esc_html__('Multi Select Dropdown', 'wpdirectorykit'),
166 'wdk_treefield_dropdown' => esc_html__('Multiple Dropdowns', 'wpdirectorykit'),
167 'wdk_treefield_checkboxes' => esc_html__('Single Tree Dropdown with checkboxes', 'wpdirectorykit'),
168 )
169 ),
170
171 array(
172 'field' => 'wdk_multi_categories_search_field_type',
173 'field_label' => __('Categoreis field Search', 'wpdirectorykit'),
174 'field_type' => 'RADIO',
175 'hint' => __('Visible on search form. Hiding field in search form based on category is only possible when using single tree dropdown', 'wpdirectorykit'),
176 'rules' => '',
177 'values' => array(
178 '' => esc_html__('Single Tree Dropdown', 'wpdirectorykit'),
179 'select2' => esc_html__('Multi Select Dropdown', 'wpdirectorykit'),
180 'wdk_treefield_dropdown' => esc_html__('Multiple Dropdowns', 'wpdirectorykit'),
181 'wdk_treefield_checkboxes' => esc_html__('Single Tree Dropdown with checkboxes', 'wpdirectorykit'),
182 )
183 ),
184
185 array(
186 'field' => 'wdk_multi_locations_edit_field_type',
187 'field_label' => __('Location field edit', 'wpdirectorykit'),
188 'field_type' => 'RADIO',
189 'hint' => __('Visible on edit form', 'wpdirectorykit'),
190 'rules' => '',
191 'values' => array(
192 '' => esc_html__('Single Tree Dropdown', 'wpdirectorykit'),
193 'wdk_treefield_dropdown' => esc_html__('Multiple Dropdowns', 'wpdirectorykit'),
194 )
195 ),
196
197 array(
198 'field' => 'wdk_multi_categories_edit_field_type',
199 'field_label' => __('Categoreis field edit', 'wpdirectorykit'),
200 'field_type' => 'RADIO',
201 'hint' => __('Visible on edit form. Hiding field in edit form based on category is only possible when using single tree dropdown', 'wpdirectorykit'),
202 'rules' => '',
203 'values' => array(
204 '' => esc_html__('Single Tree Dropdown', 'wpdirectorykit'),
205 'wdk_treefield_dropdown' => esc_html__('Multiple Dropdowns', 'wpdirectorykit'),
206 )
207 ),
208
209 array('field' => 'wdk_multi_locations_other_enable', 'field_label' => __('Enable multi location on edit listing', 'wpdirectorykit'), 'hint' => __('Enable multi location on edit listing', 'wpdirectorykit'), 'field_type' => 'CHECKBOX', 'rules' => ''),
210 array('field' => 'wdk_multi_categories_other_enable', 'field_label' => __('Enable multi categories on edit listing', 'wpdirectorykit'), 'hint' => __('Enable multi categories on edit listing', 'wpdirectorykit'), 'field_type' => 'CHECKBOX', 'rules' => ''),
211 array(
212 'field' => 'wdk_listing_plangs_documents_disable',
213 'field_label' => __('Disable "Listing plans and documents"', 'wpdirectorykit'),
214 'hint' => '',
215 'field_type' => 'CHECKBOX',
216 'rules' => '',
217 ),
218 );
219
220 /* Api-s */
221 $this->fields_list_tabs['apis'] = array(
222 array(
223 'field' => 'wdk_recaptcha_site_key',
224 'field_label' => __('Recaptcha site key', 'wpdirectorykit'),
225 'hint' => __('Please add Recaptcha site and Secret keys for enable recaptcha Add Google Recaptcha site key (use V2 recaptcha key)', 'wpdirectorykit'),
226 'field_type' => 'INPUTBOX',
227 'rules' => '',
228 ),
229 array(
230 'field' => 'wdk_recaptcha_secret_key',
231 'field_label' => __('Recaptcha site secret key', 'wpdirectorykit'),
232 'hint' => __('Add Google Recaptcha secret key', 'wpdirectorykit'),
233 'field_type' => 'INPUTBOX',
234 'rules' => '',
235 ),
236 array(
237 'field' => 'wdk_geo_google_api_key',
238 'field_label' => __('Google API Key', 'wpdirectorykit'),
239 'hint' => __('Google API Key, for address to gps coordinates conversion', 'wpdirectorykit').'. '.wdk_sprintf(__('Get key %1$s here %2$s','wpdirectorykit'),'<a target="_blank" href="https://developers.google.com/maps/documentation/javascript/get-api-key">','</a>'),
240 'field_type' => 'INPUTBOX',
241 'rules' => '',
242 ),
243 array(
244 'field' => 'wdk_import_google_api_enable',
245 'field_label' => __('Google API for import listings', 'wpdirectorykit'),
246 'hint' => __('Google API key will be used to autodetect GPS coordinates when importing listing', 'wpdirectorykit'),
247 'field_type' => 'CHECKBOX',
248 'rules' => '',
249 ),
250 array(
251 'field' => 'wdk_geo_coding_results_location',
252 'field_label' => __('Auto Search based on Geo Coding', 'wpdirectorykit'),
253 'hint' => __('if this is enabled, auto search listings based on found geo location', 'wpdirectorykit'),
254 'field_type' => 'CHECKBOX',
255 'rules' => '',
256 ),
257 );
258
259 $this->fields_list_tabs['general'] = array(
260 array('field' => 'wdk_default_lat', 'field_label' => __('Default GPS Position', 'wpdirectorykit'), 'hint' => '', 'field_type' => 'MAP', 'rules' => ''),
261 array('field' => 'wdk_default_lng', 'field_label' => __('Default GPS Longitude', 'wpdirectorykit'), 'hint' => '', 'field_type' => 'INPUTBOX', 'rules' => '', 'class' => 'hidden'),
262 array('field' => 'wdk_fixed_map_results_position', 'field_label' => __('Fix map center on default location', 'wpdirectorykit'), 'hint' => '', 'field_type' => 'CHECKBOX', 'rules' => '', 'class' => ''),
263
264 array('field' => 'wdk_is_category_enabled', 'field_label' => __('Enable Categories', 'wpdirectorykit'), 'hint' => __('If you don\'t need categories features you can disable that here', 'wpdirectorykit'), 'field_type' => 'CHECKBOX', 'rules' => ''),
265 array('field' => 'wdk_is_location_enabled', 'field_label' => __('Enable Locations', 'wpdirectorykit'), 'hint' => __('If you don\'t need location features you can disable that here', 'wpdirectorykit'), 'field_type' => 'CHECKBOX', 'rules' => '', 'class' => ''),
266
267
268 array('field' => 'wdk_is_address_enabled', 'field_label' => __('Enable Address', 'wpdirectorykit'), 'hint' => __('Select regular page which ill be used for listing preview page on frontend, you can create new one also for this purpose', 'wpdirectorykit'), 'field_type' => 'CHECKBOX', 'rules' => ''),
269 array('field' => 'wdk_slug_listing_preview_page', 'field_label' => __('Custom Listing Preview Page Slug', 'wpdirectorykit'), 'hint' => __('Slug used for listing preview page, if empty, default will be used', 'wpdirectorykit'), 'field_type' => 'INPUTBOX', 'rules' => 'wdk_slug_format'),
270 array('field' => 'wdk_listing_page', 'field_label' => __('Listing Page', 'wpdirectorykit'), 'hint' => __('Select regular page which ill be used for listing preview page on frontend, you can create new one also for this purpose', 'wpdirectorykit'), 'field_type' => 'DROPDOWN', 'rules' => '', 'values' => $pages),
271 array('field' => 'wdk_results_page', 'field_label' => __('Results Page', 'wpdirectorykit'), 'hint' => __('Select regular page which ill be used for results page on frontend, you can create new one also for this purpose', 'wpdirectorykit'), 'field_type' => 'DROPDOWN', 'rules' => '', 'values' => $pages),
272 array('field' => 'wdk_is_results_page_require', 'field_label' => __('Always use results page', 'wpdirectorykit'), 'hint' => __('Always even if on current page you have results where can be showed', 'wpdirectorykit'), 'field_type' => 'CHECKBOX', 'rules' => ''),
273
274 array(
275 'field' => 'wdk_card_video_enable',
276 'field_label' => __('Card Video From gallery in result card enable', 'wpdirectorykit'),
277 'hint' => __('If you upload video on first place in listing, will become visible in result card', 'wpdirectorykit'),
278 'field_type' => 'CHECKBOX',
279 'rules' => '',
280 ),
281 array(
282 'field' => 'wdk_listing_category_required',
283 'field_label' => __('Category is required field', 'wpdirectorykit'),
284 'hint' => __('if this is enabled, listing required category field', 'wpdirectorykit'),
285 'field_type' => 'CHECKBOX',
286 'rules' => '',
287 ),
288 array(
289 'field' => 'wdk_listing_location_required',
290 'field_label' => __('Location is required field', 'wpdirectorykit'),
291 'hint' => __('if this is enabled, listing required location field', 'wpdirectorykit'),
292 'field_type' => 'CHECKBOX',
293 'rules' => '',
294 ),
295
296 array(
297 'field' => 'wdk_sub_listings_enable',
298 'field_label' => __('Related Listings', 'wpdirectorykit'),
299 'field_type' => 'CHECKBOX',
300 'rules' => '',
301 ),
302 array(
303 'field' => 'wdk_listings_images_required_enable',
304 'field_label' => __('Listing Images required', 'wpdirectorykit'),
305 'field_type' => 'CHECKBOX',
306 'rules' => '',
307 ),
308 array(
309 'field' => 'wdk_default_currency_symbol',
310 'field_label' => __('Default Currency Symbol', 'wpdirectorykit'),
311 'hint' => __('Put default currency symbol like $', 'wpdirectorykit'),
312 'field_type' => 'INPUTBOX',
313 'rules' => '',
314 ),
315 array(
316 'field' => 'wdk_experimental_features',
317 'field_label' => __('Experimental features', 'wpdirectorykit'),
318 'hint' => '',
319 'field_type' => 'CHECKBOX',
320 'rules' => '',
321 ),
322 );
323
324 if(function_exists('run_wdk_geo')) {
325 $this->fields_list_tabs['apis'][] = array(
326 'field' => 'wdk_geo_autodetect_by_google_js_enable',
327 'field_label' => __('Enable location autodetect by Google JS', 'wpdirectorykit'),
328 'hint' => __('This using Google JS API, require API key and user need to allow this in Browser (is most accurate)', 'wpdirectorykit'),
329 'field_type' => 'CHECKBOX',
330 'rules' => '',
331 );
332
333 $this->fields_list_tabs['apis'][] = array(
334 'field' => 'wdk_geo_autodetect_by_ip_enable',
335 'field_label' => __('Enable location autodatect by IP', 'wpdirectorykit'),
336 'hint' => __('This using Free API www.geoplugin.net, not require API key and is not so accurate as Google version, if both enabled then this will be used if Google failed', 'wpdirectorykit'),
337 'field_type' => 'CHECKBOX',
338 'rules' => '',
339 );
340 }
341
342 /* Templates */
343 if(wdk_get_option('wdk_experimental_features')) {
344 $this->fields_list_tabs['experimental'] = array(
345 array(
346 'field' => 'wdk_experimental_search_popup',
347 'field_label' => __('Search Popup', 'wpdirectorykit'),
348 'hint' => __('Element open search form in popup', 'wpdirectorykit'),
349 'field_type' => 'CHECKBOX',
350 'rules' => '',
351 ),
352 array(
353 'field' => 'wdk_experimental_listing_card_elementor_layout',
354 'field_label' => __('Listing Card', 'wpdirectorykit'),
355 'hint' => __('Allow Listing card layout in elementor', 'wpdirectorykit'),
356 'field_type' => 'CHECKBOX',
357 'rules' => '',
358 ),
359 array(
360 'field' => 'wdk_experimental_listing_popup',
361 'field_label' => __('Listing Preview Popup', 'wpdirectorykit'),
362 'hint' => __('Open Listing preview in popup', 'wpdirectorykit'),
363 'field_type' => 'CHECKBOX',
364 'rules' => '',
365 ),
366 );
367 }
368
369 foreach ($this->fields_list_tabs as $tab_fields) {
370 foreach ($tab_fields as $field) {
371 $this->fields_list[] = $field;
372 }
373 }
374 }
375
376 /* [START] For dynamic data table */
377
378 public function get_available_fields()
379 {
380 $fields = $this->db->list_fields($this->_table_name);
381
382 return $fields;
383 }
384
385 public function total_lang($where = array())
386 {
387 $this->db->select('COUNT(*) as total_count');
388 $this->db->from($this->_table_name);
389 $this->db->where($where);
390 $this->db->order_by($this->_order_by);
391 $query = $this->db->get();
392 $res = $this->db->results();
393
394 if(isset($res[0]->total_count))
395 return $res[0]->total_count;
396
397 return 0;
398 }
399
400 public function get_pagination_lang($limit, $offset, $where = array())
401 {
402 $this->db->select('*');
403 $this->db->from($this->_table_name);
404 $this->db->where($where);
405 $this->db->limit($limit);
406 $this->db->offset($offset);
407 $this->db->order_by($this->_order_by);
408 $query = $this->db->get();
409
410 if ($this->db->num_rows() > 0)
411 return $this->db->results();
412
413 return array();
414 }
415
416 public function check_deletable($id)
417 {
418 return true;
419 }
420
421 /* [END] For dynamic data table */
422
423
424 /* only admin can edit */
425 public function is_related($item_id, $user_id, $method = 'edit')
426 {
427 return false;
428 }
429 }
430