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

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

390 lines 21.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 Symbol', '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 );
145
146 /* Fields */
147 $this->fields_list_tabs['fields'] = array(
148 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' => ''),
149 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' => ''),
150
151 array(
152 'field' => 'wdk_multi_locations_search_field_type',
153 'field_label' => __('Location field Search', 'wpdirectorykit'),
154 'field_type' => 'RADIO',
155 'hint' => __('Visible on search form', 'wpdirectorykit'),
156 'rules' => '',
157 'values' => array(
158 '' => esc_html__('Single Tree Dropdown', 'wpdirectorykit'),
159 'select2' => esc_html__('Multi Select Dropdown', 'wpdirectorykit'),
160 'wdk_treefield_dropdown' => esc_html__('Multiple Dropdowns', 'wpdirectorykit'),
161 'wdk_treefield_checkboxes' => esc_html__('Single Tree Dropdown with checkboxes', 'wpdirectorykit'),
162 )
163 ),
164
165 array(
166 'field' => 'wdk_multi_categories_search_field_type',
167 'field_label' => __('Categoreis field Search', 'wpdirectorykit'),
168 'field_type' => 'RADIO',
169 'hint' => __('Visible on search form. Hiding field in search form based on category is only possible when using single tree dropdown', 'wpdirectorykit'),
170 'rules' => '',
171 'values' => array(
172 '' => esc_html__('Single Tree Dropdown', 'wpdirectorykit'),
173 'select2' => esc_html__('Multi Select Dropdown', 'wpdirectorykit'),
174 'wdk_treefield_dropdown' => esc_html__('Multiple Dropdowns', 'wpdirectorykit'),
175 'wdk_treefield_checkboxes' => esc_html__('Single Tree Dropdown with checkboxes', 'wpdirectorykit'),
176 )
177 ),
178
179 array(
180 'field' => 'wdk_multi_locations_edit_field_type',
181 'field_label' => __('Location field edit', 'wpdirectorykit'),
182 'field_type' => 'RADIO',
183 'hint' => __('Visible on edit form', 'wpdirectorykit'),
184 'rules' => '',
185 'values' => array(
186 '' => esc_html__('Single Tree Dropdown', 'wpdirectorykit'),
187 'wdk_treefield_dropdown' => esc_html__('Multiple Dropdowns', 'wpdirectorykit'),
188 )
189 ),
190
191 array(
192 'field' => 'wdk_multi_categories_edit_field_type',
193 'field_label' => __('Categoreis field edit', 'wpdirectorykit'),
194 'field_type' => 'RADIO',
195 'hint' => __('Visible on edit form. Hiding field in edit form based on category is only possible when using single tree dropdown', 'wpdirectorykit'),
196 'rules' => '',
197 'values' => array(
198 '' => esc_html__('Single Tree Dropdown', 'wpdirectorykit'),
199 'wdk_treefield_dropdown' => esc_html__('Multiple Dropdowns', 'wpdirectorykit'),
200 )
201 ),
202
203 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' => ''),
204 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' => ''),
205 array(
206 'field' => 'wdk_listing_plangs_documents_disable',
207 'field_label' => __('Disable "Listing plans and documents"', 'wpdirectorykit'),
208 'hint' => '',
209 'field_type' => 'CHECKBOX',
210 'rules' => '',
211 ),
212 );
213
214 /* Api-s */
215 $this->fields_list_tabs['apis'] = array(
216 array(
217 'field' => 'wdk_recaptcha_site_key',
218 'field_label' => __('Recaptcha site key', 'wpdirectorykit'),
219 'hint' => __('Please add Recaptcha site and Secret keys for enable recaptcha Add Google Recaptcha site key (use V2 recaptcha key)', 'wpdirectorykit'),
220 'field_type' => 'INPUTBOX',
221 'rules' => '',
222 ),
223 array(
224 'field' => 'wdk_recaptcha_secret_key',
225 'field_label' => __('Recaptcha site secret key', 'wpdirectorykit'),
226 'hint' => __('Add Google Recaptcha secret key', 'wpdirectorykit'),
227 'field_type' => 'INPUTBOX',
228 'rules' => '',
229 ),
230 array(
231 'field' => 'wdk_geo_google_api_key',
232 'field_label' => __('Google Maps API Key', 'wpdirectorykit'),
233 'hint' => __('Google Maps API Key', 'wpdirectorykit'),
234 'field_type' => 'INPUTBOX',
235 'rules' => '',
236 ),
237 array(
238 'field' => 'wdk_import_google_api_enable',
239 'field_label' => __('Google API for import listings', 'wpdirectorykit'),
240 'hint' => __('Google API key will be used to autodetect GPS coordinates when importing listing', 'wpdirectorykit'),
241 'field_type' => 'CHECKBOX',
242 'rules' => '',
243 ),
244 array(
245 'field' => 'wdk_geo_coding_results_location',
246 'field_label' => __('Auto Search based on Geo Coding', 'wpdirectorykit'),
247 'hint' => __('if this is enabled, search auto search listings', 'wpdirectorykit'),
248 'field_type' => 'CHECKBOX',
249 'rules' => '',
250 ),
251 );
252
253 $this->fields_list_tabs['general'] = array(
254 array('field' => 'wdk_default_lat', 'field_label' => __('Default GPS Position', 'wpdirectorykit'), 'hint' => '', 'field_type' => 'MAP', 'rules' => ''),
255 array('field' => 'wdk_default_lng', 'field_label' => __('Default GPS Longitude', 'wpdirectorykit'), 'hint' => '', 'field_type' => 'INPUTBOX', 'rules' => '', 'class' => 'hidden'),
256 array('field' => 'wdk_fixed_map_results_position', 'field_label' => __('Fix map center on default location', 'wpdirectorykit'), 'hint' => '', 'field_type' => 'CHECKBOX', 'rules' => '', 'class' => ''),
257
258 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' => ''),
259 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' => ''),
260
261
262 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' => ''),
263 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'),
264 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),
265 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),
266 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' => ''),
267
268 array(
269 'field' => 'wdk_card_video_enable',
270 'field_label' => __('Card Video From gallery in result card enable', 'wpdirectorykit'),
271 'hint' => __('If you upload video on first place in listing, will become visible in result card', 'wpdirectorykit'),
272 'field_type' => 'CHECKBOX',
273 'rules' => '',
274 ),
275 array(
276 'field' => 'wdk_listing_category_required',
277 'field_label' => __('Category is required field', 'wpdirectorykit'),
278 'hint' => __('if this is enabled, listing required category field', 'wpdirectorykit'),
279 'field_type' => 'CHECKBOX',
280 'rules' => '',
281 ),
282 array(
283 'field' => 'wdk_listing_location_required',
284 'field_label' => __('Location is required field', 'wpdirectorykit'),
285 'hint' => __('if this is enabled, listing required location field', 'wpdirectorykit'),
286 'field_type' => 'CHECKBOX',
287 'rules' => '',
288 ),
289
290 array(
291 'field' => 'wdk_sub_listings_enable',
292 'field_label' => __('Related Listings', 'wpdirectorykit'),
293 'field_type' => 'CHECKBOX',
294 'rules' => '',
295 ),
296 array(
297 'field' => 'wdk_listings_images_required_enable',
298 'field_label' => __('Listing Images required', 'wpdirectorykit'),
299 'field_type' => 'CHECKBOX',
300 'rules' => '',
301 ),
302 array(
303 'field' => 'wdk_default_currency_symbol',
304 'field_label' => __('Default Currency Symbol', 'wpdirectorykit'),
305 'hint' => __('Put default currency symbol like $', 'wpdirectorykit'),
306 'field_type' => 'INPUTBOX',
307 'rules' => '',
308 ),
309 );
310
311 if(function_exists('run_wdk_geo')) {
312 $this->fields_list_tabs['apis'][] = array(
313 'field' => 'wdk_geo_autodetect_by_google_js_enable',
314 'field_label' => __('Enable location autodetect by Google JS', 'wpdirectorykit'),
315 'hint' => __('This using Google JS API, require API key and user need to allow this in Browser (is most accurate)', 'wpdirectorykit'),
316 'field_type' => 'CHECKBOX',
317 'rules' => '',
318 );
319
320 $this->fields_list_tabs['apis'][] = array(
321 'field' => 'wdk_geo_autodetect_by_ip_enable',
322 'field_label' => __('Enable location autodatect by IP', 'wpdirectorykit'),
323 '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'),
324 'field_type' => 'CHECKBOX',
325 'rules' => '',
326 );
327 }
328
329 foreach ($this->fields_list_tabs as $tab_fields) {
330 foreach ($tab_fields as $field) {
331 $this->fields_list[] = $field;
332 }
333 }
334 }
335
336 /* [START] For dynamic data table */
337
338 public function get_available_fields()
339 {
340 $fields = $this->db->list_fields($this->_table_name);
341
342 return $fields;
343 }
344
345 public function total_lang($where = array())
346 {
347 $this->db->select('COUNT(*) as total_count');
348 $this->db->from($this->_table_name);
349 $this->db->where($where);
350 $this->db->order_by($this->_order_by);
351 $query = $this->db->get();
352 $res = $this->db->results();
353
354 if(isset($res[0]->total_count))
355 return $res[0]->total_count;
356
357 return 0;
358 }
359
360 public function get_pagination_lang($limit, $offset, $where = array())
361 {
362 $this->db->select('*');
363 $this->db->from($this->_table_name);
364 $this->db->where($where);
365 $this->db->limit($limit);
366 $this->db->offset($offset);
367 $this->db->order_by($this->_order_by);
368 $query = $this->db->get();
369
370 if ($this->db->num_rows() > 0)
371 return $this->db->results();
372
373 return array();
374 }
375
376 public function check_deletable($id)
377 {
378 return true;
379 }
380
381 /* [END] For dynamic data table */
382
383
384 /* only admin can edit */
385 public function is_related($item_id, $user_id, $method = 'edit')
386 {
387 return false;
388 }
389 }
390