| 1 |
<?php |
| 2 |
/** |
| 3 |
* PropertyHive General Settings |
| 4 |
* |
| 5 |
* @author PropertyHive |
| 6 |
* @category Admin |
| 7 |
* @package PropertyHive/Admin |
| 8 |
* @version 1.0.0 |
| 9 |
*/ |
| 10 |
|
| 11 |
if ( ! defined( 'ABSPATH' ) ) { |
| 12 |
exit; // Exit if accessed directly |
| 13 |
} |
| 14 |
|
| 15 |
if ( ! class_exists( 'PH_Settings_General' ) ) : |
| 16 |
|
| 17 |
/** |
| 18 |
* PH_Settings_General |
| 19 |
*/ |
| 20 |
class PH_Settings_General extends PH_Settings_Page { |
| 21 |
|
| 22 |
/** |
| 23 |
* Constructor. |
| 24 |
*/ |
| 25 |
public function __construct() { |
| 26 |
$this->id = 'general'; |
| 27 |
$this->label = __( 'General', 'propertyhive' ); |
| 28 |
|
| 29 |
add_filter( 'propertyhive_settings_tabs_array', array( $this, 'add_settings_page' ), 5 ); |
| 30 |
add_action( 'propertyhive_sections_' . $this->id, array( $this, 'output_sections' ) ); |
| 31 |
add_action( 'propertyhive_settings_' . $this->id, array( $this, 'output' ) ); |
| 32 |
add_action( 'propertyhive_settings_save_' . $this->id, array( $this, 'save' ) ); |
| 33 |
} |
| 34 |
|
| 35 |
/** |
| 36 |
* Get sections |
| 37 |
* |
| 38 |
* @return array |
| 39 |
*/ |
| 40 |
public function get_sections() { |
| 41 |
$sections = array( |
| 42 |
'' => __( 'General', 'propertyhive' ), |
| 43 |
'modules' => __( 'Modules', 'propertyhive' ), |
| 44 |
'international' => __( 'International', 'propertyhive' ), |
| 45 |
'map' => __( 'Map', 'propertyhive' ), |
| 46 |
'gdpr' => __( 'GDPR', 'propertyhive' ), |
| 47 |
'misc' => __( 'Miscellaneous', 'propertyhive' ), |
| 48 |
); |
| 49 |
|
| 50 |
return $sections; |
| 51 |
} |
| 52 |
|
| 53 |
|
| 54 |
/** |
| 55 |
* Get general settings array |
| 56 |
* |
| 57 |
* @return array |
| 58 |
*/ |
| 59 |
public function get_settings() { |
| 60 |
|
| 61 |
$departments = ph_get_departments(); |
| 62 |
|
| 63 |
$settings = array( |
| 64 |
|
| 65 |
array( 'title' => __( 'General Options', 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'general_options' ), |
| 66 |
|
| 67 |
); |
| 68 |
|
| 69 |
$i = 0; |
| 70 |
foreach ( $departments as $key => $value ) |
| 71 |
{ |
| 72 |
$checkboxgroup = 'middle'; |
| 73 |
if ( $i == 0 ) { $checkboxgroup = 'start'; } |
| 74 |
if ( $i == (count($departments) - 1) ) { $checkboxgroup = 'end'; } |
| 75 |
|
| 76 |
$settings[] = array( |
| 77 |
'title' => __( 'Active Departments', 'propertyhive' ), |
| 78 |
'desc' => $value, |
| 79 |
'id' => 'propertyhive_active_departments_' . str_replace("residential-", "", $key), |
| 80 |
'type' => 'checkbox', |
| 81 |
'default' => ( ( in_array($key, array('residential-sales', 'residential-lettings', 'commercial')) ) ? 'yes' : '' ), |
| 82 |
'checkboxgroup' => $checkboxgroup, |
| 83 |
); |
| 84 |
|
| 85 |
++$i; |
| 86 |
} |
| 87 |
|
| 88 |
$settings[] = array( |
| 89 |
'title' => __( 'Primary Department', 'propertyhive' ), |
| 90 |
'id' => 'propertyhive_primary_department', |
| 91 |
'type' => 'radio', |
| 92 |
'default' => 'residential-sales', |
| 93 |
'options' => $departments, |
| 94 |
); |
| 95 |
|
| 96 |
$settings[] = array( |
| 97 |
'title' => __( 'Property Search Results Page', 'propertyhive' ), |
| 98 |
'id' => 'propertyhive_search_results_page_id', |
| 99 |
'type' => 'single_select_page', |
| 100 |
'default' => '', |
| 101 |
'css' => 'min-width:300px;', |
| 102 |
'desc' => __( 'This sets the page of your property search results', 'propertyhive' ), |
| 103 |
); |
| 104 |
|
| 105 |
$settings[] = array( |
| 106 |
'title' => __( 'Lettings Fees (Residential)', 'propertyhive' ), |
| 107 |
'id' => 'propertyhive_lettings_fees', |
| 108 |
'type' => 'textarea', |
| 109 |
'css' => 'height:150px; width:100%; max-width:400px' |
| 110 |
); |
| 111 |
|
| 112 |
$settings[] = array( |
| 113 |
'title' => __( 'Lettings Fees (Commercial)', 'propertyhive' ), |
| 114 |
'id' => 'propertyhive_lettings_fees_commercial', |
| 115 |
'type' => 'textarea', |
| 116 |
'css' => 'height:150px; width:100%; max-width:400px' |
| 117 |
); |
| 118 |
|
| 119 |
$settings[] = array( |
| 120 |
'title' => __( 'Display Link To Lettings Fees Next To Price', 'propertyhive' ), |
| 121 |
'desc' => __( 'In Search Results', 'propertyhive' ), |
| 122 |
'id' => 'propertyhive_lettings_fees_display_search_results', |
| 123 |
'type' => 'checkbox', |
| 124 |
'checkboxgroup' => 'start', |
| 125 |
); |
| 126 |
|
| 127 |
$settings[] = array( |
| 128 |
'title' => __( 'Display Link To Lettings Fees Next To Price', 'propertyhive' ), |
| 129 |
'desc' => __( 'On Property Details Page', 'propertyhive' ), |
| 130 |
'id' => 'propertyhive_lettings_fees_display_single_property', |
| 131 |
'type' => 'checkbox', |
| 132 |
'checkboxgroup' => 'end', |
| 133 |
); |
| 134 |
|
| 135 |
$settings[] = array( 'type' => 'sectionend', 'id' => 'general_options'); |
| 136 |
|
| 137 |
return apply_filters( 'propertyhive_general_settings', $settings ); |
| 138 |
} |
| 139 |
|
| 140 |
/** |
| 141 |
* Get general modules settings array |
| 142 |
* |
| 143 |
* @return array |
| 144 |
*/ |
| 145 |
public function get_general_modules_setting() { |
| 146 |
|
| 147 |
return apply_filters( 'propertyhive_general_modules_settings', array( |
| 148 |
|
| 149 |
array( 'title' => __( 'Disabled Modules', 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'modules_options' ), |
| 150 |
|
| 151 |
array( |
| 152 |
'type' => 'html', |
| 153 |
'html' => __( 'Here you can choose which modules are enabled or disabled within Property Hive. Check the modules you <strong>DO NOT</strong> wish to use from the list below', 'propertyhive' ) . ':', |
| 154 |
), |
| 155 |
|
| 156 |
array( |
| 157 |
'title' => __( 'Disabled Modules', 'propertyhive' ), |
| 158 |
'desc' => __( 'Contacts (Applicants, Owners/Landlords and Third Party Contacts)', 'propertyhive' ), |
| 159 |
'id' => 'propertyhive_module_disabled_contacts', |
| 160 |
'type' => 'checkbox', |
| 161 |
'default' => '', |
| 162 |
'checkboxgroup' => 'start' |
| 163 |
), |
| 164 |
|
| 165 |
array( |
| 166 |
'title' => __( 'Disabled Modules', 'propertyhive' ), |
| 167 |
'desc' => __( 'Appraisals', 'propertyhive' ), |
| 168 |
'id' => 'propertyhive_module_disabled_appraisals', |
| 169 |
'type' => 'checkbox', |
| 170 |
'default' => '', |
| 171 |
'checkboxgroup' => 'middle' |
| 172 |
), |
| 173 |
|
| 174 |
array( |
| 175 |
'title' => __( 'Disabled Modules', 'propertyhive' ), |
| 176 |
'desc' => __( 'Viewings', 'propertyhive' ), |
| 177 |
'id' => 'propertyhive_module_disabled_viewings', |
| 178 |
'type' => 'checkbox', |
| 179 |
'default' => '', |
| 180 |
'checkboxgroup' => 'middle' |
| 181 |
), |
| 182 |
|
| 183 |
array( |
| 184 |
'title' => __( 'Disabled Modules', 'propertyhive' ), |
| 185 |
'desc' => __( 'Offers and Sales', 'propertyhive' ), |
| 186 |
'id' => 'propertyhive_module_disabled_offers_sales', |
| 187 |
'type' => 'checkbox', |
| 188 |
'default' => '', |
| 189 |
'checkboxgroup' => 'middle' |
| 190 |
), |
| 191 |
|
| 192 |
array( |
| 193 |
'title' => __( 'Disabled Modules', 'propertyhive' ), |
| 194 |
'desc' => __( 'Enquiries', 'propertyhive' ), |
| 195 |
'id' => 'propertyhive_module_disabled_enquiries', |
| 196 |
'type' => 'checkbox', |
| 197 |
'default' => '', |
| 198 |
'checkboxgroup' => 'end' |
| 199 |
), |
| 200 |
|
| 201 |
array( 'type' => 'sectionend', 'id' => 'modules_options'), |
| 202 |
|
| 203 |
) ); // End general module settings |
| 204 |
} |
| 205 |
|
| 206 |
/** |
| 207 |
* Get international settings array |
| 208 |
* |
| 209 |
* @return array |
| 210 |
*/ |
| 211 |
public function get_general_international_setting() { |
| 212 |
|
| 213 |
$settings = array( |
| 214 |
|
| 215 |
array( 'title' => __( 'International Options', 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'international_options' ), |
| 216 |
|
| 217 |
array( |
| 218 |
'title' => __( 'Default Country', 'propertyhive' ), |
| 219 |
'id' => 'propertyhive_default_country', |
| 220 |
'type' => 'single_select_country', |
| 221 |
'css' => 'min-width:300px;', |
| 222 |
), |
| 223 |
|
| 224 |
array( |
| 225 |
'title' => __( 'Countries Where You Operate', 'propertyhive' ), |
| 226 |
'id' => 'propertyhive_countries', |
| 227 |
'type' => 'multi_select_countries', |
| 228 |
'css' => 'min-width:300px;', |
| 229 |
'desc' => __( 'Hold ctrl/cmd whilst clicking to select multiple', 'propertyhive' ) |
| 230 |
), |
| 231 |
|
| 232 |
array( |
| 233 |
'title' => __( 'Price Thousand Separator', 'propertyhive' ), |
| 234 |
'id' => 'propertyhive_price_thousand_separator', |
| 235 |
'type' => 'text', |
| 236 |
'default' => ',', |
| 237 |
'css' => 'width:50px;', |
| 238 |
), |
| 239 |
|
| 240 |
array( |
| 241 |
'title' => __( 'Price Decimal Separator', 'propertyhive' ), |
| 242 |
'id' => 'propertyhive_price_decimal_separator', |
| 243 |
'type' => 'text', |
| 244 |
'default' => '.', |
| 245 |
'css' => 'width:50px;', |
| 246 |
) |
| 247 |
); |
| 248 |
|
| 249 |
$ph_countries = new PH_Countries(); |
| 250 |
$ph_countries = $ph_countries->countries; |
| 251 |
|
| 252 |
$currencies = array(); |
| 253 |
$countries = array(); |
| 254 |
if ( !empty($ph_countries) ) |
| 255 |
{ |
| 256 |
foreach ( $ph_countries as $country_code => $country ) |
| 257 |
{ |
| 258 |
$currencies[$country['currency_code']] = $country['currency_code']; |
| 259 |
$countries[$country_code] = $country; |
| 260 |
} |
| 261 |
} |
| 262 |
$currencies = array_unique($currencies); |
| 263 |
ksort($currencies); |
| 264 |
|
| 265 |
$settings[] = array( |
| 266 |
'title' => __( 'Currency Used In Search Forms', 'propertyhive' ), |
| 267 |
'id' => 'propertyhive_search_form_currency', |
| 268 |
'type' => 'select', |
| 269 |
'options' => $currencies, |
| 270 |
'default' => 'GBP', |
| 271 |
'desc' => __( 'Please note that this doesn\'t change the currency symbol shown in price dropdowns within search forms. The easiest way to achieve that is to use our free <a href="https://wp-property-hive.com/addons/template-assistant/" target="_blank">Template Assistant add on</a>.', 'propertyhive' ), |
| 272 |
); |
| 273 |
|
| 274 |
$settings[] = array( 'type' => 'sectionend', 'id' => 'international_options'); |
| 275 |
|
| 276 |
$settings[] = array( |
| 277 |
'type' => 'html', |
| 278 |
'html' => '<script> |
| 279 |
|
| 280 |
var countries = '. json_encode( $countries ) . '; |
| 281 |
|
| 282 |
</script>' |
| 283 |
); |
| 284 |
|
| 285 |
return apply_filters( 'propertyhive_general_international_settings', $settings ); |
| 286 |
} |
| 287 |
|
| 288 |
/** |
| 289 |
* Get map settings array |
| 290 |
* |
| 291 |
* @return array |
| 292 |
*/ |
| 293 |
public function get_general_map_setting() { |
| 294 |
|
| 295 |
$settings = array( |
| 296 |
|
| 297 |
array( 'title' => __( 'Map Options', 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'map_options' ), |
| 298 |
|
| 299 |
array( |
| 300 |
'title' => __( 'Google Maps API Key', 'propertyhive' ), |
| 301 |
'id' => 'propertyhive_google_maps_api_key', |
| 302 |
'type' => 'text', |
| 303 |
'desc' => '<p>' . __( 'If you have a Google Maps API key you can enter it here. You can generate an API key <a href="https://developers.google.com/maps/documentation/javascript/get-api-key" target="_blank">here</a>.<br>This is used when displaying the map when adding/editing properties, and if using our <a href="https://wp-property-hive.com/addons/map-search/" target="_blank">Map Search</a> or <a href="https://wp-property-hive.com/addons/radial-search/" target="_blank">Radial Search</a> add ons.<br>When creating your API key we recommend that you enable the Geocoding library. More about this can be found <a href="https://docs.wp-property-hive.com/user-guide/maps-co-ordinates-and-geocoding/" target="_blank">here</a>.', 'propertyhive' ) . '</p>' |
| 304 |
) |
| 305 |
|
| 306 |
); |
| 307 |
|
| 308 |
if ( apply_filters( 'propertyhive_use_google_maps_geocoding_api_key', false) === true ) |
| 309 |
{ |
| 310 |
$settings[] = array( |
| 311 |
'title' => __( 'Google Maps Geocoding API Key', 'propertyhive' ), |
| 312 |
'id' => 'propertyhive_google_maps_geocoding_api_key', |
| 313 |
'type' => 'text', |
| 314 |
'desc' => '<p>' . __( 'If you have referer restrictions applied to the main API key entered then server side geocoding requests will be blocked. To get around this you can setup a separate API key specifically for geocoding and enter it here, with IP restrictions applied instead if required.<br>More about this can be found <a href="https://docs.wp-property-hive.com/user-guide/maps-co-ordinates-and-geocoding/" target="_blank">here</a>.', 'propertyhive' ) . '</p>' |
| 315 |
); |
| 316 |
} |
| 317 |
|
| 318 |
$settings[] = array( 'type' => 'sectionend', 'id' => 'map_options'); |
| 319 |
|
| 320 |
return apply_filters( 'propertyhive_general_map_settings', $settings ); |
| 321 |
} |
| 322 |
|
| 323 |
/** |
| 324 |
* Get GDPR settings array |
| 325 |
* |
| 326 |
* @return array |
| 327 |
*/ |
| 328 |
public function get_general_gdpr_setting() { |
| 329 |
|
| 330 |
return apply_filters( 'propertyhive_general_gdpr_settings', array( |
| 331 |
|
| 332 |
array( 'title' => __( 'GDPR Settings', 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'gdpr_options' ), |
| 333 |
|
| 334 |
array( |
| 335 |
'title' => __( 'Store Property Enquiries', 'propertyhive' ), |
| 336 |
'id' => 'propertyhive_store_property_enquiries', |
| 337 |
'type' => 'checkbox', |
| 338 |
'default' => 'yes', |
| 339 |
'desc' => __( 'If using the default property enquiry form that comes with Property Hive, select this option if enquiries should be saved in the \'Enquiries\' section of Property Hive. Note that regardless of whether this is ticked or not, the enquiry will still be sent via email. This option simply determines whether we save it to the database or not.', 'propertyhive' ) |
| 340 |
), |
| 341 |
|
| 342 |
array( |
| 343 |
'title' => __( 'Property Enquiry Form Disclaimer', 'propertyhive' ), |
| 344 |
'id' => 'propertyhive_property_enquiry_form_disclaimer', |
| 345 |
'type' => 'wysiwyg', |
| 346 |
'desc' => __( 'Add disclaimer text, including a link to a privacy policy, that will appear on the property enquiry form.', 'propertyhive' ) |
| 347 |
), |
| 348 |
|
| 349 |
array( |
| 350 |
'title' => __( 'Applicant Registration Form Disclaimer', 'propertyhive' ), |
| 351 |
'id' => 'propertyhive_applicant_registration_form_disclaimer', |
| 352 |
'type' => 'wysiwyg', |
| 353 |
'desc' => __( 'Add disclaimer text, including a link to a privacy policy, that will appear on the applicant registration form.', 'propertyhive' ) |
| 354 |
), |
| 355 |
|
| 356 |
array( 'type' => 'sectionend', 'id' => 'gdpr_options'), |
| 357 |
|
| 358 |
) ); // End general GDPR settings |
| 359 |
} |
| 360 |
|
| 361 |
/** |
| 362 |
* Get misc settings array |
| 363 |
* |
| 364 |
* @return array |
| 365 |
*/ |
| 366 |
public function get_general_misc_setting() { |
| 367 |
|
| 368 |
return apply_filters( 'propertyhive_general_misc_settings', array( |
| 369 |
|
| 370 |
array( 'title' => __( 'Property Options', 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'property_options' ), |
| 371 |
|
| 372 |
array( |
| 373 |
'title' => __( 'Search By Address Should', 'propertyhive' ), |
| 374 |
'id' => 'propertyhive_address_keyword_compare', |
| 375 |
'type' => 'radio', |
| 376 |
'default' => '=', |
| 377 |
'options' => array( |
| 378 |
'=' => __( 'Match Keyword Exactly', 'propertyhive' ), |
| 379 |
'LIKE' => __( 'Perform Loose Search', 'propertyhive' ), |
| 380 |
), |
| 381 |
'desc_tip' => __( 'Applicable if you allow users to search by entering a location. If \'Match Keyword Exactly\' is selected a search for \'Walton\' would not return properties in \'Walton On Thames\', but would prevent properties in \'Lincolnshire\' appearing when searching for \'Lincoln\'. \'Perform Loose Search\' would do the opposite.', 'propertyhive' ) |
| 382 |
), |
| 383 |
|
| 384 |
array( |
| 385 |
'title' => __( 'Commercial Display In Search Results', 'propertyhive' ), |
| 386 |
'id' => 'propertyhive_commercial_display', |
| 387 |
'type' => 'select', |
| 388 |
'default' => '', |
| 389 |
'css' => 'min-width:300px;', |
| 390 |
'options' => array( |
| 391 |
'' => __( 'Display top level properties and units', 'propertyhive' ), |
| 392 |
'top_level_only' => __( 'Display top level properties only', 'propertyhive' ), |
| 393 |
'top_level_only_but_units_when_filtered' => __( 'Display top level properties only but units as well if matching filters', 'propertyhive' ), |
| 394 |
), |
| 395 |
), |
| 396 |
|
| 397 |
array( |
| 398 |
'title' => __( 'When Entering Features', 'propertyhive' ), |
| 399 |
'id' => 'propertyhive_features_type', |
| 400 |
'type' => 'radio', |
| 401 |
'options' => array( |
| 402 |
'' => __( 'Allow Features To Be Freetyped', 'propertyhive' ), |
| 403 |
'checkbox' => __( 'Select From A Predefined List (Editable from \'Custom Fields\')', 'propertyhive' ), |
| 404 |
), |
| 405 |
), |
| 406 |
|
| 407 |
array( |
| 408 |
'title' => __( 'Enable Auto-Incremental Reference Numbers', 'propertyhive' ), |
| 409 |
'id' => 'propertyhive_auto_incremental_reference_numbers', |
| 410 |
'type' => 'checkbox', |
| 411 |
'desc' => __( 'Will prefill the property reference with an auto-incremental number when adding a new property', 'propertyhive' ) |
| 412 |
), |
| 413 |
|
| 414 |
array( |
| 415 |
'title' => __( 'Next Incremental Reference Number', 'propertyhive' ), |
| 416 |
'id' => 'propertyhive_auto_incremental_next', |
| 417 |
'type' => 'number', |
| 418 |
'default' => 1, |
| 419 |
), |
| 420 |
|
| 421 |
array( 'type' => 'sectionend', 'id' => 'property_options'), |
| 422 |
|
| 423 |
array( 'title' => __( 'Applicant Options', 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'applicant_registration_options' ), |
| 424 |
|
| 425 |
array( |
| 426 |
'title' => __( 'Allow Applicants To Login and Manage Account', 'propertyhive' ), |
| 427 |
'id' => 'propertyhive_applicant_users', |
| 428 |
'type' => 'checkbox', |
| 429 |
'desc' => __( 'Applicable when you allow users to register on a form using the [applicant_registration_form] shortcode.<br><br>Selecting this will allow applicants to create a password when registering, then login to manage their details and requirements. They will be created as a WordPress user with \'Property Hive Contact\' role.<br><br>If unticked applicants will still be able to register and they\'ll go into Property Hive as an applicant, they just won\'t be able to login at a later date.', 'propertyhive' ) |
| 430 |
), |
| 431 |
|
| 432 |
array( |
| 433 |
'title' => __( 'Send Email When Applicant Registers', 'propertyhive' ), |
| 434 |
'id' => 'propertyhive_new_registration_alert', |
| 435 |
'type' => 'checkbox', |
| 436 |
'desc' => __( 'Choose whether an email should be sent alerting you to the fact someone has registered. The email will be sent to the chosen office. Offices can be managed click selecting the \'Offices\' tab above.', 'propertyhive' ) |
| 437 |
), |
| 438 |
|
| 439 |
array( |
| 440 |
'title' => __( 'My Account Page', 'propertyhive' ), |
| 441 |
'id' => 'propertyhive_my_account_page_id', |
| 442 |
'type' => 'single_select_page', |
| 443 |
'default' => '', |
| 444 |
'css' => 'min-width:300px;', |
| 445 |
'desc' => __( 'This sets the \'My Account\' page. This page should contain the [propertyhive_my_account] shortcode', 'propertyhive' ), |
| 446 |
), |
| 447 |
|
| 448 |
array( |
| 449 |
'title' => __( 'Match Price Range % (Lower)', 'propertyhive' ), |
| 450 |
'id' => 'propertyhive_applicant_match_price_range_percentage_lower', |
| 451 |
'type' => 'number', |
| 452 |
'default' => '20', |
| 453 |
'desc' => '<p>' . __( 'When a maximum price is entered against an applicants requirements we create a \'Match Price Range\' which determines the price of properties that would get matched to the applicant.<br>We do this because you:<br>a) Wouldn\'t want to send them properties that were way below their specified maximum price and<br>b) Would probably want to send them properties which are slightly just over the price specified as, if the perfect property came along, a lot of people would actually be able to increase their maximum.<br>These settings determine the % above and below the maximum price entered that the \'Match Price Range\' will default to per applicant.<br>For example, if the maximum price entered was £500,000, the lower setting was 20% and the higher setting was 5%, the applicant would actually match to properties that were priced £400,000 - £525,000.<br>This price range can be overwritten on a per-applicant basis, or disabled completely by leaving these settings empty.<br>Note that this currently only applies to applicants looking for sales properties and changing this value at a later date will only effect applicants that don\'t already have a match price range set.', 'propertyhive' ) . '</p>', |
| 454 |
), |
| 455 |
|
| 456 |
array( |
| 457 |
'title' => __( 'Match Price Range % (Higher)', 'propertyhive' ), |
| 458 |
'id' => 'propertyhive_applicant_match_price_range_percentage_higher', |
| 459 |
'type' => 'number', |
| 460 |
'default' => '5', |
| 461 |
), |
| 462 |
|
| 463 |
array( 'type' => 'sectionend', 'id' => 'applicant_registration_options'), |
| 464 |
|
| 465 |
array( 'title' => __( 'Property Media Storage', 'propertyhive' ), 'type' => 'title', 'desc' => 'By default media attached to properties will be stored in the WordPress media library. If the property media is hosted elsewhere (for example if you import properties from a third party and they allow you to link direct to the files on their server) you can choose to store media as URL\'s. It also means that the images are not downloaded onto your server, thus saving diskspace.<br><br>Note: If you change this you\'ll need to re-add all of the property media for existing properties.<br>Note: Changing this will not delete all existing media or URLs entered.<br>Note: Choosing to store the media as URLs will mean you don\'t benefit from having access to different sized images (i.e. small , medium, large etc).', 'id' => 'media_storage_options' ), |
| 466 |
|
| 467 |
array( |
| 468 |
'title' => __( 'Images Stored As', 'propertyhive' ), |
| 469 |
'id' => 'propertyhive_images_stored_as', |
| 470 |
'type' => 'select', |
| 471 |
'default' => 'files', |
| 472 |
'options' => array( |
| 473 |
'files' => __( 'Media Files', 'propertyhive' ), |
| 474 |
'urls' => __( 'URLs', 'propertyhive' ), |
| 475 |
), |
| 476 |
'desc' => __( '', 'propertyhive' ) |
| 477 |
), |
| 478 |
|
| 479 |
array( |
| 480 |
'title' => __( 'Floorplans Stored As', 'propertyhive' ), |
| 481 |
'id' => 'propertyhive_floorplans_stored_as', |
| 482 |
'type' => 'select', |
| 483 |
'default' => 'files', |
| 484 |
'options' => array( |
| 485 |
'files' => __( 'Media Files', 'propertyhive' ), |
| 486 |
'urls' => __( 'URLs', 'propertyhive' ), |
| 487 |
), |
| 488 |
'desc' => __( '', 'propertyhive' ) |
| 489 |
), |
| 490 |
|
| 491 |
array( |
| 492 |
'title' => __( 'Brochures Stored As', 'propertyhive' ), |
| 493 |
'id' => 'propertyhive_brochures_stored_as', |
| 494 |
'type' => 'select', |
| 495 |
'default' => 'files', |
| 496 |
'options' => array( |
| 497 |
'files' => __( 'Media Files', 'propertyhive' ), |
| 498 |
'urls' => __( 'URLs', 'propertyhive' ), |
| 499 |
), |
| 500 |
'desc' => __( '', 'propertyhive' ) |
| 501 |
), |
| 502 |
|
| 503 |
array( |
| 504 |
'title' => __( 'EPCs Stored As', 'propertyhive' ), |
| 505 |
'id' => 'propertyhive_epcs_stored_as', |
| 506 |
'type' => 'select', |
| 507 |
'default' => 'files', |
| 508 |
'options' => array( |
| 509 |
'files' => __( 'Media Files', 'propertyhive' ), |
| 510 |
'urls' => __( 'URLs', 'propertyhive' ), |
| 511 |
), |
| 512 |
'desc' => __( '', 'propertyhive' ) |
| 513 |
), |
| 514 |
|
| 515 |
array( 'type' => 'sectionend', 'id' => 'media_storage_options'), |
| 516 |
|
| 517 |
) ); // End general misc settings |
| 518 |
} |
| 519 |
|
| 520 |
/** |
| 521 |
* Output the settings |
| 522 |
*/ |
| 523 |
public function output() { |
| 524 |
global $current_section; |
| 525 |
|
| 526 |
if ( $current_section ) |
| 527 |
{ |
| 528 |
switch ($current_section) |
| 529 |
{ |
| 530 |
case "modules": { $settings = $this->get_general_modules_setting(); break; } |
| 531 |
case "international": { $settings = $this->get_general_international_setting(); break; } |
| 532 |
case "map": { $settings = $this->get_general_map_setting(); break; } |
| 533 |
case "gdpr": { $settings = $this->get_general_gdpr_setting(); break; } |
| 534 |
case "misc": { $settings = $this->get_general_misc_setting(); break; } |
| 535 |
default: { die("Unknown setting section"); } |
| 536 |
} |
| 537 |
} |
| 538 |
else |
| 539 |
{ |
| 540 |
$settings = $this->get_settings(); |
| 541 |
} |
| 542 |
|
| 543 |
PH_Admin_Settings::output_fields( $settings ); |
| 544 |
} |
| 545 |
|
| 546 |
/** |
| 547 |
* Output a colour picker input box. |
| 548 |
* |
| 549 |
* @access public |
| 550 |
* @param mixed $name |
| 551 |
* @param mixed $id |
| 552 |
* @param mixed $value |
| 553 |
* @param string $desc (default: '') |
| 554 |
* @return void |
| 555 |
*/ |
| 556 |
function color_picker( $name, $id, $value, $desc = '' ) { |
| 557 |
echo '<div class="color_box"><strong><img class="help_tip" data-tip="' . esc_attr( $desc ) . '" src="' . PH()->plugin_url() . '/assets/images/help.png" height="16" width="16" /> ' . esc_html( $name ) . '</strong> |
| 558 |
<input name="' . esc_attr( $id ). '" id="' . esc_attr( $id ) . '" type="text" value="' . esc_attr( $value ) . '" class="colorpick" /> <div id="colorPickerDiv_' . esc_attr( $id ) . '" class="colorpickdiv"></div> |
| 559 |
</div>'; |
| 560 |
} |
| 561 |
|
| 562 |
/** |
| 563 |
* Save settings |
| 564 |
*/ |
| 565 |
public function save() { |
| 566 |
global $current_section; |
| 567 |
|
| 568 |
if ( $current_section != '' ) |
| 569 |
{ |
| 570 |
switch ($current_section) |
| 571 |
{ |
| 572 |
case 'modules': |
| 573 |
{ |
| 574 |
$settings = $this->get_general_modules_setting(); |
| 575 |
|
| 576 |
PH_Admin_Settings::save_fields( $settings ); |
| 577 |
break; |
| 578 |
} |
| 579 |
case 'international': |
| 580 |
{ |
| 581 |
if (!isset($_POST['propertyhive_countries']) || (isset($_POST['propertyhive_countries']) && empty($_POST['propertyhive_countries']))) |
| 582 |
{ |
| 583 |
// If we haven't selected which countries we operate in |
| 584 |
update_option( 'propertyhive_countries', array( ph_clean($_POST['propertyhive_default_country']) ) ); |
| 585 |
} |
| 586 |
else |
| 587 |
{ |
| 588 |
// We have default country and countries set |
| 589 |
// Make sure default country is in list of countries selected |
| 590 |
if ( !in_array(ph_clean($_POST['propertyhive_default_country']), ph_clean($_POST['propertyhive_countries'])) ) { |
| 591 |
$_POST['propertyhive_default_country'] = $_POST['propertyhive_countries'][0]; |
| 592 |
} |
| 593 |
|
| 594 |
update_option( 'propertyhive_default_country', ph_clean($_POST['propertyhive_default_country']) ); |
| 595 |
update_option( 'propertyhive_countries', ph_clean($_POST['propertyhive_countries']) ); |
| 596 |
} |
| 597 |
|
| 598 |
update_option( 'propertyhive_price_thousand_separator', ph_clean($_POST['propertyhive_price_thousand_separator']) ); |
| 599 |
update_option( 'propertyhive_price_decimal_separator', ph_clean($_POST['propertyhive_price_decimal_separator']) ); |
| 600 |
|
| 601 |
update_option( 'propertyhive_search_form_currency', ph_clean($_POST['propertyhive_search_form_currency']) ); |
| 602 |
|
| 603 |
do_action( 'propertyhive_update_currency_exchange_rates' ); |
| 604 |
|
| 605 |
break; |
| 606 |
} |
| 607 |
case 'map': |
| 608 |
{ |
| 609 |
$settings = $this->get_general_map_setting(); |
| 610 |
|
| 611 |
PH_Admin_Settings::save_fields( $settings ); |
| 612 |
break; |
| 613 |
} |
| 614 |
case 'gdpr': |
| 615 |
{ |
| 616 |
$settings = $this->get_general_gdpr_setting(); |
| 617 |
|
| 618 |
PH_Admin_Settings::save_fields( $settings ); |
| 619 |
break; |
| 620 |
} |
| 621 |
case 'misc': |
| 622 |
{ |
| 623 |
$settings = $this->get_general_misc_setting(); |
| 624 |
|
| 625 |
PH_Admin_Settings::save_fields( $settings ); |
| 626 |
break; |
| 627 |
} |
| 628 |
default: { die("Unknown setting section"); } |
| 629 |
} |
| 630 |
} |
| 631 |
else |
| 632 |
{ |
| 633 |
$settings = $this->get_settings(); |
| 634 |
|
| 635 |
PH_Admin_Settings::save_fields( $settings ); |
| 636 |
|
| 637 |
flush_rewrite_rules(); |
| 638 |
} |
| 639 |
} |
| 640 |
|
| 641 |
} |
| 642 |
|
| 643 |
endif; |
| 644 |
|
| 645 |
return new PH_Settings_General(); |
| 646 |
|