| 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_featured_enabled', 'field_label' => __('Enable Field and Feature Featured Listing', '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_is_rank_enabled', 'field_label' => __('Enable Field and Feature Rank Listing', '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' => ''), |
| 65 |
array('field' => 'wdk_is_user_editor_enabled', 'field_label' => __('Enable Field and Feature Agent Listing', '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' => ''), |
| 66 |
array('field' => 'wdk_is_post_content_enable', 'field_label' => __('Enable Field and Feature Post Content Listing', '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' => ''), |
| 67 |
array('field' => 'wdk_is_alt_agent_enabled', 'field_label' => __('Enable Field and Feature Agent Listing', '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' => ''), |
| 68 |
|
| 69 |
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'), |
| 70 |
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), |
| 71 |
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), |
| 72 |
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' => ''), |
| 73 |
|
| 74 |
array( |
| 75 |
'field' => 'wdk_card_video_enable', |
| 76 |
'field_label' => __('Card Video From gallery in result card enable', 'wpdirectorykit'), |
| 77 |
'hint' => __('If you upload video on first place in listing, will become visible in result card', 'wpdirectorykit'), |
| 78 |
'field_type' => 'CHECKBOX', |
| 79 |
'rules' => '', |
| 80 |
), |
| 81 |
array( |
| 82 |
'field' => 'wdk_listing_category_required', |
| 83 |
'field_label' => __('Category is required field', 'wpdirectorykit'), |
| 84 |
'hint' => __('if this is enabled, listing required category field', 'wpdirectorykit'), |
| 85 |
'field_type' => 'CHECKBOX', |
| 86 |
'rules' => '', |
| 87 |
), |
| 88 |
array( |
| 89 |
'field' => 'wdk_listing_location_required', |
| 90 |
'field_label' => __('Location is required field', 'wpdirectorykit'), |
| 91 |
'hint' => __('if this is enabled, listing required location field', 'wpdirectorykit'), |
| 92 |
'field_type' => 'CHECKBOX', |
| 93 |
'rules' => '', |
| 94 |
), |
| 95 |
|
| 96 |
array( |
| 97 |
'field' => 'wdk_sub_listings_enable', |
| 98 |
'field_label' => __('Related Listings', 'wpdirectorykit'), |
| 99 |
'field_type' => 'CHECKBOX', |
| 100 |
'rules' => '', |
| 101 |
), |
| 102 |
array( |
| 103 |
'field' => 'wdk_listings_images_required_enable', |
| 104 |
'field_label' => __('Listing Images required', 'wpdirectorykit'), |
| 105 |
'field_type' => 'CHECKBOX', |
| 106 |
'rules' => '', |
| 107 |
), |
| 108 |
array( |
| 109 |
'field' => 'wdk_default_currency_symbol', |
| 110 |
'field_label' => __('Default Currency Symbol1', 'wpdirectorykit'), |
| 111 |
'hint' => __('Put default currency symbol like $', 'wpdirectorykit'), |
| 112 |
'field_type' => 'INPUTBOX', |
| 113 |
'rules' => '', |
| 114 |
), |
| 115 |
); |
| 116 |
|
| 117 |
|
| 118 |
/* Templates */ |
| 119 |
$this->fields_list_tabs['templates'] = array( |
| 120 |
array( |
| 121 |
'field' => 'wdk_placeholder', |
| 122 |
'field_label' => __('Cooming soon listing image', 'wpdirectorykit'), |
| 123 |
'hint' => '', |
| 124 |
'field_type' => 'UPLOAD', |
| 125 |
'rules' => '', |
| 126 |
), |
| 127 |
array( |
| 128 |
'field' => 'wdk_card_slider_enable', |
| 129 |
'field_label' => __('Show slider in result card', 'wpdirectorykit'), |
| 130 |
'hint' => '', |
| 131 |
'field_type' => 'CHECKBOX', |
| 132 |
'rules' => '', |
| 133 |
), |
| 134 |
array( |
| 135 |
'field' => 'wdk_card_video_field', |
| 136 |
'field_label' => __('Card video field', 'wpdirectorykit'), |
| 137 |
'hint' => '', |
| 138 |
'field_type' => 'DROPDOWN', |
| 139 |
'values' => $fields_list_inputs, |
| 140 |
'rules' => '', |
| 141 |
'hint' => '', |
| 142 |
), |
| 143 |
array( |
| 144 |
'field' => 'wdk_mobile_bottom_navbar_enable', |
| 145 |
'field_label' => __('Mobile bottom navbar', 'wpdirectorykit'), |
| 146 |
'field_type' => 'CHECKBOX', |
| 147 |
'rules' => '', |
| 148 |
), |
| 149 |
array( |
| 150 |
'field' => 'wdk_mobile_bottom_show_menu_disable', |
| 151 |
'field_label' => __('Mobile bottom navbar, hide menu button', 'wpdirectorykit'), |
| 152 |
'hint' => __('Menu button only works, when using menu from ElementInvader addons plugins', 'wpdirectorykit'), |
| 153 |
'field_type' => 'CHECKBOX', |
| 154 |
'rules' => '', |
| 155 |
), |
| 156 |
array( |
| 157 |
'field' => 'wdk_field_search_suggestion_disable', |
| 158 |
'field_label' => __('Smart Search Suggestion Disable', 'wpdirectorykit'), |
| 159 |
'field_type' => 'CHECKBOX', |
| 160 |
'rules' => '', |
| 161 |
), |
| 162 |
); |
| 163 |
|
| 164 |
$this->fields_list_tabs['templates'] [] = array( |
| 165 |
'field' => 'wdk_multilingual_float_language_picker', |
| 166 |
'field_label' => __('Float Language Picker', 'wpdirectorykit'), |
| 167 |
'field_type' => 'CHECKBOX', |
| 168 |
'hint' => __('Multilingual float language picker required WDK Multilingual addon', 'wpdirectorykit'), |
| 169 |
'hint' => wdk_sprintf(__('Multilingual float language picker required %1$s WDK Multilingual addon%2$s','wpdirectorykit'),'<a target="_blank" href="https://wpdirectorykit.com/plugins.html">','</a>'), |
| 170 |
'rules' => '', |
| 171 |
); |
| 172 |
|
| 173 |
/* Fields */ |
| 174 |
$this->fields_list_tabs['fields'] = array( |
| 175 |
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' => ''), |
| 176 |
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' => ''), |
| 177 |
|
| 178 |
array( |
| 179 |
'field' => 'wdk_multi_locations_search_field_type', |
| 180 |
'field_label' => __('Location field Search', 'wpdirectorykit'), |
| 181 |
'field_type' => 'RADIO', |
| 182 |
'hint' => __('Visible on search form', 'wpdirectorykit'), |
| 183 |
'rules' => '', |
| 184 |
'values' => array( |
| 185 |
'' => esc_html__('Single Tree Dropdown', 'wpdirectorykit'), |
| 186 |
'select2' => esc_html__('Multi Select Dropdown', 'wpdirectorykit'), |
| 187 |
'wdk_treefield_dropdown' => esc_html__('Multiple Dropdowns', 'wpdirectorykit'), |
| 188 |
'wdk_treefield_checkboxes' => esc_html__('Single Tree Dropdown with checkboxes', 'wpdirectorykit'), |
| 189 |
) |
| 190 |
), |
| 191 |
|
| 192 |
array( |
| 193 |
'field' => 'wdk_multi_categories_search_field_type', |
| 194 |
'field_label' => __('Categoreis field Search', 'wpdirectorykit'), |
| 195 |
'field_type' => 'RADIO', |
| 196 |
'hint' => __('Visible on search form. Hiding field in search form based on category is only possible when using single tree dropdown', 'wpdirectorykit'), |
| 197 |
'rules' => '', |
| 198 |
'values' => array( |
| 199 |
'' => esc_html__('Single Tree Dropdown', 'wpdirectorykit'), |
| 200 |
'select2' => esc_html__('Multi Select Dropdown', 'wpdirectorykit'), |
| 201 |
'wdk_treefield_dropdown' => esc_html__('Multiple Dropdowns', 'wpdirectorykit'), |
| 202 |
'wdk_treefield_checkboxes' => esc_html__('Single Tree Dropdown with checkboxes', 'wpdirectorykit'), |
| 203 |
) |
| 204 |
), |
| 205 |
|
| 206 |
array( |
| 207 |
'field' => 'wdk_multi_locations_edit_field_type', |
| 208 |
'field_label' => __('Location field edit', 'wpdirectorykit'), |
| 209 |
'field_type' => 'RADIO', |
| 210 |
'hint' => __('Visible on edit form', 'wpdirectorykit'), |
| 211 |
'rules' => '', |
| 212 |
'values' => array( |
| 213 |
'' => esc_html__('Single Tree Dropdown', 'wpdirectorykit'), |
| 214 |
'wdk_treefield_dropdown' => esc_html__('Multiple Dropdowns', 'wpdirectorykit'), |
| 215 |
) |
| 216 |
), |
| 217 |
|
| 218 |
array( |
| 219 |
'field' => 'wdk_multi_categories_edit_field_type', |
| 220 |
'field_label' => __('Categoreis field edit', 'wpdirectorykit'), |
| 221 |
'field_type' => 'RADIO', |
| 222 |
'hint' => __('Visible on edit form. Hiding field in edit form based on category is only possible when using single tree dropdown', 'wpdirectorykit'), |
| 223 |
'rules' => '', |
| 224 |
'values' => array( |
| 225 |
'' => esc_html__('Single Tree Dropdown', 'wpdirectorykit'), |
| 226 |
'wdk_treefield_dropdown' => esc_html__('Multiple Dropdowns', 'wpdirectorykit'), |
| 227 |
) |
| 228 |
), |
| 229 |
|
| 230 |
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' => ''), |
| 231 |
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' => ''), |
| 232 |
array( |
| 233 |
'field' => 'wdk_listing_plangs_documents_disable', |
| 234 |
'field_label' => __('Disable "Listing plans and documents"', 'wpdirectorykit'), |
| 235 |
'hint' => '', |
| 236 |
'field_type' => 'CHECKBOX', |
| 237 |
'rules' => '', |
| 238 |
), |
| 239 |
array( |
| 240 |
'field' => 'wdk_listing_images_disable', |
| 241 |
'field_label' => __('Disable "Listing images"', 'wpdirectorykit'), |
| 242 |
'hint' => '', |
| 243 |
'field_type' => 'CHECKBOX', |
| 244 |
'rules' => '', |
| 245 |
), |
| 246 |
|
| 247 |
|
| 248 |
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' => ''), |
| 249 |
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' => ''), |
| 250 |
array('field' => 'wdk_is_address_enabled', 'field_label' => __('Enable Address', 'wpdirectorykit'), 'hint' => __('Enable this option to display the address field on the listing submission page', 'wpdirectorykit'), 'field_type' => 'CHECKBOX', 'rules' => ''), |
| 251 |
array('field' => 'wdk_is_featured_enabled', 'field_label' => __('Enable Field and Feature Featured Listing', 'wpdirectorykit'), 'hint' => __('Enable this option to allow marking listings as Featured on the submission page.', 'wpdirectorykit'), 'field_type' => 'CHECKBOX', 'rules' => ''), |
| 252 |
array('field' => 'wdk_is_rank_enabled', 'field_label' => __('Enable Field and Feature Rank Listing', 'wpdirectorykit'), 'hint' => __('Enable this option to allow assigning a rank to listings on the submission page.', 'wpdirectorykit'), 'field_type' => 'CHECKBOX', 'rules' => ''), |
| 253 |
array('field' => 'wdk_is_user_editor_enabled', 'field_label' => __('Enable Field and Feature Agent Listing', 'wpdirectorykit'), 'hint' => __('Enable this option to allow selecting an agent for the listing.', 'wpdirectorykit'), 'field_type' => 'CHECKBOX', 'rules' => ''), |
| 254 |
array('field' => 'wdk_is_post_content_enable', 'field_label' => __('Enable Field and Feature Post Content Listing', 'wpdirectorykit'), 'hint' => __('Enable this option to show the post content field on the submission page.', 'wpdirectorykit'), 'field_type' => 'CHECKBOX', 'rules' => ''), |
| 255 |
array( |
| 256 |
'field' => 'wdk_is_alt_agent_enabled', |
| 257 |
'field_label' => __('Enable Alternate Agent for Listing', 'wpdirectorykit'), |
| 258 |
'hint' => __('Enable this option to allow assigning an alternate agent to the listing.', 'wpdirectorykit'), |
| 259 |
'field_type' => 'CHECKBOX', |
| 260 |
'rules' => '', |
| 261 |
), |
| 262 |
array( |
| 263 |
'field' => 'wdk_sub_listings_enable', |
| 264 |
'field_label' => __('Related Listings', 'wpdirectorykit'), |
| 265 |
'field_type' => 'CHECKBOX', |
| 266 |
'rules' => '', |
| 267 |
), |
| 268 |
array( |
| 269 |
'field' => 'wdk_listings_images_required_enable', |
| 270 |
'field_label' => __('Listing Images required', 'wpdirectorykit'), |
| 271 |
'field_type' => 'CHECKBOX', |
| 272 |
'rules' => '', |
| 273 |
), |
| 274 |
array( |
| 275 |
'field' => 'wdk_enable_filter_zero_decimal', |
| 276 |
'field_label' => __('Enable filter zero decimal', 'wpdirectorykit'), |
| 277 |
'field_type' => 'CHECKBOX', |
| 278 |
'rules' => '', |
| 279 |
), |
| 280 |
array( |
| 281 |
'field' => 'wdk_number_format_decimal_point', |
| 282 |
'field_label' => __('Number Decimal Places', 'wpdirectorykit'), |
| 283 |
'hint' => __('Default based on language selected in WordPress', 'wpdirectorykit'), |
| 284 |
'field_type' => 'DROPDOWN', |
| 285 |
'empty_default' => esc_attr((!empty(get_option('wdk_number_format_decimal_point')) ? get_option('wdk_number_format_decimal_point') : get_option('decimal_point', ','))), |
| 286 |
'values' => array( |
| 287 |
'.' => __('Dot (.)', 'wpdirectorykit'), |
| 288 |
"'" => __('Quote (\')', 'wpdirectorykit'), |
| 289 |
',' => __('Comma (,)', 'wpdirectorykit'), |
| 290 |
' ' => __('Space', 'wpdirectorykit'), |
| 291 |
), |
| 292 |
'rules' => '' |
| 293 |
), |
| 294 |
array( |
| 295 |
'field' => 'wdk_number_format_thousands_sep', |
| 296 |
'field_label' => __('Number Format Thousands sep', 'wpdirectorykit'), |
| 297 |
'hint' => __('Default based on language selected in WordPress', 'wpdirectorykit'), |
| 298 |
'field_type' => 'DROPDOWN', |
| 299 |
'empty_default' => esc_attr((!empty(get_option('wdk_number_format_thousands_sep')) ? get_option('wdk_number_format_thousands_sep') : get_option('thousands_separator', ','))), |
| 300 |
'rules' => '', |
| 301 |
'values' => array( |
| 302 |
'.' => __('Dot (.)', 'wpdirectorykit'), |
| 303 |
',' => __('Comma (,)', 'wpdirectorykit'), |
| 304 |
"'" => __('Quote (\')', 'wpdirectorykit'), |
| 305 |
' ' => __('Space', 'wpdirectorykit'), |
| 306 |
), |
| 307 |
), |
| 308 |
array( |
| 309 |
'field' => 'wdk_number_format_decimals', |
| 310 |
'field_label' => __('Number Format Decimal count', 'wpdirectorykit'), |
| 311 |
'hint' => __('Default based on language selected in WordPress', 'wpdirectorykit'), |
| 312 |
'field_type' => 'NUMBER', |
| 313 |
'min' => '0', |
| 314 |
'max' => '5', |
| 315 |
'step' => '1', |
| 316 |
'rules' => '', |
| 317 |
'empty_default' => esc_attr(get_option('wdk_number_format_decimals', get_option('wdk_number_format_decimals', get_option('woocommerce_price_num_decimals', 2)))), |
| 318 |
), |
| 319 |
array( |
| 320 |
'field' => 'wdk_number_format_decimals', |
| 321 |
'field_label' => __('Current Number Format', 'wpdirectorykit'), |
| 322 |
'hint' => __('Example price format based on WordPress language or above configuration (1234567.89)', 'wpdirectorykit'), |
| 323 |
'field_type' => 'RAW', |
| 324 |
'rules' => '', |
| 325 |
'raw' => '<span id="wdk_example_price_format" class="label label-info" style="font-size:14px">'.wdk_number_format_i18n(1234567.89).'</span>', |
| 326 |
), |
| 327 |
array( |
| 328 |
'field' => 'wdk_custom_listings_link_field', |
| 329 |
'field_label' => __('Custom Field, like extern link for listing preview', 'wpdirectorykit'), |
| 330 |
'hint' => __('Value for this field, replace listing preview link if not empty', 'wpdirectorykit'), |
| 331 |
'field_type' => 'DROPDOWN', |
| 332 |
'values' => $fields_list_inputs, |
| 333 |
'rules' => '', |
| 334 |
), |
| 335 |
); |
| 336 |
|
| 337 |
/* Api-s */ |
| 338 |
$this->fields_list_tabs['apis'] = array( |
| 339 |
array( |
| 340 |
'field' => 'wdk_recaptcha_site_key', |
| 341 |
'field_label' => __('Recaptcha site key', 'wpdirectorykit'), |
| 342 |
'hint' => __('Please add Recaptcha site and Secret keys for enable recaptcha Add Google Recaptcha site key (use V2 recaptcha key)', 'wpdirectorykit').'. '.wdk_sprintf(__('Get key %1$s here %2$s','wpdirectorykit'),'<a target="_blank" href="https://www.google.com/recaptcha/admin">','</a>'), |
| 343 |
'field_type' => 'INPUTBOX', |
| 344 |
'rules' => '', |
| 345 |
), |
| 346 |
array( |
| 347 |
'field' => 'wdk_recaptcha_secret_key', |
| 348 |
'field_label' => __('Recaptcha site secret key', 'wpdirectorykit'), |
| 349 |
'hint' => __('Add Google Recaptcha secret key', 'wpdirectorykit'), |
| 350 |
'field_type' => 'INPUTBOX', |
| 351 |
'rules' => '', |
| 352 |
), |
| 353 |
array( |
| 354 |
'field' => 'wdk_recaptcha_site_key_v3', |
| 355 |
'field_label' => __('Recaptcha site key v3', 'wpdirectorykit'), |
| 356 |
'hint' => __('Please add Recaptcha site and Secret keys for enable recaptcha Add Google Recaptcha site key (use V3 recaptcha key)', 'wpdirectorykit').'. '.wdk_sprintf(__('Get key %1$s here %2$s','wpdirectorykit'),'<a target="_blank" href="https://www.google.com/recaptcha/admin">','</a>'), |
| 357 |
'field_type' => 'INPUTBOX', |
| 358 |
'rules' => '', |
| 359 |
), |
| 360 |
array( |
| 361 |
'field' => 'wdk_recaptcha_secret_key_v3', |
| 362 |
'field_label' => __('Recaptcha site secret key v3', 'wpdirectorykit'), |
| 363 |
'hint' => __('Add Google Recaptcha secret key', 'wpdirectorykit'), |
| 364 |
'field_type' => 'INPUTBOX', |
| 365 |
'rules' => '', |
| 366 |
), |
| 367 |
array( |
| 368 |
'field' => 'wdk_geo_google_api_key', |
| 369 |
'field_label' => __('Google API Key', 'wpdirectorykit'), |
| 370 |
'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>'), |
| 371 |
'field_type' => 'INPUTBOX', |
| 372 |
'rules' => '', |
| 373 |
), |
| 374 |
array( |
| 375 |
'field' => 'wdk_import_google_api_enable', |
| 376 |
'field_label' => __('Google API for import listings', 'wpdirectorykit'), |
| 377 |
'hint' => __('Google API key will be used to autodetect GPS coordinates when importing listing', 'wpdirectorykit'), |
| 378 |
'field_type' => 'CHECKBOX', |
| 379 |
'rules' => '', |
| 380 |
), |
| 381 |
array( |
| 382 |
'field' => 'wdk_geo_coding_results_location', |
| 383 |
'field_label' => __('Auto Search based on Geo Coding', 'wpdirectorykit'), |
| 384 |
'hint' => __('if this is enabled, auto search listings based on found geo location', 'wpdirectorykit'), |
| 385 |
'field_type' => 'CHECKBOX', |
| 386 |
'rules' => '', |
| 387 |
), |
| 388 |
); |
| 389 |
|
| 390 |
$this->fields_list_tabs['general'] = array( |
| 391 |
array('field' => 'wdk_default_lat', 'field_label' => __('Default GPS Position', 'wpdirectorykit'), 'hint' => '', 'field_type' => 'MAP', 'rules' => ''), |
| 392 |
array('field' => 'wdk_default_lng', 'field_label' => __('Default GPS Longitude', 'wpdirectorykit'), 'hint' => '', 'field_type' => 'INPUTBOX', 'rules' => '', 'class' => 'hidden'), |
| 393 |
array('field' => 'wdk_fixed_map_results_position', 'field_label' => __('Fix map center on default location', 'wpdirectorykit'), 'hint' => '', 'field_type' => 'CHECKBOX', 'rules' => '', 'class' => ''), |
| 394 |
|
| 395 |
|
| 396 |
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'), |
| 397 |
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), |
| 398 |
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), |
| 399 |
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' => ''), |
| 400 |
|
| 401 |
array( |
| 402 |
'field' => 'wdk_card_video_enable', |
| 403 |
'field_label' => __('Card Video From gallery in result card enable', 'wpdirectorykit'), |
| 404 |
'hint' => __('If you upload video on first place in listing, will become visible in result card', 'wpdirectorykit'), |
| 405 |
'field_type' => 'CHECKBOX', |
| 406 |
'rules' => '', |
| 407 |
), |
| 408 |
array( |
| 409 |
'field' => 'wdk_listing_category_required', |
| 410 |
'field_label' => __('Category is required field', 'wpdirectorykit'), |
| 411 |
'hint' => __('if this is enabled, listing required category field', 'wpdirectorykit'), |
| 412 |
'field_type' => 'CHECKBOX', |
| 413 |
'rules' => '', |
| 414 |
), |
| 415 |
array( |
| 416 |
'field' => 'wdk_listing_location_required', |
| 417 |
'field_label' => __('Location is required field', 'wpdirectorykit'), |
| 418 |
'hint' => __('if this is enabled, listing required location field', 'wpdirectorykit'), |
| 419 |
'field_type' => 'CHECKBOX', |
| 420 |
'rules' => '', |
| 421 |
), |
| 422 |
|
| 423 |
array( |
| 424 |
'field' => 'wdk_default_currency_symbol', |
| 425 |
'field_label' => __('Default Currency Symbol', 'wpdirectorykit'), |
| 426 |
'hint' => __('Put default currency symbol like $', 'wpdirectorykit'), |
| 427 |
'field_type' => 'INPUTBOX', |
| 428 |
'rules' => '', |
| 429 |
), |
| 430 |
array( |
| 431 |
'field' => 'wdk_disable_toolbar_on_content_editor', |
| 432 |
'field_label' => __('Disable toolbar on content editor', 'wpdirectorykit'), |
| 433 |
'field_type' => 'CHECKBOX', |
| 434 |
'rules' => '', |
| 435 |
), |
| 436 |
array( |
| 437 |
'field' => 'wdk_experimental_features', |
| 438 |
'field_label' => __('Experimental features', 'wpdirectorykit'), |
| 439 |
'hint' => '', |
| 440 |
'field_type' => 'CHECKBOX', |
| 441 |
'rules' => '', |
| 442 |
), |
| 443 |
); |
| 444 |
|
| 445 |
if(function_exists('run_wdk_geo')) { |
| 446 |
$this->fields_list_tabs['apis'][] = array( |
| 447 |
'field' => 'wdk_geo_autodetect_by_google_js_enable', |
| 448 |
'field_label' => __('Enable location autodetect by Google JS', 'wpdirectorykit'), |
| 449 |
'hint' => __('This using Google JS API, require API key and user need to allow this in Browser (is most accurate)', 'wpdirectorykit'), |
| 450 |
'field_type' => 'CHECKBOX', |
| 451 |
'rules' => '', |
| 452 |
); |
| 453 |
|
| 454 |
$this->fields_list_tabs['apis'][] = array( |
| 455 |
'field' => 'wdk_geo_autodetect_by_ip_enable', |
| 456 |
'field_label' => __('Enable location autodatect by IP', 'wpdirectorykit'), |
| 457 |
'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'), |
| 458 |
'field_type' => 'CHECKBOX', |
| 459 |
'rules' => '', |
| 460 |
); |
| 461 |
} |
| 462 |
|
| 463 |
/* Templates */ |
| 464 |
$this->fields_list_tabs['experimental'] = array( |
| 465 |
array( |
| 466 |
'field' => 'wdk_experimental_search_popup', |
| 467 |
'field_label' => __('Search Popup', 'wpdirectorykit'), |
| 468 |
'hint' => __('Element open search form in popup', 'wpdirectorykit'), |
| 469 |
'field_type' => 'CHECKBOX', |
| 470 |
'rules' => '', |
| 471 |
), |
| 472 |
array( |
| 473 |
'field' => 'wdk_experimental_listing_card_elementor_layout', |
| 474 |
'field_label' => __('Listing Card', 'wpdirectorykit'), |
| 475 |
'hint' => __('Allow Listing card layout in elementor', 'wpdirectorykit'), |
| 476 |
'field_type' => 'CHECKBOX', |
| 477 |
'rules' => '', |
| 478 |
), |
| 479 |
array( |
| 480 |
'field' => 'wdk_experimental_listing_popup', |
| 481 |
'field_label' => __('Listing Preview Popup', 'wpdirectorykit'), |
| 482 |
'hint' => __('Open Listing preview in popup', 'wpdirectorykit'), |
| 483 |
'field_type' => 'CHECKBOX', |
| 484 |
'rules' => '', |
| 485 |
), |
| 486 |
array( |
| 487 |
'field' => 'wdk_experimental_ajax_results', |
| 488 |
'field_label' => __('Ajax results listings', 'wpdirectorykit'), |
| 489 |
'hint' => __('Allow ajax load listings for map, results container. Reload results with pagination/search form. After activate settings, also action "Reload content with ajax" in elementor options', 'wpdirectorykit'), |
| 490 |
'field_type' => 'CHECKBOX', |
| 491 |
'rules' => '', |
| 492 |
), |
| 493 |
); |
| 494 |
|
| 495 |
/* Autosuggestion */ |
| 496 |
$this->fields_list_tabs['autosuggestion'] = array( |
| 497 |
array( |
| 498 |
'field' => 'wdk_autosuggestion_google_api_key', |
| 499 |
'field_label' => __('Google Api Key', 'wdk-autosuggestion'), |
| 500 |
'field_type' => 'INPUTBOX', |
| 501 |
'rules' => '', |
| 502 |
), |
| 503 |
array( |
| 504 |
'field' => 'wdk_autosuggestion_google_cities', |
| 505 |
'field_label' => __('Autosuggestion Google Cities', 'wdk-autosuggestion'), |
| 506 |
'field_type' => 'TEXTAREA', |
| 507 |
'rules' => '', |
| 508 |
'hint' => __('Put selectors separate by comma, like .field_1,.field_3 (required Google Api Key)', 'wdk-autosuggestion'), |
| 509 |
), |
| 510 |
array( |
| 511 |
'field' => 'wdk_autosuggestion_google_countries', |
| 512 |
'field_label' => __('Autosuggestion Google Countries', 'wdk-autosuggestion'), |
| 513 |
'field_type' => 'TEXTAREA', |
| 514 |
'rules' => '', |
| 515 |
'hint' => __('Put selectors separate by comma, like .field_1,.field_3 (required Google Api Key)', 'wdk-autosuggestion'), |
| 516 |
), |
| 517 |
|
| 518 |
array( |
| 519 |
'field' => 'wdk_autosuggestion_rapidapi_api_key', |
| 520 |
'field_label' => __('Rapidapi', 'wdk-autosuggestion'), |
| 521 |
'field_type' => 'INPUTBOX', |
| 522 |
'rules' => '', |
| 523 |
'hint' => wdk_sprintf(__('Please add Rapid Api Key, Get key %1$s here %2$s, then activate GeoDB Cities API','wpdirectorykit'),'<a target="_blank" href="https://rapidapi.com/products/pricing/">','</a>'), |
| 524 |
), |
| 525 |
array( |
| 526 |
'field' => 'wdk_autosuggestion_rapidapi_cities', |
| 527 |
'field_label' => __('Autosuggestion Rapid Api Cities', 'wdk-autosuggestion'), |
| 528 |
'field_type' => 'TEXTAREA', |
| 529 |
'rules' => '', |
| 530 |
'hint' => __('Put selectors separate by comma, like .field_1,.field_3 (required Rapid Api Key)', 'wdk-autosuggestion'), |
| 531 |
), |
| 532 |
array( |
| 533 |
'field' => 'wdk_autosuggestion_rapidapi_countries', |
| 534 |
'field_label' => __('Autosuggestion Rapid Api Countries', 'wdk-autosuggestion'), |
| 535 |
'field_type' => 'TEXTAREA', |
| 536 |
'rules' => '', |
| 537 |
'hint' => __('Put selectors separate by comma, like .field_1,.field_3 (required Rapid Api Key)', 'wdk-autosuggestion'), |
| 538 |
), |
| 539 |
array( |
| 540 |
'field' => 'wdk_autosuggestion_countriesapi_countries', |
| 541 |
'field_label' => __('Autosuggestion REST Countries API Countries', 'wdk-autosuggestion'), |
| 542 |
'field_type' => 'TEXTAREA', |
| 543 |
'rules' => '', |
| 544 |
'hint' => __('Put selectors separate by comma, like .field_1,.field_3', 'wdk-autosuggestion'), |
| 545 |
), |
| 546 |
); |
| 547 |
|
| 548 |
foreach ($this->fields_list_tabs as $tab_fields) { |
| 549 |
foreach ($tab_fields as $field) { |
| 550 |
$this->fields_list[] = $field; |
| 551 |
} |
| 552 |
} |
| 553 |
} |
| 554 |
|
| 555 |
/* [START] For dynamic data table */ |
| 556 |
|
| 557 |
public function get_available_fields() |
| 558 |
{ |
| 559 |
$fields = $this->db->list_fields($this->_table_name); |
| 560 |
|
| 561 |
return $fields; |
| 562 |
} |
| 563 |
|
| 564 |
public function total_lang($where = array()) |
| 565 |
{ |
| 566 |
$this->db->select('COUNT(*) as total_count'); |
| 567 |
$this->db->from($this->_table_name); |
| 568 |
$this->db->where($where); |
| 569 |
$this->db->order_by($this->_order_by); |
| 570 |
$query = $this->db->get(); |
| 571 |
$res = $this->db->results(); |
| 572 |
|
| 573 |
if(isset($res[0]->total_count)) |
| 574 |
return $res[0]->total_count; |
| 575 |
|
| 576 |
return 0; |
| 577 |
} |
| 578 |
|
| 579 |
public function get_pagination_lang($limit, $offset, $where = array()) |
| 580 |
{ |
| 581 |
$this->db->select('*'); |
| 582 |
$this->db->from($this->_table_name); |
| 583 |
$this->db->where($where); |
| 584 |
$this->db->limit($limit); |
| 585 |
$this->db->offset($offset); |
| 586 |
$this->db->order_by($this->_order_by); |
| 587 |
$query = $this->db->get(); |
| 588 |
|
| 589 |
if ($this->db->num_rows() > 0) |
| 590 |
return $this->db->results(); |
| 591 |
|
| 592 |
return array(); |
| 593 |
} |
| 594 |
|
| 595 |
public function check_deletable($id) |
| 596 |
{ |
| 597 |
return true; |
| 598 |
} |
| 599 |
|
| 600 |
/* [END] For dynamic data table */ |
| 601 |
|
| 602 |
|
| 603 |
/* only admin can edit */ |
| 604 |
public function is_related($item_id, $user_id, $method = 'edit') |
| 605 |
{ |
| 606 |
return false; |
| 607 |
} |
| 608 |
} |
| 609 |
|