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

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

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