PluginProbe
Property Hive / 1.4.53
Property Hive v1.4.53
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.53, at includes/admin/settings/class-ph-settings-custom-fields.php

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