PluginProbe
WP Directory Kit / 1.1.6
WP Directory Kit v1.1.6
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.1.6, at application/models/Settings_m.php

276 lines 14.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 = NULL;
17
18 public function __construct(){
19 parent::__construct();
20
21 $pages = array('' => __('Not Selected', 'wpdirectorykit'));
22 foreach(get_pages(array('sort_column' => 'post_title')) as $page)
23 {
24 $pages[$page->ID] = $page->post_title.' #'.$page->ID;
25 }
26
27 $WMVC = &wdk_get_instance();
28 $WMVC->model('field_m');
29 $fields_data = $WMVC->field_m->get();
30 $fields_list = array('' => esc_html__('Not Selected', 'wpdirectorykit'));
31 $fields_list_inputs = array('' => esc_html__('Not Selected', 'wpdirectorykit'));
32 $order_i = 0;
33
34 $fields_list ['section'] = esc_html__('-- Section Custom fields --', 'wpdirectorykit');
35 $fields_list ['post_title'] = esc_html__('WP Title', 'wpdirectorykit');
36 $fields_list ['post_content'] = esc_html__('WP Content', 'wpdirectorykit');
37
38 foreach($fields_data as $field)
39 {
40 if(wmvc_show_data('field_type', $field) == 'SECTION') {
41 $fields_list ['section__'.wmvc_show_data('idfield', $field)] = '-- '.esc_html__('Section', 'wpdirectorykit').' '.wmvc_show_data('field_label', $field).' --';
42 } else {
43 $fields_list[wmvc_show_data('idfield', $field)] = '#'.wmvc_show_data('idfield', $field).' '.wmvc_show_data('field_label', $field).'['.wmvc_show_data('field_type', $field).']';
44 }
45
46 if(wmvc_show_data('field_type', $field) == 'INPUTBOX') {
47 $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).']';
48 }
49 }
50
51 $this->fields_list = array(
52 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' => ''),
53 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' => ''),
54
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_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' => ''),
60 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),
61 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),
62 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' => ''),
63 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'),
64 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' => ''),
65 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' => ''),
66
67 array(
68 'field' => 'wdk_recaptcha_site_key',
69 'field_label' => __('Recaptcha site key', 'wpdirectorykit'),
70 'hint' => __('Please add Recaptcha site and Secret keys for enable recaptcha Add Google Recaptcha site key (use V2 recaptcha key)', 'wpdirectorykit'),
71 'field_type' => 'INPUTBOX',
72 'rules' => '',
73 ),
74
75 array(
76 'field' => 'wdk_recaptcha_secret_key',
77 'field_label' => __('Recaptcha site secret key', 'wpdirectorykit'),
78 'hint' => __('Add Google Recaptcha secret key', 'wpdirectorykit'),
79 'field_type' => 'INPUTBOX',
80 'rules' => '',
81 ),
82
83 array(
84 'field' => 'wdk_multi_locations_search_field_type',
85 'field_label' => __('Location field Search', 'wpdirectorykit'),
86 'field_type' => 'RADIO',
87 'hint' => __('Visible on search form', 'wpdirectorykit'),
88 'rules' => '',
89 'values' => array(
90 '' => esc_html__('Single Tree Dropdown', 'wpdirectorykit'),
91 'select2' => esc_html__('Multi Select Dropdown', 'wpdirectorykit'),
92 'wdk_treefield_dropdown' => esc_html__('Multiple Dropdowns', 'wpdirectorykit'),
93 'wdk_treefield_checkboxes' => esc_html__('Single Tree Dropdown with checkboxes', 'wpdirectorykit'),
94 )
95 ),
96
97 array(
98 'field' => 'wdk_multi_categories_search_field_type',
99 'field_label' => __('Categoreis field Search', 'wpdirectorykit'),
100 'field_type' => 'RADIO',
101 'hint' => __('Visible on search form. Hiding field in search form based on category is only possible when using single tree dropdown', 'wpdirectorykit'),
102 'rules' => '',
103 'values' => array(
104 '' => esc_html__('Single Tree Dropdown', 'wpdirectorykit'),
105 'select2' => esc_html__('Multi Select Dropdown', 'wpdirectorykit'),
106 'wdk_treefield_dropdown' => esc_html__('Multiple Dropdowns', 'wpdirectorykit'),
107 'wdk_treefield_checkboxes' => esc_html__('Single Tree Dropdown with checkboxes', 'wpdirectorykit'),
108 )
109 ),
110
111 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' => ''),
112 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' => ''),
113 array(
114 'field' => 'wdk_default_currency_symbol',
115 'field_label' => __('Default Currency Symbol', 'wpdirectorykit'),
116 'hint' => __('Put default currency symbol like $', 'wpdirectorykit'),
117 'field_type' => 'INPUTBOX',
118 'rules' => '',
119 ),
120 array(
121 'field' => 'wdk_listing_plangs_documents_disable',
122 'field_label' => __('Disable "Listing plans and documents"', 'wpdirectorykit'),
123 'hint' => '',
124 'field_type' => 'CHECKBOX',
125 'rules' => '',
126 ),
127 array(
128 'field' => 'wdk_placeholder',
129 'field_label' => __('Cooming soon listing image', 'wpdirectorykit'),
130 'hint' => '',
131 'field_type' => 'UPLOAD',
132 'rules' => '',
133 ),
134 array(
135 'field' => 'wdk_card_slider_enable',
136 'field_label' => __('Show slider in result card', 'wpdirectorykit'),
137 'hint' => '',
138 'field_type' => 'CHECKBOX',
139 'rules' => '',
140 ),
141 array(
142 'field' => 'wdk_card_video_field',
143 'field_label' => __('Card video field', 'wpdirectorykit'),
144 'hint' => '',
145 'field_type' => 'DROPDOWN',
146 'values' => $fields_list_inputs,
147 'rules' => '',
148 'hint' => '',
149 ),
150 array(
151 'field' => 'wdk_card_video_enable',
152 'field_label' => __('Card Video From gallery in result card enable', 'wpdirectorykit'),
153 'hint' => __('If you upload video on first place in listing, will become visible in result card', 'wpdirectorykit'),
154 'field_type' => 'CHECKBOX',
155 'rules' => '',
156 ),
157 array(
158 'field' => 'wdk_geo_google_api_key',
159 'field_label' => __('Google Maps API Key', 'wpdirectorykit'),
160 'hint' => __('Google Maps API Key', 'wpdirectorykit'),
161 'field_type' => 'INPUTBOX',
162 'rules' => '',
163 ),
164 array(
165 'field' => 'wdk_import_google_api_enable',
166 'field_label' => __('Google API for import listings', 'wpdirectorykit'),
167 'hint' => __('Google API key will be used to autodetect GPS coordinates when importing listing', 'wpdirectorykit'),
168 'field_type' => 'CHECKBOX',
169 'rules' => '',
170 ),
171 array(
172 'field' => 'wdk_geo_coding_results_location',
173 'field_label' => __('Auto Search based on Geo Coding', 'wpdirectorykit'),
174 'hint' => __('if this is enabled, search auto search listings', 'wpdirectorykit'),
175 'field_type' => 'CHECKBOX',
176 'rules' => '',
177 ),
178
179 array(
180 'field' => 'wdk_listing_category_required',
181 'field_label' => __('Category is required field', 'wpdirectorykit'),
182 'hint' => __('if this is enabled, listing required category field', 'wpdirectorykit'),
183 'field_type' => 'CHECKBOX',
184 'rules' => '',
185 ),
186 array(
187 'field' => 'wdk_listing_location_required',
188 'field_label' => __('Location is required field', 'wpdirectorykit'),
189 'hint' => __('if this is enabled, listing required location field', 'wpdirectorykit'),
190 'field_type' => 'CHECKBOX',
191 'rules' => '',
192 ),
193 array(
194 'field' => 'wdk_mobile_bottom_navbar_enable',
195 'field_label' => __('Mobile bottom navbar', 'wpdirectorykit'),
196 'field_type' => 'CHECKBOX',
197 'rules' => '',
198 ),
199 );
200
201 if(function_exists('run_wdk_geo')) {
202 $this->fields_list[] = array(
203 'field' => 'wdk_geo_autodetect_by_google_js_enable',
204 'field_label' => __('Enable location autodetect by Google JS', 'wpdirectorykit'),
205 'hint' => __('This using Google JS API, require API key and user need to allow this in Browser (is most accurate)', 'wpdirectorykit'),
206 'field_type' => 'CHECKBOX',
207 'rules' => '',
208 );
209
210 $this->fields_list[] = array(
211 'field' => 'wdk_geo_autodetect_by_ip_enable',
212 'field_label' => __('Enable location autodatect by IP', 'wpdirectorykit'),
213 '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'),
214 'field_type' => 'CHECKBOX',
215 'rules' => '',
216 );
217 }
218
219
220 }
221
222 /* [START] For dynamic data table */
223
224 public function get_available_fields()
225 {
226 $fields = $this->db->list_fields($this->_table_name);
227
228 return $fields;
229 }
230
231 public function total_lang($where = array())
232 {
233 $this->db->select('COUNT(*) as total_count');
234 $this->db->from($this->_table_name);
235 $this->db->where($where);
236 $this->db->order_by($this->_order_by);
237 $query = $this->db->get();
238 $res = $this->db->results();
239
240 if(isset($res[0]->total_count))
241 return $res[0]->total_count;
242
243 return 0;
244 }
245
246 public function get_pagination_lang($limit, $offset, $where = array())
247 {
248 $this->db->select('*');
249 $this->db->from($this->_table_name);
250 $this->db->where($where);
251 $this->db->limit($limit);
252 $this->db->offset($offset);
253 $this->db->order_by($this->_order_by);
254 $query = $this->db->get();
255
256 if ($this->db->num_rows() > 0)
257 return $this->db->results();
258
259 return array();
260 }
261
262 public function check_deletable($id)
263 {
264 return true;
265 }
266
267 /* [END] For dynamic data table */
268
269
270 /* only admin can edit */
271 public function is_related($item_id, $user_id, $method = 'edit')
272 {
273 return false;
274 }
275 }
276