PluginProbe
Property Hive / 1.4.6
Property Hive v1.4.6
2.3.1 2.3.0 2.2.6 2.2.5 2.2.4 2.2.3 2.2.2 1.4.46 1.4.47 1.4.48 1.4.49 1.4.5 1.4.50 1.4.51 1.4.52 1.4.53 1.4.54 1.4.55 1.4.56 1.4.57 1.4.58 1.4.59 1.4.6 1.4.60 1.4.61 All 261 releases
propertyhive / includes / admin / settings / class-ph-settings-general.php

class-ph-settings-general.php in Property Hive 1.4.6, at includes/admin/settings/class-ph-settings-general.php

414 lines 15.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 'misc' => __( 'Miscellaneous', 'propertyhive' ),
47 );
48
49 return $sections;
50 }
51
52
53 /**
54 * Get general settings array
55 *
56 * @return array
57 */
58 public function get_settings() {
59
60 return apply_filters( 'propertyhive_general_settings', array(
61
62 array( 'title' => __( 'General Options', 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'general_options' ),
63
64 array(
65 'title' => __( 'Active Departments', 'propertyhive' ),
66 'desc' => __( 'Residential Sales', 'propertyhive' ),
67 'id' => 'propertyhive_active_departments_sales',
68 'type' => 'checkbox',
69 'default' => 'yes',
70 'checkboxgroup' => 'start'
71 ),
72
73 array(
74 'title' => __( 'Active Departments', 'propertyhive' ),
75 'desc' => __( 'Residential Lettings', 'propertyhive' ),
76 'id' => 'propertyhive_active_departments_lettings',
77 'type' => 'checkbox',
78 'default' => 'yes',
79 'checkboxgroup' => 'middle'
80 ),
81
82 array(
83 'title' => __( 'Active Departments', 'propertyhive' ),
84 'desc' => __( 'Commercial', 'propertyhive' ),
85 'id' => 'propertyhive_active_departments_commercial',
86 'type' => 'checkbox',
87 'checkboxgroup' => 'end'
88 ),
89
90 array(
91 'title' => __( 'Primary Department', 'propertyhive' ),
92 'id' => 'propertyhive_primary_department',
93 'type' => 'radio',
94 'default' => 'residential-sales',
95 'options' => array(
96 'residential-sales' => __( 'Residential Sales', 'propertyhive' ),
97 'residential-lettings' => __( 'Residential Lettings', 'propertyhive' ),
98 'commercial' => __( 'Commercial', 'propertyhive' )
99 )
100 ),
101
102 array(
103 'title' => __( 'Property Search Results Page', 'propertyhive' ),
104 //'desc' => '<br/>' . sprintf( __( 'The base page can also be used in your <a href="%s">product permalinks</a>.', 'propertyhive' ), admin_url( 'options-permalink.php' ) ),
105 'id' => 'propertyhive_search_results_page_id',
106 'type' => 'single_select_page',
107 'default' => '',
108 'css' => 'min-width:300px;',
109 'desc' => __( 'This sets the page of your property search results', 'propertyhive' ),
110 ),
111
112 array(
113 'title' => __( 'Lettings Fees', 'propertyhive' ),
114 'id' => 'propertyhive_lettings_fees',
115 'type' => 'textarea',
116 'css' => 'height:150px; width:100%; max-width:400px'
117 ),
118
119 array( 'type' => 'sectionend', 'id' => 'general_options'),
120
121 ) ); // End general settings
122 }
123
124 /**
125 * Get general modules settings array
126 *
127 * @return array
128 */
129 public function get_general_modules_setting() {
130
131 return apply_filters( 'propertyhive_general_modules_settings', array(
132
133 array( 'title' => __( 'Disabled Modules', 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'modules_options' ),
134
135 array(
136 'type' => 'html',
137 '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' ) . ':',
138 ),
139
140 array(
141 'title' => __( 'Disabled Modules', 'propertyhive' ),
142 'desc' => __( 'Contacts (Applicants, Owners/Landlords and Third Party Contacts)', 'propertyhive' ),
143 'id' => 'propertyhive_module_disabled_contacts',
144 'type' => 'checkbox',
145 'default' => '',
146 'checkboxgroup' => 'start'
147 ),
148
149 array(
150 'title' => __( 'Disabled Modules', 'propertyhive' ),
151 'desc' => __( 'Viewings', 'propertyhive' ),
152 'id' => 'propertyhive_module_disabled_viewings',
153 'type' => 'checkbox',
154 'default' => '',
155 'checkboxgroup' => 'middle'
156 ),
157
158 array(
159 'title' => __( 'Disabled Modules', 'propertyhive' ),
160 'desc' => __( 'Offers and Sales', 'propertyhive' ),
161 'id' => 'propertyhive_module_disabled_offers_sales',
162 'type' => 'checkbox',
163 'default' => '',
164 'checkboxgroup' => 'middle'
165 ),
166
167 array(
168 'title' => __( 'Disabled Modules', 'propertyhive' ),
169 'desc' => __( 'Enquiries', 'propertyhive' ),
170 'id' => 'propertyhive_module_disabled_enquiries',
171 'type' => 'checkbox',
172 'default' => '',
173 'checkboxgroup' => 'end'
174 ),
175
176 array( 'type' => 'sectionend', 'id' => 'modules_options'),
177
178 ) ); // End general module settings
179 }
180
181 /**
182 * Get international settings array
183 *
184 * @return array
185 */
186 public function get_general_international_setting() {
187
188 return apply_filters( 'propertyhive_general_international_settings', array(
189
190 array( 'title' => __( 'International Options', 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'international_options' ),
191
192 array(
193 'title' => __( 'Default Country', 'propertyhive' ),
194 'id' => 'propertyhive_default_country',
195 'type' => 'single_select_country',
196 'css' => 'min-width:300px;',
197 ),
198
199 array(
200 'title' => __( 'Countries Where You Operate', 'propertyhive' ),
201 'id' => 'propertyhive_countries',
202 'type' => 'multi_select_countries',
203 'css' => 'min-width:300px;',
204 'desc' => __( 'Hold ctrl/cmd whilst clicking to select multiple', 'propertyhive' )
205 ),
206
207 array( 'type' => 'sectionend', 'id' => 'international_options'),
208
209 ) ); // End general international settings
210 }
211
212 /**
213 * Get map settings array
214 *
215 * @return array
216 */
217 public function get_general_map_setting() {
218
219 return apply_filters( 'propertyhive_general_map_settings', array(
220
221 array( 'title' => __( 'Map Options', 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'map_options' ),
222
223 array(
224 'title' => __( 'Google Maps API Key', 'propertyhive' ),
225 'id' => 'propertyhive_google_maps_api_key',
226 'type' => 'text',
227 'desc' => __( 'If you have a Google Maps API key you can enter it here. A map is displayed when adding/editing properties, and if using our <a href="https://wp-property-hive.com/addons/map-search/" target="_blank">Map Search Add On</a>. You can generate an API key <a href="https://developers.google.com/maps/documentation/javascript/get-api-key" target="_blank">here</a>.', 'propertyhive' )
228 ),
229
230 array( 'type' => 'sectionend', 'id' => 'map_options'),
231
232 ) ); // End general map settings
233 }
234
235 /**
236 * Get misc settings array
237 *
238 * @return array
239 */
240 public function get_general_misc_setting() {
241
242 return apply_filters( 'propertyhive_general_map_settings', array(
243
244 array( 'title' => __( 'Property Options', 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'property_options' ),
245
246 array(
247 'title' => __( 'Search By Address Should', 'propertyhive' ),
248 'id' => 'propertyhive_address_keyword_compare',
249 'type' => 'radio',
250 'default' => '=',
251 'options' => array(
252 '=' => __( 'Match Keyword Exactly', 'propertyhive' ),
253 'LIKE' => __( 'Perform Loose Search', 'propertyhive' ),
254 ),
255 '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' )
256 ),
257
258 array(
259 'title' => __( 'When Entering Features', 'propertyhive' ),
260 'id' => 'propertyhive_features_type',
261 'type' => 'radio',
262 'options' => array(
263 '' => __( 'Allow Features To Be Freetyped', 'propertyhive' ),
264 'checkbox' => __( 'Select From A Predefined List (Editable from \'Custom Fields\')', 'propertyhive' ),
265 ),
266 'desc' => __( '', 'propertyhive' )
267 ),
268
269 array( 'type' => 'sectionend', 'id' => 'property_options'),
270
271 array( 'title' => __( 'Applicant Registration Options', 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'applicant_registration_options' ),
272
273 array(
274 'title' => __( 'Allow Applicants To Login and Manage Account', 'propertyhive' ),
275 'id' => 'propertyhive_applicant_users',
276 'type' => 'checkbox',
277 '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' )
278 ),
279
280 array(
281 'title' => __( 'Send Email When Applicant Registers', 'propertyhive' ),
282 'id' => 'propertyhive_new_registration_alert',
283 'type' => 'checkbox',
284 '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' )
285 ),
286
287 array(
288 'title' => __( 'My Account Page', 'propertyhive' ),
289 'id' => 'propertyhive_my_account_page_id',
290 'type' => 'single_select_page',
291 'default' => '',
292 'css' => 'min-width:300px;',
293 'desc' => __( 'This sets the \'My Account\' page. This page should contain the [propertyhive_my_account] shortcode', 'propertyhive' ),
294 ),
295
296 array( 'type' => 'sectionend', 'id' => 'applicant_registration_options'),
297
298 ) ); // End general misc settings
299 }
300
301 /**
302 * Output the settings
303 */
304 public function output() {
305 global $current_section;
306
307 if ( $current_section )
308 {
309 switch ($current_section)
310 {
311 case "modules": { $settings = $this->get_general_modules_setting(); break; }
312 case "international": { $settings = $this->get_general_international_setting(); break; }
313 case "map": { $settings = $this->get_general_map_setting(); break; }
314 case "misc": { $settings = $this->get_general_misc_setting(); break; }
315 default: { die("Unknown setting section"); }
316 }
317 }
318 else
319 {
320 $settings = $this->get_settings();
321 }
322
323 PH_Admin_Settings::output_fields( $settings );
324 }
325
326 /**
327 * Output a colour picker input box.
328 *
329 * @access public
330 * @param mixed $name
331 * @param mixed $id
332 * @param mixed $value
333 * @param string $desc (default: '')
334 * @return void
335 */
336 function color_picker( $name, $id, $value, $desc = '' ) {
337 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>
338 <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>
339 </div>';
340 }
341
342 /**
343 * Save settings
344 */
345 public function save() {
346 global $current_section;
347
348 if ( $current_section != '' )
349 {
350 switch ($current_section)
351 {
352 case 'modules':
353 {
354 $settings = $this->get_general_modules_setting();
355
356 PH_Admin_Settings::save_fields( $settings );
357 break;
358 }
359 case 'international':
360 {
361 if (!isset($_POST['propertyhive_countries']) || (isset($_POST['propertyhive_countries']) && empty($_POST['propertyhive_countries'])))
362 {
363 // If we haven't selected which countries we operate in
364 update_option( 'propertyhive_countries', array( $_POST['propertyhive_default_country'] ) );
365 }
366 else
367 {
368 // We have default country and countries set
369 // Make sure default country is in list of countries selected
370 if ( !in_array($_POST['propertyhive_default_country'], $_POST['propertyhive_countries']) ) {
371 $_POST['propertyhive_default_country'] = $_POST['propertyhive_countries'][0];
372 }
373
374 update_option( 'propertyhive_default_country', $_POST['propertyhive_default_country'] );
375 update_option( 'propertyhive_countries', $_POST['propertyhive_countries'] );
376 }
377
378 do_action( 'propertyhive_update_currency_exchange_rates' );
379
380 break;
381 }
382 case 'map':
383 {
384 $settings = $this->get_general_map_setting();
385
386 PH_Admin_Settings::save_fields( $settings );
387 break;
388 }
389 case 'misc':
390 {
391 $settings = $this->get_general_misc_setting();
392
393 PH_Admin_Settings::save_fields( $settings );
394 break;
395 }
396 default: { die("Unknown setting section"); }
397 }
398 }
399 else
400 {
401 $settings = $this->get_settings();
402
403 PH_Admin_Settings::save_fields( $settings );
404
405 flush_rewrite_rules();
406 }
407 }
408
409 }
410
411 endif;
412
413 return new PH_Settings_General();
414