| 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 |
const LINKED_POSTS_COLUMN_HEADING = 'Assigned Properties'; |
| 23 |
|
| 24 |
private $custom_field_sections; |
| 25 |
|
| 26 |
/** |
| 27 |
* Constructor. |
| 28 |
*/ |
| 29 |
public function __construct() { |
| 30 |
$this->id = 'customfields'; |
| 31 |
$this->label = __( 'Field Manager', 'propertyhive' ); |
| 32 |
|
| 33 |
add_action( 'admin_init', array( $this, 'check_for_delete_additional_field') ); |
| 34 |
add_action( 'admin_init', array( $this, 'check_for_reorder_additional_fields') ); |
| 35 |
|
| 36 |
add_filter( 'propertyhive_settings_tabs_array', array( $this, 'add_settings_page' ), 15 ); |
| 37 |
add_action( 'propertyhive_sections_' . $this->id, array( $this, 'output_sections' ) ); |
| 38 |
add_action( 'propertyhive_settings_' . $this->id, array( $this, 'output' ) ); |
| 39 |
add_action( 'propertyhive_settings_save_' . $this->id, array( $this, 'save' ) ); |
| 40 |
|
| 41 |
add_action( 'propertyhive_admin_field_additional_fields_table', array( $this, 'additional_fields_table' ) ); |
| 42 |
|
| 43 |
add_action( 'propertyhive_admin_field_additional_field_dropdown_options', array( $this, 'additional_field_dropdown_options' ) ); |
| 44 |
|
| 45 |
$this->get_custom_field_sections(); |
| 46 |
} |
| 47 |
|
| 48 |
public function check_for_delete_additional_field() |
| 49 |
{ |
| 50 |
if ( isset($_GET['action']) && $_GET['action'] == 'deleteadditionalfield' && isset($_GET['id']) && $_GET['id'] != '' ) |
| 51 |
{ |
| 52 |
$current_settings = get_option( 'propertyhive_template_assistant', array() ); |
| 53 |
|
| 54 |
$current_id = ( !isset( $_GET['id'] ) ) ? '' : sanitize_title( $_GET['id'] ); |
| 55 |
|
| 56 |
$existing_custom_fields = ( (isset($current_settings['custom_fields'])) ? $current_settings['custom_fields'] : array() ); |
| 57 |
|
| 58 |
if ( !isset($existing_custom_fields[$current_id]) ) |
| 59 |
{ |
| 60 |
die("Trying to delete a non-existant additional field. Please go back and try again"); |
| 61 |
} |
| 62 |
|
| 63 |
if ( isset($existing_custom_fields[$current_id]) ) |
| 64 |
{ |
| 65 |
unset($existing_custom_fields[$current_id]); |
| 66 |
} |
| 67 |
|
| 68 |
$current_settings['custom_fields'] = $existing_custom_fields; |
| 69 |
|
| 70 |
update_option( 'propertyhive_template_assistant', $current_settings ); |
| 71 |
} |
| 72 |
} |
| 73 |
|
| 74 |
public function check_for_reorder_additional_fields() |
| 75 |
{ |
| 76 |
if ( isset($_GET['neworder']) && $_GET['neworder'] != '' ) |
| 77 |
{ |
| 78 |
$current_settings = get_option( 'propertyhive_template_assistant', array() ); |
| 79 |
|
| 80 |
$current_id = ( !isset( $_GET['id'] ) ) ? '' : sanitize_title( $_GET['id'] ); |
| 81 |
|
| 82 |
$existing_custom_fields = ( (isset($current_settings['custom_fields'])) ? $current_settings['custom_fields'] : array() ); |
| 83 |
|
| 84 |
$new_order = explode(",", sanitize_text_field($_GET['neworder'])); |
| 85 |
$new_order = ph_clean($new_order); |
| 86 |
|
| 87 |
$new_custom_fields = array(); |
| 88 |
|
| 89 |
foreach ( $new_order as $id ) |
| 90 |
{ |
| 91 |
$new_custom_fields[] = $existing_custom_fields[$id]; |
| 92 |
} |
| 93 |
|
| 94 |
$current_settings['custom_fields'] = $new_custom_fields; |
| 95 |
|
| 96 |
update_option( 'propertyhive_template_assistant', $current_settings ); |
| 97 |
|
| 98 |
header("Location: " . admin_url('admin.php?page=ph-settings&tab=customfields§ion=additional')); |
| 99 |
exit(); |
| 100 |
} |
| 101 |
} |
| 102 |
|
| 103 |
/** |
| 104 |
* Get sections |
| 105 |
* |
| 106 |
* @return array |
| 107 |
*/ |
| 108 |
public function get_sections() { |
| 109 |
$sections = array( |
| 110 |
'' => __( 'Field Values', 'propertyhive' ), |
| 111 |
'additional' => __( 'Additional Fields', 'propertyhive' ) |
| 112 |
); |
| 113 |
|
| 114 |
return $sections; |
| 115 |
} |
| 116 |
|
| 117 |
public function get_custom_field_sections() |
| 118 |
{ |
| 119 |
$sections = array(); |
| 120 |
|
| 121 |
$residential_active = false; |
| 122 |
$residential_sales_active = false; |
| 123 |
$residential_lettings_active = false; |
| 124 |
$commercial_active = false; |
| 125 |
|
| 126 |
if ( get_option( 'propertyhive_active_departments_sales' ) == 'yes' || get_option( 'propertyhive_active_departments_lettings' ) == 'yes' ) |
| 127 |
{ |
| 128 |
$residential_active = true; |
| 129 |
if ( get_option( 'propertyhive_active_departments_sales' ) == 'yes' ) |
| 130 |
{ |
| 131 |
$residential_sales_active = true; |
| 132 |
} |
| 133 |
if ( get_option( 'propertyhive_active_departments_lettings' ) == 'yes' ) |
| 134 |
{ |
| 135 |
$residential_lettings_active = true; |
| 136 |
} |
| 137 |
} |
| 138 |
if ( get_option( 'propertyhive_active_departments_commercial' ) == 'yes' ) |
| 139 |
{ |
| 140 |
$commercial_active = true; |
| 141 |
} |
| 142 |
|
| 143 |
$default_departments = ph_get_departments(true); |
| 144 |
$custom_departments = ph_get_custom_departments(false); |
| 145 |
if ( $custom_departments ) |
| 146 |
{ |
| 147 |
foreach ( $custom_departments as $key => $custom_department ) |
| 148 |
{ |
| 149 |
if ( isset($custom_department['based_on']) && get_option('propertyhive_active_departments_' . $key) == 'yes' ) |
| 150 |
{ |
| 151 |
foreach ( $default_departments as $dept_key => $value ) |
| 152 |
{ |
| 153 |
if ( $custom_department['based_on'] == $dept_key ) |
| 154 |
{ |
| 155 |
switch ( $custom_department['based_on'] ) |
| 156 |
{ |
| 157 |
case "residential-sales": { $residential_active = true; $residential_sales_active = true; } |
| 158 |
case "residential-lettings": { $residential_active = true; $residential_lettings_active = true; } |
| 159 |
case "commercial": { $commercial_active = true; } |
| 160 |
} |
| 161 |
} |
| 162 |
} |
| 163 |
} |
| 164 |
} |
| 165 |
} |
| 166 |
|
| 167 |
// Residential Custom Fields |
| 168 |
$sections[ 'availability' ] = __( 'Availabilities', 'propertyhive' ); |
| 169 |
add_action( 'propertyhive_admin_field_custom_fields_availability', array( $this, 'custom_fields_availability_setting' ) ); |
| 170 |
|
| 171 |
if ( $residential_active ) |
| 172 |
{ |
| 173 |
$sections[ 'property-type' ] = ( $commercial_active ? __( 'Residential ', 'propertyhive' ) . ' ' : '' ) . __( 'Property Types', 'propertyhive' ); |
| 174 |
add_action( 'propertyhive_admin_field_custom_fields_property_type', array( $this, 'custom_fields_property_type_setting' ) ); |
| 175 |
} |
| 176 |
if ( $commercial_active ) |
| 177 |
{ |
| 178 |
$sections[ 'commercial-property-type' ] = ( $residential_active ? __( 'Commercial', 'propertyhive' ) . ' ' : '' ) . __( 'Property Types', 'propertyhive' ); |
| 179 |
add_action( 'propertyhive_admin_field_custom_fields_commercial_property_type', array( $this, 'custom_fields_commercial_property_type_setting' ) ); |
| 180 |
} |
| 181 |
|
| 182 |
$sections[ 'location' ] = __( 'Locations', 'propertyhive' ); |
| 183 |
add_action( 'propertyhive_admin_field_custom_fields_location', array( $this, 'custom_fields_location_setting' ) ); |
| 184 |
|
| 185 |
if ( $residential_active ) |
| 186 |
{ |
| 187 |
$sections[ 'parking' ] = __( 'Parking', 'propertyhive' ); |
| 188 |
add_action( 'propertyhive_admin_field_custom_fields_parking', array( $this, 'custom_fields_parking_setting' ) ); |
| 189 |
|
| 190 |
$sections[ 'outside-space' ] = __( 'Outside Spaces', 'propertyhive' ); |
| 191 |
add_action( 'propertyhive_admin_field_custom_fields_outside_space', array( $this, 'custom_fields_outside_space_setting' ) ); |
| 192 |
} |
| 193 |
|
| 194 |
if ( $residential_sales_active || $commercial_active ) |
| 195 |
{ |
| 196 |
$sections[ 'price-qualifier' ] = __( 'Price Qualifiers', 'propertyhive' ); |
| 197 |
add_action( 'propertyhive_admin_field_custom_fields_price_qualifier', array( $this, 'custom_fields_price_qualifier_setting' ) ); |
| 198 |
|
| 199 |
$sections[ 'sale-by' ] = __( 'Sale By', 'propertyhive' ); |
| 200 |
add_action( 'propertyhive_admin_field_custom_fields_sale_by', array( $this, 'custom_fields_sale_by_setting' ) ); |
| 201 |
} |
| 202 |
|
| 203 |
if ( $residential_active ) |
| 204 |
{ |
| 205 |
$sections[ 'tenure' ] = ( $commercial_active ? __( 'Residential', 'propertyhive' ) . ' ' : '' ) . __( 'Tenures', 'propertyhive' ); |
| 206 |
add_action( 'propertyhive_admin_field_custom_fields_tenure', array( $this, 'custom_fields_tenure_setting' ) ); |
| 207 |
} |
| 208 |
if ( $commercial_active ) |
| 209 |
{ |
| 210 |
$sections[ 'commercial-tenure' ] = ( $residential_active ? __( 'Commercial', 'propertyhive' ) . ' ' : '' ) . __( 'Tenures', 'propertyhive' ); |
| 211 |
add_action( 'propertyhive_admin_field_custom_fields_commercial_tenure', array( $this, 'custom_fields_commercial_tenure_setting' ) ); |
| 212 |
} |
| 213 |
|
| 214 |
if ( $residential_lettings_active ) |
| 215 |
{ |
| 216 |
$sections[ 'furnished' ] = __( 'Furnished', 'propertyhive' ); |
| 217 |
add_action( 'propertyhive_admin_field_custom_fields_furnished', array( $this, 'custom_fields_furnished_setting' ) ); |
| 218 |
|
| 219 |
if ( get_option( 'propertyhive_module_disabled_tenancies', '' ) != 'yes' ) |
| 220 |
{ |
| 221 |
$sections[ 'management-key-date-type' ] = __( 'Management Date Types', 'propertyhive' ); |
| 222 |
add_action( 'propertyhive_admin_field_custom_fields_management_key_date_type', array( $this, 'custom_fields_management_key_date_type_setting' ) ); |
| 223 |
} |
| 224 |
} |
| 225 |
|
| 226 |
// Other |
| 227 |
$sections[ 'marketing-flag' ] = __( 'Marketing Flags', 'propertyhive' ); |
| 228 |
add_action( 'propertyhive_admin_field_custom_fields_marketing_flag', array( $this, 'custom_fields_marketing_flag_setting' ) ); |
| 229 |
|
| 230 |
if ( get_option('propertyhive_features_type') == 'checkbox' ) |
| 231 |
{ |
| 232 |
$sections[ 'property-feature' ] = __( 'Property Features', 'propertyhive' ); |
| 233 |
add_action( 'propertyhive_admin_field_custom_fields_property_feature', array( $this, 'custom_fields_property_feature_setting' ) ); |
| 234 |
} |
| 235 |
|
| 236 |
$sections = apply_filters( 'propertyhive_admin_field_custom_fields_sections', $sections ); |
| 237 |
|
| 238 |
$this->custom_field_sections = $sections; |
| 239 |
} |
| 240 |
|
| 241 |
/** |
| 242 |
* Get settings array |
| 243 |
* |
| 244 |
* @return array |
| 245 |
*/ |
| 246 |
public function get_settings() { |
| 247 |
|
| 248 |
global $hide_save_button; |
| 249 |
|
| 250 |
$hide_save_button = true; |
| 251 |
|
| 252 |
$i = 0; |
| 253 |
$html = '<style> |
| 254 |
|
| 255 |
.ph-custom-fields-grid { display:grid; grid-template-columns:repeat(4, 1fr); gap:22px; } |
| 256 |
.ph-custom-fields-grid > div { display:flex; gap:20px; background:#FFF; padding:25px; border:1px solid #AAA } |
| 257 |
.ph-custom-fields-grid > div .ph-grid-image { flex:0 0 50px; } |
| 258 |
.ph-custom-fields-grid > div .ph-grid-image-bg { background:#fbfcd4; border:1px solid #ffcd00; padding:10px; border-radius:7px; } |
| 259 |
.ph-custom-fields-grid > div .ph-grid-image img { max-width:40px; height:40px; display:block } |
| 260 |
.ph-custom-fields-grid > div .feature-card-content { flex:1; min-width:0; } |
| 261 |
.ph-custom-fields-grid > div h3 { margin-top:0; margin-bottom:0.6em } |
| 262 |
|
| 263 |
@media (max-width:1750px) { |
| 264 |
|
| 265 |
.ph-custom-fields-grid { grid-template-columns:repeat(3, 1fr); } |
| 266 |
|
| 267 |
} |
| 268 |
|
| 269 |
@media (max-width:1370px) { |
| 270 |
|
| 271 |
.ph-custom-fields-grid { grid-template-columns:repeat(2, 1fr); } |
| 272 |
|
| 273 |
} |
| 274 |
|
| 275 |
</style> |
| 276 |
|
| 277 |
<div class="ph-custom-fields-grid">'; |
| 278 |
foreach ( $this->custom_field_sections as $key => $value ) |
| 279 |
{ |
| 280 |
$image = 'default.png'; |
| 281 |
if ( file_exists(PH()->plugin_path() . '/assets/images/admin/settings/custom-fields/' . $key . '.png') ) |
| 282 |
{ |
| 283 |
$image = $key . '.png'; |
| 284 |
} |
| 285 |
$html .= '<div> |
| 286 |
<div class="ph-grid-image"> |
| 287 |
<div class="ph-grid-image-bg"><img alt="" src="' . esc_url(PH()->plugin_url() . '/assets/images/admin/settings/custom-fields/' . $image) . '" /></div> |
| 288 |
</div> |
| 289 |
<div class="feature-card-content"> |
| 290 |
<h3>' . esc_html($value) . '</h3> |
| 291 |
<p style="margin-top:12px;"><a href="' . esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=' . $key )) . '" class="button-primary">Manage values</a></p> |
| 292 |
</div> |
| 293 |
</div>'; |
| 294 |
} |
| 295 |
$html .= '</div>'; |
| 296 |
|
| 297 |
return apply_filters( 'propertyhive_custom_fields_settings', array( |
| 298 |
|
| 299 |
array( 'title' => __( 'Field Values', 'propertyhive' ), 'type' => 'title', 'desc' => __( 'Manage the values used in dropdowns, filters and fields across properties, contacts and other records.', 'propertyhive' ), 'id' => 'custom_field_options' ), |
| 300 |
|
| 301 |
array( |
| 302 |
'type' => 'html', |
| 303 |
'title' => '', |
| 304 |
'html' => $html, |
| 305 |
'full_width' => true |
| 306 |
), |
| 307 |
|
| 308 |
array( 'type' => 'sectionend', 'id' => 'custom_field_options') |
| 309 |
|
| 310 |
)); |
| 311 |
} |
| 312 |
|
| 313 |
/** |
| 314 |
* Output the settings |
| 315 |
*/ |
| 316 |
public function output() { |
| 317 |
global $current_section, $redirect_after_save; |
| 318 |
|
| 319 |
if ( $current_section ) |
| 320 |
{ |
| 321 |
switch ( $current_section ) |
| 322 |
{ |
| 323 |
case "additional": |
| 324 |
{ |
| 325 |
global $hide_save_button; |
| 326 |
|
| 327 |
$hide_save_button = true; |
| 328 |
|
| 329 |
// The main custom field screen listing them in a table |
| 330 |
$settings = $this->get_custom_fields_additional_fields_setting(); |
| 331 |
|
| 332 |
PH_Admin_Settings::output_fields( $settings ); |
| 333 |
break; |
| 334 |
} |
| 335 |
case "addadditionalfield": |
| 336 |
case "editadditionalfield": |
| 337 |
{ |
| 338 |
$settings = $this->get_custom_fields_additional_field_settings(); |
| 339 |
|
| 340 |
$redirect_after_save = admin_url('admin.php?page=ph-settings&tab=customfields§ion=additional'); |
| 341 |
|
| 342 |
PH_Admin_Settings::output_fields( $settings ); |
| 343 |
|
| 344 |
break; |
| 345 |
} |
| 346 |
default: |
| 347 |
{ |
| 348 |
if (isset($_REQUEST['id'])) // we're either adding or editing |
| 349 |
{ |
| 350 |
$current_id = empty( $_REQUEST['id'] ) ? '' : sanitize_text_field($_REQUEST['id']); |
| 351 |
|
| 352 |
switch ($current_section) |
| 353 |
{ |
| 354 |
case "availability": { $settings = $this->get_custom_fields_availability_setting(); break; } |
| 355 |
case "availability-delete": { $settings = $this->get_custom_fields_delete($current_id, 'availability', __( 'Availability', 'propertyhive' )); break; } |
| 356 |
case "property-type": { $settings = $this->get_custom_fields_property_type_setting(); break; } |
| 357 |
case "property-type-delete": { $settings = $this->get_custom_fields_delete($current_id, 'property_type', __( 'Property Type', 'propertyhive' )); break; } |
| 358 |
case "commercial-property-type": { $settings = $this->get_custom_fields_commercial_property_type_setting(); break; } |
| 359 |
case "commercial-property-type-delete": { $settings = $this->get_custom_fields_delete($current_id, 'commercial_property_type', __( 'Property Type', 'propertyhive' )); break; } |
| 360 |
case "location": { $settings = $this->get_custom_fields_location_setting(); break; } |
| 361 |
case "location-delete": { $settings = $this->get_custom_fields_delete($current_id, 'location', __( 'Location', 'propertyhive' )); break; } |
| 362 |
case "parking": { $settings = $this->get_custom_fields_parking_setting(); break; } |
| 363 |
case "parking-delete": { $settings = $this->get_custom_fields_delete($current_id, 'parking', __( 'Parking', 'propertyhive' )); break; } |
| 364 |
case "outside-space": { $settings = $this->get_custom_fields_outside_space_setting(); break; } |
| 365 |
case "outside-space-delete": { $settings = $this->get_custom_fields_delete($current_id, 'outside_space', __( 'Outside Space', 'propertyhive' )); break; } |
| 366 |
|
| 367 |
case "price-qualifier": { $settings = $this->get_custom_fields_price_qualifier_setting(); break; } |
| 368 |
case "price-qualifier-delete": { $settings = $this->get_custom_fields_delete($current_id, 'price_qualifier', __( 'Price Qualifier', 'propertyhive' )); break; } |
| 369 |
case "sale-by": { $settings = $this->get_custom_fields_sale_by_setting(); break; } |
| 370 |
case "sale-by-delete": { $settings = $this->get_custom_fields_delete($current_id, 'sale_by', __( 'Sale By', 'propertyhive' )); break; } |
| 371 |
case "tenure": { $settings = $this->get_custom_fields_tenure_setting(); break; } |
| 372 |
case "tenure-delete": { $settings = $this->get_custom_fields_delete($current_id, 'tenure', __( 'Tenure', 'propertyhive' )); break; } |
| 373 |
case "commercial-tenure": { $settings = $this->get_custom_fields_commercial_tenure_setting(); break; } |
| 374 |
case "commercial-tenure-delete": { $settings = $this->get_custom_fields_delete($current_id, 'commercial_tenure', __( 'Tenure', 'propertyhive' )); break; } |
| 375 |
|
| 376 |
case "furnished": { $settings = $this->get_custom_fields_furnished_setting(); break; } |
| 377 |
case "furnished-delete": { $settings = $this->get_custom_fields_delete($current_id, 'furnished', __( 'Furnished', 'propertyhive' )); break; } |
| 378 |
case "management-key-date-type": { $settings = $this->get_custom_fields_management_key_date_type_setting(); break; } |
| 379 |
case "management-key-date-type-delete": { $settings = $this->get_custom_fields_delete($current_id, 'management_key_date_type', __( 'Management Date Types', 'propertyhive' )); break; } |
| 380 |
|
| 381 |
case "marketing-flag": { $settings = $this->get_custom_fields_marketing_flag_setting(); break; } |
| 382 |
case "marketing-flag-delete": { $settings = $this->get_custom_fields_delete($current_id, 'marketing_flag', __( 'Marketing Flag', 'propertyhive' )); break; } |
| 383 |
|
| 384 |
case "property-feature": { $settings = $this->get_custom_fields_property_feature_setting(); break; } |
| 385 |
case "property-feature-delete": { $settings = $this->get_custom_fields_delete($current_id, 'property_feature', __( 'Property Feature', 'propertyhive' )); break; } |
| 386 |
|
| 387 |
default: |
| 388 |
{ |
| 389 |
$settings = apply_filters( 'propertyhive_custom_fields_section_settings', array(), $current_section ); |
| 390 |
|
| 391 |
if ( empty($settings) ) |
| 392 |
{ |
| 393 |
echo 'UNKNOWN CUSTOM FIELD'; |
| 394 |
} |
| 395 |
} |
| 396 |
} |
| 397 |
|
| 398 |
if ( strpos($current_section, '-delete') === FALSE ) |
| 399 |
{ |
| 400 |
$redirect_after_save = admin_url('admin.php?page=ph-settings&tab=customfields§ion=' . $current_section); |
| 401 |
} |
| 402 |
|
| 403 |
PH_Admin_Settings::output_fields( $settings ); |
| 404 |
} |
| 405 |
else |
| 406 |
{ |
| 407 |
global $hide_save_button; |
| 408 |
|
| 409 |
$hide_save_button = true; |
| 410 |
|
| 411 |
// The main custom field screen listing them in a table |
| 412 |
$settings = $this->get_custom_fields_setting($current_section); |
| 413 |
|
| 414 |
PH_Admin_Settings::output_fields( $settings ); |
| 415 |
} |
| 416 |
} |
| 417 |
} |
| 418 |
} |
| 419 |
else |
| 420 |
{ |
| 421 |
$settings = $this->get_settings(); |
| 422 |
|
| 423 |
PH_Admin_Settings::output_fields( $settings ); |
| 424 |
} |
| 425 |
} |
| 426 |
|
| 427 |
public function get_custom_fields_additional_field_settings() |
| 428 |
{ |
| 429 |
global $current_section; |
| 430 |
|
| 431 |
$current_settings = get_option( 'propertyhive_template_assistant', array() ); |
| 432 |
|
| 433 |
if ( !isset($current_settings['custom_fields']) ) |
| 434 |
{ |
| 435 |
$current_settings['custom_fields'] = array(); |
| 436 |
} |
| 437 |
|
| 438 |
$current_id = ( !isset( $_REQUEST['id'] ) ) ? '' : sanitize_title( $_REQUEST['id'] ); |
| 439 |
|
| 440 |
$custom_field_details = array(); |
| 441 |
|
| 442 |
if ($current_id != '') |
| 443 |
{ |
| 444 |
$custom_fields = $current_settings['custom_fields']; |
| 445 |
|
| 446 |
if (isset($custom_fields[$current_id])) |
| 447 |
{ |
| 448 |
$custom_field_details = $custom_fields[$current_id]; |
| 449 |
} |
| 450 |
else |
| 451 |
{ |
| 452 |
die('Trying to edit an additional field which does not exist. Please go back and try again.'); |
| 453 |
} |
| 454 |
} |
| 455 |
|
| 456 |
$settings = array( |
| 457 |
|
| 458 |
array( 'title' => __( ( $current_section == 'addadditionalfield' ? 'Add Additional Field' : 'Edit Additional Field' ), 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'customfield' ), |
| 459 |
|
| 460 |
); |
| 461 |
|
| 462 |
$settings[] = array( |
| 463 |
'title' => __( 'Field Label', 'propertyhive' ), |
| 464 |
'id' => 'field_label', |
| 465 |
'default' => ( (isset($custom_field_details['field_label'])) ? $custom_field_details['field_label'] : ''), |
| 466 |
'type' => 'text', |
| 467 |
'desc_tip' => false, |
| 468 |
'custom_attributes' => array( |
| 469 |
'placeholder' => 'My New Field' |
| 470 |
) |
| 471 |
); |
| 472 |
|
| 473 |
if ( isset($custom_field_details['field_name']) ) |
| 474 |
{ |
| 475 |
$settings[] = array( |
| 476 |
'title' => __( 'Field Name', 'propertyhive' ), |
| 477 |
'id' => 'field_name', |
| 478 |
'default' => ( (isset($custom_field_details['field_name'])) ? $custom_field_details['field_name'] : ''), |
| 479 |
'type' => 'text', |
| 480 |
'desc' => __( 'Please note that changing this after properties have been saved will result in any data entered being lost', 'propertyhive' ), |
| 481 |
); |
| 482 |
} |
| 483 |
|
| 484 |
$settings[] = array( |
| 485 |
'title' => __( 'Field Type', 'propertyhive' ), |
| 486 |
'id' => 'field_type', |
| 487 |
'default' => ( (isset($custom_field_details['field_type'])) ? $custom_field_details['field_type'] : 'text'), |
| 488 |
'type' => 'select', |
| 489 |
'desc_tip' => false, |
| 490 |
'options' => array( |
| 491 |
'text' => 'Text', |
| 492 |
'textarea' => 'Textarea', |
| 493 |
'select' => 'Dropdown', |
| 494 |
'multiselect' => 'Multi-Select', |
| 495 |
'checkbox' => 'Checkbox', |
| 496 |
'date' => 'Date', |
| 497 |
'image' => 'Image', |
| 498 |
'file' => 'File', |
| 499 |
) |
| 500 |
); |
| 501 |
|
| 502 |
$settings[] = array( |
| 503 |
'title' => __( 'Dropdown Options', 'propertyhive' ), |
| 504 |
'id' => 'dropdown_options', |
| 505 |
'type' => 'additional_field_dropdown_options', |
| 506 |
); |
| 507 |
|
| 508 |
$options = array( |
| 509 |
'property_address' => 'Property Address', |
| 510 |
'property_department' => 'Property Department', |
| 511 |
); |
| 512 |
|
| 513 |
if ( get_option( 'propertyhive_active_departments_sales', '' ) == 'yes' || get_option( 'propertyhive_active_departments_lettings', '' ) == 'yes' ) |
| 514 |
{ |
| 515 |
$options['property_residential_details'] = __( 'Property Residential Details', 'propertyhive' ); |
| 516 |
|
| 517 |
if ( get_option( 'propertyhive_active_departments_sales', '' ) == 'yes' ) |
| 518 |
{ |
| 519 |
$options['property_residential_sales_details'] = __( 'Property Residential Sales Details', 'propertyhive' ); |
| 520 |
} |
| 521 |
if ( get_option( 'propertyhive_active_departments_lettings', '' ) == 'yes' ) |
| 522 |
{ |
| 523 |
$options['property_residential_lettings_details'] = __( 'Property Residential Lettings Details', 'propertyhive' ); |
| 524 |
} |
| 525 |
} |
| 526 |
|
| 527 |
if ( get_option( 'propertyhive_active_departments_commercial', '' ) == 'yes' ) |
| 528 |
{ |
| 529 |
$options['property_commercial_details'] = __( 'Property Commercial Details', 'propertyhive' ); |
| 530 |
} |
| 531 |
|
| 532 |
$options['property_marketing'] = __( 'Property Marketing', 'propertyhive' ); |
| 533 |
|
| 534 |
if ( get_option('propertyhive_module_disabled_contacts', '') != 'yes' ) |
| 535 |
{ |
| 536 |
$options['contact_correspondence_address'] = __( 'Contact Correspondence Address', 'propertyhive' ); |
| 537 |
$options['contact_contact_details'] = __( 'Contact Contact Details', 'propertyhive' ); |
| 538 |
} |
| 539 |
|
| 540 |
if ( get_option('propertyhive_module_disabled_enquiries', '') != 'yes' ) |
| 541 |
{ |
| 542 |
$options['enquiry_record_details'] = __( 'Enquiry Record Details', 'propertyhive' ); |
| 543 |
} |
| 544 |
|
| 545 |
if ( get_option('propertyhive_module_disabled_appraisals', '') != 'yes' ) |
| 546 |
{ |
| 547 |
$options['appraisal_details'] = __( 'Appraisal Details', 'propertyhive' ); |
| 548 |
$options['appraisal_event'] = __( 'Appraisal Event Details', 'propertyhive' ); |
| 549 |
} |
| 550 |
|
| 551 |
if ( get_option('propertyhive_module_disabled_viewings', '') != 'yes' ) |
| 552 |
{ |
| 553 |
$options['viewing_details'] = __( 'Viewing Details', 'propertyhive' ); |
| 554 |
$options['viewing_event'] = __( 'Viewing Event Details', 'propertyhive' ); |
| 555 |
} |
| 556 |
|
| 557 |
if ( get_option('propertyhive_module_disabled_offers_sales', '') != 'yes' ) |
| 558 |
{ |
| 559 |
$options['offer_details'] = __( 'Offer Details', 'propertyhive' ); |
| 560 |
$options['sale_details'] = __( 'Sale Details', 'propertyhive' ); |
| 561 |
} |
| 562 |
|
| 563 |
if ( get_option( 'propertyhive_active_departments_lettings' ) == 'yes' && get_option('propertyhive_module_disabled_tenancies', '') != 'yes' ) |
| 564 |
{ |
| 565 |
$options['tenancy_details'] = __( 'Tenancy Details', 'propertyhive' ); |
| 566 |
$options['tenancy_management_details'] = __( 'Tenancy Management Details', 'propertyhive' ); |
| 567 |
$options['tenancy_deposit_scheme'] = __( 'Tenancy Deposit Scheme Details', 'propertyhive' ); |
| 568 |
$options['tenancy_meter_readings'] = __( 'Tenancy Meter Readings', 'propertyhive' ); |
| 569 |
} |
| 570 |
|
| 571 |
$options['office_details'] = __( 'Office Details', 'propertyhive' ); |
| 572 |
|
| 573 |
$options = apply_filters( 'propertyhive_template_assistant_custom_field_sections', $options ); |
| 574 |
|
| 575 |
$settings[] = array( |
| 576 |
'title' => __( 'Section', 'propertyhive' ), |
| 577 |
'id' => 'meta_box', |
| 578 |
'default' => ( (isset($custom_field_details['meta_box'])) ? $custom_field_details['meta_box'] : ''), |
| 579 |
'type' => 'select', |
| 580 |
'desc' => __( 'Please select which meta box on the property record this field should appear in', 'propertyhive' ), |
| 581 |
'options' => $options |
| 582 |
); |
| 583 |
|
| 584 |
$settings[] = array( |
| 585 |
'title' => __( 'Display On Website', 'propertyhive' ), |
| 586 |
'id' => 'display_on_website', |
| 587 |
'default' => ( (isset($custom_field_details['display_on_website']) && $custom_field_details['display_on_website'] == '1') ? 'yes' : ''), |
| 588 |
'type' => 'checkbox', |
| 589 |
); |
| 590 |
|
| 591 |
if ( get_option('propertyhive_module_disabled_contacts', '') != 'yes' ) |
| 592 |
{ |
| 593 |
$settings[] = array( |
| 594 |
'title' => __( 'Add As Match Field To Applicant Requirements', 'propertyhive' ), |
| 595 |
'id' => 'display_on_applicant_requirements', |
| 596 |
'default' => ( (isset($custom_field_details['display_on_applicant_requirements']) && $custom_field_details['display_on_applicant_requirements'] == '1') ? 'yes' : ''), |
| 597 |
'type' => 'checkbox', |
| 598 |
); |
| 599 |
} |
| 600 |
|
| 601 |
$settings[] = array( |
| 602 |
'title' => __( 'Exact Match Only If Searching On Field', 'propertyhive' ), |
| 603 |
'id' => 'exact_match', |
| 604 |
'default' => ( (isset($custom_field_details['exact_match']) && $custom_field_details['exact_match'] == '1') ? 'yes' : ''), |
| 605 |
'type' => 'checkbox', |
| 606 |
'desc' => __( 'If you\'re using this checkbox in property searches or matches tick this if properties should only be returned with the same ticked status. Alternatively, leave unticked for scenarios like \'Pets Allowed\' whereby properties with it ticked should come back whether search is ticked or not, but not vice versa.', 'propertyhive' ), |
| 607 |
); |
| 608 |
|
| 609 |
$settings[] = array( |
| 610 |
'title' => __( 'Display On Registration Form / My Account', 'propertyhive' ), |
| 611 |
'id' => 'display_on_user_details', |
| 612 |
'default' => ( (isset($custom_field_details['display_on_user_details']) && $custom_field_details['display_on_user_details'] == '1') ? 'yes' : ''), |
| 613 |
'type' => 'checkbox', |
| 614 |
); |
| 615 |
|
| 616 |
$settings[] = array( |
| 617 |
'title' => __( 'Show In Admin List', 'propertyhive' ), |
| 618 |
'id' => 'admin_list', |
| 619 |
'default' => ( (isset($custom_field_details['admin_list']) && $custom_field_details['admin_list'] == '1') ? 'yes' : ''), |
| 620 |
'type' => 'checkbox', |
| 621 |
); |
| 622 |
|
| 623 |
$settings[] = array( |
| 624 |
'title' => __( 'Sortable In Admin List', 'propertyhive' ), |
| 625 |
'id' => 'admin_list_sortable', |
| 626 |
'default' => ( (isset($custom_field_details['admin_list_sortable']) && $custom_field_details['admin_list_sortable'] == '1') ? 'yes' : ''), |
| 627 |
'type' => 'checkbox', |
| 628 |
); |
| 629 |
|
| 630 |
$settings[] = array( 'type' => 'sectionend', 'id' => 'customfield'); |
| 631 |
|
| 632 |
$settings[] = array( |
| 633 |
'type' => 'html', |
| 634 |
'html' => '<script> |
| 635 |
|
| 636 |
jQuery(document).ready(function() |
| 637 |
{ |
| 638 |
ph_hide_show_type_related_checkboxes(); |
| 639 |
|
| 640 |
jQuery(\'#meta_box\').change(function() |
| 641 |
{ |
| 642 |
ph_hide_show_type_related_checkboxes(); |
| 643 |
}); |
| 644 |
|
| 645 |
jQuery(\'#field_type\').change(function() |
| 646 |
{ |
| 647 |
ph_hide_show_type_related_checkboxes(); |
| 648 |
}); |
| 649 |
}); |
| 650 |
|
| 651 |
function ph_hide_show_type_related_checkboxes() |
| 652 |
{ |
| 653 |
var meta_box = jQuery(\'#meta_box\').val(); |
| 654 |
|
| 655 |
jQuery(\'#row_display_on_website\').hide(); |
| 656 |
jQuery(\'#row_display_on_applicant_requirements\').hide(); |
| 657 |
jQuery(\'#row_display_on_user_details\').hide(); |
| 658 |
jQuery(\'#row_exact_match\').hide(); |
| 659 |
|
| 660 |
jQuery(\'#row_admin_list\').show(); |
| 661 |
jQuery(\'#row_admin_list_sortable\').show(); |
| 662 |
|
| 663 |
if ( meta_box.indexOf(\'property_\') != -1 ) |
| 664 |
{ |
| 665 |
jQuery(\'#row_display_on_website\').show(); |
| 666 |
|
| 667 |
if ( jQuery(\'#field_type\').val() == \'select\' || jQuery(\'#field_type\').val() == \'multiselect\' || jQuery(\'#field_type\').val() == \'checkbox\' ) |
| 668 |
{ |
| 669 |
jQuery(\'#row_display_on_applicant_requirements\').show(); |
| 670 |
} |
| 671 |
|
| 672 |
if ( jQuery(\'#field_type\').val() == \'checkbox\' ) |
| 673 |
{ |
| 674 |
jQuery(\'#row_exact_match\').show(); |
| 675 |
} |
| 676 |
} |
| 677 |
if ( meta_box.indexOf(\'contact_\') != -1 ) |
| 678 |
{ |
| 679 |
jQuery(\'#row_display_on_user_details\').show(); |
| 680 |
} |
| 681 |
if ( meta_box == \'tenancy_management_details\' ) |
| 682 |
{ |
| 683 |
jQuery(\'#row_admin_list\').hide(); |
| 684 |
jQuery(\'#row_admin_list_sortable\').hide(); |
| 685 |
} |
| 686 |
} |
| 687 |
|
| 688 |
</script>' |
| 689 |
); |
| 690 |
|
| 691 |
return $settings; |
| 692 |
} |
| 693 |
|
| 694 |
public function additional_field_dropdown_options() |
| 695 |
{ |
| 696 |
$current_settings = get_option( 'propertyhive_template_assistant', array() ); |
| 697 |
|
| 698 |
if ( !isset($current_settings['custom_fields']) ) |
| 699 |
{ |
| 700 |
$current_settings['custom_fields'] = array(); |
| 701 |
} |
| 702 |
|
| 703 |
$current_id = ( !isset( $_REQUEST['id'] ) ) ? '' : sanitize_title( $_REQUEST['id'] ); |
| 704 |
|
| 705 |
$custom_field_details = array(); |
| 706 |
|
| 707 |
if ($current_id != '') |
| 708 |
{ |
| 709 |
$custom_fields = $current_settings['custom_fields']; |
| 710 |
|
| 711 |
if (isset($custom_fields[$current_id])) |
| 712 |
{ |
| 713 |
$custom_field_details = $custom_fields[$current_id]; |
| 714 |
} |
| 715 |
else |
| 716 |
{ |
| 717 |
die('Trying to edit an additional field which does not exist. Please go back and try again.'); |
| 718 |
} |
| 719 |
} |
| 720 |
|
| 721 |
echo ' |
| 722 |
<tr valign="top" id="row_dropdown_options"> |
| 723 |
<th scope="row" class="titledesc"> |
| 724 |
<label for="field_type">Dropdown Options</label> |
| 725 |
</th> |
| 726 |
<td class="forminp forminp-dropdown-options"><div id="sortable_options_' . $current_id . '">'; |
| 727 |
if ( isset($custom_field_details['dropdown_options']) && !empty($custom_field_details['dropdown_options']) ) |
| 728 |
{ |
| 729 |
foreach ( $custom_field_details['dropdown_options'] as $dropdown_option ) |
| 730 |
{ |
| 731 |
echo ' |
| 732 |
<div><i class="fa fa-reorder" style="cursor:pointer; opacity:0.3"></i> <input type="text" name="dropdown_options[]" value="' . $dropdown_option . '"> <a href="" class="delete-dropdown-option">Delete Option</a></div> |
| 733 |
'; |
| 734 |
} |
| 735 |
} |
| 736 |
else |
| 737 |
{ |
| 738 |
// None exist |
| 739 |
echo ' |
| 740 |
<div><i class="fa fa-reorder" style="cursor:pointer; opacity:0.3"></i> <input type="text" name="dropdown_options[]" placeholder="Add Option"> <a href="" class="delete-dropdown-option">Delete Option</a></div> |
| 741 |
'; |
| 742 |
} |
| 743 |
echo ' |
| 744 |
</div> |
| 745 |
<a href="" class="add-dropdown-option">Add New Option</a> |
| 746 |
</td> |
| 747 |
</tr> |
| 748 |
|
| 749 |
<script> |
| 750 |
jQuery(document).ready(function() |
| 751 |
{ |
| 752 |
toggle_dropdown_options(); |
| 753 |
|
| 754 |
jQuery(\'#field_type\').change(function() |
| 755 |
{ |
| 756 |
toggle_dropdown_options(); |
| 757 |
}); |
| 758 |
|
| 759 |
jQuery(\'body\').on(\'click\', \'a.add-dropdown-option\', function(e) |
| 760 |
{ |
| 761 |
e.preventDefault(); |
| 762 |
|
| 763 |
jQuery(\'.forminp-dropdown-options > div\').append(\'<div><i class="fa fa-reorder" style="cursor:pointer; opacity:0.3"></i> <input type="text" name="dropdown_options[]" placeholder="Add Option"> <a href="" class="delete-dropdown-option">Delete Option</a></div>\'); |
| 764 |
}); |
| 765 |
|
| 766 |
jQuery(\'body\').on(\'click\', \'a.delete-dropdown-option\', function(e) |
| 767 |
{ |
| 768 |
e.preventDefault(); |
| 769 |
|
| 770 |
var confirmBox = confirm(\'Are you sure you wish to delete this option?\'); |
| 771 |
|
| 772 |
if ( confirmBox ) |
| 773 |
{ |
| 774 |
jQuery(this).parent().remove(); |
| 775 |
} |
| 776 |
}); |
| 777 |
|
| 778 |
jQuery( \'#sortable_options_' . $current_id . '\' ) |
| 779 |
.sortable({ |
| 780 |
axis: "y", |
| 781 |
handle: "i", |
| 782 |
stop: function( event, ui ) |
| 783 |
{ |
| 784 |
// IE doesn\'t register the blur when sorting |
| 785 |
// so trigger focusout handlers to remove .ui-state-focus |
| 786 |
//ui.item.children( "h3" ).triggerHandler( "focusout" ); |
| 787 |
|
| 788 |
// Refresh accordion to handle new order |
| 789 |
//jQuery( this ).accordion( "refresh" ); |
| 790 |
}, |
| 791 |
update: function( event, ui ) |
| 792 |
{ |
| 793 |
// Update hidden fields |
| 794 |
var fields_order = jQuery(this).sortable(\'toArray\'); |
| 795 |
|
| 796 |
//$(\'#active_fields_order\').val( fields_order.join("|") ); |
| 797 |
} |
| 798 |
}); |
| 799 |
}); |
| 800 |
|
| 801 |
function toggle_dropdown_options() |
| 802 |
{ |
| 803 |
if ( jQuery(\'#field_type\').val() == \'select\' || jQuery(\'#field_type\').val() == \'multiselect\' ) |
| 804 |
{ |
| 805 |
jQuery(\'#row_dropdown_options\').show(); |
| 806 |
} |
| 807 |
else |
| 808 |
{ |
| 809 |
jQuery(\'#row_dropdown_options\').hide(); |
| 810 |
} |
| 811 |
} |
| 812 |
</script> |
| 813 |
'; |
| 814 |
} |
| 815 |
|
| 816 |
public function get_custom_fields_additional_fields_setting() |
| 817 |
{ |
| 818 |
return apply_filters( 'propertyhive_custom_fields_settings', array( |
| 819 |
|
| 820 |
array( 'title' => __( 'Additional Fields', 'propertyhive' ), 'type' => 'title', 'desc' => __( 'Create new fields to store information not included by default.', 'propertyhive' ), 'id' => 'additional_field_options' ), |
| 821 |
|
| 822 |
array( |
| 823 |
'type' => 'additional_fields_table', |
| 824 |
), |
| 825 |
|
| 826 |
array( 'type' => 'sectionend', 'id' => 'additional_field_options') |
| 827 |
|
| 828 |
)); |
| 829 |
} |
| 830 |
|
| 831 |
/** |
| 832 |
* Output list of additional fields |
| 833 |
* |
| 834 |
* @access public |
| 835 |
* @return void |
| 836 |
*/ |
| 837 |
public function additional_fields_table() { |
| 838 |
global $wpdb, $post; |
| 839 |
|
| 840 |
$current_settings = get_option( 'propertyhive_template_assistant', array() ); |
| 841 |
$custom_fields = array(); |
| 842 |
if ($current_settings !== FALSE) |
| 843 |
{ |
| 844 |
if (isset($current_settings['custom_fields'])) |
| 845 |
{ |
| 846 |
$custom_fields = $current_settings['custom_fields']; |
| 847 |
} |
| 848 |
} |
| 849 |
?> |
| 850 |
<tr valign="top"> |
| 851 |
<td class="forminp forminp-button"> |
| 852 |
<a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=addadditionalfield' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Field', 'propertyhive' )); ?></a> |
| 853 |
</td> |
| 854 |
</tr> |
| 855 |
<tr valign="top"> |
| 856 |
<td class="forminp"> |
| 857 |
<style type="text/css"> |
| 858 |
.ui-sortable-helper { |
| 859 |
display: table; |
| 860 |
} |
| 861 |
</style> |
| 862 |
<table class="ph_additional_fields widefat" cellspacing="0"> |
| 863 |
<thead> |
| 864 |
<tr> |
| 865 |
<th style="padding:8px 10px;" class="field-label"><?php esc_html_e( 'Field Name', 'propertyhive' ); ?></th> |
| 866 |
<th style="padding:8px 10px;" class="section"><?php esc_html_e( 'Section', 'propertyhive' ); ?></th> |
| 867 |
<th style="padding:8px 10px;" class="usage"><?php esc_html_e( 'Usage', 'propertyhive' ); ?></th> |
| 868 |
<th style="padding:8px 10px;" class="website"><?php esc_html_e( 'Display On Website', 'propertyhive' ); ?></th> |
| 869 |
<th style="padding:8px 10px;" class="admin-list"><?php esc_html_e( 'Show In Admin List', 'propertyhive' ); ?></th> |
| 870 |
<th style="padding:8px 10px;" class="admin-list-sorting"><?php esc_html_e( 'Sortable In Admin List', 'propertyhive' ); ?></th> |
| 871 |
<th style="padding:8px 10px;" class="settings"> </th> |
| 872 |
</tr> |
| 873 |
</thead> |
| 874 |
<tbody class="<?php echo !empty($custom_fields) ? 'has-rows' : ''; ?>"> |
| 875 |
<?php |
| 876 |
|
| 877 |
if (!empty($custom_fields)) |
| 878 |
{ |
| 879 |
foreach ($custom_fields as $id => $custom_field) |
| 880 |
{ |
| 881 |
echo '<tr id="custom_field_' . esc_attr($id) . '">'; |
| 882 |
echo '<td class="field-label"><span class="sort_anchor" style="cursor:grab "> � |
| 883 |
</span>' . esc_html($custom_field['field_label']) . '</td>'; |
| 884 |
echo '<td class="section">' . esc_html(ucwords( str_replace("_", " ", $custom_field['meta_box']) )) . '</td>'; |
| 885 |
echo '<td class="usage">'; |
| 886 |
if ( substr( $custom_field['meta_box'], 0, 8 ) == 'property' ) { echo '<pre style="background:#EEE; padding:5px; display:inline"><?php $property->' . esc_html(ltrim( $custom_field['field_name'], '_' )) . '; ?></pre>'; }else{ echo '-';} |
| 887 |
echo '</td>'; |
| 888 |
echo '<td class="website">'; |
| 889 |
if ( substr( $custom_field['meta_box'], 0, 8 ) == 'property' ) { echo esc_html( ( ( isset($custom_field['display_on_website']) && $custom_field['display_on_website'] == '1' ) ? __( 'Yes', 'propertyhive' ) : __( 'No', 'propertyhive' ) ) ); }else{ echo '-'; } |
| 890 |
echo '</td>'; |
| 891 |
echo '<td class="admin-list">'; |
| 892 |
echo esc_html( ( ( isset($custom_field['admin_list']) && $custom_field['admin_list'] == '1' ) ? __( 'Yes', 'propertyhive' ) : __( 'No', 'propertyhive' ) ) ); |
| 893 |
echo '</td>'; |
| 894 |
echo '<td class="sorting">'; |
| 895 |
if ( ( isset($custom_field['admin_list']) && $custom_field['admin_list'] == '1' ) ) |
| 896 |
{ |
| 897 |
echo esc_html( ( ( isset($custom_field['admin_list_sortable']) && $custom_field['admin_list_sortable'] == '1' ) ? __( 'Yes', 'propertyhive' ) : __( 'No', 'propertyhive' ) ) ); |
| 898 |
} |
| 899 |
else |
| 900 |
{ |
| 901 |
echo '-'; |
| 902 |
} |
| 903 |
echo '</td>'; |
| 904 |
echo '<td class="settings"> |
| 905 |
<a class="button" href="' . esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=editadditionalfield&id=' . $id )) . '">' . esc_html(__( 'Edit Field', 'propertyhive' )) . '</a> |
| 906 |
<a class="button" href="' . esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=additional&action=deleteadditionalfield&id=' . $id )) . '" onclick="var confirmBox = confirm(\'Are you sure you wish to delete this custom field?\'); return confirmBox;">' . esc_html(__( 'Delete', 'propertyhive' )) . '</a> |
| 907 |
</td>'; |
| 908 |
echo '</tr>'; |
| 909 |
} |
| 910 |
} |
| 911 |
else |
| 912 |
{ |
| 913 |
echo '<tr>'; |
| 914 |
echo '<td align="center" colspan="7">' . esc_html(__( 'No additional fields exist', 'propertyhive' )) . '</td>'; |
| 915 |
echo '</tr>'; |
| 916 |
} |
| 917 |
?> |
| 918 |
</tbody> |
| 919 |
</table> |
| 920 |
|
| 921 |
<script> |
| 922 |
jQuery( function($){ |
| 923 |
|
| 924 |
$('.ph_additional_fields tbody.has-rows').sortable({ |
| 925 |
opacity: 0.8, |
| 926 |
revert: true, |
| 927 |
handle: ".sort_anchor", |
| 928 |
update : function (event, ui) |
| 929 |
{ |
| 930 |
$('.ph_additional_fields tbody.has-rows').sortable( "destroy" ); |
| 931 |
|
| 932 |
var new_order = ''; |
| 933 |
jQuery('.ph_additional_fields tbody.has-rows').find('tr').each( function () |
| 934 |
{ |
| 935 |
if (new_order != '') |
| 936 |
{ |
| 937 |
new_order += ','; |
| 938 |
} |
| 939 |
new_order = new_order + jQuery(this).attr('id').replace('custom_field_', ''); |
| 940 |
}); |
| 941 |
|
| 942 |
// reload page |
| 943 |
window.location.href = '<?php echo admin_url('admin.php?page=ph-settings&tab=customfields§ion=additional'); ?>&neworder=' + new_order; |
| 944 |
} |
| 945 |
}); |
| 946 |
|
| 947 |
}); |
| 948 |
</script> |
| 949 |
</td> |
| 950 |
</tr> |
| 951 |
<tr valign="top"> |
| 952 |
<td class="forminp forminp-button"> |
| 953 |
<a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=addadditionalfield' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Field', 'propertyhive' )); ?></a> |
| 954 |
</td> |
| 955 |
</tr> |
| 956 |
<?php |
| 957 |
} |
| 958 |
|
| 959 |
/** |
| 960 |
* Output custom fields settings. |
| 961 |
* |
| 962 |
* @access public |
| 963 |
* @return void |
| 964 |
*/ |
| 965 |
public function get_custom_fields_setting($current_section) { |
| 966 |
|
| 967 |
$sections = $this->custom_field_sections; |
| 968 |
|
| 969 |
return apply_filters( 'propertyhive_custom_fields_' . $current_section . '_settings', array( |
| 970 |
|
| 971 |
array( 'title' => $sections[$current_section], 'type' => 'title', 'desc' => '', 'id' => 'custom_fields_' . $current_section . '_options' ), |
| 972 |
|
| 973 |
array( |
| 974 |
'type' => 'custom_fields_' . str_replace("-", "_", $current_section), |
| 975 |
), |
| 976 |
|
| 977 |
array( 'type' => 'sectionend', 'id' => 'custom_fields_' . $current_section . '_options'), |
| 978 |
|
| 979 |
)); |
| 980 |
|
| 981 |
} |
| 982 |
|
| 983 |
/** |
| 984 |
* Output list of availabilities |
| 985 |
* |
| 986 |
* @access public |
| 987 |
* @return void |
| 988 |
*/ |
| 989 |
public function custom_fields_availability_setting() { |
| 990 |
global $post; |
| 991 |
|
| 992 |
$departments = ph_get_departments(); |
| 993 |
|
| 994 |
$availability_departments = get_option( 'propertyhive_availability_departments', array() ); |
| 995 |
if ( !is_array($availability_departments) ) { $availability_departments = array(); } |
| 996 |
?> |
| 997 |
<tr valign="top"> |
| 998 |
<th scope="row" class="titledesc"> |
| 999 |
|
| 1000 |
</th> |
| 1001 |
<td class="forminp forminp-button"> |
| 1002 |
<a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a> |
| 1003 |
<a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=availability&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Availability', 'propertyhive' )); ?></a> |
| 1004 |
</td> |
| 1005 |
</tr> |
| 1006 |
<tr valign="top"> |
| 1007 |
<th scope="row" class="titledesc"><?php echo esc_html(__( 'Availability Options', 'propertyhive' )); ?></th> |
| 1008 |
<td class="forminp"> |
| 1009 |
<table class="ph_customfields sortable-custom-field widefat" data-taxonomy="availability" cellspacing="0"> |
| 1010 |
<thead> |
| 1011 |
<tr> |
| 1012 |
<th class="cb" style="width:1px;"><input class="select_all" type="checkbox" style="margin: 2px 0 0 0;"></th> |
| 1013 |
<th class="id" style="width:45px;"><?php echo esc_html(__( 'ID', 'propertyhive' )); ?></th> |
| 1014 |
<?php do_action( 'propertyhive_custom_field_availability_table_before_header_column' ); ?> |
| 1015 |
<th class="type"><?php echo esc_html(__( 'Availability', 'propertyhive' )); ?></th> |
| 1016 |
<th class="department"><?php echo esc_html(__( 'Applies To', 'propertyhive' )); ?></th> |
| 1017 |
<th class="assigned_count"><?php echo esc_html(__( $this::LINKED_POSTS_COLUMN_HEADING, 'propertyhive' )); ?></th> |
| 1018 |
<th class="settings"> </th> |
| 1019 |
</tr> |
| 1020 |
</thead> |
| 1021 |
<tbody> |
| 1022 |
<?php |
| 1023 |
$args = array( |
| 1024 |
'hide_empty' => false, |
| 1025 |
'parent' => 0 |
| 1026 |
); |
| 1027 |
$terms = get_terms( 'availability', $args ); |
| 1028 |
|
| 1029 |
if ( !empty( $terms ) && !is_wp_error( $terms ) ) |
| 1030 |
{ |
| 1031 |
foreach ( $terms as $term ) |
| 1032 |
{ |
| 1033 |
?> |
| 1034 |
<tr id="term-<?php echo esc_attr($term->term_id); ?>"> |
| 1035 |
<td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo esc_attr($term->term_id); ?>"></td> |
| 1036 |
<td class="id"><?php echo esc_html($term->term_id); ?></td> |
| 1037 |
<?php do_action( 'propertyhive_custom_field_availability_table_before_row_column', $term->term_id ); ?> |
| 1038 |
<td class="type"><?php echo esc_html($term->name); ?></td> |
| 1039 |
<td class="department"><?php |
| 1040 |
$this_availability_departments = array(); |
| 1041 |
if ( isset($availability_departments[$term->term_id]) ) |
| 1042 |
{ |
| 1043 |
foreach ( $availability_departments[$term->term_id] as $availability_department ) |
| 1044 |
{ |
| 1045 |
if ( get_option( 'propertyhive_active_departments_' . str_replace("residential-", "", $availability_department) ) == 'yes' ) |
| 1046 |
{ |
| 1047 |
$this_availability_departments[] = $departments[$availability_department]; |
| 1048 |
} |
| 1049 |
} |
| 1050 |
} |
| 1051 |
else |
| 1052 |
{ |
| 1053 |
foreach ( $departments as $key => $value ) |
| 1054 |
{ |
| 1055 |
if ( get_option( 'propertyhive_active_departments_' . str_replace("residential-", "", $key) ) == 'yes' ) |
| 1056 |
{ |
| 1057 |
$this_availability_departments[] = $value; |
| 1058 |
} |
| 1059 |
} |
| 1060 |
} |
| 1061 |
|
| 1062 |
echo !empty($this_availability_departments) ? esc_html(implode(", ", $this_availability_departments)) : '-'; |
| 1063 |
?></td> |
| 1064 |
<td class="assigned_count"><?php echo esc_html($term->count); ?></td> |
| 1065 |
<td class="settings"> |
| 1066 |
<a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=availability&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Edit', 'propertyhive' )); ?></a> |
| 1067 |
<a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=availability-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a> |
| 1068 |
</td> |
| 1069 |
</tr> |
| 1070 |
<?php |
| 1071 |
} |
| 1072 |
} |
| 1073 |
else |
| 1074 |
{ |
| 1075 |
?> |
| 1076 |
<tr> |
| 1077 |
<td colspan="6"><?php echo esc_html(__( 'No availability options found', 'propertyhive' )); ?></td> |
| 1078 |
</tr> |
| 1079 |
<?php |
| 1080 |
} |
| 1081 |
?> |
| 1082 |
</tbody> |
| 1083 |
</table> |
| 1084 |
</td> |
| 1085 |
</tr> |
| 1086 |
<tr valign="top"> |
| 1087 |
<th scope="row" class="titledesc"> |
| 1088 |
|
| 1089 |
</th> |
| 1090 |
<td class="forminp forminp-button"> |
| 1091 |
<a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a> |
| 1092 |
<a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=availability&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Availability', 'propertyhive' )); ?></a> |
| 1093 |
</td> |
| 1094 |
</tr> |
| 1095 |
<?php |
| 1096 |
} |
| 1097 |
|
| 1098 |
/** |
| 1099 |
* Output list of residential property types |
| 1100 |
* |
| 1101 |
* @access public |
| 1102 |
* @return void |
| 1103 |
*/ |
| 1104 |
public function custom_fields_property_type_setting() { |
| 1105 |
global $post; |
| 1106 |
?> |
| 1107 |
<tr valign="top"> |
| 1108 |
<th scope="row" class="titledesc"> |
| 1109 |
|
| 1110 |
</th> |
| 1111 |
<td class="forminp forminp-button"> |
| 1112 |
<a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a> |
| 1113 |
<a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=property-type&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Property Type', 'propertyhive' )); ?></a> |
| 1114 |
</td> |
| 1115 |
</tr> |
| 1116 |
<tr valign="top"> |
| 1117 |
<th scope="row" class="titledesc"><?php echo esc_html(__( 'Property Types', 'propertyhive' )); ?></th> |
| 1118 |
<td class="forminp"> |
| 1119 |
<table class="ph_customfields widefat" cellspacing="0"> |
| 1120 |
<thead> |
| 1121 |
<tr> |
| 1122 |
<th class="cb" style="width:1px;"><input class="select_all" type="checkbox" style="margin: 2px 0 0 0;"></th> |
| 1123 |
<th class="id" style="width:45px;"><?php echo esc_html(__( 'ID', 'propertyhive' )); ?></th> |
| 1124 |
<?php do_action( 'propertyhive_custom_field_property_type_table_before_header_column' ); ?> |
| 1125 |
<th class="type"><?php echo esc_html(__( 'Property Type', 'propertyhive' )); ?></th> |
| 1126 |
<th class="assigned_count"><?php echo esc_html(__( $this::LINKED_POSTS_COLUMN_HEADING, 'propertyhive' )); ?></th> |
| 1127 |
<th class="settings"> </th> |
| 1128 |
</tr> |
| 1129 |
</thead> |
| 1130 |
<tbody> |
| 1131 |
<?php |
| 1132 |
$args = array( |
| 1133 |
'hide_empty' => false, |
| 1134 |
'parent' => 0 |
| 1135 |
); |
| 1136 |
$terms = get_terms( 'property_type', $args ); |
| 1137 |
|
| 1138 |
if ( !empty( $terms ) && !is_wp_error( $terms ) ) |
| 1139 |
{ |
| 1140 |
foreach ($terms as $term) |
| 1141 |
{ |
| 1142 |
$parent_term_id = $term->term_id; |
| 1143 |
|
| 1144 |
$args = array( |
| 1145 |
'hide_empty' => false, |
| 1146 |
'parent' => $parent_term_id |
| 1147 |
); |
| 1148 |
$subterms = get_terms( 'property_type', $args ); |
| 1149 |
?> |
| 1150 |
<tr> |
| 1151 |
<td class="cb"><?php if ( empty( $subterms ) ) { ?><input type="checkbox" name="term_id[]" value="<?php echo esc_attr($term->term_id); ?>"><?php }else{ echo ' '; } ?></td> |
| 1152 |
<td class="id"><?php echo esc_html($term->term_id); ?></td> |
| 1153 |
<?php do_action( 'propertyhive_custom_field_property_type_table_before_row_column', $term->term_id ); ?> |
| 1154 |
<td class="type"><?php echo esc_html($term->name); ?></td> |
| 1155 |
<td class="assigned_count"><?php echo esc_html($term->count); ?></td> |
| 1156 |
<td class="settings"> |
| 1157 |
<a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=property-type&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Edit', 'propertyhive' )); ?></a> |
| 1158 |
<?php if ( empty( $subterms ) ) { ?> |
| 1159 |
<a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=property-type-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a> |
| 1160 |
<?php } ?> |
| 1161 |
</td> |
| 1162 |
</tr> |
| 1163 |
<?php |
| 1164 |
if ( !empty( $subterms ) && !is_wp_error( $subterms ) ) |
| 1165 |
{ |
| 1166 |
foreach ($subterms as $term) |
| 1167 |
{ |
| 1168 |
?> |
| 1169 |
<tr> |
| 1170 |
<td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo esc_attr($term->term_id); ?>"></td> |
| 1171 |
<td class="id"><?php echo esc_html($term->term_id); ?></td> |
| 1172 |
<?php do_action( 'propertyhive_custom_field_property_type_table_before_row_column', $term->term_id, $parent_term_id ); ?> |
| 1173 |
<td class="type subtype"> - <?php echo esc_html($term->name); ?></td> |
| 1174 |
<td class="assigned_count"><?php echo esc_html($term->count); ?></td> |
| 1175 |
<td class="settings"> |
| 1176 |
<a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=property-type&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Edit', 'propertyhive' )); ?></a> |
| 1177 |
<a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=property-type-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a> |
| 1178 |
</td> |
| 1179 |
</tr> |
| 1180 |
<?php |
| 1181 |
} |
| 1182 |
} |
| 1183 |
?> |
| 1184 |
<?php |
| 1185 |
} |
| 1186 |
} |
| 1187 |
else |
| 1188 |
{ |
| 1189 |
?> |
| 1190 |
<tr> |
| 1191 |
<td colspan="5"><?php echo esc_html(__( 'No property types found', 'propertyhive' )); ?></td> |
| 1192 |
</tr> |
| 1193 |
<?php |
| 1194 |
} |
| 1195 |
?> |
| 1196 |
</tbody> |
| 1197 |
</table> |
| 1198 |
</td> |
| 1199 |
</tr> |
| 1200 |
<tr valign="top"> |
| 1201 |
<th scope="row" class="titledesc"> |
| 1202 |
|
| 1203 |
</th> |
| 1204 |
<td class="forminp forminp-button"> |
| 1205 |
<a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a> |
| 1206 |
<a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=property-type&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Property Type', 'propertyhive' )); ?></a> |
| 1207 |
</td> |
| 1208 |
</tr> |
| 1209 |
<?php |
| 1210 |
} |
| 1211 |
|
| 1212 |
/** |
| 1213 |
* Output list of commercial property types |
| 1214 |
* |
| 1215 |
* @access public |
| 1216 |
* @return void |
| 1217 |
*/ |
| 1218 |
public function custom_fields_commercial_property_type_setting() { |
| 1219 |
global $post; |
| 1220 |
?> |
| 1221 |
<tr valign="top"> |
| 1222 |
<th scope="row" class="titledesc"> |
| 1223 |
|
| 1224 |
</th> |
| 1225 |
<td class="forminp forminp-button"> |
| 1226 |
<a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a> |
| 1227 |
<a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=commercial-property-type&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Property Type', 'propertyhive' )); ?></a> |
| 1228 |
</td> |
| 1229 |
</tr> |
| 1230 |
<tr valign="top"> |
| 1231 |
<th scope="row" class="titledesc"><?php echo esc_html(__( 'Property Types', 'propertyhive' )); ?></th> |
| 1232 |
<td class="forminp"> |
| 1233 |
<table class="ph_customfields widefat" cellspacing="0"> |
| 1234 |
<thead> |
| 1235 |
<tr> |
| 1236 |
<th class="cb" style="width:1px;"><input class="select_all" type="checkbox" style="margin: 2px 0 0 0;"></th> |
| 1237 |
<th class="id" style="width:45px;"><?php echo esc_html(__( 'ID', 'propertyhive' )); ?></th> |
| 1238 |
<?php do_action( 'propertyhive_custom_field_commercial_property_type_table_before_header_column' ); ?> |
| 1239 |
<th class="type"><?php echo esc_html(__( 'Property Type', 'propertyhive' )); ?></th> |
| 1240 |
<th class="assigned_count"><?php echo esc_html(__( $this::LINKED_POSTS_COLUMN_HEADING, 'propertyhive' )); ?></th> |
| 1241 |
<th class="settings"> </th> |
| 1242 |
</tr> |
| 1243 |
</thead> |
| 1244 |
<tbody> |
| 1245 |
<?php |
| 1246 |
$args = array( |
| 1247 |
'hide_empty' => false, |
| 1248 |
'parent' => 0 |
| 1249 |
); |
| 1250 |
$terms = get_terms( 'commercial_property_type', $args ); |
| 1251 |
|
| 1252 |
if ( !empty( $terms ) && !is_wp_error( $terms ) ) |
| 1253 |
{ |
| 1254 |
foreach ($terms as $term) |
| 1255 |
{ |
| 1256 |
$parent_term_id = $term->term_id; |
| 1257 |
|
| 1258 |
$args = array( |
| 1259 |
'hide_empty' => false, |
| 1260 |
'parent' => $parent_term_id |
| 1261 |
); |
| 1262 |
$subterms = get_terms( 'commercial_property_type', $args ); |
| 1263 |
?> |
| 1264 |
<tr> |
| 1265 |
<td class="cb"><?php if ( empty( $subterms ) ) { ?><input type="checkbox" name="term_id[]" value="<?php echo esc_attr($term->term_id); ?>"><?php }else{ echo ' '; } ?></td> |
| 1266 |
<td class="id"><?php echo esc_html($term->term_id); ?></td> |
| 1267 |
<?php do_action( 'propertyhive_custom_field_commercial_property_type_table_before_row_column', $term->term_id ); ?> |
| 1268 |
<td class="type"><?php echo esc_html($term->name); ?></td> |
| 1269 |
<td class="assigned_count"><?php echo esc_html($term->count); ?></td> |
| 1270 |
<td class="settings"> |
| 1271 |
<a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=commercial-property-type&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Edit', 'propertyhive' )); ?></a> |
| 1272 |
<?php if ( empty( $subterms ) ) { ?> |
| 1273 |
<a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=commercial-property-type-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a> |
| 1274 |
<?php } ?> |
| 1275 |
</td> |
| 1276 |
</tr> |
| 1277 |
<?php |
| 1278 |
if ( !empty( $subterms ) && !is_wp_error( $subterms ) ) |
| 1279 |
{ |
| 1280 |
foreach ($subterms as $term) |
| 1281 |
{ |
| 1282 |
?> |
| 1283 |
<tr> |
| 1284 |
<td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo esc_attr($term->term_id); ?>"></td> |
| 1285 |
<td class="id"><?php echo esc_html($term->term_id); ?></td> |
| 1286 |
<?php do_action( 'propertyhive_custom_field_commercial_property_type_table_before_row_column', $term->term_id, $parent_term_id ); ?> |
| 1287 |
<td class="type subtype"> - <?php echo esc_html($term->name); ?></td> |
| 1288 |
<td class="assigned_count"><?php echo esc_html($term->count); ?></td> |
| 1289 |
<td class="settings"> |
| 1290 |
<a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=commercial-property-type&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Edit', 'propertyhive' )); ?></a> |
| 1291 |
<a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=commercial-property-type-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a> |
| 1292 |
</td> |
| 1293 |
</tr> |
| 1294 |
<?php |
| 1295 |
} |
| 1296 |
} |
| 1297 |
?> |
| 1298 |
<?php |
| 1299 |
} |
| 1300 |
} |
| 1301 |
else |
| 1302 |
{ |
| 1303 |
?> |
| 1304 |
<tr> |
| 1305 |
<td colspan="5"><?php echo esc_html(__( 'No property types found', 'propertyhive' )); ?></td> |
| 1306 |
</tr> |
| 1307 |
<?php |
| 1308 |
} |
| 1309 |
?> |
| 1310 |
</tbody> |
| 1311 |
</table> |
| 1312 |
</td> |
| 1313 |
</tr> |
| 1314 |
<tr valign="top"> |
| 1315 |
<th scope="row" class="titledesc"> |
| 1316 |
|
| 1317 |
</th> |
| 1318 |
<td class="forminp forminp-button"> |
| 1319 |
<a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a> |
| 1320 |
<a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=commercial-property-type&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Property Type', 'propertyhive' )); ?></a> |
| 1321 |
</td> |
| 1322 |
</tr> |
| 1323 |
<?php |
| 1324 |
} |
| 1325 |
|
| 1326 |
/** |
| 1327 |
* Output list of locations |
| 1328 |
* |
| 1329 |
* @access public |
| 1330 |
* @return void |
| 1331 |
*/ |
| 1332 |
public function custom_fields_location_setting() { |
| 1333 |
global $post; |
| 1334 |
?> |
| 1335 |
<tr valign="top"> |
| 1336 |
<th scope="row" class="titledesc"> |
| 1337 |
|
| 1338 |
</th> |
| 1339 |
<td class="forminp forminp-button"> |
| 1340 |
<a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a> |
| 1341 |
<a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=location&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Location', 'propertyhive' )); ?></a> |
| 1342 |
</td> |
| 1343 |
</tr> |
| 1344 |
<tr valign="top"> |
| 1345 |
<th scope="row" class="titledesc"><?php echo esc_html(__( 'Locations', 'propertyhive' )); ?></th> |
| 1346 |
<td class="forminp"> |
| 1347 |
<table class="ph_customfields widefat" cellspacing="0"> |
| 1348 |
<thead> |
| 1349 |
<tr> |
| 1350 |
<th class="cb" style="width:1px;"><input class="select_all" type="checkbox" style="margin: 2px 0 0 0;"></th> |
| 1351 |
<th class="id" style="width:45px;"><?php echo esc_html(__( 'ID', 'propertyhive' )); ?></th> |
| 1352 |
<th class="type"><?php echo esc_html(__( 'Location', 'propertyhive' )); ?></th> |
| 1353 |
<th class="assigned_count"><?php echo esc_html(__( $this::LINKED_POSTS_COLUMN_HEADING, 'propertyhive' )); ?></th> |
| 1354 |
<th class="settings"> </th> |
| 1355 |
</tr> |
| 1356 |
</thead> |
| 1357 |
<tbody> |
| 1358 |
<?php |
| 1359 |
$args = array( |
| 1360 |
'hide_empty' => false, |
| 1361 |
'parent' => 0 |
| 1362 |
); |
| 1363 |
$terms = get_terms( 'location', $args ); |
| 1364 |
|
| 1365 |
if ( !empty( $terms ) && !is_wp_error( $terms ) ) |
| 1366 |
{ |
| 1367 |
foreach ($terms as $term) |
| 1368 |
{ |
| 1369 |
$args = array( |
| 1370 |
'hide_empty' => false, |
| 1371 |
'parent' => $term->term_id |
| 1372 |
); |
| 1373 |
$subterms = get_terms( 'location', $args ); |
| 1374 |
?> |
| 1375 |
<tr> |
| 1376 |
<td class="cb"><?php if ( empty( $subterms ) ) { ?><input type="checkbox" name="term_id[]" value="<?php echo esc_attr($term->term_id); ?>"><?php }else{ echo ' '; } ?></td> |
| 1377 |
<td class="id"><?php echo esc_html($term->term_id); ?></td> |
| 1378 |
<td class="type"><?php echo esc_html($term->name); ?></td> |
| 1379 |
<td class="assigned_count"><?php echo esc_html($term->count); ?></td> |
| 1380 |
<td class="settings"> |
| 1381 |
<a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=location&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Edit', 'propertyhive' )); ?></a> |
| 1382 |
<?php if ( empty( $subterms ) ) { ?> |
| 1383 |
<a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=location-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a> |
| 1384 |
<?php } ?> |
| 1385 |
</td> |
| 1386 |
</tr> |
| 1387 |
<?php |
| 1388 |
if ( !empty( $subterms ) && !is_wp_error( $subterms ) ) |
| 1389 |
{ |
| 1390 |
foreach ($subterms as $term) |
| 1391 |
{ |
| 1392 |
$args = array( |
| 1393 |
'hide_empty' => false, |
| 1394 |
'parent' => $term->term_id |
| 1395 |
); |
| 1396 |
$subsubterms = get_terms( 'location', $args ); |
| 1397 |
?> |
| 1398 |
<tr> |
| 1399 |
<td class="cb"><?php if ( empty( $subsubterms ) ) { ?><input type="checkbox" name="term_id[]" value="<?php echo esc_attr($term->term_id); ?>"><?php }else{ echo ' '; } ?></td> |
| 1400 |
<td class="id"><?php echo esc_html($term->term_id); ?></td> |
| 1401 |
<td class="type subtype"> - <?php echo esc_html($term->name); ?></td> |
| 1402 |
<td class="assigned_count"><?php echo esc_html($term->count); ?></td> |
| 1403 |
<td class="settings"> |
| 1404 |
<a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=location&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Edit', 'propertyhive' )); ?></a> |
| 1405 |
<?php if ( empty( $subsubterms ) ) { ?> |
| 1406 |
<a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=location-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a> |
| 1407 |
<?php } ?> |
| 1408 |
</td> |
| 1409 |
</tr> |
| 1410 |
<?php |
| 1411 |
if ( !empty( $subsubterms ) && !is_wp_error( $subsubterms ) ) |
| 1412 |
{ |
| 1413 |
foreach ($subsubterms as $term) |
| 1414 |
{ |
| 1415 |
?> |
| 1416 |
<tr> |
| 1417 |
<td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo esc_attr($term->term_id); ?>"></td> |
| 1418 |
<td class="id"><?php echo esc_html($term->term_id); ?></td> |
| 1419 |
<td class="type subtype"> - <?php echo esc_html($term->name); ?></td> |
| 1420 |
<td class="assigned_count"><?php echo esc_html($term->count); ?></td> |
| 1421 |
<td class="settings"> |
| 1422 |
<a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=location&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Edit', 'propertyhive' )); ?></a> |
| 1423 |
<a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=location-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a> |
| 1424 |
</td> |
| 1425 |
</tr> |
| 1426 |
<?php |
| 1427 |
} |
| 1428 |
} |
| 1429 |
} |
| 1430 |
} |
| 1431 |
?> |
| 1432 |
<?php |
| 1433 |
} |
| 1434 |
} |
| 1435 |
else |
| 1436 |
{ |
| 1437 |
?> |
| 1438 |
<tr> |
| 1439 |
<td colspan="5"><?php echo esc_html(__( 'No locations found', 'propertyhive' )); ?></td> |
| 1440 |
</tr> |
| 1441 |
<?php |
| 1442 |
} |
| 1443 |
?> |
| 1444 |
</tbody> |
| 1445 |
</table> |
| 1446 |
</td> |
| 1447 |
</tr> |
| 1448 |
<tr valign="top"> |
| 1449 |
<th scope="row" class="titledesc"> |
| 1450 |
|
| 1451 |
</th> |
| 1452 |
<td class="forminp forminp-button"> |
| 1453 |
<a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a> |
| 1454 |
<a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=location&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Location', 'propertyhive' )); ?></a> |
| 1455 |
</td> |
| 1456 |
</tr> |
| 1457 |
<?php |
| 1458 |
} |
| 1459 |
|
| 1460 |
/** |
| 1461 |
* Output list of parking |
| 1462 |
* |
| 1463 |
* @access public |
| 1464 |
* @return void |
| 1465 |
*/ |
| 1466 |
public function custom_fields_parking_setting() { |
| 1467 |
global $post; |
| 1468 |
?> |
| 1469 |
<tr valign="top"> |
| 1470 |
<th scope="row" class="titledesc"> |
| 1471 |
|
| 1472 |
</th> |
| 1473 |
<td class="forminp forminp-button"> |
| 1474 |
<a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a> |
| 1475 |
<a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=parking&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Parking', 'propertyhive' )); ?></a> |
| 1476 |
</td> |
| 1477 |
</tr> |
| 1478 |
<tr valign="top"> |
| 1479 |
<th scope="row" class="titledesc"><?php echo esc_html(__( 'Parking Options', 'propertyhive' )); ?></th> |
| 1480 |
<td class="forminp"> |
| 1481 |
<table class="ph_customfields sortable-custom-field widefat" data-taxonomy="parking" cellspacing="0"> |
| 1482 |
<thead> |
| 1483 |
<tr> |
| 1484 |
<th class="cb" style="width:1px;"><input class="select_all" type="checkbox" style="margin: 2px 0 0 0;"></th> |
| 1485 |
<th class="id" style="width:45px;"><?php echo esc_html(__( 'ID', 'propertyhive' )); ?></th> |
| 1486 |
<th class="type"><?php echo esc_html(__( 'Parking', 'propertyhive' )); ?></th> |
| 1487 |
<th class="assigned_count"><?php echo esc_html(__( $this::LINKED_POSTS_COLUMN_HEADING, 'propertyhive' )); ?></th> |
| 1488 |
<th class="settings"> </th> |
| 1489 |
</tr> |
| 1490 |
</thead> |
| 1491 |
<tbody> |
| 1492 |
<?php |
| 1493 |
$args = array( |
| 1494 |
'hide_empty' => false, |
| 1495 |
'parent' => 0 |
| 1496 |
); |
| 1497 |
$terms = get_terms( 'parking', $args ); |
| 1498 |
|
| 1499 |
if ( !empty( $terms ) && !is_wp_error( $terms ) ) |
| 1500 |
{ |
| 1501 |
foreach ($terms as $term) |
| 1502 |
{ |
| 1503 |
?> |
| 1504 |
<tr id="term-<?php echo esc_attr($term->term_id); ?>"> |
| 1505 |
<td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo esc_attr($term->term_id); ?>"></td> |
| 1506 |
<td class="id"><?php echo esc_html($term->term_id); ?></td> |
| 1507 |
<td class="type"><?php echo esc_html($term->name); ?></td> |
| 1508 |
<td class="assigned_count"><?php echo esc_html($term->count); ?></td> |
| 1509 |
<td class="settings"> |
| 1510 |
<a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=parking&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Edit', 'propertyhive' )); ?></a> |
| 1511 |
<a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=parking-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a> |
| 1512 |
</td> |
| 1513 |
</tr> |
| 1514 |
<?php |
| 1515 |
} |
| 1516 |
} |
| 1517 |
else |
| 1518 |
{ |
| 1519 |
?> |
| 1520 |
<tr> |
| 1521 |
<td colspan="5"><?php echo esc_html(__( 'No parking options found', 'propertyhive' )); ?></td> |
| 1522 |
</tr> |
| 1523 |
<?php |
| 1524 |
} |
| 1525 |
?> |
| 1526 |
</tbody> |
| 1527 |
</table> |
| 1528 |
</td> |
| 1529 |
</tr> |
| 1530 |
<tr valign="top"> |
| 1531 |
<th scope="row" class="titledesc"> |
| 1532 |
|
| 1533 |
</th> |
| 1534 |
<td class="forminp forminp-button"> |
| 1535 |
<a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a> |
| 1536 |
<a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=parking&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Parking', 'propertyhive' )); ?></a> |
| 1537 |
</td> |
| 1538 |
</tr> |
| 1539 |
<?php |
| 1540 |
} |
| 1541 |
|
| 1542 |
/** |
| 1543 |
* Output list of outside spaces |
| 1544 |
* |
| 1545 |
* @access public |
| 1546 |
* @return void |
| 1547 |
*/ |
| 1548 |
public function custom_fields_outside_space_setting() { |
| 1549 |
global $post; |
| 1550 |
?> |
| 1551 |
<tr valign="top"> |
| 1552 |
<th scope="row" class="titledesc"> |
| 1553 |
|
| 1554 |
</th> |
| 1555 |
<td class="forminp forminp-button"> |
| 1556 |
<a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a> |
| 1557 |
<a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=outside-space&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Outside Space', 'propertyhive' )); ?></a> |
| 1558 |
</td> |
| 1559 |
</tr> |
| 1560 |
<tr valign="top"> |
| 1561 |
<th scope="row" class="titledesc"><?php echo esc_html(__( 'Outside Spaces', 'propertyhive' )); ?></th> |
| 1562 |
<td class="forminp"> |
| 1563 |
<table class="ph_customfields sortable-custom-field widefat" data-taxonomy="outside_space" cellspacing="0"> |
| 1564 |
<thead> |
| 1565 |
<tr> |
| 1566 |
<th class="cb" style="width:1px;"><input class="select_all" type="checkbox" style="margin: 2px 0 0 0;"></th> |
| 1567 |
<th class="id" style="width:45px;"><?php echo esc_html(__( 'ID', 'propertyhive' )); ?></th> |
| 1568 |
<th class="type"><?php echo esc_html(__( 'Outside Space', 'propertyhive' )); ?></th> |
| 1569 |
<th class="assigned_count"><?php echo esc_html(__( $this::LINKED_POSTS_COLUMN_HEADING, 'propertyhive' )); ?></th> |
| 1570 |
<th class="settings"> </th> |
| 1571 |
</tr> |
| 1572 |
</thead> |
| 1573 |
<tbody> |
| 1574 |
<?php |
| 1575 |
$args = array( |
| 1576 |
'hide_empty' => false, |
| 1577 |
'parent' => 0 |
| 1578 |
); |
| 1579 |
$terms = get_terms( 'outside_space', $args ); |
| 1580 |
|
| 1581 |
if ( !empty( $terms ) && !is_wp_error( $terms ) ) |
| 1582 |
{ |
| 1583 |
foreach ($terms as $term) |
| 1584 |
{ |
| 1585 |
?> |
| 1586 |
<tr id="term-<?php echo esc_attr($term->term_id); ?>"> |
| 1587 |
<td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo esc_attr($term->term_id); ?>"></td> |
| 1588 |
<td class="id"><?php echo esc_html($term->term_id); ?></td> |
| 1589 |
<td class="type"><?php echo esc_html($term->name); ?></td> |
| 1590 |
<td class="assigned_count"><?php echo esc_html($term->count); ?></td> |
| 1591 |
<td class="settings"> |
| 1592 |
<a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=outside-space&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Edit', 'propertyhive' )); ?></a> |
| 1593 |
<a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=outside-space-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a> |
| 1594 |
</td> |
| 1595 |
</tr> |
| 1596 |
<?php |
| 1597 |
} |
| 1598 |
} |
| 1599 |
else |
| 1600 |
{ |
| 1601 |
?> |
| 1602 |
<tr> |
| 1603 |
<td colspan="5"><?php echo esc_html(__( 'No outside spaces found', 'propertyhive' )); ?></td> |
| 1604 |
</tr> |
| 1605 |
<?php |
| 1606 |
} |
| 1607 |
?> |
| 1608 |
</tbody> |
| 1609 |
</table> |
| 1610 |
</td> |
| 1611 |
</tr> |
| 1612 |
<tr valign="top"> |
| 1613 |
<th scope="row" class="titledesc"> |
| 1614 |
|
| 1615 |
</th> |
| 1616 |
<td class="forminp forminp-button"> |
| 1617 |
<a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a> |
| 1618 |
<a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=outside-space&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Outside Space', 'propertyhive' )); ?></a> |
| 1619 |
</td> |
| 1620 |
</tr> |
| 1621 |
<?php |
| 1622 |
} |
| 1623 |
|
| 1624 |
/** |
| 1625 |
* Output list of price qualifiers |
| 1626 |
* |
| 1627 |
* @access public |
| 1628 |
* @return void |
| 1629 |
*/ |
| 1630 |
public function custom_fields_price_qualifier_setting() { |
| 1631 |
global $post; |
| 1632 |
?> |
| 1633 |
<tr valign="top"> |
| 1634 |
<th scope="row" class="titledesc"> |
| 1635 |
|
| 1636 |
</th> |
| 1637 |
<td class="forminp forminp-button"> |
| 1638 |
<a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a> |
| 1639 |
<a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=price-qualifier&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Price Qualifier', 'propertyhive' )); ?></a> |
| 1640 |
</td> |
| 1641 |
</tr> |
| 1642 |
<tr valign="top"> |
| 1643 |
<th scope="row" class="titledesc"><?php echo esc_html(__( 'Price Qualifiers', 'propertyhive' )); ?></th> |
| 1644 |
<td class="forminp"> |
| 1645 |
<table class="ph_customfields sortable-custom-field widefat" data-taxonomy="price_qualifier" cellspacing="0"> |
| 1646 |
<thead> |
| 1647 |
<tr> |
| 1648 |
<th class="cb" style="width:1px;"><input class="select_all" type="checkbox" style="margin: 2px 0 0 0;"></th> |
| 1649 |
<th class="id" style="width:45px;"><?php echo esc_html(__( 'ID', 'propertyhive' )); ?></th> |
| 1650 |
<th class="type"><?php echo esc_html(__( 'Price Qualifier', 'propertyhive' )); ?></th> |
| 1651 |
<th class="assigned_count"><?php echo esc_html(__( $this::LINKED_POSTS_COLUMN_HEADING, 'propertyhive' )); ?></th> |
| 1652 |
<th class="settings"> </th> |
| 1653 |
</tr> |
| 1654 |
</thead> |
| 1655 |
<tbody> |
| 1656 |
<?php |
| 1657 |
$args = array( |
| 1658 |
'hide_empty' => false, |
| 1659 |
'parent' => 0 |
| 1660 |
); |
| 1661 |
$terms = get_terms( 'price_qualifier', $args ); |
| 1662 |
|
| 1663 |
if ( !empty( $terms ) && !is_wp_error( $terms ) ) |
| 1664 |
{ |
| 1665 |
foreach ($terms as $term) |
| 1666 |
{ |
| 1667 |
?> |
| 1668 |
<tr id="term-<?php echo esc_attr($term->term_id); ?>"> |
| 1669 |
<td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo esc_attr($term->term_id); ?>"></td> |
| 1670 |
<td class="id"><?php echo esc_html($term->term_id); ?></td> |
| 1671 |
<td class="type"><?php echo esc_html($term->name); ?></td> |
| 1672 |
<td class="assigned_count"><?php echo esc_html($term->count); ?></td> |
| 1673 |
<td class="settings"> |
| 1674 |
<a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=price-qualifier&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Edit', 'propertyhive' )); ?></a> |
| 1675 |
<a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=price-qualifier-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a> |
| 1676 |
</td> |
| 1677 |
</tr> |
| 1678 |
<?php |
| 1679 |
} |
| 1680 |
} |
| 1681 |
else |
| 1682 |
{ |
| 1683 |
?> |
| 1684 |
<tr> |
| 1685 |
<td colspan="5"><?php echo esc_html(__( 'No price qualifiers found', 'propertyhive' )); ?></td> |
| 1686 |
</tr> |
| 1687 |
<?php |
| 1688 |
} |
| 1689 |
?> |
| 1690 |
</tbody> |
| 1691 |
</table> |
| 1692 |
</td> |
| 1693 |
</tr> |
| 1694 |
<tr valign="top"> |
| 1695 |
<th scope="row" class="titledesc"> |
| 1696 |
|
| 1697 |
</th> |
| 1698 |
<td class="forminp forminp-button"> |
| 1699 |
<a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a> |
| 1700 |
<a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=price-qualifier&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Price Qualifier', 'propertyhive' )); ?></a> |
| 1701 |
</td> |
| 1702 |
</tr> |
| 1703 |
<?php |
| 1704 |
} |
| 1705 |
|
| 1706 |
/** |
| 1707 |
* Output list of sale by options |
| 1708 |
* |
| 1709 |
* @access public |
| 1710 |
* @return void |
| 1711 |
*/ |
| 1712 |
public function custom_fields_sale_by_setting() { |
| 1713 |
global $post; |
| 1714 |
?> |
| 1715 |
<tr valign="top"> |
| 1716 |
<th scope="row" class="titledesc"> |
| 1717 |
|
| 1718 |
</th> |
| 1719 |
<td class="forminp forminp-button"> |
| 1720 |
<a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a> |
| 1721 |
<a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=sale-by&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Sale By', 'propertyhive' )); ?></a> |
| 1722 |
</td> |
| 1723 |
</tr> |
| 1724 |
<tr valign="top"> |
| 1725 |
<th scope="row" class="titledesc"><?php echo esc_html(__( 'Sale By Options', 'propertyhive' )); ?></th> |
| 1726 |
<td class="forminp"> |
| 1727 |
<table class="ph_customfields sortable-custom-field widefat" data-taxonomy="sale_by" cellspacing="0"> |
| 1728 |
<thead> |
| 1729 |
<tr> |
| 1730 |
<th class="cb" style="width:1px;"><input class="select_all" type="checkbox" style="margin: 2px 0 0 0;"></th> |
| 1731 |
<th class="id" style="width:45px;"><?php echo esc_html(__( 'ID', 'propertyhive' )); ?></th> |
| 1732 |
<th class="type"><?php echo esc_html(__( 'Sale By', 'propertyhive' )); ?></th> |
| 1733 |
<th class="assigned_count"><?php echo esc_html(__( $this::LINKED_POSTS_COLUMN_HEADING, 'propertyhive' )); ?></th> |
| 1734 |
<th class="settings"> </th> |
| 1735 |
</tr> |
| 1736 |
</thead> |
| 1737 |
<tbody> |
| 1738 |
<?php |
| 1739 |
$args = array( |
| 1740 |
'hide_empty' => false, |
| 1741 |
'parent' => 0 |
| 1742 |
); |
| 1743 |
$terms = get_terms( 'sale_by', $args ); |
| 1744 |
|
| 1745 |
if ( !empty( $terms ) && !is_wp_error( $terms ) ) |
| 1746 |
{ |
| 1747 |
foreach ($terms as $term) |
| 1748 |
{ |
| 1749 |
?> |
| 1750 |
<tr> |
| 1751 |
<td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo esc_attr($term->term_id); ?>"></td> |
| 1752 |
<td class="id"><?php echo esc_html($term->term_id); ?></td> |
| 1753 |
<td class="type"><?php echo esc_html($term->name); ?></td> |
| 1754 |
<td class="assigned_count"><?php echo esc_html($term->count); ?></td> |
| 1755 |
<td class="settings"> |
| 1756 |
<a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=sale-by&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Edit', 'propertyhive' )); ?></a> |
| 1757 |
<a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=sale-by-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a> |
| 1758 |
</td> |
| 1759 |
</tr> |
| 1760 |
<?php |
| 1761 |
} |
| 1762 |
} |
| 1763 |
else |
| 1764 |
{ |
| 1765 |
?> |
| 1766 |
<tr> |
| 1767 |
<td colspan="5"><?php echo esc_html(__( 'No sale by options found', 'propertyhive' )); ?></td> |
| 1768 |
</tr> |
| 1769 |
<?php |
| 1770 |
} |
| 1771 |
?> |
| 1772 |
</tbody> |
| 1773 |
</table> |
| 1774 |
</td> |
| 1775 |
</tr> |
| 1776 |
<tr valign="top"> |
| 1777 |
<th scope="row" class="titledesc"> |
| 1778 |
|
| 1779 |
</th> |
| 1780 |
<td class="forminp forminp-button"> |
| 1781 |
<a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a> |
| 1782 |
<a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=sale-by&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Sale By', 'propertyhive' )); ?></a> |
| 1783 |
</td> |
| 1784 |
</tr> |
| 1785 |
<?php |
| 1786 |
} |
| 1787 |
|
| 1788 |
/** |
| 1789 |
* Output list of residential tenure options |
| 1790 |
* |
| 1791 |
* @access public |
| 1792 |
* @return void |
| 1793 |
*/ |
| 1794 |
public function custom_fields_tenure_setting() { |
| 1795 |
global $post; |
| 1796 |
?> |
| 1797 |
<tr valign="top"> |
| 1798 |
<th scope="row" class="titledesc"> |
| 1799 |
|
| 1800 |
</th> |
| 1801 |
<td class="forminp forminp-button"> |
| 1802 |
<a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a> |
| 1803 |
<a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=tenure&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Tenure', 'propertyhive' )); ?></a> |
| 1804 |
</td> |
| 1805 |
</tr> |
| 1806 |
<tr valign="top"> |
| 1807 |
<th scope="row" class="titledesc"><?php echo esc_html(__( 'Tenures', 'propertyhive' )); ?></th> |
| 1808 |
<td class="forminp"> |
| 1809 |
<table class="ph_customfields sortable-custom-field widefat" data-taxonomy="tenure" cellspacing="0"> |
| 1810 |
<thead> |
| 1811 |
<tr> |
| 1812 |
<th class="cb" style="width:1px;"><input class="select_all" type="checkbox" style="margin: 2px 0 0 0;"></th> |
| 1813 |
<th class="id" style="width:45px;"><?php echo esc_html(__( 'ID', 'propertyhive' )); ?></th> |
| 1814 |
<th class="type"><?php echo esc_html(__( 'Tenure', 'propertyhive' )); ?></th> |
| 1815 |
<th class="assigned_count"><?php echo esc_html(__( $this::LINKED_POSTS_COLUMN_HEADING, 'propertyhive' )); ?></th> |
| 1816 |
<th class="settings"> </th> |
| 1817 |
</tr> |
| 1818 |
</thead> |
| 1819 |
<tbody> |
| 1820 |
<?php |
| 1821 |
$args = array( |
| 1822 |
'hide_empty' => false, |
| 1823 |
'parent' => 0 |
| 1824 |
); |
| 1825 |
$terms = get_terms( 'tenure', $args ); |
| 1826 |
|
| 1827 |
if ( !empty( $terms ) && !is_wp_error( $terms ) ) |
| 1828 |
{ |
| 1829 |
foreach ($terms as $term) |
| 1830 |
{ |
| 1831 |
?> |
| 1832 |
<tr id="term-<?php echo esc_attr($term->term_id); ?>"> |
| 1833 |
<td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo esc_attr($term->term_id); ?>"></td> |
| 1834 |
<td class="id"><?php echo esc_html($term->term_id); ?></td> |
| 1835 |
<td class="type"><?php echo esc_html($term->name); ?></td> |
| 1836 |
<td class="assigned_count"><?php echo esc_html($term->count); ?></td> |
| 1837 |
<td class="settings"> |
| 1838 |
<a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=tenure&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Edit', 'propertyhive' )); ?></a> |
| 1839 |
<a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=tenure-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a> |
| 1840 |
</td> |
| 1841 |
</tr> |
| 1842 |
<?php |
| 1843 |
} |
| 1844 |
} |
| 1845 |
else |
| 1846 |
{ |
| 1847 |
?> |
| 1848 |
<tr> |
| 1849 |
<td colspan="5"><?php echo esc_html(__( 'No tenure found', 'propertyhive' )); ?></td> |
| 1850 |
</tr> |
| 1851 |
<?php |
| 1852 |
} |
| 1853 |
?> |
| 1854 |
</tbody> |
| 1855 |
</table> |
| 1856 |
</td> |
| 1857 |
</tr> |
| 1858 |
<tr valign="top"> |
| 1859 |
<th scope="row" class="titledesc"> |
| 1860 |
|
| 1861 |
</th> |
| 1862 |
<td class="forminp forminp-button"> |
| 1863 |
<a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a> |
| 1864 |
<a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=tenure&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Tenure', 'propertyhive' )); ?></a> |
| 1865 |
</td> |
| 1866 |
</tr> |
| 1867 |
<?php |
| 1868 |
} |
| 1869 |
|
| 1870 |
/** |
| 1871 |
* Output list of commercial tenure options |
| 1872 |
* |
| 1873 |
* @access public |
| 1874 |
* @return void |
| 1875 |
*/ |
| 1876 |
public function custom_fields_commercial_tenure_setting() { |
| 1877 |
global $post; |
| 1878 |
?> |
| 1879 |
<tr valign="top"> |
| 1880 |
<th scope="row" class="titledesc"> |
| 1881 |
|
| 1882 |
</th> |
| 1883 |
<td class="forminp forminp-button"> |
| 1884 |
<a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a> |
| 1885 |
<a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=commercial-tenure&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Tenure', 'propertyhive' )); ?></a> |
| 1886 |
</td> |
| 1887 |
</tr> |
| 1888 |
<tr valign="top"> |
| 1889 |
<th scope="row" class="titledesc"><?php echo esc_html(__( 'Tenures', 'propertyhive' )); ?></th> |
| 1890 |
<td class="forminp"> |
| 1891 |
<table class="ph_customfields sortable-custom-field widefat" data-taxonomy="commercial_tenure" cellspacing="0"> |
| 1892 |
<thead> |
| 1893 |
<tr> |
| 1894 |
<th class="cb" style="width:1px;"><input class="select_all" type="checkbox" style="margin: 2px 0 0 0;"></th> |
| 1895 |
<th class="id" style="width:45px;"><?php echo esc_html(__( 'ID', 'propertyhive' )); ?></th> |
| 1896 |
<th class="type"><?php echo esc_html(__( 'Tenure', 'propertyhive' )); ?></th> |
| 1897 |
<th class="assigned_count"><?php echo esc_html(__( $this::LINKED_POSTS_COLUMN_HEADING, 'propertyhive' )); ?></th> |
| 1898 |
<th class="settings"> </th> |
| 1899 |
</tr> |
| 1900 |
</thead> |
| 1901 |
<tbody> |
| 1902 |
<?php |
| 1903 |
$args = array( |
| 1904 |
'hide_empty' => false, |
| 1905 |
'parent' => 0 |
| 1906 |
); |
| 1907 |
$terms = get_terms( 'commercial_tenure', $args ); |
| 1908 |
|
| 1909 |
if ( !empty( $terms ) && !is_wp_error( $terms ) ) |
| 1910 |
{ |
| 1911 |
foreach ($terms as $term) |
| 1912 |
{ |
| 1913 |
?> |
| 1914 |
<tr id="term-<?php echo esc_attr($term->term_id); ?>"> |
| 1915 |
<td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo esc_attr($term->term_id); ?>"></td> |
| 1916 |
<td class="id"><?php echo esc_html($term->term_id); ?></td> |
| 1917 |
<td class="type"><?php echo esc_html($term->name); ?></td> |
| 1918 |
<td class="assigned_count"><?php echo esc_html($term->count); ?></td> |
| 1919 |
<td class="settings"> |
| 1920 |
<a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=commercial-tenure&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Edit', 'propertyhive' )); ?></a> |
| 1921 |
<a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=commercial-tenure-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a> |
| 1922 |
</td> |
| 1923 |
</tr> |
| 1924 |
<?php |
| 1925 |
} |
| 1926 |
} |
| 1927 |
else |
| 1928 |
{ |
| 1929 |
?> |
| 1930 |
<tr> |
| 1931 |
<td colspan="5"><?php echo esc_html(__( 'No tenure found', 'propertyhive' )); ?></td> |
| 1932 |
</tr> |
| 1933 |
<?php |
| 1934 |
} |
| 1935 |
?> |
| 1936 |
</tbody> |
| 1937 |
</table> |
| 1938 |
</td> |
| 1939 |
</tr> |
| 1940 |
<tr valign="top"> |
| 1941 |
<th scope="row" class="titledesc"> |
| 1942 |
|
| 1943 |
</th> |
| 1944 |
<td class="forminp forminp-button"> |
| 1945 |
<a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a> |
| 1946 |
<a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=commercial-tenure&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Tenure', 'propertyhive' )); ?></a> |
| 1947 |
</td> |
| 1948 |
</tr> |
| 1949 |
<?php |
| 1950 |
} |
| 1951 |
|
| 1952 |
/** |
| 1953 |
* Output list of furnished options |
| 1954 |
* |
| 1955 |
* @access public |
| 1956 |
* @return void |
| 1957 |
*/ |
| 1958 |
public function custom_fields_furnished_setting() { |
| 1959 |
global $post; |
| 1960 |
?> |
| 1961 |
<tr valign="top"> |
| 1962 |
<th scope="row" class="titledesc"> |
| 1963 |
|
| 1964 |
</th> |
| 1965 |
<td class="forminp forminp-button"> |
| 1966 |
<a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a> |
| 1967 |
<a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=furnished&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Furnished Option', 'propertyhive' )); ?></a> |
| 1968 |
</td> |
| 1969 |
</tr> |
| 1970 |
<tr valign="top"> |
| 1971 |
<th scope="row" class="titledesc"><?php echo esc_html(__( 'Furnished Options', 'propertyhive' )); ?></th> |
| 1972 |
<td class="forminp"> |
| 1973 |
<table class="ph_customfields sortable-custom-field widefat" data-taxonomy="furnished" cellspacing="0"> |
| 1974 |
<thead> |
| 1975 |
<tr> |
| 1976 |
<th class="cb" style="width:1px;"><input class="select_all" type="checkbox" style="margin: 2px 0 0 0;"></th> |
| 1977 |
<th class="id" style="width:45px;"><?php echo esc_html(__( 'ID', 'propertyhive' )); ?></th> |
| 1978 |
<th class="type"><?php echo esc_html(__( 'Furnished', 'propertyhive' )); ?></th> |
| 1979 |
<th class="assigned_count"><?php echo esc_html(__( $this::LINKED_POSTS_COLUMN_HEADING, 'propertyhive' )); ?></th> |
| 1980 |
<th class="settings"> </th> |
| 1981 |
</tr> |
| 1982 |
</thead> |
| 1983 |
<tbody> |
| 1984 |
<?php |
| 1985 |
$args = array( |
| 1986 |
'hide_empty' => false, |
| 1987 |
'parent' => 0 |
| 1988 |
); |
| 1989 |
$terms = get_terms( 'furnished', $args ); |
| 1990 |
|
| 1991 |
if ( !empty( $terms ) && !is_wp_error( $terms ) ) |
| 1992 |
{ |
| 1993 |
foreach ($terms as $term) |
| 1994 |
{ |
| 1995 |
?> |
| 1996 |
<tr id="term-<?php echo esc_attr($term->term_id); ?>"> |
| 1997 |
<td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo esc_attr($term->term_id); ?>"></td> |
| 1998 |
<td class="id"><?php echo esc_html($term->term_id); ?></td> |
| 1999 |
<td class="type"><?php echo esc_html($term->name); ?></td> |
| 2000 |
<td class="assigned_count"><?php echo esc_html($term->count); ?></td> |
| 2001 |
<td class="settings"> |
| 2002 |
<a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=furnished&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Edit', 'propertyhive' )); ?></a> |
| 2003 |
<a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=furnished-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a> |
| 2004 |
</td> |
| 2005 |
</tr> |
| 2006 |
<?php |
| 2007 |
} |
| 2008 |
} |
| 2009 |
else |
| 2010 |
{ |
| 2011 |
?> |
| 2012 |
<tr> |
| 2013 |
<td colspan="5"><?php echo esc_html(__( 'No furnished options found', 'propertyhive' )); ?></td> |
| 2014 |
</tr> |
| 2015 |
<?php |
| 2016 |
} |
| 2017 |
?> |
| 2018 |
</tbody> |
| 2019 |
</table> |
| 2020 |
</td> |
| 2021 |
</tr> |
| 2022 |
<tr valign="top"> |
| 2023 |
<th scope="row" class="titledesc"> |
| 2024 |
|
| 2025 |
</th> |
| 2026 |
<td class="forminp forminp-button"> |
| 2027 |
<a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a> |
| 2028 |
<a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=furnished&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Furnished Option', 'propertyhive' )); ?></a> |
| 2029 |
</td> |
| 2030 |
</tr> |
| 2031 |
<?php |
| 2032 |
} |
| 2033 |
|
| 2034 |
public function custom_fields_management_key_date_type_setting() { |
| 2035 |
?> |
| 2036 |
<tr valign="top"> |
| 2037 |
<th scope="row" class="titledesc"> |
| 2038 |
|
| 2039 |
</th> |
| 2040 |
<td class="forminp forminp-button"> |
| 2041 |
<a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a> |
| 2042 |
<a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=management-key-date-type&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Management Date Type', 'propertyhive' )); ?></a> |
| 2043 |
</td> |
| 2044 |
</tr> |
| 2045 |
<?php foreach( array ('property_management' => __( 'Property Management', 'propertyhive' ), 'tenancy_management' => __( 'Tenancy Management', 'propertyhive' ) ) as $type => $title): ?> |
| 2046 |
<tr valign="top"> |
| 2047 |
<th scope="row" class="titledesc no-auto"><?php echo esc_html(__( $title, 'propertyhive' )); ?></th> |
| 2048 |
<td class="forminp no-auto"> |
| 2049 |
<table class="ph_customfields widefat" cellspacing="0"> |
| 2050 |
<thead> |
| 2051 |
<tr> |
| 2052 |
<th style="width:1px;"> </th> |
| 2053 |
<th style="width:40%;"><?php echo esc_html(__( 'Description', 'propertyhive' )); ?></th> |
| 2054 |
<th><?php echo esc_html(__( 'Recurrence', 'propertyhive' )); ?></th> |
| 2055 |
<th> </th> |
| 2056 |
</tr> |
| 2057 |
</thead> |
| 2058 |
<tbody> |
| 2059 |
<?php |
| 2060 |
$args = array( |
| 2061 |
'hide_empty' => false, |
| 2062 |
'parent' => 0 |
| 2063 |
); |
| 2064 |
$terms = get_terms( 'management_key_date_type', $args ); |
| 2065 |
|
| 2066 |
if ( !empty( $terms ) && !is_wp_error( $terms ) ) |
| 2067 |
{ |
| 2068 |
$recurrence_rules = get_option( 'propertyhive_key_date_type', array() ); |
| 2069 |
$recurrence_rules = is_array( $recurrence_rules ) ? $recurrence_rules : array(); |
| 2070 |
|
| 2071 |
foreach ($terms as $term) |
| 2072 |
{ |
| 2073 |
$recurrence_type = isset($recurrence_rules[$term->term_id]) ? $recurrence_rules[$term->term_id]['recurrence_type'] : ''; |
| 2074 |
|
| 2075 |
if ( $recurrence_type !== $type) |
| 2076 |
{ |
| 2077 |
continue; |
| 2078 |
} |
| 2079 |
|
| 2080 |
|
| 2081 |
$recurrence_rule = isset($recurrence_rules[$term->term_id]) ? $recurrence_rules[$term->term_id]['recurrence_rule'] : ''; |
| 2082 |
$recurrence = array('FREQ' => '', 'INTERVAL' => ''); |
| 2083 |
foreach (explode(';', $recurrence_rule) as $key_value_pair) { |
| 2084 |
list($key, $value) = explode('=', $key_value_pair); |
| 2085 |
$recurrence[$key] = $value; |
| 2086 |
} |
| 2087 |
|
| 2088 |
$frequency = ''; |
| 2089 |
if ($recurrence['INTERVAL'] <= 1) |
| 2090 |
{ |
| 2091 |
$frequencies = array( |
| 2092 |
'ONCE' => __( 'Once', 'propertyhive' ), |
| 2093 |
'DAILY' => __( 'Daily', 'propertyhive' ), |
| 2094 |
'WEEKLY' => __( 'Weekly', 'propertyhive' ), |
| 2095 |
'MONTHLY' => __( 'Monthly', 'propertyhive' ), |
| 2096 |
'YEARLY' => __( 'Annually', 'propertyhive' ), |
| 2097 |
); |
| 2098 |
|
| 2099 |
$frequency = $frequencies[$recurrence['FREQ']]; |
| 2100 |
} |
| 2101 |
else |
| 2102 |
{ |
| 2103 |
$interval = $recurrence['INTERVAL']; |
| 2104 |
if (extension_loaded('intl')) |
| 2105 |
{ |
| 2106 |
$formatter = new NumberFormatter(get_locale(), NumberFormatter::SPELLOUT); |
| 2107 |
$interval = $formatter->format($recurrence['INTERVAL']); |
| 2108 |
} |
| 2109 |
|
| 2110 |
$periods = array( |
| 2111 |
'DAILY' => __( 'days', 'propertyhive' ), |
| 2112 |
'WEEKLY' => __( 'weeks', 'propertyhive' ), |
| 2113 |
'MONTHLY' => __( 'months', 'propertyhive' ), |
| 2114 |
'YEARLY' => __( 'years', 'propertyhive' ), |
| 2115 |
); |
| 2116 |
|
| 2117 |
|
| 2118 |
$frequency = sprintf('Every %s %s', $interval, $periods[$recurrence['FREQ']]); |
| 2119 |
} |
| 2120 |
|
| 2121 |
?> |
| 2122 |
<tr> |
| 2123 |
<td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo esc_attr($term->term_id); ?>"></td> |
| 2124 |
<td><?php echo esc_html($term->name); ?></td> |
| 2125 |
<td><?php echo esc_html($frequency); ?></td> |
| 2126 |
<td class="settings"> |
| 2127 |
<a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=management-key-date-type&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Edit', 'propertyhive' )); ?></a> |
| 2128 |
<a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=management-key-date-type-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a> |
| 2129 |
</td> |
| 2130 |
</tr> |
| 2131 |
<?php |
| 2132 |
} |
| 2133 |
} |
| 2134 |
else |
| 2135 |
{ |
| 2136 |
?> |
| 2137 |
<tr> |
| 2138 |
<td colspan="4"><?php echo esc_html(__( 'No management date types found', 'propertyhive' )); ?></td> |
| 2139 |
</tr> |
| 2140 |
<?php |
| 2141 |
} |
| 2142 |
?> |
| 2143 |
</tbody> |
| 2144 |
</table> |
| 2145 |
</td> |
| 2146 |
</tr> |
| 2147 |
<?php endforeach; ?> |
| 2148 |
<tr valign="top"> |
| 2149 |
<th scope="row" class="titledesc"> |
| 2150 |
|
| 2151 |
</th> |
| 2152 |
<td class="forminp forminp-button"> |
| 2153 |
<a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a> |
| 2154 |
<a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=management-key-date-type&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Management Date Type', 'propertyhive' )); ?></a> |
| 2155 |
</td> |
| 2156 |
</tr> |
| 2157 |
<?php |
| 2158 |
} |
| 2159 |
|
| 2160 |
/** |
| 2161 |
* Output list of marketing flag options |
| 2162 |
* |
| 2163 |
* @access public |
| 2164 |
* @return void |
| 2165 |
*/ |
| 2166 |
public function custom_fields_marketing_flag_setting() { |
| 2167 |
global $post; |
| 2168 |
?> |
| 2169 |
<tr valign="top"> |
| 2170 |
<th scope="row" class="titledesc"> |
| 2171 |
|
| 2172 |
</th> |
| 2173 |
<td class="forminp forminp-button"> |
| 2174 |
<a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a> |
| 2175 |
<a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=marketing-flag&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Marketing Flag', 'propertyhive' )); ?></a> |
| 2176 |
</td> |
| 2177 |
</tr> |
| 2178 |
<tr valign="top"> |
| 2179 |
<th scope="row" class="titledesc"><?php echo esc_html(__( 'Marketing Flags', 'propertyhive' )); ?></th> |
| 2180 |
<td class="forminp"> |
| 2181 |
<table class="ph_customfields sortable-custom-field widefat" data-taxonomy="marketing_flag" cellspacing="0"> |
| 2182 |
<thead> |
| 2183 |
<tr> |
| 2184 |
<th class="cb" style="width:1px;"><input class="select_all" type="checkbox" style="margin: 2px 0 0 0;"></th> |
| 2185 |
<th class="id" style="width:45px;"><?php echo esc_html(__( 'ID', 'propertyhive' )); ?></th> |
| 2186 |
<th class="type"><?php echo esc_html(__( 'Marketing Flag', 'propertyhive' )); ?></th> |
| 2187 |
<th class="assigned_count"><?php echo esc_html(__( $this::LINKED_POSTS_COLUMN_HEADING, 'propertyhive' )); ?></th> |
| 2188 |
<th class="settings"> </th> |
| 2189 |
</tr> |
| 2190 |
</thead> |
| 2191 |
<tbody> |
| 2192 |
<?php |
| 2193 |
$args = array( |
| 2194 |
'hide_empty' => false, |
| 2195 |
'parent' => 0 |
| 2196 |
); |
| 2197 |
$terms = get_terms( 'marketing_flag', $args ); |
| 2198 |
|
| 2199 |
if ( !empty( $terms ) && !is_wp_error( $terms ) ) |
| 2200 |
{ |
| 2201 |
foreach ($terms as $term) |
| 2202 |
{ |
| 2203 |
?> |
| 2204 |
<tr id="term-<?php echo esc_attr($term->term_id); ?>"> |
| 2205 |
<td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo esc_attr($term->term_id); ?>"></td> |
| 2206 |
<td class="id"><?php echo esc_html($term->term_id); ?></td> |
| 2207 |
<td class="type"><?php echo esc_html($term->name); ?></td> |
| 2208 |
<td class="assigned_count"><?php echo esc_html($term->count); ?></td> |
| 2209 |
<td class="settings"> |
| 2210 |
<a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=marketing-flag&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Edit', 'propertyhive' )); ?></a> |
| 2211 |
<a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=marketing-flag-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a> |
| 2212 |
</td> |
| 2213 |
</tr> |
| 2214 |
<?php |
| 2215 |
} |
| 2216 |
} |
| 2217 |
else |
| 2218 |
{ |
| 2219 |
?> |
| 2220 |
<tr> |
| 2221 |
<td colspan="5"><?php echo esc_html(__( 'No marketing flags found', 'propertyhive' )); ?></td> |
| 2222 |
</tr> |
| 2223 |
<?php |
| 2224 |
} |
| 2225 |
?> |
| 2226 |
</tbody> |
| 2227 |
</table> |
| 2228 |
</td> |
| 2229 |
</tr> |
| 2230 |
<tr valign="top"> |
| 2231 |
<th scope="row" class="titledesc"> |
| 2232 |
|
| 2233 |
</th> |
| 2234 |
<td class="forminp forminp-button"> |
| 2235 |
<a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a> |
| 2236 |
<a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=marketing-flag&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Marketing Flag', 'propertyhive' )); ?></a> |
| 2237 |
</td> |
| 2238 |
</tr> |
| 2239 |
<?php |
| 2240 |
} |
| 2241 |
|
| 2242 |
/** |
| 2243 |
* Output list of property feature options |
| 2244 |
* |
| 2245 |
* @access public |
| 2246 |
* @return void |
| 2247 |
*/ |
| 2248 |
public function custom_fields_property_feature_setting() { |
| 2249 |
global $post; |
| 2250 |
?> |
| 2251 |
<tr valign="top"> |
| 2252 |
<th scope="row" class="titledesc"> |
| 2253 |
|
| 2254 |
</th> |
| 2255 |
<td class="forminp forminp-button"> |
| 2256 |
<a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a> |
| 2257 |
<a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=property-feature&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Property Feature', 'propertyhive' )); ?></a> |
| 2258 |
</td> |
| 2259 |
</tr> |
| 2260 |
<tr valign="top"> |
| 2261 |
<th scope="row" class="titledesc"><?php echo esc_html(__( 'Property Features', 'propertyhive' )); ?></th> |
| 2262 |
<td class="forminp"> |
| 2263 |
<table class="ph_customfields widefat" cellspacing="0"> |
| 2264 |
<thead> |
| 2265 |
<tr> |
| 2266 |
<th class="cb" style="width:1px;"><input class="select_all" type="checkbox" style="margin: 2px 0 0 0;"></th> |
| 2267 |
<th class="id" style="width:45px;"><?php echo esc_html(__( 'ID', 'propertyhive' )); ?></th> |
| 2268 |
<th class="type"><?php echo esc_html(__( 'Property Feature', 'propertyhive' )); ?></th> |
| 2269 |
<th class="assigned_count"><?php echo esc_html(__( $this::LINKED_POSTS_COLUMN_HEADING, 'propertyhive' )); ?></th> |
| 2270 |
<th class="settings"> </th> |
| 2271 |
</tr> |
| 2272 |
</thead> |
| 2273 |
<tbody> |
| 2274 |
<?php |
| 2275 |
$args = array( |
| 2276 |
'hide_empty' => false, |
| 2277 |
'parent' => 0 |
| 2278 |
); |
| 2279 |
$terms = get_terms( 'property_feature', $args ); |
| 2280 |
|
| 2281 |
if ( !empty( $terms ) && !is_wp_error( $terms ) ) |
| 2282 |
{ |
| 2283 |
foreach ($terms as $term) |
| 2284 |
{ |
| 2285 |
?> |
| 2286 |
<tr> |
| 2287 |
<td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo esc_attr($term->term_id); ?>"></td> |
| 2288 |
<td class="id"><?php echo esc_html($term->term_id); ?></td> |
| 2289 |
<td class="type"><?php echo esc_html($term->name); ?></td> |
| 2290 |
<td class="assigned_count"><?php echo esc_html($term->count); ?></td> |
| 2291 |
<td class="settings"> |
| 2292 |
<a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=property-feature&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Edit', 'propertyhive' )); ?></a> |
| 2293 |
<a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=property-feature-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a> |
| 2294 |
</td> |
| 2295 |
</tr> |
| 2296 |
<?php |
| 2297 |
} |
| 2298 |
} |
| 2299 |
else |
| 2300 |
{ |
| 2301 |
?> |
| 2302 |
<tr> |
| 2303 |
<td colspan="5"><?php echo esc_html(__( 'No property features found', 'propertyhive' )); ?></td> |
| 2304 |
</tr> |
| 2305 |
<?php |
| 2306 |
} |
| 2307 |
?> |
| 2308 |
</tbody> |
| 2309 |
</table> |
| 2310 |
</td> |
| 2311 |
</tr> |
| 2312 |
<tr valign="top"> |
| 2313 |
<th scope="row" class="titledesc"> |
| 2314 |
|
| 2315 |
</th> |
| 2316 |
<td class="forminp forminp-button"> |
| 2317 |
<a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a> |
| 2318 |
<a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=property-feature&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Property Feature', 'propertyhive' )); ?></a> |
| 2319 |
</td> |
| 2320 |
</tr> |
| 2321 |
<?php |
| 2322 |
} |
| 2323 |
|
| 2324 |
/** |
| 2325 |
* Show availability add/edit options |
| 2326 |
* |
| 2327 |
* @access public |
| 2328 |
* @return string |
| 2329 |
*/ |
| 2330 |
public function get_custom_fields_availability_setting() |
| 2331 |
{ |
| 2332 |
$current_id = empty( $_REQUEST['id'] ) ? '' : (int)$_REQUEST['id']; |
| 2333 |
|
| 2334 |
$taxonomy = 'availability'; |
| 2335 |
$term_name = ''; |
| 2336 |
if ($current_id != '') |
| 2337 |
{ |
| 2338 |
$term = get_term( $current_id, $taxonomy ); |
| 2339 |
$term_name = $term->name; |
| 2340 |
} |
| 2341 |
|
| 2342 |
$departments = ph_get_departments(); |
| 2343 |
|
| 2344 |
$args = array( |
| 2345 |
|
| 2346 |
array( 'title' => __( ( $current_id == '' ? 'Add New Availability Option' : 'Edit Availability' ), 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_availability_settings' ), |
| 2347 |
|
| 2348 |
array( |
| 2349 |
'title' => __( 'Availability', 'propertyhive' ), |
| 2350 |
'id' => 'availability_name', |
| 2351 |
'default' => $term_name, |
| 2352 |
'type' => 'text', |
| 2353 |
'desc_tip' => false, |
| 2354 |
), |
| 2355 |
|
| 2356 |
); |
| 2357 |
|
| 2358 |
$availability_departments = get_option( 'propertyhive_availability_departments', array() ); |
| 2359 |
|
| 2360 |
$i = 0; |
| 2361 |
foreach ( $departments as $key => $value ) |
| 2362 |
{ |
| 2363 |
if ( get_option( 'propertyhive_active_departments_' . str_replace("residential-", "", $key) ) == 'yes' ) |
| 2364 |
{ |
| 2365 |
$args[] = array( |
| 2366 |
'title' => __( 'Applies To', 'propertyhive' ), |
| 2367 |
'name' => 'department[' . $key . ']', |
| 2368 |
'id' => 'department_' . $key, |
| 2369 |
//'default' => $term_name, |
| 2370 |
'value' => ( !isset($availability_departments[$current_id]) || in_array($key, $availability_departments[$current_id]) ? 'yes' : '' ), |
| 2371 |
'type' => 'checkbox', |
| 2372 |
'desc_tip' => false, |
| 2373 |
'desc' => $value, |
| 2374 |
'checkboxgroup' => ( $i == 0 ? 'start' : ( $i == count($departments)-1 ? 'end' : '' ) ), |
| 2375 |
); |
| 2376 |
|
| 2377 |
++$i; |
| 2378 |
} |
| 2379 |
} |
| 2380 |
|
| 2381 |
$args[] = array( |
| 2382 |
'type' => 'hidden', |
| 2383 |
'id' => 'taxonomy', |
| 2384 |
'default' => $taxonomy |
| 2385 |
); |
| 2386 |
|
| 2387 |
$args[] = array( 'type' => 'sectionend', 'id' => 'custom_field_availability_settings' ); |
| 2388 |
|
| 2389 |
return apply_filters( 'propertyhive_custom_field_availability_settings', $args ); |
| 2390 |
} |
| 2391 |
|
| 2392 |
/** |
| 2393 |
* Show residential property type add/edit options |
| 2394 |
* |
| 2395 |
* @access public |
| 2396 |
* @return string |
| 2397 |
*/ |
| 2398 |
public function get_custom_fields_property_type_setting() |
| 2399 |
{ |
| 2400 |
$current_id = empty( $_REQUEST['id'] ) ? '' : (int)$_REQUEST['id']; |
| 2401 |
|
| 2402 |
$taxonomy = 'property_type'; |
| 2403 |
$term_name = ''; |
| 2404 |
$term_parent = ''; |
| 2405 |
if ($current_id != '') |
| 2406 |
{ |
| 2407 |
$term = get_term( $current_id, $taxonomy ); |
| 2408 |
$term_name = $term->name; |
| 2409 |
$term_parent = $term->parent; |
| 2410 |
} |
| 2411 |
|
| 2412 |
$existing_terms = array('' => '(' . __ ( 'no parent', 'propertyhive') . ')'); |
| 2413 |
|
| 2414 |
$args = array( |
| 2415 |
'hide_empty' => false, |
| 2416 |
'parent' => 0, |
| 2417 |
'exclude' => array($current_id) |
| 2418 |
); |
| 2419 |
$terms = get_terms( 'property_type', $args ); |
| 2420 |
if ( !empty( $terms ) && !is_wp_error( $terms ) ) |
| 2421 |
{ |
| 2422 |
foreach ($terms as $term) |
| 2423 |
{ |
| 2424 |
$existing_terms[$term->term_id] = $term->name; |
| 2425 |
} |
| 2426 |
} |
| 2427 |
|
| 2428 |
$args = array( |
| 2429 |
|
| 2430 |
array( 'title' => __( ( $current_id == '' ? 'Add New Property Type' : 'Edit Property Type' ), 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_property_type_settings' ), |
| 2431 |
|
| 2432 |
array( |
| 2433 |
'title' => __( 'Property Type', 'propertyhive' ), |
| 2434 |
'id' => 'property_type_name', |
| 2435 |
'default' => $term_name, |
| 2436 |
'type' => 'text', |
| 2437 |
'desc_tip' => false, |
| 2438 |
), |
| 2439 |
|
| 2440 |
array( |
| 2441 |
'title' => __( 'Parent', 'propertyhive' ), |
| 2442 |
'id' => 'parent_property_type_id', |
| 2443 |
'default' => $term_parent, |
| 2444 |
'options' => $existing_terms, |
| 2445 |
'type' => 'select', |
| 2446 |
'desc_tip' => false, |
| 2447 |
'desc' => '' |
| 2448 |
), |
| 2449 |
|
| 2450 |
array( |
| 2451 |
'type' => 'hidden', |
| 2452 |
'id' => 'taxonomy', |
| 2453 |
'default' => $taxonomy |
| 2454 |
), |
| 2455 |
|
| 2456 |
array( 'type' => 'sectionend', 'id' => 'custom_field_property_type_settings' ) |
| 2457 |
|
| 2458 |
); |
| 2459 |
|
| 2460 |
return apply_filters( 'propertyhive_custom_field_property_type_settings', $args ); |
| 2461 |
} |
| 2462 |
|
| 2463 |
/** |
| 2464 |
* Show commercial property type add/edit options |
| 2465 |
* |
| 2466 |
* @access public |
| 2467 |
* @return string |
| 2468 |
*/ |
| 2469 |
public function get_custom_fields_commercial_property_type_setting() |
| 2470 |
{ |
| 2471 |
$current_id = empty( $_REQUEST['id'] ) ? '' : (int)$_REQUEST['id']; |
| 2472 |
|
| 2473 |
$taxonomy = 'commercial_property_type'; |
| 2474 |
$term_name = ''; |
| 2475 |
$term_parent = ''; |
| 2476 |
if ($current_id != '') |
| 2477 |
{ |
| 2478 |
$term = get_term( $current_id, $taxonomy ); |
| 2479 |
$term_name = $term->name; |
| 2480 |
$term_parent = $term->parent; |
| 2481 |
} |
| 2482 |
|
| 2483 |
$existing_terms = array('' => '(' . __ ( 'no parent', 'propertyhive') . ')'); |
| 2484 |
|
| 2485 |
$args = array( |
| 2486 |
'hide_empty' => false, |
| 2487 |
'parent' => 0, |
| 2488 |
'exclude' => array($current_id) |
| 2489 |
); |
| 2490 |
$terms = get_terms( 'commercial_property_type', $args ); |
| 2491 |
if ( !empty( $terms ) && !is_wp_error( $terms ) ) |
| 2492 |
{ |
| 2493 |
foreach ($terms as $term) |
| 2494 |
{ |
| 2495 |
$existing_terms[$term->term_id] = $term->name; |
| 2496 |
} |
| 2497 |
} |
| 2498 |
|
| 2499 |
$args = array( |
| 2500 |
|
| 2501 |
array( 'title' => __( ( $current_id == '' ? 'Add New Property Type' : 'Edit Property Type' ), 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_commercial_property_type_settings' ), |
| 2502 |
|
| 2503 |
array( |
| 2504 |
'title' => __( 'Property Type', 'propertyhive' ), |
| 2505 |
'id' => 'commercial_property_type_name', |
| 2506 |
'default' => $term_name, |
| 2507 |
'type' => 'text', |
| 2508 |
'desc_tip' => false, |
| 2509 |
), |
| 2510 |
|
| 2511 |
array( |
| 2512 |
'title' => __( 'Parent', 'propertyhive' ), |
| 2513 |
'id' => 'parent_commercial_property_type_id', |
| 2514 |
'default' => $term_parent, |
| 2515 |
'options' => $existing_terms, |
| 2516 |
'type' => 'select', |
| 2517 |
'desc_tip' => false, |
| 2518 |
'desc' => '' |
| 2519 |
), |
| 2520 |
|
| 2521 |
array( |
| 2522 |
'type' => 'hidden', |
| 2523 |
'id' => 'taxonomy', |
| 2524 |
'default' => $taxonomy |
| 2525 |
), |
| 2526 |
|
| 2527 |
array( 'type' => 'sectionend', 'id' => 'custom_field_commercial_property_type_settings' ) |
| 2528 |
|
| 2529 |
); |
| 2530 |
|
| 2531 |
return apply_filters( 'propertyhive_custom_field_commercial_property_type_settings', $args ); |
| 2532 |
} |
| 2533 |
|
| 2534 |
/** |
| 2535 |
* Show location add/edit options |
| 2536 |
* |
| 2537 |
* @access public |
| 2538 |
* @return string |
| 2539 |
*/ |
| 2540 |
public function get_custom_fields_location_setting() |
| 2541 |
{ |
| 2542 |
$current_id = empty( $_REQUEST['id'] ) ? '' : (int)$_REQUEST['id']; |
| 2543 |
|
| 2544 |
$taxonomy = 'location'; |
| 2545 |
$term_name = ''; |
| 2546 |
$term_parent = ''; |
| 2547 |
if ($current_id != '') |
| 2548 |
{ |
| 2549 |
$term = get_term( $current_id, $taxonomy ); |
| 2550 |
$term_name = $term->name; |
| 2551 |
$term_parent = $term->parent; |
| 2552 |
} |
| 2553 |
|
| 2554 |
$existing_terms = array('' => '(' . __ ( 'no parent', 'propertyhive') . ')'); |
| 2555 |
|
| 2556 |
$args = array( |
| 2557 |
'hide_empty' => false, |
| 2558 |
'parent' => 0, |
| 2559 |
'exclude' => array($current_id) |
| 2560 |
); |
| 2561 |
$terms = get_terms( $taxonomy, $args ); |
| 2562 |
if ( !empty( $terms ) && !is_wp_error( $terms ) ) |
| 2563 |
{ |
| 2564 |
foreach ($terms as $term) |
| 2565 |
{ |
| 2566 |
$existing_terms[$term->term_id] = '- '.$term->name; |
| 2567 |
|
| 2568 |
$args = array( |
| 2569 |
'hide_empty' => false, |
| 2570 |
'parent' => $term->term_id, |
| 2571 |
'exclude' => array($current_id) |
| 2572 |
); |
| 2573 |
$terms = get_terms( $taxonomy, $args ); |
| 2574 |
if ( !empty( $terms ) && !is_wp_error( $terms ) ) |
| 2575 |
{ |
| 2576 |
foreach ($terms as $term) |
| 2577 |
{ |
| 2578 |
$existing_terms[$term->term_id] = '- - '.$term->name; |
| 2579 |
} |
| 2580 |
} |
| 2581 |
} |
| 2582 |
} |
| 2583 |
|
| 2584 |
$args = array( |
| 2585 |
|
| 2586 |
array( 'title' => __( ( $current_id == '' ? 'Add New Location' : 'Edit Location' ), 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_location_settings' ), |
| 2587 |
|
| 2588 |
array( |
| 2589 |
'title' => __( 'Location', 'propertyhive' ), |
| 2590 |
'id' => 'location_name', |
| 2591 |
'default' => $term_name, |
| 2592 |
'type' => 'text', |
| 2593 |
'desc_tip' => false, |
| 2594 |
), |
| 2595 |
|
| 2596 |
array( |
| 2597 |
'title' => __( 'Parent', 'propertyhive' ), |
| 2598 |
'id' => 'parent_location_id', |
| 2599 |
'default' => $term_parent, |
| 2600 |
'options' => $existing_terms, |
| 2601 |
'type' => 'select', |
| 2602 |
'desc_tip' => false, |
| 2603 |
'desc' => '' |
| 2604 |
), |
| 2605 |
|
| 2606 |
array( |
| 2607 |
'type' => 'hidden', |
| 2608 |
'id' => 'taxonomy', |
| 2609 |
'default' => $taxonomy |
| 2610 |
), |
| 2611 |
|
| 2612 |
array( 'type' => 'sectionend', 'id' => 'custom_field_location_settings' ) |
| 2613 |
|
| 2614 |
); |
| 2615 |
|
| 2616 |
return apply_filters( 'propertyhive_custom_field_location_settings', $args ); |
| 2617 |
} |
| 2618 |
|
| 2619 |
/** |
| 2620 |
* Show parking add/edit options |
| 2621 |
* |
| 2622 |
* @access public |
| 2623 |
* @return string |
| 2624 |
*/ |
| 2625 |
public function get_custom_fields_parking_setting() |
| 2626 |
{ |
| 2627 |
$current_id = empty( $_REQUEST['id'] ) ? '' : (int)$_REQUEST['id']; |
| 2628 |
|
| 2629 |
$taxonomy = 'parking'; |
| 2630 |
$term_name = ''; |
| 2631 |
if ($current_id != '') |
| 2632 |
{ |
| 2633 |
$term = get_term( $current_id, $taxonomy ); |
| 2634 |
$term_name = $term->name; |
| 2635 |
} |
| 2636 |
|
| 2637 |
$args = array( |
| 2638 |
|
| 2639 |
array( 'title' => __( ( $current_id == '' ? 'Add New Parking Option' : 'Edit Parking' ), 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_parking_settings' ), |
| 2640 |
|
| 2641 |
array( |
| 2642 |
'title' => __( 'Parking', 'propertyhive' ), |
| 2643 |
'id' => 'parking_name', |
| 2644 |
'default' => $term_name, |
| 2645 |
'type' => 'text', |
| 2646 |
'desc_tip' => false, |
| 2647 |
), |
| 2648 |
|
| 2649 |
array( |
| 2650 |
'type' => 'hidden', |
| 2651 |
'id' => 'taxonomy', |
| 2652 |
'default' => $taxonomy |
| 2653 |
), |
| 2654 |
|
| 2655 |
array( 'type' => 'sectionend', 'id' => 'custom_field_parking_settings' ) |
| 2656 |
|
| 2657 |
); |
| 2658 |
|
| 2659 |
return apply_filters( 'propertyhive_custom_field_parking_settings', $args ); |
| 2660 |
} |
| 2661 |
|
| 2662 |
/** |
| 2663 |
* Show outside space add/edit options |
| 2664 |
* |
| 2665 |
* @access public |
| 2666 |
* @return string |
| 2667 |
*/ |
| 2668 |
public function get_custom_fields_outside_space_setting() |
| 2669 |
{ |
| 2670 |
$current_id = empty( $_REQUEST['id'] ) ? '' : (int)$_REQUEST['id']; |
| 2671 |
|
| 2672 |
$taxonomy = 'outside_space'; |
| 2673 |
$term_name = ''; |
| 2674 |
if ($current_id != '') |
| 2675 |
{ |
| 2676 |
$term = get_term( $current_id, $taxonomy ); |
| 2677 |
$term_name = $term->name; |
| 2678 |
} |
| 2679 |
|
| 2680 |
$args = array( |
| 2681 |
|
| 2682 |
array( 'title' => __( ( $current_id == '' ? 'Add New Outside Space' : 'Edit Outside Space' ), 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_outside_space_settings' ), |
| 2683 |
|
| 2684 |
array( |
| 2685 |
'title' => __( 'Outside Space', 'propertyhive' ), |
| 2686 |
'id' => 'outside_space_name', |
| 2687 |
'default' => $term_name, |
| 2688 |
'type' => 'text', |
| 2689 |
'desc_tip' => false, |
| 2690 |
), |
| 2691 |
|
| 2692 |
array( |
| 2693 |
'type' => 'hidden', |
| 2694 |
'id' => 'taxonomy', |
| 2695 |
'default' => $taxonomy |
| 2696 |
), |
| 2697 |
|
| 2698 |
array( 'type' => 'sectionend', 'id' => 'custom_field_outside_space_settings' ) |
| 2699 |
|
| 2700 |
); |
| 2701 |
|
| 2702 |
return apply_filters( 'propertyhive_custom_field_outside_space_settings', $args ); |
| 2703 |
} |
| 2704 |
|
| 2705 |
/** |
| 2706 |
* Show custom field delete options |
| 2707 |
* |
| 2708 |
* @access public |
| 2709 |
* @return string |
| 2710 |
*/ |
| 2711 |
public function get_custom_fields_delete($current_id, $taxonomy, $taxonomy_name) |
| 2712 |
{ |
| 2713 |
global $save_button_text; |
| 2714 |
|
| 2715 |
$save_button_text = __( 'Delete', 'propertyhive' ); |
| 2716 |
|
| 2717 |
//$taxonomy = 'outside_space'; |
| 2718 |
//$taxonomy_name = __( 'Outside Space', 'propertyhive' ); |
| 2719 |
|
| 2720 |
if ( isset($_POST['confirm_removal']) && $_POST['confirm_removal'] == 1 ) |
| 2721 |
{ |
| 2722 |
// A term has just been deleted |
| 2723 |
global $hide_save_button, $show_cancel_button, $cancel_button_href; |
| 2724 |
|
| 2725 |
$hide_save_button = TRUE; |
| 2726 |
$show_cancel_button = TRUE; |
| 2727 |
$cancel_button_href = admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=' . str_replace("_", "-", $taxonomy) ); |
| 2728 |
|
| 2729 |
$args = array(); |
| 2730 |
|
| 2731 |
$args[] = array( 'title' => __( 'Successfully Deleted', 'propertyhive' ) . ' ' . $taxonomy_name, 'type' => 'title', 'desc' => '', 'id' => 'custom_field_' . $taxonomy . '_delete' ); |
| 2732 |
|
| 2733 |
$args[] = array( |
| 2734 |
'title' => __( 'Term Deleted', 'propertyhive' ), |
| 2735 |
'id' => '', |
| 2736 |
'html' => $taxonomy_name . __(' deleted successfully', 'propertyhive' ) . ' <a href="' . admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=' . str_replace("_", "-", $taxonomy) ) . '">' . __( 'Go Back', 'propertyhive' ) . '</a>', |
| 2737 |
'type' => 'html', |
| 2738 |
'desc_tip' => false, |
| 2739 |
); |
| 2740 |
|
| 2741 |
$args[] = array( 'type' => 'sectionend', 'id' => 'custom_field_' . $taxonomy . '_delete' ); |
| 2742 |
} |
| 2743 |
else |
| 2744 |
{ |
| 2745 |
$term_name = ''; |
| 2746 |
if ($current_id == '') |
| 2747 |
{ |
| 2748 |
die("ID not passed"); |
| 2749 |
} |
| 2750 |
else |
| 2751 |
{ |
| 2752 |
$term_ids = explode("-", $current_id); |
| 2753 |
|
| 2754 |
$args = array(); |
| 2755 |
|
| 2756 |
foreach ( $term_ids as $current_id ) |
| 2757 |
{ |
| 2758 |
$term = get_term( $current_id, $taxonomy ); |
| 2759 |
|
| 2760 |
if ( is_null($term) || is_wp_error($term) ) |
| 2761 |
{ |
| 2762 |
die("Invalid term trying to be deleted"); |
| 2763 |
} |
| 2764 |
else |
| 2765 |
{ |
| 2766 |
$term_name = $term->name; |
| 2767 |
|
| 2768 |
$args[] = array( 'title' => __( 'Delete', 'propertyhive' ) . ' ' . $taxonomy_name . ': ' . $term_name, 'type' => 'title', 'desc' => '', 'id' => 'custom_field_' . $taxonomy . '_' . $current_id . '_delete' ); |
| 2769 |
|
| 2770 |
// Get number of properties assigned to this term |
| 2771 |
$query_args = array( |
| 2772 |
'post_type' => 'property', |
| 2773 |
'nopaging' => true, |
| 2774 |
'post_status' => array( 'pending', 'auto-draft', 'draft', 'private', 'publish', 'future', 'trash' ), |
| 2775 |
'tax_query' => array( |
| 2776 |
array( |
| 2777 |
'taxonomy' => $taxonomy, |
| 2778 |
'field' => 'id', |
| 2779 |
'terms' => $current_id, |
| 2780 |
), |
| 2781 |
), |
| 2782 |
); |
| 2783 |
$property_query = new WP_Query( $query_args ); |
| 2784 |
|
| 2785 |
$num_properties = $property_query->found_posts; |
| 2786 |
|
| 2787 |
wp_reset_postdata(); |
| 2788 |
|
| 2789 |
// Get number of applicants assigned to this term |
| 2790 |
$num_applicants = 0; |
| 2791 |
if ( $taxonomy == 'property_type' || $taxonomy == 'commercial_property_type' || $taxonomy == 'location' ) |
| 2792 |
{ |
| 2793 |
$query_args = array( |
| 2794 |
'post_type' => 'contact', |
| 2795 |
'nopaging' => true, |
| 2796 |
'post_status' => array( 'pending', 'auto-draft', 'draft', 'private', 'publish', 'future', 'trash' ), |
| 2797 |
'meta_query' => array( |
| 2798 |
array( |
| 2799 |
'key' => '_contact_types', |
| 2800 |
'value' => 'applicant', |
| 2801 |
'compare' => 'LIKE' |
| 2802 |
), |
| 2803 |
), |
| 2804 |
); |
| 2805 |
$applicant_query = new WP_Query( $query_args ); |
| 2806 |
|
| 2807 |
if ( $applicant_query->have_posts() ) |
| 2808 |
{ |
| 2809 |
while ( $applicant_query->have_posts() ) |
| 2810 |
{ |
| 2811 |
$applicant_query->the_post(); |
| 2812 |
|
| 2813 |
$applicant_has_taxonomy = false; |
| 2814 |
|
| 2815 |
$num_applicant_profiles = get_post_meta( get_the_ID(), '_applicant_profiles', TRUE ); |
| 2816 |
if ( $num_applicant_profiles == '' ) |
| 2817 |
{ |
| 2818 |
$num_applicant_profiles = 0; |
| 2819 |
} |
| 2820 |
|
| 2821 |
if ( $num_applicant_profiles > 0 ) |
| 2822 |
{ |
| 2823 |
for ( $i = 0; $i < $num_applicant_profiles; ++$i ) |
| 2824 |
{ |
| 2825 |
$applicant_profile = get_post_meta( get_the_ID(), '_applicant_profile_' . $i, TRUE ); |
| 2826 |
|
| 2827 |
if ( isset($applicant_profile[$taxonomy.'s']) && is_array($applicant_profile[$taxonomy.'s']) && !empty($applicant_profile[$taxonomy.'s']) ) |
| 2828 |
{ |
| 2829 |
if (in_array($current_id, $applicant_profile[$taxonomy.'s'])) |
| 2830 |
{ |
| 2831 |
$applicant_has_taxonomy = true; |
| 2832 |
} |
| 2833 |
} |
| 2834 |
} |
| 2835 |
} |
| 2836 |
|
| 2837 |
if ( $applicant_has_taxonomy ) |
| 2838 |
{ |
| 2839 |
++$num_applicants; |
| 2840 |
} |
| 2841 |
} |
| 2842 |
} |
| 2843 |
|
| 2844 |
wp_reset_postdata(); |
| 2845 |
} |
| 2846 |
|
| 2847 |
// Get number of key dates assigned to this term |
| 2848 |
$num_key_dates= 0; |
| 2849 |
if ( $taxonomy == 'management_key_date_type' ) |
| 2850 |
{ |
| 2851 |
$query_args = array( |
| 2852 |
'post_type' => 'key_date', |
| 2853 |
'nopaging' => true, |
| 2854 |
'post_status' => array( 'pending', 'auto-draft', 'draft', 'private', 'publish', 'future', 'trash' ), |
| 2855 |
'tax_query' => array( |
| 2856 |
array( |
| 2857 |
'taxonomy' => $taxonomy, |
| 2858 |
'field' => 'id', |
| 2859 |
'terms' => $current_id, |
| 2860 |
), |
| 2861 |
), |
| 2862 |
); |
| 2863 |
$key_date_query = new WP_Query( $query_args ); |
| 2864 |
|
| 2865 |
$num_key_dates = $key_date_query->found_posts; |
| 2866 |
|
| 2867 |
wp_reset_postdata(); |
| 2868 |
} |
| 2869 |
|
| 2870 |
if ($num_properties > 0 || $num_applicants > 0 || $num_key_dates > 0 ) |
| 2871 |
{ |
| 2872 |
$alternative_terms = array(); |
| 2873 |
|
| 2874 |
$alternative_terms['none'] = '-- ' . __( 'Don\'t Reassign', 'propertyhive' ) . ' --'; |
| 2875 |
|
| 2876 |
$term_args = array( |
| 2877 |
'hide_empty' => false, |
| 2878 |
'exclude' => $term_ids, |
| 2879 |
'parent' => 0 |
| 2880 |
); |
| 2881 |
$terms = get_terms( $taxonomy, $term_args ); |
| 2882 |
|
| 2883 |
if ( !empty( $terms ) && !is_wp_error( $terms ) ) |
| 2884 |
{ |
| 2885 |
foreach ($terms as $term) |
| 2886 |
{ |
| 2887 |
$alternative_terms[$term->term_id] = $term->name; |
| 2888 |
|
| 2889 |
$term_args = array( |
| 2890 |
'hide_empty' => false, |
| 2891 |
'exclude' => $term_ids, |
| 2892 |
'parent' => $term->term_id |
| 2893 |
); |
| 2894 |
$subterms = get_terms( $taxonomy, $term_args ); |
| 2895 |
|
| 2896 |
if ( !empty( $subterms ) && !is_wp_error( $subterms ) ) |
| 2897 |
{ |
| 2898 |
foreach ($subterms as $term) |
| 2899 |
{ |
| 2900 |
$alternative_terms[$term->term_id] = '- ' . $term->name; |
| 2901 |
|
| 2902 |
$term_args = array( |
| 2903 |
'hide_empty' => false, |
| 2904 |
'exclude' => $term_ids, |
| 2905 |
'parent' => $term->term_id |
| 2906 |
); |
| 2907 |
$subsubterms = get_terms( $taxonomy, $term_args ); |
| 2908 |
|
| 2909 |
if ( !empty( $subsubterms ) && !is_wp_error( $subsubterms ) ) |
| 2910 |
{ |
| 2911 |
foreach ($subsubterms as $term) |
| 2912 |
{ |
| 2913 |
$alternative_terms[$term->term_id] = '- - ' . $term->name; |
| 2914 |
} |
| 2915 |
} |
| 2916 |
} |
| 2917 |
} |
| 2918 |
} |
| 2919 |
} |
| 2920 |
|
| 2921 |
// There are properties assigned to this term |
| 2922 |
$args[] = array( |
| 2923 |
'title' => __( 'Re-assign to', 'propertyhive' ), |
| 2924 |
'id' => 'reassign_to_' . $current_id, |
| 2925 |
'default' => '', |
| 2926 |
'options' => $alternative_terms, |
| 2927 |
'type' => 'select', |
| 2928 |
'desc_tip' => false, |
| 2929 |
'desc' => __( 'There are properties, applicants or management dates that have this term assigned to them. Which, if any, term should they be reassigned to?' , 'propertyhive' ) |
| 2930 |
); |
| 2931 |
} |
| 2932 |
|
| 2933 |
$args[] = array( 'type' => 'sectionend', 'id' => 'custom_field_' . $taxonomy . '_' . $current_id . '_delete' ); |
| 2934 |
} |
| 2935 |
} |
| 2936 |
|
| 2937 |
$args[] = array( 'title' => __( 'Confirm Removal', 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_confirm_delete' ); |
| 2938 |
|
| 2939 |
$args[] = array( |
| 2940 |
'title' => __( 'Confirm Removal?', 'propertyhive' ), |
| 2941 |
'id' => 'confirm_removal', |
| 2942 |
'type' => 'checkbox', |
| 2943 |
'desc_tip' => false, |
| 2944 |
); |
| 2945 |
|
| 2946 |
$args[] = array( |
| 2947 |
'type' => 'hidden', |
| 2948 |
'id' => 'taxonomy', |
| 2949 |
'default' => $taxonomy |
| 2950 |
); |
| 2951 |
|
| 2952 |
$args[] = array( 'type' => 'sectionend', 'id' => 'custom_field_confirm_delete' ); |
| 2953 |
} |
| 2954 |
} |
| 2955 |
|
| 2956 |
return apply_filters( 'propertyhive_custom_field_' . $taxonomy . '_delete', $args ); |
| 2957 |
} |
| 2958 |
|
| 2959 |
/** |
| 2960 |
* Show price qualifier add/edit options |
| 2961 |
* |
| 2962 |
* @access public |
| 2963 |
* @return string |
| 2964 |
*/ |
| 2965 |
public function get_custom_fields_price_qualifier_setting() |
| 2966 |
{ |
| 2967 |
$current_id = empty( $_REQUEST['id'] ) ? '' : sanitize_title( $_REQUEST['id'] ); |
| 2968 |
|
| 2969 |
$taxonomy = 'price_qualifier'; |
| 2970 |
$term_name = ''; |
| 2971 |
if ($current_id != '') |
| 2972 |
{ |
| 2973 |
$term = get_term( $current_id, $taxonomy ); |
| 2974 |
$term_name = $term->name; |
| 2975 |
} |
| 2976 |
|
| 2977 |
$args = array( |
| 2978 |
|
| 2979 |
array( 'title' => __( ( $current_id == '' ? 'Add New Price Qualifier' : 'Edit Price Qualifier' ), 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_price_qualifier_settings' ), |
| 2980 |
|
| 2981 |
array( |
| 2982 |
'title' => __( 'Price Qualifier', 'propertyhive' ), |
| 2983 |
'id' => 'price_qualifier_name', |
| 2984 |
'default' => $term_name, |
| 2985 |
'type' => 'text', |
| 2986 |
'desc_tip' => false, |
| 2987 |
), |
| 2988 |
|
| 2989 |
array( |
| 2990 |
'type' => 'hidden', |
| 2991 |
'id' => 'taxonomy', |
| 2992 |
'default' => $taxonomy |
| 2993 |
), |
| 2994 |
|
| 2995 |
array( 'type' => 'sectionend', 'id' => 'custom_field_price_qualifier_settings' ) |
| 2996 |
|
| 2997 |
); |
| 2998 |
|
| 2999 |
return apply_filters( 'propertyhive_custom_field_price_qualifier_settings', $args ); |
| 3000 |
} |
| 3001 |
|
| 3002 |
/** |
| 3003 |
* Show sale by add/edit options |
| 3004 |
* |
| 3005 |
* @access public |
| 3006 |
* @return string |
| 3007 |
*/ |
| 3008 |
public function get_custom_fields_sale_by_setting() |
| 3009 |
{ |
| 3010 |
$current_id = empty( $_REQUEST['id'] ) ? '' : sanitize_title( $_REQUEST['id'] ); |
| 3011 |
|
| 3012 |
$taxonomy = 'sale_by'; |
| 3013 |
$term_name = ''; |
| 3014 |
if ($current_id != '') |
| 3015 |
{ |
| 3016 |
$term = get_term( $current_id, $taxonomy ); |
| 3017 |
$term_name = $term->name; |
| 3018 |
} |
| 3019 |
|
| 3020 |
$args = array( |
| 3021 |
|
| 3022 |
array( 'title' => __( ( $current_id == '' ? 'Add New Sale By' : 'Edit Sale By' ), 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_sale_by_settings' ), |
| 3023 |
|
| 3024 |
array( |
| 3025 |
'title' => __( 'Sale By', 'propertyhive' ), |
| 3026 |
'id' => 'sale_by_name', |
| 3027 |
'default' => $term_name, |
| 3028 |
'type' => 'text', |
| 3029 |
'desc_tip' => false, |
| 3030 |
), |
| 3031 |
|
| 3032 |
array( |
| 3033 |
'type' => 'hidden', |
| 3034 |
'id' => 'taxonomy', |
| 3035 |
'default' => $taxonomy |
| 3036 |
), |
| 3037 |
|
| 3038 |
array( 'type' => 'sectionend', 'id' => 'custom_field_sale_by_settings' ) |
| 3039 |
|
| 3040 |
); |
| 3041 |
|
| 3042 |
return apply_filters( 'propertyhive_custom_field_sale_by_settings', $args ); |
| 3043 |
} |
| 3044 |
|
| 3045 |
/** |
| 3046 |
* Show tenure add/edit options |
| 3047 |
* |
| 3048 |
* @access public |
| 3049 |
* @return string |
| 3050 |
*/ |
| 3051 |
public function get_custom_fields_tenure_setting() |
| 3052 |
{ |
| 3053 |
$current_id = empty( $_REQUEST['id'] ) ? '' : sanitize_title( $_REQUEST['id'] ); |
| 3054 |
|
| 3055 |
$taxonomy = 'tenure'; |
| 3056 |
$term_name = ''; |
| 3057 |
if ($current_id != '') |
| 3058 |
{ |
| 3059 |
$term = get_term( $current_id, $taxonomy ); |
| 3060 |
$term_name = $term->name; |
| 3061 |
} |
| 3062 |
|
| 3063 |
$args = array( |
| 3064 |
|
| 3065 |
array( 'title' => __( ( $current_id == '' ? 'Add New Tenure' : 'Edit Tenure' ), 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_tenure_settings' ), |
| 3066 |
|
| 3067 |
array( |
| 3068 |
'title' => __( 'Tenure', 'propertyhive' ), |
| 3069 |
'id' => 'tenure_name', |
| 3070 |
'default' => $term_name, |
| 3071 |
'type' => 'text', |
| 3072 |
'desc_tip' => false, |
| 3073 |
), |
| 3074 |
|
| 3075 |
array( |
| 3076 |
'type' => 'hidden', |
| 3077 |
'id' => 'taxonomy', |
| 3078 |
'default' => $taxonomy |
| 3079 |
), |
| 3080 |
|
| 3081 |
array( 'type' => 'sectionend', 'id' => 'custom_field_tenure_settings' ) |
| 3082 |
|
| 3083 |
); |
| 3084 |
|
| 3085 |
return apply_filters( 'propertyhive_custom_field_tenure_settings', $args ); |
| 3086 |
} |
| 3087 |
|
| 3088 |
/** |
| 3089 |
* Show commercial tenure add/edit options |
| 3090 |
* |
| 3091 |
* @access public |
| 3092 |
* @return string |
| 3093 |
*/ |
| 3094 |
public function get_custom_fields_commercial_tenure_setting() |
| 3095 |
{ |
| 3096 |
$current_id = empty( $_REQUEST['id'] ) ? '' : sanitize_title( $_REQUEST['id'] ); |
| 3097 |
|
| 3098 |
$taxonomy = 'commercial_tenure'; |
| 3099 |
$term_name = ''; |
| 3100 |
if ($current_id != '') |
| 3101 |
{ |
| 3102 |
$term = get_term( $current_id, $taxonomy ); |
| 3103 |
$term_name = $term->name; |
| 3104 |
} |
| 3105 |
|
| 3106 |
$args = array( |
| 3107 |
|
| 3108 |
array( 'title' => __( ( $current_id == '' ? 'Add New Tenure' : 'Edit Tenure' ), 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_commercial_tenure_settings' ), |
| 3109 |
|
| 3110 |
array( |
| 3111 |
'title' => __( 'Tenure', 'propertyhive' ), |
| 3112 |
'id' => 'commercial_tenure_name', |
| 3113 |
'default' => $term_name, |
| 3114 |
'type' => 'text', |
| 3115 |
'desc_tip' => false, |
| 3116 |
), |
| 3117 |
|
| 3118 |
array( |
| 3119 |
'type' => 'hidden', |
| 3120 |
'id' => 'taxonomy', |
| 3121 |
'default' => $taxonomy |
| 3122 |
), |
| 3123 |
|
| 3124 |
array( 'type' => 'sectionend', 'id' => 'custom_field_commercial_tenure_settings' ) |
| 3125 |
|
| 3126 |
); |
| 3127 |
|
| 3128 |
return apply_filters( 'propertyhive_custom_field_commercial_tenure_settings', $args ); |
| 3129 |
} |
| 3130 |
|
| 3131 |
/** |
| 3132 |
* Show furnished add/edit options |
| 3133 |
* |
| 3134 |
* @access public |
| 3135 |
* @return string |
| 3136 |
*/ |
| 3137 |
public function get_custom_fields_furnished_setting() |
| 3138 |
{ |
| 3139 |
$current_id = empty( $_REQUEST['id'] ) ? '' : sanitize_title( $_REQUEST['id'] ); |
| 3140 |
|
| 3141 |
$taxonomy = 'furnished'; |
| 3142 |
$term_name = ''; |
| 3143 |
if ($current_id != '') |
| 3144 |
{ |
| 3145 |
$term = get_term( $current_id, $taxonomy ); |
| 3146 |
$term_name = $term->name; |
| 3147 |
} |
| 3148 |
|
| 3149 |
$args = array( |
| 3150 |
|
| 3151 |
array( 'title' => __( ( $current_id == '' ? 'Add New Furnished' : 'Edit Furnished' ), 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_furnished_settings' ), |
| 3152 |
|
| 3153 |
array( |
| 3154 |
'title' => __( 'Furnished', 'propertyhive' ), |
| 3155 |
'id' => 'furnished_name', |
| 3156 |
'default' => $term_name, |
| 3157 |
'type' => 'text', |
| 3158 |
'desc_tip' => false, |
| 3159 |
), |
| 3160 |
|
| 3161 |
array( |
| 3162 |
'type' => 'hidden', |
| 3163 |
'id' => 'taxonomy', |
| 3164 |
'default' => $taxonomy |
| 3165 |
), |
| 3166 |
|
| 3167 |
array( 'type' => 'sectionend', 'id' => 'custom_field_furnished_settings' ) |
| 3168 |
|
| 3169 |
); |
| 3170 |
|
| 3171 |
return apply_filters( 'propertyhive_custom_field_furnished_settings', $args ); |
| 3172 |
} |
| 3173 |
|
| 3174 |
/** |
| 3175 |
* Show key date add/edit options |
| 3176 |
* |
| 3177 |
* @return string |
| 3178 |
*/ |
| 3179 |
public function get_custom_fields_management_key_date_type_setting() |
| 3180 |
{ |
| 3181 |
$current_id = empty( $_REQUEST['id'] ) ? '' : sanitize_title( $_REQUEST['id'] ); |
| 3182 |
|
| 3183 |
$taxonomy = 'management_key_date_type'; |
| 3184 |
$term_name = ''; |
| 3185 |
if ($current_id != '') |
| 3186 |
{ |
| 3187 |
$term = get_term( $current_id, $taxonomy ); |
| 3188 |
$term_name = $term->name; |
| 3189 |
} |
| 3190 |
|
| 3191 |
$recurrence = get_option( 'propertyhive_key_date_type', array() ); |
| 3192 |
if ( ! is_array($recurrence) ) |
| 3193 |
{ |
| 3194 |
$recurrence = array(); |
| 3195 |
} |
| 3196 |
$recurrence_rule = isset($recurrence[$current_id]) ? $recurrence[$current_id]['recurrence_rule'] : ''; |
| 3197 |
$recurrence_type = isset($recurrence[$current_id]) ? $recurrence[$current_id]['recurrence_type'] : ''; |
| 3198 |
|
| 3199 |
$recurrence = array( |
| 3200 |
'FREQ' => 'ONCE', |
| 3201 |
'INTERVAL' => '1', |
| 3202 |
); |
| 3203 |
|
| 3204 |
if ( !empty($recurrence_rule) ) |
| 3205 |
{ |
| 3206 |
foreach (explode(';', $recurrence_rule) as $key_value_pair){ |
| 3207 |
list($key, $value) = explode('=', $key_value_pair); |
| 3208 |
$recurrence[$key] = $value; |
| 3209 |
} |
| 3210 |
} |
| 3211 |
|
| 3212 |
$interval_disabled = $recurrence['FREQ'] == 'ONCE' ? array('disabled' => 'disabled') : array(); |
| 3213 |
|
| 3214 |
$args = array( |
| 3215 |
|
| 3216 |
array( 'title' => __( ( $current_id == '' ? 'Add New Management Date Type' : 'Edit Management Date Type' ), 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_management_key_date_type_settings' ), |
| 3217 |
|
| 3218 |
array( |
| 3219 |
'title' => __( 'Description', 'propertyhive' ), |
| 3220 |
'id' => 'management_key_date_type_name', |
| 3221 |
'default' => $term_name, |
| 3222 |
'type' => 'text', |
| 3223 |
'desc_tip' => false, |
| 3224 |
), |
| 3225 |
|
| 3226 |
array( |
| 3227 |
'title' => __( 'Type', 'propertyhive' ), |
| 3228 |
'id' => 'management_key_date_type_recurrence_type', |
| 3229 |
'default' => $recurrence_type, |
| 3230 |
'type' => 'select', |
| 3231 |
'desc_tip' => false, |
| 3232 |
'options' => array( |
| 3233 |
'tenancy_management' => __( 'Tenancy Management', 'propertyhive' ), |
| 3234 |
'property_management' => __( 'Property Management', 'propertyhive' ), |
| 3235 |
), |
| 3236 |
), |
| 3237 |
|
| 3238 |
array( |
| 3239 |
'title' => __( 'Frequency', 'propertyhive' ), |
| 3240 |
'id' => 'management_key_date_type_recurrence_freq', |
| 3241 |
'default' => $recurrence['FREQ'], |
| 3242 |
'type' => 'select', |
| 3243 |
'desc_tip' => false, |
| 3244 |
'options' => array( |
| 3245 |
'ONCE' => __( 'Once', 'propertyhive' ), |
| 3246 |
'DAILY' => __( 'Daily', 'propertyhive' ), |
| 3247 |
'WEEKLY' => __( 'Weekly', 'propertyhive' ), |
| 3248 |
'MONTHLY' => __( 'Monthly', 'propertyhive' ), |
| 3249 |
'YEARLY' => __( 'Yearly', 'propertyhive' ), |
| 3250 |
), |
| 3251 |
'custom_attributes' => array('onchange' => " |
| 3252 |
jQuery('#management_key_date_type_recurrence_interval').prop( 'disabled', this.value == 'ONCE'); |
| 3253 |
"), |
| 3254 |
), |
| 3255 |
|
| 3256 |
array( |
| 3257 |
'title' => __( 'Interval', 'propertyhive' ), |
| 3258 |
'id' => 'management_key_date_type_recurrence_interval', |
| 3259 |
'default' => $recurrence['INTERVAL'], |
| 3260 |
'type' => 'number', |
| 3261 |
'custom_attributes' => array_merge( array( 'min' => '1', 'required' => 'true'), $interval_disabled ), |
| 3262 |
'desc' => '<p>When setting a key date to Complete, these settings are used to calculate the date the next one should occur.<br>For example, if a key date should happen every 3 months, set Frequency to "Monthly" and Interval to "3".</p>', |
| 3263 |
), |
| 3264 |
|
| 3265 |
array( |
| 3266 |
'type' => 'hidden', |
| 3267 |
'id' => 'taxonomy', |
| 3268 |
'default' => $taxonomy |
| 3269 |
), |
| 3270 |
|
| 3271 |
array( 'type' => 'sectionend', 'id' => 'custom_field_management_key_date_type_settings' ) |
| 3272 |
|
| 3273 |
); |
| 3274 |
|
| 3275 |
return apply_filters( 'propertyhive_custom_field_management_key_date_type_setting', $args ); |
| 3276 |
} |
| 3277 |
|
| 3278 |
/** |
| 3279 |
* Show marketing flag add/edit options |
| 3280 |
* |
| 3281 |
* @access public |
| 3282 |
* @return string |
| 3283 |
*/ |
| 3284 |
public function get_custom_fields_marketing_flag_setting() |
| 3285 |
{ |
| 3286 |
$current_id = empty( $_REQUEST['id'] ) ? '' : sanitize_title( $_REQUEST['id'] ); |
| 3287 |
|
| 3288 |
$taxonomy = 'marketing_flag'; |
| 3289 |
$term_name = ''; |
| 3290 |
if ($current_id != '') |
| 3291 |
{ |
| 3292 |
$term = get_term( $current_id, $taxonomy ); |
| 3293 |
$term_name = $term->name; |
| 3294 |
} |
| 3295 |
|
| 3296 |
$args = array( |
| 3297 |
|
| 3298 |
array( 'title' => __( ( $current_id == '' ? 'Add New Marketing Flag' : 'Edit Marketing Flag' ), 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_marketing_flag_settings' ), |
| 3299 |
|
| 3300 |
array( |
| 3301 |
'title' => __( 'Marketing Flag', 'propertyhive' ), |
| 3302 |
'id' => 'marketing_flag_name', |
| 3303 |
'default' => $term_name, |
| 3304 |
'type' => 'text', |
| 3305 |
'desc_tip' => false, |
| 3306 |
), |
| 3307 |
|
| 3308 |
array( |
| 3309 |
'type' => 'hidden', |
| 3310 |
'id' => 'taxonomy', |
| 3311 |
'default' => $taxonomy |
| 3312 |
), |
| 3313 |
|
| 3314 |
array( 'type' => 'sectionend', 'id' => 'custom_field_marketing_flag_settings' ) |
| 3315 |
|
| 3316 |
); |
| 3317 |
|
| 3318 |
return apply_filters( 'propertyhive_custom_field_marketing_flag_settings', $args ); |
| 3319 |
} |
| 3320 |
|
| 3321 |
/** |
| 3322 |
* Show property feature add/edit options |
| 3323 |
* |
| 3324 |
* @access public |
| 3325 |
* @return string |
| 3326 |
*/ |
| 3327 |
public function get_custom_fields_property_feature_setting() |
| 3328 |
{ |
| 3329 |
$current_id = empty( $_REQUEST['id'] ) ? '' : sanitize_title( $_REQUEST['id'] ); |
| 3330 |
|
| 3331 |
$taxonomy = 'property_feature'; |
| 3332 |
$term_name = ''; |
| 3333 |
if ($current_id != '') |
| 3334 |
{ |
| 3335 |
$term = get_term( $current_id, $taxonomy ); |
| 3336 |
$term_name = $term->name; |
| 3337 |
} |
| 3338 |
|
| 3339 |
$args = array( |
| 3340 |
|
| 3341 |
array( 'title' => __( ( $current_id == '' ? 'Add New Property Feature' : 'Edit Property Feature' ), 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_property_feature_settings' ), |
| 3342 |
|
| 3343 |
array( |
| 3344 |
'title' => __( 'Property Feature', 'propertyhive' ), |
| 3345 |
'id' => 'property_feature_name', |
| 3346 |
'default' => $term_name, |
| 3347 |
'type' => 'text', |
| 3348 |
'desc_tip' => false, |
| 3349 |
), |
| 3350 |
|
| 3351 |
array( |
| 3352 |
'type' => 'hidden', |
| 3353 |
'id' => 'taxonomy', |
| 3354 |
'default' => $taxonomy |
| 3355 |
), |
| 3356 |
|
| 3357 |
array( 'type' => 'sectionend', 'id' => 'custom_field_property_feature_settings' ) |
| 3358 |
|
| 3359 |
); |
| 3360 |
|
| 3361 |
return apply_filters( 'propertyhive_custom_field_property_feature_settings', $args ); |
| 3362 |
} |
| 3363 |
|
| 3364 |
/** |
| 3365 |
* Save settings |
| 3366 |
*/ |
| 3367 |
public function save() { |
| 3368 |
global $current_section, $post; |
| 3369 |
|
| 3370 |
if ( $current_section != '' ) |
| 3371 |
{ |
| 3372 |
switch ($current_section) |
| 3373 |
{ |
| 3374 |
case "addadditionalfield": |
| 3375 |
case "editadditionalfield": |
| 3376 |
{ |
| 3377 |
$current_settings = get_option( 'propertyhive_template_assistant', array() ); |
| 3378 |
|
| 3379 |
$current_id = ( !isset( $_REQUEST['id'] ) ) ? '' : sanitize_title( $_REQUEST['id'] ); |
| 3380 |
|
| 3381 |
$existing_custom_fields = ( (isset($current_settings['custom_fields'])) ? $current_settings['custom_fields'] : array() ); |
| 3382 |
|
| 3383 |
if ( $current_section == 'editadditionalfield' && $current_id != 'default' && !isset($existing_custom_fields[$current_id]) ) |
| 3384 |
{ |
| 3385 |
die("Trying to edit a non-existant custom field. Please go back and try again"); |
| 3386 |
} |
| 3387 |
|
| 3388 |
$field_name = trim( ( ( isset($_POST['field_name']) ) ? sanitize_title( $_POST['field_name'] ) : '' ) ); |
| 3389 |
|
| 3390 |
if ( $field_name == '' ) |
| 3391 |
{ |
| 3392 |
$field_name = str_replace("-", "_", sanitize_title( $_POST['field_label'] ) ); |
| 3393 |
} |
| 3394 |
|
| 3395 |
$field_name = '_' . ltrim( $field_name, '_' ); |
| 3396 |
|
| 3397 |
if ( $current_section == 'addadditionalfield' ) |
| 3398 |
{ |
| 3399 |
$existing_custom_fields[] = array( |
| 3400 |
'field_label' => sanitize_text_field(wp_unslash($_POST['field_label'])), |
| 3401 |
'field_name' => $field_name, |
| 3402 |
'field_type' => ( ( isset($_POST['field_type']) && $_POST['field_type'] != '' ) ? sanitize_text_field($_POST['field_type']) : 'text' ), |
| 3403 |
'dropdown_options' => ( ( isset($_POST['field_type']) && ( $_POST['field_type'] == 'select' || $_POST['field_type'] == 'multiselect' ) && isset($_POST['dropdown_options']) ) ? $_POST['dropdown_options'] : '' ), |
| 3404 |
'meta_box' => sanitize_text_field($_POST['meta_box']), |
| 3405 |
'display_on_website' => ( ( isset($_POST['display_on_website']) ) ? sanitize_text_field($_POST['display_on_website']) : '' ), |
| 3406 |
'display_on_applicant_requirements' => ( ( isset($_POST['display_on_applicant_requirements']) ) ? sanitize_text_field($_POST['display_on_applicant_requirements']) : '' ), |
| 3407 |
'exact_match' => ( ( isset($_POST['exact_match']) ) ? sanitize_text_field($_POST['exact_match']) : '' ), |
| 3408 |
'display_on_user_details' => ( ( isset($_POST['display_on_user_details']) ) ? sanitize_text_field($_POST['display_on_user_details']) : '' ), |
| 3409 |
'admin_list' => ( ( isset($_POST['admin_list']) ) ? sanitize_text_field($_POST['admin_list']) : '' ), |
| 3410 |
'admin_list_sortable' => ( ( isset($_POST['admin_list_sortable']) ) ? sanitize_text_field($_POST['admin_list_sortable']) : '' ), |
| 3411 |
); |
| 3412 |
} |
| 3413 |
else |
| 3414 |
{ |
| 3415 |
$existing_custom_fields[$current_id] = array( |
| 3416 |
'field_label' => sanitize_text_field(wp_unslash($_POST['field_label'])), |
| 3417 |
'field_name' => $field_name, |
| 3418 |
'field_type' => ( ( isset($_POST['field_type']) && $_POST['field_type'] != '' ) ? sanitize_text_field($_POST['field_type']) : 'text' ), |
| 3419 |
'dropdown_options' => ( ( isset($_POST['field_type']) && ( $_POST['field_type'] == 'select' || $_POST['field_type'] == 'multiselect' ) && isset($_POST['dropdown_options']) ) ? $_POST['dropdown_options'] : '' ), |
| 3420 |
'meta_box' => sanitize_text_field($_POST['meta_box']), |
| 3421 |
'display_on_website' => ( ( isset($_POST['display_on_website']) ) ? sanitize_text_field($_POST['display_on_website']) : '' ), |
| 3422 |
'display_on_applicant_requirements' => ( ( isset($_POST['display_on_applicant_requirements']) ) ? sanitize_text_field($_POST['display_on_applicant_requirements']) : '' ), |
| 3423 |
'exact_match' => ( ( isset($_POST['exact_match']) ) ? sanitize_text_field($_POST['exact_match']) : '' ), |
| 3424 |
'display_on_user_details' => ( ( isset($_POST['display_on_user_details']) ) ? sanitize_text_field($_POST['display_on_user_details']) : '' ), |
| 3425 |
'admin_list' => ( ( isset($_POST['admin_list']) ) ? sanitize_text_field($_POST['admin_list']) : '' ), |
| 3426 |
'admin_list_sortable' => ( ( isset($_POST['admin_list_sortable']) ) ? sanitize_text_field($_POST['admin_list_sortable']) : '' ), |
| 3427 |
); |
| 3428 |
} |
| 3429 |
|
| 3430 |
$current_settings['custom_fields'] = $existing_custom_fields; |
| 3431 |
|
| 3432 |
// see if this custom field in used in search forms and amend the type accordingly |
| 3433 |
if ( $current_section != 'addadditionalfield' ) |
| 3434 |
{ |
| 3435 |
if ( isset($current_settings['search_forms']) && !empty($current_settings['search_forms']) ) |
| 3436 |
{ |
| 3437 |
foreach ( $current_settings['search_forms'] as $search_form_id => $search_form ) |
| 3438 |
{ |
| 3439 |
// Active fields |
| 3440 |
if ( isset($search_form['active_fields']) && !empty($search_form['active_fields']) ) |
| 3441 |
{ |
| 3442 |
foreach ( $search_form['active_fields'] as $field_id => $field_data ) |
| 3443 |
{ |
| 3444 |
if ( $field_name == $field_id ) |
| 3445 |
{ |
| 3446 |
// we found this field. Set type |
| 3447 |
$current_settings['search_forms'][$search_form_id]['active_fields'][$field_id]['type'] = ( ( isset($_POST['field_type']) && $_POST['field_type'] != '' ) ? sanitize_text_field($_POST['field_type']) : 'text' ); |
| 3448 |
} |
| 3449 |
} |
| 3450 |
} |
| 3451 |
|
| 3452 |
// Inactive fields |
| 3453 |
if ( isset($search_form['inactive_fields']) && !empty($search_form['inactive_fields']) ) |
| 3454 |
{ |
| 3455 |
foreach ( $search_form['inactive_fields'] as $field_id => $field_data ) |
| 3456 |
{ |
| 3457 |
if ( $field_name == $field_id ) |
| 3458 |
{ |
| 3459 |
// we found this field. Set type |
| 3460 |
$current_settings['search_forms'][$search_form_id]['inactive_fields'][$field_id]['type'] = ( ( isset($_POST['field_type']) && $_POST['field_type'] != '' ) ? sanitize_text_field($_POST['field_type']) : 'text' ); |
| 3461 |
} |
| 3462 |
} |
| 3463 |
} |
| 3464 |
} |
| 3465 |
} |
| 3466 |
} |
| 3467 |
|
| 3468 |
update_option( 'propertyhive_template_assistant', $current_settings ); |
| 3469 |
|
| 3470 |
break; |
| 3471 |
} |
| 3472 |
default: |
| 3473 |
{ |
| 3474 |
if (isset($_REQUEST['id'])) // we're either adding or editing |
| 3475 |
{ |
| 3476 |
$current_id = empty( $_REQUEST['id'] ) ? '' : sanitize_text_field($_REQUEST['id']); |
| 3477 |
|
| 3478 |
switch ($current_section) |
| 3479 |
{ |
| 3480 |
// With heirarchy |
| 3481 |
case "property-type": |
| 3482 |
case "commercial-property-type": |
| 3483 |
case "location": |
| 3484 |
{ |
| 3485 |
// TODO: Validate (check for blank fields) |
| 3486 |
|
| 3487 |
if ($current_id == '') |
| 3488 |
{ |
| 3489 |
// Adding new term |
| 3490 |
|
| 3491 |
// TODO: Check term doesn't exist already |
| 3492 |
|
| 3493 |
wp_insert_term( |
| 3494 |
ph_clean($_POST[ph_clean($_POST['taxonomy']) . '_name']), // the term |
| 3495 |
ph_clean($_POST['taxonomy']), // the taxonomy |
| 3496 |
array( |
| 3497 |
'parent' => $_POST['parent_' . ph_clean($_POST['taxonomy']) . '_id'] |
| 3498 |
) |
| 3499 |
); |
| 3500 |
|
| 3501 |
// TODO: Check for errors returned from wp_insert_term() |
| 3502 |
} |
| 3503 |
else |
| 3504 |
{ |
| 3505 |
// Editing term |
| 3506 |
wp_update_term($current_id, ph_clean($_POST['taxonomy']), array( |
| 3507 |
'name' => ph_clean($_POST[ph_clean($_POST['taxonomy']).'_name']), |
| 3508 |
'parent' => ph_clean($_POST['parent_' . $_POST['taxonomy'] . '_id']) |
| 3509 |
)); |
| 3510 |
|
| 3511 |
// TODO: Check for errors returned from wp_update_term() |
| 3512 |
} |
| 3513 |
break; |
| 3514 |
} |
| 3515 |
// Without heirarchy |
| 3516 |
case "availability": |
| 3517 |
case "outside-space": |
| 3518 |
case "parking": |
| 3519 |
case "price-qualifier": |
| 3520 |
case "sale-by": |
| 3521 |
case "tenure": |
| 3522 |
case "commercial-tenure": |
| 3523 |
case "furnished": |
| 3524 |
case "management-key-date-type": |
| 3525 |
case "marketing-flag": |
| 3526 |
case "property-feature": |
| 3527 |
{ |
| 3528 |
// TODO: Validate (check for blank fields) |
| 3529 |
|
| 3530 |
if ($current_id == '') |
| 3531 |
{ |
| 3532 |
// Adding new term |
| 3533 |
|
| 3534 |
// TODO: Check term doesn't exist already |
| 3535 |
|
| 3536 |
$term = wp_insert_term( |
| 3537 |
ph_clean($_POST[ph_clean($_POST['taxonomy']) . '_name']), // the term |
| 3538 |
$_POST['taxonomy'] // the taxonomy |
| 3539 |
); |
| 3540 |
|
| 3541 |
// TODO: Check for errors returned from wp_insert_term() |
| 3542 |
|
| 3543 |
if ( ! is_wp_error( $term ) ) |
| 3544 |
{ |
| 3545 |
$current_id = isset( $term['term_id'] ) ? $term['term_id'] : 0; |
| 3546 |
} |
| 3547 |
} |
| 3548 |
else |
| 3549 |
{ |
| 3550 |
// Editing term |
| 3551 |
wp_update_term($current_id, ph_clean($_POST['taxonomy']), array( |
| 3552 |
'name' => ph_clean($_POST[ph_clean($_POST['taxonomy']) . '_name']) |
| 3553 |
)); |
| 3554 |
|
| 3555 |
// TODO: Check for errors returned from wp_update_term() |
| 3556 |
} |
| 3557 |
|
| 3558 |
if ( $current_section == 'availability' ) |
| 3559 |
{ |
| 3560 |
$availability_departments = get_option( 'propertyhive_availability_departments', array() ); |
| 3561 |
if ( !is_array($availability_departments) ) { $availability_departments = array(); } |
| 3562 |
|
| 3563 |
$departments = ph_get_departments(); |
| 3564 |
|
| 3565 |
$availability_departments[$current_id] = array(); |
| 3566 |
foreach ( $departments as $key => $value ) |
| 3567 |
{ |
| 3568 |
if ( isset($_POST['department'][$key]) && $_POST['department'][$key] == '1' ) |
| 3569 |
{ |
| 3570 |
$availability_departments[$current_id][] = $key; |
| 3571 |
} |
| 3572 |
} |
| 3573 |
|
| 3574 |
update_option( 'propertyhive_availability_departments', $availability_departments ); |
| 3575 |
} |
| 3576 |
|
| 3577 |
if ( $current_section == 'management-key-date-type' ) |
| 3578 |
{ |
| 3579 |
$options = get_option( 'propertyhive_key_date_type', array() ); |
| 3580 |
if ( !is_array($options) ) { $options = array(); } |
| 3581 |
|
| 3582 |
$recurrence = array(); |
| 3583 |
if (isset($_POST['management_key_date_type_recurrence_freq'])) { |
| 3584 |
$recurrence[] = 'FREQ=' . $_POST['management_key_date_type_recurrence_freq']; |
| 3585 |
} |
| 3586 |
if (isset($_POST['management_key_date_type_recurrence_interval'])) { |
| 3587 |
$recurrence[] = 'INTERVAL=' . $_POST['management_key_date_type_recurrence_interval']; |
| 3588 |
} |
| 3589 |
|
| 3590 |
$options[$current_id]['recurrence_rule'] = join(';', $recurrence); |
| 3591 |
$options[$current_id]['recurrence_type'] = $_POST['management_key_date_type_recurrence_type']; |
| 3592 |
update_option( 'propertyhive_key_date_type', $options ); |
| 3593 |
} |
| 3594 |
|
| 3595 |
break; |
| 3596 |
} |
| 3597 |
case "availability-delete": |
| 3598 |
case "property-type-delete": |
| 3599 |
case "commercial-property-type-delete": |
| 3600 |
case "location-delete": |
| 3601 |
case "parking-delete": |
| 3602 |
case "outside-space-delete": |
| 3603 |
case "price-qualifier-delete": |
| 3604 |
case "sale-by-delete": |
| 3605 |
case "tenure-delete": |
| 3606 |
case "commercial-tenure-delete": |
| 3607 |
case "furnished-delete": |
| 3608 |
case "management-key-date-type-delete": |
| 3609 |
case "marketing-flag-delete": |
| 3610 |
case "property-feature-delete": |
| 3611 |
{ |
| 3612 |
if ( isset($_POST['confirm_removal']) && $_POST['confirm_removal'] == '1' ) |
| 3613 |
{ |
| 3614 |
$term_ids = explode("-", $current_id); |
| 3615 |
|
| 3616 |
foreach ( $term_ids as $current_id ) |
| 3617 |
{ |
| 3618 |
// Update properties that have this taxonomy term set |
| 3619 |
$query_args = array( |
| 3620 |
'post_type' => 'property', |
| 3621 |
'nopaging' => true, |
| 3622 |
'post_status' => array( 'pending', 'auto-draft', 'draft', 'private', 'publish', 'future', 'trash' ), |
| 3623 |
'tax_query' => array( |
| 3624 |
array( |
| 3625 |
'taxonomy' => $_POST['taxonomy'], |
| 3626 |
'field' => 'id', |
| 3627 |
'terms' => $current_id, |
| 3628 |
), |
| 3629 |
), |
| 3630 |
); |
| 3631 |
$property_query = new WP_Query( $query_args ); |
| 3632 |
|
| 3633 |
if ( $property_query->have_posts() ) |
| 3634 |
{ |
| 3635 |
while ( $property_query->have_posts() ) |
| 3636 |
{ |
| 3637 |
$property_query->the_post(); |
| 3638 |
|
| 3639 |
wp_remove_object_terms( $post->ID, $current_id, ph_clean($_POST['taxonomy']) ); |
| 3640 |
|
| 3641 |
// Re-assign to another term |
| 3642 |
if ( isset($_POST['reassign_to_' . $current_id]) && ! empty( $_POST['reassign_to_' . $current_id] ) && $_POST['reassign_to_' . $current_id] != 'none' ) |
| 3643 |
{ |
| 3644 |
$new_id = $_POST['reassign_to_' . $current_id]; |
| 3645 |
|
| 3646 |
wp_set_post_terms( $post->ID, $new_id, ph_clean($_POST['taxonomy']), TRUE ); |
| 3647 |
|
| 3648 |
// TODO: Check for WP_ERROR |
| 3649 |
} |
| 3650 |
} |
| 3651 |
} |
| 3652 |
|
| 3653 |
wp_reset_postdata(); |
| 3654 |
|
| 3655 |
if ( $current_section == 'availability-delete' ) |
| 3656 |
{ |
| 3657 |
// Remove from propertyhive_availability_departments option |
| 3658 |
$availability_departments = get_option( 'propertyhive_availability_departments', array() ); |
| 3659 |
|
| 3660 |
if ( isset($availability_departments[$current_id]) ) |
| 3661 |
{ |
| 3662 |
unset($availability_departments[$current_id]); |
| 3663 |
update_option( 'propertyhive_availability_departments', $availability_departments ); |
| 3664 |
} |
| 3665 |
} |
| 3666 |
|
| 3667 |
if ( $_POST['taxonomy'] == 'property_type' || $_POST['taxonomy'] == 'commercial_property_type' || $_POST['taxonomy'] == 'location' ) |
| 3668 |
{ |
| 3669 |
$query_args = array( |
| 3670 |
'post_type' => 'contact', |
| 3671 |
'nopaging' => true, |
| 3672 |
'post_status' => array( 'pending', 'auto-draft', 'draft', 'private', 'publish', 'future', 'trash' ), |
| 3673 |
'meta_query' => array( |
| 3674 |
array( |
| 3675 |
'key' => '_contact_types', |
| 3676 |
'value' => 'applicant', |
| 3677 |
'compare' => 'LIKE' |
| 3678 |
), |
| 3679 |
), |
| 3680 |
); |
| 3681 |
$applicant_query = new WP_Query( $query_args ); |
| 3682 |
|
| 3683 |
if ( $applicant_query->have_posts() ) |
| 3684 |
{ |
| 3685 |
while ( $applicant_query->have_posts() ) |
| 3686 |
{ |
| 3687 |
$applicant_query->the_post(); |
| 3688 |
|
| 3689 |
$num_applicant_profiles = get_post_meta( get_the_ID(), '_applicant_profiles', TRUE ); |
| 3690 |
if ( $num_applicant_profiles == '' ) |
| 3691 |
{ |
| 3692 |
$num_applicant_profiles = 0; |
| 3693 |
} |
| 3694 |
|
| 3695 |
if ( $num_applicant_profiles > 0 ) |
| 3696 |
{ |
| 3697 |
for ( $i = 0; $i < $num_applicant_profiles; ++$i ) |
| 3698 |
{ |
| 3699 |
$applicant_profile = get_post_meta( get_the_ID(), '_applicant_profile_' . $i, TRUE ); |
| 3700 |
|
| 3701 |
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']) ) |
| 3702 |
{ |
| 3703 |
if (in_array($current_id, $applicant_profile[ph_clean($_POST['taxonomy']).'s'])) |
| 3704 |
{ |
| 3705 |
// This profile has this term set |
| 3706 |
unset($applicant_profile[ph_clean($_POST['taxonomy']).'s'][$current_id]); |
| 3707 |
|
| 3708 |
if ( isset($_POST['reassign_to_' . $current_id]) && ! empty( $_POST['reassign_to_' . $current_id] ) && ph_clean($_POST['reassign_to_' . $current_id]) != 'none' ) |
| 3709 |
{ |
| 3710 |
$applicant_profile[ph_clean($_POST['taxonomy']).'s'][] = $_POST['reassign_to_' . $current_id]; |
| 3711 |
$applicant_profile[ph_clean($_POST['taxonomy']).'s'] = array_unique($applicant_profile[ph_clean($_POST['taxonomy']).'s']); |
| 3712 |
} |
| 3713 |
|
| 3714 |
$applicant_profile[ph_clean($_POST['taxonomy']).'s'] = array_values($applicant_profile[ph_clean($_POST['taxonomy']).'s']); |
| 3715 |
|
| 3716 |
update_post_meta( get_the_ID(), '_applicant_profile_' . $i, $applicant_profile ); |
| 3717 |
} |
| 3718 |
} |
| 3719 |
} |
| 3720 |
} |
| 3721 |
} |
| 3722 |
} |
| 3723 |
} |
| 3724 |
|
| 3725 |
wp_reset_postdata(); |
| 3726 |
|
| 3727 |
wp_delete_term( $current_id, ph_clean($_POST['taxonomy']) ); |
| 3728 |
} |
| 3729 |
} |
| 3730 |
|
| 3731 |
break; |
| 3732 |
} |
| 3733 |
default: |
| 3734 |
{ |
| 3735 |
$section_found = apply_filters( 'propertyhive_custom_fields_save_section', false, $current_section, $current_id ); |
| 3736 |
|
| 3737 |
if ( !($section_found) ) |
| 3738 |
{ |
| 3739 |
echo 'UNKNOWN CUSTOM FIELD'; |
| 3740 |
} |
| 3741 |
} |
| 3742 |
} |
| 3743 |
} |
| 3744 |
else |
| 3745 |
{ |
| 3746 |
// Nothing to save. Should always be an id set when editing custom fields. |
| 3747 |
// Even blank ids dictate something is being added |
| 3748 |
} |
| 3749 |
} |
| 3750 |
} |
| 3751 |
} |
| 3752 |
else |
| 3753 |
{ |
| 3754 |
// Nothing to save. Should always be a section when editing custom fields |
| 3755 |
} |
| 3756 |
} |
| 3757 |
} |
| 3758 |
|
| 3759 |
endif; |
| 3760 |
|
| 3761 |
return new PH_Settings_Custom_Fields(); |