PluginProbe
Property Hive / 1.4.62
Property Hive v1.4.62
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-custom-fields.php

class-ph-settings-custom-fields.php in Property Hive 1.4.62, at includes/admin/settings/class-ph-settings-custom-fields.php

2,668 lines 120.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * PropertyHive Custom Fields 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_Custom_Fields' ) ) :
16
17 /**
18 * PH_Settings_General
19 */
20 class PH_Settings_Custom_Fields extends PH_Settings_Page {
21
22 /**
23 * Constructor.
24 */
25 public function __construct() {
26 $this->id = 'customfields';
27 $this->label = __( 'Custom Fields', 'propertyhive' );
28
29 add_filter( 'propertyhive_settings_tabs_array', array( $this, 'add_settings_page' ), 15 );
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 '' => __( 'Custom Fields', 'propertyhive' )
43 );
44
45 $residential_active = false;
46 $residential_sales_active = false;
47 $residential_lettings_active = false;
48 $commercial_active = false;
49
50 if ( get_option( 'propertyhive_active_departments_sales' ) == 'yes' || get_option( 'propertyhive_active_departments_lettings' ) == 'yes' )
51 {
52 $residential_active = true;
53 if ( get_option( 'propertyhive_active_departments_sales' ) == 'yes' )
54 {
55 $residential_sales_active = true;
56 }
57 if ( get_option( 'propertyhive_active_departments_lettings' ) == 'yes' )
58 {
59 $residential_lettings_active = true;
60 }
61 }
62 if ( get_option( 'propertyhive_active_departments_commercial' ) == 'yes' )
63 {
64 $commercial_active = true;
65 }
66
67 // Residential Custom Fields
68 $sections[ 'availability' ] = __( 'Availabilities', 'propertyhive' );
69 add_action( 'propertyhive_admin_field_custom_fields_availability', array( $this, 'custom_fields_availability_setting' ) );
70
71 if ( $residential_active )
72 {
73 $sections[ 'property-type' ] = ( $commercial_active ? __( 'Residential ', 'propertyhive' ) . ' ' : '' ) . __( 'Property Types', 'propertyhive' );
74 add_action( 'propertyhive_admin_field_custom_fields_property_type', array( $this, 'custom_fields_property_type_setting' ) );
75 }
76 if ( $commercial_active )
77 {
78 $sections[ 'commercial-property-type' ] = ( $residential_active ? __( 'Commercial', 'propertyhive' ) . ' ' : '' ) . __( 'Property Types', 'propertyhive' );
79 add_action( 'propertyhive_admin_field_custom_fields_commercial_property_type', array( $this, 'custom_fields_commercial_property_type_setting' ) );
80 }
81
82 $sections[ 'location' ] = __( 'Locations', 'propertyhive' );
83 add_action( 'propertyhive_admin_field_custom_fields_location', array( $this, 'custom_fields_location_setting' ) );
84
85 if ( $residential_active )
86 {
87 $sections[ 'parking' ] = __( 'Parking', 'propertyhive' );
88 add_action( 'propertyhive_admin_field_custom_fields_parking', array( $this, 'custom_fields_parking_setting' ) );
89
90 $sections[ 'outside-space' ] = __( 'Outside Spaces', 'propertyhive' );
91 add_action( 'propertyhive_admin_field_custom_fields_outside_space', array( $this, 'custom_fields_outside_space_setting' ) );
92 }
93
94 if ( $residential_sales_active || $commercial_active )
95 {
96 $sections[ 'price-qualifier' ] = __( 'Price Qualifiers', 'propertyhive' );
97 add_action( 'propertyhive_admin_field_custom_fields_price_qualifier', array( $this, 'custom_fields_price_qualifier_setting' ) );
98
99 $sections[ 'sale-by' ] = __( 'Sale By', 'propertyhive' );
100 add_action( 'propertyhive_admin_field_custom_fields_sale_by', array( $this, 'custom_fields_sale_by_setting' ) );
101 }
102
103 if ( $residential_active )
104 {
105 $sections[ 'tenure' ] = ( $commercial_active ? __( 'Residential', 'propertyhive' ) . ' ' : '' ) . __( 'Tenures', 'propertyhive' );
106 add_action( 'propertyhive_admin_field_custom_fields_tenure', array( $this, 'custom_fields_tenure_setting' ) );
107 }
108 if ( $commercial_active )
109 {
110 $sections[ 'commercial-tenure' ] = ( $residential_active ? __( 'Commercial', 'propertyhive' ) . ' ' : '' ) . __( 'Tenures', 'propertyhive' );
111 add_action( 'propertyhive_admin_field_custom_fields_commercial_tenure', array( $this, 'custom_fields_commercial_tenure_setting' ) );
112 }
113
114 if ( $residential_lettings_active )
115 {
116 $sections[ 'furnished' ] = __( 'Furnished', 'propertyhive' );
117 add_action( 'propertyhive_admin_field_custom_fields_furnished', array( $this, 'custom_fields_furnished_setting' ) );
118 }
119
120 // Other
121 $sections[ 'marketing-flag' ] = __( 'Marketing Flags', 'propertyhive' );
122 add_action( 'propertyhive_admin_field_custom_fields_marketing_flag', array( $this, 'custom_fields_marketing_flag_setting' ) );
123
124 if ( get_option('propertyhive_features_type') == 'checkbox' )
125 {
126 $sections[ 'property-feature' ] = __( 'Property Features', 'propertyhive' );
127 add_action( 'propertyhive_admin_field_custom_fields_property_feature', array( $this, 'custom_fields_property_feature_setting' ) );
128 }
129
130 return $sections;
131 }
132
133 /**
134 * Get settings array
135 *
136 * @return array
137 */
138 public function get_settings() {
139
140 global $hide_save_button;
141
142 $hide_save_button = true;
143
144 $html = '';
145
146 $sections = $this->get_sections();
147
148 //$sections = array_shift($sections); // Remove 'Custom Fields' from list of custom fields sections
149 $i = 0;
150 foreach ($sections as $key => $value)
151 {
152 if ($i > 0)
153 {
154 $html .= '<p><a href="' . admin_url( 'admin.php?page=ph-settings&tab=customfields&section=' . $key ) . '">' . $value . '</a></p>';
155 }
156 ++$i;
157 }
158
159 return apply_filters( 'propertyhive_custom_fields_settings', array(
160
161 array( 'title' => __( 'Custom Fields', 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_options' ),
162
163 array(
164 'type' => 'html',
165 'title' => __( 'Custom Fields', 'propertyhive' ),
166 'html' => $html
167 ),
168
169 array( 'type' => 'sectionend', 'id' => 'custom_field_options'),
170
171 ));
172 }
173
174 /**
175 * Output the settings
176 */
177 public function output() {
178 global $current_section;
179
180 if ( $current_section ) {
181
182 if (isset($_REQUEST['id'])) // we're either adding or editing
183 {
184 $current_id = empty( $_REQUEST['id'] ) ? '' : sanitize_text_field($_REQUEST['id']);
185
186 switch ($current_section)
187 {
188 case "availability": { $settings = $this->get_custom_fields_availability_setting(); break; }
189 case "availability-delete": { $settings = $this->get_custom_fields_delete($current_id, 'availability', __( 'Availability', 'propertyhive' )); break; }
190 case "property-type": { $settings = $this->get_custom_fields_property_type_setting(); break; }
191 case "property-type-delete": { $settings = $this->get_custom_fields_delete($current_id, 'property_type', __( 'Property Type', 'propertyhive' )); break; }
192 case "commercial-property-type": { $settings = $this->get_custom_fields_commercial_property_type_setting(); break; }
193 case "commercial-property-type-delete": { $settings = $this->get_custom_fields_delete($current_id, 'commercial_property_type', __( 'Property Type', 'propertyhive' )); break; }
194 case "location": { $settings = $this->get_custom_fields_location_setting(); break; }
195 case "location-delete": { $settings = $this->get_custom_fields_delete($current_id, 'location', __( 'Location', 'propertyhive' )); break; }
196 case "parking": { $settings = $this->get_custom_fields_parking_setting(); break; }
197 case "parking-delete": { $settings = $this->get_custom_fields_delete($current_id, 'parking', __( 'Parking', 'propertyhive' )); break; }
198 case "outside-space": { $settings = $this->get_custom_fields_outside_space_setting(); break; }
199 case "outside-space-delete": { $settings = $this->get_custom_fields_delete($current_id, 'outside_space', __( 'Outside Space', 'propertyhive' )); break; }
200
201 case "price-qualifier": { $settings = $this->get_custom_fields_price_qualifier_setting(); break; }
202 case "price-qualifier-delete": { $settings = $this->get_custom_fields_delete($current_id, 'price_qualifier', __( 'Price Qualifier', 'propertyhive' )); break; }
203 case "sale-by": { $settings = $this->get_custom_fields_sale_by_setting(); break; }
204 case "sale-by-delete": { $settings = $this->get_custom_fields_delete($current_id, 'sale_by', __( 'Sale By', 'propertyhive' )); break; }
205 case "tenure": { $settings = $this->get_custom_fields_tenure_setting(); break; }
206 case "tenure-delete": { $settings = $this->get_custom_fields_delete($current_id, 'tenure', __( 'Tenure', 'propertyhive' )); break; }
207 case "commercial-tenure": { $settings = $this->get_custom_fields_commercial_tenure_setting(); break; }
208 case "commercial-tenure-delete": { $settings = $this->get_custom_fields_delete($current_id, 'commercial_tenure', __( 'Tenure', 'propertyhive' )); break; }
209
210 case "furnished": { $settings = $this->get_custom_fields_furnished_setting(); break; }
211 case "furnished-delete": { $settings = $this->get_custom_fields_delete($current_id, 'furnished', __( 'Furnished', 'propertyhive' )); break; }
212
213 case "marketing-flag": { $settings = $this->get_custom_fields_marketing_flag_setting(); break; }
214 case "marketing-flag-delete": { $settings = $this->get_custom_fields_delete($current_id, 'marketing_flag', __( 'Marketing Flag', 'propertyhive' )); break; }
215
216 case "property-feature": { $settings = $this->get_custom_fields_property_feature_setting(); break; }
217 case "property-feature-delete": { $settings = $this->get_custom_fields_delete($current_id, 'property_feature', __( 'Property Feature', 'propertyhive' )); break; }
218
219
220 default: { echo 'UNKNOWN CUSTOM FIELD'; }
221 }
222
223 PH_Admin_Settings::output_fields( $settings );
224 }
225 else
226 {
227 global $hide_save_button;
228
229 $hide_save_button = true;
230
231 // The main custom field screen listing them in a table
232 $settings = $this->get_custom_fields_setting($current_section);
233
234 PH_Admin_Settings::output_fields( $settings );
235 }
236
237 } else {
238 $settings = $this->get_settings();
239
240 PH_Admin_Settings::output_fields( $settings );
241 }
242 }
243
244 /**
245 * Output custom fields settings.
246 *
247 * @access public
248 * @return void
249 */
250 public function get_custom_fields_setting($current_section) {
251
252 $sections = $this->get_sections();
253
254 return apply_filters( 'propertyhive_custom_fields_' . $current_section . '_settings', array(
255
256 array( 'title' => $sections[$current_section], 'type' => 'title', 'desc' => '', 'id' => 'custom_fields_' . $current_section . '_options' ),
257
258 array(
259 'type' => 'custom_fields_' . str_replace("-", "_", $current_section),
260 ),
261
262 array( 'type' => 'sectionend', 'id' => 'custom_fields_' . $current_section . '_options'),
263
264 ));
265
266 }
267
268 /**
269 * Output list of availabilities
270 *
271 * @access public
272 * @return void
273 */
274 public function custom_fields_availability_setting() {
275 global $post;
276
277 $departments = ph_get_departments();
278
279 $availability_departments = get_option( 'propertyhive_availability_departments', array() );
280 if ( !is_array($availability_departments) ) { $availability_departments = array(); }
281 ?>
282 <tr valign="top">
283 <th scope="row" class="titledesc">
284 &nbsp;
285 </th>
286 <td class="forminp forminp-button">
287 <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
288 <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=availability&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Availability', 'propertyhive' ); ?></a>
289 </td>
290 </tr>
291 <tr valign="top">
292 <th scope="row" class="titledesc"><?php _e( 'Availability Options', 'propertyhive' ) ?></th>
293 <td class="forminp">
294 <table class="ph_customfields widefat" cellspacing="0">
295 <thead>
296 <tr>
297 <th class="cb" style="width:1px;">&nbsp;</th>
298 <th class="id" style="width:45px;"><?php _e( 'ID', 'propertyhive' ); ?></th>
299 <th class="type"><?php _e( 'Availability', 'propertyhive' ); ?></th>
300 <th class="department"><?php _e( 'Applies To', 'propertyhive' ); ?></th>
301 <th class="settings">&nbsp;</th>
302 </tr>
303 </thead>
304 <tbody>
305 <?php
306 $args = array(
307 'hide_empty' => false,
308 'parent' => 0
309 );
310 $terms = get_terms( 'availability', $args );
311
312 if ( !empty( $terms ) && !is_wp_error( $terms ) )
313 {
314 foreach ( $terms as $term )
315 {
316 ?>
317 <tr>
318 <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"></td>
319 <td class="id"><?php echo $term->term_id; ?></td>
320 <td class="type"><?php echo $term->name; ?></td>
321 <td class="department"><?php
322 $this_availability_departments = array();
323 if ( isset($availability_departments[$term->term_id]) )
324 {
325 foreach ( $availability_departments[$term->term_id] as $availability_department )
326 {
327 if ( get_option( 'propertyhive_active_departments_' . str_replace("residential-", "", $availability_department) ) == 'yes' )
328 {
329 $this_availability_departments[] = $departments[$availability_department];
330 }
331 }
332 }
333 else
334 {
335 foreach ( $departments as $key => $value )
336 {
337 if ( get_option( 'propertyhive_active_departments_' . str_replace("residential-", "", $key) ) == 'yes' )
338 {
339 $this_availability_departments[] = $value;
340 }
341 }
342 }
343
344 echo !empty($this_availability_departments) ? implode(", ", $this_availability_departments) : '-';
345 ?></td>
346 <td class="settings">
347 <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=availability&id=' . $term->term_id ); ?>"><?php echo __( 'Edit', 'propertyhive' ); ?></a>
348 <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=availability-delete&id=' . $term->term_id ); ?>"><?php echo __( 'Delete', 'propertyhive' ); ?></a>
349 </td>
350 </tr>
351 <?php
352 }
353 }
354 else
355 {
356 ?>
357 <tr>
358 <td><?php echo __( 'No availability options found', 'propertyhive' ); ?></td>
359 <td class="settings">
360
361 </td>
362 </tr>
363 <?php
364 }
365 ?>
366 </tbody>
367 </table>
368 </td>
369 </tr>
370 <tr valign="top">
371 <th scope="row" class="titledesc">
372 &nbsp;
373 </th>
374 <td class="forminp forminp-button">
375 <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
376 <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=availability&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Availability', 'propertyhive' ); ?></a>
377 </td>
378 </tr>
379 <?php
380 }
381
382 /**
383 * Output list of residential property types
384 *
385 * @access public
386 * @return void
387 */
388 public function custom_fields_property_type_setting() {
389 global $post;
390 ?>
391 <tr valign="top">
392 <th scope="row" class="titledesc">
393 &nbsp;
394 </th>
395 <td class="forminp forminp-button">
396 <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
397 <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=property-type&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Property Type', 'propertyhive' ); ?></a>
398 </td>
399 </tr>
400 <tr valign="top">
401 <th scope="row" class="titledesc"><?php _e( 'Property Types', 'propertyhive' ) ?></th>
402 <td class="forminp">
403 <table class="ph_customfields widefat" cellspacing="0">
404 <thead>
405 <tr>
406 <th class="cb" style="width:1px;">&nbsp;</th>
407 <th class="id" style="width:45px;"><?php _e( 'ID', 'propertyhive' ); ?></th>
408 <?php do_action( 'propertyhive_custom_field_property_type_table_before_header_column' ); ?>
409 <th class="type"><?php _e( 'Property Type', 'propertyhive' ); ?></th>
410 <th class="settings">&nbsp;</th>
411 </tr>
412 </thead>
413 <tbody>
414 <?php
415 $args = array(
416 'hide_empty' => false,
417 'parent' => 0
418 );
419 $terms = get_terms( 'property_type', $args );
420
421 if ( !empty( $terms ) && !is_wp_error( $terms ) )
422 {
423 foreach ($terms as $term)
424 {
425 $parent_term_id = $term->term_id;
426
427 $args = array(
428 'hide_empty' => false,
429 'parent' => $parent_term_id
430 );
431 $subterms = get_terms( 'property_type', $args );
432 ?>
433 <tr>
434 <td class="cb"><?php if ( empty( $subterms ) ) { ?><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"><?php }else{ echo '&nbsp;'; } ?></td>
435 <td class="id"><?php echo $term->term_id; ?></td>
436 <?php do_action( 'propertyhive_custom_field_property_type_table_before_row_column', $term->term_id ); ?>
437 <td class="type"><?php echo $term->name; ?></td>
438 <td class="settings">
439 <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=property-type&id=' . $term->term_id ); ?>"><?php echo __( 'Edit', 'propertyhive' ); ?></a>
440 <?php if ( empty( $subterms ) ) { ?>
441 <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=property-type-delete&id=' . $term->term_id ); ?>"><?php echo __( 'Delete', 'propertyhive' ); ?></a>
442 <?php } ?>
443 </td>
444 </tr>
445 <?php
446 if ( !empty( $subterms ) && !is_wp_error( $subterms ) )
447 {
448 foreach ($subterms as $term)
449 {
450 ?>
451 <tr>
452 <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"></td>
453 <td class="id"><?php echo $term->term_id; ?></td>
454 <?php do_action( 'propertyhive_custom_field_property_type_table_before_row_column', $term->term_id, $parent_term_id ); ?>
455 <td class="type subtype">&nbsp;&nbsp;&nbsp;- <?php echo $term->name; ?></td>
456 <td class="settings">
457 <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=property-type&id=' . $term->term_id ); ?>"><?php echo __( 'Edit', 'propertyhive' ); ?></a>
458 <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=property-type-delete&id=' . $term->term_id ); ?>"><?php echo __( 'Delete', 'propertyhive' ); ?></a>
459 </td>
460 </tr>
461 <?php
462 }
463 }
464 ?>
465 <?php
466 }
467 }
468 else
469 {
470 ?>
471 <tr>
472 <td colspan="3"><?php echo __( 'No property types found', 'propertyhive' ); ?></td>
473 </tr>
474 <?php
475 }
476 ?>
477 </tbody>
478 </table>
479 </td>
480 </tr>
481 <tr valign="top">
482 <th scope="row" class="titledesc">
483 &nbsp;
484 </th>
485 <td class="forminp forminp-button">
486 <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
487 <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=property-type&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Property Type', 'propertyhive' ); ?></a>
488 </td>
489 </tr>
490 <?php
491 }
492
493 /**
494 * Output list of commercial property types
495 *
496 * @access public
497 * @return void
498 */
499 public function custom_fields_commercial_property_type_setting() {
500 global $post;
501 ?>
502 <tr valign="top">
503 <th scope="row" class="titledesc">
504 &nbsp;
505 </th>
506 <td class="forminp forminp-button">
507 <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
508 <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=commercial-property-type&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Property Type', 'propertyhive' ); ?></a>
509 </td>
510 </tr>
511 <tr valign="top">
512 <th scope="row" class="titledesc"><?php _e( 'Property Types', 'propertyhive' ) ?></th>
513 <td class="forminp">
514 <table class="ph_customfields widefat" cellspacing="0">
515 <thead>
516 <tr>
517 <th class="cb" style="width:1px;">&nbsp;</th>
518 <th class="id" style="width:45px;"><?php _e( 'ID', 'propertyhive' ); ?></th>
519 <?php do_action( 'propertyhive_custom_field_commercial_property_type_table_before_header_column' ); ?>
520 <th class="type"><?php _e( 'Property Type', 'propertyhive' ); ?></th>
521 <th class="settings">&nbsp;</th>
522 </tr>
523 </thead>
524 <tbody>
525 <?php
526 $args = array(
527 'hide_empty' => false,
528 'parent' => 0
529 );
530 $terms = get_terms( 'commercial_property_type', $args );
531
532 if ( !empty( $terms ) && !is_wp_error( $terms ) )
533 {
534 foreach ($terms as $term)
535 {
536 $parent_term_id = $term->term_id;
537
538 $args = array(
539 'hide_empty' => false,
540 'parent' => $parent_term_id
541 );
542 $subterms = get_terms( 'commercial_property_type', $args );
543 ?>
544 <tr>
545 <td class="cb"><?php if ( empty( $subterms ) ) { ?><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"><?php }else{ echo '&nbsp;'; } ?></td>
546 <td class="id"><?php echo $term->term_id; ?></td>
547 <?php do_action( 'propertyhive_custom_field_commercial_property_type_table_before_row_column', $term->term_id ); ?>
548 <td class="type"><?php echo $term->name; ?></td>
549 <td class="settings">
550 <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=commercial-property-type&id=' . $term->term_id ); ?>"><?php echo __( 'Edit', 'propertyhive' ); ?></a>
551 <?php if ( empty( $subterms ) ) { ?>
552 <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=commercial-property-type-delete&id=' . $term->term_id ); ?>"><?php echo __( 'Delete', 'propertyhive' ); ?></a>
553 <?php } ?>
554 </td>
555 </tr>
556 <?php
557 if ( !empty( $subterms ) && !is_wp_error( $subterms ) )
558 {
559 foreach ($subterms as $term)
560 {
561 ?>
562 <tr>
563 <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"></td>
564 <td class="id"><?php echo $term->term_id; ?></td>
565 <?php do_action( 'propertyhive_custom_field_commercial_property_type_table_before_row_column', $term->term_id, $parent_term_id ); ?>
566 <td class="type subtype">&nbsp;&nbsp;&nbsp;- <?php echo $term->name; ?></td>
567 <td class="settings">
568 <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=commercial-property-type&id=' . $term->term_id ); ?>"><?php echo __( 'Edit', 'propertyhive' ); ?></a>
569 <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=commercial-property-type-delete&id=' . $term->term_id ); ?>"><?php echo __( 'Delete', 'propertyhive' ); ?></a>
570 </td>
571 </tr>
572 <?php
573 }
574 }
575 ?>
576 <?php
577 }
578 }
579 else
580 {
581 ?>
582 <tr>
583 <td colspan="3"><?php echo __( 'No property types found', 'propertyhive' ); ?></td>
584 </tr>
585 <?php
586 }
587 ?>
588 </tbody>
589 </table>
590 </td>
591 </tr>
592 <tr valign="top">
593 <th scope="row" class="titledesc">
594 &nbsp;
595 </th>
596 <td class="forminp forminp-button">
597 <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
598 <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=commercial-property-type&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Property Type', 'propertyhive' ); ?></a>
599 </td>
600 </tr>
601 <?php
602 }
603
604 /**
605 * Output list of locations
606 *
607 * @access public
608 * @return void
609 */
610 public function custom_fields_location_setting() {
611 global $post;
612 ?>
613 <tr valign="top">
614 <th scope="row" class="titledesc">
615 &nbsp;
616 </th>
617 <td class="forminp forminp-button">
618 <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
619 <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=location&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Location', 'propertyhive' ); ?></a>
620 </td>
621 </tr>
622 <tr valign="top">
623 <th scope="row" class="titledesc"><?php _e( 'Locations', 'propertyhive' ) ?></th>
624 <td class="forminp">
625 <table class="ph_customfields widefat" cellspacing="0">
626 <thead>
627 <tr>
628 <th class="cb" style="width:1px;">&nbsp;</th>
629 <th class="id" style="width:45px;"><?php _e( 'ID', 'propertyhive' ); ?></th>
630 <th class="type"><?php _e( 'Location', 'propertyhive' ); ?></th>
631 <th class="settings">&nbsp;</th>
632 </tr>
633 </thead>
634 <tbody>
635 <?php
636 $args = array(
637 'hide_empty' => false,
638 'parent' => 0
639 );
640 $terms = get_terms( 'location', $args );
641
642 if ( !empty( $terms ) && !is_wp_error( $terms ) )
643 {
644 foreach ($terms as $term)
645 {
646 $args = array(
647 'hide_empty' => false,
648 'parent' => $term->term_id
649 );
650 $subterms = get_terms( 'location', $args );
651 ?>
652 <tr>
653 <td class="cb"><?php if ( empty( $subterms ) ) { ?><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"><?php }else{ echo '&nbsp;'; } ?></td>
654 <td class="id"><?php echo $term->term_id; ?></td>
655 <td class="type"><?php echo $term->name; ?></td>
656 <td class="settings">
657 <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=location&id=' . $term->term_id ); ?>"><?php echo __( 'Edit', 'propertyhive' ); ?></a>
658 <?php if ( empty( $subterms ) ) { ?>
659 <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=location-delete&id=' . $term->term_id ); ?>"><?php echo __( 'Delete', 'propertyhive' ); ?></a>
660 <?php } ?>
661 </td>
662 </tr>
663 <?php
664 if ( !empty( $subterms ) && !is_wp_error( $subterms ) )
665 {
666 foreach ($subterms as $term)
667 {
668 $args = array(
669 'hide_empty' => false,
670 'parent' => $term->term_id
671 );
672 $subsubterms = get_terms( 'location', $args );
673 ?>
674 <tr>
675 <td class="cb"><?php if ( empty( $subsubterms ) ) { ?><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"><?php }else{ echo '&nbsp;'; } ?></td>
676 <td class="id"><?php echo $term->term_id; ?></td>
677 <td class="type subtype">&nbsp;&nbsp;&nbsp;- <?php echo $term->name; ?></td>
678 <td class="settings">
679 <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=location&id=' . $term->term_id ); ?>"><?php echo __( 'Edit', 'propertyhive' ); ?></a>
680 <?php if ( empty( $subsubterms ) ) { ?>
681 <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=location-delete&id=' . $term->term_id ); ?>"><?php echo __( 'Delete', 'propertyhive' ); ?></a>
682 <?php } ?>
683 </td>
684 </tr>
685 <?php
686 if ( !empty( $subsubterms ) && !is_wp_error( $subsubterms ) )
687 {
688 foreach ($subsubterms as $term)
689 {
690 ?>
691 <tr>
692 <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"></td>
693 <td class="id"><?php echo $term->term_id; ?></td>
694 <td class="type subtype">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- <?php echo $term->name; ?></td>
695 <td class="settings">
696 <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=location&id=' . $term->term_id ); ?>"><?php echo __( 'Edit', 'propertyhive' ); ?></a>
697 <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=location-delete&id=' . $term->term_id ); ?>"><?php echo __( 'Delete', 'propertyhive' ); ?></a>
698 </td>
699 </tr>
700 <?php
701 }
702 }
703 }
704 }
705 ?>
706 <?php
707 }
708 }
709 else
710 {
711 ?>
712 <tr>
713 <td><?php echo __( 'No locations found', 'propertyhive' ); ?></td>
714 <td class="settings">
715
716 </td>
717 </tr>
718 <?php
719 }
720 ?>
721 </tbody>
722 </table>
723 </td>
724 </tr>
725 <tr valign="top">
726 <th scope="row" class="titledesc">
727 &nbsp;
728 </th>
729 <td class="forminp forminp-button">
730 <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
731 <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=location&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Location', 'propertyhive' ); ?></a>
732 </td>
733 </tr>
734 <?php
735 }
736
737 /**
738 * Output list of parking
739 *
740 * @access public
741 * @return void
742 */
743 public function custom_fields_parking_setting() {
744 global $post;
745 ?>
746 <tr valign="top">
747 <th scope="row" class="titledesc">
748 &nbsp;
749 </th>
750 <td class="forminp forminp-button">
751 <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
752 <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=parking&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Parking', 'propertyhive' ); ?></a>
753 </td>
754 </tr>
755 <tr valign="top">
756 <th scope="row" class="titledesc"><?php _e( 'Parking Options', 'propertyhive' ) ?></th>
757 <td class="forminp">
758 <table class="ph_customfields widefat" cellspacing="0">
759 <thead>
760 <tr>
761 <th class="cb" style="width:1px;">&nbsp;</th>
762 <th class="id" style="width:45px;"><?php _e( 'ID', 'propertyhive' ); ?></th>
763 <th class="type"><?php _e( 'Parking', 'propertyhive' ); ?></th>
764 <th class="settings">&nbsp;</th>
765 </tr>
766 </thead>
767 <tbody>
768 <?php
769 $args = array(
770 'hide_empty' => false,
771 'parent' => 0
772 );
773 $terms = get_terms( 'parking', $args );
774
775 if ( !empty( $terms ) && !is_wp_error( $terms ) )
776 {
777 foreach ($terms as $term)
778 {
779 ?>
780 <tr>
781 <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"></td>
782 <td class="id"><?php echo $term->term_id; ?></td>
783 <td class="type"><?php echo $term->name; ?></td>
784 <td class="settings">
785 <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=parking&id=' . $term->term_id ); ?>"><?php echo __( 'Edit', 'propertyhive' ); ?></a>
786 <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=parking-delete&id=' . $term->term_id ); ?>"><?php echo __( 'Delete', 'propertyhive' ); ?></a>
787 </td>
788 </tr>
789 <?php
790 }
791 }
792 else
793 {
794 ?>
795 <tr>
796 <td><?php echo __( 'No parking options found', 'propertyhive' ); ?></td>
797 <td class="settings">
798
799 </td>
800 </tr>
801 <?php
802 }
803 ?>
804 </tbody>
805 </table>
806 </td>
807 </tr>
808 <tr valign="top">
809 <th scope="row" class="titledesc">
810 &nbsp;
811 </th>
812 <td class="forminp forminp-button">
813 <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
814 <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=parking&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Parking', 'propertyhive' ); ?></a>
815 </td>
816 </tr>
817 <?php
818 }
819
820 /**
821 * Output list of outside spaces
822 *
823 * @access public
824 * @return void
825 */
826 public function custom_fields_outside_space_setting() {
827 global $post;
828 ?>
829 <tr valign="top">
830 <th scope="row" class="titledesc">
831 &nbsp;
832 </th>
833 <td class="forminp forminp-button">
834 <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
835 <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=outside-space&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Outside Space', 'propertyhive' ); ?></a>
836 </td>
837 </tr>
838 <tr valign="top">
839 <th scope="row" class="titledesc"><?php _e( 'Outside Spaces', 'propertyhive' ) ?></th>
840 <td class="forminp">
841 <table class="ph_customfields widefat" cellspacing="0">
842 <thead>
843 <tr>
844 <th class="cb" style="width:1px;">&nbsp;</th>
845 <th class="id" style="width:45px;"><?php _e( 'ID', 'propertyhive' ); ?></th>
846 <th class="type"><?php _e( 'Outside Space', 'propertyhive' ); ?></th>
847 <th class="settings">&nbsp;</th>
848 </tr>
849 </thead>
850 <tbody>
851 <?php
852 $args = array(
853 'hide_empty' => false,
854 'parent' => 0
855 );
856 $terms = get_terms( 'outside_space', $args );
857
858 if ( !empty( $terms ) && !is_wp_error( $terms ) )
859 {
860 foreach ($terms as $term)
861 {
862 ?>
863 <tr>
864 <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"></td>
865 <td class="id"><?php echo $term->term_id; ?></td>
866 <td class="type"><?php echo $term->name; ?></td>
867 <td class="settings">
868 <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=outside-space&id=' . $term->term_id ); ?>"><?php echo __( 'Edit', 'propertyhive' ); ?></a>
869 <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=outside-space-delete&id=' . $term->term_id ); ?>"><?php echo __( 'Delete', 'propertyhive' ); ?></a>
870 </td>
871 </tr>
872 <?php
873 }
874 }
875 else
876 {
877 ?>
878 <tr>
879 <td><?php echo __( 'No outside spaces found', 'propertyhive' ); ?></td>
880 <td class="settings">
881
882 </td>
883 </tr>
884 <?php
885 }
886 ?>
887 </tbody>
888 </table>
889 </td>
890 </tr>
891 <tr valign="top">
892 <th scope="row" class="titledesc">
893 &nbsp;
894 </th>
895 <td class="forminp forminp-button">
896 <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
897 <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=outside-space&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Outside Space', 'propertyhive' ); ?></a>
898 </td>
899 </tr>
900 <?php
901 }
902
903 /**
904 * Output list of price qualifiers
905 *
906 * @access public
907 * @return void
908 */
909 public function custom_fields_price_qualifier_setting() {
910 global $post;
911 ?>
912 <tr valign="top">
913 <th scope="row" class="titledesc">
914 &nbsp;
915 </th>
916 <td class="forminp forminp-button">
917 <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
918 <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=price-qualifier&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Price Qualifier', 'propertyhive' ); ?></a>
919 </td>
920 </tr>
921 <tr valign="top">
922 <th scope="row" class="titledesc"><?php _e( 'Price Qualifiers', 'propertyhive' ) ?></th>
923 <td class="forminp">
924 <table class="ph_customfields widefat" cellspacing="0">
925 <thead>
926 <tr>
927 <th class="cb" style="width:1px;">&nbsp;</th>
928 <th class="id" style="width:45px;"><?php _e( 'ID', 'propertyhive' ); ?></th>
929 <th class="type"><?php _e( 'Price Qualifier', 'propertyhive' ); ?></th>
930 <th class="settings">&nbsp;</th>
931 </tr>
932 </thead>
933 <tbody>
934 <?php
935 $args = array(
936 'hide_empty' => false,
937 'parent' => 0
938 );
939 $terms = get_terms( 'price_qualifier', $args );
940
941 if ( !empty( $terms ) && !is_wp_error( $terms ) )
942 {
943 foreach ($terms as $term)
944 {
945 ?>
946 <tr>
947 <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"></td>
948 <td class="id"><?php echo $term->term_id; ?></td>
949 <td class="type"><?php echo $term->name; ?></td>
950 <td class="settings">
951 <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=price-qualifier&id=' . $term->term_id ); ?>"><?php echo __( 'Edit', 'propertyhive' ); ?></a>
952 <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=price-qualifier-delete&id=' . $term->term_id ); ?>"><?php echo __( 'Delete', 'propertyhive' ); ?></a>
953 </td>
954 </tr>
955 <?php
956 }
957 }
958 else
959 {
960 ?>
961 <tr>
962 <td><?php echo __( 'No price qualifiers found', 'propertyhive' ); ?></td>
963 <td class="settings">
964
965 </td>
966 </tr>
967 <?php
968 }
969 ?>
970 </tbody>
971 </table>
972 </td>
973 </tr>
974 <tr valign="top">
975 <th scope="row" class="titledesc">
976 &nbsp;
977 </th>
978 <td class="forminp forminp-button">
979 <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
980 <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=price-qualifier&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Price Qualifier', 'propertyhive' ); ?></a>
981 </td>
982 </tr>
983 <?php
984 }
985
986 /**
987 * Output list of sale by options
988 *
989 * @access public
990 * @return void
991 */
992 public function custom_fields_sale_by_setting() {
993 global $post;
994 ?>
995 <tr valign="top">
996 <th scope="row" class="titledesc">
997 &nbsp;
998 </th>
999 <td class="forminp forminp-button">
1000 <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
1001 <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=sale-by&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Sale By', 'propertyhive' ); ?></a>
1002 </td>
1003 </tr>
1004 <tr valign="top">
1005 <th scope="row" class="titledesc"><?php _e( 'Sale By Options', 'propertyhive' ) ?></th>
1006 <td class="forminp">
1007 <table class="ph_customfields widefat" cellspacing="0">
1008 <thead>
1009 <tr>
1010 <th class="cb" style="width:1px;">&nbsp;</th>
1011 <th class="id" style="width:45px;"><?php _e( 'ID', 'propertyhive' ); ?></th>
1012 <th class="type"><?php _e( 'Sale By', 'propertyhive' ); ?></th>
1013 <th class="settings">&nbsp;</th>
1014 </tr>
1015 </thead>
1016 <tbody>
1017 <?php
1018 $args = array(
1019 'hide_empty' => false,
1020 'parent' => 0
1021 );
1022 $terms = get_terms( 'sale_by', $args );
1023
1024 if ( !empty( $terms ) && !is_wp_error( $terms ) )
1025 {
1026 foreach ($terms as $term)
1027 {
1028 ?>
1029 <tr>
1030 <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"></td>
1031 <td class="id"><?php echo $term->term_id; ?></td>
1032 <td class="type"><?php echo $term->name; ?></td>
1033 <td class="settings">
1034 <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=sale-by&id=' . $term->term_id ); ?>"><?php echo __( 'Edit', 'propertyhive' ); ?></a>
1035 <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=sale-by-delete&id=' . $term->term_id ); ?>"><?php echo __( 'Delete', 'propertyhive' ); ?></a>
1036 </td>
1037 </tr>
1038 <?php
1039 }
1040 }
1041 else
1042 {
1043 ?>
1044 <tr>
1045 <td><?php echo __( 'No sale by options found', 'propertyhive' ); ?></td>
1046 <td class="settings">
1047
1048 </td>
1049 </tr>
1050 <?php
1051 }
1052 ?>
1053 </tbody>
1054 </table>
1055 </td>
1056 </tr>
1057 <tr valign="top">
1058 <th scope="row" class="titledesc">
1059 &nbsp;
1060 </th>
1061 <td class="forminp forminp-button">
1062 <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
1063 <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=sale-by&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Sale By', 'propertyhive' ); ?></a>
1064 </td>
1065 </tr>
1066 <?php
1067 }
1068
1069 /**
1070 * Output list of residential tenure options
1071 *
1072 * @access public
1073 * @return void
1074 */
1075 public function custom_fields_tenure_setting() {
1076 global $post;
1077 ?>
1078 <tr valign="top">
1079 <th scope="row" class="titledesc">
1080 &nbsp;
1081 </th>
1082 <td class="forminp forminp-button">
1083 <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
1084 <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=tenure&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Tenure', 'propertyhive' ); ?></a>
1085 </td>
1086 </tr>
1087 <tr valign="top">
1088 <th scope="row" class="titledesc"><?php _e( 'Tenures', 'propertyhive' ) ?></th>
1089 <td class="forminp">
1090 <table class="ph_customfields widefat" cellspacing="0">
1091 <thead>
1092 <tr>
1093 <th class="cb" style="width:1px;">&nbsp;</th>
1094 <th class="id" style="width:45px;"><?php _e( 'ID', 'propertyhive' ); ?></th>
1095 <th class="type"><?php _e( 'Tenure', 'propertyhive' ); ?></th>
1096 <th class="settings">&nbsp;</th>
1097 </tr>
1098 </thead>
1099 <tbody>
1100 <?php
1101 $args = array(
1102 'hide_empty' => false,
1103 'parent' => 0
1104 );
1105 $terms = get_terms( 'tenure', $args );
1106
1107 if ( !empty( $terms ) && !is_wp_error( $terms ) )
1108 {
1109 foreach ($terms as $term)
1110 {
1111 ?>
1112 <tr>
1113 <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"></td>
1114 <td class="id"><?php echo $term->term_id; ?></td>
1115 <td class="type"><?php echo $term->name; ?></td>
1116 <td class="settings">
1117 <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=tenure&id=' . $term->term_id ); ?>"><?php echo __( 'Edit', 'propertyhive' ); ?></a>
1118 <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=tenure-delete&id=' . $term->term_id ); ?>"><?php echo __( 'Delete', 'propertyhive' ); ?></a>
1119 </td>
1120 </tr>
1121 <?php
1122 }
1123 }
1124 else
1125 {
1126 ?>
1127 <tr>
1128 <td><?php echo __( 'No tenure found', 'propertyhive' ); ?></td>
1129 <td class="settings">
1130
1131 </td>
1132 </tr>
1133 <?php
1134 }
1135 ?>
1136 </tbody>
1137 </table>
1138 </td>
1139 </tr>
1140 <tr valign="top">
1141 <th scope="row" class="titledesc">
1142 &nbsp;
1143 </th>
1144 <td class="forminp forminp-button">
1145 <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
1146 <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=tenure&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Tenure', 'propertyhive' ); ?></a>
1147 </td>
1148 </tr>
1149 <?php
1150 }
1151
1152 /**
1153 * Output list of commercial tenure options
1154 *
1155 * @access public
1156 * @return void
1157 */
1158 public function custom_fields_commercial_tenure_setting() {
1159 global $post;
1160 ?>
1161 <tr valign="top">
1162 <th scope="row" class="titledesc">
1163 &nbsp;
1164 </th>
1165 <td class="forminp forminp-button">
1166 <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
1167 <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=commercial-tenure&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Tenure', 'propertyhive' ); ?></a>
1168 </td>
1169 </tr>
1170 <tr valign="top">
1171 <th scope="row" class="titledesc"><?php _e( 'Tenures', 'propertyhive' ) ?></th>
1172 <td class="forminp">
1173 <table class="ph_customfields widefat" cellspacing="0">
1174 <thead>
1175 <tr>
1176 <th class="cb" style="width:1px;">&nbsp;</th>
1177 <th class="id" style="width:45px;"><?php _e( 'ID', 'propertyhive' ); ?></th>
1178 <th class="type"><?php _e( 'Tenure', 'propertyhive' ); ?></th>
1179 <th class="settings">&nbsp;</th>
1180 </tr>
1181 </thead>
1182 <tbody>
1183 <?php
1184 $args = array(
1185 'hide_empty' => false,
1186 'parent' => 0
1187 );
1188 $terms = get_terms( 'commercial_tenure', $args );
1189
1190 if ( !empty( $terms ) && !is_wp_error( $terms ) )
1191 {
1192 foreach ($terms as $term)
1193 {
1194 ?>
1195 <tr>
1196 <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"></td>
1197 <td class="id"><?php echo $term->term_id; ?></td>
1198 <td class="type"><?php echo $term->name; ?></td>
1199 <td class="settings">
1200 <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=commercial-tenure&id=' . $term->term_id ); ?>"><?php echo __( 'Edit', 'propertyhive' ); ?></a>
1201 <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=commercial-tenure-delete&id=' . $term->term_id ); ?>"><?php echo __( 'Delete', 'propertyhive' ); ?></a>
1202 </td>
1203 </tr>
1204 <?php
1205 }
1206 }
1207 else
1208 {
1209 ?>
1210 <tr>
1211 <td><?php echo __( 'No tenure found', 'propertyhive' ); ?></td>
1212 <td class="settings">
1213
1214 </td>
1215 </tr>
1216 <?php
1217 }
1218 ?>
1219 </tbody>
1220 </table>
1221 </td>
1222 </tr>
1223 <tr valign="top">
1224 <th scope="row" class="titledesc">
1225 &nbsp;
1226 </th>
1227 <td class="forminp forminp-button">
1228 <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
1229 <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=commercial-tenure&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Tenure', 'propertyhive' ); ?></a>
1230 </td>
1231 </tr>
1232 <?php
1233 }
1234
1235 /**
1236 * Output list of furnished options
1237 *
1238 * @access public
1239 * @return void
1240 */
1241 public function custom_fields_furnished_setting() {
1242 global $post;
1243 ?>
1244 <tr valign="top">
1245 <th scope="row" class="titledesc">
1246 &nbsp;
1247 </th>
1248 <td class="forminp forminp-button">
1249 <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
1250 <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=furnished&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Furnished Option', 'propertyhive' ); ?></a>
1251 </td>
1252 </tr>
1253 <tr valign="top">
1254 <th scope="row" class="titledesc"><?php _e( 'Furnished Options', 'propertyhive' ) ?></th>
1255 <td class="forminp">
1256 <table class="ph_customfields widefat" cellspacing="0">
1257 <thead>
1258 <tr>
1259 <th class="cb" style="width:1px;">&nbsp;</th>
1260 <th class="id" style="width:45px;"><?php _e( 'ID', 'propertyhive' ); ?></th>
1261 <th class="type"><?php _e( 'Furnished', 'propertyhive' ); ?></th>
1262 <th class="settings">&nbsp;</th>
1263 </tr>
1264 </thead>
1265 <tbody>
1266 <?php
1267 $args = array(
1268 'hide_empty' => false,
1269 'parent' => 0
1270 );
1271 $terms = get_terms( 'furnished', $args );
1272
1273 if ( !empty( $terms ) && !is_wp_error( $terms ) )
1274 {
1275 foreach ($terms as $term)
1276 {
1277 ?>
1278 <tr>
1279 <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"></td>
1280 <td class="id"><?php echo $term->term_id; ?></td>
1281 <td class="type"><?php echo $term->name; ?></td>
1282 <td class="settings">
1283 <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=furnished&id=' . $term->term_id ); ?>"><?php echo __( 'Edit', 'propertyhive' ); ?></a>
1284 <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=furnished-delete&id=' . $term->term_id ); ?>"><?php echo __( 'Delete', 'propertyhive' ); ?></a>
1285 </td>
1286 </tr>
1287 <?php
1288 }
1289 }
1290 else
1291 {
1292 ?>
1293 <tr>
1294 <td><?php echo __( 'No furnished options found', 'propertyhive' ); ?></td>
1295 <td class="settings">
1296
1297 </td>
1298 </tr>
1299 <?php
1300 }
1301 ?>
1302 </tbody>
1303 </table>
1304 </td>
1305 </tr>
1306 <tr valign="top">
1307 <th scope="row" class="titledesc">
1308 &nbsp;
1309 </th>
1310 <td class="forminp forminp-button">
1311 <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
1312 <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=furnished&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Furnished Option', 'propertyhive' ); ?></a>
1313 </td>
1314 </tr>
1315 <?php
1316 }
1317
1318 /**
1319 * Output list of marketing flag options
1320 *
1321 * @access public
1322 * @return void
1323 */
1324 public function custom_fields_marketing_flag_setting() {
1325 global $post;
1326 ?>
1327 <tr valign="top">
1328 <th scope="row" class="titledesc">
1329 &nbsp;
1330 </th>
1331 <td class="forminp forminp-button">
1332 <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
1333 <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=marketing-flag&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Marketing Flag', 'propertyhive' ); ?></a>
1334 </td>
1335 </tr>
1336 <tr valign="top">
1337 <th scope="row" class="titledesc"><?php _e( 'Marketing Flags', 'propertyhive' ) ?></th>
1338 <td class="forminp">
1339 <table class="ph_customfields widefat" cellspacing="0">
1340 <thead>
1341 <tr>
1342 <th class="cb" style="width:1px;">&nbsp;</th>
1343 <th class="id" style="width:45px;"><?php _e( 'ID', 'propertyhive' ); ?></th>
1344 <th class="type"><?php _e( 'Marketing Flag', 'propertyhive' ); ?></th>
1345 <th class="settings">&nbsp;</th>
1346 </tr>
1347 </thead>
1348 <tbody>
1349 <?php
1350 $args = array(
1351 'hide_empty' => false,
1352 'parent' => 0
1353 );
1354 $terms = get_terms( 'marketing_flag', $args );
1355
1356 if ( !empty( $terms ) && !is_wp_error( $terms ) )
1357 {
1358 foreach ($terms as $term)
1359 {
1360 ?>
1361 <tr>
1362 <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"></td>
1363 <td class="id"><?php echo $term->term_id; ?></td>
1364 <td class="type"><?php echo $term->name; ?></td>
1365 <td class="settings">
1366 <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=marketing-flag&id=' . $term->term_id ); ?>"><?php echo __( 'Edit', 'propertyhive' ); ?></a>
1367 <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=marketing-flag-delete&id=' . $term->term_id ); ?>"><?php echo __( 'Delete', 'propertyhive' ); ?></a>
1368 </td>
1369 </tr>
1370 <?php
1371 }
1372 }
1373 else
1374 {
1375 ?>
1376 <tr>
1377 <td><?php echo __( 'No marketing flags found', 'propertyhive' ); ?></td>
1378 <td class="settings">
1379
1380 </td>
1381 </tr>
1382 <?php
1383 }
1384 ?>
1385 </tbody>
1386 </table>
1387 </td>
1388 </tr>
1389 <tr valign="top">
1390 <th scope="row" class="titledesc">
1391 &nbsp;
1392 </th>
1393 <td class="forminp forminp-button">
1394 <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
1395 <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=marketing-flag&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Marketing Flag', 'propertyhive' ); ?></a>
1396 </td>
1397 </tr>
1398 <?php
1399 }
1400
1401 /**
1402 * Output list of property feature options
1403 *
1404 * @access public
1405 * @return void
1406 */
1407 public function custom_fields_property_feature_setting() {
1408 global $post;
1409 ?>
1410 <tr valign="top">
1411 <th scope="row" class="titledesc">
1412 &nbsp;
1413 </th>
1414 <td class="forminp forminp-button">
1415 <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
1416 <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=property-feature&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Property Feature', 'propertyhive' ); ?></a>
1417 </td>
1418 </tr>
1419 <tr valign="top">
1420 <th scope="row" class="titledesc"><?php _e( 'Property Features', 'propertyhive' ) ?></th>
1421 <td class="forminp">
1422 <table class="ph_customfields widefat" cellspacing="0">
1423 <thead>
1424 <tr>
1425 <th class="cb" style="width:1px;">&nbsp;</th>
1426 <th class="id" style="width:45px;"><?php _e( 'ID', 'propertyhive' ); ?></th>
1427 <th class="type"><?php _e( 'Property Feature', 'propertyhive' ); ?></th>
1428 <th class="settings">&nbsp;</th>
1429 </tr>
1430 </thead>
1431 <tbody>
1432 <?php
1433 $args = array(
1434 'hide_empty' => false,
1435 'parent' => 0
1436 );
1437 $terms = get_terms( 'property_feature', $args );
1438
1439 if ( !empty( $terms ) && !is_wp_error( $terms ) )
1440 {
1441 foreach ($terms as $term)
1442 {
1443 ?>
1444 <tr>
1445 <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"></td>
1446 <td class="id"><?php echo $term->term_id; ?></td>
1447 <td class="type"><?php echo $term->name; ?></td>
1448 <td class="settings">
1449 <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=property-feature&id=' . $term->term_id ); ?>"><?php echo __( 'Edit', 'propertyhive' ); ?></a>
1450 <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=property-feature-delete&id=' . $term->term_id ); ?>"><?php echo __( 'Delete', 'propertyhive' ); ?></a>
1451 </td>
1452 </tr>
1453 <?php
1454 }
1455 }
1456 else
1457 {
1458 ?>
1459 <tr>
1460 <td colspan="3"><?php echo __( 'No property features found', 'propertyhive' ); ?></td>
1461 </tr>
1462 <?php
1463 }
1464 ?>
1465 </tbody>
1466 </table>
1467 </td>
1468 </tr>
1469 <tr valign="top">
1470 <th scope="row" class="titledesc">
1471 &nbsp;
1472 </th>
1473 <td class="forminp forminp-button">
1474 <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
1475 <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=property-feature&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Property Feature', 'propertyhive' ); ?></a>
1476 </td>
1477 </tr>
1478 <?php
1479 }
1480
1481 /**
1482 * Show availability add/edit options
1483 *
1484 * @access public
1485 * @return string
1486 */
1487 public function get_custom_fields_availability_setting()
1488 {
1489 $current_id = empty( $_REQUEST['id'] ) ? '' : (int)$_REQUEST['id'];
1490
1491 $taxonomy = 'availability';
1492 $term_name = '';
1493 if ($current_id != '')
1494 {
1495 $term = get_term( $current_id, $taxonomy );
1496 $term_name = $term->name;
1497 }
1498
1499 $departments = ph_get_departments();
1500
1501 $args = array(
1502
1503 array( 'title' => __( ( $current_id == '' ? 'Add New Availability Option' : 'Edit Availability' ), 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_availability_settings' ),
1504
1505 array(
1506 'title' => __( 'Availability', 'propertyhive' ),
1507 'id' => 'availability_name',
1508 'default' => $term_name,
1509 'type' => 'text',
1510 'desc_tip' => false,
1511 ),
1512
1513 );
1514
1515 $availability_departments = get_option( 'propertyhive_availability_departments', array() );
1516
1517 $i = 0;
1518 foreach ( $departments as $key => $value )
1519 {
1520 if ( get_option( 'propertyhive_active_departments_' . str_replace("residential-", "", $key) ) == 'yes' )
1521 {
1522 $args[] = array(
1523 'title' => __( 'Applies To', 'propertyhive' ),
1524 'name' => 'department[' . $key . ']',
1525 'id' => 'department_' . $key,
1526 //'default' => $term_name,
1527 'value' => ( !isset($availability_departments[$current_id]) || in_array($key, $availability_departments[$current_id]) ? 'yes' : '' ),
1528 'type' => 'checkbox',
1529 'desc_tip' => false,
1530 'desc' => $value,
1531 'checkboxgroup' => ( $i == 0 ? 'start' : ( $i == count($departments)-1 ? 'end' : '' ) ),
1532 );
1533
1534 ++$i;
1535 }
1536 }
1537
1538 $args[] = array(
1539 'type' => 'hidden',
1540 'id' => 'taxonomy',
1541 'default' => $taxonomy
1542 );
1543
1544 $args[] = array( 'type' => 'sectionend', 'id' => 'custom_field_availability_settings' );
1545
1546 return apply_filters( 'propertyhive_custom_field_availability_settings', $args );
1547 }
1548
1549 /**
1550 * Show residential property type add/edit options
1551 *
1552 * @access public
1553 * @return string
1554 */
1555 public function get_custom_fields_property_type_setting()
1556 {
1557 $current_id = empty( $_REQUEST['id'] ) ? '' : (int)$_REQUEST['id'];
1558
1559 $taxonomy = 'property_type';
1560 $term_name = '';
1561 $term_parent = '';
1562 if ($current_id != '')
1563 {
1564 $term = get_term( $current_id, $taxonomy );
1565 $term_name = $term->name;
1566 $term_parent = $term->parent;
1567 }
1568
1569 $existing_terms = array('' => '(' . __ ( 'no parent', 'propertyhive') . ')');
1570
1571 $args = array(
1572 'hide_empty' => false,
1573 'parent' => 0,
1574 'exclude' => array($current_id)
1575 );
1576 $terms = get_terms( 'property_type', $args );
1577 if ( !empty( $terms ) && !is_wp_error( $terms ) )
1578 {
1579 foreach ($terms as $term)
1580 {
1581 $existing_terms[$term->term_id] = $term->name;
1582 }
1583 }
1584
1585 $args = array(
1586
1587 array( 'title' => __( ( $current_id == '' ? 'Add New Property Type' : 'Edit Property Type' ), 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_property_type_settings' ),
1588
1589 array(
1590 'title' => __( 'Property Type', 'propertyhive' ),
1591 'id' => 'property_type_name',
1592 'default' => $term_name,
1593 'type' => 'text',
1594 'desc_tip' => false,
1595 ),
1596
1597 array(
1598 'title' => __( 'Parent', 'propertyhive' ),
1599 'id' => 'parent_property_type_id',
1600 'default' => $term_parent,
1601 'options' => $existing_terms,
1602 'type' => 'select',
1603 'desc_tip' => false,
1604 'desc' => ''
1605 ),
1606
1607 array(
1608 'type' => 'hidden',
1609 'id' => 'taxonomy',
1610 'default' => $taxonomy
1611 ),
1612
1613 array( 'type' => 'sectionend', 'id' => 'custom_field_property_type_settings' )
1614
1615 );
1616
1617 return apply_filters( 'propertyhive_custom_field_property_type_settings', $args );
1618 }
1619
1620 /**
1621 * Show commercial property type add/edit options
1622 *
1623 * @access public
1624 * @return string
1625 */
1626 public function get_custom_fields_commercial_property_type_setting()
1627 {
1628 $current_id = empty( $_REQUEST['id'] ) ? '' : (int)$_REQUEST['id'];
1629
1630 $taxonomy = 'commercial_property_type';
1631 $term_name = '';
1632 $term_parent = '';
1633 if ($current_id != '')
1634 {
1635 $term = get_term( $current_id, $taxonomy );
1636 $term_name = $term->name;
1637 $term_parent = $term->parent;
1638 }
1639
1640 $existing_terms = array('' => '(' . __ ( 'no parent', 'propertyhive') . ')');
1641
1642 $args = array(
1643 'hide_empty' => false,
1644 'parent' => 0,
1645 'exclude' => array($current_id)
1646 );
1647 $terms = get_terms( 'commercial_property_type', $args );
1648 if ( !empty( $terms ) && !is_wp_error( $terms ) )
1649 {
1650 foreach ($terms as $term)
1651 {
1652 $existing_terms[$term->term_id] = $term->name;
1653 }
1654 }
1655
1656 $args = array(
1657
1658 array( 'title' => __( ( $current_id == '' ? 'Add New Property Type' : 'Edit Property Type' ), 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_commercial_property_type_settings' ),
1659
1660 array(
1661 'title' => __( 'Property Type', 'propertyhive' ),
1662 'id' => 'commercial_property_type_name',
1663 'default' => $term_name,
1664 'type' => 'text',
1665 'desc_tip' => false,
1666 ),
1667
1668 array(
1669 'title' => __( 'Parent', 'propertyhive' ),
1670 'id' => 'parent_commercial_property_type_id',
1671 'default' => $term_parent,
1672 'options' => $existing_terms,
1673 'type' => 'select',
1674 'desc_tip' => false,
1675 'desc' => ''
1676 ),
1677
1678 array(
1679 'type' => 'hidden',
1680 'id' => 'taxonomy',
1681 'default' => $taxonomy
1682 ),
1683
1684 array( 'type' => 'sectionend', 'id' => 'custom_field_commercial_property_type_settings' )
1685
1686 );
1687
1688 return apply_filters( 'propertyhive_custom_field_commercial_property_type_settings', $args );
1689 }
1690
1691 /**
1692 * Show location add/edit options
1693 *
1694 * @access public
1695 * @return string
1696 */
1697 public function get_custom_fields_location_setting()
1698 {
1699 $current_id = empty( $_REQUEST['id'] ) ? '' : (int)$_REQUEST['id'];
1700
1701 $taxonomy = 'location';
1702 $term_name = '';
1703 $term_parent = '';
1704 if ($current_id != '')
1705 {
1706 $term = get_term( $current_id, $taxonomy );
1707 $term_name = $term->name;
1708 $term_parent = $term->parent;
1709 }
1710
1711 $existing_terms = array('' => '(' . __ ( 'no parent', 'propertyhive') . ')');
1712
1713 $args = array(
1714 'hide_empty' => false,
1715 'parent' => 0,
1716 'exclude' => array($current_id)
1717 );
1718 $terms = get_terms( $taxonomy, $args );
1719 if ( !empty( $terms ) && !is_wp_error( $terms ) )
1720 {
1721 foreach ($terms as $term)
1722 {
1723 $existing_terms[$term->term_id] = '- '.$term->name;
1724
1725 $args = array(
1726 'hide_empty' => false,
1727 'parent' => $term->term_id,
1728 'exclude' => array($current_id)
1729 );
1730 $terms = get_terms( $taxonomy, $args );
1731 if ( !empty( $terms ) && !is_wp_error( $terms ) )
1732 {
1733 foreach ($terms as $term)
1734 {
1735 $existing_terms[$term->term_id] = '- - '.$term->name;
1736 }
1737 }
1738 }
1739 }
1740
1741 $args = array(
1742
1743 array( 'title' => __( ( $current_id == '' ? 'Add New Location' : 'Edit Location' ), 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_location_settings' ),
1744
1745 array(
1746 'title' => __( 'Location', 'propertyhive' ),
1747 'id' => 'location_name',
1748 'default' => $term_name,
1749 'type' => 'text',
1750 'desc_tip' => false,
1751 ),
1752
1753 array(
1754 'title' => __( 'Parent', 'propertyhive' ),
1755 'id' => 'parent_location_id',
1756 'default' => $term_parent,
1757 'options' => $existing_terms,
1758 'type' => 'select',
1759 'desc_tip' => false,
1760 'desc' => ''
1761 ),
1762
1763 array(
1764 'type' => 'hidden',
1765 'id' => 'taxonomy',
1766 'default' => $taxonomy
1767 ),
1768
1769 array( 'type' => 'sectionend', 'id' => 'custom_field_location_settings' )
1770
1771 );
1772
1773 return apply_filters( 'propertyhive_custom_field_location_settings', $args );
1774 }
1775
1776 /**
1777 * Show parking add/edit options
1778 *
1779 * @access public
1780 * @return string
1781 */
1782 public function get_custom_fields_parking_setting()
1783 {
1784 $current_id = empty( $_REQUEST['id'] ) ? '' : (int)$_REQUEST['id'];
1785
1786 $taxonomy = 'parking';
1787 $term_name = '';
1788 if ($current_id != '')
1789 {
1790 $term = get_term( $current_id, $taxonomy );
1791 $term_name = $term->name;
1792 }
1793
1794 $args = array(
1795
1796 array( 'title' => __( ( $current_id == '' ? 'Add New Parking Option' : 'Edit Parking' ), 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_parking_settings' ),
1797
1798 array(
1799 'title' => __( 'Parking', 'propertyhive' ),
1800 'id' => 'parking_name',
1801 'default' => $term_name,
1802 'type' => 'text',
1803 'desc_tip' => false,
1804 ),
1805
1806 array(
1807 'type' => 'hidden',
1808 'id' => 'taxonomy',
1809 'default' => $taxonomy
1810 ),
1811
1812 array( 'type' => 'sectionend', 'id' => 'custom_field_parking_settings' )
1813
1814 );
1815
1816 return apply_filters( 'propertyhive_custom_field_parking_settings', $args );
1817 }
1818
1819 /**
1820 * Show outside space add/edit options
1821 *
1822 * @access public
1823 * @return string
1824 */
1825 public function get_custom_fields_outside_space_setting()
1826 {
1827 $current_id = empty( $_REQUEST['id'] ) ? '' : (int)$_REQUEST['id'];
1828
1829 $taxonomy = 'outside_space';
1830 $term_name = '';
1831 if ($current_id != '')
1832 {
1833 $term = get_term( $current_id, $taxonomy );
1834 $term_name = $term->name;
1835 }
1836
1837 $args = array(
1838
1839 array( 'title' => __( ( $current_id == '' ? 'Add New Outside Space' : 'Edit Outside Space' ), 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_outside_space_settings' ),
1840
1841 array(
1842 'title' => __( 'Outside Space', 'propertyhive' ),
1843 'id' => 'outside_space_name',
1844 'default' => $term_name,
1845 'type' => 'text',
1846 'desc_tip' => false,
1847 ),
1848
1849 array(
1850 'type' => 'hidden',
1851 'id' => 'taxonomy',
1852 'default' => $taxonomy
1853 ),
1854
1855 array( 'type' => 'sectionend', 'id' => 'custom_field_outside_space_settings' )
1856
1857 );
1858
1859 return apply_filters( 'propertyhive_custom_field_outside_space_settings', $args );
1860 }
1861
1862 /**
1863 * Show custom field delete options
1864 *
1865 * @access public
1866 * @return string
1867 */
1868 public function get_custom_fields_delete($current_id, $taxonomy, $taxonomy_name)
1869 {
1870 global $save_button_text;
1871
1872 $save_button_text = __( 'Delete', 'propertyhive' );
1873
1874 //$taxonomy = 'outside_space';
1875 //$taxonomy_name = __( 'Outside Space', 'propertyhive' );
1876
1877 if ( isset($_POST['confirm_removal']) && $_POST['confirm_removal'] == 1 )
1878 {
1879 // A term has just been deleted
1880 global $hide_save_button, $show_cancel_button, $cancel_button_href;
1881
1882 $hide_save_button = TRUE;
1883 $show_cancel_button = TRUE;
1884 $cancel_button_href = admin_url( 'admin.php?page=ph-settings&tab=customfields&section=' . str_replace("_", "-", $taxonomy) );
1885
1886 $args = array();
1887
1888 $args[] = array( 'title' => __( 'Successfully Deleted', 'propertyhive' ) . ' ' . $taxonomy_name, 'type' => 'title', 'desc' => '', 'id' => 'custom_field_' . $taxonomy . '_delete' );
1889
1890 $args[] = array(
1891 'title' => __( 'Term Deleted', 'propertyhive' ),
1892 'id' => '',
1893 'html' => $taxonomy_name . __(' deleted successfully', 'propertyhive' ) . ' <a href="' . admin_url( 'admin.php?page=ph-settings&tab=customfields&section=' . str_replace("_", "-", $taxonomy) ) . '">' . __( 'Go Back', 'propertyhive' ) . '</a>',
1894 'type' => 'html',
1895 'desc_tip' => false,
1896 );
1897
1898 $args[] = array( 'type' => 'sectionend', 'id' => 'custom_field_' . $taxonomy . '_delete' );
1899 }
1900 else
1901 {
1902 $term_name = '';
1903 if ($current_id == '')
1904 {
1905 die("ID not passed");
1906 }
1907 else
1908 {
1909 $term_ids = explode("-", $current_id);
1910
1911 $args = array();
1912
1913 foreach ( $term_ids as $current_id )
1914 {
1915 $term = get_term( $current_id, $taxonomy );
1916
1917 if ( is_null($term) || is_wp_error($term) )
1918 {
1919 die("Invalid term trying to be deleted");
1920 }
1921 else
1922 {
1923 $term_name = $term->name;
1924
1925 $args[] = array( 'title' => __( 'Delete', 'propertyhive' ) . ' ' . $taxonomy_name . ': ' . $term_name, 'type' => 'title', 'desc' => '', 'id' => 'custom_field_' . $taxonomy . '_' . $current_id . '_delete' );
1926
1927 // Get number of properties assigned to this term
1928 $query_args = array(
1929 'post_type' => 'property',
1930 'nopaging' => true,
1931 'post_status' => array( 'pending', 'auto-draft', 'draft', 'private', 'publish', 'future', 'trash' ),
1932 'tax_query' => array(
1933 array(
1934 'taxonomy' => $taxonomy,
1935 'field' => 'id',
1936 'terms' => $current_id,
1937 ),
1938 ),
1939 );
1940 $property_query = new WP_Query( $query_args );
1941
1942 $num_properties = $property_query->found_posts;
1943
1944 wp_reset_postdata();
1945
1946 // Get number of applicants assigned to this term
1947 $num_applicants = 0;
1948 if ( $taxonomy == 'property_type' || $taxonomy == 'commercial_property_type' || $taxonomy == 'location' )
1949 {
1950 $query_args = array(
1951 'post_type' => 'contact',
1952 'nopaging' => true,
1953 'post_status' => array( 'pending', 'auto-draft', 'draft', 'private', 'publish', 'future', 'trash' ),
1954 'meta_query' => array(
1955 array(
1956 'key' => '_contact_types',
1957 'value' => 'applicant',
1958 'compare' => 'LIKE'
1959 ),
1960 ),
1961 );
1962 $applicant_query = new WP_Query( $query_args );
1963
1964 if ( $applicant_query->have_posts() )
1965 {
1966 while ( $applicant_query->have_posts() )
1967 {
1968 $applicant_query->the_post();
1969
1970 $applicant_has_taxonomy = false;
1971
1972 $num_applicant_profiles = get_post_meta( get_the_ID(), '_applicant_profiles', TRUE );
1973 if ( $num_applicant_profiles == '' )
1974 {
1975 $num_applicant_profiles = 0;
1976 }
1977
1978 if ( $num_applicant_profiles > 0 )
1979 {
1980 for ( $i = 0; $i < $num_applicant_profiles; ++$i )
1981 {
1982 $applicant_profile = get_post_meta( get_the_ID(), '_applicant_profile_' . $i, TRUE );
1983
1984 if ( isset($applicant_profile[$taxonomy.'s']) && is_array($applicant_profile[$taxonomy.'s']) && !empty($applicant_profile[$taxonomy.'s']) )
1985 {
1986 if (in_array($current_id, $applicant_profile[$taxonomy.'s']))
1987 {
1988 $applicant_has_taxonomy = true;
1989 }
1990 }
1991 }
1992 }
1993
1994 if ( $applicant_has_taxonomy )
1995 {
1996 ++$num_applicants;
1997 }
1998 }
1999 }
2000
2001 wp_reset_postdata();
2002 }
2003
2004 if ($num_properties > 0 || $num_applicants > 0)
2005 {
2006 $alternative_terms = array();
2007
2008 $alternative_terms['none'] = '-- ' . __( 'Don\'t Reassign', 'propertyhive' ) . ' --';
2009
2010 $term_args = array(
2011 'hide_empty' => false,
2012 'exclude' => $term_ids,
2013 'parent' => 0
2014 );
2015 $terms = get_terms( $taxonomy, $term_args );
2016
2017 if ( !empty( $terms ) && !is_wp_error( $terms ) )
2018 {
2019 foreach ($terms as $term)
2020 {
2021 $alternative_terms[$term->term_id] = $term->name;
2022
2023 $term_args = array(
2024 'hide_empty' => false,
2025 'exclude' => $term_ids,
2026 'parent' => $term->term_id
2027 );
2028 $subterms = get_terms( $taxonomy, $term_args );
2029
2030 if ( !empty( $subterms ) && !is_wp_error( $subterms ) )
2031 {
2032 foreach ($subterms as $term)
2033 {
2034 $alternative_terms[$term->term_id] = '- ' . $term->name;
2035
2036 $term_args = array(
2037 'hide_empty' => false,
2038 'exclude' => $term_ids,
2039 'parent' => $term->term_id
2040 );
2041 $subsubterms = get_terms( $taxonomy, $term_args );
2042
2043 if ( !empty( $subsubterms ) && !is_wp_error( $subsubterms ) )
2044 {
2045 foreach ($subsubterms as $term)
2046 {
2047 $alternative_terms[$term->term_id] = '- - ' . $term->name;
2048 }
2049 }
2050 }
2051 }
2052 }
2053 }
2054
2055 // There are properties assigned to this term
2056 $args[] = array(
2057 'title' => __( 'Re-assign to', 'propertyhive' ),
2058 'id' => 'reassign_to_' . $current_id,
2059 'default' => '',
2060 'options' => $alternative_terms,
2061 'type' => 'select',
2062 'desc_tip' => false,
2063 'desc' => __( 'There are properties or applicants that have this term assigned to them. Which, if any, term should they be reassigned to?' , 'propertyhive' )
2064 );
2065 }
2066 else
2067 {
2068 // There are properties assigned to this term
2069 $args[] = array(
2070 'title' => __( 'Re-assign to', 'propertyhive' ),
2071 'id' => 'reassign_to',
2072 'type' => 'html',
2073 'html' => __( 'No properties or applicants assigned to this term' , 'propertyhive' )
2074 );
2075 }
2076
2077 $args[] = array( 'type' => 'sectionend', 'id' => 'custom_field_' . $taxonomy . '_' . $current_id . '_delete' );
2078 }
2079 }
2080
2081 $args[] = array( 'title' => __( 'Confirm Removal', 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_confirm_delete' );
2082
2083 $args[] = array(
2084 'title' => __( 'Confirm Removal?', 'propertyhive' ),
2085 'id' => 'confirm_removal',
2086 'type' => 'checkbox',
2087 'desc_tip' => false,
2088 );
2089
2090 $args[] = array(
2091 'type' => 'hidden',
2092 'id' => 'taxonomy',
2093 'default' => $taxonomy
2094 );
2095
2096 $args[] = array( 'type' => 'sectionend', 'id' => 'custom_field_confirm_delete' );
2097 }
2098 }
2099
2100 return apply_filters( 'propertyhive_custom_field_' . $taxonomy . '_delete', $args );
2101 }
2102
2103 /**
2104 * Show price qualifier add/edit options
2105 *
2106 * @access public
2107 * @return string
2108 */
2109 public function get_custom_fields_price_qualifier_setting()
2110 {
2111 $current_id = empty( $_REQUEST['id'] ) ? '' : sanitize_title( $_REQUEST['id'] );
2112
2113 $taxonomy = 'price_qualifier';
2114 $term_name = '';
2115 if ($current_id != '')
2116 {
2117 $term = get_term( $current_id, $taxonomy );
2118 $term_name = $term->name;
2119 }
2120
2121 $args = array(
2122
2123 array( 'title' => __( ( $current_id == '' ? 'Add New Price Qualifier' : 'Edit Price Qualifier' ), 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_price_qualifier_settings' ),
2124
2125 array(
2126 'title' => __( 'Price Qualifier', 'propertyhive' ),
2127 'id' => 'price_qualifier_name',
2128 'default' => $term_name,
2129 'type' => 'text',
2130 'desc_tip' => false,
2131 ),
2132
2133 array(
2134 'type' => 'hidden',
2135 'id' => 'taxonomy',
2136 'default' => $taxonomy
2137 ),
2138
2139 array( 'type' => 'sectionend', 'id' => 'custom_field_price_qualifier_settings' )
2140
2141 );
2142
2143 return apply_filters( 'propertyhive_custom_field_price_qualifier_settings', $args );
2144 }
2145
2146 /**
2147 * Show sale by add/edit options
2148 *
2149 * @access public
2150 * @return string
2151 */
2152 public function get_custom_fields_sale_by_setting()
2153 {
2154 $current_id = empty( $_REQUEST['id'] ) ? '' : sanitize_title( $_REQUEST['id'] );
2155
2156 $taxonomy = 'sale_by';
2157 $term_name = '';
2158 if ($current_id != '')
2159 {
2160 $term = get_term( $current_id, $taxonomy );
2161 $term_name = $term->name;
2162 }
2163
2164 $args = array(
2165
2166 array( 'title' => __( ( $current_id == '' ? 'Add New Sale By' : 'Edit Sale By' ), 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_sale_by_settings' ),
2167
2168 array(
2169 'title' => __( 'Sale By', 'propertyhive' ),
2170 'id' => 'sale_by_name',
2171 'default' => $term_name,
2172 'type' => 'text',
2173 'desc_tip' => false,
2174 ),
2175
2176 array(
2177 'type' => 'hidden',
2178 'id' => 'taxonomy',
2179 'default' => $taxonomy
2180 ),
2181
2182 array( 'type' => 'sectionend', 'id' => 'custom_field_sale_by_settings' )
2183
2184 );
2185
2186 return apply_filters( 'propertyhive_custom_field_sale_by_settings', $args );
2187 }
2188
2189 /**
2190 * Show tenure add/edit options
2191 *
2192 * @access public
2193 * @return string
2194 */
2195 public function get_custom_fields_tenure_setting()
2196 {
2197 $current_id = empty( $_REQUEST['id'] ) ? '' : sanitize_title( $_REQUEST['id'] );
2198
2199 $taxonomy = 'tenure';
2200 $term_name = '';
2201 if ($current_id != '')
2202 {
2203 $term = get_term( $current_id, $taxonomy );
2204 $term_name = $term->name;
2205 }
2206
2207 $args = array(
2208
2209 array( 'title' => __( ( $current_id == '' ? 'Add New Tenure' : 'Edit Tenure' ), 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_tenure_settings' ),
2210
2211 array(
2212 'title' => __( 'Tenure', 'propertyhive' ),
2213 'id' => 'tenure_name',
2214 'default' => $term_name,
2215 'type' => 'text',
2216 'desc_tip' => false,
2217 ),
2218
2219 array(
2220 'type' => 'hidden',
2221 'id' => 'taxonomy',
2222 'default' => $taxonomy
2223 ),
2224
2225 array( 'type' => 'sectionend', 'id' => 'custom_field_tenure_settings' )
2226
2227 );
2228
2229 return apply_filters( 'propertyhive_custom_field_tenure_settings', $args );
2230 }
2231
2232 /**
2233 * Show commercial tenure add/edit options
2234 *
2235 * @access public
2236 * @return string
2237 */
2238 public function get_custom_fields_commercial_tenure_setting()
2239 {
2240 $current_id = empty( $_REQUEST['id'] ) ? '' : sanitize_title( $_REQUEST['id'] );
2241
2242 $taxonomy = 'commercial_tenure';
2243 $term_name = '';
2244 if ($current_id != '')
2245 {
2246 $term = get_term( $current_id, $taxonomy );
2247 $term_name = $term->name;
2248 }
2249
2250 $args = array(
2251
2252 array( 'title' => __( ( $current_id == '' ? 'Add New Tenure' : 'Edit Tenure' ), 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_commercial_tenure_settings' ),
2253
2254 array(
2255 'title' => __( 'Tenure', 'propertyhive' ),
2256 'id' => 'commercial_tenure_name',
2257 'default' => $term_name,
2258 'type' => 'text',
2259 'desc_tip' => false,
2260 ),
2261
2262 array(
2263 'type' => 'hidden',
2264 'id' => 'taxonomy',
2265 'default' => $taxonomy
2266 ),
2267
2268 array( 'type' => 'sectionend', 'id' => 'custom_field_commercial_tenure_settings' )
2269
2270 );
2271
2272 return apply_filters( 'propertyhive_custom_field_commercial_tenure_settings', $args );
2273 }
2274
2275 /**
2276 * Show furnished add/edit options
2277 *
2278 * @access public
2279 * @return string
2280 */
2281 public function get_custom_fields_furnished_setting()
2282 {
2283 $current_id = empty( $_REQUEST['id'] ) ? '' : sanitize_title( $_REQUEST['id'] );
2284
2285 $taxonomy = 'furnished';
2286 $term_name = '';
2287 if ($current_id != '')
2288 {
2289 $term = get_term( $current_id, $taxonomy );
2290 $term_name = $term->name;
2291 }
2292
2293 $args = array(
2294
2295 array( 'title' => __( ( $current_id == '' ? 'Add New Furnished' : 'Edit Furnished' ), 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_furnished_settings' ),
2296
2297 array(
2298 'title' => __( 'Furnished', 'propertyhive' ),
2299 'id' => 'furnished_name',
2300 'default' => $term_name,
2301 'type' => 'text',
2302 'desc_tip' => false,
2303 ),
2304
2305 array(
2306 'type' => 'hidden',
2307 'id' => 'taxonomy',
2308 'default' => $taxonomy
2309 ),
2310
2311 array( 'type' => 'sectionend', 'id' => 'custom_field_furnished_settings' )
2312
2313 );
2314
2315 return apply_filters( 'propertyhive_custom_field_furnished_settings', $args );
2316 }
2317
2318 /**
2319 * Show marketing flag add/edit options
2320 *
2321 * @access public
2322 * @return string
2323 */
2324 public function get_custom_fields_marketing_flag_setting()
2325 {
2326 $current_id = empty( $_REQUEST['id'] ) ? '' : sanitize_title( $_REQUEST['id'] );
2327
2328 $taxonomy = 'marketing_flag';
2329 $term_name = '';
2330 if ($current_id != '')
2331 {
2332 $term = get_term( $current_id, $taxonomy );
2333 $term_name = $term->name;
2334 }
2335
2336 $args = array(
2337
2338 array( 'title' => __( ( $current_id == '' ? 'Add New Marketing Flag' : 'Edit Marketing Flag' ), 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_marketing_flag_settings' ),
2339
2340 array(
2341 'title' => __( 'Marketing Flag', 'propertyhive' ),
2342 'id' => 'marketing_flag_name',
2343 'default' => $term_name,
2344 'type' => 'text',
2345 'desc_tip' => false,
2346 ),
2347
2348 array(
2349 'type' => 'hidden',
2350 'id' => 'taxonomy',
2351 'default' => $taxonomy
2352 ),
2353
2354 array( 'type' => 'sectionend', 'id' => 'custom_field_marketing_flag_settings' )
2355
2356 );
2357
2358 return apply_filters( 'propertyhive_custom_field_marketing_flag_settings', $args );
2359 }
2360
2361 /**
2362 * Show property feature add/edit options
2363 *
2364 * @access public
2365 * @return string
2366 */
2367 public function get_custom_fields_property_feature_setting()
2368 {
2369 $current_id = empty( $_REQUEST['id'] ) ? '' : sanitize_title( $_REQUEST['id'] );
2370
2371 $taxonomy = 'property_feature';
2372 $term_name = '';
2373 if ($current_id != '')
2374 {
2375 $term = get_term( $current_id, $taxonomy );
2376 $term_name = $term->name;
2377 }
2378
2379 $args = array(
2380
2381 array( 'title' => __( ( $current_id == '' ? 'Add New Property Feature' : 'Edit Property Feature' ), 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_property_feature_settings' ),
2382
2383 array(
2384 'title' => __( 'Property Feature', 'propertyhive' ),
2385 'id' => 'property_feature_name',
2386 'default' => $term_name,
2387 'type' => 'text',
2388 'desc_tip' => false,
2389 ),
2390
2391 array(
2392 'type' => 'hidden',
2393 'id' => 'taxonomy',
2394 'default' => $taxonomy
2395 ),
2396
2397 array( 'type' => 'sectionend', 'id' => 'custom_field_property_feature_settings' )
2398
2399 );
2400
2401 return apply_filters( 'propertyhive_custom_field_property_feature_settings', $args );
2402 }
2403
2404 /**
2405 * Save settings
2406 */
2407 public function save() {
2408 global $current_section, $post;
2409
2410 if ( $current_section != '' )
2411 {
2412 if (isset($_REQUEST['id'])) // we're either adding or editing
2413 {
2414 $current_id = empty( $_REQUEST['id'] ) ? '' : sanitize_text_field($_REQUEST['id']);
2415
2416 switch ($current_section)
2417 {
2418 // With heirarchy
2419 case "property-type":
2420 case "commercial-property-type":
2421 case "location":
2422 {
2423 // TODO: Validate (check for blank fields)
2424
2425 if ($current_id == '')
2426 {
2427 // Adding new term
2428
2429 // TODO: Check term doesn't exist already
2430
2431 wp_insert_term(
2432 ph_clean($_POST[ph_clean($_POST['taxonomy']) . '_name']), // the term
2433 ph_clean($_POST['taxonomy']), // the taxonomy
2434 array(
2435 'parent' => $_POST['parent_' . ph_clean($_POST['taxonomy']) . '_id']
2436 )
2437 );
2438
2439 // TODO: Check for errors returned from wp_insert_term()
2440 }
2441 else
2442 {
2443 // Editing term
2444 wp_update_term($current_id, ph_clean($_POST['taxonomy']), array(
2445 'name' => ph_clean($_POST[ph_clean($_POST['taxonomy']).'_name']),
2446 'parent' => ph_clean($_POST['parent_' . $_POST['taxonomy'] . '_id'])
2447 ));
2448
2449 // TODO: Check for errors returned from wp_update_term()
2450 }
2451 break;
2452 }
2453 // Without heirarchy
2454 case "availability":
2455 case "outside-space":
2456 case "parking":
2457 case "price-qualifier":
2458 case "sale-by":
2459 case "tenure":
2460 case "commercial-tenure":
2461 case "furnished":
2462 case "marketing-flag":
2463 case "property-feature":
2464 {
2465 // TODO: Validate (check for blank fields)
2466
2467 if ($current_id == '')
2468 {
2469 // Adding new term
2470
2471 // TODO: Check term doesn't exist already
2472
2473 $term = wp_insert_term(
2474 ph_clean($_POST[ph_clean($_POST['taxonomy']) . '_name']), // the term
2475 $_POST['taxonomy'] // the taxonomy
2476 );
2477
2478 // TODO: Check for errors returned from wp_insert_term()
2479
2480 if ( ! is_wp_error( $term ) )
2481 {
2482 $current_id = isset( $term['term_id'] ) ? $term['term_id'] : 0;
2483 }
2484 }
2485 else
2486 {
2487 // Editing term
2488 wp_update_term($current_id, ph_clean($_POST['taxonomy']), array(
2489 'name' => ph_clean($_POST[ph_clean($_POST['taxonomy']) . '_name'])
2490 ));
2491
2492 // TODO: Check for errors returned from wp_update_term()
2493 }
2494
2495 if ( $current_section == 'availability' )
2496 {
2497 $availability_departments = get_option( 'propertyhive_availability_departments', array() );
2498 if ( !is_array($availability_departments) ) { $availability_departments = array(); }
2499
2500 $departments = ph_get_departments();
2501
2502 $availability_departments[$current_id] = array();
2503 foreach ( $departments as $key => $value )
2504 {
2505 if ( isset($_POST['department'][$key]) && $_POST['department'][$key] == '1' )
2506 {
2507 $availability_departments[$current_id][] = $key;
2508 }
2509 }
2510
2511 update_option( 'propertyhive_availability_departments', $availability_departments );
2512 }
2513
2514 break;
2515 }
2516 case "availability-delete":
2517 case "property-type-delete":
2518 case "commercial-property-type-delete":
2519 case "location-delete":
2520 case "parking-delete":
2521 case "outside-space-delete":
2522 case "price-qualifier-delete":
2523 case "sale-by-delete":
2524 case "tenure-delete":
2525 case "furnished-delete":
2526 case "marketing-flag-delete":
2527 case "property-feature-delete":
2528 {
2529 if ( isset($_POST['confirm_removal']) && $_POST['confirm_removal'] == '1' )
2530 {
2531 $term_ids = explode("-", $current_id);
2532
2533 foreach ( $term_ids as $current_id )
2534 {
2535 // Update properties that have this taxonomy term set
2536 $query_args = array(
2537 'post_type' => 'property',
2538 'nopaging' => true,
2539 'post_status' => array( 'pending', 'auto-draft', 'draft', 'private', 'publish', 'future', 'trash' ),
2540 'tax_query' => array(
2541 array(
2542 'taxonomy' => $_POST['taxonomy'],
2543 'field' => 'id',
2544 'terms' => $current_id,
2545 ),
2546 ),
2547 );
2548 $property_query = new WP_Query( $query_args );
2549
2550 if ( $property_query->have_posts() )
2551 {
2552 while ( $property_query->have_posts() )
2553 {
2554 $property_query->the_post();
2555
2556 wp_remove_object_terms( $post->ID, $current_id, ph_clean($_POST['taxonomy']) );
2557
2558 // Re-assign to another term
2559 if ( isset($_POST['reassign_to_' . $current_id]) && ! empty( $_POST['reassign_to_' . $current_id] ) && $_POST['reassign_to_' . $current_id] != 'none' )
2560 {
2561 $new_id = $_POST['reassign_to_' . $current_id];
2562
2563 wp_set_post_terms( $post->ID, $new_id, ph_clean($_POST['taxonomy']), TRUE );
2564
2565 // TODO: Check for WP_ERROR
2566 }
2567 }
2568 }
2569
2570 wp_reset_postdata();
2571
2572 if ( $current_section == 'availability-delete' )
2573 {
2574 // Remove from propertyhive_availability_departments option
2575 $availability_departments = get_option( 'propertyhive_availability_departments', array() );
2576
2577 if ( isset($availability_departments[$current_id]) )
2578 {
2579 unset($availability_departments[$current_id]);
2580 update_option( 'propertyhive_availability_departments', $availability_departments );
2581 }
2582 }
2583
2584 if ( $_POST['taxonomy'] == 'property_type' || $_POST['taxonomy'] == 'commercial_property_type' || $_POST['taxonomy'] == 'location' )
2585 {
2586 $query_args = array(
2587 'post_type' => 'contact',
2588 'nopaging' => true,
2589 'post_status' => array( 'pending', 'auto-draft', 'draft', 'private', 'publish', 'future', 'trash' ),
2590 'meta_query' => array(
2591 array(
2592 'key' => '_contact_types',
2593 'value' => 'applicant',
2594 'compare' => 'LIKE'
2595 ),
2596 ),
2597 );
2598 $applicant_query = new WP_Query( $query_args );
2599
2600 if ( $applicant_query->have_posts() )
2601 {
2602 while ( $applicant_query->have_posts() )
2603 {
2604 $applicant_query->the_post();
2605
2606 $num_applicant_profiles = get_post_meta( get_the_ID(), '_applicant_profiles', TRUE );
2607 if ( $num_applicant_profiles == '' )
2608 {
2609 $num_applicant_profiles = 0;
2610 }
2611
2612 if ( $num_applicant_profiles > 0 )
2613 {
2614 for ( $i = 0; $i < $num_applicant_profiles; ++$i )
2615 {
2616 $applicant_profile = get_post_meta( get_the_ID(), '_applicant_profile_' . $i, TRUE );
2617
2618 if ( isset($applicant_profile[ph_clean($_POST['taxonomy']).'s']) && is_array($applicant_profile[ph_clean($_POST['taxonomy']).'s']) && !empty($applicant_profile[ph_clean($_POST['taxonomy']).'s']) )
2619 {
2620 if (in_array($current_id, $applicant_profile[ph_clean($_POST['taxonomy']).'s']))
2621 {
2622 // This profile has this term set
2623 unset($applicant_profile[ph_clean($_POST['taxonomy']).'s'][$current_id]);
2624
2625 if ( isset($_POST['reassign_to_' . $current_id]) && ! empty( $_POST['reassign_to_' . $current_id] ) && ph_clean($_POST['reassign_to_' . $current_id]) != 'none' )
2626 {
2627 $applicant_profile[ph_clean($_POST['taxonomy']).'s'][] = $_POST['reassign_to_' . $current_id];
2628 $applicant_profile[ph_clean($_POST['taxonomy']).'s'] = array_unique($applicant_profile[ph_clean($_POST['taxonomy']).'s']);
2629 }
2630
2631 $applicant_profile[ph_clean($_POST['taxonomy']).'s'] = array_values($applicant_profile[ph_clean($_POST['taxonomy']).'s']);
2632
2633 update_post_meta( get_the_ID(), '_applicant_profile_' . $i, $applicant_profile );
2634 }
2635 }
2636 }
2637 }
2638 }
2639 }
2640 }
2641
2642 wp_reset_postdata();
2643
2644 wp_delete_term( $current_id, ph_clean($_POST['taxonomy']) );
2645 }
2646 }
2647
2648 break;
2649 }
2650 default: { echo 'UNKNOWN CUSTOM FIELD'; }
2651 }
2652 }
2653 else
2654 {
2655 // Nothing to save. Should always be an id set when editing custom fields.
2656 // Even blank ids dictate something is being added
2657 }
2658 }
2659 else
2660 {
2661 // Nothing to save. Should always be a section when editing custom fields
2662 }
2663 }
2664 }
2665
2666 endif;
2667
2668 return new PH_Settings_Custom_Fields();